Search Linux Wireless

[PATCH] wfx: avoid flush_workqueue(system_highpri_wq) usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Flushing system-wide workqueues is dangerous and will be forbidden.
Replace system_highpri_wq with local wfx_wq.

While we are at it, add missing spi_unregister_driver() call when
sdio_register_driver() failed.

Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
Note: This patch is only compile tested.

 drivers/net/wireless/silabs/wfx/bh.c     |  6 +++---
 drivers/net/wireless/silabs/wfx/hif_tx.c |  2 +-
 drivers/net/wireless/silabs/wfx/main.c   | 11 +++++++++++
 drivers/net/wireless/silabs/wfx/wfx.h    |  2 ++
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/silabs/wfx/bh.c b/drivers/net/wireless/silabs/wfx/bh.c
index bcea9d5b119c..377dd8b010e2 100644
--- a/drivers/net/wireless/silabs/wfx/bh.c
+++ b/drivers/net/wireless/silabs/wfx/bh.c
@@ -267,7 +267,7 @@ void wfx_bh_request_rx(struct wfx_dev *wdev)
 	wfx_control_reg_read(wdev, &cur);
 	prev = atomic_xchg(&wdev->hif.ctrl_reg, cur);
 	complete(&wdev->hif.ctrl_ready);
-	queue_work(system_highpri_wq, &wdev->hif.bh);
+	queue_work(wfx_wq, &wdev->hif.bh);
 
 	if (!(cur & CTRL_NEXT_LEN_MASK))
 		dev_err(wdev->dev, "unexpected control register value: length field is 0: %04x\n",
@@ -280,7 +280,7 @@ void wfx_bh_request_rx(struct wfx_dev *wdev)
 /* Driver want to send data */
 void wfx_bh_request_tx(struct wfx_dev *wdev)
 {
-	queue_work(system_highpri_wq, &wdev->hif.bh);
+	queue_work(wfx_wq, &wdev->hif.bh);
 }
 
 /* If IRQ is not available, this function allow to manually poll the control register and simulate
@@ -295,7 +295,7 @@ void wfx_bh_poll_irq(struct wfx_dev *wdev)
 	u32 reg;
 
 	WARN(!wdev->poll_irq, "unexpected IRQ polling can mask IRQ");
-	flush_workqueue(system_highpri_wq);
+	flush_workqueue(wfx_wq);
 	start = ktime_get();
 	for (;;) {
 		wfx_control_reg_read(wdev, &reg);
diff --git a/drivers/net/wireless/silabs/wfx/hif_tx.c b/drivers/net/wireless/silabs/wfx/hif_tx.c
index 9c653d0e9034..85c68b1b11c4 100644
--- a/drivers/net/wireless/silabs/wfx/hif_tx.c
+++ b/drivers/net/wireless/silabs/wfx/hif_tx.c
@@ -73,7 +73,7 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct wfx_hif_msg *request,
 
 	if (no_reply) {
 		/* Chip won't reply. Ensure the wq has send the buffer before to continue. */
-		flush_workqueue(system_highpri_wq);
+		flush_workqueue(wfx_wq);
 		ret = 0;
 		goto end;
 	}
diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
index e575a81ca2ca..d3d18c498dd0 100644
--- a/drivers/net/wireless/silabs/wfx/main.c
+++ b/drivers/net/wireless/silabs/wfx/main.c
@@ -40,6 +40,8 @@ MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WF200");
 MODULE_AUTHOR("J辿r担me Pouiller <jerome.pouiller@xxxxxxxxxx>");
 MODULE_LICENSE("GPL");
 
+struct workqueue_struct *wfx_wq;
+
 #define RATETAB_ENT(_rate, _rateid, _flags) { \
 	.bitrate  = (_rate),   \
 	.hw_value = (_rateid), \
@@ -473,10 +475,18 @@ static int __init wfx_core_init(void)
 {
 	int ret = 0;
 
+	wfx_wq = alloc_workqueue("wfx_wq", WQ_HIGHPRI, 0);
+	if (!wfx_wq)
+		return -ENOMEM;
 	if (IS_ENABLED(CONFIG_SPI))
 		ret = spi_register_driver(&wfx_spi_driver);
 	if (IS_ENABLED(CONFIG_MMC) && !ret)
 		ret = sdio_register_driver(&wfx_sdio_driver);
+	if (ret) {
+		if (IS_ENABLED(CONFIG_SPI))
+			spi_unregister_driver(&wfx_spi_driver);
+		destroy_workqueue(wfx_wq);
+	}
 	return ret;
 }
 module_init(wfx_core_init);
@@ -487,5 +497,6 @@ static void __exit wfx_core_exit(void)
 		sdio_unregister_driver(&wfx_sdio_driver);
 	if (IS_ENABLED(CONFIG_SPI))
 		spi_unregister_driver(&wfx_spi_driver);
+	destroy_workqueue(wfx_wq);
 }
 module_exit(wfx_core_exit);
diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h
index 6594cc647c2f..ea0ba002eb1f 100644
--- a/drivers/net/wireless/silabs/wfx/wfx.h
+++ b/drivers/net/wireless/silabs/wfx/wfx.h
@@ -159,4 +159,6 @@ static inline int memzcmp(void *src, unsigned int size)
 	return memcmp(buf, buf + 1, size - 1);
 }
 
+extern struct workqueue_struct *wfx_wq;
+
 #endif
-- 
2.34.1





[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux