Bug 12202

Summary: crappy disk performance after suspend/resume [ata_piix?]
Product: IO/Storage Reporter: Carl Michal (michal)
Component: Serial ATAAssignee: Tejun Heo (tj)
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.28-rc8 Subsystem:
Regression: --- Bisected commit-id:
Attachments: dmesg from boot/suspend/resume
lspci -nnvvxxx before suspend
lspci -nnvvvxxx after suspend
ata_piix-preserve-iocfg
lspci -nnvvvxxx output before suspend
dmesg from resume.
ata_piix-preserve-iocfg-1
dmesg output: boot, suspend, resume
ata_piix-preserve-iocfg-2
dmesg output: boot, suspend, resume
ata_piix-save-iocfg

Description Carl Michal 2008-12-11 17:19:25 UTC
Latest working kernel version: 2.6.24.3 gcc 4.2.3

On a dell mini-9, (has an Intel 82801G ICH7 IDE controller), on initial boot, the disk is in udma5, and has a decent read performance of ~70MB/s.  After a suspend/resume cycle the disk is in udma2 and the read performance is < 30MB/s.

the ubuntu kernel supplied - 2.6.24.3 doesn't have this problem.

Trying to reset to udma5 with hdparm returns:
/dev/sda:
 setting xfermode to 69 (UltraDMA mode5)
SG_IO: bad/missing ATA_16 sense data::  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 HDIO_DRIVE_CMD(setxfermode) failed: Input/output error

The relevant piece of lspci -vvv:
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02) (prog-if 8a [Master SecP PriP])
	Subsystem: Dell Unknown device 02b0
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
	Latency: 0
	Interrupt: pin B routed to IRQ 19
	Region 0: I/O ports at 01f0 [size=8]
	Region 1: I/O ports at 03f4 [size=1]
	Region 2: I/O ports at 0170 [size=8]
	Region 3: I/O ports at 0374 [size=1]
	Region 4: I/O ports at 1810 [size=16]

/proc/scsi/scsi:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: STEC PATA 16GB   Rev: C522
  Type:   Direct-Access                    ANSI  SCSI revision: 05

ver_linux:
Linux michal-mini 2.6.28-rc8 #1 SMP Thu Dec 11 16:36:30 PST 2008 i686 GNU/Linux
 
Gnu C                  4.2.3
Gnu make               3.81
binutils               2.18.0.20080103
util-linux             2.13.1
mount                  2.13.1
module-init-tools      3.3-pre11
e2fsprogs              1.40.8
pcmciautils            014
PPP                    2.4.4
Linux C Library        2.7
Dynamic linker (ldd)   2.7
Procps                 3.2.7
Net-tools              1.60
Console-tools          0.2.3
Sh-utils               6.10
udev                   117
wireless-tools         29
Modules Loaded         michael_mic arc4 ecb r8169 parport_pc ppdev parport dcdbas i915 acpi_cpufreq cpufreq_powersave cpufreq_conservative cpufreq_stats cpufreq_userspace rfkill input_polldev joydev drm uvcvideo compat_ioctl32 videodev v4l1_compat video backlight output jmb38x_ms memstick sdhci_pci intel_agp agpgart snd_hda_intel snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd soundcore snd_page_alloc ieee80211_crypt_tkip ieee80211_crypt iTCO_wdt iTCO_vendor_support serio_raw psmouse fuse isofs zlib_inflate

/proc/ioports:
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-0060 : keyboard
0064-0064 : keyboard
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : 0000:00:1f.1
  0170-0177 : ata_piix
01f0-01f7 : 0000:00:1f.1
  01f0-01f7 : ata_piix
0376-0376 : 0000:00:1f.1
  0376-0376 : ata_piix
03c0-03df : vga+
03f6-03f6 : 0000:00:1f.1
  03f6-03f6 : ata_piix
0680-069f : pnp 00:06
06a0-06af : pnp 00:07
06b0-06ff : pnp 00:07
0800-080f : pnp 00:06
0cf8-0cff : PCI conf1
1000-107f : 0000:00:1f.0
  1000-107f : pnp 00:06
    1000-1003 : ACPI PM1a_EVT_BLK
    1004-1005 : ACPI PM1a_CNT_BLK
    1008-100b : ACPI PM_TMR
    1010-1015 : ACPI CPU throttle
    1020-1020 : ACPI PM2_CNT_BLK
    1028-102f : ACPI GPE0_BLK
    1030-1033 : iTCO_wdt
    1060-107f : iTCO_wdt
