-
Notifications
You must be signed in to change notification settings - Fork 30
move the power-supply battery node parsing fully over to the generic fwnode API #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The driver is not using gpio_chip::of_xlate() callback and hence the of_gpio_n_cells assignment is unused. Drop it. With that done, remove unneeded OF dependency and extend compile test coverage. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Julien Massot <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Refer to video-interface-devices.yaml instead of documenting the common properties here. Signed-off-by: Sakari Ailus <[email protected]> Acked-by: Rob Herring (Arm) <[email protected]>
…control When operating a pipeline with a missing V4L2_CID_LINK_FREQ control this two line warning is printed each time the pipeline is started. Reduce this excessive logging by only warning once for the missing control. Signed-off-by: Niklas Söderlund <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Add the missing link-frequency to the ipu_supported_sensors[] array's Galaxy Core GC0310 entry. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The platform device name is already set by V4L2 and MC frameworks for media device bus_info and V4L2 querycap bus_info fields. Don't do it in the driver. Acked-by: Shuah Khan <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Start/stop sub-devices according to the stream mask in multiple streams case.
Fix this by setting correct stream mask in CSI-2's {enable,disable}_streams
pops which enable/disable sub-device connected to CSI-2 subdevice.
Signed-off-by: Hongju Wang <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Request the sensor clock without specifying a name so that the driver behaves as described in the imx415 bindings. Signed-off-by: Matthias Fend <[email protected]> Reviewed-by: Jai Luthra <[email protected]> Reviewed-by: Michael Riesch <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Reorder imx214_parse_fwnode call to reduce goto paths in upcoming patches. No functional change intended. Acked-by: Ricardo Ribalda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: André Apitzsch <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Move clock frequency related parameters out of the constant register sequences, such that the hard coded external clock frequency can be replaced by a variable in the upcoming patches. Acked-by: Ricardo Ribalda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: André Apitzsch <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Calculate PLL parameters based on clock frequency and link frequency. Acked-by: Ricardo Ribalda <[email protected]> Signed-off-by: André Apitzsch <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Deprecate the clock-frequency property in favor of assigned-clock-rates. While at it, re-order properties according to coding style and fix the link-frequency in the example. See commit acc2945 ("media: i2c: imx214: Fix link frequency validation"). Reviewed-by: Laurent Pinchart <[email protected]> Acked-by: Conor Dooley <[email protected]> Signed-off-by: André Apitzsch <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Instead rely on the rate set on the clock (using assigned-clock-rates etc.) Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: André Apitzsch <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Replace my corporate email address by @gmail.com. Signed-off-by: Martin Hecht <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The MT9M114 supports the different slew rates (0 to 7) on the output pads. At the moment, this is hardcoded to 7 (the fastest rate). The user might want to change this values due to EMC requirements. Add the 'slew-rate' property to the MT9M114 DT-bindings for selecting the desired slew rate. Signed-off-by: Mathis Foerst <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The MT9M114 sensor has an internal PLL that generates the required SYSCLK from EXTCLK. It also has the option to bypass the PLL and use EXTCLK directly as SYSCLK. The current driver implementation uses a hardcoded PLL configuration that requires a specific EXTCLK frequency. Depending on the available clocks, it can be desirable to use a different PLL configuration or to bypass it. The link-frequency of the output bus (Parallel or MIPI-CSI) is configured in the device tree. Check if EXTCLK can be used as SYSCLK to achieve this link-frequency. If yes, bypass the PLL. Otherwise, (as before) check if EXTCLK and the default PLL configuration provide the required SYSCLK to achieve the link-frequency. If yes, use the PLL. If no, throw an error. Signed-off-by: Mathis Foerst <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The function mt9m114_configure writes the configuration registers of both, the pixel array (pa) and the image flow processor (ifp). This is undesirable if only the config of the pa should be changed without affecting the ifp. Factor out the function mt9m114_configure_pa() that just writes the pa-configuration. Signed-off-by: Mathis Foerst <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Getting / Setting the frame interval using the V4L2 subdev pad ops get_frame_interval/set_frame_interval causes a deadlock, as the subdev state is locked in the [1] but also in the driver itself. In [2] it's described that the caller is responsible to acquire and release the lock in this case. Therefore, acquiring the lock in the driver is wrong. Remove the lock acquisitions/releases from mt9m114_ifp_get_frame_interval() and mt9m114_ifp_set_frame_interval(). [1] drivers/media/v4l2-core/v4l2-subdev.c - line 1129 [2] Documentation/driver-api/media/v4l2-subdev.rst Fixes: 24d756e ("media: i2c: Add driver for onsemi MT9M114 camera sensor") Cc: [email protected] Signed-off-by: Mathis Foerst <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
reset_gpio needs to be an output and set to GPIOD_OUT_LOW, to ensure lt6911uxe is in reset state during probe. This issue was found on the onboard lt6911uxe, where the reset_pin was not reset, causing the lt6911uxe to fail to probe. Fixes: e49563c ("media: i2c: add lt6911uxe hdmi bridge driver") Cc: [email protected] Signed-off-by: Dongcheng Yan <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The OV5670 is found on a Dell 7212, coupled to Intel's CIO2 CSI-2 receiver. The ACPI tables don't describe the connection properly and so this is one of the sensors that needs to wait for the ipu-bridge to set up the graph with software nodes. Defer probe if an endpoint isn't found to allow time for that. Signed-off-by: Daniel Scally <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The Dell 7212 Rugged Extreme Tablet pairs an OV5670 sensor with the Intel IPU3 ISP. The sensor is powered by a TPS68470 PMIC, and so we need some board data to describe how to configure the GPIOs and regulators to run the sensor. Signed-off-by: Daniel Scally <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
The OV5670 is found on Dell 7212 tablets paired with an IPU3 ISP and needs to be connected by the ipu-bridge. Add it to the list of supported devices. Signed-off-by: Daniel Scally <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
Replace storage of the active format in the cio2_queue structure with usage of V4L2 subdev active state. This simplifies locking in the driver, and drops usage of the deprecated subdev .open() internal operation. Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Sakari Ailus <[email protected]>
In order to remove .of_node from the power_supply_config struct, use .fwnode instead. Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-1-f9643b958677@collabora.com Signed-off-by: Hans de Goede <[email protected]>
All drivers have been migrated from .of_node to .fwnode, so let's kill the former. Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-2-f9643b958677@collabora.com Signed-off-by: Hans de Goede <[email protected]>
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 <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-3-f9643b958677@collabora.com Signed-off-by: Hans de Goede <[email protected]>
After ("power: supply: core: battery-info: fully switch to fwnode")
power_supply_get_battery_info() will always fail for battery fwnodes
which do not define a "resistance-temp-table".
Fix this by cleanly exiting on both 0 and EINVAL returns from
fwnode_property_count_u32(fwnode, "resistance-temp-table") which
indicates that the property is empty or not there.
While at it also fix:
1. The weird -ENOMEM return for other errors. For other errors
propagate the existing error or -EINVAL for an odd proplen.
2. Wrongly using "goto out_ret_pointer" on errors, out_ret_pointer
should only be used on success, error paths should use
out_put_node;
Signed-off-by: Hans de Goede <[email protected]>
propname must NOT be manually free-ed here since it is marked __free(kfree), freeing it will cause a double-free bug. Also move propdata to be a __free(kfree) value for consistency and also for cleaner code. Signed-off-by: Hans de Goede <[email protected]>
Replace any DT specific code with fwnode in the power-supply core. Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-4-f9643b958677@collabora.com Signed-off-by: Hans de Goede <[email protected]>
…ly_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. Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/20250430-psy-core-convert-to-fwnode-v2-5-f9643b958677@collabora.com Signed-off-by: Hans de Goede <[email protected]>
For POWER_SUPPLY_TYPE_BATTERY power-supplies the core already calls power_supply_get_battery_info() and stores the result in psy->battery_info. Use psy->battery_info instead of having the driver call power_supply_get_battery_info() itself. Signed-off-by: Hans de Goede <[email protected]>
Replace the hardcoded ocv -> capacity table and the ug3105_get_capacity() helper with using the generic power_supply_batinfo_ocv2cap() function. Note this relies on the battery fwnode providing at least 1 "ocv-capacity-table", if that is missing probe() will now fail with EINVAL. Signed-off-by: Hans de Goede <[email protected]>
Call power_supply_put_battery_info() when bq24190_get_config() is done with it. The "struct power_supply_battery_info *info" pointer runs out of scope at the end of bq24190_get_config() so there is no need to keep it around after this. Note technically this is not a memleak fix, since all battery_info data is devm_alloc()-ed so it would still be free-ed when the driver is unbound. This just frees it as soon as the driver is done with it. Signed-off-by: Hans de Goede <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the power-supply battery node parsing from OF–specific methods to the generic fwnode API. The changes update multiple driver files and core power supply functions to exclusively use fwnode handles for parsing references and properties.
- Replaces device_node and OF-specific functions with fwnode and corresponding generic API calls.
- Adjusts battery info retrieval and power supply registration logic to work with fwnode-based references.
- Updates utility and helper functions in power_supply_core.c to use the new API.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| include/linux/power_supply.h | Removes OF-specific field and updates API prototypes to use fwnode. |
| drivers/regulator/act8865-regulator.c | Uses fwnode retrieval instead of of_node for power supply registration. |
| drivers/power/supply/ug3105_battery.c | Replaces usage of legacy battery info access with fwnode-based API and updates capacity calculation. |
| drivers/power/supply/power_supply_core.c | Switches OF parsing to fwnode equivalents in supply lookup functions and battery info retrieval. |
| drivers/power/supply/bq24190_charger.c | Updates battery info release call following API changes. |
| drivers/power/supply/bq2415x_charger.c | Adapts power supply lookup to use fwnode-based reference. |
| drivers/phy/allwinner/phy-sun4i-usb.c | Uses the updated fwnode API for obtaining the VBUS power supply. |
| #define UG3105_LOW_BAT_UV 3700000 | ||
| #define UG3105_FULL_BAT_HYST_UV 38000 | ||
|
|
||
| #define AMBIENT_TEMP_CELCIUS 25 |
Copilot
AI
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro name 'AMBIENT_TEMP_CELCIUS' appears to be misspelled. Consider changing it to 'AMBIENT_TEMP_CELSIUS' to match the correct spelling.
| #define AMBIENT_TEMP_CELCIUS 25 | |
| #define AMBIENT_TEMP_CELSIUS 25 |
| } | ||
|
|
||
| tab_len = size / (2 * sizeof(__be32)); | ||
| u32 *propdata __free(kfree) = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL); |
Copilot
AI
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'propdata' is reassigned later in the function without explicitly freeing its previous allocation, which could lead to a memory leak. Consider using separate variables for the different property data allocations or explicitly freeing the first allocation before reassigning 'propdata'.
| u32 *propdata __free(kfree) = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL); | |
| u32 *propdata = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL); |
d5648ac to
d30351d
Compare
|
This pull-req was created to test Copilot code-review, see: This is not intended for merging, closing this now. |
smc_lo_register_dmb() allocates DMB buffers with kzalloc(), which are later passed to get_page() in smc_rx_splice(). Since kmalloc memory is not page-backed, this triggers WARN_ON_ONCE() in get_page() and prevents holding a refcount on the buffer. This can lead to use-after-free if the memory is released before splice_to_pipe() completes. Use folio_alloc() instead, ensuring DMBs are page-backed and safe for get_page(). WARNING: CPU: 18 PID: 12152 at ./include/linux/mm.h:1330 smc_rx_splice+0xaf8/0xe20 [smc] CPU: 18 UID: 0 PID: 12152 Comm: smcapp Kdump: loaded Not tainted 6.17.0-rc3-11705-g9cf4672ecfee #10 NONE Hardware name: IBM 3931 A01 704 (z/VM 7.4.0) Krnl PSW : 0704e00180000000 000793161032696c (smc_rx_splice+0xafc/0xe20 [smc]) R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:2 PM:0 RI:0 EA:3 Krnl GPRS: 0000000000000000 001cee80007d3001 00077400000000f8 0000000000000005 0000000000000001 001cee80007d3006 0007740000001000 001c000000000000 000000009b0c99e0 0000000000001000 001c0000000000f8 001c000000000000 000003ffcc6f7c88 0007740003e98000 0007931600000005 000792969b2ff7b8 Krnl Code: 0007931610326960: af000000 mc 0,0 0007931610326964: a7f4ff43 brc 15,00079316103267ea #0007931610326968: af000000 mc 0,0 >000793161032696c: a7f4ff3f brc 15,00079316103267ea 0007931610326970: e320f1000004 lg %r2,256(%r15) 0007931610326976: c0e53fd1b5f5 brasl %r14,000793168fd5d560 000793161032697c: a7f4fbb5 brc 15,00079316103260e6 0007931610326980: b904002b lgr %r2,%r11 Call Trace: smc_rx_splice+0xafc/0xe20 [smc] smc_rx_splice+0x756/0xe20 [smc]) smc_rx_recvmsg+0xa74/0xe00 [smc] smc_splice_read+0x1ce/0x3b0 [smc] sock_splice_read+0xa2/0xf0 do_splice_read+0x198/0x240 splice_file_to_pipe+0x7e/0x110 do_splice+0x59e/0xde0 __do_splice+0x11a/0x2d0 __s390x_sys_splice+0x140/0x1f0 __do_syscall+0x122/0x280 system_call+0x6e/0x90 Last Breaking-Event-Address: smc_rx_splice+0x960/0xe20 [smc] ---[ end trace 0000000000000000 ]--- Fixes: f7a2207 ("net/smc: implement DMB-related operations of loopback-ism") Reviewed-by: Mahanta Jambigi <[email protected]> Signed-off-by: Sidraya Jayagond <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
Running sha224_kunit on a KMSAN-enabled kernel results in a crash in
kmsan_internal_set_shadow_origin():
BUG: unable to handle page fault for address: ffffbc3840291000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 1810067 P4D 1810067 PUD 192d067 PMD 3c17067 PTE 0
Oops: 0000 [#1] SMP NOPTI
CPU: 0 UID: 0 PID: 81 Comm: kunit_try_catch Tainted: G N 6.17.0-rc3 #10 PREEMPT(voluntary)
Tainted: [N]=TEST
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014
RIP: 0010:kmsan_internal_set_shadow_origin+0x91/0x100
[...]
Call Trace:
<TASK>
__msan_memset+0xee/0x1a0
sha224_final+0x9e/0x350
test_hash_buffer_overruns+0x46f/0x5f0
? kmsan_get_shadow_origin_ptr+0x46/0xa0
? __pfx_test_hash_buffer_overruns+0x10/0x10
kunit_try_run_case+0x198/0xa00
This occurs when memset() is called on a buffer that is not 4-byte aligned
and extends to the end of a guard page, i.e. the next page is unmapped.
The bug is that the loop at the end of kmsan_internal_set_shadow_origin()
accesses the wrong shadow memory bytes when the address is not 4-byte
aligned. Since each 4 bytes are associated with an origin, it rounds the
address and size so that it can access all the origins that contain the
buffer. However, when it checks the corresponding shadow bytes for a
particular origin, it incorrectly uses the original unrounded shadow
address. This results in reads from shadow memory beyond the end of the
buffer's shadow memory, which crashes when that memory is not mapped.
To fix this, correctly align the shadow address before accessing the 4
shadow bytes corresponding to each origin.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 2ef3cec ("kmsan: do not wipe out origin when doing partial unpoisoning")
Signed-off-by: Eric Biggers <[email protected]>
Tested-by: Alexander Potapenko <[email protected]>
Reviewed-by: Alexander Potapenko <[email protected]>
Cc: Dmitriy Vyukov <[email protected]>
Cc: Marco Elver <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
move the power-supply battery node parsing fully over to the generic fwnode API instead of relying on OF specific methods.