AsahiLinux / linux

Linux kernel source tree
Other
2.16k stars 85 forks source link

power: supply: macsmc_power: Report available charge_behaviours #277

Closed t-8ch closed 6 days ago

t-8ch commented 3 months ago

The generic handling if charge_behaviours in the power_supply core requires power_supply_desc.charge_behaviours to be set.

Note:

This is entirely untested, not even compiled. This patch requires changes to upstream linux that should land in mainline 6.9-rc1.

See commit "power: supply: core: fix charge_behaviour formatting"

mzyngier commented 1 month ago

This fixes an issue I'm currently seeing on my M2 Air that screams:

[  234.839586] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.847377] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.855430] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.863108] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.871860] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.879245] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.887118] power_supply macsmc-battery: driver reporting unsupported charge behaviour
[  234.895056] power_supply macsmc-battery: driver reporting unsupported charge behaviour

FWIW:

Tested-by: Marc Zyngier <maz@kernel.org>

t-8ch commented 1 month ago

...that screams:

In hindsight that warning should have been ratelimited. But well, only (this) out-of-tree code is affected.

jannau commented 1 month ago

thanks, merged into my rebase onto v6.9 (https://github.com/jannau/linux/tree/asahi-wip-6.9). I'll keep this open until the change is in this repository

t-8ch commented 1 month ago

@mzyngier Why is that file read 100 times per second?

mzyngier commented 1 month ago

@mzyngier Why is that file read 100 times per second?

systemd-journald is the one. for some reason, it thinks it needs that.

openat(AT_FDCWD, "/sys/devices/platform/soc/23e400000.smc/macsmc-power/power_supply/macsmc-battery/uevent", O_RDONLY|O_NOCTTY|O_CLOEXEC) = 18
newfstatat(18, "", {st_mode=S_IFREG|0644, st_size=16384, ...}, AT_EMPTY_PATH) = 0
read(18, "", 16392)                     = 0
close(18)                               = 0
readlinkat(AT_FDCWD, "/sys/devices/platform/soc/23e400000.smc/macsmc-power/power_supply/macsmc-battery/subsystem", "../../../../../../../class/power"..., 4096) = 39
openat(AT_FDCWD, "/run/udev/data/+power_supply:macsmc-battery", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/run/systemd/journal/flushed", F_OK) = 0
read(9, "4,62318,574228820,-;power_supply"..., 8192) = 156
faccessat(AT_FDCWD, "/sys/bus/power_supply/devices/macsmc-battery", F_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/sys/class/power_supply/macsmc-battery", F_OK) = 0
openat(AT_FDCWD, "/", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = 18
openat(18, "sys", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 19
newfstatat(19, "", {st_mode=S_IFDIR|0555, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(18)                               = 0
openat(19, "class", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
newfstatat(18, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(19)                               = 0
openat(18, "power_supply", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 19
newfstatat(19, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(18)                               = 0
openat(19, "macsmc-battery", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
newfstatat(18, "", {st_mode=S_IFLNK|0777, st_size=0, ...}, AT_EMPTY_PATH) = 0
readlinkat(19, "macsmc-battery", "../../devices/platform/soc/23e40"..., 4096) = 81
close(18)                               = 0
openat(19, "..", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
close(19)                               = 0
openat(18, "..", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 19
close(18)                               = 0
openat(19, "devices", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
newfstatat(18, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(19)                               = 0
openat(18, "platform", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 19
newfstatat(19, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(18)                               = 0
openat(19, "soc", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
newfstatat(18, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(19)                               = 0
openat(18, "23e400000.smc", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 19
newfstatat(19, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(18)                               = 0
openat(19, "macsmc-power", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
newfstatat(18, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(19)                               = 0
openat(18, "power_supply", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 19
newfstatat(19, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(18)                               = 0
openat(19, "macsmc-battery", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH) = 18
newfstatat(18, "", {st_mode=S_IFDIR|0755, st_size=0, ...}, AT_EMPTY_PATH) = 0
close(19)                               = 0
faccessat2(18, "uevent", F_OK, 0)       = 0
fstatfs(18, {f_type=SYSFS_MAGIC, f_bsize=16384, f_blocks=0, f_bfree=0, f_bavail=0, f_files=0, f_ffree=0, f_fsid={val=[0xf7892793, 0x326e46c9]}, f_namelen=255, f_frsize=16384, f_flags=ST_VALID|ST_NOSUID|ST_NODEV|ST_NOEXEC|ST_RELATIME}) = 0
close(18)                               = 0
openat(AT_FDCWD, "/sys/devices/platform/soc/23e400000.smc/macsmc-power/power_supply/macsmc-battery/uevent", O_RDONLY|O_NOCTTY|O_CLOEXEC) = 18

Ad nauseam.

t-8ch commented 1 month ago

systemd-journald is the one. for some reason, it thinks it needs that.

It doesn't do that for me. Seems like something worth investigating.

mzyngier commented 1 month ago

Investigating systemd? I have better ways to waste my time! :smile:

jannau commented 6 days ago

closing as this is in asahi-wip and and asahi-6.9.* tags