netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq()
@ 2024-09-09 13:30 Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 1/7] net: apple: bmac: " Jinjie Ruan
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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.

Jinjie Ruan (7):
  net: apple: bmac: Use IRQF_NO_AUTOEN flag in request_irq()
  net: enetc: Use IRQF_NO_AUTOEN flag in request_irq()
  nfp: Use IRQF_NO_AUTOEN flag in request_irq()
  net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
  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/ethernet/apple/bmac.c                   | 3 +--
 drivers/net/ethernet/freescale/enetc/enetc.c        | 3 +--
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++---
 drivers/net/ieee802154/mcr20a.c                     | 5 +----
 drivers/net/wireless/intersil/p54/p54spi.c          | 4 +---
 drivers/net/wireless/marvell/mwifiex/main.c         | 4 ++--
 drivers/net/wireless/ti/wl1251/sdio.c               | 4 ++--
 7 files changed, 10 insertions(+), 18 deletions(-)

-- 
2.34.1


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

* [PATCH 1/7] net: apple: bmac: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 2/7] net: enetc: " Jinjie Ruan
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/ethernet/apple/bmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c
index 292b1f9cd9e7..785f4b4ff758 100644
--- a/drivers/net/ethernet/apple/bmac.c
+++ b/drivers/net/ethernet/apple/bmac.c
@@ -1317,7 +1317,7 @@ static int bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
 
 	timer_setup(&bp->tx_timeout, bmac_tx_timeout, 0);
 
-	ret = request_irq(dev->irq, bmac_misc_intr, 0, "BMAC-misc", dev);
+	ret = request_irq(dev->irq, bmac_misc_intr, IRQF_NO_AUTOEN, "BMAC-misc", dev);
 	if (ret) {
 		printk(KERN_ERR "BMAC: can't get irq %d\n", dev->irq);
 		goto err_out_iounmap_rx;
@@ -1336,7 +1336,6 @@ static int bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
 	/* Mask chip interrupts and disable chip, will be
 	 * re-enabled on open()
 	 */
-	disable_irq(dev->irq);
 	pmac_call_feature(PMAC_FTR_BMAC_ENABLE, macio_get_of_node(bp->mdev), 0, 0);
 
 	if (register_netdev(dev) != 0) {
-- 
2.34.1


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

* [PATCH 2/7] net: enetc: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 1/7] net: apple: bmac: " Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 3/7] nfp: " Jinjie Ruan
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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: bbb96dc7fa1a ("enetc: Factor out the traffic start/stop procedures")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 5c45f42232d3..f04f42ea60c0 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -2305,12 +2305,11 @@ static int enetc_setup_irqs(struct enetc_ndev_priv *priv)
 
 		snprintf(v->name, sizeof(v->name), "%s-rxtx%d",
 			 priv->ndev->name, i);
-		err = request_irq(irq, enetc_msix, 0, v->name, v);
+		err = request_irq(irq, enetc_msix, IRQF_NO_AUTOEN, v->name, v);
 		if (err) {
 			dev_err(priv->dev, "request_irq() failed!\n");
 			goto irq_err;
 		}
-		disable_irq(irq);
 
 		v->tbier_base = hw->reg + ENETC_BDR(TX, 0, ENETC_TBIER);
 		v->rbier = hw->reg + ENETC_BDR(RX, i, ENETC_RBIER);
-- 
2.34.1


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

* [PATCH 3/7] nfp: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 1/7] net: apple: bmac: " Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 2/7] net: enetc: " Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-10  9:53   ` Louis Peens
  2024-09-09 13:30 ` [PATCH 4/7] net: ieee802154: mcr20a: " Jinjie Ruan
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 182ba0a8b095..6e0929af0f72 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -821,14 +821,13 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,
 
 	snprintf(r_vec->name, sizeof(r_vec->name),
 		 "%s-rxtx-%d", nfp_net_name(nn), idx);
-	err = request_irq(r_vec->irq_vector, r_vec->handler, 0, r_vec->name,
-			  r_vec);
+	err = request_irq(r_vec->irq_vector, r_vec->handler, IRQF_NO_AUTOEN,
+			  r_vec->name, r_vec);
 	if (err) {
 		nfp_net_napi_del(&nn->dp, r_vec);
 		nn_err(nn, "Error requesting IRQ %d\n", r_vec->irq_vector);
 		return err;
 	}
-	disable_irq(r_vec->irq_vector);
 
 	irq_set_affinity_hint(r_vec->irq_vector, &r_vec->affinity_mask);
 
-- 
2.34.1


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

* [PATCH 4/7] net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
                   ` (2 preceding siblings ...)
  2024-09-09 13:30 ` [PATCH 3/7] nfp: " Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-10  7:32   ` Miquel Raynal
  2024-09-10 10:49   ` Stefan Schmidt
  2024-09-09 13:30 ` [PATCH 5/7] wifi: p54: " Jinjie Ruan
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/ieee802154/mcr20a.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index 433fb5839203..020d392a98b6 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -1302,16 +1302,13 @@ mcr20a_probe(struct spi_device *spi)
 		irq_type = IRQF_TRIGGER_FALLING;
 
 	ret = devm_request_irq(&spi->dev, spi->irq, mcr20a_irq_isr,
-			       irq_type, dev_name(&spi->dev), lp);
+			       irq_type | IRQF_NO_AUTOEN, dev_name(&spi->dev), lp);
 	if (ret) {
 		dev_err(&spi->dev, "could not request_irq for mcr20a\n");
 		ret = -ENODEV;
 		goto free_dev;
 	}
 
-	/* disable_irq by default and wait for starting hardware */
-	disable_irq(spi->irq);
-
 	ret = ieee802154_register_hw(hw);
 	if (ret) {
 		dev_crit(&spi->dev, "ieee802154_register_hw failed\n");
-- 
2.34.1


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

* [PATCH 5/7] wifi: p54: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
                   ` (3 preceding siblings ...)
  2024-09-09 13:30 ` [PATCH 4/7] net: ieee802154: mcr20a: " Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 6/7] wifi: mwifiex: " Jinjie Ruan
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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:
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 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] 13+ messages in thread

* [PATCH 6/7] wifi: mwifiex: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
                   ` (4 preceding siblings ...)
  2024-09-09 13:30 ` [PATCH 5/7] wifi: p54: " Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-09 13:30 ` [PATCH 7/7] wifi: wl1251: " Jinjie Ruan
  2024-09-09 14:39 ` [PATCH 0/7] net: " Kalle Valo
  7 siblings, 0 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 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] 13+ messages in thread

* [PATCH 7/7] wifi: wl1251: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
                   ` (5 preceding siblings ...)
  2024-09-09 13:30 ` [PATCH 6/7] wifi: mwifiex: " Jinjie Ruan
@ 2024-09-09 13:30 ` Jinjie Ruan
  2024-09-09 14:39 ` [PATCH 0/7] net: " Kalle Valo
  7 siblings, 0 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-09 13:30 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey, kvalo,
	briannorris, francesco, set_pte_at, damien.lemoal, ruanjinjie,
	mpe, horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

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] 13+ messages in thread

* Re: [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
                   ` (6 preceding siblings ...)
  2024-09-09 13:30 ` [PATCH 7/7] wifi: wl1251: " Jinjie Ruan
@ 2024-09-09 14:39 ` Kalle Valo
  2024-09-10 11:46   ` Jinjie Ruan
  7 siblings, 1 reply; 13+ messages in thread
From: Kalle Valo @ 2024-09-09 14:39 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey,
	briannorris, francesco, set_pte_at, damien.lemoal, mpe, horms,
	yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

Jinjie Ruan <ruanjinjie@huawei.com> writes:

> 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.
>
> Jinjie Ruan (7):
>   net: apple: bmac: Use IRQF_NO_AUTOEN flag in request_irq()
>   net: enetc: Use IRQF_NO_AUTOEN flag in request_irq()
>   nfp: Use IRQF_NO_AUTOEN flag in request_irq()
>   net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
>   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/ethernet/apple/bmac.c                   | 3 +--
>  drivers/net/ethernet/freescale/enetc/enetc.c        | 3 +--
>  drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++---
>  drivers/net/ieee802154/mcr20a.c                     | 5 +----
>  drivers/net/wireless/intersil/p54/p54spi.c          | 4 +---
>  drivers/net/wireless/marvell/mwifiex/main.c         | 4 ++--
>  drivers/net/wireless/ti/wl1251/sdio.c               | 4 ++--
>  7 files changed, 10 insertions(+), 18 deletions(-)

Wireless patches go to wireless-next, please submit them in a separate
patchset.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

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

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

* Re: [PATCH 4/7] net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 ` [PATCH 4/7] net: ieee802154: mcr20a: " Jinjie Ruan
@ 2024-09-10  7:32   ` Miquel Raynal
  2024-09-10 10:49   ` Stefan Schmidt
  1 sibling, 0 replies; 13+ messages in thread
