dmaengine: dw-edma: fix MSI data programming for multi-IRQ case
Subsystems (2)
PATCH v2 1/1 dmaengine: dw-edma: fix MSI data programming for multi-IRQ case
When using MSI (not MSI-X) with multiple IRQs, the MSI data value must be unique per vector to ensure correct interrupt delivery. Currently, the driver fails to increment the MSI data per vector, causing interrupts to be misrouted.
Fix this by caching the base MSI data and adjusting each vector's data accordingly during IRQ setup.
This issue was reproduced and tested on:
- Device: [20e0:2502] (rev 01)
- Kernel: 6.8.0-90-generic
--- drivers/dma/dw-edma/dw-edma-core.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +23 -2
@@ -844,11 +844,15 @@ static int dw_edma_irq_request(struct dw_edma *dw, {struct dw_edma_chip *chip = dw->chip;struct device *dev = dw->chip->dev; +struct msi_desc *msi_desc;u32 wr_mask =1 ;u32 rd_mask =1 ;int i, err =0 ;u32 ch_cnt;int irq; +u16 msi_base_data =0 ; +bool msi_base_valid = false; +bool is_msix = false; ch_cnt = dw->wr_ch_cnt + dw->rd_ch_cnt;
@@ -869,8 +873,15 @@ static int dw_edma_irq_request(struct dw_edma *dw,return err; } -if (irq_get_msi_desc (irq)) +if (irq_get_msi_desc (irq)) {get_cached_msi_msg (irq, &dw->irq[0 ].msi); + msi_desc =irq_get_msi_desc (irq); + is_msix = msi_desc && msi_desc->pci.msi_attrib.is_msix; +if (!is_msix) { + msi_base_data = dw->irq[0 ].msi.data; + msi_base_valid = true; + } + } dw->nr_irqs =1 ; }else {
@@ -896,8 +907,18 @@ static int dw_edma_irq_request(struct dw_edma *dw,if (err) goto err_irq_free; -if (irq_get_msi_desc (irq)) +if (irq_get_msi_desc (irq)) {get_cached_msi_msg (irq, &dw->irq[i].msi); + msi_desc =irq_get_msi_desc (irq); + is_msix = msi_desc && msi_desc->pci.msi_attrib.is_msix; +if (!is_msix) { +if (!msi_base_valid) { + msi_base_data = dw->irq[i].msi.data; + msi_base_valid = true; + } + dw->irq[i].msi.data = (u16)(msi_base_data + i); + } + } } dw->nr_irqs = i;
Signature · 1 line
2.49.0.windows.1
Quoted 43 lines · Shenghui Shi
When using MSI (not MSI-X) with multiple IRQs, the MSI data value must be unique per vector to ensure correct interrupt delivery. Currently, the driver fails to increment the MSI data per vector, causing interrupts to be misrouted.
Fix this by caching the base MSI data and adjusting each vector's data accordingly during IRQ setup.
This issue was reproduced and tested on:
- Device: [20e0:2502] (rev 01)
- Kernel: 6.8.0-90-genericFixes e63d79d1ff04 ("dmaengine: dw-edma: Add Synopsys DesignWare eDMA IP core driver")Signed-off-by Shenghui Shi <[email protected]>--- drivers/dma/dw-edma/dw-edma-core.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)drivers/dma/dw-edma/dw-edma-core.c +4
-0@@ -844,11 +844,15 @@ static int dw_edma_irq_request(struct dw_edma *dw, {struct dw_edma_chip *chip = dw->chip;struct device *dev = dw->chip->dev; +struct msi_desc *msi_desc;u32 wr_mask =1 ;u32 rd_mask =1 ;int i, err =0 ;u32 ch_cnt;int irq; +u16 msi_base_data =0 ; +bool msi_base_valid = false; +bool is_msix = false; ch_cnt = dw->wr_ch_cnt + dw->rd_ch_cnt;@@ -869,8 +873,15 @@ static int dw_edma_irq_request(struct dw_edma *dw,return err; }
drivers/dma/dw-edma/dw-edma-core.c static int dw_edma_irq_request(struct dw_edma *dw, · line 884
Quoted 10 lines
drivers/dma/dw-edma/dw-edma-core.c +8
-1-if (irq_get_msi_desc (irq)) +if (irq_get_msi_desc (irq)) {get_cached_msi_msg (irq, &dw->irq[0 ].msi); + msi_desc =irq_get_msi_desc (irq); + is_msix = msi_desc && msi_desc->pci.msi_attrib.is_msix; +if (!is_msix) { + msi_base_data = dw->irq[0 ].msi.data; + msi_base_valid = true; + } + }
look like this dead code. Not touch dw->irq[i].msi.data at all. All local variable will not affect else branch.
Quoted 8 lines
drivers/dma/dw-edma/dw-edma-core.c +0
-1dw->nr_irqs =1 ; }else {@@ -896,8 +907,18 @@ static int dw_edma_irq_request(struct dw_edma *dw,if (err) goto err_irq_free; -if (irq_get_msi_desc (irq))
drivers/dma/dw-edma/dw-edma-core.c static int dw_edma_irq_request(struct dw_edma *dw, · line 919
Quoted 10 lines
drivers/dma/dw-edma/dw-edma-core.c +9
-0+if (irq_get_msi_desc (irq)) {get_cached_msi_msg (irq, &dw->irq[i].msi); + msi_desc =irq_get_msi_desc (irq); + is_msix = msi_desc && msi_desc->pci.msi_attrib.is_msix; +if (!is_msix) { +if (!msi_base_valid) { + msi_base_data = dw->irq[i].msi.data; + msi_base_valid = true; + } + dw->irq[i].msi.data = (u16)(msi_base_data + i);
look like all dw->irq[i].msi.data is same for msi. (according to your commit message).
Simple dw->irq[i].msi.data += i; should work. Needn't msi_base_data and
msi_base_valid
Frank
Quoted 8 lines
drivers/dma/dw-edma/dw-edma-core.c +2
-1+ } + } } dw->nr_irqs = i; --2.49.0.windows.1