Skip to content

Commit 44eb827

Browse files
nxpfranklivinodkoul
authored andcommitted
dmaengine: fsl-edma: request per-channel IRQ only when channel is allocated
The edma feature individual IRQs for each DMA channel at some devices. Given the presence of numerous eDMA instances, each with multiple channels, IRQ request during probe results in an extensive list at /proc/interrupts. However, a significant portion of these channels remains unused by the system. Request irq only when a DMA client driver requests a DMA channel. Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 49b1c21 commit 44eb827

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

drivers/dma/fsl-edma-common.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ void fsl_edma_issue_pending(struct dma_chan *chan)
805805
int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
806806
{
807807
struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
808+
int ret;
808809

809810
if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_CHCLK)
810811
clk_prepare_enable(fsl_chan->clk);
@@ -813,6 +814,17 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
813814
fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_TCD64 ?
814815
sizeof(struct fsl_edma_hw_tcd64) : sizeof(struct fsl_edma_hw_tcd),
815816
32, 0);
817+
818+
if (fsl_chan->txirq) {
819+
ret = request_irq(fsl_chan->txirq, fsl_chan->irq_handler, IRQF_SHARED,
820+
fsl_chan->chan_name, fsl_chan);
821+
822+
if (ret) {
823+
dma_pool_destroy(fsl_chan->tcd_pool);
824+
return ret;
825+
}
826+
}
827+
816828
return 0;
817829
}
818830

@@ -832,6 +844,9 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan)
832844
fsl_edma_unprep_slave_dma(fsl_chan);
833845
spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
834846

847+
if (fsl_chan->txirq)
848+
free_irq(fsl_chan->txirq, fsl_chan);
849+
835850
vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
836851
dma_pool_destroy(fsl_chan->tcd_pool);
837852
fsl_chan->tcd_pool = NULL;

drivers/dma/fsl-edma-common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ struct fsl_edma_chan {
172172
int priority;
173173
int hw_chanid;
174174
int txirq;
175+
irqreturn_t (*irq_handler)(int irq, void *dev_id);
175176
bool is_rxchan;
176177
bool is_remote;
177178
bool is_multi_fifo;

drivers/dma/fsl-edma-main.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ static irqreturn_t fsl_edma3_tx_handler(int irq, void *dev_id)
6565
return IRQ_HANDLED;
6666
}
6767

68+
static irqreturn_t fsl_edma2_tx_handler(int irq, void *devi_id)
69+
{
70+
struct fsl_edma_chan *fsl_chan = devi_id;
71+
72+
return fsl_edma_tx_handler(irq, fsl_chan->edma);
73+
}
74+
6875
static irqreturn_t fsl_edma_err_handler(int irq, void *dev_id)
6976
{
7077
struct fsl_edma_engine *fsl_edma = dev_id;
@@ -228,7 +235,6 @@ fsl_edma_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma
228235

229236
static int fsl_edma3_irq_init(struct platform_device *pdev, struct fsl_edma_engine *fsl_edma)
230237
{
231-
int ret;
232238
int i;
233239

234240
for (i = 0; i < fsl_edma->n_chans; i++) {
@@ -243,13 +249,7 @@ static int fsl_edma3_irq_init(struct platform_device *pdev, struct fsl_edma_engi
243249
if (fsl_chan->txirq < 0)
244250
return -EINVAL;
245251

246-
ret = devm_request_irq(&pdev->dev, fsl_chan->txirq,
247-
fsl_edma3_tx_handler, IRQF_SHARED,
248-
fsl_chan->chan_name, fsl_chan);
249-
if (ret) {
250-
dev_err(&pdev->dev, "Can't register chan%d's IRQ.\n", i);
251-
return -EINVAL;
252-
}
252+
fsl_chan->irq_handler = fsl_edma3_tx_handler;
253253
}
254254

255255
return 0;
@@ -278,19 +278,20 @@ fsl_edma2_irq_init(struct platform_device *pdev,
278278
*/
279279
for (i = 0; i < count; i++) {
280280
irq = platform_get_irq(pdev, i);
281+
ret = 0;
281282
if (irq < 0)
282283
return -ENXIO;
283284

284285
/* The last IRQ is for eDMA err */
285-
if (i == count - 1)
286+
if (i == count - 1) {
286287
ret = devm_request_irq(&pdev->dev, irq,
287288
fsl_edma_err_handler,
288289
0, "eDMA2-ERR", fsl_edma);
289-
else
290-
ret = devm_request_irq(&pdev->dev, irq,
291-
fsl_edma_tx_handler, 0,
292-
fsl_edma->chans[i].chan_name,
293-
fsl_edma);
290+
} else {
291+
fsl_edma->chans[i].txirq = irq;
292+
fsl_edma->chans[i].irq_handler = fsl_edma2_tx_handler;
293+
}
294+
294295
if (ret)
295296
return ret;
296297
}

0 commit comments

Comments
 (0)