]> git.ipfire.org Git - thirdparty/linux.git/log
thirdparty/linux.git
6 months agoplatform/x86: dell-laptop: Use power_supply_charge_types_show/_parse() helpers
Hans de Goede [Sat, 21 Dec 2024 12:51:40 +0000 (13:51 +0100)] 
platform/x86: dell-laptop: Use power_supply_charge_types_show/_parse() helpers

Make battery_modes a map between tokens and enum power_supply_charge_type
values instead of between tokens and strings and use the new
power_supply_charge_types_show/_parse() helpers for show()/store()
to ensure that things are handled in the same way as in other drivers.

This also changes battery_supported_modes to be a bitmap of charge-types
(enum power_supply_charge_type values) rather then a bitmap of indices
into battery_modes[].

Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20241221125140.345776-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq2415x_charger: Immediately reschedule delayed work on notifier events
Sicelo A. Mhlongo [Sat, 21 Dec 2024 16:10:23 +0000 (18:10 +0200)] 
power: supply: bq2415x_charger: Immediately reschedule delayed work on notifier events

When the notifier is called we want to schedule the worker as
soon as possible. Thus it makes sense to reschedule any waiting
work and only queue a new one if there is none.

Suggested-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Link: https://lore.kernel.org/r/20241221161124.114989-1-absicsz@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: Add STC3117 fuel gauge unit driver
Bhavin Sharma [Fri, 20 Dec 2024 08:49:55 +0000 (14:19 +0530)] 
power: supply: Add STC3117 fuel gauge unit driver

Adds initial support for the STC3117 fuel gauge.

The driver provides functionality to monitor key parameters including:
Voltage, Current, State of Charge (SOC), Temperature, Status

Co-developed-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Signed-off-by: Bhavin Sharma <bhavin.sharma@siliconsignals.io>
Link: https://lore.kernel.org/r/20241220084958.32367-3-bhavin.sharma@siliconsignals.io
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agodt-bindings: power: supply: Add STC3117 Fuel Gauge
Hardevsinh Palaniya [Fri, 20 Dec 2024 08:49:54 +0000 (14:19 +0530)] 
dt-bindings: power: supply: Add STC3117 Fuel Gauge

The STC3117 provides a simple fuel gauge via I2C.
Add a DT schema to describe how to set it up in the device tree.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io>
Signed-off-by: Bhavin Sharma <bhavin.sharma@siliconsignals.io>
Link: https://lore.kernel.org/r/20241220084958.32367-2-bhavin.sharma@siliconsignals.io
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ug3105_battery: Let the core handle POWER_SUPPLY_PROP_TECHNOLOGY
Hans de Goede [Sun, 15 Dec 2024 17:21:26 +0000 (18:21 +0100)] 
power: supply: ug3105_battery: Let the core handle POWER_SUPPLY_PROP_TECHNOLOGY

The power-supply core already takes care of handling
POWER_SUPPLY_PROP_TECHNOLOGY based on the battery_info.

Drop the unnecessary handling from the driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241215172133.178460-4-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: gpio-charger: add support for default charge current limit
Dimitri Fedrau [Wed, 18 Dec 2024 08:35:01 +0000 (09:35 +0100)] 
power: supply: gpio-charger: add support for default charge current limit

With DT properties charge-current-limit-gpios and
charge-current-limit-mapping one can define charge current limits in uA
using up to 32 GPIOs. At the moment the driver defaults to smallest charge
current limitation for safety reasons. When disabling charging is
supported, which should be common, the driver defaults to non charging on
probe. By having a default, charging can be enabled on probe for such
devices.

Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://lore.kernel.org/r/20241218-default-charge-current-limit-v3-2-b26118cf06b5@liebherr.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agodt-bindings: power: supply: gpio-charger: add support for default charge current...
Dimitri Fedrau [Wed, 18 Dec 2024 08:35:00 +0000 (09:35 +0100)] 
dt-bindings: power: supply: gpio-charger: add support for default charge current limit

With DT properties charge-current-limit-gpios and
charge-current-limit-mapping one can define charge current limits in uA
using up to 32 GPIOs. Add property charge-current-limit-default-microamp
which selects a default charge current limit that must be listed in
charge-current-limit-mapping.
This is helpful when the smallest possible charge current limit is 0uA. The
driver defaults to the smallest possible value at the moment, which
disables charging on probe. With the default its possible to setup a safe
charge current limit.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://lore.kernel.org/r/20241218-default-charge-current-limit-v3-1-b26118cf06b5@liebherr.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: Use power_supply_external_power_changed() in __power_supply_changed_work()
Hans de Goede [Sun, 15 Dec 2024 17:21:24 +0000 (18:21 +0100)] 
power: supply: Use power_supply_external_power_changed() in __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>
7 months agopower: supply: core: fix build of extension sysfs group if CONFIG_SYSFS=n
Thomas Weißschuh [Thu, 19 Dec 2024 14:28:18 +0000 (15:28 +0100)] 
power: supply: core: fix build of extension sysfs group if CONFIG_SYSFS=n

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>
7 months agopower: supply: bq2415x_charger: report charging state changes to userspace
Sicelo A. Mhlongo [Thu, 28 Nov 2024 08:57:28 +0000 (10:57 +0200)] 
power: supply: bq2415x_charger: report charging state changes to userspace

Continuously track the charging status register in order to send uevents
whenever the state changes. Generate an uevent also when the chip's OTG
line is toggled, in bq2415x_notifier_call().

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Link: https://lore.kernel.org/r/20241128085759.11840-2-absicsz@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agobq27xxx: add voltage min design for bq27000 and bq27200
Sicelo A. Mhlongo [Mon, 25 Nov 2024 15:12:58 +0000 (17:12 +0200)] 
bq27xxx: add voltage min design for bq27000 and bq27200

The bq27x00 gauges have an EEPROM register which contains the value of
the voltage that should be considered to be zero battery capacity. Expose
this to userspace using the VOLTAGE_MIN_DESIGN property.

Tested on Nokia N900 with bq27200.

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20241125151321.45440-1-absicsz@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: reset: as3722-poweroff: Remove unnecessary return in as3722_poweroff_probe
Nobuhiro Iwamatsu [Sun, 17 Nov 2024 05:34:43 +0000 (14:34 +0900)] 
power: reset: as3722-poweroff: Remove unnecessary return in as3722_poweroff_probe

The return is executed on the devm_register_sys_off_handler() line in
as3722_poweroff_probe, so the last return line is unnecessary. Remove it.

Fixes: 348fde771ce7 ("power: reset: as3722-poweroff: Use devm_register_sys_off_handler(POWER_OFF)")
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Acked-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20241117053443.1148902-1-iwamatsu@nigauri.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq24190: Add BQ24297 support
Hans de Goede [Sat, 16 Nov 2024 20:36:48 +0000 (21:36 +0100)] 
power: supply: bq24190: Add BQ24297 support

The BQ24297 is identical to the BQ24296 except that it uses USB D+ / D-
data-lines for charger-type (max. input-current) detection instead of
a PSEL input pin.

This is the same difference as between the already supported BQ24190
(D+ / D-) and the BQ24192 (PSEL).

Note just like with the BQ24190 vs BQ24192 there is no difference how
the charger-IC works at the register-level. The only difference is in
the external hardware interface.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241116203648.169100-3-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agodt-bindings: power: supply: bq24190: Add BQ24297 compatible
Hans de Goede [Sat, 16 Nov 2024 20:36:46 +0000 (21:36 +0100)] 
dt-bindings: power: supply: bq24190: Add BQ24297 compatible

The BQ24297 is identical to the BQ24296 except that it uses USB D+ / D-
data-lines for charger-type (max. input-current) detection instead of
a PSEL input pin.

This is the same difference as between the already supported BQ24190
(D+ / D-) and the BQ24192 (PSEL).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/r/20241116203648.169100-1-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: add UAPI to discover currently used extensions
Thomas Weißschuh [Wed, 11 Dec 2024 19:57:58 +0000 (20:57 +0100)] 
power: supply: core: add UAPI to discover currently used extensions

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>
7 months agopower: supply: cros_charge-control: implement a power supply extension
Thomas Weißschuh [Wed, 11 Dec 2024 19:57:57 +0000 (20:57 +0100)] 
power: supply: cros_charge-control: implement a power supply extension

Power supply extensions provide an easier mechanism to implement
additional properties for existing power supplies.
Use that instead of reimplementing the sysfs attributes manually.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241211-power-supply-extensions-v6-3-9d9dc3f3d387@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: Merge fixes branch into for-next
Sebastian Reichel [Sat, 14 Dec 2024 21:21:20 +0000 (22:21 +0100)] 
power: supply: Merge fixes branch into for-next

Merge the fixes branch into the development branch, since the it
contains multiple changes to the cros_charge-control driver needed to
convert it to the new power-supply extension framework.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: test-power: implement a power supply extension
Thomas Weißschuh [Wed, 11 Dec 2024 19:57:56 +0000 (20:57 +0100)] 
power: supply: test-power: implement a power supply extension

Allow easy testing of the new power supply extension functionality.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241211-power-supply-extensions-v6-2-9d9dc3f3d387@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: implement extension API
Thomas Weißschuh [Wed, 11 Dec 2024 19:57:55 +0000 (20:57 +0100)] 
power: supply: core: implement extension API

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>
7 months agopower: supply: ltc4162-l-charger: Add support for ltc4162-f/s and ltc4015
Kim Seer Paller [Fri, 13 Dec 2024 02:37:46 +0000 (10:37 +0800)] 
power: supply: ltc4162-l-charger: Add support for ltc4162-f/s and ltc4015

LTC4162-L 35V/3.2A Multi-Cell Lithium-Ion Step-Down Battery Charger
LTC4162-F 35V/3.2A Multi-Cell LiFePO4 Step-Down Battery Charger
LTC4162-S 35V/3.2A Lead-Acid Step-Down Battery Charger
LTC4015 35V/3.2A Multichemistry Buck Battery Charger Controller

The LTC4162-L/F/S variants and LTC4015 share a common set of registers.
The difference lies in the resolution value of the scaling factor for
battery voltage and battery current measurement, input voltage, and
input current for different battery chemistries. The difference also
includes the calculation of setting and getting the actual voltage
setting applied to the charge voltage, as well as getting the die
temperature. Adding chip info structure to encapsulates these
differences by defining function pointers and parameters specific to
each device. This structure includes:
  - function pointers for getting and setting various parameters such as
    battery voltage, charge voltage, and die temperature
  - resolution parameters for battery current and input voltage
  - telemetry mask to specify which bits in the register are used for
    telemetry features

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://lore.kernel.org/r/20241213023746.34168-3-kimseer.paller@analog.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agodt-bindings: power: supply: ltc4162-l-charger: Add ltc4162-f/s and ltc4015
Kim Seer Paller [Fri, 13 Dec 2024 02:37:45 +0000 (10:37 +0800)] 
dt-bindings: power: supply: ltc4162-l-charger: Add ltc4162-f/s and ltc4015

Add LTC4162-F/S and LTC4015 to the supported devices of LTC4162-L.
They share a common set of registers. The only differences lie in the
resolution value of the scaling factor for battery voltage and battery
current measurement, input voltage, and input current for different
battery chemistries. The differences also include the calculation of
setting and getting the actual voltage applied to the charge voltage,
as well as getting the die temperature.

This add compatible entries for ltc4162-f/s and ltc4015 and include
datasheets for new devices.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://lore.kernel.org/r/20241213023746.34168-2-kimseer.paller@analog.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq24190_charger: Add support for "charge_types" property
Hans de Goede [Wed, 11 Dec 2024 17:44:50 +0000 (18:44 +0100)] 
power: supply: bq24190_charger: Add support for "charge_types" property

The bq24190 power_supply class device has a writeable "charge_type"
property, add support for the new "charge_types" property. Reading this
returns a list of supported charge-types with the currently active type
surrounded by square brackets, allowing userspace to find out which
enum power_supply_charge_type values are supported.

This has been tested on a GPD win gaming-handheld.

Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20241211174451.355421-4-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: Add new "charge_types" property
Hans de Goede [Wed, 11 Dec 2024 17:44:49 +0000 (18:44 +0100)] 
power: supply: core: Add new "charge_types" property

Add a new "charge_types" property, this is identical to "charge_type" but
reading returns a list of supported charge-types with the currently active
type surrounded by square brackets, e.g.:

Fast [Standard] "Long_Life"

This has the advantage over the existing "charge_type" property that this
allows userspace to find out which charge-types are supported for writable
charge_type properties.

Drivers which already support "charge_type" can easily add support for
this by setting power_supply_desc.charge_types to a bitmask representing
valid charge_type values. The existing "charge_type" get_property() and
set_property() code paths can be re-used for "charge_types".

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241211174451.355421-3-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: reset: at91-reset: add sdhwc support for sam9x7 SoC
Varshini Rajendran [Thu, 10 Oct 2024 12:04:14 +0000 (17:34 +0530)] 
power: reset: at91-reset: add sdhwc support for sam9x7 SoC

Add shutdown controller support for SAM9X7 SoC.

Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/20241010120414.92993-1-varshini.rajendran@microchip.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: reset: at91-reset: add reset support for sam9x7 SoC
Varshini Rajendran [Thu, 10 Oct 2024 12:04:10 +0000 (17:34 +0530)] 
power: reset: at91-reset: add reset support for sam9x7 SoC

Add power reset support for SAM9X7 SoC.

Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/20241010120410.92942-1-varshini.rajendran@microchip.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: reset: at91-poweroff: lookup for proper pmc dt node for sam9x7
Varshini Rajendran [Thu, 10 Oct 2024 12:04:04 +0000 (17:34 +0530)] 
power: reset: at91-poweroff: lookup for proper pmc dt node for sam9x7

Use sam9x7 pmc's compatible to lookup for in the SHDWC driver.

Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/20241010120404.92893-1-varshini.rajendran@microchip.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agodt-bindings: power: reset: atmel,sama5d2-shdwc: add sam9x7
Varshini Rajendran [Thu, 10 Oct 2024 12:04:25 +0000 (17:34 +0530)] 
dt-bindings: power: reset: atmel,sama5d2-shdwc: add sam9x7

Add shutdown controller DT bindings.

Signed-off-by: Varshini Rajendran <varshini.rajendran@microchip.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20241010120425.93102-1-varshini.rajendran@microchip.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: reset: gpio-poweroff: Clarify the warning message
Fabio Estevam [Thu, 12 Dec 2024 13:04:56 +0000 (10:04 -0300)] 
power: reset: gpio-poweroff: Clarify the warning message

When gpio-poweroff fails, a WARN_ON() is triggered without
an explanation to the user about the failure.

Add some comments explaining that the attempt to poweroff the system
via gpio-poweroff failed and convert it to a WARN() message with a
bit of context to provide some hint to the user.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/20241212130456.580197-1-festevam@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: power_supply_show_enum_with_available(): Replace spaces with '_'
Hans de Goede [Mon, 9 Dec 2024 20:40:48 +0000 (21:40 +0100)] 
power: supply: power_supply_show_enum_with_available(): Replace spaces with '_'

Some enum style power-supply properties have text-values / labels for some
of the enum values containing a space, e.g. "Long Life" for
POWER_SUPPLY_CHARGE_TYPE_LONGLIFE.

Make power_supply_show_enum_with_available() replace these spaces with
'_' when showing the available text-values. After this the output for
a battery which supports "Long Life" will be e.g.:

Fast [Standard] Long_Life

or:

Fast Standard [Long_Life]

Modify power_supply_store_property() to accept both the original text-value
with space and the alternative value with the spaces replaced by '_'.
This allows users to write the value with '_' after seeing this on reading
the property.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241209204051.8786-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq24257_charger: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:56:01 +0000 (22:56 +0100)] 
power: supply: bq24257_charger: use dev_to_psy()

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-14-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq24190_charger: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:56:00 +0000 (22:56 +0100)] 
power: supply: bq24190_charger: use dev_to_psy()

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-13-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq2415x_charger: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:59 +0000 (22:55 +0100)] 
power: supply: bq2415x_charger: use dev_to_psy()

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-12-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: surface_battery: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:58 +0000 (22:55 +0100)] 
power: supply: surface_battery: use dev_to_psy()

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-11-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ab8500: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:57 +0000 (22:55 +0100)] 
power: supply: ab8500: use dev_to_psy()

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-10-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: sysfs: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:56 +0000 (22:55 +0100)] 
power: supply: sysfs: use dev_to_psy()

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-9-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: use dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:55 +0000 (22:55 +0100)] 
power: supply: core: use dev_to_psy()

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>
7 months agopower: supply: core: introduce dev_to_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:54 +0000 (22:55 +0100)] 
power: supply: core: introduce dev_to_psy()

The psy core and drivers currently use dev_get_drvdata() to go from a
'struct device' to its 'struct power_supply'.
This is not typesafe and or documented.

Introduce a new helper to make this pattern explicit.
Instead of using dev_get_drvdata(), use container_of_const() which
also preserves the constness.
Furthermore 'dev' does need to be dereferenced anymore and at some point
the drvdata could be reused for something else.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241210-power-supply-dev_to_psy-v2-7-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: remove power_supply_for_each_device()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:53 +0000 (22:55 +0100)] 
power: supply: core: remove power_supply_for_each_device()

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>
7 months agopower: supply: apm_power: use power_supply_for_each_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:52 +0000 (22:55 +0100)] 
power: supply: apm_power: use power_supply_for_each_psy()

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-5-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ab8500: use power_supply_for_each_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:51 +0000 (22:55 +0100)] 
power: supply: ab8500: use power_supply_for_each_psy()

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-4-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: use power_supply_for_each_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:50 +0000 (22:55 +0100)] 
power: supply: core: use power_supply_for_each_psy()

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>
7 months agopower: supply: core: introduce power_supply_for_each_psy()
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:49 +0000 (22:55 +0100)] 
power: supply: core: introduce power_supply_for_each_psy()

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>
7 months agopower: supply: mm8013: use accessor for driver data
Thomas Weißschuh [Tue, 10 Dec 2024 21:55:48 +0000 (22:55 +0100)] 
power: supply: mm8013: use accessor for driver data

Instead of directly accessing the structure member, use the accessor.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241210-power-supply-dev_to_psy-v2-1-9d8c9d24cfe4@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: cros_charge-control: hide start threshold on v2 cmd
Thomas Weißschuh [Sun, 8 Dec 2024 14:59:28 +0000 (15:59 +0100)] 
power: supply: cros_charge-control: hide start threshold on v2 cmd

ECs implementing the v2 command will not stop charging when the end
threshold is reached. Instead they will begin discharging until the
start threshold is reached, leading to permanent charge and discharge
cycles. This defeats the point of the charge control mechanism.

Avoid the issue by hiding the start threshold on v2 systems.
Instead on those systems program the EC with start == end which forces
the EC to reach and stay at that level.

v1 does not support thresholds and v3 works correctly,
at least judging from the code.

Reported-by: Thomas Koch <linrunner@gmx.net>
Fixes: c6ed48ef5259 ("power: supply: add ChromeOS EC based charge control driver")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241208-cros_charge-control-v2-v1-3-8d168d0f08a3@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: cros_charge-control: allow start_threshold == end_threshold
Thomas Weißschuh [Sun, 8 Dec 2024 14:59:27 +0000 (15:59 +0100)] 
power: supply: cros_charge-control: allow start_threshold == end_threshold

Allow setting the start and stop thresholds to the same value.
There is no reason to disallow it.

Suggested-by: Thomas Koch <linrunner@gmx.net>
Fixes: c6ed48ef5259 ("power: supply: add ChromeOS EC based charge control driver")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241208-cros_charge-control-v2-v1-2-8d168d0f08a3@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: cros_charge-control: add mutex for driver data
Thomas Weißschuh [Sun, 8 Dec 2024 14:59:26 +0000 (15:59 +0100)] 
power: supply: cros_charge-control: add mutex for driver data

Concurrent accesses through sysfs may lead to inconsistent state in the
priv data. Introduce a mutex to avoid this.

Fixes: c6ed48ef5259 ("power: supply: add ChromeOS EC based charge control driver")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241208-cros_charge-control-v2-v1-1-8d168d0f08a3@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: gpio-charger: Fix set charge current limits
Dimitri Fedrau [Mon, 9 Dec 2024 10:46:15 +0000 (11:46 +0100)] 
power: supply: gpio-charger: Fix set charge current limits

Fix set charge current limits for devices which allow to set the lowest
charge current limit to be greater zero. If requested charge current limit
is below lowest limit, the index equals current_limit_map_size which leads
to accessing memory beyond allocated memory.

Fixes: be2919d8355e ("power: supply: gpio-charger: add charge-current-limit feature")
Cc: stable@vger.kernel.org
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://lore.kernel.org/r/20241209-fix-charge-current-limit-v1-1-760d9b8f2af3@liebherr.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Fix uninitialized variable read
Bence Csókás [Sun, 8 Dec 2024 13:15:31 +0000 (14:15 +0100)] 
power: ip5xxx_power: Fix uninitialized variable read

The check for whether a charger supports the requested
battery voltage was incorrectly added to the
`ip5xxx_battery_get_voltage_max()` function, instead of
`set_voltage_max()`. This commit fixes it.

Reported-by: Kees Bakker <kees@ijzerbout.nl>
Closes: https://lore.kernel.org/linux-kernel/b547c228-df70-4137-9e96-175923f62404@ijzerbout.nl/
Fixes: 8584bc5df539 ("power: ip5xxx_power: Allow for more parameters to be configured")
Signed-off-by: Bence Csókás <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241208131532.1028581-1-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: bq24190_charger: Fix typo 'jeta' -> 'jeita'
Sho Tanimoto [Thu, 5 Dec 2024 08:46:00 +0000 (17:46 +0900)] 
power: supply: bq24190_charger: Fix typo 'jeta' -> 'jeita'

The sysfs file 'jeta_iset' was probably intended for 'jeita_iset'

Signed-off-by: Sho Tanimoto <mojyack@gmail.com>
Link: https://lore.kernel.org/r/20241205084601.2720462-1-mojyack@gmail.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Add support for IP5306
Csókás, Bence [Tue, 19 Nov 2024 18:07:40 +0000 (19:07 +0100)] 
power: ip5xxx_power: Add support for IP5306

Add ip5xxx_regfield_config for IP5306

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-8-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agodt-bindings: trivial-devices: Add Injoinic IP5306
Csókás, Bence [Tue, 19 Nov 2024 18:07:39 +0000 (19:07 +0100)] 
dt-bindings: trivial-devices: Add Injoinic IP5306

It is to be handled with the rest of the IP51xx/52xx family.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-7-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Fall back to Charge End bit if status register is absent
Csókás, Bence [Tue, 19 Nov 2024 18:07:38 +0000 (19:07 +0100)] 
power: ip5xxx_power: Fall back to Charge End bit if status register is absent

On parts where there is no status register, check the Charge End
bit to set charging/not charging status. Fullness, trickle charge
status, discharging etc. cannot be determined from just this bit.

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-6-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Check for optional bits
Csókás, Bence [Tue, 19 Nov 2024 18:07:37 +0000 (19:07 +0100)] 
power: ip5xxx_power: Check for optional bits

Some parts may not have certain control bits. These bits
however may be non-essential to the system's operation,
as the default behaviour is the one we would set anyways,
or the bits are not applicable for said part (e. g. enabling
NTC on a part without an NTC pin, or one where it cannot
be disabled via registers anyways).

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-5-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Add battery type for 4.4V
Csókás, Bence [Tue, 19 Nov 2024 18:07:36 +0000 (19:07 +0100)] 
power: ip5xxx_power: Add battery type for 4.4V

IP53xx series supports 4.4V batteries. Add support for it
to compatible parts (that have `vbat_max` set to >= 4.4 V).

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-4-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Allow for more parameters to be configured
Csókás, Bence [Tue, 19 Nov 2024 18:07:35 +0000 (19:07 +0100)] 
power: ip5xxx_power: Allow for more parameters to be configured

Other parts such as IP5306 may support other battery voltages and
have different constants for input voltage regulation. Allow these
to be passed from `struct ip5xxx_regfield_config`.

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-3-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Use regmap_field API
Csókás, Bence [Tue, 19 Nov 2024 18:07:33 +0000 (19:07 +0100)] 
power: ip5xxx_power: Use regmap_field API

The IP53xx series [1] has a much different register
layout than the 51xx/52xx [2] currently supported
by this driver. To accommodate supporting the former,
refactor the code to use the flexible regmap_field API.

[1] https://sharvielectronics.com/wp-content/uploads/2021/07/IP5306-I2C-registers.pdf
[2] https://www.windworkshop.cn/wp-content/uploads/2022/04/IP5209-IP5109-IP5207-IP5108-I2C-registers.pdf

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-1-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: ip5xxx_power: Fix return value on ADC read errors
Csókás, Bence [Tue, 19 Nov 2024 18:07:34 +0000 (19:07 +0100)] 
power: ip5xxx_power: Fix return value on ADC read errors

If ADC read returns an error, the return value was silently ignored,
execution continued and an uninitialized value and a return code of 0
was passed back to userspace. The only exception was
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, which bailed out correctly.
Fix returns for the other cases as well.

Fixes: 75853406fa27 ("power: supply: Add a driver for Injoinic power bank ICs")
Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-2-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: sysfs: rework uevent property loop
Thomas Weißschuh [Mon, 11 Nov 2024 21:40:08 +0000 (22:40 +0100)] 
power: supply: sysfs: rework uevent property loop

Instead of looping through all properties known to be supported by the
psy, loop over all known properties and decide based on the return value
of power_supply_get_property() whether the property existed.

This makes the code shorter now and even more so when power supply
extensions are added.
It also simplifies the locking, as it can all happen inside
power_supply_get_property().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20241111-power-supply-extensions-v4-6-7240144daa8e@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: sysfs: prepare for power supply extensions
Thomas Weißschuh [Mon, 11 Nov 2024 21:40:07 +0000 (22:40 +0100)] 
power: supply: sysfs: prepare for power supply extensions

The upcoming extension API will add properties which are not part of the
the power_supply_desc.
Use power_supply_has_property() so the properties from extensions are
also checked.

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>
Link: https://lore.kernel.org/r/20241111-power-supply-extensions-v4-5-7240144daa8e@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: hwmon: prepare for power supply extensions
Thomas Weißschuh [Mon, 11 Nov 2024 21:40:06 +0000 (22:40 +0100)] 
power: supply: hwmon: prepare for power supply extensions

