Bug 112571

Summary: Regression in 4.5 RCs, SDIO wifi card is not detected in Baytrail tablet
Product: Drivers Reporter: Laszlo Fiat (laszlo.fiat)
Component: MMC/SDAssignee: drivers_mmc-sd
Status: RESOLVED CODE_FIX    
Severity: normal CC: chris, darlor, jjmeijer88, marc.epost, paul+kernel.org, rhowell, russianneuromancer
Priority: P1    
Hardware: Intel   
OS: Linux   
Kernel Version: 4.5.0, 4.6rc Subsystem:
Regression: Yes Bisected commit-id:
Attachments: dmesg of v4.5-rc4
dmesg of 4.5.0 with reverted patch. It works OK. See comment #3 and #5.
dmesg of v4.6.0-rc2 with extra patch-still no SDIO Wifi
dmesg of v4.6.0-rc2 with extra patch-still no SDIO Wifi
dmesg-4.6-rc3-mmc-debug-no-patches.txt
dmesg-4.6-rc3-mmc-debug-no-patches-working-case.txt
acpidump of Teclast X80h Baytrail-T tablet
mmc: sdhci-acpi: Ensure connected devices are powered on before probing

Description Laszlo Fiat 2016-02-16 19:21:52 UTC
Created attachment 203761 [details]
dmesg of v4.5-rc4

V4.0-4.4 kernels worked nicely:

$ grep mmc dmesg-4.4.0-rc2-next-20151127.txt 
[    2.421329] mmc0: SDHCI controller on ACPI [80860F14:00] using ADMA
[    2.425847] mmc1: SDHCI controller on ACPI [INT33BB:00] using ADMA
[    2.431164] mmc2: SDHCI controller on ACPI [80860F14:02] using ADMA
[    2.561342] mmc0: MAN_BKOPS_EN bit is not set
[    2.569496] mmc0: new HS200 MMC card at address 0001
[    2.571164] mmcblk0: mmc0:0001 032GE4 29.1 GiB 
[    2.571453] mmcblk0boot0: mmc0:0001 032GE4 partition 1 4.00 MiB
[    2.571655] mmcblk0boot1: mmc0:0001 032GE4 partition 2 4.00 MiB
[    2.571863] mmcblk0rpmb: mmc0:0001 032GE4 partition 3 4.00 MiB
[    2.573835]  mmcblk0: p1 p2 p3 p4 p5 p6
[    2.647372] mmc1: new high speed SDIO card at address 0001
[    2.812340] mmc2: new high speed SDXC card at address 0001
[    2.812719] mmcblk1: mmc2:0001 00000 59.6 GiB 

With v4.5:

$ grep mmc dmesg-4.5.0-rc4.txt 
[    2.678828] mmc0: SDHCI controller on ACPI [80860F14:00] using ADMA
[    2.683332] mmc1: SDHCI controller on ACPI [INT33BB:00] using ADMA
[    2.705315] mmc2: SDHCI controller on ACPI [80860F14:02] using ADMA
[    2.850013] mmc2: new high speed SDXC card at address 0001
[    2.858675] mmcblk0: mmc2:0001 00000 59.6 GiB 
[    2.871384] mmc0: MAN_BKOPS_EN bit is not set
[    2.883166] mmc0: new HS200 MMC card at address 0001
[    2.883725] mmcblk1: mmc0:0001 032GE4 29.1 GiB 
[    2.884029] mmcblk1boot0: mmc0:0001 032GE4 partition 1 4.00 MiB
[    2.884322] mmcblk1boot1: mmc0:0001 032GE4 partition 2 4.00 MiB
[    2.884518] mmcblk1rpmb: mmc0:0001 032GE4 partition 3 4.00 MiB
[    2.886442]  mmcblk1: p1 p2 p3 p4 p5 p6

Notice that the following line is missing with v4.5:

mmc1: new high speed SDIO card at address 0001

And of course the out-of-tree wifi driver (rtl8723bs) cannot find the hardware with kernel v4.5.

The hardware is a Teclast X80h Baytrail tablet.
Cpu:  Intel(R) Atom(TM) CPU  Z3735F
Comment 1 Chris Ball 2016-02-16 19:23:45 UTC
Hi, I suggest reporting this with an email to linux-mmc@vger.kernel.org.
Comment 2 Laszlo Fiat 2016-03-19 10:58:31 UTC
The bug is still present in mainline v4.5.0.

There was relevant discussion about this bug on 17-18 Feb 2016 on the linux-mmc mailing-list: http://article.gmane.org/gmane.linux.kernel.mmc/36045 to 36053.
Comment 3 BzukTuk 2016-03-22 07:58:28 UTC
I bisected kernel v4.5 (BAD) vs v4.4 (GOOD) to find that first bad commit is 520bd7a8b4152aacfbd34eb7f7a447354b631039. After reverting this commit , my r8723bs wifi card works - firmware is loaded without problem. However in dmesg on vanilla v4.5 it looks little bit different than whats stated by Laszlo Fiat. (Line "new high speed SDIO card at address 0001" is always there).

My HW is Acer Aspire Switch 10. (Z3735F)

