Commit Graph

5929 Commits

Author SHA1 Message Date
Joy Zou
0eeb0ae1f5 LF-6207-1: dmaengine: fsl-edma-v3: support edma-v3 and edma-v4 for imx93
Add edma-v3 AHB and edma-v4 AXI support for imx93.

The edma AHB support 31 channels. Channels and peripherals are
one-to-one corresponding. The edma AXI support 64 channels.
Channels are dynamically allocated.

Add fsl_edma3_engine struct member bus_axi in order to differentiate
edma AHB and AXI. Add fsl_edma3_engine struct member dmaclk and
fsl_edma3_drvdata struct member has_chclk due to the all channels
share edma clocks. It's different from 8ulp that each channel have
its own clock. Add fsl_edma3_engine struct member has_chmux because
the edma AHB not support Channel Multiplexor Configuration.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:33 +08:00
Shengjiu Wang
fb2e0cbcfb LF-6705: dmaengine: fsl-edma-v3: Fix residue issue with MLOFF exist
The nbytes in vtcd only have 10 valid bits with MLOFF exist case,
so can't use whole 30bits for nbytes, which cause issue with micfil
case.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Chancel Liu <chancel.liu@nxp.com>
2023-10-30 18:43:33 +08:00
Robin Gong
4484818c79 MLK-25533-1: dmaengine: fsl-edma-v3: add support for i.mx8ulp
Add has_pd into drvdata to support i.mx8ulp which has no dma
power domain feature.

Add edma mp in dts since i.mx8ulp may need it, while scfw will
touch MP in scfw, but now we just map it without any touching.

There are clocks for every channel and dmamux for choosing the source id
from dts on i.mx8ulp.
Note: dma_spec->args[0] is changed to source/event id on i.mx8ulp, not
channel id on i.mx8qm/qxp since any channel could be freely configured by
dmamux to any source/event on i.mx8ulp.

Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 87ee321a52)
2023-10-30 18:43:33 +08:00
Robin Gong
7b3e511999 MLK-24825-2: dmaengine: fsl-edma: checking ACTIVE bit for channel stop
Checking ACTIVE bit to ensure channel stop indeed, otherwise, there is risk
that illegal memory touch after channel not stopped with buffer freed.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 48cea8ae90)
2023-10-30 18:43:33 +08:00
Stoica Cosmin-Stefan
ec82535fb0 LF-631-4: dmaengine: fsl-edma: Add support for S32V234
S32V234 eDMA has two transmission IRQs assigned per channels 0-15 and
16-31, instead of one, like VF610/LS1028A, or 16, like i.MX 7ULP, which is
why this platform needs a custom IRQ initialization function.

Signed-off-by: Stoica Cosmin-Stefan <cosmin.stoica@nxp.com>
Signed-off-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Acked-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 18:43:32 +08:00
Stefan-Gabriel Mirea
4ba5793653 LF-631-1: dmaengine: fsl-edma: Store and free interrupts uniformly
To prepare the eDMA driver for S32V234 support, the "DMA transfer complete"
interrupt lines need to be freed (and therefore stored) in a uniform way.

After this commit, fsl_edma2_irq_init() will no longer accept an arbitrary
number of interrupts in the device tree, but only a pre-established number
of 17 interrupts, as the documentation (fsl-edma.txt) requires.

Signed-off-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Acked-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 18:43:32 +08:00
Fugang Duan
b27afde218 dmaengine: fsl-edma: calculate the real count for slave sg
Calculate the rela count for current slave sg after eDMA stop.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2023-10-30 18:43:32 +08:00
Robin Gong
399674dd26 MLK-17094-1: dmaengine: fsl-edma-v3: add suspend/resume to restore back channel registers
Add suspend to save channel registers and resume to restore them back since
edmav3 may powered off in suspend.

Reviewed-by: S.j. Wang <shengjiu.wang@nxp.com>
Reviewed-by: Andy Duan <fugang.duan@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 18:43:32 +08:00
Joy Zou
8a600d8bef MLK-21443: dmaengine: fsl-edma-v3: clear pending irq before request irq
edma interrupt maybe happened during reboot or watchdog reset, meanwhile
gic never power down on i.mx8QM/QXP, thus the unexpect irq will come in
once edma driver request irq at probe phase. Unfortunately, at that time
that edma channel's power domain which power-up by customer driver such
as audio/uart driver may not be ready, so kernel panic triggered once
touch such edma registers which still not power up in interrupt handler.

This patch move request irq from probe to alloc dma channel so that edma
channel's power domain has already been powered, besides, clear meaningless
interrupt before request irq.

Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:32 +08:00
Joy Zou
3e0f2b83ba MLK-15330-1: dmaengine: 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.

edma has dual fifo mode feature for audio cyclic. Besides dual fifo,
there is also multiple fifo use case. In this patch MLOFF field of
TCD register is modified to support multiple fifo. Correspondingly,
the burst should be set to the suitable value. For example it is set
to the number of channels if there is 1 channel in per fifo.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:32 +08:00
Joy Zou
7a735437dd MLK-14610-1: dmaengine: fsl-edma-v3: add fsl-edma-v3 driver support
Add edma-v3 driver on i.mx8qm.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 18:43:32 +08:00
Dong Aisheng
17508933c5 Revert fsl-edma to the version of next-20230804
The working on the verification of upstream edma driver is still in progress.
Let's use the local version first for the rebase.

Revert "dmaengine: fsl-edma: integrate v3 support"

This reverts commit 72f5801a4e.

Revert "dmaengine: fsl-edma: move tcd into struct fsl_dma_chan"

This reverts commit 7536f8b371.

Revert "dmaengine: fsl-edma: refactor chan_name setup and safety"

This reverts commit 9b05554c5c.

Revert "dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function"

This reverts commit f5b3ba52f3.

Revert "dmaengine: fsl-edma: refactor using devm_clk_get_enabled"

This reverts commit a9903de3aa.

Revert "dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs()"

This reverts commit ee2dda0646.

Revert "dmaengine: fsl-edma: move common IRQ handler to common.c"

This reverts commit 79434f9b97.

Revert "dmaengine: fsl-edma: Remove enum edma_version"

This reverts commit c26e611433.

Revert "dmaengine: fsl-edma: transition from bool fields to bitmask flags in drvdata"

This reverts commit 9e006b2439.

Revert "dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c"

This reverts commit 66aac8ea0a.
2023-10-30 18:43:14 +08:00
Dong Aisheng
9d7e24bcc7 Revert "dmaengine: fsl-edma: fix all channels requested when call fsl_edma3_xlate()"
This reverts commit 3fa53518ad.
2023-10-30 18:37:06 +08:00
Dong Aisheng
628a38f8a6 Revert "dmaengine: fsl-dma: fix DMA error when enabling sg if 'DONE' bit is set"
This reverts commit 3c67c5236f.
2023-10-30 18:30:58 +08:00
Dong Aisheng
2e1d3cf25b Revert "dmaengine: fsl-edma: fix edma4 channel enable failure on second attempt"
This reverts commit 3f4b82167a.
2023-10-30 18:30:53 +08:00
Robby Cai
768e074352 LF-9755 dma: pxp_dma_v3: fix typo causing function break
Fix typo introduced from the commit 9a06b8f28f ("LF-9509: dma: pxp_dma_v3:
fix dereference after null check issue") which causes pxp timeout when run
epdc test on MX8ULP EVK ('/unit_tests/Display/mxc_epdc_v2_fb_test.out').

...
[  223.598322] pxp_dispatch_thread: task is timeout
[  223.630619] imx_epdc_v2_fb 2db30000.epdc: PxP operation failed due to timeout
[  223.637898] imx_epdc_v2_fb 2db30000.epdc: Unable to complete PxP update task: pre_prcoess.
Change back to non-inverted RGB565
...

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
(cherry picked from commit a069b2188d)
2023-10-30 16:08:22 +08:00
Guoniu.zhou
cc893c8ad4 LF-9509: dma: pxp_dma_v3: fix dereference after null check issue
In pxp_is_v3(), it call pxp->devdata, but it out of null check for
pxp->devdata, so maybe refer null data when lut_transform is true.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 9a06b8f28f)
2023-10-30 16:08:22 +08:00
Guoniu.zhou
c0f1bf72b5 LF-9435: dma: pxp_dma_v3: fix dereference after null check
Fix dereference after null check issue reported by coverity(CID:25701409)

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 8af5982325)
2023-10-30 16:08:22 +08:00
Guoniu.zhou
61f86d18d5 LF-8978: dma: pxp: fix fetch/store engine low performance issue
When pxp read pixel data by fetch engine and output by store engine.
The performance is very low, about 50Mpixel/s when the bytes of both
read and write burst are the default value 8. While increase both
read and write burst bytes to 64, the performance will be improved
to about 125Mpixel/s.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
(cherry picked from commit 519de8586c)
2023-10-30 16:08:22 +08:00
Julien Vuillaumier
2cb0e42acd MGS-7088: dma: pxp: add generic dma-buf cache coherency management
PXP_IOC_FLUSH_PHYMEM ioctl implements support for cache coherency
of buffers previously allocated by the PXP driver using
PXP_IOC_GET_PHYMEM ioctl, hence associated to its PXP driver
handle.

This change adds the option to handle dma coherency on a dma-buf
issued by a generic exporter.
Handle associated to buffers allocated by PXP driver can not be null.
Therefore null handle is used by implementation as criteria to fall
back onto the dma-buf file descriptor passed in arguments, keeping
the backward compatibility.

Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
5367f9ac34 MLK-25315: dma: pxp: add monochrome mode support for PS engine
When input format of PS engine is monochrome, such as Y8 or Y4,
the low 16 bits of PS_VBUF are used as the U/V data in the data
path instead of sourcing U/V data from external buffers. In this
case it represents a fixed value for U/V data.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
1930d2433d LF-6841: dma: pxp: fix pxp timeout issue when run g2d samples test
When run g2d sample test, pxp will report timeout issue. The reason
is that BGRA32 format is used in the case and driver will select AS
engine as input source. But from PXP datasheet, As can't do a simple
copy operation since it usually need to co-work with PS engine which
mean the output pixel value will determined by both AS and PS, such
as raster operation "AS OR PS" which usually used in legacy blending
operation. So add this workaround to fix this issue.

Reproduce steps:
/opt/g2d_samples/g2d_wayland_shm_test

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
ba8c267758 LF-8022: dma: pxp: fix Coverity Issue
Fix Coverity issue 25910920 about dereference after null check

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
bc0d76fae8 LF-6441-06: dma: pxp: add workaround to support RGB with alpha for PS engine
PS engine doesn't support RGB format with alpha channel, so it will discard
alpha value in RGBA/ARGB when PXP carry data from source to destination. The
workaround enable ALPHA_A porter_duff and use source blend mode, so it will
keep the alpha component as same in source buffer.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
27e3f85366 LF-6441-05: dma: pxp: fix pxp convert YUV to ABGR32 with rotation issue
The case is that source buffer is YUYV format and need to convert it
to ABGR32 and do rotation operation. But it will fail due to the reason
as bellow:

