[PATCH master] phy: stm32-usbphyc: fix unbalanced phy exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On the STM32MP1, shutting down barebox can result in a

  ERROR: phy1: phy exit failed --> -22

message printed to the console. This is because the regulator is disabled
more often than it was enabled, because stm32_usbphyc_pll_disable
is called twice:

  - Once from stm32_usbphyc_remove calling stm32_usbphyc_phy_exit
  - Once from dwc2_remove calling phy_exit -> stm32_usbphyc_phy_exit

The code is taken from Linux and likely causes no issues there, because
devices are removed in reverse probe order, which barebox doesn't
enforce. Properly solving this would be a larger endeavour, so for now
just fix the stm32-usbphyc driver to ignore reference count dropping
below zero and only call __stm32_usbphyc_pll_disable once.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/phy/phy-stm32-usbphyc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c
index ac82b019f44c..91f4e7f7e08d 100644
--- a/drivers/phy/phy-stm32-usbphyc.c
+++ b/drivers/phy/phy-stm32-usbphyc.c
@@ -277,7 +277,7 @@ static int __stm32_usbphyc_pll_disable(struct stm32_usbphyc *usbphyc)
 static int stm32_usbphyc_pll_disable(struct stm32_usbphyc *usbphyc)
 {
 	/* Check if a phy port is still active or clk48 in use */
-	if (atomic_dec_return(&usbphyc->n_pll_cons) > 0)
+	if (atomic_dec_return(&usbphyc->n_pll_cons) != 1)
 		return 0;
 
 	return __stm32_usbphyc_pll_disable(usbphyc);
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux