aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_error.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2015-03-27 11:46:37 -0400
committerTejun Heo <tj@kernel.org>2015-03-27 11:59:22 -0400
commita1524f226a02aa6edebd90ae0752e97cfd78b159 (patch)
tree3b694223de3a939c51271f779966f1a11c74c74b /drivers/scsi/scsi_error.c
parentfe7173c206de63fc28475ee6ae42ff95c05692de (diff)
libata-eh: Set 'information' field for autosense
If NCQ autosense or the sense data reporting feature is enabled the LBA of the offending command should be stored in the sense data 'information' field. Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/scsi/scsi_error.c')
-rw-r--r--drivers/scsi/scsi_error.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 4cdaffca17fc..c95a4e943fc6 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -26,6 +26,7 @@
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/jiffies.h> 28#include <linux/jiffies.h>
29#include <asm/unaligned.h>
29 30
30#include <scsi/scsi.h> 31#include <scsi/scsi.h>
31#include <scsi/scsi_cmnd.h> 32#include <scsi/scsi_cmnd.h>
@@ -2586,3 +2587,33 @@ void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq)
2586 } 2587 }
2587} 2588}
2588EXPORT_SYMBOL(scsi_build_sense_buffer); 2589EXPORT_SYMBOL(scsi_build_sense_buffer);
2590
2591/**
2592 * scsi_set_sense_information - set the information field in a
2593 * formatted sense data buffer
2594 * @buf: Where to build sense data
2595 * @info: 64-bit information value to be set
2596 *
2597 **/
2598void scsi_set_sense_information(u8 *buf, u64 info)
2599{
2600 if ((buf[0] & 0x7f) == 0x72) {
2601 u8 *ucp, len;
2602
2603 len = buf[7];
2604 ucp = (char *)scsi_sense_desc_find(buf, len + 8, 0);
2605 if (!ucp) {
2606 buf[7] = len + 0xa;
2607 ucp = buf + 8 + len;
2608 }
2609 ucp[0] = 0;
2610 ucp[1] = 0xa;
2611 ucp[2] = 0x80; /* Valid bit */
2612 ucp[3] = 0;
2613 put_unaligned_be64(info, &ucp[4]);
2614 } else if ((buf[0] & 0x7f) == 0x70) {
2615 buf[0] |= 0x80;
2616 put_unaligned_be64(info, &buf[3]);
2617 }
2618}
2619EXPORT_SYMBOL(scsi_set_sense_information);