Bug 8649

Summary: pata_via fails to initialize dvd burner
Product: IO/Storage Reporter: Marcin Kurek (morgoth6)
Component: Serial ATAAssignee: Tejun Heo (htejun)
Status: CLOSED CODE_FIX    
Severity: normal CC: alan, albertcc
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.21 Subsystem:
Regression: --- Bisected commit-id:
Attachments: Log from faulty boot
hda info
hdd info
lspci
Kernel configuration
pio-inquiry-horkage.patch
use-irq-driven-IDENTIFY-and-SETXFERMODE.patch
update-ata_check_atapi_dma.patch
full dmesg from working kernel
lspci -nnvvvxxx as requested
pata_via-ppc-chrp-workaround.patch
Boot with old ata drivers && 2.6.22-rc7
Boot with libata pata drivers && 2.6.22-rc7
Fixup for arch/powerpc/platforms/chrp/pci.c
fixup for arch/powerpc/platforms/chrp/pci.c
Recent version of fixup
Recent version of fixup
dmesg from boot with latest fix
lspci after bootup with latest fix
ppc-pegasos-via-ata-legacy-irq.patch

Description Marcin Kurek 2007-06-18 07:45:21 UTC
Most recent kernel where this bug did not occur: Good question
Distribution: Gentoo
Hardware Environment: Pegasos 2 / PPC G4 1GHz / 1GB Ram
Software Environment: -
Problem Description: Generaly I must say my ATAPI drive fails always with libata pata driver, but some time ago I decide to upgrade my Fedora 6 to recent version and it seems they switched completly to libata and this is a good reason to report this here I guess.

When booting libata enabled kernel it fails with following message:

....
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
ata2.00: cmd a0/01:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x12 data 36 in
         res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata2: soft resetting port
ata2.00: configured for UDMA/66
ata2: EH complete
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
ata2.00: cmd a0/01:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x12 data 36 in
         res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata2: soft resetting port
ata2.00: configured for UDMA/66
ata2: EH complete
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
ata2.00: cmd a0/01:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x12 data 36 in
         res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata2: soft resetting port
ata2.00: configured for UDMA/66
ata2: EH complete
ata2.00: limiting speed to UDMA/44:PIO4
ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2 frozen
ata2.00: cmd a0/01:00:00:00:00/00:00:00:00:00/a0 tag 0 cdb 0x12 data 36 in
         res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata2: soft resetting port
ata2.00: configured for UDMA/44
ata2: EH complete
....

In previous kernel version (.19) it fails when set xfermode with similar message, but after diging up on redhat bugzilla I located a patch to enable ATA_TFLAG_POLLING by default (Attached) and now it looks like that.

Fedora installer complains about missing CD/DVD driver and it makes impossible to install/upgrade it here. I send some e-mails to Alan Cox about this problem when I first try to use pata_via (Around 2.6.16/2.6.17), but without any result.

I attach a full serial log from faulty boot and hdparm/lspci info from my system.

