Hi Marek, > > On 8/20/19 5:42 PM, Sherry Sun wrote: > [...] > > >>>>>>> +U_BOOT_DRIVER(xhci_imx8) = { > >>>>>>> + .name = "xhci_imx8", > >>>>>>> + .id = UCLASS_USB, > >>>>>>> + .of_match = xhci_usb_ids, > >>>>>>> + .probe = xhci_imx8_probe, > >>>>>>> + .remove = xhci_imx8_remove, > >>>>>>> + .ops = &xhci_usb_ops, > >>>>>>> + .platdata_auto_alloc_size = sizeof(struct usb_platdata), > >>>>>>> + .priv_auto_alloc_size = sizeof(struct xhci_ctrl), > >>>>>>> + .flags = DM_FLAG_ALLOC_PRIV_DMA, > >>>>>> > >>>>>> I think you also need DM_FLAG_OS_PREPARE to trigger .remove > >>>>>> before booting Linux, but I might be wrong. Please check that. > >>>>> > >>>>> When use usb stop command to stop the usb host driver, > >>>>> device_remove(bus, DM_REMOVE_NORMAL) is called by usb_stop(), so > >>>>> normally we don’t need the DM_FLAG_OS_PREPARE flag. > >>>>> But considering some special circumstances, maybe add this flag is > helpful. > >>>> > >>>> I'm not talking about "usb stop", I am talking about booting Linux. > >>>> That's when then .remove should be called to tear down the driver. Is it? > >>> > >>> I know what you mean. The only function of DM_FLAG_OS_PREPARE is to > >>> call .remove before booting kernel, to make sure the device is > >>> removed. > >>> But normally, the host device is removed every time after we use it. > >> > >> How so ? The controller is left running until you call .remove() > > > > We usually start the host driver in uboot by using the usb start command, > right? > > And we will call usb stop command to finish the usb start command. > > .remove will be called in usb_stop(). So I think the controller has already > been teared before booting kernel. > > That is only if you assume that every user will manually call usb stop, > always, > and never fail to do so. And also every piece of code which might have inited > the USB will also tear down the controller. That is not realistic. > > Hence. you should call the .remove() before boot to tear down the controller.
Okay, you are right, I will add this flag, thanks. Best regards Sherry sun _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot