On 20.06.2024 20:13:20, Martin Jocic wrote: > Use MSI interrupts with fallback to INTx interrupts. > > Signed-off-by: Martin Jocic <martin.jocic@xxxxxxxxxx> > --- > > Changes since v1: > * Implemented review comments from Jimmy Assarsson: > - Add missing pci_free_irq_vectors() in kvaser_pciefd_remove() > - Replace dev_info() with dev_err() when reporting errors > > * Implemented review comment from Marc Kleine-Budde: > - Replace deprecated #define PCI_IRQ_LEGACY with PCI_IRQ_INTX > > Thank you for your comments. > > /Martin > > drivers/net/can/kvaser_pciefd.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c > index b4ffd56fdeff..5aed2521ccd1 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_INTX | PCI_IRQ_MSI); > + if (ret < 0) { > + dev_err(&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_err(&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); I think you can call this unconditionally here, too. Will fixup while applying. Marc > + > err_teardown_can_ctrls: > kvaser_pciefd_teardown_can_ctrls(pcie); > iowrite32(0, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CTRL_REG); > @@ -1852,7 +1869,7 @@ static void kvaser_pciefd_remove(struct pci_dev *pdev) > iowrite32(0, KVASER_PCIEFD_PCI_IEN_ADDR(pcie)); > > free_irq(pcie->pci->irq, pcie); > - > + pci_free_irq_vectors(pcie->pci); > pci_iounmap(pdev, pcie->reg_base); > pci_release_regions(pdev); > pci_disable_device(pdev); > -- > 2.40.1 > > > -- 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:
signature.asc
Description: PGP signature