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; } 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 */