Try reverting patch 520bd7a8b4152aacfbd34eb7f7a447354b631039 ("mmc: core: Optimize boot time by detecting cards simultaneously"). Hope this is the one and only culprit.
Comment 4 Laszlo Fiat 2016-03-22 18:56:21 UTC
Thank you for bisecting it. I have reverted that patch, and started compiling a new 4.5.0 kernel. I will be able to check the result Tomorrow night, as it takes about 2 hours to compile a kernel on the tablet (with a bit modified Debian config, and the target is a Debian package, with a mandatory make clean built into the make deb-pkg, so it has to recompile everything each time).
Comment 5 Laszlo Fiat 2016-03-22 21:05:22 UTC
(In reply to BzukTuk from comment #3)
> I bisected kernel v4.5 (BAD) vs v4.4 (GOOD) to find that first bad commit is
> 520bd7a8b4152aacfbd34eb7f7a447354b631039. After reverting this commit , my
> r8723bs wifi card works - firmware is loaded without problem. However in
> dmesg on vanilla v4.5 it looks little bit different than whats stated by
> Laszlo Fiat. (Line "new high speed SDIO card at address 0001" is always
> there).
> 
> My HW is Acer Aspire Switch 10. (Z3735F)
> 
> Try reverting patch 520bd7a8b4152aacfbd34eb7f7a447354b631039 ("mmc: core:
> Optimize boot time by detecting cards simultaneously"). Hope this is the one
> and only culprit.

You are right. I reverted that patch, compiled a new version of 4.5.0, and I got my SDIO wifi card back. I attach the new dmesg.
Comment 6 Laszlo Fiat 2016-03-22 21:11:15 UTC
Created attachment 210261 [details]
dmesg of 4.5.0 with reverted patch. It works OK. See comment #3 and #5.
Comment 7 Robert R. Howell 2016-03-27 18:39:38 UTC
I've seen the same problem (mmc1 WiFi not detected) on a Toshiba WT8-A Encore (Baytrail) tablet starting with kernel 4.5-rc1 even though the exact same kernel works fine on an ASUS T100-TAM.  The problem persists through kernel 4.6-rc1.  Although I haven't gone back to test 4.5, I did just try reverting the above commit on 4.6-rc1 and that DOES fix WiFi for the Toshiba Encore.

Thanks very much for tracking this down.
Comment 8 Laszlo Fiat 2016-04-10 17:26:25 UTC
Created attachment 212321 [details]
dmesg of v4.6.0-rc2 with extra patch-still no SDIO Wifi
Comment 9 Laszlo Fiat 2016-04-10 17:30:56 UTC
Created attachment 212331 [details]
dmesg of v4.6.0-rc2 with extra patch-still no SDIO Wifi

Ulf Hansson has created and posted a patch [1] to correct the problem.
I have tried it on v4.6-rc2 (I have also applied the usual patches from [2]), but the rtl8723bs SDIO Wifi adapter is still missing. 

[1] http://article.gmane.org/gmane.linux.kernel.mmc/36747
[2] https://github.com/hadess/rtl8723bs/tree/master/patches
Comment 10 Laszlo Fiat 2016-04-12 17:58:25 UTC
Created attachment 212531 [details]
dmesg-4.6-rc3-mmc-debug-no-patches.txt

Adrian Hunter asked for a failing case dmesg with mmc-debug config option.
Comment 11 Laszlo Fiat 2016-04-13 18:06:15 UTC
Created attachment 212651 [details]
dmesg-4.6-rc3-mmc-debug-no-patches-working-case.txt

This is the same 4.6-rc3 vanilla kernel, no additional patches, only the offending patch 520bd7a8b4152aacfbd34eb7f7a447354b631039 ("mmc: core: Optimize boot time by detecting cards simultaneously") was reverted. The SDIO wifi card is showing up in that case.
Comment 12 Laszlo Fiat 2016-04-13 18:07:56 UTC
Created attachment 212661 [details]
acpidump of Teclast X80h Baytrail-T tablet
Comment 13 jjmeijer88 2016-05-17 20:38:30 UTC
Hi,

Since I'm not part of the mailing list I would like to report over here that Adrien's latest patch from here: http://thread.gmane.org/gmane.linux.kernel.mmc/36747 fixes the issue for me on kernel v4.6-rc7 (HP Omni10 Baytrail tablet). 
Also it seems to fix some other issues on kernel v4.4.10 like the charger sometimes not detected, sensors sometimes not detected and DDR50 tuning can be enabled now.
Comment 14 jjmeijer88 2016-05-17 20:46:40 UTC
Created attachment 216461 [details]
mmc: sdhci-acpi: Ensure connected devices are powered on  before probing
Comment 15 Marc 2016-05-30 16:09:36 UTC
Thanks for the patch, it fixes the same issue (SDIO wifi card not detected at boot) on Baytrail tablet Acer Iconia W1-810, with kernels 4.5 and 4.6.
Comment 16 Laszlo Fiat 2016-06-01 17:15:02 UTC
The necessary patches have reached 4.7rc1:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/acpi?id=78a898d0e39513469858de990de83210fee28ee9
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/mmc?id=e5bbf30733f930a1d17b4ccf19eac88e30a39cc7

Greg K-H has also picked them up for 4.5-stable and 4.6-stable. So hopefully they will land in 4.5 and 4.6 soon.
Comment 17 Paul Mansfield 2016-06-15 16:22:40 UTC
I built 4.7-rc3 and didn't need to reverse-apply the sdio wifi patch to get the r8723bs sdio wifi adaptor to work, so this issue appears solved.
Comment 18 Laszlo Fiat 2016-06-15 16:48:41 UTC
The patches have reached stable 4.6.1 and 4.5.6, and were included previously in 4.7rc1, so I declare this bug as resolved.

Thanks to Adrian Hunter and Ulf Hansson for their work on this.