From patchwork Mon May 9 09:13:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian Hui Lee X-Patchwork-Id: 1628417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=WthAI2uT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kxb853WPDz9sGJ for ; Mon, 9 May 2022 19:13:57 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nnzSh-0000zh-S7; Mon, 09 May 2022 09:13:51 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nnzSg-0000zM-20 for kernel-team@lists.ubuntu.com; Mon, 09 May 2022 09:13:50 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id BDC763F1CA for ; Mon, 9 May 2022 09:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1652087629; bh=f2bfPO3GELhbhG00thX4CJdC1a2u/b40bgXy0XpeSQw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WthAI2uTgvnUtO0m7wTUsS+U9LXC5/5qNCVb3ClXGMzMPeFZjCVgb5cjz7CWWlcTG 0NM3OE4gNXOoTulg1yYBMP+c4XZ6k+srYo3WZ12SJ3tJAiMylM9kOHQRuTkDsvVCiU EwxuSvuh002FHRfwKpkMbIsnejVJfb+D9KO1Wr5RE3QuswyTIsst8azQC2Gy/skloL ZhyFMHP+x0cQGK4CK5nbfrRDvyVqZo/4X1ubn/n2GKDF7hL3cVkrpm9RX94Y3kZGHH ty73RRd72yNhL5A8j5n17UfuSqJtdEvYDdwFR20snSKYfKbOHYPk2Vj0SZDPdLErPw KNu/jCuiCuBpQ== Received: by mail-pg1-f197.google.com with SMTP id v69-20020a638948000000b003c6e1f48397so26525pgd.19 for ; Mon, 09 May 2022 02:13:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f2bfPO3GELhbhG00thX4CJdC1a2u/b40bgXy0XpeSQw=; b=uqfeJzRLMZsBpnqWN1PCU6v4yhh5VoYwj5tuLFYcqUh11TGTABxsP3SRDPO7acQ+Zw lYEplfMXjNJrG5E78qUxxdFRPbFlyh3+YYyCA5iRXdOgH0gm5BpSP8r9jwq9wJEt/ekz giYzDBOfmhbk97vCkh9ewpbFOFloHvZJ9Rjfg+EwDLiHmKSDlvT2xw0uNHuLO4gxix2W vZtYrglFsfvMdYaa96S2GAikehbcRx9+ks2V7qe5LKHysZPaWY/q5stDX92B91Td2d73 hyDcihn/ZBe24CojDF3Oa9/TNG+wdQDrsv8YLcUZhLRd7PhPAjrP/r8Uym2mFH71RUmf NoOw== X-Gm-Message-State: AOAM532HosAiH6Z03GnMB47lbgln3B4aPJfMRUzAugiVxXc+SXO3Z4iZ q8tW1IbiLSB4gzhQBwIkbPGrI2Xb4Tm8Vx+fRpSeVFdIGxZSLKHonpBQYo8kJedtH4V615aUK+7 P+NNCEQPN1IVzPluNy5shLBwOvGTZNr3oNZ0DeGgp5A== X-Received: by 2002:a05:6a00:98c:b0:50d:f856:53d8 with SMTP id u12-20020a056a00098c00b0050df85653d8mr15240271pfg.49.1652087628197; Mon, 09 May 2022 02:13:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywAcjuPzc8cm8d5g2hwpSiz288M6Ln1DuLy9Y3/LBzmpSQAYHHDaQnFT8bHrdS4SgnU8xq9Q== X-Received: by 2002:a05:6a00:98c:b0:50d:f856:53d8 with SMTP id u12-20020a056a00098c00b0050df85653d8mr15240249pfg.49.1652087627891; Mon, 09 May 2022 02:13:47 -0700 (PDT) Received: from Razer-Stealth.. (36-230-106-94.dynamic-ip.hinet.net. [36.230.106.94]) by smtp.gmail.com with ESMTPSA id s16-20020a632150000000b003c63ae859d3sm6365854pgm.83.2022.05.09.02.13.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:13:47 -0700 (PDT) From: Jian Hui Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal:linux-intel-iotg-5.15][PATCH 1/1] usb: core: Bail out when port is stuck in reset loop Date: Mon, 9 May 2022 17:13:43 +0800 Message-Id: <20220509091343.39471-2-jianhui.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220509091343.39471-1-jianhui.lee@canonical.com> References: <20220509091343.39471-1-jianhui.lee@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kai-Heng Feng BugLink: https://launchpad.net/bugs/1960777 Unplugging USB device may cause an incorrect warm reset loop and the port can no longer be used: [ 143.039019] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x4202c0 [ 143.039025] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling. [ 143.039051] hub 2-0:1.0: state 7 ports 10 chg 0000 evt 0008 [ 143.039058] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x4202c0, return 0x4102c0 [ 143.039092] xhci_hcd 0000:00:14.0: clear port3 connect change, portsc: 0x4002c0 [ 143.039096] usb usb2-port3: link state change [ 143.039099] xhci_hcd 0000:00:14.0: clear port3 link state change, portsc: 0x2c0 [ 143.039101] usb usb2-port3: do warm reset [ 143.096736] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2b0, return 0x2b0 [ 143.096751] usb usb2-port3: not warm reset yet, waiting 50ms [ 143.131500] xhci_hcd 0000:00:14.0: Can't queue urb, port error, link inactive [ 143.138260] xhci_hcd 0000:00:14.0: Port change event, 2-3, id 19, portsc: 0x2802a0 [ 143.138263] xhci_hcd 0000:00:14.0: handle_port_status: starting usb2 port polling. [ 143.160756] xhci_hcd 0000:00:14.0: Get port status 2-3 read: 0x2802a0, return 0x3002a0 [ 143.160798] usb usb2-port3: not warm reset yet, waiting 200ms The port status is PP=1, CCS=0, PED=0, PLS=Inactive, which is Error state per "USB3 Root Hub Port State Machine". It's reasonable to perform warm reset several times, but if the port is still not enabled after many attempts, consider it's gone and treat it as disconnected. Signed-off-by: Kai-Heng Feng Link: https://lore.kernel.org/r/20220120070518.1643873-1-kai.heng.feng@canonical.com Signed-off-by: Greg Kroah-Hartman (cherry picked from commit c89686118c786a523eee3ef68ed38330319626d8) Signed-off-by: Jian Hui Lee --- drivers/usb/core/hub.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 22adb595e21b..599d88142bd5 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3014,8 +3014,12 @@ static int hub_port_reset(struct usb_hub *hub, int port1, status); } - /* Check for disconnect or reset */ - if (status == 0 || status == -ENOTCONN || status == -ENODEV) { + /* + * Check for disconnect or reset, and bail out after several + * reset attempts to avoid warm reset loop. + */ + if (status == 0 || status == -ENOTCONN || status == -ENODEV || + (status == -EBUSY && i == PORT_RESET_TRIES - 1)) { usb_clear_port_feature(hub->hdev, port1, USB_PORT_FEAT_C_RESET);