WSL2-Linux-Kernel/drivers/dma/idxd
Dave Jiang 93a40a6d74 dmaengine: idxd: add percpu_ref to descriptor submission path
Current submission path has no way to restrict the submitter from
stop submiting on shutdown path or wq disable path. This provides a way to
quiesce the submission path.

Modeling after 'struct reqeust_queue' usage of percpu_ref. One of the
abilities of per_cpu reference counting is the ability to stop new
references from being taken while awaiting outstanding references to be
dropped. On wq shutdown, we want to block any new submissions to the kernel
workqueue and quiesce before disabling. The percpu_ref allows us to block
any new submissions and wait for any current submission calls to finish
submitting to the workqueue.

A percpu_ref is embedded in each idxd_wq context to allow control for
individual wq. The wq->wq_active counter is elevated before calling
movdir64b() or enqcmds() to submit a descriptor to the wq and dropped once
the submission call completes. The function is gated by
percpu_ref_tryget_live(). On shutdown with percpu_ref_kill() called, any
new submission would be blocked from acquiring a ref and failed. Once all
references are dropped for the wq, shutdown can continue.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/161894438293.3202472.14894701611500822232.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2021-04-23 23:08:44 +05:30
..
Makefile dmaengine: idxd: add char driver to expose submission portal to userland 2020-01-24 11:18:45 +05:30
cdev.c dmaengine: idxd: remove detection of device type 2021-04-20 16:43:53 +05:30
device.c dmaengine: idxd: add percpu_ref to descriptor submission path 2021-04-23 23:08:44 +05:30
dma.c dmaengine: idxd: fix dma device lifetime 2021-04-20 16:43:52 +05:30
idxd.h dmaengine: idxd: add percpu_ref to descriptor submission path 2021-04-23 23:08:44 +05:30
init.c dmaengine: idxd: add percpu_ref to descriptor submission path 2021-04-23 23:08:44 +05:30
irq.c dmaengine: idxd: fix cdev setup and free device lifetime issues 2021-04-20 16:43:53 +05:30
registers.h dmaengine updates for v5.11-rc1 2020-12-17 12:52:23 -08:00
submit.c dmaengine: idxd: add percpu_ref to descriptor submission path 2021-04-23 23:08:44 +05:30
sysfs.c dmaengine: idxd: add percpu_ref to descriptor submission path 2021-04-23 23:08:44 +05:30