1
0
Fork 0
Commit Graph

3646 Commits (redonkable)

Author SHA1 Message Date
Guoniu.Zhou 3eff3a6d64 MLK-15325: pxp-v3: Modify pxp pitch parameter and csc
coefficient setting.

Because the caller of pxp-v3 does not set the stride parameter,
this will cause pitch parameter to be zero and pxp can't work.

Correct the csc1 coefficient when use pxp convert YUV to RGB format.

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 4134e06c26 MLK-15330-3 dma: fsl-edma-v3: add dual fifo support
There is Audio dual fifo cause that fill fifo one by one and
loop back after every minor loop:
  -- fill the first 32bit width fifo
  -- fill the next 32bit width fifo
  -- +MLOFF signed offset after the above two FIFOs filled
  -- loop back to the first step to handle the next minor loop.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 8a66c72101 MLK-15330-1: dma: fsl-edma-v3: combine two cells into one
For dual fifo case, fsl-edma-v3 need add another cell. It's not friendly
for user and it's possible other cells maybe added to other use cases,
so combine two cells into one now, and for some special use cases such as
dual fifo property can directly be passed by one bit of cell3 rather than
another cell.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong a5c8f7c10f MLK-15034: dma: imx-sdma: no need report interrupt for channel0
It is possible for an irq triggered by channel0 to be received later,
after clks are disabled. If that happens then clearing them by writing
to SDMA_H_INTR won't work and the system will hang processing infinite
interrupts. Actually, don't need interrupt triggered on channel0 since
it's pollling to know channel0 done rather than interrupt in current
code, just clear BD setting to disable channel0 interrupt to avoid the
above case.

Reported-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Han Xu 8f2b815378 MLK-15284-4: dma: Kconfig: add MXS_DMA dependency for ARM64
add MXS_DMA dependency for ARCH_MXC_ARM64

The patch also merge the upstreamed change that extend the dependency to
allow the mxs dma driver to be built whenever ARCH_MXS or ARCH_MXC is
selected. Refer to
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/dma/Kconfig?h=next-20170626&id=d762e4f35601239cbebfbfd43d99876d8f220927

Signed-off-by: Han Xu <han.xu@nxp.com>
2018-10-29 11:10:38 +08:00
Han Xu 87105a8356 MLK-15284-2: dma: mxs-dma: add i.MX8QXP support in mxs-dma
add one more entry for i.MX8QXP mxs-dma, also check mxs_dma in filter
function.

Signed-off-by: Han Xu <han.xu@nxp.com>
2018-10-29 11:10:38 +08:00
Leonard Crestez 70b1c408f7 MLK-15151: dma: imx-sdma: Fix keepings clks enabled on sdma_resume error
This is obviously a bug but I don't know of a scenario where those errors
might happen.

Fixes: 7e84737c9c ("MLK-11385 dma: imx-sdma: enable clock before context restored")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 394f9be303 MLK-15135-2 dma: Kconfig: add sdma on i.mx8mq
select sdma on i.mx8mq.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong d1b6e3e9c0 MLK-15135-1: dma: imx-sdma: fix build warning on aarch64
fix below build warning with aarch64:
drivers/dma/imx-sdma.c: In function ‘sdma_prep_dma_cyclic’:
drivers/dma/imx-sdma.c:1727:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat=]
   dev_dbg(sdma->dev, "entry %d: count: %d dma: %pad %s%s\n",

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Guoniu.Zhou 4e263e9ce3 MLK-15041: PXP-V3: enable stroe engine block mode and fill function
1. When pxp do rotation, fetch and store engine need block mode.
2. When use pxp store engine fill function, not only need config
store engine, but also need config fetch engine, otherwise, it
will not work.

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
2018-10-29 11:10:38 +08:00
Cristina Ciocan 6f841088a5 MLK-15027: arm: pxp: Fix uninitialized use of variables
This patch fixes build warning that 2 variables may be used uninitialized
in the pxp_fetch_config() function in drivers/dma/pxp/pxp_dma_v3.c .

The variables in_fmt and out_fmt are passed as parameters to
pxp_fetch_shift_calc() only if shift_bypass is false. This flag cannot be
false unless changed in a code block that also assigns in_fmt and out_fmt.

Since the compiler cannot detect this flow, it shows a warning that in_fmt
and out_fmt are not initialized. Fix this by changing the code flow such
that in_fmt and out_fmt are sent as parameters in the same code block where
they are assigned.

Signed-off-by: Cristina Ciocan <cristina-mihaela.ciocan@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong f2d83ee89b MLK-15014 dma: fsl-edma-v3: clear DONE before E_SG enabled
Below described in RM, otherwise, channel error status(CHa_ES)
may be triggered:
The user must clear the CHa_CSR[DONE] bit before writing the
TCDa_CSR[MAJORELINK] or TCDa_CSR[ESG] bits.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Shengjiu Wang 4a473d879f MLK-15003-1: DMA: fsl-edma-v3: add one more parameter for xlate
The parameter is "is_remote", which is to use remote access for
edma, the default access is local access.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2018-10-29 11:10:38 +08:00
Guoniu.Zhou 624f4cdc15 MLK-14963 PXP: enable pxp interrupt after soft reset
After soft reset, the irq register value will be zero, so we need set it to enable
all pxp interrupts.

Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 26683929dc MLK-14976: dma: virt-dma: free description after callback
Some drivers may access dma_async_tx_descriptor in callback such as
tty/serial/fsl_lpuart.c, but the description has already been freed
before callback, memory corrupt here. Move the free description
behind of callback.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Daniel Baluta 6981369c04 MLK-14528: ASoC: sdma: Update period/segment max bytes
Commit 665ced16cf ("MLK-10050 dma: imx-sdma: add support for sdma
memory copy") enforces maximum SDMA buffer descriptor length at 65532,
but doesn't update period_bytes_max or max_segment size in DMA drivers.

Thus, resulting in the following bug:

$ arecord -Dhw:0,0 -r 192000 -f S20_3LE -c 1 -d 10 audio192k20b1c.wav
imx-sdma: SDMA channel 5: maximum period size exceeded: 65534 > 65532

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2018-10-29 11:10:38 +08:00
Guoniu.Zhou 60aea081f1 MLK-14771 dma: pxp-v3: add new added 2D features support
The V3 version PXP has added below new 2D features:
	1. Input fetch/store blocks to accept different formats input/output.
	2. Add Rotation1 block to do rotation before alpha blending.
	3. Add Composite1 block to accept source from input fetch.
	4. AS and PS have increased supported pixel formats.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit 4daef24b19890ca65135c48fc24018f64761444f)
2018-10-29 11:10:38 +08:00
Fancy Fang ab5c921b67 MLK-14314-14 dma: pxp-v3: derive the shortest path table for 2D nodes
Based on the previously caculated adjacent list and mux
config info, the shortest path table can be derived by
distance calculation between two different 2D nodes.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit c8adf0f7089d5c5e286d7ae74c138a84bed5e280)
2018-10-29 11:10:38 +08:00
Fancy Fang cdc8b49342 MLK-14314-13 dma: pxp-v3: construct graph structures to store pxp nodes.
According to the PXP arch diagram, the V3 PXP can be
abstracted to a graph structure. There are totally
16 2D nodes in PXP and 16 2D related mux nodes:

     1. Using '16x16' adjacent array to record the 2D nodes
        relationship and '16' size array to record the
        input and output nodes for each muxe node.
     2. Construct the adjacent list to store all the 2D
        nodes and also config the mux info used by each
        two nodes of one edge during pxp probing stage.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit e8087406df2e04982fd90b4070ac68fafa4ad3d5)
2018-10-29 11:10:38 +08:00
Fancy Fang 230536b678 MLK-14314-12 dma: pxp-v3: refine pxp timer init in probe()
Extract the timer initialization from pxp_probe()
to a seperate function call to make probing process
more clear.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit c8a127e506bca2e38fae02c03ceae4e6956d6ea3)
2018-10-29 11:10:38 +08:00
Fancy Fang 7ca1c66dde MLK-14314-11 dma: pxp-v3: refine attributes create in probe()
Extract the attributes creation from the pxp_probe()
to a seperate function call to make the probing process
more clear.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 85ab5476bf59a407037b43419b920b681b58b52d)
2018-10-29 11:10:38 +08:00
Fancy Fang 59c21d5e53 MLK-14314-10 dma: pxp-v3: refine m4 init in probe()
Extract the m4 related initialization code from
pxp_probe() to make the probing function more
clear.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit f1bd8146332f880b75f08eab64505070069018fb)
2018-10-29 11:10:38 +08:00
Fancy Fang 50753a5496 MLK-14314-9 dma: pxp-v3: refine pxp interrupt init code
The PXP interrupt functions in V3 is relatively complex.
So do the interrupt initalization in a sperate function
to make the pxp_probe() more clear.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 2fa43d26f81cf0331820b41bc198adbb414c0c37)
2018-10-29 11:10:38 +08:00
Fancy Fang 3aa83bf342 MLK-14314-8 dma: pxp: remove meaningless assignments in probe()
Remove some assignments which have no real effects for
V2 and V3 PXP drivers, since using devm_kzalloc() to
make the data to be zero.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit a6d6e4d2b6b21427c529a33a7d47ddc918b19eb7)
2018-10-29 11:10:38 +08:00
Fancy Fang 2dfaae7c0c MLK-14314-6 dma: pxp: change some RGB formats definition
Some RGB formats fourcc definition are not precise
according to its original meaning. So make some
changes for them.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit b0b4ad680e267bdf542d2c9a3202c0192bde9cb0)
2018-10-29 11:10:38 +08:00
Fancy Fang eadab7db15 MLK-14314-5 dma: pxp-v3: divide whole pxp into four parts
According to the pxp high level architecture diagram,
it is better to divide the whole big pxp module into
four sub-modules:
   1. 2D operation module(legacy pxp and input fetch & store).
   2. Dithering module.
   3. WFE_A module.
   4. WFE_B module.
This division will simplify driver implementations and
management.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 5e57840b41adb195515bd652d9624feaadf3448e)
2018-10-29 11:10:38 +08:00
Fancy Fang ea801c35b5 MLK-14314-4 dma: pxp-v3: abstract ps and out fmts parse functions
Abstract PS and OUT formats parsing jobs to seperate
functions 'pxp_parse_ps_fmt()' and 'pxp_parse_out_fmt()'
to make the code clean and easier to maintain.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 3e2cd1880fdf219c77f119fa5c9fb33e50e8654c)
2018-10-29 11:10:38 +08:00
Fancy Fang 669ee4cd76 MLK-14314-3 pxp-v3: add 'need_yuv_swap' field
Add 'need_yuv_swap' field to 'pxp_proc_data' structure to
record the yuv formats which needs byte swap.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 28ce43b27faad915e93f47b438d23f4ebfe020b5)
2018-10-29 11:10:38 +08:00
Fancy Fang 0434c64e16 MLK-14314-2 dma: pxp: refine is_yuv().
Use 'switch' statement to replace 'if' statement to
make logic more clear and easier to maintain.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit ca1b4393b86054a81bb40ad856af9c4f166841ea)
2018-10-29 11:10:38 +08:00
Fancy Fang 73d269b2eb MLK-14314-1 dma: pxp: remove unused multiple overlay layers support
The multiple overlay layers are not used on pxp v2 and
v3 module, so remove this.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit c4fd8b36dbf9b53079d88d55ccfedde3a444ec29)
2018-10-29 11:10:38 +08:00
Robby Cai 859328d871 MLK-14518-2 pxp: set data path for pxp after reset
it's needed for pxp legacy process, so set it just after
pxp does the reset.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 5cd462d857 MLK-14518-1 pxp: initialize pxp according to recommended flow
use pxp_soft_reset() in probe and resume function because this implementation
follows the recommended flow in the IC spec.
without soft reset, when only use wfe_a process without legacy process it's
likely to meet timeout issue since. In other words, wfe_a process need the
soft reset to work properly.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 2d9575f930 MLK-14369 epdc: sync LUT status to PXP before enable collision detection
on imx7d and imx6ull/imx6sll, the collision detection logic is implemented
in PXP WFE (A on imx7d, or B on imx6ull/imx6sll) instead of the logic
implemented on EPDC on previous SoCs (like imx6sl/imx6dl). The driver need
read the LUT status and send this information to PXP WFE (A on imx7d, or B
on imx6ull/imx6sll) engine, so that PXP WFE engine can detect if there is
an active LUT assigned to the pixels affected by current update.
Without this patch, there could possibly be some false collision report due
to the out-of-sync. The patch intends to fix it.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 39497c272e MLK-13198 pxp: imx7d: fix error histogram status report issue
The cause is the legacy process involves PXP AS engine accidentally to
process data, which results to one pixel at (0,0) to be changed. This
will cause an incorrect histogram calculation.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 0f536a36eb MLK-14610 DMA: fsl-edma-v3: add fsl-edma-v3 support
Add edma-v3 driver on i.mx8qm.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robert Chiras 1207a568d5 MLK-14524: dma: Fix division by zero
The audio driver is initialized by preparing a DMA slave channel using 0's
as parameters in sdma_prep_dma_cyclic function. This would lead to a
division by zero, since period_len is used as a divisor.
Used the code from 4.1 to fix this, where the division is made only for
non HDMI peripheral types.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan cb20852875 MLK-14541 dmaengine: fsl-edma: remove the duplicated code
The function .fsl_edma_irq_init() has been called twice in .probe(), which
cause all dma controller registered failed.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan a28ab62516 MLK-13712 dmaengine: fsl-edma: restore edma registers for i.MX7ULP VLLS mode
EDMA controller will loss power on i.MX7ULP VLLS mode, then registers
are set to HW reset default value that cause EDMA cannot work after
system wake up. So the patch is to restore eDMA registers status after
system exit from VLLS mode.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit:bc15f814383d)

Conflicts:
	drivers/dma/fsl-edma.c
2018-10-29 11:10:38 +08:00
Robin Gong b3ef615a10 MLK-14514-2 dma: sdma: use dma_pool_free instead of dma_free_coherent
Some drivers may call terminate dma channel in interrupt, thus
we'd better use dma_poo_free.(Documentation/DMA-API-HOWTO.txt)

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan cd77d0162c MLK-14498-10 dma: imx-sdma: fix wrong chn_real_count in cyclic mode
The sdmac->chn_real_count is equal to sdmac->period_len in dma cyclic
mode that is not correct, correct it to real count in current BD transfer.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan 89487716c2 MLK-14498-7 dma: imx-sdma: pass ->dev to dma_alloc_coherent() API
Pass ->dev to dma_alloc_coherent() API.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan f09f749456 MLK-14498-4 dma: imx-sdma: remove the redundant clock operation
Remove the redundant clock operation.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan ea2d382144 MLK-14498-3 dma: imx-sdma: avoid dead lock in cyclic case
Avoid dead lock in DMA cyclic case.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong d3e1eb2553 MLK-11689: dma: imx-sdma: correct channel context restore
Before, checking SDMA_H_C0PTR register to know whether sdma controller turned
off in DSM, if yes restore channel context back. Unfortunatly, this checking
is wrong, because SDMA_H_C0PTR has been initialized as non-zero value in
sdma_resume, which means channel context will never be restored back if mega/
fast off on i.mx6sx or i.mx7d. Using 'suspend_off' flag to keep this 'restore
needed' requirement.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 565d4c45926a03029d7750a57f3e3f2404de7301)
(cherry picked from commit 70dbe82f8f)
2018-10-29 11:10:38 +08:00
Robin Gong a3053e7462 MLK-11358-6: dma: imx-sdma: reload context once sdma channel terminated
Some driver may call dmaengine_terminate_all firstly, and then start next by
calling dmaengine_prep_* without dmaengine_slave_config. In this case sdma
transfer failed since no context loaded, take this case in this patch.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 51ff948df5)
2018-10-29 11:10:38 +08:00
Robin Gong ea847b9a76 MLK-14482-2: dma: imx-sdma: add virt-dma support
Old sdma can't support multi instances, because next transfer will return
error if the last transfer not done(sdmac->status == DMA_IN_PROGRESS). virt
dma is a common framework for versus dma drivers, and it's support multi
instances, driver can dynamicly alloc description and add it to list which
will be handled in the last sdma transfer done later.

Another advantage of this patch is to clean up the constrain of max bd numer:
--#define NUM_BD (int)(PAGE_SIZE / sizeof(struct sdma_buffer_descriptor))
in other words, now sdma driver can support any length data now.

Meanwhile, remove sdma_load_context() in prep_* everytime, since it can do
only once in config channel.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>

When porting to 4.14 transformed upstream sdma_disable_channel_with_delay
into sdma_terminate_all_with_delay.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong bcd8dbc9bc MLK-14482-1: dma: imx-sdma: fix memory_2_memory copy failed
emi_2_emi have to be set in memory_2_memory case, code miss during
rebase, fix up it now.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 6eb6ff1370 MLK-13862-2 epdc/pxp: imx6ull/imx6sll: enhance the LUT cleanup flow to avoid stalling display
- change setting for wfe_b to support new flow
  (note there's no wfe_a on i.mx6ull/i.mx6sll, while on i.mx7d wfe_a is used
  for this purpose)
- the underlying design policy change as follows (similar to i.mx7d).
  in previous flow, when all LUTs are used, the LUT cleanup operation
  need to wait for all the LUT to finish, it will not happen util last LUT
  is done. while in new flow, the cleanup operation does not need to wait
  for all LUTs to finish, instead it can start when there's LUT's done.
  The saved time is multiple LUT operation time.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 1d5f0d3b4a MLK-13862-1 epdc/pxp: imx7d: enhance the LUT cleanup flow to avoid stalling display
- change from wfe_b to wfe_a, and modifiy register settings to support new flow
- the underlying design policy change as follows.
  in previous flow, when all LUTs are used, the LUT cleanup operation
  need to wait for all the LUT to finish, it will not happen util last LUT
  is done. while in new flow, the cleanup operation does not need to wait
  for all LUTs to finish, instead it can start when there's LUT's done.
  The saved time is multiple LUT operation time.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 80349e0f29 MLK-13737 pxp: refine dithering setting
- use different LUT setting and coefficient setting for different quantization
  bits.
- clear CTRL0_MUX14_SEL to 0 only when use dithering algorithm, set to 1 for
  not using dithering module.
- bypass PXP_OUT_AS for dithering and add DITHER_STORE_SIZE setting

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong f760f8d4ea MLK-13849 dma: imx-sdma: fix kernel crashs when play Audio by HDMI
In cyclic/loop mode, DMA call shouldn't touch dma cookie, since only one
time need to be submitted, otherwise, below kernel bug will be triggered:

Playing WAVE '/unit_tests/audio8k16S.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
------------[ cut here ]------------
Kernel BUG at 8043d030 [verbose debug info unavailable]
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
Modules linked in: ov5642_camera mxc_v4l2_capture ipu_bg_overlay_sdc ipu_still ipu_prp_enc ipu_csi_enc ipu_fg_overlay_sdc ov5640_camera_mipi_int ov5640_camera_int v4l2_int_device mxc_dcic
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.9.5-01681-g6dbd27b #7
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
task: 80f06600 task.stack: 80f00000
PC is at mxc_sdma_handle_channel_normal+0xc0/0xd8
LR is at tasklet_action+0x94/0x14c

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Signed-off-by: Mihai Serban <mihai.serban@nxp.com>
2018-10-29 11:10:38 +08:00
Nandor Han d4bcb2637d MLK-13794: BACKPORT: dmaengine: imx-sdma - correct the dma transfer residue calculation
This patch fixes crackling sound reported when running autorun-asrc.sh
and it is a backport of 85f57752b3 ("dmaengine: imx-sdma - correct
the dma transfer residue calculation") from v10-rc6.

Original commit message:

	From: Nandor Han <nandor.han@ge.com>
	Date: Tue, 11 Oct 2016 14:13:41 +0300
	Subject: [PATCH] dmaengine: imx-sdma - correct the dma transfer residue
	 calculation

	The residue calculation was taking in consideration that dma
	transaction status will be always retrieved in the dma callback
	used to inform that dma transfer is complete. However this is not
	the case for all subsystems that use dma. Some subsystems use a
	timer to check the dma status periodically.

	Therefore the calculation was updated and residue is calculated
	accordingly by a) update the residue calculation taking in
	consideration the last used buffer index by using *buf_ptail* variable
	and b) chn_real_count (number of bytes transferred) is initialized to
	zero, when dma channel is created, to avoid using an uninitialized
	value in residue calculation when dma status is checked without
	waiting dma complete event.

Signed-off-by: Nandor Han <nandor.han@ge.com>
Acked-by: Peter Senna Tschudin <peter.senna@collabora.com>
Tested-by: Peter Senna Tschudin <peter.senna@collabora.com>
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan df15ec3d51 MLK-13554-02 dmaengine: fsl-edma: enable the correct the DMAMUX
- correct DMAMUX enable bit.
- correct mapping the DMAMUX source and slot.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2018-10-29 11:10:38 +08:00
Andy Duan ef2e962fff MLK-13529-2 dmaengine: fsl-edma: calculate the real count for sg
Calculate the rela count for the case that eDMA stop after get eeop signal.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong c5ac0acc20 MLK-13529-1 dmaengine: fsl-edma: support edma2 on ULP1
Updated the edma driver to support edma2 on ULP1.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Fancy Fang 73877d9b4e MLK-12983 dma: pxp: add sanity check in pxp_set_scaling()
Add the sanity check for drect's width and height in
pxp_set_scaling() to avoid div0 exception.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2018-10-29 11:10:38 +08:00
Fancy Fang 449010cf26 MLK-12972 dma: pxp-v3: add asynchronous multi-task support
Using a dedicated kernel thread to dispatch all the client
requests which can support asynchronous multi-task.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai fc707b723f MLK-12908-2 damengine: pxp: fix the histogram setting for i.mx7d
the commit 1b98a9be39a37c2d3ad239c3a1a3a1af1d4ac637 breaks the setting for mx7d.
the patch fixes it.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 36d30ecc54 MLK-12908-1 damengine: pxp: correct dithering setting
dithering test will met timeout issue on i.MX6ULL platform.
to reproduce, run ' /unit_tests/mxc_epdc_v2_fb_test.out -n 17 -d 1 -q 1'

Ginger dithering mode "Floyd-Steinberg" and quant_bit 1
imx_epdc_v2_fb 228c000.epdc: PxP operation failed due to timeout
imx_epdc_v2_fb 228c000.epdc: Unable to complete PxP update task: dithering process
imx_epdc_v2_fb 228c000.epdc: Timed out waiting for update completion

This patch corrects the setting (different from V3 on i.MX7D).

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai 0befe35454 MLK-12893 dma-engine: pxp: correct histogram setting
- HIST_A as collision, need set to 1 for wfb_store
- WFE-A flag0~3 changed to WFE-B flag4~7 on i.MX6ULL

This patch fixes the collision issue and some part of
updated region can not display with auto waveform mode.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Robby Cai eda0685a3e MLK-12811-1 pxp-dma: update PxP driver for i.MX6ULL
on i.MX6ULL, the WFE_A is removed due to die size, but instead use WFE_B
to the task for WFE_A. We may call this version as V3P - V3 patch.

use device_id to differentiate the operations on different version.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2018-10-29 11:10:38 +08:00
Fancy Fang 6dfdaba817 MLK-12695 dma: pxp-v2: fixing the mismatch calls of pm_runtime suspend/resume
The 'pm_runtime_get_sync()' and 'pm_runtime_put_sync_suspend()'
may be called not pairs. And this will cause the 'usage_count'
to be negative.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 10135c736dfc1b3d5c449adb78118e3642b99276)
2018-10-29 11:10:38 +08:00
Fancy Fang 74360d8f97 MLK-12669-2 dma: pxp-v3: add 'ipg' and 'axi' clocks
Add 'ipg' and 'axi' clocks for pxp which should
be used to control runtime power managments.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2018-10-29 11:10:38 +08:00
Fancy Fang 937972ac4a MLK-12420 fix potential head list corruption.
The head list may be corrupted when two requests from
the same 'pxp_chan' are issued sequentially. So change
the issue_pending function to strictly serialized the
requests to avoid this kind of issue.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2018-10-29 11:10:38 +08:00
Fancy Fang d7e35ba8f7 MLK-12213 dma: pxp-v2: fix the potential resource leak issue reported by Coverity
There may be potential memory leak when the 'desc' allocation failed.
The previous allocated descriptors should be freed when the allocation
failed.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2018-10-29 11:10:38 +08:00
Fugang Duan b094f8daff MLK-12188 dmaengine: fsl-edma: add fsl_chan->edesc NULL check
Add fsl_chan->edesc NULL when calling .fsl_edma_desc_residue() to avoid
NULL pointer access.

Signed-off-by: Fugang Duan <B38611@freescale.com>
2018-10-29 11:10:38 +08:00
Robin Gong 4e3a746d7b MLK-12175: dma: imx-sdma: fix issues repoted by Coverity
Fix two code issues, but not function break or potential bug:
  --Unsigned compared against 0 (NO_EFFECT)
  --Wrong size argument (SIZEOF_MISMATCH)

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2018-10-29 11:10:38 +08:00
Robin Gong 618285375d MLK-12076-3: dma: imx-sdma: add imx6ul device type
Add imx6ul device type to enable the ERR008517 workaround or not by dts.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 17d6a090b7a39bfd7836a3685d20201dcb0fa25e)
2018-10-29 11:10:38 +08:00
Fancy Fang 78cb00dc10 MLK-11913 dma: pxp-v3: remove some duplicate dead code
The code slice in the pxp_probe() function:
"
       if (!res || irq < 0) {
               err = -ENODEV;
               goto exit;
       }
"
appears twice closely. And the second code slice will become
dead code which is never executed. So remove the second one.

Signed-off-by: Fancy Fang <chen.fang@freescale.com>
2018-10-29 11:10:38 +08:00
Fancy Fang 27df7db7bd MLK-11907 dma: pxp-dev: allocate the 'sg' buffer dynamically.
The 'sg' buffer should be allocated dynamically, since its
size is dependent on the 'sg_len' which is calculated
according to the functions required.

Signed-off-by: Fancy Fang <chen.fang@freescale.com>
(cherry picked from commit 57f08c108fc4f4721449b4b94be9820c7443978a)
2018-10-29 11:10:38 +08:00
Fancy Fang 2d6f7ff5bf MLK-11841 dma: pxp: change 'CONFIG_PM_RUNTIME' to 'CONFIG_PM'
The 'CONFIG_PM_RUNTIME' has been eliminated and all the users
should use 'CONFIG_PM' directly. So do this change for pxp-v2
and pxp-v3.

Signed-off-by: Fancy Fang <chen.fang@freescale.com>
2018-10-29 11:10:38 +08:00
Zidan Wang 26f37f2953 MLK-11530-04 dmaengine: imx-sdma: add hdmi audio support
No need to alloc bd for hdmi audio, and the period len of hdmi audio is
0, so add constraint for it.

And correct per_address and per_address2 for hdmi audio.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
2018-10-29 11:10:38 +08:00
Shengjiu Wang 47cb2707cd MLK-11424: dmaengine: imx-sdma: slave_sg can't work after running cyclic
After running asrc p2p, then asrc m2m can't work. It is caused by the
sdmac->flags isn't reset after running. then sdma_int_handler go to
wrong branch.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2018-10-29 11:10:38 +08:00
Robin Gong 97abc8d25c MLK-11385 dma: imx-sdma: enable clock before context restored
fix sdma driver resume back failed if SDMA clock disabled before suspend:

PM: noirq resume of devices complete after 0.802 msecs
imx-sdma 30bd0000.sdma: Timeout waiting for CH0 ready
imx-sdma 30bd0000.sdma: loaded firmware 4.1
imx-sdma 30bd0000.sdma: restore context error!
dpm_run_callback(): sdma_resume+0x0/0x1c8 returns -110
PM: Device 30bd0000.sdma failed to resume early: error -110

Signed-off-by: Robin Gong <b38343@freescale.com>
2018-10-29 11:10:38 +08:00
Robin Gong f3ceb0b5f6 MLK-11358-4: dma: imx-sdma: save and restore context on i.mx6sx/i.mx7d
Because load context code has been removed in prepare DMA transfer everytime.
Need restore them back once mega/fast powered off.

Signed-off-by: Robin Gong <b38343@freescale.com>
2018-10-29 11:10:38 +08:00
Robin Gong c3e6083267 MLK-11358-1: dma: imx-sdma: support dmatest module
dmatest is a common dma test module for dma driver which support mem_2_mem copy
.Since  SDMA driver has the mem_2_mem interface, make little code change to
support this feature rather than our internal  mxc_sdma_memcopy_test test
module.

Signed-off-by: Robin Gong <b38343@freescale.com>
2018-10-29 11:10:38 +08:00
Fugang Duan 34dc4b6c3e MLK-11326 dma: mxs-dma: remove the runtime pm dummy code
Currently, the dma engine driver don't support runtime pm,
and it is not necessary to support the feature since it support
slave sg and cyclic mode, and clock enable/disable during dma
chans allocate and release.

The patch remove the runtime pm dummy code.

Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit: 2c8f8e3e6a21184e6cf8b8e5ba3ec8e76794c951)
2018-10-29 11:10:38 +08:00
Fugang Duan ec409cfa80 MLK-11325 dma: mxs-dma: fix dma_io clock enable count mismatch issue
After dma init by calling .mxs_dma_init(), disable dma_io and
dma_bch clocks. When dma chans are requested by devices, clocks
are enabled in .device_alloc_chan_resources(). The patch is to
fix clock enable count mismatch issue.

Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit: 4868cf5e39a0aeb1ad12c5c1a453d233c0f472ce)
2018-10-29 11:10:38 +08:00
Adrian Alonso 47987d5d5b MLK-11019-2: mxs-sdma: add im7d dma-apbh clock
* iMX7D dma-apbh support add additional clock dependency
* Add clock for mxs-dma support dma_apbh_bch dma_apbh_io

