-
Notifications
You must be signed in to change notification settings - Fork 7.3k
drivers: dma: esp32: added support for multiple descriptors #74974
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
Hello @epc-ake, and thank you very much for your first pull request to the Zephyr project! |
@epc-ake please fix the marked compliance errors, also please use the single new-line in code. |
76e1dae
to
eba4979
Compare
37a1e9f
to
d7edb29
Compare
I'm not happy about the descriptors getting defined twice, once trough the API and and then again in the driver to convert Any inputs on that? |
d7edb29
to
64c1d91
Compare
@raffarost, can you take a look? |
54d2ba4
to
27c316a
Compare
hi @epc-ake, tests/drivers/dma/loop_transfer would you be willing to take a look and make sure the original functionality is preserved? we could afterwards do a full review on your code. A first question I'd have is: should the number of descriptors be a constant? Considering other subsystems in Zephyr might use only one descriptor (as in the original code), how would that work out? |
27c316a
to
8d3b16e
Compare
@raffarost Thanks for reviewing and pointing me to these tests—I wasn't aware of them. I had a bug in the TX path, but it’s resolved now.
Regarding your question, As I mentioned, I’m not entirely satisfied with the current solution, but it’s the only feasible option using the DMA API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just minor checks and suggestions, overall I think your code looks good
@@ -80,12 +80,16 @@ static void IRAM_ATTR dma_esp32_isr_handle_rx(const struct device *dev, | |||
|
|||
gdma_ll_rx_clear_interrupt_status(data->hal.dev, rx->channel_id, intr_status); | |||
|
|||
if (intr_status & (GDMA_LL_EVENT_RX_SUC_EOF | GDMA_LL_EVENT_RX_DONE)) { | |||
intr_status &= ~(GDMA_LL_EVENT_RX_SUC_EOF | GDMA_LL_EVENT_RX_DONE); | |||
if (intr_status == (GDMA_LL_EVENT_RX_SUC_EOF | GDMA_LL_EVENT_RX_DONE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would avoid reassigning the variable with a different data type.
Is there another way to pass the status without doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way I see is to create an extra variable for it.
I can do that if you like, but I wait for your feedback.
drivers/dma/dma_esp32_gdma.c
Outdated
{ | ||
dma_descriptor_t *desc_iter = dma_channel->desc_list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this right before the loop?
If validation of input parameter fails, running this instruction can be avoided.
I see now your concern regarding initializing descriptors. Do you think converting desc_list[] from data type dma_descriptor_t to dma_config_block and adjusting the internals of the driver for that change is possible? To me it looks like doing that loop inside the driver might not even be a productive task for the driver to do, and could be done outside, unless there's some unavoidable validation to be done internally or some lower layer detail forbids us to do so. Edit: I checked again and it seems unlikely we could adapt the LL workings with Zephyr's data type. We could either leave it as you implemented or do the initialization of dma_descriptor_t * instead of dma_block_config * outside and pass it to the driver. This would violate data typing (terrible idea) but the current implementation seems to not use the other fields of dma_block_config. Other than this, I'd prefer others to give their opinions on this regard. |
Hi @epc-ake, |
This is the downside generally of the DMA API as an attempt to sort of cover all possible hardware with a single API. In DMA we don't end up with a least common denominator but instead a union of all DMA functionality all hardware in Zephyr supports. Mostly this isn't a problem to be honest though, DMA is typically embedded in various bus drivers rather than being exposed as an application API. It has one application level user in SoF which requires some specific DMA drivers to ensure things work as expected. |
This is wrong, if you wish to implement the DMA API today, you would convert from the dma.h descriptors to your hardware descriptors. That's it. If you are unhappy with the zephyr dma.h API and descriptors there's nothing preventing your device from saying "please use the hal driver if you wish to use DMA directly". |
@epc-ake Would you mind fixing the compliance checks and conflicts so we can merge this PR? Nice work! |
50f41b7
50f41b7
to
8965005
Compare
8965005
to
070d5af
Compare
Previously, configuring the GDMA was limited to a single descriptor, restricting memory transfers to a maximum of 4kB. This update introduces support for multiple descriptors, enabling users to define multiple dma_blocks. The maximum number of descriptors can be configured via the CONFIG_DMA_ESP32_DESCRIPTOR_NUM option. Additionally, the dma_get_status() function now reports the index of the currently processed descriptor through the status.read_position and status.write_position fields. Signed-off-by: Armin Kessler <[email protected]>
070d5af
to
b37adee
Compare
@@ -127,17 +132,43 @@ static void IRAM_ATTR dma_esp32_isr_handle(const struct device *dev, uint8_t rx_ | |||
#endif | |||
|
|||
static int dma_esp32_config_rx_descriptor(struct dma_esp32_channel *dma_channel, | |||
struct dma_block_config *block) | |||
struct dma_block_config *block) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you update this to meet compliance check? Same for other places.
LGTM, need to check compliance stuff. |
Hi @epc-ake! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
In the past, configuring the GDMA was limited to using a single descriptor, which restricted memory transfers to a maximum of 4kB.
CONFIG_DMA_ESP32_DESCRIPTOR_NUM
option.dma_get_status()
function now provides the index of the currently processed descriptor through thestatus.read_position
andstatus.write_position
fields.This is my first PR, and I welcome any feedback!