* [PATCH] phy: qcom-usb-hs: Fix extcon double register after power cycle
@ 2019-10-08 11:52 ` Stephan Gerhold
2019-10-10 11:08 ` Chanwoo Choi
0 siblings, 1 reply; 2+ messages in thread
From: Stephan Gerhold @ 2019-10-08 11:52 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: Chanwoo Choi, Andy Gross, Bjorn Andersson, linux-arm-msm,
linux-kernel, Stephan Gerhold
Commit f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API")
switched from extcon_register_notifier() to the resource-managed
API, i.e. devm_extcon_register_notifier().
This is problematic in this case, because the extcon notifier
is dynamically registered/unregistered whenever the PHY is powered
on/off. The resource-managed API does not unregister the notifier
until the driver is removed, so as soon as the PHY is power cycled,
attempting to register the notifier again results in:
double register detected
WARNING: CPU: 1 PID: 182 at kernel/notifier.c:26 notifier_chain_register+0x74/0xa0
Call trace:
...
extcon_register_notifier+0x74/0xb8
devm_extcon_register_notifier+0x54/0xb8
qcom_usb_hs_phy_power_on+0x1fc/0x208
...
... and USB stops working after plugging the cable out and in
another time.
The easiest way to fix this is to make a partial revert of
commit f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API")
and avoid using the resource-managed API in this case.
Fixes: f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API")
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
An other way to fix this would be keep the extcon notifier
permanently registered, and check in qcom_usb_hs_phy_vbus_notifier
if the PHY is currently powered on.
---
drivers/phy/qualcomm/phy-qcom-usb-hs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
index b163b3a1558d..61054272a7c8 100644
--- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c
+++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
@@ -158,8 +158,8 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy)
/* setup initial state */
qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state,
uphy->vbus_edev);
- ret = devm_extcon_register_notifier(&ulpi->dev, uphy->vbus_edev,
- EXTCON_USB, &uphy->vbus_notify);
+ ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB,
+ &uphy->vbus_notify);
if (ret)
goto err_ulpi;
}
@@ -180,6 +180,9 @@ static int qcom_usb_hs_phy_power_off(struct phy *phy)
{
struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy);
+ if (uphy->vbus_edev)
+ extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB,
+ &uphy->vbus_notify);
regulator_disable(uphy->v3p3);
regulator_disable(uphy->v1p8);
clk_disable_unprepare(uphy->sleep_clk);
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] phy: qcom-usb-hs: Fix extcon double register after power cycle
2019-10-08 11:52 ` [PATCH] phy: qcom-usb-hs: Fix extcon double register after power cycle Stephan Gerhold
@ 2019-10-10 11:08 ` Chanwoo Choi
0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2019-10-10 11:08 UTC (permalink / raw)
To: Stephan Gerhold, Kishon Vijay Abraham I
Cc: Andy Gross, Bjorn Andersson, linux-arm-msm, linux-kernel
On 19. 10. 8. 오후 8:52, Stephan Gerhold wrote:
> Commit f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API")
> switched from extcon_register_notifier() to the resource-managed
> API, i.e. devm_extcon_register_notifier().
>
> This is problematic in this case, because the extcon notifier
> is dynamically registered/unregistered whenever the PHY is powered
> on/off. The resource-managed API does not unregister the notifier
> until the driver is removed, so as soon as the PHY is power cycled,
> attempting to register the notifier again results in:
>
> double register detected
> WARNING: CPU: 1 PID: 182 at kernel/notifier.c:26 notifier_chain_register+0x74/0xa0
> Call trace:
> ...
> extcon_register_notifier+0x74/0xb8
> devm_extcon_register_notifier+0x54/0xb8
> qcom_usb_hs_phy_power_on+0x1fc/0x208
> ...
>
> ... and USB stops working after plugging the cable out and in
> another time.
>
> The easiest way to fix this is to make a partial revert of
> commit f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API")
> and avoid using the resource-managed API in this case.
>
> Fixes: f0b5c2c96370 ("phy: qcom-usb-hs: Replace the extcon API")
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
> An other way to fix this would be keep the extcon notifier
> permanently registered, and check in qcom_usb_hs_phy_vbus_notifier
> if the PHY is currently powered on.
> ---
> drivers/phy/qualcomm/phy-qcom-usb-hs.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs.c b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
> index b163b3a1558d..61054272a7c8 100644
> --- a/drivers/phy/qualcomm/phy-qcom-usb-hs.c
> +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs.c
> @@ -158,8 +158,8 @@ static int qcom_usb_hs_phy_power_on(struct phy *phy)
> /* setup initial state */
> qcom_usb_hs_phy_vbus_notifier(&uphy->vbus_notify, state,
> uphy->vbus_edev);
> - ret = devm_extcon_register_notifier(&ulpi->dev, uphy->vbus_edev,
> - EXTCON_USB, &uphy->vbus_notify);
> + ret = extcon_register_notifier(uphy->vbus_edev, EXTCON_USB,
> + &uphy->vbus_notify);
> if (ret)
> goto err_ulpi;
> }
> @@ -180,6 +180,9 @@ static int qcom_usb_hs_phy_power_off(struct phy *phy)
> {
> struct qcom_usb_hs_phy *uphy = phy_get_drvdata(phy);
>
> + if (uphy->vbus_edev)
> + extcon_unregister_notifier(uphy->vbus_edev, EXTCON_USB,
> + &uphy->vbus_notify);
> regulator_disable(uphy->v3p3);
> regulator_disable(uphy->v1p8);
> clk_disable_unprepare(uphy->sleep_clk);
>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-10 11:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20191008115339epcas3p313aae9554dcee0a4269518fef1474ccd@epcas3p3.samsung.com>
2019-10-08 11:52 ` [PATCH] phy: qcom-usb-hs: Fix extcon double register after power cycle Stephan Gerhold
2019-10-10 11:08 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).