Bug#869084: linux-image-4.12.0-trunk-amd64: rtl8723be fails to work with old firmware

2017-08-05 Thread Sven Joachim
Control: tags -1 + patch

On 2017-07-28 13:29 +0200, Sven Joachim wrote:

> Control: forwarded -1 
> https://marc.info/?l=linux-wireless=150124050420053=2
>
> On 2017-07-20 13:54 +0200, Sven Joachim wrote:
>
>> Package: src:linux
>> Version: 4.12.2-1~exp1
>> Severity: important
>>
>> As of commit f70e4df2b384d21e36a7c30a591639592692e0ec, the rtl8723be
>> driver uses a new firmware file rtlwifi/rtl8723befw_36.bin which is not
>> packaged for Debian yet.  There is fallback code to load the old
>> firmware file rtlwifi/rtl8723befw.bin, but does not seem to work, for
>> the wifi fails to come up on my laptop. :-(
>
> AFAICS the problem is that request_firmware_nowait() does not wait for
> the firmware to show up and returns 0 even if the file is not there, so
> the code to load the fallback file will never be reached.
>
> I have reported this upstream now.

And even managed to come up with a patch that got accepted in the
wireless-drivers-next tree[1].  It does not apply to 4.12, therefore I
have attached a version which does.  Alternatively you could cherry-pick
commit f2764f61fa10 ("rtlwifi: Fix memory leak when firmware request
fails")[2] before it.

Cheers,
   Sven


1. 
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=1d9b168d8ea9a0f51947d0e2f84856e77d2fe7ff

2. 
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git/commit/?id=f2764f61fa10593204b0c5e4e9a68dba02112e50

>From 6fff98234b7a25b717714a9a504d1ca805765ef1 Mon Sep 17 00:00:00 2001
From: Sven Joachim 
Date: Sat, 29 Jul 2017 11:10:13 +0200
Subject: [PATCH] rtlwifi: Fix fallback firmware loading

Commit f70e4df2b384 ("rtlwifi: Add code to read new versions of
firmware") added code to load an old firmware file if the new one is
not available.  Unfortunately that code is never reached because
request_firmware_nowait() does not wait for the firmware to show up
and returns 0 even if the file is not there.

Use the existing fallback mechanism introduced by commit 62009b7f1279
("rtlwifi: rtl8192cu: Add new firmware") instead.

Fixes: f70e4df2b384 ("rtlwifi: Add code to read new versions of firmware")
Cc: sta...@vger.kernel.org
Signed-off-by: Sven Joachim 
---
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 13 +++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 13 +++--
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
index 8c0ac96b5430..c781105a8524 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
@@ -187,16 +187,8 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw)
   rtlpriv->io.dev, GFP_KERNEL, hw,
   rtl_fw_cb);
 	if (err) {
-		/* Failed to get firmware. Check if old version available */
-		fw_name = "rtlwifi/rtl8723befw.bin";
-		pr_info("Using firmware %s\n", fw_name);
-		err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
-	  rtlpriv->io.dev, GFP_KERNEL, hw,
-	  rtl_fw_cb);
-		if (err) {
-			pr_err("Failed to request firmware!\n");
-			return 1;
-		}
+		pr_err("Failed to request firmware!\n");
+		return 1;
 	}
 	return 0;
 }
@@ -287,6 +279,7 @@ static const struct rtl_hal_cfg rtl8723be_hal_cfg = {
 	.bar_id = 2,
 	.write_readback = true,
 	.name = "rtl8723be_pci",
+	.alt_fw_name = "rtlwifi/rtl8723befw.bin",
 	.ops = _hal_ops,
 	.mod_params = _mod_params,
 	.maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
index abaf34cb1433..bc6dcac34924 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c
@@ -214,16 +214,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
   rtlpriv->io.dev, GFP_KERNEL, hw,
   rtl_fw_cb);
 	if (err) {
-		/* Failed to get firmware. Check if old version available */
-		fw_name = "rtlwifi/rtl8821aefw.bin";
-		pr_info("Using firmware %s\n", fw_name);
-		err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
-	  rtlpriv->io.dev, GFP_KERNEL, hw,
-	  rtl_fw_cb);
-		if (err) {
-			pr_err("Failed to request normal firmware!\n");
-			return 1;
-		}
+		pr_err("Failed to request normal firmware!\n");
+		return 1;
 	}
 	/*load wowlan firmware*/
 	pr_info("Using firmware %s\n", wowlan_fw_name);
@@ -325,6 +317,7 @@ static const struct rtl_hal_cfg rtl8821ae_hal_cfg = {
 	.bar_id = 2,
 	.write_readback = true,
 	.name = "rtl8821ae_pci",
+	.alt_fw_name = "rtlwifi/rtl8821aefw.bin",
 	.ops = _hal_ops,
 	.mod_params = _mod_params,
 	.maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
-- 
2.13.3



Bug#869084: linux-image-4.12.0-trunk-amd64: rtl8723be fails to work with old firmware

2017-07-28 Thread Sven Joachim
Control: forwarded -1 https://marc.info/?l=linux-wireless=150124050420053=2

On 2017-07-20 13:54 +0200, Sven Joachim wrote:

> Package: src:linux
> Version: 4.12.2-1~exp1
> Severity: important
>
> As of commit f70e4df2b384d21e36a7c30a591639592692e0ec, the rtl8723be
> driver uses a new firmware file rtlwifi/rtl8723befw_36.bin which is not
> packaged for Debian yet.  There is fallback code to load the old
> firmware file rtlwifi/rtl8723befw.bin, but does not seem to work, for
> the wifi fails to come up on my laptop. :-(

AFAICS the problem is that request_firmware_nowait() does not wait for
the firmware to show up and returns 0 even if the file is not there, so
the code to load the fallback file will never be reached.

I have reported this upstream now.

Cheers,
   Sven



Bug#869084: linux-image-4.12.0-trunk-amd64: rtl8723be fails to work with old firmware

2017-07-20 Thread Sven Joachim
Package: src:linux
Version: 4.12.2-1~exp1
Severity: important

As of commit f70e4df2b384d21e36a7c30a591639592692e0ec, the rtl8723be
driver uses a new firmware file rtlwifi/rtl8723befw_36.bin which is not
packaged for Debian yet.  There is fallback code to load the old
firmware file rtlwifi/rtl8723befw.bin, but does not seem to work, for
the wifi fails to come up on my laptop. :-(


-- Package-specific info:
** Version:
Linux version 4.12.0-trunk-amd64 (debian-ker...@lists.debian.org) (gcc version 
6.4.0 20170704 (Debian 6.4.0-1) ) #1 SMP Debian 4.12.2-1~exp1 (2017-07-18)

** Command line:
BOOT_IMAGE=/boot/vmlinuz-4.12.0-trunk-amd64 
root=UUID=54317940-5e45-4370-8f77-153d1b67ca31 ro quiet

** Not tainted

** Kernel log:
[  917.542154]  ? rcu_dump_cpu_stacks+0x99/0xd0
[  917.542160]  ? rcu_check_callbacks+0x78b/0x8e0
[  917.542167]  ? update_wall_time+0x486/0x750
[  917.542174]  ? tick_sched_handle.isra.15+0x50/0x50
[  917.542179]  ? update_process_times+0x28/0x50
[  917.542185]  ? tick_sched_handle.isra.15+0x20/0x50
[  917.542190]  ? tick_sched_timer+0x38/0x70
[  917.542195]  ? __hrtimer_run_queues+0xdc/0x220
[  917.542200]  ? hrtimer_interrupt+0xa6/0x1f0
[  917.542208]  ? smp_apic_timer_interrupt+0x34/0x50
[  917.542213]  ? apic_timer_interrupt+0x82/0x90
[  917.542215]  
[  917.542223]  ? delay_tsc+0x21/0x50
[  917.542236]  ? rtl8723_fw_free_to_go+0x98/0x110 [rtl8723_common]
[  917.542243]  ? rtl8723_download_fw+0xb6/0x150 [rtl8723_common]
[  917.542254]  ? rtl8723be_hw_init+0xc6c/0x1760 [rtl8723be]
[  917.542268]  ? rtl_ps_enable_nic+0x29/0x90 [rtlwifi]
[  917.542277]  ? rtl8723be_phy_set_rf_power_state+0x337/0x370 [rtl8723be]
[  917.542288]  ? rtl_ps_set_rf_state+0xb6/0x140 [rtlwifi]
[  917.542299]  ? _rtl_ps_inactive_ps+0x36/0xb0 [rtlwifi]
[  917.542309]  ? rtl_ips_nic_on+0x7b/0xb0 [rtlwifi]
[  917.542320]  ? rtl_op_config+0x1cc/0x390 [rtlwifi]
[  917.542369]  ? ieee80211_hw_config+0x85/0x350 [mac80211]
[  917.542412]  ? __ieee80211_start_scan+0x1f6/0x6a0 [mac80211]
[  917.542455]  ? ieee80211_request_scan+0x2b/0x50 [mac80211]
[  917.542507]  ? nl80211_trigger_scan+0x317/0x7a0 [cfg80211]
[  917.542515]  ? genl_family_rcv_msg+0x1e0/0x380
[  917.542521]  ? compat_poll_select_copy_remaining+0x120/0x120
[  917.542528]  ? genl_rcv_msg+0x47/0x90
[  917.542532]  ? genl_family_rcv_msg+0x380/0x380
[  917.542536]  ? netlink_rcv_skb+0xe7/0x120
[  917.542541]  ? genl_rcv+0x24/0x40
[  917.542544]  ? netlink_unicast+0x184/0x230
[  917.542549]  ? netlink_sendmsg+0x2b8/0x3a0
[  917.542557]  ? sock_sendmsg+0x30/0x40
[  917.542562]  ? ___sys_sendmsg+0x2d7/0x2f0
[  917.542568]  ? core_sys_select+0x211/0x2b0
[  917.542576]  ? SYSC_recvfrom+0xc3/0x130
[  917.542581]  ? ktime_get_ts64+0x49/0xe0
[  917.542586]  ? __sys_sendmsg+0x51/0x90
[  917.542589]  ? __sys_sendmsg+0x51/0x90
[  917.542596]  ? system_call_fast_compare_end+0xc/0x97
[  925.616165] rtl8723_common: Polling FW ready fail!! REG_MCUFWDL:0x0006 .
[  925.622859] rtl8723_common: Firmware is not ready to run!
[  953.972286] INFO: rcu_sched self-detected stall on CPU
[  953.979117]  1-...: (5249 ticks this GP) idle=e0a/141/0 
softirq=4410/4410 fqs=2625 
[  953.986070]   (t=5250 jiffies g=2057 c=2056 q=30)
[  953.992961] NMI backtrace for cpu 1
[  953.992968] CPU: 1 PID: 1980 Comm: wpa_supplicant Not tainted 
4.12.0-trunk-amd64 #1 Debian 4.12.2-1~exp1
[  953.992970] Hardware name: HP HP Notebook/81F5, BIOS F.08 04/21/2016
[  953.992973] Call Trace:
[  953.992979]  
[  953.992989]  ? dump_stack+0x5c/0x84
[  953.992995]  ? nmi_cpu_backtrace+0x89/0x90
[  953.993003]  ? irq_force_complete_move+0x140/0x140
[  953.993009]  ? nmi_trigger_cpumask_backtrace+0xf4/0x120
[  953.993016]  ? rcu_dump_cpu_stacks+0x99/0xd0
[  953.993023]  ? rcu_check_callbacks+0x78b/0x8e0
[  953.993028]  ? update_wall_time+0x486/0x750
[  953.993035]  ? tick_sched_handle.isra.15+0x50/0x50
[  953.993040]  ? update_process_times+0x28/0x50
[  953.993046]  ? tick_sched_handle.isra.15+0x20/0x50
[  953.993051]  ? tick_sched_timer+0x38/0x70
[  953.993056]  ? __hrtimer_run_queues+0xdc/0x220
[  953.993061]  ? hrtimer_interrupt+0xa6/0x1f0
[  953.993069]  ? smp_apic_timer_interrupt+0x34/0x50
[  953.993074]  ? apic_timer_interrupt+0x82/0x90
[  953.993076]  
[  953.993083]  ? delay_tsc+0x1f/0x50
[  953.993096]  ? rtl8723_fw_free_to_go+0x98/0x110 [rtl8723_common]
[  953.993103]  ? rtl8723_download_fw+0xb6/0x150 [rtl8723_common]
[  953.993114]  ? rtl8723be_hw_init+0xc6c/0x1760 [rtl8723be]
[  953.993128]  ? rtl_ps_enable_nic+0x29/0x90 [rtlwifi]
[  953.993137]  ? rtl8723be_phy_set_rf_power_state+0x337/0x370 [rtl8723be]
[  953.993148]  ? rtl_ps_set_rf_state+0xb6/0x140 [rtlwifi]
[  953.993159]  ? _rtl_ps_inactive_ps+0x36/0xb0 [rtlwifi]
[  953.993170]  ? rtl_ips_nic_on+0x7b/0xb0 [rtlwifi]
[  953.993180]  ? rtl_op_config+0x1cc/0x390 [rtlwifi]
[  953.993230]  ? ieee80211_hw_config+0x85/0x350 [mac80211]
[  953.993273]  ? __ieee80211_start_scan+0x1f6/0x6a0 [mac80211]
[  953.993315]  ?