All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core
Date: Thu, 8 Oct 2026 18:32:11 -0500	[thread overview]
Message-ID: <20261008233211.GA941209@bhelgaas> (raw)
In-Reply-To: <1791446700-100166-1-git-send-email-shawn.lin@rock-chips.com>

On Thu, Oct 08, 2026 at 04:05:00PM +0800, Shawn Lin wrote:
> pci_pwrctrl_create_device() only creates platform devices for OF nodes
> that pci_pwrctrl_is_required() accepts, but pci_pwrctrl_destroy_device()
> unregisters the platform device of every available child node without
> that check.
> 
> Nodes under a PCI host controller that are not pwrctrl devices may have
> been populated by another mechanism.  Destroying them here would tear
> down devices owned by other code.
> 
> Mirror the check done at creation time so that only devices created by
> the pwrctrl core are removed.
> 
> Fixes: 4c4132489201 ("PCI/pwrctrl: Add APIs to create, destroy pwrctrl devices")
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Applied to pci/pwrctrl for v7.4, thanks!

Tearing down devices owned by other code sounds like an issue; maybe
this should have a cc: stable tag, since 4c4132489201 appeared in
v7.0?

> ---
> 
>  drivers/pci/pwrctrl/core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c
> index 10d817a..c14df11 100644
> --- a/drivers/pci/pwrctrl/core.c
> +++ b/drivers/pci/pwrctrl/core.c
> @@ -388,6 +388,9 @@ static void pci_pwrctrl_destroy_device(struct device_node *np)
>  	for_each_available_child_of_node_scoped(np, child)
>  		pci_pwrctrl_destroy_device(child);
>  
> +	if (!pci_pwrctrl_is_required(np))
> +		return;
> +
>  	pdev = of_find_device_by_node(np);
>  	if (!pdev)
>  		return;
> -- 
> 2.7.4
> 

  parent reply	other threads:[~2026-10-08 23:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  8:05 [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core Shawn Lin
2026-10-08  8:28 ` sashiko-bot
2026-10-08  9:38 ` Bartosz Golaszewski
2026-10-08 23:32 ` Bjorn Helgaas [this message]
2026-10-09  0:24   ` Shawn Lin

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=20261008233211.GA941209@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=brgl@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=shawn.lin@rock-chips.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.