From patchwork Sat Nov 19 02:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 23183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp520080wrr; Fri, 18 Nov 2022 18:23:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4obqDUWqJCtg2wmqf2cBVC78mhVOe9C6m2uXXGNWHB3kZaIR8MW+6HvnIO00UIANOEuKkL X-Received: by 2002:aa7:95b7:0:b0:548:4e65:348d with SMTP id a23-20020aa795b7000000b005484e65348dmr10411317pfk.56.1668824586533; Fri, 18 Nov 2022 18:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668824586; cv=none; d=google.com; s=arc-20160816; b=dvMtz3R+KGccwA7pfS09ilAH73dohffxxA5yUzeLV1vFqRwIfP2CpNNZfBOL/f1fGH 2SrARIDmlMsV8tKee50p5wenS2dxEpQ33/gSWIZYa1ykSvdcHmW/zVx+iHLmP9wugEJZ 5HksRU76JUyMv4Mk3cDPrzKTwZllDiQVyxQx2ZGsuil7JJ70T6XYgqPCDJ7HIw0+hQVk 4sPSSRvb5qBNcUmxEyTNsxY9UWPCz0y0Xp5cGBG2CCia+VIIX2pqn+E5uIW9fAwZAkqB An7BVlntVS1d4twm2UUn1K4nreg7wNmLErJkz3/vuHhzBJtzvz6rSlbxHW0RkITn+ejs 0FzA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AX3kPljFr9Hg9ftjBuJlUgFpKST3/mytW83xrjulEAQ=; b=r6iOFM4aWQHFa0AtXL7HXhxtgsvhMLeFaMBGkIc+SRTP20WseAmjWqAxh9gt4rrf89 PkvxE+XOzVTs7pIT/dtR/+YUmVTvzhImIVhdD34licWvf1L9oqxZJCIgc+dpr9txA1bI D7uLOsEmkf2uFK0g/tAR3QBcsHTzqkektQr+/tD/WsszZiyyVvA/egYO+u0CmKs+8e9A DFv721vLUaXaZbgVSd48HYlXwh4krL6WnCPEJSLUK/UVsa1Y9OBehLcB5rXpNTHUeeOl igHXYEuvMfqLeIuHvpseYgQ9Hqo5j+1FdjqH3TQJKGiAOl1B5FUWHWTzNOkRhB4km8Ql RYdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VMAgmBtb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a20-20020a170903101400b00186f81a0765si4779858plb.540.2022.11.18.18.22.53; Fri, 18 Nov 2022 18:23:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VMAgmBtb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235623AbiKSCVi (ORCPT + 99 others); Fri, 18 Nov 2022 21:21:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234848AbiKSCU7 (ORCPT ); Fri, 18 Nov 2022 21:20:59 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D02879376; Fri, 18 Nov 2022 18:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668824082; x=1700360082; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P2Oru1XWgSLoubaeIvYnvzBTX/eKLDmi6dShF0lVLzs=; b=VMAgmBtbG2v4sbFJ2nNRE1UtkOGZ6Ufs/e81kSE272CcVXBTYKGOrV9r DaSijxFMYwJPwd7c3IhaeyxaaOe7opkeixa6/G3mV5PJlfn3R94tWcDk4 GPjjDNc0fyR2b28GzURSEdEaTWSh5Mz0JrepAoDnTxoAlx9BqFXz3Mc7K WN5J4XoowEB+gE4uJBeWH5gllyQJOUi1S9WaqX8I6POsu4ua1QRkSXZdY eV915kf5HnBKawS2MDnnRk5VJQgvQFit0hPQVaWyFcWEsiq9Oz9kEHklb h+d22FPZmrySeDid0/XuQVzLqhweWP6Q9pXcSBRnsw5UJRX72kYnLcYTB g==; X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="340126977" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="340126977" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2022 18:14:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="765371057" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="765371057" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 18 Nov 2022 18:14:12 -0800 Received: from debox1-desk4.lan (unknown [10.252.138.169]) by linux.intel.com (Postfix) with ESMTP id C8545580DDF; Fri, 18 Nov 2022 18:14:11 -0800 (PST) From: "David E. Box" To: nirmal.patel@linux.intel.com, jonathan.derrick@linux.dev, lorenzo.pieralisi@arm.com, hch@infradead.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, david.e.box@linux.intel.com, michael.a.bottini@intel.com, rafael@kernel.org, me@adhityamohan.in Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V8 RESEND 1/4] PCI/ASPM: Add pci_enable_link_state() Date: Fri, 18 Nov 2022 18:14:08 -0800 Message-Id: <20221119021411.1383248-2-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221119021411.1383248-1-david.e.box@linux.intel.com> References: <20221119021411.1383248-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749889409843364981?= X-GMAIL-MSGID: =?utf-8?q?1749889409843364981?= From: Michael Bottini Add pci_enable_link_state() to allow devices to change the default BIOS configured states. Clears the BIOS default settings then sets the new states and reconfigures the link under the semaphore. Also add PCIE_LINK_STATE_ALL macro for convenience for callers that want to enable all link states. Signed-off-by: Michael Bottini Signed-off-by: David E. Box Acked-by: Bjorn Helgaas --- V8 - No change V7 - Fix description as suggested by Bjorn - Rename function to pci_enable_link_state V6 - No change V5 - Rename to pci_enable_default_link_state and model after pci_disable_link_state() as suggested by Bjorn. - Add helper PCIE_LINK_STATE_ALL which sets bits for all links states and clock pm. - Clarify commit language to indicate the function changes the default link states (not ASPM policy). V4 - Refactor vmd_enable_apsm() to exit early, making the lines shorter and more readable. Suggested by Christoph. V3 - No changes V2 - Use return status to print pci_info message if ASPM cannot be enabled. - Add missing static declaration, caught by lkp@intel.com drivers/pci/pcie/aspm.c | 54 +++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 7 ++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 53a1fa306e1e..339c686a5094 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1181,6 +1181,60 @@ int pci_disable_link_state(struct pci_dev *pdev, int state) } EXPORT_SYMBOL(pci_disable_link_state); +/** + * pci_enable_link_state - Clear and set the default device link state so that + * the link may be allowed to enter the specified states. Note that if the + * BIOS didn't grant ASPM control to the OS, this does nothing because we can't + * touch the LNKCTL register. Also note that this does not enable states + * disabled by pci_disable_link_state(). Return 0 or a negative errno. + * + * @pdev: PCI device + * @state: Mask of ASPM link states to enable + */ +int pci_enable_link_state(struct pci_dev *pdev, int state) +{ + struct pcie_link_state *link = pcie_aspm_get_link(pdev); + + if (!link) + return -EINVAL; + /* + * A driver requested that ASPM be enabled on this device, but + * if we don't have permission to manage ASPM (e.g., on ACPI + * systems we have to observe the FADT ACPI_FADT_NO_ASPM bit and + * the _OSC method), we can't honor that request. + */ + if (aspm_disabled) { + pci_warn(pdev, "can't override BIOS ASPM; OS doesn't have ASPM control\n"); + return -EPERM; + } + + down_read(&pci_bus_sem); + mutex_lock(&aspm_lock); + link->aspm_default = 0; + 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; + if (state & PCIE_LINK_STATE_L1_1) + link->aspm_default |= ASPM_STATE_L1_1; + if (state & PCIE_LINK_STATE_L1_2) + link->aspm_default |= ASPM_STATE_L1_2; + if (state & PCIE_LINK_STATE_L1_1_PCIPM) + link->aspm_default |= ASPM_STATE_L1_1_PCIPM; + if (state & PCIE_LINK_STATE_L1_2_PCIPM) + link->aspm_default |= ASPM_STATE_L1_2_PCIPM; + pcie_config_aspm_link(link, policy_to_aspm_state(link)); + + link->clkpm_default = (state & PCIE_LINK_STATE_CLKPM) ? 1 : 0; + pcie_set_clkpm(link, policy_to_clkpm_state(link)); + mutex_unlock(&aspm_lock); + up_read(&pci_bus_sem); + + return 0; +} +EXPORT_SYMBOL(pci_enable_link_state); + static int pcie_aspm_set_policy(const char *val, const struct kernel_param *kp) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 2bda4a4e47e8..8c35f15e6012 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1651,10 +1651,15 @@ extern bool pcie_ports_native; #define PCIE_LINK_STATE_L1_2 BIT(4) #define PCIE_LINK_STATE_L1_1_PCIPM BIT(5) #define PCIE_LINK_STATE_L1_2_PCIPM BIT(6) +#define PCIE_LINK_STATE_ALL (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |\ + PCIE_LINK_STATE_CLKPM | PCIE_LINK_STATE_L1_1 |\ + PCIE_LINK_STATE_L1_2 | PCIE_LINK_STATE_L1_1_PCIPM |\ + PCIE_LINK_STATE_L1_2_PCIPM) #ifdef CONFIG_PCIEASPM int pci_disable_link_state(struct pci_dev *pdev, int state); int pci_disable_link_state_locked(struct pci_dev *pdev, int state); +int pci_enable_link_state(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); @@ -1663,6 +1668,8 @@ static inline int pci_disable_link_state(struct pci_dev *pdev, int state) { return 0; } static inline int pci_disable_link_state_locked(struct pci_dev *pdev, int state) { return 0; } +static inline int pci_enable_link_state(struct pci_dev *pdev, int state) +{ return 0; } 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; } From patchwork Sat Nov 19 02:14:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 23184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp520086wrr; Fri, 18 Nov 2022 18:23:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6TOblh8Ux8NsF10HCl4NxVvZi4Puq44ZYuiy92BslJR/DpCSns7u5Om7Hg4L9mlQi9Kbmg X-Received: by 2002:a17:902:7402:b0:188:a51c:b581 with SMTP id g2-20020a170902740200b00188a51cb581mr2223967pll.55.1668824587895; Fri, 18 Nov 2022 18:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668824587; cv=none; d=google.com; s=arc-20160816; b=j4CMEwtzXrtqu6zz8ma3rq9Ry5n7pFO98r1Ji6KuAXR9IMz9SGuBZ0L6g2pxSKrB4l mDxOtxV49yrBjD/0zBQXbOJdMWBVqEYF2Awv6foJjzhuC83oIFx72jZIYOFpRKgF2HC1 uVb7L+kcOICjdHmNQ3nw9KLffI25PSKWDaKJ+1u5xisXazoNurMV7NsrcQEzq4LUlGBI 785w/DTecLbCPrBmLXUqx4Ax3V/lFlit966qNqZqKE+gfo4q+ZDqG57prCyvRO7fjAe2 XynhDtl4ab2qKIlCuxB4lvVZgd7hicCCSw0hawWkQe/tjnjfmaqAbWN6PDsKvg2RWvI9 dC+Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0gZCoampUooYkztnEDrMgimVqQDHJaNqFDvOc4OrnVw=; b=wjXH2YAZ+COn7qMy7a9Rg24ZoMPzUz56yExChDKniN2Y58C5F02jDCc1VTy9elSO+c ZMcImjTMV8oOvwGWZLlYMXKhqb3ll0NKHc3i6QdxxdkqwKMNxPZ/KVNzfPCOnRSWlyiC uf3XHUjUCGi9Iy4G41SGP+oRo9Y93z4jVn8ojcThSiR3UgB0rP3fUep0JqKmdZa4SxPA FrNgUCkxhZeNUz2FqoOmCRxfaklVYrFMyI9nqMWf9YQwvZVnZnhXAv01A09kI+ERxVK3 qXMlAi7AXbihoVYh61oGJuQ4AI+t8nS2BzBybNRE6hnZlCBhJPsuEyx3aLlZzZ/Qfgkt fkKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HsD+8euC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a056a001bcd00b005638dc03ab3si4731865pfw.323.2022.11.18.18.22.55; Fri, 18 Nov 2022 18:23:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HsD+8euC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235628AbiKSCVs (ORCPT + 99 others); Fri, 18 Nov 2022 21:21:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235067AbiKSCVC (ORCPT ); Fri, 18 Nov 2022 21:21:02 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C78C5616; Fri, 18 Nov 2022 18:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668824082; x=1700360082; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rwsEQa82RGEY35/kVIyEKXcQKfXvSrWD1YVUMbGBB/c=; b=HsD+8euCxtgPhfPXD8M7kJ7TZIqQcyJHjQnbecmJOkA4NLqMa0YPEdGB NtZARpwjyGAHGoOxPy4g2irtGmZ6WPgKQM5e0SebsGKb4HV5I9A1+aN4J 0eVXkRPC3D6wiYAG3qwIUHcAa4WOcIkybKHvlg1kVKQPIw403JzprRTD8 DgNyOcKqieWH5iFhwDqAZVD5Mpur82DbHAMiMpxI3Bsjq0cYuEKgWgIm9 wyQyApfdVeJ17XS8JgQhFA+N3nzZRqvnNj1hCoYJ43TrWWk3iJzKIcZAk cDtxiEvjEC5/WxPDZeqwa1xuJk5kUO7j/LMIAM3PU3QHst6fqjOSqa97G Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="313310239" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="313310239" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2022 18:14:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="815129819" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="815129819" Received: from linux.intel.com ([10.54.29.200]) by orsmga005.jf.intel.com with ESMTP; 18 Nov 2022 18:14:12 -0800 Received: from debox1-desk4.lan (unknown [10.252.138.169]) by linux.intel.com (Postfix) with ESMTP id 1E738580DFA; Fri, 18 Nov 2022 18:14:12 -0800 (PST) From: "David E. Box" To: nirmal.patel@linux.intel.com, jonathan.derrick@linux.dev, lorenzo.pieralisi@arm.com, hch@infradead.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, david.e.box@linux.intel.com, michael.a.bottini@intel.com, rafael@kernel.org, me@adhityamohan.in Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V8 RESEND 2/4] PCI: vmd: Use PCI_VDEVICE in device list Date: Fri, 18 Nov 2022 18:14:09 -0800 Message-Id: <20221119021411.1383248-3-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221119021411.1383248-1-david.e.box@linux.intel.com> References: <20221119021411.1383248-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,UPPERCASE_50_75 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749889411354541751?= X-GMAIL-MSGID: =?utf-8?q?1749889411354541751?= Refactor the PCI ID list to use PCI_VDEVICE. Signed-off-by: David E. Box Reviewed-by: Jon Derrick Reviewed-by: Nirmal Patel --- V8 - No change V7 - New Patch. Separate patch suggested by Lorenzo drivers/pci/controller/vmd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index e06e9f4fc50f..9dedca714c18 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -994,33 +994,33 @@ static int vmd_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(vmd_dev_pm_ops, vmd_suspend, vmd_resume); static const struct pci_device_id vmd_ids[] = { - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_201D), + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_VMD_201D), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_28C0), + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_VMD_28C0), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_CAN_BYPASS_MSI_REMAP,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x467f), + {PCI_VDEVICE(INTEL, 0x467f), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_OFFSET_FIRST_VECTOR,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4c3d), + {PCI_VDEVICE(INTEL, 0x4c3d), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_OFFSET_FIRST_VECTOR,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa77f), + {PCI_VDEVICE(INTEL, 0xa77f), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_OFFSET_FIRST_VECTOR,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7d0b), + {PCI_VDEVICE(INTEL, 0x7d0b), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_OFFSET_FIRST_VECTOR,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xad0b), + {PCI_VDEVICE(INTEL, 0xad0b), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_OFFSET_FIRST_VECTOR,}, - {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B), + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B), .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_OFFSET_FIRST_VECTOR,}, From patchwork Sat Nov 19 02:14:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 23182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp520075wrr; Fri, 18 Nov 2022 18:23:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4rS+tbZzBuwvKGJ4kp6MSYOtkgQWNfNTGGB6AYLmhkPOgSthxrH6NDwPMr7UG7rszhJIjh X-Received: by 2002:a17:90b:1214:b0:213:43bc:92aa with SMTP id gl20-20020a17090b121400b0021343bc92aamr10552358pjb.119.1668824584841; Fri, 18 Nov 2022 18:23:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668824584; cv=none; d=google.com; s=arc-20160816; b=o6ZpVir2OKeifQXCZGEN35rN9E1upUzjCA7uhCrwvuvgIGWCf0s9TYnHJllBQDz9gu lJsZIN8us82jWMoLMPraZwWwJKFjDe5o41i7NFY6SNn9NWT82HzNZTCNbAjWA8SRprDX ixSFIdV9FQqtrZcmv3DaZ7oS/iTZ1+5Yunahx3rofd2ynRGWXSTA1khs3stxihRJ/q4i fTPhRn34VDJI/rLZTimKYdeIeh6kdNaabR6CguEV0JZGuv7ng8mkj2E77NAWnH3c53OM T0uxe6M2EZeNWz5/9XU2SNl7sEUMxNaUJMhbnzmRcsBAb2Qpx/xnH/TsJ18H+HtL/IaQ +LIg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c8HEDzXLuHtpJYRMr1xunO8qdHHJvvobqs/qL7Rvops=; b=IeruQhH9uPd4Wmq8j4r5wMbt6040Q9DMRU54WcdFybSfriUMbjaYjpWbaD44NoLiHo HXnDArPc4bmjl2YF4p3nU4DO9+LvfpJKSQXzIUab/NqL8bOxXJ/RjIttfmvG4vNPHcz+ IFXPt7B5uzKLTf6juODJF+LEKGmgJEjlGijxwRXzSScfE6kUR76eJYuj+vLhFjXciQ3c jx9cBgZSbHNTX5UXNd7RFaPgEFJ6Ew70wkyCmu+efsdcukyJzW6hXh3KDQSCz2jgACiy 8NfL0N1h8EVmDLt4GaQsXS4RpNkSTHVtWGFoQaGXVuLrXBsxxDvABOvOQLEQOPFZOxW8 Mb2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KlphkqrQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a63d053000000b0045a43a568casi5337868pgi.717.2022.11.18.18.22.52; Fri, 18 Nov 2022 18:23:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KlphkqrQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235581AbiKSCVg (ORCPT + 99 others); Fri, 18 Nov 2022 21:21:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232999AbiKSCUw (ORCPT ); Fri, 18 Nov 2022 21:20:52 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7F0B9725; Fri, 18 Nov 2022 18:14:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668824082; x=1700360082; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Axh+ZBumwlo0dW64PCUDUQPBaXXqzQOyDLHu/ClAkI4=; b=KlphkqrQjOPCzJIwoV5iSbnk9qeH9xn+kOnr0JmPictWAhYukME8rClm Wq+EkBfFNiLrfluCk6Zyf80afsrj2M2x99+zvqeKhBiWFZ6Raq/9gZdck Q0WwTdDkCfEKwON4mrnxv7Znm73yeJIrTKoL1zJ+9bt0YMrINC13/b54j 4AFON9Qu8BPH6b9I3q8yk2qIaxzGsn83RwDXdq/fT9YJwy7f7e+1AHE2e kcG7zKn2nRYv1NH2rIyp3ZuCj573dpOG/FcF8jqLzwkL4Ta95QDDn0SS9 jO3CsvOi5XRPeE5PaTVvPn/6X6rmiBlBSAPLct6DD+ecom/Q0lr8vucQI w==; X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="310913056" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="310913056" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2022 18:14:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="729440803" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="729440803" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 18 Nov 2022 18:14:12 -0800 Received: from debox1-desk4.lan (unknown [10.252.138.169]) by linux.intel.com (Postfix) with ESMTP id 65612580DDF; Fri, 18 Nov 2022 18:14:12 -0800 (PST) From: "David E. Box" To: nirmal.patel@linux.intel.com, jonathan.derrick@linux.dev, lorenzo.pieralisi@arm.com, hch@infradead.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, david.e.box@linux.intel.com, michael.a.bottini@intel.com, rafael@kernel.org, me@adhityamohan.in Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V8 RESEND 3/4] PCI: vmd: Create feature grouping for client products Date: Fri, 18 Nov 2022 18:14:10 -0800 Message-Id: <20221119021411.1383248-4-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221119021411.1383248-1-david.e.box@linux.intel.com> References: <20221119021411.1383248-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,UPPERCASE_50_75 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749889407996754362?= X-GMAIL-MSGID: =?utf-8?q?1749889407996754362?= Simplify the device ID list by creating a grouping of features shared by client products. Suggested-by: Jon Derrick Signed-off-by: David E. Box Reviewed-by: Kuppuswamy Sathyanarayanan --- V8 - New patch. drivers/pci/controller/vmd.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 9dedca714c18..86f3085db014 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -68,6 +68,10 @@ enum vmd_features { VMD_FEAT_CAN_BYPASS_MSI_REMAP = (1 << 4), }; +#define VMD_FEATS_CLIENT (VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | \ + VMD_FEAT_HAS_BUS_RESTRICTIONS | \ + VMD_FEAT_OFFSET_FIRST_VECTOR) + static DEFINE_IDA(vmd_instance_ida); /* @@ -1001,29 +1005,17 @@ static const struct pci_device_id vmd_ids[] = { VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_CAN_BYPASS_MSI_REMAP,}, {PCI_VDEVICE(INTEL, 0x467f), - .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | - VMD_FEAT_HAS_BUS_RESTRICTIONS | - VMD_FEAT_OFFSET_FIRST_VECTOR,}, + .driver_data = VMD_FEATS_CLIENT,}, {PCI_VDEVICE(INTEL, 0x4c3d), - .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | - VMD_FEAT_HAS_BUS_RESTRICTIONS | - VMD_FEAT_OFFSET_FIRST_VECTOR,}, + .driver_data = VMD_FEATS_CLIENT,}, {PCI_VDEVICE(INTEL, 0xa77f), - .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | - VMD_FEAT_HAS_BUS_RESTRICTIONS | - VMD_FEAT_OFFSET_FIRST_VECTOR,}, + .driver_data = VMD_FEATS_CLIENT,}, {PCI_VDEVICE(INTEL, 0x7d0b), - .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | - VMD_FEAT_HAS_BUS_RESTRICTIONS | - VMD_FEAT_OFFSET_FIRST_VECTOR,}, + .driver_data = VMD_FEATS_CLIENT,}, {PCI_VDEVICE(INTEL, 0xad0b), - .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | - VMD_FEAT_HAS_BUS_RESTRICTIONS | - VMD_FEAT_OFFSET_FIRST_VECTOR,}, + .driver_data = VMD_FEATS_CLIENT,}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B), - .driver_data = VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | - VMD_FEAT_HAS_BUS_RESTRICTIONS | - VMD_FEAT_OFFSET_FIRST_VECTOR,}, + .driver_data = VMD_FEATS_CLIENT,}, {0,} }; MODULE_DEVICE_TABLE(pci, vmd_ids); From patchwork Sat Nov 19 02:14:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 23185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp523284wrr; Fri, 18 Nov 2022 18:34:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4VQet7okpPa3Zg8oxbXprAw6ezdrdyGp9/qqPNQ2azQ1/0ZTHn60QVPUkaoGdUn0Jw+nb5 X-Received: by 2002:a63:e509:0:b0:474:4380:cca6 with SMTP id r9-20020a63e509000000b004744380cca6mr9089392pgh.229.1668825259716; Fri, 18 Nov 2022 18:34:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668825259; cv=none; d=google.com; s=arc-20160816; b=sL2p9T0Kj9Vzuvq+1jCvAZ2DaidbfWnhK/WLKPhDAUxM9ukTPC3sB6lwPnMnQcPrD+ c3lFZzMfOCt+qME7udsKCuBJvtizsU07zPD03FGVP/C+berU+QFQvM92Oebd7mfNLy7U cLW2NhFavQXrjvslQy+8+xwKIWg3dx80ma0WRtF1+A1eLHugQUZ7EJXfga/GEiOrqu0c c0SH8Rqc6ry0/EpwYHz+Ssxw2Pm2jlJI47BYNyFstYUq/mpDOY7MmpWXBSRG75/teEah 1zacGTfn5J9Bayft1Ch2azt5Qg+6sbcO7jKl6J1AndRsqRDEHkfhPA7jUWT0y4153Net L8sA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AN3y3/lf9jUBuRSm5dowTkXFBWVvdiwZbUDUB15fGtk=; b=KfrsRiG+csX/1LRjFx1PAv4ABL7iq8UDJJ9diC23SFJjufmXoIqvqVfw8ktze3J7xq hUMkx2dGfI7mGSFaW2iCX8oKuJOrDZ0LKW0PiZc2hBosl9bCQCwx2qUzkV2OHCCewM1+ l1ovmjfRcEuH8jjvnperJV3nHgQSXiR5+FWUH+ppUAgfyVaht5khLenGudaAaILphvwY uo9wHY6cO1DDijuT2gAbD3LKpKLLbIhSbATr0VJGhc8e6JDJ0eGG+adpl/16RwhJsBz3 jocuGifysrC72HnX0OMhoZommOdJz+lv8SpdBZdOB9CmLlDBS3EgV6w1Z88YUYyoTGlP Pxlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AUGT0i2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t141-20020a635f93000000b004622caf9ac4si5462427pgb.805.2022.11.18.18.34.07; Fri, 18 Nov 2022 18:34:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AUGT0i2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236003AbiKSC0a (ORCPT + 99 others); Fri, 18 Nov 2022 21:26:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235936AbiKSCYo (ORCPT ); Fri, 18 Nov 2022 21:24:44 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD560C7599; Fri, 18 Nov 2022 18:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668824144; x=1700360144; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oeZu/jIyN1c5IQFJ1A7HgOl4IY4Uaxs22ZTpXdLDbgo=; b=AUGT0i2yZw3gwHddRNbW4qrRHXd9gduysswN87KvFC+yYbrxAmoqCyMs O9e7xJ2tVDYLK+1ZZDmEXw/Y02Xob8v7XPA/qSLgMZkLY5F7++PXhReiK YUicgPQ+Qmg0RtrYP7WO4TcYyBGieJ5B29/wnff5qJrZzTE6MVFsK4pHW V+WBoH7pOdKfkSFT+w6Ga5fqIFlHVKuqLmuEgqMaqjR92GbbtqHRUl/ig 4f4K8d8uji0HNFHrvlg/3gQ9DCPXwj4S23zjMY2RMG/t44a1KP9K1+qRj BH9oROqx32jRXTP3rObyY38WB2sQIzRkKK99T2aYEmSC89v68v68bRkcF w==; X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="315100484" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="315100484" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2022 18:14:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10535"; a="618225634" X-IronPort-AV: E=Sophos;i="5.96,175,1665471600"; d="scan'208";a="618225634" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 18 Nov 2022 18:14:12 -0800 Received: from debox1-desk4.lan (unknown [10.252.138.169]) by linux.intel.com (Postfix) with ESMTP id AB668580DFA; Fri, 18 Nov 2022 18:14:12 -0800 (PST) From: "David E. Box" To: nirmal.patel@linux.intel.com, jonathan.derrick@linux.dev, lorenzo.pieralisi@arm.com, hch@infradead.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, david.e.box@linux.intel.com, michael.a.bottini@intel.com, rafael@kernel.org, me@adhityamohan.in Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V8 RESEND 4/4] PCI: vmd: Add quirk to configure PCIe ASPM and LTR Date: Fri, 18 Nov 2022 18:14:11 -0800 Message-Id: <20221119021411.1383248-5-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221119021411.1383248-1-david.e.box@linux.intel.com> References: <20221119021411.1383248-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749890115483337854?= X-GMAIL-MSGID: =?utf-8?q?1749890115483337854?= PCIe ports reserved for VMD use are not visible to BIOS and therefore not configured to enable PCIe ASPM or LTR values (which BIOS will configure if they are not set). Lack of this programming results in high power consumption on laptops as reported in bugzilla. For affected products use pci_enable_link_state to set the allowed link states for devices on the root ports. Also set the LTR value to the maximum value needed for the SoC. This is a workaround for products from Rocket Lake through Alder Lake. Raptor Lake, the latest product at this time, has already implemented LTR configuring in BIOS. Future products will move ASPM configuration back to BIOS as well. As this solution is intended for laptops, support is not added for hotplug or for devices downstream of a switch on the root port. Link: https://bugzilla.kernel.org/show_bug.cgi?id=212355 Link: https://bugzilla.kernel.org/show_bug.cgi?id=215063 Link: https://bugzilla.kernel.org/show_bug.cgi?id=213717 Signed-off-by: Michael Bottini Signed-off-by: David E. Box Reviewed-by: Jon Derrick Reviewed-by: Nirmal Patel --- V8 - Removed struct vmd_device_data patch. Instead use #define for the LTR value which is the same across all products needing the quirk. V7 - No change V6 - Set ASPM first before setting LTR. This is needed because some devices may only have LTR set by BIOS and not ASPM - Skip setting the LTR if the current LTR in non-zero. V5 - Provide the LTR value as driver data. - Use DWORD for the config space write to avoid PCI WORD access bug. - Set ASPM links firsts, enabling all link states, before setting a default LTR if the capability is present - Add kernel message that VMD is setting the device LTR. V4 - Refactor vmd_enable_apsm() to exit early, making the lines shorter and more readable. Suggested by Christoph. V3 - No changes V2 - Use return status to print pci_info message if ASPM cannot be enabled. - Add missing static declaration, caught by lkp@intel.com drivers/pci/controller/vmd.c | 64 ++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 86f3085db014..cba57e3091f6 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -66,12 +66,22 @@ enum vmd_features { * interrupt handling. */ VMD_FEAT_CAN_BYPASS_MSI_REMAP = (1 << 4), + + /* + * Enable ASPM on the PCIE root ports and set the default LTR of the + * storage devices on platforms where these values are not configured by + * BIOS. This is needed for laptops, which require these settings for + * proper power management of the SoC. + */ + VMD_FEAT_BIOS_PM_QUIRK = (1 << 5), }; #define VMD_FEATS_CLIENT (VMD_FEAT_HAS_MEMBAR_SHADOW_VSCAP | \ VMD_FEAT_HAS_BUS_RESTRICTIONS | \ VMD_FEAT_OFFSET_FIRST_VECTOR) +#define VMD_BIOS_PM_QUIRK_LTR 0x1003 /* 3145728 ns */ + static DEFINE_IDA(vmd_instance_ida); /* @@ -713,6 +723,46 @@ static void vmd_copy_host_bridge_flags(struct pci_host_bridge *root_bridge, vmd_bridge->native_dpc = root_bridge->native_dpc; } +/* + * Enable ASPM and LTR settings on devices that aren't configured by BIOS. + */ +static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) +{ + unsigned long features = *(unsigned long *)userdata; + u16 ltr = VMD_BIOS_PM_QUIRK_LTR; + u32 ltr_reg; + int pos; + + if (!(features & VMD_FEAT_BIOS_PM_QUIRK)) + return 0; + + pci_enable_link_state(pdev, PCIE_LINK_STATE_ALL); + + pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_LTR); + if (!pos) + return 0; + + /* + * Skip if the max snoop LTR is non-zero, indicating BIOS has set it + * so the LTR quirk is not needed. + */ + pci_read_config_dword(pdev, pos + PCI_LTR_MAX_SNOOP_LAT, <r_reg); + if (!!(ltr_reg & (PCI_LTR_VALUE_MASK | PCI_LTR_SCALE_MASK))) + return 0; + + /* + * Set the default values to the maximum required by the platform to + * allow the deepest power management savings. Write as a DWORD where + * the lower word is the max snoop latency and the upper word is the + * max non-snoop latency. + */ + ltr_reg = (ltr << 16) | ltr; + pci_write_config_dword(pdev, pos + PCI_LTR_MAX_SNOOP_LAT, ltr_reg); + pci_info(pdev, "VMD: Default LTR value set by driver\n"); + + return 0; +} + static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) { struct pci_sysdata *sd = &vmd->sysdata; @@ -867,6 +917,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) pci_reset_bus(child->self); pci_assign_unassigned_bus_resources(vmd->bus); + pci_walk_bus(vmd->bus, vmd_pm_enable_quirk, &features); + /* * VMD root buses are virtual and don't return true on pci_is_pcie() * and will fail pcie_bus_configure_settings() early. It can instead be @@ -1005,17 +1057,17 @@ static const struct pci_device_id vmd_ids[] = { VMD_FEAT_HAS_BUS_RESTRICTIONS | VMD_FEAT_CAN_BYPASS_MSI_REMAP,}, {PCI_VDEVICE(INTEL, 0x467f), - .driver_data = VMD_FEATS_CLIENT,}, + .driver_data = VMD_FEATS_CLIENT | VMD_FEAT_BIOS_PM_QUIRK,}, {PCI_VDEVICE(INTEL, 0x4c3d), - .driver_data = VMD_FEATS_CLIENT,}, + .driver_data = VMD_FEATS_CLIENT | VMD_FEAT_BIOS_PM_QUIRK,}, {PCI_VDEVICE(INTEL, 0xa77f), - .driver_data = VMD_FEATS_CLIENT,}, + .driver_data = VMD_FEATS_CLIENT | VMD_FEAT_BIOS_PM_QUIRK,}, {PCI_VDEVICE(INTEL, 0x7d0b), - .driver_data = VMD_FEATS_CLIENT,}, + .driver_data = VMD_FEATS_CLIENT | VMD_FEAT_BIOS_PM_QUIRK,}, {PCI_VDEVICE(INTEL, 0xad0b), - .driver_data = VMD_FEATS_CLIENT,}, + .driver_data = VMD_FEATS_CLIENT | VMD_FEAT_BIOS_PM_QUIRK,}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_VMD_9A0B), - .driver_data = VMD_FEATS_CLIENT,}, + .driver_data = VMD_FEATS_CLIENT | VMD_FEAT_BIOS_PM_QUIRK,}, {0,} }; MODULE_DEVICE_TABLE(pci, vmd_ids);