From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hannes Reinecke Subject: [PATCHv3 06/14] libata: Check log page directory before accessing pages Date: Mon, 25 Apr 2016 12:45:48 +0200 Message-ID: <1461581156-92581-7-git-send-email-hare@suse.de> References: <1461581156-92581-1-git-send-email-hare@suse.de> Return-path: Received: from mx2.suse.de ([195.135.220.15]:59274 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932081AbcDYKs2 (ORCPT ); Mon, 25 Apr 2016 06:48:28 -0400 In-Reply-To: <1461581156-92581-1-git-send-email-hare@suse.de> Sender: linux-ide-owner@vger.kernel.org List-Id: linux-ide@vger.kernel.org To: Tejun Heo Cc: linux-ide@vger.kernel.org, Shaun Tancheff , Damien Le Moal , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke 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 --- drivers/ata/libata-core.c | 17 +++++++++++++++++ include/linux/ata.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index fa74b57..b2bd7c4 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -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) { diff --git a/include/linux/ata.h b/include/linux/ata.h index 94ccde5..b5be5e8 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -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, -- 1.8.5.6