From patchwork Thu May 9 16:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659890 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2058.outbound.protection.outlook.com [40.107.94.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0769816F8F7; Thu, 9 May 2024 16:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272085; cv=fail; b=tyaNXkJ+XILEnXjMyf2fIJtwHQyAq5lJOrNfXgTAyf2mrk67WwTWaVjgvWIsPJ5EkCQMI6oHzhme4mFZEGcajbqAGxmuPtzJGa1QeE0VcB2YrKg597zCRhDTJn7Zf3UF27eDNKo6UCyD1+mNmfH3ClnH+G9l71ZptKp+hhLZGoc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272085; c=relaxed/simple; bh=Oi2JAhDjXFr+4b2HodN0Av/r2PrKL8/BAX7BUM/zt6A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pOl46REYiilaNr4KOmqto3+ltmmnNTk19OpPnmuQnvq67/eBvmaE2/VzRZw8AaRw2oirx6QC2kI+SwGChUO/EttT0LYiAr9OOi/J+k0+vOlhYWE1EgYUr1eC9yxCzqU1UTl2Y8oSnAPvsMdxzXHljt0FIJu5lPTQz1ehk8YyNYk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=H+DxcrGT; arc=fail smtp.client-ip=40.107.94.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="H+DxcrGT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ad1RHTCyt1tWico5QP80IR1JMTwvvnziZq/FIl9XWtYK5k53dTTv9hW3zzzy+/unPsgusgTC9Pb6vx9sCIuU9bUsO0SNsYher4LmtvSMl08tEcu+IjJe5GJduV4aHV15dRQoZ1hNrxsb5Gqjkgmxpt+ShoF2dHSE9B3D/F+yDX+UWs1en8DYNBNzbBsQUcpiIqP8bvdCJBG1fnXotR3IQ54LgxDZoIdSHO5CfRpYagi50/SC/UjCcsS7GHUutB1vo5zCzw/GzW2L/JU7IBFw7JqIRKkXmiPdGI0NxGr/S75moPIol600Vp9flb/cmkqn0QdcQTdQRfYuqi5MNvSjMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JiL5Pe+bmxJOSG+rM4CY2MEuGsszwZIA85ae3Z1h05g=; b=JyqFMlJM8SA2Ky8cPJPxFZQzAvHbSVLfaaMXWR8w5lCezzfmYTyxDG6c/+MqbJ+aHly1YMC9Wt029Dw3IDnu0pJXKDUPCagbvsbcqRoXUmJAi6MfD17HNUE7KJR0Oj2w0CiV88doGEdGDgWazwSkbSxhVbl9SeHI28RpvSlEqhMbiBxOWrjysZ0QREPGSthDoTATs2nBbQvjpkqAjgd99BqnCw9yc2xDzLUU93w6+wJ7LVjkOMw1MepVwNQ0tVgXSPHfqlKXNthkF3tsaINkq6pqZLhdckvW+N7GItJeiZK1wwAfQBCmn5yRMDgvSG6F/Hn9TTle2cAFO5mgcVSPCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JiL5Pe+bmxJOSG+rM4CY2MEuGsszwZIA85ae3Z1h05g=; b=H+DxcrGTjskccHpTHxywWZUTVAL8oBB/5xLVLHN37z32xUAQIboiP+PJC3gwFKWhXYjg/o9jFnOKxtBkow8QDdo9xl2JVEY6SsOpX/gtXF67P/ujEwSbw/m5Lbr9yn6h/u4RiEO1kyXv05FkT2Hhv3ipoCcOI6pfgzUNQ2wDPLc= Received: from CH2PR02CA0021.namprd02.prod.outlook.com (2603:10b6:610:4e::31) by SJ2PR12MB8942.namprd12.prod.outlook.com (2603:10b6:a03:53b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.45; Thu, 9 May 2024 16:27:59 +0000 Received: from CH3PEPF00000015.namprd21.prod.outlook.com (2603:10b6:610:4e:cafe::b6) by CH2PR02CA0021.outlook.office365.com (2603:10b6:610:4e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.47 via Frontend Transport; Thu, 9 May 2024 16:27:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000015.mail.protection.outlook.com (10.167.244.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:27:59 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:27:58 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 1/9] PCI: Introduce PCIe TPH support framework Date: Thu, 9 May 2024 11:27:33 -0500 Message-ID: <20240509162741.1937586-2-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000015:EE_|SJ2PR12MB8942:EE_ X-MS-Office365-Filtering-Correlation-Id: 936867e5-f695-4e79-cba0-08dc7044fd86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400017|376005|7416005|1800799015; X-Microsoft-Antispam-Message-Info: 8as+7yQaeS1OJbuzcJCiukKZdJ8GTk+6Rt8JXDOV2J7kjKRB6Thke3Rkv2qz6I7NRpy4D2f59L2EDUQ3MwJDAzaSTQBMpbBGSUEX7r43Kyd/WHkCmYBdBvJjZimc783noHljZeasgGN7Ofl2hPt/MfyucTZ8xrC3AlipFTGYAh1upXUPh2/CI06h7/lWiZezT/YuNsgZvcEpVIsrXbPwPNxt7dfqlspwATENPpNc74Oa/RIacGr5eaf+DuSc+ZzDkIdhYZynQ4dKoI/4WdkG3FR5mV6EXEtwA8bwMUM8fNvdXo1YRkDZ01vXIsmh44fn81Ytj0nhEMQZwbFRfipGkrGWnMN/oQcGfgBuIQ/0u1KMyQx05oZJtq5ULvyTrIEsuALOmNZePhc/v07bP6Xt02Z9F10MLZTvRS0AQ3n9myWF+pzcqW9KhziNT8hmG9JjhvE5yLIqGlcpCwZInZ9zNPF9//0iw3PBcsYh7G/m+3u4knRbHMPseJYpEaadRKq72t7zLG9h1g/iioTokEw96pDlFpzAjqrlfq27Sa35gsLqfTHsceUOkAp5R4HGuljJAE71IElivSG0gZtYLhEBVfEowUBRrDg/TSIixnq/uThuFuOK2DluPXSbcWX5jqHP4oeKHX0GyB0bcvx3UgFqf1dO9+ifLgy6uGEDgy08XL+RZr4YWscMPFD+nbaUhYlZd14RWuJw3Vfz3oEvo6CjNd9p3NnAy8RnJ2lYiA2UTqP9jB7AjsFZSkR/KHHo9euGsjof1JakFG0R/RPxZFD8sf0saismE1c2Y8IceLmLz2IWu4mXOhzFNXjfd7B5+5+11ThzFHcUPD+JzjqciWRHDq47HqptvXwyGIWgxWi7J68eEPZbKuWS+k911+fnTemKmcvvdRvdCgE3SlqMgIvD1xMCblZtazj/VZSrSFIGB5AwrVS4hnsP336MoUIkICxo0MRhVvvnPPbpn3Ukej7e3mVrpPEiKiF6gKU/5udm5t7nZ5ifKVciIyIr0T+HpOin1AOPoiuoUOxd867NAfMAOeBoDyXeEynidWyRyBEQjrx3qZhlDAU9k9srIQdIvDOgIAQXO1BH60UxXrYCIyQnqyqMTJxPIwfp1UTRxYfNnrvcadCv662zXG+qhlqUgKQBpdlStRR4KgcxG0PRgavEwKvMbvBaCPUWGzDy/C3hkOtsuDEl1AdnNtlgtAWZhu2993BK8bSg3XjxAd1pXKbxgMJrfnpKJuM30AibRD5hTPB74d2Jlnn64jC3MXZ1KT43tAN0f0zHxlRHn+QrvE9u9UWxIF3jopEmHJ9BXv72jmQFbQ66E1j/q/Cr+BxUC/uI0QZyXCVHwXLYx3FY+0rxoCFWYEmArsBUQ5qoGMO2HmmDQaBjLzJ4ESOuo3F0qqg0 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400017)(376005)(7416005)(1800799015);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:27:59.2699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 936867e5-f695-4e79-cba0-08dc7044fd86 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000015.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8942 This patch implements the framework for PCIe TPH support. It introduces tph.c source file, along with CONFIG_PCIE_TPH, to Linux PCIe subsystem. A new member, named tph_cap, is also introduced in pci_dev to cache TPH capability offset. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang --- drivers/pci/pci.h | 6 ++++++ drivers/pci/pcie/Kconfig | 10 ++++++++++ drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/tph.c | 28 ++++++++++++++++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 4 ++++ 6 files changed, 50 insertions(+) create mode 100644 drivers/pci/pcie/tph.c diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 17fed1846847..6f1d35a68126 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -508,6 +508,12 @@ static inline int pci_iov_bus_range(struct pci_bus *bus) #endif /* CONFIG_PCI_IOV */ +#ifdef CONFIG_PCIE_TPH +void pcie_tph_init(struct pci_dev *dev); +#else +static inline void pcie_tph_init(struct pci_dev *dev) {} +#endif + #ifdef CONFIG_PCIE_PTM void pci_ptm_init(struct pci_dev *dev); void pci_save_ptm_state(struct pci_dev *dev); diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index 8999fcebde6a..a4940e2af9b1 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -155,3 +155,13 @@ config PCIE_EDR the PCI Firmware Specification r3.2. Enable this if you want to support hybrid DPC model which uses both firmware and OS to implement DPC. + +config PCIE_TPH + bool "TLP Processing Hints" + default n + help + This option adds support for PCIE TLP Processing Hints (TPH). + TPH allows endpoint devices to provide optimization hints, such as + desired caching behavior, for requests that target memory space. + These hints, called steering tags, can empower the system hardware + to optimize the utilization of platform resources. diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile index 6461aa93fe76..3542b42ea0b9 100644 --- a/drivers/pci/pcie/Makefile +++ b/drivers/pci/pcie/Makefile @@ -13,3 +13,4 @@ obj-$(CONFIG_PCIE_PME) += pme.o obj-$(CONFIG_PCIE_DPC) += dpc.o obj-$(CONFIG_PCIE_PTM) += ptm.o obj-$(CONFIG_PCIE_EDR) += edr.o +obj-$(CONFIG_PCIE_TPH) += tph.o diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c new file mode 100644 index 000000000000..5f0cc06b74bb --- /dev/null +++ b/drivers/pci/pcie/tph.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * TPH (TLP Processing Hints) support + * + * Copyright (C) 2024 Advanced Micro Devices, Inc. + * Eric Van Tassell + * Wei Huang + */ + +#define pr_fmt(fmt) "TPH: " fmt +#define dev_fmt pr_fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../pci.h" + +void pcie_tph_init(struct pci_dev *dev) +{ + dev->tph_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_TPH); +} + diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1325fbae2f28..9ac511032639 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2481,6 +2481,7 @@ static void pci_init_capabilities(struct pci_dev *dev) pci_dpc_init(dev); /* Downstream Port Containment */ pci_rcec_init(dev); /* Root Complex Event Collector */ pci_doe_init(dev); /* Data Object Exchange */ + pcie_tph_init(dev); /* TLP Processing Hints */ pcie_report_downtraining(dev); pci_init_reset_methods(dev); diff --git a/include/linux/pci.h b/include/linux/pci.h index 16493426a04f..73d92c7d2c5b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -529,6 +529,10 @@ struct pci_dev { /* These methods index pci_reset_fn_methods[] */ u8 reset_methods[PCI_NUM_RESET_METHODS]; /* In priority order */ + +#ifdef CONFIG_PCIE_TPH + u16 tph_cap; /* TPH capability offset */ +#endif }; static inline struct pci_dev *pci_physfn(struct pci_dev *dev) From patchwork Thu May 9 16:27:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659891 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2064.outbound.protection.outlook.com [40.107.94.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F26C170828; Thu, 9 May 2024 16:28:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272104; cv=fail; b=Xz8YZ+en7r6y/AkDbQ+z3KQit8yDmlkhYVLvrU7hy0pnrTIBHpWqKkKx8bWjokjfm7AbZq3MUOwNMoE0liOBycCCdUwuFqMnkJ89RdtyFiC8IG+ZRqwSssN7i5n4swKio2Mc6qt1AvIhY7VfOSBpzsXVDwaHnLnBlb7y+n0oPuw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272104; c=relaxed/simple; bh=0IRW7MS63foHzy/5weCuwS45+nd4WR7SRlvtpV5sYKQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nb3mrmlHanZGd87l7Qm+3gufW3GaTiFfe/zQu3JvqhZxQupV9yuJTSE6X6+OT98aCDMl9PBM03FY8X9+lQiyftS/mmPOY4NNc9J8DxsYepf7NmQjSY9VQ9hwthOySDP+PKEZhh5j999moU3f44q7MUuBHy75r2bE4kUy2GblIfE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LL0mH+xf; arc=fail smtp.client-ip=40.107.94.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LL0mH+xf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K4Qb/nroaHon2vzakWMAL0uYm7eBtqlE+kiygGMkYESfyO81z/8NKz/uapicD900+StLaZYScuQUHDkoY/M8MC3DygZr/c9QrxF0UYz4Kepyvy975w0euMhli9O1By2/PwfZQv0SbTtN2vELqB6+JMEjZQ51TmJ28D3Q+afwBOEYBYQTlQYEWsnk0LJad5ltmkHTMZG1OIfPEVlqbRHBpH01n675G2i6TjhYz0VpXCvsVL3eP0Pyc3bGVBVER760Poum9jPwiaIKJFogQ4E1ojYlYYddjlafi5yoYrRfmiOsSipPDTyNT7KuGWbVRsHdFUfELzgXtVGqdOztKR5Lrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y5lxnhYrRUJ0S96/4P+aM6HMIVh/w7lH7FXNjXEi73g=; b=AxoOi8r2vgUPHcbb0BE2Er7bteTsjos3zhUQMIbvBFYgpXmSf8q4yCSDcQB6h6xmDx48D0K58GegttNMLdxTICqs+UdJq7FUe/Rt2MhYGqIeQH6qIt07mGY5ahLEvCOHrx0EdXNlZF9RHW/qOEC59DCyNce+sONqN3fJUGToGNtWRvnzXRz+nw1MmeHao8T8hmEM730val4XM6g+p/OsvmfzYkaf44G6CKwvxcJqbCA2RIgiCU1zAJjge2sMjfpwxjUfu4/8Gs8/GQJqE7lzIp/ZMLdlA3yC4olC+mdDaq1Uezi/oSINF9bX5E+lNMrjYKYU9/eKonxX8YjHIXjFJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y5lxnhYrRUJ0S96/4P+aM6HMIVh/w7lH7FXNjXEi73g=; b=LL0mH+xf37wRno+tPdUo/ZfgJM1S9DDi8F14rJANkBIo0sTJhhPne4liMMei5uVhpoo2j7WafFnvVq6Ub0mX8cI8K0OdAtNGWG25K9X99Tl5uKh5SjjtqK/IZmCtbmo3DKAALANw+Iy5sBvOZ7H+JDrXH10CylVpI6DcUl0oYxI= Received: from CH2PR16CA0022.namprd16.prod.outlook.com (2603:10b6:610:50::32) by SA3PR12MB7782.namprd12.prod.outlook.com (2603:10b6:806:31c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48; Thu, 9 May 2024 16:28:11 +0000 Received: from CH3PEPF00000012.namprd21.prod.outlook.com (2603:10b6:610:50:cafe::a0) by CH2PR16CA0022.outlook.office365.com (2603:10b6:610:50::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48 via Frontend Transport; Thu, 9 May 2024 16:28:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000012.mail.protection.outlook.com (10.167.244.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:28:10 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:28:09 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 2/9] PCI: Add TPH related register definition Date: Thu, 9 May 2024 11:27:34 -0500 Message-ID: <20240509162741.1937586-3-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000012:EE_|SA3PR12MB7782:EE_ X-MS-Office365-Filtering-Correlation-Id: 06675467-6fce-4faa-1eac-08dc70450431 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|7416005|82310400017|36860700004; X-Microsoft-Antispam-Message-Info: kzEYGOrlydym+iX0Pe3PlNWk1APlbl7+LBZz23qKc2HSwwMrL/DQNMkJqUYT0wXF0SM+xtB/kDZH9/U6e0L30/rTs7dPcVBdL+6fa5UfPSa6EiQSXaQKixUyNiLEmIpsWq/iDuWTu3t719jmzWkTe301CqxxLu0AwdTyI68zEDgo/LPUQS+I8UKkoY5/mz2GtIkC4WhaIs15GuHu6Y72fb2UWl/H/t12rvntbDyOg9kpdTyC8iwZpqa2XnVOznDTewRs0Qts84gxhNDIa9zr3wAcru0U4GEkX2xpPREFBdx/y5XBgjCVV3keU7flEx3GMHNRp6ZCePjbsMnenPwZSMI4uQMGtJDw/dQBaRttC6WuJdKdbjpgv6TS7Gu2tnbBfQHp1WcupbeXiQGE2uSxRukb44J385LS8+N2SxMiKBhDzakXPVFXQ7BOthFSIH5HbG+COe2vtdiQp0tCzma6jDgoftNB/BqA3IYTN+zVctpuF5TmVfvIF9vCIarhMtvt4MmCUpKL/JIvH3wxJ2wzmHYKPRYPIvVHX3tiE36i5WI6e0YHjZ4H5Acm2fKbYs6J2Zu3kHP1RfdyAks7jltCAF+z+Bsz735l6Bh/+nN1diDdB2NUysEcQEuGUIEemygOgpygSo+5ag8T5ShybWYehLqKtSg4JFoDHc7cp/4fwcSQm3qvFDCJn0++3dXVDKRH2sCp8K8RBC0sEzbBp8pWeg52BuZ406818rClBt6TJIjKG58n7I+t5rLtG8ENwCtetnzPg4ItIbLXkjhDEbh3AEbZhLSQ/Miac7KJ2WG1ay7f5gRHRTCR7UiP4ELe59umJg5Jv3DKV/l+FO8mBFzievw/tZX4X5cszhyfIEF92hKpaejhUuMrBbsisY2t7YeVB73wzs0bh/I38uouI2G6yZzENDcJ7A3L+VV4zkTaCV4VhZB2Z+chgm0U6qIZJJT+cE+MQdsr5SCbSjBCEuWZ7tFUZeXc+pz5whxRnVPByAywvdhnpkSOpbGU5QVolM4jpsVqnbPtNm+nLDIa1Sz23cbutzID5VXeGLOW3KSsIXJ82U7srpm/yp8kC3ymOxdDCqLF9TCrJPJckMZjLwdQW3yV5biGu/Ra7qLiwrz3ahvovmoz0fybHb4WIx7/qBlc/2awfp+mWhoyceZwroZ0AE4hba63Qiiagf1jSlObwtnb0ys5S0o7Cyqkdua7XioZsvPRBZ1Jrfuux3qsQzRmldgUsVeghPT31f+8inB+slZ9hzGgNFnPHiP3YzQ6xg7IdN7LJgytix9L0kz4Y4E/hsEmu6yCDZ9DCd+UJjwvJ6C7MBE0AhxCgH9XZqV/lNIS6uDAxxhxNTMm9uN+Ghs5pf2/rE/LJnutIFa6wMGeBaWakwXmAqyB547zrOjL25eR X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(1800799015)(376005)(7416005)(82310400017)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:28:10.4524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06675467-6fce-4faa-1eac-08dc70450431 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000012.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7782 Linux has some basic, but incomplete, definition for the TPH Requester capability registers. Also the control registers of TPH Requester and the TPH Completer are missing. This patch adds all required definitions to support TPH enablement. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang --- drivers/vfio/pci/vfio_pci_config.c | 7 +++--- include/uapi/linux/pci_regs.h | 35 ++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index 97422aafaa7b..de622cdfc2a4 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -1434,14 +1434,15 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo if (ret) return pcibios_err_to_errno(ret); - if ((dword & PCI_TPH_CAP_LOC_MASK) == PCI_TPH_LOC_CAP) { + if (((dword & PCI_TPH_CAP_LOC_MASK) >> PCI_TPH_CAP_LOC_SHIFT) + == PCI_TPH_LOC_CAP) { int sts; sts = dword & PCI_TPH_CAP_ST_MASK; sts >>= PCI_TPH_CAP_ST_SHIFT; - return PCI_TPH_BASE_SIZEOF + (sts * 2) + 2; + return PCI_TPH_ST_TABLE + (sts * 2) + 2; } - return PCI_TPH_BASE_SIZEOF; + return PCI_TPH_ST_TABLE; case PCI_EXT_CAP_ID_DVSEC: ret = pci_read_config_dword(pdev, epos + PCI_DVSEC_HEADER1, &dword); if (ret) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index a39193213ff2..bf5dcd626613 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -657,6 +657,7 @@ #define PCI_EXP_DEVCAP2_ATOMIC_COMP64 0x00000100 /* 64b AtomicOp completion */ #define PCI_EXP_DEVCAP2_ATOMIC_COMP128 0x00000200 /* 128b AtomicOp completion */ #define PCI_EXP_DEVCAP2_LTR 0x00000800 /* Latency tolerance reporting */ +#define PCI_EXP_DEVCAP2_TPH_COMP 0x00003000 /* TPH completer support */ #define PCI_EXP_DEVCAP2_OBFF_MASK 0x000c0000 /* OBFF support mechanism */ #define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ @@ -1020,15 +1021,41 @@ #define PCI_DPA_CAP_SUBSTATE_MASK 0x1F /* # substates - 1 */ #define PCI_DPA_BASE_SIZEOF 16 /* size with 0 substates */ +/* TPH Completer Support */ +#define PCI_EXP_DEVCAP2_TPH_COMP_SHIFT 12 +#define PCI_EXP_DEVCAP2_TPH_COMP_NONE 0x0 /* None */ +#define PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY 0x1 /* TPH only */ +#define PCI_EXP_DEVCAP2_TPH_COMP_TPH_AND_EXT 0x3 /* TPH and Extended TPH */ + /* TPH Requester */ #define PCI_TPH_CAP 4 /* capability register */ +#define PCI_TPH_CAP_NO_ST 0x1 /* no ST mode supported */ +#define PCI_TPH_CAP_NO_ST_SHIFT 0x0 /* no ST mode supported shift */ +#define PCI_TPH_CAP_INT_VEC 0x2 /* interrupt vector mode supported */ +#define PCI_TPH_CAP_INT_VEC_SHIFT 0x1 /* interrupt vector mode supported shift */ +#define PCI_TPH_CAP_DS 0x4 /* device specific mode supported */ +#define PCI_TPH_CAP_DS_SHIFT 0x4 /* device specific mode supported shift */ #define PCI_TPH_CAP_LOC_MASK 0x600 /* location mask */ -#define PCI_TPH_LOC_NONE 0x000 /* no location */ -#define PCI_TPH_LOC_CAP 0x200 /* in capability */ -#define PCI_TPH_LOC_MSIX 0x400 /* in MSI-X */ +#define PCI_TPH_CAP_LOC_SHIFT 9 /* location shift */ +#define PCI_TPH_LOC_NONE 0x0 /* no ST Table */ +#define PCI_TPH_LOC_CAP 0x1 /* ST Table in extended capability */ +#define PCI_TPH_LOC_MSIX 0x2 /* ST table in MSI-X table */ #define PCI_TPH_CAP_ST_MASK 0x07FF0000 /* ST table mask */ #define PCI_TPH_CAP_ST_SHIFT 16 /* ST table shift */ -#define PCI_TPH_BASE_SIZEOF 0xc /* size with no ST table */ + +#define PCI_TPH_CTRL 0x8 /* control register */ +#define PCI_TPH_CTRL_MODE_SEL_MASK 0x7 /* ST Model Select mask */ +#define PCI_TPH_CTRL_MODE_SEL_SHIFT 0x0 /* ST Model Select shift */ +#define PCI_TPH_NO_ST_MODE 0x0 /* No ST Mode */ +#define PCI_TPH_INT_VEC_MODE 0x1 /* Interrupt Vector Mode */ +#define PCI_TPH_DEV_SPEC_MODE 0x2 /* Device Specific Mode */ +#define PCI_TPH_CTRL_REQ_EN_MASK 0x300 /* TPH Requester mask */ +#define PCI_TPH_CTRL_REQ_EN_SHIFT 8 /* TPH Requester shift */ +#define PCI_TPH_REQ_DISABLE 0x0 /* No TPH request allowed */ +#define PCI_TPH_REQ_TPH_ONLY 0x1 /* 8-bit TPH tags allowed */ +#define PCI_TPH_REQ_EXT_TPH 0x3 /* 16-bit TPH tags allowed */ + +#define PCI_TPH_ST_TABLE 0xc /* base of ST table */ /* Downstream Port Containment */ #define PCI_EXP_DPC_CAP 0x04 /* DPC Capability */ From patchwork Thu May 9 16:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659892 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2046.outbound.protection.outlook.com [40.107.101.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D0EB1708A0; Thu, 9 May 2024 16:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272107; cv=fail; b=ANsD5Lns5wYmXlneOgYmV1gbaEjUxVPcUodGfDkfUfU/yRyNQfOI0FwZmmjAE65it/hELsui58XTz44uhRI2Eru35GsGhfj9Wo2EMokDF0d4uyfWP2GYzBLqm2rmitPzQf84RMBlRUkGC0rS7F0NdoIKKJb7wnuiU5BFPn2GSmI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272107; c=relaxed/simple; bh=A+bdPvLNUU7dMpHEg5FyIyNIEF5XonOVfSM8fCRFpV8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mv75sLxHB5ZhDn/F6G2pecbImdpBVV/tXc1vSdesSCavB56l3d3hcH5dcDC/zDy3XUBTXLaJPoOZMCNAAyA0xPEsToBUqS/p5tMkFrdlFfczpp+4umk6vv+e70XnjxVVZlB7AHi9TS7nuOW9KTDgo9vtvjbKrfFsQCakgbadvVk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=089azERu; arc=fail smtp.client-ip=40.107.101.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="089azERu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVeyrpTpoU2iXTo+iefISr529t9NAN6gK8kzhVCpdBKY9jnb00mZ1GBjmSDzHNJ7ngH9zsRDbuWZQVuEY8q0QbiUIaWHPYVeM5NmEGdTDvmpkX5CQRh6+GETNZ+j4NOvSPGJeHzMp3eeKf32dku/04JScZGjmJUvdR0UMuktvwXI+BuoQo8VDUMb/e3t7OrvCvtH9eSLd23GlUKgitaG7qF0RxuBPwRk5qMbJWdoVqRlI7NWyWx2U9xsiiwvMnJZaGi9sf5bQYpMRANo+kwm856m6a6a7XrVTCr1jALs/kGPlFr4AGHLabAAJcxx6EY9g3ienC/CTAgjvcPMUNsUJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zmT34m7Qpw+VHXVkwStmijxFc0INyq4jf6m5bh6Loz0=; b=X7mnMn2qQZl0+yTzriIe1zwnXldNkwp08zRYOHmEdqvgacCKtpuxjQB2rgtx83eZ9uP+vjfOVfEo56GTX2vN9YDIncvkBIys9dLXXEdz8anL9CD+mPyxdGMHPfgP4vesWGkpQBDWNlQ61vOEsv+Qn3rNXIh1HEN1mhnr61s+t3kpAI53TaSH/2LTtjFsx9+mcSRU60axhbqpX2TK1aiILltmy5WyYZX3G2kiqj3pegk34uvQOgLGsl6wjm5by/0Q2TLVwTvm/PdfHsybDwqwXzAa+slVq+gERj4CPLWOr+xZjiTcpDJ2EpvHafJ7V0ZzER3TXFmxrlyx8yTieqOtMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zmT34m7Qpw+VHXVkwStmijxFc0INyq4jf6m5bh6Loz0=; b=089azERum71ZWllM+6jvQ/6WjrhBSlAIOV7nqFFWwwWvLMxMPznnNHGhuZNvNly85AfKDFwSKlkEOF2lqZFq8gUh4vKd+cqM3Irvia+J1ByfsRFSwg9ji+cYPznGPnGo8HCbjQl45Tw8q7Gs4CEdcIYgiGqwt2UCKKh4s61fNno= Received: from CH2PR16CA0029.namprd16.prod.outlook.com (2603:10b6:610:50::39) by SJ2PR12MB8956.namprd12.prod.outlook.com (2603:10b6:a03:53a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.46; Thu, 9 May 2024 16:28:21 +0000 Received: from CH3PEPF00000014.namprd21.prod.outlook.com (2603:10b6:610:50:cafe::b7) by CH2PR16CA0029.outlook.office365.com (2603:10b6:610:50::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48 via Frontend Transport; Thu, 9 May 2024 16:28:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000014.mail.protection.outlook.com (10.167.244.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:28:21 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:28:20 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 3/9] PCI/TPH: Implement a command line option to disable TPH Date: Thu, 9 May 2024 11:27:35 -0500 Message-ID: <20240509162741.1937586-4-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000014:EE_|SJ2PR12MB8956:EE_ X-MS-Office365-Filtering-Correlation-Id: b2d64f14-c08f-4281-056e-08dc70450ad4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|7416005|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: hAmE9KWOVvXiWfSntRoQVnr2XlHYOzVlRkS8c+zFMVu6TVVLPIIsBrYdZIY+odFrNYxyCPzHP90eHpFVmEkuYpQbLHzjKqQsCD7yJkhV/tov4pZfXgRGnoe0aiBsibb09abbt7N75xy+VWcpBH/mUFmsgLaWnIrICt/JGPPkYKF9iQmO1TqFhDpXvnuAhaKIwj8w2K3b7hm+Sd0bMWJuJmoEx9oOuEiaECwvTX8JIj0KMJ1b3YiAGEQDAdGMUm0yeZcie9vH08zO1Fjg0ZdtI6imJ0pSDoZCskDp7BOiY70crNf0bXuUo8LtbiZZ3WjmMTgftdvuo6itpNFGW5aMoi7/Hjc7QsLa7dSdDZSD2Er5RVuK0KiBmmC6t+WNimN5xZUdTMeEMM/66jFdOM+73jP1CDapbpjTB3iiywtK6yJUa8r3gPoUD5KAJVowC0ThvUC1b8o56JRJp8zljD4hXbVhUtT82qFnKOzZSMn+SbgESQcYuRHUCs6ertsqPZHN5cYks1UvuP/nKCl5bT7ZNZAVJA5Z7Ks6ilM9hN10oM6uY6XSEhBKwoUeUI4QLLPs065O8KTFCjY3IMfQpg26gUX0EtWTJ/K4kk2mE4o49lsb37r+oNG3rt4uKgXIBRgj/aXAEOFiJtolOW/oHbRhMw2s8SDEfdhZp63W7eH+jwO5e2V/kLUufdTm+kFjSVpDKNXnD8L2ixMpUV4WpmjIncplIhKjjhfzARIMBXD0QjmkMmeUWlna6sMWagi7I03ElfowJVqI2p2eKNXRpMEJUadle4NIRdfJYOKzjKgBpVKh/5ABYJ1ymoEY6Tz14zcqPOGMN9G9b3+TpD36RTOqYrVhKmXiSGl5Cq/t71duTZE/NA4H6sqvyNMG5qNECpAapZXdaWGIMhXnDNYLPLhI3k+1mzgn1hLSZ+6G61ONw4btMWXu4UXSa1z6bg8P2RIiLB3FaxI7lkK8MAnunerEnpMBi6M0TRTP5N7IKMaFI1IGZWZkLwB05Z/TqII0WnWq+Oc7Y5/lN0GTVDmtvYb5kpw7ukLR1Q/pyZH2Me2C45vdv1AdwcqqtFSs4PtvvHuDXTEuoYEzYbKLOxGB71eir9SecztjK9q8f9Wbpk0RfimMH4g3MRSd4PeAl0rOXUMXLByEhJSk2osJzSDX1UTECb4GrBW2NBfFhqX5g0NI68MrEdFhZSlUdYDBRYA6fWe2RvFuqDQMCdTsirU91a+XmKm0j351dIv5Xx8AUILqfxhR8No2HMyJWsywaWZPheg24TrZKAQwDdLHmiTprcEHwQRFIVwuCcraTPZdYIRhBZ6Z6OMj1ZJrY+gWd+K0Af98BuHbx4yInqw/BjPtVpthROREHuwOJPZSCnBPdQmAY8Fb3jpSLLCohTZwc2XFBPhu X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(7416005)(1800799015)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:28:21.5864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2d64f14-c08f-4281-056e-08dc70450ad4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000014.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8956 Provide a kernel option, with related helper functions, to completely disable TPH so that no TPH headers are generated. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Reviewed-by: Andy Gospodarek Signed-off-by: Wei Huang --- .../admin-guide/kernel-parameters.txt | 1 + drivers/pci/pci-driver.c | 7 ++++- drivers/pci/pci.c | 12 ++++++++ drivers/pci/pcie/tph.c | 30 +++++++++++++++++++ include/linux/pci-tph.h | 19 ++++++++++++ include/linux/pci.h | 1 + 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 include/linux/pci-tph.h diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 396137ee018d..5681600c6941 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4593,6 +4593,7 @@ nomio [S390] Do not use MIO instructions. norid [S390] ignore the RID field and force use of one PCI domain per PCI function + notph [PCIE] Do not use PCIe TPH pcie_aspm= [PCIE] Forcibly enable or ignore PCIe Active State Power Management. diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index af2996d0d17f..9722d070c0ca 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "pci.h" #include "pcie/portdrv.h" @@ -322,8 +323,12 @@ static long local_pci_probe(void *_ddi) pm_runtime_get_sync(dev); pci_dev->driver = pci_drv; rc = pci_drv->probe(pci_dev, ddi->id); - if (!rc) + if (!rc) { + if (pci_tph_disabled()) + pcie_tph_disable(pci_dev); + return rc; + } if (rc < 0) { pci_dev->driver = NULL; pm_runtime_put_sync(dev); diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e5f243dd4288..06f9656f95bf 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -157,6 +157,9 @@ static bool pcie_ari_disabled; /* If set, the PCIe ATS capability will not be used. */ static bool pcie_ats_disabled; +/* If set, the PCIe TPH capability will not be used. */ +static bool pcie_tph_disabled; + /* If set, the PCI config space of each device is printed during boot. */ bool pci_early_dump; @@ -166,6 +169,12 @@ bool pci_ats_disabled(void) } EXPORT_SYMBOL_GPL(pci_ats_disabled); +bool pci_tph_disabled(void) +{ + return pcie_tph_disabled; +} +EXPORT_SYMBOL_GPL(pci_tph_disabled); + /* Disable bridge_d3 for all PCIe ports */ static bool pci_bridge_d3_disable; /* Force bridge_d3 for all PCIe ports */ @@ -6707,6 +6716,9 @@ static int __init pci_setup(char *str) pci_no_domains(); } else if (!strncmp(str, "noari", 5)) { pcie_ari_disabled = true; + } else if (!strcmp(str, "notph")) { + pr_info("PCIe: TPH is disabled\n"); + pcie_tph_disabled = true; } else if (!strncmp(str, "cbiosize=", 9)) { pci_cardbus_io_size = memparse(str + 9, &str); } else if (!strncmp(str, "cbmemsize=", 10)) { diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 5f0cc06b74bb..5dc533b89a33 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -16,11 +16,41 @@ #include #include #include +#include #include #include #include "../pci.h" +static int tph_set_reg_field_u32(struct pci_dev *dev, u8 offset, u32 mask, + u8 shift, u32 field) +{ + u32 reg_val; + int ret; + + if (!dev->tph_cap) + return -EINVAL; + + ret = pci_read_config_dword(dev, dev->tph_cap + offset, ®_val); + if (ret) + return ret; + + reg_val &= ~mask; + reg_val |= (field << shift) & mask; + + ret = pci_write_config_dword(dev, dev->tph_cap + offset, reg_val); + + return ret; +} + +int pcie_tph_disable(struct pci_dev *dev) +{ + return tph_set_reg_field_u32(dev, PCI_TPH_CTRL, + PCI_TPH_CTRL_REQ_EN_MASK, + PCI_TPH_CTRL_REQ_EN_SHIFT, + PCI_TPH_REQ_DISABLE); +} + void pcie_tph_init(struct pci_dev *dev) { dev->tph_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_TPH); diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h new file mode 100644 index 000000000000..e187d7e89e8c --- /dev/null +++ b/include/linux/pci-tph.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * TPH (TLP Processing Hints) + * + * Copyright (C) 2024 Advanced Micro Devices, Inc. + * Eric Van Tassell + * Wei Huang + */ +#ifndef LINUX_PCI_TPH_H +#define LINUX_PCI_TPH_H + +#ifdef CONFIG_PCIE_TPH +int pcie_tph_disable(struct pci_dev *dev); +#else +static inline int pcie_tph_disable(struct pci_dev *dev) +{ return -EOPNOTSUPP; } +#endif + +#endif /* LINUX_PCI_TPH_H */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 73d92c7d2c5b..63aa6f888c90 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1866,6 +1866,7 @@ static inline bool pci_aer_available(void) { return false; } #endif bool pci_ats_disabled(void); +bool pci_tph_disabled(void); #ifdef CONFIG_PCIE_PTM int pci_enable_ptm(struct pci_dev *dev, u8 *granularity); From patchwork Thu May 9 16:27:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659893 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2076.outbound.protection.outlook.com [40.107.244.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F25F8170830; Thu, 9 May 2024 16:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272121; cv=fail; b=SRehp6RIrqXHJYdR4vN8c55Tm0dCDW880KdhTT6cPNhGUckMfkUEX4g9DQSH9hzVbNSHCr0nn1pUtYnp6QqLl/4sb8Il4d57onl22/j7xDKV9aLeNkzpyK2MZW4E0vs4znuriJ1m1/RMaUTyrDV/0cGSuacMHVZPSUPzQj/biis= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272121; c=relaxed/simple; bh=xmSMpvWySVctwj0QudWyRNlIRGEIJUyuRGvkfNrHbpw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rO3bEvLecw20lAIUCZypYd5nebk6M8zE/tnPh0xFN4TKVC7h8kKCQOQH28pOWioAd/xdvwVWbAShl1rsZiLRS6IQ+iv1x8ch3SqWqJBGNMyi+I/y4fyQjzBmLnZhZpMaUtBXk767uItWX684N0gEomdWdjeANtI6i7WXH7UtTBw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Xsbl9g7i; arc=fail smtp.client-ip=40.107.244.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Xsbl9g7i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=imuIE206vsJZxyOWYIItza3iPvSJNkCWqVTAt0PCya4QTgyVp3oeX+efMaEo/VisJy4bCisD+c/w3v2fI7vWZ8/fIr+pMji7B11DTwRp5Zv/X7iN40LcOC6SH4U9KtOA55xz3la55RYm2T47m+2BBMzBAvbhJklijVtoroXrLeRFIxXWg0bvL644uvD1AdzG9gdhrCDhHwZnpPjwylOvY1SUsrtWnBmlyI+HMp8mp+L+tyUiyM9X1qriQk847mgJKJB594rL4H64cznHN7e2mqGmhZEfqj7nv+TlUiWlaBrQHR+G5iHMOrp2CsH2Ht8734f/7N4UMU8eIX89yLagWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Dm53saFe7QZ9LV6828TvIprYLM5llR2/Lc6g0XkwWVg=; b=Ww7+XFt6EPN9j+2BkvmEk3RYDzLat7lemgYu85nENgmKFPF4wNrghZS42BAJGc7qGVfioKYIKSv241bRoUzSt6nFlu/iVTMr+zdCTMCIR7dkhxk9fZJgWxFjNQ92jQIFHKDVHi1/c9rLFWfifEUIjLDJVEipyNzoxwCvawhXYk4LIIgLfs6CSnCn6c6Jl5Ve35cqrWx4KAX77JXPtbyRRFjZfCyW36LYoDMU58Zrh5xlO+ojv8WHCbhKgd1QXxAb1KO+JbnXH4VPlxHzpM6/vBWDLVQr1FMEI7BVclWf7SzLH1bEGUyrO+rU46rNx6Ahox4gUQxOmG+dtVZBdeIMKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dm53saFe7QZ9LV6828TvIprYLM5llR2/Lc6g0XkwWVg=; b=Xsbl9g7imEep73MceYg3G0P8guYAIWUzdZhtuKtbC9gy+d+uA1lVWh9exgECp759fj6E7jLnOB2zlnHJcX/kt8Azh+l4GOkQSuL1A9y3JfTDSpzXoo5+EMxi1OQ9GC/lzLFKZy1QGYlqar8hLt8PTwdLoL+19QA+vkSuZ4e+2CA= Received: from CH0PR07CA0016.namprd07.prod.outlook.com (2603:10b6:610:32::21) by IA0PR12MB7673.namprd12.prod.outlook.com (2603:10b6:208:435::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.47; Thu, 9 May 2024 16:28:36 +0000 Received: from CH3PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:32:cafe::dc) by CH0PR07CA0016.outlook.office365.com (2603:10b6:610:32::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48 via Frontend Transport; Thu, 9 May 2024 16:28:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000017.mail.protection.outlook.com (10.167.244.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:28:35 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:28:34 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 4/9] PCI/TPH: Implement a command line option to force No ST Mode Date: Thu, 9 May 2024 11:27:36 -0500 Message-ID: <20240509162741.1937586-5-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000017:EE_|IA0PR12MB7673:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b5203a0-a0e7-4ea2-78c4-08dc7045131b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|376005|1800799015|7416005|82310400017; X-Microsoft-Antispam-Message-Info: JcWAGmEOzvIYRGzzqPuUw5xNLcoItVJp6HDTk8N7Mof4JoZ2ikY9x3w9voWW4nzryrdklhNpFhVIJhk5Wq0KGvgFUlI8Zcjfjie0Q5fM3FGFBtUWMZJJj16bXlPeLoPU1fBkYe4xd84cftLVgAedxxRxIYPRw/Zxa6JFg4TllQkFbjvL74j7BBIkEB/j/yF4jvOzkW694gKls8UKi8Nl0f6rBt992kxy7tpc7o3JXKgw1ztodACw/pFsA3d4o2qwzF95qiG7Smj9HcRSSc5MXRtq/hc37uMRfUNUgFIqRpoB35Qk3w+ME99/DCkOTGUT3pYWmGeJuFVkw5df/Tp3W32IjOu1jNYP5lclRd2jCvewDkvKTjUBRMIt6LqD1ob3uhaIwUEjUDBtunKDVfCH9gRRp2+SeUDGQCs3OFX9deafiUmKhYalHyJO/VW2M7yrXz6JuUO0e6gNqWB7d5C/pN1+0XD8JR5xeqS5C5JqrQFnLNNPj9qrT0tMdGP0JwwkKcejkUuBEhZM8Fz3pWWbDnItHz9Ad2Y/aZRZ8o1S6r7Dtbst2QqP/ooAiB5+DZcXM6drvYjypjZD3zzurvOqbeXChISlHZ696mjVtFV/IBbvj9YI1dcZiVcTFdbhsGp5LvjshUfxoxrEnnIJKH01b/Y4HnqXvc1NBmtpfe42AExKHkUQPJJCwnO84gPwpsoXbLolQC6BCu1cP/HkMYqW6ek07A22/8bdPVTQPcXgM1n7WOv6GVIt6bXN+7P5YiAoaJHV6TVi9s0TotPLwVlJzVNMXvUBx1nTiZXnV25uvbekwkyxpJvdKg3VqbMTng2pwa3SJ/iXSgU9gT1erVCJc37pL+YUtVVpOfJMv4PdcOgqCO1wAhzGZA0xzYY3iYgr7+VPGrgIH3cu3dKGgFE4qXRTpRXAktBYGInLS21PHqZSzW5bzbVQ5TA0zMswIcpQM+VB/Pzb2lbwbd7ajrcs+5GF/gk3XXWHj4g4AtHe3mCOOn3gETlZYh7zcKddz7yQ/sgp2puGrTY2lOemhcByeh2xM71ibgygnok2GFTZ7TIdpMi3pQNpWkgPGXOK+IU2bKcu6PqgwZItOJfXlLwOuik7aec1R97ZUuRjE5MrEybRUxmv6hpsgsMsKdjcZjzrK1w2FHhYZPPHRIvruUIWzvCQKhimV+HT++cZxY1NhX/HcaZ041HQkTDrPHcOvOpLPoL15zrpkQB3uzFHCSooewxkFVEvoh9sXlecZcWy6JkVwhtlBjxe642k7f6UxYlw88ruBg7/5urX1pF+a4uwxf6SWgAbQrOndqBUM51+Hdc1rQM+PJay4pRhfeFY6LI0sksC6ZoJMM79j71Pqxq9N5cHtJBacVzkjCEJX4ZIB4Bf7ldADQeishLlLp5RB0v9 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(376005)(1800799015)(7416005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:28:35.4764 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b5203a0-a0e7-4ea2-78c4-08dc7045131b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7673 When "No ST mode" is enabled, end-point devices can generate TPH headers but with all steering tags treated as zero. A steering tag of zero is interpreted as "using the default policy" by the root complex. This is essential to quantify the benefit of steering tags for some given workloads. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Reviewed-by: Andy Gospodarek Signed-off-by: Wei Huang --- .../admin-guide/kernel-parameters.txt | 1 + drivers/pci/pci-driver.c | 7 ++++++- drivers/pci/pci.c | 12 +++++++++++ drivers/pci/pcie/tph.c | 21 +++++++++++++++++++ include/linux/pci-tph.h | 3 +++ include/linux/pci.h | 1 + 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 5681600c6941..0adbbe291783 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4594,6 +4594,7 @@ norid [S390] ignore the RID field and force use of one PCI domain per PCI function notph [PCIE] Do not use PCIe TPH + nostmode [PCIE] Force TPH to use No ST Mode pcie_aspm= [PCIE] Forcibly enable or ignore PCIe Active State Power Management. diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 9722d070c0ca..aa98843d9884 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -324,8 +324,13 @@ static long local_pci_probe(void *_ddi) pci_dev->driver = pci_drv; rc = pci_drv->probe(pci_dev, ddi->id); if (!rc) { - if (pci_tph_disabled()) + if (pci_tph_disabled()) { pcie_tph_disable(pci_dev); + return rc; + } + + if (pci_tph_nostmode()) + tph_set_dev_nostmode(pci_dev); return rc; } diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 06f9656f95bf..ba9ec6f1b51e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -160,6 +160,9 @@ static bool pcie_ats_disabled; /* If set, the PCIe TPH capability will not be used. */ static bool pcie_tph_disabled; +/* If TPH is enabled, "No ST Mode" will be enforced. */ +static bool pcie_tph_nostmode; + /* If set, the PCI config space of each device is printed during boot. */ bool pci_early_dump; @@ -175,6 +178,12 @@ bool pci_tph_disabled(void) } EXPORT_SYMBOL_GPL(pci_tph_disabled); +bool pci_tph_nostmode(void) +{ + return pcie_tph_nostmode; +} +EXPORT_SYMBOL_GPL(pci_tph_nostmode); + /* Disable bridge_d3 for all PCIe ports */ static bool pci_bridge_d3_disable; /* Force bridge_d3 for all PCIe ports */ @@ -6719,6 +6728,9 @@ static int __init pci_setup(char *str) } else if (!strcmp(str, "notph")) { pr_info("PCIe: TPH is disabled\n"); pcie_tph_disabled = true; + } else if (!strcmp(str, "nostmode")) { + pr_info("PCIe: TPH No ST Mode is enabled\n"); + pcie_tph_nostmode = true; } else if (!strncmp(str, "cbiosize=", 9)) { pci_cardbus_io_size = memparse(str + 9, &str); } else if (!strncmp(str, "cbmemsize=", 10)) { diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 5dc533b89a33..d5f7309fdf52 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -43,6 +43,27 @@ static int tph_set_reg_field_u32(struct pci_dev *dev, u8 offset, u32 mask, return ret; } +int tph_set_dev_nostmode(struct pci_dev *dev) +{ + int ret; + + /* set ST Mode Select to "No ST Mode" */ + ret = tph_set_reg_field_u32(dev, PCI_TPH_CTRL, + PCI_TPH_CTRL_MODE_SEL_MASK, + PCI_TPH_CTRL_MODE_SEL_SHIFT, + PCI_TPH_NO_ST_MODE); + if (ret) + return ret; + + /* set "TPH Requester Enable" to "TPH only" */ + ret = tph_set_reg_field_u32(dev, PCI_TPH_CTRL, + PCI_TPH_CTRL_REQ_EN_MASK, + PCI_TPH_CTRL_REQ_EN_SHIFT, + PCI_TPH_REQ_TPH_ONLY); + + return ret; +} + int pcie_tph_disable(struct pci_dev *dev) { return tph_set_reg_field_u32(dev, PCI_TPH_CTRL, diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index e187d7e89e8c..95269afc8b7d 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -11,9 +11,12 @@ #ifdef CONFIG_PCIE_TPH int pcie_tph_disable(struct pci_dev *dev); +int tph_set_dev_nostmode(struct pci_dev *dev); #else static inline int pcie_tph_disable(struct pci_dev *dev) { return -EOPNOTSUPP; } +static inline int tph_set_dev_nostmode(struct pci_dev *dev) +{ return -EOPNOTSUPP; } #endif #endif /* LINUX_PCI_TPH_H */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 63aa6f888c90..6781a1bd28c5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1867,6 +1867,7 @@ static inline bool pci_aer_available(void) { return false; } bool pci_ats_disabled(void); bool pci_tph_disabled(void); +bool pci_tph_nostmode(void); #ifdef CONFIG_PCIE_PTM int pci_enable_ptm(struct pci_dev *dev, u8 *granularity); From patchwork Thu May 9 16:27:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659894 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2053.outbound.protection.outlook.com [40.107.93.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1C71171085; Thu, 9 May 2024 16:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272134; cv=fail; b=koWYJ0DNpdziiGUWRHV6FXV2QEJV3kBOKKAu/hdYZzO4vMPXYG7H/5sGlRoNZOn1suCLgoe+ODApo20k4Elq/Gn2CsQWU5t+qe5BNuC7WFXGh+JBpKU+7rS3EE56W9hm0YLC+sLUclfIcL3788H/jjp8aVZWZ2eJf5RN5hoyywM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272134; c=relaxed/simple; bh=QANFEGymyNpQUiaAGV4sD/tLR77mcAhBix6xshVksnk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hTrdnRJRM417QKxmGFFaOFz4x6qjGGieNIe+A7dsTi4kHa4gQ/ag0D99LVOG8E4JcCloSxgSG1rYqG6I0VKt/nPx57G6WmBPDlqUJxAVQ+W52d06j8pZbng5zFH84jbUSfA9oRk6Oma9Q8Dvh3bEqT3UmKjEVKVpoxtVKXOJGSY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=3+NieaQD; arc=fail smtp.client-ip=40.107.93.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="3+NieaQD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SOpgtS5t8sSDDvXJyywWW0SwO1MXzNqcSmp74IGbezBt0Gsk4hKhgjFu0UNsgNAfAoCjbezH3hc8bBq+MNjaauIqrZelddDMLU/2vq6OlXtYXWSxKYmKk4be4zwcalKCP5ZnW/DcQM4CGM3FirF3lr2xpR66H9CGynvfu2ikjMMjZ0cqCVGlaqprnVOhx9Lku9wr21jPFkZaC9tga+JCVXl1RMPGUcj56z6SamVZIcXfJ6/IgahDi9WchZsYv5p68RyblZOy4AzkzITCJlWdRkXf1VLtaXMEjdZEDfqGd3g1antPR5PySLOM4oQAYQ0wlXMavFjdyFieLxj2y44LPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2/cVdpr78IkToACdzs0G86EgxND+1os60xbsbZz+cgQ=; b=XGK7XrF0PDD/jQpyI7WCnwKIsV6j4W/YpyN9kFLDOxQc4tISCTRoKUI3esYcFBXnp1p8TJQQorS+SK5z3vKfpmU/FtmSAtpid5WP9aM4mmIszWAknS0nuSOUx0C+ANhz3i21/QTKzb0m8gCa/OAbgP8Pmpb9Rc5MqQAiHd02L3D+eNoLJCetdV6WJ7OY9fNvvJfhrKOCDw/Ij25udINF6Sn+sl7XlDZPmDNWatZblbQOvGZqJwZAJ4j35myn52kz68OgVRTa7hlR3zkJRG8jQ9ejegNBbvfAmP50QV6lFf6vVw57h7WCSsUkXpfJsptu/vhubwbrY6FZtHrS/yW6Mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2/cVdpr78IkToACdzs0G86EgxND+1os60xbsbZz+cgQ=; b=3+NieaQD4HSUf8vA9S3FVy7XTOZQLek2yZyBGo9/plhWwX9zBOi9LF8GMPCX+bBJ7bdYMPLD6fYK7AG2OsYHpR5b5PI5lbzGMqLYHCo9yoV/YktKbdhSVjOLPzEc8AvpL8z0mVSLiFenqSzyAnA/axbj/jabmY54n7YkslVbBCY= Received: from CH2PR16CA0014.namprd16.prod.outlook.com (2603:10b6:610:50::24) by MN0PR12MB5785.namprd12.prod.outlook.com (2603:10b6:208:374::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48; Thu, 9 May 2024 16:28:49 +0000 Received: from CH3PEPF00000012.namprd21.prod.outlook.com (2603:10b6:610:50:cafe::9b) by CH2PR16CA0014.outlook.office365.com (2603:10b6:610:50::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48 via Frontend Transport; Thu, 9 May 2024 16:28:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000012.mail.protection.outlook.com (10.167.244.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:28:49 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:28:48 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 5/9] PCI/TPH: Introduce API functions to get/set steering tags Date: Thu, 9 May 2024 11:27:37 -0500 Message-ID: <20240509162741.1937586-6-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000012:EE_|MN0PR12MB5785:EE_ X-MS-Office365-Filtering-Correlation-Id: 75be4544-1236-4d91-bda6-08dc70451b74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|1800799015|7416005|376005|36860700004; X-Microsoft-Antispam-Message-Info: kzK0A3mjo6A/xJVY8XPHaS+n+R7QPxAqlJqf8pZw3p8N112LHMv3LoyZ4ydpZ5DGfi4Ftv+dzyfgmgmxyW3QfDQCimzUtlGNgdKbu2VFjx+8u45cDw2rvChvDz5SmCSQ5bdLSAYAOSXSzGvkM3Q33cLoNh1VKspOMN8Fv1I32FmvxNTAvU4dYRqGShzhEPGIb7sAt+YGfhcYMkB52d0DRj4iLOAu+feNPiV4kmbH/YP1egtfzxnVeRYU2w2EvBACzTAhLS3T8hVZ7iv9tNsz9u4uhQdJ9eH1iRomOBQz983dmD58XVEAwgXuo9cvvlFYciwL8wzH88Xv/e+ROluLALn2tCvpNfugYyEmiFq6WrbyjKASagedXpRX5dVYWPfjC1XvMYIPIC+P20kAfrOyCB3fQLuWt4MlcFWC0eDE+p8AI9ehSS8U2gRS/hvzEyTolcNsL/A/+mAtFRwn5d+4dzQLdqHBfYssQrpc3Ex1UcfgypOG01ZuR3szva7b3H8sjmCUAYMpaeCtL2b8hqq9fXju+clewM3kPFyKQPF3P1NOJrtnfOKBVqlte1rZMbqzfnArs40dSaWOTDY9g80Prx7b5ikh7ZfCYGnOlIkMxgLLMh52AE2jV5Elnzfn6NGuoY+hm2jfDJIbepWn6HXKVpDQf0w06+clh1gPp74CUMwcehZBcFWTiniyL7B/fKNgdX+FijQZocDo93G6zJk6IOeKRvlcZMXUAO95YVtqt4AhiKolO9NHxfPBmMZCIxkNG1M2wAL03YJpQKNLco1Y0+aXtHyzxmj9ZV6qZoBwyK8nlIcVHLpS+O/J+cCoq/T2vKqV7ULpv7VN2/z94Q3lg2EZTNtrCtZxkUfKM8/ypzpCMUh13bnms8TODfpVPcNcl1WXavtrhNA77PuF1+lGeHkTjrztVo01GxWKt3PR4NQXN1IHRzBYSoN8U2apIK/bfPsmbe4YrMmt+Fs9AYWLTusoWZSp2sEnn9nGkBm+fVCd983yryYLcSFVPwFa5Ath8J6HjT9bkfhkLgAr6kAd8v4Aq0j/6bzXmc+jiXNlRc4ttt3/EjcbFDvM3EpWibCTrG7og7YgiOv6AmSzT/1A1tEnUZjh/PVOFypwy6j9IuD1NyM/9hUSNRnRxCXXdF7cCzzRvw16rK9/qiX905AuLeh0xDfbM/BD9JXqk0wGtUcgP9cWtzC8xP44bMdNE4G/tzs7iINShNOuz77HGyMDNqjtEnj+mNDwWgUYyoNkhIkB9XcJKTCq20JZnmXuNzxLLR819+MoxOQATmHE6KKL7wIk1ZfgGIoWtXRse+saW7ZEh9fkMaAAICbvisTTvs0d75ofj3JRy5I+P6vgzWneFTixz3Y8OHd7LRp2hkQV8pE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(1800799015)(7416005)(376005)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:28:49.4832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75be4544-1236-4d91-bda6-08dc70451b74 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000012.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5785 This patch introduces two API functions, pcie_tph_get_st() and pcie_tph_set_st(), for a driver to retrieve or configure device's steering tags. There are two possible locations for steering tag table and the code automatically figure out the right location to set the tags if pcie_tph_set_st() is called. Note the tag value is always zero currently and will be extended in the follow-up patches. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang --- drivers/pci/pcie/tph.c | 383 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-tph.h | 19 ++ 2 files changed, 402 insertions(+) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index d5f7309fdf52..50451a0a32ff 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -43,6 +43,336 @@ static int tph_set_reg_field_u32(struct pci_dev *dev, u8 offset, u32 mask, return ret; } +static int tph_get_reg_field_u32(struct pci_dev *dev, u8 offset, u32 mask, + u8 shift, u32 *field) +{ + u32 reg_val; + int ret; + + if (!dev->tph_cap) + return -EINVAL; + + ret = pci_read_config_dword(dev, dev->tph_cap + offset, ®_val); + if (ret) + return ret; + + *field = (reg_val & mask) >> shift; + + return 0; +} + +static int tph_get_table_size(struct pci_dev *dev, u16 *size_out) +{ + int ret; + u32 tmp; + + ret = tph_get_reg_field_u32(dev, PCI_TPH_CAP, + PCI_TPH_CAP_ST_MASK, + PCI_TPH_CAP_ST_SHIFT, &tmp); + + if (ret) + return ret; + + *size_out = (u16)tmp; + + return 0; +} + +/* + * For a given device, return a pointer to the MSI table entry at msi_index. + */ +static void __iomem *tph_msix_table_entry(struct pci_dev *dev, + __le16 msi_index) +{ + void *entry; + u16 tbl_sz; + int ret; + + ret = tph_get_table_size(dev, &tbl_sz); + if (ret || msi_index > tbl_sz) + return NULL; + + entry = dev->msix_base + msi_index * PCI_MSIX_ENTRY_SIZE; + + return entry; +} + +/* + * For a given device, return a pointer to the vector control register at + * offset 0xc of MSI table entry at msi_index. + */ +static void __iomem *tph_msix_vector_control(struct pci_dev *dev, + __le16 msi_index) +{ + void __iomem *vec_ctrl_addr = tph_msix_table_entry(dev, msi_index); + + if (vec_ctrl_addr) + vec_ctrl_addr += PCI_MSIX_ENTRY_VECTOR_CTRL; + + return vec_ctrl_addr; +} + +/* + * Translate from MSI-X interrupt index to struct msi_desc * + */ +static struct msi_desc *tph_msix_index_to_desc(struct pci_dev *dev, int index) +{ + struct msi_desc *entry; + + msi_lock_descs(&dev->dev); + msi_for_each_desc(entry, &dev->dev, MSI_DESC_ASSOCIATED) { + if (entry->msi_index == index) + return entry; + } + msi_unlock_descs(&dev->dev); + + return NULL; +} + +static bool tph_int_vec_mode_supported(struct pci_dev *dev) +{ + u32 mode = 0; + int ret; + + ret = tph_get_reg_field_u32(dev, PCI_TPH_CAP, + PCI_TPH_CAP_INT_VEC, + PCI_TPH_CAP_INT_VEC_SHIFT, &mode); + if (ret) + return false; + + return !!mode; +} + +static int tph_get_table_location(struct pci_dev *dev, u8 *loc_out) +{ + u32 loc; + int ret; + + ret = tph_get_reg_field_u32(dev, PCI_TPH_CAP, PCI_TPH_CAP_LOC_MASK, + PCI_TPH_CAP_LOC_SHIFT, &loc); + if (ret) + return ret; + + *loc_out = (u8)loc; + + return 0; +} + +static bool msix_nr_in_bounds(struct pci_dev *dev, int msix_nr) +{ + u16 tbl_sz; + + if (tph_get_table_size(dev, &tbl_sz)) + return false; + + return msix_nr <= tbl_sz; +} + +/* Return root port capability - 0 means none */ +static int get_root_port_completer_cap(struct pci_dev *dev) +{ + struct pci_dev *rp; + int ret; + int val; + + rp = pcie_find_root_port(dev); + if (!rp) { + pr_err("cannot find root port of %s\n", dev_name(&dev->dev)); + return 0; + } + + ret = pcie_capability_read_dword(rp, PCI_EXP_DEVCAP2, &val); + if (ret) { + pr_err("cannot read device capabilities 2 of %s\n", + dev_name(&dev->dev)); + return 0; + } + + val &= PCI_EXP_DEVCAP2_TPH_COMP; + + return val >> PCI_EXP_DEVCAP2_TPH_COMP_SHIFT; +} + +/* + * TPH device needs to be below a rootport with the TPH Completer and + * the completer must offer a compatible level of completer support to that + * requested by the device driver. + */ +static bool completer_support_ok(struct pci_dev *dev, u8 req) +{ + int rp_cap; + + rp_cap = get_root_port_completer_cap(dev); + + if (req > rp_cap) { + pr_err("root port lacks proper TPH completer capability\n"); + return false; + } + + return true; +} + +/* + * The PCI Specification version 5.0 requires the "No ST Mode" mode + * be supported by any compatible device. + */ +static bool no_st_mode_supported(struct pci_dev *dev) +{ + bool no_st; + int ret; + u32 tmp; + + ret = tph_get_reg_field_u32(dev, PCI_TPH_CAP, PCI_TPH_CAP_NO_ST, + PCI_TPH_CAP_NO_ST_SHIFT, &tmp); + if (ret) + return false; + + no_st = !!tmp; + + if (!no_st) { + pr_err("TPH devices must support no ST mode\n"); + return false; + } + + return true; +} + +static int tph_write_ctrl_reg(struct pci_dev *dev, u32 value) +{ + int ret; + + ret = tph_set_reg_field_u32(dev, PCI_TPH_CTRL, ~0L, 0, value); + + if (ret) + goto err_out; + + return 0; + +err_out: + /* minimizing possible harm by disabling TPH */ + pcie_tph_disable(dev); + return ret; +} + +/* Update the ST Mode Select field of the TPH Control Register */ +static int tph_set_ctrl_reg_mode_sel(struct pci_dev *dev, u8 st_mode) +{ + int ret; + u32 ctrl_reg; + + ret = tph_get_reg_field_u32(dev, PCI_TPH_CTRL, ~0L, 0, &ctrl_reg); + if (ret) + return ret; + + /* clear the mode select and enable fields */ + ctrl_reg &= ~(PCI_TPH_CTRL_MODE_SEL_MASK); + ctrl_reg |= ((u32)(st_mode << PCI_TPH_CTRL_MODE_SEL_SHIFT) & + PCI_TPH_CTRL_MODE_SEL_MASK); + + ret = tph_write_ctrl_reg(dev, ctrl_reg); + if (ret) + return ret; + + return 0; +} + +/* Write the steering tag to MSI-X vector control register */ +static void tph_write_tag_to_msix(struct pci_dev *dev, int msix_nr, u16 tag) +{ + u32 val; + void __iomem *vec_ctrl; + struct msi_desc *msi_desc; + + msi_desc = tph_msix_index_to_desc(dev, msix_nr); + if (!msi_desc) { + pr_err("MSI-X descriptor for #%d not found\n", msix_nr); + return; + } + + vec_ctrl = tph_msix_vector_control(dev, msi_desc->msi_index); + + val = readl(vec_ctrl); + val &= 0xffff; + val |= (tag << 16); + writel(val, vec_ctrl); + + /* read back to flush the update */ + val = readl(vec_ctrl); + msi_unlock_descs(&dev->dev); +} + +/* Update the TPH Requester Enable field of the TPH Control Register */ +static int tph_set_ctrl_reg_en(struct pci_dev *dev, u8 req_type) +{ + int ret; + u32 ctrl_reg; + + ret = tph_get_reg_field_u32(dev, PCI_TPH_CTRL, ~0L, 0, + &ctrl_reg); + if (ret) + return ret; + + /* clear the mode select and enable fields and set new values*/ + ctrl_reg &= ~(PCI_TPH_CTRL_REQ_EN_MASK); + ctrl_reg |= (((u32)req_type << PCI_TPH_CTRL_REQ_EN_SHIFT) & + PCI_TPH_CTRL_REQ_EN_MASK); + + ret = tph_write_ctrl_reg(dev, ctrl_reg); + if (ret) + return ret; + + return 0; +} + +static bool pcie_tph_write_st(struct pci_dev *dev, unsigned int msix_nr, + u8 req_type, u16 tag) +{ + int offset; + u8 loc; + int ret; + + /* setting ST isn't needed - not an error, just return true */ + if (!dev->tph_cap || pci_tph_disabled() || pci_tph_nostmode() || + !dev->msix_enabled || !tph_int_vec_mode_supported(dev)) + return true; + + /* setting ST is incorrect in the following cases - return error */ + if (!no_st_mode_supported(dev) || !msix_nr_in_bounds(dev, msix_nr) || + !completer_support_ok(dev, req_type)) + return false; + + /* + * disable TPH before updating the tag to avoid potential instability + * as cautioned about in the "ST Table Programming" of PCI-E spec + */ + pcie_tph_disable(dev); + + ret = tph_get_table_location(dev, &loc); + if (ret) + return false; + + switch (loc) { + case PCI_TPH_LOC_MSIX: + tph_write_tag_to_msix(dev, msix_nr, tag); + break; + case PCI_TPH_LOC_CAP: + offset = dev->tph_cap + PCI_TPH_ST_TABLE + + msix_nr * sizeof(u16); + pci_write_config_word(dev, offset, tag); + break; + default: + pr_err("unable to write steering tag for device %s\n", + dev_name(&dev->dev)); + return false; + } + + /* select interrupt vector mode */ + tph_set_ctrl_reg_mode_sel(dev, PCI_TPH_INT_VEC_MODE); + tph_set_ctrl_reg_en(dev, req_type); + + return true; +} + int tph_set_dev_nostmode(struct pci_dev *dev) { int ret; @@ -77,3 +407,56 @@ void pcie_tph_init(struct pci_dev *dev) dev->tph_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_TPH); } +/** + * pcie_tph_get_st() - Retrieve steering tag for a specific CPU + * @dev: pci device + * @cpu: the acpi cpu_uid. + * @mem_type: memory type (vram, nvram) + * @req_type: request type (disable, tph, extended tph) + * @tag: steering tag return value + * + * Return: + * true : success + * false: failed + */ +bool pcie_tph_get_st(struct pci_dev *dev, unsigned int cpu, + enum tph_mem_type mem_type, u8 req_type, + u16 *tag) +{ + *tag = 0; + + return true; +} + +/** + * pcie_tph_set_st() - Set steering tag in ST table entry + * @dev: pci device + * @msix_nr: ordinal number of msix interrupt. + * @cpu: the acpi cpu_uid. + * @mem_type: memory type (vram, nvram) + * @req_type: request type (disable, tph, extended tph) + * + * Return: + * true : success + * false: failed + */ +bool pcie_tph_set_st(struct pci_dev *dev, unsigned int msix_nr, + unsigned int cpu, enum tph_mem_type mem_type, + u8 req_type) +{ + u16 tag; + bool ret = true; + + ret = pcie_tph_get_st(dev, cpu, mem_type, req_type, &tag); + + if (!ret) + return false; + + pr_debug("%s: writing tag %d for msi-x intr %d (cpu: %d)\n", + __func__, tag, msix_nr, cpu); + + ret = pcie_tph_write_st(dev, msix_nr, req_type, tag); + + return ret; +} +EXPORT_SYMBOL(pcie_tph_set_st); diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index 95269afc8b7d..42ecd6192e69 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -9,14 +9,33 @@ #ifndef LINUX_PCI_TPH_H #define LINUX_PCI_TPH_H +enum tph_mem_type { + TPH_MEM_TYPE_VM, /* volatile memory type */ + TPH_MEM_TYPE_PM /* persistent memory type */ +}; + #ifdef CONFIG_PCIE_TPH int pcie_tph_disable(struct pci_dev *dev); int tph_set_dev_nostmode(struct pci_dev *dev); +bool pcie_tph_get_st(struct pci_dev *dev, unsigned int cpu, + enum tph_mem_type tag_type, u8 req_enable, + u16 *tag); +bool pcie_tph_set_st(struct pci_dev *dev, unsigned int msix_nr, + unsigned int cpu, enum tph_mem_type tag_type, + u8 req_enable); #else static inline int pcie_tph_disable(struct pci_dev *dev) { return -EOPNOTSUPP; } static inline int tph_set_dev_nostmode(struct pci_dev *dev) { return -EOPNOTSUPP; } +static inline bool pcie_tph_get_st(struct pci_dev *dev, unsigned int cpu, + enum tph_mem_type tag_type, u8 req_enable, + u16 *tag) +{ return false; } +static inline bool pcie_tph_set_st(struct pci_dev *dev, unsigned int msix_nr, + unsigned int cpu, enum tph_mem_type tag_type, + u8 req_enable) +{ return true; } #endif #endif /* LINUX_PCI_TPH_H */ From patchwork Thu May 9 16:27:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659895 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2052.outbound.protection.outlook.com [40.107.223.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0185917083F; Thu, 9 May 2024 16:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272148; cv=fail; b=bY4Oax4p2E9nrlXA4mTCCszrSdnt9ed7krJ7GKB+HHcw9/FR/MQ0NWFAmHXiNGI9Os/Z4wea+ULLbz494AOLDMxtyy+pf4BtN3pMDay9ejim1iAr/796TUHzdzllY0CE+vWo67h+puYg0IIaheM/+NduVqa20+XSqrWAz8eap6k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272148; c=relaxed/simple; bh=Yhc9s6uYSK9X4v0SINfVpHmcW2DTUb00++1j6VTrzxA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=odmoQVp9GABJ5sKgn1/1aAv1iG9f9OxvHa/2fE88UAFIb3Actr3FB5ilIwLH0ejExt7+iv1ZRCRfQY9c/x/0rgyD1IUByOW866R/gmpvom7OL2OdWE5/2BXq2GVl+U2F7L6tIs9fvpjtcJmYNUV1AXggblonb7RU7/hiC6tzQ1E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=rdCI5zbW; arc=fail smtp.client-ip=40.107.223.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="rdCI5zbW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g7wTiyLYhBlqBQZjekJtu3PYY6cT+pjHFeJ9XyBVqCQBRTHD/godQfcZP8lRC5nR9Q+gYbo36J7uB6WADiE6Sd3XzzX3toEilu/DecB1uiNWyWjlguM4PbRrFicCZh3qA5dWIpEwU6C1znIpb+mj3bEXcg/jVgM9jLsBxsmMo1pnH7lIDnQge/3xQeIH6zJMEy7dBvz00XPYG7xnNIV0wsYHWNg6LRmUnAkO0wUmTmm3NVQ4xScgQHzPT6DJKOIEQ/RvLRcR+uLeiYLxkRdgQ/+kpGwB3fvKCuxaksjGsfkyGWeNfBgLEBTreidnrl/y76dZ9WOihIo6OM2ro5SYXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T7nzZkBmis+PVS+pZs1aLLvIsReyfZCrD8K2qr9oL6Y=; b=CsD0P2Kz0dcHq1J7+jAxMU30T0EenhC1d4cNfxMe7KNTLjG5fouBudRv0Bbs5DAHuEl5w8hSVfaNHunbd8NH3d+KxSDDjq+QQgBch1I58tgn53e4DTCx2IDYDwb9uSRosWxLg0pTKvSGyXA7dn7eCoUBAapjsDqfdovtU/UD7GDMmCjyE7c2889+SnrjKNJAqsYGCqwHEayavgvxFOHlgLmdfQaM00a1SstiAd4W4NYhpc1VgE3T78MoLCuxc0RhBrSciSSc2TQYBh7xBN85JU5iM4A+DSyllgmNuWDXB/jjyiOB2MxYyaCiQAraH1FnXWlT1WlCqxPSRfVA7/wNGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T7nzZkBmis+PVS+pZs1aLLvIsReyfZCrD8K2qr9oL6Y=; b=rdCI5zbWqCNoNENSNJzfhp8I6xyOQtVxHGFTZjyhA43HEAWhuSyyDVGO9Yug/WMklmnomJwt1myFm/wmxBYgivm3pdcbpKg+Ohi3I20d8Xfva0KTf7+V2EX0b0bifTlLbIKCWM7qlDb4nGTURveMbD/XErviR1LEnnq0bvp1cLU= Received: from CH0PR13CA0044.namprd13.prod.outlook.com (2603:10b6:610:b2::19) by IA1PR12MB7517.namprd12.prod.outlook.com (2603:10b6:208:41a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48; Thu, 9 May 2024 16:29:03 +0000 Received: from CH3PEPF00000018.namprd21.prod.outlook.com (2603:10b6:610:b2:cafe::d7) by CH0PR13CA0044.outlook.office365.com (2603:10b6:610:b2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.13 via Frontend Transport; Thu, 9 May 2024 16:29:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000018.mail.protection.outlook.com (10.167.244.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:29:03 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:29:02 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 6/9] PCI/TPH: Retrieve steering tag from ACPI _DSM Date: Thu, 9 May 2024 11:27:38 -0500 Message-ID: <20240509162741.1937586-7-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000018:EE_|IA1PR12MB7517:EE_ X-MS-Office365-Filtering-Correlation-Id: 808542cd-1255-4daf-ed67-08dc704523d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|376005|7416005|82310400017; X-Microsoft-Antispam-Message-Info: eSeLZ9ncmOVcjwY7tiElJr4v+LnuZFJKgy/BJk/0rfg7PqO1X6gjoEBqepUquZp2WPwrzV6I6p84i/x2WM/gNvtGJPv7zJXcGSX/yL67SFgzEBov+X8+xByeOK2sa1+c9q8GXoJCISLfdhmieoqoP0JgQ8CotcvLW1UlUX3+OQKzhlNFlV2Wqds3nQlUp7wqh2ChefxtOSEWzcRkQjJ96otqYIvd2wF7MqcDMol4v1rL8re/yn6KN46uv/4SUcs7S6fxg1Wed33QKFkDcyt0mnmYNOCk3eQ5Ecm8aI4a+4pYQyTvYWCum76Z77BKJFN17il2hsZcLie/zPLHMzhnhFaxIPCXRMVdVs/nZiDfh4xU2tb11Cf2wxgS/uRF5CSoPYYbkhLHU9mixJBqDNIiGt/rw6LqCQjvd7eozQLAed+6TrkIGNKUQskCvcwZtr8ytPCuHJMhvFjShbJmoQY+dVChPz+lZIYALj8naP5Hd0Sv+3i+ecIAxfi7wSsncOg7gLpuxRyBLOaHpxO98zRj4iTJxtzRoAZjujCzir81i3a72ppRF3U6nboOj/cdBRVSUh7s6o5oBYufSeHDTBZW5auNQjcB9keBE1rv7BlQbgX5VMIKcG/nW53/6DNMVJg6JfRKLLexo4j7hItPPVmi60iqLWprRHLW8KpKyZzAQ2dNAzmnyvXdWTsWpilimHdzbkYbakaf+R/E0SQSbQOFPUPQo7YOk1p1Ly6rvIJCRh8lEkC1WXMcBtt+tCi6t1TSEnEBB8sVfSVD0Y8Adpr1q2+/HTH/LJ/fi+2UbJ4XRQFKNeFHITZEqLGH1k4oQJjsFtMpMfh3bwpDE/HFWMElQzOBS+YU7KB271DCrCxCuJ9fihzyzdAnv1Vnilm+ikqobhWeFxZJjo5ss+K3UJDMWwxs8F7CBeatTAYC5aVBwnnxQSIFS3nRxiLYLPHrEaWsXaMyyya/JzYRZVvr1l14fhPvZgHhwiiLtbSFFSzKnmOY+3SagYQdOLhfN3oh2K2p13DkRX5u/DnAvHAI6JlNZhhJawMiHJPoyqHIMAFs7OsfV7g5R9b5HPOlbe1d2h/Fi8lzFy4oqK/hQ7KCBMPU99su2/D1Ehj3BXLEiukjCQnQvGEpiqnzQpM5PLGGetq2b1s3kjDrYSK/s7mEZ83ahIWdUUGuT4QISRSS6rZjR/FiZlyyyX+Ke1zBX89Nne63yeTKV+IUuPH2PeNp9B5c5bCGIV02uX8oR2PL8z4NTCy34usWcZcm3+4VgcD0McJVNRv+n+WtiZottzJbJuFAL6yP0rR/pobFOH8PulIhHQNxesaZNyQ6BO7/zM0np4aR X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(376005)(7416005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:29:03.5157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 808542cd-1255-4daf-ed67-08dc704523d1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000018.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7517 According to PCI SIG ECN, calling the _DSM firmware method for a given CPU_UID returns the steering tags for different types of memory (volatile, non-volatile). These tags are supposed to be used in ST table entry for optimal results. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Reviewed-by: Andy Gospodarek Signed-off-by: Wei Huang --- drivers/pci/pcie/tph.c | 103 +++++++++++++++++++++++++++++++++++++++- include/linux/pci-tph.h | 34 +++++++++++++ 2 files changed, 136 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 50451a0a32ff..b9d61e1cfd88 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -158,6 +158,98 @@ static int tph_get_table_location(struct pci_dev *dev, u8 *loc_out) return 0; } +static u16 tph_extract_tag(enum tph_mem_type mem_type, u8 req_type, + union st_info *st_tag) +{ + switch (req_type) { + case PCI_TPH_REQ_TPH_ONLY: /* 8 bit tags */ + switch (mem_type) { + case TPH_MEM_TYPE_VM: + if (st_tag->vm_st_valid) + return st_tag->vm_st; + break; + case TPH_MEM_TYPE_PM: + if (st_tag->pm_st_valid) + return st_tag->pm_st; + break; + } + break; + case PCI_TPH_REQ_EXT_TPH: /* 16 bit tags */ + switch (mem_type) { + case TPH_MEM_TYPE_VM: + if (st_tag->vm_xst_valid) + return st_tag->vm_xst; + break; + case TPH_MEM_TYPE_PM: + if (st_tag->pm_xst_valid) + return st_tag->pm_xst; + break; + } + break; + default: + pr_err("invalid steering tag in ACPI _DSM\n"); + return 0; + } + + return 0; +} + +#define MIN_ST_DSM_REV 7 +#define ST_DSM_FUNC_INDEX 0xf +static bool invoke_dsm(acpi_handle handle, u32 cpu_uid, u8 ph, + u8 target_type, bool cache_ref_valid, + u64 cache_ref, union st_info *st_out) +{ + union acpi_object in_obj, in_buf[3], *out_obj; + + in_buf[0].integer.type = ACPI_TYPE_INTEGER; + in_buf[0].integer.value = 0; /* 0 => processor cache steering tags */ + + in_buf[1].integer.type = ACPI_TYPE_INTEGER; + in_buf[1].integer.value = cpu_uid; + + in_buf[2].integer.type = ACPI_TYPE_INTEGER; + in_buf[2].integer.value = ph & 3; + in_buf[2].integer.value |= (target_type & 1) << 2; + in_buf[2].integer.value |= (cache_ref_valid & 1) << 3; + in_buf[2].integer.value |= (cache_ref << 32); + + in_obj.type = ACPI_TYPE_PACKAGE; + in_obj.package.count = ARRAY_SIZE(in_buf); + in_obj.package.elements = in_buf; + + out_obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, MIN_ST_DSM_REV, + ST_DSM_FUNC_INDEX, &in_obj); + + if (!out_obj) + return false; + + if (out_obj->type != ACPI_TYPE_BUFFER) { + pr_err("invalid return type %d from TPH _DSM\n", + out_obj->type); + ACPI_FREE(out_obj); + return false; + } + + st_out->value = *((u64 *)(out_obj->buffer.pointer)); + + ACPI_FREE(out_obj); + + return true; +} + +static acpi_handle root_complex_acpi_handle(struct pci_dev *dev) +{ + struct pci_dev *root_port; + + root_port = pcie_find_root_port(dev); + + if (!root_port || !root_port->bus || !root_port->bus->bridge) + return NULL; + + return ACPI_HANDLE(root_port->bus->bridge); +} + static bool msix_nr_in_bounds(struct pci_dev *dev, int msix_nr) { u16 tbl_sz; @@ -423,7 +515,16 @@ bool pcie_tph_get_st(struct pci_dev *dev, unsigned int cpu, enum tph_mem_type mem_type, u8 req_type, u16 *tag) { - *tag = 0; + union st_info info; + + if (!invoke_dsm(root_complex_acpi_handle(dev), cpu, 0, 0, false, 0, + &info)) { + *tag = 0; + return false; + } + + *tag = tph_extract_tag(mem_type, req_type, &info); + pr_debug("%s: cpu=%d tag=%d\n", __func__, cpu, *tag); return true; } diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index 42ecd6192e69..ed5299a831cb 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -14,6 +14,40 @@ enum tph_mem_type { TPH_MEM_TYPE_PM /* persistent memory type */ }; +/* + * The st_info struct defines the steering tag returned by the firmware _DSM + * method defined in PCI SIG ECN. The specification is available at: + * https://members.pcisig.com/wg/PCI-SIG/document/15470. + + * @vm_st_valid: 8 bit tag for volatile memory is valid + * @vm_xst_valid: 16 bit tag for volatile memory is valid + * @vm_ignore: 1 => was and will be ignored, 0 => ph should be supplied + * @vm_st: 8 bit steering tag for volatile mem + * @vm_xst: 16 bit steering tag for volatile mem + * @pm_st_valid: 8 bit tag for persistent memory is valid + * @pm_xst_valid: 16 bit tag for persistent memory is valid + * @pm_ignore: 1 => was and will be ignore, 0 => ph should be supplied + * @pm_st: 8 bit steering tag for persistent mem + * @pm_xst: 16 bit steering tag for persistent mem + */ +union st_info { + struct { + u64 vm_st_valid:1, + vm_xst_valid:1, + vm_ph_ignore:1, + rsvd1:5, + vm_st:8, + vm_xst:16, + pm_st_valid:1, + pm_xst_valid:1, + pm_ph_ignore:1, + rsvd2:5, + pm_st:8, + pm_xst:16; + }; + u64 value; +}; + #ifdef CONFIG_PCIE_TPH int pcie_tph_disable(struct pci_dev *dev); int tph_set_dev_nostmode(struct pci_dev *dev); From patchwork Thu May 9 16:27:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659896 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2060.outbound.protection.outlook.com [40.107.236.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2826171E41; Thu, 9 May 2024 16:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272160; cv=fail; b=DmMke7bjnysFQL4X6LnXbyRkNRAvxO9IwOzUpX/mq6TDdM+PLWA+tZXRDYO242hfdl/5Wl/odFuvJXlrHEdYRxe1Oij6269AvON4vRRQAGI/U2xVoFDeJixUE/OVOGGqTAx8UsS8WM5gLWgg/tPqJPxAleup1rYUwzqOrTCdoFs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272160; c=relaxed/simple; bh=YjLA+MbfUwCiqqWE3wLmFU1uonFtQNQ1c5U5WHkctqg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eBuYrODJPJEwdPu6mcO0g5zi/eY/rNwasfgbilvwz9HAZU/ajxOr2pyzcSgBOKusbn/ONsgGMaRx76bDnjXqM1ArDlXub6XhTZwm1YbOJcE4Kb05VI3YLFQroVU8nIGo3PNUTJtlHOHZcqfoYniLm3Vaq7wHWo3Fbu2Czm0iFbY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=D0w3pt4N; arc=fail smtp.client-ip=40.107.236.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="D0w3pt4N" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RaPlTbLJ91Qg3GOdZz/mHyolK7GsdahJKVnPxK2Vwxo53dReUIhjIMMESxRJ7iRA1RxNpO1cJ4IyIjboH1Hpf6IwwfBaxGTQ0EkAKxLdAhxc61KJ0g9jE8B2MuDKEI25nswF3uATyktSp0pUq6l1//f+kLIdaYFwnYne4glj43Sh6NxvVam4vJW1JIVwc8MQcIGJy7qU9HfzifRe3MS7YhCR68prl4/Zvbl+7UHgJSqMYAckspiweGOFIKIbZpPgCyN9a0GFMTLr8ZH5xa06z8JZ1Y6AIgYOxT0nxpX3g2etNknZyNlwPyDaZoCoL4okCYf7O0HM2CmrIVzSxOZ9pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oZz7uU7dVhO+zDM0ufsEL8QMSXOoZXkxpNkAdKIcX6s=; b=KGQ71zdU/++PBuOU9qoR60rW9+PMSkCMsdwFLKi7sqZhmOIAAn12gVnvxlaR+9Ub1gaSbvDXEDKq5GcTYEoyYX+iQgsr91/6V6V3cIepUy2P1KaBzPAcYTi12vrZ8cDe/9B87oL/dew0M/Cqg9Z1QTen2Ub4WptEoW2HbPPbmPCavSG/bDVJQKDEMfiH7Y2j3szzATmjGN2W6EaHAhT5uoRO3hJaUpHhCGtEkvsm/hRMCDwtGxZu8SYomf/cEHmEfZRZkzq6cEzyL1SnPqxoEC3tn7R9zrHqW6Tbllseg2jSTKiY6GLcQ4l/1Qt7vy7v5IBVADjkFkiVf3uQupqbAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oZz7uU7dVhO+zDM0ufsEL8QMSXOoZXkxpNkAdKIcX6s=; b=D0w3pt4N6xOeWAZu98oJTr3j8IVgljK2AzK3Pn1ll70uet1rz4O9k9ogjAhWkIfqZv8yccxApMUb6PBS7Y+Sb5wlVcsfxLIOhNEYRV0i5Eu/UfRXPYwnEMBy7Ln/xa6m4bXtnmbC3qsen0pm2an7Txxe26rVdDC6x2oVupsUFMg= Received: from CH2PR16CA0019.namprd16.prod.outlook.com (2603:10b6:610:50::29) by PH7PR12MB5877.namprd12.prod.outlook.com (2603:10b6:510:1d5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.46; Thu, 9 May 2024 16:29:15 +0000 Received: from CH3PEPF00000012.namprd21.prod.outlook.com (2603:10b6:610:50::4) by CH2PR16CA0019.outlook.office365.com (2603:10b6:610:50::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.45 via Frontend Transport; Thu, 9 May 2024 16:29:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000012.mail.protection.outlook.com (10.167.244.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:29:14 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:29:13 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 7/9] PCI/TPH: Add TPH documentation Date: Thu, 9 May 2024 11:27:39 -0500 Message-ID: <20240509162741.1937586-8-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000012:EE_|PH7PR12MB5877:EE_ X-MS-Office365-Filtering-Correlation-Id: e2364dce-00cd-40c6-0350-08dc70452a78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|82310400017|7416005|376005; X-Microsoft-Antispam-Message-Info: Dub8cUhe4RydH7eVov43/uV/NoEw1EmiOwjfzEky5/twtsWLMO9SA/YEfd/I6kgxcd6G/JnCBd5VwUD1yfOKrIyzY7LfMLRrZwZdFI8SrZzUHqeccoySj3oAsPFdRe3oot5fRPV9ZC7hokvzMmowaix5sFnpnperRKvuAFWPbCtXj9NTLjlyTuK6ZvplTzzxc1UpGmpzEBqL96SISXYzP3wzQzUOYllLoaSL0pCqK9Kglu04lcLatguxM/CheCjkC0yx51w9w5UC1DITVSt1zG1sXQbM5MXmLzjiJK8nykzvYqN7jcJdD3F7xZt4f+cB7Xo0tMUqkCQXzmbxgqcH8QfZR+PK0Hepz+u//2bUYTR1m3UBpC23chg9LZNj0gWoc4AdRepZtr8VsstHG0BgR0J6Qc6BXGecaJ/HQyAnFCriAQZ2UQ0T1M5363/9dnVWYLLM9oxq35Wgp9ysuO8mMIQwUBWuF7Yn7ypthEA0YleZeRFiakyv0PRs3swQUvvAaF1Nvj40BONj1vPO1s4XW01XBK/hZhF+u87T8B6Pz25paPslvRwf0nJ8QKW9fKD6e3ULPlyUERB5SD1xqguvGoHljtokuAy/XiJ9etibXhWH68A+TzICL9JVKhNQBkz9IBtJkxuhJsXhwcBHl/LaMK9IUOmUSIx7PZjiwFewZAwF/co+CkrI54eUS8YSKbE/nuxNSudU3XYPgaCaDhK3m6iKxUOhe1EeBj3n8o4ZEDmjan1FAmwy3oJmce4+YB1RLk1aW81IQtJ636FBXkq4LGM/DML7LUWtsqtGzyzRmmTJf8zPQX7SCHiWwl7eY5n4JpeQkto9r+LIggfRIB1nwCT7JT5yG8ZYSQscdqic6WUzqW/NfSUZvicdYILN/WsAvDu3P7H09zcKzK2kJ++Hexppokl7dHmImpqybe2jziZzcCwGZwDLWvG39ZxTexq+rbq9kYLXAC3WmZ46cI6V7PA1AOmRhKHhsIiWpd0o21n1v3pGJkQDcEdckmylMvkYvIwM7Hybj72lrmGDceJvoFthFmyW6idmn0cmSrg051NW/Uo1A4JHNRYFboE0E+STSrB6S9cqGysZlU+0YOPYwExnqRXq/dT50kSNzRUZ/B7BPUeb3Nzp6TkrU5VRi0TkW6kB0VSnGE9n4KkfuFCeBuAZJXp01JEXwrL3Zssr6es6DnP3Njxo7ihzOY6NOZ9Ojp74rWWLqs/L3sRVa2e1UIWxNvkJtZUWGXzGWTI9WMEotNON5vbVkjHOo1YCub8cf7i+FzNkeOFt/XNr9aLe021BjHAkXZHsbFJfza7Q8uwQ3RBTRuE/ZRFLs8CdE1Pu4HcITG7fcl1gQXiyIl+uigZEnsF2wjhOXkO2IhCe+nP7G8aMPkkKVqz4OFqGbAqV X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(82310400017)(7416005)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:29:14.6236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2364dce-00cd-40c6-0350-08dc70452a78 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000012.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5877 Provide a document for TPH feature, including the description of kernel options and driver API interface. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Reviewed-by: Andy Gospodarek Signed-off-by: Wei Huang --- Documentation/PCI/index.rst | 1 + Documentation/PCI/tph.rst | 57 ++++++++++++++++++++++++++++ Documentation/driver-api/pci/pci.rst | 3 ++ 3 files changed, 61 insertions(+) create mode 100644 Documentation/PCI/tph.rst diff --git a/Documentation/PCI/index.rst b/Documentation/PCI/index.rst index e73f84aebde3..5e7c4e6e726b 100644 --- a/Documentation/PCI/index.rst +++ b/Documentation/PCI/index.rst @@ -18,3 +18,4 @@ PCI Bus Subsystem pcieaer-howto endpoint/index boot-interrupts + tph diff --git a/Documentation/PCI/tph.rst b/Documentation/PCI/tph.rst new file mode 100644 index 000000000000..ea9c8313f3e4 --- /dev/null +++ b/Documentation/PCI/tph.rst @@ -0,0 +1,57 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=========== +TPH Support +=========== + + +:Copyright: |copy| 2024 Advanced Micro Devices, Inc. +:Authors: - Eric van Tassell + - Wei Huang + +Overview +======== +TPH (TLP Processing Hints) is a PCIe feature that allows endpoint devices +to provide optimization hints, such as desired caching behavior, for +requests that target memory space. These hints, in a format called steering +tags, are provided in the requester's TLP headers and can empower the system +hardware, including the Root Complex, to optimize the utilization of platform +resources for the requests. + +User Guide +========== + +Kernel Options +-------------- +There are two kernel command line options available to control TPH feature + + * "notph": TPH will be disabled for all endpoint devices. + * "nostmode": TPH will be enabled but the ST Mode will be forced to "No ST Mode". + +Device Driver API +----------------- +In brief, an endpoint device driver using the TPH interface to configure +Interrupt Vector Mode will call pcie_tph_set_st() when setting up MSI-X +interrupts as shown below: + +.. code-block:: c + + for (i = 0, j = 0; i < nr_rings; i++) { + ... + rc = request_irq(irq->vector, irq->handler, flags, irq->name, NULL); + ... + if (!pcie_tph_set_st(pdev, i, cpumask_first(irq->cpu_mask), + TPH_MEM_TYPE_VM, PCI_TPH_REQ_TPH_ONLY)) + pr_err("Error in configuring steering tag\n"); + ... + } + +If a device only supports TPH vendor specific mode, its driver can call +pcie_tph_get_st() to retrieve the steering tag for a specific CPU and uses +the tag to control TPH behavior. + +.. kernel-doc:: drivers/pci/pcie/tph.c + :export: + +.. kernel-doc:: drivers/pci/pcie/tph.c + :identifiers: pcie_tph_set_st diff --git a/Documentation/driver-api/pci/pci.rst b/Documentation/driver-api/pci/pci.rst index aa40b1cc243b..3d896b2cf16e 100644 --- a/Documentation/driver-api/pci/pci.rst +++ b/Documentation/driver-api/pci/pci.rst @@ -46,6 +46,9 @@ PCI Support Library .. kernel-doc:: drivers/pci/pci-sysfs.c :internal: +.. kernel-doc:: drivers/pci/pcie/tph.c + :export: + PCI Hotplug Support Library --------------------------- From patchwork Thu May 9 16:27:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659897 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7427414B097; Thu, 9 May 2024 16:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272176; cv=fail; b=e6zyrIrM9pFcfvfHtzJ6O6pR/QmOm96z3SPC8Lv9qAtPtJWak1cbi7bEGN/Ekg0FWYsFXjRlnTj6AjM6AYoPDV1HgKClFbbQGUFktYbRutlKFpNCuSIWbwt8DURWgni4JjIn/QTX0AuS6nDHsObLnd9gVudSdb3PK3bui1s0sTk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272176; c=relaxed/simple; bh=Ha514QROtKdlMtS0+TefLRII82zy23bFfJakZLMVS+c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bn4JwKXFO5mqUHx28LP0AtJL6RQsW2ZA1GMu0LYGuZQse749SD+3WnCcmPzHgcb6IbT/w31f0GABhpDt0OWe2k33hJ6EXTpAMcZOsLRu/aPixstw0un+E4ygI7sxAGCHTWV5QnCUkxUKUlnh0QpWNw/CjDOFy42a9g1Jiw/DPcY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Kc8M/8KD; arc=fail smtp.client-ip=40.107.94.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Kc8M/8KD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gg0LYIzlrkncKNC+wg/PdM51eWEGIty9A4Z5CVF9+efX6k9/9s/dnOyBVt54GS6aB3gwdYI6nS5FWcwdNKjPW9B+JtKXzk7+6dSE+CteLNVCP94jIxnW9sjQDe7Bj/1TjiPWdahd8XdJWmlXp7BPz+1TR/LBzkn+NHURXHV0ZiIfiWzBf96kvBh4QiLLd3agiIaPWFQplMHg8rbEYSlHYKDkBGlwmBS1OJdN6znadFKOyhPOsC4bGQGud8OwOVZ5PmTUUSDppEfsdVd/vbnKCUI+JGZQM7wMnHS9hNVf7fCQ1xAultoZLpZz7MV1lnKSWq9pqXw9oU/xvQpUsXIFDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KoeapxQV/SXRV8ErW6IRaRhOI6nkWb2RIxsMSWcdyFw=; b=TU7MwISbmTB8KMq4CmNSMWjmNIrTGEicXMhhfZSwCzMR0bBLhL3u2InrjhO8hICG0tGH29W5JyEkbrY2CE0uwFeyU3Djaqww62zCq7sDUFCO4Czc0fQNatdiWg08lhadpmUAUL826BqxQu0MFHliZbsuXyUNk6h74QvSMwlw0mBC1pGRfGYY233xg9eT1/Sz0lwK1N1lBJONu+QRAzytY521s/oz3HBpfn0SK/7VWKDMzbAl2lWUihwQZYNunxVOGX0mggnw45IhEfnGJhmNUOkc+R3uRv5cakaGoB4Q3TifoWwJnFgNwy7X3e+NzOaarEKRICpp2dlzxJQEuUVLGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KoeapxQV/SXRV8ErW6IRaRhOI6nkWb2RIxsMSWcdyFw=; b=Kc8M/8KDYM5Hg2JZ3zYCMlhWAW82LysV66Lobp/lhiD9u6sFvqJNKkUmTp7gPqSC/lLu+FwGzc+XL0uxe3VnTbuLr75Brrd0KlgMrYx3tsUJRVlQyFSXGofqY2WhFPcyOlzg3X6yjjnBY4iC/BTX2M+/vD/1Sn85hPyO2LRadqk= Received: from CH0PR13CA0034.namprd13.prod.outlook.com (2603:10b6:610:b2::9) by IA0PR12MB8748.namprd12.prod.outlook.com (2603:10b6:208:482::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41; Thu, 9 May 2024 16:29:29 +0000 Received: from CH3PEPF00000018.namprd21.prod.outlook.com (2603:10b6:610:b2:cafe::d5) by CH0PR13CA0034.outlook.office365.com (2603:10b6:610:b2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.13 via Frontend Transport; Thu, 9 May 2024 16:29:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000018.mail.protection.outlook.com (10.167.244.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:29:25 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:29:24 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 8/9] bnxt_en: Add TPH support in BNXT driver Date: Thu, 9 May 2024 11:27:40 -0500 Message-ID: <20240509162741.1937586-9-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000018:EE_|IA0PR12MB8748:EE_ X-MS-Office365-Filtering-Correlation-Id: 167b7c77-fa97-47d5-73d8-08dc70453117 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400017|7416005|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: dShViuThvXNzdOQEHpjPiL0yIX9TbvxCAZgtlaaiUMLf7cfelZIjU4Pgpn0n7CAmy4orOOwfxSaULPuuHlrlC5cbCRcXY6Sd8njA7ol1hNShT6JgoCX+yGCptS2SArtyjnr2pcm7LrkwBTORwB3UcmKp4dYn/x0/uMSD3++E009iZJJnOH+on6FQtgG/Dg+N73uOU8Wxcs/ExnFzJw+xkaphB6YZTiIQqKJjTxfhL5NMQvj5MgeDAEb2XkqJZBhCCrVzHlvuX+cGGjVmrYW3sNLI1sa/ridQJi7pdsfNpLbKS0l/9bIBclyKHsj9ykVOWv0+nAT/gzbMRtWJLnMmR3Nr2VMggzZ+QALLS8Eh7B4k/+93O5aWNZoP0Vs+Nw89N/6WgozTrEmcsF/yaxBAzIORBPwRqhTBKtDcgvAyn0yp295SxIzgke11QuMIddgRlDlEQQC43JHw1WD2xit1cPd1Wi2f72fOGL4zBs+NiQhjue0BBHYB4FYCOrigf9+BCRNojs4eMAr3jRj5a+iVGWdWZt0SzCn80V8lOQ9uboRiR1j1qBIfGiatfxg5lVwrJpfrMYLoBT26lbYkLhnTm428TNKtIVfx6WGe2oW6F3SOFfrsvwFibdAUdKLxeZ5kL10oOt5qytqcmEj66CT2MDtvLtjfzvdquIGG2hXRl5NK0LRGNjPBtd1N2Sl9l1tanQnqWDbX7Q5wE6jEYkANJcTNI4JY+cj79GC2RAUMLHUA1spsouQJQhRwPv4hEGMpokweqWP5FgywR8Ow3VygkDZnGxbBKRjkV8AblpbQ+E5s1beGL6a01mDY5I9svnreA+eF9bx4x/27PqBLSlzyJJbyUyuRcxwIi9Nmi3ph/bAc0gPCWLq9p2qk+p77BhzpX/klhfQsv5Enf1rFPsoUgQWX0ZO2SIcKWKQ8pBPjkl7J9u/NfDWM9YRnf32ZZ6O4sctEA/awTwIKtYC4/wAPmmWugx7x0ya6/MZVg9rilQU26llQv9Ph2z7x86XaNaGmoA9XoE9NaAmr2X5WM4F0Yyq1o6Qz5LGE+UAm4GEPhkc6qDV3uQCt7UAVPYVfCT/uSbVWzwXBwSl8kglypINZTC/7sMeE1pDGO45hotLK4Qhuaa2Kc+1upJ5xM91rTjVckCcvVXf82Bt/Vfyo7b86Hqhxm2JjFi6/jbK41EONQmlkdmuEPw7KtrBJttaQ7OwwhjsbOSVz9lhsPrOZyQqnckVG9+gANfWFf3+nZlhs5ZmBnbysHacFADojzU4UfNW0Z/+5ETVHqqrptzqug/kaQPEeCs/q0wvE+3g7GjZDPWtmCqr7N8FQ1kzoYONJjB5mFztY0e/qDceNu2im4MHC03G7/Zmni+I0mXFsX650ScmgRsJgLUc3geQ1A5xhwB3T X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400017)(7416005)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:29:25.7973 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 167b7c77-fa97-47d5-73d8-08dc70453117 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000018.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8748 From: Manoj Panicker As a usage example, this patch implements TPH support in Broadcom BNXT device driver by invoking pcie_tph_set_st() function when interrupt affinity is changed. Reviewed-by: Ajit Khaparde Reviewed-by: Andy Gospodarek Reviewed-by: Wei Huang Signed-off-by: Manoj Panicker Reviewed-by: Somnath Kotur --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 51 +++++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++ 2 files changed, 55 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 2c2ee79c4d77..be9c17566fb4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -55,6 +55,7 @@ #include #include #include +#include #include "bnxt_hsi.h" #include "bnxt.h" @@ -10491,6 +10492,7 @@ static void bnxt_free_irq(struct bnxt *bp) free_cpumask_var(irq->cpu_mask); irq->have_cpumask = 0; } + irq_set_affinity_notifier(irq->vector, NULL); free_irq(irq->vector, bp->bnapi[i]); } @@ -10498,6 +10500,45 @@ static void bnxt_free_irq(struct bnxt *bp) } } +static void bnxt_rtnl_lock_sp(struct bnxt *bp); +static void bnxt_rtnl_unlock_sp(struct bnxt *bp); +static void bnxt_irq_affinity_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct bnxt_irq *irq; + + irq = container_of(notify, struct bnxt_irq, affinity_notify); + cpumask_copy(irq->cpu_mask, mask); + + if (!pcie_tph_set_st(irq->bp->pdev, irq->msix_nr, + cpumask_first(irq->cpu_mask), + TPH_MEM_TYPE_VM, PCI_TPH_REQ_TPH_ONLY)) + pr_err("error in configuring steering tag\n"); + + if (netif_running(irq->bp->dev)) { + rtnl_lock(); + bnxt_close_nic(irq->bp, false, false); + bnxt_open_nic(irq->bp, false, false); + rtnl_unlock(); + } +} + +static void bnxt_irq_affinity_release(struct kref __always_unused *ref) +{ +} + +static inline void __bnxt_register_notify_irqchanges(struct bnxt_irq *irq) +{ + struct irq_affinity_notify *notify; + + notify = &irq->affinity_notify; + notify->irq = irq->vector; + notify->notify = bnxt_irq_affinity_notify; + notify->release = bnxt_irq_affinity_release; + + irq_set_affinity_notifier(irq->vector, notify); +} + static int bnxt_request_irq(struct bnxt *bp) { int i, j, rc = 0; @@ -10543,6 +10584,7 @@ static int bnxt_request_irq(struct bnxt *bp) int numa_node = dev_to_node(&bp->pdev->dev); irq->have_cpumask = 1; + irq->msix_nr = map_idx; cpumask_set_cpu(cpumask_local_spread(i, numa_node), irq->cpu_mask); rc = irq_set_affinity_hint(irq->vector, irq->cpu_mask); @@ -10552,6 +10594,15 @@ static int bnxt_request_irq(struct bnxt *bp) irq->vector); break; } + + if (!pcie_tph_set_st(bp->pdev, i, + cpumask_first(irq->cpu_mask), + TPH_MEM_TYPE_VM, PCI_TPH_REQ_TPH_ONLY)) { + netdev_err(bp->dev, "error in setting steering tag\n"); + } else { + irq->bp = bp; + __bnxt_register_notify_irqchanges(irq); + } } } return rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index dd849e715c9b..0d3442590bb4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1195,6 +1195,10 @@ struct bnxt_irq { u8 have_cpumask:1; char name[IFNAMSIZ + 2]; cpumask_var_t cpu_mask; + + int msix_nr; + struct bnxt *bp; + struct irq_affinity_notify affinity_notify; }; #define HWRM_RING_ALLOC_TX 0x1 From patchwork Thu May 9 16:27:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13659898 X-Patchwork-Delegate: bhelgaas@google.com Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2051.outbound.protection.outlook.com [40.107.93.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74E16171E61; Thu, 9 May 2024 16:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272186; cv=fail; b=dqtfsbyDSFxVn+al1U/eZUn44oSmEggovKGd26Ldlj6BOEzU5nj2KV253Ks19C9+x5dH5IaUhO4Tb42dFCHDKiGYxdWlGAnL6ZtDsrU6RBNaft/+x2zojqTFSl07Ahz9YiNFVMLRo8SrDhhq5xDWSJhHk43ADm86F5VPUwlMeMY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715272186; c=relaxed/simple; bh=Sebm3OjuOFFFFNRYH2dUCIiHV1tBLrl2wClphyDNZ4c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sjs7XH0bcHn5gXTNiuiq8Sa9nOz8KJzMXquV8Gm0wVccsweY61JJwMZ+aUygYiSSLyYHTT/+Us06LNyIfqSlbRXhLmdO5qhAsPBWDbdPaXp3zUr1nV6WZWz8A4IKcjR5ubgqgNZQU/LJMNjpQv+GHmc2pxEw4VnGQgcRZt8jEDQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=EzRpleTh; arc=fail smtp.client-ip=40.107.93.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="EzRpleTh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VsGmNYjBQSCmkEnDQSU5uAddbK/mA3EdgBf4FDVlfQMORNfrtNl6lub9rCtRdyAlly7jiMZ6TPM/TH6vATAEZgFPOpjxupWYUUYZVPuuT3TuGxkQ0EkzzqkaCqfVTVG7SeoMEUguVGclf4xHfJ84evXccn3v1UJP6+zavdmwSvT8POT72AtkLmi+D2eUPu+TEEEHz7WJjCTVBAo8NPYH66kLId8eH+mpy5Io/CbcGgrPgi9DDyE6eUj0eFavcIYIv4wEVuDBE7DMyIMAxhXZ3k6PTI+96MleHR04dADlSn8DRFMrwWDivUxxCH6SHy9Hvi5wqb0zdhGJoG90JwlwhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WyKIwVCJ/5zXgFKQoytLGB9KlcgUgLwEnCTGpjfht24=; b=O/kIM+Ms1S5xuTy/maJBMfxo1MSxdASvj4b9lr+lHbFNg0mmdHoKoD1hUoxZL1xg+fviK9JP9tZ6FXRKhP5btTQsQv9KChQSPGYC40t3x/L+VeVS/ET2xEDOtN9XjP8LmXIWkeoEKhjQOUjrDCZZFOiG7/KxkTJWyVwUzTT+brqSGhMCWxDGyHNMSU4htfLL57P83xwSDGXERFAurTIsQYbU5Km2U7shbNtT2H2P+o1aPmrRxgRXPqZYFlAql3xLVtLCiJZXK0GxGc201Scj4ir8MKzD59Y+xRc2M1DKDiEBE5g/BimepzAbxlfZMJcYtwI6wF8kHS1pYOyH3rzkfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WyKIwVCJ/5zXgFKQoytLGB9KlcgUgLwEnCTGpjfht24=; b=EzRpleThLWnoB8UHbalDXQADIBMzmKfzdqO7Xwv0lmHVKfW79E0xEm6V9N9ebqCbje1IZ2EiKdES3ksUWbm8K/2yYVjGlZ9Um0eTzau9YprffHzMzlXUikdBONpQgOcfbk3jqLU6o2V7DZKE2j4u4beZ7z3/xAs5CVcxmVIeFcQ= Received: from CH0PR13CA0041.namprd13.prod.outlook.com (2603:10b6:610:b2::16) by SJ2PR12MB8941.namprd12.prod.outlook.com (2603:10b6:a03:542::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48; Thu, 9 May 2024 16:29:42 +0000 Received: from CH3PEPF00000018.namprd21.prod.outlook.com (2603:10b6:610:b2:cafe::96) by CH0PR13CA0041.outlook.office365.com (2603:10b6:610:b2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.46 via Frontend Transport; Thu, 9 May 2024 16:29:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000018.mail.protection.outlook.com (10.167.244.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7587.0 via Frontend Transport; Thu, 9 May 2024 16:29:41 +0000 Received: from weiserver.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 9 May 2024 11:29:40 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , Subject: [PATCH V1 9/9] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Date: Thu, 9 May 2024 11:27:41 -0500 Message-ID: <20240509162741.1937586-10-wei.huang2@amd.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509162741.1937586-1-wei.huang2@amd.com> References: <20240509162741.1937586-1-wei.huang2@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000018:EE_|SJ2PR12MB8941:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bf0f52e-fc1f-4faa-34d6-08dc70453aaf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|1800799015|376005|82310400017|36860700004; X-Microsoft-Antispam-Message-Info: oHnird0Xc/ohTDi6IDlDL4NRey+Iwm+gnVXIEvuvvzxgPBcptL96+30fgadJJMhV0/QljUOC3mDRi7KYOxNxZPZPDDFH2/eyvPYcMa3JYY4ukBSiCIgvLCHmYPBZKSty56V2Ddj2RU0FkIACqPbDzlhNvaV3gCyAFj6xxipmjJ3Z94da8frgExVB3S10ZvrJgaSZTblzuhAA7qIMCVKW6ODQDMaRYjspZ+eUE4qQbc2piRcHwv6FdloeUbgxDjrPHXmcFwGpF6uqvK9+QNoDMhLXsRYOTdW0fJHKEJsQls8FOL3j8xm8zyq3y6wF1rjGsrnCplzeebDadsUhJnUF+atRt0c8Z3XF33KN5S7yQYYtdTxvtSuAatqIeqoxzxR0vuI0AUGkTowKaG5v/MYhpFVpdMLDh+NqmUPlD3OLLi/b+62WwIwIJ97GPfQZXurhtGKkc0NjWdZ1yME29quIGdv9MW4FxosV4GlBGkemnhtzLDlXX/nDKPRaqzrV8li/TkOBHl1X4Jv/jCd3zZ4MNwKYOiDBdHmRZDik/9ZW/mFAsOTZWoNO/MO8pu6vsu44TO25+iU/tzYwZi1sAtYx1gH8GF1FqNmcSoUie89gyqH5AeJU49gJbSLLGStFDAJnusVvg9NmGLxV+icZTCOGRhSSSieOMBal6lljFrUjvNxt8jzgBeSVoCrdFC+t7pI7LrXjF7zVJffEg2yzpsuVegiNJuaWMBs1dokrem9dhTqNMjmt0ArCwyk3ahLr5tSdWFwQmjQCeCWTZ/fL4doYRmY3uen5WVzfl2urKgAEkjQJA5adXVymlcDlNHafAuPiMmKFVfKv9Jy3+80abyume9jmsczwkPVF0CjSEi/u4Uj8aBxmWdmi0NkNB9DpDoQ/Lv3W+56SRZdQVJzs+/CHi9uesCP8Hvt6ntjkwDCsFnnW8I0gSwK3Rgy3eu1NRtG3kgDUBaLqoh0G/mZi3aj6oNhrHI/tGHAAdvQDdfyFC9Ciz6EHbEXzECuEAZGkwrU9p/Kq0iEAE8a5h8CpsC4eV5fh0IANqycCl1/o+9/fu0kFxA2VzdDfjkMUQzVbY6CISefrg4AJH6XWQeIcBhx4eEBR8vuwyMsp/9UHDFhoSS3FbX/7pQB6Xlmy9BOdGxzuwYaIYClXOdYjhwkDbOkgD8xHh4neZqaD3avd44CwC+tuj5DppGlMpFFzZi9ZMLARQSMOYSvtJC9QgGw8U/CLfH80c3r7qf1hVexge/J+FKx4nRRwzkt0nVVG0yFzyKcjND86Sr/JtdTxxk5HJZ1ukH1o5gEPQhP+kHaT9C9dpqQks73tFfGdvTX0I433UC9hdwEaFyL/HOZrcLiVxdE1BagqNnztTTHW/9GULrnZH8S03vxATqJD7Bbv0Rd1HovR X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(7416005)(1800799015)(376005)(82310400017)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 16:29:41.8758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bf0f52e-fc1f-4faa-34d6-08dc70453aaf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000018.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8941 From: Michael Chan Newer firmware can use the NQ ring ID associated with each RX/RX AGG ring to enable PCIe steering tag. Older firmware will just ignore the information. Signed-off-by: Michael Chan Signed-off-by: Andy Gospodarek Reviewed-by: Hongguang Gao Reviewed-by: Ajit Khaparde --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index be9c17566fb4..2b5bedb47a27 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6620,10 +6620,12 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, /* Association of rx ring with stats context */ grp_info = &bp->grp_info[ring->grp_idx]; + req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); req->rx_buf_size = cpu_to_le16(bp->rx_buf_use_size); req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); req->enables |= cpu_to_le32( - RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID); + RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID | + RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID); if (NET_IP_ALIGN == 2) flags = RING_ALLOC_REQ_FLAGS_RX_SOP_PAD; req->flags = cpu_to_le16(flags); @@ -6635,11 +6637,13 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, /* Association of agg ring with rx ring */ grp_info = &bp->grp_info[ring->grp_idx]; req->rx_ring_id = cpu_to_le16(grp_info->rx_fw_ring_id); + req->nq_ring_id = cpu_to_le16(grp_info->cp_fw_ring_id); req->rx_buf_size = cpu_to_le16(BNXT_RX_PAGE_SIZE); req->stat_ctx_id = cpu_to_le32(grp_info->fw_stats_ctx); req->enables |= cpu_to_le32( RING_ALLOC_REQ_ENABLES_RX_RING_ID_VALID | - RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID); + RING_ALLOC_REQ_ENABLES_RX_BUF_SIZE_VALID | + RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID); } else { req->ring_type = RING_ALLOC_REQ_RING_TYPE_RX; }