Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Darren Stevens <darren@stevens-zone.net>
To: linux-ide@vger.kernel.org
Subject: [PATCH v2] libata-sff: Don't scan disabled ports when checking for legacy mode.
Date: Sun, 22 Jan 2017 19:34:30 +0000 (GMT)	[thread overview]
Message-ID: <4978ca2860b.2931a5b8@auth.smtp.1and1.co.uk> (raw)

[-- 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;
 	}

             reply	other threads:[~2017-01-22 19:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 19:34 Darren Stevens [this message]
2017-01-23 19:41 ` [PATCH v2] libata-sff: Don't scan disabled ports when checking for legacy mode 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=4978ca2860b.2931a5b8@auth.smtp.1and1.co.uk \
    --to=darren@stevens-zone.net \
    --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