Skip to content

Commit bcf0814

Browse files
damien-lemoalgregkh
authored andcommitted
ata: libata-core: fix cancellation of a port deferred qc work
commit 55db009 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 33abac5 commit bcf0814

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
@@ -6163,10 +6163,6 @@ static void ata_port_detach(struct ata_port *ap)
61636163
}
61646164
}
61656165

6166-
/* Make sure the deferred qc work finished. */
6167-
cancel_work_sync(&ap->deferred_qc_work);
6168-
WARN_ON(ap->deferred_qc);
6169-
61706166
/* Tell EH to disable all devices */
61716167
ap->pflags |= ATA_PFLAG_UNLOADING;
61726168
ata_port_schedule_eh(ap);
@@ -6177,9 +6173,11 @@ static void ata_port_detach(struct ata_port *ap)
61776173
/* wait till EH commits suicide */
61786174
ata_port_wait_eh(ap);
61796175

6180-
/* it better be dead now */
6176+
/* It better be dead now and not have any remaining deferred qc. */
61816177
WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
6178+
WARN_ON(ap->deferred_qc);
61826179

6180+
cancel_work_sync(&ap->deferred_qc_work);
61836181
cancel_delayed_work_sync(&ap->hotplug_task);
61846182
cancel_delayed_work_sync(&ap->scsi_rescan_task);
61856183

0 commit comments

Comments
 (0)