mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-18 09:44:18 +08:00
b36f09c3c4
The DMAengine API has a long standing race condition that is inherent to the API itself. Calling dmaengine_terminate_all() is supposed to stop and abort any pending or active transfers that have previously been submitted. Unfortunately it is possible that this operation races against a currently running (or with some drivers also scheduled) completion callback. Since the API allows dmaengine_terminate_all() to be called from atomic context as well as from within a completion callback it is not possible to synchronize to the execution of the completion callback from within dmaengine_terminate_all() itself. This means that a user of the DMAengine API does not know when it is safe to free resources used in the completion callback, which can result in a use-after-free race condition. This patch addresses the issue by introducing an explicit synchronization primitive to the DMAengine API called dmaengine_synchronize(). The existing dmaengine_terminate_all() is deprecated in favor of dmaengine_terminate_sync() and dmaengine_terminate_async(). The former aborts all pending and active transfers and synchronizes to the current context, meaning it will wait until all running completion callbacks have finished. This means it is only possible to call this function from non-atomic context. The later function does not synchronize, but can still be used in atomic context or from within a complete callback. It has to be followed up by dmaengine_synchronize() before a client can free the resources used in a completion callback. In addition to this the semantics of the device_terminate_all() callback are slightly relaxed by this patch. It is now OK for a driver to only schedule the termination of the active transfer, but does not necessarily have to wait until the DMA controller has completely stopped. The driver must ensure though that the controller has stopped and no longer accesses any memory when the device_synchronize() callback returns. This was in part done since most drivers do not pay attention to this anyway at the moment and to emphasize that this needs to be done when the device_synchronize() callback is implemented. But it also helps with implementing support for devices where stopping the controller can require operations that may sleep. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Vinod Koul <vinod.koul@intel.com> |
||
---|---|---|
.. | ||
bestcomm | ||
dw | ||
hsu | ||
ioat | ||
ipu | ||
ppc4xx | ||
sh | ||
xilinx | ||
acpi-dma.c | ||
amba-pl08x.c | ||
at_hdmac_regs.h | ||
at_hdmac.c | ||
at_xdmac.c | ||
bcm2835-dma.c | ||
coh901318_lli.c | ||
coh901318.c | ||
coh901318.h | ||
cppi41.c | ||
dma-axi-dmac.c | ||
dma-jz4740.c | ||
dma-jz4780.c | ||
dmaengine.c | ||
dmaengine.h | ||
dmatest.c | ||
edma.c | ||
ep93xx_dma.c | ||
fsl_raid.c | ||
fsl_raid.h | ||
fsl-edma.c | ||
fsldma.c | ||
fsldma.h | ||
idma64.c | ||
idma64.h | ||
img-mdc-dma.c | ||
imx-dma.c | ||
imx-sdma.c | ||
iop-adma.c | ||
k3dma.c | ||
Kconfig | ||
lpc18xx-dmamux.c | ||
Makefile | ||
mic_x100_dma.c | ||
mic_x100_dma.h | ||
mmp_pdma.c | ||
mmp_tdma.c | ||
moxart-dma.c | ||
mpc512x_dma.c | ||
mv_xor.c | ||
mv_xor.h | ||
mxs-dma.c | ||
nbpfaxi.c | ||
of-dma.c | ||
omap-dma.c | ||
pch_dma.c | ||
pl330.c | ||
pxa_dma.c | ||
qcom_bam_dma.c | ||
s3c24xx-dma.c | ||
sa11x0-dma.c | ||
sirf-dma.c | ||
ste_dma40_ll.c | ||
ste_dma40_ll.h | ||
ste_dma40.c | ||
sun4i-dma.c | ||
sun6i-dma.c | ||
tegra20-apb-dma.c | ||
ti-dma-crossbar.c | ||
timb_dma.c | ||
TODO | ||
txx9dmac.c | ||
txx9dmac.h | ||
virt-dma.c | ||
virt-dma.h | ||
xgene-dma.c | ||
zx296702_dma.c |