[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231023054111.2744872-1-Meng.Li@windriver.com>
Date: Mon, 23 Oct 2023 13:41:11 +0800
From: Meng Li <Meng.Li@...driver.com>
To: stern@...land.harvard.edu, gregkh@...uxfoundation.org,
linux-usb@...r.kernel.org, usb-storage@...ts.one-eyed-alien.net,
linux-kernel@...r.kernel.org
Cc: meng.li@...driver.com
Subject: [PATCH] usb: storage: add shutdown function for usb storage driver
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. Therefore, add shutdown function
used to disconnect the usb mass storage device to avoid data transferring under
the stopped status of PCIe device.
Signed-off-by: Meng Li <Meng.Li@...driver.com>
---
drivers/usb/storage/usb.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index ed7c6ad96a74..e076d7e3784f 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -1142,6 +1142,15 @@ static int storage_probe(struct usb_interface *intf,
return result;
}
+static void usb_stor_shutdown(struct device *dev)
+{
+ struct usb_driver *driver = to_usb_driver(dev->driver);
+ struct usb_interface *intf = to_usb_interface(dev);
+
+ if (driver->disconnect)
+ driver->disconnect(intf);
+}
+
static struct usb_driver usb_storage_driver = {
.name = DRV_NAME,
.probe = storage_probe,
@@ -1151,6 +1160,7 @@ static struct usb_driver usb_storage_driver = {
.reset_resume = usb_stor_reset_resume,
.pre_reset = usb_stor_pre_reset,
.post_reset = usb_stor_post_reset,
+ .drvwrap.driver.shutdown = usb_stor_shutdown,
.id_table = usb_storage_usb_ids,
.supports_autosuspend = 1,
.soft_unbind = 1,
--
2.34.1
Powered by blists - more mailing lists