From patchwork Sun Oct 29 06:37:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856682 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=jciAA1Jm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6Dt07tbz1yQ4 for ; Sun, 29 Oct 2023 17:38:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE48587546; Sun, 29 Oct 2023 07:38:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="jciAA1Jm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5B98C871E8; Sun, 29 Oct 2023 07:38:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7C9528723E for ; Sun, 29 Oct 2023 07:38:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 2959E4268B; Sun, 29 Oct 2023 06:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561514; bh=sMQh7bVawXy0WhD2dNbG6eMTmPg5iywzeluiqHfUanU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jciAA1JmdGdhP9JYRDTIjine8atkXbUEiyLvmK+no0mKAjXWmRZDi/A6qH0DcrArn 6cy0xovmKaXF47vB5/uAA0hv9X+xOECht5/m2tZU93YnShkdCUF1mgNExDv6NgN2l0 fwLpzd2BmYOHbXBEz2xNGUV5nAvJDlq6kiCt33M23RurTQFHcbY51vdN1YBMPtYlzy eom2sWhCXD3hmk9XAZUohTE9Sb9tns1F/6Dj2V8/yLn+ZMJcOAE8zc+g2xqOZxz3pS BMNiuCxY/aWh5n+obEjxNDRCUDmlzWqImGuFkUrv6MqsyRbZD19gpjAY9LnNB+X4gG d7IFtKLyo5bUA== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:38 +0900 Subject: [PATCH v2 1/8] usb: xhci: Guard all calls to xhci_wait_for_event MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-1-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3992; i=marcan@marcan.st; h=from:subject:message-id; bh=sMQh7bVawXy0WhD2dNbG6eMTmPg5iywzeluiqHfUanU=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbv3fais4depx9xPB46IEnn3QnlW3Y/e3rwoNah5+Gp 83ZoT6/rKOUhUGMg0FWTJGl8UTvqW7P6efUVVOmw8xhZQIZwsDFKQAT8fnD8FfKSGKN8ckpq3y/ +3IfCJtSNy/uwNTzCu5PJXout7Apps1jZFh76bjqzZ1KkcuZ/913FGN5uy1J6dKkqw1tgq+l5/N pP2YDAA== X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean xhci_wait_for_event returns NULL on timeout, so the caller always has to check for that. This addresses immediate explosions in this part of the code when timeouts happen, but not the root cause for the timeout. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 15 +++++++++++++++ drivers/usb/host/xhci.c | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c8260cbdf94b..d0960812a47b 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -511,6 +511,9 @@ static void reset_ep(struct usb_device *udev, int ep_index) printf("Resetting EP %d...\n", ep_index); xhci_queue_command(ctrl, 0, udev->slot_id, ep_index, TRB_RESET_EP); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return; + field = le32_to_cpu(event->trans_event.flags); BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id); xhci_acknowledge_event(ctrl); @@ -519,6 +522,9 @@ static void reset_ep(struct usb_device *udev, int ep_index) (void *)((uintptr_t)ring->enqueue | ring->cycle_state)); xhci_queue_command(ctrl, addr, udev->slot_id, ep_index, TRB_SET_DEQ); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return; + BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id || GET_COMP_CODE(le32_to_cpu( event->event_cmd.status)) != COMP_SUCCESS); @@ -544,6 +550,9 @@ static void abort_td(struct usb_device *udev, int ep_index) xhci_queue_command(ctrl, 0, udev->slot_id, ep_index, TRB_STOP_RING); event = xhci_wait_for_event(ctrl, TRB_TRANSFER); + if (!event) + return; + field = le32_to_cpu(event->trans_event.flags); BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id); BUG_ON(TRB_TO_EP_INDEX(field) != ep_index); @@ -552,6 +561,9 @@ static void abort_td(struct usb_device *udev, int ep_index) xhci_acknowledge_event(ctrl); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return; + BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id || GET_COMP_CODE(le32_to_cpu( event->event_cmd.status)) != COMP_SUCCESS); @@ -561,6 +573,9 @@ static void abort_td(struct usb_device *udev, int ep_index) (void *)((uintptr_t)ring->enqueue | ring->cycle_state)); xhci_queue_command(ctrl, addr, udev->slot_id, ep_index, TRB_SET_DEQ); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return; + BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id || GET_COMP_CODE(le32_to_cpu( event->event_cmd.status)) != COMP_SUCCESS); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 5cacf0769ec7..d13cbff9b372 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -451,6 +451,9 @@ static int xhci_configure_endpoints(struct usb_device *udev, bool ctx_change) xhci_queue_command(ctrl, in_ctx->dma, udev->slot_id, 0, ctx_change ? TRB_EVAL_CONTEXT : TRB_CONFIG_EP); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return -ETIMEDOUT; + BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id); @@ -647,6 +650,9 @@ static int xhci_address_device(struct usb_device *udev, int root_portnr) xhci_queue_command(ctrl, virt_dev->in_ctx->dma, slot_id, 0, TRB_ADDR_DEV); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return -ETIMEDOUT; + BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != slot_id); switch (GET_COMP_CODE(le32_to_cpu(event->event_cmd.status))) { @@ -722,6 +728,9 @@ static int _xhci_alloc_device(struct usb_device *udev) xhci_queue_command(ctrl, 0, 0, 0, TRB_ENABLE_SLOT); event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return -ETIMEDOUT; + BUG_ON(GET_COMP_CODE(le32_to_cpu(event->event_cmd.status)) != COMP_SUCCESS); From patchwork Sun Oct 29 06:37:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856683 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=o829k8iC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6F61wy0z1yQ4 for ; Sun, 29 Oct 2023 17:39:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8C9DA8755C; Sun, 29 Oct 2023 07:38:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="o829k8iC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF34B871E8; Sun, 29 Oct 2023 07:38:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EF67D87546 for ; Sun, 29 Oct 2023 07:38:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 9D1BD42699; Sun, 29 Oct 2023 06:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561516; bh=GHn3v5LlOeMlC6cj+xN5ckRq+X6ZOTSSgSh4Uz7JtTw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=o829k8iCPBaIwiyYqbh5rgWzOtWWjMgBUy5IvyxF20LxZDJeaOv6oOkphIV0Y9Wms JO2a8bJ8B9+tzed3TqN0NywNd+wJbYnAUQZDFe38ASDep4dpWzQktdWEzMEZhWW7rZ sKB/CoQBaLQkv0l9jLLn91J8Q2JFVwo1zPcPSnKwIR6xNuyg5YOo2nwnMkK2Euvl2e ACSUrkhTgQs9dqHh9NUtxQ/RaKjodRikLVCfd5BrZt0CeXP0W/DYJqs7iSSSf/OVGA 6ot5TSvEBUKmCCpswuAa34XHdk7xJcAd0kTpFHLBYXFQRNwWT7k7EwFaXI5TIKs5Hm HMMyxCw3b6zuQ== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:39 +0900 Subject: [PATCH v2 2/8] usb: xhci: Better error handling in abort_td() MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-2-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3266; i=marcan@marcan.st; h=from:subject:message-id; bh=GHn3v5LlOeMlC6cj+xN5ckRq+X6ZOTSSgSh4Uz7JtTw=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbv3eZjQJCf1+yymt886ls89r7Fh+701NfZddN2bPwV znruwl9HaUsDGIcDLJiiiyNJ3pPdXtOP6eumjIdZg4rE8gQBi5OAZiI20aGP5xF664sWizAdp2J dYujXou0tb3xN8GvVovf/mBu2Lf/3ClGhpkvX75hzSjJk/+u2jLfpE4o26Bx4aQJSSV6wu98X2Q YMAMA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean If the xHC has a problem with our STOP ENDPOINT command, it is likely to return a completion directly instead of first a transfer event for the in-progress transfer. Handle that more gracefully. We still BUG() on the error code, but at least we don't end up timing out on the event and ending up with unexpected event errors. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 34 ++++++++++++++++++++++------------ include/usb/xhci.h | 2 ++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d0960812a47b..d21e76e0bdb6 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -466,7 +466,8 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) continue; type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->event_cmd.flags)); - if (type == expected) + if (type == expected || + (expected == TRB_NONE && type != TRB_PORT_STATUS)) return event; if (type == TRB_PORT_STATUS) @@ -544,27 +545,36 @@ static void abort_td(struct usb_device *udev, int ep_index) struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring; union xhci_trb *event; + trb_type type; u64 addr; u32 field; xhci_queue_command(ctrl, 0, udev->slot_id, ep_index, TRB_STOP_RING); - event = xhci_wait_for_event(ctrl, TRB_TRANSFER); + event = xhci_wait_for_event(ctrl, TRB_NONE); if (!event) return; - field = le32_to_cpu(event->trans_event.flags); - BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id); - BUG_ON(TRB_TO_EP_INDEX(field) != ep_index); - BUG_ON(GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len - != COMP_STOP))); - xhci_acknowledge_event(ctrl); + type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->event_cmd.flags)); + if (type == TRB_TRANSFER) { + field = le32_to_cpu(event->trans_event.flags); + BUG_ON(TRB_TO_SLOT_ID(field) != udev->slot_id); + BUG_ON(TRB_TO_EP_INDEX(field) != ep_index); + BUG_ON(GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len + != COMP_STOP))); + xhci_acknowledge_event(ctrl); - event = xhci_wait_for_event(ctrl, TRB_COMPLETION); - if (!event) - return; + event = xhci_wait_for_event(ctrl, TRB_COMPLETION); + if (!event) + return; + type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->event_cmd.flags)); - BUG_ON(TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) + } else { + printf("abort_td: Expected a TRB_TRANSFER TRB first\n"); + } + + BUG_ON(type != TRB_COMPLETION || + TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) != udev->slot_id || GET_COMP_CODE(le32_to_cpu( event->event_cmd.status)) != COMP_SUCCESS); xhci_acknowledge_event(ctrl); diff --git a/include/usb/xhci.h b/include/usb/xhci.h index 4a4ac10229ac..04d16a256bbd 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -901,6 +901,8 @@ union xhci_trb { /* TRB type IDs */ typedef enum { + /* reserved, used as a software sentinel */ + TRB_NONE = 0, /* bulk, interrupt, isoc scatter/gather, and control data stage */ TRB_NORMAL = 1, /* setup stage for control transfers */ From patchwork Sun Oct 29 06:37:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856684 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=xzGwAQIB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6FL35gRz1yQ4 for ; Sun, 29 Oct 2023 17:39:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A3C78755B; Sun, 29 Oct 2023 07:38:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="xzGwAQIB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A9A9871E8; Sun, 29 Oct 2023 07:38:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 70CCA8723E for ; Sun, 29 Oct 2023 07:38:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 1CBD74269A; Sun, 29 Oct 2023 06:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561519; bh=+uNlvOQTliC68AiSD0644nsVxzLYR2l34Apw6zfhJVw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=xzGwAQIBPb+40EdpXEo6mGaKTKzni4qpIgyqVskGs+1F8Vs3JNhAp1sLla+8iNfez yBW4IZBClWsFDu/LT0NTiXSduglH76wXXCopliaUgVx6K5ANu5KNt/CLsDjTIOXFNR 0qthENx378BKXjbVM1zyvFE8fR8FMUCYNGRTEn+pDJAZWARx/Ci+t5rsWtUA219Rri FEgT82JI40eiGnUOz/46fBHr199tDLDVk0QWlgB7KGBF5OSP1+zo5s2JvCEnaCdWHl Z91JzccL0BcLSmxesFNi1HF6KhXrAGS3mr1/fis6mppE5vOoFDgIAZjHizdEoOM0K0 HDnRzo8obX/mQ== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:40 +0900 Subject: [PATCH v2 3/8] usb: xhci: Allow context state errors when halting an endpoint MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-3-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1562; i=marcan@marcan.st; h=from:subject:message-id; bh=+uNlvOQTliC68AiSD0644nsVxzLYR2l34Apw6zfhJVw=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbv/eMWs2i5V6G6ypP03r3+cR9SRW2d0/qG3U+vux8v 6vpk+iLjlIWBjEOBlkxRZbGE72nuj2nn1NXTZkOM4eVCWQIAxenAEyk7zcjw+3zu8ym+TnGruFs OKM8aWdsWrRW1dNdIotyg5mezGBfupqRYe+k3AMzGl6U3WRfXHlVxI/776yTct3lBS/nRRX0/Hi fygMA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean There is a race where an endpoint may halt by itself while we are trying to halt it, which results in a context state error. See xHCI 4.6.9 which mentions this case. This also avoids BUGging when we attempt to stop an endpoint which was already stopped to begin with, which is probably a bug elsewhere but not a good reason to crash. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d21e76e0bdb6..e02a6e300c4f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -545,6 +545,7 @@ static void abort_td(struct usb_device *udev, int ep_index) struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); struct xhci_ring *ring = ctrl->devs[udev->slot_id]->eps[ep_index].ring; union xhci_trb *event; + xhci_comp_code comp; trb_type type; u64 addr; u32 field; @@ -573,10 +574,11 @@ static void abort_td(struct usb_device *udev, int ep_index) printf("abort_td: Expected a TRB_TRANSFER TRB first\n"); } + comp = GET_COMP_CODE(le32_to_cpu(event->event_cmd.status)); BUG_ON(type != TRB_COMPLETION || TRB_TO_SLOT_ID(le32_to_cpu(event->event_cmd.flags)) - != udev->slot_id || GET_COMP_CODE(le32_to_cpu( - event->event_cmd.status)) != COMP_SUCCESS); + != udev->slot_id || (comp != COMP_SUCCESS && comp + != COMP_CTX_STATE)); xhci_acknowledge_event(ctrl); addr = xhci_trb_virt_to_dma(ring->enq_seg, From patchwork Sun Oct 29 06:37:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856685 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=v3szJg+o; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6FZ2Fzrz1yQ4 for ; Sun, 29 Oct 2023 17:39:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 43F758756F; Sun, 29 Oct 2023 07:38:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="v3szJg+o"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 83B9F87550; Sun, 29 Oct 2023 07:38:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E337F8758F for ; Sun, 29 Oct 2023 07:38:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 92E074269B; Sun, 29 Oct 2023 06:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561521; bh=cTK2n4nJfIjhYgrfnO7KnHAERQlBK/UrEyzwgBcEO6g=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=v3szJg+o8SkecUdDH1JrL+PYIRmw9vlnqoRfgA/a44tsgG3gyflWFo7Djo1TkDoWE lTS90Sjtkspvu2eXhNVuNawtP+NIwvpqdzUGfbhSw+5OfeBFedonKgrPUfy6YG8gmV qEe7DpLepC46Qq5KBxkBhC/E6yjcj5Zo3lq2+3pZC2+MCS3rujCGQQzAoYmFQU6Rpm pDHfkzQpFAagq/gdH16rtlC90TKvk5qBpUtfp4nbrbc+GDZpiFZHhsYVh49uz7nQWE UylLxkx+BKYO3iy9B7eU7X7PGMfnbc5z60DqgqApoOk9fmD7gWbRUyc7y0HXHCJ+Z2 CaEGTKpKeKo3w== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:41 +0900 Subject: [PATCH v2 4/8] usb: xhci: Recover from halted bulk endpoints MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-4-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1200; i=marcan@marcan.st; h=from:subject:message-id; bh=cTK2n4nJfIjhYgrfnO7KnHAERQlBK/UrEyzwgBcEO6g=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbv/eXpU16sq9V09/S6o1MeOUz5SQHxjmnlrL877Bd4 fHnHTtrRykLgxgHg6yYIkvjid5T3Z7Tz6mrpkyHmcPKBDKEgYtTACaSupLhr2BJ+MzKO/wROVoK xvw8+cvO3ufa112bW++a3NSyrFJIlOEP/5bQFwyLeY8at55y3bG0kPfCOlsrZnkHo22r9MPvXmb kBgA= X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean There is currently no codepath to recover from this case. In principle we could require that the upper layer do this explicitly, but let's just do it in xHCI when the next bulk transfer is started, since that reasonably implies whatever caused the problem has been dealt with. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e02a6e300c4f..db8b8f200250 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -671,6 +671,14 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, ep_ctx = xhci_get_ep_ctx(ctrl, virt_dev->out_ctx, ep_index); + /* + * If the endpoint was halted due to a prior error, resume it before + * the next transfer. It is the responsibility of the upper layer to + * have dealt with whatever caused the error. + */ + if ((le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK) == EP_STATE_HALTED) + reset_ep(udev, ep_index); + ring = virt_dev->eps[ep_index].ring; /* * How much data is (potentially) left before the 64KB boundary? From patchwork Sun Oct 29 06:37:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856686 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=CKub+lQV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6Fm4qlPz1yQ4 for ; Sun, 29 Oct 2023 17:39:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B540687615; Sun, 29 Oct 2023 07:38:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="CKub+lQV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5DEBE870E4; Sun, 29 Oct 2023 07:38:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 61BF287258 for ; Sun, 29 Oct 2023 07:38:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 12683426BA; Sun, 29 Oct 2023 06:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561524; bh=omrmzNklgVMvUbEzorKZ9alk9sHxhNw8icvLAtAAbQM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CKub+lQVlubvDweBa47YLnDi+G0EgDgPM/XVH/cUdpBoQcZXdj/fGqMYCH8+klMSd HQP+meFxZA5P8X/Mu11pRMIExHTRq9ScYfIlm6OSSe6/H6TlT2hWSlZ1pLXmgDwu7X KaCPyXFndOBAJwoLT+iG5yhpN7YWrHflPtdhqUQynCvgmBKGjdXXleHjhWYi5P0D/B hMKt7JppqLP9WghObvlsCy7lzQf90cCptLdDuYBQeSfGLOg6IYBDmHwB6GdbJue81z YqjBMJDNe687LOt4mLvUSRTXOAEZrM/VPy+UZBStFoUi3C+TSYcq7uCkjXmGSeODcQ omPNH2LlF3UCA== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:42 +0900 Subject: [PATCH v2 5/8] usb: xhci: Fail on attempt to queue TRBs to a halted endpoint MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-5-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=828; i=marcan@marcan.st; h=from:subject:message-id; bh=omrmzNklgVMvUbEzorKZ9alk9sHxhNw8icvLAtAAbQM=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbvw/MLBwqFoY1RXpV37vlrd+c5nS3ke/qiYNfWNr5f +/hE53eUcrCIMbBICumyNJ4ovdUt+f0c+qqKdNh5rAygQxh4OIUgIlMcWL4w6M9J3ZT1fGN3yc/ CPd8kFI5XU9X5tmjfJMfwd2Sut+zDjMyHDtgviqV/emqBxV/dpxk/H0r1Kxr2akHhTcNL7Yq6ie YMwMA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This isn't going to work, don't pretend it will and then end up timing out. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index db8b8f200250..a969eafdc8ee 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -243,7 +243,8 @@ static int prepare_ring(struct xhci_ctrl *ctrl, struct xhci_ring *ep_ring, puts("WARN waiting for error on ep to be cleared\n"); return -EINVAL; case EP_STATE_HALTED: - puts("WARN halted endpoint, queueing URB anyway.\n"); + puts("WARN endpoint is halted\n"); + return -EINVAL; case EP_STATE_STOPPED: case EP_STATE_RUNNING: debug("EP STATE RUNNING.\n"); From patchwork Sun Oct 29 06:37:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856687 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=Aq41iN2v; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6G51qzdz1yQ4 for ; Sun, 29 Oct 2023 17:39:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A1B4876C0; Sun, 29 Oct 2023 07:38:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="Aq41iN2v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 91E9F870E4; Sun, 29 Oct 2023 07:38:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DE89D874E1 for ; Sun, 29 Oct 2023 07:38:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 86A834269A; Sun, 29 Oct 2023 06:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561526; bh=2Ezazxo/l/m35b7gLCXnhikSTgV+JLOV/BkAoTnghb8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Aq41iN2vSj1jmEASSvUX71dgP+TITRQKSlkJKMn2fZ7H+u0a1npZDva57A06BFejS StalOh4HeKMqghLGHgPhAvSkTrHLOEqHmuJFE+3b7yCr6alwZBRAOETR5zyU5GPLEU deCk0RW+cxeaQi+6N+b1+T+RheLjo+o9l9hjeYTrnAsDetzDMYnjqzbz+8g4WVv3LV a6Kk1UDdtGfBY7kzF8+pKwIurpTcYT71wUHvDF7TVT0w7UM6Zag3obykHelVESpXDd gXCAsXjhwDosMR2zumcLnA2BYtaxyLf422VhvlnTM7HAa89pDiNJBhDeLCEEO+Y1Fg G/Bb+LanyRzKQ== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:43 +0900 Subject: [PATCH v2 6/8] usb: xhci: Do not panic on event timeouts MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-6-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=837; i=marcan@marcan.st; h=from:subject:message-id; bh=2Ezazxo/l/m35b7gLCXnhikSTgV+JLOV/BkAoTnghb8=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbvw+36Io27DAslbS5tk85RcS+zGPvzrnzcs9Hrn7Uy MIn4vyto5SFQYyDQVZMkaXxRO+pbs/p59RVU6bDzGFlAhnCwMUpABM59omR4VOR+uSl14t9tcMy /e9Yikp12wsetr1rrVX3VmK/ZpNgLSPD9HmMak/0pjhmX7vYut9MOd01TPPMc/M6v+W7ztt/PsP ECgA= X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Now that we always check the return value, just return NULL on timeouts. We can still log the error since this is a problem, but it's not reason to panic. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index a969eafdc8ee..ae0ab5744df0 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -494,8 +494,9 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) if (expected == TRB_TRANSFER) return NULL; - printf("XHCI timeout on event type %d... cannot recover.\n", expected); - BUG(); + printf("XHCI timeout on event type %d...\n", expected); + + return NULL; } /* From patchwork Sun Oct 29 06:37:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856688 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=ir13GisZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6GK3Cx0z1yQ4 for ; Sun, 29 Oct 2023 17:40:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B5D1687740; Sun, 29 Oct 2023 07:38:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="ir13GisZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D44A8763A; Sun, 29 Oct 2023 07:38:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7249A8769C for ; Sun, 29 Oct 2023 07:38:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 0640F4268B; Sun, 29 Oct 2023 06:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561528; bh=ppe6Yz6eRH+7A2U81PZqJ6AYVRQhDWwxRmqdPM5NSoE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ir13GisZhJfTavqDCoF76XgmTswkQBpkE38IkRGLmQ78zzo9nYCHfYTwKi8WVfwKp P/tTt/orR7g3T3JPfZm4CnDfZA6zA34eyrv1B4kXf0qZP3mN75EGgjsBW1rBFQ5G/f FyXa0rwfaMxK6otp4DsQSZvCAbLn6VS4CZL/FUvKzj9pR7TGinKu+T7u29vdrdGWys P+Te1KsOUwQ5qkCzbZMtq+zXYaaGiGZJWEQDcPYSW+Xoy5qwx+sNfv3VnnRp5E4b/o HnijC5ub53ofHHiHXdbDctn6JLqfg+LxUtPljDWaiBKLHlYOiDZQPSYS8CqTEOFqWY XgGV0hkCknhoQ== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:44 +0900 Subject: [PATCH v2 7/8] usb: xhci: Fix DMA address calculation in queue_trb MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-7-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1110; i=marcan@marcan.st; h=from:subject:message-id; bh=ppe6Yz6eRH+7A2U81PZqJ6AYVRQhDWwxRmqdPM5NSoE=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbv4/TjN75K2/cPC9hz6Ivxet3HtlgELbxgJnK4td5d pv2fdm/qqOUhUGMg0FWTJGl8UTvqW7P6efUVVOmw8xhZQIZwsDFKQATWV/MyHB8JxePZlC6XshP df9vK4JexLXFSml3sH6rN7H9/mpxaDIjw3lG9iIxl/1X98SEfc1P4pzxbCPXy8mfjpee5ryW8K3 +BQcA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We need to get the DMA address before incrementing the pointer, as that might move us onto another segment. Signed-off-by: Hector Martin Reviewed-by: Marek Vasut --- drivers/usb/host/xhci-ring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index ae0ab5744df0..b60661fe05e7 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -202,6 +202,7 @@ static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring, bool more_trbs_coming, unsigned int *trb_fields) { struct xhci_generic_trb *trb; + dma_addr_t addr; int i; trb = &ring->enqueue->generic; @@ -211,9 +212,11 @@ static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring, xhci_flush_cache((uintptr_t)trb, sizeof(struct xhci_generic_trb)); + addr = xhci_trb_virt_to_dma(ring->enq_seg, (union xhci_trb *)trb); + inc_enq(ctrl, ring, more_trbs_coming); - return xhci_trb_virt_to_dma(ring->enq_seg, (union xhci_trb *)trb); + return addr; } /** From patchwork Sun Oct 29 06:37:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 1856689 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.a=rsa-sha256 header.s=default header.b=wY89B0hG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SJ6GX2gh8z1yQ9 for ; Sun, 29 Oct 2023 17:40:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5233787555; Sun, 29 Oct 2023 07:38:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=marcan.st header.i=@marcan.st header.b="wY89B0hG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AACDA87739; Sun, 29 Oct 2023 07:38:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CACD187258 for ; Sun, 29 Oct 2023 07:38:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=marcan.st Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marcan@marcan.st Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 7992D42699; Sun, 29 Oct 2023 06:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1698561531; bh=FG1JkDzGbCUxaDoCxOVb1Tj7GDoWE6jnrmiEM/52LS8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=wY89B0hGZR1xkrWYRr9Qb23Gd+TOr1JSdEbNHw7tfN0gbN8mb3OCF3Nvbu8uIZXtF gUok9cRutjZiKltAPbbE+XZWYcAWVsS8cZZI25dZMEQYIx1YxOIh4nAFq9Mu8zhVrv ohiHFKlLyFZB//Zr0NMUdc2USg4A/MYb7Pm/8esLm7dUnw5f74Vn8j0mKVXzyxu8M/ Fxc6Rw5cc2IS2vPE+yq+yxMYHCKLnSPpQ+sFLia78Rbpw6Ron0TqvD+R+Zw7Vpxfmj 7CTqMb5t/u8gNGtcQ80CUHSe0rEZCWrFBlqmNDPv89JwJear062JJxnAQq2I6FV0GF SYoB1RiBYoROQ== From: Hector Martin Date: Sun, 29 Oct 2023 15:37:45 +0900 Subject: [PATCH v2 8/8] usb: xhci: Add more debugging MIME-Version: 1.0 Message-Id: <20231029-usb-fixes-1-v2-8-623533f6316e@marcan.st> References: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> In-Reply-To: <20231029-usb-fixes-1-v2-0-623533f6316e@marcan.st> To: Bin Meng , Marek Vasut Cc: Mark Kettenis , Neal Gompa , u-boot@lists.denx.de, asahi@lists.linux.dev, Hector Martin X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3768; i=marcan@marcan.st; h=from:subject:message-id; bh=FG1JkDzGbCUxaDoCxOVb1Tj7GDoWE6jnrmiEM/52LS8=; b=owGbwMvMwCEm+yP4NEe/cRLjabUkhlTbv09udy7h+1qVk2diYDKXSTDUMO7Rk+OTjKZe/mglo WNxSiW7o5SFQYyDQVZMkaXxRO+pbs/p59RVU6bDzGFlAhnCwMUpABNp2MnIMHXpSzklw/fBtjk/ NM2rX5k9FVsy5/EKq967Kezb90TsTGFk+OdsMe38p6KVXjvjGx5/yV1Rt4rp/bKvKpGr1BfPnv0 6jhEA X-Developer-Key: i=marcan@marcan.st; a=openpgp; fpr=FC18F00317968B7BE86201CBE22A629A4C515DD5 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean A bunch of miscellaneous debug messages to aid in working out USB issues. Signed-off-by: Hector Martin --- drivers/usb/host/xhci-ring.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b60661fe05e7..dabe6cf86af2 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -214,6 +214,9 @@ static dma_addr_t queue_trb(struct xhci_ctrl *ctrl, struct xhci_ring *ring, addr = xhci_trb_virt_to_dma(ring->enq_seg, (union xhci_trb *)trb); + debug("trb @ %llx: %08x %08x %08x %08x\n", addr, + trb_fields[0], trb_fields[1], trb_fields[2], trb_fields[3]); + inc_enq(ctrl, ring, more_trbs_coming); return addr; @@ -296,6 +299,8 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, dma_addr_t addr, u32 slot_id, { u32 fields[4]; + debug("CMD: %llx 0x%x 0x%x %d\n", addr, slot_id, ep_index, cmd); + BUG_ON(prepare_ring(ctrl, ctrl->cmd_ring, EP_STATE_RUNNING)); fields[0] = lower_32_bits(addr); @@ -471,8 +476,14 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->event_cmd.flags)); if (type == expected || - (expected == TRB_NONE && type != TRB_PORT_STATUS)) + (expected == TRB_NONE && type != TRB_PORT_STATUS)) { + debug("Event: %08x %08x %08x %08x\n", + le32_to_cpu(event->generic.field[0]), + le32_to_cpu(event->generic.field[1]), + le32_to_cpu(event->generic.field[2]), + le32_to_cpu(event->generic.field[3])); return event; + } if (type == TRB_PORT_STATUS) /* TODO: remove this once enumeration has been reworked */ @@ -484,8 +495,9 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) le32_to_cpu(event->generic.field[2])) != COMP_SUCCESS); else - printf("Unexpected XHCI event TRB, skipping... " + printf("Unexpected XHCI event TRB, expected %d... " "(%08x %08x %08x %08x)\n", + expected, le32_to_cpu(event->generic.field[0]), le32_to_cpu(event->generic.field[1]), le32_to_cpu(event->generic.field[2]), @@ -602,10 +614,13 @@ static void abort_td(struct usb_device *udev, int ep_index) static void record_transfer_result(struct usb_device *udev, union xhci_trb *event, int length) { + xhci_comp_code code = GET_COMP_CODE( + le32_to_cpu(event->trans_event.transfer_len)); + udev->act_len = min(length, length - (int)EVENT_TRB_LEN(le32_to_cpu(event->trans_event.transfer_len))); - switch (GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len))) { + switch (code) { case COMP_SUCCESS: BUG_ON(udev->act_len != length); /* fallthrough */ @@ -613,16 +628,23 @@ static void record_transfer_result(struct usb_device *udev, udev->status = 0; break; case COMP_STALL: + debug("Xfer STALL\n"); udev->status = USB_ST_STALLED; break; case COMP_DB_ERR: + debug("Xfer DB_ERR\n"); + udev->status = USB_ST_BUF_ERR; + break; case COMP_TRB_ERR: + debug("Xfer TRB_ERR\n"); udev->status = USB_ST_BUF_ERR; break; case COMP_BABBLE: + debug("Xfer BABBLE\n"); udev->status = USB_ST_BABBLE_DET; break; default: + debug("Xfer error: %d\n", code); udev->status = 0x80; /* USB_ST_TOO_LAZY_TO_MAKE_A_NEW_MACRO */ } } @@ -1016,6 +1038,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, record_transfer_result(udev, event, length); xhci_acknowledge_event(ctrl); if (udev->status == USB_ST_STALLED) { + debug("EP %d stalled\n", ep_index); reset_ep(udev, ep_index); return -EPIPE; }