aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2015-05-04 21:54:21 -0400
committerTejun Heo <tj@kernel.org>2015-05-05 09:30:19 -0400
commit5d3abf8ff67f49271a42c0f7fa4f20f9e046bf0e (patch)
treebe812ae236e94d84fab9435c0ca41e947e6faa3a /drivers/ata
parent406c057c4e00744453d5b0731eb23629ec14dcdf (diff)
libata: Fall back to unqueued READ LOG EXT if the DMA variant fails
Some devices advertise support for the READ/WRITE LOG DMA EXT commands but fail when we try to issue them. This can lead to queued TRIM being unintentionally disabled since the relevant feature flag is located in a general purpose log page. Fall back to unqueued READ LOG EXT if the DMA variant fails while reading a log page. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-eh.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 07f41be38fbe..2893563d0537 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1507,13 +1507,17 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
1507{ 1507{
1508 struct ata_taskfile tf; 1508 struct ata_taskfile tf;
1509 unsigned int err_mask; 1509 unsigned int err_mask;
1510 bool dma = false;
1510 1511
1511 DPRINTK("read log page - log 0x%x, page 0x%x\n", log, page); 1512 DPRINTK("read log page - log 0x%x, page 0x%x\n", log, page);
1512 1513
1514retry:
1513 ata_tf_init(dev, &tf); 1515 ata_tf_init(dev, &tf);
1514 if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id)) { 1516 if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
1517 !(dev->horkage & ATA_HORKAGE_NO_NCQ_LOG)) {
1515 tf.command = ATA_CMD_READ_LOG_DMA_EXT; 1518 tf.command = ATA_CMD_READ_LOG_DMA_EXT;
1516 tf.protocol = ATA_PROT_DMA; 1519 tf.protocol = ATA_PROT_DMA;
1520 dma = true;
1517 } else { 1521 } else {
1518 tf.command = ATA_CMD_READ_LOG_EXT; 1522 tf.command = ATA_CMD_READ_LOG_EXT;
1519 tf.protocol = ATA_PROT_PIO; 1523 tf.protocol = ATA_PROT_PIO;
@@ -1527,6 +1531,12 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
1527 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, 1531 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
1528 buf, sectors * ATA_SECT_SIZE, 0); 1532 buf, sectors * ATA_SECT_SIZE, 0);
1529 1533
1534 if (err_mask && dma) {
1535 dev->horkage |= ATA_HORKAGE_NO_NCQ_LOG;
1536 ata_dev_warn(dev, "READ LOG DMA EXT failed, trying unqueued\n");
1537 goto retry;
1538 }
1539
1530 DPRINTK("EXIT, err_mask=%x\n", err_mask); 1540 DPRINTK("EXIT, err_mask=%x\n", err_mask);
1531 return err_mask; 1541 return err_mask;
1532} 1542}