]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
libata-sff: Don't scan disabled ports when checking for legacy mode.
authorDarren Stevens <darren@stevens-zone.net>
Mon, 23 Jan 2017 19:33:36 +0000 (14:33 -0500)
committerTejun Heo <tj@kernel.org>
Mon, 23 Jan 2017 19:35:17 +0000 (14:35 -0500)
libata-sff.c checks for legacy mode by testing if both primary and
secondary ports on a controller are in legacy mode and selects legacy
if either one is. However on some south bridge chips (e.g AMD
SB600/SB700) the secondary port is not wired, and when it is disabled
by setting the disable bit in the PCI header it appears as a fixed
legacy port.

Prevent incorrect detection by not testing ports that are marked as
'dummy'

tj: Addressed Sergei's review points.  Other style edits.

Signed-off-by: Darren Stevens <darren@stevens-zone.net>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
drivers/ata/libata-sff.c

index 4441b5c5e4fbf16637f72f54ef0e44ad28c855fc..2bd92dca3e6204027f6c1b5fb07ba519cbe039fa 100644 (file)
@@ -2428,11 +2428,21 @@ int ata_pci_sff_activate_host(struct ata_host *host,
                return rc;
 
        if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
-               u8 tmp8, mask;
+               u8 tmp8, mask = 0;
 
-               /* TODO: What if one channel is in native mode ... */
+               /*
+                * ATA spec says we should use legacy mode when one
+                * port is in legacy mode, but disabled ports on some
+                * PCI hosts appear as fixed legacy ports, e.g SB600/700
+                * on which the secondary port is not wired, so
+                * ignore ports that are marked as 'dummy' during
+                * this check
+                */
                pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
-               mask = (1 << 2) | (1 << 0);
+               if (!ata_port_is_dummy(host->ports[0]))
+                       mask |= (1 << 0);
+               if (!ata_port_is_dummy(host->ports[1]))
+                       mask |= (1 << 2);
                if ((tmp8 & mask) != mask)
                        legacy_mode = 1;
        }