Commit 021ee9a6da1cfc57f6a6c769c3c898bdd4753108
Committed by
Jeff Garzik
1 parent
a0f79b929a
Exists in
master
and in
7 other branches
libata: reimplement ata_acpi_cbl_80wire() using ata_acpi_gtm_xfermask()
Reimplement ata_acpi_cbl_80wire() using ata_acpi_gtm_xfermask() and while at it relocate the function below ata_acpi_gtm_xfermask(). New ata_acpi_cbl_80wire() implementation takes @gtm, in both pata_via and pata_amd, use the initial GTM value. Both are trying to peek initial BIOS configuration, so using initial caching value makes sense. This fixes ACPI part of cable detection in pata_amd which previously always returned 0 because configuring PIO0 during reset clears DMA configuration. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Showing 4 changed files with 27 additions and 30 deletions Side-by-side Diff
drivers/ata/libata-acpi.c
... | ... | @@ -490,38 +490,29 @@ |
490 | 490 | /** |
491 | 491 | * ata_acpi_cbl_80wire - Check for 80 wire cable |
492 | 492 | * @ap: Port to check |
493 | + * @gtm: GTM data to use | |
493 | 494 | * |
494 | - * Return 1 if the ACPI mode data for this port indicates the BIOS selected | |
495 | - * an 80wire mode. | |
495 | + * Return 1 if the @gtm indicates the BIOS selected an 80wire mode. | |
496 | 496 | */ |
497 | - | |
498 | -int ata_acpi_cbl_80wire(struct ata_port *ap) | |
497 | +int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm) | |
499 | 498 | { |
500 | - const struct ata_acpi_gtm *gtm = ata_acpi_init_gtm(ap); | |
501 | - int valid = 0; | |
499 | + struct ata_device *dev; | |
502 | 500 | |
503 | - if (!gtm) | |
504 | - return 0; | |
501 | + ata_link_for_each_dev(dev, &ap->link) { | |
502 | + unsigned long xfer_mask, udma_mask; | |
505 | 503 | |
506 | - /* Split timing, DMA enabled */ | |
507 | - if ((gtm->flags & 0x11) == 0x11 && gtm->drive[0].dma < 55) | |
508 | - valid |= 1; | |
509 | - if ((gtm->flags & 0x14) == 0x14 && gtm->drive[1].dma < 55) | |
510 | - valid |= 2; | |
511 | - /* Shared timing, DMA enabled */ | |
512 | - if ((gtm->flags & 0x11) == 0x01 && gtm->drive[0].dma < 55) | |
513 | - valid |= 1; | |
514 | - if ((gtm->flags & 0x14) == 0x04 && gtm->drive[0].dma < 55) | |
515 | - valid |= 2; | |
504 | + if (!ata_dev_enabled(dev)) | |
505 | + continue; | |
516 | 506 | |
517 | - /* Drive check */ | |
518 | - if ((valid & 1) && ata_dev_enabled(&ap->link.device[0])) | |
519 | - return 1; | |
520 | - if ((valid & 2) && ata_dev_enabled(&ap->link.device[1])) | |
521 | - return 1; | |
507 | + xfer_mask = ata_acpi_gtm_xfermask(dev, gtm); | |
508 | + ata_unpack_xfermask(xfer_mask, NULL, NULL, &udma_mask); | |
509 | + | |
510 | + if (udma_mask & ~ATA_UDMA_MASK_40C) | |
511 | + return 1; | |
512 | + } | |
513 | + | |
522 | 514 | return 0; |
523 | 515 | } |
524 | - | |
525 | 516 | EXPORT_SYMBOL_GPL(ata_acpi_cbl_80wire); |
526 | 517 | |
527 | 518 | static void ata_acpi_gtf_to_tf(struct ata_device *dev, |
drivers/ata/pata_amd.c
... | ... | @@ -272,7 +272,8 @@ |
272 | 272 | if ((udma & 0xC4) == 0xC4 || (udma & 0xC400) == 0xC400) |
273 | 273 | cbl = ATA_CBL_PATA80; |
274 | 274 | /* And a triple check across suspend/resume with ACPI around */ |
275 | - if (ata_acpi_cbl_80wire(ap)) | |
275 | + if (ata_acpi_init_gtm(ap) && | |
276 | + ata_acpi_cbl_80wire(ap, ata_acpi_init_gtm(ap))) | |
276 | 277 | cbl = ATA_CBL_PATA80; |
277 | 278 | return cbl; |
278 | 279 | } |
drivers/ata/pata_via.c
... | ... | @@ -185,7 +185,8 @@ |
185 | 185 | if (ata66 & (0x10100000 >> (16 * ap->port_no))) |
186 | 186 | return ATA_CBL_PATA80; |
187 | 187 | /* Check with ACPI so we can spot BIOS reported SATA bridges */ |
188 | - if (ata_acpi_cbl_80wire(ap)) | |
188 | + if (ata_acpi_init_gtm(ap) && | |
189 | + ata_acpi_cbl_80wire(ap, ata_acpi_init_gtm(ap))) | |
189 | 190 | return ATA_CBL_PATA80; |
190 | 191 | return ATA_CBL_PATA40; |
191 | 192 | } |
include/linux/libata.h
... | ... | @@ -968,18 +968,16 @@ |
968 | 968 | return &ap->__acpi_init_gtm; |
969 | 969 | return NULL; |
970 | 970 | } |
971 | -extern int ata_acpi_cbl_80wire(struct ata_port *ap); | |
972 | 971 | int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm); |
973 | 972 | int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); |
974 | 973 | unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, |
975 | 974 | const struct ata_acpi_gtm *gtm); |
976 | - | |
975 | +int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm); | |
977 | 976 | #else |
978 | 977 | static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) |
979 | 978 | { |
980 | 979 | return NULL; |
981 | 980 | } |
982 | -static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } | |
983 | 981 | |
984 | 982 | static inline int ata_acpi_stm(const struct ata_port *ap, |
985 | 983 | struct ata_acpi_gtm *stm) |
... | ... | @@ -995,6 +993,12 @@ |
995 | 993 | |
996 | 994 | static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev, |
997 | 995 | const struct ata_acpi_gtm *gtm) |
996 | +{ | |
997 | + return 0; | |
998 | +} | |
999 | + | |
1000 | +static inline int ata_acpi_cbl_80wire(struct ata_port *ap, | |
1001 | + const struct ata_acpi_gtm *gtm) | |
998 | 1002 | { |
999 | 1003 | return 0; |
1000 | 1004 | } |