Skip to content

Commit 9542961

Browse files
1991Joyzouvinodkoul
authored andcommitted
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 <[email protected]> Reviewed-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 90d21f6 commit 9542961

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/dma/fsl-edma-main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ static irqreturn_t fsl_edma_irq_handler(int irq, void *dev_id)
100100
return fsl_edma_err_handler(irq, dev_id);
101101
}
102102

103+
static bool fsl_edma_srcid_in_use(struct fsl_edma_engine *fsl_edma, u32 srcid)
104+
{
105+
struct fsl_edma_chan *fsl_chan;
106+
int i;
107+
108+
for (i = 0; i < fsl_edma->n_chans; i++) {
109+
fsl_chan = &fsl_edma->chans[i];
110+
111+
if (fsl_chan->srcid && srcid == fsl_chan->srcid) {
112+
dev_err(&fsl_chan->pdev->dev, "The srcid is in use, can't use!");
113+
return true;
114+
}
115+
}
116+
return false;
117+
}
118+
103119
static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
104120
struct of_dma *ofdma)
105121
{
@@ -117,6 +133,10 @@ static struct dma_chan *fsl_edma_xlate(struct of_phandle_args *dma_spec,
117133
list_for_each_entry_safe(chan, _chan, &fsl_edma->dma_dev.channels, device_node) {
118134
if (chan->client_count)
119135
continue;
136+
137+
if (fsl_edma_srcid_in_use(fsl_edma, dma_spec->args[1]))
138+
return NULL;
139+
120140
if ((chan->chan_id / chans_per_mux) == dma_spec->args[0]) {
121141
chan = dma_get_slave_channel(chan);
122142
if (chan) {
@@ -161,6 +181,8 @@ static struct dma_chan *fsl_edma3_xlate(struct of_phandle_args *dma_spec,
161181
continue;
162182

163183
fsl_chan = to_fsl_edma_chan(chan);
184+
if (fsl_edma_srcid_in_use(fsl_edma, dma_spec->args[0]))
185+
return NULL;
164186
i = fsl_chan - fsl_edma->chans;
165187

166188
fsl_chan->priority = dma_spec->args[1];

0 commit comments

Comments
 (0)