2016-02-08 21:24:09

by Lars-Peter Clausen

[permalink] [raw]
Subject: [PATCH 1/2] b43: Remove unnecessary synchronize_irq() before free_irq()

Calling synchronize_irq() right before free_irq() is quite useless. On one
hand the IRQ can easily fire again before free_irq() is entered, on the
other hand free_irq() itself calls synchronize_irq() internally (in a race
condition free way), before any state associated with the IRQ is freed.

Patch was generated using the following semantic patch:
// <smpl>
@@
expression irq;
@@
-synchronize_irq(irq);
free_irq(irq, ...);
// </smpl>

Signed-off-by: Lars-Peter Clausen <[email protected]>
---
drivers/net/wireless/broadcom/b43/main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/main.c b/drivers/net/wireless/broadcom/b43/main.c
index c279211..72380af 100644
--- a/drivers/net/wireless/broadcom/b43/main.c
+++ b/drivers/net/wireless/broadcom/b43/main.c
@@ -4375,12 +4375,10 @@ redo:
/* Synchronize and free the interrupt handlers. Unlock to avoid deadlocks. */
orig_dev = dev;
mutex_unlock(&wl->mutex);
- if (b43_bus_host_is_sdio(dev->dev)) {
+ if (b43_bus_host_is_sdio(dev->dev))
b43_sdio_free_irq(dev);
- } else {
- synchronize_irq(dev->dev->irq);
+ else
free_irq(dev->dev->irq, dev);
- }
mutex_lock(&wl->mutex);
dev = wl->current_dev;
if (!dev)
--
2.1.4



2016-02-25 10:00:50

by Kalle Valo

[permalink] [raw]
Subject: Re: [1/2] b43: Remove unnecessary synchronize_irq() before free_irq()


> Calling synchronize_irq() right before free_irq() is quite useless. On one
> hand the IRQ can easily fire again before free_irq() is entered, on the
> other hand free_irq() itself calls synchronize_irq() internally (in a race
> condition free way), before any state associated with the IRQ is freed.
>
> Patch was generated using the following semantic patch:
> // <smpl>
> @@
> expression irq;
> @@
> -synchronize_irq(irq);
> free_irq(irq, ...);
> // </smpl>
>
> Signed-off-by: Lars-Peter Clausen <[email protected]>

Thanks, 2 patches applied to wireless-drivers-next.git:

10fbc7cf031d b43: Remove unnecessary synchronize_irq() before free_irq()
400b43c58269 rtlwifi: Remove unnecessary synchronize_irq() before free_irq()

Kalle Valo

2016-02-08 22:22:53

by Michael Büsch

[permalink] [raw]
Subject: Re: [PATCH 1/2] b43: Remove unnecessary synchronize_irq() before free_irq()

On Mon, 8 Feb 2016 21:41:12 +0100
Lars-Peter Clausen <[email protected]> wrote:

> Calling synchronize_irq() right before free_irq() is quite useless. On one
> hand the IRQ can easily fire again before free_irq() is entered,

Well, that depends on whether the interrupt is shared and whether we
disabled the interrupt mask inside of the device (which we did).

> on the
> other hand free_irq() itself calls synchronize_irq() internally (in a race
> condition free way), before any state associated with the IRQ is freed.

Ok, fair enough.

--
Michael


Attachments:
(No filename) (819.00 B)
OpenPGP digital signature

2016-02-08 21:24:09

by Lars-Peter Clausen

[permalink] [raw]
Subject: [PATCH 2/2] rtlwifi: Remove unnecessary synchronize_irq() before free_irq()

Calling synchronize_irq() right before free_irq() is quite useless. On one
hand the IRQ can easily fire again before free_irq() is entered, on the
other hand free_irq() itself calls synchronize_irq() internally (in a race
condition free way), before any state associated with the IRQ is freed.

Patch was generated using the following semantic patch:
// <smpl>
@@
expression irq;
@@
-synchronize_irq(irq);
free_irq(irq, ...);
// </smpl>

Signed-off-by: Lars-Peter Clausen <[email protected]>
---
drivers/net/wireless/realtek/rtlwifi/pci.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 7f471bf..140d254 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -2392,7 +2392,6 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
rtlpriv->cfg->ops->deinit_sw_vars(hw);

if (rtlpci->irq_alloc) {
- synchronize_irq(rtlpci->pdev->irq);
free_irq(rtlpci->pdev->irq, hw);
rtlpci->irq_alloc = 0;
}
--
2.1.4


2016-02-08 21:44:54

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 2/2] rtlwifi: Remove unnecessary synchronize_irq() before free_irq()

On 02/08/2016 02:41 PM, Lars-Peter Clausen wrote:
> Calling synchronize_irq() right before free_irq() is quite useless. On one
> hand the IRQ can easily fire again before free_irq() is entered, on the
> other hand free_irq() itself calls synchronize_irq() internally (in a race
> condition free way), before any state associated with the IRQ is freed.
>
> Patch was generated using the following semantic patch:
> // <smpl>
> @@
> expression irq;
> @@
> -synchronize_irq(irq);
> free_irq(irq, ...);
> // </smpl>
>
> Signed-off-by: Lars-Peter Clausen <[email protected]>
> ---
> drivers/net/wireless/realtek/rtlwifi/pci.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
> index 7f471bf..140d254 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/pci.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
> @@ -2392,7 +2392,6 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
> rtlpriv->cfg->ops->deinit_sw_vars(hw);
>
> if (rtlpci->irq_alloc) {
> - synchronize_irq(rtlpci->pdev->irq);
> free_irq(rtlpci->pdev->irq, hw);
> rtlpci->irq_alloc = 0;
> }
>

Acked-by: Larry Finger <[email protected]>

Makes sense to me.

Thanks,

Larry