Devicetree
 help / color / mirror / Atom feed
From: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Bjorn Andersson <andersson@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Souvik Chakravarty <Souvik.Chakravarty@arm.com>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Conor Dooley <conor+dt@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	Moritz Fischer <moritz.fischer@ettus.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Christian Loehle <christian.loehle@arm.com>,
	Lee Jones <lee@kernel.org>, Ulf Hansson <ulfh@kernel.org>,
	Pavan Kondeti <pavan.kondeti@oss.qualcomm.com>,
	Abel Vesa <abelvesa@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Sudeep Holla <sudeep.holla@kernel.org>,
	Andy Yan <andyshrk@163.com>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
	Andre Draszik <andre.draszik@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kathiravan Thirumoorthy
	<kathiravan.thirumoorthy@oss.qualcomm.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	Srinivas Kandagatla <srini@kernel.org>
Subject: Re: [PATCH v27 02/10] power: reset: reboot-mode: Add support for predefined reboot modes
Date: Wed, 18 Nov 2026 19:33:42 +0530	[thread overview]
Message-ID: <7c67eec5-b382-4e58-bf3b-09df69752f5e@oss.qualcomm.com> (raw)
In-Reply-To: <avo7dUvBvULHCOY1@venus>



On 11/16/2026 4:43 AM, Sebastian Reichel wrote:
> Hi,
> 
> On Thu, Oct 29, 2026 at 02:30:56PM +0530, Shivendra Pratap wrote:
>> reboot-mode based drivers can define a reboot-mode by adding it under
>> the reboot-mode node in device tree. This limits such drivers, to define
>> any predefined reboot-modes statically within the driver and creates a
>> dependency on device-tree.
>>
>> Extend the reboot-mode framework to support driver-defined predefined
>> reboot modes. Add a centralized initcall to initialize driver state
>> along with predefined modes.
>>
>> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>> ---
>>   drivers/power/reset/nvmem-reboot-mode.c  |   7 +-
>>   drivers/power/reset/qcom-pon.c           |   7 +-
>>   drivers/power/reset/reboot-mode.c        | 192 ++++++++++++++++++++++---------
>>   drivers/power/reset/syscon-reboot-mode.c |   7 +-
>>   include/linux/reboot-mode.h              |  26 ++++-
>>   5 files changed, 175 insertions(+), 64 deletions(-)
>>
>> diff --git a/drivers/power/reset/nvmem-reboot-mode.c b/drivers/power/reset/nvmem-reboot-mode.c
>> index d260715fccf6..700732ed0f5b 100644
>> --- a/drivers/power/reset/nvmem-reboot-mode.c
>> +++ b/drivers/power/reset/nvmem-reboot-mode.c
>> @@ -51,8 +51,11 @@ static int nvmem_reboot_mode_probe(struct platform_device *pdev)
>>   	if (!nvmem_rbm)
>>   		return -ENOMEM;
>>   
>> -	nvmem_rbm->reboot.dev = &pdev->dev;
>> -	nvmem_rbm->reboot.write = nvmem_reboot_mode_write;
>> +	ret = reboot_mode_driver_init(&nvmem_rbm->reboot, &pdev->dev,
>> +				      nvmem_reboot_mode_write, NULL,
>> +				      NULL, 0);
>> +	if (ret)
>> +		return ret;
>>   
>>   	nvmem_rbm->cell = devm_nvmem_cell_get(&pdev->dev, "reboot-mode");
>>   	if (IS_ERR(nvmem_rbm->cell)) {
>> diff --git a/drivers/power/reset/qcom-pon.c b/drivers/power/reset/qcom-pon.c
>> index cd7ba680b841..55aaa99d88b6 100644
>> --- a/drivers/power/reset/qcom-pon.c
>> +++ b/drivers/power/reset/qcom-pon.c
>> @@ -84,9 +84,12 @@ static int qcom_pon_probe(struct platform_device *pdev)
>>   	reason_shift = (long)of_device_get_match_data(&pdev->dev);
>>   
>>   	if (reason_shift != NO_REASON_SHIFT) {
>> -		pon->reboot_mode.dev = &pdev->dev;
>> +		error = reboot_mode_driver_init(&pon->reboot_mode, &pdev->dev,
>> +						qcom_pon_reboot_mode_write, NULL,
>> +						NULL, 0);
>> +		if (error)
>> +			return error;
>>   		pon->reason_shift = reason_shift;
>> -		pon->reboot_mode.write = qcom_pon_reboot_mode_write;
>>   		error = devm_reboot_mode_register(&pdev->dev, &pon->reboot_mode);
>>   		if (error) {
>>   			dev_err(&pdev->dev, "can't register reboot mode\n");
>> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
>> index 328fa37598df..fd61de226383 100644
>> --- a/drivers/power/reset/reboot-mode.c
>> +++ b/drivers/power/reset/reboot-mode.c
>> @@ -30,12 +30,12 @@ struct reboot_mode_sysfs_data {
>>   	struct list_head head;
>>   };
>>   
>> -static inline void reboot_mode_release_list(struct reboot_mode_sysfs_data *priv)
>> +static void reboot_mode_release_list(struct list_head *head)
>>   {
>>   	struct mode_info *info;
>>   	struct mode_info *next;
>>   
>> -	list_for_each_entry_safe(info, next, &priv->head, list) {
>> +	list_for_each_entry_safe(info, next, head, list) {
>>   		list_del(&info->list);
>>   		kfree_const(info->mode);
>>   		kfree(info);
>> @@ -119,6 +119,80 @@ static int reboot_mode_notify(struct notifier_block *this,
>>   	return NOTIFY_DONE;
>>   }
>>   
>> +/**
>> + * reboot_mode_driver_init - Initialize reboot-mode state
>> + * @reboot: reboot mode driver object to initialize
>> + * @dev: backing device
>> + * @write: write callback to program a single magic value
>> + * @write_array: write callback to program multiple magic values
>> + * @predefined_modes: optional predefined reboot-mode table
>> + * @predefined_mode_count: number of entries in @predefined_modes
>> + *
>> + * Exactly one write callback must be provided by the driver.
>> + *
>> + * This function must be called with a valid @dev before calling
>> + * reboot_mode_register().
>> + *
>> + * Returns: 0 on success or -EINVAL if callback/predefined mode configuration
>> + * is invalid.
>> + */
>> +int reboot_mode_driver_init(struct reboot_mode_driver *reboot,
>> +			    struct device *dev,
>> +			    int (*write)(struct reboot_mode_driver *reboot, unsigned int magic),
>> +			    int (*write_array)(struct reboot_mode_driver *reboot,
>> +					       const u32 *magic, u32 count),
>> +			    const struct reboot_mode_entry *predefined_modes,
>> +			    size_t predefined_mode_count)
>> +{
>> +	if (!reboot || !dev)
>> +		return -EINVAL;
>> +
>> +	if (!write == !write_array)
>> +		return -EINVAL;
>> +
>> +	memset(reboot, 0, sizeof(*reboot));
>> +	reboot->dev = dev;
>> +	reboot->write = write;
>> +	reboot->write_array = write_array;
>> +	reboot->predefined_modes = predefined_modes;
>> +	reboot->predefined_mode_count = predefined_mode_count;
>> +	INIT_LIST_HEAD(&reboot->head);
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(reboot_mode_driver_init);
>> +
>> +static struct mode_info *reboot_mode_create_info(struct device *dev, const char *mode,
>> +						 const u32 *magic, int count)
>> +{
>> +	struct mode_info *info;
>> +
>> +	if (!mode || mode[0] == '\0') {
>> +		dev_err(dev, "invalid mode name\n");
>> +		return ERR_PTR(-EINVAL);
>> +	}
>> +
>> +	info = kzalloc_obj(*info, GFP_KERNEL);
>> +	if (!info)
>> +		return ERR_PTR(-ENOMEM);
> 
> info = kzalloc_obj(*info);

sure, will update this in next post.

thanks,
Shivendra

  reply	other threads:[~2026-11-18 14:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  9:00 [PATCH v27 00/10] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-10-29  9:00 ` [PATCH v27 01/10] power: reset: reboot-mode: Support up to 3 magic values per mode Shivendra Pratap
2026-11-15 23:08   ` Sebastian Reichel
2026-10-29  9:00 ` [PATCH v27 02/10] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-10-29  9:23   ` sashiko-bot
2026-11-15 23:13   ` Sebastian Reichel
2026-11-18 14:03     ` Shivendra Pratap [this message]
2026-10-29  9:00 ` [PATCH v27 03/10] firmware: psci: Introduce command-based resets Shivendra Pratap
2026-10-29  9:00 ` [PATCH v27 04/10] firmware: psci: Add support for PSCI auxiliary devices Shivendra Pratap
2026-10-29 10:00   ` sashiko-bot
2026-10-29  9:00 ` [PATCH v27 05/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-11-02  9:40   ` Bartosz Golaszewski
2026-11-17 13:45   ` Bartosz Golaszewski
2026-10-29  9:01 ` [PATCH v27 06/10] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-11-15 23:08   ` Sebastian Reichel
2026-11-18 14:04     ` Shivendra Pratap
2026-10-29  9:01 ` [PATCH v27 07/10] arm64: dts: qcom: Add psci reboot-modes for kodiak boards Shivendra Pratap
2026-10-29 10:23   ` Abel Vesa
2026-10-29  9:01 ` [PATCH v27 08/10] arm64: dts: qcom: Add psci reboot-modes for lemans boards Shivendra Pratap
2026-10-29 10:23   ` Abel Vesa
2026-10-29  9:01 ` [PATCH v27 09/10] arm64: dts: qcom: Add psci reboot-modes for monaco boards Shivendra Pratap
2026-10-29 10:24   ` Abel Vesa
2026-10-29  9:01 ` [PATCH v27 10/10] arm64: dts: qcom: Add psci reboot-modes for talos boards Shivendra Pratap
2026-10-29 10:24   ` Abel Vesa
2026-11-09 15:47 ` [PATCH v27 00/10] Implement PSCI reboot mode driver for PSCI resets Ulf Hansson
2026-11-15 23:14   ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7c67eec5-b382-4e58-bf3b-09df69752f5e@oss.qualcomm.com \
    --to=shivendra.pratap@oss.qualcomm.com \
    --cc=Souvik.Chakravarty@arm.com \
    --cc=abelvesa@kernel.org \
    --cc=andersson@kernel.org \
    --cc=andre.draszik@linaro.org \
    --cc=andyshrk@163.com \
    --cc=arnd@arndb.de \
    --cc=brgl@kernel.org \
    --cc=christian.loehle@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.stultz@linaro.org \
    --cc=kathiravan.thirumoorthy@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=moritz.fischer@ettus.com \
    --cc=mukesh.ojha@oss.qualcomm.com \
    --cc=pavan.kondeti@oss.qualcomm.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=srini@kernel.org \
    --cc=sudeep.holla@kernel.org \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox