Received: by 2002:a05:6512:23a5:0:0:0:0 with SMTP id c37csp378104lfv; Tue, 15 Feb 2022 04:30:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJww5DKEqBAhusZvA1aJM0BaRxBUegaOhMRFIxfTaT+/Juk26fO6p2I86MV92TbqplGcSeaS X-Received: by 2002:a63:8649:: with SMTP id x70mr85728pgd.548.1644928237148; Tue, 15 Feb 2022 04:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644928237; cv=none; d=google.com; s=arc-20160816; b=FmyWRKnO6XMsagnUNGCLqoNLfSvHIfvrSkB4vf5T7lP9Zz8j3FOeNAzCaQzijEPfSp nov5xE7oog8aLSXnjvhy2e3L50vmkMyC2jl8wL005He35JoICaPGk4Eevpqy6p/3l0b1 DGGHHHBZuQNj+Q5FcI5GSk6XzZ1rcyKPgJVmuXx15Jw93qIkse0p9t3kKoq1HlIg7mVE vQmWhPhGKsg8zmEm13DpI3540RoCnDe9JqUyylhvoy90/Hw5jwVfahZCHVoVq1ASS4Dl zrfBQpSsCLiZkQaWN1ZvHaEPGgvOk6ouOaS9ssliutXm3UzX5RfGlneWcY42SuR1CKeC iWqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AvoSKo98ulJsw2WNwaVfLj/l/nh9gyg8Vgm73/f2Cg0=; b=YKtZTlafNrHGtuXJ4SzOXKUJB8bDiyheSggQzjFn03AOlbFvFQFV/2pdDdGsA6MkrU Ru7zRjyR1ygLsI8nRRsWjm/dhXOKUjFMC2QGvL+EkfZrZPCOR8JIaGqDKY4o0G5KtUmB dJDh2Umr7jhtKo1AtQfVmj2CFJ5kJ3Hy1nUQpKqyJYj1uzrJdCtvntNZL+3MBpdDWvy9 au2LQf+fPmbPETofxkSsZvJE1swq8Cakta7os982foCE3ePL+Cg/XYErn4Q1r6Ww64Lf rttZs9jfF9GY0iNXGgE5Bq7vSaGPdxCaobSIuzb7c7K2POcXtIF7LVjuQFsXMLv60AYz S8Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QwMS041z; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14si37451318pfu.318.2022.02.15.04.30.23; Tue, 15 Feb 2022 04:30:37 -0800 (PST) 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=@google.com header.s=20210112 header.b=QwMS041z; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237474AbiBOMFt (ORCPT + 99 others); Tue, 15 Feb 2022 07:05:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237472AbiBOMFs (ORCPT ); Tue, 15 Feb 2022 07:05:48 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E97A7D207A for ; Tue, 15 Feb 2022 04:05:37 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id m22so15302285pfk.6 for ; Tue, 15 Feb 2022 04:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AvoSKo98ulJsw2WNwaVfLj/l/nh9gyg8Vgm73/f2Cg0=; b=QwMS041zrimjNV74ySW6/aEYe7UiHK52oC4sA7e5yXzaKYm47mFk2ThPjn6rsCa5/w pcneguNLnPKLl9Iyy/7mdNG/s4XJo0gQztdp2w28VT+XlklF8pIsuBYhZKpTa0uKmT6T gq+8A5YvlPgSEe63jC9r1+xxeJCPeN4K7sE7HT32ZRwlRJExpCIAm8LV7oWMrI3XaqEq nM0x3OQkPX10IbiuBEpekHpxVnB/ZDsFgzxqLPREk6w23Lz8p+sUtSc9u4Ob+mC9fv7+ uUBTpM3pQq40xLUrqweNbRpYzAos9jzswxhQTGnygnPUd8R/8fO+YZ/YKL8519MYCIvD DAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AvoSKo98ulJsw2WNwaVfLj/l/nh9gyg8Vgm73/f2Cg0=; b=Q4AtuSj7Hu4SNoBeYBv1qyO97iFcRPN44zTyvMUMtE9AVQGQ2hKHIXzRQf8BkzTpbG Eji6QL1P7F27x/TEk6Max3Rq4RVKsye/ydfCAtZzaxB2xQ2uWxI7Rmwy9rw38QHT+Em7 L1yv7jlg2sOURzLVtjX6dy1m3N5fv876jxq5rzvjgmlUksigGRUlnJW3jzyISmK5DZv/ Ug/qXW4Ctn0388rfhkUBxM2ULgPjAiIUWN2udTJ4mKEWntt4LDJonLMuWTvFc4y+ODRj tkKOSewV6SuijTn+ZP3JTmN0aN4wUBS86jdCowdm0Yl72G1Y0NS4Kd7S/Ohi1MhxaGIk aORQ== X-Gm-Message-State: AOAM530c2pbyEDGEX6RvmSu06m+WVB7yCaTKDbaKgwr0WFmanGxJYGg3 XajqYLiFrUnu9kjcb3HZyShgd5VAJwd8g1xp3/plOw== X-Received: by 2002:a05:6a00:b83:: with SMTP id g3mr4064233pfj.58.1644926737009; Tue, 15 Feb 2022 04:05:37 -0800 (PST) MIME-Version: 1.0 References: <20220129093036.488231-1-pumahsu@google.com> <413ce7e5-1c35-c3d0-a89e-a3c7f03b4db7@linux.intel.com> <86bd1bef-2f07-8dee-a125-be208903204e@linux.intel.com> In-Reply-To: <86bd1bef-2f07-8dee-a125-be208903204e@linux.intel.com> From: Puma Hsu Date: Tue, 15 Feb 2022 20:05:00 +0800 Message-ID: Subject: Re: [PATCH v6] xhci: re-initialize the HC during resume if HCE was set To: Mathias Nyman Cc: mathias.nyman@intel.com, Greg KH , Sergey Shtylyov , Albert Wang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Thu, Feb 10, 2022 at 7:08 PM Mathias Nyman wrote: > > On 8.2.2022 9.11, Puma Hsu wrote: > > On Thu, Feb 3, 2022 at 3:11 AM Mathias Nyman > > wrote: > >> > >> On 29.1.2022 11.30, Puma Hsu wrote: > >>> When HCE(Host Controller Error) is set, it means an internal > >>> error condition has been detected. Software needs to re-initialize > >>> the HC, so add this check in xhci resume. > >>> > >>> Cc: stable@vger.kernel.org > >>> Signed-off-by: Puma Hsu > >>> --- > >>> v2: Follow Sergey Shtylyov 's comment. > >>> v3: Add stable@vger.kernel.org for stable release. > >>> v4: Refine the commit message. > >>> v5: Add a debug log. Follow Mathias Nyman 's comment. > >>> v6: Fix the missing declaration for str. > >>> > >>> drivers/usb/host/xhci.c | 7 +++++-- > >>> 1 file changed, 5 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > >>> index dc357cabb265..6f1198068004 100644 > >>> --- a/drivers/usb/host/xhci.c > >>> +++ b/drivers/usb/host/xhci.c > >>> @@ -1091,6 +1091,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) > >>> int retval = 0; > >>> bool comp_timer_running = false; > >>> bool pending_portevent = false; > >>> + char str[XHCI_MSG_MAX]; > >>> > >>> if (!hcd->state) > >>> return 0; > >>> @@ -1146,8 +1147,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) > >>> temp = readl(&xhci->op_regs->status); > >>> } > >>> > >>> - /* If restore operation fails, re-initialize the HC during resume */ > >>> - if ((temp & STS_SRE) || hibernated) { > >>> + /* If restore operation fails or HC error is detected, re-initialize the HC during resume */ > >>> + if ((temp & (STS_SRE | STS_HCE)) || hibernated) { > >>> + xhci_warn(xhci, "re-initialize HC during resume, USBSTS:%s\n", > >>> + xhci_decode_usbsts(str, temp)); > >>> > >>> if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) && > >>> !(xhci_all_ports_seen_u0(xhci))) { > >>> > >> > >> Ended up modifying this patch a bit more than I first intended, > >> - don't print warning in hibernation case, only error. > >> - maybe using a lot of stack for a debug string isn't really needed. > >> - make sure we read the usbsts register before checking for the HCE bit. > >> > >> Does the below work for you? If yes, and you agree I'll apply it instead > > > > Hi Mathias, > > Yes, your patch works for me, thanks! > > Will you submit a new patch? or should I update to a new version? > > Thanks. > > I'll submit it Hi Mathias, Could I know when you will submit the new patch? We will sync the patch to our project. Thank you for your effort! > > Thanks > -Mathias