Skip to content

dmaengine: Add Peripheral DMA support for SpacemiT K3 SoC #321

Open
EncrowThorne19 wants to merge 5 commits into
RVCK-Project:rvck-6.6from
EncrowThorne19:dev-dma-k3
Open

dmaengine: Add Peripheral DMA support for SpacemiT K3 SoC #321
EncrowThorne19 wants to merge 5 commits into
RVCK-Project:rvck-6.6from
EncrowThorne19:dev-dma-k3

Conversation

@EncrowThorne19

@EncrowThorne19 EncrowThorne19 commented Jul 2, 2026

Copy link
Copy Markdown

fixed: #320

The K3 PDMA IP is largely based on the design found in the previous
SpacemiT K1 SoC, but introduces a few key architectural differences:

  1. It features a variable extended DRCMR base address for DMA request
    numbers (>= 64) depending on the hardware implementation.
  2. Unlike the K1 SoC, where some DMA masters had memory addressing
    limitations (requiring a dedicated dma-bus), the K3 DMA masters
    have full memory addressing capabilities.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

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

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/321/head
base ref rvck-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

[10:13:01] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 10

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/321_28582174284_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/321_28582174284_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_pull_request_target_321__common-test_qemu

result: Lava check done!

@unicornx

unicornx commented Jul 3, 2026

Copy link
Copy Markdown

同样存在和我在 #319 提到的一样的问题 #319 (comment),你从上游 copy commit messaage 过来时漏了部分信息,我怀疑你没有参考 上游主线中的 commit 而是拿的 mailist 中的 patch email 的签名,导致遗漏了实际上游主线中的信息(maintainer 会在上游 merge 时追加自己的签名和 mail link 信息)。

既然我们要求参考的 commit 必须是 已经合入上游主线 的 ,所以我们的要求是 copy 最终主线中的 patch 信息。

请检查改正。

Guodong Xu and others added 5 commits July 3, 2026 10:00
mainline inclusion
from mainline-7.2-rc1
commit 55620b1
category: feature
bugzilla: RVCK-Project#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>
mainline inclusion
from mainline-7.2-rc1
commit f46b476
category: feature
bugzilla: RVCK-Project#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>
mainline inclusion
from mainline-7.2-rc1
commit 6587b86
category: feature
bugzilla: RVCK-Project#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>
mainline inclusion
from mainline-7.2-rc1
commit 3f47ca8
category: feature
bugzilla: RVCK-Project#320

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

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>

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.

Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
rvck inclusion
category: feature
bugzilla: RVCK-Project#320

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

Adaptation details:
- Added initialization for clock (`clk`) and reset control (`rst`) in
  `mmp_pdma_probe()` to match the hardware requirements on v6.6.
- Replaced the deprecated `of_match_device()` with `of_device_get_match_data()`.
- Updated DMA mask configuration to use `dma_set_mask_and_coherent()`
  based on the hardware's supported dma_width, replacing legacy masks.
- Removed dependencies on v7.x specific macros and header files

Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

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

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/321/head
base ref rvck-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

[02:29:30] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 9

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/321_28634325511_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/321_28634325511_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_pull_request_target_321__common-test_qemu

result: Lava check done!

@unicornx unicornx self-requested a review July 6, 2026 05:40

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

存在类似 #319 (comment) 的问题,请改正

Comment thread drivers/dma/mmp_pdma.c

@unicornx unicornx Jul 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于这种公共文件的修改,特别是涉及到对齐的处理,我的建议是尽量 follow 主线中对这个文件的 commit 修改历史,而不是一次性魔改后对齐。这个原则其实在前面 review bindig 文件中已经有所体现。只是这里是 c 源文件,稍有区别,具体解释如下,如有问题欢迎讨论:

首先针对 drivers/dma/mmp_pdma.c ,我比较了一下主线中最新的版本和你 PR 分支上的版本,两个版本差别很小。这是我们的对齐目标,这个没有问题。

我关心的是我们如何做到这个对齐的过程,而不是简单的结果。具体来说:

在上游主线中 git log --oneline drivers/dma/mmp_pdma.c, 我们会看到修改历史如下:

6587b8661a0b dmaengine: mmp_pdma: add SpacemiT K3 support <================================== (6)
f46b47623e70 dmaengine: mmp_pdma: refactor DRCMR access with helper function
a143545855bc dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue()
49400b701eca dmaengine: mmp_pdma: fix DMA mask handling
5cfe585d8624 dmaengine: mmp_pdma: Add SpacemiT K1 PDMA support with 64-bit addressing
35e40bf761fc dmaengine: mmp_pdma: Add operations structure for controller abstraction
fc72462bc610 dmaengine: mmp_pdma: Add reset controller support
e73a9a13c99c dmaengine: mmp_pdma: Add clock support
76355c25e4f7 dmaengine: Switch back to struct platform_driver::remove()
c48de45d4cef dmaengine: Drop unnecessary of_match_device() calls
c0f0d93fc1da dmaengine: mmp_pdma: Convert to platform remove callback returning void <======= (5)
4b23603a251d dmaengine: drivers: Use devm_platform_ioremap_resource()  <===================== 6.6.y 对齐在这里
......

基于你 pr 的分支, git log --oneline drivers/dma/mmp_pdma.c, 我们会看到修改历史如下:

3c50a0a83217 (HEAD -> pr-321-review) dmaengine: mmp_pdma: Adapt SpacemiT K3 support <======== (4)
cb34e472b3f3 dmaengine: mmp_pdma: add SpacemiT K3 support
3a7be98d7820 dmaengine: mmp_pdma: refactor DRCMR access with helper function <=============== (3) 从这里往上是 PR321 加入的 commit
eba0c75670c0 dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue()   <=============== (2) rvck-6.6 cherrypick 了主线上的一个 commit 在这里
4b23603a251d dmaengine: drivers: Use devm_platform_ioremap_resource()        <=============== (1) 6.6.y 对齐在这里
......

也就是说从 (3) 到 (4) 覆盖了 (5) 到 (6) 的所有内容。那么我期望你对这个文件的 PR 中也是按照主线的推进方式逐渐对齐的,而不是在 (4) 中一步到位。
沿袭主线的历史方便我们以后,或者未来的开发人员和主线进行比较并理解我们对 6.6 的改进过程,简单的 Adapt 很容易丢失信息,这个在 #319 (comment) 中对于 pxa-pwm.txt 的遗漏可以作为一个典型反面例子。

考虑到在逐个 pick 上游 commit 中必然会出现最新主线和 6.6 的冲突问题,我觉得可以在对应的 commit 中进行相应的修改,这可能包括以下几类问题

  • 一个 commit 可能涉及除了本文件外的多个文件,这个要酌情考虑,是全部拿过来,还是部分,或者仅仅本文件,如果只是部分,这可能就不算是 cherry-pick, 而是你自己的一个改动,但是可以在 commit 中说清楚是参考了某个上游补丁的部分。
  • 有些 commit 整体无法 pick 的情况也是存在的。那只能跳过了。

我觉得可以在逐个 commit pick 前先像现在这样看看整体差别大不大,如果很难改到一致,其实 adapt 就没有意义了。但是我们追求的是历史尽可能和主线对齐这个目标应该是不变的。

如果 pick 中对某个 commit 的冲突需要修改,请在新的 commit 中添加说明,格式可以如下,仅仅是举例供参考

dt-bindings: pxa-pwm: Convert to YAML // commit 标题

mainline inclusion
from mainline-v6.9-rc1
commit bdc585f ("dt-bindings: pxa-pwm: Convert to YAML")
category: feature
bugzilla: #317

解释一下这个 commit 是有改动的,大致改动的原因.... (这部分如果 cherrypick 过来没有修改那可以忽略)

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

Convert the PXA PWM binding file from TXT to YAML.

The original binding does not mention any clocks, but the PWM controller
will not probe without a clock.

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Duje Mihanović <duje.mihanovic@skole.hr>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240107-pxa-pwm-yaml-v3-1-92ac90911c3f@skole.hr
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>

值得注意的是,如果是对 C 文件的逐个 commit 摘取,每个 commit 应该是原子性的,需要保证编译正常。

另外,基于以上原则修改时我们注意到 ”dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue()“ 这个 commit 已经被提前 cherry-pick 了,但很可惜当时没有及时对齐,所以你这里做对齐时就先保留它好了(不用 revert),就当提前 pick 了。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经进上游的补丁,需要在pr中按顺序逐个backport。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的 我理解了您的意思,我去看了一下commit的历史,确实有个别 commit 改动相当庞大,甚至动到了核心层/框架层。考虑到 rvck 大部分是基于厂商 vendor 树维护的,这类改动一旦引入,很难保证不影响其他驱动和平台的正常使用,所以像这种情况只能选择跳过。但跳过之后,后续依赖它的 commit 就成了麻烦:如果为了往下走而强行合并,势必要手动改成和上游不一致的样子,也就是"魔改",这就违背了"在 PR 里按上游顺序逐个 backport"的前提。

@unicornx unicornx Jul 8, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大原则我们已经一致,所以剩下的就是具体落实的问题了。
针对本 PR,或者说针对 drivers/dma/mmp_pdma.c 的修改,如果我们要 adpat 到最新的主线,我看了一下,也就是

76355c25e4f7 dmaengine: Switch back to struct platform_driver::remove()
c48de45d4cef dmaengine: Drop unnecessary of_match_device() calls

这两笔改动涉及多个文件。

对于 ”c48de45d4cef dmaengine: Drop unnecessary of_match_device() calls“,有几种思路

  • 不 backport,因为只是优化,有没有都没有关系
  • 如果想要,可能是考虑到后面的代码会依赖它,又不想引入对其他模块的影响,可以部分 pick,这里就是只 pick mmp_pdma.c 的修改,但这需要在 commit 中说清楚。

对于 76355c25e4f7 dmaengine: Switch back to struct platform_driver::remove() 也是类似的问题,但区别是这个 patch 依赖于 0edb555a65d1 ("platform: Make platform_driver::remove() return void")。我看了一下 rvck 中还没有引入这个补丁,所以如果没有这个或者我们不想引入这个新特性(原则上我们也不鼓励在 rvck 中引入主线上的公共新特性),那么 76355c2 原则上就不要 backport。

其他的 commit 都是只涉及 drivers/dma/mmp_pdma.c, 可以分析一下是否可以拿来,此时的根据就看你 K3 的要求了。综上所述,所谓要求按顺序 backport 并不是说每个都要,完全看分析的结果和你 K3 的新需求。

顺便说一下,我前面描述中有个错误纠正一下,针对 ”eba0c75670c0 dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue()“ 这个 commit ,这是 gregKH 在维护 6.6.y stable 时从 master 上摘取过来的 bugfix。不是我们 rvck 自己加的。

所以说针对 mmp_pdma.c 的修改,为何我们希望你分析每一个这个文件在主线上的 commit 后再一步一步地 adapt,这是有原因的,整体 adpat 往往意味着缺少对主线的分析而容易丢失一些关键的信息。

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DMA: Support Peripheral DMA (PDMA) for SpacemiT K3 SoC

5 participants