All of lore.kernel.org
 help / color / mirror / Atom feed
* PATA DMA problem leading to kernel panic on reading movie DVDs
@ 2009-05-17  9:12 Martin Lottermoser
  2009-05-17 10:42 ` Borislav Petkov
  2009-05-17 17:59 ` Robert Hancock
  0 siblings, 2 replies; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-17  9:12 UTC (permalink / raw)
  To: linux-kernel

Hello,

newer versions of the Linux kernel overestimate my DVD drive's
DMA capabilities, leading either to DMA being disabled or a kernel
panic.

My setup is:

  Motherboard: ASUS P4C800-E Deluxe
    South bridge: ICH5R
      IDE Interface Controller (PATA): Intel 82801EB/ER (PCI: 8086:24db)
  DVD drive: Samsung SH-S202N, attached as hdc.
    There is also an older CD writer (Lite-On LTR-52327S) attached as
    hdd.
  Operating system: Debian 5.0.0 with security updates

On upgrading from Debian 4.0 (Linux 2.6.18) to 5.0 (Linux 2.6.26) I
found that trying to play movie DVDs with vlc (VideoLAN media player)
led to DMA being disabled:

  hdc: cdrom_decode_status: status=0x51 { DriveReady SeekComplete Error }
  hdc: cdrom_decode_status: error=0x40 { LastFailedSense=0x04 }
  ide: failed opcode was: unknown
  <4 more identical groups of these messages>
  hdc: DMA disabled
  hdc: ide_intr: huh? expected NULL handler on exit
  hdc: ATAPI reset complete

The resulting configuration is too slow to play movies. I booted the
older kernel and everything was fine.

I then tested various versions of the Linux kernel where I happened to
have the original sources. The most interesting results were:

  2.6.22.9      works, no errors visible in syslog
  2.6.23.14     works, but syslog shows an error (see below)
  2.6.24.3	DMA disabled
  2.6.29.3	Kernel panic: Fatal exception in interrupt (ide_intr)
                on trying to open the DVD with vlc

The error message with 2.6.23.14 was:

  hdc: drive_cmd: status=0x51 { DriveReady SeekComplete Error }
  hdc: drive_cmd: error=0x04 { AbortedCommand }
  ide: failed opcode was: 0xec

This kernel as well as 2.6.22.9 also showed the following on booting:

  hdc: host side 80-wire cable detection failed, limiting max speed to UDMA33

This is correct: the drive is only capable of Ultra DMA mode 2 33.3 MB/s
(see manufacturer's documentation) and is attached with a standard 40-wire
ATA cable (black connectors for master and slave).

This led me to inspect other boot messages. With 2.6.18.3 I found:

  hdc: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache, UDMA(33)

2.6.24.3 showed:

  hdc: UDMA/66 mode selected
  ...
  hdc: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache

In contrast, the hdd drive shows up with "UDMA/33 mode selected" up to
and including 2.6.29.3.

I now use "hdparm -d1 -X udma2 /dev/hdc" with the Debian kernel 2.6.26
and the drive works as desired. However, when querying the drive's
capabilities with "hdparm -I", although the command terminates
successfully and without any error messages (it shows

  DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4

), on inspecting the syslog I find, on each invocation, a similar
error message as above with 2.6.23.14:

  hdc: task_in_intr: status=0x51 { DriveReady SeekComplete Error }
  hdc: task_in_intr: error=0x04 { AbortedCommand }
  ide: failed opcode was: 0xec

Interestingly enough, this happens also when calling "hdparm -I" on hdd.
There are also error messages

  hdc: set_drive_speed_status: status=0x51 { DriveReady SeekComplete Error }
  hdc: set_drive_speed_status: error=0x04 { AbortedCommand }
  ide: failed opcode was: unknown

from the boot phase.

Therefore there is still something wrong. Any suggestions on what that
is and how to fix it? (Answers preferably through "Cc:", but I'll also
try and follow the thread through list archives.)

Martin Lottermoser
--
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17  9:12 PATA DMA problem leading to kernel panic on reading movie DVDs Martin Lottermoser
@ 2009-05-17 10:42 ` Borislav Petkov
  2009-05-17 11:15   ` Martin Lottermoser
  2009-05-17 17:59 ` Robert Hancock
  1 sibling, 1 reply; 22+ messages in thread
From: Borislav Petkov @ 2009-05-17 10:42 UTC (permalink / raw)
  To: Martin Lottermoser; +Cc: linux-kernel

Hi,

On Sun, May 17, 2009 at 11:12:24AM +0200, Martin Lottermoser wrote:
> Hello,
> 
> newer versions of the Linux kernel overestimate my DVD drive's
> DMA capabilities, leading either to DMA being disabled or a kernel
> panic.
> 
> My setup is:
> 
>   Motherboard: ASUS P4C800-E Deluxe
>     South bridge: ICH5R
>       IDE Interface Controller (PATA): Intel 82801EB/ER (PCI: 8086:24db)
>   DVD drive: Samsung SH-S202N, attached as hdc.
>     There is also an older CD writer (Lite-On LTR-52327S) attached as
>     hdd.
>   Operating system: Debian 5.0.0 with security updates
> 
> On upgrading from Debian 4.0 (Linux 2.6.18) to 5.0 (Linux 2.6.26) I
> found that trying to play movie DVDs with vlc (VideoLAN media player)
> led to DMA being disabled:
> 
>   hdc: cdrom_decode_status: status=0x51 { DriveReady SeekComplete Error }
>   hdc: cdrom_decode_status: error=0x40 { LastFailedSense=0x04 }
>   ide: failed opcode was: unknown
>   <4 more identical groups of these messages>
>   hdc: DMA disabled
>   hdc: ide_intr: huh? expected NULL handler on exit
>   hdc: ATAPI reset complete
> 
> The resulting configuration is too slow to play movies. I booted the
> older kernel and everything was fine.
> 
> I then tested various versions of the Linux kernel where I happened to
> have the original sources. The most interesting results were:
> 
>   2.6.22.9      works, no errors visible in syslog
>   2.6.23.14     works, but syslog shows an error (see below)
>   2.6.24.3	DMA disabled
>   2.6.29.3	Kernel panic: Fatal exception in interrupt (ide_intr)
>                 on trying to open the DVD with vlc

can you catch that kernel panic on another machine through serial
console/netconsole and send it to me, please?

Thanks.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 10:42 ` Borislav Petkov
@ 2009-05-17 11:15   ` Martin Lottermoser
  2009-05-17 12:14     ` Martin Lottermoser
  0 siblings, 1 reply; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-17 11:15 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel

Hello,

On Sun, May 17, 2009 at 12:42:28PM +0200, Borislav Petkov wrote:
...
> can you catch that kernel panic on another machine through serial
> console/netconsole and send it to me, please?

no, I don't have the necessary cable for that, but I'll provide a
photograph of the screen and put it on my web site. For now, as I see
from my notes, the call trace was:

  Call Trace:
    handle_IRQ_event
    handle_edge_IRQ
    do_IRQ
    __dequeue_entity
    common_interrupt
    default_idle
    cpu_idle
    rest_init

Thanks for the interest,
Martin Lottermoser
-- 
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 11:15   ` Martin Lottermoser
@ 2009-05-17 12:14     ` Martin Lottermoser
  2009-05-17 19:34       ` Borislav Petkov
  0 siblings, 1 reply; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-17 12:14 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel

Hello,

On Sun, May 17, 2009 at 01:15:35PM +0200, Martin Lottermoser wrote:
> no, I don't have the necessary cable for that, but I'll provide a
> photograph of the screen and put it on my web site.

I've done that now. The file is available from this URL:

  http://home.vrweb.de/martin.lottermoser/linux/

The directory contains a file "0-readme.txt" which explains what the
files in the directory are; I've added the kernel configuration and the
syslog.

Regards,
Martin Lottermoser
-- 
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17  9:12 PATA DMA problem leading to kernel panic on reading movie DVDs Martin Lottermoser
  2009-05-17 10:42 ` Borislav Petkov
@ 2009-05-17 17:59 ` Robert Hancock
  2009-05-17 19:35   ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 22+ messages in thread
From: Robert Hancock @ 2009-05-17 17:59 UTC (permalink / raw)
  To: Martin Lottermoser; +Cc: linux-kernel

Martin Lottermoser wrote:
> Hello,
> 
> newer versions of the Linux kernel overestimate my DVD drive's
> DMA capabilities, leading either to DMA being disabled or a kernel
> panic.
> 
> My setup is:
> 
>   Motherboard: ASUS P4C800-E Deluxe
>     South bridge: ICH5R
>       IDE Interface Controller (PATA): Intel 82801EB/ER (PCI: 8086:24db)
>   DVD drive: Samsung SH-S202N, attached as hdc.
>     There is also an older CD writer (Lite-On LTR-52327S) attached as
>     hdd.
>   Operating system: Debian 5.0.0 with security updates
> 
> On upgrading from Debian 4.0 (Linux 2.6.18) to 5.0 (Linux 2.6.26) I
> found that trying to play movie DVDs with vlc (VideoLAN media player)
> led to DMA being disabled:
> 
>   hdc: cdrom_decode_status: status=0x51 { DriveReady SeekComplete Error }
>   hdc: cdrom_decode_status: error=0x40 { LastFailedSense=0x04 }
>   ide: failed opcode was: unknown
>   <4 more identical groups of these messages>
>   hdc: DMA disabled
>   hdc: ide_intr: huh? expected NULL handler on exit
>   hdc: ATAPI reset complete

Looks like kind of a comedy of errors. It failed to indicate what the 
failed command was (though, it seems like the failed opcode is always 
unknown with the IDE drivers), disabled DMA incorrectly, then seemingly 
confused itself.

Seems like the IDE layer grew some regressions at some point. You could 
try a newer (2.6.29) kernel. However, from a user perspective, quite 
likely you'll be happier ditching the IDE drivers and using libata 
instead, it tends to be better tested these days..

> 
> The resulting configuration is too slow to play movies. I booted the
> older kernel and everything was fine.
> 
> I then tested various versions of the Linux kernel where I happened to
> have the original sources. The most interesting results were:
> 
>   2.6.22.9      works, no errors visible in syslog
>   2.6.23.14     works, but syslog shows an error (see below)
>   2.6.24.3	DMA disabled
>   2.6.29.3	Kernel panic: Fatal exception in interrupt (ide_intr)
>                 on trying to open the DVD with vlc
> 
> The error message with 2.6.23.14 was:
> 
>   hdc: drive_cmd: status=0x51 { DriveReady SeekComplete Error }
>   hdc: drive_cmd: error=0x04 { AbortedCommand }
>   ide: failed opcode was: 0xec
> 
> This kernel as well as 2.6.22.9 also showed the following on booting:
> 
>   hdc: host side 80-wire cable detection failed, limiting max speed to UDMA33
> 
> This is correct: the drive is only capable of Ultra DMA mode 2 33.3 MB/s
> (see manufacturer's documentation) and is attached with a standard 40-wire
> ATA cable (black connectors for master and slave).
> 
> This led me to inspect other boot messages. With 2.6.18.3 I found:
> 
>   hdc: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache, UDMA(33)
> 
> 2.6.24.3 showed:
> 
>   hdc: UDMA/66 mode selected
>   ...
>   hdc: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache
> 
> In contrast, the hdd drive shows up with "UDMA/33 mode selected" up to
> and including 2.6.29.3.
> 
> I now use "hdparm -d1 -X udma2 /dev/hdc" with the Debian kernel 2.6.26
> and the drive works as desired. However, when querying the drive's
> capabilities with "hdparm -I", although the command terminates
> successfully and without any error messages (it shows
> 
>   DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4
> 
> ), on inspecting the syslog I find, on each invocation, a similar
> error message as above with 2.6.23.14:
> 
>   hdc: task_in_intr: status=0x51 { DriveReady SeekComplete Error }
>   hdc: task_in_intr: error=0x04 { AbortedCommand }
>   ide: failed opcode was: 0xec
> 
> Interestingly enough, this happens also when calling "hdparm -I" on hdd.
> There are also error messages
> 
>   hdc: set_drive_speed_status: status=0x51 { DriveReady SeekComplete Error }
>   hdc: set_drive_speed_status: error=0x04 { AbortedCommand }
>   ide: failed opcode was: unknown
> 
> from the boot phase.
> 
> Therefore there is still something wrong. Any suggestions on what that
> is and how to fix it? (Answers preferably through "Cc:", but I'll also
> try and follow the thread through list archives.)
> 
> Martin Lottermoser
> --
> Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
> Greifswaldstrasse 28
> 38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
> Germany


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 12:14     ` Martin Lottermoser
@ 2009-05-17 19:34       ` Borislav Petkov
  2009-05-17 19:45         ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 22+ messages in thread
From: Borislav Petkov @ 2009-05-17 19:34 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, Martin Lottermoser

(adding Bart to CC)

Hi Bart,

please take a look at the OOPS below, seems like we BUG() in ide_intr() at
BUG_ON(!hwif->handler) which shouldn't happen. Full message is at:

http://www.gossamer-threads.com/lists/linux/kernel/1077445.

It is 2.6.29.3 with both PIIX_IDE and ata_piix compiled and it could be
that those two step on each other's toes, but this is only wild stab in
the dark.

I'm sure you have more ideas.

On Sun, May 17, 2009 at 02:14:44PM +0200, Martin Lottermoser wrote:
> Hello,
> 
> On Sun, May 17, 2009 at 01:15:35PM +0200, Martin Lottermoser wrote:
> > no, I don't have the necessary cable for that, but I'll provide a
> > photograph of the screen and put it on my web site.
> 
> I've done that now. The file is available from this URL:
> 
>   http://home.vrweb.de/martin.lottermoser/linux/
> 
> The directory contains a file "0-readme.txt" which explains what the
> files in the directory are; I've added the kernel configuration and the
> syslog.
> 
> Regards,
> Martin Lottermoser
> -- 
> Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
> Greifswaldstrasse 28
> 38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
> Germany

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 17:59 ` Robert Hancock
@ 2009-05-17 19:35   ` Bartlomiej Zolnierkiewicz
  2009-05-17 20:18     ` Martin Lottermoser
                       ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-17 19:35 UTC (permalink / raw)
  To: Robert Hancock; +Cc: Martin Lottermoser, linux-kernel, linux-ide


On Sunday 17 May 2009 19:59:56 Robert Hancock wrote:
> Martin Lottermoser wrote:
> > Hello,
> > 
> > newer versions of the Linux kernel overestimate my DVD drive's
> > DMA capabilities, leading either to DMA being disabled or a kernel
> > panic.
> > 
> > My setup is:
> > 
> >   Motherboard: ASUS P4C800-E Deluxe
> >     South bridge: ICH5R
> >       IDE Interface Controller (PATA): Intel 82801EB/ER (PCI: 8086:24db)
> >   DVD drive: Samsung SH-S202N, attached as hdc.
> >     There is also an older CD writer (Lite-On LTR-52327S) attached as
> >     hdd.
> >   Operating system: Debian 5.0.0 with security updates
> > 
> > On upgrading from Debian 4.0 (Linux 2.6.18) to 5.0 (Linux 2.6.26) I
> > found that trying to play movie DVDs with vlc (VideoLAN media player)
> > led to DMA being disabled:
> > 
> >   hdc: cdrom_decode_status: status=0x51 { DriveReady SeekComplete Error }
> >   hdc: cdrom_decode_status: error=0x40 { LastFailedSense=0x04 }
> >   ide: failed opcode was: unknown
> >   <4 more identical groups of these messages>
> >   hdc: DMA disabled
> >   hdc: ide_intr: huh? expected NULL handler on exit
> >   hdc: ATAPI reset complete
> 
> Looks like kind of a comedy of errors. It failed to indicate what the 
> failed command was (though, it seems like the failed opcode is always 
> unknown with the IDE drivers), disabled DMA incorrectly, then seemingly 
> confused itself.
> 
> Seems like the IDE layer grew some regressions at some point. You could 
> try a newer (2.6.29) kernel. However, from a user perspective, quite 
               ^^^^^^

> likely you'll be happier ditching the IDE drivers and using libata 
> instead, it tends to be better tested these days..

Robert, recommending alternatives is of course fine, same cannot be said
about not reading the whole bug-report before making final conclusions...

> > 
> > The resulting configuration is too slow to play movies. I booted the
> > older kernel and everything was fine.
> > 
> > I then tested various versions of the Linux kernel where I happened to
> > have the original sources. The most interesting results were:
> > 
> >   2.6.22.9      works, no errors visible in syslog
> >   2.6.23.14     works, but syslog shows an error (see below)
> >   2.6.24.3	DMA disabled
> >   2.6.29.3	Kernel panic: Fatal exception in interrupt (ide_intr)
      ^^^^^^^^

> >                 on trying to open the DVD with vlc
> > 
> > The error message with 2.6.23.14 was:
> > 
> >   hdc: drive_cmd: status=0x51 { DriveReady SeekComplete Error }
> >   hdc: drive_cmd: error=0x04 { AbortedCommand }
> >   ide: failed opcode was: 0xec

This is more-or-less innocent -- some user-space utility wrongly uses
ATA IDENTIFY command on ATAPI devices and it gets logged as an error...

> > This kernel as well as 2.6.22.9 also showed the following on booting:
> > 
> >   hdc: host side 80-wire cable detection failed, limiting max speed to UDMA33
> > 
> > This is correct: the drive is only capable of Ultra DMA mode 2 33.3 MB/s
> > (see manufacturer's documentation) and is attached with a standard 40-wire
> > ATA cable (black connectors for master and slave).

Martin, this is one of ATAPI drives which support UDMA66 but have broken
cable detection.  Since 2.6.26 we have a special quirk for it ide (commit
3ced5c49bd2d1f2c7f769e3a54385883de63a652) and subsequent one in libata
(commit e9f3340673c1da32041f2a282b166c72cd78632e).

In your system's case the cable detection doesn't seem to work properly
which in turn results in all kind of later problems.

It could be that the quirk itself needs to be revised (I wonder if it was
originally tested with 40-wires cable) or maybe we need some other cable
detection fix...

Please:

* send 'hdparm --Istdout /dev/hdc' output

* try 2.6.30-rc6 (maybe 2.6.29.3 oops has been fixed already and we just
  need to backport it)

also connecting the drive using 80-wires cable and getting another hdparm
output (+ seeing if it helps the other problems) would be very useful.

PS guys, please remember to cc: linux-ide.

Thanks.
Bart

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 19:34       ` Borislav Petkov
@ 2009-05-17 19:45         ` Bartlomiej Zolnierkiewicz
  2009-05-17 19:50           ` Borislav Petkov
  0 siblings, 1 reply; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-17 19:45 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, Martin Lottermoser, linux-ide

On Sunday 17 May 2009 21:34:09 Borislav Petkov wrote:
> (adding Bart to CC)
> 
> Hi Bart,
> 
> please take a look at the OOPS below, seems like we BUG() in ide_intr() at
> BUG_ON(!hwif->handler) which shouldn't happen. Full message is at:
> 
> http://www.gossamer-threads.com/lists/linux/kernel/1077445.
> 
> It is 2.6.29.3 with both PIIX_IDE and ata_piix compiled and it could be
> that those two step on each other's toes, but this is only wild stab in
> the dark.
> 
> I'm sure you have more ideas.

Yes, see my other mail.

[ After writing "I will cc: linux-ide on IDE/ATA problems" 100x times
  on the whiteboard... ;-) ]

> On Sun, May 17, 2009 at 02:14:44PM +0200, Martin Lottermoser wrote:
> > Hello,
> > 
> > On Sun, May 17, 2009 at 01:15:35PM +0200, Martin Lottermoser wrote:
> > > no, I don't have the necessary cable for that, but I'll provide a
> > > photograph of the screen and put it on my web site.
> > 
> > I've done that now. The file is available from this URL:
> > 
> >   http://home.vrweb.de/martin.lottermoser/linux/
> > 
> > The directory contains a file "0-readme.txt" which explains what the
> > files in the directory are; I've added the kernel configuration and the
> > syslog.
> > 
> > Regards,
> > Martin Lottermoser
> > -- 
> > Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
> > Greifswaldstrasse 28
> > 38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
> > Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 19:45         ` Bartlomiej Zolnierkiewicz
@ 2009-05-17 19:50           ` Borislav Petkov
  2009-05-17 20:18             ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 22+ messages in thread
From: Borislav Petkov @ 2009-05-17 19:50 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: Borislav Petkov, linux-kernel, Martin Lottermoser, linux-ide

On Sun, May 17, 2009 at 09:45:45PM +0200, Bartlomiej Zolnierkiewicz wrote:
> On Sunday 17 May 2009 21:34:09 Borislav Petkov wrote:
> > (adding Bart to CC)
> > 
> > Hi Bart,
> > 
> > please take a look at the OOPS below, seems like we BUG() in ide_intr() at
> > BUG_ON(!hwif->handler) which shouldn't happen. Full message is at:
> > 
> > http://www.gossamer-threads.com/lists/linux/kernel/1077445.
> > 
> > It is 2.6.29.3 with both PIIX_IDE and ata_piix compiled and it could be
> > that those two step on each other's toes, but this is only wild stab in
> > the dark.
> > 
> > I'm sure you have more ideas.
> 
> Yes, see my other mail.

Saw it right after hitting send.

> [ After writing "I will cc: linux-ide on IDE/ATA problems" 100x times
>   on the whiteboard... ;-) ]

And I CC'ed you instead, this has even bigger effect :)

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 19:50           ` Borislav Petkov
@ 2009-05-17 20:18             ` Bartlomiej Zolnierkiewicz
  2009-05-17 20:30               ` Borislav Petkov
  0 siblings, 1 reply; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-17 20:18 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, Martin Lottermoser, linux-ide

On Sunday 17 May 2009 21:50:51 Borislav Petkov wrote:
> On Sun, May 17, 2009 at 09:45:45PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > On Sunday 17 May 2009 21:34:09 Borislav Petkov wrote:
> > > (adding Bart to CC)
> > > 
> > > Hi Bart,
> > > 
> > > please take a look at the OOPS below, seems like we BUG() in ide_intr() at
> > > BUG_ON(!hwif->handler) which shouldn't happen. Full message is at:
> > > 
> > > http://www.gossamer-threads.com/lists/linux/kernel/1077445.
> > > 
> > > It is 2.6.29.3 with both PIIX_IDE and ata_piix compiled and it could be
> > > that those two step on each other's toes, but this is only wild stab in
> > > the dark.
> > > 
> > > I'm sure you have more ideas.
> > 
> > Yes, see my other mail.
> 
> Saw it right after hitting send.
> 
> > [ After writing "I will cc: linux-ide on IDE/ATA problems" 100x times
> >   on the whiteboard... ;-) ]
> 
> And I CC'ed you instead, this has even bigger effect :)

Actually no.

I'm following all IDE discussions on linux-ide anyway and whenever I see
that I can help immediately I do it (and if I can't the issue gets its
priority level according to which it will be looked at later).  CC:ing me
on not fully debugged problems is not helping anything.  More likely that
it disrupts the work-flow since people are waiting on me instead of just
pushing for the solution harder...

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 19:35   ` Bartlomiej Zolnierkiewicz
@ 2009-05-17 20:18     ` Martin Lottermoser
  2009-05-18 16:40     ` Martin Lottermoser
  2009-05-18 19:12     ` Martin Lottermoser
  2 siblings, 0 replies; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-17 20:18 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide

Hello,

On Sun, May 17, 2009 at 21:35:09 +0200, Bartlomiej Zolnierkiewicz wrote:
> > > The error message with 2.6.23.14 was:
> > > 
> > >   hdc: drive_cmd: status=0x51 { DriveReady SeekComplete Error }
> > >   hdc: drive_cmd: error=0x04 { AbortedCommand }
> > >   ide: failed opcode was: 0xec
> 
> This is more-or-less innocent -- some user-space utility wrongly uses
> ATA IDENTIFY command on ATAPI devices and it gets logged as an error...

thanks; that's a load off my mind :-).

> > > This is correct: the drive is only capable of Ultra DMA mode 2 33.3 MB/s
> > > (see manufacturer's documentation) and is attached with a standard 40-wire
> > > ATA cable (black connectors for master and slave).
> 
> Martin, this is one of ATAPI drives which support UDMA66 but have broken
> cable detection.

Are you sure? Compare this:

  http://downloadcenter.samsung.com/content/UM/200709/20070928095126750_SH-S202N_Eng.pdf

> Please:
> 
> * send 'hdparm --Istdout /dev/hdc' output

Here it is:

  /dev/hdc:
  85c0 0000 0000 0000 0000 0000 0000 0000
  0000 0000 2020 2020 2020 2020 2020 2020
  2020 2020 2020 2020 0000 0000 0000 5342
  3031 2020 2020 5453 5354 636f 7270 2043
  4444 5644 5720 5348 2d53 3230 324e 2020
  2020 2020 2020 2020 2020 2020 2020 0000
  0000 0b00 0000 0200 0200 0006 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0007
  0003 0078 0078 017f 0078 0000 0000 0000
  0000 00f8 0210 0000 0000 0000 0000 0000
  00f8 0210 0210 0000 0000 0000 0000 0000
  041f 0000 8005 3200 005b 2000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 0000
  0000 0000 0000 0000 0000 0000 0000 a3a5

> * try 2.6.30-rc6 (maybe 2.6.29.3 oops has been fixed already and we just
>   need to backport it)

That'll have to wait until tomorrow -- I have a low-bandwidth connection
here.

> also connecting the drive using 80-wires cable and getting another hdparm
> output (+ seeing if it helps the other problems) would be very useful.

I'll try that too, but that also will have to wait until tommorrow.

Thanks for the help,
Martin Lottermoser
-- 
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 20:18             ` Bartlomiej Zolnierkiewicz
@ 2009-05-17 20:30               ` Borislav Petkov
  2009-05-17 22:48                 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 22+ messages in thread
From: Borislav Petkov @ 2009-05-17 20:30 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, Martin Lottermoser, linux-ide

Hi,

On Sun, May 17, 2009 at 10:18:01PM +0200, Bartlomiej Zolnierkiewicz wrote:
> On Sunday 17 May 2009 21:50:51 Borislav Petkov wrote:
> > On Sun, May 17, 2009 at 09:45:45PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > > On Sunday 17 May 2009 21:34:09 Borislav Petkov wrote:
> > > > (adding Bart to CC)
> > > > 
> > > > Hi Bart,
> > > > 
> > > > please take a look at the OOPS below, seems like we BUG() in ide_intr() at
> > > > BUG_ON(!hwif->handler) which shouldn't happen. Full message is at:
> > > > 
> > > > http://www.gossamer-threads.com/lists/linux/kernel/1077445.
> > > > 
> > > > It is 2.6.29.3 with both PIIX_IDE and ata_piix compiled and it could be
> > > > that those two step on each other's toes, but this is only wild stab in
> > > > the dark.
> > > > 
> > > > I'm sure you have more ideas.
> > > 
> > > Yes, see my other mail.
> > 
> > Saw it right after hitting send.
> > 
> > > [ After writing "I will cc: linux-ide on IDE/ATA problems" 100x times
> > >   on the whiteboard... ;-) ]
> > 
> > And I CC'ed you instead, this has even bigger effect :)
> 
> Actually no.
> 
> I'm following all IDE discussions on linux-ide anyway and whenever I see
> that I can help immediately I do it (and if I can't the issue gets its
> priority level according to which it will be looked at later).  CC:ing me
> on not fully debugged problems is not helping anything.  More likely that
> it disrupts the work-flow since people are waiting on me instead of just
> pushing for the solution harder...

In this case, however, it made more sense to CC you - you know that code
better than me, you have the bunch of experience while I have to read
a ton of stuff before I get up to speed with the problem. You, on the
other hand, have seen similar errors like that before and can at least
have a hunch - and you did. Besides, it's not like I'm waiting for you
- I have other things on my plate which I could tackle while you handle
the case you're more knowledgeable at. It is simple as that.

But I'll start CCing linux-ide if that's your preference.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 20:30               ` Borislav Petkov
@ 2009-05-17 22:48                 ` Bartlomiej Zolnierkiewicz
  2009-05-18  6:32                   ` Borislav Petkov
  0 siblings, 1 reply; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-17 22:48 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, Martin Lottermoser, linux-ide

On Sunday 17 May 2009 22:30:33 Borislav Petkov wrote:
> Hi,
> 
> On Sun, May 17, 2009 at 10:18:01PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > On Sunday 17 May 2009 21:50:51 Borislav Petkov wrote:
> > > On Sun, May 17, 2009 at 09:45:45PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > > > On Sunday 17 May 2009 21:34:09 Borislav Petkov wrote:
> > > > > (adding Bart to CC)
> > > > > 
> > > > > Hi Bart,
> > > > > 
> > > > > please take a look at the OOPS below, seems like we BUG() in ide_intr() at
> > > > > BUG_ON(!hwif->handler) which shouldn't happen. Full message is at:
> > > > > 
> > > > > http://www.gossamer-threads.com/lists/linux/kernel/1077445.
> > > > > 
> > > > > It is 2.6.29.3 with both PIIX_IDE and ata_piix compiled and it could be
> > > > > that those two step on each other's toes, but this is only wild stab in
> > > > > the dark.
> > > > > 
> > > > > I'm sure you have more ideas.
> > > > 
> > > > Yes, see my other mail.
> > > 
> > > Saw it right after hitting send.
> > > 
> > > > [ After writing "I will cc: linux-ide on IDE/ATA problems" 100x times
> > > >   on the whiteboard... ;-) ]
> > > 
> > > And I CC'ed you instead, this has even bigger effect :)
> > 
> > Actually no.
> > 
> > I'm following all IDE discussions on linux-ide anyway and whenever I see
> > that I can help immediately I do it (and if I can't the issue gets its
> > priority level according to which it will be looked at later).  CC:ing me
> > on not fully debugged problems is not helping anything.  More likely that
> > it disrupts the work-flow since people are waiting on me instead of just
> > pushing for the solution harder...
> 
> In this case, however, it made more sense to CC you - you know that code
> better than me, you have the bunch of experience while I have to read
> a ton of stuff before I get up to speed with the problem. You, on the
> other hand, have seen similar errors like that before and can at least

You seem to forget that I'm not reading LKML regularly but I do linux-ide
(I know that the same is true for some other people) so I would have helped
much earlier if I had noticed the *initial* mail instead of the most recent
at the time...

> have a hunch - and you did. Besides, it's not like I'm waiting for you
> - I have other things on my plate which I could tackle while you handle
> the case you're more knowledgeable at. It is simple as that.

That is missing the point -- we are not the only knowledgeable ones here
and we definitely want to encourage other people to attack the problems.

[ Please read my mail again.  I explicitly said "people" not "you" there. ]

> But I'll start CCing linux-ide if that's your preference.

Thanks but my preferences are not the point here.  That is just the most
efficient way for everybody: IDE/ATA problems should be handled at linux-ide
mailing list.  You can still cc: me but cc:ing linux-ide takes priority.

Thanks.
Bart

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 22:48                 ` Bartlomiej Zolnierkiewicz
@ 2009-05-18  6:32                   ` Borislav Petkov
  0 siblings, 0 replies; 22+ messages in thread
From: Borislav Petkov @ 2009-05-18  6:32 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, Martin Lottermoser, linux-ide

Hi,

On Mon, May 18, 2009 at 12:48:36AM +0200, Bartlomiej Zolnierkiewicz wrote:

[..]

> > have a hunch - and you did. Besides, it's not like I'm waiting for you
> > - I have other things on my plate which I could tackle while you handle
> > the case you're more knowledgeable at. It is simple as that.
> 
> That is missing the point -- we are not the only knowledgeable ones here
> and we definitely want to encourage other people to attack the problems.
> 
> [ Please read my mail again.  I explicitly said "people" not "you" there. ]

I was being a realist - nobody but you, Sergei and me does attack
problems. But there's always the hope :).

> 
> > But I'll start CCing linux-ide if that's your preference.
> 
> Thanks but my preferences are not the point here.  That is just the most
> efficient way for everybody: IDE/ATA problems should be handled at linux-ide
> mailing list.  You can still cc: me but cc:ing linux-ide takes priority.

Yep, got it.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 19:35   ` Bartlomiej Zolnierkiewicz
  2009-05-17 20:18     ` Martin Lottermoser
@ 2009-05-18 16:40     ` Martin Lottermoser
  2009-05-18 19:12     ` Martin Lottermoser
  2 siblings, 0 replies; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-18 16:40 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide

Hello,

On Sun, May 17, 2009 at 09:35:09PM +0200, Bartlomiej Zolnierkiewicz wrote:
> * try 2.6.30-rc6 (maybe 2.6.29.3 oops has been fixed already and we just
>   need to backport it)

I've done that and put the resulting files again on the web at:

  http://home.vrweb.de/martin.lottermoser/linux/

The files are named "2.6.30-rc6-*".

The basic result is that the kernel still panics, still in
drivers/ide/ide-io.c, the final output on the real console shows only
a call stack (far deeper than with 2.6.29.3) but no terminating panic
message, and the ouput sent through netconsole arrives truncated.

Regards,
Martin Lottermoser
--
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-17 19:35   ` Bartlomiej Zolnierkiewicz
  2009-05-17 20:18     ` Martin Lottermoser
  2009-05-18 16:40     ` Martin Lottermoser
@ 2009-05-18 19:12     ` Martin Lottermoser
  2009-05-19 15:19       ` Bartlomiej Zolnierkiewicz
  2 siblings, 1 reply; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-18 19:12 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide

Hi,

On Sun, May 17, 2009 at 09:35:09PM +0200, Bartlomiej Zolnierkiewicz wrote:
> Martin, this is one of ATAPI drives which support UDMA66 but have broken
> cable detection.  Since 2.6.26 we have a special quirk for it ide (commit
> 3ced5c49bd2d1f2c7f769e3a54385883de63a652) and subsequent one in libata
> (commit e9f3340673c1da32041f2a282b166c72cd78632e).
> 
> In your system's case the cable detection doesn't seem to work properly
> which in turn results in all kind of later problems.
> 
> It could be that the quirk itself needs to be revised (I wonder if it was
> originally tested with 40-wires cable) or maybe we need some other cable
> detection fix...
> 
> Please:
> 
> * send 'hdparm --Istdout /dev/hdc' output
> 
> * try 2.6.30-rc6 (maybe 2.6.29.3 oops has been fixed already and we just
>   need to backport it)
> 
> also connecting the drive using 80-wires cable and getting another hdparm
> output (+ seeing if it helps the other problems) would be very useful.

I've done that now as well. Test runs with Debian's 2.6.26 and with 2.6.30-rc6
show no problems: no disabling of DMA, no kernel panic.

The hdparm output ("hdparm --Istdout") is the same for a 40-wire cable and an
80-wire cable (checked under 2.6.26).

This indicates that your hypothesis above that it's a cable detection problem
is correct.

Just out of curiosity: is this a bug on the drive's side or in the kernel?
Or in other words: if the output of "hdparm -I" shows the drive as attached
to be able to support UDMA4, is this a statement passed through unmodified
from the drive or is this a deduction made by the kernel? I ask because
under 2.6.22.9 and 2.6.23.14 I got a message that "host side 80-wire cable
detection failed".

Should anyone find a fix to correct/circumvent this problem in the kernel,
I'ld be willing to test it on my system; just send a patch file or tell me
where to pick it up.

Regards,
Martin Lottermoser
-- 
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-18 19:12     ` Martin Lottermoser
@ 2009-05-19 15:19       ` Bartlomiej Zolnierkiewicz
  2009-05-19 18:29         ` Martin Lottermoser
  0 siblings, 1 reply; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-19 15:19 UTC (permalink / raw)
  To: Martin Lottermoser; +Cc: linux-kernel, linux-ide

On Monday 18 May 2009 21:12:07 Martin Lottermoser wrote:
> Hi,
> 
> On Sun, May 17, 2009 at 09:35:09PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > Martin, this is one of ATAPI drives which support UDMA66 but have broken
> > cable detection.  Since 2.6.26 we have a special quirk for it ide (commit
> > 3ced5c49bd2d1f2c7f769e3a54385883de63a652) and subsequent one in libata
> > (commit e9f3340673c1da32041f2a282b166c72cd78632e).
> > 
> > In your system's case the cable detection doesn't seem to work properly
> > which in turn results in all kind of later problems.
> > 
> > It could be that the quirk itself needs to be revised (I wonder if it was
> > originally tested with 40-wires cable) or maybe we need some other cable
> > detection fix...
> > 
> > Please:
> > 
> > * send 'hdparm --Istdout /dev/hdc' output
> > 
> > * try 2.6.30-rc6 (maybe 2.6.29.3 oops has been fixed already and we just
> >   need to backport it)
> > 
> > also connecting the drive using 80-wires cable and getting another hdparm
> > output (+ seeing if it helps the other problems) would be very useful.
> 
> I've done that now as well. Test runs with Debian's 2.6.26 and with 2.6.30-rc6
> show no problems: no disabling of DMA, no kernel panic.
> 
> The hdparm output ("hdparm --Istdout") is the same for a 40-wire cable and an
> 80-wire cable (checked under 2.6.26).

Thanks, this verifies that this drive just lacks proper cable detection.

[ BTW I guess that UDMA66 was added later, after the hardware design was
  ready but it is official.  Please see product spec for "[E-IDE] SH-S202N"
  at http://www.samsungodd.com/:

        "Data transfer mode: ... Ultra DMA Mode 4 : 66.6MB/sec" ]

> This indicates that your hypothesis above that it's a cable detection problem
> is correct.
> 
> Just out of curiosity: is this a bug on the drive's side or in the kernel?

Both. :)  However the root cause is a "problematic" device not the kernel.

> Or in other words: if the output of "hdparm -I" shows the drive as attached
> to be able to support UDMA4, is this a statement passed through unmodified
> from the drive or is this a deduction made by the kernel? I ask because

It comes from the drive.

> under 2.6.22.9 and 2.6.23.14 I got a message that "host side 80-wire cable
> detection failed".

Your host controller correctly detected 40-wire cable and complained about
it since drive supports UDMA66.  In later kernels we added workaround for it
and trusted the drive side cable detection only...

> Should anyone find a fix to correct/circumvent this problem in the kernel,
> I'ld be willing to test it on my system; just send a patch file or tell me
> where to pick it up.

Here is the patch for 2.6.30-rc6 to fix operation with 40-wire cable, please
test it (we have also oops in the error-recovery issue to fix but I'll try to
reproduce it locally some time later and ping you when I'm done / need help).

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: fix 40-wire cable detection for TSST SH-S202* ATAPI devices

Since 2.6.26 we support UDMA66 on ATAPI devices requiring IVB quirk:

  commit 8588a2b732928b343233af9b1855705b8286bed4
  ("ide: add SH-S202J to ivb_list[]")

We also later added support for more such devices in:

  commit e97564f362a93f8c248246c19828895950341252
  ("ide: More TSST drives with broken cable detection")

and in:

  commit 3ced5c49bd2d1f2c7f769e3a54385883de63a652
  ("ide: add TSSTcorp CDDVDW SH-S202H to ivb_list[]")

It turns out that such devices lack cable detection altogether
(which in turn results in incorrect detection of 40-wire cables
by our current cable detection strategy) so always handle them
by trusting host-side cable detection only.

Reported-by: Martin Lottermoser <Martin.Lottermoser@t-online.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-iops.c |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -206,8 +206,6 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
 
 /*
  * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid.
- * We list them here and depend on the device side cable detection for them.
- *
  * Some optical devices with the buggy firmwares have the same problem.
  */
 static const struct drive_list_entry ivb_list[] = {
@@ -251,10 +249,25 @@ u8 eighty_ninty_three(ide_drive_t *drive
 	 * - force bit13 (80c cable present) check also for !ivb devices
 	 *   (unless the slave device is pre-ATA3)
 	 */
-	if ((id[ATA_ID_HW_CONFIG] & 0x4000) ||
-	    (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000)))
+	if (id[ATA_ID_HW_CONFIG] & 0x4000)
 		return 1;
 
+	if (ivb) {
+		const char *model = (char *)&id[ATA_ID_PROD];
+
+		if (strcmp("TSSTcorp CDDVDW SH-S202", model) == 0) {
+			/*
+			 * These ATAPI devices always report 80c cable
+			 * so we have to depend on the host in this case.
+			 */
+			if (hwif->cbl == ATA_CBL_PATA80)
+				return 1;
+		} else {
+			/* Depend on the device side cable detection. */
+			if (id[ATA_ID_HW_CONFIG] & 0x2000)
+				return 1;
+		}
+	}
 no_80w:
 	if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED)
 		return 0;

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-19 15:19       ` Bartlomiej Zolnierkiewicz
@ 2009-05-19 18:29         ` Martin Lottermoser
  2009-05-19 19:30           ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-19 18:29 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide

Hello,

On Tue, May 19, 2009 at 05:19:35PM +0200, Bartlomiej Zolnierkiewicz wrote:
> Subject: [PATCH] ide: fix 40-wire cable detection for TSST SH-S202* ATAPI devices

I'm sorry, but that also generated a panic, looking identical to the
behaviour as for the unpatched 2.6.30-rc6.

After booting the patched kernel, the syslog file showed:

  hdc: UDMA/66 mode selected

"hdparm -I" reported that the drive was set to "udma4". On accessing the DVD,
the kernel panicked. Here's the main output from netconsole:

  hdc: cdrom_decode_status: error=0x40 <3>{ LastFailedSense=0x04 }
  ide: failed opcode was: unknown
  hdc: DMA disabled
  ------------[ cut here ]------------
  kernel BUG at drivers/ide/ide-io.c:872!
  invalid opcode: 0000 [#1]
  last sysfs file: /sys/devices/pci0000:00/0000:00:1f.1/ide1/1.0/block/hdc/size

After booting the kernel and before doing the test I had checked with
"uname -a" that this really was the newly compiled kernel. After reboot I
checked that ide-iops.o existed and had a modification time later than the
moment I applied your patch. Also, the new vmlinuz is 64 bytes shorter than
the unpatched one. Therefore I don't think I made some silly mistake which
led to the patch being ignored.

The offer for testing patches remains open :-).

Regards,
Martin Lottermoser
--
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-19 18:29         ` Martin Lottermoser
@ 2009-05-19 19:30           ` Bartlomiej Zolnierkiewicz
  2009-05-19 21:11             ` Bartlomiej Zolnierkiewicz
  2009-05-19 21:12             ` Martin Lottermoser
  0 siblings, 2 replies; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-19 19:30 UTC (permalink / raw)
  To: Martin Lottermoser; +Cc: linux-kernel, linux-ide

On Tuesday 19 May 2009 20:29:28 Martin Lottermoser wrote:
> Hello,
> 
> On Tue, May 19, 2009 at 05:19:35PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > Subject: [PATCH] ide: fix 40-wire cable detection for TSST SH-S202* ATAPI devices
> 
> I'm sorry, but that also generated a panic, looking identical to the
> behaviour as for the unpatched 2.6.30-rc6.
> 
> After booting the patched kernel, the syslog file showed:
> 
>   hdc: UDMA/66 mode selected
> 
> "hdparm -I" reported that the drive was set to "udma4". On accessing the DVD,
> the kernel panicked. Here's the main output from netconsole:
> 
>   hdc: cdrom_decode_status: error=0x40 <3>{ LastFailedSense=0x04 }
>   ide: failed opcode was: unknown
>   hdc: DMA disabled
>   ------------[ cut here ]------------
>   kernel BUG at drivers/ide/ide-io.c:872!
>   invalid opcode: 0000 [#1]
>   last sysfs file: /sys/devices/pci0000:00/0000:00:1f.1/ide1/1.0/block/hdc/size
> 
> After booting the kernel and before doing the test I had checked with
> "uname -a" that this really was the newly compiled kernel. After reboot I
> checked that ide-iops.o existed and had a modification time later than the
> moment I applied your patch. Also, the new vmlinuz is 64 bytes shorter than
> the unpatched one. Therefore I don't think I made some silly mistake which
> led to the patch being ignored.

You didn't.  I did.

Incremental patch fixing it:

diff -u b/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
--- b/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -255,7 +255,7 @@
 	if (ivb) {
 		const char *model = (char *)&id[ATA_ID_PROD];
 
-		if (strcmp("TSSTcorp CDDVDW SH-S202", model) == 0) {
+		if (strstr("TSSTcorp CDDVDW SH-S202", model)) {
 			/*
 			 * These ATAPI devices always report 80c cable
 			 * so we have to depend on the host in this case.


> The offer for testing patches remains open :-).

We will get there. ;-)

I've reproduced the problem and I'm testing the fix currently...

Thanks,
Bart

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-19 19:30           ` Bartlomiej Zolnierkiewicz
@ 2009-05-19 21:11             ` Bartlomiej Zolnierkiewicz
  2009-05-19 21:12             ` Martin Lottermoser
  1 sibling, 0 replies; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-19 21:11 UTC (permalink / raw)
  To: Martin Lottermoser; +Cc: linux-kernel, linux-ide, Borislav Petkov

On Tuesday 19 May 2009 21:30:59 Bartlomiej Zolnierkiewicz wrote:

[...]

> > The offer for testing patches remains open :-).
> 
> We will get there. ;-)
> 
> I've reproduced the problem and I'm testing the fix currently...

