Skip to content

Commit b5ef7d0

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 21e0d7a commit b5ef7d0

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
@@ -6233,10 +6233,6 @@ static void ata_port_detach(struct ata_port *ap)
62336233
}
62346234
}
62356235

6236-
/* Make sure the deferred qc work finished. */
6237-
cancel_work_sync(&ap->deferred_qc_work);
6238-
WARN_ON(ap->deferred_qc);
6239-
62406236
/* Tell EH to disable all devices */
62416237
ap->pflags |= ATA_PFLAG_UNLOADING;
62426238
ata_port_schedule_eh(ap);
@@ -6247,9 +6243,11 @@ static void ata_port_detach(struct ata_port *ap)
62476243
/* wait till EH commits suicide */
62486244
ata_port_wait_eh(ap);
62496245

6250-
/* it better be dead now */
6246+
/* It better be dead now and not have any remaining deferred qc. */
62516247
WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
6248+
WARN_ON(ap->deferred_qc);
62526249

6250+
cancel_work_sync(&ap->deferred_qc_work);
62536251
cancel_delayed_work_sync(&ap->hotplug_task);
62546252
cancel_delayed_work_sync(&ap->scsi_rescan_task);
62556253

0 commit comments

Comments
 (0)