* [PATCH] phy: broadcom: brcm-usb: unwind late probe failures
@ 2026-06-15 7:01 Pengpeng Hou
2026-06-15 18:22 ` Justin Chen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pengpeng Hou @ 2026-06-15 7:01 UTC (permalink / raw)
To: Justin Chen, Al Cooper, Broadcom internal kernel review list,
Vinod Koul, Neil Armstrong, linux-kernel, linux-phy
Cc: pengpeng
brcm_usb_phy_probe() registers a PM notifier and may create a sysfs group
before registering the OF PHY provider. If provider registration fails,
probe returns the error with those resources still active.
Track which optional resources were installed and remove them on the late
provider-registration failure path. Use the same state in remove() so
cleanup matches probe progress.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/phy/broadcom/phy-brcm-usb.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c
index 59d756a10d6c..e606db489698 100644
--- a/drivers/phy/broadcom/phy-brcm-usb.c
+++ b/drivers/phy/broadcom/phy-brcm-usb.c
@@ -71,6 +71,8 @@ struct brcm_usb_phy_data {
int wake_irq;
struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX];
struct notifier_block pm_notifier;
+ bool pm_notifier_registered;
+ bool sysfs_group_created;
bool pm_active;
};
@@ -545,7 +547,11 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
return err;
priv->pm_notifier.notifier_call = brcm_pm_notifier;
- register_pm_notifier(&priv->pm_notifier);
+ err = register_pm_notifier(&priv->pm_notifier);
+ if (err)
+ dev_warn(dev, "Error registering PM notifier\n");
+ else
+ priv->pm_notifier_registered = true;
mutex_init(&priv->mutex);
@@ -561,6 +567,8 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
err = sysfs_create_group(&dev->kobj, &brcm_usb_phy_group);
if (err)
dev_warn(dev, "Error creating sysfs attributes\n");
+ else
+ priv->sysfs_group_created = true;
/* Get piarbctl syscon if it exists */
rmap = syscon_regmap_lookup_by_phandle(dev->of_node,
@@ -581,16 +589,29 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
clk_disable_unprepare(priv->usb_30_clk);
phy_provider = devm_of_phy_provider_register(dev, brcm_usb_phy_xlate);
+ err = PTR_ERR_OR_ZERO(phy_provider);
+ if (err)
+ goto err_remove_debug;
+
+ return 0;
+
+err_remove_debug:
+ if (priv->sysfs_group_created)
+ sysfs_remove_group(&dev->kobj, &brcm_usb_phy_group);
+ if (priv->pm_notifier_registered)
+ unregister_pm_notifier(&priv->pm_notifier);
- return PTR_ERR_OR_ZERO(phy_provider);
+ return err;
}
static void brcm_usb_phy_remove(struct platform_device *pdev)
{
struct brcm_usb_phy_data *priv = dev_get_drvdata(&pdev->dev);
- sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group);
- unregister_pm_notifier(&priv->pm_notifier);
+ if (priv->sysfs_group_created)
+ sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group);
+ if (priv->pm_notifier_registered)
+ unregister_pm_notifier(&priv->pm_notifier);
}
#ifdef CONFIG_PM_SLEEP
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] phy: broadcom: brcm-usb: unwind late probe failures
2026-06-15 7:01 [PATCH] phy: broadcom: brcm-usb: unwind late probe failures Pengpeng Hou
@ 2026-06-15 18:22 ` Justin Chen
2026-09-08 8:12 ` Manivannan Sadhasivam
2026-09-13 10:56 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Justin Chen @ 2026-06-15 18:22 UTC (permalink / raw)
To: Pengpeng Hou, Al Cooper, Broadcom internal kernel review list,
Vinod Koul, Neil Armstrong, linux-kernel, linux-phy
On 6/15/26 12:01 AM, Pengpeng Hou wrote:
> brcm_usb_phy_probe() registers a PM notifier and may create a sysfs group
> before registering the OF PHY provider. If provider registration fails,
> probe returns the error with those resources still active.
>
> Track which optional resources were installed and remove them on the late
> provider-registration failure path. Use the same state in remove() so
> cleanup matches probe progress.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Justin Chen <justin.chen@broadcom.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] phy: broadcom: brcm-usb: unwind late probe failures
2026-06-15 7:01 [PATCH] phy: broadcom: brcm-usb: unwind late probe failures Pengpeng Hou
2026-06-15 18:22 ` Justin Chen
@ 2026-09-08 8:12 ` Manivannan Sadhasivam
2026-09-13 10:56 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-09-08 8:12 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Justin Chen, Al Cooper, Broadcom internal kernel review list,
Vinod Koul, Neil Armstrong, linux-kernel, linux-phy
On Mon, Jun 15, 2026 at 03:01:23PM +0800, Pengpeng Hou wrote:
> brcm_usb_phy_probe() registers a PM notifier and may create a sysfs group
> before registering the OF PHY provider. If provider registration fails,
> probe returns the error with those resources still active.
>
> Track which optional resources were installed and remove them on the late
> provider-registration failure path. Use the same state in remove() so
> cleanup matches probe progress.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] phy: broadcom: brcm-usb: unwind late probe failures
2026-06-15 7:01 [PATCH] phy: broadcom: brcm-usb: unwind late probe failures Pengpeng Hou
2026-06-15 18:22 ` Justin Chen
2026-09-08 8:12 ` Manivannan Sadhasivam
@ 2026-09-13 10:56 ` Vinod Koul
2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2026-09-13 10:56 UTC (permalink / raw)
To: Justin Chen, Al Cooper, Broadcom internal kernel review list,
Neil Armstrong, linux-kernel, linux-phy, Pengpeng Hou
On Mon, 15 Jun 2026 15:01:23 +0800, Pengpeng Hou wrote:
> brcm_usb_phy_probe() registers a PM notifier and may create a sysfs group
> before registering the OF PHY provider. If provider registration fails,
> probe returns the error with those resources still active.
>
> Track which optional resources were installed and remove them on the late
> provider-registration failure path. Use the same state in remove() so
> cleanup matches probe progress.
>
> [...]
Applied, thanks!
[1/1] phy: broadcom: brcm-usb: unwind late probe failures
commit: 402266bacb70263d4ba2a1f0a615210c9c4cbdd8
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-13 10:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-15 7:01 [PATCH] phy: broadcom: brcm-usb: unwind late probe failures Pengpeng Hou
2026-06-15 18:22 ` Justin Chen
2026-09-08 8:12 ` Manivannan Sadhasivam
2026-09-13 10:56 ` Vinod Koul
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®