-
Notifications
You must be signed in to change notification settings - Fork 3
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
dma: Add support for DMA API: IRQ+assign/startup part #44
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
A couple of comments so far ...
8 tasks
iartemov-ledger
approved these changes
Sep 30, 2024
pthierry-ledger
added a commit
that referenced
this pull request
Oct 1, 2024
As defined in DMA wiki, adding a new event queue specific to DMA streams vents. As DMA streams events are specific, consolidated, events types, they should be pushed up to userspace tasks as such, instead of pushing bare IRQn. Bare IRQn are useless to userspace, as DMA IRQ acknowledge is under the kernel control. Instead pushing consolidated event is useful for user task, as they can directly manipulate such event for functional implementation. A DMA event is then received as a specific event of the `wait_for_event()` syscall. In that case, the event received looks like the following tuple: ``` typedef enum dma_chan_state { GPDMA_STATE_IDLE = 1, /**< DMA channel idle (not set or unused) */ GPDMA_STATE_RUNNING = 2, /**< DMA channel is running */ GPDMA_STATE_ABORTED = 3, /**< DMA stream aborted on SW request */ GPDMA_STATE_SUSPENDED = 4, /**< DMA stream suspended on SW request*/ GPDMA_STATE_TRANSMISSION_FAILURE = 5, /**< DMA transmission failure */ GPDMA_STATE_CONFIGURATION_FAILURE = 6, /**< DMA channel configuration failure */ GPDMA_STATE_OVERRUN = 7, /**< DMA transmission overrun */ GPDMA_STATE_TRANSFER_COMPLETE = 8, /**< DMA transfer complete for this channel */ GPDMA_STATE_HALF_TRANSFER = 9, /**< DMA transfer half-complete for this channel */ } dma_chan_state_t; { dma_handle, dma_event_state } ``` This tuple allows to directly associate the handle with a userspace context, and the DMA event type used to react to various events as required. The DMA event structure pushed by the kernel is the following, respecting the exchange_event_t standard Sentry header: ```c { header.type = EVENT_TYPE_DMA, header.length = 1, /* 1 data byte: the DMA event type */ header.magic = 0x4242, /* hardcoded by now */ header.source = dma_stream_handle, header.data[0] = dma_stream_event; } ``` This allows such a usage: ```c uint8_t dma_event_buf[sizeof(exchange_event_t)+sizeof(uint8_t)]; sys_dma_start(dmah); if (sys_wait_for_event(EVENT_TYPE_DMA, WAIT_FOREVER) == STATUS_OKAY) { copy_to_user(dma_event_buf, sizeof(exchange_event_t)+sizeof(uint8_t)); /* manipulate dma event info locally */ exchange_event_t *event = &dma_event_buf[0]; printf("dma event %d, from handle %lx\n", event->data[0], event->source); switch (event->data[0]) { case GPDMA_STATE_TRANSMISSION_FAILURE: // case GPDMA_STATE_USER_FAILURE: // case GPDMA_STATE_TRANSFER_COMPLETE: // } } ``` - [x] push DMA event type to uapi types.h header - [x] add support for DMA event queue in task context - [x] add support for DMA event queue push interface - [x] make DMA IRQn handler pushing the event to the corresponding stream owner - [x] Add DMA event to the `wait_for_event()` events list - [x] add support for DMA event pull interface from task context - [x] add support for DMA event at `wait_for_event()` syscall level - [x] update autotest to support this new API depends on #44 closes #60
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: missing DMA features:
Note2: this PR do not impact in any way the kernel behavior for any of the other usages than DMA. autotest must pass for all tests except DMA ones