Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@paulstelian97
Copy link
Owner

No description provided.

@paulstelian97 paulstelian97 requested a review from dbaluta as a code owner March 18, 2020 13:12
{
.index = 3,
.plat_data = {
.base = SAI_3_BASE,
Copy link
Collaborator

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.

Copy link
Owner Author

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,
},
Copy link
Collaborator

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 */
Copy link
Collaborator

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.

Copy link
Owner Author

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 */

Copy link
Collaborator

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.

Copy link
Owner Author

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;
Copy link
Collaborator

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
Copy link
Collaborator

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:

  1. PR with cleanups in preparation for SDMA driver.
  2. PR adding SDMA driver

We could get 1) accepted faster so that i.MX8MP boots fine with qemu.

timer.c
sdma.c
)

Copy link
Collaborator

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.

Copy link
Owner Author

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
Copy link
Collaborator

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.

Copy link
Owner Author

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;
Copy link
Collaborator

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);
}
Copy link
Collaborator

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?

Copy link
Owner Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks.


/* Writeback descriptors and CCB */

dcache_writeback_region(c0data->descriptors, sizeof(c0data->descriptors[0]));
Copy link
Collaborator

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)
Copy link
Collaborator

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");

Copy link
Collaborator

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.

Copy link
Owner Author

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)

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks.

}
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));
Copy link
Collaborator

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.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Will do.

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];

Copy link
Collaborator

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) {
Copy link
Collaborator

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__ */
Copy link
Collaborator

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.

@paulstelian97 paulstelian97 force-pushed the sdma_cleanup branch 4 times, most recently from 09ecb50 to f9ca3f6 Compare March 19, 2020 12:47
Paul Olaru added 7 commits March 20, 2020 11:17
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants