Skip to content

Commit 42ea6c4

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 08d9175 commit 42ea6c4

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
@@ -6132,10 +6132,6 @@ static void ata_port_detach(struct ata_port *ap)
61326132
}
61336133
}
61346134

6135-
/* Make sure the deferred qc work finished. */
6136-
cancel_work_sync(&ap->deferred_qc_work);
6137-
WARN_ON(ap->deferred_qc);
6138-
61396135
/* Tell EH to disable all devices */
61406136
ap->pflags |= ATA_PFLAG_UNLOADING;
61416137
ata_port_schedule_eh(ap);
@@ -6146,9 +6142,11 @@ static void ata_port_detach(struct ata_port *ap)
61466142
/* wait till EH commits suicide */
61476143
ata_port_wait_eh(ap);
61486144

6149-
/* it better be dead now */
6145+
/* It better be dead now and not have any remaining deferred qc. */
61506146
WARN_ON(!(ap->pflags & ATA_PFLAG_UNLOADED));
6147+
WARN_ON(ap->deferred_qc);
61516148

6149+
cancel_work_sync(&ap->deferred_qc_work);
61526150
cancel_delayed_work_sync(&ap->hotplug_task);
61536151
cancel_delayed_work_sync(&ap->scsi_rescan_task);
61546152

0 commit comments

Comments
 (0)