[PATCH 3/4] ide: make ide_rate_filter() also respect PIO and SW/MW DMA mode masks

[PATCH 3/4] ide: make ide_rate_filter() also respect PIO and SW/MW DMA mode masks

Post by Sergei Sht » Tue, 04 Sep 2007 04:10:07


ake ide_rate_filter() also respect PIO/SWDMA/MWDMA mode masks. While at it,
make the udma_filter() method calls take precedence over using the mode masks.

---
This version doesn't use explicit UltraDMA masks, so converting them to the
ATA_UDMA* is left for another, global patch. This patch against the current
Linus' tree and unfortunately I was able to only compile test it since that
tree gives MODPOST warning and dies early on bootup.

drivers/ide/ide-dma.c | 7 +++--
drivers/ide/ide-lib.c | 65 +++++++++++++++++++++++++++++++++-----------------
2 files changed, 47 insertions(+), 25 deletions(-)

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
@@ -664,10 +664,11 @@ static unsigned int ide_get_mode_mask(id
if ((id->field_valid & 4) == 0)
break;

- mask = id->dma_ultra & hwif->ultra_mask;
-
if (hwif->udma_filter)
- mask &= hwif->udma_filter(drive);
+ mask = hwif->udma_filter(drive);
+ else
+ mask = hwif->ultra_mask;
+ mask &= id->dma_ultra;

if ((mask & 0x78) && (eighty_ninty_three(drive) == 0))
mask &= 0x07;
Index: linux-2.6/drivers/ide/ide-lib.c
===================================================================
--- linux-2.6.orig/drivers/ide/ide-lib.c
+++ linux-2.6/drivers/ide/ide-lib.c
@@ -75,38 +75,59 @@ EXPORT_SYMBOL(ide_xfer_verbose);
*
* Given the available transfer modes this function returns
* the best available speed at or below the speed requested.
- *
- * FIXME: filter also PIO/SWDMA/MWDMA modes
*/

u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
{
-#ifdef CONFIG_BLK_DEV_IDEDMA
ide_hwif_t *hwif = drive->hwif;
- u8 mask = hwif->ultra_mask, mode = XFER_MW_DMA_2;
+ u8 mask, base = XFER_UDMA_0;

- if (hwif->udma_filter)
- mask = hwif->udma_filter(drive);
+ switch (speed & 0xf8) {
+#ifdef CONFIG_BLK_DEV_IDEDMA
+ case XFER_UDMA_0:
+ mask = hwif->udma_filter ? hwif->udma_filter(drive) :
+ hwif->ultra_mask;

- /*
- * TODO: speed > XFER_UDMA_2 extra check is needed to avoid false
- * cable warning from eighty_ninty_three(), moving ide_rate_filter()
- * calls from ->speedproc to core code will make this hack go away
- */
- if (speed > XFER_UDMA_2) {
- if ((mask & 0x78) && (eighty_ninty_three(drive) == 0))
+ /*
+ * TODO: if speed > XFER_UDMA_2, an extra check is needed to
+ * avoid a false cable warning from eighty_ninty_three() --
+ * moving ide_rate_filter() calls from ->speedproc to core
+ * code will make this hack go away...
+ */
+ if (speed > XFER_UDMA_2 && (mask & 0x78) &&
+ eighty_ninty_three(drive) == 0)
mask &= 0x07;
- }
-
- if (mask)
- mode = fls(mask) - 1 + XFER_UDMA_0;

-// printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed);
-
- return min(speed, mode);
-#else /* !CONFIG_BLK_DEV_IDEDMA */
- return min(speed, (u8)XFER_PIO_4);
+ if (mask) {
+ base = XFER_UDMA_0;
+ break;
+ }
+ /* Fall thru */
+ case XFER_MW_DMA_0:
+ if (hwif->mwdma_mask) {
+ mask = hwif->mwdma_mask;
+ base = XFER_MW_DMA_0;
+ break;
+ }
+ /* Fall thru */
+ case XFER_SW_DMA_0:
+ if (hwif->swdma_mask) {
+ mask = hwif->swdma_mask;
+ base = XFER_SW_DMA_0;
+ break;
+ }
+ /* Fall thru */
#endif /* CONFIG_BLK_DEV_IDEDMA */
+
 
 
 

1. Primary/secondary IDE drives: PIO mode DMA mode

2. IDE DMA/PIO mode problem, see KB 817472


Hello Group, I seem to have the problem described in
the aforementioned KB article. I was imaging a cracked cd
to try and recover the data(it worked BTW :)), and after
that it stuck in PIO mode. If anyone can tell me
specifically how to get the hotfix it would be
appreciated, as it seems to have not shown up in SP4 yet
and they don't have a downoad link. :( Its kind of
irritating only being able to burn at 6X even though I
have a 16X burner. I've already un and re-installed the
IDE contorllers and the ASPI driver, so the only thing
left is the hotfix. Many thanks in advance for anyone who
can help on this, please reply to group and e-mail.


I think this is the right group to post to, maybe not, if
its not someone please advise me which one is. :)

http://www.yqcomputer.com/ ;en-
us;817472

73, DE Josh Sponenberg, KB3GUF

3. Dma mode has reverted to Pio mode..Please Help...:o)

4. hard drives revert to PIO mode instead of DMA mode 5

5. dma mode vs. pio mode

6. Changing DVD Burner from PIO Mode to DMA Mode

7. Enable DMA mode on my Hard Drive, currently set as PIO Mode

8. IDE ATA/ATAPT -the primary IDE channel is stuck on PIO mode

9. [PATCH] ide-dma.c, ide.c, ide.h, kernel 2.4.24

10. DMA mapping (was [PATCH] cciss 2.6; replaces DMA masks with kernel defines)

11. DMA mapping (was [PATCH] cciss 2.6; replaces DMA masks with kernel defines)

12. DMA mapping (was [PATCH] cciss 2.6; replaces DMA masks with kernel defines)

13. DMA mapping (was [PATCH] cciss 2.6; replaces DMA masks with kernel defines)

14. Solved/Kinda: IDE Hard disk reverts from DMA to PIO, many thanks folks

15. IDE Hard disk reverts from DMA to PIO