Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1709179 > unrolled thread
| Started by | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| First post | 2017-08-11 04:50 +0200 |
| Last post | 2017-08-11 04:50 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v3 0/5] usb: xhci: Handle USB transaction error on address command Lu Baolu <baolu.lu@linux.intel.com> - 2017-08-11 04:50 +0200
[PATCH v3 5/5] usb: xhci: Handle USB transaction error on address command Lu Baolu <baolu.lu@linux.intel.com> - 2017-08-11 04:50 +0200
[PATCH v3 4/5] usb: xhci: Return error when host is dead in xhci_disable_slot() Lu Baolu <baolu.lu@linux.intel.com> - 2017-08-11 04:50 +0200
[PATCH v3 1/5] usb: xhci: Disable slot even virt-dev is null Lu Baolu <baolu.lu@linux.intel.com> - 2017-08-11 04:50 +0200
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2017-08-11 04:50 +0200 |
| Subject | [PATCH v3 0/5] usb: xhci: Handle USB transaction error on address command |
| Message-ID | <ud8bn-6aS-5@gated-at.bofh.it> |
Xhci driver handles USB transaction errors on transfer events, but transaction errors are possible on address device command completion events as well. The xHCI specification (section 4.6.5) says: A USB Transaction Error Completion Code for an Address Device Command may be due to a Stall response from a device. Software should issue a Disable Slot Command for the Device Slot then an Enable Slot Command to recover from this error. The related discussion threads can be found through below links. http://marc.info/?l=linux-usb&m=149362010728921&w=2 http://marc.info/?l=linux-usb&m=149252752825755&w=2 This patch set includes some fixes in xhci_disable_slot() as well which will be used to handle USB transaction error on address command. --- Change log: v1->v2: - Add 4 fixes in xhci_disable_slot which will be used to handle USB transaction error on address command. v2->v3: - Add checking virt dev for test mode in PATCH 1/5. Lu Baolu (5): usb: xhci: Disable slot even virt-dev is null usb: xhci: Fix potential memory leak in xhci_disable_slot() usb: xhci: Fix memory leak when xhci_disable_slot() returns error usb: xhci: Return error when host is dead in xhci_disable_slot() usb: xhci: Handle USB transaction error on address command drivers/usb/host/xhci-hub.c | 5 ++++- drivers/usb/host/xhci.c | 52 ++++++++++++++++++--------------------------- drivers/usb/host/xhci.h | 3 +-- 3 files changed, 26 insertions(+), 34 deletions(-) -- 2.7.4
[toc] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2017-08-11 04:50 +0200 |
| Subject | [PATCH v3 5/5] usb: xhci: Handle USB transaction error on address command |
| Message-ID | <ud8bn-6aS-11@gated-at.bofh.it> |
| In reply to | #1709179 |
Xhci driver handles USB transaction errors on transfer events, but transaction errors are possible on address device command completion events as well. The xHCI specification (section 4.6.5) says: A USB Transaction Error Completion Code for an Address Device Command may be due to a Stall response from a device. Software should issue a Disable Slot Command for the Device Slot then an Enable Slot Command to recover from this error. This patch handles USB transaction errors on address command completion events. The related discussion threads can be found through below links. http://marc.info/?l=linux-usb&m=149362010728921&w=2 http://marc.info/?l=linux-usb&m=149252752825755&w=2 Suggested-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> --- drivers/usb/host/xhci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index d6b728d..95780f8 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3822,6 +3822,11 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, break; case COMP_USB_TRANSACTION_ERROR: dev_warn(&udev->dev, "Device not responding to setup %s.\n", act); + + ret = xhci_disable_slot(xhci, udev->slot_id); + if (!ret) + xhci_alloc_dev(hcd, udev); + ret = -EPROTO; break; case COMP_INCOMPATIBLE_DEVICE_ERROR: -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2017-08-11 04:50 +0200 |
| Subject | [PATCH v3 4/5] usb: xhci: Return error when host is dead in xhci_disable_slot() |
| Message-ID | <ud8bo-6aS-17@gated-at.bofh.it> |
| In reply to | #1709179 |
xhci_disable_slot() is a helper for disabling a slot when a device
goes away or recovers from error situations. Currently, it returns
success when it sees a dead host. This is not the right way to go.
It should return error and let the invoker know that disable slot
command was failed due to a dead host.
Fixes: f9e609b82479 ("usb: xhci: Add helper function xhci_disable_slot().")
Cc: Guoqing Zhang <guoqing.zhang@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/usb/host/xhci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2df601e..d6b728d 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3568,10 +3568,9 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id)
state = readl(&xhci->op_regs->status);
if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
(xhci->xhc_state & XHCI_STATE_HALTED)) {
- xhci_free_virt_device(xhci, slot_id);
spin_unlock_irqrestore(&xhci->lock, flags);
kfree(command);
- return ret;
+ return -ENODEV;
}
ret = xhci_queue_slot_control(xhci, command, TRB_DISABLE_SLOT,
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Lu Baolu <baolu.lu@linux.intel.com> |
|---|---|
| Date | 2017-08-11 04:50 +0200 |
| Subject | [PATCH v3 1/5] usb: xhci: Disable slot even virt-dev is null |
| Message-ID | <ud8bp-6aS-23@gated-at.bofh.it> |
| In reply to | #1709179 |
xhci_disable_slot() is a helper for disabling a slot when a device
goes away or recovers from error situations. Currently, it checks
the corespoding virt-dev pointer and returns directly (w/o issuing
disable slot command) if it's null.
This is unnecessary and will cause problems in case where virt-dev
allocation fails and xhci_disable_slot() is called to roll back the
hardware state. Refer to the implementation of xhci_alloc_dev().
This patch removes lines to check virt-dev in xhci_disable_slot().
Fixes: f9e609b82479 ("usb: xhci: Add helper function xhci_disable_slot().")
Cc: Guoqing Zhang <guoqing.zhang@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/usb/host/xhci-hub.c | 3 +++
drivers/usb/host/xhci.c | 4 ----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 00721e8..6fcb98d 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -612,6 +612,9 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
xhci_dbg(xhci, "Disable all slots\n");
spin_unlock_irqrestore(&xhci->lock, *flags);
for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
+ if (!xhci->devs[i])
+ continue;
+
retval = xhci_disable_slot(xhci, NULL, i);
if (retval)
xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n",
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index b2ff1ff..e69073f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3567,11 +3567,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, struct xhci_command *command,
unsigned long flags;
u32 state;
int ret = 0;
- struct xhci_virt_device *virt_dev;
- virt_dev = xhci->devs[slot_id];
- if (!virt_dev)
- return -EINVAL;
if (!command)
command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
if (!command)
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web