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 CF7FCECE599 for ; Wed, 16 Oct 2019 22:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A623021835 for ; Wed, 16 Oct 2019 22:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571264543; bh=f5umoON5O7p/oyVQf6vH3mRhGZFhmXF8Ui1yyCgKYHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=E1iYDLZ2R9pyIZbG82gWNssNocJljyC+9K/H+ov3MbsQv1aTM8jXN6YOg/4EWJ3Ec c32Ek1mPtyfPEG/qtz+wM95QsnD5lYwvft7q+mBiaZQCB2+6XTAVvc22pofLLJY0Rc w+njuZKIU6tw/79L/VR4HL498aX8QATekAS2H5SI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407633AbfJPWWW (ORCPT ); Wed, 16 Oct 2019 18:22:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:41998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437497AbfJPVxR (ORCPT ); Wed, 16 Oct 2019 17:53:17 -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 E5DEB21A49; Wed, 16 Oct 2019 21:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262797; bh=f5umoON5O7p/oyVQf6vH3mRhGZFhmXF8Ui1yyCgKYHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fR/g7hukAFYb+qHJ8buxdf8Rvs/U1lwWCkLLZEFqsKAOsilHcGl/DzqZqIOklKVPS ery6PyS8R1jJR/KJDBQPPbFgVymcGx7DJpIeCTYvknpukhwpvKON4YlEl+wY3Gdw39 Eqcr3wXD1pnydmKlZsAF6V53aFwdHCmiQFIM6oeE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rick Tseng , Mathias Nyman Subject: [PATCH 4.4 36/79] usb: xhci: wait for CNR controller not ready bit in xhci resume Date: Wed, 16 Oct 2019 14:50:11 -0700 Message-Id: <20191016214759.581844372@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214729.758892904@linuxfoundation.org> References: <20191016214729.758892904@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -1041,6 +1041,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 */