]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: core: Add counters for New Media and Power On/Reset UNIT ATTENTIONs
authorKai Mäkisara <Kai.Makisara@kolumbus.fi>
Mon, 20 Jan 2025 19:49:23 +0000 (21:49 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 3 Feb 2025 22:43:31 +0000 (17:43 -0500)
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 <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250120194925.44432-3-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_error.c
include/scsi/scsi_device.h

index 815e7d63f3e23bea9156f6a219a1448dcdee1e23..ec60e8a96b11253e146f8be1f80cd22762def1c7 100644 (file)
@@ -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;
 
index 7acd0ec82bb0a0598745628ea15d6d5d98bc6f16..bcc76986096b4e02fa4d452f41de1f288633a27a 100644 (file)
@@ -247,6 +247,9 @@ struct scsi_device {
        unsigned int queue_stopped;     /* request queue is quiesced */
        bool offline_already;           /* Device offline message logged */
 
+       unsigned int ua_new_media_ctr;  /* Counter for New Media UNIT ATTENTIONs */
+       unsigned int ua_por_ctr;        /* Counter for Power On / Reset UAs */
+
        atomic_t disk_events_disable_depth; /* disable depth for disk events */
 
        DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */