All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core
@ 2026-10-08  8:05 Shawn Lin
  2026-10-08  8:28 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Shawn Lin @ 2026-10-08  8:05 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Bartosz Golaszewski, Bjorn Helgaas
  Cc: linux-pci, Shawn Lin

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>
---

 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core
  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
  2 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-08  8:28 UTC (permalink / raw)
  To: Shawn Lin; +Cc: linux-pci

> 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>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/1791446700-100166-1-git-send-email-shawn.lin@rock-chips.com?part=1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core
  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
  2 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-10-08  9:38 UTC (permalink / raw)
  To: Shawn Lin
  Cc: linux-pci, Manivannan Sadhasivam, Bartosz Golaszewski,
	Bjorn Helgaas

On Thu, 8 Oct 2026 10:05:00 +0200, Shawn Lin <shawn.lin@rock-chips.com> said:
> 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>
> ---

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core
  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
  2026-10-09  0:24   ` Shawn Lin
  2 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2026-10-08 23:32 UTC (permalink / raw)
  To: Shawn Lin
  Cc: Manivannan Sadhasivam, Bartosz Golaszewski, Bjorn Helgaas,
	linux-pci

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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI/pwrctrl: Only destroy devices created by pwrctrl core
  2026-10-08 23:32 ` Bjorn Helgaas
@ 2026-10-09  0:24   ` Shawn Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Shawn Lin @ 2026-10-09  0:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: shawn.lin, Manivannan Sadhasivam, Bartosz Golaszewski,
	Bjorn Helgaas, linux-pci

Hi Bjorn,

在 2026/10/09 星期五 7:32, Bjorn Helgaas 写道:
> 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?
> 

It would be better if this could be backported to v7.0, so it's fine for
me to cc stable.

>> ---
>>
>>   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
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-09  0:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-10-09  0:24   ` Shawn Lin

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.