From patchwork Tue Apr 11 11:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Agarwal X-Patchwork-Id: 13207379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25BA6C76196 for ; Tue, 11 Apr 2023 11:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbjDKLLI (ORCPT ); Tue, 11 Apr 2023 07:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbjDKLLF (ORCPT ); Tue, 11 Apr 2023 07:11:05 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD24544A2 for ; Tue, 11 Apr 2023 04:10:58 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54c0b8ca2d1so148835057b3.17 for ; Tue, 11 Apr 2023 04:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681211458; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=v8qMlgNbDx0jGULJ7F2Nuk2N1BwNFYg0vrO1o3nyayg=; b=N0/T70b3fIPZ53RB6G6QenDZdRwcJY2stYCyJiPmm6TcktCybmJRrf8vAj6q9M9qLi k2guPXtD6gacaWHrr3Ts2f5OMEiI18cDhRDxD9vCuyJPlsAZHwjYkVhAnccW4di0zPJR 0zeQJ6494S//aADB6yTvsoTYNZ2S3ca/hgAFfK2TR+myYdiNe7VvhuDR9beVPQQcVe1H H4mUTwjuK4O5TVY6Gh/9qmDcDQyi90plmE7ruRrdPzMH5DACpGOxS4mIpFf+6uyCL3MN j9STIIs0f9ZakMLG252wk8Bly/GG1UthAhz+vRuv1SS9dSihFXCJ5IfaxlbVpfplVcZe AgNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681211458; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=v8qMlgNbDx0jGULJ7F2Nuk2N1BwNFYg0vrO1o3nyayg=; b=y8tg3cfl5HXsGePalRWQEVYMlbrhSQTPPJYrUZ8AfpvMYlJyCmVTpCWLAWSgmI7Ey0 Au7hGO9Oq8Bu0CZmA5eCd7D4qCBdvlzhj5I2qGDKWVGDh+gLIXh4g1HNZbg+fEwE//VI BQaA/fyaq1qf+aW+/xR5LQc92zRPEP5zDKxh2dngSPykWRtYLyMz8+BSvu/MIYt1cprx uI3sNPBbQBpaGRtoEnCDKVqwMZcOy6tqLRt0IQR9gszneb5TfU8aniVLSoN3R5wYqzaW lB3J9Cf6Vp5rV+j8i7fbetz8x1710+sI+EaqNFHSQjGRc3j6GJ8o8rgiCfugBENK8RbL /FKQ== X-Gm-Message-State: AAQBX9d/FCjAR4qj7IbK5ClzQHWiXJB60wSr+Vvl7+DVn8WbvDdnmNkX DJ6Z0kWX/KycQygIYoGBByobtuccIJwP9XxIuA== X-Google-Smtp-Source: AKy350bofEoA/nGomWSRbgETszSYLdfqX0zuvh/oiBf02sBr71iLWapjXWt89sE2X0WivKY/wWEMU5Qqrj7ympQGww== X-Received: from ajaya.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:39b5]) (user=ajayagarwal job=sendgmr) by 2002:a81:c904:0:b0:534:d71f:14e6 with SMTP id o4-20020a81c904000000b00534d71f14e6mr7423066ywi.9.1681211457905; Tue, 11 Apr 2023 04:10:57 -0700 (PDT) Date: Tue, 11 Apr 2023 16:40:32 +0530 In-Reply-To: <20230411111034.1473044-1-ajayagarwal@google.com> Mime-Version: 1.0 References: <20230411111034.1473044-1-ajayagarwal@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230411111034.1473044-2-ajayagarwal@google.com> Subject: [PATCH 1/3] PCI/ASPM: Disable ASPM_STATE_L1 only when class driver disables L1 ASPM From: Ajay Agarwal To: Bjorn Helgaas , Kuppuswamy Sathyanarayanan , Vidya Sagar , Nikhil Devshatwar , Manu Gautam , "David E. Box" , Kai-Heng Feng , Michael Bottini Cc: linux-pci@vger.kernel.org, Ajay Agarwal Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Currently the aspm driver sets ASPM_STATE_L1 as well as ASPM_STATE_L1SS bits when the class driver disables L1. pcie_config_aspm_link takes care that L1ss ASPM is not enabled if L1 is disabled. ASPM_STATE_L1SS bits do not need to be explicitly set. The sysfs node store() function, which also modifies the aspm_disable value, does not set these bits either when only L1 ASPM is disabled by the user. Disable ASPM_STATE_L1 only when class driver disables L1 ASPM. Signed-off-by: Ajay Agarwal --- drivers/pci/pcie/aspm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 66d7514ca111..5765b226102a 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1095,8 +1095,7 @@ static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) if (state & PCIE_LINK_STATE_L0S) link->aspm_disable |= ASPM_STATE_L0S; if (state & PCIE_LINK_STATE_L1) - /* L1 PM substates require L1 */ - link->aspm_disable |= ASPM_STATE_L1 | ASPM_STATE_L1SS; + link->aspm_disable |= ASPM_STATE_L1; if (state & PCIE_LINK_STATE_L1_1) link->aspm_disable |= ASPM_STATE_L1_1; if (state & PCIE_LINK_STATE_L1_2) From patchwork Tue Apr 11 11:10:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Agarwal X-Patchwork-Id: 13207380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B680C7619A for ; Tue, 11 Apr 2023 11:11:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjDKLLP (ORCPT ); Tue, 11 Apr 2023 07:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjDKLLO (ORCPT ); Tue, 11 Apr 2023 07:11:14 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8258E4210 for ; Tue, 11 Apr 2023 04:11:04 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54f6474b2feso22300357b3.5 for ; Tue, 11 Apr 2023 04:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681211463; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ov/mNuHCriSJNK+j92LJ7xxXi3IiZ7Lg7C3ge9u+upM=; b=CFtgh+9uEhowZGpk6SzBRxW36tLl8YchhHynUd6PmcGJQ/7tChidXuHNTtfifOqw6B 1XwIkybHoouWs+wnmvg8aJ5QpaYw4jq23wjmBlaqHr8MhexIt6PpjToPMLGiMQSNAR38 /Aw0WT2s7eHYuKoB7hZ5IXXg1ieAl3xi4RZXnkbmHCLgxwFetHQRqw27JTqnBrZuxrPq CZB/T4K1VaIWSF4CXQ5apAzRrxf1CRSTegygUaKo7LQrB4v+y7DLTNJlvCSkGqSlRbFT Nmh2SpbwgX+2N0EVb+n2pLZtl9vL9uQr61i13G5xcbye1VGY8eGcGZsT5Z4MOkyqatT7 5O2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681211463; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ov/mNuHCriSJNK+j92LJ7xxXi3IiZ7Lg7C3ge9u+upM=; b=I57OjCIS8TKDUS/p9j747vYqoBe61dWAaXHOfGYzRoIXmpxXq1sVpcAVzomHJuxKp+ dLlHLbirJDnT2LyBy0GRGfCmSBc1rn1w5fNewWsOZJlr/VW7SoucxEdm+iCV8vyHEcLW JROEoag9Kgyt/3s3ilU1FrtdxSvlz71Qa1lI996X2lBtlobiTYd/hQIAFvmJxXZ2mOCb REMBFR0LMPNLzKDtb3LQBDgQzYkFy4lnOKcJh+S7LmcznfXmXAJ6zm5PaP/aZHlyyS2T Qs4r60AM+eRmuviPHNjD0i6ax1oktu9cM8Eqw1qpOrVpxWmYLnTjpZkfc3se9N0WBK5E DuNQ== X-Gm-Message-State: AAQBX9cvBjrOqeWLu97jEe5/pzyRAAsJuQ0qPFYqYqh0QUu3ZE2Xnsri Opt4pP6o2ljRazWEU23/uLPGyBkj/SnDGJoPcA== X-Google-Smtp-Source: AKy350aJPDMi1ru/nTyvdLI8YpfZDRSbAqxsadZMBD4IpIReRo3FQJMuiwh4qgI9FWf6YvxNY6kqAZXYatxIo3HgcQ== X-Received: from ajaya.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:39b5]) (user=ajayagarwal job=sendgmr) by 2002:a81:b714:0:b0:54b:fd28:c5ff with SMTP id v20-20020a81b714000000b0054bfd28c5ffmr8221904ywh.3.1681211463835; Tue, 11 Apr 2023 04:11:03 -0700 (PDT) Date: Tue, 11 Apr 2023 16:40:33 +0530 In-Reply-To: <20230411111034.1473044-1-ajayagarwal@google.com> Mime-Version: 1.0 References: <20230411111034.1473044-1-ajayagarwal@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230411111034.1473044-3-ajayagarwal@google.com> Subject: [PATCH 2/3] PCI/ASPM: Set ASPM_STATE_L1 when class driver enables L1ss From: Ajay Agarwal To: Bjorn Helgaas , Kuppuswamy Sathyanarayanan , Vidya Sagar , Nikhil Devshatwar , Manu Gautam , "David E. Box" , Kai-Heng Feng , Michael Bottini Cc: linux-pci@vger.kernel.org, Ajay Agarwal Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Currently the aspm driver does not set ASPM_STATE_L1 bit in aspm_default when the class driver requests L1SS ASPM state. This will lead to pcie_config_aspm_link() not enabling the requested L1SS state. Set ASPM_STATE_L1 when class driver enables L1ss. Signed-off-by: Ajay Agarwal --- drivers/pci/pcie/aspm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 5765b226102a..7c9935f331f1 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1170,16 +1170,16 @@ int pci_enable_link_state(struct pci_dev *pdev, int state) if (state & PCIE_LINK_STATE_L0S) link->aspm_default |= ASPM_STATE_L0S; if (state & PCIE_LINK_STATE_L1) - /* L1 PM substates require L1 */ - link->aspm_default |= ASPM_STATE_L1 | ASPM_STATE_L1SS; + link->aspm_default |= ASPM_STATE_L1; + /* L1 PM substates require L1 */ if (state & PCIE_LINK_STATE_L1_1) - link->aspm_default |= ASPM_STATE_L1_1; + link->aspm_default |= ASPM_STATE_L1_1 | ASPM_STATE_L1; if (state & PCIE_LINK_STATE_L1_2) - link->aspm_default |= ASPM_STATE_L1_2; + link->aspm_default |= ASPM_STATE_L1_2 | ASPM_STATE_L1; if (state & PCIE_LINK_STATE_L1_1_PCIPM) - link->aspm_default |= ASPM_STATE_L1_1_PCIPM; + link->aspm_default |= ASPM_STATE_L1_1_PCIPM | ASPM_STATE_L1; if (state & PCIE_LINK_STATE_L1_2_PCIPM) - link->aspm_default |= ASPM_STATE_L1_2_PCIPM; + link->aspm_default |= ASPM_STATE_L1_2_PCIPM | ASPM_STATE_L1; pcie_config_aspm_link(link, policy_to_aspm_state(link)); link->clkpm_default = (state & PCIE_LINK_STATE_CLKPM) ? 1 : 0; From patchwork Tue Apr 11 11:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Agarwal X-Patchwork-Id: 13207381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B069C7619A for ; Tue, 11 Apr 2023 11:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjDKLLb (ORCPT ); Tue, 11 Apr 2023 07:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjDKLLa (ORCPT ); Tue, 11 Apr 2023 07:11:30 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44E62449C for ; Tue, 11 Apr 2023 04:11:10 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u188-20020a2560c5000000b00b8f15f2111dso3000056ybb.4 for ; Tue, 11 Apr 2023 04:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681211469; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HECeuQBdvQRhBEsgYTKbTTwg6tOb1uM7yGa+73zqdqA=; b=as+qG2uonqno7lffKPDNQyHtYtg/2dwfu/zv1Ez6nZmk8roWgVc1bDSZ+j+BZ8g4w5 gs2VESpdOUmSkn/EiA9Rpd/8gutmzZEaKH6jyiMaa+bIC3E3ZQQXm641eYsvR3Js8FGt rMIGD9GI72IQRbiw1PlfHLNlJUhkYTCTAEtxuvV1CeUAbvAJ9y2coi4B+C0fH4rPdj3i DiKvtYGwHK2x41wKjPAP5Bo3yNiYEv12zl+Nm6jooCjyjYU2nC0lBEQXX9W24NsNKBVU cqKgrQ2a3rpAt2gGr+PjYtvB8hd0+AUsDK30I7CWvqQsqekroVyWLywskph1s81BQ7Ss FOeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681211469; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HECeuQBdvQRhBEsgYTKbTTwg6tOb1uM7yGa+73zqdqA=; b=CpTpadVQqVj5sCrBk2vaCRqDSMUqhpUlu0b2xvSk6xKkrGa1o7GWc1eyQTTgaY0Xg3 shW0BAEDKPkPLZ3t6pNdEzwRwXAXIEt1G8Tu6VIKpJFivtp7dzosvKyMgcXHNch/PiVR asNUjqE8qPRFmwSKegp3zBpYPw76yBuY8MaExmzCHGgp4DXMIBq4SmA/u2FXjKeJNZvm ElMvyH9xFA8ZrnCgqjMz48HKan5yERBa2PDogvMrpYrtf+t4BA/4pqqQUFvvkguy11HF B3isfxHaarpSR7FslnsO19oee70FBOO/3l1pBsCSlJP17CxAgEKCnPL5t4GY35ID+TBe mqkQ== X-Gm-Message-State: AAQBX9dGv2vyu6DxyKHAt/CQ13w1oMqh3zCTjS9IpDw5YmOuPSyTXmWJ bKe0N+QOZi+YuDprPIiqADltn2jEKyD+35b2xw== X-Google-Smtp-Source: AKy350bVnE7DUZpxorgG/hP+8ar1xmlSZ5U9JyoxRqJajloUYU8gBPAPZNCToe2rpOmgdKF1LZQV0G9z8t5caTROag== X-Received: from ajaya.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:39b5]) (user=ajayagarwal job=sendgmr) by 2002:a81:e20a:0:b0:54d:4a49:ba22 with SMTP id p10-20020a81e20a000000b0054d4a49ba22mr7301387ywl.7.1681211469259; Tue, 11 Apr 2023 04:11:09 -0700 (PDT) Date: Tue, 11 Apr 2023 16:40:34 +0530 In-Reply-To: <20230411111034.1473044-1-ajayagarwal@google.com> Mime-Version: 1.0 References: <20230411111034.1473044-1-ajayagarwal@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230411111034.1473044-4-ajayagarwal@google.com> Subject: [PATCH 3/3] PCI/ASPM: Remove unnecessary ASPM_STATE_L1SS check From: Ajay Agarwal To: Bjorn Helgaas , Kuppuswamy Sathyanarayanan , Vidya Sagar , Nikhil Devshatwar , Manu Gautam , "David E. Box" , Kai-Heng Feng , Michael Bottini Cc: linux-pci@vger.kernel.org, Ajay Agarwal Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Currently the driver checks if ASPM_STATE_L1SS is supported before calling aspm_calc_l1ss_info(), only for this function to return if ASPM_STATE_L1_2_MASK is not supported. Simplify the logic by directly checking for L1.2 mask. Signed-off-by: Ajay Agarwal --- drivers/pci/pcie/aspm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 7c9935f331f1..8c45835e8016 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -481,9 +481,6 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link, u32 pctl1, pctl2, cctl1, cctl2; u32 pl1_2_enables, cl1_2_enables; - if (!(link->aspm_support & ASPM_STATE_L1_2_MASK)) - return; - /* Choose the greater of the two Port Common_Mode_Restore_Times */ val1 = (parent_l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; val2 = (child_l1ss_cap & PCI_L1SS_CAP_CM_RESTORE_TIME) >> 8; @@ -616,7 +613,7 @@ static void aspm_l1ss_init(struct pcie_link_state *link) if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_2) link->aspm_enabled |= ASPM_STATE_L1_2_PCIPM; - if (link->aspm_support & ASPM_STATE_L1SS) + if (link->aspm_support & ASPM_STATE_L1_2_MASK) aspm_calc_l1ss_info(link, parent_l1ss_cap, child_l1ss_cap); }