add edma src ID check at request channel
Subsystems (3)
v2 cover add edma src ID check at request channel
For the details, please check the patch commit log.
Changes in v2:
1. modify the dev_err() log description.
2. add review tag.
Joy Zou (2):
dmaengine: fsl-edma: change to guard(mutex) within fsl_edma3_xlate()
dmaengine: fsl-edma: add edma src ID check at request channel
drivers/dma/fsl-edma-main.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
Signature · 1 line
2.37.1
PATCH v2 1/2 dmaengine: fsl-edma: change to guard(mutex) within fsl_edma3_xlate()
Introduce a scope guard to automatically unlock the mutex within fsl_edma3_xlate() to simplify the code.
Prepare to add source ID checks in the future.
--- drivers/dma/fsl-edma-main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/dma/fsl-edma-main.c +1 -4
@@ -153,7 +153,7 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec, b_chmux = !!(fsl_edma->drvdata->flags &FSL_EDMA_DRV_HAS_CHMUX ); -mutex_lock (&fsl_edma->fsl_edma_mutex); +guard (mutex)(&fsl_edma->fsl_edma_mutex);list_for_each_entry_safe (chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
@@ -177,18 +177,15 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec,if (!b_chmux && i == dma_spec->args[0 ]) { chan =dma_get_slave_channel (chan); chan->device->privatecnt++; -mutex_unlock (&fsl_edma->fsl_edma_mutex);return chan; }else if (b_chmux && !fsl_chan->srcid) {/* if controller support channel mux, choose a free channel */ chan =dma_get_slave_channel (chan); chan->device->privatecnt++; fsl_chan->srcid = dma_spec->args[0 ]; -mutex_unlock (&fsl_edma->fsl_edma_mutex);return chan; } } -mutex_unlock (&fsl_edma->fsl_edma_mutex);return NULL ; }
Signature · 1 line
2.37.1
PATCH v2 2/2 dmaengine: fsl-edma: add edma src ID check at request channel
In reply to Joy ZouCheck src ID to detect misuse of same src ID for multiple DMA channels.
--- drivers/dma/fsl-edma-main.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/dma/fsl-edma-main.c +22 -0
@@ -100,6 +100,22 @@ static irqreturn_t fsl_edma_irq_handler(int irq, void *dev_id)return fsl_edma_err_handler (irq, dev_id); } +static bool fsl_edma_srcid_in_use (struct fsl_edma_engine *fsl_edma,u32 srcid) +{ +struct fsl_edma_chan *fsl_chan; +int i; + +for (i =0 ; i < fsl_edma->n_chans; i++) { + fsl_chan = &fsl_edma->chans[i]; + +if (fsl_chan->srcid && srcid == fsl_chan->srcid) { +dev_err (&fsl_chan->pdev->dev,"The srcid is in use, can't use!" ); +return true; + } + } +return false; +} +static struct dma_chan *fsl_edma_xlate (struct of_phandle_args *dma_spec,struct of_dma *ofdma) {
@@ -117,6 +133,10 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,list_for_each_entry_safe (chan, _chan, &fsl_edma->dma_dev.channels, device_node) {if (chan->client_count)continue ; + +if (fsl_edma_srcid_in_use (fsl_edma, dma_spec->args[1 ])) +return NULL ; +if ((chan->chan_id / chans_per_mux) == dma_spec->args[0 ]) { chan =dma_get_slave_channel (chan);if (chan) {
@@ -161,6 +181,8 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec,continue ; fsl_chan =to_fsl_edma_chan (chan); +if (fsl_edma_srcid_in_use (fsl_edma, dma_spec->args[0 ])) +return NULL ; i = fsl_chan - fsl_edma->chans; fsl_chan->priority = dma_spec->args[1 ];
Signature · 1 line
2.37.1
Quoted 11 lines · Joy Zou
For the details, please check the patch commit log.
Changes in v2:
1. modify thedev_err()log description.
2. add review tag.Joy Zou (2):
dmaengine: fsl-edma: change to guard(mutex) withinfsl_edma3_xlate()
dmaengine: fsl-edma: add edma src ID check at request channel[...]
Applied, thanks!
[1/2] dmaengine: fsl-edma: change to guard(mutex) within fsl_edma3_xlate()
commit: 90d21f6e57a898ef02810404dd3866acaf707ebf
[2/2] dmaengine: fsl-edma: add edma src ID check at request channel
commit: 9542961494bf747a73413f925f8ea9ac410a4aecBest regards,
Signature · 1 line
~Vinod