From: Hannes Reinecke <hare@suse.de>
To: Tejun Heo <tj@kernel.org>
Cc: linux-ide@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>,
Shaun Tancheff <shaun.tancheff@seagate.com>,
Damien Le Moal <damien.lemoal@hgst.com>,
linux-scsi@vger.kernel.org,
Sathya Prakash <sathya.prakash@broadcom.com>,
Hannes Reinecke <hare@suse.de>
Subject: [PATCH 01/14] libata: Implement NCQ autosense
Date: Mon, 4 Apr 2016 11:43:54 +0200 [thread overview]
Message-ID: <1459763047-125551-2-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1459763047-125551-1-git-send-email-hare@suse.de>
Some newer devices support NCQ autosense (cf ACS-4), so we should
be using it to retrieve the sense code and speed up recovery.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/ata/libata-eh.c | 12 ++++++++++++
drivers/ata/libata-scsi.c | 7 ++++++-
drivers/ata/libata.h | 1 +
include/linux/ata.h | 2 ++
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 961acc7..8c8355f 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1600,6 +1600,8 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
tf->hob_lbah = buf[10];
tf->nsect = buf[12];
tf->hob_nsect = buf[13];
+ if (ata_id_has_ncq_autosense(dev->id))
+ tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16];
return 0;
}
@@ -1797,6 +1799,16 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
memcpy(&qc->result_tf, &tf, sizeof(tf));
qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
+ if (qc->result_tf.auxiliary) {
+ char sense_key, asc, ascq;
+
+ sense_key = (qc->result_tf.auxiliary >> 16) & 0xff;
+ asc = (qc->result_tf.auxiliary >> 8) & 0xff;
+ ascq = qc->result_tf.auxiliary & 0xff;
+ ata_scsi_set_sense(qc->scsicmd, sense_key, asc, ascq);
+ qc->flags |= ATA_QCFLAG_SENSE_VALID;
+ }
+
ehc->i.err_mask &= ~AC_ERR_DEV;
}
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 567859c..6dc2fad 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -270,8 +270,11 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR,
ata_scsi_park_show, ata_scsi_park_store);
EXPORT_SYMBOL_GPL(dev_attr_unload_heads);
-static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
+void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
{
+ if (!cmd)
+ return;
+
cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq);
@@ -1784,6 +1787,8 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
((cdb[2] & 0x20) || need_sense))
ata_gen_passthru_sense(qc);
+ else if (qc->flags & ATA_QCFLAG_SENSE_VALID)
+ cmd->result = SAM_STAT_CHECK_CONDITION;
else if (need_sense)
ata_gen_ata_sense(qc);
else
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index f840ca1..8cfdd96 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -137,6 +137,7 @@ extern int ata_scsi_add_hosts(struct ata_host *host,
struct scsi_host_template *sht);
extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
extern int ata_scsi_offline_dev(struct ata_device *dev);
+extern void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq);
extern void ata_scsi_media_change_notify(struct ata_device *dev);
extern void ata_scsi_hotplug(struct work_struct *work);
extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
diff --git a/include/linux/ata.h b/include/linux/ata.h
index c1a2f34..e797e1b53 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -528,6 +528,8 @@ struct ata_bmdma_prd {
#define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20)
#define ata_id_has_da(id) ((id)[ATA_ID_SATA_CAPABILITY_2] & (1 << 4))
#define ata_id_has_devslp(id) ((id)[ATA_ID_FEATURE_SUPP] & (1 << 8))
+#define ata_id_has_ncq_autosense(id) \
+ ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7))
static inline bool ata_id_has_hipm(const u16 *id)
{
--
1.8.5.6
next prev parent reply other threads:[~2016-04-04 9:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 9:43 [PATCH 00/14] libata: SATL update Hannes Reinecke
2016-04-04 9:43 ` Hannes Reinecke [this message]
2016-04-04 9:43 ` [PATCH 02/14] libata: Implement support for sense data reporting Hannes Reinecke
2016-04-04 9:43 ` [PATCH 03/14] libata-scsi: sanitize ata_gen_ata_sense() Hannes Reinecke
2016-04-04 11:26 ` Sergei Shtylyov
2016-04-04 16:22 ` Tejun Heo
2016-04-04 17:33 ` Sergei Shtylyov
2016-04-04 9:43 ` [PATCH 04/14] libata: sanitize ata_tf_read_block() Hannes Reinecke
2016-04-04 9:43 ` [PATCH 05/14] libata-scsi: use scsi_set_sense_information() Hannes Reinecke
2016-04-04 9:43 ` [PATCH 06/14] libata-eh: Set 'information' field for autosense Hannes Reinecke
2016-04-04 9:44 ` [PATCH 07/14] libata-scsi: use ata_scsi_set_sense() Hannes Reinecke
2016-04-04 9:44 ` [PATCH 08/14] libata: evaluate SCSI sense code Hannes Reinecke
2016-04-04 11:21 ` Sergei Shtylyov
2016-04-04 9:44 ` [PATCH 09/14] libata-scsi: generate correct ATA pass-through sense Hannes Reinecke
2016-04-04 9:44 ` [PATCH 10/14] libata: Implement control mode page to select sense format Hannes Reinecke
2016-04-04 12:53 ` kbuild test robot
2016-04-04 9:44 ` [PATCH 11/14] scsi: add scsi_set_sense_field_pointer() Hannes Reinecke
2016-04-04 9:44 ` [PATCH 12/14] libata-scsi: Set field pointer in sense code Hannes Reinecke
2016-04-04 9:44 ` [PATCH 13/14] libata-scsi: set bit pointer for sense code information Hannes Reinecke
2016-04-04 9:44 ` [PATCH 14/14] libata-scsi: Set information sense field for invalid parameter Hannes Reinecke
2016-04-04 15:22 ` kbuild test robot
2016-04-04 15:46 ` [PATCH 00/14] libata: SATL update Tejun Heo
2016-04-04 19:54 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459763047-125551-2-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=damien.lemoal@hgst.com \
--cc=hch@lst.de \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sathya.prakash@broadcom.com \
--cc=shaun.tancheff@seagate.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).