From e86e8a0ba76129b0251e751a1742652862ebd949 Mon Sep 17 00:00:00 2001 From: Jared Mackey Date: Mon, 17 Aug 2015 00:59:03 -0600 Subject: [PATCH 1/2] Added delay to PMP read Copied some code from very old commit attempt to fix the issue described here. http://www.spinics.net/lists/linux-ide/msg42820.html --- drivers/ata/libata-pmp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c index 85aa76116a305e..d643b6982f85fb 100644 --- a/drivers/ata/libata-pmp.c +++ b/drivers/ata/libata-pmp.c @@ -145,12 +145,23 @@ int sata_pmp_scr_read(struct ata_link *link, int reg, u32 *r_val) if (reg > SATA_PMP_PSCR_CONTROL) return -EINVAL; + + /* For some PMP cards, we need to delay some time */ + if (link>flags & ATA_LFLAG_DELAY) { + set_current_state(TASK_INTERRUPTIBLE); + /* sleep 50 msecond */ + schedule_timeout(msecs_to_jiffies(50)); + } err_mask = sata_pmp_read(link, reg, r_val); if (err_mask) { ata_link_warn(link, "failed to read SCR %d (Emask=0x%x)\n", reg, err_mask); return -EIO; + } else if (vendor== 0x197b && devid == 0x0325) { + ata_for_each_link(link, ap, EDGE) { + link->flags |= ATA_LFLAG_DELAY; + } } return 0; } @@ -176,13 +187,15 @@ int sata_pmp_scr_write(struct ata_link *link, int reg, u32 val) if (reg > SATA_PMP_PSCR_CONTROL) return -EINVAL; + + err_mask = sata_pmp_write(link, reg, val); if (err_mask) { ata_link_warn(link, "failed to write SCR %d (Emask=0x%x)\n", reg, err_mask); return -EIO; - } + } return 0; } From dc59fe717ebe9cbcb4169de40c48d847a94a7a19 Mon Sep 17 00:00:00 2001 From: Jared Mackey Date: Mon, 17 Aug 2015 01:03:48 -0600 Subject: [PATCH 2/2] Update libata.h --- include/linux/libata.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/libata.h b/include/linux/libata.h index c9cfbcdb8d140e..e9a580f78eb40f 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -205,6 +205,7 @@ enum { ATA_LFLAG_NO_LPM = (1 << 8), /* disable LPM on this link */ ATA_LFLAG_RST_ONCE = (1 << 9), /* limit recovery to one reset */ ATA_LFLAG_CHANGED = (1 << 10), /* LPM state changed on this link */ + ATA_LFLAG_DELAY = (1 << 9), /* Delay some time for PMP */ /* struct ata_port flags */ ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */