From patchwork Thu Aug 22 20:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774187 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2076.outbound.protection.outlook.com [40.107.212.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 174B71CDFD5; Thu, 22 Aug 2024 20:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359305; cv=fail; b=UOQ68yWIkDeUHlPxoskdeK4lQ3Jt7VFMeYuUGiVb/8ovrnZ4mUqvY4cmB7wm3J6KOPkns0eSw+41ejbCXlz4BICH2DwG61ZBlqulsqHRe900jAkhsLPJEiZHsbNlwgzWYZHdjC/KbV48swt/1r9bDHeR9OajUuBbYZUCYxCKbYE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359305; c=relaxed/simple; bh=aTMWadOUnxaFEtVI87wLEEzz7J/DRVmkbaG8kTDLut4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nijAFKO78lyUWWerSnKiIfEsDtTM+0aAiBalwH25w52ftaQ0Ztidg0sJigCRnG4ZUg3/9APaR7TmKsN0RP74tmqn8qV/MhE0opoJMlRbYquyFiRabDOux7mXSoJYIIPvCpo6+t76DBoxLZH60RDdw/wQVwy1VZ9STCQPBc0Pneg= 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=PYC/y+2f; arc=fail smtp.client-ip=40.107.212.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="PYC/y+2f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oOgsOIUsmucmaK4t7Tt0z2+4If55j+CmEnXsWv00/zORICXEobC8iPFosdE+b0COdk6jxs8gH6KjJ/t+8k/Ma1DmBFb7CD+Xe1q/ZgIHcdtOhwUTHp43HYV060nwxOKh22nEb6wNGgU/Akdc8zHjWGM9OV3vkEfW1XDzMEvkt48A6bYZ6pkhFmr6+7xTmPVqZjMN/nPg4r30IsHGFaI0Jnrt2TKuRhvzIQv4JkcfcA/9ThYUsLWdILQ9aTxwikfoAXefgYlFszNOPSCf21yWjaMXGpAnYHDVpIQB/ldqdKh90A7VGFpsFizaQ+VHrpubzYqE8Wc7z5fmBFEss47Epw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Jql50VMoXTOB/6gtiCqMMolAkPHge8M7BG4HU4aa/Jg=; b=m8r41qeblNkim89LtSAM9/LZQ6Ya1ugzUSAV4Uqt5LCEfKOOhem3fv5FUhpDc68f/SPqpuOuwMn4vR7XBrejnuNdh5r4jKi1S8kixJ00tEvG1BItIaS+cs+EyvButLgdOuLf6tWnJ7rfexjjbiDzHm1gTGmoB/t8O+wOeevgEAuH0LvizY2/lnal6dLibkhD/EqPCiq2zLHZGim/q7HZ67tPv5aqPG3CT7JNUz9EqVgaRgDRKiUtTqqjU3Tfi6z8RPIbcU//nbQ/I9iueyo0MCGPxhFbIK6V11BF48lH/C9q/8XV/A68yg0LXTuqBOWPS4nksxMUEc2Jb5rXrNwzgw== 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=Jql50VMoXTOB/6gtiCqMMolAkPHge8M7BG4HU4aa/Jg=; b=PYC/y+2fGFFFnUXgs3Hgpqci6Y3++rvAvvkWpETZFYIotQB8JOIRG1JZkzM+nrX6yLmrprk1OsjdfUeywYqJhpykICY9hApZs//yI294tyKj5IJtZegbbiY6BJwz+uwBN4QzrZQTrFyZpORleI56REKly339DEL06YcNJitAnaM= Received: from MW4PR03CA0123.namprd03.prod.outlook.com (2603:10b6:303:8c::8) by DM4PR12MB8451.namprd12.prod.outlook.com (2603:10b6:8:182::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Thu, 22 Aug 2024 20:41:40 +0000 Received: from CO1PEPF000075F1.namprd03.prod.outlook.com (2603:10b6:303:8c:cafe::8a) by MW4PR03CA0123.outlook.office365.com (2603:10b6:303:8c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20 via Frontend Transport; Thu, 22 Aug 2024 20:41:39 +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 CO1PEPF000075F1.mail.protection.outlook.com (10.167.249.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:41:39 +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.39; Thu, 22 Aug 2024 15:41:37 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 01/12] PCI: Introduce PCIe TPH support framework Date: Thu, 22 Aug 2024 15:41:09 -0500 Message-ID: <20240822204120.3634-2-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F1:EE_|DM4PR12MB8451:EE_ X-MS-Office365-Filtering-Correlation-Id: c1b07fce-4d87-47fb-f490-08dcc2ead2ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: Z/t4kiw4vMesdF4qwbwwDGsXpk1q3QqPEtMtSTd4H6cqf+qR0i5ZGU45IGaqmz57ruA/xTouLv2LLwPjI4X9hTUr47PEfZzWhCdKQk3xJKUl+HDpSOqW5AvSuPRkZyTa/EhKQYOxGdjjIfMsvY+1aI0PS4g3n8raMX6wm8mBQ8tYXiPBQv5nCf7/s7F0GqVWfpKExuTxeE78I6PnFYTVRF+DycV4WpGddHfWaDaosDrvtQzKqWkXPFLoj7ilhF+3jf2IZ5u6UoHRq4/hW7nswolg4CSEwkH2mfspCIqBoQm+JPmjKxoUL875WqEi1yFTN6YCvTdMI/DubM1r5CTXfhp7MQbc9np4Wg5Q94KwFRcMj/GHataB8d28asHz+StlYw5YCOOI4afFnz1Q7F9t0UbYGLk0lHT7d/ZgpmR4KuYj4iNHPpp3kx8ZaEAQzilzHsGsnn6FLTVvBWqPRu/2W3hbDAzUnELI742BaRNkuXeQHeBj6rWIiOgeQZe4xuiq26OPDLtF66jafoXiAK8OrM6Suk5VdOi9GN/bBHwmz2pWRkxjSzcubGl5t4P0JQf1jJlTzYv4ZXYmK0K/7gN3hm0kF7IHVuPWQC5v9i5moYSAxL06XlLie9hg7EtkljdmX+yH/Lsv0uwZ7bSRnNI4aIba3SLP1vjdiiv9b9mDQ6X9OXE3NQr6cFC80vMSquff6rz0++edYBFrxYRmQOY7aIkNNwG2BaZvoNyFJZ2MNVpW4YAk0Q9+/Ns+R6foZmczptwxph09KBH0NXWRzyt1Y6uIcyCOme+qZlLZqzlIzlnK35eNqVhGrDQ75KUl7HJ3fOUJ+r0NOjnUdALArjMNwg7QCXB6s0AiopawSxLnnqxE5lF5W3mNY+8azZwWaaIr3D0WDrTM08WA8yTPfuXSDzVTb59FFA/OMZlpaNlxATwHAMICitC5K0PdPSet4oxPVmWbRj7QUWtV9hZGLtXCdYqUF1/sV9654M3IfzZlRH5s0Cs7L/lMQcumjlx/tl1ZbruzEPnwvS62Ovc05YakgQXI4wnSa5wBUtsLrW1vGYZCN2TFXp6rFC7ZiFXcvD2AdhGFsxM3KYzPxeL79Q4M+ZGXJWuyhAl0KT9vNHZVh5Xqar1ZTKpxBTKkZLc/lymM+vsbutLSjXTm09sPWFUMel6scyRN83f9QpfN2CLprB5GsjPhYN/eEoR7ZYT3P3AWg8oFSgvP+QKeO+IlfQFYlqQV3k4FpaQPdXY7Ve0/b9lFMH7z6j7H/qeavNZ2qiBQ2pd39s8NeQKSpmDTueXFQYxHqvE3+dt+fG4VlyWfu5hZn5klY3aDuOOj8v0I1kMqKrC8Yf9aS2Jb8ljXq054PRqqxFBtoPDKJB/aXyjbOVv53ecSWMR92pgHUUeu9gX8Ina7wXnjxjuVYUGWK+ui+HwOmK5VcOaGWZvoHzkOUByZo0iLVUygxe5FI4G1Q46o 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:(13230040)(376014)(1800799024)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:41:39.3875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1b07fce-4d87-47fb-f490-08dcc2ead2ef 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: CO1PEPF000075F1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8451 Implement the framework for PCIe TPH support by introducing tph.c source file, along with CONFIG_PCIE_TPH, to Linux PCIe subsystem. Add tph_cap 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 Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek Reviewed-by: Jonathan Cameron --- drivers/pci/pci.h | 6 ++++++ drivers/pci/pcie/Kconfig | 11 +++++++++++ drivers/pci/pcie/Makefile | 1 + drivers/pci/pcie/tph.c | 15 +++++++++++++++ drivers/pci/probe.c | 1 + include/linux/pci.h | 4 ++++ 6 files changed, 38 insertions(+) create mode 100644 drivers/pci/pcie/tph.c diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 79c8398f3938..289eddfe350b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -571,6 +571,12 @@ static inline int pci_iov_bus_range(struct pci_bus *bus) #endif /* CONFIG_PCI_IOV */ +#ifdef CONFIG_PCIE_TPH +void pci_tph_init(struct pci_dev *dev); +#else +static inline void pci_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 17919b99fa66..61e4bd16eaf1 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -155,3 +155,14 @@ 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" + depends on ACPI + 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..a547858c3f68 --- /dev/null +++ b/drivers/pci/pcie/tph.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * TPH (TLP Processing Hints) support + * + * Copyright (C) 2024 Advanced Micro Devices, Inc. + * Eric Van Tassell + * Wei Huang + */ + +#include "../pci.h" + +void pci_tph_init(struct pci_dev *pdev) +{ + pdev->tph_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); +} diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b14b9876c030..c74adcdee52b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2498,6 +2498,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 */ + pci_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 4cf89a4b4cbc..c59e7ecab491 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -530,6 +530,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 Aug 22 20:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774188 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2078.outbound.protection.outlook.com [40.107.220.78]) (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 AFAA21CDFD5; Thu, 22 Aug 2024 20:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359317; cv=fail; b=dTQarfbSbC9jZfR/YhC5GLbyXpMn33kNArgs5fU0q5v53QXWhc1NtaFXlBJkNeIwBaH9cjwLVlGRhdsF7LrFJ7GweFRn4VGiMGofZepUabTkp3JjWjcIxd0sshb3F1N7VASXqu2S+2I3BE7PrM0zyqpSKJfGOXA1On6xgzIcwas= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359317; c=relaxed/simple; bh=S35hk/rdfSR1NPuPYLyQNC7IrLMHcjqYr8QEzSD8rhg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oDrcflnSLHtAiDRaFby2/cqp8HVQF17tnSTmClLqppmz+CD0IY9Oy+lQW7H7sLV469Gy1wKgfChpDt2vXCfJjDHippxJFLl1EUluuFPb9P1dVi+Cc07hmTtrGCl+MOSiM+W2CeqFCESmLydcutujvi0vRj80/hywvzSV1XLlVj0= 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=jTOgui4x; arc=fail smtp.client-ip=40.107.220.78 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="jTOgui4x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TFlP3DUVn1n2MtPj9VFU93uraWzIqNwNrGZf1z7X5JLlzk7PxedDAJOV0dcH3lZivbVZ3hLesN5F03M8nYNIp2D8X8pdgAixFQju4BOfdJqbd3+NB8DoqVwzhDg/Cs/qmBYGEdEjrjlmmKBJ6TzT208C5ImmdlgfYMLdp6FYSEy2TuTbctNRg6Dr+b/loCKKXj9Yll2p8GsSYtOyD43QPabq/MsxC76uj06A7PHyilEAdoAFR1WLP3ikM7W+0dK7dYyFNDnPIlXqeL57iDXmKACBAegxbmGHSZmpUtSiGYt22DBdu/9sXV+Y3Tn3OdOmcq/X0tuy9S8A0gJUrcO9SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kdkfrOITbDPcGCMYR+Si1dB6AxPG2TBTrGAuw9H5XAo=; b=QcR4fz7gzRk62iEzbSvf65Q21Nw3zXWqeh/uxHSUunrzEAzs3rSR1KMOMptu9VIfWnvGq32QwYCIcUpFvWi4HMPVOvUhij8NnWSJjbU6ba2gLvAfZ6yUb7WxhQ1eQlwYz6uPRne41utPcotepiBKOlBPdDM6HR4QFg/c/p9+2D7meugoqzK5IyNFSi705UW7dTUu8pPvVuHQ/S+EFBTKFx4qJ/CjuGoBWOSmk9t/QMguPAMYzc5+hnHisJd5t3xRnnTK5thzPdYjbDdWXy5ugfu5vjnKt1qwTXlIjpPLITJjRFfUmg0ubTB9Wf6TjHLBvbYO51hCcWONqVCTNw7R0g== 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=kdkfrOITbDPcGCMYR+Si1dB6AxPG2TBTrGAuw9H5XAo=; b=jTOgui4xynuymzGLPsVBQj67sDwuSW+h6eLIQLZpZ5YJbrpo9SpKYl0wkx8dCBQc6Wb3N/Yw8pg6SIJ9w8EbtITBGRtWWu/u8itJnh12B57ELXCqR8QHHatvM0t/kvFlk2CB6DBhw52N47D3fN7gGaXkru5JZRnSSsih1h3EGi4= Received: from SJ0PR03CA0387.namprd03.prod.outlook.com (2603:10b6:a03:3a1::32) by CY8PR12MB7516.namprd12.prod.outlook.com (2603:10b6:930:94::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Thu, 22 Aug 2024 20:41:51 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::24) by SJ0PR03CA0387.outlook.office365.com (2603:10b6:a03:3a1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:41:51 +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 CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:41:50 +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.39; Thu, 22 Aug 2024 15:41:49 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 02/12] PCI: Add TPH related register definition Date: Thu, 22 Aug 2024 15:41:10 -0500 Message-ID: <20240822204120.3634-3-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075ED:EE_|CY8PR12MB7516:EE_ X-MS-Office365-Filtering-Correlation-Id: b9c00691-f0b6-4249-1167-08dcc2ead9a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: /dHSZsjEce+iUe9Y9QTycodvaJSFvYeeDrycaGhsF+pft1R1GT9/VIUA71GZV+CryFAVTbGxnazP529m14exFsj6H37RrSy0gO424oVpV5XqKlqibvgScbWsynkyNWwdwPMSk9WtqVHaCBM23kHvyHi32fJ1jZepW/DcQ7v+AZF2/rrrszUekoxNjlcSnEOlPeRzLo9JQj/XsyicSdPo4qhrGfXZTqBZ1+pT0/ymAtNa6Wyectbs5v8hz2Mbwa2/fFPVqsI3+NHLk1kXCcN4x2oaqmOv/PKACXC95/M9yRPt6YDCdp/Jlwca7eHgEQZ9P8CqDFOe2W9MAKGeE8j9paC6lp15z44Ipfshj0pwkl2lT0F9dsdWLXNvkyjl1aOYl+nNAM1/s/OhHXSDqnZwv8D36j8ai4ParRlSo677qSGXy0uDeoJ1gcihRLLTcCV/m7HQFk9+5qHO5LBSMdAwujpd+Hw/z6hZJuDK1e5oAK/2O4+jfKkG5/h+pLZv3vbfuYjIU7cbfL8eIyAGt6f4mstucqDS0DEiYRpJSGcWSKDJy0LwKF8mwt8vdMHezlQWM0rV0Aq4JNxbiRxP5bscQBIRI6swiRx65sQbrZ9CEYDoyGDWr+N6XbtdpclWirFh5Wz8oMScb7qx2565Omyqy1EoUeKqtYAud0hUS2pI7KffiVeJza5TiRKlqNpwykz5QwgRTx7miktJ3LRvP2IfsV0WGWEmqySMsb18+Q7YHCTuimNga8ZQ3KfX86gfHYOb10L9HnhnMvRZThWenhNzVOfcQrUbAorK4urv2k4SIwlPMjLYMaeVj5gjp3JHE/GoPG7APe0BX96cdJIKkqY9UawuM46XvuvdRv1q/gvLXm910uzt/F9WxGRdkpmRfF+8nwaLioCreGgkta6UUzCUXtsyNTxUJBNA/6nWozwaAmXp4xSCjiTTDxpFao5825cNNRPV+NL/PyP+DPZQzdmZy5ZFbYqLUAypZvlGt/WpWa7Q5cATXwf4soyMX1qPeAoKXkR9UH4N0fKwmoezGSpST2vEOSPRrgGCL1XiQjTdrY5f0PsRWf7Kl2bJ/b6bA7TKQZaM4nm4YNOZGxV3HofcTeX3mKe1Dj39ofaiG4+PVGFQd98Wl/qpGTrJ/q9pi88KHyYLb+RM/PZCqxz/CgGhTG7oxz3gymIF0CTGYeEMk/9RSN5QaKz0rPtfnD5FlHVd57HbtX+cpu4zsUfUCvYz6QGbo9Y8WOQOhwa/E1lrM9xvtwZ34bvBFANruE3LU2LYEAN4Jhspo5CUeq52LMCEH9UlgqWRs1A6lnJ+EnnM0qdHFdriz+BA9xu3dlI9GshgQ7kqCaLmndvnemC5zFZQustrNeanPx4KcDD0OJGStJa03an1gltOtPbd95bEm3Vak38khGKDUO25GaJ6yzo9YQJkgsM+pVSRJ9/wEOe+5OY5Zgyz2E4NBM23ygaIb2YX 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:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:41:50.7551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9c00691-f0b6-4249-1167-08dcc2ead9a1 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: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7516 Linux has some basic, but incomplete, definition for the TPH Requester capability registers. Also the definitions of TPH Requester control register and TPH Completer capability, as well as the ST fields of MSI-X entry, are missing. Add all required definitions to support TPH without changing the existing Linux UAPI. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- include/uapi/linux/pci_regs.h | 38 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 94c00996e633..643236f43f4d 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -340,7 +340,9 @@ #define PCI_MSIX_ENTRY_UPPER_ADDR 0x4 /* Message Upper Address */ #define PCI_MSIX_ENTRY_DATA 0x8 /* Message Data */ #define PCI_MSIX_ENTRY_VECTOR_CTRL 0xc /* Vector Control */ -#define PCI_MSIX_ENTRY_CTRL_MASKBIT 0x00000001 +#define PCI_MSIX_ENTRY_CTRL_MASKBIT 0x00000001 /* Mask Bit */ +#define PCI_MSIX_ENTRY_CTRL_ST_LOWER 0x00ff0000 /* ST Lower */ +#define PCI_MSIX_ENTRY_CTRL_ST_UPPER 0xff000000 /* ST Upper */ /* CompactPCI Hotswap Register */ @@ -657,6 +659,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_MASK 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 +1023,34 @@ #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_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_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_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_CAP_NO_ST 0x00000001 /* No ST Mode Supported */ +#define PCI_TPH_CAP_INT_VEC 0x00000002 /* Interrupt Vector Mode Supported */ +#define PCI_TPH_CAP_DEV_SPEC 0x00000004 /* Device Specific Mode Supported */ +#define PCI_TPH_CAP_EXT_TPH 0x00000100 /* Ext TPH Requester Supported */ +#define PCI_TPH_CAP_LOC_MASK 0x00000600 /* ST Table Location */ +#define PCI_TPH_LOC_NONE 0x00000000 /* Not present */ +#define PCI_TPH_LOC_CAP 0x00000200 /* In capability */ +#define PCI_TPH_LOC_MSIX 0x00000400 /* In MSI-X */ +#define PCI_TPH_CAP_ST_MASK 0x07FF0000 /* ST Table Size */ +#define PCI_TPH_CAP_ST_SHIFT 16 /* ST Table Size shift */ +#define PCI_TPH_BASE_SIZEOF 0xc /* Size with no ST table */ + +#define PCI_TPH_CTRL 8 /* control register */ +#define PCI_TPH_CTRL_MODE_SEL_MASK 0x00000007 /* ST Mode Select */ +#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 0x00000300 /* TPH Requester Enable */ +#define PCI_TPH_REQ_DISABLE 0x0 /* No TPH requests allowed */ +#define PCI_TPH_REQ_TPH_ONLY 0x1 /* TPH only requests allowed */ +#define PCI_TPH_REQ_EXT_TPH 0x3 /* Extended TPH requests allowed */ /* Downstream Port Containment */ #define PCI_EXP_DPC_CAP 0x04 /* DPC Capability */ From patchwork Thu Aug 22 20:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774189 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.72]) (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 4DC221CDFD5; Thu, 22 Aug 2024 20:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359327; cv=fail; b=KK8Pj+JL+hoBC3/KuSgn1kFU/AbhgDTZbRymHRrE0cG3jL5EUWlQ0i0eKaqK3ylkcQHIlj+f+iTJXc+KtQ06SmT9DBmi0y+JVZOVWiJDrjay3fkyZmFvmM9KI3fHGlXcCuu70xrrNefRXL2ui9/yuN9jmAVjhwFnJMDlUkgr6Uw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359327; c=relaxed/simple; bh=KMb/7aq2ieYYX9cNCUmLqsA1V1Th9YQx27JplWvuo8Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t0+5EBh6/f+WxL7ThwQ6KXH+Gd9cWo/wHfAQv//YWdfC5E8hUU3dncTPX/libknz6R5fX4c5LqdRItyh7iU3FZlA4zPQ901XmaYFqVq1k9AY8y4r6szGbt3ByazLt+IUfI3W4zutZEZ6unNd7HicXsSeGXKvVQE3W+34Kh50zwQ= 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=miPWngqC; arc=fail smtp.client-ip=40.107.236.72 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="miPWngqC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hoVQb9mgzKT1yj+IHyeHyoUzP8o0BBczWkfKjCfFNujh/dK5dK83B7w2U73wTsGosw/aYSf3BiKLat10Hh3s9wWLWNGtjHAMQ+N4qQrrjTLYYPNGHPOTZ9a9ZPQ06odaiIENELH04WXGVX20cCWtuxK0Wns+SezdgnQHiREoe/rBo1bR4kL5JKwiNMCs9hYAovcH1DFsuf/dRlnwi+wcuENnoVNbaaZpwtefcbJhzwvE+kLDw1+Tww7/GyCn5ai6PWdYPDbX+6awmsY5AlTWlM3pFuuat8s9yj31zhfhm9u6HYvSIxfq5rYvlLkDOMPv8ElBlmupKrmfHjEvrnknOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=2wZCT1U9PS1V2MHoJwpJjQD6lVZXeOAnttu8JvXVIiY=; b=t3kg8iBzaJU9Qt4kG1A3l/Y8nIJIyb1l8H/Zky/fw/tM56UZe8s1/cOnTwl8jhecNyCDkOjS2g2BatCLLE53anlMGRYkkswlkFM9tqwwo4oHegH5DCu+NWzMGHKsaRlNWyCzwLxLk8s2PSDguQNNzA/EgQ4bUYrXUpQUD+Y87qT8StZKs1IUlJYM8F+3Xm+uQ6AKafsT2LaFg0TV61cDtRBPeX2AJULjtXtDNp55DdE5SzN/mFALADMNsLd9we6c9YkKtjsHsNywfSVitN95SvdMX7TDxki+dMyRQPncq0u63I3Ioc3IngViYZSn1hdrmc56gjMNh68cv/9S9AaShA== 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=2wZCT1U9PS1V2MHoJwpJjQD6lVZXeOAnttu8JvXVIiY=; b=miPWngqC9cfLe2K4pEiFWVdh5S+cKs2fbgLTbDDSmzsa4bkz53k94vlogFjkrc5ys0ciC4FilLib9L9WiK+rSTpJB1AGJPrGhBW4Qh1yAn9XMZh9a4GDXmppObbcomKWEuyBZgQe7CFOQLooJQIA+FrwRP1WFm2MN+ye8suH+6s= Received: from SJ0PR03CA0365.namprd03.prod.outlook.com (2603:10b6:a03:3a1::10) by SJ0PR12MB7476.namprd12.prod.outlook.com (2603:10b6:a03:48d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Thu, 22 Aug 2024 20:42:02 +0000 Received: from CO1PEPF000075F0.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::c7) by SJ0PR03CA0365.outlook.office365.com (2603:10b6:a03:3a1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:42:02 +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 CO1PEPF000075F0.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:42:02 +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.39; Thu, 22 Aug 2024 15:42:00 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 03/12] PCI/TPH: Add pcie_tph_modes() to query TPH modes Date: Thu, 22 Aug 2024 15:41:11 -0500 Message-ID: <20240822204120.3634-4-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F0:EE_|SJ0PR12MB7476:EE_ X-MS-Office365-Filtering-Correlation-Id: b8b90676-c708-45a8-1499-08dcc2eae09a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: xT/I3m+Lcw1maHS8p7Q6gpwuFwNm8ZJeKcxSkayhSDwbSMNT4pDphW7bGSxAKW5xHHGxQADegQay3GzicrzvUVXT187STcasPqP0KI5/ciGHv3Oyf+Ww2r14LR65CJGuucqeDSeM+gQBjbwcRBF5O+jhSZua0vUemhRhdvDAO3DtpXpCOCBprTJBkjbtVoeMwUt1XA+WnctXTcdYm+GilDrFFPrJEBvDMvcgkM3FyQK5WPh6MinJf5sK/Ry+f3p+9fkyDVxwRq+nGv7gwdmBT8twUG7tUzt3/A5A4uX5P+hCwkS6Rd7WLRqYKogrDs0AYS9akoc3EcT+951bzeNnvQl6lqtzeCXStYq4dLKMShfw1Fdw0z38V/nkdeuGRmwBXefMGSEORXroJfPlktbAFqS8Zhe7zjU+oUdrD6O3pawJKxtwQLXhk+n16dTP+nlXi254MGGR/M4zvAhlONYueKIn6CAxpjGndz+QhHouFL8YZ5pE4vJWxnB8zta5Ife5fyhnrz8HE1f7d6DxxCJqN/VpA24dbPxiV3VGU5bAH+S0JMDHgdHcPY0RV/Mh7bevSzicjxKpKs0AB4Z3tJ1FE9vM1hecqjhIVhmLW0tRhwBnTyS9iO/6u3HCaqVdc6zYKrraxrU7QSfeJ7XjfyiPE8bqDES4fdu9O8tk01KL7V/qmsXczX87b1FZn/4ohC0nYjxI7El9dIzt5tVc/fMi4cU1MYFZi79nFtw3ITqrYeoARsvB41orYLE2zzuipu6mZOEIFOuA4DOUzZHrO8K7ze524ey4bSk3fxTHkQO8K6MBPYKCQTeEzX+6YZq/BT/PyxrzPnyzYnrJQ7+bAdJDoYi2EwGSs4JtyBjUSCi2FZgnduWvV7XxLW7tevw6IhuFsghtlMqnFRU/CBhid+1lOlgLIh/W82ww7lecEW71FyZekMJ+JC/Z1QkxlTYw+wk8eeZ5nw51fOp7ZO6l0rr1obc2f2i28qRB9p4FPwzC5qz7RL4D1HvHU2TBR56/LSI0xoSH3bmBQbJmHCG5KeyZC2INwRgG1GHQa6GkBLVfSBtStKdPzt9V9fJi1zdLK4yrn4zZDZcYnwyLKXn1cVaAJU/kLntXaa49Q3DELy4mGsy0kWTWidAFHpEJhK7qH+UEzKQxewtV0qsfj4RlYohE3a6foyjRk+ObeXSiOcKUwAoyoQ5x2S4/EG8jA9uXhC+sZAJ7ij+IeYBozE84oIUEwl7CoRMAOIoNhpXn3JDcUil0OruFP1gRlZiimhqq9VfeixHra3FRCzFM6VeDqITrVB13/s48tR+zP17V+D0AbG6odxQZwo2c0rJ1I8dpQlkGVJfvDj3/BGgynEXOYrc6BaN0Sk9QFUOEviVbZxB0eAugnSJp8dVNJfbe6I35V1B6oeUMj5kI0O8xXSQocd/BMEcT3H6fu7K10IBgj754wIFtbosF4iMDMdEw7MggqUj2 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:(13230040)(36860700013)(7416014)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:42:02.4379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8b90676-c708-45a8-1499-08dcc2eae09a 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: CO1PEPF000075F0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7476 Add pcie_tph_modes() to allow drivers to query the TPH modes supported by an endpoint device, as reported in the TPH Requester Capability register. The modes are reported as a bitmask and current supported modes include: - PCI_TPH_CAP_NO_ST: NO ST Mode Supported - PCI_TPH_CAP_INT_VEC: Interrupt Vector Mode Supported - PCI_TPH_CAP_DEV_SPEC: Device Specific Mode Supported Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci-tph.h | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 include/linux/pci-tph.h diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index a547858c3f68..a28dced3097d 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -6,9 +6,42 @@ * Eric Van Tassell * Wei Huang */ +#include +#include #include "../pci.h" +static u8 get_st_modes(struct pci_dev *pdev) +{ + u32 reg; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + reg &= PCI_TPH_CAP_NO_ST | PCI_TPH_CAP_INT_VEC | PCI_TPH_CAP_DEV_SPEC; + + return reg; +} + +/** + * pcie_tph_modes - Get the ST modes supported by device + * @pdev: PCI device + * + * Returns a bitmask with all TPH modes supported by a device as shown in the + * TPH capability register. Current supported modes include: + * PCI_TPH_CAP_NO_ST - NO ST Mode Supported + * PCI_TPH_CAP_INT_VEC - Interrupt Vector Mode Supported + * PCI_TPH_CAP_DEV_SPEC - Device Specific Mode Supported + * + * Return: 0 when TPH is not supported, otherwise bitmask of supported modes + */ +int pcie_tph_modes(struct pci_dev *pdev) +{ + if (!pdev->tph_cap) + return 0; + + return get_st_modes(pdev); +} +EXPORT_SYMBOL(pcie_tph_modes); + void pci_tph_init(struct pci_dev *pdev) { pdev->tph_cap = pci_find_ext_capability(pdev, 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..fa378afe9c7e --- /dev/null +++ b/include/linux/pci-tph.h @@ -0,0 +1,18 @@ +/* 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_modes(struct pci_dev *pdev); +#else +static inline int pcie_tph_modes(struct pci_dev *pdev) { return 0; } +#endif + +#endif /* LINUX_PCI_TPH_H */ From patchwork Thu Aug 22 20:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774190 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2045.outbound.protection.outlook.com [40.107.236.45]) (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 E9C191CDFD5; Thu, 22 Aug 2024 20:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359340; cv=fail; b=nDHg9P7d+k2RdwVxtrP4W/WD3P1816EtMNYLdRMd+sKr8OCHzcoD5xU3KAYksjiBFu0rE2beYDzL/CXjVFi8ajVfKVSoSQpEWV1YmYmnfCUm7mOXtkIJrRWLXA7+LJjyBVimIKpU4GWTgdZYXc/Pex2941L5NGd1Uoraan5ACyc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359340; c=relaxed/simple; bh=KAgJBHjAyWO8bO+uvadWpvELKncabt+8eeSuQs7dvBI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YXGB66QgjqRn6eefCW9BIGaVvt66VAiWSBpCss8dmoLSeM3QdLIzIqqe6UyUGvW1pHi5ES2etC+uP7Ccbx7bKPNPnVJSnA3zBhXRDQ3bxbQ96OZfe/9HEVw++0j7NQXUqhYtYUxAFC3EbV2Aph/Q5foVu425X89P3bAHT5QZqg8= 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=SauX1uH+; arc=fail smtp.client-ip=40.107.236.45 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="SauX1uH+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NAPkEmvj4i78IEx/1iW0SDbr9lU3+6EoplNMoI89vtbDHmL6fV0Rr+SfZWXH0IEk0dobI/Ct203/cQxrDeO84klHTiGgF6/HW7T80btFyLdXwVMx33jvgQgi0E5YtemXglW2R5469qBAnueH2w9xAlrao8g+CD/Mffk0oEH4QgisznAd2lX1gV7n5nA6vRMCltFZ+3JaKl2xrTurzqarePWX86smHHi4sl3LXdTveLuDi3ZS8ixL0cxc6pFV9WQ5L1Kzshm0NOORYVRzZ+bgV9N1jt7iwl5A2U+hnxptFMLLLpdmI7CK88dfyafmWbYrnKxLrSIctwADFzNTmT/FKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=VUksyS7lRHIRzRcpofQuvHY9NslDjXez0L+vGPoEnlk=; b=xtLt7mhonQ+QL7LeGQDPTC1+f4MGP7Y8Ac1Jg4EhMaXlz8B5OGaU83IQQjmKefs/3mDhwj2tU/X+jSJycqicGVrog3S4CsxNnZXKx9e8K1b+PIWHdx7kWl5ITrXO6tgVt+6PJ9L1XBKcwusDPqQdUF1eYhENV8IXtHudpiVUXkvqu81THrPqJxTIziEHciPCjvAcCp/IEQyE5Rp4dOvoYVK99yIo2+7fnyw+PJyYCH0VoBvaiUxbJlQFvbch/RGSbCbCG+Xy/ZVyoX/KGLNwH58aD6FYIJrgTEtqTOhrCLTdIYm+D7Qr2Tsf7ptjpG1EveJFxJ95HcM4k264UU7wCw== 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=VUksyS7lRHIRzRcpofQuvHY9NslDjXez0L+vGPoEnlk=; b=SauX1uH+wVqh/IG4Tqv85DjE/MuB6YNxGkQAyJ/bXdORAD2myMkh4Uq1ZEt9I6raVTXVzigZrSXVS2sAFgz5Yb7SPU3Xy3ihkJhbXFx7rbM7ByNohW0UipMH9DWb+H+MGRlXkTG31JKXT/nqZDySIV0pkCTM3vBHe1WHQx4VXMU= Received: from SJ0PR05CA0154.namprd05.prod.outlook.com (2603:10b6:a03:339::9) by DS0PR12MB9037.namprd12.prod.outlook.com (2603:10b6:8:f1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 20:42:15 +0000 Received: from CO1PEPF000075F2.namprd03.prod.outlook.com (2603:10b6:a03:339:cafe::26) by SJ0PR05CA0154.outlook.office365.com (2603:10b6:a03:339::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:42: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 CO1PEPF000075F2.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:42: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.39; Thu, 22 Aug 2024 15:42:12 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 04/12] PCI/TPH: Add pcie_enable_tph() to enable TPH Date: Thu, 22 Aug 2024 15:41:12 -0500 Message-ID: <20240822204120.3634-5-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F2:EE_|DS0PR12MB9037:EE_ X-MS-Office365-Filtering-Correlation-Id: e5e047c0-0562-4c5b-2bf8-08dcc2eae7d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 5NTxioxAabeBa3XuQUrZ8Rt9GtM7CBsB6vVmCO6r27a010z2/epQIL9PlYrI+fVe5UglxAZQS3DwrbwJx1vKBFCT/M3JN3FuKWKmau1sqFdVD00zkFa9do17/cUTmGUTt6Ulsg/7m7FJ/atcq1GxRIW7q3pmkhYSIdq2Ox2mesiZgHCqWT1FLzIJxlD3dRH/aEiokAZhnMLxpQ186JFrh/+7/qkCGUcKBNjvPRnU+/8hFRu0TW06x+KMNbgEPvIsOKHyhDizp/1+wkDqIXfEqmwBcjxenVDNsALd9RMf7vOsmeUN+dNjJzC+4yyIGs1znIJYGNdcrz6YQxafbHeq+8YHSqktqI84w/k8tJ1dPuxg/6s+IkYBUrNv8zFgWmIso+Im9qxUxZ556Ev3KQFihX43+F6IU4e1IdeM8BC804iluhsvWmoltGjAu11CS7TTYbFelynIpdAX84K0NYvtdgojsROWyTekIK/EEYJKtT9PBG2h6FB/O69Oz/N5dIBqsXRwIdazXpLUBQIGe7rmCeIr1eQ2courYibB0Z43XdKHOcIH0+ODUALuk30PIcTZw9gzKOo2zMCqiAu+JnnfKZNu0UagaKYgeRjzrdpB8g8MvB3ZP4yIeVAxSi7JhEmv3lVl8eOZ0vd/iqya8sZTvkmeEC1upe+VlV1UHH3lNP4oxJoLN2hxJqR7X1IJ9Bsoend92brI1ICD2UVV+f7WhOPFaOiiGk7KprOMre5P/fTLZZ++ICJvEM7tceoIz/yqtfmOt27aw6yOgocuxPEFYhnCsmPchaZs67UZSG6Hav8DOqQF5DyK7kLs3A78qZecH+Y5017TDsuV962yhnR2H65MNbY+LO+RVURYehIZLQFcVDQQpaXyS/T6lRG2bkK7W6pSySKNR9XYrLpfdwDzV1R0IObvtEEx2OKUlIbgXdgKcAtlKBbVQzE1k7QJCj5EUaxhJE9ia0wjLOD9Zr7tRlEZ7r+GOhagGt7st9Cnoexx3Wi+l5yMr4iZQYRdqaq4wXFR93bDy/rwGxWcH3f27h9wkzwGGFZhy26oNc4zIFzHaG1zsUXEoT7tF0WVKrnzeQxpvy8ZTcn06xSjD8GM6Z2RgGYRYOZyDJh1TnV2Us8Jej+ovV/QSdoidyCwboOLj4b4PZXX/DNegb2Ww/Um837GOM+zrgzKaGQJeQTQhBd701+6irxub/Uo79cJqNr1qz6TP+iQ33AgUu0pYMKF7YhR3KVsqM/pgah3GOvg4i57I2JeMyxjjQElwJp0TGkMBz0JokN4vn8K/Xgw7ggUyiCv8eE/bC4srY8jMAcjNhHepctaW0+1DdEIkDbr0/XvwFxNXyTv4JT2sisFBEvhrvHXti/Ju3MSpINMc6BLiRRVtfrdpV2yV7r1Di4O+P99LY8hCeIFMgQeo6wDoPCSltyTGzSgtwaD6oO3iQ3nSGk= 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:(13230040)(376014)(82310400026)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:42:14.5273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5e047c0-0562-4c5b-2bf8-08dcc2eae7d1 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: CO1PEPF000075F2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9037 Allow drivers to enable TPH support using a specific ST mode. It checks whether the mode is actually supported by the device before enabling. Additionally determines what types of requests, TPH (8-bit) or Extended TPH (16-bit), can be issued by the device based on the device's TPH Requester capability and its Root Port's Completer capability. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 92 +++++++++++++++++++++++++++++++++++++++++ include/linux/pci-tph.h | 3 ++ include/linux/pci.h | 3 ++ 3 files changed, 98 insertions(+) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index a28dced3097d..14ad8c5e895c 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -7,6 +7,7 @@ * Wei Huang */ #include +#include #include #include "../pci.h" @@ -21,6 +22,97 @@ static u8 get_st_modes(struct pci_dev *pdev) return reg; } +/* Return device's Root Port completer capability */ +static u8 get_rp_completer_type(struct pci_dev *pdev) +{ + struct pci_dev *rp; + u32 reg; + int ret; + + rp = pcie_find_root_port(pdev); + if (!rp) + return 0; + + ret = pcie_capability_read_dword(rp, PCI_EXP_DEVCAP2, ®); + if (ret) + return 0; + + return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg); +} + +/** + * pcie_enable_tph - Enable TPH support for device using a specific ST mode + * @pdev: PCI device + * @mode: ST mode to enable, as returned by pcie_tph_modes() + * + * Checks whether the mode is actually supported by the device before enabling + * and returns an error if not. Additionally determines what types of requests, + * TPH or extended TPH, can be issued by the device based on its TPH requester + * capability and the Root Port's completer capability. + * + * Return: 0 on success, otherwise negative value (-errno) + */ +int pcie_enable_tph(struct pci_dev *pdev, int mode) +{ + u32 reg; + u8 dev_modes; + u8 rp_req_type; + + if (!pdev->tph_cap) + return -EINVAL; + + if (pdev->tph_enabled) + return -EBUSY; + + /* Check ST mode comptability */ + dev_modes = get_st_modes(pdev); + if (!(mode & dev_modes)) + return -EINVAL; + + /* Select a supported mode */ + switch (mode) { + case PCI_TPH_CAP_INT_VEC: + pdev->tph_mode = PCI_TPH_INT_VEC_MODE; + break; + case PCI_TPH_CAP_DEV_SPEC: + pdev->tph_mode = PCI_TPH_DEV_SPEC_MODE; + break; + case PCI_TPH_CAP_NO_ST: + pdev->tph_mode = PCI_TPH_NO_ST_MODE; + break; + default: + return -EINVAL; + } + + /* Get req_type supported by device and its Root Port */ + reg = pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + if (FIELD_GET(PCI_TPH_CAP_EXT_TPH, reg)) + pdev->tph_req_type = PCI_TPH_REQ_EXT_TPH; + else + pdev->tph_req_type = PCI_TPH_REQ_TPH_ONLY; + + rp_req_type = get_rp_completer_type(pdev); + + /* Final req_type is the smallest value of two */ + pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type); + + /* Write them into TPH control register */ + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®); + + reg &= ~PCI_TPH_CTRL_MODE_SEL_MASK; + reg |= FIELD_PREP(PCI_TPH_CTRL_MODE_SEL_MASK, pdev->tph_mode); + + reg &= ~PCI_TPH_CTRL_REQ_EN_MASK; + reg |= FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, pdev->tph_req_type); + + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); + + pdev->tph_enabled = 1; + + return 0; +} +EXPORT_SYMBOL(pcie_enable_tph); + /** * pcie_tph_modes - Get the ST modes supported by device * @pdev: PCI device diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index fa378afe9c7e..cdf561076484 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -10,8 +10,11 @@ #define LINUX_PCI_TPH_H #ifdef CONFIG_PCIE_TPH +int pcie_enable_tph(struct pci_dev *pdev, int mode); int pcie_tph_modes(struct pci_dev *pdev); #else +static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) +{ return -EINVAL; } static inline int pcie_tph_modes(struct pci_dev *pdev) { return 0; } #endif diff --git a/include/linux/pci.h b/include/linux/pci.h index c59e7ecab491..6f05deb6a0bf 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -433,6 +433,7 @@ struct pci_dev { unsigned int ats_enabled:1; /* Address Translation Svc */ unsigned int pasid_enabled:1; /* Process Address Space ID */ unsigned int pri_enabled:1; /* Page Request Interface */ + unsigned int tph_enabled:1; /* TLP Processing Hints */ unsigned int is_managed:1; /* Managed via devres */ unsigned int is_msi_managed:1; /* MSI release via devres installed */ unsigned int needs_freset:1; /* Requires fundamental reset */ @@ -533,6 +534,8 @@ struct pci_dev { #ifdef CONFIG_PCIE_TPH u16 tph_cap; /* TPH capability offset */ + u8 tph_mode; /* TPH mode */ + u8 tph_req_type; /* TPH requester type */ #endif }; From patchwork Thu Aug 22 20:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774191 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2041.outbound.protection.outlook.com [40.107.92.41]) (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 D76201D1741; Thu, 22 Aug 2024 20:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359351; cv=fail; b=aYnYC2ixzrGjPki62a0tzg6kRqXNpNedHVMAa2NCKZbv1+J9IciCA4aGBZm0W8UAGQjDwrvHZLH4ZCJbzPA+lVFKAT8+h3F/PXopeSVsaX0e1zhDJxtHVfaUcMK/f9eeHmHbS1xXM1CB/W/Ah7v0GQ/KPefIPezuXaW6FsHcSOY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359351; c=relaxed/simple; bh=ZQ1lbGBYgAY3im2GAU/D5xjSsCLcdKfecUkc6Qc84FQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g16QMbA53mP/YDPolg6YKDsK2yW51A+oNJiFLIFDI7Al2qtaT6Xybn+HUgf044rw5kMi+oqV3xxk8wOz9/xV1fBtpW7MFISy48KYGsejaKlvJPTGHjd2piLEFbFxKilZ365y4s2xvzn+H810N2WtqIGVWoC7G+6ViYb5NR0Jpas= 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=31TPXwDu; arc=fail smtp.client-ip=40.107.92.41 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="31TPXwDu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rf8TIHvZGTTLlAwr2/UFcDgMTwMv9wbRZXqQP2WhVz+IG3vSQyYiEhIW/rys7Ze40oE/KQiNJZ7KmHmtNlDtzDfm8PHEYeORvTlmPrjiLCfiHEyH/EMU3ASvoRYfYU7evhaJSHcP7N4PR04F5LHpR+MhiNt16s7VGurzVv92/Gc7bStsR3+v53/IFn8ovry4HNgLkHkLqwnF2ql9O5G9UEMawmMz18G639G1OBZibwVZ5ZnDSo3687xywrZcBVOPcIjTB7RVp9uexb7WdrxunClftwVhSlzhJAzSd/FiNlm1bf+RPugIUueL41Nho/882uu2AiWlgdx6n3MOtE8lSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=vAHFzz0oA9pHF5G9HIzmwSA3nadkB10mjeoLQtmmgo0=; b=Gjt43X+i6LaO8Y/lwVJmcLEqMlLx6XJ6ou17vSSZY4b6DqTgRcaukgXlS7/ZDq2CeiS5d6gOBeLbAd0lMRtnhz8moQlnGaZlFOuRJNfdHX/QoAXSwX+nYxcN0hWFEmToh5PC9vB9AjdlRvj6CnZLlUA4Gb7UJnPrud6ixiUXKqpW0/zLIoueaIJvv7Lvz6xTbwC/vz22WyECNQInlbiWxos0aeFeftQtGmluCeG9vgR1hb/Tw8SgK2ZcXvCuo1aevGB40nOOA3kG4tqses7+vy+Q1MzjWTT+h/IYq4TmNjH/w7DkIQQwBVS1iQEsQhK/CdI4TznjsLtHuHzLTNvHaQ== 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=vAHFzz0oA9pHF5G9HIzmwSA3nadkB10mjeoLQtmmgo0=; b=31TPXwDu8mSMQ8041nO0L88SkYffntxMHvhMLC4CUABdHc25o34cS37HpA+hX8CIm5jMC/z2ysdNze3sU7m1FZK02iZXgeX4a/kntQaaeVANn/j23WjZSCQTrWs7AJ//zA+Na88EZiT9pqRYf6A3/bese8jypgKr7hYE/WR0SV8= Received: from BYAPR03CA0017.namprd03.prod.outlook.com (2603:10b6:a02:a8::30) by CY5PR12MB6406.namprd12.prod.outlook.com (2603:10b6:930:3d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 20:42:26 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a02:a8:cafe::d6) by BYAPR03CA0017.outlook.office365.com (2603:10b6:a02:a8::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:42:26 +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 CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:42: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.39; Thu, 22 Aug 2024 15:42:24 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 05/12] PCI/TPH: Add pcie_disable_tph() to disable TPH Date: Thu, 22 Aug 2024 15:41:13 -0500 Message-ID: <20240822204120.3634-6-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F4:EE_|CY5PR12MB6406:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bda0eec-2827-4b04-6087-08dcc2eaee8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: LRWL3iuNW/YqeUDxa4czB/eWqYJhf8pvx4gbyc4KZIRscwduvxGqC1keEdO9jFRIluHV/5BQ7jcY88hIgCiXTcQxd/24iUmWg5u5W1ZUunDfiC9Fx+NDNwfbZndVPbOTipFxXH3pBFKKHcnRo1oxURce/YBenAHqaWwi1N4nzNoeSLaFoNUwsoY4Pu1pTzUMCv1zxbRjp5M6ZB2u/aI9eZVrikQf+uL10D3aB2+0mc2FlD8gdcdjrCYrOk+/yMcMWzj5gET4cZqnXt+yMhoIKwt80odclUYcuBeQPV+NK9GfsJF31pB3c6G6ayHKAG1lNNJD4gX5tAyJIxTYq/vokSDpfjkeOj2VifLusLUow+RogdDVjr8tgUucp1C/K2YzUUSHDG+X/q+wlIwzwyOxIpkfnAxnXBo0bSZ+VedaUi0kJnQDOQcIQ0AUXqD9kfSkgf1Zc54ucyGJGcfvQZXQoS+qRmPanPWVUoUleQ6MZFL3Fi++/yyRo3YoP4Yupm13oOnvKVdDMAUnQUXC0sUXUb7CRhSzzV95UQQWw8VzX4CV6hVjqMVuvLIGbvpdd9+GQO3v4CLfWDMqbEFI8ZcX84bDAl6RdjL9jajIoC+f3h9TABAVWWXfm3bPHeHvCjKsVOmWFS40a6R2R6JWZL4Buf+YPY85nzi/tRz6p2D0XAhxqdhCdrpCJ2rRSsF+r1LfIIMhz/R5axVaKdcEqyCpMtuEI6YtI+3wAka7hncaeERYLIihGShi1mndIw6/zgC2+wJw+I1Vwy6U8s9w4yuXxqym3AyIQ7IIyIlKJ9IBQ4CiG70Sc2buFDgRbh21AguXP7Y+7OQ9kZtpyK13VTE23Uult3eAvue6M+to2nS/gvb0tH7zPSNrdhQ58UhKVd036OfiTgGAEb2ctrED+vLIBO5eRB0IZk4BwQ23I1E3P3ABtZG2OJ01QHxNI93WbcNSH8o1W0jHMCPSfu+MHaHeSXhp/TDJiuk7dI7YFGMh97p9XO7IfGxq2SQ5YlkBIhlriD8n3bzwMwf8vhLY0qypcm/4rP/iH6HlOu0gfq3GxA6TIwyB5MsRIfxl+s0okJCkOgO6stR5AXaljrR4eIHCKT4w+UvvdbMDfwMAm4B8xRKMr+jceeU1/8umdHsXpoz/i8LsQwaQh8wSh1vVukl+26VUyyBG5e75y7NYzmFaMGy5x2r8ppVFC2ZXL4uGfz13H6YHqJ7iwd2WNnnhHcD69gyBQLK6pl1I066pFK8nu8/DhiEgQCjdW7Sjruo27UWUs9hvktd+EXDrVe8xEwpxRqTFKuQIoXsJ9UKmJtip1wmRWscuU1JtdSrhIqatXt9oJKeh52rfTJzLF4/Gj/AUlNsTYBZorBKlOtQrQeCvzOuYxkS6pTrYUpMO4xfa9XnLV0eKaP3NlgrinoNhOffLiEWA0DwHno7ctDk1arLt8WUuVFAHh6UdaHoyFHl4zAPb 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:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:42:25.8714 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bda0eec-2827-4b04-6087-08dcc2eaee8f 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: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6406 Turn off TPH support for a device and clean all related states. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 22 ++++++++++++++++++++++ include/linux/pci-tph.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 14ad8c5e895c..08ce4fdeb160 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -40,6 +40,28 @@ static u8 get_rp_completer_type(struct pci_dev *pdev) return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg); } +/** + * pcie_disable_tph - Turn off TPH support for device + * @pdev: PCI device + * + * Return: none + */ +void pcie_disable_tph(struct pci_dev *pdev) +{ + if (!pdev->tph_cap) + return; + + if (!pdev->tph_enabled) + return; + + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, 0); + + pdev->tph_mode = 0; + pdev->tph_req_type = 0; + pdev->tph_enabled = 0; +} +EXPORT_SYMBOL(pcie_disable_tph); + /** * pcie_enable_tph - Enable TPH support for device using a specific ST mode * @pdev: PCI device diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index cdf561076484..422d395ade68 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -10,9 +10,11 @@ #define LINUX_PCI_TPH_H #ifdef CONFIG_PCIE_TPH +void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); int pcie_tph_modes(struct pci_dev *pdev); #else +static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) { return -EINVAL; } static inline int pcie_tph_modes(struct pci_dev *pdev) { return 0; } From patchwork Thu Aug 22 20:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774192 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.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 445591CC8AC; Thu, 22 Aug 2024 20:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359365; cv=fail; b=WtwH8vef87ME59OqtR0mXf2Xwae3E+04Q3OtaiccWuNxXut71i2QcpH9h/TlwWoihwfEGExhCtgnCkJohXD6NaZPkagjd5V0dsqB9RlIL8GK8QEtFRh5xU1/q9tWEHktWvjtafoyCmrswi6HnN1ZIIbU51lXnqk8gzjDBEvewWo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359365; c=relaxed/simple; bh=EfUdOXOHmwrEOJ7RZBur6oecPHjnFsGocyzVQ2AWUhk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZGmG4r9GjVnrZND944jgHQ10P1PcYqXTdPRIYKWCBlmV1MTo7xVgUVhEMfhABvrq+tT7O8Yz69IyCQ62+f6jI4eecA98cLf5CcjARIJkCh/BHquVIGz6kuO5xj4q0gLFEl7rCxUuyn31wtGBcLS3gOO5o/l8A6nPXzgqHBSJvhA= 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=2uiLj2H3; arc=fail smtp.client-ip=40.107.220.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="2uiLj2H3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ltSaKkHSNfLCW3CTXW8xiZnZEx2xIXhnKKS8YQ+0KvwSea4iP8x4hPDXsHkL5HAuIsrTG8gg23yBEft8mtqjEQBStIUdkoBHsLpe7vAdDiH2zTJeDvwIOfvckxczJ9l1XySd2qWGtKMEIZEzDHdn+IsWrjxaVQNkF1FkQ6Xvyr3OY1v+vUzqVFNxFeF8Bxg6Adsgh/shEoeyUHrJ8o/u78UraXjpPqwT8B+XXRvhyc/D1OP9iOhmaJeFVcq4YiBOE7OqzMxRAQMQs67EAYQD/E74JvLG3SEx1m+UhnoPoWVUSU8/HFyWhZPIpUp3e7/eelqfDqatpOsEoP1Y2tu8rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=BFxjTIRgbaMpDJrHdXXnF2MLO26fcyA8SkAVyNDXhUs=; b=fxqYleoK+iOnmNDJOmj5UPbhEfpNM4XDfQoFNIhcVAc9KYwx/WIwryesRYJtXJn+U46RrXtrVm015dtSqSdClMwzOYOCXHVj3gCD9lnWZmDJ97WgkrPrOVMqm2xp9njcPmsb1v0BY44+ZnIyDRnROUTM59/41Thla3TqmwFy02wYJ6a1ABw+lwIDG9QU/EFskbWtreBk2/+vFN4yOSNT/bm73UMDQqj6Mr5iwVt5wpb/Rn26/Ud+Vs2kRR2qhvn4DdvqqYaoCjusw4njqnjPjSeQFBYPrlVeuMuvC+ms6iOSRV//oo76NT5xiLugqbIny7Tnn0Q8c74VGknQLths2Q== 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=BFxjTIRgbaMpDJrHdXXnF2MLO26fcyA8SkAVyNDXhUs=; b=2uiLj2H3ROfisczne8p+WM+7MUreaHblrvKEjb3Q0xV5+0b71TUjbHpVK2D79r9J/tN6eqJlC59Kg/2m1P34egtOpEhPCbzPYBwM+nDwsWzdRqpVTRCJ+UAL3tDuY0wKaPFywQUSskaEu761zTN+YxecnNMRM3cB53A7PZmnnuc= Received: from SJ0PR03CA0362.namprd03.prod.outlook.com (2603:10b6:a03:3a1::7) by SJ0PR12MB6967.namprd12.prod.outlook.com (2603:10b6:a03:44b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 20:42:38 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::3c) by SJ0PR03CA0362.outlook.office365.com (2603:10b6:a03:3a1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:42:37 +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 CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:42:37 +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.39; Thu, 22 Aug 2024 15:42:35 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 06/12] PCI/TPH: Add pcie_tph_enabled() to check TPH state Date: Thu, 22 Aug 2024 15:41:14 -0500 Message-ID: <20240822204120.3634-7-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075ED:EE_|SJ0PR12MB6967:EE_ X-MS-Office365-Filtering-Correlation-Id: 592de166-6ff1-40dd-d62e-08dcc2eaf54e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: HNoiXdXLpvA2Wf4PmI08c1HeSJ3vj+imOIbZ21pK/jfDLVGGrWJI78VMZC3IK+0aa/kJhlnjovV21lckj4sH65mYQ/+jdtaZ+RjM5D8fc1A+avpvmktfFdgyit+Rqinl6u1EuypT/unUqBUcx/1Xx7bCqqUewV3lFJ3yyApdRaRHt7WkWWyiqSvQ3ead66SOp7dubkvt/yVR8F7KUD5QHaJYVvW5p19YyDW29H4D7fjX15vVsSas67OyiYmZzJ/WEm9OhsJR/PPgYHFPQu9p/OUODdDb+XjQ++7sjt0kkE/IucWRjhItUb3oINEbzeBULcE36oyaiGucI/qkyJImmbO2PIUfBm/VSxvl6d4mSVzvUmO2ZYhCEJZb57CGEQcUzUB0B7aNyNbzgEGlO/TEMKQm3T5phQt3mIGV8C8Jj0mBrUQA4Rxiq7tIPKrWq60Pwf3hNOmdM6bVjOBADkOPCST8J2JR+3LqvTm2bVdultU1BE6/RYYkiUyUXDDOSuIufteKIovVXgtbaUNM1EZBUwqZfcRAyIz12grRbjFHI0MuoQHrmNC63PjdprCOcjMQiy3XhANX8M2u0swUX3tOXTE4sZz4BkpBm/VhwXMpMUH4D7jU6sjFl+5yDylHWcCIp0Xbl2QMxv4lffBkZEtpw9tVq40XpoIShUSXYUVciULuNJF/oOFcPsTZIRbv5kW568oKCV50F67z+/+G96oQ0VWxvetB9G6+/tXgK3dp7Yi6m8tFfzz+EvAYQlLWywB4RSGTGfShea+tCWg80cQOSgnh5RGy2hpsSBAbnOKy6iOrCupZmsWLzGF1InB6CIVGMJyJ2HRmmTbH+XcFLJWMoSUynIQZH6uOVc5Jj87nSi2GlRyLAKIhfVk0pykOpp4s28zxL3NU/y9CeKyYkkf+jubslUL6WxsjVhO1xvIwFj8xBSIhJqe0hVQhlUL2JOEsjxokHmnVoWaIyJGIip0nfqwBode/mNLtdo9nWhb7y4m6fX1iuSWmAsQK7WsnX2gtf7JIcL0Z82TH4swXU2/RryNk/yFl6Q9sbwAzox+av/tiYkpxsUA/neQmkKBRNyjZcDs9JCcf5uKGvUtsCjGk12JjXVpK2Ld3aQG1hXZ2EZi7FeQUk+ykKX6zn1VMlZ+ZxLgGtLYaFJypozUiQc1BFFen0kT/A/H5vB6LOIGwKY6qLmYwaykhsby6+eihHfuZXmoeKweNGrcnIJwPK3j5jqvDV83lLSZtBvikLJ0vhDcTq3NsIi5X1WRCKg295dTNwFgX0gp2IsPQCbsFyCzm6Z6wSk5vMGm53j/BP1WTpdw77wGnvQU/TQ6KQUCVCankX7Ludx2I8HoM5yPCL61J+NuGHt1R/DhUKlvN36F/qzyU9tzzrh8pJSt+fJ9dUZ8B1aRHxM/HeQIjHXZdkc72hmV32QAkGC7MouBRa1ScX012A518Dv9e/fMaEwtR13Gi 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:(13230040)(82310400026)(36860700013)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:42:37.2550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 592de166-6ff1-40dd-d62e-08dcc2eaf54e 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: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6967 Check if TPH has been enabled on a device. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 12 ++++++++++++ include/linux/pci-tph.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 08ce4fdeb160..d949930e7e78 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -40,6 +40,18 @@ static u8 get_rp_completer_type(struct pci_dev *pdev) return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg); } +/** + * pcie_tph_enabled - Check whether TPH is enabled in device + * @pdev: PCI device + * + * Return: true if TPH is enabled, otherwise false + */ +bool pcie_tph_enabled(struct pci_dev *pdev) +{ + return pdev->tph_enabled; +} +EXPORT_SYMBOL(pcie_tph_enabled); + /** * pcie_disable_tph - Turn off TPH support for device * @pdev: PCI device diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index 422d395ade68..50e05cdfbc43 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -10,10 +10,12 @@ #define LINUX_PCI_TPH_H #ifdef CONFIG_PCIE_TPH +bool pcie_tph_enabled(struct pci_dev *pdev); void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); int pcie_tph_modes(struct pci_dev *pdev); #else +static inline bool pcie_tph_enabled(struct pci_dev *pdev) { return false; } static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) { return -EINVAL; } From patchwork Thu Aug 22 20:41:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774193 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2043.outbound.protection.outlook.com [40.107.95.43]) (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 60E991D0DF9; Thu, 22 Aug 2024 20:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359374; cv=fail; b=A2htLuxFAVNzHhMKdrhocn3WYB0x/6Dx26pywkzQJJkGzZFe7KTKxVnsyR26eXKsYBSnVn8v0Vq2wq2TCC+Z6Aj6S/fk8O4QyKAjzBSzuxa4RuSOvo1/DoHNoL6jA+tw3TTLoyFSDRQ1DxiB+CTUdB6DBquG0UJbOrbLzdkRORw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359374; c=relaxed/simple; bh=ysBYaKmuV2CiAKRG8LXBhMR8hLqWcYsa0EijbBj8O4o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t0zoD+J4aoQMzU2nSR69vNotHDgYCn0Di2719ZsmVU/Tv2sFdsMXlrHUwSv0JSK8UGAMHLkZvwC1kb4R1u0bQX9CD++auDRfmsqEAUmzCKDwa6rNckSFF/UuP8P8fsDJVs1OBKOf1611OT1LzbdSFcLj7OCx1WRuwUfZVQvLov8= 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=joVyEbG5; arc=fail smtp.client-ip=40.107.95.43 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="joVyEbG5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BO81POAIOSEpofIjv30WX8DD4GgL8dr1r3EKo6agMQuWnVW4QM7CH5RjncveAWvFs68sIO1oy44m/W0LB4pNYVLOVmKrC/UZSvw8ZRAGAscnIVqUh7NQkvV565PwDOfJZYDJxFpucgAO+qjrAChA2DT1uMQFS2iGj9MA2cFLUjbK/cxisDA4DK+UPF5Ca9GYzsX2DXDZ4/erFXiSr28R+aV7Zf8o5Zz2pUbVYBBY5Sg1R2U1RnVKzPp2aMHI8b/RvnHo8vKO+YLlgaTZaxPTtluzGPPI73uI6zC7jhaSr0dTJnjh2S8ICBDIO2REHJTYLwTbd5Z4LVbdPg2nsPtxLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XmxK14t2ZYd+bJqSgCt8gkWac3sxRoapV8YMXB4gn34=; b=d7NrDj8du27pvUpYQQZ3OUyBZ3yXt+FkrwxE5pJ4uJDPoDnZwwsNmeyCWreIFSdJswyR0XsxbVvO54/58nITpDm3102AebD1Mpr2vp6xKmRVTVouF1CPnyXVS3feE9nJsr8/s/UpNFIvs7Fv2iDilp4iHEiZiD27mVJzNIeX3E2cV5ipO0B/O6FikPCjB0hz5IO782aiJ+I6TBm8HcM5rGlx1qDJKyzvu68uHiWjqlCqgLdKGQm/NEkPQdZghjb/QXHZkL9HKTzYvWapofdhUmWgvH6E5BPXlG92hPoEGuRiI3aWFxolntG4IzC9w2MuGkfmVc4tT+z3E7kwYVTFMg== 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=XmxK14t2ZYd+bJqSgCt8gkWac3sxRoapV8YMXB4gn34=; b=joVyEbG52b1dpaaMdg6gCQGdUj1e73i9ZsP4wfZtcBoTryjZ4/hT4mF76krTctYeyaqjh5Ie78P5gEHLaPRGL4rUK1JMa/Geerm9mSYQTlc1c3G6m62Z83vbSb+JnvLEu9NZ36N468Z+0u7RHenq+bdrEPgLs9LeS+cESN2UHTQ= Received: from SJ0PR03CA0377.namprd03.prod.outlook.com (2603:10b6:a03:3a1::22) by DM6PR12MB4188.namprd12.prod.outlook.com (2603:10b6:5:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 20:42:49 +0000 Received: from CO1PEPF000075F0.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::a1) by SJ0PR03CA0377.outlook.office365.com (2603:10b6:a03:3a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.16 via Frontend Transport; Thu, 22 Aug 2024 20:42: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 CO1PEPF000075F0.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:42: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.39; Thu, 22 Aug 2024 15:42:47 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 07/12] PCI/TPH: Add pcie_tph_set_st_entry() to set ST tag Date: Thu, 22 Aug 2024 15:41:15 -0500 Message-ID: <20240822204120.3634-8-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F0:EE_|DM6PR12MB4188:EE_ X-MS-Office365-Filtering-Correlation-Id: b1829079-1b13-4e00-2137-08dcc2eafc5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: o3Irm1ATT4/oAnFRDAcv1OWCX52jODnnGvSyrOIRahS9zNwnhaZD6/e7hAb9VGG3Y2D/tpWUzGaD53uu+jONJw6LG3WHvNxj+8mH7GTWYL3vhX5xGZxFsntgdbSiyk65nPlXRHT6uPuPmXfsUdcdb/O62S3KIQ4avmF7ORHzQ5UXjg16aYV6LaWGZw6gn+b832lli3sH9ThDzxGLlqYR1JgNAWogfvG4v4s8nz05PNLvKgbgzrclip9zK9ETH6L6aCkCf0cvDgtBluM3lMSfPZH9cWVqpIymA3PcAj/9TDSf9hQAdmW3BjGA8gKRKRoHSHD0n7+IuX8pvqQteg2S2q4ceOUeW7Uge67eHMYrCDkUuoFi3/Xs66ngjpacfqJG/CW5dBKiVnC5sf8oxwg4IYlEToPKI++jYoAmDTESCHW+w1Rj4mRFPCpXz4R3mnRxYGWf23DHy+9uy/K4qs7w3p/MB7bOto610VTcYJkiAzrmTSveC1uIomF3zflyHcDTmJO3yVIS/y84SEELNGsRBSzyP1JUz2e2rLhB0GnW5ZBtv1vP3o4coiAGXMbIVbq+91SyvzAGjVndTuA0v8tOAhQ2IK7irhnJuZia0IIhfRkNr+5vwiJ1YfljLm2S/sSsZgaLX7c8HJEWnsjr6XaCAXACS8mCzNp/WQ682dc06eiJU5OtvYMQLqSf2qFlT4GUk3f/z4dZt7RCG5kWQ5pCHyGmdRh+fU0xrGc15BFTIfQ1nP6D2hGfItNmaiYL/82stug3a4Ul9kO4EAJwcryhtINGQ8FwDVXfzpC6VSAY/v0yvrJB1NCBwiZLZQc8bepGQgaz3JN9F9+9lz1VcNeZmgG4VUTzLdE7iAM+vlvZlusLYVDVYI8W2bVSUyA/KnDQsq7U4p+7H5wWNBkbH9FUo6GSeY8Dq4eQConQSDBg0p6HBugv2O2rcc6S/Biy0VW114XutgE7o+f+et8HQhcbKe9sg3k19771YAQyGD18Y5+v1ggJgOQEUA8haGiZmKQEamxHcx5F/uRfuPGdWZS+HibZg4hh9vmarfmcCgDBZ4V0QvQj4Z4KCBfDl4hQ2jkabnFN9ohTS0ioXLg4jPBLp+HKoqNVkD0SQ4O9euCxHZUQFxvF4W2InsPiTLj9TfPgaDdLtfQrXqNh7g+P31Hj7c3/LK4BDW0C2elp6SITxjBIUGHW73iXX6G5UoAAtzpmO+ulhJ3O8F0lURkbAxWrqXgm9IokwA6i4XPUOPfS7fv391+ZZ6HfaIZfof61N3bAniVxw/xCtTaLwyWHcot64AQTEyxI28L4cgnRmiO+12Gc0bi22goSmP3luxlme5Ew7e+Zzrh3kn/i3dYObE+P5TuTpQGTOtnUG7nXK79eOviPnep/gGdiDKcx04q1/3fL/wlcCUFhOI8U4o9rY2yrEpJuEogIhNZ/EBvR0Q77cFNy6ALzdGMlb7mTqEAzHmEM 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:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:42:49.0170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1829079-1b13-4e00-2137-08dcc2eafc5b 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: CO1PEPF000075F0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4188 Add a function to update the device's steering tags. Depending on the ST table location, the tags will be automatically written into the device's MSI-X table or into the ST table located in the TPH Extended Capability space. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 161 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-tph.h | 5 ++ 2 files changed, 166 insertions(+) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index d949930e7e78..82189361a2ee 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -8,10 +8,24 @@ */ #include #include +#include #include #include "../pci.h" +/* Update the TPH Requester Enable field of TPH Control Register */ +static void set_ctrl_reg_req_en(struct pci_dev *pdev, u8 req_type) +{ + u32 reg; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®); + + reg &= ~PCI_TPH_CTRL_REQ_EN_MASK; + reg |= FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, req_type); + + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); +} + static u8 get_st_modes(struct pci_dev *pdev) { u32 reg; @@ -22,6 +36,37 @@ static u8 get_st_modes(struct pci_dev *pdev) return reg; } +static u32 get_st_table_loc(struct pci_dev *pdev) +{ + u32 reg; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + + return FIELD_GET(PCI_TPH_CAP_LOC_MASK, reg); +} + +/* + * Return the size of ST table. If ST table is not in TPH Requester Extended + * Capability space, return 0. Otherwise return the ST Table Size + 1. + */ +static u16 get_st_table_size(struct pci_dev *pdev) +{ + u32 reg; + u32 loc; + + /* Check ST table location first */ + loc = get_st_table_loc(pdev); + + /* Convert loc to match with PCI_TPH_LOC_* defined in pci_regs.h */ + loc = FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc); + if (loc != PCI_TPH_LOC_CAP) + return 0; + + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); + + return FIELD_GET(PCI_TPH_CAP_ST_MASK, reg) + 1; +} + /* Return device's Root Port completer capability */ static u8 get_rp_completer_type(struct pci_dev *pdev) { @@ -40,6 +85,122 @@ static u8 get_rp_completer_type(struct pci_dev *pdev) return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg); } +/* Write ST to MSI-X vector control reg - Return 0 if OK, otherwise -errno */ +static int write_tag_to_msix(struct pci_dev *pdev, int msix_idx, u16 tag) +{ + struct msi_desc *msi_desc = NULL; + void __iomem *vec_ctrl; + u32 val, mask; + int err = 0; + + msi_lock_descs(&pdev->dev); + + /* Find the msi_desc entry with matching msix_idx */ + msi_for_each_desc(msi_desc, &pdev->dev, MSI_DESC_ASSOCIATED) { + if (msi_desc->msi_index == msix_idx) + break; + } + + if (!msi_desc) { + err = -ENXIO; + goto err_out; + } + + /* Get the vector control register (offset 0xc) pointed by msix_idx */ + vec_ctrl = pdev->msix_base + msix_idx * PCI_MSIX_ENTRY_SIZE; + vec_ctrl += PCI_MSIX_ENTRY_VECTOR_CTRL; + + val = readl(vec_ctrl); + mask = PCI_MSIX_ENTRY_CTRL_ST_LOWER | PCI_MSIX_ENTRY_CTRL_ST_UPPER; + val &= ~mask; + val |= FIELD_PREP(mask, tag); + writel(val, vec_ctrl); + + /* Read back to flush the update */ + val = readl(vec_ctrl); + +err_out: + msi_unlock_descs(&pdev->dev); + return err; +} + +/* Write tag to ST table - Return 0 if OK, otherwise errno */ +static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag) +{ + int st_table_size; + int offset; + + /* Check if index is out of bound */ + st_table_size = get_st_table_size(pdev); + if (index >= st_table_size) + return -ENXIO; + + offset = pdev->tph_cap + PCI_TPH_BASE_SIZEOF + index * sizeof(u16); + + return pci_write_config_word(pdev, offset, tag); +} + +/** + * pcie_tph_set_st_entry() - Set Steering Tag in the ST table entry + * @pdev: PCI device + * @index: ST table entry index + * @tag: Steering Tag to be written + * + * This function will figure out the proper location of ST table, either in + * the MSI-X table or in the TPH Extended Capability space, and write the + * Steering Tag into the ST entry pointed by index. + * + * Returns: 0 if success, otherwise negative value (-errno) + */ +int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag) +{ + u32 loc; + int err = 0; + + if (!pdev->tph_cap) + return -EINVAL; + + if (!pdev->tph_enabled) + return -EINVAL; + + /* No need to write tag if device is in "No ST Mode" */ + if (pdev->tph_mode == PCI_TPH_NO_ST_MODE) + return 0; + + /* Disable TPH before updating ST to avoid potential instability as + * cautioned in PCIe r6.2, sec 6.17.3, "ST Modes of Operation" + */ + set_ctrl_reg_req_en(pdev, PCI_TPH_REQ_DISABLE); + + loc = get_st_table_loc(pdev); + /* Convert loc to match with PCI_TPH_LOC_* defined in pci_regs.h */ + loc = FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc); + + switch (loc) { + case PCI_TPH_LOC_MSIX: + err = write_tag_to_msix(pdev, index, tag); + break; + case PCI_TPH_LOC_CAP: + err = write_tag_to_st_table(pdev, index, tag); + break; + default: + err = -EINVAL; + } + + if (err) { + pcie_disable_tph(pdev); + return err; + } + + set_ctrl_reg_req_en(pdev, pdev->tph_mode); + + pci_dbg(pdev, "set steering tag: %s table, index=%d, tag=%#04x\n", + (loc == PCI_TPH_LOC_MSIX) ? "MSI-X" : "ST", index, tag); + + return 0; +} +EXPORT_SYMBOL(pcie_tph_set_st_entry); + /** * pcie_tph_enabled - Check whether TPH is enabled in device * @pdev: PCI device diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index 50e05cdfbc43..a0c93b97090a 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -10,11 +10,16 @@ #define LINUX_PCI_TPH_H #ifdef CONFIG_PCIE_TPH +int pcie_tph_set_st_entry(struct pci_dev *pdev, + unsigned int index, u16 tag); bool pcie_tph_enabled(struct pci_dev *pdev); void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); int pcie_tph_modes(struct pci_dev *pdev); #else +static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, + unsigned int index, u16 tag) +{ return -EINVAL; } static inline bool pcie_tph_enabled(struct pci_dev *pdev) { return false; } static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) From patchwork Thu Aug 22 20:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774194 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2057.outbound.protection.outlook.com [40.107.220.57]) (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 6CED91D0DFA; Thu, 22 Aug 2024 20:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359388; cv=fail; b=YtBvSlHliTw/fmfuS2Y5BztRxjfVTANPbu/4lcAbw0TY8WC3onGy6zk1qZPwgSM81ieVfihdsRqGFL6HnwpVsejsNp2lILkg+SUsWvlB/W0aUEIAwqWprF9fhzo6FrZmrEXLt85476UZx0yggW23UI5zWfO0pzkdGB/tyQ8EM4M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359388; c=relaxed/simple; bh=lGpezmEHBOftE9zul+gS+ggitrrrojjj86m3gCKd2+c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IXKnUpWnKlO6AFz1p/bx6JpPFl4kNB6+YzXmNGO10ha29GUT+yoo6UOm1rUsv3XXX7cJ19vgtLqJYpKNltY53nYkrjGVwxqf/iJVEIb5s7gMoTbbqeRTonxSfzeVsVgAWKxAa9OLeenlXBae2NWjgmzKPFjikOCNsgSu2776/Lg= 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=KlbZbgJd; arc=fail smtp.client-ip=40.107.220.57 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="KlbZbgJd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rkUO4z7cKpr+n61c7T5/badry6Wb9zxQ6Ll9VmU3M13g0hRy5k3TRCK+GxkqLYiSxcWMt58Z43Z8n2DwG5ylK1CFA2SHxAGr9GhustU3CA09lf5Famp+xp3JA7vOXNyudrF/XvW6vTjbyytEUzABlx3dym1qVpo3X3Wij8m72IFGXhryjqXADqmt3jnCR5WKuzERXJ/pytq0yNXQCZVlYElHUTESD/ElN9OR4L3EcTFrOPc+e3IIoPs5VyZTwSkU6uxxR2WCFvcjCJXAF96Kv5QbvQbbF15H5R5UnQco0JrZQZBhNVTDYAifBsb42SFYjlh5vYFVP1QLV2JH3JJL1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=0tkxORMkLIo/2S9Hc7kF7joPZYPPHM8oLKAMMHTDOVk=; b=X/PsdgRSB5+Sv9IWqRc1DWCrqaaMRZujnsHuniSv8zCj6khnQNx7NK03dhS9a8jE6LF8LHVLJ+65I12B4aQPT8RAOBMg9kyB3NEJEZnZdZqhl/FfWSyyJHBN6yCO52NAr6FLtkSaPPMo/rCxj5kmc8tNApd+ssQUlD52+3C9SojxE7pwiqw0L6t5KQmw+XCi2SCUeBAsAdJQce/oW/q8c6BuiXhhWrxKTaiIwtITlQ1yh1k58orMarDpT9cDv/cF8a0dSJCGRaWatyyspLU0UUtTSywIA3AVsD1XLHJ8F37og8B9+aYQvcbwY29yL+C+qtrw3QVwXsWG/2xFRxHGrQ== 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=0tkxORMkLIo/2S9Hc7kF7joPZYPPHM8oLKAMMHTDOVk=; b=KlbZbgJdPBLDDV/JWlnk4o+rXbro03rHjQJLxmqcGR7dCLDYWMUOb541bsrCPnHFsKxTm86uQoHnR9LudCyyBL9gebhBWdM+LW1oMsUY2snYUsCGhOuUH9arqiDy45ogrHANlOC1eRN2cmSfuh9yCKgdRoQPNNqiBpeW1ZTLJyE= Received: from MW4PR03CA0271.namprd03.prod.outlook.com (2603:10b6:303:b5::6) by IA1PR12MB6257.namprd12.prod.outlook.com (2603:10b6:208:3e7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 20:43:01 +0000 Received: from CO1PEPF000075F3.namprd03.prod.outlook.com (2603:10b6:303:b5:cafe::38) by MW4PR03CA0271.outlook.office365.com (2603:10b6:303:b5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21 via Frontend Transport; Thu, 22 Aug 2024 20:43:01 +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 CO1PEPF000075F3.mail.protection.outlook.com (10.167.249.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:43:01 +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.39; Thu, 22 Aug 2024 15:42:58 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 08/12] PCI/TPH: Add pcie_tph_get_cpu_st() to get ST tag Date: Thu, 22 Aug 2024 15:41:16 -0500 Message-ID: <20240822204120.3634-9-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F3:EE_|IA1PR12MB6257:EE_ X-MS-Office365-Filtering-Correlation-Id: d9930b35-ca96-4c6c-a157-08dcc2eb03ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: sIe9L44ToC+uSLN13ZpmCgadKrh3LQgm+1mM1xxXS3kqM/NEKKjvZk7wWJq8lRW+xZBE+Gwzzr2gKW17oGkfE4oeCJTMzgFEStgW/HWAJfTyyyLWXqoSkjGs5dNaR1x5xQM63ZoZuYD9ogRfgyTOXnu8h4w+ZEhWQmc3wtPCtho0bPRWp5gn4BgjcX4G6GlSe9v3IlIcxjR630bU75eM8F3Ue6pjMkc37tM4rofhffDyZubiK+Y69gsBn8zlrkQDxdyUHM4KGSAv3ck77xsmjCZtc+NrLlnQ/uJfoSFF669pL3HmbMquSMIkZJPMKCNnLy73f7Jvq3hcBlz1I85nSzh+www5Qej/QJmeRLpDbbke3KpxLmEaE/h9COhSzxUZ9R1o/0h4MUrcvseoH4BwUFvEEfOxjuQ2yovfUxO0QGKNLQ8XDNRMpCKbEm0VTGoXMscZRRlmURHdYxu7dDUvJnD3tD3aB1a6v1AohT1EhqsQhcn/U84u26XZjDKaYvJo/SYl3z3FMfCFvU6xudVR5atRtGe1AEjOr38DUcShoWV+uYNW7pJfvNyC5o71Z/NF5IMgsYdK/JQpvprzM8IqeyJ5NN4ezSMexWCeMfplMRzeE4iC8aWIClxN7nRrAMrW1i/toTdyhZ0uG3xTHyXMTORn3rgh4NNZ1eUjTFTUCMYYV2mOpRlElDP5KzA9TvUbqoSD5uvXusV0tdnNqLCtPCpilv2phf3eehSwGjIu8OmH+Aw9ZjyYaZYM+E/ZHReY0jCdPcFq7XjlJDVbt4MZST76nO/hiO7E/nfyUC3FcS/dNZrnXo9nsIhCpkBxBKbto3SmF1sg+KJJTLXsYJqo+qnbKrjAlNyxP05J8gXLgdNdBwFieYWRDXaAG9OMP3MFlybdAcFMX/ym/CAlfyG1UXAm0uYtNfnMVUZhagoMEYNQLMo4eP3vvd7qhu18j5sM/LQVP+VCHaUhPoOntFrHOBFUSszfTH3G6Kg0iEbWSVfwNmBvZZOHEcarrXtjTAlphyGuZmAMDHQX+AS1gsB7pAFXcwxCgWPWyXz0pAxqcr3AlCmiuQYKn8U37cQ/IcVkYHvZOpGiWTU1AnqR7R4/qFDQN7VtAIgcSRW4QqEGstZ6W8AjUydFX0q/Y3hRzAX0uJyLTUl+gWzMsusakKe96kL9QAeVoq5Y9lD6coUb8E8OXFTBeLQ8RjNhykgNilc6e+aBmkrkREHfPXmJRppECN+mOCdl0CcrPUAXYUnXkcqoLulS7k0A8Sg5RCCN7tA0n3/gjFanOhDQ5YIPav6//RqkHuZMOTo9LmkOi5ogCfOovGPHHtP1jbDumA35lHGuF710VMEm5HLmmAR/CKYqcWFHSS4f50OGo51oIkquTg21OtD+WzVjf53A0JkArBEgKolp2oXUEdl63BTmN1yWQVqrrRIr/I6o3RrP4zOtBW3v3VBCMdJA/rL6MMBgxTqM 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:(13230040)(1800799024)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:43:01.2575 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9930b35-ca96-4c6c-a157-08dcc2eb03ab 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: CO1PEPF000075F3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6257 Allow a caller to retrieve Steering Tags for a target memory that is associated with a specific CPU. The caller must provided two parameters, memory type and CPU UID, when calling this function. The tag is retrieved by invoking ACPI _DSM of the device's Root Port device. Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/pci/pcie/tph.c | 154 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-tph.h | 18 +++++ 2 files changed, 172 insertions(+) diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 82189361a2ee..5bd194fb425e 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -7,12 +7,125 @@ * Wei Huang */ #include +#include #include #include #include #include "../pci.h" +/* + * The st_info struct defines the Steering Tag (ST) info returned by the + * firmware _DSM method defined in the approved ECN for PCI Firmware Spec, + * available at https://members.pcisig.com/wg/PCI-SIG/document/15470. + * + * @vm_st_valid: 8-bit ST for volatile memory is valid + * @vm_xst_valid: 16-bit extended ST for volatile memory is valid + * @vm_ph_ignore: 1 => PH was and will be ignored, 0 => PH should be supplied + * @vm_st: 8-bit ST for volatile mem + * @vm_xst: 16-bit extended ST for volatile mem + * @pm_st_valid: 8-bit ST for persistent memory is valid + * @pm_xst_valid: 16-bit extended ST for persistent memory is valid + * @pm_ph_ignore: 1 => PH was and will be ignored, 0 => PH should be supplied + * @pm_st: 8-bit ST for persistent mem + * @pm_xst: 16-bit extended ST for persistent mem + */ +union st_info { + struct { + u64 vm_st_valid : 1; + u64 vm_xst_valid : 1; + u64 vm_ph_ignore : 1; + u64 rsvd1 : 5; + u64 vm_st : 8; + u64 vm_xst : 16; + u64 pm_st_valid : 1; + u64 pm_xst_valid : 1; + u64 pm_ph_ignore : 1; + u64 rsvd2 : 5; + u64 pm_st : 8; + u64 pm_xst : 16; + }; + u64 value; +}; + +static u16 tph_extract_tag(enum tph_mem_type mem_type, u8 req_type, + union st_info *info) +{ + switch (req_type) { + case PCI_TPH_REQ_TPH_ONLY: /* 8-bit tag */ + switch (mem_type) { + case TPH_MEM_TYPE_VM: + if (info->vm_st_valid) + return info->vm_st; + break; + case TPH_MEM_TYPE_PM: + if (info->pm_st_valid) + return info->pm_st; + break; + } + break; + case PCI_TPH_REQ_EXT_TPH: /* 16-bit tag */ + switch (mem_type) { + case TPH_MEM_TYPE_VM: + if (info->vm_xst_valid) + return info->vm_xst; + break; + case TPH_MEM_TYPE_PM: + if (info->pm_xst_valid) + return info->pm_xst; + break; + } + break; + default: + return 0; + } + + return 0; +} + +#define TPH_ST_DSM_FUNC_INDEX 0xF +static acpi_status tph_invoke_dsm(acpi_handle handle, u32 cpu_uid, + union st_info *st_out) +{ + union acpi_object arg3[3], in_obj, *out_obj; + + if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 7, + BIT(TPH_ST_DSM_FUNC_INDEX))) + return AE_ERROR; + + /* DWORD: feature ID (0 for processor cache ST query) */ + arg3[0].integer.type = ACPI_TYPE_INTEGER; + arg3[0].integer.value = 0; + + /* DWORD: target UID */ + arg3[1].integer.type = ACPI_TYPE_INTEGER; + arg3[1].integer.value = cpu_uid; + + /* QWORD: properties, all 0's */ + arg3[2].integer.type = ACPI_TYPE_INTEGER; + arg3[2].integer.value = 0; + + in_obj.type = ACPI_TYPE_PACKAGE; + in_obj.package.count = ARRAY_SIZE(arg3); + in_obj.package.elements = arg3; + + out_obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 7, + TPH_ST_DSM_FUNC_INDEX, &in_obj); + if (!out_obj) + return AE_ERROR; + + if (out_obj->type != ACPI_TYPE_BUFFER) { + ACPI_FREE(out_obj); + return AE_ERROR; + } + + st_out->value = *((u64 *)(out_obj->buffer.pointer)); + + ACPI_FREE(out_obj); + + return AE_OK; +} + /* Update the TPH Requester Enable field of TPH Control Register */ static void set_ctrl_reg_req_en(struct pci_dev *pdev, u8 req_type) { @@ -140,6 +253,47 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag) return pci_write_config_word(pdev, offset, tag); } +/** + * pcie_tph_get_cpu_st() - Retrieve Steering Tag for a target memory associated + * with a specific CPU + * @pdev: PCI device + * @mem_type: target memory type (volatile or persistent RAM) + * @cpu_uid: associated CPU id + * @tag: Steering Tag to be returned + * + * This function returns the Steering Tag for a target memory that is + * associated with a specific CPU as indicated by cpu_uid. + * + * Returns 0 if success, otherwise negative value (-errno) + */ +int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type, + unsigned int cpu_uid, u16 *tag) +{ + struct pci_dev *rp; + acpi_handle rp_acpi_handle; + union st_info info; + + rp = pcie_find_root_port(pdev); + if (!rp || !rp->bus || !rp->bus->bridge) + return -ENODEV; + + rp_acpi_handle = ACPI_HANDLE(rp->bus->bridge); + + if (tph_invoke_dsm(rp_acpi_handle, cpu_uid, &info) != AE_OK) { + *tag = 0; + return -EINVAL; + } + + *tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info); + + pci_dbg(pdev, "get steering tag: mem_type=%s, cpu_uid=%d, tag=%#04x\n", + (mem_type == TPH_MEM_TYPE_VM) ? "volatile" : "persistent", + cpu_uid, *tag); + + return 0; +} +EXPORT_SYMBOL(pcie_tph_get_cpu_st); + /** * pcie_tph_set_st_entry() - Set Steering Tag in the ST table entry * @pdev: PCI device diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index a0c93b97090a..c9f33688b9a9 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -9,9 +9,23 @@ #ifndef LINUX_PCI_TPH_H #define LINUX_PCI_TPH_H +/* + * According to the ECN for PCI Firmware Spec, Steering Tag can be different + * depending on the memory type: Volatile Memory or Persistent Memory. When a + * caller query about a target's Steering Tag, it must provide the target's + * tph_mem_type. ECN link: https://members.pcisig.com/wg/PCI-SIG/document/15470. + */ +enum tph_mem_type { + TPH_MEM_TYPE_VM, /* volatile memory */ + TPH_MEM_TYPE_PM /* persistent memory */ +}; + #ifdef CONFIG_PCIE_TPH int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag); +int pcie_tph_get_cpu_st(struct pci_dev *dev, + enum tph_mem_type mem_type, + unsigned int cpu_uid, u16 *tag); bool pcie_tph_enabled(struct pci_dev *pdev); void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); @@ -20,6 +34,10 @@ int pcie_tph_modes(struct pci_dev *pdev); static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag) { return -EINVAL; } +static inline int pcie_tph_get_cpu_st(struct pci_dev *dev, + enum tph_mem_type mem_type, + unsigned int cpu_uid, u16 *tag) +{ return -EINVAL; } static inline bool pcie_tph_enabled(struct pci_dev *pdev) { return false; } static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) From patchwork Thu Aug 22 20:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774195 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2049.outbound.protection.outlook.com [40.107.96.49]) (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 9585B1D1F4C; Thu, 22 Aug 2024 20:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359398; cv=fail; b=s8+T/pS+aWHHdxH3v/AZevH/JJvtvtd3SBzhM0Gyq4HuEA0BNg9JcsIizXuY5lWLUEPEapMSdUxuybUgjMngsYp116vvEE/y4GtXt/2fW5Z3NPHukRzTJkShTFNL9znMy376BY9ITUtluw49mjP7+iZi/hzV1mecX5uYb3cnOCE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359398; c=relaxed/simple; bh=kVgWI7X5t9BwUKtMkwSy1K2pMBwxdUOBS+x2JO2o/TY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qubO9oFl1LXWGL+Gn3tuSOaNxZZVo9fQXNPE5VTnL4QQNvtgiIKw0+bx0i+tACWyIZJXjUOp/IV9tYmCyQ8OA2iSFT2bl8Zcpaxzu3g6pHKpgFbMPW/fiY42DYWBlCKIsAjtcQ1mm+zHQjdpKqquJxK9mrWikJqxGHV8czTlwTE= 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=5sjDDvQ0; arc=fail smtp.client-ip=40.107.96.49 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="5sjDDvQ0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B2+Q8l/nRljVmrPj60EjQk/LC3IxlZDiVvnuISoDD3/AuOmtA5RSyMDWxi6DAHNt1SJoqnxHXhislg3b94mvyulDqAN5f5mm30IO2RxxnzjLpIoY0HROnbIYPCPq6fXOKY01vFyQKcvJXFHc56/mEGRtwxtj74FsPorbSOuGBK/xoj6Nu560y87zhUs/+VBSoQFoP9mmmGQcVBIJJPPrImWzF2ZyskrX2bMEkn0gSm1Ch9pBPd/IozpiF8jMeg7HUhH1IXpWPvXcX0UynY4jgV2ih3dBS8J3mI2qg+o8M60zwqtD9Bo/Q0ld3M6Suw5kO1vN3YBWUajGo1QfiPv6fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=F8+wjjQWSuFUEWnxu2YLMGcrlUzuzhg00LNygpB8jVQ=; b=hutk2SQx4FB++M4Gtsm0jTstvguj+ZXvaYU4RQx34FUBEvbdXkZfm+myjr6x9HbAzqpe0ViV92aBFKtqrzPmorepsp1gu/i1WGVCyi8Dx1t2SdEL7DhODo/8o6AjtTnJndMaNex+sbE6L7CGv84yS+/EsGJdflO3V7kgVMKxSCbnwa600Din/eK+jJHRbfZhWMFrTqaNtrK7nnaUnVXeIPZTxeO4LT4cxf8GAWrRZhQrVOPBrkQv/0wUDmR/q7lOqv5pDzxXEA9pW+0UFKhXiv1GAJMud3kw/OeGAwn+Gnvy51PPqdzX2+6HYDymNG1KeulI1i+Yd2+mV+WDSoJNWA== 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=F8+wjjQWSuFUEWnxu2YLMGcrlUzuzhg00LNygpB8jVQ=; b=5sjDDvQ06TmjJTnsVAs8FfSdcGAaOYJhAihOPZd7jiR8p6DAU6Ojv0Jtl55CRg/anr8C8E71o+zUbAYsadfH8qraYlZcehhAbNBRxVwjm3fegXUth9VfSpgzZoaSb6WwSvgMojeA7OXcBelryhGoCJ0up3Oq15cTZziSAtJg1tk= Received: from MW4PR03CA0273.namprd03.prod.outlook.com (2603:10b6:303:b5::8) by IA1PR12MB8407.namprd12.prod.outlook.com (2603:10b6:208:3d9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Thu, 22 Aug 2024 20:43:12 +0000 Received: from CO1PEPF000075F3.namprd03.prod.outlook.com (2603:10b6:303:b5:cafe::5c) by MW4PR03CA0273.outlook.office365.com (2603:10b6:303:b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:43:12 +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 CO1PEPF000075F3.mail.protection.outlook.com (10.167.249.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:43:11 +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.39; Thu, 22 Aug 2024 15:43:10 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 09/12] PCI/TPH: Add save/restore support for TPH Date: Thu, 22 Aug 2024 15:41:17 -0500 Message-ID: <20240822204120.3634-10-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F3:EE_|IA1PR12MB8407:EE_ X-MS-Office365-Filtering-Correlation-Id: 8110dab8-7f6c-4a4e-93b5-08dcc2eb0a11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: SsAZy2qflMc7eaVpv/lb7qT80GrxO45enJy3nMO4hfVmQyVS8zCFXbyVPOBl8rKMWbna9QLOa+ZhMfYqJ0OrPcvIlx67zVb0E37wsZvnQKbNPFOSRKJn57xjBW5XXAZEIKj6J6WogDOQdFdfXih9K3x5MAIYl8DYoRN2dXiuIBF+gd4kMlQIMzy/1LwYEoETT6Lh3XBMhF6HawWSBEWK7TAp2g2cwGoa/dknGhLVkR0aYrrgv7Ro3GJT1vXGz8J+8VpHzLV/w7dvq6igMppXWgIsxuRDvpKQT36FTDz4lV7p275RdR9YVb4ZE5aGkqC6afCSQ7QzX6er/gOic42pEnttwDapHJAgG9kO8jmrt7woiWawgLxo3K4e/A4+CtCrhCCp9sr1FhkbIDptHtusID2gzLAStRtbhg+/upRPCqD8Qc2+rjBIJsmxZA+ZOHhaT8IfBmaSwSguiAKOym7H8+cgNrRXH2HKk4Zy016cENbGPKiwYe/rW5dFlW5zUhGmu0/C9gMHl/M6tq9+7gNVKyQr7FHEzst6xihPj5JjW00VPA//BLZjMOBKzlnflo34++YKa1K06aUXLsBaz1Oj+oYCLlVR7+DRkW9EoE93fIv12HRZTebim4lsu/SrpkkI9f5o5Dh1y6bTQWp6WqPaXQ/3YUeLzy51di2pnedFIbEPEuF74BxG3PaxHz5/8KVBeN3v/1FsXCeoI0dz+W7Sg9ufyUB1I/4QfumLs3xSSrRrsNNqwmFeZxNsh5jEDPmL7tfxXomDJGHV4XYyhGRqijLueyd4ugQ/LOxJXecZczGZqc/xeUHe4iXaBodN9sC7RdMx+zqWvTXNra2WT6UvdAeicWHvZij9d5gi0TcXpXcyw3iuAhUP8bAWh7dgVc5GW4QURMSy9oJNsw9fzOcEGSkQLKkAEVrbCuRnMJp1g/o5udYPuioCRCWwIyPd2+ISg6dKxNrh4EIMZc1QUxQooem8j97pDOBcnSN1emm8tQXByt6CRsxZMqRneEmxt4l4dCjz5UjY+xZaqx4Jx+hg8sIV6rLctj1Z5jqcLa8ih/O0DnMRWn1r61YVRZzW+aiff5DWfphkXV+ohNkkxVdO3pNGIvun2MpKhywfblSIPjIwfvbgzwiR73MVKJ4mRwtcPIso56wrRlku0msW7DB3nIQcYHTZA+yjuYzvqHE4GnCwv+fSba/HVCsI6q7b7nny8eHbmvv9ZAm9155wczFo7kvmJvNGRGALRr1BBXaI8A+c9eNxXYr7oFMszzxbZYIkOBNn8HoviCQHb/9NCtL1nSmAkbk7gEkJWhIMnzJXNKvt3x+B9zSfakCqF+HcMyLew8oRrbpdiu8/uWrYrxKAUC778o7UAOiEjlv7PowD1k1eOKJcRPF4bBvPJ8MZODaUZina8H7Ly1DoNBcNbCui2mByq5xWXiUCAukymEYZK2Up74zkGFFH/7Al33PIs2aJ 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:(13230040)(7416014)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:43:11.9920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8110dab8-7f6c-4a4e-93b5-08dcc2eb0a11 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: CO1PEPF000075F3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8407 From: Paul Luse Save and restore the configuration space for TPH capability to preserve the settings during PCI reset. The settings include the TPH control register and the ST table if present. Co-developed-by: Wei Huang Signed-off-by: Wei Huang Co-developed-by: Jing Liu Signed-off-by: Jing Liu Reviewed-by: Lukas Wunner Signed-off-by: Paul Luse --- drivers/pci/pci.c | 2 ++ drivers/pci/pci.h | 4 +++ drivers/pci/pcie/tph.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e3a49f66982d..1e4960994b1a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1813,6 +1813,7 @@ int pci_save_state(struct pci_dev *dev) pci_save_dpc_state(dev); pci_save_aer_state(dev); pci_save_ptm_state(dev); + pci_save_tph_state(dev); return pci_save_vc_state(dev); } EXPORT_SYMBOL(pci_save_state); @@ -1917,6 +1918,7 @@ void pci_restore_state(struct pci_dev *dev) pci_restore_vc_state(dev); pci_restore_rebar_state(dev); pci_restore_dpc_state(dev); + pci_restore_tph_state(dev); pci_restore_ptm_state(dev); pci_aer_clear_status(dev); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 289eddfe350b..d7c7f86e8705 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -572,8 +572,12 @@ static inline int pci_iov_bus_range(struct pci_bus *bus) #endif /* CONFIG_PCI_IOV */ #ifdef CONFIG_PCIE_TPH +void pci_restore_tph_state(struct pci_dev *dev); +void pci_save_tph_state(struct pci_dev *dev); void pci_tph_init(struct pci_dev *dev); #else +static inline void pci_restore_tph_state(struct pci_dev *dev) { } +static inline void pci_save_tph_state(struct pci_dev *dev) { } static inline void pci_tph_init(struct pci_dev *dev) { } #endif diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index 5bd194fb425e..b228ef5b7948 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -483,6 +483,68 @@ int pcie_tph_modes(struct pci_dev *pdev) } EXPORT_SYMBOL(pcie_tph_modes); +void pci_restore_tph_state(struct pci_dev *pdev) +{ + struct pci_cap_saved_state *save_state; + int num_entries, i, offset; + u16 *st_entry; + u32 *cap; + + if (!pdev->tph_cap) + return; + + if (!pdev->tph_enabled) + return; + + save_state = pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_TPH); + if (!save_state) + return; + + /* Restore control register and all ST entries */ + cap = &save_state->cap.data[0]; + pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++); + st_entry = (u16 *)cap; + offset = PCI_TPH_BASE_SIZEOF; + num_entries = get_st_table_size(pdev); + for (i = 0; i < num_entries; i++) { + pci_write_config_word(pdev, pdev->tph_cap + offset, + *st_entry++); + offset += sizeof(u16); + } +} + +void pci_save_tph_state(struct pci_dev *pdev) +{ + struct pci_cap_saved_state *save_state; + int num_entries, i, offset; + u16 *st_entry; + u32 *cap; + + if (!pdev->tph_cap) + return; + + if (!pdev->tph_enabled) + return; + + save_state = pci_find_saved_ext_cap(pdev, PCI_EXT_CAP_ID_TPH); + if (!save_state) + return; + + /* Save control register */ + cap = &save_state->cap.data[0]; + pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, cap++); + + /* Save all ST entries in extended capability structure */ + st_entry = (u16 *)cap; + offset = PCI_TPH_BASE_SIZEOF; + num_entries = get_st_table_size(pdev); + for (i = 0; i < num_entries; i++) { + pci_read_config_word(pdev, pdev->tph_cap + offset, + st_entry++); + offset += sizeof(u16); + } +} + void pci_tph_init(struct pci_dev *pdev) { pdev->tph_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); From patchwork Thu Aug 22 20:41:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774196 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.70]) (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 C7FE61D1726; Thu, 22 Aug 2024 20:43:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359413; cv=fail; b=av/Yuol/oo+K7GXH62s3HdryU6/bNak4tVcpSng0zCfHTUyghwR8nVrrPeNePKrY8z2HwvG2NJ2FDWsRP+lPxgs+4DeogFOmyZTHPgezvbY+sy6GIgI0qKcI86yt9LxgXfd2atiL6RndqAoLsxZcL1TUMjou9O0JawvDxuIqO04= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359413; c=relaxed/simple; bh=UgB7UbuKvXBpdONd15kK//IZLjtAnTlhoGrNWvF8ayA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hgalKlME7UvrdPla83ouV5JcidYkJSs5HBURy6B1di8fkq4/9lrDsyH0QSqSxYKuj9lYfDUKEibTRdRcGTSIrAg508WmCk6iZfsgVYBx4B6DECasu8qnKbdu1kKB0U6PzVgRntHU7JzKl4T69S4adV9kalTVuZ1HcWFlRDTfMO8= 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=b1rODSUN; arc=fail smtp.client-ip=40.107.223.70 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="b1rODSUN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cu+GZFKFr7Z9YxlsmwZtbjLF1chBN8aMp38f5Fx3oyetrHKgp0voNS0WvthAz9SwTe/G0qaQlZeve5QZ+43KOq4TsX8EEITnI/L+nKTxg5vqSfga+1NHm7wlOdo8PIClLJmAhOptK9rkSRUa8hvjLMZt+77SNxRsafpX2byWOMVG6BR+FGA1UZELOkAfR/XjCYQxwZzYkbbWh+NlmXkMHnZxlEtdA/5kjzNCJne/5ZLXJS1kOQpcrTYLO7cFIkTCbzlyz+LLtMgQ2i2BTUAyq/zCr8PN9Mfo0yofyR4K1mrVjEQVcw/0FT74ORZtj4n8wtkyous/jcqB8fuvfweKNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HzVoIMKuwHwM4kRfqn+mcm06D5WgK0PdGib+32oNs6A=; b=X9fpVTA5B5lQu31T0Dnl6vTFDgM6atXMjGOO8xSt57rua8xL/vPgJG9JtRMsYeBTELQsxG+DxTtNlG5ePMJLb+/I9ypwJJUyqJsqtiAb9ZPjNgZQJVfzKbsegAzHZ8vrGPGP7ZkBNSujrZxNeBJbR8dAamIxJjkU7wZHtHempfR127fRqZh1ca12xNX6xdKNN41gVjGGsoNYeSJw4JsuNKCogkT6tlUxabiMtaGWSqH7WMCLmZnRc+P6mIsDfsQ7IT2JZJhMQBTI7y+i1hjQ6P1VUcQ4m1k0+8w39x0+Dupv59X3qepFhO6GVhfPrK4QFLJKtvXADbAKavBTAsnDqA== 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=HzVoIMKuwHwM4kRfqn+mcm06D5WgK0PdGib+32oNs6A=; b=b1rODSUNRPn2mI2hxJMazxObdhNiBBSfI6710u6+MLkhv9UEYZgbrOXaIiA/j9eUjMOgSbzPtZKa8TPgESbu1gjGlEljWyMYhgTuk+qtOCgFJE//pnqanDF+iax/g9CYNCITkShkKbpfYI2/u3xvfIaACiQuxkppp3ViBCtxLpE= Received: from SJ0PR03CA0375.namprd03.prod.outlook.com (2603:10b6:a03:3a1::20) by SA0PR12MB7089.namprd12.prod.outlook.com (2603:10b6:806:2d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.17; Thu, 22 Aug 2024 20:43:24 +0000 Received: from CO1PEPF000075F0.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::bd) by SJ0PR03CA0375.outlook.office365.com (2603:10b6:a03:3a1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:43:24 +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 CO1PEPF000075F0.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:43:23 +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.39; Thu, 22 Aug 2024 15:43:21 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 10/12] PCI/TPH: Add pci=nostmode to force TPH No ST Mode Date: Thu, 22 Aug 2024 15:41:18 -0500 Message-ID: <20240822204120.3634-11-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F0:EE_|SA0PR12MB7089:EE_ X-MS-Office365-Filtering-Correlation-Id: 600e753c-2e11-4817-d178-08dcc2eb1118 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: aAqEPtYLkJxV19IVKBEcczZuy0HODJn1neK1DEPxUuWEBt8cpKUdG5KzRbmzo4BHvCv3XAejgGTRZcfoFPJVARSn6lQfBiUPyCbxy6UsLkrcLUwGgCRM2cjd/wSIVObQuYffGgxWhDvoEEaKt9E9JhWb5cKAx7fRScj4txmBfnzHi0ly0VVyfLDnVqw8fym+mPRtiFuVD5Dx/4ZNWvPqETPA4u4fWtN7bgII9IO4S6DZZLzrfQlvJEY69UyHymjIZoKooPs5e7fz7SaFUy5nsGKQjiS7R3cROoRGMMCq5sSlkQXQdG0zPXFKeySK8ze1q4tWcafZPeo4HELAv66a2c3nGBz/O9PSQ9QzZA09WG0e+ahls8GDxLudtMqkrdAtLmOw1GdzfBiEinMcbfN57YcTfNXLYxV1419RxZsiJ/JQJxdFLW5TeGvhirNbFm7BWt+QWkHHKkN40JK8OIPR5Kkgv5M7Tgvx2DMzmthsbn+9K3Yavx8NMh/iswJ+TbyJiY5Rh2HT2ah6IRfzKy5vfxh1NOzEzHIAQEz04VCCZcoS/h0jttfFZ4LNdWGRsngqh7euMaqdq4WPVEodCAkKjIJOdveVpl0nSfgOHqxdWIUGkL8xEjYOigMpSuKaYTH1BsLASRLLTRDjIKHtyCrAq6hk+A4Z1p0fW4K5K07Qm5Ago6I94cRigsJqf8sbBK6gNaSjSW5vNvnr6GitGv09Hz77/d//16RTscEC9i+3ThZ004LoPeFxxADi2jF1KChne7Dp24OadJ2lCDeVT5BoHjU5MWjwJ5g5zWEOn9EiOaM8+diy6xqtvjGQfArgHs2tdldG9346KQC56NfNy7BPFlG+sRmG6pdYUAJ5BMSHc2XwRHpB0/Zr7ab7Y1sXwLlWl1Llxj1mpqnLQeqt2asQVcZpf59XsdjYB0P7NkET4LvCiGjUZDnSxFBZTSbEgTczViHOxLuH48NARGIBBTHc1JZNAmDz/A5hzgqaqRqmCdDZGTMIWTTgAV8pX5speG5yhsZBTq+u7/evRTn0/vFCig0N0bftWWZ/5NcK+nGSYzeVK5Xs9RzZ45L5NNSCa5aHkbPxkQQzQdtSl9TqJPKTq1WHy4W4i7OxhuEZoSxMCpAPQ96gKVmPAbCubi3amAfyRj2h9+E0mNL46s0UVc2aG8OZO8YkKgfzOYsgU0thrD1eTGjoyh9sW9af0LNt8QPZzs0TAaF2dn53jpsI8p6WfQI2KYFEbrTTV7Te2SeDF/nUMK+HkQsz2vYb2RLAwxSZvZoObT0qxrArJogO6HCUZKiQHIPEnzXj01torLPBTAtPrIq6ASog+5vIcgmg1V8aCDB/kmGk+WRUPopNyCeijt6Ls2h72VA8r3Ux6GItGitFY6eCuRbVK1hX7S4AVX12MBrTJFjwzt+yE0cGzyG7Wt0ihbwKFvLbqTg0vzI6O42KUOne3h5IqLm3VCtB/wso 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:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:43:23.8147 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 600e753c-2e11-4817-d178-08dcc2eb1118 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: CO1PEPF000075F0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7089 When "No ST mode" is enabled, endpoint 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 Signed-off-by: Wei Huang Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ drivers/pci/pci.c | 2 ++ drivers/pci/pci.h | 2 ++ drivers/pci/pcie/tph.c | 12 ++++++++++++ 4 files changed, 19 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f1384c7b59c9..ed2ee97cf7fb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4617,6 +4617,9 @@ nomio [S390] Do not use MIO instructions. norid [S390] ignore the RID field and force use of one PCI domain per PCI function + nostmode [PCIE] If PCIe TPH Processing Hints (TPH) is + enabled, this kernel option forces all Steering + Tags to be treated as zero (aka "No ST Mode"). pcie_aspm= [PCIE] Forcibly enable or ignore PCIe Active State Power Management. diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1e4960994b1a..88aabac354c0 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6870,6 +6870,8 @@ static int __init pci_setup(char *str) pci_no_domains(); } else if (!strncmp(str, "noari", 5)) { pcie_ari_disabled = true; + } else if (!strncmp(str, "nostmode", 8)) { + pci_tph_set_nostmode(); } 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/pci.h b/drivers/pci/pci.h index d7c7f86e8705..54d74f5ff861 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -574,10 +574,12 @@ static inline int pci_iov_bus_range(struct pci_bus *bus) #ifdef CONFIG_PCIE_TPH void pci_restore_tph_state(struct pci_dev *dev); void pci_save_tph_state(struct pci_dev *dev); +void pci_tph_set_nostmode(void); void pci_tph_init(struct pci_dev *dev); #else static inline void pci_restore_tph_state(struct pci_dev *dev) { } static inline void pci_save_tph_state(struct pci_dev *dev) { } +static inline void pci_tph_set_nostmode(void) { } static inline void pci_tph_init(struct pci_dev *dev) { } #endif diff --git a/drivers/pci/pcie/tph.c b/drivers/pci/pcie/tph.c index b228ef5b7948..f723352adcf5 100644 --- a/drivers/pci/pcie/tph.c +++ b/drivers/pci/pcie/tph.c @@ -48,6 +48,8 @@ union st_info { u64 value; }; +static bool pci_tph_nostmode; + static u16 tph_extract_tag(enum tph_mem_type mem_type, u8 req_type, union st_info *info) { @@ -433,6 +435,10 @@ int pcie_enable_tph(struct pci_dev *pdev, int mode) return -EINVAL; } + /* Honor "nostmode" kernel parameter */ + if (pci_tph_nostmode) + pdev->tph_mode = PCI_TPH_NO_ST_MODE; + /* Get req_type supported by device and its Root Port */ reg = pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); if (FIELD_GET(PCI_TPH_CAP_EXT_TPH, reg)) @@ -545,6 +551,12 @@ void pci_save_tph_state(struct pci_dev *pdev) } } +void pci_tph_set_nostmode(void) +{ + pci_tph_nostmode = true; + pr_info("PCIe TPH No ST Mode is enabled\n"); +} + void pci_tph_init(struct pci_dev *pdev) { pdev->tph_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); From patchwork Thu Aug 22 20:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774197 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2055.outbound.protection.outlook.com [40.107.102.55]) (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 5CD461D1726; Thu, 22 Aug 2024 20:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359421; cv=fail; b=efpL27RGrVnJG9oKGi81hzKCVO12EwUOIJGWcyc/WzrhthYVIlXrY4CaFDLf/N8qTa2LSSzQW/DNytgUhbCmdeGzhLR1KxT4gTn6SSzgZwj7X+n59xYR3bkB9NLdi719AeB6DNueYrU0vbHC7GDvvrqMCq6DLmMv2UrkV1lJGDU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359421; c=relaxed/simple; bh=ojiNqcbNmSLQVg/A8B/QPA1ivsPeQvkTyq/kWhj4esg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pS6s8T8MZiKUKllsz0lffmcq8N4goAZjHSPX1u0U2lZbxqu0V9+3OpRjBPgy3twbgm2zT1jsUSC3tvXQ/MxuQ+L20XjAOaxq+JjHN7igKfc0R0W1lX6bkt3csvv0p0dKRHCb6XQrKfwl0ZJ+HnC6KvdQb3sfrJsu2rUiZiqECU0= 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=ZijJeHgm; arc=fail smtp.client-ip=40.107.102.55 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="ZijJeHgm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZTksz7qWMqY46cP8b99OMoW8wkhRgfU1MWcxkUEpgpreZ5A4sbjAdvg7o9KdYFrP9vCTnvQZ28CH+XmMJvsxunyWPGkL0hZfLjylITKXjRUnLcp4RSm2DNa3lQjXzjbXO90ZLL3Z2IV1Wn/Z3LKETpZ9Y9Sqwg+cqxiIfmpS+jBRrpfDNAAzKYlHcd4LNgDJL605lrW0yr1QOXyw7Rl4/aTajvc6+KaZKEBCPn6O430Kai1WAm2obFfkpXjgbfx1y4trP1sYynMYDOZqpe+HJerT1MUA+izysxcmKy3mgFGWVLRWl/+hsZZ2aFJe1L+weJN2+RNBeEJLynHKUwGnWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=B+G3BWJJ1jj7LIMRbC9aMihk2XTyPQkizDvWAIfQ7Tw=; b=Y2gWNF3W2p1sIg+t0jiiRERy1bcIYcOJdTaLhAi//5lK4t0k4kwnd3JSgxX4i5XlPk8cF1yuAPVwhtxKXyZhuqkwcEbQLSpzQMDLNplFnfJgw5OGr1gGHSLfBZI6KhFvSjrMO6JfvdpeFG2rY4Be08vsdrENQqLgCTm4luccozBm3vi5Fuii7gqa9TDORs14eBSScAIvGu/Z2cYYb+WacLgvDtXPQMAH1Or3h/ceE0q4OKHqLYVSXqxqORKj4/AOAApi+Ut3yLEuCVjFK9T1qqX1RKzhU3w0wDV3Smj4be/q88GiLUammqDp2GRdB1vuq85ZaPcSjet7LnUIC5cbRw== 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=B+G3BWJJ1jj7LIMRbC9aMihk2XTyPQkizDvWAIfQ7Tw=; b=ZijJeHgmRWckpRBJ/vI/4WCJhqAiNdb0fl/9H86rOgKxQBUWA1jdKgpH3iE8Zc97BmVQDcLdg0ZF4xhgSP1qtoF3rRGTibETgrMiZD1AN7ee1UWugKqxaa5stbj+h9BAW+Jp0N1RMvawaceIDLrh7beahBTMmBx0MlMmkk0LWgM= Received: from MW4PR03CA0297.namprd03.prod.outlook.com (2603:10b6:303:b5::32) by SJ2PR12MB8943.namprd12.prod.outlook.com (2603:10b6:a03:547::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 20:43:35 +0000 Received: from CO1PEPF000075F3.namprd03.prod.outlook.com (2603:10b6:303:b5:cafe::a9) by MW4PR03CA0297.outlook.office365.com (2603:10b6:303:b5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:43:34 +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 CO1PEPF000075F3.mail.protection.outlook.com (10.167.249.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:43:34 +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.39; Thu, 22 Aug 2024 15:43:33 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 11/12] bnxt_en: Add TPH support in BNXT driver Date: Thu, 22 Aug 2024 15:41:19 -0500 Message-ID: <20240822204120.3634-12-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F3:EE_|SJ2PR12MB8943:EE_ X-MS-Office365-Filtering-Correlation-Id: 49c29be6-6341-495e-20fa-08dcc2eb17a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: QpM5mbQ4dbSg9AMn+VuU7viVaQF/9Y8rx6p3STrkV+V/mTVZJX6nLuO1Kwb27fxBcBEn3qkTJV8RqXsAPM0CE3mien31zqiepUM+ugKBH2OROztRo4hCdCLY3v1WcRXbK/aaIwdLs4dJ2eKZFs7G17g/1x/o9b4HsHZ+UsQ7E2LXgY0AscniAjAceDaB68aiQMOn24GvImALVAVwAL/LquOski8zxQz77LT8lFsUHtJR9/PNTE+BAedN+LjKEtWdNIO9Ldj7mdcP3uB7S0dpypYmjyHuqV4Fk+9mMsxK1VEWopfYMiNciFQtZjkFlwbWcbJlxf4H4v05JxyEobY0QZ98ImdnEWXfdJ6w5xR++0DwjeO0XcRO40zymlh9fAHGsbVAkP7DLqmnr4TThsh0xDltz72y4BeJHIn7lVX/C3rWvlMsndWLu0Nf3Y127ZjdY8ATzDMMvbQV3rkAaKmSoJ29zGwZdLK1q3osZcewVHH783pYVOtQUhfF4QhKa4pyj+MxQnon0uONAYmWL968LaeUhL1BbDh95nCgi2Vq/vGHH7OOpQ+6m2Q0XADO9ej363cu0GSomHvQYKQBWZRgMuTKnVo0SSqJ0WFYqfulOdzOcrV5b+ZpdSNHUGMTGjp4D7XpcxrryzYUGcbyfZgCJLFEVzViQjoJYmJMSefXOcwOZRroCMQd14Tqrue42RDWfPOCPm0bAImmGnDQDiDryGAX+6yetyEZ2+kt4cEFJqND78y+syxUTFLHgnARCOSVWILgu9YsH2Gfwp24IP65ZSdzZyYOBRd/QRlkXXlxLiPz8V6n7gWQMmIyG1AacVEPOkm3mVdZK9xWesuVM1y5IR8v1KAaFWEMzXlJe7QzSOZl+BbeeC0fRLTueEYcKumLLOaFueX1tYqqY73vqEaaAT6tjCCbnmJz3qM0Ft77Y6DdtjmwjMtTUZuQpCSxebhN7fIArzYDrO/QoVZScawEfDSd1yKYMcR4AlhaYo/SuVVxYePY5IexCVd/dYDWxFnTSi/528Yz501SgJUzFRUZz0dK2a472jfcR4ThkX1oIWVtJD8CvdE8CdU26ML405Wwdgyr/eCHLRF0SxjdT3W6FVt5fy2O6QnSNMVxLwj7Qv3UHF9Pljp8qhN68yCmJ3/1nJy17oV0t8zJi+bZbahZPtVWdCsF9GaUpuuBIE5HYNjbTpJ9zVOSJjiFGZ+UxWebR1RHjyg/eWWMJzetvU93oT4lDxZ8CKp5H2atjizo2RoMxLG3xFFv0E33E7hCChfQwzB/3HqyUqVCy6cVDTwlMvit0DA2plf5lj8HQPZDHzpfmz5kbTUoJuyipMOrPqEzInQbWxXffdcYj0GcT6S0XjZzqOCiNfWgYRjiJ1kKfxTNXOdOQlisgY9In9SlzVPINIdBZLlFaoudO9EYeqWoerM6x+Evf6AAsivQiF/lnVGrzScW82gZc/99SwiYHUlY 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:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:43:34.7890 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49c29be6-6341-495e-20fa-08dcc2eb17a8 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: CO1PEPF000075F3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8943 From: Manoj Panicker Implement TPH support in Broadcom BNXT device driver. The driver uses TPH functions to retrieve and configure the device's Steering Tags when its interrupt affinity is being changed. Co-developed-by: Wei Huang Signed-off-by: Wei Huang Signed-off-by: Manoj Panicker Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Andy Gospodarek --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 78 +++++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++ 2 files changed, 82 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index ffa74c26ee53..5903cd36b54d 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" @@ -10821,6 +10822,58 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) return 0; } +static void __bnxt_irq_affinity_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct bnxt_irq *irq; + u16 tag; + + irq = container_of(notify, struct bnxt_irq, affinity_notify); + cpumask_copy(irq->cpu_mask, mask); + + if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, + cpumask_first(irq->cpu_mask), &tag)) + return; + + if (pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag)) + return; + + 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 void bnxt_release_irq_notifier(struct bnxt_irq *irq) +{ + irq_set_affinity_notifier(irq->vector, NULL); +} + +static void bnxt_register_irq_notifier(struct bnxt *bp, struct bnxt_irq *irq) +{ + struct irq_affinity_notify *notify; + + /* Nothing to do if TPH is not enabled */ + if (!pcie_tph_enabled(bp->pdev)) + return; + + irq->bp = bp; + + /* Register IRQ affinility notifier */ + 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 void bnxt_free_irq(struct bnxt *bp) { struct bnxt_irq *irq; @@ -10843,11 +10896,17 @@ static void bnxt_free_irq(struct bnxt *bp) free_cpumask_var(irq->cpu_mask); irq->have_cpumask = 0; } + + bnxt_release_irq_notifier(irq); + free_irq(irq->vector, bp->bnapi[i]); } irq->requested = 0; } + + /* Disable TPH support */ + pcie_disable_tph(bp->pdev); } static int bnxt_request_irq(struct bnxt *bp) @@ -10870,6 +10929,13 @@ static int bnxt_request_irq(struct bnxt *bp) if (!(bp->flags & BNXT_FLAG_USING_MSIX)) flags = IRQF_SHARED; + /* Enable TPH support as part of IRQ request */ + if (pcie_tph_modes(bp->pdev) & PCI_TPH_CAP_INT_VEC) { + rc = pcie_enable_tph(bp->pdev, PCI_TPH_CAP_INT_VEC); + if (rc) + netdev_warn(bp->dev, "failed enabling TPH support\n"); + } + for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { int map_idx = bnxt_cp_num_to_irq_num(bp, i); struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; @@ -10893,8 +10959,10 @@ static int bnxt_request_irq(struct bnxt *bp) if (zalloc_cpumask_var(&irq->cpu_mask, GFP_KERNEL)) { int numa_node = dev_to_node(&bp->pdev->dev); + u16 tag; 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); @@ -10904,6 +10972,16 @@ static int bnxt_request_irq(struct bnxt *bp) irq->vector); break; } + + bnxt_register_irq_notifier(bp, irq); + + /* Init ST table entry */ + if (pcie_tph_get_cpu_st(irq->bp->pdev, TPH_MEM_TYPE_VM, + cpumask_first(irq->cpu_mask), + &tag)) + break; + + pcie_tph_set_st_entry(irq->bp->pdev, irq->msix_nr, tag); } } return rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 6bbdc718c3a7..ae1abcc1bddf 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1224,6 +1224,10 @@ struct bnxt_irq { u8 have_cpumask:1; char name[IFNAMSIZ + 2]; cpumask_var_t cpu_mask; + + struct bnxt *bp; + int msix_nr; + struct irq_affinity_notify affinity_notify; }; #define HWRM_RING_ALLOC_TX 0x1 From patchwork Thu Aug 22 20:41:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 13774198 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2055.outbound.protection.outlook.com [40.107.237.55]) (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 A22E91D1728; Thu, 22 Aug 2024 20:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359441; cv=fail; b=FhVpVsJhcLBv6GCQN2NID+zcpkrVVS01vr1OgelSO/G+i8U8BdJusUspqwzYeN0zFxpuMx6l8GTinlz1jzDsuOWBgA9j2OOL2F7po8LS7q2nf/Ip8wAHx8nZyynjzsQB2/n6i4SnVVScwsW6cqoNH18JsiC5JVhnxqwbs+Rj+Mw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724359441; c=relaxed/simple; bh=k0CMdfeVPacNL41VrFyrAgKKGSdNVISUtHCOPmVvLdw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oCPHaxEs3I+5lChOWo1T2ktF3MDeAsFihkkzQU/xDnBnBb/MO9BOQl7PY2f6a7iMXsENwsdten41R7le2y8JtLRhpddw4M5Z2uxiBMVoUtbd699kdFGZKUEg+PC8yxKCA66VdOY8KnFI3uumdexE+rP5+3VQvsWK3sSncqEPPVQ= 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=gU67GFC1; arc=fail smtp.client-ip=40.107.237.55 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="gU67GFC1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LhP7owSuIfZDV7QrBsqTRPsbiC88QunJOinF0qPBkSEQJyhxOSMNYs/nRjJrzULb8eYcKR/hr63nOh9pjPUMh4DdbAg2WVS0iXFx7YD5R3EBD9swrSCrNUp6ZO9GR5IHWk41naZB91rhrtPS3W46Vyt/Ag9HZjTWR3q25qH1Jz2tQIFldZLE1hg1h4vkdCGMCyHEWMzkzgM0ejlca5+WNX3Ri75IueH96RI/Y+J2XkD9u9jmQQmnNRH8wVo0rgH0TUMSFTzxveWSlbpP8JySpJKZECmw9qi/6CtUtmOna+NFHsqUWFLvWGSuMgeByGLczS27zLaQGO5bY6IAo4o8LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=EwHk0OBuSEKgHsoLxc5/ykm35uLmgtEAzk4cXg1Kyv4=; b=EkUWe2BnfA02emWJoLEfTPPPEqRL0SlCUUp406yVEk+ZX3v6Dc1Fw2l9jBITy0BeXbQs0t9hBBQCAWvBlxh6MnNxmyuD4h86VSksQr6YFm+z1veTBIZJRPizMU6nhQ2ovKYwKjZhyRe16yCalALtxwrUnBv1SKm59JhLgcMJqvOjZ8B0A0YEFwuxHhcj/sQRACJQOKkxaHRw9RzM7ar5kjCKQV8aJvmIvY9MEMj50/R0nJrt2ehr2nZ0UE95LEFY3ON5cf8CIaXtjY5ccpC4fCliqM+FGmLcKZBHuhw8LUe1VXObMGD3TtQbfjwcgFIIWBqGqnazhfgAvfEowi00iQ== 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=EwHk0OBuSEKgHsoLxc5/ykm35uLmgtEAzk4cXg1Kyv4=; b=gU67GFC1YuJAaqhLvSF7ar0f+lnUsMTbCMSBp6RQzDjLLrC8uwNJcZaZMPzXbqD7w/JsEiLjdbl1gOzPnAcV8VnLTdV0w7GEWEPoDQhCCA0Xya6vec8taLHEGZkgDIs/nPYlSjE/wrj5Wh0BSnCeLDCPfATMWagvxZNyJ81DrQY= Received: from BYAPR03CA0024.namprd03.prod.outlook.com (2603:10b6:a02:a8::37) by PH7PR12MB9101.namprd12.prod.outlook.com (2603:10b6:510:2f9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 20:43:47 +0000 Received: from CO1PEPF000075F4.namprd03.prod.outlook.com (2603:10b6:a02:a8:cafe::2e) by BYAPR03CA0024.outlook.office365.com (2603:10b6:a02:a8::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19 via Frontend Transport; Thu, 22 Aug 2024 20:43:47 +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 CO1PEPF000075F4.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7897.11 via Frontend Transport; Thu, 22 Aug 2024 20:43:46 +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.39; Thu, 22 Aug 2024 15:43:44 -0500 From: Wei Huang To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V4 12/12] bnxt_en: Pass NQ ID to the FW when allocating RX/RX AGG rings Date: Thu, 22 Aug 2024 15:41:20 -0500 Message-ID: <20240822204120.3634-13-wei.huang2@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240822204120.3634-1-wei.huang2@amd.com> References: <20240822204120.3634-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: CO1PEPF000075F4:EE_|PH7PR12MB9101:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f30e823-22fc-42f8-2ebf-08dcc2eb1ed2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: Jc0/Ca1j0zxQoyJXHrVMgqC8vv7Mw/7kLqHlnAKhHvYyX0HyagBeCM50x5b2AfmIl58js+3iI00V1owMyPm+CPMye1R6X10dhWS3LDJVc/IKZeS2yVGVNVbZhP0O4dFtXgJGVX/mZMPz4iIDXD10vu/VJYbIaq3OmYvQBEhDywhHxJsH8npiLSpbAHyEm8PD7M1ONLLK1rZb3xInygQ+83kNMAXbmphHOywo6ngA+wrxmYb2toZWzvmcVEMcAvKgfaPIeUmWy3gUhr22OsKlvoh4v5KXV+aft3YfwaUzy+v629y4h4cbzIDxZlL0Zixz3kuEnn0dwBhEknLd8/z/CfqQuFZZx9LgzbbCi0PgEXNSC4qMdFsNIij5YDCXuNUY29GbSLbde95iUnKU5mDbtt3nFxAti0gWE1qTRq/IK0yX5t5VuPRMWHdMA30HTw0vcDdcV7D5Am/KZh92uYY2oMGfEyvnu4inZb8Ji6gHQ8lmcuxIBUw77tbpZ711C0M+Vos+o4/pBYByi50TailyAYH1ERAC8P0NgMqvMYf/piCf5nAl2lPuk7aksFoc0LJtaHUkWx7nBzKt2UjJJhlKLtY2SIRUZd5cHK2CQvIPpDjuES/Hfd3gLqEjU7K/1bzNS1QNQvJ7UyQQVkELbauxODg4U0OmwxyARqPHsymm/RQ11boMN1D94Kw0UjIe3OsAJS3J8G0aUtrfKEBDK5Wxn3QBe0vNF+mXaFfsksilvnZ3lLM96ndz7T9paa69+hBbR5lBSqaNySm0EZ1PWPuKyiAmyHL5Uh+aBgWSxkULinTCmb2XqQ+6tVuMc/Um7WB+N7kkPhbQQ+eWzhNhfpBu5vSS1HYpKUXd35YAEa6Yl5t1KHX6W8f/z6X/VlFL3/pwwKrytnnXFR66QnFA3oLbRZB/Kj47rA7oyTEoEmw06nLkzd/lcfApcvKW5wTB2ECUEyYxWGIgFbWoLngN0B0nIhxjXeK6VPnINwytR+sPHD1dcdMEEYpOIcMOMPs8ZJCkXyih2DN2X7LjWN93Z7hzZgGv87HZmyichZjUYm6kwKcXrIEQQi76AWEr3Wvfc4dzb972AwiKnCIgxTlKXPjqtXARsK1a5v8cFZjrmQEX7pv5GfSrvxbESUez8958Uf/MnQEhbA8pgmCQti9aL/6Iqb+5YtbiouB8zBe8FEGIjrkaunyyqO3z9v5CvA842HaNaGpwUxv3C2J/BWjuQCFK6M6ZWQ1+duLfO/hj5gjwPBAWwBkt+0cgVQOIReDUdCgNkKy30dxb/st5iJkSDyhHG+zXXq32oVF/41bxqdve6+zSI4P+s7lVfKOnOpyH+E/24fkwcNXAPdKb8hHXzq2BgpkIltrMFGQ9dIaZUa/Nk8CrQHBXw8kt5yX414LU34ut8IbyaYrnLUFrJfgRwipTXXI+0xuy3zYAXhyucd7rY/GUeg5d+TFYOaS1GIiizFgA 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:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 20:43:46.8399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f30e823-22fc-42f8-2ebf-08dcc2eb1ed2 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: CO1PEPF000075F4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9101 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 5903cd36b54d..5fb46aaa16e3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -6838,10 +6838,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); @@ -6853,11 +6855,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; }