linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ide: identify data word 53 bit 1 doesn't cover words 62 and 63 (take 2)
@ 2009-03-03 11:04 Sergei Shtylyov
  2009-03-07 16:05 ` Bartlomiej Zolnierkiewicz
  2009-03-10 12:52 ` Sergei Shtylyov
  0 siblings, 2 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2009-03-03 11:04 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-ide

The IDE code assumed for years that the bit 1 of the identify data word 53 also
covers the validity of the SW/MW DMA information in words 62 and 63, but it has
always covered only words 64 thru 70, with words 62 and 63 being defined in the
original ATA spec, not in ATA-2...

This fix however should only concern *very* old hard disks and rather old CF
cards...

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

---
This patch is against the recent Linus' tree...

 drivers/ide/ide-dma-sff.c |    7 +++----
 drivers/ide/ide-dma.c     |   32 ++++++++++++++------------------
 2 files changed, 17 insertions(+), 22 deletions(-)

Index: linux-2.6/drivers/ide/ide-dma-sff.c
===================================================================
--- linux-2.6.orig/drivers/ide/ide-dma-sff.c
+++ linux-2.6/drivers/ide/ide-dma-sff.c
@@ -38,10 +38,9 @@ int config_drive_for_dma(ide_drive_t *dr
 	 * Enable DMA on any drive that has mode2 DMA
 	 * (multi or single) enabled
 	 */
-	if (id[ATA_ID_FIELD_VALID] & 2)	/* regular DMA */
-		if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 ||
-		    (id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404)
-			return 1;
+	if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 ||
+	    (id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404)
+		return 1;
 
 	/* Consult the list of known "good" drives */
 	if (ide_dma_good_drive(drive))
Index: linux-2.6/drivers/ide/ide-dma.c
===================================================================
--- linux-2.6.orig/drivers/ide/ide-dma.c
+++ linux-2.6/drivers/ide/ide-dma.c
@@ -238,12 +238,11 @@ static unsigned int ide_get_mode_mask(id
 	case XFER_UDMA_0:
 		if ((id[ATA_ID_FIELD_VALID] & 4) == 0)
 			break;
-
+		mask = id[ATA_ID_UDMA_MODES];
 		if (port_ops && port_ops->udma_filter)
-			mask = port_ops->udma_filter(drive);
+			mask &= port_ops->udma_filter(drive);
 		else
-			mask = hwif->ultra_mask;
-		mask &= id[ATA_ID_UDMA_MODES];
+			mask &= hwif->ultra_mask;
 
 		/*
 		 * avoid false cable warning from eighty_ninty_three()
@@ -254,18 +253,15 @@ static unsigned int ide_get_mode_mask(id
 		}
 		break;
 	case XFER_MW_DMA_0:
-		if ((id[ATA_ID_FIELD_VALID] & 2) == 0)
-			break;
+		mask = id[ATA_ID_MWDMA_MODES];
 		if (port_ops && port_ops->mdma_filter)
-			mask = port_ops->mdma_filter(drive);
+			mask &= port_ops->mdma_filter(drive);
 		else
-			mask = hwif->mwdma_mask;
-		mask &= id[ATA_ID_MWDMA_MODES];
+			mask &= hwif->mwdma_mask;
 		break;
 	case XFER_SW_DMA_0:
-		if (id[ATA_ID_FIELD_VALID] & 2) {
-			mask = id[ATA_ID_SWDMA_MODES] & hwif->swdma_mask;
-		} else if (id[ATA_ID_OLD_DMA_MODES] >> 8) {
+		mask = id[ATA_ID_SWDMA_MODES];
+		if (!(mask & ATA_SWDMA2) && (id[ATA_ID_OLD_DMA_MODES] >> 8)) {
 			u8 mode = id[ATA_ID_OLD_DMA_MODES] >> 8;
 
 			/*
@@ -273,8 +269,9 @@ static unsigned int ide_get_mode_mask(id
 			 * (the maximum allowed mode is XFER_SW_DMA_2)
 			 */
 			if (mode <= 2)
-				mask = ((2 << mode) - 1) & hwif->swdma_mask;
+				mask = (2 << mode) - 1;
 		}
+		mask &= hwif->swdma_mask;
 		break;
 	default:
 		BUG();
@@ -391,11 +388,10 @@ int ide_id_dma_bug(ide_drive_t *drive)
 		if ((id[ATA_ID_UDMA_MODES] >> 8) &&
 		    (id[ATA_ID_MWDMA_MODES] >> 8))
 			goto err_out;
-	} else if (id[ATA_ID_FIELD_VALID] & 2) {
-		if ((id[ATA_ID_MWDMA_MODES] >> 8) &&
-		    (id[ATA_ID_SWDMA_MODES] >> 8))
-			goto err_out;
-	}
+	} else if ((id[ATA_ID_MWDMA_MODES] >> 8) &&
+		   (id[ATA_ID_SWDMA_MODES] >> 8))
+		goto err_out;
+
 	return 0;
 err_out:
 	printk(KERN_ERR "%s: bad DMA info in identify block\n", drive->name);


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

* Re: [PATCH] ide: identify data word 53 bit 1 doesn't cover words 62 and 63 (take 2)
  2009-03-03 11:04 [PATCH] ide: identify data word 53 bit 1 doesn't cover words 62 and 63 (take 2) Sergei Shtylyov
@ 2009-03-07 16:05 ` Bartlomiej Zolnierkiewicz
  2009-03-10 12:52 ` Sergei Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-03-07 16:05 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-ide

On Tuesday 03 March 2009, Sergei Shtylyov wrote:
> The IDE code assumed for years that the bit 1 of the identify data word 53 also
> covers the validity of the SW/MW DMA information in words 62 and 63, but it has
> always covered only words 64 thru 70, with words 62 and 63 being defined in the
> original ATA spec, not in ATA-2...
> 
> This fix however should only concern *very* old hard disks and rather old CF
> cards...
> 
> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

applied

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

* Re: [PATCH] ide: identify data word 53 bit 1 doesn't cover words 62 and 63 (take 2)
  2009-03-03 11:04 [PATCH] ide: identify data word 53 bit 1 doesn't cover words 62 and 63 (take 2) Sergei Shtylyov
  2009-03-07 16:05 ` Bartlomiej Zolnierkiewicz
@ 2009-03-10 12:52 ` Sergei Shtylyov
  1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2009-03-10 12:52 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-ide

Hello, I wrote:

> The IDE code assumed for years that the bit 1 of the identify data word 53 also
> covers the validity of the SW/MW DMA information in words 62 and 63, but it has
> always covered only words 64 thru 70, with words 62 and 63 being defined in the
> original ATA spec, not in ATA-2...

> This fix however should only concern *very* old hard disks and rather old CF
> cards...

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

    Looks like the patch is still incomplete, as I've only fixed the generic 
files, while two drivers also needed to be fixed... :-/

WBR, Sergei

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

end of thread, other threads:[~2009-03-10 12:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03 11:04 [PATCH] ide: identify data word 53 bit 1 doesn't cover words 62 and 63 (take 2) Sergei Shtylyov
2009-03-07 16:05 ` Bartlomiej Zolnierkiewicz
2009-03-10 12:52 ` Sergei Shtylyov

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).