Bug 219517 - REGRESSION: charge_control missing in 6.12
Summary: REGRESSION: charge_control missing in 6.12
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Platform_x86 (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: drivers_platform_x86@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-20 15:56 UTC by Michael
Modified: 2024-11-22 14:40 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
acpidump of latest kernel 6.12-rc7 (4.09 MB, text/plain)
2024-11-21 09:07 UTC, Michael
Details
acpidump of older kernel 6.9.12 (4.09 MB, text/plain)
2024-11-21 09:07 UTC, Michael
Details
Prototype patch (2.09 KB, patch)
2024-11-21 21:41 UTC, Armin Wolf
Details | Diff

Description Michael 2024-11-20 15:56:51 UTC
On my ASUS Vivobook S14 (TP3402VA) I noticed that with kernel 6.12(-rc4,-rc7) several charge control related /sys entries are missing.

with kernel 6.12 the corresponding folder looks like this:
ls /sys/class/power_supply/BAT0/

alarm               charge_now   manufacturer   status      voltage_min_design
capacity            current_now  model_name     subsystem   voltage_now
capacity_level      cycle_count  power          technology
charge_full         device       present        type
charge_full_design  hwmon3       serial_number  uevent

Specifically missing is charge_control_end_threshold, which is normally used to set individual charge end points. That worked nicely up to kernel 6.11, but is defect now in the current 6.12 version.

Anything special you need from me to fix the problem?
Comment 1 Armin Wolf 2024-11-20 21:19:40 UTC
Does the asus-wmi driver even load with kernel 6.12?
Comment 2 Michael 2024-11-21 05:50:28 UTC
Hi Armin

Yes, the asus-wmi driver loads, but the asus-nb-wmi driver fails with error 5. Here is the relevant dmesg:

 dmesg|grep asus
[   18.552935] asus_wmi: ASUS WMI generic driver loaded
[   18.570919] asus_wmi: Initialization: 0x1
[   18.572730] asus_wmi: SFUN value: 0x21
[   18.572746] asus-nb-wmi asus-nb-wmi: Detected ATK, not ASUSWMI, use DSTS
[   18.619578] asus_wmi: Failed to set throttle thermal policy (retval): 0x0
[   18.619584] asus_wmi: Failed to set default thermal profile
[   18.619589] asus-nb-wmi asus-nb-wmi: probe with driver asus-nb-wmi failed with error -5
Comment 3 Michael 2024-11-21 05:56:47 UTC
As a comparison, here's the dmesg from an earlier kernel with working asus-nb-wmi:

❯ dmesg|grep asus
[   14.268902] asus_wmi: ASUS WMI generic driver loaded
[   14.283569] asus_wmi: Initialization: 0x1
[   14.284980] asus_wmi: SFUN value: 0x21
[   14.284993] asus-nb-wmi asus-nb-wmi: Detected ATK, not ASUSWMI, use DSTS
[   14.329923] input: Asus WMI hotkeys as /devices/platform/asus-nb-wmi/input/input11
Comment 4 Armin Wolf 2024-11-21 08:59:26 UTC
I see, the kewly added platform profile support fails to initialize and thus the whole driver fails to load.

Can you share the output of "acpidump"?
Comment 5 Michael 2024-11-21 09:07:29 UTC
Created attachment 307259 [details]
acpidump of latest kernel 6.12-rc7
Comment 6 Michael 2024-11-21 09:07:58 UTC
Created attachment 307260 [details]
acpidump of older kernel 6.9.12
Comment 7 Michael 2024-11-21 09:09:39 UTC
I did acpidumps on 6.12-rc7 (with the regression) and on an older kernel 6.9.12 (with no issue). Interestingly the dump is not identical. Not sure, if that is to be expected or not. See the two attachments. And here is the diff:

❯ diff acpidump_6.*
47639c47639
<     0000: 50 48 41 54 0D 06 00 00 01 2A 5F 41 53 55 53 5F  PHAT.....*_ASUS_
---
>     0000: 50 48 41 54 0D 06 00 00 01 C0 5F 41 53 55 53 5F  PHAT......_ASUS_
47708,47709c47708,47709
<     0450: 45 00 45 00 43 00 33 00 29 00 00 00 01 48 FD FB  E.E.C.3.)....H..
<     0460: A7 01 00 00 00 F1 B7 8E 98 01 00 00 00 2D 00 00  .............-..
---
>     0450: 45 00 45 00 43 00 33 00 29 00 00 00 01 1F 3D AA  E.E.C.3.).....=.
>     0460: A7 01 00 00 00 17 76 4B 99 01 00 00 00 2E 00 00  ......vK........
Comment 8 Armin Wolf 2024-11-21 11:26:12 UTC
It seems that the ACPI method responsible for setting the thermal policy always returns the thermal policy passed as an argument. The driver however checks if the return value is zero and returns an error if its not.

