linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wireless v2 0/3] wifi: Use IRQF_NO_AUTOEN flag in request_irq()
@ 2024-09-10 12:43 Jinjie Ruan
  2024-09-10 12:43 ` [PATCH wireless v2 1/3] wifi: p54: " Jinjie Ruan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jinjie Ruan @ 2024-09-10 12:43 UTC (permalink / raw)
  To: chunkeey, kvalo, briannorris, francesco, krzysztof.kozlowski,
	leitao, linville, rajatja, linux-wireless, linux-kernel
  Cc: ruanjinjie

As commit cbe16f35bee6 ("genirq: Add IRQF_NO_AUTOEN for request_irq/nmi()")
said, reqeust_irq() and then disable_irq() is unsafe.

And the code below is subobtimal:
	 irq_set_status_flags(irq, IRQ_NOAUTOEN);
	 request_irq(dev, irq...);

IRQF_NO_AUTOEN flag can be used by drivers to request_irq(). It prevents
the automatic enabling of the requested interrupt in the same safe way.
With that the usage can be simplified and corrected.

Only compile-tested.

Changes in v2:
- wireless prefixed subject and submit them in a separate patchset.
- Add fix tag.

Jinjie Ruan (3):
  wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
  wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
  wifi: wl1251: Use IRQF_NO_AUTOEN flag in request_irq()

 drivers/net/wireless/intersil/p54/p54spi.c  | 4 +---
 drivers/net/wireless/marvell/mwifiex/main.c | 4 ++--
 drivers/net/wireless/ti/wl1251/sdio.c       | 4 ++--
 3 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH wireless v2 1/3] wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-10 12:43 [PATCH wireless v2 0/3] wifi: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
@ 2024-09-10 12:43 ` Jinjie Ruan
  2024-09-18 13:54   ` Kalle Valo
  2024-09-10 12:43 ` [PATCH wireless v2 2/3] wifi: mwifiex: " Jinjie Ruan
  2024-09-10 12:43 ` [PATCH wireless v2 3/3] wifi: wl1251: " Jinjie Ruan
  2 siblings, 1 reply; 6+ messages in thread
From: Jinjie Ruan @ 2024-09-10 12:43 UTC (permalink / raw)
  To: chunkeey, kvalo, briannorris, francesco, krzysztof.kozlowski,
	leitao, linville, rajatja, linux-wireless, linux-kernel
  Cc: ruanjinjie

disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable when request IRQ.

Fixes: cd8d3d321285 ("p54spi: p54spi driver")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Add fix tag.
- Wireless patches go to wireless-next, submit them in a separate patchset.
---
 drivers/net/wireless/intersil/p54/p54spi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intersil/p54/p54spi.c b/drivers/net/wireless/intersil/p54/p54spi.c
index d33a994906a7..27f44a9f0bc1 100644
--- a/drivers/net/wireless/intersil/p54/p54spi.c
+++ b/drivers/net/wireless/intersil/p54/p54spi.c
@@ -624,7 +624,7 @@ static int p54spi_probe(struct spi_device *spi)
 	gpio_direction_input(p54spi_gpio_irq);
 
 	ret = request_irq(gpio_to_irq(p54spi_gpio_irq),
-			  p54spi_interrupt, 0, "p54spi",
+			  p54spi_interrupt, IRQF_NO_AUTOEN, "p54spi",
 			  priv->spi);
 	if (ret < 0) {
 		dev_err(&priv->spi->dev, "request_irq() failed");
@@ -633,8 +633,6 @@ static int p54spi_probe(struct spi_device *spi)
 
 	irq_set_irq_type(gpio_to_irq(p54spi_gpio_irq), IRQ_TYPE_EDGE_RISING);
 
-	disable_irq(gpio_to_irq(p54spi_gpio_irq));
-
 	INIT_WORK(&priv->work, p54spi_work);
 	init_completion(&priv->fw_comp);
 	INIT_LIST_HEAD(&priv->tx_pending);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH wireless v2 2/3] wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-10 12:43 [PATCH wireless v2 0/3] wifi: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
  2024-09-10 12:43 ` [PATCH wireless v2 1/3] wifi: p54: " Jinjie Ruan
@ 2024-09-10 12:43 ` Jinjie Ruan
  2024-09-10 17:17   ` Brian Norris
  2024-09-10 12:43 ` [PATCH wireless v2 3/3] wifi: wl1251: " Jinjie Ruan
  2 siblings, 1 reply; 6+ messages in thread
From: Jinjie Ruan @ 2024-09-10 12:43 UTC (permalink / raw)
  To: chunkeey, kvalo, briannorris, francesco, krzysztof.kozlowski,
	leitao, linville, rajatja, linux-wireless, linux-kernel
  Cc: ruanjinjie

disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable when request IRQ.

Fixes: 853402a00823 ("mwifiex: Enable WoWLAN for both sdio and pcie")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Add fix tag.
- Wireless patches go to wireless-next, submit them in a separate patchset.
---
 drivers/net/wireless/marvell/mwifiex/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index d99127dc466e..6c60a4c21a31 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -1633,7 +1633,8 @@ static void mwifiex_probe_of(struct mwifiex_adapter *adapter)
 	}
 
 	ret = devm_request_irq(dev, adapter->irq_wakeup,
-			       mwifiex_irq_wakeup_handler, IRQF_TRIGGER_LOW,
+			       mwifiex_irq_wakeup_handler,
+			       IRQF_TRIGGER_LOW | IRQF_NO_AUTOEN,
 			       "wifi_wake", adapter);
 	if (ret) {
 		dev_err(dev, "Failed to request irq_wakeup %d (%d)\n",
@@ -1641,7 +1642,6 @@ static void mwifiex_probe_of(struct mwifiex_adapter *adapter)
 		goto err_exit;
 	}
 
-	disable_irq(adapter->irq_wakeup);
 	if (device_init_wakeup(dev, true)) {
 		dev_err(dev, "fail to init wakeup for mwifiex\n");
 		goto err_exit;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH wireless v2 3/3] wifi: wl1251: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-10 12:43 [PATCH wireless v2 0/3] wifi: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
  2024-09-10 12:43 ` [PATCH wireless v2 1/3] wifi: p54: " Jinjie Ruan
  2024-09-10 12:43 ` [PATCH wireless v2 2/3] wifi: mwifiex: " Jinjie Ruan
@ 2024-09-10 12:43 ` Jinjie Ruan
  2 siblings, 0 replies; 6+ messages in thread
From: Jinjie Ruan @ 2024-09-10 12:43 UTC (permalink / raw)
  To: chunkeey, kvalo, briannorris, francesco, krzysztof.kozlowski,
	leitao, linville, rajatja, linux-wireless, linux-kernel
  Cc: ruanjinjie

As commit cbe16f35bee6 ("genirq: Add IRQF_NO_AUTOEN for request_irq/nmi()")
said, the code below is subobtimal. IRQF_NO_AUTOEN flag can be used by
drivers to request_irq(). It prevents the automatic enabling of the
requested interrupt in the same safe way. With that the usage can be
simplified and corrected.

	irq_set_status_flags(irq, IRQ_NOAUTOEN);
	request_irq(dev, irq...);

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/wireless/ti/wl1251/sdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
index c705081249d6..b45050243129 100644
--- a/drivers/net/wireless/ti/wl1251/sdio.c
+++ b/drivers/net/wireless/ti/wl1251/sdio.c
@@ -233,8 +233,8 @@ static int wl1251_sdio_probe(struct sdio_func *func,
 	}
 
 	if (wl->irq) {
-		irq_set_status_flags(wl->irq, IRQ_NOAUTOEN);
-		ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl);
+		ret = request_irq(wl->irq, wl1251_line_irq, IRQF_NO_AUTOEN,
+				  "wl1251", wl);
 		if (ret < 0) {
 			wl1251_error("request_irq() failed: %d", ret);
 			goto disable;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH wireless v2 2/3] wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-10 12:43 ` [PATCH wireless v2 2/3] wifi: mwifiex: " Jinjie Ruan
@ 2024-09-10 17:17   ` Brian Norris
  0 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2024-09-10 17:17 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: chunkeey, kvalo, francesco, krzysztof.kozlowski, leitao, linville,
	rajatja, linux-wireless, linux-kernel

On Tue, Sep 10, 2024 at 08:43:13PM +0800, Jinjie Ruan wrote:
> disable_irq() after request_irq() still has a time gap in which
> interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
> disable IRQ auto-enable when request IRQ.
> 
> Fixes: 853402a00823 ("mwifiex: Enable WoWLAN for both sdio and pcie")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Add fix tag.
> - Wireless patches go to wireless-next, submit them in a separate patchset.
> ---
>  drivers/net/wireless/marvell/mwifiex/main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Acked-by: Brian Norris <briannorris@chromium.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH wireless v2 1/3] wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-10 12:43 ` [PATCH wireless v2 1/3] wifi: p54: " Jinjie Ruan
@ 2024-09-18 13:54   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2024-09-18 13:54 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: chunkeey, briannorris, francesco, krzysztof.kozlowski, leitao,
	linville, rajatja, linux-wireless, linux-kernel, ruanjinjie

Jinjie Ruan <ruanjinjie@huawei.com> wrote:

> disable_irq() after request_irq() still has a time gap in which
> interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
> disable IRQ auto-enable when request IRQ.
> 
> Fixes: cd8d3d321285 ("p54spi: p54spi driver")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

3 patches applied to wireless-next.git, thanks.

bcd1371bd85e wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
9a98dd48b6d8 wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
5a4d42c1688c wifi: wl1251: Use IRQF_NO_AUTOEN flag in request_irq()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20240910124314.698896-2-ruanjinjie@huawei.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-18 13:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 12:43 [PATCH wireless v2 0/3] wifi: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
2024-09-10 12:43 ` [PATCH wireless v2 1/3] wifi: p54: " Jinjie Ruan
2024-09-18 13:54   ` Kalle Valo
2024-09-10 12:43 ` [PATCH wireless v2 2/3] wifi: mwifiex: " Jinjie Ruan
2024-09-10 17:17   ` Brian Norris
2024-09-10 12:43 ` [PATCH wireless v2 3/3] wifi: wl1251: " Jinjie Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).