linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata: Correct IORDY handling
@ 2007-07-31 13:01 Alan Cox
  2007-07-31 14:18 ` Sergei Shtylyov
  2007-08-15  7:09 ` Jeff Garzik
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Cox @ 2007-07-31 13:01 UTC (permalink / raw)
  To: akpm, linux-ide, linux-kernel

Debugging a report of a problem with an ancient solid state disk showed
up some problems in the IORDY handling

1.	We check the wrong bit to see if the device has IORDY
2.	Even then some ancient creaking piles of crap don't support
	SETXFER at all.

I think this should go via -mm for a bit. The cases it fixes are obscure
and the risk of side effects is slight but possible. This also moves us
slightly closer to supporting original MFM/RLL disks with libata but
before Jeff panics I have no plans to do that....

Signed-off-by: Alan Cox <alan@redhat.com>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.23rc1-mm1/drivers/ata/libata-core.c linux-2.6.23rc1-mm1/drivers/ata/libata-core.c
--- linux.vanilla-2.6.23rc1-mm1/drivers/ata/libata-core.c	2007-07-26 15:02:57.000000000 +0100
+++ linux-2.6.23rc1-mm1/drivers/ata/libata-core.c	2007-07-31 10:47:21.152431008 +0100
@@ -2787,7 +2803,11 @@
 	/* Old CFA may refuse this command, which is just fine */
 	if (dev->xfer_shift == ATA_SHIFT_PIO && ata_id_is_cfa(dev->id))
         	err_mask &= ~AC_ERR_DEV;