The upcoming extension API will add properties which are not part of the
the power_supply_desc.
Use power_supply_has_property() so the properties from extensions are
also checked.

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-4-7240144daa8e@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: core: introduce power_supply_has_property()
Thomas Weißschuh [Mon, 11 Nov 2024 21:40:05 +0000 (22:40 +0100)] 
power: supply: core: introduce power_supply_has_property()

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>
7 months agopower: supply: core: rename psy_has_property() to psy_desc_has_property()
Thomas Weißschuh [Mon, 11 Nov 2024 21:40:04 +0000 (22:40 +0100)] 
power: supply: core: rename psy_has_property() to psy_desc_has_property()

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>
7 months agopower: supply: sysfs: print single value in uevent for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR
Thomas Weißschuh [Mon, 11 Nov 2024 21:40:03 +0000 (22:40 +0100)] 
power: supply: sysfs: print single value in uevent for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR

Currently an uevent contains the same string representation of a
property as sysfs. However for POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR this
is specially formatted to indicate all possible values.
This doesn't make sense for uevents and complicates parsing.
Instead only include the currently active value in uevents.

As currently no in-tree driver uses POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR
this change is not a problem.
Soon the property will actually be used so fix the formatting before
that happens.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20241111-power-supply-extensions-v4-1-7240144daa8e@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: max1720x: add charge full property
Dimitri Fedrau [Tue, 3 Dec 2024 08:04:36 +0000 (09:04 +0100)] 
power: supply: max1720x: add charge full property

Charge full holds the calculated full capacity of the cell based on all
inputs from the ModelGauge m5 algorithm including empty compensation. A
new full-capacity value is calculated continuously as application
conditions change.

Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://lore.kernel.org/r/20241203-max1720x-charge-full-prop-v1-1-b02776b43f17@liebherr.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2782: Use devm_delayed_work_autocancel() helper
Andrew Davis [Mon, 2 Dec 2024 21:15:19 +0000 (15:15 -0600)] 
power: supply: ds2782: Use devm_delayed_work_autocancel() helper

Use the device lifecycle managed work init function. This helps prevent
mistakes like canceling out of order in cleanup functions and
forgetting to canceling on error paths.

Note we move this to after the registering the power supply so that
the cancel is called before unregistering.

This was the last thing the .remove() function did, so remove that too.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20241202211519.199635-5-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2782: Use devm_power_supply_register() helper
Andrew Davis [Mon, 2 Dec 2024 21:15:18 +0000 (15:15 -0600)] 
power: supply: ds2782: Use devm_power_supply_register() helper

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20241202211519.199635-4-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2782: Use devm based memory allocators
Andrew Davis [Mon, 2 Dec 2024 21:15:17 +0000 (15:15 -0600)] 
power: supply: ds2782: Use devm based memory allocators

Use device lifecycle managed memory alloc helpers. This helps
prevent mistakes like freeing out of order in cleanup functions and
forgetting to free on all error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20241202211519.199635-3-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2782: Free IDA with devm action
Andrew Davis [Mon, 2 Dec 2024 21:15:16 +0000 (15:15 -0600)] 
power: supply: ds2782: Free IDA with devm action

This helps prevent mistakes like freeing out of order in cleanup functions
and forgetting to free on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20241202211519.199635-2-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2782: Switch to simpler IDA interface
Andrew Davis [Mon, 2 Dec 2024 21:15:15 +0000 (15:15 -0600)] 
power: supply: ds2782: Switch to simpler IDA interface

We don't need to specify any ranges when allocating IDs so we can switch
to ida_alloc() and ida_free() instead of idr_*.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20241202211519.199635-1-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: olpc_battery: constify 'struct bin_attribute'
Thomas Weißschuh [Mon, 2 Dec 2024 19:02:22 +0000 (20:02 +0100)] 
power: supply: olpc_battery: constify 'struct bin_attribute'

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241202-sysfs-const-bin_attr-psy-v1-4-f846430b8b66@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2781: constify 'struct bin_attribute'
Thomas Weißschuh [Mon, 2 Dec 2024 19:02:21 +0000 (20:02 +0100)] 
power: supply: ds2781: constify 'struct bin_attribute'

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241202-sysfs-const-bin_attr-psy-v1-3-f846430b8b66@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2780: constify 'struct bin_attribute'
Thomas Weißschuh [Mon, 2 Dec 2024 19:02:20 +0000 (20:02 +0100)] 
power: supply: ds2780: constify 'struct bin_attribute'

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241202-sysfs-const-bin_attr-psy-v1-2-f846430b8b66@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agopower: supply: ds2760: constify 'struct bin_attribute'
Thomas Weißschuh [Mon, 2 Dec 2024 19:02:19 +0000 (20:02 +0100)] 
power: supply: ds2760: constify 'struct bin_attribute'

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241202-sysfs-const-bin_attr-psy-v1-1-f846430b8b66@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
7 months agoLinux 6.13-rc1 v6.13-rc1
Linus Torvalds [Sun, 1 Dec 2024 22:28:56 +0000 (14:28 -0800)] 
Linux 6.13-rc1

7 months agoMerge tag 'i2c-for-6.13-rc1-part3' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 1 Dec 2024 21:38:24 +0000 (13:38 -0800)] 
Merge tag 'i2c-for-6.13-rc1-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c component probing support from Wolfram Sang:
 "Add OF component probing.

  Some devices are designed and manufactured with some components having
  multiple drop-in replacement options. These components are often
  connected to the mainboard via ribbon cables, having the same signals
  and pin assignments across all options. These may include the display
  panel and touchscreen on laptops and tablets, and the trackpad on
  laptops. Sometimes which component option is used in a particular
  device can be detected by some firmware provided identifier, other
  times that information is not available, and the kernel has to try to
  probe each device.

  Instead of a delicate dance between drivers and device tree quirks,
  this change introduces a simple I2C component probe function. For a
  given class of devices on the same I2C bus, it will go through all of
  them, doing a simple I2C read transfer and see which one of them
  responds. It will then enable the device that responds"

* tag 'i2c-for-6.13-rc1-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  MAINTAINERS: fix typo in I2C OF COMPONENT PROBER
  of: base: Document prefix argument for of_get_next_child_with_prefix()
  i2c: Fix whitespace style issue
  arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads as fail
  platform/chrome: Introduce device tree hardware prober
  i2c: of-prober: Add GPIO support to simple helpers
  i2c: of-prober: Add simple helpers for regulator support
  i2c: Introduce OF component probe function
  of: base: Add for_each_child_of_node_with_prefix()
  of: dynamic: Add of_changeset_update_prop_string

7 months agoMerge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
Linus Torvalds [Sun, 1 Dec 2024 21:10:51 +0000 (13:10 -0800)] 
Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull bprintf() removal from Steven Rostedt:

 - Remove unused bprintf() function, that was added with the rest of the
   "bin-printf" functions.

   These are functions that are used by trace_printk() that allows to
   quickly save the format and arguments into the ring buffer without
   the expensive processing of converting numbers to ASCII. Then on
   output, at a much later time, the ring buffer is read and the string
   processing occurs then. The bprintf() was added for consistency but
   was never used. It can be safely removed.

* tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  printf: Remove unused 'bprintf'

7 months agoMerge tag 'timers_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 1 Dec 2024 20:41:21 +0000 (12:41 -0800)] 
Merge tag 'timers_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer fixes from Borislav Petkov:

 - Fix a case where posix timers with a thread-group-wide target would
   miss signals if some of the group's threads are exiting

 - Fix a hang caused by ndelay() calling the wrong delay function
   __udelay()

 - Fix a wrong offset calculation in adjtimex(2) when using ADJ_MICRO
   (microsecond resolution) and a negative offset

* tag 'timers_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  posix-timers: Target group sigqueue to current task only if not exiting
  delay: Fix ndelay() spuriously treated as udelay()
  ntp: Remove invalid cast in time offset math

7 months agoMerge tag 'irq_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 1 Dec 2024 20:37:58 +0000 (12:37 -0800)] 
Merge tag 'irq_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull irq fixes from Borislav Petkov:

 - Move the ->select callback to the correct ops structure in
   irq-mvebu-sei to fix some Marvell Armada platforms

 - Add a workaround for Hisilicon ITS erratum 162100801 which can cause
   some virtual interrupts to get lost

 - More platform_driver::remove() conversion

* tag 'irq_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip: Switch back to struct platform_driver::remove()
  irqchip/gicv3-its: Add workaround for hip09 ITS erratum 162100801
  irqchip/irq-mvebu-sei: Move misplaced select() callback to SEI CP domain

7 months agoMerge tag 'x86_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 1 Dec 2024 20:35:37 +0000 (12:35 -0800)] 
Merge tag 'x86_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:

 - Add a terminating zero end-element to the array describing AMD CPUs
   affected by erratum 1386 so that the matching loop actually
   terminates instead of going off into the weeds

 - Update the boot protocol documentation to mention the fact that the
   preferred address to load the kernel to is considered in the
   relocatable kernel case too

 - Flush the memory buffer containing the microcode patch after applying
   microcode on AMD Zen1 and Zen2, to avoid unnecessary slowdowns

 - Make sure the PPIN CPU feature flag is cleared on all CPUs if PPIN
   has been disabled

* tag 'x86_urgent_for_v6.13_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/CPU/AMD: Terminate the erratum_1386_microcode array
  x86/Documentation: Update algo in init_size description of boot protocol
  x86/microcode/AMD: Flush patch buffer mapping after application
  x86/mm: Carve out INVLPG inline asm for use by others
  x86/cpu: Fix PPIN initialization

7 months agostrscpy: write destination buffer only once
Linus Torvalds [Sun, 1 Dec 2024 17:23:33 +0000 (09:23 -0800)] 
strscpy: write destination buffer only once

The point behind strscpy() was to once and for all avoid all the
problems with 'strncpy()' and later broken "fixed" versions like
strlcpy() that just made things worse.

So strscpy not only guarantees NUL-termination (unlike strncpy), it also
doesn't do unnecessary padding at the destination.  But at the same time
also avoids byte-at-a-time reads and writes by _allowing_ some extra NUL
writes - within the size, of course - so that the whole copy can be done
with word operations.

It is also stable in the face of a mutable source string: it explicitly
does not read the source buffer multiple times (so an implementation
using "strnlen()+memcpy()" would be wrong), and does not read the source
buffer past the size (like the mis-design that is strlcpy does).

Finally, the return value is designed to be simple and unambiguous: if
the string cannot be copied fully, it returns an actual negative error,
making error handling clearer and simpler (and the caller already knows
the size of the buffer).  Otherwise it returns the string length of the
result.

However, there was one final stability issue that can be important to
callers: the stability of the destination buffer.

In particular, the same way we shouldn't read the source buffer more
than once, we should avoid doing multiple writes to the destination
buffer: first writing a potentially non-terminated string, and then
terminating it with NUL at the end does not result in a stable result
buffer.

Yes, it gives the right result in the end, but if the rule for the
destination buffer was that it is _always_ NUL-terminated even when
accessed concurrently with updates, the final byte of the buffer needs
to always _stay_ as a NUL byte.

[ Note that "final byte is NUL" here is literally about the final byte
  in the destination array, not the terminating NUL at the end of the
  string itself. There is no attempt to try to make concurrent reads and
  writes give any kind of consistent string length or contents, but we
  do want to guarantee that there is always at least that final
  terminating NUL character at the end of the destination array if it
  existed before ]

This is relevant in the kernel for the tsk->comm[] array, for example.
Even without locking (for either readers or writers), we want to know
that while the buffer contents may be garbled, it is always a valid C
string and always has a NUL character at 'comm[TASK_COMM_LEN-1]' (and
never has any "out of thin air" data).

So avoid any "copy possibly non-terminated string, and terminate later"
behavior, and write the destination buffer only once.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 months agoprintf: Remove unused 'bprintf'
Dr. David Alan Gilbert [Wed, 2 Oct 2024 17:31:47 +0000 (18:31 +0100)] 
printf: Remove unused 'bprintf'

bprintf() is unused. Remove it. It was added in the commit 4370aa4aa753
("vsprintf: add binary printf") but as far as I can see was never used,
unlike the other two functions in that patch.

Link: https://lore.kernel.org/20241002173147.210107-1-linux@treblig.org
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Acked-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
7 months agoMerge tag 'turbostat-2024.11.30' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 1 Dec 2024 02:30:22 +0000 (18:30 -0800)] 
Merge tag 'turbostat-2024.11.30' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux

Pull turbostat updates from Len Brown:

 - assorted minor bug fixes

 - assorted platform specific tweaks

 - initial RAPL PSYS (SysWatt) support

* tag 'turbostat-2024.11.30' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: 2024.11.30
  tools/power turbostat: Add RAPL psys as a built-in counter
  tools/power turbostat: Fix child's argument forwarding
  tools/power turbostat: Force --no-perf in --dump mode
  tools/power turbostat: Add support for /sys/class/drm/card1
  tools/power turbostat: Cache graphics sysfs file descriptors during probe
  tools/power turbostat: Consolidate graphics sysfs access
  tools/power turbostat: Remove unnecessary fflush() call
  tools/power turbostat: Enhance platform divergence description
  tools/power turbostat: Add initial support for GraniteRapids-D
  tools/power turbostat: Remove PC3 support on Lunarlake
  tools/power turbostat: Rename arl_features to lnl_features
  tools/power turbostat: Add back PC8 support on Arrowlake
  tools/power turbostat: Remove PC7/PC9 support on MTL
  tools/power turbostat: Honor --show CPU, even when even when num_cpus=1
  tools/power turbostat: Fix trailing '\n' parsing
  tools/power turbostat: Allow using cpu device in perf counters on hybrid platforms
  tools/power turbostat: Fix column printing for PMT xtal_time counters
  tools/power turbostat: fix GCC9 build regression

