Skip to contentSkip to conversation

ide-dma: fix ide_build_dmatable() for TRM290

PATCH Applied Sergei Shtylylov 2 participants 6 messages Sep 28, 2008 – Oct 16, 2008 libata

lore
Share & tools
lore
#0 lore raw

Apparently, 'xcount' being 0 does not mean 0 bytes for TRM290; it means 4 bytes, judging from the code immediately preceding this check. So, we must never try to "split" the PRD for TRM290.

This is probably never hit anyway -- with the DMA buffers aligned to at least 512 bytes and ATAPI DMA not being used for non block I/O commands...

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

 drivers/ide/ide-dma.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-dma.c +1 -1
Index: linux-2.6/drivers/ide/ide-dma.c
===================================================================
@@ -211,7 +211,7 @@ int ide_build_dmatable (ide_drive_t *dri
 				xcount = bcount & 0xffff;
 				if (is_trm290)
 					xcount = ((xcount >> 2) - 1) << 16;
-				if (xcount == 0x0000) {
+				else if (xcount == 0x0000) {
 	/* 
 	 * Most chipsets correctly interpret a length of 0x0000 as 64KB,
 	 * but at least one (e.g. CS5530) misinterprets it as zero (!).
#1 lore raw
Quoted 8 lines · Sergei Shtylylov

Apparently, 'xcount' being 0 does not mean 0 bytes for TRM290; it means 4 bytes, judging from the code immediately preceding this check. So, we must never try to "split" the PRD for TRM290.

This is probably never hit anyway -- with the DMA buffers aligned to at least 512 bytes and ATAPI DMA not being used for non block I/O commands...

applied, thanks

#2 lore raw
In reply to Sergei Shtylylov
Quoted 9 lines · Hello, I wrote:

Apparently, 'xcount' being 0 does not mean 0 bytes for TRM290; it means 4 bytes, judging from the code immediately preceding this check. So, we must never try to "split" the PRD for TRM290.

This is probably never hit anyway -- with the DMA buffers aligned to at least 512 bytes and ATAPI DMA not being used for non block I/O commands...

Bart, unfortunately, drivers/ide/ide-dma-sff.c has the same mistake
-- you probably forgot to modify the patch splitting it from ide-dma.c... :-/

MBR, Sergei

#3 lore raw
Quoted 6 lines · Hello, I wrote:
Quoted 6 lines

Apparently, 'xcount' being 0 does not mean 0 bytes for TRM290; it means 4 bytes, judging from the code immediately preceding this check. So, we must never try to "split" the PRD for TRM290.

This is probably never hit anyway -- with the DMA buffers aligned to at least 512 bytes and ATAPI DMA not being used for non block I/O commands...

Quoted 6 lines
Quoted 2 lines

Bart, unfortunately, drivers/ide/ide-dma-sff.c has the same mistake
-- you probably forgot to modify the patch splitting it from ide-dma.c... :-/

Even the one cleaning up ide_build_dmatable() actually...

MBR, Sergei

#4 lore raw
Quoted 11 lines · Sergei Shtylyov
Quoted 9 lines · Hello, I wrote:
Quoted 9 lines

Apparently, 'xcount' being 0 does not mean 0 bytes for TRM290; it means 4 bytes, judging from the code immediately preceding this check. So, we must never try
to "split" the PRD for TRM290.

This is probably never hit anyway -- with the DMA buffers aligned to at least
512 bytes and ATAPI DMA not being used for non block I/O commands...

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Bart, unfortunately, drivers/ide/ide-dma-sff.c has the same mistake
-- you probably forgot to modify the patch splitting it from ide-dma.c... :-/

Even the one cleaning up ide_build_dmatable() actually...

Thanks for noticing and sorry for that.

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: re-add TRM290 fix lost during ide_build_dmatable() cleanup

commit 14c123f37187aba0b4e0e893a969efc6820c4170 ("ide: cleanup ide_build_dmatable()") accidentally reverted TRM290 fix introduced by commit 22e05b4549bf2405d6aca128540b20cd2dd33f1f ("ide-dma: fix ide_build_dmatable() for TRM290").

---
 drivers/ide/ide-dma-sff.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-dma-sff.c +1 -1
Index: b/drivers/ide/ide-dma-sff.c
===================================================================
@@ -130,7 +130,7 @@ int ide_build_dmatable(ide_drive_t *driv
 			xcount = bcount & 0xffff;
 			if (is_trm290)
 				xcount = ((xcount >> 2) - 1) << 16;
-			if (xcount == 0x0000) {
+			else if (xcount == 0x0000) {
 				if (count++ >= PRD_ENTRIES)
 					goto use_pio_instead;
 				*table++ = cpu_to_le32(0x8000);
author Acked-by
#5 lore raw

Hello.

Quoted 2 lines · Bartlomiej Zolnierkiewicz

Thanks for noticing and sorry for that.

Not that it was an important patch... :-)

Quoted 11 lines

From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] ide: re-add TRM290 fix lost during ide_build_dmatable() cleanup

commit 14c123f37187aba0b4e0e893a969efc6820c4170 ("ide: cleanup ide_build_dmatable()") accidentally reverted TRM290 fix introduced by commit 22e05b4549bf2405d6aca128540b20cd2dd33f1f ("ide-dma: fix ide_build_dmatable() for TRM290").

WBR, Sergei