Skip to content

drivers: dma_mcux_lpc: Add host directions, integrate DMA driver context, implement dma_mcux_lpc_get_attribute #85742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

VitekST
Copy link
Contributor

@VitekST VitekST commented Feb 13, 2025

The dma_mcux_lpc driver doesn't integrate a valid Zephyr DMA driver context, implying undefined behaviour of some of the Zephyr's DMA functions that wrap around the DMA API and expect a valid context to be present (such as z_impl_dma_request_channel and z_impl_dma_release_channel). While not detrimental to the DMA functionality itself, some applications (such as SOF) are written against those wrapper functions, making the driver unusable.

SOF also expects DMA drivers to support HOST_TO_MEMORY and MEMORY_TO_HOST directions for transfers between domains. As domains on devices where this driver runs are closely intertwined (at the very least they share memory), I don't think that aliasing them to MEMORY_TO_MEMORY should imply any sticky situations. Use case of this is on the i.MX RT685.

...thus add support for HOST_TO_MEMORY, MEMORY_TO_HOST directions (aliases of MEMORY_TO_MEMORY), implement dma_mcux_lpc_get_attribute function and fix missing DMA driver context.

Somewhat related to #77814, marking it as a prerequisite.

@zephyrbot zephyrbot added platform: NXP Drivers NXP Semiconductors, drivers area: DMA Direct Memory Access labels Feb 13, 2025
@VitekST VitekST force-pushed the bugfix/dma-mcux-lpc-compliant-context branch 3 times, most recently from 9e151f2 to ebdbbc2 Compare February 13, 2025 16:05
dbaluta
dbaluta previously approved these changes Feb 13, 2025
@@ -825,11 +829,36 @@ static int dma_mcux_lpc_get_status(const struct device *dev, uint32_t channel,
return 0;
}

static int dma_mcux_lpc_get_attribute(const struct device *dev, uint32_t type, uint32_t *value)
Copy link
Collaborator

@Raymond0225 Raymond0225 Feb 14, 2025

Choose a reason for hiding this comment

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

I don't think we need implement this API. As it is introduced for special HW:
"DMA API get attribute function added, added attributes for scatter/gather blocks available to Intel HDA and Intel GPDMA drivers"
Even we implement it, why these values are 4, not 1 ?

Copy link
Contributor Author

@VitekST VitekST Feb 20, 2025

Choose a reason for hiding this comment

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

@Raymond0225 That may be a commit message initially introducing this API, perhaps in a similar fashion like I extended the codec API to support features, at the moment, only utilised by the wm8904 driver (4b3fae8), but the documentation doesn't say anything about the API being specific to a particular piece of hardware (https://docs.zephyrproject.org/apidoc/latest/group__dma__interface.html#ga641f3fa492bfb17cf9f0a0361d429257). And why would it? My view is that it's a generic API for retrieving a selected set of attributes specific for each DMA controller/platform on which it is instantiated.

The change came into existence because SOF uses that API (specifically - host-zephyr.c). I made an attempt to get SOF to work on the RT685's DSP domain. While fully functional SOF on that target is somewhat of a distant goal, this function is groundwork for making SOF run.

About the values - I think it's best to keep data transferred being domains aligned to 4 byte boundaries because of data caches of the two domains. While I haven't touched on that topic, invalidation would be easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Raymond0225 So... any other arguments?

Copy link
Contributor Author

@VitekST VitekST May 2, 2025

Choose a reason for hiding this comment

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

@Raymond0225 Would like to gently nudge this.

@VitekST VitekST force-pushed the bugfix/dma-mcux-lpc-compliant-context branch from ebdbbc2 to bb1ec56 Compare February 20, 2025 08:58
Add support for HOST_TO_MEMORY, MEMORY_TO_HOST directions (aliases of
MEMORY_TO_MEMORY). Implement dma_mcux_lpc_get_attribute function. Fix
missing DMA driver context.

Signed-off-by: Vit Stanicek <[email protected]>
@VitekST VitekST force-pushed the bugfix/dma-mcux-lpc-compliant-context branch from bb1ec56 to 8b241f3 Compare February 20, 2025 08:58
@VitekST VitekST requested review from decsny and dbaluta February 20, 2025 12:35
@VitekST VitekST requested a review from Raymond0225 February 27, 2025 15:53
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@VitekST
Copy link
Contributor Author

VitekST commented May 2, 2025

Well... this PR is stale, but still relevant, at least to me.
@teburd As it's assigned to you, do you have any verdict on this?

@github-actions github-actions bot removed the Stale label May 3, 2025
@decsny decsny added this to the v4.2.0 milestone May 5, 2025
@kartben kartben merged commit eeaf860 into zephyrproject-rtos:main May 5, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DMA Direct Memory Access platform: NXP Drivers NXP Semiconductors, drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants