* [PATCH v2] libata-sff: Don't scan disabled ports when checking for legacy mode.
@ 2017-01-22 19:34 Darren Stevens
2017-01-23 19:41 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Darren Stevens @ 2017-01-22 19:34 UTC (permalink / raw)
To: linux-ide
[-- Attachment #1: Type: text/plain, Size: 178 bytes --]
AmigaOS...........: http://yam.ch/
Unix/MacOS/Windows: http://www.mozilla.com/thunderbird/
General information about MIME can be found at:
http://en.wikipedia.org/wiki/MIME
[-- Attachment #2: Type: text/plain, Size: 549 bytes --]
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 southbridge 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'
Signed-off-by: Darren Stevens <darren@stevens-zone.net>
---
v2: Changed to using 2 if statements instead of binary logic
[-- Attachment #3: libata.patch --]
[-- Type: text/plain, Size: 992 bytes --]
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 051b615..09bed5d 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -2427,11 +2427,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[1]))
+ mask = mask | (1 << 2);
+ if (! ata_port_is_dummy(host->ports[0]))
+ mask = mask | (1 << 0);
if ((tmp8 & mask) != mask)
legacy_mode = 1;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] libata-sff: Don't scan disabled ports when checking for legacy mode.
2017-01-22 19:34 [PATCH v2] libata-sff: Don't scan disabled ports when checking for legacy mode Darren Stevens
@ 2017-01-23 19:41 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2017-01-23 19:41 UTC (permalink / raw)
To: Darren Stevens; +Cc: linux-ide, Sergei Shtylyov
Hello,
I did some minor edits and applied the following to libata/for-4.11.
When you're attaching the patch next time, please attach the whole
output of git-format-patch; otherwise, I have to stitch them back
together.
Thanks.
------ 8< ------
>From 589d572671fe7ca342d25cde07a0e310a6912971 Mon Sep 17 00:00:00 2001
From: Darren Stevens <darren@stevens-zone.net>
Date: Mon, 23 Jan 2017 14:33:36 -0500
Subject: [PATCH] libata-sff: Don't scan disabled ports when checking for
legacy mode.
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 | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 4441b5c..2bd92dc 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -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;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-23 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-22 19:34 [PATCH v2] libata-sff: Don't scan disabled ports when checking for legacy mode Darren Stevens
2017-01-23 19:41 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox