diff mbox series

[2/2,v3] wifi: brcmfmac: handle possible PCIE irq handling errors

Message ID 20240122115749.67682-2-dmantipov@yandex.ru (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series [1/2,v3] wifi: brcmfmac: handle possible completion timeouts | expand

Commit Message

Dmitry Antipov Jan. 22, 2024, 11:57 a.m. UTC
Switch to newer 'pci_{alloc,feee}_irq_vectors()' API and handle
possible errors in 'brcmf_pcie_request_irq()'. Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v3: switch to 'pci_{alloc,feee}_irq_vectors()' per Bjorn's review
v2: rebase against wireless-next tree
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Arend van Spriel Jan. 22, 2024, 5:45 p.m. UTC | #1
On January 22, 2024 12:59:03 PM Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Switch to newer 'pci_{alloc,feee}_irq_vectors()' API and handle
> possible errors in 'brcmf_pcie_request_irq()'. Compile tested only.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

See comment below...

Reviewed-by: Arend van Spriel<arend.vanspriel@broadcom.com>
> Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> v3: switch to 'pci_{alloc,feee}_irq_vectors()' per Bjorn's review
> v2: rebase against wireless-next tree
> ---
> .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> index 80220685f5e4..0f77d94f34a3 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> @@ -965,6 +965,7 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void 
> *arg)
>
> static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
> {
> + int ret;
>  struct pci_dev *pdev = devinfo->pdev;
>  struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
>
> @@ -972,11 +973,14 @@ static int brcmf_pcie_request_irq(struct 
> brcmf_pciedev_info *devinfo)
>
>  brcmf_dbg(PCIE, "Enter\n");
>
> - pci_enable_msi(pdev);
> + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
> + if (ret < 0)
> + return ret;
> +
>  if (request_threaded_irq(pdev->irq,

Reading the kerneldoc for pci_alloc_irq_vectors() you should use the helper 
function pci_irq_vector() instead of pdev->irq


brcmf_pcie_quick_check_isr,
>  brcmf_pcie_isr_thread, IRQF_SHARED,
>  "brcmf_pcie_intr", devinfo)) {
> - pci_disable_msi(pdev);
> + pci_free_irq_vectors(pdev);
>  brcmf_err(bus, "Failed to request IRQ %d\n", pdev->irq);
>  return -EIO;
>  }
> @@ -997,7 +1001,7 @@ static void brcmf_pcie_release_irq(struct 
> brcmf_pciedev_info *devinfo)
>
>  brcmf_pcie_intr_disable(devinfo);
>  free_irq(pdev->irq, devinfo);
> - pci_disable_msi(pdev);
> + pci_free_irq_vectors(pdev);
>
>  msleep(50);
>  count = 0;
> --
> 2.43.0
Bjorn Helgaas Jan. 22, 2024, 6:20 p.m. UTC | #2
On Mon, Jan 22, 2024 at 02:57:25PM +0300, Dmitry Antipov wrote:
> Switch to newer 'pci_{alloc,feee}_irq_vectors()' API and handle
> possible errors in 'brcmf_pcie_request_irq()'. Compile tested only.

If you have occasion to update this, possibly s/PCIE/PCI/ in the
subject, since this is generic to PCI and PCIe.

Bjorn
Dmitry Antipov Jan. 24, 2024, 6:22 a.m. UTC | #3
On 1/22/24 21:20, Bjorn Helgaas wrote:

> If you have occasion to update this, possibly s/PCIE/PCI/ in the
> subject, since this is generic to PCI and PCIe.

OK. BTW if we're touching this anyway, shouldn't we hook into the generic device
framework and switch to devm_request_threaded_irq()/devm_free_irq() as well?

Dmitry
Arend van Spriel Jan. 24, 2024, 7:03 a.m. UTC | #4
On January 24, 2024 7:22:58 AM Dmitry Antipov <dmantipov@yandex.ru> wrote:

> On 1/22/24 21:20, Bjorn Helgaas wrote:
>
>> If you have occasion to update this, possibly s/PCIE/PCI/ in the
>> subject, since this is generic to PCI and PCIe.
>
> OK. BTW if we're touching this anyway, shouldn't we hook into the generic 
> device
> framework and switch to devm_request_threaded_irq()/devm_free_irq() as well?

Hi Dmitry,

Those are not generic device functions. They create device managed resource 
so devm_free_irq() is implicitly invoked upon device detach. So replacing 
free_irq() with devm_free_irq() is not very meaningful. There are some 
devm_*() usages in the driver, but it's not used commonly. However, feel 
free to add it.

Regards,
Arend

> Dmitry
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 80220685f5e4..0f77d94f34a3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -965,6 +965,7 @@  static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg)
 
 static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
 {
+	int ret;
 	struct pci_dev *pdev = devinfo->pdev;
 	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 
@@ -972,11 +973,14 @@  static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
 
 	brcmf_dbg(PCIE, "Enter\n");
 
-	pci_enable_msi(pdev);
+	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
+	if (ret < 0)
+		return ret;
+
 	if (request_threaded_irq(pdev->irq, brcmf_pcie_quick_check_isr,
 				 brcmf_pcie_isr_thread, IRQF_SHARED,
 				 "brcmf_pcie_intr", devinfo)) {
-		pci_disable_msi(pdev);
+		pci_free_irq_vectors(pdev);
 		brcmf_err(bus, "Failed to request IRQ %d\n", pdev->irq);
 		return -EIO;
 	}
@@ -997,7 +1001,7 @@  static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo)
 
 	brcmf_pcie_intr_disable(devinfo);
 	free_irq(pdev->irq, devinfo);
-	pci_disable_msi(pdev);
+	pci_free_irq_vectors(pdev);
 
 	msleep(50);
 	count = 0;