]> git.karo-electronics.de Git - linux-beck.git/commitdiff
libata: Check log page directory before accessing pages
authorHannes Reinecke <hare@suse.de>
Mon, 25 Apr 2016 10:45:48 +0000 (12:45 +0200)
committerTejun Heo <tj@kernel.org>
Mon, 9 May 2016 16:36:45 +0000 (12:36 -0400)
When reading the NCQ Send/Recv log it might actually not
supported, thereby causing irritating messages
'READ LOG DMA EXT failed'.
Instead we should be reading the log directory first to
figure out if the log is actually supported before trying
to access it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/libata-core.c
include/linux/ata.h

index fa74b57ee52e32d1cbf75bfdadf880783cdac1c1..b2bd7c4996530b9bdbc551e1c707034b79e13922 100644 (file)
@@ -66,6 +66,7 @@
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <asm/byteorder.h>
+#include <asm/unaligned.h>
 #include <linux/cdrom.h>
 #include <linux/ratelimit.h>
 #include <linux/pm_runtime.h>
@@ -2083,7 +2084,23 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
 {
        struct ata_port *ap = dev->link->ap;
        unsigned int err_mask;
+       int log_index = ATA_LOG_NCQ_SEND_RECV * 2;
+       u16 log_pages;
 
+       err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY,
+                                    0, ap->sector_buf, 1);
+       if (err_mask) {
+               ata_dev_dbg(dev,
+                           "failed to get Log Directory Emask 0x%x\n",
+                           err_mask);
+               return;
+       }
+       log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
+       if (!log_pages) {
+               ata_dev_warn(dev,
+                            "NCQ Send/Recv Log not supported\n");
+               return;
+       }
        err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
                                     0, ap->sector_buf, 1);
        if (err_mask) {
index 94ccde5ee83c8a0702cf5ed953b107570edba318..b5be5e85d2d345fb91ba50af7d21a75b1e6e4e01 100644 (file)
@@ -314,6 +314,7 @@ enum {
        ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02,
 
        /* READ_LOG_EXT pages */
+       ATA_LOG_DIRECTORY       = 0x0,
        ATA_LOG_SATA_NCQ        = 0x10,
        ATA_LOG_NCQ_SEND_RECV     = 0x13,
        ATA_LOG_SATA_ID_DEV_DATA  = 0x30,