libata: add command name parsing for error output
PATCH 1/1 libata: add command name parsing for error output
This patch improve libata's output for error/notification messages to allow easier comprehension and debugging:
When ATAPI commands issued through the SCSI layer fail, use SCSI functions to print the CDB in human-readable form instead of just dumping out the CDB in hex.
Print out the name of the failed command (as defined by the ATA specification) in error handling output along with the raw register contents.
When reporting status of ACPI taskfile commands executed on resume, also output the names of the commands being executed (or not) in readable form.
Since the extra data for printing command names increases kernel size slightly, a config option has been added to allow disabling command name output (as well as some of the error register parsing) for those highly sensitive to kernel text size.
drivers/ata/Kconfig +11 -0
@@ -26,6 +26,17 @@ config ATA_NONSTANDARD bool default n +config ATA_VERBOSE_ERROR + bool "Verbose ATA error reporting" + default y + help + This option adds parsing of ATA command descriptions and error bits + in libata kernel output, making it easier to interpret. + This option will enlarge the kernel by approx. 6KB. Disable it only + if kernel size is more important than ease of debugging. + + If unsure, say Y. + config ATA_ACPI bool "ATA ACPI Support" depends on ACPI && PCI
drivers/ata/libata-acpi.c +5 -2
@@ -689,6 +689,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,struct ata_taskfile tf, ptf, rtf;unsigned int err_mask;const char *level; +const char *descr;char msg[60 ];int rc;
@@ -736,11 +737,13 @@ static int ata_acpi_run_tf(struct ata_device *dev,snprintf (msg,sizeof (msg),"filtered out" ); rc =0 ; } + descr =ata_get_cmd_descript (tf.command);ata_dev_printk (dev, level, -"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x %s\n" , +"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x (%s) %s\n" , tf.command, tf.feature, tf.nsect, tf.lbal, - tf.lbam, tf.lbah, tf.device, msg); + tf.lbam, tf.lbah, tf.device, + (descr ? descr :"unknown" ), msg);return rc; }
drivers/ata/libata-eh.c +126 -2
176 lines not on this page · raw message
drivers/ata/libata.h +1 -0
@@ -164,6 +164,7 @@ extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,extern void ata_eh_done (struct ata_link *link,struct ata_device *dev,unsigned int action);extern void ata_eh_autopsy (struct ata_port *ap); +const char *ata_get_cmd_descript (u8 command);extern void ata_eh_report (struct ata_port *ap); extern int ata_eh_reset(struct ata_link *link, int classify, ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
include/linux/ata.h +31 -1
@@ -210,15 +210,25 @@ enum {ATA_CMD_STANDBY =0xE2 ,/* place in standby power mode */ ATA_CMD_IDLE =0xE3 ,/* place in idle power mode */ ATA_CMD_EDD =0x90 ,/* execute device diagnostic */ +ATA_CMD_DOWNLOAD_MICRO =0x92 , +ATA_CMD_NOP =0x00 ,ATA_CMD_FLUSH =0xE7 ,ATA_CMD_FLUSH_EXT =0xEA ,ATA_CMD_ID_ATA =0xEC ,ATA_CMD_ID_ATAPI =0xA1 , +ATA_CMD_SERVICE =0xA2 ,ATA_CMD_READ =0xC8 ,ATA_CMD_READ_EXT =0x25 , +ATA_CMD_READ_QUEUED =0x26 , +ATA_CMD_READ_STREAM_EXT =0x2B , +ATA_CMD_READ_STREAM_DMA_EXT =0x2A ,ATA_CMD_WRITE =0xCA ,ATA_CMD_WRITE_EXT =0x35 , +ATA_CMD_WRITE_QUEUED =0x36 , +ATA_CMD_WRITE_STREAM_EXT =0x3B , +ATA_CMD_WRITE_STREAM_DMA_EXT =0x3A ,ATA_CMD_WRITE_FUA_EXT =0x3D , +ATA_CMD_WRITE_QUEUED_FUA_EXT =0x3E ,ATA_CMD_FPDMA_READ =0x60 ,ATA_CMD_FPDMA_WRITE =0x61 , ATA_CMD_PIO_READ = 0x20,
@@ -235,6 +245,7 @@ enum {ATA_CMD_PACKET =0xA0 ,ATA_CMD_VERIFY =0x40 ,ATA_CMD_VERIFY_EXT =0x42 , +ATA_CMD_WRITE_UNCORR_EXT =0x45 ,ATA_CMD_STANDBYNOW1 =0xE0 ,ATA_CMD_IDLEIMMEDIATE =0xE1 , ATA_CMD_SLEEP = 0xE6,
@@ -243,15 +254,34 @@ enum {ATA_CMD_READ_NATIVE_MAX_EXT =0x27 ,ATA_CMD_SET_MAX =0xF9 ,ATA_CMD_SET_MAX_EXT =0x37 , -ATA_CMD_READ_LOG_EXT =0x2f , +ATA_CMD_READ_LOG_EXT =0x2F , +ATA_CMD_WRITE_LOG_EXT =0x3F , +ATA_CMD_READ_LOG_DMA_EXT =0x47 , +ATA_CMD_WRITE_LOG_DMA_EXT =0x57 , +ATA_CMD_TRUSTED_RCV =0x5C , +ATA_CMD_TRUSTED_RCV_DMA =0x5D , +ATA_CMD_TRUSTED_SND =0x5E , +ATA_CMD_TRUSTED_SND_DMA =0x5F ,ATA_CMD_PMP_READ =0xE4 ,ATA_CMD_PMP_WRITE =0xE8 ,ATA_CMD_CONF_OVERLAY =0xB1 , +ATA_CMD_SEC_SET_PASS =0xF1 , +ATA_CMD_SEC_UNLOCK =0xF2 , +ATA_CMD_SEC_ERASE_PREP =0xF3 , +ATA_CMD_SEC_ERASE_UNIT =0xF4 ,ATA_CMD_SEC_FREEZE_LOCK =0xF5 , +ATA_CMD_SEC_DISABLE_PASS =0xF6 , +ATA_CMD_CONFIG_STREAM =0x51 ,ATA_CMD_SMART =0xB0 ,ATA_CMD_MEDIA_LOCK =0xDE ,ATA_CMD_MEDIA_UNLOCK =0xDF ,ATA_CMD_DSM =0x06 , +ATA_CMD_CHK_MED_CRD_TYP =0xD1 , +ATA_CMD_CFA_REQ_EXT_ERR =0x03 , +ATA_CMD_CFA_WRITE_NE =0x38 , +ATA_CMD_CFA_TRANS_SECT =0x87 , +ATA_CMD_CFA_ERASE =0xC0 , +ATA_CMD_CFA_WRITE_MULT_NE =0xCD ,/* marked obsolete in the ATA/ATAPI-7 spec */ ATA_CMD_RESTORE = 0x10,
Quoted 13 lines · Robert Hancock
This patch improve libata's output for error/notification messages to allow easier comprehension and debugging:
When ATAPI commands issued through the SCSI layer fail, use SCSI functions to print the CDB in human-readable form instead of just dumping out the CDB in hex.
Print out the name of the failed command (as defined by the ATA specification) in error handling output along with the raw register contents.
When reporting status of ACPI taskfile commands executed on resume, also output the names of the commands being executed (or not) in readable form.
Quoted 6 lines
Since the extra data for printing command names increases kernel size slightly, a config option has been added to allow disabling command name output (as well as some of the error register parsing) for those highly sensitive to kernel text size.
Signed-off-by Robert Hancock <[email protected]>
Thanks.
Signature · 1 line
tejun
Jeff Garzik
AppliedQuoted 13 lines · Robert Hancock
This patch improve libata's output for error/notification messages to allow easier comprehension and debugging:
When ATAPI commands issued through the SCSI layer fail, use SCSI functions to print the CDB in human-readable form instead of just dumping out the CDB in hex.
Print out the name of the failed command (as defined by the ATA specification) in error handling output along with the raw register contents.
When reporting status of ACPI taskfile commands executed on resume, also output the names of the commands being executed (or not) in readable form.
Quoted 6 lines
Since the extra data for printing command names increases kernel size slightly, a config option has been added to allow disabling command name output (as well as some of the error register parsing) for those highly sensitive to kernel text size.
Signed-off-by Robert Hancock <[email protected]>
applied... nice!
any chance you wanna work on filling out ata_msg_*/ATA_MSG_*?
Such a feature should permit people to change libata debugging output at runtime, on a per-port basis, via sysfs.
That's always been the ideal, and was the idea when ata_msg_* was originally added. Would _immensely_ help with debugging.
Jeff