Skip to content

sync: rvck #321: dmaengine: Add Peripheral DMA support for SpacemiT K3 SoC - #250

Open
ieiao wants to merge 15 commits into
RVCK-Project:OLK-6.6from
ieiao:PR321@rvck
Open

sync: rvck #321: dmaengine: Add Peripheral DMA support for SpacemiT K3 SoC#250
ieiao wants to merge 15 commits into
RVCK-Project:OLK-6.6from
ieiao:PR321@rvck

Conversation

@ieiao

@ieiao ieiao commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Sync commits from rvck PR 321.
Source PR: RVCK-Project/rvck#321

encrow and others added 15 commits August 14, 2026 20:41
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

This reverts commit "riscv: config: enable dma driver for spacemit k1".

Following the upstream approach, both K1 and K3 will use the mmp_pdma driver,
so this configuration is not required.

Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

This reverts commit "driver: k1: add dma driver support for spacemit k1".

Following the upstream approach, both K1 and K3 will use the mmp_pdma driver,
no longer using the vendor driver.

Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 39ce725e621b
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Add device tree binding documentation for the SpacemiT K1 PDMA
controller.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/r/20250822-working_dma_0701_v2-v5-1-f5c0eda734cc@riscstar.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 55620b11186c
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Add the "spacemit,k3-pdma" compatible string for the SpacemiT K3 SoC.

While the K3 PDMA IP reuses most of the design found on the earlier
K1 SoC, a new compatible string is required because the DRCMR
(DMA Request/Command Register) base address for extended DMA request
numbers (>= 64) differs from the K1 implementation.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Link: https://patch.msgid.link/20260518-k3-pdma-v6-1-67fdf319a8f8@linux.spacemit.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit c0f0d93fc1da
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new() which already returns void. Eventually after all drivers
are converted, .remove_new() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230919133207.1400430-26-u.kleine-koenig@pengutronix.de
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit c48de45d4cef
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

If probe is reached, we've already matched the device and in the case of
DT matching, the struct device_node pointer will be set. Therefore, there
is no need to call of_match_device() in probe.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20231006213835.332848-1-robh@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit e73a9a13c99c
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Add support for retrieving and enabling an optional clock during
mmp_pdma_probe(). It is optional because in Marvell devices
such as "marvell,pdma-1.0" the clocks property is not a required
property. But in SpacemiT K1 PDMA, "spacemit,k1-pdma" as the dt
binding schema file stated, clocks is required.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Link: https://lore.kernel.org/r/20250822-working_dma_0701_v2-v5-2-f5c0eda734cc@riscstar.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit fc72462bc610
category: feature
bugzilla: RVCK-Project/rvck#320

Replace devm_reset_control_get_optional_exclusive_deasserted() with explicit
devm_reset_control_get_optional_exclusive() and reset_control_deassert() calls
for compatibility with Linux 6.6 kernels.

--------------------------------

Add support to acquire and deassert an optional hardware reset controller
during mmp_pdma_probe(). It is optional because in Marvell devices
such as "marvell,pdma-1.0" the resets property is not a required
property. But in SpacemiT K1 PDMA, "spacemit,k1-pdma" as the dt
binding schema file stated, resets is required.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Link: https://lore.kernel.org/r/20250822-working_dma_0701_v2-v5-3-f5c0eda734cc@riscstar.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 35e40bf761fc
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Introduce mmp_pdma_ops structure to abstract 32-bit addressing operations
and enable support for different controller variants. This prepares for
adding 64-bit addressing support.

The ops structure includes:
- Hardware register operations (read/write DDADR, DSADR, DTADR)
- Descriptor memory operations (manipulate descriptor structs)
- Controller configuration (run bits, DMA mask)

Convert existing 32-bit operations to use the new abstraction layer
while maintaining backward compatibility.

Cc: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Guodong Xu <guodong@riscstar.com>
Link: https://lore.kernel.org/r/20250822-working_dma_0701_v2-v5-4-f5c0eda734cc@riscstar.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 5cfe585d8624
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Add support for SpacemiT K1 PDMA controller which features 64-bit
addressing capabilities.

The SpacemiT K1 PDMA extends the descriptor format with additional
32-bit words for high address bits, enabling access to memory beyond
4GB boundaries. The new spacemit_k1_pdma_ops provides necessary 64-bit
address handling functions and k1 specific controller configurations.

Key changes:
- Add ARCH_SPACEMIT dependency to Kconfig
- Define new high 32-bit address registers (DDADRH, DSADRH, DTADRH)
- Add DCSR_LPAEEN bit for Long Physical Address Extension Enable
- Implement 64-bit operations for SpacemiT K1 PDMA

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Link: https://lore.kernel.org/r/20250822-working_dma_0701_v2-v5-5-f5c0eda734cc@riscstar.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 49400b701eca
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

