Skip to content

Commit 7aae547

Browse files
damien-lemoalfloatious
authored andcommitted
ata: libata: Introduce ata_port_eh_scheduled()
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>
1 parent 31921e8 commit 7aae547

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/ata/libata-eh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ void ata_port_wait_eh(struct ata_port *ap)
823823
retry:
824824
spin_lock_irqsave(ap->lock, flags);
825825

826-
while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) {
826+
while (ata_port_eh_scheduled(ap)) {
827827
prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE);
828828
spin_unlock_irqrestore(ap->lock, flags);
829829
schedule();

drivers/ata/libata-scsi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4316,9 +4316,10 @@ int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev)
43164316
* scsi_queue_rq() will defer commands if scsi_host_in_recovery().
43174317
* However, this check is done without holding the ap->lock (a libata
43184318
* specific lock), so we can have received an error irq since then,
4319-
* therefore we must check if EH is pending, while holding ap->lock.
4319+
* therefore we must check if EH is pending or running, while holding
4320+
* ap->lock.
43204321
*/
4321-
if (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS))
4322+
if (ata_port_eh_scheduled(ap))
43224323
return SCSI_MLQUEUE_DEVICE_BUSY;
43234324

43244325
if (unlikely(!scmd->cmd_len))

drivers/ata/libata.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ static inline bool ata_dev_is_zac(struct ata_device *dev)
5151
ata_id_zoned_cap(dev->id) == 0x01;
5252
}
5353

54+
static inline bool ata_port_eh_scheduled(struct ata_port *ap)
55+
{
56+
return ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS);
57+
}
58+
5459
#ifdef CONFIG_ATA_FORCE
5560
extern void ata_force_cbl(struct ata_port *ap);
5661
#else

0 commit comments

Comments
 (0)