Skip to content

Commit 55db009

Browse files
committed
ata: libata-core: fix cancellation of a port deferred qc work
cancel_work_sync() is a sleeping function so it cannot be called with the spin lock of a port being held. Move the call to this function in ata_port_detach() after EH completes, with the port lock released, together with other work cancellation calls. Fixes: 0ea8408 ("ata: libata-scsi: avoid Non-NCQ command starvation") Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Igor Pylypiv <ipylypiv@google.com>
1 parent eddb98a commit 55db009

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/ata/libata-core.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6269,10 +6269,6 @@ static void ata_port_detach(struct ata_port *ap)
62696269
}
62706270
}
62716271

6272-
/* Make sure the deferred qc work finished. */
6273-
cancel_work_sync(&ap->deferred_qc_work);
6274-
WARN_ON(ap->deferred_qc);
6275-
62766272
/* Tell EH to disable all devices */
62776273
ap->pflags |= ATA_PFLAG_UNLOADING;
62786274
ata_port_schedule_eh(ap);
@@ -6283,9 +6279,11 @@ static void ata_port_detach(struct ata_port *ap)
62836279
/* wait till EH commits suicide */
62846280
ata_port_wait_eh(ap);
62856281

6286-
/* it better be dead now */
6282+
/* It better be dead now and not have any remaining deferred qc. */
62876283
WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
6284+
WARN_ON(ap->deferred_qc);
62886285

6286+
cancel_work_sync(&ap->deferred_qc_work);
62896287
cancel_delayed_work_sync(&ap->hotplug_task);
62906288
cancel_delayed_work_sync(&ap->scsi_rescan_task);
62916289

0 commit comments

Comments
 (0)