The following patch should fix OOPS w/ vanilla 2.6.30-rc6 and 40-wire cable:

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: fix OOPS during ide-cd error recovery

On Tuesday 19 May 2009 20:29:28 Martin Lottermoser wrote:

>   hdc: cdrom_decode_status: error=0x40 <3>{ LastFailedSense=0x04 }
>   ide: failed opcode was: unknown
>   hdc: DMA disabled
>   ------------[ cut here ]------------
>   kernel BUG at drivers/ide/ide-io.c:872!

It is possible for ide-cd to ignore ide_error()'s return value under
some circumstances.  Workaround it in ide_intr() and ide_timer_expiry()
by checking if there is a device/port reset pending currently.

Reported-by: Martin Lottermoser <Martin.Lottermoser@t-online.de>
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
in the longer-term ide-cd should be fixed to not do such things
(too invasive for 2.6.30 and 2.6.29)

 drivers/ide/ide-io.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: b/drivers/ide/ide-io.c
===================================================================
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -696,7 +696,7 @@ void ide_timer_expiry (unsigned long dat
 		}
 		spin_lock_irq(&hwif->lock);
 		enable_irq(hwif->irq);
-		if (startstop == ide_stopped) {
+		if (startstop == ide_stopped && hwif->polling == 0) {
 			ide_unlock_port(hwif);
 			plug_device = 1;
 		}
@@ -868,7 +868,7 @@ irqreturn_t ide_intr (int irq, void *dev
 	 * same irq as is currently being serviced here, and Linux
 	 * won't allow another of the same (on any CPU) until we return.
 	 */
-	if (startstop == ide_stopped) {
+	if (startstop == ide_stopped && hwif->polling == 0) {
 		BUG_ON(hwif->handler);
 		ide_unlock_port(hwif);
 		plug_device = 1;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-19 19:30           ` Bartlomiej Zolnierkiewicz
  2009-05-19 21:11             ` Bartlomiej Zolnierkiewicz
@ 2009-05-19 21:12             ` Martin Lottermoser
  2009-05-19 21:31               ` Bartlomiej Zolnierkiewicz
  1 sibling, 1 reply; 22+ messages in thread
From: Martin Lottermoser @ 2009-05-19 21:12 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide

Hi,

On Tue, May 19, 2009 at 09:30:59PM +0200, Bartlomiej Zolnierkiewicz wrote:
> Incremental patch fixing it:
> 
> diff -u b/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
> --- b/drivers/ide/ide-iops.c
> +++ b/drivers/ide/ide-iops.c
> @@ -255,7 +255,7 @@
>  	if (ivb) {
>  		const char *model = (char *)&id[ATA_ID_PROD];
>  
> -		if (strcmp("TSSTcorp CDDVDW SH-S202", model) == 0) {
> +		if (strstr("TSSTcorp CDDVDW SH-S202", model)) {
>  			/*
>  			 * These ATAPI devices always report 80c cable
>  			 * so we have to depend on the host in this case.
> 

I applied that, recompiled, installed, rebooted, and checked the syslog.
The message was still

  hdc: UDMA/66 mode selected

and hdparm also showed "udma4" as being selected. I therefore didn't test
with a DVD.

However, after twice reading the POSIX definition of strstr() I reversed
the order of the arguments to

                if (strstr(model, "TSSTcorp CDDVDW SH-S202")) {

and that did it. Syslog now contained:

  hdc: host side 80-wire cable detection failed, limiting max speed to UDMA33
  hdc: UDMA/33 mode selected

hdparm showed "udma2", and playing movie DVDs worked without DMA being
disabled. :-)

That seems to be it, then. Many thanks for your help, and in particular for
the explanations.

Regards,
Martin Lottermoser
-- 
Martin Lottermoser             Martin.Lottermoser at _REMOVE_t-online.de
Greifswaldstrasse 28
38124 Braunschweig             http://home.vrweb.de/martin.lottermoser
Germany

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: PATA DMA problem leading to kernel panic on reading movie DVDs
  2009-05-19 21:12             ` Martin Lottermoser
@ 2009-05-19 21:31               ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 22+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-05-19 21:31 UTC (permalink / raw)
  To: Martin Lottermoser; +Cc: linux-kernel, linux-ide

On Tuesday 19 May 2009 23:12:21 Martin Lottermoser wrote:
> Hi,
> 
> On Tue, May 19, 2009 at 09:30:59PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > Incremental patch fixing it:
> > 
> > diff -u b/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
> > --- b/drivers/ide/ide-iops.c
> > +++ b/drivers/ide/ide-iops.c
> > @@ -255,7 +255,7 @@
> >  	if (ivb) {
> >  		const char *model = (char *)&id[ATA_ID_PROD];
> >  
> > -		if (strcmp("TSSTcorp CDDVDW SH-S202", model) == 0) {
> > +		if (strstr("TSSTcorp CDDVDW SH-S202", model)) {
> >  			/*
> >  			 * These ATAPI devices always report 80c cable
> >  			 * so we have to depend on the host in this case.
> > 
> 
> I applied that, recompiled, installed, rebooted, and checked the syslog.
> The message was still
> 
>   hdc: UDMA/66 mode selected
> 
> and hdparm also showed "udma4" as being selected. I therefore didn't test
> with a DVD.
> 
> However, after twice reading the POSIX definition of strstr() I reversed
> the order of the arguments to
> 
>                 if (strstr(model, "TSSTcorp CDDVDW SH-S202")) {

/me hides

> and that did it. Syslog now contained:
> 
>   hdc: host side 80-wire cable detection failed, limiting max speed to UDMA33
>   hdc: UDMA/33 mode selected
> 
> hdparm showed "udma2", and playing movie DVDs worked without DMA being
> disabled. :-)

:)

The final patch version:

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: fix 40-wire cable detection for TSST SH-S202* ATAPI devices (v2)

Since 2.6.26 we support UDMA66 on ATAPI devices requiring IVB quirk:

  commit 8588a2b732928b343233af9b1855705b8286bed4
  ("ide: add SH-S202J to ivb_list[]")

We also later added support for more such devices in:

  commit e97564f362a93f8c248246c19828895950341252
  ("ide: More TSST drives with broken cable detection")

and in:

  commit 3ced5c49bd2d1f2c7f769e3a54385883de63a652
  ("ide: add TSSTcorp CDDVDW SH-S202H to ivb_list[]")

It turns out that such devices lack cable detection altogether
(which in turn results in incorrect detection of 40-wire cables
by our current cable detection strategy) so always handle them
by trusting host-side cable detection only.

v2:
Model detection fixup from Martin.

Reported-and-tested-by: Martin Lottermoser <Martin.Lottermoser@t-online.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-iops.c |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -206,8 +206,6 @@ EXPORT_SYMBOL_GPL(ide_in_drive_list);
 
 /*
  * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid.
- * We list them here and depend on the device side cable detection for them.
- *
  * Some optical devices with the buggy firmwares have the same problem.
  */
 static const struct drive_list_entry ivb_list[] = {
@@ -251,10 +249,25 @@ u8 eighty_ninty_three(ide_drive_t *drive
 	 * - force bit13 (80c cable present) check also for !ivb devices
 	 *   (unless the slave device is pre-ATA3)
 	 */
-	if ((id[ATA_ID_HW_CONFIG] & 0x4000) ||
-	    (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000)))
+	if (id[ATA_ID_HW_CONFIG] & 0x4000)
 		return 1;
 
+	if (ivb) {
+		const char *model = (char *)&id[ATA_ID_PROD];
+
+		if (strstr(model, "TSSTcorp CDDVDW SH-S202")) {
+			/*
+			 * These ATAPI devices always report 80c cable
+			 * so we have to depend on the host in this case.
+			 */
+			if (hwif->cbl == ATA_CBL_PATA80)
+				return 1;
+		} else {
+			/* Depend on the device side cable detection. */
+			if (id[ATA_ID_HW_CONFIG] & 0x2000)
+				return 1;
+		}
+	}
 no_80w:
 	if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED)
 		return 0;

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-05-19 21:31 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-17  9:12 PATA DMA problem leading to kernel panic on reading movie DVDs Martin Lottermoser
2009-05-17 10:42 ` Borislav Petkov
2009-05-17 11:15   ` Martin Lottermoser
2009-05-17 12:14     ` Martin Lottermoser
2009-05-17 19:34       ` Borislav Petkov
2009-05-17 19:45         ` Bartlomiej Zolnierkiewicz
2009-05-17 19:50           ` Borislav Petkov
2009-05-17 20:18             ` Bartlomiej Zolnierkiewicz
2009-05-17 20:30               ` Borislav Petkov
2009-05-17 22:48                 ` Bartlomiej Zolnierkiewicz
2009-05-18  6:32                   ` Borislav Petkov
2009-05-17 17:59 ` Robert Hancock
2009-05-17 19:35   ` Bartlomiej Zolnierkiewicz
2009-05-17 20:18     ` Martin Lottermoser
2009-05-18 16:40     ` Martin Lottermoser
2009-05-18 19:12     ` Martin Lottermoser
2009-05-19 15:19       ` Bartlomiej Zolnierkiewicz
2009-05-19 18:29         ` Martin Lottermoser
2009-05-19 19:30           ` Bartlomiej Zolnierkiewicz
2009-05-19 21:11             ` Bartlomiej Zolnierkiewicz
2009-05-19 21:12             ` Martin Lottermoser
2009-05-19 21:31               ` Bartlomiej Zolnierkiewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.