7 months agoMerge tag 'pci-v6.13-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
Linus Torvalds [Sun, 1 Dec 2024 02:23:05 +0000 (18:23 -0800)] 
Merge tag 'pci-v6.13-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci

Pull PCI fix from Bjorn Helgaas:

 - When removing a PCI device, only look up and remove a platform device
   if there is an associated device node for which there could be a
   platform device, to fix a merge window regression (Brian Norris)

* tag 'pci-v6.13-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci:
  PCI/pwrctrl: Unregister platform device only if one actually exists

7 months agoMerge tag 'lsm-pr-20241129' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm
Linus Torvalds [Sun, 1 Dec 2024 02:14:56 +0000 (18:14 -0800)] 
Merge tag 'lsm-pr-20241129' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm

Pull ima fix from Paul Moore:
 "One small patch to fix a function parameter / local variable naming
  snafu that went up to you in the current merge window"

* tag 'lsm-pr-20241129' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm:
  ima: uncover hidden variable in ima_match_rules()

7 months agoMerge tag 'block-6.13-20242901' of git://git.kernel.dk/linux
Linus Torvalds [Sat, 30 Nov 2024 23:47:29 +0000 (15:47 -0800)] 
Merge tag 'block-6.13-20242901' of git://git.kernel.dk/linux

Pull more block updates from Jens Axboe:

 - NVMe pull request via Keith:
      - Use correct srcu list traversal (Breno)
      - Scatter-gather support for metadata (Keith)
      - Fabrics shutdown race condition fix (Nilay)
      - Persistent reservations updates (Guixin)

 - Add the required bits for MD atomic write support for raid0/1/10

 - Correct return value for unknown opcode in ublk

 - Fix deadlock with zone revalidation

 - Fix for the io priority request vs bio cleanups

 - Use the correct unsigned int type for various limit helpers

 - Fix for a race in loop

 - Cleanup blk_rq_prep_clone() to prevent uninit-value warning and make
   it easier for actual humans to read

 - Fix potential UAF when iterating tags

 - A few fixes for bfq-iosched UAF issues

 - Fix for brd discard not decrementing the allocated page count

 - Various little fixes and cleanups

* tag 'block-6.13-20242901' of git://git.kernel.dk/linux: (36 commits)
  brd: decrease the number of allocated pages which discarded
  block, bfq: fix bfqq uaf in bfq_limit_depth()
  block: Don't allow an atomic write be truncated in blkdev_write_iter()
  mq-deadline: don't call req_get_ioprio from the I/O completion handler
  block: Prevent potential deadlock in blk_revalidate_disk_zones()
  block: Remove extra part pointer NULLify in blk_rq_init()
  nvme: tuning pr code by using defined structs and macros
  nvme: introduce change ptpl and iekey definition
  block: return bool from get_disk_ro and bdev_read_only
  block: remove a duplicate definition for bdev_read_only
  block: return bool from blk_rq_aligned
  block: return unsigned int from blk_lim_dma_alignment_and_pad
  block: return unsigned int from queue_dma_alignment
  block: return unsigned int from bdev_io_opt
  block: req->bio is always set in the merge code
  block: don't bother checking the data direction for merges
  block: blk-mq: fix uninit-value in blk_rq_prep_clone and refactor
  Revert "block, bfq: merge bfq_release_process_ref() into bfq_put_cooperator()"
  md/raid10: Atomic write support
  md/raid1: Atomic write support
  ...

7 months agoMerge tag 'io_uring-6.13-20242901' of git://git.kernel.dk/linux
Linus Torvalds [Sat, 30 Nov 2024 23:43:02 +0000 (15:43 -0800)] 
Merge tag 'io_uring-6.13-20242901' of git://git.kernel.dk/linux

Pull more io_uring updates from Jens Axboe:

 - Remove a leftover struct from when the cqwait registered waiting was
   transitioned to regions.

 - Fix for an issue introduced in this merge window, where nop->fd might
   be used uninitialized. Ensure it's always set.

 - Add capping of the task_work run in local task_work mode, to prevent
   bursty and long chains from adding too much latency.

 - Work around xa_store() leaving ->head non-NULL if it encounters an
   allocation error during storing. Just a debug trigger, and can go
   away once xa_store() behaves in a more expected way for this
   condition. Not a major thing as it basically requires fault injection
   to trigger it.

 - Fix a few mapping corner cases

 - Fix KCSAN complaint on reading the table size post unlock. Again not
   a "real" issue, but it's easy to silence by just keeping the reading
   inside the lock that protects it.

* tag 'io_uring-6.13-20242901' of git://git.kernel.dk/linux:
  io_uring/tctx: work around xa_store() allocation error issue
  io_uring: fix corner case forgetting to vunmap
  io_uring: fix task_work cap overshooting
  io_uring: check for overflows in io_pin_pages
  io_uring/nop: ensure nop->fd is always initialized
  io_uring: limit local tw done
  io_uring: add io_local_work_pending()
  io_uring/region: return negative -E2BIG in io_create_region()
  io_uring: protect register tracing
  io_uring: remove io_uring_cqwait_reg_arg

7 months agoMerge tag 'dma-mapping-6.13-2024-11-30' of git://git.infradead.org/users/hch/dma...
Linus Torvalds [Sat, 30 Nov 2024 23:36:17 +0000 (15:36 -0800)] 
Merge tag 'dma-mapping-6.13-2024-11-30' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fix from Christoph Hellwig:

 - fix physical address calculation for struct dma_debug_entry (Fedor
   Pchelkin)

* tag 'dma-mapping-6.13-2024-11-30' of git://git.infradead.org/users/hch/dma-mapping:
  dma-debug: fix physical address calculation for struct dma_debug_entry

7 months agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Sat, 30 Nov 2024 22:51:08 +0000 (14:51 -0800)] 
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull more kvm updates from Paolo Bonzini:

 - ARM fixes

 - RISC-V Svade and Svadu (accessed and dirty bit) extension support for
   host and guest

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test
  RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM
  dt-bindings: riscv: Add Svade and Svadu Entries
  RISC-V: Add Svade and Svadu Extensions Support
  KVM: arm64: Use MDCR_EL2.HPME to evaluate overflow of hyp counters
  KVM: arm64: Ignore PMCNTENSET_EL0 while checking for overflow status
  KVM: arm64: Mark set_sysreg_masks() as inline to avoid build failure
  KVM: arm64: vgic-its: Add stronger type-checking to the ITS entry sizes
  KVM: arm64: vgic: Kill VGIC_MAX_PRIVATE definition
  KVM: arm64: vgic: Make vgic_get_irq() more robust
  KVM: arm64: vgic-v3: Sanitise guest writes to GICR_INVLPIR

