Skip to content

Conversation

nordic-krch
Copy link
Contributor

@nordic-krch nordic-krch commented Sep 12, 2025

Driver does not implement Zephyr DMA API. The reason is that it will mainly be used in the vendor specific code and translation to the Zephyr API significantly decreases the performance to a point where using DMA is no longer beneficial.

Driver offers free running transfer setup and a transfer with a callback. If free running mode is used (without a callback) then nrf_mvdma_xfer_check can be used to poll for transfer completion. It is required to poll until function returns success (transfer has finished). That is because MVDMA blocks entering S2RAM PM mode and unblocking is done only when transfer completes.

Test contains timings measurements that can be used to decide whether use of MVDMA is beneficial.

DNM as it requires #96909.

@nordic-krch nordic-krch added the DNM This PR should not be merged (Do Not Merge) label Sep 12, 2025
teburd
teburd previously requested changes Sep 12, 2025
Copy link
Contributor

@teburd teburd left a comment

Choose a reason for hiding this comment

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

I'm a bit confused by this PR to be honest, it is adding the driver to the DMA drivers, but it is not in fact a DMA driver from Zephyr's perspective. I'm not sure exactly where this should go, but I do not believe it should go into drivers/dma.

To be clear, I'm not at all opposed to a vendor creating their own APIs and drivers around DMA, as noted already in the documentation the DMA API is a bit of a union of DMA peripheral capabilities. If DMA-like actions are wanted in a cross platform way we already provide this in peripheral APIs in part. But to put this driver in drivers/dma should imply it implements the dma.h interface which it does not.

@nordic-krch
Copy link
Contributor Author

@teburd I was also not sure if that is a good location. It can as well be placed in soc/nordic. My argument for placing it in drivers/dma is that it is easier for the user to find it if dma-like operation is needed.

Copy link

github-actions bot commented Sep 15, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hal_nordic DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Sep 15, 2025
@zephyrbot zephyrbot added platform: Microchip MEC Microchip MEC Platform platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) labels Sep 15, 2025
@nordic-krch nordic-krch force-pushed the mvdma2 branch 2 times, most recently from 9815803 to 8a8510d Compare September 16, 2025 06:24
@carlescufi
Copy link
Member

We should not be adding drviers under soc/ that are covered by an existing Zephyr API. This requires further discussion and clarification on why this is needed and why something like this can't be implemented under drivers/ using zephyr APIs.

I think this is worth discussing in the Architecture WG meeting to ensure that @nordic-krch has a chance to explain why the common DMA API is not suitable in this case and an internal variant is required.

@teburd
Copy link
Contributor

teburd commented Oct 2, 2025

I guess the only question I have is why not have this live in hal_nrf or whatever, I guess because you’d still need some DT/Kconfig integration which would be missing?

Add MVDMA binding and nodes to nrf54h20.

Signed-off-by: Krzysztof Chruściński <[email protected]>
@nordic-krch nordic-krch force-pushed the mvdma2 branch 2 times, most recently from 44c439f to 998c510 Compare October 2, 2025 11:33
Add function for getting and putting a lock for all power states.
It is much faster version of requesting 0 us latency with actual
intention to disable all power states.

Signed-off-by: Krzysztof Chruściński <[email protected]>
@nordic-krch
Copy link
Contributor Author

I guess the only question I have is why not have this live in hal_nrf or whatever, I guess because you’d still need some DT/Kconfig integration which would be missing?

yes, we keep Zephyr agnostic stuff in hal_nordic. It's Kconfig/DTS but also driver needs to use Zephyr API inside (block PM states when MVDMA is operating).

MVDMA driver does not implement Zephyr DMA API. It implements its own
due to performance reasons and it is intended to be used mainly in the
Nordic specific code.

Signed-off-by: Krzysztof Chruściński <[email protected]>
MVDMA is present in the application domain so it's configuration
need to be restored when waking up from suspend to RAM.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Add test suite for MVDMA driver.

Signed-off-by: Krzysztof Chruściński <[email protected]>
Copy link

sonarqubecloud bot commented Oct 6, 2025

@carlescufi
Copy link
Member

I guess the only question I have is why not have this live in hal_nrf or whatever, I guess because you’d still need some DT/Kconfig integration which would be missing?

@teburd and also because this driver uses Zephyr primitives, and drivers in HALs should be OS-neutral, otherwise we have a dependency in both directions.

*/
void pm_policy_state_lock_put(enum pm_state state, uint8_t substate_id);

/**
Copy link
Member

Choose a reason for hiding this comment

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

please split this into own PR including PM changes only, making this part of a driver PR does not give it the visibility and reviews it deserves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is there: #96909

@teburd
Copy link
Contributor

teburd commented Oct 6, 2025

I guess the only question I have is why not have this live in hal_nrf or whatever, I guess because you’d still need some DT/Kconfig integration which would be missing?

@teburd and also because this driver uses Zephyr primitives, and drivers in HALs should be OS-neutral, otherwise we have a dependency in both directions.

Is this driver in any way accessible to an application or usable by an application?

If yes then I'd say I still have a concern here that you are going to introduce a nordic specific API for what could be a broadly useful function of asynchronous memcpy/zeroing, where "how its done" could be soc specific and still avoid the cost of dealing with the DMA APIs and its descriptors.

If no, consider doing this instead. I think it'd be a great feature, and could internally use mvdma or other soc specifics (e.g. a dedicated dma channel in other scenarios) without needing to fully expose the DMA which often has varying behavior across vendors.

@nordic-krch nordic-krch added the DNM This PR should not be merged (Do Not Merge) label Oct 7, 2025
@nordic-krch
Copy link
Contributor Author

Is this driver in any way accessible to an application or usable by an application?

Currently we don't see a use case. Application operates on "fast" RAM. For memory-to-memory operations time needed to setup a MVDMA will be longer than memory operation itself. nRF54H20 SoC has "slow" RAM that is used by peripherals and main use case for MVDMA is to copy data between "fast/user" memory and "slow" which happens in drivers.

@carlescufi
Copy link
Member

Architecture WG meeting:

  • On Nordic devices, there's DMA for each peripheral that is independent of the DMA being exposed here
  • The MVDMA engine instead can copy from memory to memory and from register space to memory
  • The peripherals themselves can only access slow RAM, but usually buffers are populated in fast RAM, so copying is needed
  • MVDMA however can access both fast and slow RAM, and so the purpose of this driver is to be able to copy from and to slow/fast RAM
  • Using MVDMA only makes sense if setting up the DMA transfer is faster than actually copying memory, and using the standard DMA API would effectively negate the advantages
    • In particular, preparing the descriptors is a time-consuming task
  • Why can't then just be in the HAL?
    • It's using Zephyr APIs, particularly power management and cache APIs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture Review Discussion in the Architecture WG required area: Boards/SoCs area: Cache area: Devicetree Bindings area: DMA Direct Memory Access area: Linker Scripts area: Power Management area: Tests Issues related to a particular existing or missing test DNM This PR should not be merged (Do Not Merge) platform: nRF Nordic nRFx
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

5 participants