After checking the acpidumps from other ASUS machines, it seems that the return value has not special meaning (some always return 1, some return something different).

Can you apply a patch and build a custom kernel?
Comment 9 Michael 2024-11-21 11:28:45 UTC
Yes, sure. Would it be sufficient to build a module or is the full kernel build needed? (The latter takes significantly longer on the laptop.)
Comment 10 Armin Wolf 2024-11-21 11:34:01 UTC
You will only need to build the module, i will send you a patch soon.
Comment 11 Armin Wolf 2024-11-21 13:24:54 UTC
Can you check in the mean time if any BIOS updates are available for your device?
Comment 12 Michael 2024-11-21 13:58:55 UTC
I am running the latest official BIOS version from ASUS (307 from 2024/04/03).
Comment 13 Armin Wolf 2024-11-21 21:41:34 UTC
Created attachment 307261 [details]
Prototype patch
Comment 14 Armin Wolf 2024-11-21 21:44:27 UTC
Can you apply this patch and test if this solves the problem?

I still suspect that this is somehow a BIOS issue, so if you have a dualboot setup then please try to verify if the ASUS software under Windows can successfully switch thermal policies.
Comment 15 Michael 2024-11-22 12:21:27 UTC
Hi Armin

I cannot comnpile the module. I get the following error:

drivers/platform/x86/asus-wmi.c: In function 'fan_boost_mode_write':
drivers/platform/x86/asus-wmi.c:3116:38: error: 'retval' undeclared (first use in this function)
 3116 |                                     &retval);
      |                                      ^~~~~~
drivers/platform/x86/asus-wmi.c:3116:38: note: each undeclared identifier is reported only once for each function it appears in
  CC [M]  drivers/platform/x86/gpd-pocket-fan.o
drivers/platform/x86/asus-wmi.c: In function 'throttle_thermal_policy_write':
drivers/platform/x86/asus-wmi.c:3699:13: warning: unused variable 'retval' [-Wunused-variable]
 3699 |         u32 retval;
      |             ^~~~~~
Comment 16 Michael 2024-11-22 12:27:50 UTC
Update: I removed the first part of the patch (where the retval declaration was removed). Now the patch applies and restores correct functionality.
Comment 17 Armin Wolf 2024-11-22 14:36:27 UTC
Ok, i will try to fix the issue with the patch.

Do you have a dualboot setup?
Comment 18 Michael 2024-11-22 14:40:11 UTC
No, it is a single boot setup, running only linux.

Here is the dmesg from 6.12-rc7 with the truncated patch applied:

❯ dmesg|grep asus
[   12.756754] asus_wmi: ASUS WMI generic driver loaded
[   12.797541] asus_wmi: Initialization: 0x1
[   12.798530] asus_wmi: SFUN value: 0x21
[   12.798540] asus-nb-wmi asus-nb-wmi: Detected ATK, not ASUSWMI, use DSTS
[   12.845043] asus-nb-wmi asus-nb-wmi: Using throttle_thermal_policy for platform_profile support
[   12.860431] input: Asus WMI hotkeys as /devices/platform/asus-nb-wmi/input/input11
[   12.909854] asus_wmi: using asus-wmi for asus::kbd_backlight

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