1180-11bf : 0000:00:1f.0
  1180-11bf : pnp 00:06
1640-164f : pnp 00:06
1800-1807 : 0000:00:02.0
1810-181f : 0000:00:1f.1
  1810-181f : ata_piix
1820-183f : 0000:00:1d.0
  1820-183f : uhci_hcd
1840-185f : 0000:00:1d.1
  1840-185f : uhci_hcd
1860-187f : 0000:00:1d.2
  1860-187f : uhci_hcd
1880-189f : 0000:00:1d.3
  1880-189f : uhci_hcd
18a0-18bf : 0000:00:1f.3
2000-2fff : PCI Bus 0000:04
  2000-20ff : 0000:04:00.0
    2000-20ff : r8169
fe00-fe7f : pnp 00:06
ff00-ff7f : pnp 00:06

/proc/iomem:
00000000-00001fff : System RAM
00002000-00005fff : reserved
00006000-00006fff : System RAM
00007000-0000ffff : reserved
00010000-000927ff : System RAM
0009f800-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000cf000-000cffff : Adapter ROM
000e0000-000fffff : reserved
  000f0000-000fffff : System ROM
00100000-3f6cffff : System RAM
  00100000-003f4189 : Kernel code
  003f418a-0055df3f : Kernel data
  005bf000-0065b4bf : Kernel bss
3f6d0000-3f6e1fff : ACPI Tables
3f6e2000-3f6e2fff : ACPI Non-volatile Storage
3f6e3000-3fffffff : reserved
50000000-500fffff : PCI Bus 0000:02
  50000000-5000ffff : 0000:02:00.0
50100000-501fffff : PCI Bus 0000:04
50200000-50200fff : Intel Flush Page
d0000000-dfffffff : 0000:00:02.0
e0000000-efffffff : PCI MMCONFIG 0
  e0000000-efffffff : reserved
    e0000000-efffffff : pnp 00:01
f0000000-f007ffff : 0000:00:02.0
f0080000-f00fffff : 0000:00:02.1
f0100000-f01fffff : PCI Bus 0000:02
  f0100000-f01000ff : 0000:02:00.0
    f0100000-f01000ff : mmc0
  f0100400-f01004ff : 0000:02:00.2
  f0100800-f01008ff : 0000:02:00.3
    f0100800-f01008ff : jmb38x_ms
f0200000-f02fffff : PCI Bus 0000:03
  f0200000-f0203fff : 0000:03:00.0
f0300000-f033ffff : 0000:00:02.0
f0540000-f0543fff : 0000:00:1b.0
  f0540000-f0543fff : ICH HD audio
f0544000-f05443ff : 0000:00:1d.7
  f0544000-f05443ff : ehci_hcd
f0600000-f06fffff : PCI Bus 0000:04
  f0600000-f060ffff : 0000:04:00.0
    f0600000-f060ffff : r8169
  f0610000-f0610fff : 0000:04:00.0
    f0610000-f0610fff : r8169
  f0620000-f063ffff : 0000:04:00.0
fec00000-fec0ffff : reserved
  fec00000-fec00fff : IOAPIC 0
fed00000-fed003ff : HPET 0
  fed00000-fed003ff : reserved
    fed00000-fed003ff : pnp 00:04
fed14000-fed19fff : reserved
  fed14000-fed17fff : pnp 00:01
  fed18000-fed18fff : pnp 00:01
  fed19000-fed19fff : pnp 00:01
fed1c000-fed8ffff : reserved
  fed1c000-fed1ffff : pnp 00:01
  fed20000-fed3ffff : pnp 00:01
  fed40000-fed44fff : pnp 00:01
  fed45000-fed8ffff : pnp 00:01
fee00000-fee00fff : Local APIC
  fee00000-fee00fff : reserved
ff000000-ffffffff : reserved
Comment 1 Tejun Heo 2008-12-11 17:32:01 UTC
Please attach (instead of posting inline) the output of dmesg after suspend/resume.  Thanks.b
Comment 2 Carl Michal 2008-12-11 21:17:03 UTC
Created attachment 19259 [details]
dmesg from boot/suspend/resume

The resume starts at 57.17 s

I subsequently added a printk into libata-core.c at the start of cable_is_40wire.  ap->cbl shows up there as ATA_CBL_PATA40 on resume, but as ATA_CBL_PATA80 on a fresh boot.
Comment 3 Tejun Heo 2008-12-13 19:30:11 UTC
Yeah, I had similar report and was testing patch but the bug reporter disappeared before the problem was resolved.  Please don't go away.  :-)

