Age | Commit message (Collapse) | Author |
|
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel:
"Power-supply core:
- battery-info: replace any DT specific bits with fwnode usage
- replace any device-tree code with generic fwnode based handling
Power-supply drivers:
- ug3105_battery: use battery-info API
- qcom_battmgr: report capacity
- qcom_battmgr: support LiPo battery reporting
- add missing missing power-supply ref to a bunch of DT bindings
- update drivers regarding pm_runtime_autosuspend() usage
- misc minor fixes and cleanups
Reset drivers:
- misc minor cleanups"
* tag 'for-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (32 commits)
power: supply: core: fix static checker warning
power: supply: twl4030_charger: Remove redundant pm_runtime_mark_last_busy() calls
power: supply: bq24190: Remove redundant pm_runtime_mark_last_busy() calls
MAINTAINERS: rectify file entry in QUALCOMM SMB CHARGER DRIVER
power: supply: max1720x correct capacity computation
MAINTAINERS: add myself as smbx charger driver maintainer
power: supply: pmi8998_charger: rename to qcom_smbx
power: supply: qcom_pmi8998_charger: fix wakeirq
power: supply: max14577: Handle NULL pdata when CONFIG_OF is not set
power: return the correct error code
power: reset: POWER_RESET_TORADEX_EC should depend on ARCH_MXC
power: supply: cpcap-charger: Fix null check for power_supply_get_by_name
power: supply: bq25980_charger: Constify reg_default array
power: supply: bq256xx_charger: Constify reg_default array
power: reset: at91-sama5d2_shdwc: Refactor wake-up source logging to use dev_info
power: reset: qcom-pon: Rename variables to use generic naming
power: supply: qcom_battmgr: Add lithium-polymer entry
power: supply: qcom_battmgr: Report battery capacity
power: supply: bq24190: Free battery_info
power: supply: ug3105_battery: Switch to power_supply_batinfo_ocv2cap()
...
|
|
static checker complains, that the block already breaks if IS_ERR(np)
and thus the extra !IS_ERR(np) check in the while condition is
superfluous. Avoid the extra check by using while(true) instead. This
should not change the runtime behavior at all and I expect the binary
to be more or less the same for an optimizing compiler.
Fixes: f368f87b22da ("power: supply: core: convert to fwnnode")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-pm/285c9c39-482c-480c-8b0b-07111e39fdfe@sabinyo.mountain/
Reviewed-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250707-fix-psy-static-checker-warning-v1-1-42d555c2b68a@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Power supply extensions might want to interact with the underlying
power supply to retrieve data like serial numbers, charging status
and more. However doing so causes psy->extensions_sem to be locked
twice, possibly causing a deadlock.
Provide special variants of power_supply_get/set_property() that
ignore any power supply extensions and thus do not touch the
associated psy->extensions_sem lock.
Suggested-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250627205124.250433-1-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
|
|
power_supply_get_by_reference
(devm_)power_supply_get_by_phandle now internally uses fwnode and are no
longer DT specific. Thus drop the ifdef check for CONFIG_OF and rename
to (devm_)power_supply_get_by_reference to avoid the DT terminology.
Reviewed-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-5-f9643b958677@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Replace any DT specific code with fwnode in the power-supply
core.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-4-f9643b958677@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Also use fwnode based parsing for "ocv-capacity-celsius" and
"resistance-temp-table", so that any DT specific bits are
removed from the power-supply core.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-3-f9643b958677@collabora.com
Co-developed-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
All drivers have been migrated from .of_node to .fwnode,
so let's kill the former.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-2-f9643b958677@collabora.com
Reviewed-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel:
"Power-supply core:
- remove unused set_charged infrastructure
- drop of_node from power_supply struct
Power-supply drivers:
- axp717: support devices without thermistors
- bq27xxx: support max design voltage for bq270x0 and bq27x10
- pcf50633: drop charger driver
- max1720x: add battery health support
- switch all power-supply devices from of_node to fwnode
- convert regmap users to maple tree register cache
- convert drivers to devm_kmemdup_array
- misc cleanups and fixes
Reset drivers:
- at91-sama5d2_shdwc: add sama7d65 support
* tag 'for-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (30 commits)
power: supply: mt6370: Remove redundant 'flush_workqueue()' calls
Revert "power: supply: bq27xxx: do not report bogus zero values"
power: supply: max77693: Fix wrong conversion of charge input threshold value
power: supply: pcf50633: Remove charger
power: supply: all: switch psy_cfg from of_node to fwnode
power: supply: core: get rid of of_node
power: reset: at91-sama5d2_shdwc: Add sama7d65 PMC
power: supply: smb347: convert to use maple tree register cache
power: supply: rt9455: convert to use maple tree register cache
power: supply: max1720x: convert to use maple tree register cache
power: supply: ltc4162l: convert to use maple tree register cache
power: supply: bq25980: convert to use maple tree register cache
power: supply: bq25890: convert to use maple tree register cache
power: supply: bq2515x: convert to use maple tree register cache
power: supply: bq24257: convert to use maple tree register cache
power: supply: bd99954: convert to use maple tree register cache
power: supply: Remove unused set_charged method
power: supply: ds2760: Remove unused ds2760_battery_set_charged
power: supply: core: Remove unused power_supply_set_battery_charged
power: supply: sc27xx: use devm_kmemdup_array()
...
|
|
This removes .of_node from 'struct power_supply', since there
is already a copy in .dev.of_node and there is no need to have
two copies.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20250225-psy-core-convert-to-fwnode-v1-1-d5e4369936bb@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
power_supply_set_battery_charged() has been unused since 2019's
commit 0f884f8a090e ("ARM: pxa: remove raumfeld board files and
defconfig")
Remove it.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Link: https://lore.kernel.org/r/20250307230225.128775-2-linux@treblig.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Since commit 6037802bbae8 ("power: supply: core: implement extension API")
there is the following ABBA deadlock (simplified) between the LED trigger
code and the power-supply code:
1) When registering a power-supply class device, power_supply_register()
calls led_trigger_register() from power_supply_create_triggers() in
a scoped_guard(rwsem_read, &psy->extensions_sem) context.
led_trigger_register() then in turn takes a LED subsystem lock.
So here we have the following locking order:
* Read-lock extensions_sem
* Lock LED subsystem lock(s)
2) When registering a LED class device, with its default trigger set
to a power-supply LED trigger (which has already been registered)
The LED class code calls power_supply_led_trigger_activate() when
setting up the default trigger. power_supply_led_trigger_activate()
calls power_supply_get_property() to determine the initial value of
to assign to the LED and that read-locks extensions_sem. So now we
have the following locking order:
* Lock LED subsystem lock(s)
* Read-lock extensions_sem
Fixing this is easy, there is no need to hold the extensions_sem when
calling power_supply_create_triggers() since all triggers are always
created rather then checking for the presence of certain attributes as
power_supply_add_hwmon_sysfs() does. Move power_supply_create_triggers()
out of the guard block to fix this.
Here is the lockdep report fixed by this change:
[ 31.249343] ======================================================
[ 31.249378] WARNING: possible circular locking dependency detected
[ 31.249413] 6.13.0-rc6+ #251 Tainted: G C E
[ 31.249440] ------------------------------------------------------
[ 31.249471] (udev-worker)/553 is trying to acquire lock:
[ 31.249501] ffff892adbcaf660 (&psy->extensions_sem){.+.+}-{4:4}, at: power_supply_get_property.part.0+0x22/0x150
[ 31.249574]
but task is already holding lock:
[ 31.249603] ffff892adbc0bad0 (&led_cdev->trigger_lock){+.+.}-{4:4}, at: led_trigger_set_default+0x34/0xe0
[ 31.249657]
which lock already depends on the new lock.
[ 31.249696]
the existing dependency chain (in reverse order) is:
[ 31.249735]
-> #2 (&led_cdev->trigger_lock){+.+.}-{4:4}:
[ 31.249778] down_write+0x3b/0xd0
[ 31.249803] led_trigger_set_default+0x34/0xe0
[ 31.249833] led_classdev_register_ext+0x311/0x3a0
[ 31.249863] input_leds_connect+0x1dc/0x2a0
[ 31.249889] input_attach_handler.isra.0+0x75/0x90
[ 31.249921] input_register_device.cold+0xa1/0x150
[ 31.249955] hidinput_connect+0x8a2/0xb80
[ 31.249982] hid_connect+0x582/0x5c0
[ 31.250007] hid_hw_start+0x3f/0x60
[ 31.250030] hid_device_probe+0x122/0x1f0
[ 31.250053] really_probe+0xde/0x340
[ 31.250080] __driver_probe_device+0x78/0x110
[ 31.250105] driver_probe_device+0x1f/0xa0
[ 31.250132] __device_attach_driver+0x85/0x110
[ 31.250160] bus_for_each_drv+0x78/0xc0
[ 31.250184] __device_attach+0xb0/0x1b0
[ 31.250207] bus_probe_device+0x94/0xb0
[ 31.250230] device_add+0x64a/0x860
[ 31.250252] hid_add_device+0xe5/0x240
[ 31.250279] usbhid_probe+0x4dc/0x620
[ 31.250303] usb_probe_interface+0xe4/0x2a0
[ 31.250329] really_probe+0xde/0x340
[ 31.250353] __driver_probe_device+0x78/0x110
[ 31.250377] driver_probe_device+0x1f/0xa0
[ 31.250404] __device_attach_driver+0x85/0x110
[ 31.250431] bus_for_each_drv+0x78/0xc0
[ 31.250455] __device_attach+0xb0/0x1b0
[ 31.250478] bus_probe_device+0x94/0xb0
[ 31.250501] device_add+0x64a/0x860
[ 31.250523] usb_set_configuration+0x606/0x8a0
[ 31.250552] usb_generic_driver_probe+0x3e/0x60
[ 31.250579] usb_probe_device+0x3d/0x120
[ 31.250605] really_probe+0xde/0x340
[ 31.250629] __driver_probe_device+0x78/0x110
[ 31.250653] driver_probe_device+0x1f/0xa0
[ 31.250680] __device_attach_driver+0x85/0x110
[ 31.250707] bus_for_each_drv+0x78/0xc0
[ 31.250731] __device_attach+0xb0/0x1b0
[ 31.250753] bus_probe_device+0x94/0xb0
[ 31.250776] device_add+0x64a/0x860
[ 31.250798] usb_new_device.cold+0x141/0x38f
[ 31.250828] hub_event+0x1166/0x1980
[ 31.250854] process_one_work+0x20f/0x580
[ 31.250879] worker_thread+0x1d1/0x3b0
[ 31.250904] kthread+0xee/0x120
[ 31.250926] ret_from_fork+0x30/0x50
[ 31.250954] ret_from_fork_asm+0x1a/0x30
[ 31.250982]
-> #1 (triggers_list_lock){++++}-{4:4}:
[ 31.251022] down_write+0x3b/0xd0
[ 31.251045] led_trigger_register+0x40/0x1b0
[ 31.251074] power_supply_register_led_trigger+0x88/0x150
[ 31.251107] power_supply_create_triggers+0x55/0xe0
[ 31.251135] __power_supply_register.part.0+0x34e/0x4a0
[ 31.251164] devm_power_supply_register+0x70/0xc0
[ 31.251190] bq27xxx_battery_setup+0x1a1/0x6d0 [bq27xxx_battery]
[ 31.251235] bq27xxx_battery_i2c_probe+0xe5/0x17f [bq27xxx_battery_i2c]
[ 31.251272] i2c_device_probe+0x125/0x2b0
[ 31.251299] really_probe+0xde/0x340
[ 31.251324] __driver_probe_device+0x78/0x110
[ 31.251348] driver_probe_device+0x1f/0xa0
[ 31.251375] __driver_attach+0xba/0x1c0
[ 31.251398] bus_for_each_dev+0x6b/0xb0
[ 31.251421] bus_add_driver+0x111/0x1f0
[ 31.251445] driver_register+0x6e/0xc0
[ 31.251470] i2c_register_driver+0x41/0xb0
[ 31.251498] do_one_initcall+0x5e/0x3a0
[ 31.251522] do_init_module+0x60/0x220
[ 31.251550] __do_sys_init_module+0x15f/0x190
[ 31.251575] do_syscall_64+0x93/0x180
[ 31.251598] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ 31.251629]
-> #0 (&psy->extensions_sem){.+.+}-{4:4}:
[ 31.251668] __lock_acquire+0x13ce/0x21c0
[ 31.251694] lock_acquire+0xcf/0x2e0
[ 31.251719] down_read+0x3e/0x170
[ 31.251741] power_supply_get_property.part.0+0x22/0x150
[ 31.251774] power_supply_update_leds+0x8d/0x230
[ 31.251804] power_supply_led_trigger_activate+0x18/0x20
[ 31.251837] led_trigger_set+0x1fc/0x300
[ 31.251863] led_trigger_set_default+0x90/0xe0
[ 31.251892] led_classdev_register_ext+0x311/0x3a0
[ 31.251921] devm_led_classdev_multicolor_register_ext+0x6e/0xb80 [led_class_multicolor]
[ 31.251969] ktd202x_probe+0x464/0x5c0 [leds_ktd202x]
[ 31.252002] i2c_device_probe+0x125/0x2b0
[ 31.252027] really_probe+0xde/0x340
[ 31.252052] __driver_probe_device+0x78/0x110
[ 31.252076] driver_probe_device+0x1f/0xa0
[ 31.252103] __driver_attach+0xba/0x1c0
[ 31.252125] bus_for_each_dev+0x6b/0xb0
[ 31.252148] bus_add_driver+0x111/0x1f0
[ 31.252172] driver_register+0x6e/0xc0
[ 31.252197] i2c_register_driver+0x41/0xb0
[ 31.252225] do_one_initcall+0x5e/0x3a0
[ 31.252248] do_init_module+0x60/0x220
[ 31.252274] __do_sys_init_module+0x15f/0x190
[ 31.253986] do_syscall_64+0x93/0x180
[ 31.255826] entry_SYSCALL_64_after_hwframe+0x76/0x7e
[ 31.257614]
other info that might help us debug this:
[ 31.257619] Chain exists of:
&psy->extensions_sem --> triggers_list_lock --> &led_cdev->trigger_lock
[ 31.257630] Possible unsafe locking scenario:
[ 31.257632] CPU0 CPU1
[ 31.257633] ---- ----
[ 31.257634] lock(&led_cdev->trigger_lock);
[ 31.257637] lock(triggers_list_lock);
[ 31.257640] lock(&led_cdev->trigger_lock);
[ 31.257643] rlock(&psy->extensions_sem);
[ 31.257646]
*** DEADLOCK ***
[ 31.289433] 4 locks held by (udev-worker)/553:
[ 31.289443] #0: ffff892ad9658108 (&dev->mutex){....}-{4:4}, at: __driver_attach+0xaf/0x1c0
[ 31.289463] #1: ffff892adbc0bbc8 (&led_cdev->led_access){+.+.}-{4:4}, at: led_classdev_register_ext+0x1c7/0x3a0
[ 31.289476] #2: ffffffffad0e30b0 (triggers_list_lock){++++}-{4:4}, at: led_trigger_set_default+0x2c/0xe0
[ 31.289487] #3: ffff892adbc0bad0 (&led_cdev->trigger_lock){+.+.}-{4:4}, at: led_trigger_set_default+0x34/0xe0
Fixes: 6037802bbae8 ("power: supply: core: implement extension API")
Cc: Thomas Weißschuh <linux@weissschuh.net>
Cc: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20250130140035.20636-1-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
__power_supply_changed_work()
The power-supply core is designed so that power-supply driver callbacks
such as get_property() and external_power_changed() will not be called
until the power-supply's parent driver's probe() function has completed.
There is a race where power_supply_changed() can be called for a supplier
of a power-supply which is being probed after the device_add() in
__power_supply_register() but before the parent driver's probe() function
has completed. Hitting this race breaks the power-supply core's design
to not call power-supply driver callbacks before probe() completion.
This problem is caused by __power_supply_changed_work() calling
the external_power_changed() directly rather then going through
the power_supply_external_power_changed() helper which correcly checks
psy->use_cnt .
Switch to using power_supply_external_power_changed() to fix this race.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241215172133.178460-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Add and use wrapper functions for the sysfs interaction.
Restore the compatibility of CONFIG_POWER_SUPPLY=y and CONFIG_SYSFS=n.
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/lkml/20241218195229.GA2796534@ax162/
Fixes: 288a2cabcf6b ("power: supply: core: add UAPI to discover currently used extensions")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241219-psy-extensions-sysfs-v1-1-868fc6cb46d6@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Userspace wants to now about the used power supply extensions,
for example to handle a device extended by a certain extension
differently or to discover information about the extending device.
Add a sysfs directory to the power supply device.
This directory contains links which are named after the used extension
and point to the device implementing that extension.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20241211-power-supply-extensions-v6-4-9d9dc3f3d387@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Various drivers, mostly in platform/x86 extend the ACPI battery driver
with additional sysfs attributes to implement more UAPIs than are
exposed through ACPI by using various side-channels, like WMI,
nonstandard ACPI or EC communication.
While the created sysfs attributes look similar to the attributes
provided by the powersupply core, there are various deficiencies:
* They don't show up in uevent payload.
* They can't be queried with the standard in-kernel APIs.
* They don't work with triggers.
* The extending driver has to reimplement all of the parsing,
formatting and sysfs display logic.
* Writing a extension driver is completely different from writing a
normal power supply driver.
This extension API avoids all of these issues.
An extension is just a "struct power_supply_ext" with the same kind of
callbacks as in a normal "struct power_supply_desc".
The API is meant to be used via battery_hook_register(), the same way as
the current extensions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20241211-power-supply-extensions-v6-1-9d9dc3f3d387@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Use the new, explicit accessor to go from a 'struct device' to its
'struct power_supply'.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241210-power-supply-dev_to_psy-v2-8-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
There are no users anymore. All potential future users are expected to
use power_supply_for_each_psy().
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241210-power-supply-dev_to_psy-v2-6-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Simplify the callbacks by removing the need to convert a 'struct device'
into a 'struct power_supply'.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241210-power-supply-dev_to_psy-v2-3-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
All existing callers of power_supply_for_each_device() want to iterate
over 'struct power_supply', not 'struct device'.
The power_supply_for_each_device() forces each caller to duplicate the
logic to go from one to the other.
Introduce power_supply_for_each_psy() to simplify the callers.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241210-power-supply-dev_to_psy-v2-2-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Introduce a helper to check if a power supply implements a certain
property. It will be used by the sysfs and hwmon code to remove similar
open-coded checks.
It also paves the way for the extension API to hook into.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20241111-power-supply-extensions-v4-3-7240144daa8e@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The function only takes a desc as parameter, align the naming.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20241111-power-supply-extensions-v4-2-7240144daa8e@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Since commit ("power: supply: Drop use_cnt check from power_supply_property_is_writeable()"),
this function does not check use_cnt anymore, making it unsuitable for
general usage. As it is only used by the psy core anyways, remove it
from the public header and unexport it to avoid misusage.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241005-power-supply-cleanups-v1-2-45303b2d0a4d@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The mutex is an implementation detail of struct device.
Use the dedicated wrappers to access the field.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241005-power-supply-cleanups-v1-1-45303b2d0a4d@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The put_device() call in power_supply_put() may call
power_supply_dev_release(). The latter function does not sleep so
power_supply_put() doesn't sleep either. Hence, remove the might_sleep()
call from power_supply_put(). This patch suppresses false positive
complaints about calling a sleeping function from atomic context if
power_supply_put() is called from atomic context.
Cc: Kyle Tso <kyletso@google.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Fixes: 1a352462b537 ("power_supply: Add power_supply_put for decrementing device reference counter")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240917193914.47566-1-bvanassche@acm.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The same functionality is available through
power_supply_config::no_wakeup_source, which is more idiomatic.
All users of the old API have been converted.
Also remove the argument "ws" from __power_supply_register(),
as it is now always "true".
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20241005-power-supply-no-wakeup-source-v1-8-1d62bf9bcb1d@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
To inhibit wakeup users currently have to use dedicated functions to
register the power supply: {,devm_}power_supply_register_no_ws().
This is inconsistent to other runtime settings which can be configured
through struct power_supply_config.
It's also not obvious what _no_ws() is meant to mean.
Extend power_supply_config to also be able to inhibit the wakeup source.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20241005-power-supply-no-wakeup-source-v1-1-1d62bf9bcb1d@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The power supply core never modifies the ocv table.
Reflect this in the API, so drivers can mark their static tables as
const.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241005-power-supply-battery-const-v1-5-c1f721927048@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The power supply core never modifies the resist table.
Reflect this in the API, so drivers can mark their static tables as
const.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241005-power-supply-battery-const-v1-1-c1f721927048@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
power_supply_property_is_writeable() gets called from the is_visible()
callback for the sysfs attributes of power_supply class devices and for
the sysfs attributes of power_supply core instantiated hwmon class devices.
These sysfs attributes get registered by the device_add() respectively
power_supply_add_hwmon_sysfs() calls in power_supply_register().
use_cnt gets initialized to 0 and is incremented only after these calls.
So when power_supply_property_is_writeable() gets called it always return
-ENODEV because of use_cnt == 0.
This causes all the attributes to have permissions of 444 even those which
should be writable. This used to be a problem only for hwmon sysfs
attributes but since commit be6299c6e55e ("power: supply: sysfs: use
power_supply_property_is_writeable()") this now also impacts power_supply
class sysfs attributes.
Fixes: be6299c6e55e ("power: supply: sysfs: use power_supply_property_is_writeable()")
Fixes: e67d4dfc9ff1 ("power: supply: Add HWMON compatibility layer")
Cc: stable@vger.kernel.org
Cc: Thomas Weißschuh <linux@weissschuh.net>
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/stable/20240908185337.103696-1-hdegoede%40redhat.com
Link: https://lore.kernel.org/r/20240908185337.103696-1-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Changing usb_types type from array to bitmap in the power_supply_desc
struct requires updating power-supply drivers living in different
subsystem, so it is handled via an immutable branch.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The bit_types array just hold a list of valid enum power_supply_usb_type
values which map to 0 - 9. This can easily be represented as a bitmap.
This reduces the size of struct power_supply_desc and further reduces
the data section size by drivers no longer needing to store the array.
This also unifies how usb_types are handled with charge_behaviours,
which allows power_supply_show_usb_type() to be removed.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20240831142039.28830-7-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
This struct is never modified, so mark it const.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240828-power-supply-const-psy_tzd_ops-v1-1-dc27176fda5b@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240705113113.42851-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
power_supply_maintenance_charge_table
'struct power_supply_maintenance_charge_table' is not modified in this
driver.
Constifying this structure moves some data to a read-only section, so
increase overall security.
In order to do it, some code also needs to be adjusted to this new const
qualifier.
On a x86_64, with allmodconfig:
Before:
======
$ size drivers/power/supply/samsung-sdi-battery.o
text data bss dec hex filename
4055 4584 0 8639 21bf drivers/power/supply/samsung-sdi-battery.o
After:
=====
$ size drivers/power/supply/samsung-sdi-battery.o
text data bss dec hex filename
4087 4552 0 8639 21bf drivers/power/supply/samsung-sdi-battery.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/6caafd0ac2556a40405273b1a4badc508ea8e9b0.1719125040.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
'struct power_supply_vbat_ri_table' are not modified in this driver.
Constifying these structures moves some data to a read-only section, so
increase overall security.
In order to do it, some code also needs to be adjusted to this new const
qualifier.
On a x86_64, with allmodconfig:
Before:
======
$ size drivers/power/supply/samsung-sdi-battery.o
text data bss dec hex filename
955 7664 0 8619 21ab drivers/power/supply/samsung-sdi-battery.o
After:
=====
$ size drivers/power/supply/samsung-sdi-battery.o
text data bss dec hex filename
4055 4584 0 8639 21bf drivers/power/supply/samsung-sdi-battery.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/d01818abd880bf435d1106a9a6cc11a7a8a3e661.1719125040.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
As reported by the kernel test robot, 'power_supply_attr_group' is defined
but not used when CONFIG_SYSFS is not set. Sebastian suggested that the
correct fix implemented by this patch, instead of my attempt in commit
ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef
block"), is to define power_supply_attr_groups in power_supply_sysfs.c and
expose it in the power_supply.h header. For the case where CONFIG_SYSFS=n,
define it as NULL.
Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Fixes: ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef block")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403021518.SUQzk3oA-lkp@intel.com/
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240303-class_cleanup-power-v2-1-e248b7128519@marliere.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Technically the sysfs attributes should be initialized
before the class is registered, since that will use them.
As a nice side effect this nicely simplifies the code,
since it allows dropping the helper variable.
Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240301-psy-class-cleanup-v1-2-aebe8c4b6b08@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Introduce power_supply_for_each_device(), which is a wrapper
for class_for_each_device() using the power_supply_class and
going through all devices.
This allows making the power_supply_class itself a local
variable, so that drivers cannot mess with it and simplifies
the code slightly.
Reviewed-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240301-psy-class-cleanup-v1-1-aebe8c4b6b08@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the power_supply_class structure to be declared at build
time placing it into read-only memory, instead of having to be dynamically
allocated at boot time.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240301-class_cleanup-power-v1-1-97e0b7bf9c94@marliere.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
power_supply_dev_type variable to be a constant structure as well, placing
it into read-only memory which can not be modified at runtime.
In order to accomplish that, export power_supply_attr_group in
power_supply.h and use it with the macro __ATTRIBUTE_GROUPS when defining
power_supply_dev_type in power_supply_core.c. Therefore the attribute group
is no longer static. Lastly, because power_supply_attr_groups is no longer
dynamically associated to power_supply_dev_type in
power_supply_init_attrs(), make the function receive zero arguments.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240224-device_cleanup-power-v2-1-465ff94b896c@marliere.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
This resolves checkpatch warning "quoted string split across lines" on:
1640: WARNING: quoted string split across lines
1641: WARNING: quoted string split across lines
The motive to use multiple MODULE_AUTHOR statements came from this
comment from "include/linux/module.h":
/*
* Author(s), use "Name <email>" or just "Name", for multiple
* authors use multiple MODULE_AUTHOR() statements/lines.
*/
#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
These were mentioned by checkpatch:
Errors:
(1) code indent should use tabs where possible
(2) switch and case should be at the same indent
Warnings:
(1) Missing a blank line after declarations
Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
power_supply_notifier can be internal, since all users are going
through power_supply_reg_notifier()/power_supply_unreg_notifier().
Link: https://lore.kernel.org/r/20230913133900.591637-1-sebastian.reichel@collabora.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
Ensure that the dynamically created power supply device sets its
->of_node if the driver supplies one. This brings it in line with
several other subsystems (see git grep 'of_node =.*parent.*of_node') and
allows easier identification of the device from udev rules and similar.
Before this patch:
/sys/class/power_supply# ls -l bq256xx-battery/of_node
ls: cannot access 'bq256xx-battery/of_node': No such file or directory
# ls -l bq256xx-battery/hwmon1/of_node
ls: cannot access 'bq256xx-battery/hwmon1/of_node': No such file or directory
After:
/sys/class/power_supply# ls -l bq256xx-battery/of_node
lrwxrwxrwx 1 root root 0 May 17 09:14 bq256xx-battery/of_node ->
../../../../../../../../firmware/devicetree/base/virtio@1/i2c/bq25619@09
# ls -l bq256xx-battery/hwmon1/of_node
lrwxrwxrwx 1 root root 0 May 17 09:14 bq256xx-battery/hwmon1/of_node ->
../../../../../../../../../firmware/devicetree/base/virtio@1/i2c/bq25619@09
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Link: https://lore.kernel.org/r/20230915-power-of-v2-1-ca54c441867e@axis.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
AMD PMF driver can cause the following warning:
[ 196.159546] ------------[ cut here ]------------
[ 196.159556] Voluntary context switch within RCU read-side critical section!
[ 196.159571] WARNING: CPU: 0 PID: 9 at kernel/rcu/tree_plugin.h:320 rcu_note_context_switch+0x43d/0x560
[ 196.159604] Modules linked in: nvme_fabrics ccm rfcomm snd_hda_scodec_cs35l41_spi cmac algif_hash algif_skcipher af_alg bnep joydev btusb btrtl uvcvideo btintel btbcm videobuf2_vmalloc intel_rapl_msr btmtk videobuf2_memops uvc videobuf2_v4l2 intel_rapl_common binfmt_misc hid_sensor_als snd_sof_amd_vangogh hid_sensor_trigger bluetooth industrialio_triggered_buffer videodev snd_sof_amd_rembrandt hid_sensor_iio_common amdgpu ecdh_generic kfifo_buf videobuf2_common hp_wmi kvm_amd sparse_keymap snd_sof_amd_renoir wmi_bmof industrialio ecc mc nls_iso8859_1 kvm snd_sof_amd_acp irqbypass snd_sof_xtensa_dsp crct10dif_pclmul crc32_pclmul mt7921e snd_sof_pci snd_ctl_led polyval_clmulni mt7921_common polyval_generic snd_sof ghash_clmulni_intel mt792x_lib mt76_connac_lib sha512_ssse3 snd_sof_utils aesni_intel snd_hda_codec_realtek crypto_simd mt76 snd_hda_codec_generic cryptd snd_soc_core snd_hda_codec_hdmi rapl ledtrig_audio input_leds snd_compress i2c_algo_bit drm_ttm_helper mac80211 snd_pci_ps hid_multitouch ttm drm_exec
[ 196.159970] drm_suballoc_helper snd_rpl_pci_acp6x amdxcp drm_buddy snd_hda_intel snd_acp_pci snd_hda_scodec_cs35l41_i2c serio_raw gpu_sched snd_hda_scodec_cs35l41 snd_acp_legacy_common snd_intel_dspcfg snd_hda_cs_dsp_ctls snd_hda_codec libarc4 drm_display_helper snd_pci_acp6x cs_dsp snd_hwdep snd_soc_cs35l41_lib video k10temp snd_pci_acp5x thunderbolt snd_hda_core drm_kms_helper cfg80211 snd_seq snd_rn_pci_acp3x snd_pcm snd_acp_config cec snd_soc_acpi snd_seq_device rc_core ccp snd_pci_acp3x snd_timer snd soundcore wmi amd_pmf platform_profile amd_pmc mac_hid serial_multi_instantiate wireless_hotkey hid_sensor_hub sch_fq_codel msr parport_pc ppdev lp parport efi_pstore ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx libcrc32c xor raid6_pq raid1 raid0 multipath linear dm_mirror dm_region_hash dm_log cdc_ether usbnet r8152 mii hid_generic nvme i2c_hid_acpi i2c_hid nvme_core i2c_piix4 xhci_pci amd_sfh drm xhci_pci_renesas nvme_common hid
[ 196.160382] CPU: 0 PID: 9 Comm: kworker/0:1 Not tainted 6.6.0-rc1 #4
[ 196.160397] Hardware name: HP HP EliteBook 845 14 inch G10 Notebook PC/8B6E, BIOS V82 Ver. 01.02.00 08/24/2023
[ 196.160405] Workqueue: events power_supply_changed_work
[ 196.160426] RIP: 0010:rcu_note_context_switch+0x43d/0x560
[ 196.160440] Code: 00 48 89 be 40 08 00 00 48 89 86 48 08 00 00 48 89 10 e9 63 fe ff ff 48 c7 c7 10 e7 b0 9e c6 05 e8 d8 20 02 01 e8 13 0f f3 ff <0f> 0b e9 27 fc ff ff a9 ff ff ff 7f 0f 84 cf fc ff ff 65 48 8b 3c
[ 196.160450] RSP: 0018:ffffc900001878f0 EFLAGS: 00010046
[ 196.160462] RAX: 0000000000000000 RBX: ffff88885e834040 RCX: 0000000000000000
[ 196.160470] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
[ 196.160476] RBP: ffffc90000187910 R08: 0000000000000000 R09: 0000000000000000
[ 196.160482] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
[ 196.160488] R13: 0000000000000000 R14: ffff888100990000 R15: ffff888100990000
[ 196.160495] FS: 0000000000000000(0000) GS:ffff88885e800000(0000) knlGS:0000000000000000
[ 196.160504] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 196.160512] CR2: 000055cb053c8246 CR3: 000000013443a000 CR4: 0000000000750ef0
[ 196.160520] PKRU: 55555554
[ 196.160526] Call Trace:
[ 196.160532] <TASK>
[ 196.160548] ? show_regs+0x72/0x90
[ 196.160570] ? rcu_note_context_switch+0x43d/0x560
[ 196.160580] ? __warn+0x8d/0x160
[ 196.160600] ? rcu_note_context_switch+0x43d/0x560
[ 196.160613] ? report_bug+0x1bb/0x1d0
[ 196.160637] ? handle_bug+0x46/0x90
[ 196.160658] ? exc_invalid_op+0x19/0x80
[ 196.160675] ? asm_exc_invalid_op+0x1b/0x20
[ 196.160709] ? rcu_note_context_switch+0x43d/0x560
[ 196.160727] __schedule+0xb9/0x15f0
[ 196.160746] ? srso_alias_return_thunk+0x5/0x7f
[ 196.160765] ? srso_alias_return_thunk+0x5/0x7f
[ 196.160778] ? acpi_ns_search_one_scope+0xbe/0x270
[ 196.160806] schedule+0x68/0x110
[ 196.160820] schedule_timeout+0x151/0x160
[ 196.160829] ? srso_alias_return_thunk+0x5/0x7f
[ 196.160842] ? srso_alias_return_thunk+0x5/0x7f
[ 196.160855] ? acpi_ns_lookup+0x3c5/0xa90
[ 196.160878] __down_common+0xff/0x220
[ 196.160905] __down_timeout+0x16/0x30
[ 196.160920] down_timeout+0x64/0x70
[ 196.160938] acpi_os_wait_semaphore+0x85/0x200
[ 196.160959] acpi_ut_acquire_mutex+0x9e/0x280
[ 196.160979] acpi_ex_enter_interpreter+0x2d/0xb0
[ 196.160992] acpi_ns_evaluate+0x2f0/0x5f0
[ 196.161005] acpi_evaluate_object+0x172/0x490
[ 196.161018] ? acpi_os_signal_semaphore+0x8a/0xd0
[ 196.161038] acpi_evaluate_integer+0x52/0xe0
[ 196.161055] ? kfree+0x79/0x120
[ 196.161071] ? srso_alias_return_thunk+0x5/0x7f
[ 196.161089] acpi_ac_get_state.part.0+0x27/0x80
[ 196.161110] get_ac_property+0x5c/0x70
[ 196.161127] ? __pfx___power_supply_is_system_supplied+0x10/0x10
[ 196.161146] __power_supply_is_system_supplied+0x44/0xb0
[ 196.161166] class_for_each_device+0x124/0x160
[ 196.161184] ? acpi_ac_get_state.part.0+0x27/0x80
[ 196.161203] ? srso_alias_return_thunk+0x5/0x7f
[ 196.161223] power_supply_is_system_supplied+0x3c/0x70
[ 196.161243] amd_pmf_get_power_source+0xe/0x20 [amd_pmf]
[ 196.161276] amd_pmf_power_slider_update_event+0x49/0x90 [amd_pmf]
[ 196.161310] amd_pmf_pwr_src_notify_call+0xe7/0x100 [amd_pmf]
[ 196.161340] notifier_call_chain+0x5f/0xe0
[ 196.161362] atomic_notifier_call_chain+0x33/0x60
[ 196.161378] power_supply_changed_work+0x84/0x110
[ 196.161394] process_one_work+0x178/0x360
[ 196.161412] ? __pfx_worker_thread+0x10/0x10
[ 196.161424] worker_thread+0x307/0x430
[ 196.161440] ? __pfx_worker_thread+0x10/0x10
[ 196.161451] kthread+0xf4/0x130
[ 196.161467] ? __pfx_kthread+0x10/0x10
[ 196.161486] ret_from_fork+0x43/0x70
[ 196.161502] ? __pfx_kthread+0x10/0x10
[ 196.161518] ret_from_fork_asm+0x1b/0x30
[ 196.161558] </TASK>
[ 196.161562] ---[ end trace 0000000000000000 ]---
Since there's no guarantee that all the callbacks can work in atomic
context, switch to use blocking_notifier_call_chain to relax the
constraint.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reported-by: Allen Zhong <allen@atr.me>
Fixes: 4c71ae414474 ("platform/x86/amd/pmf: Add support SPS PMF feature")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217571
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20230913033233.602986-1-kai.heng.feng@canonical.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
All of the remaining callers of thermal_zone_device_register()
can use thermal_tripless_zone_device_register(), so make them
do so in order to allow the former to be dropped.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
|
When the power supply device being registered supports a temperature
readout, the core registers a thermal zone for it. The thermal core
would register a hwmon device for that unless told otherwise.
When CONFIG_POWER_SUPPLY_HWMON is enabled, the power supply core creates
a hwmon device. This results in a second entry, one which has a better
name than the one registered through the thermal framework. It could
potentially have readouts other than temperature.
To simplify the result, tell the thermal framework to not register a
hwmon device if CONFIG_POWER_SUPPLY_HWMON is enabled. The result is
one hwmon device with all the readings the device supports.
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
The logic used for power_supply_is_system_supplied() counts all power
supplies and assumes that the system is running from AC if there is
either a non-battery power-supply reporting to be online or if no
power-supplies exist at all.
The second rule is for desktop systems, that don't have any
battery/charger devices. These systems will incorrectly report to be
powered from battery once a device scope power-supply is registered
(e.g. a HID device), since these power-supplies increase the counter.
Apart from HID devices, recent dGPUs provide UCSI power supplies on a
desktop systems. The dGPU by default doesn't have anything plugged in so
it's 'offline'. This makes power_supply_is_system_supplied() return 0
with a count of 1 meaning all drivers that use this get a wrong judgement.
To fix this case adjust the logic to also examine the scope of the power
supply. If the power supply is deemed a device power supply, then don't
count it.
Cc: Evan Quan <Evan.Quan@amd.com>
Suggested-by: Lijo Lazar <Lijo.Lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
After commit 27a2195efa8d26447c ("power: supply: core: auto-exposure
of simple-battery data") we call power_supply_get_battery_info() in
__power_supply_register(), but it causes test_battery crash with NULL
pointer:
[ 7.524846] __power_supply_register: Expected proper parent device for 'test_battery'
[ 7.524856] CPU 3 Unable to handle kernel paging request at virtual address 0000000000000278, era == 9000000002fb279c, ra == 9000000003173434
[ 7.524862] Oops[#1]:
[ 7.524866] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.3.0+ #524
[ 7.524870] Hardware name: Loongson Loongson-3A5000-7A1000-1w-CRB/Loongson-LS3A5000-7A1000-1w-CRB, BIOS vUDK2018-LoongArch-V2.0.0-prebeta9 10/21/2022
[ 7.524872] pc 9000000002fb279c ra 9000000003173434 tp 90000001001f0000 sp 90000001001f3c00
[ 7.524875] a0 0000000000000000 a1 0000000000000000 a2 0000000000000000 a3 9000000004553e13
[ 7.524878] a4 9000000004553e16 a5 ffffffffffffffff a6 9000000003fd0948 a7 0000000000000030
[ 7.524881] t0 9000000003173434 t1 90000000035e2c00 t2 0000000000000001 t3 00000000fffff2b0
[ 7.524883] t4 0000000000000007 t5 fffffffffffffffe t6 0000000000000000 t7 0000000000000010
[ 7.524886] t8 00000000000000b4 u0 00000001c0840c76 s9 0000000000000000 s0 0000000000000000
[ 7.524889] s1 900000000370c458 s2 0000000000000001 s3 9000000101f81000 s4 9000000101f81038
[ 7.524891] s5 9000000101f813a0 s6 900000000370c398 s7 9000000003eebd18 s8 90000000037c0070
[ 7.524894] ra: 9000000003173434 power_supply_get_battery_info+0xe4/0x710
[ 7.591224] ERA: 9000000002fb279c __dev_fwnode+0x8/0x20
[ 7.853583] CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
[ 7.859740] PRMD: 00000004 (PPLV0 +PIE -PWE)
[ 7.864073] EUEN: 00000000 (-FPE -SXE -ASXE -BTE)
[ 7.868839] ECFG: 00071c1c (LIE=2-4,10-12 VS=7)
[ 7.873430] ESTAT: 00010000 [PIL] (IS= ECode=1 EsubCode=0)
[ 7.878884] BADV: 0000000000000278
[ 7.882346] PRID: 0014c010 (Loongson-64bit, Loongson-3A5000)
[ 7.888056] Modules linked in:
[ 7.891088] Process swapper/0 (pid: 1, threadinfo=0000000091357ee8, task=00000000313d98cb)
[ 7.899307] Stack : 00000000000000b4 900000000279aca8 0000000000000001 0000000000000000
[ 7.907274] 0000000000000049 0000000000000408 9000000100008c00 90000000035b6370
[ 7.915238] 900000000b801080 90000000029a440c 9000000003eb4680 9000000003eb4680
[ 7.923202] 9000000101f81038 900000000357cdcc 0000000000000001 900000000370c458
[ 7.931166] 9000000101f81000 90000000037c0070 9000000003eebd18 900000000370c398
[ 7.939131] 90000000045f4530 9000000101f81038 0000000000000000 0000000000000001
[ 7.947095] 900000000370c458 9000000101f81000 0000000000000000 9000000003173e64
[ 7.955059] 0000000000000026 9000000003de3880 9000000100562040 900000000357e07c
[ 7.963023] 000000000000026f 0000000000000001 90000001001f3d68 fffffffffffffff5
[ 7.970987] 90000000036d2ca8 90000000027429d8 90000000037c0030 0000000000000001
[ 7.978951] ...
[ 7.981379] Call Trace:
[ 7.981382] [<9000000002fb279c>] __dev_fwnode+0x8/0x20
[ 7.988916] [<9000000003173434>] power_supply_get_battery_info+0xe4/0x710
[ 7.995666] [<9000000003173e64>] __power_supply_register+0x404/0x580
[ 8.001984] [<900000000379d368>] test_power_init+0x6c/0x124
[ 8.007527] [<90000000026e08f8>] do_one_initcall+0x58/0x1ec
[ 8.013066] [<9000000003761614>] kernel_init_freeable+0x290/0x310
[ 8.019127] [<90000000035b40e8>] kernel_init+0x24/0x11c
[ 8.024324] [<90000000026e2048>] ret_from_kernel_thread+0xc/0xa4
[ 8.030295]
[ 8.031769] Code: 4c000020 0015002c 03400000 <28c9e08c> 40000d80 02c06184 4c000020 28ca0084 4c000020
Root cause: psy->dev.parent is NULL in power_supply_get_battery_info(),
so change the else branch to be 'else if (psy->dev.parent)' and return
-ENOENT if psy->dev.parent is NULL.
Fixes: 27a2195efa8d26447c ("power: supply: core: auto-exposure of simple-battery data")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel:
- power-supply core support for automatic handling of constant battery
data supplied by firmware
- generic-adc-battery: major cleanup
- axp288_charger: fix ACPI issues on x86 Android tablets
- rk817: cleanup and fix handling for low state of charge
* tag 'for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (26 commits)
power: supply: rk817: Fix low SOC bugs
power: supply: rk817: Drop unneeded debugging code
power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets
power: supply: generic-adc-battery: style fixes
power: supply: generic-adc-battery: improve error message
power: supply: generic-adc-battery: update copyright info
power: supply: generic-adc-battery: add DT support
power: supply: generic-adc-battery: add temperature support
power: supply: generic-adc-battery: simplify read_channel logic
power: supply: generic-adc-battery: use simple-battery API
power: supply: generic-adc-battery: drop memory alloc error message
power: supply: generic-adc-battery: drop charge now support
power: supply: generic-adc-battery: drop jitter delay support
power: supply: generic-adc-battery: fix unit scaling
power: supply: generic-adc-battery: convert to managed resources
power: supply: core: auto-exposure of simple-battery data
dt-bindings: power: supply: adc-battery: add binding
power: supply: bq256xx: Support to disable charger
power: supply: charger-manager: Use of_property_read_bool() for boolean properties
power: reset: qcom-pon: drop of_match_ptr for ID table
...
|