We are seeing deadlocks during hotplug of devices under vfio.
As per the Linux kernel source code, there is a deadlock situation between vfio_pci_remove() and vfio_pci_release() on PCIe hotplug events. This issue can be avoided either by skipping the PCIe reset functionality or do device_unlock() in vfio_pci_remove() beforfe calling the function vfio_del_group_dev()().
We are seeing deadlocks during hotplug of devices under vfio.
As per the Linux kernel source code, there is a deadlock situation between vfio_pci_remove() and vfio_pci_release() on PCIe hotplug events. This issue can be avoided either by skipping the PCIe reset functionality or do device_unlock() in vfio_pci_remove() beforfe calling the function vfio_del_ group_dev( )().
Code flow on PCIe hotplug event:
Execution flow 1: release_ driver( ) ( ( https:/ /elixir. bootlin. com/linux/ latest/ source/ drivers/ base/dd. c#L935 ) release_ driver_ internal( ) ( https:/ /elixir. bootlin. com/linux/ latest/ source/ drivers/ base/dd. c#L908 ) lock(dev) ; ( https:/ /elixir. bootlin. com/linux/ latest/ source/ drivers/ base/dd. c#L915 ) pci_remove( ) ( https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ vfio/pci/ vfio_pci. c#L392 ) del_group_ dev() https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ vfio/vfio. c#L923 /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ vfio/vfio. c#L967 )
device_
device_
device_
vfio_
vfio_
send event request to user and wait for VFIO_PCI_DEVICE release in vfio_pci_release() ( https:/
Execution flow 2 triggered by above step "send event request to user": /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ vfio/pci/ vfio_pci. c#L392 ) pci_disable( ) ( https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ vfio/pci/ vfio_pci. c#L302 ) pci_try_ bus_reset( ) ( https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ vfio/pci/ vfio_pci. c#L1346 )
pci_try_ reset_bus( ) ( https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ pci/pci. c#L4981 )
pci_ bus_save_ and_disable( ) ( https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ pci/pci. c#L4760 )
pci_ dev_lock( dev); ( https:/ /elixir. bootlin. com/linux/ v4.18.5/ source/ drivers/ pci/pci. c#L4765 )
vfio_pci_releas() ( https:/
vfio_
vfio_