-
+	/* Some very old devices and some bad newer ones fail any kind of
+	   SET_XFERMODE request but support PIO0-2 timings and no IORDY */
+	if (dev->xfer_shift == ATA_SHIFT_PIO && !ata_id_has_iordy(dev->id) &&
+			dev->pio_mode <= XFER_PIO_2)
+		err_mask &= ~AC_ERR_DEV;
 	if (err_mask) {
 		ata_dev_printk(dev, KERN_ERR, "failed to set xfermode "
 			       "(err_mask=0x%x)\n", err_mask);
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.23rc1-mm1/include/linux/ata.h linux-2.6.23rc1-mm1/include/linux/ata.h
--- linux.vanilla-2.6.23rc1-mm1/include/linux/ata.h	2007-07-26 15:02:58.000000000 +0100
+++ linux-2.6.23rc1-mm1/include/linux/ata.h	2007-07-27 19:03:40.000000000 +0100
@@ -354,7 +355,7 @@
 	( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \
 	  ((id)[78] & (1 << 5)) )
 #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10))
-#define ata_id_has_iordy(id) ((id)[49] & (1 << 9))
+#define ata_id_has_iordy(id) ((id)[49] & (1 << 11))
 #define ata_id_u32(id,n)	\
 	(((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
 #define ata_id_u64(id,n)	\

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

* Re: [PATCH] libata: Correct IORDY handling
  2007-07-31 13:01 [PATCH] libata: Correct IORDY handling Alan Cox
@ 2007-07-31 14:18 ` Sergei Shtylyov
  2007-07-31 15:45   ` Alan Cox
  2007-08-15  7:09 ` Jeff Garzik
  1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2007-07-31 14:18 UTC (permalink / raw)
  To: Alan Cox; +Cc: akpm, linux-ide, linux-kernel

Hello.

Alan Cox wrote:

> Debugging a report of a problem with an ancient solid state disk showed
> up some problems in the IORDY handling

> 1.	We check the wrong bit to see if the device has IORDY
> 2.	Even then some ancient creaking piles of crap don't support
> 	SETXFER at all.

> I think this should go via -mm for a bit. The cases it fixes are obscure
> and the risk of side effects is slight but possible. This also moves us
> slightly closer to supporting original MFM/RLL disks with libata but
> before Jeff panics I have no plans to do that....

> Signed-off-by: Alan Cox <alan@redhat.com>

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

> diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.23rc1-mm1/drivers/ata/libata-core.c linux-2.6.23rc1-mm1/drivers/ata/libata-core.c
> --- linux.vanilla-2.6.23rc1-mm1/drivers/ata/libata-core.c	2007-07-26 15:02:57.000000000 +0100
> +++ linux-2.6.23rc1-mm1/drivers/ata/libata-core.c	2007-07-31 10:47:21.152431008 +0100
> @@ -2787,7 +2803,11 @@
>  	/* Old CFA may refuse this command, which is just fine */
>  	if (dev->xfer_shift == ATA_SHIFT_PIO && ata_id_is_cfa(dev->id))
>          	err_mask &= ~AC_ERR_DEV;
> -
> +	/* Some very old devices and some bad newer ones fail any kind of
> +	   SET_XFERMODE request but support PIO0-2 timings and no IORDY */
> +	if (dev->xfer_shift == ATA_SHIFT_PIO && !ata_id_has_iordy(dev->id) &&

    I'd have joined this to the previous if...

> +			dev->pio_mode <= XFER_PIO_2)

    Overindented line (to my taste :-). And do we really need to check this?

> +		err_mask &= ~AC_ERR_DEV;
>  	if (err_mask) {
>  		ata_dev_printk(dev, KERN_ERR, "failed to set xfermode "
>  			       "(err_mask=0x%x)\n", err_mask);
> diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.23rc1-mm1/include/linux/ata.h linux-2.6.23rc1-mm1/include/linux/ata.h
> --- linux.vanilla-2.6.23rc1-mm1/include/linux/ata.h	2007-07-26 15:02:58.000000000 +0100
> +++ linux-2.6.23rc1-mm1/include/linux/ata.h	2007-07-27 19:03:40.000000000 +0100
> @@ -354,7 +355,7 @@
>  	( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \
>  	  ((id)[78] & (1 << 5)) )
>  #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10))
> -#define ata_id_has_iordy(id) ((id)[49] & (1 << 9))
> +#define ata_id_has_iordy(id) ((id)[49] & (1 << 11))

   Ha, it was cheking for LBA support instead... :-)

MBR, Sergei

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

* Re: [PATCH] libata: Correct IORDY handling
  2007-07-31 14:18 ` Sergei Shtylyov
@ 2007-07-31 15:45   ` Alan Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2007-07-31 15:45 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: akpm, linux-ide, linux-kernel

> 
> > +			dev->pio_mode <= XFER_PIO_2)
> 
>     Overindented line (to my taste :-). And do we really need to check this?
> 

Yes - if it refuses SET_XFER_MODE we really don't want to run any mode
above PIO2. No hardware *should* do this but then this is IDE...

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

* Re: [PATCH] libata: Correct IORDY handling
  2007-07-31 13:01 [PATCH] libata: Correct IORDY handling Alan Cox
  2007-07-31 14:18 ` Sergei Shtylyov
@ 2007-08-15  7:09 ` Jeff Garzik
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Garzik @ 2007-08-15  7:09 UTC (permalink / raw)
  To: Alan Cox; +Cc: akpm, linux-ide, linux-kernel

Alan Cox wrote:
> Debugging a report of a problem with an ancient solid state disk showed
> up some problems in the IORDY handling
> 
> 1.	We check the wrong bit to see if the device has IORDY
> 2.	Even then some ancient creaking piles of crap don't support
> 	SETXFER at all.
> 
> I think this should go via -mm for a bit. The cases it fixes are obscure
> and the risk of side effects is slight but possible. This also moves us
> slightly closer to supporting original MFM/RLL disks with libata but
> before Jeff panics I have no plans to do that....
> 
> Signed-off-by: Alan Cox <alan@redhat.com>

applied



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

end of thread, other threads:[~2007-08-15  7:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-31 13:01 [PATCH] libata: Correct IORDY handling Alan Cox
2007-07-31 14:18 ` Sergei Shtylyov
2007-07-31 15:45   ` Alan Cox
2007-08-15  7:09 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).