mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
To: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
	Sebastian Reichel <sre@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>,
	John Stultz <john.stultz@linaro.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	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>,
	Kathiravan Thirumoorthy
	<kathiravan.thirumoorthy@oss.qualcomm.com>,
	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 v16 05/14] power: reset: reboot-mode: Expose sysfs for registered reboot_modes
Date: Thu, 23 Oct 2025 21:24:01 +0530	[thread overview]
Message-ID: <0e49a6b0-276c-85b4-3ffa-39e5412db522@oss.qualcomm.com> (raw)
In-Reply-To: <CACMJSetctEH4K58R9JvSYNzzYgE0NGMsAr5JxiZ4RH_3T08x-A@mail.gmail.com>



On 10/23/2025 8:32 PM, Bartosz Golaszewski wrote:
> On Wed, 22 Oct 2025 at 16:21, Shivendra Pratap
> <shivendra.pratap@oss.qualcomm.com> wrote:
>>
>>
>>
>> On 10/20/2025 1:10 PM, Bartosz Golaszewski wrote:
>>> On Fri, 17 Oct 2025 at 21:40, Shivendra Pratap
>>> <shivendra.pratap@oss.qualcomm.com> wrote:
>>>>
>>>>>
>>>>> If you're using devres here - at least make it obvious by adding the
>>>>> devm_ prefix to the function name and make it take an explicit struct
>>>>> device * parameter so that it's clear who owns the managed resource.
>>>>>
>>>>
>>>> sure. we can add devm_ prefix to the function name.
>>>> reboot->reboot_dev is an internal member of struct reboot_mode_driver *reboot.
>>>> The struct reboot_mode_driver *reboot is owned by the calling driver.
>>>> If we want to PASS reboot->reboot_dev to the devm_ prefixed function call, we
>>>> will need to kind of split create_reboot_mode_device into two calls - device_create
>>>> in a separate function and then call the devm_ prefix function where we add the devres_alloc.
>>>> Can you suggest a bit more on this?
>>>>
>>>
>>> Ah, ok I missed the broken logic here. Devres should only be used in
>>> devices already *attached* to a driver as all managed resources will
>>> get released on driver *detach*. What you have here may "work" by
>>> accident but that's not correct and is very fragile as soon as you
>>> have some non-standard behavior or error paths. Devres won't fly here,
>>> please just use regular allocation and free whatever you need in the
>>> corresponding release/free/whatever routine.
>>
>> Thanks, got the problem here. Was using devres to associate the reboot_mode struct
>> with the driver, so that it could be retrieved later when reboot_modes_show is called.
>>
>> When reboot_modes_show is invoked, there's no direct way to identify which reboot_mode
>> instance is tied to the current driver, as multiple drivers can register with the reboot-mode
>> framework at the same time. Without devres, will need to maintain a global list of mapping for
>> all device driver structs and their corresponding reboot_mode struct. Then reboot_modes_show
>> would have to look up the correct reboot_mode struct using the device driver's pointer.
>>
>> Hope its ok to maintain that separate logic here?
>>
> 
> Why can't you just do:
> 
> device_create(rb_class, NULL, 0, data reboot->driver_name);
> 
> Where data is whatever driver data you want to associate with the new
> class device? You can then retrieve it with dev_get_drvdata() in
> callbacks.

sure. thanks for the suggestion. That will make it much simpler.

thanks,
Shivendra

  reply	other threads:[~2025-10-23 15:54 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15  4:38 [PATCH v16 00/14] Implement vendor resets for PSCI SYSTEM_RESET2 Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 01/14] power: reset: reboot-mode: Synchronize list traversal Shivendra Pratap
2025-10-15 14:32   ` Bartosz Golaszewski
2025-10-17 14:47     ` Shivendra Pratap
2025-10-28  3:34   ` Bjorn Andersson
2025-10-29 17:48     ` Shivendra Pratap
2025-11-03  8:16       ` Mukesh Ojha
2025-10-15  4:38 ` [PATCH v16 02/14] power: reset: reboot-mode: Add device tree node-based registration Shivendra Pratap
2025-10-15 14:40   ` Bartosz Golaszewski
2025-10-16 17:19     ` Shivendra Pratap
2025-10-17  9:06       ` Bartosz Golaszewski
2025-10-17 14:24         ` Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 03/14] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
2025-10-15  8:40   ` Nirmesh Kumar Singh
2025-10-15  4:38 ` [PATCH v16 04/14] Documentation: ABI: Add sysfs-class-reboot-mode-reboot_modes Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 05/14] power: reset: reboot-mode: Expose sysfs for registered reboot_modes Shivendra Pratap
2025-10-15  8:45   ` Nirmesh Kumar Singh
2025-10-15 14:47   ` Bartosz Golaszewski
2025-10-17 19:40     ` Shivendra Pratap
2025-10-20  7:40       ` Bartosz Golaszewski
2025-10-22 14:21         ` Shivendra Pratap
2025-10-23 15:02           ` Bartosz Golaszewski
2025-10-23 15:54             ` Shivendra Pratap [this message]
2025-10-15  4:38 ` [PATCH v16 06/14] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 07/14] firmware: psci: Implement vendor-specific resets as reboot-mode Shivendra Pratap
2025-10-15  6:55   ` Pavan Kondeti
2025-10-15  7:47     ` Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 08/14] arm64: dts: qcom: qcm6490-idp: Add PSCI SYSTEM_RESET2 types Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 09/14] arm64: dts: qcom: qcs6490-rb3gen2: " Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 10/14] arm64: dts: qcom: lemans-ride: " Shivendra Pratap
2025-11-03  8:36   ` Mukesh Ojha
2025-10-15  4:38 ` [PATCH v16 11/14] arm64: dts: qcom: lemans-evk: " Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 12/14] arm64: dts: qcom: qcs8300-ride: " Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 13/14] arm64: dts: qcom: monaco-evk: " Shivendra Pratap
2025-10-15  4:38 ` [PATCH v16 14/14] arm64: dts: qcom: qcs615-ride: " Shivendra Pratap
2025-11-07  8:08   ` Xin Liu
2025-11-07  8:00 ` [PATCH v16 00/14] Implement vendor resets for PSCI SYSTEM_RESET2 Xin Liu
2025-11-07  8:10   ` Krzysztof Kozlowski

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=0e49a6b0-276c-85b4-3ffa-39e5412db522@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=john.stultz@linaro.org \
    --cc=kathiravan.thirumoorthy@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@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=mukesh.ojha@oss.qualcomm.com \
    --cc=quic_eberman@quicinc.com \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    --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®