This is v3 of the callback synchronization series. It is based on
Michael S. Tsirkin's linux-next branch at f49e6cf91942 ("virtio:
synchronize callbacks after device reset"), which already contains the
core change and the virtio_input teardown reorder from v2.Patches 1 and 2 fix two bugs in virtio-ccw's existing synchronize_cbs() hook. After a fallback from adapter to classic interrupts it selects the wrong lock, and the classic interrupt handler only takes the matching lock when notification hardening is enabled. Patch 3 adds SRCU tracking for remoteproc callbacks, which can sleep. Patches 4 and 5 replace the RCU fallback with synchronization against the UML IRQ and the TmFIFO callback locks. The fallback already covers these IRQ handlers and spinlock sections. Patch 6 adds SRCU tracking in virtio_vdpa so callback synchronization does not depend on the context in which the vDPA driver invokes the callback. The UML, TmFIFO and remoteproc reset paths do not themselves prevent new virtqueue callbacks. UML and TmFIFO only clear a status field, and remoteproc does not wait for the remote side to acknowledge the reset. Without notification hardening or driver-specific teardown protection, callbacks can still start after reset. The new synchronization hooks do not fix that. The TmFIFO hook also does not synchronize with the rest of the FIFO work item outside the callback locks. The virtio_input loop change from v2 (continue instead of break, so events the device already completed are still delivered) and the event buffer leak are sent separately. Changes in v3: - Rebased on Michael's linux-next branch. Dropped the core change and the virtio_input patch, which are there already. - Split the virtio-ccw fixes out of the core patch, one per bug, and the transport patch into one patch per transport. The CCW and TmFIFO changes are functionally unchanged from v2. - Patch 2: added a Fixes tag and described the existing shutdown case. Removed the dependency note on the core reset change. - remoteproc: read the queue pointer once in rproc_vq_interrupt(), and synchronize with callbacks in __rproc_virtio_del_vqs() before freeing the queues (Sashiko). Place vq_srcu next to rvdevs so the hunk also applies to mainline, which added attach_work after index. - virtio_uml: compare against UM_IRQ_ALLOC instead of a bare negative check. - virtio_vdpa: use SRCU instead of a per-device rwlock, so the callback tracking uses per-CPU counters, and cover the config callback (Sashiko). - Rewrote the commit messages. Corrected the RCU fallback description for UML, TmFIFO and the vDPA simulators. Dropped the claimed simulator reset race: the simulators disable bottom halves around virtqueue callbacks and serialize reset with the worker's mutex. Changes in v2: - Moved callback synchronization from virtio-pci into the core, as Michael suggested, and added the missing synchronize_cbs() hooks. Testing: the changed objects build with W=1 without warnings, with clang on arm64, x86-64 and s390 and with gcc on SMP UML, and the patches also apply to current mainline and linux-next. The runtime tests from v2 were not repeated on this version: the input, rebind and shutdown checks on arm64 MMIO and x86 PCI covered code that is unchanged here, and the remoteproc and virtio_vdpa hooks have only been build-tested. No remoteproc, TmFIFO or s390 hardware was available. v2: https://lore.kernel.org/r/[email protected] v1: https://lore.kernel.org/r/[email protected] Karl Mehltretter (6): virtio_ccw: fix synchronize_cbs() after interrupt fallback virtio_ccw: always take irq_lock in the classic interrupt handler remoteproc: implement synchronize_cbs() for virtio devices um: virtio_uml: implement synchronize_cbs() platform/mellanox: mlxbf-tmfifo: implement synchronize_cbs() virtio_vdpa: implement synchronize_cbs() arch/um/drivers/virtio_uml.c | 10 +++++++ drivers/platform/mellanox/mlxbf-tmfifo.c | 15 ++++++++++ drivers/remoteproc/remoteproc_core.c | 12 ++++++++ drivers/remoteproc/remoteproc_virtio.c | 37 +++++++++++++++++++----- drivers/s390/virtio/virtio_ccw.c | 6 +--- drivers/virtio/virtio_vdpa.c | 34 ++++++++++++++++++++-- include/linux/remoteproc.h | 3 ++ 7 files changed, 102 insertions(+), 15 deletions(-) base-commit: f49e6cf919425cc55f10fd7cda7e0fc895df4cc0 -- 2.39.5 (Apple Git-154)

