Skip to content

Commit a5d518c

Browse files
kmakisaramartinkpetersen
authored andcommitted
scsi: core: Add counters for New Media and Power On/Reset UNIT ATTENTIONs
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: John Meneghini <[email protected]> Tested-by: John Meneghini <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7081dc7 commit a5d518c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/scsi/scsi_error.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
547547

548548
scsi_report_sense(sdev, &sshdr);
549549

550+
if (sshdr.sense_key == UNIT_ATTENTION) {
551+
/*
552+
* Increment the counters for Power on/Reset or New Media so
553+
* that all ULDs interested in these can see that those have
554+
* happened, even if someone else gets the sense data.
555+
*/
556+
if (sshdr.asc == 0x28)
557+
scmd->device->ua_new_media_ctr++;
558+
else if (sshdr.asc == 0x29)
559+
scmd->device->ua_por_ctr++;
560+
}
561+
550562
if (scsi_sense_is_deferred(&sshdr))
551563
return NEEDS_RETRY;
552564

include/scsi/scsi_device.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ struct scsi_device {
247247
unsigned int queue_stopped; /* request queue is quiesced */
248248
bool offline_already; /* Device offline message logged */
249249

250+
unsigned int ua_new_media_ctr; /* Counter for New Media UNIT ATTENTIONs */
251+
unsigned int ua_por_ctr; /* Counter for Power On / Reset UAs */
252+
250253
atomic_t disk_events_disable_depth; /* disable depth for disk events */
251254

252255
DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */

0 commit comments

Comments
 (0)