linux/drivers/dma
Addy Ke 0091b9d6c1 dmaengine: pl330: fix bug that cause start the same descs in cyclic
This bug will cause NULL pointer after commit dfac17, and cause
wrong package in I2S DMA transfer before commit dfac17.

Tested on RK3288-pinky2 board.

Detail:
I2S DMA transfer(sound/core/pcm_dmaengine.c):
dmaengine_pcm_prepare_and_submit -->
dmaengine_prep_dma_cyclic -->
pl330_prep_dma_cyclic -->
the case:
1. pl330_submit_req(desc0): thrd->req[0].desc = desc0, thrd->lstenq = 0
2. pl330_submit_req(desc1): thrd->req[1].desc = desc1, thrd->lstenq = 1
3. _start(desc0) by submit_req: thrd->req_running = 0
   because: idx = 1 - thrd->lstenq = 0
4. pl330_update(desc0 OK): thrd->req[0].desc = NULL, desc0 to req_done list
   because: idx = active = thrd->req_running = 0
5. _start(desc1) by pl330_update: thrd->req_running = 1
   because:
   idx = 1 - thrd->lstenq = 0, but thrd->req[0].desc == NULL,
   so:
   idx = thrd->lstenq = 1
6. pl330_submit_req(desc2): thrd->req[0].desc = desc2, thrd->lstenq = 0
7. _start(desc1) by submit_req: thrd->req_running = 1
   because: idx = 1 - thrd->lstenq = 1
   Note: _start started the same descs
         _start should start desc2 here, NOT desc1

8. pl330_update(desc1 OK): thrd->req[1].desc = NULL, desc1 to req_done list
   because: idx = active = thrd->req_running = 1
9. _start(desc2) by pl330_update : thrd->req_running = 0
   because: idx = 1 - thrd->lstenq = 0
10.pl330_update(desc1 OK, NOT desc2): thrd->req[0].desc = NULL,
   desc2 to req_done list
   because: idx = active = thrd->req_running = 0

11.pl330_submit_req(desc3): thrd->req[0].desc = desc3, thrd->lstenq = 0
12.pl330_submit_req(desc4): thrd->req[1].desc = desc4, thrd->lstenq = 1
13._start(desc3) by submit_req: thrd->req_running = 0
   because: idx = 1 - thrd->lstenq = 0
14.pl330_update(desc2 OK NOT desc3): thrd->req[0].desc = NULL
   desc3 to req_done list
   because: idx = active = thrd->req_running = 0
15._start(desc4) by pl330_update: thrd->req_running = 1
   because:
   idx = 1 - thrd->lstenq = 0, but thrd->req[0].desc == NULL,
   so:
   idx = thrd->lstenq = 1
16.pl330_submit_req(desc5): thrd->req[0].desc = desc5, thrd->lstenq = 0
17._start(desc4) by submit_req: thrd->req_running = 1
   because: idx = 1 - thrd->lstenq = 1
18.pl330_update(desc3 OK NOT desc4): thrd->req[1].desc = NULL
   desc4 to req_done list
   because: idx = active = thrd->req_running = 1
19._start(desc4) by pl330_update: thrd->req_running = 0
   because:
   idx = 1 - thrd->lstenq = 1, but thrd->req[1].desc == NULL,
   so:
   idx = thrd->lstenq = 0
20.pl330_update(desc4 OK): thrd->req[0].desc = NULL, desc5 to req_done list
   because: idx = active = thrd->req_running = 0
21.pl330_update(desc4 OK):
   1) before commit dfac17(set req_running -1 in pl330_update/mark_free()):
      because: active = -1, abort
      result: desc0-desc5's callback are all called,
	      but step 10 and step 18 go wrong.
   2) before commit dfac17:
      idx = active = thrd->req_runnig = 0 -->
      descdone = thrd->req[0] = NULL -->
      list_add_tail(&descdone->rqd, &pl330->req_done); -->
      got NULL pointer!!!

