diff options
author | Alan Cox <alan@redhat.com> | 2008-08-01 04:18:34 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-08-22 02:27:49 -0400 |
commit | b15b3ebae102f89c25ccbcae0b2099af312f2e82 (patch) | |
tree | 73f64d0e578d1c6bc6a3dc43f940a31f24daad8f /include | |
parent | 20e2de4a505aa02131a95665e8920eb053fce686 (diff) |
libata: Fix a large collection of DMA mode mismatches
Dave Müller sent a diff for the pata_oldpiix that highlighted a problem
where a lot of the ATA drivers assume dma_mode == 0 means "no DMA" while
the core code uses 0xFF.
This turns out to have other consequences such as code doing >= XFER_UDMA_0
also catching 0xFF as UDMAlots. Fortunately it doesn't generally affect
set_dma_mode, although some drivers call back into their own set mode code
from other points.
Having been through the drivers I've added helpers for using_udma/using_mwdma
dma_enabled so that people don't open code ranges that may change (eg if UDMA8
appears somewhere)
Thanks to David for the initial bits
[and added fix for pata_oldpiix from and signed-off-by Dave Mueller
<dave.mueller@gmx.ch> -jg]
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/libata.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index 80233fdc159f..225bfc5bd9ec 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -1429,6 +1429,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies, | |||
1429 | return from_jiffies + msecs_to_jiffies(timeout_msecs); | 1429 | return from_jiffies + msecs_to_jiffies(timeout_msecs); |
1430 | } | 1430 | } |
1431 | 1431 | ||
1432 | /* Don't open code these in drivers as there are traps. Firstly the range may | ||
1433 | change in future hardware and specs, secondly 0xFF means 'no DMA' but is | ||
1434 | > UDMA_0. Dyma ddreigiau */ | ||
1435 | |||
1436 | static inline int ata_using_mwdma(struct ata_device *adev) | ||
1437 | { | ||
1438 | if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4) | ||
1439 | return 1; | ||
1440 | return 0; | ||
1441 | } | ||
1442 | |||
1443 | static inline int ata_using_udma(struct ata_device *adev) | ||
1444 | { | ||
1445 | if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7) | ||
1446 | return 1; | ||
1447 | return 0; | ||
1448 | } | ||
1449 | |||
1450 | static inline int ata_dma_enabled(struct ata_device *adev) | ||
1451 | { | ||
1452 | return (adev->dma_mode == 0xFF ? 0 : 1); | ||
1453 | } | ||
1432 | 1454 | ||
1433 | /************************************************************************** | 1455 | /************************************************************************** |
1434 | * PMP - drivers/ata/libata-pmp.c | 1456 | * PMP - drivers/ata/libata-pmp.c |