dmaengine: Add Peripheral DMA support for SpacemiT K3 SoC #321
dmaengine: Add Peripheral DMA support for SpacemiT K3 SoC #321EncrowThorne19 wants to merge 15 commits into
Conversation
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/28582174284 参数解析结果
测试完成 详细结果:
Kunit Test Result[10:13:01] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
|
1st review: 同样存在和我在 #319 提到的一样的问题 #319 (comment),你从上游 copy commit messaage 过来时漏了部分信息,我怀疑你没有参考 上游主线中的 commit 而是拿的 mailist 中的 patch email 的签名,导致遗漏了实际上游主线中的信息(maintainer 会在上游 merge 时追加自己的签名和 mail link 信息)。 既然我们要求参考的 commit 必须是 已经合入上游主线 的 ,所以我们的要求是 copy 最终主线中的 patch 信息。 请检查改正。 |
8e1b74a to
3c50a0a
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/28634325511 参数解析结果
测试完成 详细结果:
Kunit Test Result[02:29:30] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
3c50a0a to
029d70b
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/29797092848 参数解析结果
测试完成 详细结果:
Kunit Test Result[02:59:28] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
unicornx
left a comment
There was a problem hiding this comment.
3rd review:
还存在一些问题。
其中发现比较大的一个问题是 k1 dma 补丁的冲突问题,请和 zhangmeng 一起研究一下。
| ret = reset_control_deassert(rst); | ||
| if (ret) | ||
| return ret; | ||
|
|
There was a problem hiding this comment.
我看你和原补丁的做法有区别,没有引入另外两个文件的修改。
但是我觉得这个担心是没有必要的,这个补丁的逻辑和修改原因非常直接,如果他们其他两个会有问题,我觉得 drivers/dma/mmp_pdma.c 的修改也早就有问题了,所以我觉得直接 pick 原先完整的补丁是安全的,你觉得呢?
| .compatible = "marvell,pdma-1.0", | ||
| .data = &marvell_pdma_v1_ops | ||
| }, { | ||
| .compatible = "spacemit,k1-pdma", |
There was a problem hiding this comment.
有个问题,我发现 "spacemit,k1-pdma" 这个 compatible 在 drivers/dma/spacemit-k1-dma.c 中也存在(重复了),而上游的主线中我看了一下是没有 drivers/dma/spacemit-k1-dma.c 这个文件的。
看上去现在 k1 和 k3 都统一使用了 mmp_pdma.c, 那么看上去以前有些 k1 的 dma PR 需要先 Revert 掉?
我查了一下,对应的 issue是 #44,是 zhangmeng 提交的,请和他讨论一下怎么处理。@kevin-zhm
029d70b to
ac0b42c
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/29915053871 参数解析结果
测试完成 详细结果:
Kunit Test Result[11:20:50] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check fail!
|
|
4th review: 问题1:补丁的提交顺序,应该是先 revert 再加新的功能或者修改,也就是说你本地 git log --oneline 时应该看到的顺序是: 问题 2:在 revert 的 commit message 中应该同样按照其他 commit 的格式进行说明,以 "Revert "riscv: k1: dt-bindings: support dma binding for spacemit k1 soc" 为例 问题3对于 "Revert "riscv: k1: dt-bindings: support dma binding for spacemit k1 soc" 这个 commit 有个疑问:你删除了 注意在引用依赖的 commit 时不要用 commit hashcode。而要用 commit 的 title。因为 rvck 会 rebase,导致 commit hash 发生改变,但 title 不变,这一点和上游主线 master 不同。 问题4:对于 “dmaengine: Drop unnecessary of_match_device() calls” 和 “riscv: dts: spacemit: Add PDMA controller node for K3 SoC” 这两个,上游 commit hashcode 建议用 12 位和其他保持一致。 问题 5我发现你没有为 defconfig 增加配置,建议普通驱动用 |
问题已知晓,关于include/dt-bindings/dma/spacemit-k1-dma.h 头文件打算还是保留下来,因为k1 dma引入的比较早,已经有了上层外设(如 SPI、I2C、UART)都依赖此文件,(很抱歉昨天没有及时发现),如果revret的话,那么在k1.dtsi里的 “dmas = <&pdma0 通道号>”就要使用魔数了 |
category: feature bugzilla: RVCK-Project#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>
category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit 39ce725 category: feature bugzilla: RVCK-Project#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>
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 c0f0d93 category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit c48de45 category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit e73a9a1 category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit fc72462 category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit 35e40bf category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit 5cfe585 category: feature bugzilla: RVCK-Project#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>
mainline inclusion from mainline-7.2-rc1 commit 49400b7 category: feature bugzilla: RVCK-Project#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: 5cfe585 ("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>
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 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>
ac0b42c to
03f0f28
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/29992183719 参数解析结果
测试完成 详细结果:
Kunit Test Result[08:49:57] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
|
5th review “riscv: config: enable dma driver for spacemit k1 and k3” rvck 只需要改 defconfig,因为 rvck 的设计思想是一份配置支持所有的产品,k1_defconfig 和 k3_defconfig 实际上是不支持的,已经有一个 PR #337 将会删除这两个文件。目前请只要改 defconfig。 |
category: feature bugzilla: RVCK-Project#320 -------------------------------- Enable DMA support Signed-off-by: Yongchao Jia <yongchao.jia@spacemit.com>
03f0f28 to
4ef875d
Compare
|
开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/30017029127 参数解析结果
测试完成 详细结果:
Kunit Test Result[14:46:12] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
测试完成 详细结果:
Kunit Test Result[14:46:12] Testing complete. Ran 482 tests: passed: 465, skipped: 17
Kernel Build Result
Check Patch Result
LAVA Check (qemu)
result: Lava check done!
|
unicornx
left a comment
There was a problem hiding this comment.
LGTM
Reviewed-by: Chen Wang wangchen20@iscas.ac.cn
Tested-by: Chen Wang wangchen20@iscas.ac.cn only built pass with defconfig and boot successfully with QEMU and insmod passed.
我这里没有 K1/K3 的硬件,所以请 @EncrowThorne19 确保 dma 功能在 K1/K3 上工作正常。
另外,请更新一下 PR 的描述,将 PR 中涉及的修改简单总结补充一下,方便以后回溯,谢谢。
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:
numbers (>= 64) depending on the hardware implementation.
limitations (requiring a dedicated dma-bus), the K3 DMA masters
have full memory addressing capabilities.
Remove the legacy Spacemit K1 DMA implementation and unify the DMA
driver support for both K1 and K3 SoCs using mmp_pdma.c.
Keep spacemit-k1-dma.h to retain DMA macros for peripherals (SPI/I2C/UART)
and avoid magic numbers in k1.dtsi.