Skip to contentSkip to conversation

wifi: mwifiex: fix freeze for 60 seconds caused by request_firmware

PATCH Applied Georgi Valkov 4 participants 8 messages Jul 12 – Jul 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mwifiex: fix freeze for 60 seconds caused by request_firmware

Fix regression in rgpower table loading, caused by using request_firmware(): when the requested firmware does not exist, e.g. nxp/rgpower_WW.bin does not exist on OpenWRT builds for WRT3200ACM, request_firmware() falls back to firmware_fallback_sysfs(), which expects the firmware to be provided by user space using SYSFS. No such utility is provided in this configuration, so the entire system locks up for 60 seconds, until the request times out. During this time, no other log messages are observed, and the device does not respond to commands over UART.

The request_firmware() call is performed in the following context:
current->comm kworker/1:2 in_task 1 irqs_disabled 0 in_atomic 0

Fixed by using request_firmware_direct(). This prevents fallback to SYSFS, and avoids delay. The rgpower table is optional. The driver falls back to the device tree power table if the firmware is not present.

The error code is printed for debugging and returned to the caller, which only cares for success or failure, so there are no side effects.

Fixes 7b6f16a25806 ("wifi: mwifiex: add rgpower table loading support")
---
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +8 -6
index a6550548d3b4..9460d5352b23 100644
@@ -196,6 +196,7 @@ static int mwifiex_request_rgpower_table(struct mwifiex_private *priv)
 	struct mwifiex_adapter *adapter = priv->adapter;
 	char rgpower_table_name[30];
 	char country_code[3];
+	int ret;
 
 	strscpy(country_code, domain_info->country_code, sizeof(country_code));
 
@@ -214,16 +215,17 @@ static int mwifiex_request_rgpower_table(struct mwifiex_private *priv)
 		adapter->rgpower_data = NULL;
 	}
 
-	if ((request_firmware(&adapter->rgpower_data, rgpower_table_name,
-			      adapter->dev))) {
+	ret = request_firmware_direct(&adapter->rgpower_data, rgpower_table_name,
+				      adapter->dev);
+
+	if (ret) {
 		mwifiex_dbg(
 			adapter, INFO,
-			"info: %s: failed to request regulatory power table\n",
-			__func__);
-		return -EIO;
+			"info: %s: failed to request regulatory power table: %d\n",
+			__func__, ret);
 	}
 
-	return 0;
+	return ret;
 }
 
 static int mwifiex_dnld_rgpower_table(struct mwifiex_private *priv)
Signature · 1 line
2.55.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Georgi Valkov

Fix regression in rgpower table loading, caused by using request_firmware(): when the requested firmware does not exist, e.g. nxp/rgpower_WW.bin does not exist on OpenWRT builds for WRT3200ACM, request_firmware() falls back to firmware_fallback_sysfs(), which expects the firmware to be provided by user space using SYSFS. No such utility is provided in this configuration, so the entire system locks up for 60 seconds, until the request times out. During this time, no other log messages are observed, and the device does not respond to commands over UART.

The request_firmware() call is performed in the following context:
current->comm kworker/1:2 in_task 1 irqs_disabled 0 in_atomic 0

Fixed by using request_firmware_direct(). This prevents fallback to SYSFS, and avoids delay. The rgpower table is optional. The driver falls back to the device tree power table if the firmware is not present.

Quoted 5 lines

The error code is printed for debugging and returned to the caller, which only cares for success or failure, so there are no side effects.

Fixes 7b6f16a25806 ("wifi: mwifiex: add rgpower table loading support")
#2 lore raw

Please backport to 6.18 and 6.12, which are used by OpenWrt. Initially I did not know that I could insert
free text between the commit message and the patch.
I apologise for that. I am still learning how to use git send-mail.

Quoted 27 lines · Francesco Dolcini
Quoted 17 lines · Georgi Valkov

Fix regression in rgpower table loading, caused by using request_firmware(): when the requested firmware does not exist, e.g. nxp/rgpower_WW.bin does not exist on OpenWRT builds for WRT3200ACM, request_firmware() falls back to firmware_fallback_sysfs(), which expects the firmware to be provided by user space using SYSFS. No such utility is provided in this configuration, so the entire system locks up for 60 seconds, until the request times out. During this time, no other log messages are observed, and the device does not respond to commands over UART.

The request_firmware() call is performed in the following context:
current->comm kworker/1:2 in_task 1 irqs_disabled 0 in_atomic 0

Fixed by using request_firmware_direct(). This prevents fallback to SYSFS, and avoids delay. The rgpower table is optional. The driver falls back to the device tree power table if the firmware is not present.

Quoted 5 lines

The error code is printed for debugging and returned to the caller, which only cares for success or failure, so there are no side effects.

Fixes 7b6f16a25806 ("wifi: mwifiex: add rgpower table loading support")
#3 lore raw
Quoted 4 lines · George Valkov

Please backport to 6.18 and 6.12, which are used by OpenWrt. Initially I did not know that I could insert
free text between the commit message and the patch.
I apologise for that. I am still learning how to use git send-mail.

Please see Documentation/process/stable-kernel-rules.rst It should explain everything you need on this regard.

Francesco

#4 lore raw

Thank you! Note taken and I will try to do better when I submit my last planned patch for this driver, soon. I wanted to collect opinions from OpenWrt members first.

Georgi

Quoted 12 lines · Francesco Dolcini
Quoted 4 lines · George Valkov

Please backport to 6.18 and 6.12, which are used by OpenWrt. Initially I did not know that I could insert
free text between the commit message and the patch.
I apologise for that. I am still learning how to use git send-mail.

Please see Documentation/process/stable-kernel-rules.rst It should explain everything you need on this regard.

Francesco

#5 lore raw

Any update on the progress? Do I need to do or change anything?

Quoted 20 lines · George Valkov

Thank you! Note taken and I will try to do better when I submit my last planned patch for this driver, soon. I wanted to collect opinions from OpenWrt members first.

Georgi

Quoted 12 lines · Francesco Dolcini
Quoted 4 lines · George Valkov

Please backport to 6.18 and 6.12, which are used by OpenWrt. Initially I did not know that I could insert
free text between the commit message and the patch.
I apologise for that. I am still learning how to use git send-mail.

Please see Documentation/process/stable-kernel-rules.rst It should explain everything you need on this regard.

Francesco

maintainer Applied
#6 lore raw
Quoted 1 line · George Valkov

Any update on the progress? Do I need to do or change anything?

Queued for 6.18 and 7.1, thanks - nothing more needed from you.

Signature · 2 lines
Thanks,
Sasha
Reviewed-by on v1 1/1
#7 lore raw
In reply to Georgi Valkov

Hi Georgi,

thank you for the fix!

Quoted 17 lines · Georgi Valkov

Fix regression in rgpower table loading, caused by using request_firmware(): when the requested firmware does not exist, e.g. nxp/rgpower_WW.bin does not exist on OpenWRT builds for WRT3200ACM, request_firmware() falls back to firmware_fallback_sysfs(), which expects the firmware to be provided by user space using SYSFS. No such utility is provided in this configuration, so the entire system locks up for 60 seconds, until the request times out. During this time, no other log messages are observed, and the device does not respond to commands over UART.

The request_firmware() call is performed in the following context:
current->comm kworker/1:2 in_task 1 irqs_disabled 0 in_atomic 0

Fixed by using request_firmware_direct(). This prevents fallback to SYSFS, and avoids delay. The rgpower table is optional. The driver falls back to the device tree power table if the firmware is not present.

Quoted 5 lines

The error code is printed for debugging and returned to the caller, which only cares for success or failure, so there are no side effects.

Fixes 7b6f16a25806 ("wifi: mwifiex: add rgpower table loading support")
Quoted 40 lines
---
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +8 -6
index a6550548d3b4..9460d5352b23 100644
@@ -196,6 +196,7 @@ static int mwifiex_request_rgpower_table(struct mwifiex_private *priv)
 	struct mwifiex_adapter *adapter = priv->adapter;
 	char rgpower_table_name[30];
 	char country_code[3];
+	int ret;
 
 	strscpy(country_code, domain_info->country_code, sizeof(country_code));
 
@@ -214,16 +215,17 @@ static int mwifiex_request_rgpower_table(struct mwifiex_private *priv)
 		adapter->rgpower_data = NULL;
 	}
 
-	if ((request_firmware(&adapter->rgpower_data, rgpower_table_name,
-			      adapter->dev))) {
+	ret = request_firmware_direct(&adapter->rgpower_data, rgpower_table_name,
+				      adapter->dev);
+
+	if (ret) {
 		mwifiex_dbg(
 			adapter, INFO,
-			"info: %s: failed to request regulatory power table\n",
-			__func__);
-		return -EIO;
+			"info: %s: failed to request regulatory power table: %d\n",
+			__func__, ret);
 	}
 
-	return 0;
+	return ret;
 }
 
 static int mwifiex_dnld_rgpower_table(struct mwifiex_private *priv)
Signature · 4 lines
Pengutronix e.K.                       | Stefan Kerkmann             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |