Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp824095pxb; Tue, 3 Nov 2020 13:35:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwlN72meQCdEOX+yf6ifsH5ajvk13H2a9/8/ztJPM4hBuALgDI6kSq/s/njMkJKrABTqWG X-Received: by 2002:a17:906:f744:: with SMTP id jp4mr3367227ejb.122.1604439301025; Tue, 03 Nov 2020 13:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439301; cv=none; d=google.com; s=arc-20160816; b=in3Fhj8LCM9Vubem3OwJKSGl0GSmsYQduU5CNdHp11Fdc+ez+nTiDiaLHCVW/t7VHz KU7uDet3ov3bpqM8nwm6FUBwaganxm0Hj+Xia5TGcQ+ojENXdmVYdYBPDeq4MRyxV+kw ySVkol/qyUDYy0v5Gm9Ehq9Qpv9FwFrTEWHUu6IM5CNhAxXqQXVCLUYBmye+FxlfBbCY 9jCBCCvzJ3SnDZ5Qll5HEJ3HEEvoVpiQmqXM2xkkcxX6HGLVCUEmkXA1J/QqeH+AmXux Z+XriOBE0ikYESriqcrX/b7kxxUmS6X2u4DW+NRDYd88kgxmrXmzu/ZZNrvZgm7ux/AX gPtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BYE38vxOWjwQnIpDtwedbcWUtMJ5Ak59P72rLtygpOo=; b=PwNhSCPKxJco8Pt96YNUvqbei8XqOBMNLsDWts+/7QXOm848aErbkargvv6wuSQkmk Ejxh2Zl01tbSRx4HNT1lM8e9B0p7kJAIasrl4ZVy65n+EJdD7wHzDK0svresSovy7sZJ Aj0ZI8T4Jw8kXyh04docdfR9Yw+zcfdk8vavINQVlZdkRlSyYaVDTHQIR3ZZ/1wgb8mO mOitQHhHFI4AqwQcBabbPcT0jUd8FOPUoL0TRRyCWEKaxOKqRT+wb2+pjaDokG9f5a9A XTk7kwaBUyoZqSMMeLDU2ptFxq7JbEjxkWH7yjY/OTSlzi7a+zY3A4E/torxZCEqSEmB 0/wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0asamOZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si7462897edp.176.2020.11.03.13.34.38; Tue, 03 Nov 2020 13:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0asamOZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732806AbgKCVbP (ORCPT + 99 others); Tue, 3 Nov 2020 16:31:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:60338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732072AbgKCU5u (ORCPT ); Tue, 3 Nov 2020 15:57:50 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 543C82053B; Tue, 3 Nov 2020 20:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437069; bh=eGYt8rqlx/TOoH5+mFNKX8JsVdYybdqwV0ctOpx2/Yg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0asamOZTXKP4eRUrQmKgKm+jDtv2+ZWHXZxsIWs0OYMoyOwJLjZa1cHbFzh1PJ0E Un4bLajy+sv+wouBZtRaJWM+tVfvIHkbLDwQDXdlaYfJGPJlYglv3cRqlJOTk6skCi KgIYfUDt+5EjL5N+5IyDPvP0K5mHfEHVJ4a3Mml4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sanket Goswami , Sandeep Singh , Mathias Nyman Subject: [PATCH 5.4 133/214] usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC Date: Tue, 3 Nov 2020 21:36:21 +0100 Message-Id: <20201103203303.302178969@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sandeep Singh commit 2a632815683d2d34df52b701a36fe5ac6654e719 upstream. On some platform of AMD, S3 fails with HCE and SRE errors. To fix this, need to disable a bit which is enable in sparse controller. Cc: stable@vger.kernel.org #v4.19+ Signed-off-by: Sanket Goswami Signed-off-by: Sandeep Singh Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20201028203124.375344-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-pci.c | 17 +++++++++++++++++ drivers/usb/host/xhci.h | 1 + 2 files changed, 18 insertions(+) --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -21,6 +21,8 @@ #define SSIC_PORT_CFG2_OFFSET 0x30 #define PROG_DONE (1 << 30) #define SSIC_PORT_UNUSED (1 << 31) +#define SPARSE_DISABLE_BIT 17 +#define SPARSE_CNTL_ENABLE 0xC12C /* Device for a quirk */ #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 @@ -149,6 +151,9 @@ static void xhci_pci_quirks(struct devic (pdev->device == 0x15e0 || pdev->device == 0x15e1)) xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND; + if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5) + xhci->quirks |= XHCI_DISABLE_SPARSE; + if (pdev->vendor == PCI_VENDOR_ID_AMD) xhci->quirks |= XHCI_TRUST_TX_LENGTH; @@ -467,6 +472,15 @@ static void xhci_pme_quirk(struct usb_hc readl(reg); } +static void xhci_sparse_control_quirk(struct usb_hcd *hcd) +{ + u32 reg; + + reg = readl(hcd->regs + SPARSE_CNTL_ENABLE); + reg &= ~BIT(SPARSE_DISABLE_BIT); + writel(reg, hcd->regs + SPARSE_CNTL_ENABLE); +} + static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); @@ -486,6 +500,9 @@ static int xhci_pci_suspend(struct usb_h if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) xhci_ssic_port_unused_quirk(hcd, true); + if (xhci->quirks & XHCI_DISABLE_SPARSE) + xhci_sparse_control_quirk(hcd); + ret = xhci_suspend(xhci, do_wakeup); if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED)) xhci_ssic_port_unused_quirk(hcd, false); --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1873,6 +1873,7 @@ struct xhci_hcd { #define XHCI_DEFAULT_PM_RUNTIME_ALLOW BIT_ULL(33) #define XHCI_RESET_PLL_ON_DISCONNECT BIT_ULL(34) #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) +#define XHCI_DISABLE_SPARSE BIT_ULL(38) unsigned int num_active_eps; unsigned int limit_active_eps;