BeardOverflow / msi-ec

GNU General Public License v2.0
134 stars 42 forks source link

Add debug mode #19

Closed teackot closed 12 months ago

teackot commented 1 year ago

Debug mode lets the user load the module on unsupported hardware to collect information required to add a new configuration.

Currently has EC dump implemented. This way we won't have to use isw which requires an additional acpi_ec module on some distros.

(!) Depends on #17, first 4 commits are from that PR, so you can review it first.

BeardOverflow commented 1 year ago

Previous PR #17 is already merged.

BeardOverflow commented 1 year ago

Hello @teackot This is a major (and interesting) feature and we should document it properly in the README file. Please, do a brief mention about the debug mode in the README file.

Tatsh commented 1 year ago

I tried this version as is and I get Invalid parameters and I am passing debug=1. I am on a MSI GE66 11UE.

This branch also needs rebasing with main.

And it needs the following change for newer kernels (which would come with rebasing):

diff --git a/msi-ec.c b/msi-ec.c
index 427e74e..45e988d 100644
--- a/msi-ec.c
+++ b/msi-ec.c
@@ -937,12 +937,12 @@ static struct attribute *msi_battery_attrs[] = {

 ATTRIBUTE_GROUPS(msi_battery);

-static int msi_battery_add(struct power_supply *battery)
+static int msi_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook)
 {
    return device_add_groups(&battery->dev, msi_battery_groups);
 }

-static int msi_battery_remove(struct power_supply *battery)
+static int msi_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook)
 {
    device_remove_groups(&battery->dev, msi_battery_groups);
    return 0;
teackot commented 1 year ago

tried this version as is and I get Invalid parameters and I am passing debug=1. I am on a MSI GE66 11UE.

What command gives you this error?

This branch also needs rebasing with main.

And it needs the following change for newer kernels (which would come with rebasing): ...

Yes, I just did that. Now I'm going to document the debug mode

Tatsh commented 1 year ago

I fixed the loading issue. It was caused by a compiler mismatch.

It loads some things into platform/msi-ec and not platform/msi-laptop

Tatsh commented 1 year ago

Are there things missing here? Is there another place with more info?

/sys/devices/platform/msi-ec/
├── debug
│   ├── ec_dump
│   ├── ec_set
│   └── fw_version
├── driver -> ../../../bus/platform/drivers/msi-ec
├── driver_override
├── modalias
├── power
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_time
│   ├── runtime_status
│   └── runtime_suspended_time
├── subsystem -> ../../../bus/platform
└── uevent
glpnk commented 1 year ago

@Tatsh look like your hardware is not in supported, but debug mode loaded, so you can try cat /sys/devices/platform/msi-ec/debug/ec_dump and implement support for your device

Tatsh commented 1 year ago

Here is the dump:

     | _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _a _b _c _d _e _f
-----+------------------------------------------------
0x0_ | 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1_ | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x2_ | 00 00 00 00 00 00 00 00 0a 05 00 00 00 04 0b 4b
0x3_ | 03 03 00 0d 00 00 50 81 6a 18 60 3b 71 02 c0 00
0x4_ | 35 0c 63 00 ee 15 00 00 b5 15 d3 41 ca 0b f8 43
0x5_ | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x6_ | 00 00 00 00 00 00 00 00 33 00 32 39 40 47 4e 55
0x7_ | 64 30 00 28 30 38 40 48 50 00 0a 08 08 08 08 08
0x8_ | 30 00 37 3c 41 46 4b 4b 62 00 00 31 3a 43 4c 55
0x9_ | 55 00 0a 07 06 06 06 06 02 16 7d 02 16 62 46 00
0xa_ | 31 35 34 33 45 4d 53 31 2e 31 31 33 30 38 31 36
0xb_ | 32 30 32 31 31 35 3a 34 36 3a 32 31 00 00 00 28
0xc_ | 00 00 02 33 00 00 00 00 00 e1 00 00 00 00 00 00
0xd_ | 00 00 c1 82 0d 00 05 80 00 01 00 00 00 00 00 00
0xe_ | e2 00 00 02 16 00 00 c1 00 00 00 00 00 c2 00 00
0xf_ | 00 00 70 00 30 64 00 00 64 00 03 c0 00 02 00 00

Is it very similar to 1542 which is already present? Mine is 1543EMS1.113

Tatsh commented 1 year ago

I forced loading the 1542 configuration and it seems most things work but not all.

name value
available_fan_modes auto silent advanced
available_shift_modes eco comfort sport turbo
battery_mode unknown (0)
cooler_boost off
cpu/basic_fan_speed cat: cpu/basic_fan_speed: Invalid argument
cpu/realtime_fan_speed cat: cpu/realtime_fan_speed: Invalid argument
cpu/realtime_temperature 51
fan_mode unknown (50)
fn_key left
fw_release_date 2021/08/16 15:46:21
fw_version 1543EMS1.113
gpu/realtime_fan_speed 128
gpu/realtime_temperature 50
power/autosuspend_delay_ms cat: power/autosuspend_delay_ms: Input/output error
power/control auto
power/runtime_active_time 0
power/runtime_status unsupported
power/runtime_suspended_time 0
shift_mode unknown (112)
super_battery off
webcam on
win_key right

If I understand the win_key value, it is incorrect as the keyboard only has a single Windows key on the left, and the Fn key is on the right.

Based on my experience with isw I think gpu/realtime_fan_speed might not be a real value here.

teackot commented 1 year ago

Okay, I've documented the debug mode!

BeardOverflow commented 12 months ago

Thanks again @teackot