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 /drivers | |
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 'drivers')
-rw-r--r-- | drivers/ata/libata-core.c | 4 | ||||
-rw-r--r-- | drivers/ata/pata_acpi.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_atiixp.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_cs5530.c | 6 | ||||
-rw-r--r-- | drivers/ata/pata_oldpiix.c | 2 | ||||
-rw-r--r-- | drivers/ata/pata_sc1200.c | 6 |
6 files changed, 11 insertions, 11 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 5f8f57a818fb..79e3a8e7a84a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -3288,7 +3288,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
3288 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); | 3288 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); |
3289 | 3289 | ||
3290 | found = 1; | 3290 | found = 1; |
3291 | if (dev->dma_mode != 0xff) | 3291 | if (ata_dma_enabled(dev)) |
3292 | used_dma = 1; | 3292 | used_dma = 1; |
3293 | } | 3293 | } |
3294 | if (!found) | 3294 | if (!found) |
@@ -3313,7 +3313,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
3313 | 3313 | ||
3314 | /* step 3: set host DMA timings */ | 3314 | /* step 3: set host DMA timings */ |
3315 | ata_link_for_each_dev(dev, link) { | 3315 | ata_link_for_each_dev(dev, link) { |
3316 | if (!ata_dev_enabled(dev) || dev->dma_mode == 0xff) | 3316 | if (!ata_dev_enabled(dev) || !ata_dma_enabled(dev)) |
3317 | continue; | 3317 | continue; |
3318 | 3318 | ||
3319 | dev->xfer_mode = dev->dma_mode; | 3319 | dev->xfer_mode = dev->dma_mode; |
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c index fbe605711554..eb919c16a03e 100644 --- a/drivers/ata/pata_acpi.c +++ b/drivers/ata/pata_acpi.c | |||
@@ -181,7 +181,7 @@ static unsigned int pacpi_qc_issue(struct ata_queued_cmd *qc) | |||
181 | 181 | ||
182 | if (adev != acpi->last) { | 182 | if (adev != acpi->last) { |
183 | pacpi_set_piomode(ap, adev); | 183 | pacpi_set_piomode(ap, adev); |
184 | if (adev->dma_mode) | 184 | if (ata_dma_enabled(adev)) |
185 | pacpi_set_dmamode(ap, adev); | 185 | pacpi_set_dmamode(ap, adev); |
186 | acpi->last = adev; | 186 | acpi->last = adev; |
187 | } | 187 | } |
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index d7de7baf58a8..e8a0d99d7356 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c | |||
@@ -183,7 +183,7 @@ static void atiixp_bmdma_start(struct ata_queued_cmd *qc) | |||
183 | u16 tmp16; | 183 | u16 tmp16; |
184 | 184 | ||
185 | pci_read_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, &tmp16); | 185 | pci_read_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, &tmp16); |
186 | if (adev->dma_mode >= XFER_UDMA_0) | 186 | if (ata_using_udma(adev)) |
187 | tmp16 |= (1 << dn); | 187 | tmp16 |= (1 << dn); |
188 | else | 188 | else |
189 | tmp16 &= ~(1 << dn); | 189 | tmp16 &= ~(1 << dn); |
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 744beebaaf49..0c4b271a9d5a 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c | |||
@@ -149,10 +149,10 @@ static unsigned int cs5530_qc_issue(struct ata_queued_cmd *qc) | |||
149 | struct ata_device *prev = ap->private_data; | 149 | struct ata_device *prev = ap->private_data; |
150 | 150 | ||
151 | /* See if the DMA settings could be wrong */ | 151 | /* See if the DMA settings could be wrong */ |
152 | if (adev->dma_mode != 0 && adev != prev && prev != NULL) { | 152 | if (ata_dma_enabled(adev) && adev != prev && prev != NULL) { |
153 | /* Maybe, but do the channels match MWDMA/UDMA ? */ | 153 | /* Maybe, but do the channels match MWDMA/UDMA ? */ |
154 | if ((adev->dma_mode >= XFER_UDMA_0 && prev->dma_mode < XFER_UDMA_0) || | 154 | if ((ata_using_udma(adev) && !ata_using_udma(prev)) || |
155 | (adev->dma_mode < XFER_UDMA_0 && prev->dma_mode >= XFER_UDMA_0)) | 155 | (ata_using_udma(prev) && !ata_using_udma(adev))) |
156 | /* Switch the mode bits */ | 156 | /* Switch the mode bits */ |
157 | cs5530_set_dmamode(ap, adev); | 157 | cs5530_set_dmamode(ap, adev); |
158 | } | 158 | } |
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index e678af383d13..df64f2443001 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c | |||
@@ -198,7 +198,7 @@ static unsigned int oldpiix_qc_issue(struct ata_queued_cmd *qc) | |||
198 | 198 | ||
199 | if (adev != ap->private_data) { | 199 | if (adev != ap->private_data) { |
200 | oldpiix_set_piomode(ap, adev); | 200 | oldpiix_set_piomode(ap, adev); |
201 | if (adev->dma_mode) | 201 | if (ata_dma_enabled(adev)) |
202 | oldpiix_set_dmamode(ap, adev); | 202 | oldpiix_set_dmamode(ap, adev); |
203 | } | 203 | } |
204 | return ata_sff_qc_issue(qc); | 204 | return ata_sff_qc_issue(qc); |
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c index cbab397e3db7..0278fd2b8fb1 100644 --- a/drivers/ata/pata_sc1200.c +++ b/drivers/ata/pata_sc1200.c | |||
@@ -167,10 +167,10 @@ static unsigned int sc1200_qc_issue(struct ata_queued_cmd *qc) | |||
167 | struct ata_device *prev = ap->private_data; | 167 | struct ata_device *prev = ap->private_data; |
168 | 168 | ||
169 | /* See if the DMA settings could be wrong */ | 169 | /* See if the DMA settings could be wrong */ |
170 | if (adev->dma_mode != 0 && adev != prev && prev != NULL) { | 170 | if (ata_dma_enabled(adev) && adev != prev && prev != NULL) { |
171 | /* Maybe, but do the channels match MWDMA/UDMA ? */ | 171 | /* Maybe, but do the channels match MWDMA/UDMA ? */ |
172 | if ((adev->dma_mode >= XFER_UDMA_0 && prev->dma_mode < XFER_UDMA_0) || | 172 | if ((ata_using_udma(adev) && !ata_using_udma(prev)) || |
173 | (adev->dma_mode < XFER_UDMA_0 && prev->dma_mode >= XFER_UDMA_0)) | 173 | (ata_using_udma(prev) && !ata_using_udma(adev))) |
174 | /* Switch the mode bits */ | 174 | /* Switch the mode bits */ |
175 | sc1200_set_dmamode(ap, adev); | 175 | sc1200_set_dmamode(ap, adev); |
176 | } | 176 | } |