From patchwork Sat Feb 25 03:46:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 13152017 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 01DAAC6FA8E for ; Sat, 25 Feb 2023 03:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbjBYDr7 (ORCPT ); Fri, 24 Feb 2023 22:47:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjBYDr6 (ORCPT ); Fri, 24 Feb 2023 22:47:58 -0500 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 649DE46174; Fri, 24 Feb 2023 19:47:46 -0800 (PST) Received: from localhost.localdomain (unknown [10.101.196.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 102183FD9B; Sat, 25 Feb 2023 03:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1677296861; bh=FIo8POnb+lvnkz6JRqx93RRjQHuBp7vbw79esPyEjA0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Los2piUAEP9gWQoxuIV40dDO8Cg6XERp1hkvm7aFj6mfArHStfZXr0nnMUYw2dzID iLSxaP8K+JEGYoVcqUCs+Fs+ujaaTFMqkm077Qn6VKg6Uos2lsIbuNVW79qRUIYJ1G hJFjHrPD65VTjDlARqEPJxtIXBoQ9XteoEGWtcSmHvtmtaSMVjWVJZUe13tVf3OsCF 67MyfEUtEcsdQ5iCnEM6ZwqTtE9WS/j6MI0aw3ziymSVrr4sbrjeQAtW2JY0XGWrGf qMMwEa13lIpq2D6Tjj2+jZ7b4moCFvd+I+EoQk6u2D3DkeeT3ICDeQ7wAhXkEMXsQZ exups1dTu2QHA== From: Kai-Heng Feng To: hkallweit1@gmail.com, nic_swsd@realtek.com, bhelgaas@google.com Cc: koba.ko@canonical.com, acelan.kao@canonical.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, sathyanarayanan.kuppuswamy@linux.intel.com, vidyas@nvidia.com, rafael.j.wysocki@intel.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Kai-Heng Feng Subject: [PATCH net-next v9 2/5] PCI/ASPM: Add pcie_aspm_capable() helper Date: Sat, 25 Feb 2023 11:46:32 +0800 Message-Id: <20230225034635.2220386-3-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230225034635.2220386-1-kai.heng.feng@canonical.com> References: <20230225034635.2220386-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Introduce a new helper, pcie_aspm_capable(), to report ASPM capability. The user will be introduced by next patch. Acked-by: Bjorn Helgaas Suggested-by: Bjorn Helgaas Signed-off-by: Kai-Heng Feng --- v9: v8: - No change. v7: - Change subject. v6: - No change. v5: - No change. v4: - Report aspm_capable instead. v3: - This is a new patch drivers/pci/pcie/aspm.c | 11 +++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 692d6953f0970..d96bf0a362aa2 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1199,6 +1199,17 @@ bool pcie_aspm_enabled(struct pci_dev *pdev) } EXPORT_SYMBOL_GPL(pcie_aspm_enabled); +bool pcie_aspm_capable(struct pci_dev *pdev) +{ + struct pcie_link_state *link = pcie_aspm_get_link(pdev); + + if (!link) + return false; + + return link->aspm_capable; +} +EXPORT_SYMBOL_GPL(pcie_aspm_capable); + static ssize_t aspm_attr_show_common(struct device *dev, struct device_attribute *attr, char *buf, u8 state) diff --git a/include/linux/pci.h b/include/linux/pci.h index adffd65e84b4e..fd56872883e14 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1692,6 +1692,7 @@ int pci_disable_link_state_locked(struct pci_dev *pdev, int state); void pcie_no_aspm(void); bool pcie_aspm_support_enabled(void); bool pcie_aspm_enabled(struct pci_dev *pdev); +bool pcie_aspm_capable(struct pci_dev *pdev); #else static inline int pci_disable_link_state(struct pci_dev *pdev, int state) { return 0; } @@ -1700,6 +1701,7 @@ static inline int pci_disable_link_state_locked(struct pci_dev *pdev, int state) static inline void pcie_no_aspm(void) { } static inline bool pcie_aspm_support_enabled(void) { return false; } static inline bool pcie_aspm_enabled(struct pci_dev *pdev) { return false; } +static inline bool pcie_aspm_capable(struct pci_dev *pdev) { return false; } #endif #ifdef CONFIG_PCIEAER