From: Tejun Heo <htejun@gmail.com>
To: jeff@garzik.org, linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: [PATCH 07/12] libata: fix ata_acpi_gtm_xfermask()
Date: Tue, 6 Nov 2007 14:39:05 +0900 [thread overview]
Message-ID: <1194327551238-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <1194327550227-git-send-email-htejun@gmail.com>
ata_acpi_gtm_xfermask() as separated out from pacpi_discover_modes()
has various bugs. Fix them.
* The wrong comparison operator is used when finding for matching
cycle resulting totally bogus result.
* With the comparion operator fixed, boundary condtion handling is
clumsy.
* Setting of any DMA mask bit set all bits in PIO mask.
* MWDMA and UDMA blocks are swapped.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
---
drivers/ata/libata-acpi.c | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 5ffa542..06d9961 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -456,49 +456,49 @@ EXPORT_SYMBOL_GPL(ata_acpi_udma_cycle);
unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev,
const struct ata_acpi_gtm *gtm)
{
+ unsigned int pio_mask = 0, mwdma_mask = 0, udma_mask = 0;
int unit, i;
u32 t;
- unsigned long mask = (0x7f << ATA_SHIFT_UDMA) | (0x7 << ATA_SHIFT_MWDMA) | (0x1F << ATA_SHIFT_PIO);
/* we always use the 0 slot for crap hardware */
unit = dev->devno;
if (!(gtm->flags & 0x10))
unit = 0;
+ /* Values larger than the longest cycle results in 0 mask
+ * while values equal to smaller than the shortest cycle
+ * results in mask which includes all supported modes.
+ * Disabled transfer method has the value of 0xffffffff which
+ * will always result in 0 mask.
+ */
+
/* start by scanning for PIO modes */
- for (i = 0; i < 7; i++) {
- t = gtm->drive[unit].pio;
- if (t <= ata_acpi_pio_cycle[i]) {
- mask |= (2 << (ATA_SHIFT_PIO + i)) - 1;
+ t = gtm->drive[unit].pio;
+ for (i = 0; i < ARRAY_SIZE(ata_acpi_pio_cycle); i++)
+ if (t > ata_acpi_pio_cycle[i])
break;
- }
- }
+ pio_mask = (1 << i) - 1;
/* See if we have MWDMA or UDMA data. We don't bother with
* MWDMA if UDMA is available as this means the BIOS set UDMA
* and our error changedown if it works is UDMA to PIO anyway.
*/
- if (gtm->flags & (1 << (2 * unit))) {
+ t = gtm->drive[unit].dma;
+ if (!(gtm->flags & (1 << (2 * unit)))) {
/* MWDMA */
- for (i = 0; i < 5; i++) {
- t = gtm->drive[unit].dma;
- if (t <= ata_acpi_mwdma_cycle[i]) {
- mask |= (2 << (ATA_SHIFT_MWDMA + i)) - 1;
+ for (i = 0; i < ARRAY_SIZE(ata_acpi_mwdma_cycle); i++)
+ if (t > ata_acpi_mwdma_cycle[i])
break;
- }
- }
+ mwdma_mask = (1 << i) - 1;
} else {
/* UDMA */
- for (i = 0; i < 7; i++) {
- t = gtm->drive[unit].dma;
- if (t <= ata_acpi_udma_cycle[i]) {
- mask |= (2 << (ATA_SHIFT_UDMA + i)) - 1;
+ for (i = 0; i < ARRAY_SIZE(ata_acpi_udma_cycle); i++)
+ if (t > ata_acpi_udma_cycle[i])
break;
- }
- }
+ udma_mask = (1 << i) - 1;
}
- return mask;
+ return ata_pack_xfermask(pio_mask, mwdma_mask, udma_mask);
}
EXPORT_SYMBOL_GPL(ata_acpi_gtm_xfermask);
--
1.5.2.4
next prev parent reply other threads:[~2007-11-06 5:39 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-06 5:38 [PATCHSET] libata: update timing and fix pata_amd transfer mode selection Tejun Heo
2007-11-06 5:38 ` [PATCH 01/12] ata_generic: unindent loop in generic_set_mode() Tejun Heo
2007-11-06 5:39 ` [PATCH 02/12] libata: export xfermode / PATA timing related functions Tejun Heo
2007-11-06 5:39 ` [PATCH 03/12] libata: clean up xfermode / PATA timing related stuff Tejun Heo
2007-11-06 5:39 ` [PATCH 04/12] libata: kill ata_id_to_dma_mode() Tejun Heo
2007-11-06 10:49 ` Alan Cox
2007-11-06 11:21 ` Tejun Heo
2007-11-24 1:13 ` Jeff Garzik
2007-11-06 5:39 ` [PATCH 05/12] libata: xfer_mask is unsigned int not unsigned long Tejun Heo
2007-11-06 10:51 ` Alan Cox
2007-11-06 10:59 ` Tejun Heo
2007-11-06 17:53 ` Jeff Garzik
2007-11-07 1:12 ` Tejun Heo
2007-11-24 1:13 ` Jeff Garzik
2007-11-24 1:13 ` Jeff Garzik
2007-11-27 8:42 ` Tejun Heo
2007-11-06 5:39 ` [PATCH 06/12] libata: separate out ata_acpi_gtm_xfermask() from pacpi_discover_modes() Tejun Heo
2007-11-06 10:54 ` Alan Cox
2007-11-06 11:00 ` Tejun Heo
2007-11-24 1:14 ` Jeff Garzik
2007-11-06 5:39 ` Tejun Heo [this message]
2007-11-06 10:55 ` [PATCH 07/12] libata: fix ata_acpi_gtm_xfermask() Alan Cox
2007-11-24 1:16 ` Jeff Garzik
2007-11-27 8:40 ` Tejun Heo
2007-11-06 5:39 ` [PATCH 08/12] libata: implement ata_timing_cycle2mode() and use it in libata-acpi and pata_acpi Tejun Heo
2007-11-06 10:59 ` Alan Cox
2007-11-06 11:09 ` Tejun Heo
2007-11-24 1:17 ` Jeff Garzik
2007-11-06 5:39 ` [PATCH 09/12] libata: implement ata_acpi_init_gtm() Tejun Heo
2007-11-06 5:39 ` [PATCH 10/12] libata: reimplement ata_acpi_cbl_80wire() using ata_acpi_gtm_xfermask() Tejun Heo
2007-11-06 5:39 ` [PATCH 11/12] libata: add ATA_CBL_PATA_IGN Tejun Heo
2007-11-06 10:59 ` Alan Cox
2007-11-06 11:02 ` Tejun Heo
2007-11-06 11:25 ` Alan Cox
2007-11-06 5:39 ` [PATCH 12/12] pata_amd: update mode selection for NV PATAs Tejun Heo
2007-11-06 10:59 ` Alan Cox
2007-11-23 1:08 ` [PATCHSET] libata: update timing and fix pata_amd transfer mode selection Tejun Heo
2007-11-24 1:18 ` Jeff Garzik
-- strict thread matches above, loose matches on Subject: below --
2007-11-27 10:43 [PATCHSET] libata: improve timing code and fix pata_amd transfer mode selection, take #2 Tejun Heo
2007-11-27 10:43 ` [PATCH 07/12] libata: fix ata_acpi_gtm_xfermask() Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1194327551238-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jeff@garzik.org \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).