[PATCH v17 03/12] power: reset: reboot-mode: Add support for 64 bit magic
Shivendra Pratap
shivendra.pratap at oss.qualcomm.com
Mon Nov 10 09:52:40 PST 2025
On 11/10/2025 10:00 PM, Bjorn Andersson wrote:
> On Mon, Nov 10, 2025 at 07:15:29PM +0530, Mukesh Ojha wrote:
>> On Sun, Nov 09, 2025 at 08:07:16PM +0530, Shivendra Pratap wrote:
>>> Current reboot-mode supports a single 32-bit argument for any
>>> supported mode. Some reboot-mode based drivers may require
>>> passing two independent 32-bit arguments during a reboot
>>> sequence, for uses-cases, where a mode requires an additional
>>> argument. Such drivers may not be able to use the reboot-mode
>>> driver. For example, ARM PSCI vendor-specific resets, need two
>>> arguments for its operation – reset_type and cookie, to complete
>>> the reset operation. If a driver wants to implement this
>>> firmware-based reset, it cannot use reboot-mode framework.
>>>
>>> Introduce 64-bit magic values in reboot-mode driver to
>>> accommodate dual 32-bit arguments when specified via device tree.
>>> In cases, where no second argument is passed from device tree,
>>> keep the upper 32-bit of magic un-changed(0) to maintain backward
>>> compatibility.
>>>
>>> Update the current drivers using reboot-mode for a 64-bit magic
>>> value.
[SNIP..]
>>> + if (magic > U32_MAX)
>>> + return -EINVAL;
>>> +
>>> + magic_32 = magic;
>>> +
>>> syscon_rbm = container_of(reboot, struct syscon_reboot_mode, reboot);
>>>
>>> ret = regmap_update_bits(syscon_rbm->map, syscon_rbm->offset,
>>> - syscon_rbm->mask, magic);
>>> + syscon_rbm->mask, magic_32);
>
> As above, if we're no longer silently discarding bits, I think we should
> compare the magic against syscon_rbm->mask.
>
> No need for a local variable, just type cast after checking the validity.
Trying to summarize below why we added these check-
the patch in v11 used typecasting and did not have any of these checks(link below):
https://lore.kernel.org/all/20250717-arm-psci-system_reset2-vendor-reboots-v11-2-df3e2b2183c3@oss.qualcomm.com/
As per below upstream review, type cast was removed and bound checks were added all-over patchset:
"As a general rule of thumb, code with casts is poor quality code. Try
to write the code without casts." -
https://lore.kernel.org/all/8d4a42b6-657f-4c30-8e25-4213d8d53a89@lunn.ch/
We can revert to the typecast way. Please suggest.
thanks,
Shivendra
More information about the linux-arm-kernel
mailing list