WSL2-Linux-Kernel/drivers/dma
Maxime Jayat 156b45ed22 dmaengine: at_xdmac: fix rare residue corruption
commit c5637476bb upstream.

Despite the efforts made to correctly read the NDA and CUBC registers,
the order in which the registers are read could sometimes lead to an
inconsistent state.

Re-using the timeline from the comments, this following timing of
registers reads could lead to reading NDA with value "@desc2" and
CUBC with value "MAX desc1":

 INITD --------                    ------------
              |____________________|
       _______________________  _______________
 NDA       @desc2             \/   @desc3
       _______________________/\_______________
       __________  ___________  _______________
 CUBC       0    \/ MAX desc1 \/  MAX desc2
       __________/\___________/\_______________
        |  |          |  |
Events:(1)(2)        (3)(4)

(1) check_nda = @desc2
(2) initd = 1
(3) cur_ubc = MAX desc1
(4) cur_nda = @desc2

This is allowed by the condition ((check_nda == cur_nda) && initd),
despite cur_ubc and cur_nda being in the precise state we don't want.

This error leads to incorrect residue computation.

Fix it by inversing the order in which CUBC and INITD are read. This
makes sure that NDA and CUBC are always read together either _before_
INITD goes to 0 or _after_ it is back at 1.
The case where NDA is read before INITD is at 0 and CUBC is read after
INITD is back at 1 will be rejected by check_nda and cur_nda being
different.

Fixes: 53398f4888 ("dmaengine: at_xdmac: fix residue corruption")
Cc: stable@vger.kernel.org
Signed-off-by: Maxime Jayat <maxime.jayat@mobile-devices.fr>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-24 09:36:32 +02:00
..
bestcomm License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dw License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hsu
ioat dmaengine: ioat: Fix error handling path 2018-02-25 11:08:01 +01:00
ipu
ppc4xx Merge branch 'topic/ppc4xx' into for-linus 2017-09-06 21:54:41 +05:30
qcom dmaengine: qcom_hidma: check pending interrupts 2018-03-19 08:42:56 +01:00
sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xilinx dmaengine: zynqmp_dma: Fix race condition in the probe 2018-03-24 11:01:23 +01:00
Kconfig dmaengine: Add driver for Altera / Intel mSGDMA IP core 2017-07-18 22:04:54 +05:30
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
TODO
acpi-dma.c
altera-msgdma.c dmaengine: altera: Use IRQ-safe spinlock calls in the error paths as well 2017-10-20 11:51:10 +05:30
amba-pl08x.c dmaengine: pl08x: constify amba_id 2017-08-28 21:11:08 +05:30
at_hdmac.c dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved 2018-02-25 11:08:01 +01:00
at_hdmac_regs.h
at_xdmac.c dmaengine: at_xdmac: fix rare residue corruption 2018-04-24 09:36:32 +02:00
bcm-sba-raid.c dmaengine: bcm-sba-raid: Remove redundant SBA_REQUEST_STATE_COMPLETED 2017-08-28 16:44:24 +05:30
bcm2835-dma.c
coh901318.c
coh901318.h
coh901318_lli.c
cppi41.c
dma-axi-dmac.c
dma-jz4740.c dmaengine: jz4740: disable/unprepare clk if probe fails 2018-02-25 11:08:03 +01:00
dma-jz4780.c
dmaengine.c dmaengine: remove BUG_ON while registering devices 2017-08-28 09:39:46 +05:30
dmaengine.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dmatest.c dmaengine: dmatest: fix container_of member in dmatest_callback 2018-02-16 20:22:43 +01:00
edma.c dmaengine: edma: Align the memcpy acnt array size with the transfer 2017-09-21 22:51:07 +05:30
ep93xx_dma.c
fsl-edma.c dmaengine: fsl-edma: disable clks on all error paths 2018-03-03 10:24:22 +01:00
fsl_raid.c
fsl_raid.h
fsldma.c dmaengine: remove DMA_SG as it is dead code in kernel 2017-08-22 09:22:11 +05:30
fsldma.h
idma64.c
idma64.h
img-mdc-dma.c
imx-dma.c
imx-sdma.c
iop-adma.c
k3dma.c dmaengine: k3dma: remove useless ON_WARN_ONCE() 2017-08-25 12:15:40 +05:30
lpc18xx-dmamux.c
mic_x100_dma.c
mic_x100_dma.h
mmp_pdma.c
mmp_tdma.c
moxart-dma.c
mpc512x_dma.c
mv_xor.c dmaengine: remove DMA_SG as it is dead code in kernel 2017-08-22 09:22:11 +05:30
mv_xor.h
mv_xor_v2.c
mxs-dma.c
nbpfaxi.c dmaengine: remove DMA_SG as it is dead code in kernel 2017-08-22 09:22:11 +05:30
of-dma.c dmaengine: Convert to using %pOF instead of full_name 2017-07-19 09:30:44 +05:30
omap-dma.c
pch_dma.c
pl330.c dmaengine: pl330: constify amba_id 2017-08-28 21:11:08 +05:30
pxa_dma.c
s3c24xx-dma.c
sa11x0-dma.c
sirf-dma.c
st_fdma.c
st_fdma.h
ste_dma40.c Merge branch 'topic/dmatest' into for-linus 2017-09-06 21:55:10 +05:30
ste_dma40_ll.c
ste_dma40_ll.h
stm32-dma.c
sun4i-dma.c
sun6i-dma.c dmaengine: sun6i: support V3s SoC variant 2017-09-05 09:07:20 +05:30
tegra20-apb-dma.c
tegra210-adma.c dmaengine: tegra210-adma: fix of_irq_get() error check 2017-08-09 11:39:16 +05:30
ti-dma-crossbar.c dmaengine: ti-dma-crossbar: Fix event mapping for TPCC_EVT_MUX_60_63 2018-03-24 11:01:28 +01:00
timb_dma.c
txx9dmac.c
txx9dmac.h
virt-dma.c
virt-dma.h
xgene-dma.c dmaengine: xgene-dma: remove unused xgene_dma_invalidate_buffer 2017-08-22 22:13:44 +05:30
zx_dma.c