-
Notifications
You must be signed in to change notification settings - Fork 0
Sdma cleanup #8
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
base: master
Are you sure you want to change the base?
Sdma cleanup #8
Conversation
| { | ||
| .index = 3, | ||
| .plat_data = { | ||
| .base = SAI_3_BASE, |
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.
This can go as a separate PR. Please add some more info in the commit message. The current commit message is not very informative.
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.
Will do.
| .offset = SAI_3_BASE + REG_SAI_RDR0, | ||
| .depth = 16, | ||
| .handshake = 4, | ||
| }, |
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.
Maybe we could add some meaningful macros for event 4 and 5.
| .fifo[SOF_IPC_STREAM_PLAYBACK] = { | ||
| .offset = SAI_3_BASE + REG_SAI_TDR0, | ||
| .depth = 16, | ||
| /* Handshake is SDMA hardware event */ |
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.
Looking in the upstream SAI Linux driver (sound/soc/fsl/fsl_sai.c) depth for i.MX8MQ is 128. I think that SAI is the same on 8MP vs 8MP.
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.
Depth is in number of words and is interpreted by SDMA driver. Will need to check.
|
|
||
| #define SDMA2_IRQ 7 /* TODO What? */ | ||
| #define SDMA2_IRQ_NAME "irqstr2" /* TODO find the correct one */ | ||
|
|
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.
Whe should remove the TODOs here. If we are sure the numbers are correct.
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.
I am not 100% certain. I may also end up using irqstr_get_sof_int like on the other platforms (perhaps my calculations were in fact incorrect).
| #include <sof/sof.h> | ||
| #include <sof/spinlock.h> | ||
|
|
||
| extern struct dma_ops dummy_dma_ops; |
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 we should update the commit message once all questions are answered.
|
|
||
| #define DMA_ID_EDMA0 0 | ||
| #define DMA_ID_SDMA2 0 | ||
| #define DMA_ID_HOST 1 |
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.
good catch. I think we can make the following PRs:
- PR with cleanups in preparation for SDMA driver.
- PR adding SDMA driver
We could get 1) accepted faster so that i.MX8MP boots fine with qemu.
| timer.c | ||
| sdma.c | ||
| ) | ||
|
|
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.
TODO: Add selectable config for SDMA. e.g: CONFIG_IMX_SDMA. This can be done later.
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.
I think I can do this in the same PR that will have the implementation.
| add_local_sources(sof | ||
| esai.c | ||
| sai.c | ||
| interrupt.c |
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.
We could cleanup commit message, be deleting DO NOT MERGE and this commit requires the cleanup. Also, would be nice to add a link to a RM containing SDMA bits. Maybe link to 8MQ RM.
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.
That's a reminder for myself that I need to clean up some bits from this commit. We have seen how unreliable direct links for the RM are so I will look into how to make a reasonably-persistent link for future reference.
|
|
||
| struct sdma_bd { | ||
| /* SDMA BD configuration */ | ||
| uint32_t config; |
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.
maybe first time use full name for BD, not sure what it stands for.
| trace_sdma_error("sdma_set_overrides(%d, %d)", event_override, host_override); | ||
| dma_reg_update_bits(channel->dma, SDMA_EVTOVR, BIT(channel->index), event_override ? BIT(channel->index) : 0); | ||
| dma_reg_update_bits(channel->dma, SDMA_HOSTOVR, BIT(channel->index), host_override ? BIT(channel->index) : 0); | ||
| } |
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.
I think this line goes over 80 chars. In fact I think there are several places where this happens. Maybe run checkpatch.ppl with --strict?
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.
Will fix the lines-too-long issues as I look again into this file. I still have a few dummy functions that need to go.
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.
thanks.
src/drivers/imx/sdma.c
Outdated
|
|
||
| /* Writeback descriptors and CCB */ | ||
|
|
||
| dcache_writeback_region(c0data->descriptors, sizeof(c0data->descriptors[0])); |
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.
No need for new line here.
| sdma_set_overrides(c0, true, false); | ||
| ret = dma_start(&dma->chan[0]); | ||
|
|
||
| if (ret < 0) |
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.
Same here, no need for new line.
|
|
||
| trace_sdma("SDMA: probe"); | ||
| trace_sdma_error("sdma_probe"); | ||
|
|
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 keep trace_sdma here.
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 trace_sdma_error calls will all go (some may be converted to trace or trace_verbose if they are important enough)
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.
thanks.
src/drivers/imx/sdma.c
Outdated
| } | ||
| trace_sdma_error("sdma_set_event(%d, %d)", channel->index, eventnum); | ||
| struct sdma_chan *pdata = dma_chan_get_data(channel); | ||
| dma_reg_update_bits(channel->dma, SDMA_CHNENBL(eventnum), BIT(channel->index), BIT(channel->index)); |
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.
I would suggest on declaring all the variables at the beginning of function.
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.
Will do.
src/drivers/imx/sdma.c
Outdated
| for (int i = 0; i < dma->plat_data.channels; i++) { | ||
| struct dma_chan_data *channel = &dma->chan[i]; | ||
| struct sdma_chan *cdata = &pdata->chan_pdata[i]; | ||
|
|
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.
Declare all the variable at the beginning of function. Hope this wont trigger an compiler error for unused variable.
| return -EINVAL; | ||
| } | ||
| bool src_may_change, dst_may_change; | ||
| switch (config->direction) { |
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.
move declaration at the beginning of function.
| #define SDMA_SCRIPT_SHP2MCU_OFF 979 | ||
| #define SDMA_SCRIPT_MCU2SHP_OFF 1048 | ||
|
|
||
| #endif /* __SOF_DRIVERS_SDMA_H__ */ |
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.
Other than that it looks good.
09ecb50 to
f9ca3f6
Compare
Signed-off-by: Paul Olaru <[email protected]>
The extra memory blocks are required for SDMA proper functioning. TODO figure out which of the increases are actually required. Signed-off-by: Paul Olaru <[email protected]>
Some i.MX platforms use SDMA (Smart DMA) controller for DMA related operations. This commit adds the initial functionality for SDMA. Signed-off-by: Paul Olaru <[email protected]>
This includes interrupt number and a tweak used when probing the driver (which must match hardware configuration). Signed-off-by: Paul Olaru <[email protected]>
This commit adds the definition of the SDMA controller we use for SOF, namely SDMA2 (the other instances of SDMA are used for non-audio-related DMA in the system). This DMAC can serve the SAI. [DO NOT MERGE] because I need help in how to account for channel 0 being used for management functionality, with only channels 1-31 being usable by SOF directly. Signed-off-by: Paul Olaru <[email protected]>
SDMA is in dma_array[1], and uses a single interrupt for all channels. Signed-off-by: Paul Olaru <[email protected]>
f9ca3f6 to
3059764
Compare
No description provided.