Driver will select PS as input engine according to input format(YUYV)
and OUT engine will be used as output engine since PS can't work with
STORE engine, but OUT engine don't support ABGR32 format.

When do rotation operation, ROTATION2(iMX93 reference manual) will be
selected first, but it only can work with fetch engine due to PXP's
limitation(TKT0603343), so driver need to clean it and select ROTATION1
engine to do the rotation operation.

This patch fix this issue by adding ABGR32 format for OUT engine and
selecting ROTATION1 for PS/AS engine

Reproduce steps as bellow and run on iMX93 platform:
/opt/g2d_samples/g2d_basic_test

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:22 +08:00
Guoniu.zhou
043bb6ba0f LF-6441-04: dma: pxp: enable 16x16 block size for fetch engine by default
PXP block size is selected as 16x16 pixels by default in order to request
data more efficient. So driver also need to set each module which support
block size to 16x16. This patch is used to set input fetch engine block
size to 16x16.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
713cc4dbf6 LF-6441-03: dma: pxp: fill fetch engine active size when user miss them
Fill input fetch engine upper left X-coordinate(in pixels) of the active
surface of the total input memory by frame boundary size when user don't
configure them.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
4027f887ff LF-6441-02: dma: pxp: enable input fetch arbitration bit for iMX93 platform
Enable input fetch engine arbitration bit for iMX93 platform when use its
two channel simultaneously since only one AXI bus interface is connected
to PXP fetch engine channel in order to balance system performance. For
other platform which use PXP don't have this design, so set arbitration
bit as platform data and only enable it for iMX93 platform(TKT0601126).

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
8fdebcad90 LF-6441-01: dma: pxp: remove unnecessary modules in PXP pipeline
The selected modules by user case in PXP pipeline will be configured
and enabled in pxp_2d_task_config() , so don't need to enable unused
modules and re-enable the used modules in pxp_start()

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
3f978fdaf9 LF-8372: dma: pxp/v3: fix U/V offset calculation issue when crop enabled
The offset of U/V relative to Y buffer address base in PS engine is
wrong when format is multi-plane YUV format and crop enabled. So
correct it.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Robby Cai
60bb62a13f LF-8222 dma: pxp: fix build error for pxp_device
../drivers/dma/pxp/pxp_device.c: In function 'pxp_dmabuf_ops_map':
../drivers/dma/pxp/pxp_device.c:666:40: error: 'struct dma_buf' has no member named 'lock'
  666 | struct mutex *lock = &db_attach->dmabuf->lock;
      |                                        ^~
../drivers/dma/pxp/pxp_device.c:666:15: warning: unused variable 'lock' [-Wunused-variable]
  666 | struct mutex *lock = &db_attach->dmabuf->lock;
      |               ^~~~

Remove internal dma-buf lock as it's removed in new framework and dma-buf reservation
is guaranteed to be locked by importers during the mapping operations.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Guoniu.zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:21 +08:00
Jindong Yue
8c40cd2dab MA-19811-3 dma: pxp: Support building pxp driver as module
Change defconfig as tristate type, and export
register/unregister API symbols.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Change-Id: If457ca1fd5433a34ab82f750e3a298af9d71f234
2023-10-30 16:08:21 +08:00
Guoniu.zhou
53ba277269 LF-7334: dma: pxp: v3: fix kernel dump issue when enable debug output
Kernel will dump when enable debug output in PXP driver with iMX93 platform.
The root cause is that PXP in iMX93 remove LUT related register compared
with other PXP version, so access non exist register in PXP will trigger
bus error signal to system. The solution is to mark these registers as
optional and skip them when run iMX93 PXP.

Hardware name: NXP i.MX93 11X11 EVK board (DT)
pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : dump_pxp_reg+0xc8/0xec
lr : dump_pxp_reg+0xe0/0xec
sp : ffff800009e3b660
x29: ffff800009e3b660 x28: 00000000fffffffa x27: ffff80000973f2d8
x26: 0000000000000001 x25: 0000000000000070 x24: ffff0000047040e0
x23: ffff80000973ee60 x22: ffff8000096d5638 x21: ffff800009e3bb28
x20: ffff000004704080 x19: ffff800009e3ba08 x18: 0000000000000008
x17: 3030303030303078 x16: 30203a5d3039315b x15: ffff800009dbcb59
x14: 0000000000000000 x13: ffff800009c41f78 x12: 0000000000000420
x11: 0000000000000160 x10: ffff800009c41f78 x9 : ffff800009c41f78
x8 : 00000000ffffefff x7 : ffff800009c99f78 x6 : ffff800009c99f78
x5 : ffff80000a790240 x4 : 0000000000000240 x3 : 0000000000000000
x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000004080000
Call trace:
 dump_pxp_reg+0xc8/0xec
 pxp_probe+0x31c/0x9e4
 platform_probe+0x68/0xe0
 really_probe.part.0+0x9c/0x30c
 __driver_probe_device+0x98/0x144
 driver_probe_device+0x44/0x15c
 __driver_attach+0x80/0x18c
 bus_for_each_dev+0x70/0xd0
 driver_attach+0x24/0x30
 bus_add_driver+0x108/0x1fc
 driver_register+0x78/0x130
 __platform_driver_register+0x28/0x34
 pxp_init+0x1c/0x28
 do_one_initcall+0x50/0x1b0
 kernel_init_freeable+0x20c/0x290
 kernel_init+0x24/0x12c
 ret_from_fork+0x10/0x20
 Code: d65f03c0 f9400e85 b9400264 8b2440a5 (b94000a5)
 ---[ end trace b6e6cc2fe83edf8f ]---
 Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
1a06109b34 LF-6806: dma: pxp: workaround for PXP when do RGB to gray color conversion
CSC2 engine in PXP has IC bug(TKT272216) and fixed after 7D PXP version.
Driver update new CSC coefficient provided by PXP IP owner(MLK-25625-02).
But when run e-ink case, it can't do clear operation after applying the
patch. We don't know reason until now, so add a temporary patch to fix it
and will remove after finding the root cause.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
3e0af81f1c LF-6741: dma: pxp: fix coverity issue: Uninitialized scalar variable
Fix coverity issue: 22322873 Uninitialized scalar variable

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
4240caef4b LF-6743: dma: pxp: fix coverity issue: dereference before null check
Fix coverity issue 22322872: dereference before null check

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:21 +08:00
Li Yang
3ee1522c44 dma: pxp_device: Replace dma-buf-map with iosys-map
Since upstream commit 7938f421816 ("dma-buf-map: Rename to iosys-map")
the dma-buf-map names need to be updated.

Signed-off-by: Li Yang <leoyang.li@nxp.com>
2023-10-30 16:08:21 +08:00
Guoniu.zhou
f21d626cdd LF-6244-06: dma: pxp: add PXP support for iMX93 platform
Add PXP support for iMX93 platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
d3361bfc50 LF-6244-03: dma: pxp: config block size to 16x16 for primary path
Select block size to 16x16 pixel blocks for PXP primary path in order
to improve PXP performance

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
84cef45c10 LF-6244-02: dma: pxp: config block size to 16x16 for fetch and store engine
Config block size to 16x16 for input fetch and store engine in order to
improve PXP performance

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
93b78fa77c LF-6244-01: dma: pxp: config write burst size to 64 bytes
Config write burst size to 64 bytes in order to improve PXP performance

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
776f92e9f1 MLK-25625-02: dma: pxp_v3: correct csc2 coefficient
Correct csc2 coefficient due to PXP issue(TKT272216). It apply to PXP
version after than iMX7D

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Tested-by: Jared Hu <jared.hu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
50758a54b2 MLK-25625-01: dma: pxp_v3: expose multi address settting for multi-plane format
In current pxp driver, U and V address are caculated by driver when input/output
format is multi-plane format, such as NV12. But for some cases, user space want
to set U and V address by themself, so expose multi address settting for the case

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Tested-by: Jared Hu <jared.hu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Robby Cai
75c385c034 LF-5942-2 media: pxp_device: Fix build warning with clang
CC      drivers/dma/pxp/pxp_device.o
drivers/dma/pxp/pxp_device.c:358:8: warning: implicit conversion from enumeration type
'enum dma_data_direction' to different enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
                                                 DMA_TO_DEVICE,

To reproduce the warnings:
1) Install clang 12:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 12

2) Build kernel with clang:
export PATH=/usr/lib/llvm-12/bin/:$PATH  LLVM=1
make ARCH=arm64 imx_v8_defconfig
make ARCH=arm64

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 16:08:20 +08:00
Robby Cai
ca5c6c2c68 LF-5942-1 dma: pxp_v3: fix build warning with clang
drivers/dma/pxp/pxp_dma_v3.c:7769:15: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
                if ((output == enode->adjvex)) {
                     ~~~~~~~^~~~~~~~~~~~~~~~
drivers/dma/pxp/pxp_dma_v3.c:7769:15: note: remove extraneous parentheses around the comparison to silence this warning
                if ((output == enode->adjvex)) {
                    ~       ^               ~
drivers/dma/pxp/pxp_dma_v3.c:7769:15: note: use '=' to turn this equality comparison into an assignment
                if ((output == enode->adjvex)) {

To reproduce the warnings:
1) Install clang 12:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 12

2) Build kernel with clang:
export PATH=/usr/lib/llvm-12/bin/:$PATH  LLVM=1
make ARCH=arm64 imx_v8_defconfig
make ARCH=arm64

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 16:08:20 +08:00
Robby Cai
ee98bc2ca3 LF-5061 dma: pxp_v3: Fix Coverity Issue 17888794:Out-of-bounds access
Fixed together with LF-5068, just make the coverity checking system no complain.
actually there's no potential issue for out-of-bounds access.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.N. Zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
bae2ea06e1 LF-4550: dma: pxp: fix -Wimplicit-fallthrough build warning issue
In linux-nxp repo, -Wimplicit-fallthrough is set to 5, so it causes
warning for /* fall through */ in switch case statement. So the patch
is used to fix it

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
608692314d MLK-25707-01: dma: pxp_v3: add software restart for iMX8ULP
When pxp driver probe, it will do software reset and reconfigure
operation. For iMX8ULP, power domain will be turned off in runtime
suspend and the status will be missed, so need to do software reset
and reconfigure operation again. But for other platform, such as 7D,
it's not necessary.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
f69da07357 MLK-25591-04: uapi: linux: fix segmentation fault when run pxp lib unit test
Fix segmentation fault when run pxp lib unit test on iMX8ULP platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by  : Robby.Cai <robby.cai@nxp.com>
2023-10-30 16:08:20 +08:00
Guoniu.zhou
610925eade MLK-25591-06: dma: pxp_v3: Add PXP driver support for iMX8ULP
Add PXP driver support for iMX8ULP platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by  : Robby.Cai <robby.cai@nxp.com>
2023-10-30 16:08:19 +08:00
Guoniu.zhou
a09028baa1 MLK-25591-05: dma: pxp_v3: fix warning for data type mismatch issue
Fix data type mismatch issue when PXP driver run on arm64 platform

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by  : Robby.Cai <robby.cai@nxp.com>
2023-10-30 16:08:19 +08:00
Guoniu.zhou
1678afba3d MLK-25591-03: pxp: Kconfg: remove dependency of 32 bits ARM platform
Due to PXP is used in iMX6, iMX7 Serial platform and they are 32 bits arm
platform, so add the dependency for PXP driver.

In iMX8ULP, it also integrate PXP and it's 64 bits arm platform, so remove
the dependency for it.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by  : Robby.Cai <robby.cai@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
1bb609622a LF-4342 dma: pxp: set register for LUT cleanup is not available on mx8ulp
set register (offset 4) for LUT cleanup can't be accessed on mx8ulp (different
from other SoCs), otherwise generate APB bus error.