Signed-off-by: Adrian Alonso <aalonso@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit: aea75669daac9101592de2cfbadc7aaacbc7d887)
2018-10-29 11:10:38 +08:00
Huang Shijie a8a76b86c8 MLK-9810 dma: mxs-dma: add power management support
this patch adds power management support for mxs-dma driver.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Allen Xu <b45815@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit 7a59828eeda36457e6e60383705a0bc5831ffbf7)
2018-10-29 11:10:38 +08:00
Shengjiu Wang 67415da8f1 MLK-11248: dmaengine: imx-sdma: add new api for sync with dma and substream
There is occasion that dma callback come late after the substream is released.
Then there will be kernel dump.

[<805866b0>] (imx_pcm_dma_complete) from [<802fad9c>] (sdma_handle_channel_loop.isra.25+0x48/0x54)
[<802fad9c>] (sdma_handle_channel_loop.isra.25) from [<802fae48>] (sdma_tasklet+0xa0/0x1d4)
[<802fae48>] (sdma_tasklet) from [<800356e0>] (tasklet_action+0x64/0xf8)
[<800356e0>] (tasklet_action) from [<80034ea0>] (__do_softirq+0x104/0x218)
[<80034ea0>] (__do_softirq) from [<80035220>] (irq_exit+0xa8/0xec)
[<80035220>] (irq_exit) from [<8000ed44>] (handle_IRQ+0x3c/0x90)
[<8000ed44>] (handle_IRQ) from [<80008578>] (gic_handle_irq+0x28/0x5c)
[<80008578>] (gic_handle_irq) from [<80012100>] (__irq_svc+0x40/0x70)

The reason is the sdma tasklet is async with audio substream release. ALSA
think when terminate dma, the dma should be stopped and no callback be called.

This patch is to add new api dma_sync_wait_tasklet(), which is called in
snd_dmaengine_pcm_close(). It will make sure the callback not be called
after this funtion. Tasklet_kill is to wait scheduled tasklet end.

Tasklet_kill can't be added to terminate dma function, because terminate dma
function may be called in interrupt, but tasklet_kill can't be called in
interrupt context.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 9815881b6acaa72a705e1fa3c26a852fc81bfce5)
2018-10-29 11:10:38 +08:00
Shengjiu Wang 9383090d7f MLK-11259-1: dmaengine: imx-sdma: support dual fifo for DEV_TO_DEV
As SSI has dual fifo, add src_dualfifo and dst_dualfifo in imx_dma_data
to support dual fifo in DMA_DEV_TO_DEV.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit cfde1308f170166a0099ca39ee8733895f9626f0)
2018-10-29 11:10:38 +08:00
Robin Gong 1aad3a412c MLK-11122: dma: imx-sdma: use late system sleep pm ops
Use SET_LATE_SYSTEM_SLEEP_PM_OPS rather than the common sleep pm ops to ensure
sdma has resumed back before all other module drivers which use sdma resume
back.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit a7f8725509b494c3073b1bcca63252d5c61bb80d)
2018-10-29 11:10:38 +08:00
Robin Gong 4813bb3ab2 MLK-10450: dma: imx-sdma: enable Mega/Fast support for i.mx7d
Enable Mega/Fast support for i.mx7d. Need save and restore SDMA registers.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 4e1ea64c5d360ebc4f8168c1fcdee314b547bd13)
2018-10-29 11:10:38 +08:00
Robin Gong 87194b0103 MLK-10405 dma: imx-sdma: fix uart6 rx not working
The SDMA driver not consider the case of event_id0 is 0. That make uart6 rx
not working.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit dbcacbcb3a885d7569e9e415035b1dd06c4a117b)
(cherry picked from commit 6dfdbe41a7d6ab7e6fae5d6fb4d73435839beff3)
2018-10-29 11:10:38 +08:00
Robin Gong 742d709722 MLK-9986-4 dma: imx-sdma: add new ecspi tx script
Current ecspi rom script didn't take care of rxfifo overflow risk. Add new
ecspi tx script to check the rxfifo status, if it is near to full(>=48 bytes),
do not copy data to txfifo which will trigger data push into rxfifo. Because
rx script may not read rxfifo in time, we have to consider it.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 17f472aa698aba0af5da4566df447e23306f4289)
(cherry picked from commit 90c929d7d1a3f8e196641b5ed7a33d2ee03bd63c)
(cherry picked from commit 6d76bdcf2097e4198217edf27363cf6ba2e6542a)
2018-10-29 11:10:38 +08:00
Robin Gong 49cdc40a21 MLK-11344-8: dma: imx-sdma: support sdma restore from mega/fast power down status
cherry-pick below patch from v3.14.y:
 ENGR00319473: dma: imx-sdma: support sdma restore from
 mega/fast power down status

Support sdma suspend and resume interface to restore from mega/fast power down.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 682fd1f47ab9cb69382fa0e8d20a830ae99c26fc)
(cherry picked from commit dd17fa18b9a0c11f8bce3b87f792775d96e461c1)
2018-10-29 11:10:38 +08:00
Robin Gong aa3c23529d MLK-10050 dma: imx-sdma: add support for sdma memory copy
This patch is just created by so many confilict while cherry-pick
from v3.10 a6a6cf911f85a3a09f763195478d422c571b9565.

Signed-off-by: Robin Gong <b38343@freescale.com>

Leonard: Fixed minor conflicts while rebasing on 4.14
Removed sdma_prep_memcpy_sg because API removed from upstream
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2018-10-29 11:10:38 +08:00
Shengjiu Wang c98f44f1fd MLK-11344-7: dma: imx-sdma: Add hdmi audio support in sdma
cherry-pick below patch from v3.14.y:
ENGR00329948-3: dma: imx-sdma: Add hdmi audio support
 in sdma

There's a missing script for hdmi audio support in current sdma driver,
thus add it.

This HDMI script doesn't use bd to copy memory like a normal one does
but only to update the memory address for HDMI internal AHB DMA and
then trigger its procedure automatically.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit dafddac916a03ae4477e2de7c1b7ad291f956f68)
2018-10-29 11:10:38 +08:00
Nicolin Chen 2c2204e13a MLK-11344-6: dma: imx-sdma: allocate memory from iram
ENGR00286273-1 dma: imx-sdma: allocate memory from iram

