From a5d518cd4e3e592eaa59b888a5d75ad639d554ea Mon Sep 17 00:00:00 2001 From: Kai Mäkisara Date: Mon, 20 Jan 2025 21:49:23 +0200 Subject: scsi: core: Add counters for New Media and Power On/Reset UNIT ATTENTIONs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose of the counters is to enable all ULDs attached to a device to find out that a New Media or/and Power On/Reset Unit Attentions has/have been set, even if another ULD catches the Unit Attention as response to a SCSI command. The ULDs can read the counters and see if the values have changed from the previous check. Signed-off-by: Kai Mäkisara Link: https://lore.kernel.org/r/20250120194925.44432-3-Kai.Makisara@kolumbus.fi Reviewed-by: John Meneghini Tested-by: John Meneghini Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi_error.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/scsi/scsi_error.c') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 815e7d63f3e2..ec60e8a96b11 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -547,6 +547,18 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) scsi_report_sense(sdev, &sshdr); + if (sshdr.sense_key == UNIT_ATTENTION) { + /* + * Increment the counters for Power on/Reset or New Media so + * that all ULDs interested in these can see that those have + * happened, even if someone else gets the sense data. + */ + if (sshdr.asc == 0x28) + scmd->device->ua_new_media_ctr++; + else if (sshdr.asc == 0x29) + scmd->device->ua_por_ctr++; + } + if (scsi_sense_is_deferred(&sshdr)) return NEEDS_RETRY; -- cgit From e6a815673b3b4ed69745f7a954742e12fc60139a Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Fri, 28 Feb 2025 12:17:51 +0900 Subject: scsi: scsi_error: Add comments to scsi_check_sense() Add a comment block describing the COMPLETED case with ASC/ASCQ 0x55/0xA to mention that it relates to command duration limits very special policy 0xD command completion. Signed-off-by: Damien Le Moal Link: https://lore.kernel.org/r/20250228031751.12083-1-dlemoal@kernel.org Signed-off-by: Martin K. Petersen --- drivers/scsi/scsi_error.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/scsi/scsi_error.c') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ec60e8a96b11..376b8897ab90 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -723,6 +723,13 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) return SUCCESS; case COMPLETED: + /* + * A command using command duration limits (CDL) with a + * descriptor set with policy 0xD may be completed with success + * and the sense data DATA CURRENTLY UNAVAILABLE, indicating + * that the command was in fact aborted because it exceeded its + * duration limit. Never retry these commands. + */ if (sshdr.asc == 0x55 && sshdr.ascq == 0x0a) { set_scsi_ml_byte(scmd, SCSIML_STAT_DL_TIMEOUT); req->cmd_flags |= REQ_FAILFAST_DEV; -- cgit