reproduce step:
run '/unit_tests/Display/mxc_epdc_v2_fb_test.out'
...
*** Try again at 1,1 ***
[  153.808422] SError Interrupt on CPU1, code 0xbf000002 -- SError
[  153.808431] CPU: 1 PID: 124 Comm: pxp_dispatch Not tainted 5.10.52-02305-gd72ff8b018b0-dirty #7
[  153.808435] Hardware name: NXP i.MX8ULP EVK (DT)
[  153.808441] pstate: 60000085 (nZCv daIf -PAN -UAO -TCO BTYPE=--)
[  153.808445] pc : pxp_wfe_a_process+0xec/0x28c
[  153.808449] lr : pxp_dispatch_thread+0x1758/0x2430
[  153.808453] sp : ffff80001247bd40
[  153.808457] x29: ffff80001247bd40 x28: ffff000008a8c080
[  153.808471] x27: ffff0000054f8080 x26: ffff000008a8c000
[  153.808480] x25: ffff800011cd2000 x24: ffff800011cd2028
[  153.808490] x23: ffff0000054f80a4 x22: fffffffffffffffc
[  153.808499] x21: 0000000000000040 x20: ffff0000054f8080
[  153.808509] x19: ffff0000054f9480 x18: 0000000000001b90
[  153.808518] x17: 0000000000001b80 x16: 0000000000001c60
[  153.808528] x15: 0000000000001c50 x14: 0000000000001c40
[  153.808537] x13: 0000000000001c30 x12: 0000000000001c20
[  153.808546] x11: 0000000000001c10 x10: 0000000000001400
[  153.808556] x9 : 0000000000001bf0 x8 : 0000000000000000
[  153.808565] x7 : 0000000000000400 x6 : 0000000000000000
[  153.808574] x5 : ffff800012750ca0 x4 : 0000000000000000
[  153.808584] x3 : 00000000000002f5 x2 : 00000000000002f6
[  153.808593] x1 : ffff800012750000 x0 : 00000000000003ff
[  153.808604] Kernel panic - not syncing: Asynchronous SError Interrupt
[  153.808610] CPU: 1 PID: 124 Comm: pxp_dispatch Not tainted 5.10.52-02305-gd72ff8b018b0-dirty #7
[  153.808614] Hardware name: NXP i.MX8ULP EVK (DT)
[  153.808618] Call trace:
[  153.808622]  dump_backtrace+0x0/0x1a0
[  153.808626]  show_stack+0x18/0x70
[  153.808630]  dump_stack+0xd0/0x12c
[  153.808633]  panic+0x16c/0x334
[  153.808637]  nmi_panic+0x8c/0x90
[  153.808641]  arm64_serror_panic+0x78/0x84
[  153.808644]  do_serror+0x64/0x6c
[  153.808648]  el1_error+0x90/0x110
[  153.808652]  pxp_wfe_a_process+0xec/0x28c
[  153.808656]  pxp_dispatch_thread+0x1758/0x2430
[  153.808660]  kthread+0x154/0x160
[  153.808664]  ret_from_fork+0x10/0x30
[  153.808697] SMP: stopping secondary CPUs
[  153.808701] Kernel Offset: disabled
[  153.808705] CPU features: 0x0240002,20002008
[  153.808709] Memory Limit: none

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.n. Zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
8f4e5a8bc5 MLK-25335 dma: pxp: fix kernel dump for pxp device
dma API(s) can't use NULL device because of following patch:

d7e02a9312 dma-mapping: remove leftover NULL device support

this patch uses pxp_dev instead of NULL device to resolve kernel dump.

[  445.484900] 8<--- cut here ---
[  445.488002] Unable to handle kernel NULL pointer dereference at virtual address 0000015c
[  445.512965] pgd = 2afadd37
[  445.515707] [0000015c] *pgd=00000000
[  445.521436] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[  445.526776] Modules linked in: 8021q mx6s_capture ov5640_camera_v2
[  445.532993] CPU: 0 PID: 2117 Comm: vqueue:src Not tainted 5.4.70-2.3.0+g4f2631b022d8 #1
[  445.541006] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[  445.547214] PC is at pxp_device_ioctl+0xc64/0xe80
[  445.551933] LR is at pxp_buffer_object_lookup+0x30/0x38
[  445.557169] pc : [<80550e20>]    lr : [<8054fd00>]    psr: 60000013
[  445.563446] sp : 93bffea8  ip : 908a03ac  fp : 76957ff8
[  445.568681] r10: 00000036  r9 : 93bfe000  r8 : 93b04540
[  445.573917] r7 : 939d78c0  r6 : 80085007  r5 : 939d77c0  r4 : 00000000
[  445.580454] r3 : 00000001  r2 : 00000000  r1 : 00000002  r0 : 939d77c0
[  445.586993] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[  445.594140] Control: 10c5387d  Table: 93bd806a  DAC: 00000051
[  445.599904] Process vqueue:src (pid: 2117, stack limit = 0xcf85841b)
[  445.606270] Stack: (0x93bffea8 to 0x93c00000)
[  445.610645] fea0:                   73800000 8020a840 93ab8800 81304f08 739bc000 93ab8800
[  445.618841] fec0: 93b8f840 739bc000 93b0fa80 8020eddc 93ab8800 00000002 00000001 00100c00
[  445.627037] fee0: 00000000 93bffee8 00000000 81304f08 00000008 741d7ff4 926428d0 80085007
[  445.635234] ff00: 741d7ff4 93b04540 93bfe000 00000036 76957ff8 80256c3c 93ab8800 0000010a
[  445.643430] ff20: 00000106 00000000 00000000 93b8f840 00000001 80210c20 000001e7 00000000
[  445.651626] ff40: 0009a100 93b8f848 93bfff54 0001c200 93bfff7c 00000001 93b04540 0000000b
[  445.659822] ff60: 00000001 00004000 93adc200 81304f08 93b04541 0000000b 80085007 741d7ff4
[  445.668019] ff80: 93b04540 93bfe000 00000036 8025716c 75742980 743caee0 01a152e0 00000036
[  445.676214] ffa0: 80101204 80101000 75742980 743caee0 0000000b 80085007 741d7ff4 743cb004
[  445.684410] ffc0: 75742980 743caee0 01a152e0 00000036 00000002 741d8064 741d81d4 76957ff8
[  445.692605] ffe0: 743caf40 741d7fd4 743b88d1 76d2cfe8 80000030 0000000b 00000000 00000000
[  445.700820] [<80550e20>] (pxp_device_ioctl) from [<80256c3c>] (do_vfs_ioctl+0x404/0x900)
[  445.708936] [<80256c3c>] (do_vfs_ioctl) from [<8025716c>] (ksys_ioctl+0x34/0x60)
[  445.716355] [<8025716c>] (ksys_ioctl) from [<80101000>] (ret_fast_syscall+0x0/0x54)
[  445.724023] Exception stack(0x93bfffa8 to 0x93bffff0)
[  445.729091] ffa0:                   75742980 743caee0 0000000b 80085007 741d7ff4 743cb004
[  445.737287] ffc0: 75742980 743caee0 01a152e0 00000036 00000002 741d8064 741d81d4 76957ff8
[  445.745477] ffe0: 743caf40 741d7fd4 743b88d1 76d2cfe8
[  445.750550] Code: e595100c e3a00000 e12fff34 eafffd39 (e594315c)
[  445.773509] ---[ end trace a4bb9353c99e0cef ]---

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: G.n. Zhou <guoniu.zhou@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
4cc4435291 LF-1596 dma: pxp: add checking for out against NULL
Coverity Issue ID: 414719

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Fancy Fang <chen.fang@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
437b49e593 LF-1595 dma: pxp: fix the typo for possible_inputs_s1 checking
Coverity Issue ID: 379378

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Fancy Fang <chen.fang@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
42fd87ca8b LF-1594 dma: pxp: fix out-of-bounds access
Coverity issue ID: 379372

As only one overlayer supported, the initialization for ol_param
need to be adjusted accordingly.

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Fancy Fang <chen.fang@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
1f696ce529 LF-105-1 dmaengine: pxp: fix build warning of fall through
Fix the following build warning:
../drivers/dma/pxp/pxp_dma_v3.c: In function 'pxp_store_shift_ctrl_config':
../drivers/dma/pxp/pxp_dma_v3.c:1700:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
    shift_bypass = 1;
    ~~~~~~~~~~~~~^~~
../drivers/dma/pxp/pxp_dma_v3.c:1701:3: note: here
   case PXP_PIX_FMT_YVYU:
   ^~~~
../drivers/dma/pxp/pxp_dma_v3.c:1705:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
    shift_bypass = 1;
    ~~~~~~~~~~~~~^~~
