Re: [PATCH] usb: storage: add shutdown function for usb storage driver

From: gregkh@xxxxxxxxxxxxxxxxxxx
Date: Tue Oct 24 2023 - 11:45:50 EST


On Tue, Oct 24, 2023 at 11:35:19AM -0400, Alan Stern wrote:
> On Tue, Oct 24, 2023 at 03:43:56AM +0000, Li, Meng wrote:
> >
> >
> > > -----Original Message-----
> > > From: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
>
> > > On Mon, Oct 23, 2023 at 01:41:11PM +0800, Meng Li wrote:
> > > > On ls1043/ls1046 rdb platform, if a PCIe-USB host controller is
> > > > installed, and an USB disk is also installed on the PCIe card, when
> > > > executing "reboot -f" to reset the board, there will be below error reported:
> > > > usb 2-2: device not accepting address 2, error -108
>
> > > > This issue is introduced by linux-yocto commit 837547b64a34("driver: net:
> > > > dpaa: release resource when executing kexec") that cause to spend more
> > > > time on shutdown operation. So, the 2 platforms with DPAA are not
> > > > reset immediately after executing force reboot command. Moreover, the
> > > > usb-storage thread is still in active status, there is still control
> > > > data transferred between USB disk and PCIe host controller. But now
> > > > the shutdown callback of usb pci driver had been invoked to stop the
> > > > PCIe host controller completely. In this situation, the data transferring failed
> > > and report error.
> > >
> > > That's _supposed_ to happen. By design, the "reboot -f" command is meant
> > > to carry out an immediate reboot, without using the init system, unmounting
> > > filesystems, or doing other cleanup operations.
> > >
> >
> > As my above said, I understand what you mean. I also thought over what you said.
> > I am not sure, but I still sent patch to upstream community, and want to get some suggest from more authoritative maintainer.
> >
> > > If you want a clean reboot with no errors, don't use the "-f" option.
> > >
> >
> > There is also error report even if I use command "reboot"
>
> Okay, that's a different matter. In fact, I don't know what is supposed
> to happen during a clean reboot.

Define "clean" :)

reboot is a system thing that happens before the reboot syscall happens.
So which are we talking nabout here?

> Greg, do you know? Should we take the time to disconnect all the USB
> devices during a system shutdown?

In the past we have not. And if we switch to do so, we might get some
complaints as we would now delaying the shutdown process to be longer
than before.

> What happens with non-USB disk drives? Or other removable devices?

It would have to come from "above" in the device tree, so does the PCI
or platform bus say that they should be shut down and their child
devices?

thanks,

greg k-h