* [PATCH 0/2] can: kvaser_pciefd: Support MSI interrupts
@ 2024-06-14 15:20 Martin Jocic
2024-06-14 15:20 ` [PATCH 1/2] can: kvaser_pciefd: Move reset of DMA RX buffers to the end of the ISR Martin Jocic
2024-06-14 15:20 ` [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts Martin Jocic
0 siblings, 2 replies; 5+ messages in thread
From: Martin Jocic @ 2024-06-14 15:20 UTC (permalink / raw)
To: linux-can, mkl, mailhol.vincent; +Cc: extja
This patch series adds support for MSI interrupts. It depends on
the patch series can: kvaser_pciefd: Minor improvements and cleanups.
Martin Jocic (2):
can: kvaser_pciefd: Move reset of DMA RX buffers to the end of the ISR
can: kvaser_pciefd: Add MSI interrupts
drivers/net/can/kvaser_pciefd.c | 54 ++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 15 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] can: kvaser_pciefd: Move reset of DMA RX buffers to the end of the ISR
2024-06-14 15:20 [PATCH 0/2] can: kvaser_pciefd: Support MSI interrupts Martin Jocic
@ 2024-06-14 15:20 ` Martin Jocic
2024-06-14 15:20 ` [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts Martin Jocic
1 sibling, 0 replies; 5+ messages in thread
From: Martin Jocic @ 2024-06-14 15:20 UTC (permalink / raw)
To: linux-can, mkl, mailhol.vincent; +Cc: extja
A new interrupt is triggered by resetting the DMA RX buffers.
Since MSI interrupts are faster than legacy interrupts, the reset
of the DMA buffers must be moved to the very end of the ISR,
otherwise a new MSI interrupt will be masked by the current one.
Signed-off-by: Martin Jocic <martin.jocic@kvaser.com>
---
drivers/net/can/kvaser_pciefd.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c
index 24871c276b31..63b4d2a4c7ce 100644
--- a/drivers/net/can/kvaser_pciefd.c
+++ b/drivers/net/can/kvaser_pciefd.c
@@ -1640,23 +1640,15 @@ static int kvaser_pciefd_read_buffer(struct kvaser_pciefd *pcie, int dma_buf)
return res;
}
-static void kvaser_pciefd_receive_irq(struct kvaser_pciefd *pcie)
+static u32 kvaser_pciefd_receive_irq(struct kvaser_pciefd *pcie)
{
u32 irq = ioread32(KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IRQ_REG);
- if (irq & KVASER_PCIEFD_SRB_IRQ_DPD0) {
+ if (irq & KVASER_PCIEFD_SRB_IRQ_DPD0)
kvaser_pciefd_read_buffer(pcie, 0);
- /* Reset DMA buffer 0 */
- iowrite32(KVASER_PCIEFD_SRB_CMD_RDB0,
- KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG);
- }
- if (irq & KVASER_PCIEFD_SRB_IRQ_DPD1) {
+ if (irq & KVASER_PCIEFD_SRB_IRQ_DPD1)
kvaser_pciefd_read_buffer(pcie, 1);
- /* Reset DMA buffer 1 */
- iowrite32(KVASER_PCIEFD_SRB_CMD_RDB1,
- KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG);
- }
if (unlikely(irq & KVASER_PCIEFD_SRB_IRQ_DOF0 ||
irq & KVASER_PCIEFD_SRB_IRQ_DOF1 ||
@@ -1665,6 +1657,7 @@ static void kvaser_pciefd_receive_irq(struct kvaser_pciefd *pcie)
dev_err(&pcie->pci->dev, "DMA IRQ error 0x%08X\n", irq);
iowrite32(irq, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IRQ_REG);
+ return irq;
}
static void kvaser_pciefd_transmit_irq(struct kvaser_pciefd_can *can)
@@ -1692,19 +1685,32 @@ static irqreturn_t kvaser_pciefd_irq_handler(int irq, void *dev)
struct kvaser_pciefd *pcie = (struct kvaser_pciefd *)dev;
const struct kvaser_pciefd_irq_mask *irq_mask = pcie->driver_data->irq_mask;
u32 pci_irq = ioread32(KVASER_PCIEFD_PCI_IRQ_ADDR(pcie));
+ u32 srb_irq = 0;
int i;
if (!(pci_irq & irq_mask->all))
return IRQ_NONE;
if (pci_irq & irq_mask->kcan_rx0)
- kvaser_pciefd_receive_irq(pcie);
+ srb_irq = kvaser_pciefd_receive_irq(pcie);
for (i = 0; i < pcie->nr_channels; i++) {
if (pci_irq & irq_mask->kcan_tx[i])
kvaser_pciefd_transmit_irq(pcie->can[i]);
}
+ if (srb_irq & KVASER_PCIEFD_SRB_IRQ_DPD0) {
+ /* Reset DMA buffer 0, may trigger new interrupt */
+ iowrite32(KVASER_PCIEFD_SRB_CMD_RDB0,
+ KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG);
+ }
+
+ if (srb_irq & KVASER_PCIEFD_SRB_IRQ_DPD1) {
+ /* Reset DMA buffer 1, may trigger new interrupt */
+ iowrite32(KVASER_PCIEFD_SRB_CMD_RDB1,
+ KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CMD_REG);
+ }
+
return IRQ_HANDLED;
}
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts
2024-06-14 15:20 [PATCH 0/2] can: kvaser_pciefd: Support MSI interrupts Martin Jocic
2024-06-14 15:20 ` [PATCH 1/2] can: kvaser_pciefd: Move reset of DMA RX buffers to the end of the ISR Martin Jocic
@ 2024-06-14 15:20 ` Martin Jocic
2024-06-20 10:05 ` Marc Kleine-Budde
1 sibling, 1 reply; 5+ messages in thread
From: Martin Jocic @ 2024-06-14 15:20 UTC (permalink / raw)
To: linux-can, mkl, mailhol.vincent; +Cc: extja
Use MSI interrupts with fallback to legacy interrupts.
Signed-off-by: Martin Jocic <martin.jocic@kvaser.com>
---
drivers/net/can/kvaser_pciefd.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c
index 63b4d2a4c7ce..53b82e11f7f3 100644
--- a/drivers/net/can/kvaser_pciefd.c
+++ b/drivers/net/can/kvaser_pciefd.c
@@ -1774,11 +1774,24 @@ static int kvaser_pciefd_probe(struct pci_dev *pdev,
if (ret)
goto err_teardown_can_ctrls;
- ret = request_irq(pcie->pci->irq, kvaser_pciefd_irq_handler,
- IRQF_SHARED, KVASER_PCIEFD_DRV_NAME, pcie);
- if (ret)
+ ret = pci_alloc_irq_vectors(pcie->pci, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSI);
+ if (ret < 0) {
+ dev_info(&pcie->pci->dev, "Failed to allocate IRQ vectors.\n");
goto err_teardown_can_ctrls;
+ }
+
+ ret = pci_irq_vector(pcie->pci, 0);
+ if (ret < 0)
+ goto err_free_msi;
+
+ pcie->pci->irq = ret;
+ ret = request_irq(pcie->pci->irq, kvaser_pciefd_irq_handler,
+ IRQF_SHARED, KVASER_PCIEFD_DRV_NAME, pcie);
+ if (ret) {
+ dev_info(&pcie->pci->dev, "Failed to request IRQ %d\n", pcie->pci->irq);
+ goto err_free_msi;
+ }
iowrite32(KVASER_PCIEFD_SRB_IRQ_DPD0 | KVASER_PCIEFD_SRB_IRQ_DPD1,
KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_IRQ_REG);
@@ -1807,6 +1820,10 @@ static int kvaser_pciefd_probe(struct pci_dev *pdev,
iowrite32(0, irq_en_base);
free_irq(pcie->pci->irq, pcie);
+err_free_msi:
+ if (pcie->pci->msi_enabled)
+ pci_free_irq_vectors(pcie->pci);
+
err_teardown_can_ctrls:
kvaser_pciefd_teardown_can_ctrls(pcie);
iowrite32(0, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CTRL_REG);
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts
2024-06-14 15:20 ` [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts Martin Jocic
@ 2024-06-20 10:05 ` Marc Kleine-Budde
2024-06-20 10:09 ` Marc Kleine-Budde
0 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2024-06-20 10:05 UTC (permalink / raw)
To: Martin Jocic; +Cc: linux-can, mailhol.vincent, extja
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
On 14.06.2024 17:20:08, Martin Jocic wrote:
> Use MSI interrupts with fallback to legacy interrupts.
Thanks for your patches, but this fails to build on current net-next.
| drivers/net/can/kvaser_pciefd.c: In function ‘kvaser_pciefd_probe’:
| drivers/net/can/kvaser_pciefd.c:1777:54: error: ‘PCI_IRQ_LEGACY’ undeclared (first use in this function); did you mean ‘NR_IRQS_LEGACY’?
| 1777 | ret = pci_alloc_irq_vectors(pcie->pci, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSI);
| | ^~~~~~~~~~~~~~
| | NR_IRQS_LEGACY
| drivers/net/can/kvaser_pciefd.c:1777:54: note: each undeclared identifier is reported only once for each function it appears in
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts
2024-06-20 10:05 ` Marc Kleine-Budde
@ 2024-06-20 10:09 ` Marc Kleine-Budde
0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2024-06-20 10:09 UTC (permalink / raw)
To: Martin Jocic; +Cc: linux-can, mailhol.vincent, extja
[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]
On 20.06.2024 12:05:33, Marc Kleine-Budde wrote:
> On 14.06.2024 17:20:08, Martin Jocic wrote:
> > Use MSI interrupts with fallback to legacy interrupts.
>
> Thanks for your patches, but this fails to build on current net-next.
>
> | drivers/net/can/kvaser_pciefd.c: In function ‘kvaser_pciefd_probe’:
> | drivers/net/can/kvaser_pciefd.c:1777:54: error: ‘PCI_IRQ_LEGACY’ undeclared (first use in this function); did you mean ‘NR_IRQS_LEGACY’?
> | 1777 | ret = pci_alloc_irq_vectors(pcie->pci, 1, 1, PCI_IRQ_LEGACY | PCI_IRQ_MSI);
> | | ^~~~~~~~~~~~~~
> | | NR_IRQS_LEGACY
> | drivers/net/can/kvaser_pciefd.c:1777:54: note: each undeclared identifier is reported only once for each function it appears in
See 0e1fdd222f0a ("PCI: Remove PCI_IRQ_LEGACY"). I'll fix it up here.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-20 10:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14 15:20 [PATCH 0/2] can: kvaser_pciefd: Support MSI interrupts Martin Jocic
2024-06-14 15:20 ` [PATCH 1/2] can: kvaser_pciefd: Move reset of DMA RX buffers to the end of the ISR Martin Jocic
2024-06-14 15:20 ` [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts Martin Jocic
2024-06-20 10:05 ` Marc Kleine-Budde
2024-06-20 10:09 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox