Linux USB
 help / color / mirror / Atom feed
From: Meng Li <Meng.Li@windriver.com>
To: stern@rowland.harvard.edu, gregkh@linuxfoundation.org,
	linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
	linux-kernel@vger.kernel.org
Cc: meng.li@windriver.com
Subject: [PATCH] usb: storage: add shutdown function for usb storage driver
Date: Mon, 23 Oct 2023 13:41:11 +0800	[thread overview]
Message-ID: <20231023054111.2744872-1-Meng.Li@windriver.com> (raw)

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@windriver.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


             reply	other threads:[~2023-10-23  5:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23  5:41 Meng Li [this message]
2023-10-23 19:11 ` [PATCH] usb: storage: add shutdown function for usb storage driver Alan Stern
2023-10-24  3:43   ` Li, Meng
2023-10-24 15:35     ` Alan Stern
2023-10-24 15:45       ` gregkh
2023-10-24 15:58         ` Alan Stern
2023-10-24 17:11           ` gregkh
2023-10-24 19:23             ` Alan Stern
2023-10-25  2:25               ` Li, Meng
2023-10-25 14:25                 ` Alan Stern
2023-10-25  9:07               ` Oliver Neukum
2023-10-25 14:28                 ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231023054111.2744872-1-Meng.Li@windriver.com \
    --to=meng.li@windriver.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox