]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ata: libata: Introduce ata_port_eh_scheduled()
authorDamien Le Moal <dlemoal@kernel.org>
Fri, 4 Jul 2025 10:46:00 +0000 (19:46 +0900)
committerNiklas Cassel <cassel@kernel.org>
Mon, 7 Jul 2025 10:40:56 +0000 (12:40 +0200)
Introduce the inline helper function ata_port_eh_scheduled() to test if
EH is pending (ATA_PFLAG_EH_PENDING port flag is set) or running
(ATA_PFLAG_EH_IN_PROGRESS port flag is set) for a port. Use this helper
in ata_port_wait_eh() and __ata_scsi_queuecmd() to replace the hardcoded
port flag tests.

No functional changes.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Link: https://lore.kernel.org/r/20250704104601.310643-1-dlemoal@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
drivers/ata/libata-eh.c
drivers/ata/libata-scsi.c
drivers/ata/libata.h

index e5fa61fb8a59d8d98641c0c727bc7a8da6728490..8c6c83d4afbbad1350b7bde4a5b0349d70fec3d3 100644 (file)
@@ -823,7 +823,7 @@ void ata_port_wait_eh(struct ata_port *ap)
  retry:
        spin_lock_irqsave(ap->lock, flags);
 
-       while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) {
+       while (ata_port_eh_scheduled(ap)) {
                prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE);
                spin_unlock_irqrestore(ap->lock, flags);
                schedule();
index b502b123008a53c826830147fc1bf6655c6eaa72..27b15176db568581228e28d732b2ce3f04c84170 100644 (file)
@@ -4316,9 +4316,10 @@ int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev)
         * scsi_queue_rq() will defer commands if scsi_host_in_recovery().
         * However, this check is done without holding the ap->lock (a libata
         * specific lock), so we can have received an error irq since then,
-        * therefore we must check if EH is pending, while holding ap->lock.
+        * therefore we must check if EH is pending or running, while holding
+        * ap->lock.
         */
-       if (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS))
+       if (ata_port_eh_scheduled(ap))
                return SCSI_MLQUEUE_DEVICE_BUSY;
 
        if (unlikely(!scmd->cmd_len))
index 135e1e5ee44edb52a28ae80345d9d1baaa44bf39..ca44fb792aeb5a6d24be208993549c7ebd99a626 100644 (file)
@@ -51,6 +51,11 @@ static inline bool ata_dev_is_zac(struct ata_device *dev)
                ata_id_zoned_cap(dev->id) == 0x01;
 }
 
+static inline bool ata_port_eh_scheduled(struct ata_port *ap)
+{
+       return ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS);
+}
+
 #ifdef CONFIG_ATA_FORCE
 extern void ata_force_cbl(struct ata_port *ap);
 #else