Signed-off-by: Addy Ke <addy.ke@rock-chips.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
2015-02-10 16:20:19 -08:00
..
bestcomm dma: bestcomm: drop owner assignment from platform_drivers 2014-10-20 16:20:28 +02:00
dw dmaengine: dw: define DW_DMA_MAX_NR_MASTERS 2015-02-04 22:39:44 -08:00
ioat ioat: fail self-test if wait_for_completion times out 2015-02-04 22:54:22 -08:00
ipu dmaengine: ipu-idmac: Split device_control 2014-12-22 12:28:59 +05:30
ppc4xx dma: ppc4xx: drop owner assignment from platform_drivers 2014-10-20 16:20:29 +02:00
sh Merge branch 'topic/rcar' into for-linus 2015-02-02 16:55:43 -08:00
xilinx dmaengine: xilinx: Split device_control 2014-12-22 12:33:21 +05:30
acpi-dma.c acpi-dma: convert to return error code when asked for channel 2014-02-11 23:30:50 +05:30
amba-pl08x.c dmaengine: pl08x: Split device_control 2014-12-22 12:28:56 +05:30
at_hdmac_regs.h dmaengine: at_hdmac: update the driver comments 2014-12-22 20:24:14 +05:30
at_hdmac.c dmaengine: at_hdmac: declare slave capabilities 2015-01-14 00:04:02 +05:30
at_xdmac.c dmaengine: at_xdmac: allow muliple dwidths when doing slave transfers 2015-02-04 23:12:29 -08:00
bcm2835-dma.c dmaengine: bcm2835: Declare slave capabilities for the generic code 2014-12-22 12:33:23 +05:30
coh901318_lli.c Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma 2013-02-26 09:24:48 -08:00
coh901318.c dmaengine: coh901318: fix function return types build warnings 2015-01-18 20:01:36 +05:30
coh901318.h dma: coh901318: merge header files 2013-01-07 17:36:37 +01:00
cppi41.c dmaengine: cppi41: Split device_control 2014-12-22 12:28:57 +05:30
dma-jz4740.c dmaengine: jz4740: Split device_control 2014-12-22 12:28:58 +05:30
dmaengine.c dmaengine: Move dma_get_slave_caps() implementation to dmaengine.c 2015-01-18 19:55:57 +05:30
dmaengine.h dmaengine: consolidate initialization of cookies 2012-03-13 11:37:22 +05:30
dmatest.c dmatest: move src_off, dst_off, len inside loop 2015-02-04 18:17:21 -08:00
edma.c dmaengine: edma: Declare slave capabilities for the generic code 2014-12-22 12:33:23 +05:30
ep93xx_dma.c dmaengine: ep93xx: update the driver comments 2014-12-22 20:27:25 +05:30
fsl-edma.c dmaengine: fsl-edma: Declare slave capabilities for the generic code 2014-12-22 12:33:23 +05:30
fsldma.c dmaengine: fsldma: remove the unused variable 2015-01-13 23:58:08 +05:30
fsldma.h dmaengine: fsldma: declare slave capabilities for the generic code 2015-01-13 23:58:08 +05:30
img-mdc-dma.c dmaengine: Add driver for IMG MDC 2015-02-04 18:13:32 -08:00
imx-dma.c Merge branch 'topic/slave_caps_device_control_fix_rebased' into for-linus 2015-02-02 16:55:35 -08:00
imx-sdma.c Merge branch 'topic/slave_caps_device_control_fix_rebased' into for-linus 2015-02-02 16:55:35 -08:00
intel_mid_dma_regs.h dma: fix comments 2012-09-01 08:57:12 -07:00
intel_mid_dma.c dmaengine: intel-mid-dma: Split device_control 2014-12-22 12:28:59 +05:30
iop-adma.c dmaengine: Remove .owner field for driver 2014-11-06 11:54:18 +05:30
k3dma.c dmaengine: k3: fix duplicate function definition 2015-01-13 21:20:09 +05:30
Kconfig dmaengine: Add driver for IMG MDC 2015-02-04 18:13:32 -08:00
Makefile dmaengine: Add driver for IMG MDC 2015-02-04 18:13:32 -08:00
mic_x100_dma.c dma: MIC X100 DMA Driver 2014-07-12 09:57:42 -07:00
mic_x100_dma.h dma: MIC X100 DMA Driver 2014-07-12 09:57:42 -07:00
mmp_pdma.c dmaengine: mmp-pdma: Split device_control 2014-12-22 12:29:00 +05:30
mmp_tdma.c dmaengine: mmp-tdma: fix terminate_all return code 2015-01-13 21:20:10 +05:30
moxart-dma.c dmaengine: moxart: Split device_control 2014-12-22 12:29:01 +05:30
mpc512x_dma.c dmaengine: mpc512x: Split device_control 2014-12-22 12:29:04 +05:30
mv_xor.c dmaengine: mv_xor: Remove device_control 2014-12-22 12:33:22 +05:30
mv_xor.h dma: mv_xor: Add support for DMA_INTERRUPT 2014-09-23 20:17:01 +05:30
mxs-dma.c dmaengine: mxs-dma: Declare slave capabilities for the generic code 2015-01-13 23:48:40 +05:30
nbpfaxi.c dmaengine: nbpfaxi: update the driver comments 2014-12-22 20:28:04 +05:30
of-dma.c dmaengine: of: bail out early if "dmas" property is not present 2015-01-25 22:44:23 -08:00
omap-dma.c dmaengine: omap: fix the assignment to .device_config 2014-12-22 12:34:22 +05:30
pch_dma.c dmaengine: pch-dma: Rename device_control 2014-12-22 12:33:22 +05:30
pl330.c dmaengine: pl330: fix bug that cause start the same descs in cyclic 2015-02-10 16:20:19 -08:00
qcom_bam_dma.c dmaengine: bam-dma: Split device_control 2014-12-22 12:32:15 +05:30
s3c24xx-dma.c dmaengine: s3c24xx: missing unlock on an error path 2015-02-04 17:52:42 -08:00
sa11x0-dma.c dmaengine: sa11x0: Fix warning and compilation errors 2015-01-18 20:01:15 +05:30
sirf-dma.c dmaengine: sirf: Declare slave capabilities for the generic code 2014-12-22 12:34:21 +05:30
ste_dma40_ll.c dmaengine: ste_dma40_ll: Replace meaningless register set with comment 2013-06-04 11:12:10 +02:00
ste_dma40_ll.h dmaengine: ste_dma40: Remove unnecessary call to d40_phy_cfg() 2013-05-23 21:13:19 +02:00
ste_dma40.c dmaengine: ste_dma: fix incompatible pointer type warns 2014-12-22 12:34:23 +05:30
sun6i-dma.c dmaengine: sun6i: Declare slave capabilities for the generic code 2014-12-22 12:34:21 +05:30
tegra20-apb-dma.c dmaengine: tegra: add slave capabilities reporting 2015-01-14 00:00:30 +05:30
timb_dma.c dmaengine: td: Rename device_control 2014-12-22 12:33:22 +05:30
TODO dmaengine: dw: don't perform DMA when dmaengine_submit is called 2014-07-15 22:14:30 +05:30
txx9dmac.c dmaengine: txx9: Rename device_control 2014-12-22 12:33:22 +05:30
txx9dmac.h MIPS: Replace MIPS-specific 64BIT_PHYS_ADDR with generic PHYS_ADDR_T_64BIT 2014-11-24 22:46:44 +01:00
virt-dma.c dmaengine: virt-dma: add support for cyclic DMA periodic callbacks 2012-07-01 14:15:23 +01:00
virt-dma.h dma: fix vchan_cookie_complete() debug print 2014-01-26 17:33:45 +05:30