From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77157FA372C for ; Wed, 16 Oct 2019 21:59:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 443A0222BE for ; Wed, 16 Oct 2019 21:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263143; bh=b12KZj4m24KunwpGgNP4b0M2EsXKqxJq5IdkhF8bQHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PA9MY+LK3GybDnYsNBMz1Uv7MInoKLnhjqjp2tAFw5By3YWwKYFEfGLP3RajaabQ2 FXziivkKsRuD5M3ZCRNIPKvnG/NTg1g0qBsNKb/JyXWmqfod0RMNIQlRV1WfRZJE4Q HtWZwZJ+NM4q2xSfbnqle9cuz4z3Neqo9Bbp9pds= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438363AbfJPV7B (ORCPT ); Wed, 16 Oct 2019 17:59:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:51492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438125AbfJPV6M (ORCPT ); Wed, 16 Oct 2019 17:58:12 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 458FA21D7D; Wed, 16 Oct 2019 21:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263090; bh=b12KZj4m24KunwpGgNP4b0M2EsXKqxJq5IdkhF8bQHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oJXOdMykflMO2QHmeOedUqnNu4z9gn1iXR98BSO/5OkIc8nMwFxnsP/mXsSTwMG19 i5ro3nlsRypcnOmh5Rizmg8lVYgKl+EsYTfMdsYQMZH8im9eeNoEGSljVRKzt14198 +7kJbgAvFXm3pCSRqtJsVFulCiUcUQVU/iIDRmoM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rick Tseng , Mathias Nyman Subject: [PATCH 5.3 011/112] usb: xhci: wait for CNR controller not ready bit in xhci resume Date: Wed, 16 Oct 2019 14:50:03 -0700 Message-Id: <20191016214846.972983264@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rick Tseng commit a70bcbc322837eda1ab5994d12db941dc9733a7d upstream. NVIDIA 3.1 xHCI card would lose power when moving power state into D3Cold. Thus we need to wait for CNR bit to clear in xhci resume, just as in xhci init. [Minor changes to comment and commit message -Mathias] Cc: Signed-off-by: Rick Tseng Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/1570190373-30684-6-git-send-email-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1108,6 +1108,18 @@ int xhci_resume(struct xhci_hcd *xhci, b hibernated = true; if (!hibernated) { + /* + * Some controllers might lose power during suspend, so wait + * for controller not ready bit to clear, just as in xHC init. + */ + retval = xhci_handshake(&xhci->op_regs->status, + STS_CNR, 0, 10 * 1000 * 1000); + if (retval) { + xhci_warn(xhci, "Controller not ready at resume %d\n", + retval); + spin_unlock_irq(&xhci->lock); + return retval; + } /* step 1: restore register */ xhci_restore_registers(xhci); /* step 2: initialize command ring buffer */