We try to allocate memory from SoC internal SRAM so that we can turn off
voltage of external DDR to save power. Surely, if we failed to get the
iram DT node or allocate memory due to no enough SRAM space, we would
allow SDMA driver to allocate memory in a traditional way.

Signed-off-by: Nicolin Chen <b42378@freescale.com>
Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit f6924fbdb90d1f01266fc018caff953457e04d34)
(cherry picked from commit 7b643e5c9119ac43b937816fd1b785d2b859b05f)
2018-10-29 11:10:38 +08:00
Robin Gong ca92c6cd09 MLK-9768: dma: imx-sdma: fix UART loopback random failed
For UART, we need use old chn_real_count to know the real rx count even in
cylic dma mode, because UART driver use cyclic mode to increase performance
without any data loss.

Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 398cee2ad110c4f183e553af0564fbdcbe8548cb)
2018-10-29 11:10:38 +08:00
Fugang Duan 0013e95979 MLK-11344-5: dmaengine: imx: fix loop mode issue
cherry-pick below patch from v3.14.y:

ENGR00329822-01 dmaengine: imx: fix loop mode issue

Fix loop mode issue that calling dmaengine_tx_status() can get
right state.residue value.

Signed-off-by: Fugang Duan <B38611@freescale.com>
Signed-off-by: Robin Gong <b38343@freescale.com>
(cherry picked from commit 37e17f10b35c34317def08704e4b4edf5aa23894)
(cherry picked from commit 00cc7021317ac6efb460eb1b9bc3bd8aa6ad73c2)
2018-10-29 11:10:38 +08:00
Leonard Crestez 1e20257cae MLK-11327 dma: pxp: porting pxp dma driver to imx_4.1.y
Porting pxp dma drivers v2 and v3 to imx_4.1.y branch.

Signed-off-by: Fancy Fang <chen.fang@freescale.com>
2018-10-29 11:10:38 +08:00
Hanna Hawa 82c53969af dmaengine: mv_xor_v2: kill the tasklets upon exit
[ Upstream commit 8bbafed8dd ]

The mv_xor_v2 driver uses a tasklet, initialized during the probe()
routine. However, it forgets to cleanup the tasklet using
tasklet_kill() function during the remove() routine, which this patch
fixes. This prevents the tasklet from potentially running after the
module has been removed.

Fixes: 19a340b1a8 ("dmaengine: mv_xor_v2: new driver")

Signed-off-by: Hanna Hawa <hannah@marvell.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-26 08:38:05 +02:00
John Keeping e1cfd4533f dmaengine: pl330: fix irq race with terminate_all
[ Upstream commit e49756544a ]

In pl330_update() when checking if a channel has been aborted, the
channel's lock is not taken, only the overall pl330_dmac lock.  But in
pl330_terminate_all() the aborted flag (req_running==-1) is set under
the channel lock and not the pl330_dmac lock.

With threaded interrupts, this leads to a potential race:

    pl330_terminate_all	        pl330_update
    -------------------         ------------
    lock channel
                                entry
    lock pl330
    _stop channel
    unlock pl330
                                lock pl330
                                check req_running != -1
    req_running = -1
                                _start channel

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-26 08:38:00 +02:00
Dan Carpenter bb2b7243e3 dmaengine: k3dma: Off by one in k3_of_dma_simple_xlate()
[ Upstream commit c4c2b7644c ]

The d->chans[] array has d->dma_requests elements so the > should be
>= here.

