Skip to contentSkip to conversation

Fix log page accesses

PATCH New Damien Le Moal 1 participant 3 messages Nov 15, 2021 libata

lore
Share & tools
lore
#0 lore raw

cover Fix log page accesses

A couple of patches to improve ata_read_log_page() error message and to avoid attempts to access non-existent logs.

Damien Le Moal (2):
libata: core: improve ata_read_log_page() error message
libata: core: add missing ata_identify_page_supported() calls

 drivers/ata/libata-core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 libata: core: improve ata_read_log_page() error message

If ata_read_log_page() fails to read a log page, the ata_dev_err() error message only print the page number, omitting the log number. In case of error, facilitate debugging by also printing the log number.

---
 drivers/ata/libata-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/libata-core.c +3 -2
index 8a0ccb190d76..edaedcd82630 100644
@@ -2031,8 +2031,9 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
 			dev->horkage |= ATA_HORKAGE_NO_DMA_LOG;
 			goto retry;
 		}
-		ata_dev_err(dev, "Read log page 0x%02x failed, Emask 0x%x\n",
-			    (unsigned int)page, err_mask);
+		ata_dev_err(dev,
+			    "Read log 0x%02x page 0x%02x failed, Emask 0x%x\n",
+			    (unsigned int)log, (unsigned int)page, err_mask);
 	}
 
 	return err_mask;
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/2 libata: core: add missing ata_identify_page_supported() calls

In reply to Damien Le Moal

ata_dev_config_ncq_prio() and ata_dev_config_devslp() both access pages of the IDENTIFY DEVICE data log. Before calling ata_read_log_page(), make sure to check for the existence of the IDENTIFY DEVICE data log and of the log page accessed suing ata_identify_page_supported(). This avoids useless error messages from ata_read_log_page().

---
 drivers/ata/libata-core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ata/libata-core.c +5 -1
index edaedcd82630..59ad8c979cb3 100644
@@ -2178,6 +2178,9 @@ static void ata_dev_config_ncq_prio(struct ata_device *dev)
 	struct ata_port *ap = dev->link->ap;
 	unsigned int err_mask;
 
+	if (!ata_identify_page_supported(dev, ATA_LOG_SATA_SETTINGS))
+		return;
+
 	err_mask = ata_read_log_page(dev,
 				     ATA_LOG_IDENTIFY_DEVICE,
 				     ATA_LOG_SATA_SETTINGS,
@@ -2454,7 +2457,8 @@ static void ata_dev_config_devslp(struct ata_device *dev)
 	 * Check device sleep capability. Get DevSlp timing variables
 	 * from SATA Settings page of Identify Device Data Log.
 	 */
-	if (!ata_id_has_devslp(dev->id))
+	if (!ata_id_has_devslp(dev->id) ||
+	    !ata_identify_page_supported(dev, ATA_LOG_SATA_SETTINGS))
 		return;
 
 	err_mask = ata_read_log_page(dev,
Signature · 1 line
2.31.1