The driver's existing logic for setting the DMA mask for "marvell,pdma-1.0"
was flawed. It incorrectly relied on pdev->dev->coherent_dma_mask instead
of declaring the hardware's fixed addressing capability. A cleaner and
more correct approach is to define the mask directly based on the hardware
limitations.

The MMP/PXA PDMA controller is a 32-bit DMA engine. This is supported by
datasheets and various dtsi files for PXA25x, PXA27x, PXA3xx, and MMP2,
all of which are 32-bit systems.

This patch simplifies the driver's logic by replacing the 'u64 dma_mask'
field with a simpler 'u32 dma_width' to store the addressing capability
in bits. The complex if/else block in probe() is then replaced with a
single, clear call to dma_set_mask_and_coherent(). This sets a fixed
32-bit DMA mask for "marvell,pdma-1.0" and a 64-bit mask for
"spacemit,k1-pdma," matching each device's hardware capabilities.

Finally, this change also works around a specific build error encountered
with clang-20 on x86_64 allyesconfig. The shift-count-overflow error is
caused by a known clang compiler issue where the DMA_BIT_MASK(n) macro's
ternary operator is not correctly evaluated in static initializers. By
moving the macro's evaluation into the probe() function, the driver avoids
this compiler bug.

Fixes: 5cfe585d8624 ("dmaengine: mmp_pdma: Add SpacemiT K1 PDMA support with 64-bit addressing")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Closes: https://lore.kernel.org/lkml/CA+G9fYsPcMfW-e_0_TRqu4cnwqOqYF3aJOeKUYk6Z4qRStdFvg@mail.gmail.com
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Guodong Xu <guodong@riscstar.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Nathan Chancellor <nathan@kernel.org> # build
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit f46b47623e70
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Refactor the DRCMR macro into a helper function mmp_pdma_get_drcmr()
to support variable extended DRCMR base addresses across different PDMA
implementations, such as SpacemiT K3.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Link: https://patch.msgid.link/20260518-k3-pdma-v6-2-67fdf319a8f8@linux.spacemit.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 6587b8661a0b
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

SpacemiT K3 reuses most of the PDMA IP design found on K1, with one
difference being the extended DRCMR base address. Add "spacemit,k3-pdma"
compatible string and define a new mmp_pdma_ops for K3 PDMA.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Link: https://patch.msgid.link/20260518-k3-pdma-v6-3-67fdf319a8f8@linux.spacemit.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
mainline inclusion
from mainline-7.2-rc1
commit 3f47ca8bb3c3
category: feature
bugzilla: RVCK-Project/rvck#320

Added `interrupt-parent = <&saplic>;` to the PDMA node in k3.dtsi,
because the `soc` node in our v6.6 tree does not inherit the
interrupt controller context globally.

--------------------------------

Add the Peripheral DMA (PDMA) controller node for the SpacemiT K3 SoC.
The PDMA controller provides general-purpose DMA capabilities for various
peripheral devices across the system to offload CPU data transfers.

Unlike the previous K1 SoC, where some DMA masters had memory addressing
limitations (e.g. restricted to the 0-4GB space) requiring a dedicated
dma-bus with dma-ranges to restrict memory allocations, the K3 DMA masters
have full memory addressing capabilities. Therefore, the PDMA node is now
instantiated directly under the main soc bus.

Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Link: https://patch.msgid.link/20260518-k3-pdma-v6-4-67fdf319a8f8@linux.spacemit.com
Signed-off-by: Yixun Lan <dlan@kernel.org>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
category: feature
bugzilla: RVCK-Project/rvck#320

--------------------------------

Enable DMA support

Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
[sync from rvck.]
Signed-off-by: WeiHao Li <cn.liweihao@gmail.com>
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

开始测试 log: https://github.com/RVCK-Project/rvck-olk/actions/runs/31801952115

参数解析结果
args value
repository RVCK-Project/rvck-olk
head ref pull/250/head
base ref OLK-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware ['qemu']
LAVA Testcase path lava-testcases/common-test/ltp/ltp.yaml
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu success
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[12:54:43] Testing complete. Ran 482 tests: passed: 466, skipped: 16

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 6

LAVA Check (qemu)

args value
testcase_repo RVCK-Project/lavaci
lava_template lava-job-template/qemu/qemu-ltp.yaml
testcase_path lava-testcases/common-test/ltp/ltp.yaml
kernel_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck-olk/250_31801952115_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck-olk/250_31801952115_1/initramfs.img
rootfs_download_url https://fast-mirror.isrc.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/RVCK/openEuler24.03-LTS-SP1/openeuler-rootfs.img.zst
testcase_ref main
testitem_name RVCK-Project_rvck-olk_pull_request_target_250__common-test_qemu

result: Lava check done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants