Linux CAN drivers development
 help / color / mirror / Atom feed
From: Martin Jocic <martin.jocic@kvaser.com>
To: linux-can@vger.kernel.org, mkl@pengutronix.de,
	mailhol.vincent@wanadoo.fr
Cc: extja@kvaser.com
Subject: [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts
Date: Fri, 14 Jun 2024 17:20:08 +0200	[thread overview]
Message-ID: <20240614152008.2730746-3-martin.jocic@kvaser.com> (raw)
In-Reply-To: <20240614152008.2730746-1-martin.jocic@kvaser.com>

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


  parent reply	other threads:[~2024-06-14 15:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2024-06-20 10:05   ` [PATCH 2/2] can: kvaser_pciefd: Add MSI interrupts Marc Kleine-Budde
2024-06-20 10:09     ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240614152008.2730746-3-martin.jocic@kvaser.com \
    --to=martin.jocic@kvaser.com \
    --cc=extja@kvaser.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=mkl@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox