Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2972519pxb; Tue, 12 Jan 2021 03:15:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqjt5y1kX+JhSPN7DbK1kFSnqpn7v7diLAQTns9Vkr95hjTA+JZVBVXo8hTCY0hYEBEg87 X-Received: by 2002:a17:906:6d14:: with SMTP id m20mr2787937ejr.3.1610450130972; Tue, 12 Jan 2021 03:15:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610450130; cv=none; d=google.com; s=arc-20160816; b=qoC0bCIHD/5y4ljeov2aDrr3NjIwVx38OWfd3Nbt6Zt93qrH22H5Byqwf7iMYytaVp K9/sQbMPkXD1V/mM+PIbPU5sRXDmJjxnTir9XjN3f6z+EPYqUyHn+SG8JMuLuMEaBRdf DkAR6pOnGGDy67AOJg/2qZtfvxkcZsKnWSubWs4UCfBX2dvlzBdscisNVu2tsB5vpIl9 s1ZaZuj3tiHFtDURBwEz3GIMxOI+60mxsZ+W7MVgpbW1ZDI89wQ9dmWlH+votyqZldu4 YLj5kULBzQxn2DppFLmmNqcKKzBYg9Piq+05XrFk873XjuGOKKPbGvjPa4ZsiCqOMX6G ClbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=ak768gEI6XCH+aPGM5U6EpkG7B0YhsCWJJw1G4ZyE7I=; b=AxD+l0cucYYImgkUlvw+RvlZy5One9iey3+CMkxBBuNbM4o28laplcaMxT19I4qCFB NfDvyhFwYVUdact2AwyRGQ3bY1RIcD3omiI3UCtOSdbMI3LHiOAS9e5SnCV9F4telvxU FN2fTEVA59oQBxlOOahU5e1N91wrQidm74kqgGoaZ4rAQAMtrZfEfJspx+22hr8pco/n xdc/BOhFLiUVs/eadh9Izfixi+m/SdZ9s97OLw0mckO32RgYmICW6+HQ5NN2Li24Tm7A RAdtAbNsfxTExzYR2GVrrv3EfGOkldNrUHH1X1zO1WhCzLs5kfevJZiN7I0o9Zj9abPa NtNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JG+Sg8xW; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pv16si518730ejb.339.2021.01.12.03.15.07; Tue, 12 Jan 2021 03:15:30 -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=@google.com header.s=20161025 header.b=JG+Sg8xW; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728556AbhALEC4 (ORCPT + 99 others); Mon, 11 Jan 2021 23:02:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbhALEC4 (ORCPT ); Mon, 11 Jan 2021 23:02:56 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49696C061795 for ; Mon, 11 Jan 2021 20:02:16 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id v5so621827pjt.1 for ; Mon, 11 Jan 2021 20:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=ak768gEI6XCH+aPGM5U6EpkG7B0YhsCWJJw1G4ZyE7I=; b=JG+Sg8xWVV6o2H7jEpk7k4T+BYMj0g9b6yD/Ot9mOHxD3cId9PvCBaP793TPOW6UDE NemddI4QWvvzitpZfeFW+h/oZk7T6Jnj+EEIilx9OvKxUllf+a15pi4wBluJwif15orG lxt0Iwhipfxrk6ZW89+/Fvs9cjOHvOjWU7z5Ydl+jyjAJMe1yjselzRW72578Bx2Fyqc d3fSSxw4Snb1Eucb/fUPnADWmIUQDqlRl6E6WwlguCH12WUI4466mfh2+DLUIKH0GubQ Z+ijve1yEtXLZp0i1ZdOM1OSbmUX0fmUjCnlyPY9JvwvvDhbZnup8zgujXBoFuyz5geq 1Dyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ak768gEI6XCH+aPGM5U6EpkG7B0YhsCWJJw1G4ZyE7I=; b=T169fUyccwVZ3oEKny+I8c3mVA+ZEY3y/PHe/EGLC+ovOnhDoO8dq1lxUJJoBJ69eH MYkBYN0Ua+bcyIbjFPVGHdcRRmEVNs2VWV1gj1VzfVXOCHZmgCHMhdsPCoH4zB7g5ir7 wQ2mD8DJKazk8hktVvaedusCRJt/JofTQHHNwzx9uX5EvDZ6Avr2rro72g5pwS3GjdU4 z9D6V4bqdSmbJWWWmftCQnc7UUr2pCmx9J9Vqlghq02h9cLrr5skr6CpPtue9q3ePiTm x6jt3hENkfvoHNP8nO+/ZRBQL/CRHKGMwXM96jv1M987L1XJtR6gNu0XnhMB8x7XCA4C waiw== X-Gm-Message-State: AOAM5310MYAKk/U82dr6+odQwq4/v/0+t+Nqo/4HoL3b4c7ZYyonU7s+ HFRIDyPJlpEV0LDVcYF8TN+p/t9xj2TbxPHT Sender: "victording via sendgmr" X-Received: from victording.c.googlers.com ([fda3:e722:ac3:10:24:72f4:c0a8:65c7]) (user=victording job=sendgmr) by 2002:a17:902:c144:b029:dc:292e:a8a1 with SMTP id 4-20020a170902c144b02900dc292ea8a1mr3103608plj.13.1610424135755; Mon, 11 Jan 2021 20:02:15 -0800 (PST) Date: Tue, 12 Jan 2021 04:02:04 +0000 In-Reply-To: <20210112040205.4117303-1-victording@google.com> Message-Id: <20210112040146.1.I9aa2b9dd39a6ac9235ec55a8c56020538aa212fb@changeid> Mime-Version: 1.0 References: <20210112040205.4117303-1-victording@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 1/2] PCI/ASPM: Disable ASPM until its LTR and L1ss state is restored From: Victor Ding To: Ulf Hansson , Adrian Hunter Cc: Ben Chuang , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-mmc@vger.kernel.org, Victor Ding , Alex Levin , Bjorn Helgaas , Kai-Heng Feng , "Saheed O. Bolarinwa" , Sean Paul , Sukumar Ghorai , Yicong Yang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Right after powering up, the device may have ASPM enabled; however, its LTR and/or L1ss controls may not be in the desired states; hence, the device may enter L1.2 undesirably and cause resume performance penalty. This is especially problematic if ASPM related control registers are modified before a suspension. Therefore, ASPM should disabled until its LTR and L1ss states are fully restored. Signed-off-by: Victor Ding --- drivers/pci/pci.c | 11 +++++++++++ drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aspm.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index eb323af34f1e..428de433f2e6 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1660,6 +1660,17 @@ void pci_restore_state(struct pci_dev *dev) if (!dev->state_saved) return; + /* + * Right after powering up, the device may have ASPM enabled; + * however, its LTR and/or L1ss controls may not be in the desired + * states; as a result, the device may enter L1.2 undesirably and + * cause resume performance penalty. + * Therefore, ASPM is disabled until its LTR and L1ss states are + * fully restored. + * (enabling ASPM is part of pci_restore_pcie_state) + */ + pcie_config_aspm_dev(dev, 0); + /* * Restore max latencies (in the LTR capability) before enabling * LTR itself (in the PCIe capability). diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index e9ea5dfaa3e0..f774bd6d2555 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -564,6 +564,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev); void pcie_aspm_exit_link_state(struct pci_dev *pdev); void pcie_aspm_pm_state_change(struct pci_dev *pdev); void pcie_aspm_powersave_config_link(struct pci_dev *pdev); +void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val); void pci_save_aspm_l1ss_state(struct pci_dev *dev); void pci_restore_aspm_l1ss_state(struct pci_dev *dev); #else @@ -571,6 +572,7 @@ static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { } static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { } static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { } static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { } +static inline void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) { } static inline void pci_save_aspm_l1ss_state(struct pci_dev *dev) { } static inline void pci_restore_aspm_l1ss_state(struct pci_dev *dev) { } #endif diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index a08e7d6dc248..45535b4e1595 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -778,7 +778,7 @@ void pci_restore_aspm_l1ss_state(struct pci_dev *dev) pci_write_config_dword(dev, aspm_l1ss + PCI_L1SS_CTL2, *cap++); } -static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) +void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) { pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_ASPMC, val); -- 2.30.0.284.gd98b1dd5eaa7-goog