From 3b7e453012fa45334205d60ee47f3aff9941de47 Mon Sep 17 00:00:00 2001 From: Justin Hammond Date: Sun, 16 Aug 2026 16:03:56 +0800 Subject: [PATCH] drivers/usbhost: Take an xHCI command result from its completion event. xhci_command() returned -ETIMEDOUT when a completion arrived without an interrupt, although the fallback poll had already retrieved the event, so callers unwound work the controller had completed. Use the event's completion code whichever path retrieved it. Assisted-by: Claude:claude-opus-5 Signed-off-by: Justin Hammond --- drivers/usbhost/usbhost_xhci_pci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usbhost/usbhost_xhci_pci.c b/drivers/usbhost/usbhost_xhci_pci.c index 3a44dae1d01..e66718fb00a 100644 --- a/drivers/usbhost/usbhost_xhci_pci.c +++ b/drivers/usbhost/usbhost_xhci_pci.c @@ -1938,7 +1938,15 @@ static int xhci_command(FAR struct usbhost_xhci_s *priv, trb->d1 = priv->cmdres.d1; trb->d2 = priv->cmdres.d2; - if (XHCI_TRB_D1_CC_GET(trb->d1) != XHCI_TRB_CC_SUCCESS) + if (XHCI_TRB_D1_CC_GET(trb->d1) == XHCI_TRB_CC_SUCCESS) + { + /* The completion event decides the result, whether it arrived by + * interrupt or was found by the poll above. + */ + + ret = OK; + } + else { pcierr("event CC = %d\n", XHCI_TRB_D1_CC_GET(trb->d1)); ret = -EIO;