dmaengine: fsl-edma: add edma src ID check at request channel
Check src ID to detect misuse of same src ID for multiple DMA channels. Signed-off-by: Joy Zou <joy.zou@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20240701070232.2519179-3-joy.zou@nxp.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
90d21f6e57
commit
9542961494
@ -100,6 +100,22 @@ static irqreturn_t fsl_edma_irq_handler(int irq, void *dev_id)
|
|||||||
return fsl_edma_err_handler(irq, 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,
|
static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
|
||||||
struct of_dma *ofdma)
|
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) {
|
list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
|
||||||
if (chan->client_count)
|
if (chan->client_count)
|
||||||
continue;
|
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]) {
|
if ((chan->chan_id / chans_per_mux) == dma_spec->args[0]) {
|
||||||
chan = dma_get_slave_channel(chan);
|
chan = dma_get_slave_channel(chan);
|
||||||
if (chan) {
|
if (chan) {
|
||||||
@ -161,6 +181,8 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
fsl_chan = to_fsl_edma_chan(chan);
|
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;
|
i = fsl_chan - fsl_edma->chans;
|
||||||
|
|
||||||
fsl_chan->priority = dma_spec->args[1];
|
fsl_chan->priority = dma_spec->args[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user