Re: [PATCH V1 1/1] usb/host: Let usb phy shutdown later

surong pang
2022-04-22T10:44:12Z

>>> @@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>>> clk_disable_unprepare(clk);
>>> clk_disable_unprepare(reg_clk);
>>> + usb_phy_shutdown(hcd->usb_phy);
>>> usb_put_hcd(hcd);

Is it ok to put usb_phy_shutdown before usb_put_hcd(hcd)? hcd is
released at usb_put_hcd.

UNISOC DWC3 phy is not divided USB 2.0/3.0 phy clearly. Yes, it's
UNISOC's issue.
It UNISOC's dtsi: phys = <&ssphy>, <&ssphy>;
If to shutdown phy too earlier, it will cost 10s timeout to do xhci_reset.
usb_remmove_hcd --> usb_stop_hcd --> xhci_stop --> xhci_reset -->
xhci_handshake(&xhci->op_regs->command, CMD_RESET, 0, 10 * 1000 *1000)

I want to know this change is acceptable or not?

hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
Why in xhci_plat_remove, just to shutdown "usb-phy"[0], not to
shutdown "usb-phy"[1] ?

Mathias Nyman <mathias.nyman@linux.intel.com> 于2022年4月22日周五 15:51写道：
>
> On 22.4.2022 5.10, surong pang wrote:
> > shared_hcd might be freed already here, but hcd should not be freed
> > here, because "usb_put_hcd(hcd)" is called later.
>
> To me it still looks like this patch calls usb_phy_shutdown(hcd->usb_phy) _after_
> usb_put_hcd(hcd):
>
> >>> @@ -398,6 +397,7 @@ static int xhci_plat_remove(struct platform_device *dev)
> >>> clk_disable_unprepare(clk);
> >>> clk_disable_unprepare(reg_clk);
> >>> usb_put_hcd(hcd);
> >>> + usb_phy_shutdown(hcd->usb_phy);
>
>
> shared hcd was freed even earlier, before disabling the clocks.
>
> Thanks
> Mathias