Can you please post the output of "lspci -nnvvvxxx" before and after suspend/resume?
Comment 4 Carl Michal 2008-12-14 14:36:27 UTC
Created attachment 19302 [details]
lspci -nnvvxxx before suspend
Comment 5 Carl Michal 2008-12-14 14:41:59 UTC
Created attachment 19303 [details]
lspci -nnvvvxxx after suspend

as requested.  I'll try not to disappear.

As a workaround, I found that using the kernel parameter:
libata.force=1.00:udma5
does force it back to udma5.  I booted without this option to collect the lspci data.

A printk added at line 630 of ata_piix.c (in ich_pata_cable_detect) shows that the pci config byte is read as decimal 19 on initial boot, but as 1 after resume.
Comment 6 Tejun Heo 2008-12-22 00:00:15 UTC
Created attachment 19418 [details]
ata_piix-preserve-iocfg

Sorry about the delay.  Can you please test the attached patch?  It saves iocfg (the cable detection register) on suspend and restores it on resume.  Please report whether it works or not and the output of "lspci -nnvvvxxx -s 00:1f.1" before and after resume with the patch applied.  Thanks.
Comment 7 Carl Michal 2008-12-22 15:10:30 UTC
sorry, no joy. dmesg still reports: limited to UDMA/33 due to 40-wire cable.

The only differences in the lspci output are at bytes 4A, 54 and 55.

diff lspci.before  lspci.after 
16,17c16,17
< 40: 07 e3 00 40 00 00 00 00 01 00 01 00 00 00 00 00
< 50: 00 00 00 00 12 30 00 00 00 00 00 00 00 00 00 00
---
> 40: 07 e3 00 40 00 00 00 00 01 00 02 00 00 00 00 00
> 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Comment 8 Carl Michal 2008-12-22 15:11:18 UTC
Created attachment 19439 [details]
lspci -nnvvvxxx output before suspend
Comment 9 Tejun Heo 2008-12-22 18:10:43 UTC
Can you please post dmesg after resume?
Comment 10 Carl Michal 2008-12-22 22:25:21 UTC
Created attachment 19445 [details]
dmesg from resume.

Sorry - should have done this earlier.  

The attachment is the dmesg from resume after the first suspend after a clean boot.

Afterwards, I did a hibernate, and the dmesg output from that thaw says:
 XXX restored IOCFG to 0x0
Comment 11 Carl Michal 2008-12-22 22:33:34 UTC
with three suspend/resumes in a row, dmesg shows:
XXX restored IOCFG to 0x3012

XXX restored IOCFG to 0x1000

XXX restored IOCFG to 0x1000
Comment 12 Tejun Heo 2008-12-23 19:31:29 UTC
Created attachment 19465 [details]
ata_piix-preserve-iocfg-1

Hmmm... Something is clearing IOCFG afterwards.  Can you please apply the attached patch and post the resulting log?
Comment 13 Carl Michal 2008-12-23 22:03:12 UTC
Created attachment 19466 [details]
dmesg output: boot, suspend, resume

patched as requested.  dmesg output attached.
Comment 14 Tejun Heo 2008-12-23 22:23:44 UTC
Created attachment 19467 [details]
ata_piix-preserve-iocfg-2

Okay, hopefully the last one.  It seems ata_piix is somehow clearing the wrong bits during resume.  Can you please repeat the test with the attached patch and post the log?  Thanks.
Comment 15 Carl Michal 2008-12-24 07:01:16 UTC
Created attachment 19470 [details]
dmesg output: boot, suspend, resume

somewhere between the two calls to: piix_pata_prereset.
Comment 16 Tejun Heo 2008-12-29 00:03:26 UTC
Created attachment 19518 [details]
ata_piix-save-iocfg

Can you please test the attached patch?
Comment 17 Carl Michal 2008-12-29 11:56:53 UTC
That fixes it.  

I don't understand where the problem comes from in the first place though - since it seems to work in 2.6.24...
Comment 18 Tejun Heo 2009-01-01 19:19:22 UTC
It's due to the ATA-ACPI support.  _STM during resume corrupts iocfg.  The other guy who reported this problem tracked it down.  The patch is posted upstream.  I'll close this one as duplicate.  Thanks and happy new year.

*** This bug has been marked as a duplicate of bug 11879 ***