]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
PCI hot-plug: use dedicated taskqueue for device attach / detach
authorAndriy Gapon <avg@FreeBSD.org>
Thu, 6 May 2021 18:49:37 +0000 (21:49 +0300)
committerAndriy Gapon <avg@FreeBSD.org>
Thu, 6 May 2021 18:49:37 +0000 (21:49 +0300)
commit12588ce02dd835b332952d9fece5881d943554a9
tree8fb1adac7f9b84a035c214edf275fdfc7d6a184d
parent420dbe763f15b076751443edfeeb4f676deb3c44
PCI hot-plug: use dedicated taskqueue for device attach / detach

Attaching and detaching devices can be heavy-weight and detaching can
sleep waiting for events.  For that reason using the system-wide
single-threaded taskqueue_thread is not really appropriate.
There is even a possibility for a deadlock if taskqueue_thread is used
for detaching.

In fact, there is an easy to reproduce deadlock involving nvme, pass
and a sudden removal of an NVMe device.
A pass peripheral would not release a reference on an nvme sim until
pass_shutdown_kqueue() is executed via taskqueue_thread.  But the
taskqueue's thread is blocked in nvme_detach() -> ... -> cam_sim_free()
because of the outstanding reference.

MFC after: 10 days
Sponsored by: CyberSecure
Reviewed by: mav, imp
Differential Revision: https://reviews.freebsd.org/D30144
sys/dev/pci/pci_pci.c