mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Souvik Chakravarty <Souvik.Chakravarty@arm.com>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Andy Yan <andy.yan@rock-chips.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Konrad Dybcio <konradybcio@kernel.org>,
	cros-qcom-dts-watchers@chromium.org,
	Vinod Koul <vkoul@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>,
	Stephen Boyd <swboyd@chromium.org>,
	Andre Draszik <andre.draszik@linaro.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	Elliot Berman <quic_eberman@quicinc.com>,
	Srinivas Kandagatla <srini@kernel.org>
Subject: Re: [PATCH v14 05/10] power: reset: reboot-mode: Expose sysfs for registered reboot_modes
Date: Wed, 17 Sep 2025 08:26:38 +0530	[thread overview]
Message-ID: <32d8329f-0d73-fb16-f12d-308e6ee6b45d@oss.qualcomm.com> (raw)
In-Reply-To: <lgoahuqgoajuj352h7rnjfyeeyf24x45pj3qmidc6qqrc75vej@3hrblxle7uyk>



On 9/17/2025 12:32 AM, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Aug 15, 2025 at 08:05:10PM +0530, Shivendra Pratap wrote:
>> Currently, there is no standardized mechanism for userspace to
>> discover which reboot-modes are supported on a given platform.
>> This limitation forces tools and scripts to rely on hardcoded
>> assumptions about the supported reboot-modes.
>>
>> Create a class 'reboot-mode' and a device under it to expose a
>> sysfs interface to show the available reboot mode arguments to
>> userspace.
>>
>> Provision the register function with an additional parameter to
>> get an explicit driver_name. Create the device using this
>> driver_name. For platform drivers, use the driver_name configured
>> in dev node.
>>
>> This results in the creation of:
>>   /sys/class/reboot-mode/<driver>/reboot_modes
>>
>> This read-only sysfs file will exposes the list of supported
>> reboot modes arguments provided by the driver, enabling userspace
>> to query the list of arguments.
>>
>> Align the clean up path to maintain backward compatibility for
>> existing reboot-mode based drivers.
>>
>> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>> ---
>>  drivers/power/reset/reboot-mode.c | 131 +++++++++++++++++++++++++++++++-------
>>  include/linux/reboot-mode.h       |   4 +-
>>  2 files changed, 110 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
>> index ac81b8b0a9b7fc31f8ef21024333a050087ce90f..7ecab050e496af3e1cc01c1a4614787707cb74b4 100644
>> --- a/drivers/power/reset/reboot-mode.c
>> +++ b/drivers/power/reset/reboot-mode.c
>> @@ -6,6 +6,7 @@
>>  #define pr_fmt(fmt)	"reboot-mode: " fmt
>>  
>>  #include <linux/device.h>
>> +#include <linux/err.h>
>>  #include <linux/init.h>
>>  #include <linux/kernel.h>
>>  #include <linux/list.h>
>> @@ -23,6 +24,8 @@ struct mode_info {
>>  	struct list_head list;
>>  };
>>  
>> +static struct class *rb_class;
>> +
>>  static u64 get_reboot_mode_magic(struct reboot_mode_driver *reboot, const char *cmd)
>>  {
>>  	const char *normal = "normal";
>> @@ -75,26 +78,121 @@ static int reboot_mode_notify(struct notifier_block *this,
>>  	return NOTIFY_DONE;
>>  }
>>  
>> +static void release_reboot_mode_device(struct device *dev, void *res);
>> +
>> +static ssize_t reboot_modes_show(struct device *dev, struct device_attribute *attr, char *buf)
>> +{
>> +	struct reboot_mode_driver **devres_reboot;
>> +	struct reboot_mode_driver *reboot;
>> +	struct mode_info *info;
>> +	ssize_t size = 0;
>> +
>> +	devres_reboot = devres_find(dev, release_reboot_mode_device, NULL, NULL);
>> +	if (!devres_reboot || !(*devres_reboot))
>> +		return -ENODATA;
>> +
>> +	reboot = *devres_reboot;
>> +	mutex_lock(&reboot->rb_lock);
>> +	list_for_each_entry(info, &reboot->head, list) {
>> +		size += sprintf(buf + size, "%s ", info->mode);
> 
> sysfs_emit_at

ACK. will update.

> 
>> +	}
>> +	mutex_unlock(&reboot->rb_lock);
>> +
>> +	if (size) {
>> +		size += sprintf(buf + size - 1, "\n");
> 
> sysfs_emit_at

ACK. will update.

> 
>> +		return size;
>> +	}
>> +
>> +	return -ENODATA;
>> +}
>> +static DEVICE_ATTR_RO(reboot_modes);
>> +
>> +static void release_reboot_mode_device(struct device *dev, void *res)
>> +{
>> +	struct reboot_mode_driver *reboot = *(struct reboot_mode_driver **)res;
>> +	struct mode_info *info;
>> +	struct mode_info *next;
>> +
>> +	unregister_reboot_notifier(&reboot->reboot_notifier);
>> +
>> +	mutex_lock(&reboot->rb_lock);
>> +	list_for_each_entry_safe(info, next, &reboot->head, list) {
>> +		list_del(&info->list);
>> +		kfree_const(info->mode);
>> +		kfree(info);
>> +	}
>> +	mutex_unlock(&reboot->rb_lock);
>> +
>> +	device_remove_file(reboot->reboot_dev, &dev_attr_reboot_modes);
>> +}
>> +
>> +static int create_reboot_mode_device(struct reboot_mode_driver *reboot,
>> +				     const char *dev_name)
> 
> Instead of adding more and more arguments to this, just add a name
> field to struct reboot_mode_driver.

ACK. will update.

thanks,
Shivendra

  reply	other threads:[~2025-09-17  2:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15 14:35 [PATCH v14 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 01/10] power: reset: reboot-mode: Synchronize list traversal Shivendra Pratap
2025-09-16 18:44   ` Sebastian Reichel
2025-09-17 17:06     ` Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 02/10] power: reset: reboot-mode: Add device tree node-based registration Shivendra Pratap
2025-09-16 18:48   ` Sebastian Reichel
2025-09-17 16:29     ` Shivendra Pratap
2025-09-17 22:32       ` Sebastian Reichel
2025-09-18 17:19         ` Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 03/10] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
2025-08-28 13:22   ` Casey Connolly
2025-09-02  9:55     ` Shivendra Pratap
2025-09-02 14:20     ` Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 04/10] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes Shivendra Pratap
2025-09-16 18:51   ` Sebastian Reichel
2025-08-15 14:35 ` [PATCH v14 05/10] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Shivendra Pratap
2025-09-16 19:02   ` Sebastian Reichel
2025-09-17  2:56     ` Shivendra Pratap [this message]
2025-08-15 14:35 ` [PATCH v14 06/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 07/10] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 08/10] arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 09/10] arm64: dts: qcom: qcs6490-rb3gen2: " Shivendra Pratap
2025-08-15 14:35 ` [PATCH v14 10/10] arm64: dts: qcom: lemans-ride: " Shivendra Pratap
2025-08-15 21:22 ` [PATCH v14 00/10] Implement vendor resets for PSCI SYSTEM_RESET2 Florian Fainelli
2025-08-28  8:05 ` Kathiravan Thirumoorthy
2025-09-02 13:10   ` Shivendra Pratap
2025-09-02 15:05     ` Kathiravan Thirumoorthy

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=32d8329f-0d73-fb16-f12d-308e6ee6b45d@oss.qualcomm.com \
    --to=shivendra.pratap@oss.qualcomm.com \
    --cc=Souvik.Chakravarty@arm.com \
    --cc=andersson@kernel.org \
    --cc=andre.draszik@linaro.org \
    --cc=andy.yan@rock-chips.com \
    --cc=arnd@arndb.de \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=cros-qcom-dts-watchers@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@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=mukesh.ojha@oss.qualcomm.com \
    --cc=quic_eberman@quicinc.com \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=srini@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=swboyd@chromium.org \
    --cc=vkoul@kernel.org \
    --cc=will@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

all inboxes | Powered by JetHome®