From: Yuan-Hsin Chen <yuanlmm@gmail.com>
To: jgarzik@pobox.com
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuan-Hsin Chen <yhchen@faraday-tech.com>
Subject: [PATCH] ahci: enable pmp but connected to HDD issue fixed
Date: Tue, 14 Jun 2011 13:48:24 +0800 [thread overview]
Message-ID: <1308030504-3026-1-git-send-email-yuanlmm@gmail.com> (raw)
From: Yuan-Hsin Chen <yhchen@faraday-tech.com>
When enabling both port multiplier and platform ahci sata, ahci
times out while connecting to HDD directly. This is because soft
reset fails with IPMS set. Do soft reset again to port 0.
The soft reset sequence is copied from ahci.c.
Signed-off-by: Yuan-Hsin Chen <yhchen@faraday-tech.com>
---
drivers/ata/ahci_platform.c | 62 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 61 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 6fef1fa..6eab716 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -27,6 +27,66 @@ static struct scsi_host_template ahci_platform_sht = {
AHCI_SHT("ahci_platform"),
};
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+ unsigned long deadline);
+
+static struct ata_port_operations ahci_pmp_ops = {
+ .inherits = &ahci_ops,
+ .softreset = ahci_pmp_softreset,
+ .pmp_softreset = ahci_pmp_softreset,
+};
+
+static int ahci_pmp_check_ready(struct ata_link *link)
+{
+ void __iomem *port_mmio = ahci_port_base(link->ap);
+ u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
+ u32 irq_status = readl(port_mmio + PORT_IRQ_STAT);
+
+ /*
+ * There is no need to check TFDATA if BAD PMP is found due to HW bug,
+ * which can save timeout delay.
+ */
+ if (irq_status & PORT_IRQ_BAD_PMP)
+ return -EIO;
+
+ printk("%s:TFT 0x%x\n", __func__, status);
+ return ata_check_ready(status);
+}
+
+static int ahci_pmp_softreset(struct ata_link *link, unsigned int *class,
+ unsigned long deadline)
+{
+ struct ata_port *ap = link->ap;
+ void __iomem *port_mmio = ahci_port_base(ap);
+ int pmp = sata_srst_pmp(link);
+ int rc;
+ u32 irq_sts;
+
+ DPRINTK("ENTER\n");
+
+ rc = ahci_do_softreset(link, class, pmp, deadline,
+ ahci_pmp_check_ready);
+
+ /*
+ * Soft reset fails with IPMS set when PMP is enabled but
+ * SATA HDD/ODD is connected to SATA port, do soft reset
+ * again to port 0.
+ */
+ if (rc == -EIO) {
+ irq_sts = readl(port_mmio + PORT_IRQ_STAT);
+ if (irq_sts & PORT_IRQ_BAD_PMP) {
+ ata_link_printk(link, KERN_WARNING,
+ "applying PMP SRST workaround "
+ "and retrying\n");
+ rc = ahci_do_softreset(link, class, 0, deadline,
+ ahci_check_ready);
+ }
+ }
+
+ return rc;
+}
+
+
static int __init ahci_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -35,7 +95,7 @@ static int __init ahci_probe(struct platform_device *pdev)
.flags = AHCI_FLAG_COMMON,
.pio_mask = ATA_PIO4,
.udma_mask = ATA_UDMA6,
- .port_ops = &ahci_ops,
+ .port_ops = &ahci_pmp_ops,
};
const struct ata_port_info *ppi[] = { &pi, NULL };
struct ahci_host_priv *hpriv;
--
1.7.3.1
next reply other threads:[~2011-06-14 5:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-14 5:48 Yuan-Hsin Chen [this message]
2011-06-14 6:52 ` Tejun Heo
2011-06-15 10:04 ` [PATCH v2] ahci: fix pmp softreset with HDD Yuan-Hsin Chen
2011-06-15 10:14 ` Tejun Heo
2011-06-17 10:39 ` [PATCH v3] ahci: move ahci_sb600_softreset to libahci.c and rename it Yuan-Hsin Chen
2011-06-17 11:34 ` Sergei Shtylyov
2011-06-17 12:07 ` Tejun Heo
2011-06-20 8:06 ` [PATCH v4] " Yuan-Hsin Chen
2011-06-20 8:15 ` Sergei Shtylyov
2011-06-20 8:47 ` Yuan-Hsin Chen
2011-06-20 8:19 ` Tejun Heo
2011-06-20 10:06 ` Yuan-Hsin Chen
2011-06-20 12:47 ` Tejun Heo
2011-06-21 3:24 ` Yuan-Hsin Chen
2011-06-21 7:17 ` Tejun Heo
2011-06-21 9:17 ` [PATCH v5] " Yuan-Hsin Chen
2011-06-21 9:53 ` Tejun Heo
[not found] ` <BANLkTimiJheFauWXjh-8GszGHoqMOa0Kkw@mail.gmail.com>
2011-06-15 2:50 ` Fwd: [PATCH] ahci: enable pmp but connected to HDD issue fixed BingJiun Luo
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=1308030504-3026-1-git-send-email-yuanlmm@gmail.com \
--to=yuanlmm@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yhchen@faraday-tech.com \
/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
all inboxes | Powered by JetHome®