From patchwork Tue Jul 18 11:25:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13317026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C858EB64DA for ; Tue, 18 Jul 2023 11:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231831AbjGRLWg (ORCPT ); Tue, 18 Jul 2023 07:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbjGRLWe (ORCPT ); Tue, 18 Jul 2023 07:22:34 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2088.outbound.protection.outlook.com [40.107.20.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF551701 for ; Tue, 18 Jul 2023 04:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QBLu5GDjLHc+p+Oyy9LJP0q/Pi0UpiwF0QwzqV4WsIpxAXLw5h3JaMz5L+dT/5+4zayjdYWh+8DuJNlVB+oUsMriJqxBKRzDX+mA6ejqebpwlRaa0C2nvOBBe6ReVDQore1Mo06gqWWjVgYpOFhN6Na/7L3gx2bOGFzQ7vc/f0TA9oicMwu/c+47n8ryDcE0h4zB1WLju7xEbyJJforgM8+UeNZXjI8iOg6FRZsCxplysuRE2Yw5ZGbk2qs23eFlTQlj6+bOl+b4ICajZybURm4KOks7nVTVC7sjrlogx9YRpA3vFfbDk31mZ1gWZFJTJM7AVngm0gOZBgZZafJqVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WABKwB67A0itaa/O3pQi5SwXQZUmAdNDXW9Q0+Zds8w=; b=SAJj3D2k2ZJ/IQcg8k0bF9H5CO4fkDdrlJQNWMNCFP28uYLvwTjm5RN6Z7/7+9PScPoaKzrpMc6qOMoBhnH5GZevcMjc++plqmYgLtCKiN7OShzsm5+zz1lPmkiY3GR+Wt6CUJbF5CljagW/oPQFRcbJ0HhQNbDDjuEmyfhD0XZ+GE6+VWYv+qtNabLle2RYsGesDsOgx090A+m0BZKuGfVd+cttHnJtEFqy7hBMKUzhCw4qsoPhb50WZ7lRrvDuOQ7mXxAKrBTmB7v9TP58IF+Sf/Jbwz1cCu5GY2FLK5wbbiMEjEnOHk3HMYL5HTEr2pjdJlYYEmE/PTMZBB8v1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WABKwB67A0itaa/O3pQi5SwXQZUmAdNDXW9Q0+Zds8w=; b=GQ/gKtJ5YGYm9Bai3yZhvnjf3zcRyvguEx3801yGC+stEkefbArfOG+2i/NzTzq41LUz/MWPkSqYsSufpBCvG6q+iN2uzfkhUaDREXxeQDHcgiBzzbVL9CZ5S8eeumsB9rciE9YhAcc09ZrSW4HINMgWlYfAAPpOP6x4PF2WjC0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4505.eurprd04.prod.outlook.com (2603:10a6:5:39::26) by DU2PR04MB8743.eurprd04.prod.outlook.com (2603:10a6:10:2e1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Tue, 18 Jul 2023 11:22:13 +0000 Received: from DB7PR04MB4505.eurprd04.prod.outlook.com ([fe80::473a:28:1d98:10ab]) by DB7PR04MB4505.eurprd04.prod.outlook.com ([fe80::473a:28:1d98:10ab%5]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 11:22:13 +0000 From: Xu Yang To: stern@rowland.harvard.edu Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, xu.yang_2@nxp.com, jun.li@nxp.com Subject: [PATCH 1/2] usb: host: ehci-sched: add itd/sitd_unlink_urb() functions Date: Tue, 18 Jul 2023 19:25:59 +0800 Message-Id: <20230718112600.3969141-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR04CA0169.apcprd04.prod.outlook.com (2603:1096:4::31) To DB7PR04MB4505.eurprd04.prod.outlook.com (2603:10a6:5:39::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4505:EE_|DU2PR04MB8743:EE_ X-MS-Office365-Filtering-Correlation-Id: fb6cfc4c-cc62-4bac-b64b-08db87813bf3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L6plY7UWsx4NSq3ozKlLPyMU7MdF3+cfFh+zUbExUzUueAzM5BSOV1AgxPRjjcd/hcCpVuPuBLQrLvT+xIXTlnfxco3mHijGfqZ4xlN0f+h+XOp3Olt0zACglCeluCfRdYjY+11G+ltMjm0ET+dSOmlbeGtQ16y9q9i7E8t8gI06XVaOhnmCqnw4wMWLCvaEooTBzIgjk89zWN31b1iFgtalU+T0S9O47nMdvMY9urHvfsh5N1NRDyo8YEgvmvO2HwFvMVThI6pFBBYwZf+zhXRDJqOj0duJCnCkvU+tJ5+Cx7nvxuQtcrR+VUoVHOeUfDPYmxW/1nYQxLj146cq3BAb5nDN3JkFPre78Hr5OB0lX5FYdORw5Vfd6z0yf+yPKJNzaSGPmpdYKeV82WN4epPf5rqnykzhyorU69Hb9U8GrkvL7S5gGszD9NHwnPOudDg8jM5od6JFlaPILfmVuq7prPCAKtoOqywHZh0vMSYDdDHj/YYaG37DbLCqKmBDE0Fm36EjME23PVZRBCGfi5dgQ4d29LfQ3MEjo3ieX+o/syGT9MsFR0d0BTdukFITOrf7/O99UIAIZHhO0vftC5ZEN/nF8HCmQJjs4rwL0mQX3to4OnBV0hGxzS5KKK5H X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4505.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(39860400002)(346002)(376002)(366004)(451199021)(86362001)(2906002)(66476007)(5660300002)(66556008)(41300700001)(4326008)(8936002)(8676002)(66946007)(38350700002)(6916009)(38100700002)(316002)(186003)(36756003)(2616005)(1076003)(6506007)(478600001)(26005)(52116002)(6666004)(6486002)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7C+itHoFdWi6qnumKC3sdB7MU2j3uI1B2ABO45SAxiPuFTSQcRiuB6ZGGEDK/ZvVX0OQ6ycgORimf2P+H2e95IcnVQuEQvg2dujCxbY7hKZfwv6A5NwX+CRyu3DSxCXW2QshfowAX1uxKnSeXzW58oNnDrVH9n0C+YrNPf1AjN6qa3xSvHPgHpmEdiviJ/4VmiZg+LPOsuRh0D0sgqxX5ZYZBx+ZebrpfvPQxdCn8pDVWDPUjYlew1Kht88mN49zqbuRUWdnsTmMF/0StN0qHWqhUC0Qra556NKA9MEW+9hdLIFseBHmPryLqxD7TZfU/IdNBJtGhOU2XZdIpGXJ+7KL53elM9U+qWGSXGqobfv/L9v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c+JuwGkVTup0eFYb1hVWDrIIdQuC4lJr8x1zkNYopYFrRrzFvE0TlTEyopX0uddcCj8K9olCif0IIQdevM9zfkynNo2PYyD7IYMSjlf6yHKv8hcwFS2HvvOkZklGi3KulHhQiw1pmjUURT9OR782h7Jr1p/LNiJjzfKgUOwI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb6cfc4c-cc62-4bac-b64b-08db87813bf3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4505.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 11:22:13.3970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fUUPIe9Ssl0KPdSQii7/HVBKjGU15PEHAukW07f5nXczPqTBhODFhj/nFJunmRzXA7jjAJJ9/i0QCMRrojyOqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8743 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This will add itd/sitd_unlink_urb() functions in case of the driver needs to unlink these urbs manually. Signed-off-by: Xu Yang --- drivers/usb/host/ehci-sched.c | 94 +++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index bd542b6fc46b..b95a8bc4d3ba 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -1805,6 +1805,67 @@ static void itd_link_urb( enable_periodic(ehci); } +/* unlink itd/sitd from the periodic list */ +static inline void +unlink(struct ehci_hcd *ehci, unsigned frame, void *ptr) +{ + union ehci_shadow *prev = &ehci->pshadow[frame]; + __hc32 *hw_p = &ehci->periodic[frame]; + union ehci_shadow here = *prev; + + while (here.ptr && here.ptr != ptr) { + prev = periodic_next_shadow(ehci, prev, + Q_NEXT_TYPE(ehci, *hw_p)); + hw_p = shadow_next_periodic(ehci, &here, + Q_NEXT_TYPE(ehci, *hw_p)); + here = *prev; + } + + *prev = *periodic_next_shadow(ehci, &here, + Q_NEXT_TYPE(ehci, *hw_p)); + + if (!ehci->use_dummy_qh || + *shadow_next_periodic(ehci, &here, Q_NEXT_TYPE(ehci, *hw_p) + != EHCI_LIST_END(ehci))) + *hw_p = *shadow_next_periodic(ehci, &here, + Q_NEXT_TYPE(ehci, *hw_p)); + else + *hw_p = cpu_to_hc32(ehci, ehci->dummy->qh_dma); +} + +static void itd_unlink_urb( + struct ehci_hcd *ehci, + struct urb *urb +) +{ + struct ehci_itd *itd, *n; + struct ehci_iso_stream *stream = urb->hcpriv; + + if (unlikely(list_empty(&stream->td_list))) + return; + + list_for_each_entry_safe(itd, n, &stream->td_list, itd_list) { + if (itd->urb != urb) + continue; + unlink(ehci, itd->frame, itd); + itd->urb = NULL; + list_move_tail(&itd->itd_list, &stream->free_list); + } + + ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; + if (unlikely(list_empty(&stream->td_list))) + ehci_to_hcd(ehci)->self.bandwidth_allocated -= stream->bandwidth; + + ehci_urb_done(ehci, urb, -ENOENT); + + --ehci->isoc_count; + disable_periodic(ehci); + + list_splice_tail_init(&stream->free_list, + &ehci->cached_itd_list); + start_free_itds(ehci); +} + #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) /* Process and recycle a completed ITD. Return true iff its urb completed, @@ -2196,6 +2257,39 @@ static void sitd_link_urb( enable_periodic(ehci); } +static void sitd_unlink_urb( + struct ehci_hcd *ehci, + struct urb *urb +) +{ + struct ehci_sitd *sitd, *n; + struct ehci_iso_stream *stream = urb->hcpriv; + + if (unlikely(list_empty(&stream->td_list))) + return; + + list_for_each_entry_safe(sitd, n, &stream->td_list, sitd_list) { + if (sitd->urb != urb) + continue; + unlink(ehci, sitd->frame, sitd); + sitd->urb = NULL; + list_move_tail(&sitd->sitd_list, &stream->free_list); + } + + ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; + if (unlikely(list_empty(&stream->td_list))) + ehci_to_hcd(ehci)->self.bandwidth_allocated -= stream->bandwidth; + + ehci_urb_done(ehci, urb, -ENOENT); + + --ehci->isoc_count; + disable_periodic(ehci); + + list_splice_tail_init(&stream->free_list, + &ehci->cached_sitd_list); + start_free_itds(ehci); +} + /*-------------------------------------------------------------------------*/ #define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ From patchwork Tue Jul 18 11:26:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13317027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E629EB64DA for ; Tue, 18 Jul 2023 11:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231964AbjGRLXE (ORCPT ); Tue, 18 Jul 2023 07:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbjGRLWy (ORCPT ); Tue, 18 Jul 2023 07:22:54 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2088.outbound.protection.outlook.com [40.107.20.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048BB1731 for ; Tue, 18 Jul 2023 04:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mgUdpGSHZ5ot7+R6F7uC3LTymauVkB/QQhmiURMctCH0lK1u59Q1D1SsYG/Y03n9txbUhwgUaLHDR71l04e8PasMqXLmVpw/q+PPKQLMo4XslUc9qNh0lrS8BH1y0aQ91wspvXoyb+k9jlP+9I9a6lxP9bNtenbk1P+wi9QTXumtbLKBXcnwJs3zlSV5343iGrf8xQftScjX3h/bxk5ZR5cA0m3+YHe0qL+6BtoTnMX6FeOgHGSWHwZ51J04Y/ZOl5ZmyR9r+lxwNyrDJW89pIZolSE9jv0T2VGQNmKPq142uz6FKpL++dhvVymrqsw2LPRvDrKh11XkNVxgtpjggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HxYM8wAOWLY4g48aacF1x+UadbVDfLASTVbSiy4zkeI=; b=Lh7s5tWcL6PiYzeY6NT0Zfu+ehNuMmbua+GcRPZaCmqO13vHlKb8ANcH31OJUwKr21+bnIrFS1jzzEP8sl0iI28+fXnIhjjnxN/FTLqi404IDEn5UZw7JnBTIYgJVo+UUqKXXS7kw+c6mxtpLjhEi3zkCObALt5+SCnGZo8xRv/alaxezL/jDfNo4GzhFez/N10w2ipjNJhsIutVq6Sk/0qWpJd9f7l1khBYVw6JT7JQO0FN/Hq0COwleN7e11l7J7MSr0Gim0vw3PXDhb/M/87Ze6+1iMirDQcHkpOSaWAl2H6iGgPmkmzB04TZe9v3JgMy5EgZOPwtNqgByQHn1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HxYM8wAOWLY4g48aacF1x+UadbVDfLASTVbSiy4zkeI=; b=nIUweqZmj1sHMNay9KZUwYwHoxpIQ1ITey3gt8tuMcIueFHo+4YwEaXrHV0cZqbOfW0uMipx8Xcsdw7yV+Jy53dJ9iMU/kCiyu8eoI2KRb+/UzQoZVvuS+Zk+9N9RcEjB0+CbGraJ5RvhfD3Kb7tpJNydsYsYi0YbgeDJjtJQYI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4505.eurprd04.prod.outlook.com (2603:10a6:5:39::26) by DU2PR04MB8743.eurprd04.prod.outlook.com (2603:10a6:10:2e1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Tue, 18 Jul 2023 11:22:15 +0000 Received: from DB7PR04MB4505.eurprd04.prod.outlook.com ([fe80::473a:28:1d98:10ab]) by DB7PR04MB4505.eurprd04.prod.outlook.com ([fe80::473a:28:1d98:10ab%5]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 11:22:15 +0000 From: Xu Yang To: stern@rowland.harvard.edu Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, xu.yang_2@nxp.com, jun.li@nxp.com Subject: [PATCH 2/2] usb: ehci: unlink itd/sitds from hardware list if the controller has stopped periodic schedule Date: Tue, 18 Jul 2023 19:26:00 +0800 Message-Id: <20230718112600.3969141-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718112600.3969141-1-xu.yang_2@nxp.com> References: <20230718112600.3969141-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SG2PR04CA0169.apcprd04.prod.outlook.com (2603:1096:4::31) To DB7PR04MB4505.eurprd04.prod.outlook.com (2603:10a6:5:39::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4505:EE_|DU2PR04MB8743:EE_ X-MS-Office365-Filtering-Correlation-Id: 14d23877-ad59-4450-c49a-08db87813d6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uKVelnQ6df/B/AGdPcs8AGaK7ORhsrf9g6hEjli/Zoh0v5zxg8e3NwRp569KMAzkZbJIsWpClZmQTD5fb2GsgyK2aGCOzGIk/cZgkHQG+RI3oOWWdtkqGVyUsSz/ycQDJxkwlxnkFzraAClCFLW/YoLXSYdlp/7YdQWSAYgaQtX1ffPoRHHxFAJi6EFfzuKBe2ceiLvYv8DGdSIcmvKIT//HK74AFZeGLNwOm2PBP9VzRzMFsdnrCpyXzOpqmNxT+3HK9pC/ob5S98K27OIkbXE8E5aGF+6nj97+eQwvf7u2v9By7ntmXqdGx0G1sB5UaI0+Ad/UJyh2P4AvK3HXJdQ0fdqM8XSUXPkAFK5BrnyAu5J/J1JNnRyUcUHtjPwzEw4YovWyu6py5v6f5H14tWdRDM+Ta2SoHSI/1po+3/yyE7h8W99trwzYJHOxiRAPlM8jLkxmPFeDv49XHrI2v3BGvlcHPwcmEacM/NV4eNnp0KKt3B0pY2MZA8Ql+uFUE/0w+TZ0kMAeEAIDr4lr+jJHWXVMrsISfthd24EhegZW83AA5JzJl/7AQpFk96lMAQnpRFsrCiicMhrIKLnJ7yJggvReyxnhtxnhdk32Iz7D2cILm4MiJTifevpmFY/h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4505.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(39860400002)(346002)(376002)(366004)(451199021)(86362001)(2906002)(66476007)(5660300002)(66556008)(41300700001)(4326008)(8936002)(8676002)(66946007)(38350700002)(6916009)(38100700002)(316002)(186003)(36756003)(2616005)(1076003)(6506007)(478600001)(26005)(83380400001)(52116002)(6666004)(6486002)(6512007);DIR:OUT;SFP:1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Ng4brcvHOGEm9gmbdXwmAIwJoG0U7B1Zy5yZvBUSrcKnWzXtQ7uipKRAD6RNvrJ10Na/3xbaCIbxvWtCN5lwyDkfbJ43zJzYy7Yl5jBtHZ7PLL+dXGgq6AaU2ZURehlkvBsA51AqTMydAWvlCjpwgz2fxSWX7ihoY7ip4dZpCsF/8jV90v1k7IMrlbkpE/GEz/OAqxq/kz3ZR1u2qOE2bE8K205BwowLTHo3pbwygoSMSujIBLqo65EXTNzhGXd8m09BvbTlc79tKRVGV2bMxFg1RuWINTC9jhtPih6Rmu697241FgaJzR8DZNiq2qs3ESxsnpgTkw3mcCOYvATFh/FC82qeyd9rmTGg6fPDtPDiITWb2y5gEhorKeW30iKNTAnut0mw+Y5j9gbEBg4UNPGek4MIcuuQLLsLzJZfFW7Mpp8T9ccOLsm8Ykt+p87xLRTb3mM5OcFs6Gq2Vxk9627NfYCaZV3L18/FBBwwpCnDMF66ieCOOGtbfJsiKCHnYYntG2GMIzYXca2bV5/WtLVU1pOiq9Yw3wtKSQDGBwYsmYTNdO8ecIPMhHna35EiSt9O5hcz4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14d23877-ad59-4450-c49a-08db87813d6e X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4505.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 11:22:15.6984 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: p1yjPElLjq//rrulziwZ4PVT2DHUmaovpc9VfXfqLqENbdSum3oEmbZAdHiZj0eyF88CH0JxeWSu7uEaRRNwkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8743 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org In current design, the ehci driver will not unlink itd/sitds from the hardware list when dequeue isochronous urbs. Rather just wait until they complete normally or their time slot expires. However, this will cause issues if the controller has stopped periodic schedule before finished all periodic schedule. The urb will not be done forever in this case and then usb_kill/poison_urb() will always wait there. The ChipIdea IP exactly has a bug: if frame babble occurs during periodic transfer, PE (PORTSC.bit2) will be cleared and the controller will stop periodic schedule immediately. So if the user tries to kill or poison related urb, it will wait there since the urb can't be done forever. This patch will check if this issue occurs, then it will unlink itd/sitds from the hardware list depends on the result. Signed-off-by: Xu Yang --- drivers/usb/host/ehci-hcd.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a1930db0da1c..26dc1d1ae5e8 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -930,10 +930,41 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { /* - * We don't expedite dequeue for isochronous URBs. + * 1. We don't expedite dequeue for isochronous URBs. * Just wait until they complete normally or their * time slot expires. + * + * 2. The ChipIdea IP has a bug: if frame babble occurs, + * PE will be cleared and the controller will stop periodic + * schedule. So if we don't force dequeue this urb, it + * won't be done forever. Here, a force dequeue is needed + * for this case. */ + unsigned i = HCS_N_PORTS (ehci->hcs_params); + bool need_force_dequeue = false; + + while (i--) { + int pstatus; + + pstatus = ehci_readl(ehci, + &ehci->regs->port_status[i]); + + /* Any cleared PE means controller has stopped + * periodic schedule. + */ + if (!(pstatus & PORT_PE)) { + need_force_dequeue = true; + break; + } + } + + if (!need_force_dequeue) + goto done; + + if (urb->dev->speed == USB_SPEED_HIGH) + itd_unlink_urb(ehci, urb); + else + sitd_unlink_urb(ehci, urb); } else { qh = (struct ehci_qh *) urb->hcpriv; qh->unlink_reason |= QH_UNLINK_REQUESTED;