From patchwork Wed May 31 22:27:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 101615 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3224540vqr; Wed, 31 May 2023 15:49:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4lif3x/nti/A/O6Kq150kol9ggitdxkoi/bfsCfgUz8Pyh9jFn7l38ORpSuBxZEfEiYXF6 X-Received: by 2002:a17:902:ceca:b0:1ad:e2b6:d292 with SMTP id d10-20020a170902ceca00b001ade2b6d292mr7410405plg.4.1685573343077; Wed, 31 May 2023 15:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685573343; cv=none; d=google.com; s=arc-20160816; b=TQKB7PeFBjPNDnxdVBM8CUiWX3QJHn370d5MKfluAlx2Yp1SZAJoEVnnmrmInaR/Ky cUt1pHBOb5czb5WOvVxgPXGROazR18WctEhTP6VPhZDOHNMm8e/0ZihWO4JujqIsvNm/ /XE3AZ3ErFBujSxo6yPEQHNxo5q++oYU6vnVSlxhyA5dNxISgZbChM/XBXKC1TV97tTz 2r+Hh3hXVWAZT0uMWqCLvNvFVZ9djDlz/391Aw4Y55nni5HlHvqYusXGpsRDfKzJea7q YBILMQUKu6Cd/1m8U1jQZlaLgSxGGta9jKpNwpo8kK58pPzx6zduaTP8+NVlIpCnX59c nB5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XYphsjpFQZ8qoW0HxD5fU0fwEGPiJV9LRkSsjbqnP9k=; b=cJMlrxqkhJGjPq8R8Dah3NW6jQ/AEyPY3TX5n2ah5LV2jaVkrf4vC+nZ6UUicJwFOZ t+2KFwVBvp/3IkbyROTqbKZYs21L2YiEqeLi69UXfDAV/I9uwg60gc4trqGgjFpZOd+X 0Qk6ze+9LAULeNgz4D7iY3LigOHbDXXAV06XhYu0N1QApxMbWe9fLt3xaiDDXf/09Ou3 7wu3ZmOzygP53oqlzWzNG6lBw2Al5OkDoy+gPN0QZt5pizrO55VIQP/se6UnOxyWQ4iH QduM8nM6JGKLBf/edCeWqajGiOHjENkcPQje4U+tA2WnQRdcvhwwTJV/zVnkSNjAOlkU aIaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R0psU+9Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a170902c1d300b001a6b5a7db52si1605292plc.596.2023.05.31.15.48.47; Wed, 31 May 2023 15:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R0psU+9Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbjEaW1m (ORCPT + 99 others); Wed, 31 May 2023 18:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbjEaW1h (ORCPT ); Wed, 31 May 2023 18:27:37 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6013121; Wed, 31 May 2023 15:27:35 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34VL0Ser014433; Wed, 31 May 2023 22:27:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=XYphsjpFQZ8qoW0HxD5fU0fwEGPiJV9LRkSsjbqnP9k=; b=R0psU+9YGwnkQkRzEIlFCJ6qEn+siZoo0qpfzhEMUtyED67e0mwZ1+icd68+5/VsR4Wq 0wGGR3l53CMY7xzGisB2bjygYLSZJIzSCfJ9Hh3ayY/EpQs1dLlc9tN9m6E54LeCLeTV oaTWH7Bl+QRHzRUDO857nMWaoKWWfce+i59lKVoDq2VuWdV9590UzCz50iKgEJ5MXvUP cOPP/4jozPF0kKjOdyMO5JbXRoCJXLcDBF0rgxnYXhxFedNnj+23HSGX/2jvqRCGUe9i 0/fu36fIbd4LOMrOUziWk+V+vTkSsyD5qOatHm6nSbFYudyOajIv/TPTw/1PnOYPridx OQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qxdr984wp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 May 2023 22:27:33 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34VMRWN0009728 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 May 2023 22:27:32 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 31 May 2023 15:27:31 -0700 From: Wesley Cheng To: , CC: , , Wesley Cheng Subject: [PATCH v3 1/2] usb: host: xhci: Do not re-initialize the XHCI HC if being removed Date: Wed, 31 May 2023 15:27:18 -0700 Message-ID: <20230531222719.14143-2-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230531222719.14143-1-quic_wcheng@quicinc.com> References: <20230531222719.14143-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: usDMe0dUJbpodKc9F1h83bCyQxWrYyqg X-Proofpoint-GUID: usDMe0dUJbpodKc9F1h83bCyQxWrYyqg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-31_16,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 impostorscore=0 mlxlogscore=803 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305310189 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767451753532812862?= X-GMAIL-MSGID: =?utf-8?q?1767451753532812862?= During XHCI resume, if there was a host controller error detected the routine will attempt to re-initialize the XHCI HC, so that it can return back to an operational state. If the XHCI host controller is being removed, this sequence would be already handled within the XHCI halt path, leading to a duplicate set of reg ops/calls. In addition, since the XHCI bus is being removed, the overhead added in restarting the HCD is unnecessary. Check for the XHC state before setting the reinit_xhc parameter, which is responsible for triggering the restart. Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index b81313ffeb76..02a30b883bde 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1028,7 +1028,8 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg) temp = readl(&xhci->op_regs->status); /* re-initialize the HC on Restore Error, or Host Controller Error */ - if (temp & (STS_SRE | STS_HCE)) { + if ((temp & (STS_SRE | STS_HCE)) && + !(xhci->xhc_state & XHCI_STATE_REMOVING)) { reinit_xhc = true; if (!xhci->broken_suspend) xhci_warn(xhci, "xHC error in resume, USBSTS 0x%x, Reinit\n", temp); From patchwork Wed May 31 22:27:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 101614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3224494vqr; Wed, 31 May 2023 15:48:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mjbcjHMLor1m6fenKCFRlo5bjP5WnMn4h8IkxgaCak/xW1cOFGxqjdRPKMj5Cb3040Q8G X-Received: by 2002:a05:6a00:b84:b0:64d:6db8:f191 with SMTP id g4-20020a056a000b8400b0064d6db8f191mr8983271pfj.27.1685573335458; Wed, 31 May 2023 15:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685573335; cv=none; d=google.com; s=arc-20160816; b=HZZFfdJTWqJe95jA+jyTNdtDRojdZQYQJ/FMKKVXURQTGouCKRYS+E54GCA9gI5YKb Y2C8IOImOeBx4wSoxqHDzn4cGvhd8mK9T824Gk70Urk/kzaJ8M9WfdNeH4UaqNUSVm2z alOAz6Tc2lvFRQa5/hkALgW+AChJodFTIsJm91OwToF5kWydmuy93J9yP8Wbu51VPzL8 8/+P4JriP/jSgyN0xjrfJWJE5C9JT/Siwa3VPuF5gmMOaRK0PhyBZu+qhuCuC93ZnbcP t2mlxxIBDbxTCl53X2VtgT2yVYdDSeZ91mLBSQyslNxwXGGpIbQObUVTaAA/+8uSN2ai Y+lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NioG84benTqgh2FgyViWa+iQXvzohB7fZ1EUffswWPM=; b=hif5VzflX3XAmvHw7Uua/YRzDZdrYFgcUplSS9oS8a/iqOK9WU62/a2nr00sxogWxr eP13rTpP8srelirpDUzDsSjvTVENqBSi6HpnbSCoFXxh+HTHqoWs2gnRsnAIYZW5L0vI +DVFEqDa0FUjYlRJKeSHCMQSh4wiYZGTNNMhwVnY+vwHQ5WcUwKA9g4JBax/Jls9oR2M H0sAgK8RQE93S3WoXgD5jFifb77w0yYd4q3aP2S5XztfQ04WVMb9USkh2/i4cEf/j7vN /o1bF+dAbuyHb9YRV8hZ8Gr3tyZJTMKrrgH/XXlZswLePlyH1Vkae4v1ZOV6AgtHTrSq mlfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=McYh0Sjo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a63af53000000b00534e67fd867si1892305pgo.62.2023.05.31.15.48.41; Wed, 31 May 2023 15:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=McYh0Sjo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbjEaW1k (ORCPT + 99 others); Wed, 31 May 2023 18:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230328AbjEaW1h (ORCPT ); Wed, 31 May 2023 18:27:37 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D78A39D; Wed, 31 May 2023 15:27:35 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34VLN6wq004816; Wed, 31 May 2023 22:27:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=NioG84benTqgh2FgyViWa+iQXvzohB7fZ1EUffswWPM=; b=McYh0Sjoz0+GsKQH6BDdoLUf5vfPoN8Om0Q05GWebnIv5kLZYYfZ7jGI/1IOkGBcCA1O TESEo/IVVPZ3UDQUHRPfcigLyDMER78tHbh41vM2A8j7Y+f+vhKp4pfaZNdabTAVWYPX L2iTFNV/9RkI6DrCzG+HAH8OCeP0OvSox7o1ch7Ks9KLQipkBdBGq9tO7lFjkXQtMBuD MFCeC8t1zf9Fryc7oY5Vjg6JwQ9JqhJyzNQWAV33kirZDxPJwRhwh7xW9hd4Idbw6BRY 4Xv6g3MRVOIjLDyGKu7kECuHTz6nHr39gUGOloThyKftsZGHFfLttXt4MppXMFGe5xFu vQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qwx8qae02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 May 2023 22:27:33 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34VMRWgn007459 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 May 2023 22:27:32 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 31 May 2023 15:27:32 -0700 From: Wesley Cheng To: , CC: , , Wesley Cheng Subject: [PATCH v3 2/2] usb: host: xhci-plat: Set XHCI_STATE_REMOVING before resuming XHCI HC Date: Wed, 31 May 2023 15:27:19 -0700 Message-ID: <20230531222719.14143-3-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230531222719.14143-1-quic_wcheng@quicinc.com> References: <20230531222719.14143-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: nA6Ysp8rqCH_H2jetBJTEgGnyi0wnrRj X-Proofpoint-GUID: nA6Ysp8rqCH_H2jetBJTEgGnyi0wnrRj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-31_16,2023-05-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 mlxlogscore=831 adultscore=0 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305310189 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767451745824204949?= X-GMAIL-MSGID: =?utf-8?q?1767451745824204949?= There are situations during the xhci_resume() sequence, which allows for re-initializing of the XHCI HC. However, in case the HCD is being removed, these operations may not be needed. Set the removal state before issuing the runtime PM get on the XHCI device, so that the XHCI resume routine will know when to bypass the re-init logic. Signed-off-by: Wesley Cheng --- drivers/usb/host/xhci-plat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index a666b21c21bb..a1e552d9da09 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -403,8 +403,8 @@ int xhci_plat_remove(struct platform_device *dev) struct clk *reg_clk = xhci->reg_clk; struct usb_hcd *shared_hcd = xhci->shared_hcd; - pm_runtime_get_sync(&dev->dev); xhci->xhc_state |= XHCI_STATE_REMOVING; + pm_runtime_get_sync(&dev->dev); if (shared_hcd) { usb_remove_hcd(shared_hcd);