Bug 201611 - rtl8723bs wifi weak signal, always disconnect
Summary: rtl8723bs wifi weak signal, always disconnect
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Network (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_network@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-03 15:58 UTC by youling257
Modified: 2018-11-09 16:58 UTC (History)
4 users (show)

See Also:
Kernel Version: 4.19
Subsystem:
Regression: No
Bisected commit-id:


Attachments
revert patch (5.14 KB, application/zip)
2018-11-06 08:05 UTC, youling257
Details

Description youling257 2018-11-03 15:58:54 UTC
The router is beside me, but weak signal, how to debug?
Comment 1 Larry Finger 2018-11-03 18:01:47 UTC
I know nothing of the SDIO card or driver. If you can get access to the card, does it have one or two antennas connected? If only one, try moving the antenna to the other connector. Does that help?
Comment 2 youling257 2018-11-03 23:40:16 UTC
(In reply to Larry Finger from comment #1)
> I know nothing of the SDIO card or driver. If you can get access to the
> card, does it have one or two antennas connected? If only one, try moving
> the antenna to the other connector. Does that help?

from drivers/staging/rtl8723bs source code, i need add which one to cc list help me?
Comment 3 youling257 2018-11-03 23:48:35 UTC
The router is beside me,on 4.14.78 signal is well,connect wifi signal well.
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -45.00 dBm
        SSID: YOULING

on 4.19/4.18/4.17 kernel,connect wifi,the router is beside me,signal final 90dbm.
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -78.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -83.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -83.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -85.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -85.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -87.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -88.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -90.00 dBm
        SSID: YOULING
# iw dev wlan0 scan | egrep "SSID|signal"
        signal: -90.00 dBm
        SSID: YOULING
Comment 4 Larry Finger 2018-11-04 00:06:08 UTC
I have no idea why the signal varies so much from scan to scan unless you are in a place with multiple APs all broadcasting the same SSID. To test that, change the command to

sudo iw dev wlp0s20u6 scan | egrep "SSID|signal|\(on"

Post the results.
Comment 5 youling257 2018-11-04 01:58:07 UTC
(In reply to Larry Finger from comment #4)
> I have no idea why the signal varies so much from scan to scan unless you
> are in a place with multiple APs all broadcasting the same SSID. To test
> that, change the command to
> 
> sudo iw dev wlp0s20u6 scan | egrep "SSID|signal|\(on"
> 
> Post the results.

signal Weaker and weaker,can you understand?
only one ssid, router is beside me only 50cm.
Comment 6 youling257 2018-11-04 01:59:52 UTC
(In reply to Larry Finger from comment #4)
> 我不知道为什么信号在扫描到扫描之间变化很大,除非你在一个有多个AP的地方都广播相同的SSID。要测试它,请将命令更改为
> 
> sudo iw dev wlp0s20u6 scan | egrep“SSID | signal | \(on”
> 
> 发布结果。

connect ssid 10 second,signal Weaker and weaker,final 95 -dbm,router is beside me only 50cm.
Comment 7 Larry Finger 2018-11-04 16:30:22 UTC
Then there may be nothing I can do. The strength of the AP is set by the firmware in the AP, not by the driver in the station. As you have seen -45 dBm, that means that the driver is working OK, at least once. One possibility is that the station is too strong. Try moving the computer to a distance of about 2m and try again.

Is there a possibility of trying a different AP?
Comment 8 Srikant Patnaik 2018-11-05 18:31:39 UTC
I too have the same issue, except for the disconnect part.
The wifi signal on rtl8723bs on 4.19rc7 show good strength before connection, but as soon as the connection is established the strength reduces to less than 30% or so, however it doesn't affect the speed or performance. The same router and setup work fine (signal strength > 90%) when I reboot and select my 4.14+ kernel. 

Config file for 4.19rc7: https://gist.github.com/srikantpatnaik/0d78b23345e9a36d022a1139fac0f70c

Dmesg output for 4.19rc7: https://gist.github.com/srikantpatnaik/deecd8adf561e2b5704346aa82ecfe6c

Is it possible to get the correct signal strength on this kernel?
Comment 9 Larry Finger 2018-11-05 21:38:38 UTC
Yes, but someone with the problem will need to bisect between 4.14 and 4.19 to see what commit causes the problem. There are a number of non-trivial changes in kernel 4.17, but I would not know where to look.
Comment 10 youling257 2018-11-06 05:02:18 UTC
checkout df34df483a97b1591a3e90a6941f99fe9f863508, test single low,
checkout 9abf8acea297b4c65f5fa3206e2b8e468e730e84, test single normal,
582 patches,37 patches for rtl8723bs,

git reset --hard 9abf8acea297b4c65f5fa3206e2b8e468e730e84, git am these 37 patches, test single low.

now, find problem on my branch,
$ git format-patch -s 6e5750427e71b729ed46d777e28915adc28d5b35
0001-staging-rtl8723bs-make-myid-function-to-follow-kerne.patch
0002-staging-rtl8723bs-clean-up-conditionals.patch
0003-staging-rtl8723bs-Remove-unneeded-cast.patch
0004-staging-rtl8723bs-use-kmemdup-for-allocation-and-cop.patch
0005-staging-rtl8723bs-fix-u8-less-than-zero-check.patch
0006-staging-rtl8723bs-Remove-unnecessary-semicolon.patch
0007-staging-rtl8723bs-Replace-memset-with-eth_zero_addr.patch
0008-staging-rtl8723bs-core-rtw_cmd-remove-unnecessary-in.patch
0009-Staging-rtl8723bs-static-variables-are-always-0.patch
0010-Staging-rtl8723bs-Remove-unnecessary-braces.patch
0011-Staging-rtl8723bs-clean-up-spaces.patch
0012-Staging-rtl8723bs-Add-blank-line-after-declaration.patch
0013-staging-rtl8723bs-Remove-duplicate-defines.patch
0014-staging-rtl8723bs-Remove-defines-shadowing-enums-in-.patch
0015-staging-rtl8723bs-Replace-RTW_IEEE80211_FCTL_-with-I.patch
0016-staging-rtl8723bs-Replace-RTW_IEEE80211_FTYPE_-with-.patch
0017-staging-rtl8723bs-Replace-RTW_IEEE80211_STYPE_-with-.patch
0018-staging-rtl8723bs-Fix-newlines-in-rtw_wx_set_auth.patch
0019-staging-rtl8723bs-Remove-unecessary-braces-from-swit.patch
0020-staging-rtl8723bs-Remove-braces-from-single-statemen.patch
0021-staging-rtl8723bs-Fix-alignment-in-rtw_wx_set_auth.patch
0022-staging-rtl8723bs-Fix-IEEE80211-authentication-algor.patch
0023-staging-rtl8723bs-Remove-unnecessary-length-define-s.patch
0024-staging-rtl8723bs-Fix-lines-with-trailing-open-paren.patch
0025-staging-rtl8723bs-Add-spaces-around-ternary-operator.patch
0026-staging-rtl8723bs-Add-missing-braces-in-else-stateme.patch
0027-staging-rtl8723bs-Change-camel-case-to-snake-case-in.patch
0028-staging-rtl8723bs-Remove-unnecessary-blank-lines-in-.patch
0029-staging-rtl8723bs-Fix-lines-too-long-in-update_recvf.patch
0030-staging-rtl8723bs-Fix-function-signature-that-goes-o.patch
0031-staging-rtl8723bs-Factor-out-rtl8723bs_recv_tasklet-.patch
0032-staging-rtl8723bs-Replace-NULL-pointer-comparison-wi.patch
0033-staging-rtl8723bs-Rework-struct-_ODM_Per_Pkt_Info_-c.patch
0034-staging-rtl8723bs-Rework-struct-_ODM_Phy_Status_Info.patch
0035-staging-rtl8723bs-Remove-unecessary-newlines-from-od.patch
0036-staging-rtl8723bs-Replace-yield-call-with-cond_resch.patch
0037-staging-rtl8723bs-Remove-yield-call-replace-with-con.patch

$ git reset --hard 0a84d43431a27898b9383cec84d34bab10b437ea
HEAD is now at 0a84d43431a2 staging: rtl8723bs: Remove #defines shadowing enums in 'linux/ieee80211.h' (single normal)
$ git reset --hard 73550e32363332f3a4a0223bf703c8f19b23f08b
HEAD is now at 73550e323633 staging: rtl8723bs: Replace RTW_IEEE80211_STYPE_* with IEEE80211_STYPE_*. (single normal)
$ git reset --hard cb45367a3c3ad84ee3e3b8f1b515750126d814d1
HEAD is now at cb45367a3c3a staging: rtl8723bs: Add spaces around ternary operators. (single normal)
$ git reset --hard 40e24fe89b8102374d05a50b29531232f4377604
HEAD is now at 40e24fe89b81 staging: rtl8723bs: Fix function signature that goes over 80 characters. (single low)
$ git reset --hard 0203a50434e82fa5d85cff8a4d781f4dcdf56680
HEAD is now at 0203a50434e8 staging: rtl8723bs: Change camel case to snake case in 'rtl8723bs_recv.c'. (single normal)
$ git reset --hard 2c3c92cb59fa9131c6f46db3afc0bf8d70406530
HEAD is now at 2c3c92cb59fa staging: rtl8723bs: Fix lines too long in update_recvframe_attrib(). (single low)
$
Comment 11 youling257 2018-11-06 08:05:13 UTC
Created attachment 279331 [details]
revert patch

Revert "staging: rtl8723bs: Factor out rtl8723bs_recv_tasklet() sections."
Revert "staging: rtl8723bs: Fix function signature that goes over 80 characters."
Revert "staging: rtl8723bs: Fix lines too long in update_recvframe_attrib()."

signal normal on 4.20 kernel.
Comment 12 Larry Finger 2018-11-06 15:01:54 UTC
Thanks for the testing. Looking at your attachment and evaluating each of the patches:

1. 0001-Revert-staging-rtl8723bs-Replace-NULL-pointer-compar.patch cannot be causing a problem unless you have a gcc problem.

2. 0002-Revert-staging-rtl8723bs-Factor-out-rtl8723bs_recv_t.patch - I have not analyzed this patch.

3. 0003-Revert-staging-rtl8723bs-Fix-function-signature-that.patch looks OK. It just splits a long line.

4. 0004-Revert-staging-rtl8723bs-Fix-lines-too-long-in-updat.patch - This change has a problem:
The original code

-       pkt_info.bssid_match = ((!IsFrameTypeCtrl(wlanhdr)) &&
-               !pattrib->icv_err && !pattrib->crc_err &&
-               !memcmp(get_hdr_bssid(wlanhdr), get_bssid(&padapter->mlmepriv), ETH_ALEN));

was replaced by

+       pkt_info.bssid_match = ((!IsFrameTypeCtrl(wlanhdr)) &&
+                               !pattrib->icv_err && !pattrib->crc_err &&
+                               !ether_addr_equal(rx_bssid, my_bssid));

The problem is that memcmp() returns 0 (or false) when the two items are equal, whereas ether_addr_equal() returns true when the items are equal.

The following patch will fix that problem:

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index 85077947b9b8..d2b9d99ac480 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -109,7 +109,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe,
        rx_bssid = get_hdr_bssid(wlanhdr);
        pkt_info.bssid_match = ((!IsFrameTypeCtrl(wlanhdr)) &&
                                !pattrib->icv_err && !pattrib->crc_err &&
-                               !ether_addr_equal(rx_bssid, my_bssid));
+                               ether_addr_equal(rx_bssid, my_bssid));
 
        rx_ra = get_ra(wlanhdr);
        my_hwaddr = myid(&padapter->eeprompriv);

The white space will be corrupted in the above listing, thus you will need to do the edit, but removing one character should not be a problem. :)

After the above one character change, does the driver function correctly, or do I need to look harder at #2?
Comment 13 youling257 2018-11-06 16:26:11 UTC
(In reply to Larry Finger from comment #12)

> The following patch will fix that problem:
> 
> diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
> b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
> index 85077947b9b8..d2b9d99ac480 100644
> --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
> +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
> @@ -109,7 +109,7 @@ static void update_recvframe_phyinfo(union recv_frame
> *precvframe,
>         rx_bssid = get_hdr_bssid(wlanhdr);
>         pkt_info.bssid_match = ((!IsFrameTypeCtrl(wlanhdr)) &&
>                                 !pattrib->icv_err && !pattrib->crc_err &&
> -                               !ether_addr_equal(rx_bssid, my_bssid));
> +                               ether_addr_equal(rx_bssid, my_bssid));
>  
>         rx_ra = get_ra(wlanhdr);
>         my_hwaddr = myid(&padapter->eeprompriv);
> 
> The white space will be corrupted in the above listing, thus you will need
> to do the edit, but removing one character should not be a problem. :)
> 
> After the above one character change, does the driver function correctly, or
> do I need to look harder at #2?

Yes,only the above one character change, signal normal.
Comment 14 Larry Finger 2018-11-07 01:41:39 UTC
Thank you for testing. Do you want to prepare the patch for the kernel, or should I? If the latter, is it OK to list your name and E-mail in a "reported-and-tested-by" line?
Comment 15 youling257 2018-11-07 01:53:48 UTC
(In reply to Larry Finger from comment #14)
> Thank you for testing. Do you want to prepare the patch for the kernel, or
> should I? If the latter, is it OK to list your name and E-mail in a
> "reported-and-tested-by" line?

Reported-and-tested-by: youling257 <youling257@gmail.com>
Comment 16 Larry Finger 2018-11-07 02:01:55 UTC
I need a first and last name, not a "screen" name. That name can be an anglicized form if that is what you want, or a formal name.
Comment 18 youling257 2018-11-08 03:53:20 UTC
Hi,Larry Finger
my userspace scan wifi signal request NL80211_STA_INFO_TX_FAILED support,
so i make a patch, my userspace scan wifi signal seem OK.

Subject: [PATCH] add NL80211_STA_INFO_TX_FAILED support

---
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index af2234798fa8..637684b93828 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1278,6 +1278,8 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
 		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
 		sinfo->tx_packets = psta->sta_stats.tx_pkts;
 
+		sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
+
 	}
 
 	/* for Ad-Hoc/AP mode */
-- 
2.19.1

if you think my patch right, can you add detail and subject it?

btw,only these has NL80211_STA_INFO_TX_FAILED
https://elixir.bootlin.com/linux/latest/ident/NL80211_STA_INFO_TX_FAILED
Comment 19 Srikant Patnaik 2018-11-08 04:11:15 UTC
(In reply to youling257 from comment #18)
> Hi,Larry Finger
> my userspace scan wifi signal request NL80211_STA_INFO_TX_FAILED support,
> so i make a patch, my userspace scan wifi signal seem OK.
> 
> Subject: [PATCH] add NL80211_STA_INFO_TX_FAILED support
> 
> ---
>  drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index af2234798fa8..637684b93828 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> @@ -1278,6 +1278,8 @@ static int cfg80211_rtw_get_station(struct wiphy
> *wiphy,
>               sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
>               sinfo->tx_packets = psta->sta_stats.tx_pkts;
>  
> +             sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
> +
>       }
>  
>       /* for Ad-Hoc/AP mode */
> -- 
> 2.19.1
> 
> if you think my patch right, can you add detail and subject it?
> 
> btw,only these has NL80211_STA_INFO_TX_FAILED
> https://elixir.bootlin.com/linux/latest/ident/NL80211_STA_INFO_TX_FAILED


How do I reproduce this? I'm using Debian-9 and my userspace wifi signal seem fine even after adding that "single" character patch to 4.19.1. 
Do I need this patch as well?
Comment 20 youling257 2018-11-08 04:33:27 UTC
my userspace is Androidx86 7.1 and 8.1, run Android on Linux mainline kernel.
comment 10 and 11, i tested on Androidx86 7.1, not need wificond.
but Android 8 wificond,
wificond: failed to get nl80211_sta_info_tx_failed
WificondControl: Invalid signal poll result from wificond
Comment 21 youling257 2018-11-08 04:37:22 UTC
this is Android wificond problem, impossible every wifi driver all support "NL80211_STA_INFO_TX_FAILED".
Comment 22 Srikant Patnaik 2018-11-08 05:35:00 UTC
Ok, got it. By the way, your previous fix works fine, I now have the normal wifi signal.
Comment 23 Larry Finger 2018-11-08 19:49:18 UTC
Yes, I will prepare a patch.

Do I understand correctly that the fix is needed for Android 8? Does it cause any problems if this change is used with 7.1? What kernel is used with Android 8?
Comment 24 youling257 2018-11-09 02:00:53 UTC
(In reply to Larry Finger from comment #23)
> Yes, I will prepare a patch.
> 
> Do I understand correctly that the fix is needed for Android 8? Does it
> cause any problems if this change is used with 7.1? What kernel is used with
> Android 8?

Android 8 need NL80211_STA_INFO_TX_FAILED, no any effect on Android 7,
google Android 8 used 4.9 lts, google Android 9 used 4.14 lts.
Androidx86 project used 4.18/4.19 kernel.
Comment 25 Larry Finger 2018-11-09 16:58:24 UTC
The fix for Android is queued for inclusion.

Note You need to log in before you can comment on or make changes to this bug.