Skip to content

Commit fe5af0c

Browse files
hreineckehtejun
authored andcommitted
libata: Check log page directory before accessing pages
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>
1 parent 5c65d8b commit fe5af0c

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎drivers/ata/libata-core.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include <scsi/scsi_host.h>
6767
#include <linux/libata.h>
6868
#include <asm/byteorder.h>
69+
#include <asm/unaligned.h>
6970
#include <linux/cdrom.h>
7071
#include <linux/ratelimit.h>
7172
#include <linux/pm_runtime.h>
@@ -2083,7 +2084,23 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
20832084
{
20842085
struct ata_port *ap = dev->link->ap;
20852086
unsigned int err_mask;
2087+
int log_index = ATA_LOG_NCQ_SEND_RECV * 2;
2088+
u16 log_pages;
20862089

2090+
err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY,
2091+
0, ap->sector_buf, 1);
2092+
if (err_mask) {
2093+
ata_dev_dbg(dev,
2094+
"failed to get Log Directory Emask 0x%x\n",
2095+
err_mask);
2096+
return;
2097+
}
2098+
log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
2099+
if (!log_pages) {
2100+
ata_dev_warn(dev,
2101+
"NCQ Send/Recv Log not supported\n");
2102+
return;
2103+
}
20872104
err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
20882105
0, ap->sector_buf, 1);
20892106
if (err_mask) {

‎include/linux/ata.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ enum {
314314
ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02,
315315

316316
/* READ_LOG_EXT pages */
317+
ATA_LOG_DIRECTORY = 0x0,
317318
ATA_LOG_SATA_NCQ = 0x10,
318319
ATA_LOG_NCQ_SEND_RECV = 0x13,
319320
ATA_LOG_SATA_ID_DEV_DATA = 0x30,

0 commit comments

Comments
 (0)