7 months agoMerge tag 'sh-for-v6.13-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/glaubi...
Linus Torvalds [Sat, 30 Nov 2024 22:45:29 +0000 (14:45 -0800)] 
Merge tag 'sh-for-v6.13-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/glaubitz/sh-linux

Pull sh updates from John Paul Adrian Glaubitz:
 "Two small fixes.

  The first one by Huacai Chen addresses a runtime warning when
  CONFIG_CPUMASK_OFFSTACK and CONFIG_DEBUG_PER_CPU_MAPS are selected
  which occurs because the cpuinfo code on sh incorrectly uses NR_CPUS
  when iterating CPUs instead of the runtime limit nr_cpu_ids.

  A second fix by Dan Carpenter fixes a use-after-free bug in
  register_intc_controller() which occurred as a result of improper
  error handling in the interrupt controller driver code when
  registering an interrupt controller during plat_irq_setup() on sh"

* tag 'sh-for-v6.13-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/glaubitz/sh-linux:
  sh: intc: Fix use-after-free bug in register_intc_controller()
  sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK

7 months agoMerge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Linus Torvalds [Sat, 30 Nov 2024 22:33:44 +0000 (14:33 -0800)] 
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Catalin Marinas:

 - Deselect ARCH_CORRECT_STACKTRACE_ON_KRETPROBE so that tests depending
   on it don't run (and fail) on arm64

 - Fix lockdep assert in the Arm SMMUv3 PMU driver

 - Fix the port and device ID bits setting in the Arm CMN perf driver

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  perf/arm-cmn: Ensure port and device id bits are set properly
  perf/arm-smmuv3: Fix lockdep assert in ->event_init()
  arm64: disable ARCH_CORRECT_STACKTRACE_ON_KRETPROBE tests

7 months agotools/power turbostat: 2024.11.30
Len Brown [Sat, 30 Nov 2024 21:22:00 +0000 (16:22 -0500)] 
tools/power turbostat: 2024.11.30

since 2024.07.26:

assorted minor bug fixes
assorted platform specific tweaks
initial RAPL PSYS (SysWatt) support

Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Add RAPL psys as a built-in counter
Patryk Wlazlyn [Wed, 2 Oct 2024 13:05:15 +0000 (15:05 +0200)] 
tools/power turbostat: Add RAPL psys as a built-in counter

Introduce the counter as a part of global, platform counters structure.
We open the counter for only one cpu, but otherwise treat it as an
ordinary RAPL counter, allowing for grouped perf read.

The counter is disabled by default, because it's interpretation may
require additional, platform specific information, making it unsuitable
for general use.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Fix child's argument forwarding
Patryk Wlazlyn [Wed, 13 Nov 2024 14:48:22 +0000 (15:48 +0100)] 
tools/power turbostat: Fix child's argument forwarding

Add '+' to optstring when early scanning for --no-msr and --no-perf.
It causes option processing to stop as soon as a nonoption argument is
encountered, effectively skipping child's arguments.

Fixes: 3e4048466c39 ("tools/power turbostat: Add --no-msr option")
Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Force --no-perf in --dump mode
Patryk Wlazlyn [Thu, 24 Oct 2024 13:17:45 +0000 (15:17 +0200)] 
tools/power turbostat: Force --no-perf in --dump mode

Force the --no-perf early to prevent using it as a source. User asks for
raw values, but perf returns them relative to the opening of the file
descriptor.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Add support for /sys/class/drm/card1
Zhang Rui [Thu, 14 Nov 2024 07:59:46 +0000 (15:59 +0800)] 
tools/power turbostat: Add support for /sys/class/drm/card1

On some machines, the graphics device is enumerated as
/sys/class/drm/card1 instead of /sys/class/drm/card0. The current
implementation does not handle this scenario, resulting in the loss of
graphics C6 residency and frequency information.

Add support for /sys/class/drm/card1, ensuring that turbostat can
retrieve and display the graphics columns for these platforms.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Cache graphics sysfs file descriptors during probe
Zhang Rui [Thu, 14 Nov 2024 07:59:45 +0000 (15:59 +0800)] 
tools/power turbostat: Cache graphics sysfs file descriptors during probe

Snapshots of the graphics sysfs knobs are taken based on file
descriptors. To optimize this process, open the files and cache the file
descriptors during the graphics probe phase. As a result, the previously
cached pathnames become redundant and are removed.

This change aims to streamline the code without altering its functionality.

No functional change intended.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Consolidate graphics sysfs access
Zhang Rui [Thu, 14 Nov 2024 07:59:44 +0000 (15:59 +0800)] 
tools/power turbostat: Consolidate graphics sysfs access

Currently, there is an inconsistency in how graphics sysfs knobs are
accessed: graphics residency sysfs knobs are opened and closed for each
read, while graphics frequency sysfs knobs are opened once and remain
open until turbostat exits. This inconsistency is confusing and adds
unnecessary code complexity.

Consolidate the access method by opening the sysfs files once and
reusing the file pointers for subsequent accesses. This approach
simplifies the code and ensures a consistent method for accessing
graphics sysfs knobs.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Remove unnecessary fflush() call
Zhang Rui [Thu, 14 Nov 2024 07:59:43 +0000 (15:59 +0800)] 
tools/power turbostat: Remove unnecessary fflush() call

The graphics sysfs knobs are read-only, making the use of fflush()
before reading them redundant.

Remove the unnecessary fflush() call.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Enhance platform divergence description
Zhang Rui [Thu, 14 Nov 2024 07:59:42 +0000 (15:59 +0800)] 
tools/power turbostat: Enhance platform divergence description

In various generations, platforms often share a majority of features,
diverging only in a few specific aspects. The current approach of using
hardcoded values in 'platform_features' structure fails to effectively
represent these divergences.

To improve the description of platform divergence:
1. Each newly introduced 'platform_features' structure must have a base,
   typically derived from the previous generation.
2. Platform feature values should be inherited from the base structure
   rather than being hardcoded.
This approach ensures a more accurate and maintainable representation of
platform-specific features across different generations.

Converts `adl_features` and `lnl_features` to follow this new scheme.

No functional change.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
7 months agotools/power turbostat: Add initial support for GraniteRapids-D
Zhang Rui [Thu, 14 Nov 2024 07:59:41 +0000 (15:59 +0800)] 
tools/power turbostat: Add initial support for GraniteRapids-D

Add initial support for GraniteRapids-D. It shares the same features
with SapphireRapids.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>