Steps to reproduce: -
Comment 1 Marcin Kurek 2007-06-18 07:46:02 UTC
Created attachment 11776 [details]
Log from faulty boot
Comment 2 Marcin Kurek 2007-06-18 07:46:38 UTC
Created attachment 11777 [details]
hda info
Comment 3 Marcin Kurek 2007-06-18 07:47:03 UTC
Created attachment 11778 [details]
hdd info
Comment 4 Marcin Kurek 2007-06-18 07:47:30 UTC
Created attachment 11779 [details]
lspci
Comment 5 Marcin Kurek 2007-06-18 07:47:59 UTC
Created attachment 11780 [details]
Kernel configuration
Comment 6 Tejun Heo 2007-06-18 09:54:36 UTC
Hmm... This is the third report where INQUIRY fails.  Three different ODD models on three different controllers.  Were you able to burn cd/dvd using cdrecord or wodim with the IDE driver?
Comment 7 Marcin Kurek 2007-06-18 12:26:14 UTC
(In reply to comment #6)

This drive works without any problems with old via ata driver and I never had any problems with it. Also I burned at last one hundred dvd's using k3b without any problems too.

Maybe this would help. Previously I had BenQ BenQ DW-1640 drive with similar problem, it fails with xfermode set when boot libata enabled kernel. I tired it on x86 box but with NForce2 chipset and it works without any problems with libata.
Comment 8 Marcin Kurek 2007-06-18 12:28:30 UTC
Hmmm, but maybe the present problem and set xfermode problem are two diffrent problems as xfer should be fixed with this attached patch. Unfortunatly I can not check current kernel with this old DW-1640 :(
Comment 9 Tejun Heo 2007-06-18 21:49:02 UTC
The SETXFERMODE issue is caused by the via controller.  It raises interrupt too early (before the command is actually complete) and thus causes HSM violation.  Polling execution solves the problem.
Comment 10 Tejun Heo 2007-06-18 21:54:51 UTC
Created attachment 11789 [details]
pio-inquiry-horkage.patch

Does this patch make any difference?
Comment 11 Marcin Kurek 2007-06-19 09:31:51 UTC
Im afraid this patch doesn't make any diffrence here ;( Still same messages when booting. 

Also a small thing take my attention:

ata1: PATA max UDMA/100 cmd 0xfdff1040 ctl 0xfdff104e bmdma 0xfdff1060 irq 14
ata2: PATA max UDMA/100 cmd 0xfdff1050 ctl 0xfdff105e bmdma 0xfdff1068 irq 14

I wonder why both channels use same irq ? With old ata drivers it looks diffrent and ide0 uses irq 14 and ide1 uses irq 15.
Comment 12 Tejun Heo 2007-06-20 00:38:10 UTC
Please post full dmesg.  Hmmm... indeed.  Please also post the result of 'lspci -nnvvvxxx'.  Thanks.
Comment 13 Tejun Heo 2007-06-20 03:02:49 UTC
Created attachment 11813 [details]
use-irq-driven-IDENTIFY-and-SETXFERMODE.patch

Also, please test this one and report the result.
Comment 14 Tejun Heo 2007-06-20 07:54:30 UTC
Created attachment 11823 [details]
update-ata_check_atapi_dma.patch

Okay, scrap that.  Please test this one.  This gotta be it.
Comment 15 Marcin Kurek 2007-06-20 09:39:57 UTC
Created attachment 11825 [details]
full dmesg from working kernel
Comment 16 Marcin Kurek 2007-06-20 09:40:47 UTC
Created attachment 11826 [details]
lspci -nnvvvxxx as requested
Comment 17 Marcin Kurek 2007-06-20 12:49:41 UTC
I compiled kernel with path from #14, but this one doesn't solve my problem too. I can still see same error messages when boot. It detects my HD quite fast and stops when detecting DVD drive for maybe a second or two and prints this timeout error.

I wonder about this irq thing, can this be related ?
Comment 18 Tejun Heo 2007-06-20 21:15:03 UTC
Okay, got it.  It's PPC CHRP, right?  VIA chip on that machine lies about its IRQ usage.  It reports it's in native PCI mode using IRQ 14 for both channels but it actually uses legacy IRQs (14 for primary, 15 for secondary).  I'll prepare a quick fix for pata_via.
Comment 19 Tejun Heo 2007-06-20 21:27:17 UTC
Created attachment 11836 [details]
pata_via-ppc-chrp-workaround.patch

Please test this patch.  Thanks.
Comment 20 Marcin Kurek 2007-06-21 00:48:54 UTC
I assume this patch is for 2.6.22rcX as it not apply cleanly to 2.6.21. I will compile rc5 if required, but this will take some time. Anyway I apply it by hand to 2.6.21 and it seems this fixed this irq problem:

....
loop: loaded (max 8 devices)
ata1: PATA max UDMA/100 cmd 0xfdff01f0 ctl 0xfdff03f6 bmdma 0xfdff1060 irq 14
ata2: PATA max UDMA/100 cmd 0xfdff0170 ctl 0xfdff0376 bmdma 0xfdff1068 irq 15
scsi0 : pata_via
scsi1 : pata_via
PCI: Enabling device 0000:00:05.2 (0000 -> 0002)
ehci_hcd 0000:00:05.2: EHCI Host Controller
....

But as you can see it doesn't detect anything on both channels this way :/
Comment 21 Tejun Heo 2007-07-01 22:17:20 UTC
Sorry about the delay.  -EWASBURIEDINDEBUGGING.

That's weird.  Can you test 2.6.22-rc6 without the patch and report dmesg, both with pata_via and via82cxxx?  Thanks.
Comment 22 Marcin Kurek 2007-07-02 00:49:58 UTC
Of, coz. Tested with rc7 for old ata and pata. BTW This legacy irq fix seems to be a good direction at last for irq problem. Take a look at: http://www.powerdeveloper.org/forums/viewtopic.php?p=8299#8299
Comment 23 Marcin Kurek 2007-07-02 00:50:51 UTC
Created attachment 11916 [details]
Boot with old ata drivers && 2.6.22-rc7
Comment 24 Marcin Kurek 2007-07-02 00:51:30 UTC
Created attachment 11917 [details]
Boot with libata pata drivers && 2.6.22-rc7
Comment 25 Tejun Heo 2007-07-02 03:57:24 UTC
Hmmm... What did I do wrong?  So, no device is detected if you apply the patch from comment 19, right?  Can you turn on ATA_DEBUG in include/linux/libata.h and report the full boot log?  The patch should only affect IRQ.  Dunno why it's affecting device detection like that.

I tried to comment on the powerdeveloper entry but my account hasn't been approved yet.  Can you tell Matt Sealey that this case is a bit special because the controller claims to be in native mode and IO registers are allocated using PCI BARs but only IRQs are in legacy configuration (using both 14/15).  I don't think you can work around this by flipping legacy bit in the PCI header.
Comment 26 Marcin Kurek 2007-07-02 04:26:33 UTC
Subject: Re:  pata_via fails to initialize dvd burner

2007/7/2, bugme-daemon@bugzilla.kernel.org <bugme-daemon@bugzilla.kernel.org>:
> http://bugzilla.kernel.org/show_bug.cgi?id=8649
>
>
>
>
>
> ------- Comment #25 from htejun@gmail.com  2007-07-02 03:57 -------
> Hmmm... What did I do wrong?  So, no device is detected if you apply the
> patch
> from comment 19, right?  Can you turn on ATA_DEBUG in include/linux/libata.h
> and report the full boot log?  The patch should only affect IRQ.  Dunno why
> it's affecting device detection like that.
>
> I tried to comment on the powerdeveloper entry but my account hasn't been
> approved yet.  Can you tell Matt Sealey that this case is a bit special
> because
> the controller claims to be in native mode and IO registers are allocated
> using
> PCI BARs but only IRQs are in legacy configuration (using both 14/15).  I
> don't
> think you can work around this by flipping legacy bit in the PCI header.
>
>
> --
> Configure bugmail: http://bugzilla.kernel.org/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
Comment 27 Albert Lee 2007-07-02 19:34:08 UTC
The strange thing in old IDE dmesg is the chip is detected as native "VP_IDE: 100% native mode on irq 14".

However, later the ports are assigned with legacy (rather than native) irq number:
"ide0 at 0x1040-0x1047,0x104e on irq 14"
"ide1 at 0x1050-0x1057,0x105e on irq 15"

Maybe the VIA native mode bit is incorrect and needs to be ignored?
========================================================
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
VP_IDE: IDE controller at PCI slot 0000:00:0c.1
VP_IDE: chipset revision 6
VP_IDE: VIA vt8231 (rev 10) IDE UDMA100 controller on pci0000:00:0c.1
VP_IDE: 100% native mode on irq 14
    ide0: BM-DMA at 0x1060-0x1067, BIOS settings: hda:pio, hdb:pio
    ide1: BM-DMA at 0x1068-0x106f, BIOS settings: hdc:pio, hdd:pio
hda: WDC WD3200JB-00KFA0, ATA DISK drive
ide0 at 0x1040-0x1047,0x104e on irq 14
hdc: PIONEER DVD-RW DVR-111L, ATAPI CD/DVD-ROM drive
ide1 at 0x1050-0x1057,0x105e on irq 15
hda: max request size: 512KiB
hda: 625142448 sectors (320072 MB) w/8192KiB Cache, CHS=38913/255/63, UDMA(100)
hda: cache flushes supported
 hda: RDSK (512) hda1 (DOS^C)(res 2 spb 1) hda2 (SFS^@)(res 0 spb 1) hda3 (SFS^@)(res 0 spb 2) hda4 (SFS^@)(res 0 spb 1) hda5 (SFS^@)(res 0 spb 2) hda6 (SFS^@)(res 0 spb 1) hda7 (SFS^@)(res 0 spb 2) hda8 (SWP^@)(res 0 spb 1) hda9 (RFS^@)(res 0 spb 1) hda10 (RFS^@)(res 0 spb 1) hda11 (EXT^C)(res 0 spb 1) hda12 (RFS^@)(res 0 spb 1) hda13 (RFS^@)(res 0 spb 1)
hdc: ATAPI 40X DVD-ROM DVD-R-RAM CD-R/RW drive, 2000kB Cache, UDMA(66)
Uniform CD-ROM driver Revision: 3.20
Comment 28 Tejun Heo 2007-07-02 19:59:20 UTC
IDE code has chrp specific workaround similar to the one I tried for libata (and failed :-).  This isn't native nor legacy.  IO regions are in PCI BARs but pdev->irq can't be trusted, so it's native for IO regions and legacy for irq.  Solutions are...

1. Add chrp specific quirk into libata (no, can't be done from PCI quirk)

2. If the IO addresses are fixed, add arch-specific ATA_PRIMARY/SECONDARY_CMD/CTL macros and mark it legacy.  ie. make it proper legacy SFF controller.
Comment 29 Marcin Kurek 2007-07-10 00:21:00 UTC
Matt Sealey propose a fixup on powerdev forum for this problem and I already tested it with final 2.6.22.

It seems both irq's are set to 14, but this is correct now ? Anyway the problem with ATAPI device is still there and it still fails to initialize it ;( Should I apply any patches attached here in final 2.6.22 ?
Comment 30 Marcin Kurek 2007-07-10 00:22:28 UTC
Created attachment 11988 [details]
Fixup for arch/powerpc/platforms/chrp/pci.c

There is a small typo as ')' is missing from if(), but it compiles fine here.
Comment 31 Marcin Kurek 2007-07-10 00:25:50 UTC
Created attachment 11989 [details]
fixup for arch/powerpc/platforms/chrp/pci.c

No typo and url attach this time.
Comment 32 Tejun Heo 2007-07-10 00:29:09 UTC
It needs to be combined with IDE un-quirking.  The fixup looks good other than that.  It's probably the way it should have been done in the first place.  I think Matt will re-submit the patch in proper form after some verification from users.
Comment 33 Marcin Kurek 2007-07-12 09:30:53 UTC
There was some interesting new informations acording to this problem on powerdeveloper forum. Take a look at http://www.powerdeveloper.org/forums/viewtopic.php?t=1302&start=15&postdays=0&postorder=asc&highlight=
Comment 34 Marcin Kurek 2007-07-12 09:33:25 UTC
Created attachment 12014 [details]
Recent version of fixup

Anyway it seems there can be a problem with this kind of fix. Look at comment http://www.powerdeveloper.org/forums/viewtopic.php?p=8450#8450
Comment 35 Marcin Kurek 2007-07-13 05:51:58 UTC
Created attachment 12023 [details]
Recent version of fixup
Comment 36 Marcin Kurek 2007-07-13 05:53:50 UTC
Created attachment 12024 [details]
dmesg from boot with latest fix

It seems with latest fix the timeouts are still there. Also I can not see my DVD drive in system (Al last not as sdX or sgX)
Comment 37 Marcin Kurek 2007-07-13 05:55:01 UTC
Created attachment 12025 [details]
lspci after bootup with latest fix
Comment 38 Marcin Kurek 2007-08-16 10:31:49 UTC
Good news I was able to use libata drivers on my pegasos now. 

After apply a patch from Hejun (simplify PCI legacy SFF host handling) to 2.6.22 I tired atempt from http://bugzilla.kernel.org/attachment.cgi?id=11836&action=view and it seems this does the trick and libata works fine here.

I will attach a lspci && dmegs in a minute.
Comment 39 Olaf Hering 2007-08-17 06:46:02 UTC
Created attachment 12424 [details]
ppc-pegasos-via-ata-legacy-irq.patch

advertise correct IDE mode on Pegasos.
http://ozlabs.org/pipermail/linuxppc-dev/2007-August/041095.html
Comment 40 Tejun Heo 2007-08-17 10:29:54 UTC
Thanks, Olaf.  That should do the trick for libata on kernels > 2.6.22 or 2.6.22 + simplify-PCI-legacy-SFF-host-handling.  I think IDE should be fine too.  If somebody can verify the patch works, I'll forward it upstream.  Thanks.
Comment 41 Marcin Kurek 2007-08-23 00:38:58 UTC
I use it on 2.6.22 without any problems. Works fine.
Comment 42 Tejun Heo 2007-08-28 20:01:31 UTC
Marcin, just to be sure, 2.6.22 + the patches work fine on chrp with ide and libata drivers, right?
Comment 43 Marcin Kurek 2007-08-28 23:57:19 UTC
Tired only on libata and use it on my gentoo and fresh installed fedora 7 currently without any problems. It is included in SuSe and Fedora 7 kernels already.

As I can see SuSe and Fedora leave the old ata pegasos irq hack in kernel. 
Comment 44 Tejun Heo 2007-09-02 19:32:06 UTC
Please try ide on 2.6.22 + the patches.  It might affect IDE.  It should work but I wanna be sure before sending the patch upstream.  Thanks.