../drivers/dma/pxp/pxp_dma_v3.c:1706:3: note: here
   case PXP_PIX_FMT_NV61:
   ^~~~

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 16:08:19 +08:00
Robby Cai
e38c4297f7 media: pxp device: fix kernel dump when run pxp_test
In 5.x, the first parameter of dma_alloc_coherent() can't be 0, otherwise
the following dump will arise when run the command:
`/unit_tests/Display/pxp_test.out -I "-o 1.yuv" '. This patch fixed this.
And also, use register_chrdev instead of misc_register to make it clean.

[   53.838653] Internal error: Oops: 17 [#1] SMP ARM
[   53.844538] Modules linked in:
[   53.847610] CPU: 0 PID: 754 Comm: pxp_test.out Not tainted 5.4.0-rc5-03564-g9792b86 #46
[   53.855620] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[   53.861473] PC is at dma_alloc_attrs+0x10/0x114
[   53.866015] LR is at pxp_device_ioctl+0x90c/0xe98
[   53.870728] pc : [<c01bf1e8>]    lr : [<c05eb360>]    psr: a0070013
[   53.877001] sp : ed4e7e74  ip : 00000001  fp : b6591f9c
[   53.882232] r10: 00000000  r9 : e47efd40  r8 : ed4e7ecc
[   53.887463] r7 : ed508cc0  r6 : c1408b08  r5 : 00000000  r4 : 00000051
[   53.893997] r3 : 00000cc1  r2 : e47efd4c  r1 : 00055000  r0 : 00000240
[   53.900533] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   53.907675] Control: 10c5387d  Table: ad14804a  DAC: 00000051
[   53.913428] Process pxp_test.out (pid: 754, stack limit = 0x(ptrval))
[   53.919878] Stack: (0xed4e7e74 to 0xed4e8000)
[   53.924245] 7e60:                                              00000051 b6591cf4 c1408b08
[   53.932434] 7e80: ed508cc0 ed4e7ecc e47efd40 00000000 b6591f9c c05eb360 00000000 c0605e08
[   53.940622] 7ea0: ed42ac00 c0607e3c 00000034 e47fe3c0 ed4e6000 00000034 c1408b08 c0605cc0
[   53.948810] 7ec0: ed4e7f78 00000000 ed4e6000 00000000 00054600 00000000 00000000 00000000
[   53.956998] 7ee0: c1408b08 0479b828 00000000 c1408b08 b6591cf4 e47fb640 c02b7b8c b6591cf4
[   53.965187] 7f00: ed4e6000 eca65e00 b6591f9c c02b71e0 c02c4bbc c0192be8 ec2dc380 c018dc54
[   53.973374] 7f20: c1408b08 00000001 00000000 0479b828 c15344fd 00000004 00004000 e47fb3c0
[   53.981562] 7f40: c15344fd c112a1d4 c110a05c c02c4bcc 00000000 00000000 c02c4aa8 00000000
[   53.989750] 7f60: e47fab41 0479b828 bee8aad0 e47fb641 e47fb640 00000004 c0145004 b6591cf4
[   53.997938] 7f80: ed4e6000 00000036 b6591f9c c02b7b8c b6591cf4 bee8aad0 b6591ce8 00000036
[   54.006125] 7fa0: c01011c4 c0101000 b6591cf4 bee8aad0 00000004 c0145004 b6591cf4 b6ee603c
[   54.014313] 7fc0: b6591cf4 bee8aad0 b6591ce8 00000036 00077858 00000000 bee8aad0 b6591f9c
[   54.022502] 7fe0: b6ee6018 b6591cac b6ed5848 b6e604bc 60070010 00000004 00000000 00000000
[   54.030699] [<c01bf1e8>] (dma_alloc_attrs) from [<00000034>] (0x34)
[   54.036981] Code: e92d4ff0 e1a05000 e2800d09 e59f60ec (e140a0d8)
[   54.043222] ---[ end trace d872f4c07e2464bf ]---

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:18 +08:00
Robby Cai
2af6194aa2 dma: pxp: porting pxp dma driver from imx_4.19.y
Porting pxp dma drivers v2 and v3 from imx_4.19.y

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 16:08:18 +08:00
Joy Zou
1da6465fa1 LF-9861: dmaengine: imx-sdma: Fix audio p2p test on imx8m
The sdma p2p script presently does not deal with the transactions involving
two devices connected to AIPS bus.

So the audio p2p test can use spba-bus, but the sdma driver check the
peripherals address doesn't belong to the spba-bus due to get wrong
spba-bus address when there are multi spba-bus. The sdma controllers
and the peripherals are fixed to the correspond spba-bus.

This patch modifies the method of finding spba-bus, and make sure the
parent node of the spba-bus is same with the sdma.

Reported-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 15:40:28 +08:00
Joy Zou
672fca4236 LF-8851: dmaengine: imx-sdma: sdma driver code optimization
The bluetooth starts to use sdma before sdma driver initialization done.
It will cause NULL pointer access.

This patch adds sdma is_on check in order to avoid accessing NULL pointer.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 15:40:28 +08:00
Robin Gong
ea52796d5d MLK-25266: dmaengine: imx-sdma: add i2c dma support
add new i2c dma script.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Acked-by: Clark Wang <xiaoning.wang@nxp.com>
2023-10-30 15:40:28 +08:00
Robin Gong
5d9cee419d LF-301: dmaengine: imx-sdma: Add once more loading firmware
In case 60 seconds maybe not enough for Yocto loading sdma firmware on
some poor performance chips such as i.mx6sll in nfs case, add another
round to load firmware.

If there is more than one sdma controller, the first controller
load sdma firmware using fallback failed in first time, it will
retry load sdma firmware again. But the second sdma controller
error state clean up may be still not finished (the firmware
request priv data has not been released). So the retry will fail
immediately due to get the old firmware priv data.

The fail log as follow:

[   62.505753] imx-sdma 30e10000.dma-controller: external firmware not found, using ROM firmware
[   62.599868] imx-sdma 30bd0000.dma-controller: firmware found.
[   62.605808] imx-sdma 30bd0000.dma-controller: loaded firmware 4.6

This patch adds a bit delay to wait for the second controller
firmware priv data released.

This issue is very hard to reproduce with yocto rootfs.
The 20ms delay is tested value with ubuntu rootfs which is more easy
to reproduce.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 15:40:28 +08:00
Robin Gong
77b45aa69f dmaengine: imx-sdma: Add pm_ops to support suspend & resume
Split sdma_init_sw from sdma_init, so that it's easier for implementing
runtime suspend/resume.

On i.mx6sx or i.mx7d chip, megafast could be off in suspend which
means sdma controller will be power-ed off, thus sdma driver
should resume back including firmware loaded again.

Add sdma restore back for i.mx8mp since its power resource audioimx will
be off after suspend.

Add runtime suspend/resume support on i.mx8mp. So sdma will be initialized
and firmware will be loaded at first channel requested, sdma will be off
once no any channel is running.For the legacy chips just keep sdma on
always as before.

There are two more DONE0_CONFIG/DONE1_CONFIG registers on i.mx8m family.
Add them to save/restore register list  during systerm level suspend/
resume to restore them after resume back, otherwise, PDM case maybe failed
in suspend/resume case.

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
Reported-by: Jun Li <jun.li@nxp.com>
Tested-by: Jun Li <jun.li@nxp.com>
2023-10-30 15:40:28 +08:00
Joy Zou
c1530ea01a MLK-11259: dmaengine: imx-sdma: Add multi fifo for DEV_TO_DEV
Support multi fifo for DEV_TO_DEV.

Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 15:40:28 +08:00
Robin Gong
c705c35b1c dmaengine: imx-sdma: update sdma script for multi fifo on SAI
update sdma script for multi fifo SAI on i.mx8MQ. Besides,Add
new cell for sw_done/sw_done_selector, because PDM need enable
software done feature in sdma script(same multi fifo script).
The new fourth cell defined as below:
        Bit31: sw_done
        Bit15~bit0: selector
For example: 0x80000000 means sw_done enabled for done0 sector which
is for PDM on i.mx8mm.

Reviewed-by: Dong Aisheng <Aisheng.dong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
[ Shengjiu: fix memory release leakage ]
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 15:40:27 +08:00
Shengjiu Wang
6b9ecede8d MLK-22239: dmaengine: imx-sdma: Support 24bit/3bytes for sg mode
Update 3bytes buswidth that is supported by sdma.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
Signed-off-by: Srikanth Krishnakar <Srikanth_Krishnakar@mentor.com>
Acked-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 15:40:27 +08:00
Nicolin Chen
253b8927e1 dmaengine: imx-sdma: support allocate memory from iram
Allocate memory from SoC internal SRAM so that we can turn off
voltage of external DDR to save power if 'iram' property in dts.

Check iram_pool before sdma_init() so that ccb/context could be
allocated from iram because DDR maybe in self-referesh in lower power
audio case while sdma still running.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Joy Zou <joy.zou@nxp.com>
2023-10-30 15:40:27 +08:00
Yi Zhao
92fef99a93 dmaengine: fsl-dpaa2-qdma: Fix dpdmai unbind call trace issue
Signed-off-by: Yi Zhao <yi.zhao@nxp.com>
2023-10-30 15:40:02 +08:00
Yi Zhao
e19aac8bb9 LF-4727 dmaengine: fix qdma test failed
Signed-off-by: Yi Zhao <yi.zhao@nxp.com>
2023-10-30 15:40:02 +08:00
Yi Zhao
cbc1a797b1 LF-2780: dma: fsl-qdma: fix coverity issue: Dereference after null check
Coverity Issue: 11394158 Dereference after null check

Signed-off-by: Yi Zhao <yi.zhao@nxp.com>
2023-10-30 15:40:02 +08:00
Curtis Klein
6cdf349b35 fsl-qdma: Init irq after reg initialization
Initialize the qDMA irqs after the registers are configured so that
interrupts that may have been pending from a primary kernel don't get
processed by the irq handler before it is ready to and cause panic with
the following trace:

  Call trace:
   fsl_qdma_queue_handler+0xf8/0x3e8
   __handle_irq_event_percpu+0x78/0x2b0
   handle_irq_event_percpu+0x1c/0x68
   handle_irq_event+0x44/0x78
   handle_fasteoi_irq+0xc8/0x178
   generic_handle_irq+0x24/0x38
   __handle_domain_irq+0x90/0x100
   gic_handle_irq+0x5c/0xb8
   el1_irq+0xb8/0x180
   _raw_spin_unlock_irqrestore+0x14/0x40
   __setup_irq+0x4bc/0x798
   request_threaded_irq+0xd8/0x190
   devm_request_threaded_irq+0x74/0xe8
   fsl_qdma_probe+0x4d4/0xca8
   platform_drv_probe+0x50/0xa0
   really_probe+0xe0/0x3f8
   driver_probe_device+0x64/0x130
   device_driver_attach+0x6c/0x78
   __driver_attach+0xbc/0x158
   bus_for_each_dev+0x5c/0x98
   driver_attach+0x20/0x28
   bus_add_driver+0x158/0x220
   driver_register+0x60/0x110
   __platform_driver_register+0x44/0x50
   fsl_qdma_driver_init+0x18/0x20
   do_one_initcall+0x48/0x258
   kernel_init_freeable+0x1a4/0x23c
   kernel_init+0x10/0xf8
   ret_from_fork+0x10/0x18

Signed-off-by: Curtis Klein <curtis.klein@hpe.com>
Signed-off-by: Yi Zhao <yi.zhao@nxp.com>
2023-10-30 15:40:02 +08:00
Guanhua Gao
d87bbcf469 dmaengine: fsl-dpaa2-qdma: Update DPDMAI interfaces
This patch dupdates the DPDMAI interfaces to support MC firmware to
10.1x.x.

Signed-off-by: Guanhua Gao <guanhua.gao@nxp.com>
2023-10-30 15:40:02 +08:00
Guanhua Gao
1f81c27645 dmaengine: fsl-dpaa2-qdma: Fix the size of dma pools
In case of long format of qDMA command descriptor, there are one frame
descriptor, three entries in the frame list and two data entries. So the
size of dma_pool_create for these three fields should be the same with
the total size of entries respectively, or the contents may be overwritten
by the next allocated descriptor.

Signed-off-by: Guanhua Gao <guanhua.gao@nxp.com>
2023-10-30 15:40:02 +08:00
Peng Ma
d2c283d3e5 dmaengine: fsl-qdma: workaround for errata A-050265
There is an erratum which is: "Unaligned read transactions initiated
by QDMA may stall in the NOC (Network On-Chip), causing a deadlock
condition. Stalled transactions will trigger completion timeouts in
PCIe controller."

This patch is to resolve it.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
2023-10-30 15:40:01 +08:00
Jindong Yue
beb2548177 MA-19046-2 dma: mxs-dma: Turn MXS_DMA as tristate
Use tristate for mxs-dma to support module building.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Reviewed-by: Han Xu <han.xu@nxp.com>
2023-10-30 15:39:08 +08:00
Jindong Yue
87b6844732 MA-19046-1 dma: mxs-dma: Add module license and description
Module license string is required for loading it as a module.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Reviewed-by: Han Xu <han.xu@nxp.com>
2023-10-30 15:39:08 +08:00
Han Xu
c336d6f4e4 LF-251-2: dma: mxs-dma: switch from dma_coherent to dma_pool
create one dma_pool dedicate for all following dma_alloc and avoid
keeping allocate available memories.

Signed-off-by: Han Xu <han.xu@nxp.com>
2023-10-30 15:39:08 +08:00
Han Xu
b1e770181b LF-251-1: dma: mxs-dma: enable runtime PM for mxs-dma
enable runtime PM for mxs-dma

Signed-off-by: Han Xu <han.xu@nxp.com>
2023-10-30 15:39:08 +08:00
Han Xu
bbac597c6e MLK-19897: dma: mxs-dma: filter out the unrelated dma channels
update mxs-dma filter function to firstly filter the dma channels only
for mxs-dma, rather than checking unrelated dma chans in following code.

Signed-off-by: Han Xu <han.xu@nxp.com>
2023-10-30 15:39:08 +08:00
Iuliana Prodan
cd2c991835 LF-1116-2 dma: caam - update the check for the return code of caam_jr_enqueue function
In commit 4d370a1036 ("crypto: caam - change return code in caam_jr_enqueue function"),
the return code of caam_jr_enqueue function was changed
from 0 to -EINPROGRESS, in case of success, -ENOSPC in case
the CAAM is busy (has no space left in job ring queue),
-EIO if it cannot map the caller's descriptor.

Update the case for break from the loop of caam_dma_prep_memcpy
based on the new return code from caam_jr_enqueue function.

Fixes: 4d370a1036 ("crypto: caam - change return code in caam_jr_enqueue function")
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Peng Ma <peng.ma@nxp.com>
2023-10-30 15:38:41 +08:00
Horia Geantă
371f2dfced dma: caam: fix compilation error
Fix compilation error, introduced by incorrect rebase of the
commit 9c51c141264c ("dma: caam: add dma memcpy driver"
on top of upstream
commit 1bcdf5a00f41 ("crypto: caam - make CAAM_PTR_SZ dynamic")

Fixes: 9c51c141264c ("dma: caam: add dma memcpy driver")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
2023-10-30 15:38:41 +08:00
Peng Ma
438038f4cd dma: caam: add dma memcpy driver
This module introduces a memcpy DMA driver based on the DMA capabilities
of the CAAM hardware block. CAAM DMA is a platform driver that is only
probed if the device is defined in the device tree. The driver creates
a DMA channel for each JR of the CAAM. This introduces a dependency on
the JR driver. Therefore a defering mechanism was used to ensure that
the CAAM DMA driver is probed only after the JR driver.

Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
Signed-off-by: Rajiv Vishwakarma <rajiv.vishwakarma@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
2023-10-30 15:38:41 +08:00
Linus Torvalds
3439b2a87e dmaengine fixes for v6.6
Driver fixes for:
  - stm32 dma residue calculation and chaining
  - stm32 mdma for setting inflight bytes, residue calculation
    and resume abort
  - channel request, channel enable and dma error in fsl_edma
  - runtime pm imbalance in ste_dma40 driver
  - deadlock fix in mediatek driver
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+vs47OPLdNbVcHzyfBQHDyUjg0cFAmUpSbsACgkQfBQHDyUj
 g0dlphAAxeixlq3kY6JzAa1IDSDuahLB8ldtW3Vlqbs9q8WvAIdWK/CJAxZp97MU
 JeTG1JutXpHuPKobYvgqZGiDi5yGTqXsWgPMQhjC82ewiFJGA5csJiPBv60QX5Yv
 Y9jsnX9umUBsTNAB9vE9Qn7RpclZWW9brILtE3Cwomxbl1E3RBWCOJJf9tfVDoT4
 WBgrFCBA6cXmeebe3TKCc4vCNrThcrV0jN3fOt0YEBaLEXUF7jtSikGHzoqR9j3D
 G9cwS/Xcc5MkYsHzRV+HSdxoeM4AZoaUP2PpOpI+XH3RoN9DsDmKflgtbRDvTvmA
 9swXZOpcY28aZZ7zgrSBCeNW2uWUuFTtGZvsOhRcYciXaNWSb+07BO4tYwVx3FWk
 apFEj97cYHbus4LuHaG6xOupqv4o6g4OBP35+Q4T6CU8yPlrZst7fQei4puJhLsv
 nv8q85EofXWre+VpA5lJ0Y1viBNQMJzr4r8dSwS/1VdSoo7vCYvJ6v0rfXVQJBRM
 PC1zrUBX6unIhCP+BNzNSY1KOIiNF/b0jJQZTMNRWtS5KbcmIO1WtkOKJDvODS+M
 DuXOC97Z4wGv4xhieTDm8Sxbd8WnoiCtz6KPhKZ6CKnY61kJyqzhAe6RG+UcmlGI
 m2I8MPYG6OvoxUSxOTibhBM1bZCgcErYOLFQ7N1uHomVpO/09QI=
 =8dWs
 -----END PGP SIGNATURE-----

Merge tag 'dmaengine-fix-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine

Pull dmaengine fixes from Vinod Koul:
 "Driver fixes for:

   - stm32 dma residue calculation and chaining

   - stm32 mdma for setting inflight bytes, residue calculation and
     resume abort

   - channel request, channel enable and dma error in fsl_edma

   - runtime pm imbalance in ste_dma40 driver

   - deadlock fix in mediatek driver"

* tag 'dmaengine-fix-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine:
  dmaengine: fsl-edma: fix all channels requested when call fsl_edma3_xlate()
  dmaengine: stm32-dma: fix residue in case of MDMA chaining
  dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining
  dmaengine: stm32-mdma: set in_flight_bytes in case CRQA flag is set
  dmaengine: stm32-mdma: use Link Address Register to compute residue
  dmaengine: stm32-mdma: abort resume if no ongoing transfer
  dmaengine: ste_dma40: Fix PM disable depth imbalance in d40_probe
  dmaengine: mediatek: Fix deadlock caused by synchronize_irq()
  dmaengine: idxd: use spin_lock_irqsave before wait_event_lock_irq
  dmaengine: fsl-edma: fix edma4 channel enable failure on second attempt
  dt-bindings: dmaengine: zynqmp_dma: add xlnx,bus-width required property
  dmaengine: fsl-dma: fix DMA error when enabling sg if 'DONE' bit is set
2023-10-13 08:52:57 -07:00
Frank Li
3fa53518ad dmaengine: fsl-edma: fix all channels requested when call fsl_edma3_xlate()
dma_get_slave_channel() increases client_count for all channels. It should
only be called when a matched channel is found in fsl_edma3_xlate().

Move dma_get_slave_channel() after checking for a matched channel.

Cc: stable@vger.kernel.org
Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20231004142911.838916-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 11:12:19 +05:30
Amelie Delaunay
67e13e8974 dmaengine: stm32-dma: fix residue in case of MDMA chaining
In case of MDMA chaining, DMA is configured in Double-Buffer Mode (DBM)
with two periods, but if transfer has been prepared with _prep_slave_sg(),
the transfer is not marked cyclic (=!chan->desc->cyclic). However, as DBM
is activated for MDMA chaining, residue computation must take into account
cyclic constraints.

With only two periods in MDMA chaining, and no update due to Transfer
Complete interrupt masked, n_sg is always 0. If DMA current memory address
(depending on SxCR.CT and SxM0AR/SxM1AR) does not correspond, it means n_sg
should be increased.
Then, the residue of the current period is the one read from SxNDTR and
should not be overwritten with the full period length.

Fixes: 723795173c ("dmaengine: stm32-dma: add support to trigger STM32 MDMA")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231004155024.2609531-2-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 11:10:58 +05:30
Amelie Delaunay
2df467e908 dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining
Current Target (CT) have to be reset when starting an MDMA chaining use
case, as Double Buffer mode is activated. It ensures the DMA will start
processing the first memory target (pointed with SxM0AR).

Fixes: 723795173c ("dmaengine: stm32-dma: add support to trigger STM32 MDMA")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231004155024.2609531-1-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 11:10:58 +05:30
Amelie Delaunay
5849704217 dmaengine: stm32-mdma: set in_flight_bytes in case CRQA flag is set
CRQA flag is set by hardware when the channel request become active and
the channel is enabled. It is cleared by hardware, when the channel request
is completed.
So when it is set, it means MDMA is transferring bytes.
This information is useful in case of STM32 DMA and MDMA chaining,
especially when the user pauses DMA before stopping it, to trig one last
MDMA transfer to get the latest bytes of the SRAM buffer to the
destination buffer.
STM32 DCMI driver can then use this to know if the last MDMA transfer in
case of chaining is done.

Fixes: 6968743227 ("dmaengine: stm32-mdma: add support to be triggered by STM32 DMA")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231004163531.2864160-3-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 11:10:30 +05:30
Amelie Delaunay
a4b306eb83 dmaengine: stm32-mdma: use Link Address Register to compute residue
Current implementation relies on curr_hwdesc index. But to keep this index
up to date, Block Transfer interrupt (BTIE) has to be enabled.
If it is not, curr_hwdesc is not updated, and then residue is not reliable.
Rely on Link Address Register instead. And disable BTIE interrupt
in stm32_mdma_setup_xfer() because it is no more needed in case of
_prep_slave_sg() to maintain curr_hwdesc up to date.
It avoids extra interrupts and also ensures a reliable residue. These
improvements are required for STM32 DCMI camera capture use case, which
need STM32 DMA and MDMA chaining for good performance.

Fixes: 6968743227 ("dmaengine: stm32-mdma: add support to be triggered by STM32 DMA")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231004163531.2864160-2-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 11:10:30 +05:30
Amelie Delaunay
81337b9a72 dmaengine: stm32-mdma: abort resume if no ongoing transfer
chan->desc can be null, if transfer is terminated when resume is called,
leading to a NULL pointer when retrieving the hwdesc.
To avoid this case, check that chan->desc is not null and channel is
disabled (transfer previously paused or terminated).

Fixes: a4ffb13c89 ("dmaengine: Add STM32 MDMA driver")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231004163531.2864160-1-amelie.delaunay@foss.st.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 11:10:30 +05:30
Zhang Shurong
0618c077a8 dmaengine: ste_dma40: Fix PM disable depth imbalance in d40_probe
The pm_runtime_enable will increase power disable depth. Thus
a pairing decrement is needed on the error handling path to
keep it balanced according to context.
We fix it by calling pm_runtime_disable when error returns.

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/tencent_DD2D371DB5925B4B602B1E1D0A5FA88F1208@qq.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-09 10:56:51 +05:30
Duoming Zhou
01f1ae2733 dmaengine: mediatek: Fix deadlock caused by synchronize_irq()
The synchronize_irq(c->irq) will not return until the IRQ handler
mtk_uart_apdma_irq_handler() is completed. If the synchronize_irq()
holds a spin_lock and waits the IRQ handler to complete, but the
IRQ handler also needs the same spin_lock. The deadlock will happen.
The process is shown below:

          cpu0                        cpu1
mtk_uart_apdma_device_pause() | mtk_uart_apdma_irq_handler()
  spin_lock_irqsave()         |
                              |   spin_lock_irqsave()
  //hold the lock to wait     |
  synchronize_irq()           |

This patch reorders the synchronize_irq(c->irq) outside the spin_lock
in order to mitigate the bug.

Fixes: 9135408c3a ("dmaengine: mediatek: Add MediaTek UART APDMA support")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Eugen Hristev <eugen.hristev@collabora.com>
Link: https://lore.kernel.org/r/20230806032511.45263-1-duoming@zju.edu.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-04 19:26:36 +05:30
Dan Carpenter
f9a1d3216a dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
The k3_udma_glue_tx_get_irq() function currently returns negative error
codes on error, zero on error and positive values for success.  This
complicates life for the callers who need to propagate the error code.
Also GCC will not warn about unsigned comparisons when you check:

	if (unsigned_irq <= 0)

All the callers have been fixed now but let's just make this easy going
forward.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-10-04 10:29:55 +01:00
Rex Zhang
c0409dd3d1 dmaengine: idxd: use spin_lock_irqsave before wait_event_lock_irq
In idxd_cmd_exec(), wait_event_lock_irq() explicitly calls
spin_unlock_irq()/spin_lock_irq(). If the interrupt is on before entering
wait_event_lock_irq(), it will become off status after
wait_event_lock_irq() is called. Later, wait_for_completion() may go to
sleep but irq is disabled. The scenario is warned in might_sleep().

Fix it by using spin_lock_irqsave() instead of the primitive spin_lock()
to save the irq status before entering wait_event_lock_irq() and using
spin_unlock_irqrestore() instead of the primitive spin_unlock() to restore
the irq status before entering wait_for_completion().

Before the change:
idxd_cmd_exec() {
interrupt is on
spin_lock()                        // interrupt is on
	wait_event_lock_irq()
		spin_unlock_irq()  // interrupt is enabled
		...
		spin_lock_irq()    // interrupt is disabled
spin_unlock()                      // interrupt is still disabled
wait_for_completion()              // report "BUG: sleeping function
				   // called from invalid context...
				   // in_atomic() irqs_disabled()"
}

After applying spin_lock_irqsave():
idxd_cmd_exec() {
interrupt is on
spin_lock_irqsave()                // save the on state
				   // interrupt is disabled
	wait_event_lock_irq()
		spin_unlock_irq()  // interrupt is enabled
		...
		spin_lock_irq()    // interrupt is disabled
spin_unlock_irqrestore()           // interrupt is restored to on
wait_for_completion()              // No Call trace
}

Fixes: f9f4082dbc ("dmaengine: idxd: remove interrupt disable for cmd_lock")
Signed-off-by: Rex Zhang <rex.zhang@intel.com>
Signed-off-by: Lijun Pan <lijun.pan@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20230916060619.3744220-1-rex.zhang@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-10-04 13:01:29 +05:30
Frank Li
3f4b82167a dmaengine: fsl-edma: fix edma4 channel enable failure on second attempt
When attempting to start DMA for the second time using
fsl_edma3_enable_request(), channel never start.

CHn_MUX must have a unique value when selecting a peripheral slot in the
channel mux configuration. The only value that may overlap is source 0.
If there is an attempt to write a mux configuration value that is already
consumed by another channel, a mux configuration of 0 (SRC = 0) will be
written.

Check CHn_MUX before writing in fsl_edma3_enable_request().

Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230823182635.2618118-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-09-28 16:58:57 +05:30
Frank Li
3c67c5236f dmaengine: fsl-dma: fix DMA error when enabling sg if 'DONE' bit is set
In eDMAv3, clearing 'DONE' bit (bit 30) of CHn_CSR is required when
enabling scatter-gather (SG). eDMAv4 does not require this change.

Cc: stable@vger.kernel.org
Fixes: 72f5801a4e ("dmaengine: fsl-edma: integrate v3 support")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230921144652.3259813-1-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-09-28 16:50:34 +05:30
Linus Torvalds
708283abf8 dmaengine updates for v6.6
New support:
  - Qualcomm SM6115 and QCM2290 dmaengine support
  - at_xdma support for microchip,sam9x7 controller
 
  Updates:
  - idxd updates for wq simplification and ats knob updates
  - fsl edma updates for v3 support
  - Xilinx AXI4-Stream control support
  - Yaml conversion for bcm dma binding
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+vs47OPLdNbVcHzyfBQHDyUjg0cFAmT0xHEACgkQfBQHDyUj
 g0cUNw/+IN6UpnQyQ61D6Ljv1IjjmmhJS7hVVnkQvAzlFdsRdAw9Ez5jJB2qz7kU
 dAcFKDPTVGZaLYSeQFkmbHeRF8Sk8rCOBHTWMMM085LMttATVhRjth3m2gj4Jp0Y
 XOaJ/TWXGM9DAtojhOoEV+xtY8KdASkwrS7DiPYrwx8u/BTA3p8fa6v3ggyi/ttf
 PoPXfmXR7PupZM5CLDaPMDBW5aIveLbTSsXGlixRrWbccI2dH9RG/l5KKUPFq2Se
 LEIYtsa4ZK8OOb+WpUaZjJ5C7JgXMm0ZCXK9n8tqcdMjxjPAdOoy0lasaVLS0yw9
 BiL4D5sFkUYAOf/9QTY3CSlzv7sjuSCBCGzppV5dYdliKCMx/qv34zNyBnWyhhgA
 oW6h0cWQU/kcX9AUptYn9bHWDb4/Cykd+g9fUlCa1En8DL4lMRkKojHGKieD0mWw
 A9p8W5p8K//g0FOjfPvqNhFP3iCkVCXMys1/mLZvKzofX6PEJc7lPPetY/YLYdBQ
 g02lb6X4FP6MIyPlAzrmudGnCkYuUWGzXE2K4Rs/uTJtfTEkVwICMEQrnAszSl3o
 4hYVjcDfk+5/4guFr4gHRqMq58E+cVv+zV70r2ttnF79lX6sTJ/Uvr7cJa1qVhB9
 0mPLf7GXoKVanrX0rH0w/67Lo7wrQVdd/94BmHyd0kd8lUh63FM=
 =LPWk
 -----END PGP SIGNATURE-----

Merge tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine

Pull dmaengine updates from Vinod Koul:
 "New controller support and updates to drivers.

  New support:
   - Qualcomm SM6115 and QCM2290 dmaengine support
   - at_xdma support for microchip,sam9x7 controller

  Updates:
   - idxd updates for wq simplification and ats knob updates
   - fsl edma updates for v3 support
   - Xilinx AXI4-Stream control support
   - Yaml conversion for bcm dma binding"

* tag 'dmaengine-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine: (53 commits)
  dmaengine: fsl-edma: integrate v3 support
  dt-bindings: fsl-dma: fsl-edma: add edma3 compatible string
  dmaengine: fsl-edma: move tcd into struct fsl_dma_chan
  dmaengine: fsl-edma: refactor chan_name setup and safety
  dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function
  dmaengine: fsl-edma: refactor using devm_clk_get_enabled
  dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs()
  dmaengine: fsl-edma: move common IRQ handler to common.c
  dmaengine: fsl-edma: Remove enum edma_version
  dmaengine: fsl-edma: transition from bool fields to bitmask flags in drvdata
  dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c
  dmaengine: fsl-edma: fix build error when arch is s390
  dmaengine: idxd: Fix issues with PRS disable sysfs knob
  dmaengine: idxd: Allow ATS disable update only for configurable devices
  dmaengine: xilinx_dma: Program interrupt delay timeout
  dmaengine: xilinx_dma: Use tasklet_hi_schedule for timing critical usecase
  dmaengine: xilinx_dma: Freeup active list based on descriptor completion bit
  dmaengine: xilinx_dma: Increase AXI DMA transaction segment count
  dmaengine: xilinx_dma: Pass AXI4-Stream control words to dma client
  dt-bindings: dmaengine: xilinx_dma: Add xlnx,irq-delay property
  ...
2023-09-03 10:49:42 -07:00
Frank Li
72f5801a4e dmaengine: fsl-edma: integrate v3 support
Significant alterations have been made to the EDMA v3's register layout.
Now, each channel possesses a separate address space, encapsulating all
channel-related controls and statuses, including IRQs. There are changes
in bit position definitions as well. However, the fundamental control flow
remains analogous to the previous versions.

EDMA v3 was utilized in imx8qm, imx93, and will be in forthcoming chips.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-13-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:03 +05:30
Frank Li
7536f8b371 dmaengine: fsl-edma: move tcd into struct fsl_dma_chan
Relocates the tcd into the fsl_dma_chan structure. This adjustment reduces
the need to reference back to fsl_edma_engine, paving the way for EDMA V3
support.

Unified the edma_writel and edma_writew functions for accessing TCD
(Transfer Control Descriptor) registers. A new macro is added that can
automatically detect whether a 32-bit or 16-bit access should be used
based on the structure field definition. This provide better support
64-bit TCD with future v5 version.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202305271951.gmRobs3a-lkp@intel.com/
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-11-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:03 +05:30
Frank Li
9b05554c5c dmaengine: fsl-edma: refactor chan_name setup and safety
Relocated the setup of chan_name from setup_irq() to fsl_chan init. This
change anticipates its future use in various locations.

For increased safety, sprintf has been replaced with snprintf. In addition,
The size of the fsl_chan->name[] array was expanded from 16 to 32.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-10-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:03 +05:30
Frank Li
f5b3ba52f3 dmaengine: fsl-edma: move clearing of register interrupt into setup_irq function
This accommodates differences in the register layout of EDMA v3 by moving
the clearing of register interrupts into the platform-specific set_irq
function. This should ensure better compatibility with EDMA v3.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-9-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:03 +05:30
Frank Li
a9903de3aa dmaengine: fsl-edma: refactor using devm_clk_get_enabled
Use devm_clk_get_enabled in probe code to reduce error checks,
thereby enhancing readability

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-8-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:03 +05:30
Frank Li
ee2dda0646 dmaengine: fsl-edma: simply ATTR_DSIZE and ATTR_SSIZE by using ffs()
Removes all ATTR_DSIZE_*BIT(BYTE) and ATTR_SSIZE_*BIT(BYTE) definitions
in edma. Uses ffs() instead, as it gives identical results. This simplifies
the code and avoids adding more similar definitions in future V3 version.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-7-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:02 +05:30
Frank Li
79434f9b97 dmaengine: fsl-edma: move common IRQ handler to common.c
Move the common part of IRQ handler from fsl-edma-main.c and
mcf-edma-main.c to fsl-edma-common.c. This eliminates redundant code, as
the both files contains mostly identical code.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-6-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:02 +05:30
Frank Li
c26e611433 dmaengine: fsl-edma: Remove enum edma_version
The enum edma_version, which defines v1, v2, and v3, is a software concept
used to distinguish IP differences. However, it is not aligned with the
chip reference manual. According to the 7ulp reference manual, it should
be edma2. In the future, there will be edma3, edma4, and edma5, which
could cause confusion. To avoid this confusion, remove the edma_version
and instead use drvdata->flags to distinguish the IP difference.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-5-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:02 +05:30
Frank Li
9e006b2439 dmaengine: fsl-edma: transition from bool fields to bitmask flags in drvdata
Replace individual bool fields with bitmask flags within drvdata. This
will facilitate future extensions, making it easier to add more flags to
accommodate new versions of the edma IP.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-4-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:02 +05:30
Frank Li
66aac8ea0a dmaengine: fsl-edma: clean up EXPORT_SYMBOL_GPL in fsl-edma-common.c
Exported functions in fsl-edma-common.c are only used within
fsl-edma.c and mcf-edma.c. Global export is unnecessary.

This commit removes all EXPORT_SYMBOL_GPL in fsl-edma-common.c,
and renames fsl-edma.c and mcf-edma.c to maintain the same
final module names as before, thereby simplifying the codebase.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-3-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:02 +05:30
Frank Li
8b9aee8073 dmaengine: fsl-edma: fix build error when arch is s390
fixed build error reported by kernel test robot.

>> s390-linux-ld: fsl-edma-main.c:(.text+0xf4c): undefined reference to `devm_platform_ioremap_resource'
   s390-linux-ld: drivers/dma/idma64.o: in function `idma64_platform_probe':

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202306210131.zaHVasxz-lkp@intel.com/
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230821161617.2142561-2-Frank.Li@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-22 20:11:02 +05:30
Fenghua Yu
8cae665743 dmaengine: idxd: Fix issues with PRS disable sysfs knob
There are two issues in the current PRS disable sysfs store function
wq_prs_disable_store():

1. Since PRS disable knob is invisible if PRS disable is not supported
   in WQ, it's redundant to check PRS support again in the store function
   again. Remove the redundant PRS support check.
2. Since PRS disable is read-only when the device is not configurable,
   PRS disable cannot be changed on the device. Add device configurable
   check in the store function.

Fixes: f2dc327131 ("dmaengine: idxd: add per wq PRS disable")
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230811012635.535413-2-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:56:31 +05:30
Fenghua Yu
0056a7f07b dmaengine: idxd: Allow ATS disable update only for configurable devices
ATS disable status in a WQ is read-only if the device is not configurable.
This change ensures that the ATS disable attribute can be modified via
sysfs only on configurable devices.

Fixes: 92de5fa2dc ("dmaengine: idxd: add ATS disable knob for work queues")
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230811012635.535413-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:56:30 +05:30
Radhey Shyam Pandey
84b798fedf dmaengine: xilinx_dma: Program interrupt delay timeout
Program IRQDelay for AXI DMA. The interrupt timeout mechanism causes
the DMA engine to generate an interrupt after the delay time period
has expired. It enables dmaengine to respond in real-time even though
interrupt coalescing is configured. It also remove the placeholder
for delay interrupt and merge it with frame completion interrupt.
Since by default interrupt delay timeout is disabled this feature
addition has no functional impact on VDMA, MCDMA and CDMA IP's.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://lore.kernel.org/r/1691387509-2113129-8-git-send-email-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:40:37 +05:30
Radhey Shyam Pandey
c77d4c5081 dmaengine: xilinx_dma: Use tasklet_hi_schedule for timing critical usecase
Schedule tasklet with high priority to ensure that callback processing
is prioritized. It improves throughput for netdev dma clients.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://lore.kernel.org/r/1691387509-2113129-7-git-send-email-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:40:37 +05:30
Radhey Shyam Pandey
7bcdaa6581 dmaengine: xilinx_dma: Freeup active list based on descriptor completion bit
AXIDMA IP in SG mode sets completion bit to 1 when the transfer is
completed. Read this bit to move descriptor from active list to the
done list. This feature is needed when interrupt delay timeout and
IRQThreshold is enabled i.e Dly_IrqEn is triggered w/o completing
interrupt threshold.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://lore.kernel.org/r/1691387509-2113129-6-git-send-email-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:40:37 +05:30
Radhey Shyam Pandey
491e9d4096 dmaengine: xilinx_dma: Increase AXI DMA transaction segment count
Increase AXI DMA transaction segments count to ensure that even in
high load we always get a free segment in prepare descriptor for a
DMA_SLAVE transaction.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://lore.kernel.org/r/1691387509-2113129-5-git-send-email-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:40:37 +05:30
Radhey Shyam Pandey
d8a3f65f6c dmaengine: xilinx_dma: Pass AXI4-Stream control words to dma client
Read DT property to check if AXI DMA is connected to streaming IP
i.e axiethernet. If connected i.e xlnx,axistream-connected property
is present in the dma node then pass AXI4-Stream control words to dma
client using metadata_ops dmaengine API.

If not connected then driver won't support metadata_ops dmaengine API
and continue to support all legacy usecases.

Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://lore.kernel.org/r/1691387509-2113129-4-git-send-email-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:40:36 +05:30
Jialin Zhang
c65029b13b dmaengine: ioatdma: use pci_dev_id() to simplify the code
PCI core API pci_dev_id() can be used to get the BDF number for a pci
device. We don't need to compose it mannually. Use pci_dev_id() to
simplify the code a little bit.

Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230815023821.3518007-1-zhangjialin11@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:39:25 +05:30
Yajun Deng
f4f84fb632 dmaengine: ioat: fixing the wrong dma_dev->chancnt
The chancnt would be updated in __dma_async_device_channel_register(),
but it was assigned in ioat_enumerate_channels(). Therefore chancnt has
the wrong value.

Add chancnt member to the struct ioatdma_device, ioat_dma->chancnt
is used in ioat, dma_dev->chancnt is used in dmaengine.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230815061151.2724474-1-yajun.deng@linux.dev
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:38:19 +05:30
Yajun Deng
81ebed8aa2 dmaengine: Simplify dma_async_device_register()
There are a lot of duplicate codes for checking if the dma has some
capability.

Define a temporary macro that is used to check if the dma claims some
capability and if the corresponding function is implemented.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230815072346.2798927-1-yajun.deng@linux.dev
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:36:46 +05:30
Yu Liao
33a0b73454 dmaengine: fsl-edma: use struct_size() helper
Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worst scenario, could lead to heap overflows.

Signed-off-by: Yu Liao <liaoyu15@huawei.com>
Link: https://lore.kernel.org/r/20230821073600.4078584-1-liaoyu15@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 18:35:23 +05:30
Joerg Roedel
d8fe59f110 Merge branches 'apple/dart', 'arm/mediatek', 'arm/renesas', 'arm/rockchip', 'arm/smmu', 'unisoc', 'x86/vt-d', 'x86/amd' and 'core' into next 2023-08-21 14:18:43 +02:00
Christophe JAILLET
923b138388 dmaengine: mcf-edma: Use struct_size()
Use struct_size() instead of hand writing it.
This is less verbose and more informative.

'mcf_chan' is now unused and can be removed. In fact, it is shadowed by
another variable in the 'for' loop below. Keep this one.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/97c2bb1c9b69d0739da3762a7752ae6582c4ad02.1683390112.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 11:17:23 +05:30
Li Zetao
8674ca3950 dmaengine: lgm: Use builtin_platform_driver macro to simplify the code
Use the builtin_platform_driver macro to simplify the code, which is the
same as declaring with device_initcall().

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Acked-by: Peter Harliman Liem <pliem@maxlinear.com>
Link: https://lore.kernel.org/r/20230815080250.1089589-1-lizetao1@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 11:13:09 +05:30
ruanjinjie
c05ce6907b dmaengine: ste_dma40: Add missing IRQ check in d40_probe
Check for the return value of platform_get_irq(): if no interrupt
is specified, it wouldn't make sense to call request_irq().

Fixes: 8d318a50b3 ("DMAENGINE: Support for ST-Ericssons DMA40 block v3")
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230724144108.2582917-1-ruanjinjie@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 11:12:16 +05:30
Justin Stitt
1fbda5f4c7 dmaengine: owl-dma: fix clang -Wvoid-pointer-to-enum-cast warning
When building with clang 18 I see the following warning:
|       drivers/dma/owl-dma.c:1119:14: warning: cast to smaller integer type
|       'enum owl_dma_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
|        1119 | od->devid = (enum owl_dma_id)of_device_get_match_data(&pdev->dev);

This is due to the fact that `of_device_get_match_data()` returns a
void* while `enum owl_dma_id` has the size of an int.

Cast result of `of_device_get_match_data()` to a uintptr_t to silence
the above warning for clang builds using W=1

Link: https://github.com/ClangBuiltLinux/linux/issues/1910
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://lore.kernel.org/r/20230816-void-drivers-dma-owl-dma-v1-1-a0a5e085e937@google.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 11:06:08 +05:30
Yue Haibing
3c935af7a8 dmaengine: idxd: Remove unused declarations
Commit c05257b560 ("dmanegine: idxd: open code the dsa_drv registration")
removed idxd_{un}register_driver() definitions but not the declarations.
Commit 034b3290ba ("dmaengine: idxd: create idxd_device sub-driver")
declared idxd_{un}register_idxd_drv() but never implemented it.
Commit 8f47d1a5e5 ("dmaengine: idxd: connect idxd to dmaengine
subsystem") declared idxd_parse_completion_status() but never implemented
it.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20230817114135.50264-1-yuehaibing@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-21 11:05:04 +05:30
Jacob Pan
f5ccf55e10 dmaengine/idxd: Re-enable kernel workqueue under DMA API
Kernel workqueues were disabled due to flawed use of kernel VA and SVA
API. Now that we have the support for attaching PASID to the device's
default domain and the ability to reserve global PASIDs from SVA APIs,
we can re-enable the kernel work queues and use them under DMA API.

We also use non-privileged access for in-kernel DMA to be consistent
with the IOMMU settings. Consequently, interrupt for user privilege is
enabled for work completion IRQs.

Link: https://lore.kernel.org/linux-iommu/20210511194726.GP1002214@nvidia.com/
Tested-by: Tony Zhu <tony.zhu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Link: https://lore.kernel.org/r/20230802212427.1497170-9-jacob.jun.pan@linux.intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2023-08-09 17:44:39 +02:00
Miquel Raynal
422dbc66b7 dmaengine: xilinx: xdma: Fix typo
Probably a copy/paste error with the previous block, here we are
actually managing C2H IRQs.

Fixes: 17ce252266 ("dmaengine: xilinx: xdma: Add xilinx xdma driver")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20230731101442.792514-3-miquel.raynal@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-07 00:01:41 +05:30
Miquel Raynal
96891e90d1 dmaengine: xilinx: xdma: Fix interrupt vector setting
A couple of hardware registers need to be set to reflect which
interrupts have been allocated to the device. Each register is 32-bit
wide and can receive four 8-bit values. If we provide any other interrupt
number than four, the irq_num variable will never be 0 within the while
check and the while block will loop forever.

There is an easy way to prevent this: just break the for loop
when we reach "irq_num == 0", which anyway means all interrupts have
been processed.

Cc: stable@vger.kernel.org
Fixes: 17ce252266 ("dmaengine: xilinx: xdma: Add xilinx xdma driver")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://lore.kernel.org/r/20230731101442.792514-2-miquel.raynal@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-07 00:01:41 +05:30
Zhang Jianhua
74d7221c1f dmaengine: owl-dma: Modify mismatched function name
No functional modification involved.

drivers/dma/owl-dma.c:208: warning: expecting prototype for struct owl_dma_pchan. Prototype was for struct owl_dma_vchan instead HDRTEST usr/include/sound/asequencer.h

Fixes: 47e20577c2 ("dmaengine: Add Actions Semi Owl family S900 DMA driver")
Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20230722153244.2086949-1-chris.zjh@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-07 00:01:41 +05:30
Fenghua Yu
863676fe1a dmaengine: idxd: Clear PRS disable flag when disabling IDXD device
Disabling IDXD device doesn't reset Page Request Service (PRS)
disable flag to its initial value 0. This may cause user confusion
because once PRS is disabled user will see PRS still remains the
previous setting (i.e. disabled) via sysfs interface even after the
device is disabled.

To eliminate user confusion, reset PRS disable flag to ensure that
the PRS flag bit reflects correct state after the device is disabled.

Additionally, simplify the code by setting wq->flags to 0, which clears
all flag bits, including any future additions.

Fixes: f2dc327131 ("dmaengine: idxd: add per wq PRS disable")
Tested-by: Tony Zhu <tony.zhu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230712193505.3440752-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-07 00:01:41 +05:30
Ilpo Järvinen
8cda3ececf dmaengine: pl330: Return DMA_PAUSED when transaction is paused
pl330_pause() does not set anything to indicate paused condition which
causes pl330_tx_status() to return DMA_IN_PROGRESS. This breaks 8250
DMA flush after the fix in commit 57e9af7831 ("serial: 8250_dma: Fix
DMA Rx rearm race"). The function comment for pl330_pause() claims
pause is supported but resume is not which is enough for 8250 DMA flush
to work as long as DMA status reports DMA_PAUSED when appropriate.

Add PAUSED state for descriptor and mark BUSY descriptors with PAUSED
in pl330_pause(). Return DMA_PAUSED from pl330_tx_status() when the
descriptor is PAUSED.

Reported-by: Richard Tresidder <rtresidd@electromag.com.au>
Tested-by: Richard Tresidder <rtresidd@electromag.com.au>
Fixes: 88987d2c75 ("dmaengine: pl330: add DMA_PAUSE feature")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/linux-serial/f8a86ecd-64b1-573f-c2fa-59f541083f1a@electromag.com.au/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230526105434.14959-1-ilpo.jarvinen@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-07 00:01:41 +05:30
Christophe JAILLET
0a46781c89 dmaengine: mcf-edma: Fix a potential un-allocated memory access
When 'mcf_edma' is allocated, some space is allocated for a
flexible array at the end of the struct. 'chans' item are allocated, that is
to say 'pdata->dma_channels'.

Then, this number of item is stored in 'mcf_edma->n_chans'.

A few lines later, if 'mcf_edma->n_chans' is 0, then a default value of 64
is set.

This ends to no space allocated by devm_kzalloc() because chans was 0, but
64 items are read and/or written in some not allocated memory.

Change the logic to define a default value before allocating the memory.

Fixes: e7a3ff92ea ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/f55d914407c900828f6fad3ea5fa791a5f17b9a4.1685172449.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-07 00:01:29 +05:30
Christophe JAILLET
926a4b17e9 dmaengine: ep93xx: Use struct_size()
Use struct_size() instead of hand-writing it, when allocating a structure
with a flex array.

This is less verbose, more robust and more informative.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/36fa11d95b448b5f3f1677da41fe35b9e2751427.1690041500.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-02 00:02:51 +05:30
Rob Herring
897500c7ea dmaengine: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230718143138.1066177-1-robh@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-01 23:51:27 +05:30
Fenghua Yu
62b41b6566 dmaengine: idxd: Expose ATS disable knob only when WQ ATS is supported
WQ Advanced Translation Service (ATS) can be controlled only when
WQ ATS is supported. The sysfs ATS disable knob should be visible only
when the features is supported.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230712174436.3435088-2-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-01 23:34:43 +05:30
Fenghua Yu
97b1185fe5 dmaengine: idxd: Simplify WQ attribute visibility checks
The functions that check if WQ attributes are invisible are almost
duplicate. Define a helper to simplify these functions and future
WQ attribute visibility checks as well.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230712174436.3435088-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-01 23:34:43 +05:30
Uros Bizjak
cae701b9cc dmaengine:idxd: Use local64_try_cmpxchg in perfmon_pmu_event_update
Use local64_try_cmpxchg instead of local64_cmpxchg (*ptr, old, new) == old
in perfmon_pmu_event_update.  x86 CMPXCHG instruction returns success in
ZF flag, so this change saves a compare after cmpxchg (and related move
instruction in front of cmpxchg).

Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails. There is no need to re-read the value in the loop.

No functional change intended.

Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Link: https://lore.kernel.org/r/20230703145346.5206-1-ubizjak@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-01 23:32:06 +05:30
Fabio Estevam
f1de55ff7c dmaengine: ipu: Remove the driver
The i.MX3 IPU driver does not support devicetree and i.MX has been converted
to a DT-only platform since kernel 5.10.

As there is no user for this driver anymore, just remove it.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230729192945.1217206-1-festevam@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-08-01 23:26:46 +05:30
Zong Li
1b13e52c0c dmaengine: xilinx: dma: remove arch dependency
As following patches, xilinx dma is also now architecture agnostic,
and it can be compiled for several architectures. We have verified the
CDMA on RISC-V platform, let's remove the ARCH dependency list instead
of adding new ARCH.

To avoid breaking the s390 build, add a dependency on HAS_IOMEM.

'e8b6c54f6d57 ("net: xilinx: temac: Relax Kconfig dependencies")'
'd7eaf962a90b ("net: axienet: In kconfig remove arch dependency for axi_emac")'

Signed-off-by: Zong Li <zong.li@sifive.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Suggested-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20230531090141.23546-1-zong.li@sifive.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:02 +05:30
Christophe JAILLET
4ca95a5b22 dmaengine: idxd: No need to clear memory after a dma_alloc_coherent() call
dma_alloc_coherent() already clear the allocated memory, there is no need
to explicitly call memset().

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/f44be04317387f8936d31d5470963541615f30ef.1685283065.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:01 +05:30
Rex Zhang
50c5e6f41d dmaengine: idxd: Modify the dependence of attribute pasid_enabled
Kernel PASID and user PASID are separately enabled. User needs to know the
user PASID enabling status to decide how to use IDXD device in user space.
This is done via the attribute /sys/bus/dsa/devices/dsa0/pasid_enabled.
It's unnecessary for user to know the kernel PASID enabling status because
user won't use the kernel PASID. But instead of showing the user PASID
enabling status, the attribute shows the kernel PASID enabling status. Fix
the issue by showing the user PASID enabling status in the attribute.

Fixes: 42a1b73852 ("dmaengine: idxd: Separate user and kernel pasid enabling")
Signed-off-by: Rex Zhang <rex.zhang@intel.com>
Acked-by: Fenghua Yu <fenghua.yu@intel.com>
Acked-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20230614062706.1743078-1-rex.zhang@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:01 +05:30
Johan Hovold
ecc3cfc31f dmaengine: mediatek: drop bogus pm_runtime_set_active()
The runtime PM state must be updated while runtime PM is disabled for
the change to take effect.

Drop the bogus pm_runtime_set_active() which left the PM state set to
suspended (as it should be or the clock would not be enabled when the
device is resumed).

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20230622075150.885-1-johan+linaro@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:01 +05:30
Yangtao Li
42c3cdaaac dmaengine: stm32-dma: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Tested-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20230705081856.13734-5-frank.li@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30
Yangtao Li
8b229a01a5 dmaengine: shdmac: Convert to devm_platform_ioremap_resource()
Use devm_platform_ioremap_resource() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230705081856.13734-4-frank.li@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30
Yangtao Li
1dedb81c5b dmaengine: qcom: hidma_mgmt: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230705081856.13734-3-frank.li@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30
Yangtao Li
f1e47b8390 dmaengine: qcom_hidma: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230705081856.13734-2-frank.li@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30
Yangtao Li
e93c47a3dd dmaengine: qcom: gpi: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230705081856.13734-1-frank.li@vivo.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30
Hien Huynh
c6ec8c83a2 dmaengine: sh: rz-dmac: Fix destination and source data size setting
Before setting DDS and SDS values, we need to clear its value first
otherwise, we get incorrect results when we change/update the DMA bus
width several times due to the 'OR' expression.

Fixes: 5000d37042 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")
Cc: stable@kernel.org
Signed-off-by: Hien Huynh <hien.huynh.px@renesas.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230706112150.198941-3-biju.das.jz@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30
Biju Das
7ab04b7cff dmaengine: sh: rz-dmac: Improve cleanup order in probe()/remove()
We usually do cleanup in reverse order of init. Currently, in the
case of error, this is not followed in rz_dmac_probe(), and similar
case for remove().

This patch improves error handling in probe() and cleanup in
reverse order of init in the remove().

Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Pavel Machek <pavel@denx.de>
Link: https://lore.kernel.org/r/20230706112150.198941-2-biju.das.jz@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-07-12 22:24:00 +05:30