Fixes: 8e6152bc66 ("dmaengine: Add hisilicon k3 DMA engine driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-24 13:09:08 +02:00
Marek Szyprowski 4cea08638e dmaengine: pl330: report BURST residue granularity
[ Upstream commit e3f329c600 ]

The reported residue is already calculated in BURST unit granularity, so
advertise this capability properly to other devices in the system.

Fixes: aee4d1fac8 ("dmaengine: pl330: improve pl330_tx_status() function")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-24 13:09:08 +02:00
Srinivas Kandagatla 909474cd38 dmaengine: qcom: bam_dma: get num-channels and num-ees from dt
[ Upstream commit 48d163b1aa ]

When Linux is master of BAM, it can directly read registers to know number
of supported channels, however when its remotely controlled reading these
registers would trigger a crash if the BAM is not yet initialized or
powered up on the remote side.

This patch allows driver to read num-channels and num-ees from Device Tree
for remotely controlled BAM.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-30 07:52:37 +02:00
Yoshihiro Shimoda b3b2630720 dmaengine: rcar-dmac: Check the done lists in rcar_dmac_chan_get_residue()
[ Upstream commit 3e081628d5 ]

This patch fixes an issue that a race condition happens between a client
driver and the rcar-dmac driver:

- The rcar_dmac_isr_transfer_end() is called.
 - The done list appears, and desc.running is the next active list.
- rcar_dmac_chan_get_residue() is called by a client driver before
  rcar_dmac_isr_channel_thread() is called.
 - The rcar_dmac_chan_get_residue() will not find any descriptors.
 - And, the following WARNING happens:
	WARN(1, "No descriptor for cookie!");

The sh-sci driver with HSCIF (921,600bps) on R-Car H3 can cause this
situation.
So, this patch checks the done lists in rcar_dmac_chan_get_residue()
and returns zero if the done lists has the argument cookie.

Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-30 07:52:36 +02:00
Qi Hou e41de468a6 dmaengine: pl330: fix a race condition in case of threaded irqs
[ Upstream commit a3ca831249 ]

When booting up with "threadirqs" in command line, all irq handlers of the DMA
controller pl330 will be threaded forcedly. These threads will race for the same
list, pl330->req_done.

Before the callback, the spinlock was released. And after it, the spinlock was
taken. This opened an race window where another threaded irq handler could steal
the spinlock and be permitted to delete entries of the list, pl330->req_done.

If the later deleted an entry that was still referred to by the former, there would
be a kernel panic when the former was scheduled and tried to get the next sibling
of the deleted entry.

The scenario could be depicted as below:

  Thread: T1  pl330->req_done  Thread: T2
      |             |              |
      |          -A-B-C-D-         |
    Locked          |              |
      |             |           Waiting
    Del A           |              |
      |          -B-C-D-           |
    Unlocked        |              |
      |             |           Locked
    Waiting         |              |
      |             |            Del B
      |             |              |
      |           -C-D-         Unlocked
    Waiting         |              |
      |
    Locked
      |
   get C via B
      \
       - Kernel panic

The kernel panic looked like as below:

Unable to handle kernel paging request at virtual address dead000000000108
pgd = ffffff8008c9e000
[dead000000000108] *pgd=000000027fffe003, *pud=000000027fffe003, *pmd=0000000000000000
Internal error: Oops: 96000044 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 85 Comm: irq/59-66330000 Not tainted 4.8.24-WR9.0.0.12_standard #2
Hardware name: Broadcom NS2 SVK (DT)
task: ffffffc1f5cc3c00 task.stack: ffffffc1f5ce0000
PC is at pl330_irq_handler+0x27c/0x390
LR is at pl330_irq_handler+0x2a8/0x390
pc : [<ffffff80084cb694>] lr : [<ffffff80084cb6c0>] pstate: 800001c5
sp : ffffffc1f5ce3d00
x29: ffffffc1f5ce3d00 x28: 0000000000000140
x27: ffffffc1f5c530b0 x26: dead000000000100
x25: dead000000000200 x24: 0000000000418958
x23: 0000000000000001 x22: ffffffc1f5ccd668
x21: ffffffc1f5ccd590 x20: ffffffc1f5ccd418
x19: dead000000000060 x18: 0000000000000001
x17: 0000000000000007 x16: 0000000000000001
x15: ffffffffffffffff x14: ffffffffffffffff
x13: ffffffffffffffff x12: 0000000000000000
x11: 0000000000000001 x10: 0000000000000840
x9 : ffffffc1f5ce0000 x8 : ffffffc1f5cc3338
x7 : ffffff8008ce2020 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000001
x3 : dead000000000200 x2 : dead000000000100
x1 : 0000000000000140 x0 : ffffffc1f5ccd590

Process irq/59-66330000 (pid: 85, stack limit = 0xffffffc1f5ce0020)
Stack: (0xffffffc1f5ce3d00 to 0xffffffc1f5ce4000)
3d00: ffffffc1f5ce3d80 ffffff80080f09d0 ffffffc1f5ca0c00 ffffffc1f6f7c600
3d20: ffffffc1f5ce0000 ffffffc1f6f7c600 ffffffc1f5ca0c00 ffffff80080f0998
3d40: ffffffc1f5ce0000 ffffff80080f0000 0000000000000000 0000000000000000
3d60: ffffff8008ce202c ffffff8008ce2020 ffffffc1f5ccd668 ffffffc1f5c530b0
3d80: ffffffc1f5ce3db0 ffffff80080f0d70 ffffffc1f5ca0c40 0000000000000001
3da0: ffffffc1f5ce0000 ffffff80080f0cfc ffffffc1f5ce3e20 ffffff80080bf4f8
3dc0: ffffffc1f5ca0c80 ffffff8008bf3798 ffffff8008955528 ffffffc1f5ca0c00
3de0: ffffff80080f0c30 0000000000000000 0000000000000000 0000000000000000
3e00: 0000000000000000 0000000000000000 0000000000000000 ffffff80080f0b68
3e20: 0000000000000000 ffffff8008083690 ffffff80080bf420 ffffffc1f5ca0c80
3e40: 0000000000000000 0000000000000000 0000000000000000 ffffff80080cb648
3e60: ffffff8008b1c780 0000000000000000 0000000000000000 ffffffc1f5ca0c00
3e80: ffffffc100000000 ffffff8000000000 ffffffc1f5ce3e90 ffffffc1f5ce3e90
3ea0: 0000000000000000 ffffff8000000000 ffffffc1f5ce3eb0 ffffffc1f5ce3eb0
3ec0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3ee0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3f00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3f20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3f40: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3f60: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3f80: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3fa0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
3fc0: 0000000000000000 0000000000000005 0000000000000000 0000000000000000
3fe0: 0000000000000000 0000000000000000 0000000275ce3ff0 0000000275ce3ff8
Call trace:
Exception stack(0xffffffc1f5ce3b30 to 0xffffffc1f5ce3c60)
3b20:                                   dead000000000060 0000008000000000
3b40: ffffffc1f5ce3d00 ffffff80084cb694 0000000000000008 0000000000000e88
3b60: ffffffc1f5ce3bb0 ffffff80080dac68 ffffffc1f5ce3b90 ffffff8008826fe4
3b80: 00000000000001c0 00000000000001c0 ffffffc1f5ce3bb0 ffffff800848dfcc
3ba0: 0000000000020000 ffffff8008b15ae4 ffffffc1f5ce3c00 ffffff800808f000
3bc0: 0000000000000010 ffffff80088377f0 ffffffc1f5ccd590 0000000000000140
3be0: dead000000000100 dead000000000200 0000000000000001 0000000000000000
3c00: 0000000000000000 ffffff8008ce2020 ffffffc1f5cc3338 ffffffc1f5ce0000
3c20: 0000000000000840 0000000000000001 0000000000000000 ffffffffffffffff
3c40: ffffffffffffffff ffffffffffffffff 0000000000000001 0000000000000007
[<ffffff80084cb694>] pl330_irq_handler+0x27c/0x390
[<ffffff80080f09d0>] irq_forced_thread_fn+0x38/0x88
[<ffffff80080f0d70>] irq_thread+0x140/0x200
[<ffffff80080bf4f8>] kthread+0xd8/0xf0
[<ffffff8008083690>] ret_from_fork+0x10/0x40
Code: f2a00838 f9405763 aa1c03e1 aa1503e0 (f9000443)
---[ end trace f50005726d31199c ]---
Kernel panic - not syncing: Fatal exception in interrupt
SMP: stopping secondary CPUs
SMP: failed to stop secondary CPUs 0-1
Kernel Offset: disabled
Memory Limit: none
---[ end Kernel panic - not syncing: Fatal exception in interrupt

To fix this, re-start with the list-head after dropping the lock then
re-takeing it.

Reviewed-by: Frank Mori Hess <fmh6jj@gmail.com>
Tested-by: Frank Mori Hess <fmh6jj@gmail.com>
Signed-off-by: Qi Hou <qi.hou@windriver.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-30 07:52:36 +02:00