From patchwork Wed May 11 03:01:10 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: 1629419 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=vlo8D/xt; 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 4Kyfp83LNkz9sG0 for ; Wed, 11 May 2022 13:02:07 +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 1nocbu-0001lB-05; Wed, 11 May 2022 03:01:58 +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 1nocbs-0001kh-W0 for kernel-team@lists.ubuntu.com; Wed, 11 May 2022 03:01:56 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (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 C67B33F175 for ; Wed, 11 May 2022 03:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1652238116; bh=f2bfPO3GELhbhG00thX4CJdC1a2u/b40bgXy0XpeSQw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vlo8D/xt5fp3FhKVJy+/fptGkVG/j84lbgOnSPhy+MOSGuA4HqYSTsi4jnuDSrcQH PF5ovZrtClrNtplqu0+5rhbPJQqtqWqtRRBYOopF3r7QnycmWKty5mUxpDc4o7Oaj1 JA1uz571DnxAo9i8wdnciE/SQMbKR4vwplcwgpVP/x6Yqyn2d0rZ4RawbLUgwwJpBz OXDT6CMKNfX2nRREEj+DnxR1m4sNl2UG4ycB8X+kuD5x4/FmWfhrYaOKlmbM6+VxT7 zpQIoPTkfJehYk66Z9CAMtQN1TAcwr4zR30VLFF7/iikrSsqrKK27dP35iMntbWtiM 03iJnz3uTvIXw== Received: by mail-pl1-f200.google.com with SMTP id x23-20020a170902b41700b0015ea144789fso377616plr.13 for ; Tue, 10 May 2022 20:01:56 -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=2V7VK9zlo8xOnVB0ukk2E6l83MyrHUxJofaId2lmtWqaGDeniQipPP1Ek8de7Jqd0j Ledrvl1auxepd+Y/ZGv2qg0MY00oYNbV9MBanAs9nvGxGd6RN8v0YpuMkOfwioCWzYiR FbRCbcBKq9tJxQEU3V53PkMJrPkpQuI8pmZuDbeCAp47LOPospodSKlaR3ob4/Tpi/qC BnRGvlIOHmuPg+sx3la91ZvjhxEbCmVO0dv9wXFle0mWT1tpm6HnUrLyJniglz5dNsYy jOBgjDV3xlPN4aeChgZttT7s8+Xjr8u+iosvmZ1I6L5A86VMXsxuTjir0mzOTd1PnwJU CySw== X-Gm-Message-State: AOAM533IZeKgHvb1DiE17vp+znzHiHj3UiPBR6UgA3GhJFlnoOZ9Cxp+ aF3OHtWf4Fx1rvp1Ebdh4ftJqgvve0z63h/SJ1o3Ck/mIkWTX+pSYw8b5Dm3IqeUGSUss8wu0X/ i/Gs03nDLvWS+fDdOxZTnZmQmPVc1VbaB7fP9LCb73A== X-Received: by 2002:a17:903:41c3:b0:15e:b690:bedc with SMTP id u3-20020a17090341c300b0015eb690bedcmr23570197ple.161.1652238115422; Tue, 10 May 2022 20:01:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYxlDzxL1MwRlQu7TSHeanaZZ31GY8T45pwuZ2bymx5ww9DVr2HXIWbvW4GgvsaE2CxuklTg== X-Received: by 2002:a17:903:41c3:b0:15e:b690:bedc with SMTP id u3-20020a17090341c300b0015eb690bedcmr23570184ple.161.1652238115087; Tue, 10 May 2022 20:01:55 -0700 (PDT) Received: from localhost.localdomain (36-230-93-232.dynamic-ip.hinet.net. [36.230.93.232]) by smtp.gmail.com with ESMTPSA id e17-20020a62aa11000000b0050dc762815asm295027pff.52.2022.05.10.20.01.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 20:01:54 -0700 (PDT) From: Jian Hui Lee To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy:linux-intel-iotg][PATCH v2 1/1] usb: core: Bail out when port is stuck in reset loop Date: Wed, 11 May 2022 11:01:10 +0800 Message-Id: <20220511030110.188288-2-jianhui.lee@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220511030110.188288-1-jianhui.lee@canonical.com> References: <20220511030110.188288-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);