From: Miquel Raynal @ 2024-09-10  7:32 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, chunkeey, kvalo, briannorris,
	francesco, set_pte_at, damien.lemoal, mpe, horms, yinjun.zhang,
	fei.qin, johannes.berg, ryno.swart, krzysztof.kozlowski, leitao,
	liuxuenetmail, netdev, linux-kernel, oss-drivers, linux-wpan,
	linux-wireless

Hi Jinjie,

ruanjinjie@huawei.com wrote on Mon, 9 Sep 2024 21:30:31 +0800:

> 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: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>

This one could go through wpan(-next), but otherwise:

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

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

* Re: [PATCH 3/7] nfp: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 ` [PATCH 3/7] nfp: " Jinjie Ruan
@ 2024-09-10  9:53   ` Louis Peens
  0 siblings, 0 replies; 13+ messages in thread
From: Louis Peens @ 2024-09-10  9:53 UTC (permalink / raw)
  To: Jinjie Ruan
  Cc: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	stefan, alex.aring, miquel.raynal, chunkeey, kvalo, briannorris,
	francesco, set_pte_at, damien.lemoal, mpe, horms, yinjun.zhang,
	fei.qin, johannes.berg, ryno.swart, krzysztof.kozlowski, leitao,
	liuxuenetmail, netdev, linux-kernel, oss-drivers, linux-wpan,
	linux-wireless

On Mon, Sep 09, 2024 at 09:30:30PM +0800, Jinjie Ruan wrote:
> [Some people who received this message don't often get email from ruanjinjie@huawei.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> 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.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
Hi, thanks for propagating this. For the nfp driver:

Signed-off-by: Louis Peens <louis.peens@corigine.com>

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

* Re: [PATCH 4/7] net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 13:30 ` [PATCH 4/7] net: ieee802154: mcr20a: " Jinjie Ruan
  2024-09-10  7:32   ` Miquel Raynal
@ 2024-09-10 10:49   ` Stefan Schmidt
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Schmidt @ 2024-09-10 10:49 UTC (permalink / raw)
  To: Jinjie Ruan, davem, edumazet, kuba, pabeni, claudiu.manoil,
	vladimir.oltean, louis.peens, alex.aring, miquel.raynal, chunkeey,
	kvalo, briannorris, francesco, set_pte_at, damien.lemoal, mpe,
	horms, yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless

Hello Jinjie Ruan.

On 9/9/24 3:30 PM, 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: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>   drivers/net/ieee802154/mcr20a.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> index 433fb5839203..020d392a98b6 100644
> --- a/drivers/net/ieee802154/mcr20a.c
> +++ b/drivers/net/ieee802154/mcr20a.c
> @@ -1302,16 +1302,13 @@ mcr20a_probe(struct spi_device *spi)
>   		irq_type = IRQF_TRIGGER_FALLING;
>   
>   	ret = devm_request_irq(&spi->dev, spi->irq, mcr20a_irq_isr,
> -			       irq_type, dev_name(&spi->dev), lp);
> +			       irq_type | IRQF_NO_AUTOEN, dev_name(&spi->dev), lp);
>   	if (ret) {
>   		dev_err(&spi->dev, "could not request_irq for mcr20a\n");
>   		ret = -ENODEV;
>   		goto free_dev;
>   	}
>   
> -	/* disable_irq by default and wait for starting hardware */
> -	disable_irq(spi->irq);
> -
>   	ret = ieee802154_register_hw(hw);
>   	if (ret) {
>   		dev_crit(&spi->dev, "ieee802154_register_hw failed\n");


Dave, Eric, Jakub, if you are taking them into net/net-next directly 
here is my ack (and Miquel's review as well).

Acked-by: Stefan Schmidt <stefan@datenfreihafen.org>

regards
Stefan Schmidt

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

* Re: [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq()
  2024-09-09 14:39 ` [PATCH 0/7] net: " Kalle Valo
@ 2024-09-10 11:46   ` Jinjie Ruan
  0 siblings, 0 replies; 13+ messages in thread
From: Jinjie Ruan @ 2024-09-10 11:46 UTC (permalink / raw)
  To: Kalle Valo
  Cc: davem, edumazet, kuba, pabeni, claudiu.manoil, vladimir.oltean,
	louis.peens, stefan, alex.aring, miquel.raynal, chunkeey,
	briannorris, francesco, set_pte_at, damien.lemoal, mpe, horms,
	yinjun.zhang, fei.qin, johannes.berg, ryno.swart,
	krzysztof.kozlowski, leitao, liuxuenetmail, netdev, linux-kernel,
	oss-drivers, linux-wpan, linux-wireless



On 2024/9/9 22:39, Kalle Valo wrote:
> Jinjie Ruan <ruanjinjie@huawei.com> writes:
> 
>> 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.
>>
>> Jinjie Ruan (7):
>>   net: apple: bmac: Use IRQF_NO_AUTOEN flag in request_irq()
>>   net: enetc: Use IRQF_NO_AUTOEN flag in request_irq()
>>   nfp: Use IRQF_NO_AUTOEN flag in request_irq()
>>   net: ieee802154: mcr20a: Use IRQF_NO_AUTOEN flag in request_irq()
>>   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/ethernet/apple/bmac.c                   | 3 +--
>>  drivers/net/ethernet/freescale/enetc/enetc.c        | 3 +--
>>  drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++---
>>  drivers/net/ieee802154/mcr20a.c                     | 5 +----
>>  drivers/net/wireless/intersil/p54/p54spi.c          | 4 +---
>>  drivers/net/wireless/marvell/mwifiex/main.c         | 4 ++--
>>  drivers/net/wireless/ti/wl1251/sdio.c               | 4 ++--
>>  7 files changed, 10 insertions(+), 18 deletions(-)
> 
> Wireless patches go to wireless-next, please submit them in a separate
> patchset.

Thank you very much!

> 

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

end of thread, other threads:[~2024-09-10 11:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 13:30 [PATCH 0/7] net: Use IRQF_NO_AUTOEN flag in request_irq() Jinjie Ruan
2024-09-09 13:30 ` [PATCH 1/7] net: apple: bmac: " Jinjie Ruan
2024-09-09 13:30 ` [PATCH 2/7] net: enetc: " Jinjie Ruan
2024-09-09 13:30 ` [PATCH 3/7] nfp: " Jinjie Ruan
2024-09-10  9:53   ` Louis Peens
2024-09-09 13:30 ` [PATCH 4/7] net: ieee802154: mcr20a: " Jinjie Ruan
2024-09-10  7:32   ` Miquel Raynal
2024-09-10 10:49   ` Stefan Schmidt
2024-09-09 13:30 ` [PATCH 5/7] wifi: p54: " Jinjie Ruan
2024-09-09 13:30 ` [PATCH 6/7] wifi: mwifiex: " Jinjie Ruan
2024-09-09 13:30 ` [PATCH 7/7] wifi: wl1251: " Jinjie Ruan
2024-09-09 14:39 ` [PATCH 0/7] net: " Kalle Valo
2024-09-10 11:46   ` 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).