From patchwork Wed Apr 17 16:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13633630 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2068.outbound.protection.outlook.com [40.107.241.68]) (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 C540717107E; Wed, 17 Apr 2024 17:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373211; cv=fail; b=YtboqV/my7dmFr8RkCyl0hTSCiL3c7nAiFckNccIr8EIkeM7OnSV7nvi0Jmz1Sc6+nZOzrkM3mk1iPWzfpUjxuYdVVTlromXNZME3njrRkhSnw0koMyep73c1v/lq4r9EZhYKYUW14b9ESzJacDyb8dpTd8XXRK9TfltBcFNw0Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373211; c=relaxed/simple; bh=RGiIXYVRmfGJBV1HNXeAiH/lKJo/HvVSSGdFR93iLDE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=J7REGQuQi6VP3dEQtnh+3ZtmSfTrNIh6ag0mNxMa8UrUCQag5PT6YjLKRdYrgEicLEHTjTuL6O4nTnotbD16OoKTqPtLjnPqPlDvxAUB6qY9hET2+sYRqwJDCw9QkqnzaIpsLvV8pNeE9sgcW//LRnUXcVAk+dXDuEWWMTmYOMI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=loQp+CCv; arc=fail smtp.client-ip=40.107.241.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="loQp+CCv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjZ0sZ9FwD9R8C1XVgp4iYkdYejlcY464MTz24XLFqjcMCepvkLKSlQIY9XWXSS5R8kL1xZizgIxTva+jvNkWv/Suc+IG0pSMKF/bQH3Em2sEJnQ+vziurfk03xmkGFW75UPMdTuUf6kjf3nSza3CNMD8Eel5XWAClxA8XQRn3VWf4LNKHSLYMML9MvsWMoferopH1+Q9xOXHbkNIYCgI3oenWi8CSlg9SKl1oLVSgVxK/s2hehmCJAjr4vlwR2GZm/epV/013Rq7BmQuWKnUBn3k1BaVDzyiMUCzryl0gmdriOc8gU84I/0q+m+7/WGrbbwQblrwxoPCOz/Y8xD5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7XJormfUbxmrv0piWzu3dWXoF2ecnIxqtssuoVKEuJU=; b=oCt/apZU3OiHuvKJ3frKjzkbo5hcEPnzLfGImWVGtFdHoKTKbjsxWVeyEuV+zGJHafWDIsgA1P8pJ/eKYo4/d9Vs9p1oRj8/P4OIyWeEKjgQb0KyW/otudjlbFXj7ocwmgKL5cY6tU7DtgI1LYE8t7ch9nFAu0I4ipbY1E3wlp4O8GNZCwWtQlMbEs8ZDB1c6U1LCXIik1oUi9YUJfTTn70WCX1+ul51jCYTEeqeZN3/4KOCUftYMIxpVSkitAeA2sxDTwL1St6fonvqIRhdbDys/6mtr3u6o3k25W7jcz3Avq5pz0IhTOB5eR+eINrtE7QeZZpeU/k/YPZkPfB61g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7XJormfUbxmrv0piWzu3dWXoF2ecnIxqtssuoVKEuJU=; b=loQp+CCvA7SdleZkSz7wmSn1H7aeifIqB5noDu32oVsic+/LlL24+YwOydT68kpCYcfcaOzE7uuUUmRQDfnd9H5le8R37V/XVsXN7obESZL1sYm2jfPgK4fGzNd5H3Fa3UUv1A6OTrvAfaukEVqDznMymt4ApbJQAlhtjSpGrM8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PAXPR04MB8080.eurprd04.prod.outlook.com (2603:10a6:102:1c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.51; Wed, 17 Apr 2024 17:00:08 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7452.049; Wed, 17 Apr 2024 17:00:08 +0000 From: Frank Li Date: Wed, 17 Apr 2024 12:59:39 -0400 Subject: [PATCH v7 1/5] PCI: Add INTx Mechanism Messages macros Message-Id: <20240417-pme_msg-v7-1-9c6208cda90f@nxp.com> References: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> In-Reply-To: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Yoshihiro Shimoda , Serge Semin X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1713373200; l=1623; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=T7axIIwEU0hBwz5dW25mb2R9FYDj6emglE2AhxS6gq8=; b=QsAkgdc0M94P4kLwp1lMZ5Dj/5NWRiCC9kKaGAafSTD/ZJDnn3GxySi9x2PDlhfrodraChulz NHakwLBTjO2Aghxvjv9fn9zl/9UEC3OpadvC1dherDF5smYhyJDZiG7 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0012.namprd05.prod.outlook.com (2603:10b6:a03:33b::17) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8080:EE_ X-MS-Office365-Filtering-Correlation-Id: fde0befc-5c02-4aee-fe14-08dc5effd5f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bXWShc65dqa9BJ31BfhPcDTyFSCGTJkqZh8YKWgX1C4fyLwGhrpdaAd7BcMvd2o3sDJH03n++TbNkdRAfdNvC2XL1LPS082zr+IVFMDWAgTDBrgva2ALPrhSZjlj+2MKO3UJCceyLp9040dfx3JKZ7oNslajSpovQIq2kxlawRRfSGozNC9t1lzrw7VESmWvEetyfSB8DruyAB99oUpW1VcltstU3S3VP/MiUNI3eh4OcYZ8OADKps87BNx1jn5SrNeqKKGANuGkM0oQhvvVFBXZbRIDbAbLTITgYIsZSPORL99opAjtWNE4ZvfLZDGqhXVp99e2A2bO8QUOzREZKT9ncD8N5+h4pXVArfNkPGJlKBpATo5l6V0xuqfw590ssb1FbPsF4GeV0Axp87UdICLK2KeReDXy5NfIrM3yoMoTBZ19KX3P8l+MI8zKxc34R816HJzD0XbNi3O1HeyxLFiGZgHCb0QUuB4hPEN6Wo0s5pxeujownXw3Wn0qF9JduQ1CI17f8c4VTmcxDijW/57efkYXFDCtHZb86MMug1oQ2Ba+bEAvxAGwJqv3YJjESgsVA+/Th/tQ7uYG4WNv364uZtd/X74Z7jBuMpi/NDbiNCU0Pf5O5bWg8QL8zfeBIYfFHP8bQea9B6Ng8WPI1niDg4HYoGPXpiQUyX7DR1k9SIR09fTfOjQj4UhQ8nyHmLYr+i5TfZcrp73BwYW0y/6fVGWN3JDD7UoVYxzlNe4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(376005)(52116005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?M5LwJ5r7ATx1LyWtuWUgA4bGjTH3?= =?utf-8?q?lmR2gjvhYCYNEp/ZQA/Zul/erevdUI29qBGEketP5t83AZNbB2EsFvL3hWE+ywffO?= =?utf-8?q?5Hpzyuj5lq+W6pD5PITvxlpz2hN2Gd6zwaTO8KsWsjOxKVswiYBIXMYoT081c+lFc?= =?utf-8?q?lx7fJ3NBb4916/hAOVy3IUUTDig8sT/0eUeQjrPlTPB/uulgPLStoxiKBCTlOK3qX?= =?utf-8?q?2PNP+JYEmfT7N+IZqTbOB6Z2ef3kFmAZr511g8uRUy6xX+N8+RbzJyanmyxBOu63Q?= =?utf-8?q?X2QYjCZn7QIPfSEKx+FtdaC5BjtHv9eiJ3+t51PoMNk3oW4ay04cK5IfqW+XhfZY2?= =?utf-8?q?zuAWPMz9He+dGrw3HlSvJbW2xdX0KLvyPNKwqJJfEOzSTmTQFqmfbLRDu49O748lc?= =?utf-8?q?WWv00P0NqyJRFcoM17DnhTWYx6h0d1O71M/4M8c4QNapyNDJ7pCnF8ZBGgu9DtRKg?= =?utf-8?q?q9I7+M5Wz6dG7KwgmJXdWWmxN0JvrOTV0FpfGMlck8j9jXtJjAJl4G3IecxVK2yY0?= =?utf-8?q?K87KgUxuGLd8OQk5jtP0M6+1tCS1/9TVGUWYRyZaGv679pCxeN2uRJn/M/CT4pyte?= =?utf-8?q?mwuePobRJBMKfPyii3XSMm3q0IgxOUfBt96dc1h8YEI+1Bx8P6diThYDtHbHOHRdY?= =?utf-8?q?wtDD6ZRv8oGrVwFdhxzE/ubVL5dFmPobJAM0udLX1P57b+/PMf5gUCrYT1EdmB91q?= =?utf-8?q?csZ6sZeVzrcifCt/ScOMDcavleuAXbgQFs9QsFSZzJtZ8vbb3BHx7+mXnPDNLN2Tb?= =?utf-8?q?4Kz8ghtStTCi37I0M5qgVQbFVQ3nIcM7AbQVAzaNGtnu2SYL1fsGgn0kaf+IvNnUL?= =?utf-8?q?yX+NaPpyog9hXNe3XBUgpvo8u7Ti+ic3SAg+4vjL1sAne/LhUXf2ZUvV2SNlgWSAn?= =?utf-8?q?K/dwlGqLSryEsdmro5GoB7YAXyFip2ohE+/KdCn3tsD9k0uVKeyT0M26KWQjm6FnI?= =?utf-8?q?CQZEYpzy2C6MoR6OIGQ4LNt6f9weOcT8mNDnbqzbuaRfS1FyteFzQvgPq+YehNc0R?= =?utf-8?q?5McmbEpj/4vkSRyRiczXTXLiin6i9WjEmc0wZA1unt+RLa3UctJH/8P9kZHRzLU8R?= =?utf-8?q?kNvYDwOPYT5A/h8ekKIZWcc23TjdbjFpF33BLuIGRmnrY8tfCcYdSgO2hitmffpqr?= =?utf-8?q?5527CUhVSVJnuPNTcd/iElX9cZuEehqHuJ01/Y/o9v+Qy8RlAPgbuVbUuGtmng+w8?= =?utf-8?q?nDJdiBbEjt0nDdAuEo+7cBuGjNqFuGSgNQXZpF7YgcLkjVRky6svX5bI0Pr7xnGFz?= =?utf-8?q?TjIUqfrwRGaz5ehffyK9F+ZeBLzsFFuF4VkwBstp/ZaRNE7o8Mfmarq1UWSJkkBEi?= =?utf-8?q?N/FzSKC7vt1pMqZVROvmDY1X/WyHBA+tYAc/BnODVxNHY1R/rhxRz/WjUbEP64EYh?= =?utf-8?q?L3zD2E8fpBs3tNTOkFmycGfCFsLEoOspDCnRvasvmFpBi+Nah7xOXcqNuZRfZzYzb?= =?utf-8?q?i7q2XQQBDYebZSRnxo6tDC05N72/Ao6tTkpGU2vOpSBxCl2Shu3BmWw3nTMrDVlXg?= =?utf-8?q?vFj4AdmqjJS7?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fde0befc-5c02-4aee-fe14-08dc5effd5f8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:00:08.0033 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rNJbzGNIlRDWecGH1vNipDhfG8DPt1SD2mZjnAivHJkK10g1F6ERGVduKkhwD2qsBwL1bU8Yxr5G0zvlWZL1kA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8080 From: Yoshihiro Shimoda Add "Message Routing" and "INTx Mechanism Messages" macros to enable a PCIe driver to send messages for INTx Interrupt Signaling. The "Message Routing" is in the section 2.2.8, and the "INTx Mechanism Messages" is in the section 2.2.8.1 on the PCI Express Base Specification, Rev 6.1. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Acked-by: Bjorn Helgaas Signed-off-by: Frank Li --- drivers/pci/pci.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 17fed18468474..02f46875fe2d9 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -22,6 +22,24 @@ */ #define PCIE_PME_TO_L2_TIMEOUT_US 10000 +/* Message Routing (r[2:0]); PCIe r6.0, sec 2.2.8 */ +#define PCIE_MSG_TYPE_R_RC 0 +#define PCIE_MSG_TYPE_R_ADDR 1 +#define PCIE_MSG_TYPE_R_ID 2 +#define PCIE_MSG_TYPE_R_BC 3 +#define PCIE_MSG_TYPE_R_LOCAL 4 +#define PCIE_MSG_TYPE_R_GATHER 5 + +/* INTx Mechanism Messages; PCIe r6.0, sec 2.2.8.1 */ +#define PCIE_MSG_CODE_ASSERT_INTA 0x20 +#define PCIE_MSG_CODE_ASSERT_INTB 0x21 +#define PCIE_MSG_CODE_ASSERT_INTC 0x22 +#define PCIE_MSG_CODE_ASSERT_INTD 0x23 +#define PCIE_MSG_CODE_DEASSERT_INTA 0x24 +#define PCIE_MSG_CODE_DEASSERT_INTB 0x25 +#define PCIE_MSG_CODE_DEASSERT_INTC 0x26 +#define PCIE_MSG_CODE_DEASSERT_INTD 0x27 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Wed Apr 17 16:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13633631 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2069.outbound.protection.outlook.com [40.107.241.69]) (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 8EBD717166E; Wed, 17 Apr 2024 17:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373216; cv=fail; b=c6Ozm/uiizjG4MkarAqnT6rMYi1lR17tGq+dnOdk3e4pdejGdR0c4m8gNpcue/vsQvVm7UXbzHLjgImq9Ii3pqG2qVF2OZCNGupRcB9Vx7inv43use3/8WtHVH5XJx0CrlyMtHNMjT7X7NI0OnRSqKbiLrb1QbRPBgvLG1jYSRo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373216; c=relaxed/simple; bh=Z1R7qi1P8tpG+wqfBqFnd3RzZIQbkAXoWFjXpkLP86U=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=RQPd/+yz7xHO00IrjHy0t9vzjM8W/O7qEH86KVDAyJdmrxcPIRzSM2TvZXtw9U0tnupW4mb+5Aw6UZkwR4jLIPL0Sf+9h+Xp5mqwdx571hvXvd1wqeJycxTGLxZAZFgCrfPddqvyXQtyZZ9ruKeU+ITyol5cRFoSQGcomTrND40= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=g7K500MA; arc=fail smtp.client-ip=40.107.241.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="g7K500MA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CeTZK8OprDyl3sGWs/RJI+Qu3PEx+SceTwcc25ihRNmxmht8TTsiyhF9AWoeB/hGf/rI0WVo5LlXFQotaLowlJYQNYO98acUJ0lKREJ1gkqzYKwkiAo1RGI2ldshs+zhERp0sg/tmdy0DexQQmrBHiEZKXcanXfqfyeG9Vxq0s272F9RaFkQU9K8PEDF8oqA8r6DGYIRSnWceTUyetOjXVEDrmz58ayV9zhzcCWSK0+zNRuFWaY3L3mxJBBHm+tmESX2TLnVPC8cMLiC+tpBQfOvvfgELFRJG+uNUtEqCkE8MeB82sIBnokWMW1+eNf2FYkEcWCEdeQYXt4DZuKsKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HpPzzDR2t0W4uJFD/pHJufCGdd3ZJ8oAc5V/JrUqpWM=; b=ZFiWcGwo8DZ5W2lnvOWMSSiwGmOSKCnTn6I+uFkGmqVCUK4kSfqd1OWSIDrCHNzkbhs+KsCrhaDLZ/T48mKkfOhkOvCo7r9tyjn1EIwg+qNwugbpG6QSFs9ZZP8T45i1QD8k69VlvhRjNBT1KM0XudNES8r37PQdWLmi7qk1j80xqmpq7b/vStczLFxD3N8ctma5wmnVV2o8eU8U2yYGZXtnJFMlyKba9JMFxOzYpoB8s1RMGGVYiwwhFWMPWni4wfk8RTKHI9SL7H/UhyYsi01TpMJBHfEx/H28Oe5+WglnRpvHIEJUVBHm8GuYkXvf10aXHqb8y9Tte/2OXFUTnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HpPzzDR2t0W4uJFD/pHJufCGdd3ZJ8oAc5V/JrUqpWM=; b=g7K500MA8k3R2QTsOK4LZyPiMMXMj6HGV79XO2Fvb9gHN6O9YZWqtzYRbF7WW0Y6NokiLyZygl9mGBcM6sPsc99Ezla/AYGLnDrzRc6McJaz0wC7Y0rFmGDA6TYOLO9WnlalQ7Frno/Bl8GXhygqnhS0FOHsMm9QnmenuYj3jl4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PAXPR04MB8080.eurprd04.prod.outlook.com (2603:10a6:102:1c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.51; Wed, 17 Apr 2024 17:00:12 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7452.049; Wed, 17 Apr 2024 17:00:12 +0000 From: Frank Li Date: Wed, 17 Apr 2024 12:59:40 -0400 Subject: [PATCH v7 2/5] PCI: dwc: Consolidate args of dw_pcie_prog_outbound_atu() into a structure Message-Id: <20240417-pme_msg-v7-2-9c6208cda90f@nxp.com> References: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> In-Reply-To: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Yoshihiro Shimoda , Serge Semin X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1713373200; l=12761; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Ub0sCY9OqWzN3Pm6SPBEwtB2z80F4sah7lj6v7E5fbk=; b=ehwcx5a5f6xGhAwVrknFQWZYDsezt9SKt9DnsPu4dBafU+1M8hPVXN50eKXMBUGF1JdrQMJbW 8tpNwbWDTV9AspLk651qtJWxMhkk2AT5N0qC0jUku6Do4gpTWhK/LWG X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0012.namprd05.prod.outlook.com (2603:10b6:a03:33b::17) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8080:EE_ X-MS-Office365-Filtering-Correlation-Id: 218c189e-927c-4d11-2edf-08dc5effd854 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yOZEHVtFgbXBCiQpJ8FiL0gT23U7/7NmWBryOm25+M4Ny6R2viu8+0uMZNKzJMkpfstKnxELz6+bdBK4Nu+50GPEwhr1kgqKCMfQnEjgkRKz6p47NpeInF/enuSpSN77qjtNJ5zlpnucD6INK3Y3PzvhU157KgHDxWKcUh1X0EYUmodVn9noiJE+G7lipcykVa2txFLiCkT5HbhtSqEszWAM16ClryiVbI8mOkSAdl48+svl4gKSLcBbypIuRzf6yOrSbnDw5AvQNHIzC2KJusfF3aFtsoADJAR4KKYiLlLxs8R1/gSTysbpmSOuf5IMSSJ3oGh/VCc07qMbFr3xw5N4G98SuvcGVqC/7nehbRaWuADoNTzFyzkqMefSLLNNYURrkQDs56e30rC6ArgRzLsXXsfwMZXTjy3BTvsu8qZp5EcZNz5hCy8ddu5L/4KAd+Pmq7960iSIpuuQHcpJ38IHf+LZQPf7tob5VjB5yJ17XjxznLoUwMa4SiQuo0oSuDG4Z5Q3fht9FiIz5cLbyqlbLYWJZxSVpeE8IUEgk8Z7/qrRxtzD2X3FA6KuEjKT7WR9zJZbW91IbyTRUrVrzJyKFUT2F5Gm8PJZM/vzSxbAcavsNJRUCWEFrVxXwp+9EcTkxYulxEafwrs8Wn9UmVXT0K/CCnket+0YxUSZ2UBkkWP8MD77y4BDeJ8ot/y5HpGyaRAQsisZogwad7AIeB58hxa55z8NKcG2KmNt37M= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(376005)(52116005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?P5O+vT8GNCWQ5Ugd1YJJW545hcti?= =?utf-8?q?FHzzN1G7544ibQ4/n9Rw4hf40hfIQ4+XmmSBvubpooGg6KwyJh7K0lSPrgSxkfK95?= =?utf-8?q?+eqOfpknFgMS9jSH3UeTGyoxo9ZyjznYodkyLfjfpv1zJ+TK43hNh6i+vW4bNl6fU?= =?utf-8?q?iDiaM1wcZNeu6nUhkpuun/Y/fu3gCBIHDuM05+QsTC3Amh2UbeFNGB1QT/1+zaH8z?= =?utf-8?q?uwXN70dJyIoaOtrM8DmHDcuBzSEY9NhjQsbQffNcYo5RYUagFQ0DOmCnqWz0EpuZ9?= =?utf-8?q?iuovd7rVJKK0N2dB87qv5hmcRJY2s8keY6z4WDT2NU6MdmnsNDFQT+fekcPT9WB/C?= =?utf-8?q?VwNBW4OpFEScz2E2gxjhT9qwYjLU/5ac977uKgPJNUtQ0ULlISEirEUKXSYmG8bT7?= =?utf-8?q?5A3pt2npkCA7OArRbzVMmSwriGGyHb5TKVKG0x6cSAEf9jS7l+KDTQKXAOmZN5CAf?= =?utf-8?q?024tS+r3PtvjD4GboGf10husrR/b7p0Lg8ROQMUF5QJpDB22v/qVPrQHfom7ukod5?= =?utf-8?q?761+f+FVMIgMHF/4rUOJxu94WcGrWwKDUUEr0be+Hml5vrh7AuXb3TJIIqelkzpPE?= =?utf-8?q?+VwQdQMIt7T3pLWb0Fkg3Rc0p4d01gK+Wv4IeDneKBEpPyGpxRBarOvnCAHKVaIMQ?= =?utf-8?q?+ucBr3PunLf4iUN7Ly3ZqIFqEHJpZ4gRM9B82JpZcdodsnlD//el4OQkorIAApai5?= =?utf-8?q?4qpYti/xYmx4lyHjOJR43VSXXIA/482XBcC+CIiSP9gfyJ66BJ9xHjuLKqkloqHRU?= =?utf-8?q?L+RfiolhXx2v3sj7PSVY3ztoJEGPw1dcGnFQ4cbDSHOZXxRgp+p6C2zm77aV1mI44?= =?utf-8?q?ga/lzzfN22826+wWdJXN6BTIXjJ51A5NJwLveq4WGsPxkKhKS3M5Yk4OwAL0IEJGm?= =?utf-8?q?wmmg4DghXtoMVxsYs2RxjHGTfVIx21icD2NdDNxux4FtJ0MpJAgjpsr0gXa7D6TMM?= =?utf-8?q?Bc5N5dG6DpYOagqO/X476223GdWEkgmpWQQCc6KyZAzrF6ZLbWUhamzm2aCOYR47a?= =?utf-8?q?WjYjV0i0aFC0hhL8R/+8qqT8KYL1An5ZjrAdI0dJuQhsCNZz0vS2j2v7zv7BWvJbv?= =?utf-8?q?047p/DoAvBKUh32UdrqohOjIjs+gXCXkJn+/YeI79/ek5Ripl1TXYK9nWCtdAnQXg?= =?utf-8?q?DU6HvX82gK/MGlc7e6ZzjNemo+OQ7RE97vQ7spsPb1dlNqTES1zVZ0eL44MVMHPyJ?= =?utf-8?q?jHNUOEkg3w6fJopwxkjWyoqlGzR0yDtI22dC49K40p8a2QvT66vvwFH3+dWUU9XM+?= =?utf-8?q?kEHQGLZn7lQkK6KOBX3fKfqthtwaSbE+UVGxdNKNFU637Q3w9JBBP32owiYCkjRwD?= =?utf-8?q?g/cIYXCLYNhj0nlQE80d19beiKhITkSYwHGRJFa5o+9UD2YgxnR3zobdaFOAltlsi?= =?utf-8?q?B2jhXWr/kday1WUf6h7z/pVqkMGjsuG801IiTSSHlES1EsltWGcG2vdTppb0LMJhE?= =?utf-8?q?RY9aVBDzpoIhUwUguK0UV9fctbNGhpWRoR9vCk1/o9bxX+1nPNIvHD7QDbntbXYNi?= =?utf-8?q?MIppHy8IfHAn?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 218c189e-927c-4d11-2edf-08dc5effd854 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:00:11.9486 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kCMSWlm4zmUGJtTOw21QBTr0IzMYJK6qHlDc8l0loa8x7lkhpJN8MzhJ6I4/9N+40ZpMnoaUvgIfAm5J8PipMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8080 From: Yoshihiro Shimoda This is a preparation before adding the Msg-type outbound iATU mapping. The respective update will require two more arguments added to __dw_pcie_prog_outbound_atu(). That will make the already complicated function prototype even more hard to comprehend accepting _eight_ arguments. In order to prevent that and keep the code more-or-less readable all the outbound iATU-related arguments are moved to the new config-structure: struct dw_pcie_ob_atu_cfg pointer to which shall be passed to dw_pcie_prog_outbound_atu(). The structure is supposed to be locally defined and populated with the outbound iATU settings implied by the caller context. As a result of the denoted change there is no longer need in having the two distinctive methods for the Host and End-point outbound iATU setups since the corresponding code can directly call the dw_pcie_prog_outbound_atu() method with the config-structure populated. Thus dw_pcie_prog_ep_outbound_atu() is dropped. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-designware-ep.c | 21 +++++---- drivers/pci/controller/dwc/pcie-designware-host.c | 52 ++++++++++++++++------- drivers/pci/controller/dwc/pcie-designware.c | 49 ++++++++------------- drivers/pci/controller/dwc/pcie-designware.h | 15 +++++-- 4 files changed, 77 insertions(+), 60 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 746a11dcb67f1..9dd6a2edc7ae5 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -160,9 +160,8 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no, int type, return 0; } -static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, u8 func_no, - phys_addr_t phys_addr, - u64 pci_addr, size_t size) +static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, + struct dw_pcie_ob_atu_cfg *atu) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 free_win; @@ -174,13 +173,13 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, u8 func_no, return -EINVAL; } - ret = dw_pcie_prog_ep_outbound_atu(pci, func_no, free_win, PCIE_ATU_TYPE_MEM, - phys_addr, pci_addr, size); + atu->index = free_win; + ret = dw_pcie_prog_outbound_atu(pci, atu); if (ret) return ret; set_bit(free_win, ep->ob_window_map); - ep->outbound_addr[free_win] = phys_addr; + ep->outbound_addr[free_win] = atu->cpu_addr; return 0; } @@ -280,8 +279,14 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no, int ret; struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - - ret = dw_pcie_ep_outbound_atu(ep, func_no, addr, pci_addr, size); + struct dw_pcie_ob_atu_cfg atu = { 0 }; + + atu.func_no = func_no; + atu.type = PCIE_ATU_TYPE_MEM; + atu.cpu_addr = addr; + atu.pci_addr = pci_addr; + atu.size = size; + ret = dw_pcie_ep_outbound_atu(ep, &atu); if (ret) { dev_err(pci->dev, "Failed to enable address\n"); return ret; diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index d15a5c2d5b480..3a9cb4be22ab2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -554,6 +554,7 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus, { struct dw_pcie_rp *pp = bus->sysdata; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; int type, ret; u32 busdev; @@ -576,8 +577,12 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus, else type = PCIE_ATU_TYPE_CFG1; - ret = dw_pcie_prog_outbound_atu(pci, 0, type, pp->cfg0_base, busdev, - pp->cfg0_size); + atu.type = type; + atu.cpu_addr = pp->cfg0_base; + atu.pci_addr = busdev; + atu.size = pp->cfg0_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) return NULL; @@ -589,6 +594,7 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie_rp *pp = bus->sysdata; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; int ret; ret = pci_generic_config_read(bus, devfn, where, size, val); @@ -596,9 +602,12 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn, return ret; if (pp->cfg0_io_shared) { - ret = dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_IO, - pp->io_base, pp->io_bus_addr, - pp->io_size); + atu.type = PCIE_ATU_TYPE_IO; + atu.cpu_addr = pp->io_base; + atu.pci_addr = pp->io_bus_addr; + atu.size = pp->io_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) return PCIBIOS_SET_FAILED; } @@ -611,6 +620,7 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie_rp *pp = bus->sysdata; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; int ret; ret = pci_generic_config_write(bus, devfn, where, size, val); @@ -618,9 +628,12 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn, return ret; if (pp->cfg0_io_shared) { - ret = dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_IO, - pp->io_base, pp->io_bus_addr, - pp->io_size); + atu.type = PCIE_ATU_TYPE_IO; + atu.cpu_addr = pp->io_base; + atu.pci_addr = pp->io_bus_addr; + atu.size = pp->io_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) return PCIBIOS_SET_FAILED; } @@ -655,6 +668,7 @@ static struct pci_ops dw_pcie_ops = { static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; struct resource_entry *entry; int i, ret; @@ -682,10 +696,13 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) if (pci->num_ob_windows <= ++i) break; - ret = dw_pcie_prog_outbound_atu(pci, i, PCIE_ATU_TYPE_MEM, - entry->res->start, - entry->res->start - entry->offset, - resource_size(entry->res)); + atu.index = i; + atu.type = PCIE_ATU_TYPE_MEM; + atu.cpu_addr = entry->res->start; + atu.pci_addr = entry->res->start - entry->offset; + atu.size = resource_size(entry->res); + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) { dev_err(pci->dev, "Failed to set MEM range %pr\n", entry->res); @@ -695,10 +712,13 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) if (pp->io_size) { if (pci->num_ob_windows > ++i) { - ret = dw_pcie_prog_outbound_atu(pci, i, PCIE_ATU_TYPE_IO, - pp->io_base, - pp->io_bus_addr, - pp->io_size); + atu.index = i; + atu.type = PCIE_ATU_TYPE_IO; + atu.cpu_addr = pp->io_base; + atu.pci_addr = pp->io_bus_addr; + atu.size = pp->io_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) { dev_err(pci->dev, "Failed to set IO range %pr\n", entry->res); diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 250cf7f40b858..df2575ec5f44c 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -465,56 +465,56 @@ static inline u32 dw_pcie_enable_ecrc(u32 val) return val | PCIE_ATU_TD; } -static int __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, - int index, int type, u64 cpu_addr, - u64 pci_addr, u64 size) +int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, + const struct dw_pcie_ob_atu_cfg *atu) { + u64 cpu_addr = atu->cpu_addr; u32 retries, val; u64 limit_addr; if (pci->ops && pci->ops->cpu_addr_fixup) cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr); - limit_addr = cpu_addr + size - 1; + limit_addr = cpu_addr + atu->size - 1; if ((limit_addr & ~pci->region_limit) != (cpu_addr & ~pci->region_limit) || !IS_ALIGNED(cpu_addr, pci->region_align) || - !IS_ALIGNED(pci_addr, pci->region_align) || !size) { + !IS_ALIGNED(atu->pci_addr, pci->region_align) || !atu->size) { return -EINVAL; } - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_LOWER_BASE, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_LOWER_BASE, lower_32_bits(cpu_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_UPPER_BASE, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_BASE, upper_32_bits(cpu_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_LIMIT, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_LIMIT, lower_32_bits(limit_addr)); if (dw_pcie_ver_is_ge(pci, 460A)) - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_UPPER_LIMIT, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_LIMIT, upper_32_bits(limit_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_LOWER_TARGET, - lower_32_bits(pci_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_UPPER_TARGET, - upper_32_bits(pci_addr)); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_LOWER_TARGET, + lower_32_bits(atu->pci_addr)); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_TARGET, + upper_32_bits(atu->pci_addr)); - val = type | PCIE_ATU_FUNC_NUM(func_no); + val = atu->type | PCIE_ATU_FUNC_NUM(atu->func_no); if (upper_32_bits(limit_addr) > upper_32_bits(cpu_addr) && dw_pcie_ver_is_ge(pci, 460A)) val |= PCIE_ATU_INCREASE_REGION_SIZE; if (dw_pcie_ver_is(pci, 490A)) val = dw_pcie_enable_ecrc(val); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_REGION_CTRL1, val); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL1, val); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_REGION_CTRL2, PCIE_ATU_ENABLE); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2, PCIE_ATU_ENABLE); /* * Make sure ATU enable takes effect before any subsequent config * and I/O accesses. */ for (retries = 0; retries < LINK_WAIT_MAX_IATU_RETRIES; retries++) { - val = dw_pcie_readl_atu_ob(pci, index, PCIE_ATU_REGION_CTRL2); + val = dw_pcie_readl_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2); if (val & PCIE_ATU_ENABLE) return 0; @@ -526,21 +526,6 @@ static int __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, return -ETIMEDOUT; } -int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, - u64 cpu_addr, u64 pci_addr, u64 size) -{ - return __dw_pcie_prog_outbound_atu(pci, 0, index, type, - cpu_addr, pci_addr, size); -} - -int dw_pcie_prog_ep_outbound_atu(struct dw_pcie *pci, u8 func_no, int index, - int type, u64 cpu_addr, u64 pci_addr, - u64 size) -{ - return __dw_pcie_prog_outbound_atu(pci, func_no, index, type, - cpu_addr, pci_addr, size); -} - static inline u32 dw_pcie_readl_atu_ib(struct dw_pcie *pci, u32 index, u32 reg) { return dw_pcie_readl_atu(pci, PCIE_ATU_REGION_DIR_IB, index, reg); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 26dae48374627..d21db82e586d5 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -299,6 +299,15 @@ enum dw_pcie_ltssm { DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF, }; +struct dw_pcie_ob_atu_cfg { + int index; + int type; + u8 func_no; + u64 cpu_addr; + u64 pci_addr; + u64 size; +}; + struct dw_pcie_host_ops { int (*init)(struct dw_pcie_rp *pp); void (*deinit)(struct dw_pcie_rp *pp); @@ -434,10 +443,8 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val); int dw_pcie_link_up(struct dw_pcie *pci); void dw_pcie_upconfig_setup(struct dw_pcie *pci); int dw_pcie_wait_for_link(struct dw_pcie *pci); -int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, - u64 cpu_addr, u64 pci_addr, u64 size); -int dw_pcie_prog_ep_outbound_atu(struct dw_pcie *pci, u8 func_no, int index, - int type, u64 cpu_addr, u64 pci_addr, u64 size); +int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, + const struct dw_pcie_ob_atu_cfg *atu); int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int type, u64 cpu_addr, u64 pci_addr, u64 size); int dw_pcie_prog_ep_inbound_atu(struct dw_pcie *pci, u8 func_no, int index, From patchwork Wed Apr 17 16:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13633632 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2070.outbound.protection.outlook.com [40.107.241.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 64006171E5E; Wed, 17 Apr 2024 17:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373221; cv=fail; b=anpkpACpT4Zqfq8qMn0oND019FVskSUP9xt2/6oMqgomJwIFmzpsmVGvbdOd800hD82vMfll2bQHdz+IfL2ciZT5fFxhDK36m0uXIOnFWdLR+hTLiekRxuqTMJW+b3WydeoqnRniBqp6qg3cGpjriUDj4BUJflBc/OpnSqi6+p8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373221; c=relaxed/simple; bh=iaMVhIlaxnDKrjo/B86UwmBA4lUHgRwjSU/hHDluay0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Cu7ApNHwv5TYcNlBxttGNWVM8xCG7lg8aJ44z9dkiWh5cL5qb3b90Y4Kmxsp+oHp0KuA6yfDu+wJ2M2pDuk/eOSQPJzjRIwwA4Yk83ScuiRHDP2GfiUSG+r9wk7jA7Gnn9kdOxeLUsI3sOxkai1jUVMnrpzKIMMZHnAzhkdW0Cc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=m8HDRPFJ; arc=fail smtp.client-ip=40.107.241.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="m8HDRPFJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J6zcTXs0DDLHgwbs+vbC52ysB4Zz/lx9U7PRl5wrJiTIpzfIHqxMAbIbSX1XJ04GKGXsovznyIysRK5UGkD9MuZ/m/A3HzgVNPt+mKkwcHadhosCKD8vAA7YIwJgH3+708MaML8c/h+2yc3aAgCFV7a7TOlt5NSXKOngeZcI6Fh+ccMh74AgFmxiq4O4fKoTPAr9SjTxuzaTRUPw9zxPqqFNYJMetCUL34yU0Gzf+rUEnyFGlx5+QldyqpaAcbyOyQBESycPsGPONeyzWJMbTE6kalP8igw0Oh6UofzZz/QwzuJPeP7YmdCmzehDYLLz7OvK0kR+rhaB+a4bC10vsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wqraZNkbMXJ8bdVBUWBtPeGCWP+ilAu0pVj9SSD+e7E=; b=b4B2ON+T1XLZzgPdwu2/kLdBLqnx9bAaLhUe8G2eGuyOo9ro2VsWMYOY126MknzMIv2WkD3v6YNVR75NlWzRXD8Dn2VCF9VjK2fnLfKFURuJnTB0xOmvICdli5nuQiSfNrgoUvf1HQIFI4u8AoGzys+6A71LYMhchjGol4RzAAo9Fgznywr7KpIfjWoZ9e7lG0wug5YiTvRnjDxUitRHXPhGUMtg2MluykgGAKCo/DKcXenwLFJK4WUm7WnU/r4KkAsIr1919B0ZpIZ4FjBtGLQise9cMLNdmB58Bl0KAr7PdEEsdyH+pwD26LD/ZNWh5OX4T+DBixUAnvVmOxbdPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wqraZNkbMXJ8bdVBUWBtPeGCWP+ilAu0pVj9SSD+e7E=; b=m8HDRPFJ6mPzlHVfsaTlAvdi574rCDkVpUG4ET4qK/8ej/ER1pHF7UtNHACv9z8/sCi+6JztEqIJlxz0HEp0BdLnCMJ27XzhtgMbBVSP4lKjprn2tP3IpLhcFg9LL3WF0OQTTh1rVCt9vDK/BLEbzqgvnd3LcpKpwCXyigmZ6Lo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PAXPR04MB8080.eurprd04.prod.outlook.com (2603:10a6:102:1c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.51; Wed, 17 Apr 2024 17:00:16 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7452.049; Wed, 17 Apr 2024 17:00:16 +0000 From: Frank Li Date: Wed, 17 Apr 2024 12:59:41 -0400 Subject: [PATCH v7 3/5] PCI: dwc: Add outbound MSG TLPs support Message-Id: <20240417-pme_msg-v7-3-9c6208cda90f@nxp.com> References: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> In-Reply-To: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Yoshihiro Shimoda , Serge Semin X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1713373200; l=2940; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Vx141tscxeq3VO/J2v1vu73YFB2QjcNfIuChtPapKMY=; b=1LJpCmMiRrn4ck/tPFNQIu4iwmBkMQrz/+4zZ7FIRF6o62nq/4aB+jeLcansIJ5XeQNg+sqTF mLo9gUEvsstAX93OIU72wiVKR343Sg+6xwkUHvJu3WYySNWXyB3Z/gc X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0012.namprd05.prod.outlook.com (2603:10b6:a03:33b::17) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8080:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bf56f52-e684-4e94-ef21-08dc5effdb05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JO7+L8Y3052c0eqeXF+2FbdkgnX8i0jfgtCkCY2vMI/rfmtXdb4Hj0jp6O25loMaa2NY1qt5iJ7fvIGyUDmYQWPbh9ltSAlRrskVa0iKNv1K1fR15VSTQYo2ewuPtsR88i0Xd7fzQd1e4Z8QmdXAK4htp4SAWtHOLtMmPOpwWkIKp1pCMc0evYFo1Lod5Y5v5uvW2eMmuRkn0JNB/TIuy/fi/1UTvZkywimT+v5BaSU+NatnlcCibzwDUl0R27lk7C6eZU41lZWk+F4UDcm3/vh5pgLCwlVIejPIxgHEjcsfb13iBRFXCAY1Vv363CYqDcrSTSNyhU0dU9eyYISq2KxAU6GCpfBArCSZTEYo6r6Z0KNNo/gohQfja/pKTOzqgnwitmVX+QX3bvr+4YRvwcdzReSau9SFU/N8kJ6h7rHRbkpfQ8rldyo3DPNRulkGGA8bXpXASQqAqcbJ82Aduk/sMR5Jn8umbGlDyrWC8PksL6SNV3RCzdIhMtp7Mw0kQdZGGvi48UBYFA/++U/hWiQ8MBA6w8fSFJDnQ3uMEW+/pFe3F8BcmtPOVmpIOHbK8lsoFcQBRf59rMTHNnQ0K5IlC2q9JmJRNjhVQA34MhO/l63GcYSoehKhiHgMIRwzrxBGHMKPlUGa33P5LEEzFFg0loNqsG3sAZDBubtw8DMlKsNablsjpM53JqRRENtR/CkKLGVWR4c5d5t37P0GlbcE9eCAIsLhM229ZUYC06E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(376005)(52116005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RVoaRrO9qwc6d2WUT6NbodZJUQUc?= =?utf-8?q?+mmLil6iP3meIzPKQgXT46/f44roxmQCjF0+ohbrEHrbn73naNBr8kdzN73HYw3L1?= =?utf-8?q?rmc7cKhwcQmks1PiQg7jw4AuBCYo2t3b5pkfzzC0P3cDbUN5SfhtMuOpMit/5DTct?= =?utf-8?q?lU3yEwHI1w5/oEwoOePOoP62XL2WglWFKGz7xjQIgNNcdOPhYuHmfxoyETBmpHL+8?= =?utf-8?q?jnlyadYAy45/i6LIbaQ43MdJWylGH7U61nPXYLJfjr9EKC0Cn293GidfABuaSoLJM?= =?utf-8?q?thVLF3k+oauTDQNgk1ezs72eeGMI6tOEXtaFlFl9JDwTzETpuTtxNpN+/zuIGY+YG?= =?utf-8?q?Y2TsYUkJk+M1nJmRdRBTFQ344BhzeiLY/ka582zqQUKyBiu7Gw4FTPK0hoCKFnwqe?= =?utf-8?q?Mg2cjMKWGZKlpgLvzgiZ0noyuVEZhFoybhajs/ukTbMk6d/oZVNMs/SjG3mAGFe6y?= =?utf-8?q?PqOnOgVXXYS8uQbiSu07+uBpUvNbGWaubzLO9MXS02mc1mwSEA9ewkQjzVlhmQNvB?= =?utf-8?q?aHHozaSEoMMEPuZfzwNytg3VzeuC5aV5bdHZqf+XxbZ2VbnexZAmqTwXvWQa5cp4D?= =?utf-8?q?pJ0QLrmeYrb4nckJIpWIFx9EJxqbotdoek6fVP7oqt7HHqHaEh3UHV0+uH92Mxz1Y?= =?utf-8?q?Wp1QSqpuUDnPLgHlM7GhBcjm1YcQY1SEZPs4e1D52DAqWeUy2UAltlVi5b+UWVa+T?= =?utf-8?q?8I3I1b7zgeqZo6g2HdizOamU0gb3bGQnDrzTWjsNozn/sKg/2E/JSYBcQCQA5Gk42?= =?utf-8?q?+uz1Pb9mbjyRG0O6i0QX5hMcEh5ZbH5gAhIkK/NbzvLP4AueVsUxmOdupnarPiG7j?= =?utf-8?q?9dNbf1AaUMQz3TNvGE2pXs5V0QdOq/0GTy13NBqMoMOU8CJG9HmtfxMwZbmjq4cag?= =?utf-8?q?QP6NF9vGZEgXcA427GZNrsHxe46Bogtlif4CCQ6Jx7lTXeEOJy3zt0nlqD0obMbC6?= =?utf-8?q?977AYls+5llyTyqpwbBdgA7slKNku+4aKGxdj4kpq5CjLVyw1ah4azqxJ6yl/DIVM?= =?utf-8?q?SG3w8fhNQqVxxCwCdOy7DQM3fA9UaSFn04iqq51i5B/+Ss4czuQpgJEUsEjtQcX3n?= =?utf-8?q?SMh8T5eSReF3xbQBUgv3dkyo/ZZaFv1UyB7CsNUhxtWVzqgoFAdZU8dndVNa+fp1Y?= =?utf-8?q?7V7AtTzdQKUkJOmPl672eAoQpPdxFsmTcZPDH4e45jHWjbT18yOji3UpRxHTHEvh6?= =?utf-8?q?J7lSw/j0LIODy+6XXl1rFInw6V2Lex7rKJMu/kXDmDQuufPqwENtdye+1LWDADFeo?= =?utf-8?q?S2hAexy+MjExRNwnQOCLlfN5XfHEVW6EepYECVuJ+iSiINfT3RxXSfcu+EutLSWrg?= =?utf-8?q?8J9UdpVFkmtUW53Ad3uuIHT9rdmTZbkWtOdIPJ+OrkomTEs+Io5cwt1FzzXouIImf?= =?utf-8?q?5Yao4S2zAG0te/3aMUFAHUjEuKXOd4A3yz3x5slrq0tkR0ORLuE/rIRsT6JOTHLy1?= =?utf-8?q?+0UfC2n5vPdyRgyfyQ2sDo9D9cCrXxrATuq6hlbrDf5O1niZX3LH63ktYJF4S70r8?= =?utf-8?q?1WVJe0HWvH1q?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bf56f52-e684-4e94-ef21-08dc5effdb05 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:00:16.4904 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jj4Je8nM5pFBX5ClqWv69yRJya4oGMactUjKm0PItcgvQsXllvAihYG66yyPdgWXmpVIWxPZfFwyXeowF0+ZHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8080 From: Yoshihiro Shimoda Add "code" and "routing" into struct dw_pcie_ob_atu_cfg for triggering INTx IRQs by iATU in the PCIe endpoint mode in near the future. PCIE_ATU_INHIBIT_PAYLOAD is set to issue TLP type of Msg instead of MsgD. So, this implementation supports the data-less messages only for now. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++-- drivers/pci/controller/dwc/pcie-designware.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index df2575ec5f44c..ba909fade9db1 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -499,7 +499,7 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_TARGET, upper_32_bits(atu->pci_addr)); - val = atu->type | PCIE_ATU_FUNC_NUM(atu->func_no); + val = atu->type | atu->routing | PCIE_ATU_FUNC_NUM(atu->func_no); if (upper_32_bits(limit_addr) > upper_32_bits(cpu_addr) && dw_pcie_ver_is_ge(pci, 460A)) val |= PCIE_ATU_INCREASE_REGION_SIZE; @@ -507,7 +507,12 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, val = dw_pcie_enable_ecrc(val); dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL1, val); - dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2, PCIE_ATU_ENABLE); + val = PCIE_ATU_ENABLE; + if (atu->type == PCIE_ATU_TYPE_MSG) { + /* The data-less messages only for now */ + val |= PCIE_ATU_INHIBIT_PAYLOAD | atu->code; + } + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2, val); /* * Make sure ATU enable takes effect before any subsequent config diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index d21db82e586d5..703b50bc5e0f1 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -148,11 +148,13 @@ #define PCIE_ATU_TYPE_IO 0x2 #define PCIE_ATU_TYPE_CFG0 0x4 #define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TYPE_MSG 0x10 #define PCIE_ATU_TD BIT(8) #define PCIE_ATU_FUNC_NUM(pf) ((pf) << 20) #define PCIE_ATU_REGION_CTRL2 0x004 #define PCIE_ATU_ENABLE BIT(31) #define PCIE_ATU_BAR_MODE_ENABLE BIT(30) +#define PCIE_ATU_INHIBIT_PAYLOAD BIT(22) #define PCIE_ATU_FUNC_NUM_MATCH_EN BIT(19) #define PCIE_ATU_LOWER_BASE 0x008 #define PCIE_ATU_UPPER_BASE 0x00C @@ -303,6 +305,8 @@ struct dw_pcie_ob_atu_cfg { int index; int type; u8 func_no; + u8 code; + u8 routing; u64 cpu_addr; u64 pci_addr; u64 size; From patchwork Wed Apr 17 16:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13633633 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2070.outbound.protection.outlook.com [40.107.241.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 6FF29171E72; Wed, 17 Apr 2024 17:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373223; cv=fail; b=ksHxjJGjav7WM7QMe9gLEBm0Hy5lpHAb9suV3tkHiGDYhw3nxZScLorQbDK0VcaZIpGewX0aMfPDgaiodTl80ALs2UqALzZO91/2A8XcgjlQP/Q8XsECcYbDRdKXNdmjSBOO0edCycD79r2uAlp5K9PXFj7elxkOQmN9H7ActpQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373223; c=relaxed/simple; bh=TFgqFDue1aadqg2y+3rRxqvx5IDVQ3/Xrl0gfgcuPms=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=tOk26Kta1iar86XKHEBnVJxdQCFHIH6RQrfZaeQq/aW9qf0sWHmyPxtLC9E9eTd6ty2MKpxlokSCmK8/ROBACQyugMv0B7uIy8TzA2M8KzttQhH2LK2qzmUNAHLA14oASvf2Kxka7HvKLJC+0CuhPdwAiOeexFOxEEBAcYGHoAA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=edBHrkjq; arc=fail smtp.client-ip=40.107.241.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="edBHrkjq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nr1ovp1GeSURT0BDNXjPtfravfsZYzUci0iDW0LeM1MfIcJUGEBafTRG2FyVNGh63orn6B/2perXKJeLQRmPaWYdw+LMARCIlT40CNpXwb20E8kBfescVCNV9E3fX4OflOGaESO+Cg0JGPm9Qe8f7f8iajQgxsgC4rGdLWTUcrA9dQtORh3YNzTwCpOoeFJikll0556k1TdgVFSXVMqlSI0mXAmu8Zic3DZ3U4LQ+lTjDdgdp1VtrbpecAm8fkx7vxMEsMGroKFJtYkzmJywQ/kamNMzuXMTA5JZcEL/G/IQLtHLEsD1bz5Rsc3LBINGQHtzwXxGzIGub0WvQyD0Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RrDm70oFH5JEMjN5zo19TAic6YhIgjCqSE+nHU7GghM=; b=MHjRxsnKUrNP7f8Qrl0cH8U9paqVDJTxkjA/zRPoe6SYOsyjoLuSjWI4T1hUM88ckIB4fYdJVyFfa103PasqP4WMLajarvL7lbo0BOU2B2dBQj2R8w7CM76CQKWhg3PEkeJ0jTzv6Kwwq3vekL0Jbz9NLjWeUDR6VvPqI8rwppOXU0HGjH/pxEmoIsgcCiygZMz7ERdyQHel/Kkk2H0OlThN9E80QeVrOVtvHOUeQrTXtXlmYNoP4x9vdpPfpvnvr0CAZrFb+4JRNkc5wrfVO3C8S6LCVDUI+c4ZQLDCFddwZyzwRaEsEr1nC8/Ar35p+17aiK7PQCPJvQ8OUFuoTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RrDm70oFH5JEMjN5zo19TAic6YhIgjCqSE+nHU7GghM=; b=edBHrkjq+vLWopqD/xoRUHcRzHQDBCDeOdjiLA6QeIgPsb+Z7oko94g9uCwHEE1roPrvLWlFSO9sA8WGxfSfFQz6xubDHg4xgmiSA4WcBOpVjKZYzGIv25zsTh/Odt+33xE4v2Yr5ZeEaztYyxFqj5T4RRHDRRfxWHdzwlXCKvY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PAXPR04MB8080.eurprd04.prod.outlook.com (2603:10a6:102:1c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.51; Wed, 17 Apr 2024 17:00:20 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7452.049; Wed, 17 Apr 2024 17:00:20 +0000 From: Frank Li Date: Wed, 17 Apr 2024 12:59:42 -0400 Subject: [PATCH v7 4/5] PCI: Add PCIE_MSG_CODE_PME_TURN_OFF message macro Message-Id: <20240417-pme_msg-v7-4-9c6208cda90f@nxp.com> References: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> In-Reply-To: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1713373200; l=754; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=TFgqFDue1aadqg2y+3rRxqvx5IDVQ3/Xrl0gfgcuPms=; b=tgn4TYufGAAE9ehOYLzYDs3s/r+EbNJjlUnAYI3plydHApewn1eUEczxgBbwcN0Q3O4RDREa7 eZJHFLNjvO9AP1HPMbej5Qq3kqafBXTB8iKZsv+5JKAAv/3eA2C6eiY X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0012.namprd05.prod.outlook.com (2603:10b6:a03:33b::17) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8080:EE_ X-MS-Office365-Filtering-Correlation-Id: 70cf1fad-8bff-4521-f1c4-08dc5effdd4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e8JF0zZrDJ90dhDYCUNm8mNfMOP3Tfgf+oYDk3F2gY4gAOttQZ9696f0TccryYtjLjPHReAPBUziDh6HJYMh2JhX0VbpMRX8KOZvva/icpFW9sMcQOG1iAwCJaQ9srn18GIRJXw32cJRS9wZsMurq849acQDECycXlWUWKMItuhNyRjFUXanC6K6wgwyG8Zlfhj+IIJqUcS75Rc6Z3rp2YX8m4GEofu+rJZJz6ZbOpOrHnRIcvH3HXXjUeJo2RSVqoZwgv3VKZOpBuTfPlm5qPnRicOCOfv9EaQ5rJbN133IIcRRnQikavO9v62yoGt534ez4R8yLc38/XoWMu6OV1HQdm9V/iqvJn1QbhETuOk4psj9i+y8LBFhhQNL/1qy4hesiDRcDqfw6jmFl4nptiBUzkUVwbl1753LB9mTvVtIuU5Q676SsZ6huoqpEixRNwwgvXX6FX4NhgBBUoeEj4dcjxao26PJsHZiEyG8yrg3xLKLKXJ83QpTRK3ZNOHL5nh7Ul8GA7Z+CZfHEu5zl5mlNslYL/xBWOYs2KmuR0WUGhssoWIlbY6Sx5inzUIkRZ+ObRqx43Yt1qD/n8jUU6hP0GgUg6hp4guwveTChsvfRt2EfR+kKOARkdHLNVinT9CVaWHW7pJoDcbR+JFAQTatKDzqjiUOEJx0ZlX4AL05VuSsdIIq9C7FNoLjcXmKyWr8GlYCN/ZkM5+dImaXWIQOtg7EvrKi9yK2Kf8AiZw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(376005)(52116005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Omx7/3lHi5FQaxMNO2Ppyu0pzEm8?= =?utf-8?q?lYcx8hcGWFfCp54NhmBU1pDs5+B3tK4xdeBTCgGJwRKu3up8Tem86Mo6ikA/aGHp0?= =?utf-8?q?pYfkhpRfmIcJdfS/3EMAzw/2XF9o7cFGReUC0d64zZLc87wFy+5GG1HJdSDX4+TLo?= =?utf-8?q?vSE0un2vuVOLKULv1ZDvhZvsE6AZEisQrfEPKDaAQZX4B6RTf3O9MLvxZFs9Bf/sN?= =?utf-8?q?9S+7d9fKmXoVedNQ4HmGRf4pxZH9Is/laTZkmGnStp17IONhTGLf4rGB2vShWo8hI?= =?utf-8?q?1diRtPEOumy2WM1NhcWErhrNJkPN+IhvuhObI4H4jk0MEpmGObqIX/vKshbq4VnMD?= =?utf-8?q?Cyq/fi6TTy42vE+/2Q9Dr9q9tZYsmyLZGlxD7elyz01eNj6TvVxZVHK78L/CIUe2L?= =?utf-8?q?XhmWjkbarJrsfsmEfAs2QyaB5rbnow2c0lqmFehucVm4y/SA5cb5ITyDJCIkPRzdX?= =?utf-8?q?bE1GUByXM9eWASZ+ngHWsWX2xNpALsc96J5qQw4GIpylKW03Cf0vmjSNwn7pY1Cvy?= =?utf-8?q?lxRFRrx1Bw5qJ3EzT5B1W18HE8Ka3c9Nt5754CdnKG4Es3IauP96BEyJAmR5xrneK?= =?utf-8?q?KNYJyyHwP2AgC3oA5iLfsHUKB7/+TIm5lCCkVejsgHbaPw355PBO1+B22HMK3zjs8?= =?utf-8?q?mLypark161IMYjGPZ0YDiuFKTGODjewnSwjlCeLE57u3fnDZSlaJ0n2Gs1bEnEfHY?= =?utf-8?q?U8R4PJ0QIJhKcYE6y+TV5oO/AF9jwRoIgLdkbGeqHBdKYxgtRUDfK5VrKmgRW/SHr?= =?utf-8?q?4p4NrB4zEo5Pw/Qi50faJCGwyGBoHu+SgvIxxTN/njOg+bN7EqL1soECZuk0kL07T?= =?utf-8?q?iuV1Z99GMBGDX9f6PBkTVIQah6y78tQ7Wih2gI3Yf++BEAty8Y8jdXuzrd2MxWUqg?= =?utf-8?q?Nmu0RFW/Lm6/wWPU24vKiWbK59WDAjHRNX/TgmPB1McIsLC69HCFjy+p7rC1CNUYD?= =?utf-8?q?RECBSFX0FK6zBMs1Ng4E5B0pU0UI5LHVFfIDRk+viP84/e5qYSsnPyLeWpUemZHYy?= =?utf-8?q?2YSb37uurQDs5p3zfIq/3ZZVWWM6rAEMW0KD5cXHdlxb7KAa4M7qjAiXgy9qnwH+u?= =?utf-8?q?4xguavw75U91RoHeW4FWa0hwLF6h63qsxJTF3SnT+gUm1vO8z6cQcti7hSaHQ5M40?= =?utf-8?q?rVFLH6vtUgzpXA0KiMpyt9s6iUh9LNyaSljzzCBQ7NJJGFslQMlnAYaxPtcy12dkz?= =?utf-8?q?EMLDNblohheD+h4P8SYEFdpFRj0sDlq3ztbr8L8/Oexs43xNcsOyx1kvNDYSaz2ia?= =?utf-8?q?Y+i3YZmFLl4VehlryYXEehXqMgv1bP2sEmZh12iyRbf2x9qdb2MPTan+GEtb8L4Ly?= =?utf-8?q?qPPC01paAOq1gn2V7uZmwoS6PwI8v2yyn18QApbdUazUSXVljzrUTqHysR5P+ADGP?= =?utf-8?q?SktwLm9UbKvXmhXOJBAaVGsinGlYIH+slah2BxoKc/XwRF0FJUfy9WawXe2ODjsT3?= =?utf-8?q?/wW9vuf4rk3gB5sztgOLTUdNZdezyEi+AX1cheU9KIUC/57N92HAPPHGWvvgJ8AKv?= =?utf-8?q?YUW7JC2k0ppz?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70cf1fad-8bff-4521-f1c4-08dc5effdd4d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:00:20.3118 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jr5Z9sAPjQKwHVgtQ7QdpapBoYv/WBi/HedB7ILOjnnKQKwBFtTXSogqNhQeJPLHOFcusG/frpPF1nftiOFCAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8080 Add PCIE_MSG_CODE_PME_TURN_OFF macros to enable a PCIe host driver to send PME_Turn_Off messages. Acked-by: Bjorn Helgaas Signed-off-by: Frank Li Reviewed-by: Manivannan Sadhasivam --- drivers/pci/pci.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 02f46875fe2d9..36381fc7ebd32 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -30,6 +30,9 @@ #define PCIE_MSG_TYPE_R_LOCAL 4 #define PCIE_MSG_TYPE_R_GATHER 5 +/* Power Management Messages; PCIe r6.0, sec 2.2.8.2 */ +#define PCIE_MSG_CODE_PME_TURN_OFF 0x19 + /* INTx Mechanism Messages; PCIe r6.0, sec 2.2.8.1 */ #define PCIE_MSG_CODE_ASSERT_INTA 0x20 #define PCIE_MSG_CODE_ASSERT_INTB 0x21 From patchwork Wed Apr 17 16:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13633634 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2047.outbound.protection.outlook.com [40.107.241.47]) (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 99B0E171647; Wed, 17 Apr 2024 17:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373229; cv=fail; b=FQwUu4hwr76M30iiQV0dVQCC1rGMEDt0bHHOM/qgsySccJGhnp3hJJitBtd/UPENMvwPgCKtneXTsYvU0hVxgXrIWfutlim0z4N3MYqmHlZBALSN+AoUPyzyq9o6kO6u381L7M5z3znrhxCWkX/KeCisFfPDOpCsIZzLZcyv1lw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713373229; c=relaxed/simple; bh=WYnwvMsizIBjI0dsvib/vHgErqffgHMQFqLXx05KeyI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=CduqD8dc5M9LlsoZLx2c4mT1xtxdNsjco3DyE44xmoLlcTl8DCdM0hwUk0ziGLkJtzQUYHrx3pc7DCSyF48Hn+BWw1J7WyGANu4lbduXz24ZomZeZ+G0+mDfqRL43o3LbepP77hYI/xph/XlPWydXidasGLdlI6Wj2FA6xQs9z0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=VIPJn7ml; arc=fail smtp.client-ip=40.107.241.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="VIPJn7ml" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jqqf/wKpih4G2yv4Rdz3ffY/kt1hTD7h9BSaOe0YgjETVPSm9mh7k0HhMp0QsnHZMolYk19pSRPbtisRzRrjfIFuvDga9CRiSlaoEqp4Ohgy+wXF7ikKyuOvL1gX4/KVUqE7s0+UdSVpFWbzjsCgycfCP+JF0DpkmTjg/rlOL0eUWPdGdXQzoRl64cxOvW9kGwRJ/tjSixguzUmAfMCAkLYFfKEok2o7iAVwPLy74gsbMiIiGJhJgWNmdjOHBkdwk32akQ3vl9X12RoAf5BcRSDTiuui/TRyD/BWJJsNHHlstihlzI9yzqDxJQ9Qwl3fgjadLR2GGf4miWTn6tGBeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5eGDa6Oi5FpOqvaJybgmzVETHo6HCdbgKB/yOCCnyqY=; b=GGDFTA/pWG8UPFrTbXxYTovODMcax9gf6SL9EXDlbdzm35s89Bcq0SZY0mLAylGMpbwSPuWlcLowIqF0bQmbKUw9DcH1iCMV7S5LmmsyslLDrDxU6YMINoY8gcOLwA+hBwStOcywuCkdg49MGwL1fFkPtZj/nGQ53VTtxhweUjWtkimJaMSCGiRGH+ylft0aTR+OWuY/MtjyTsVN0P/wwIoXRWXmsPaH+fVwt2EK57/47qAbiBCQO5h+h9QS1NIY/vrz2PQe/Ftecp+u4rm+y1o19HBijSR2cx40tGiKYeIf9Z9+gPHHZzvu1Oc1bT+3wO/5xgEPaffWYd4/yYfXZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5eGDa6Oi5FpOqvaJybgmzVETHo6HCdbgKB/yOCCnyqY=; b=VIPJn7mlO9f+iwPEs2Jjr7jXdH6Bp49V8J5pn4HfQLAOYT7wfIdg/6CD8n3VVmSa3L0tgc0wS1ZfLPD+PHhMc8uQ6EPKABpXsGd5Rb1yHJ5c8uRQGr+4ppjyJt22NIDtxHjnJFP+EqKIQRObQ/35nI534dNS6m2VpbP03b8MG7Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PAXPR04MB8080.eurprd04.prod.outlook.com (2603:10a6:102:1c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.51; Wed, 17 Apr 2024 17:00:23 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::1e67:dfc9:d0c1:fe58%7]) with mapi id 15.20.7452.049; Wed, 17 Apr 2024 17:00:23 +0000 From: Frank Li Date: Wed, 17 Apr 2024 12:59:43 -0400 Subject: [PATCH v7 5/5] PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspend Message-Id: <20240417-pme_msg-v7-5-9c6208cda90f@nxp.com> References: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> In-Reply-To: <20240417-pme_msg-v7-0-9c6208cda90f@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1713373200; l=6369; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=WYnwvMsizIBjI0dsvib/vHgErqffgHMQFqLXx05KeyI=; b=iw75DLzDPH8t4Y5PLnGGaj8MTEJfzsqPoMH2wtnRfVk3JOXDlb+FySLw+bi6nlSz0A+N1yUa/ 5xUCzF5/EJABF4ZSeOE1c6oJe7/Y776lVy7r5SXRiQV2FHKDkeyp9i6 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0012.namprd05.prod.outlook.com (2603:10b6:a03:33b::17) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8080:EE_ X-MS-Office365-Filtering-Correlation-Id: 95ec8319-b82f-4c92-8d55-08dc5effdf72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jJnPLp5TDBST08NRXyaGHn4HM5C651Owobc79+SeWQ6Gy5iLzQc4X6rritiNCPdsqmGDajgKKaGbxoNt2NcTiNZbf+TVN/wkHOyZ4j2ZFBIqtq+4C+iLvc//NcSIJcUhPgOcNlGgmZ/HPBy7wrsEzVoPd90hc8RFHUcVWMlrY3c4Z4HfH0qJw7rS3cYVlFuer8+1kO0swRYbsk3qFmfC+vkXyRemDQJp2IImTTct+uoWwU/BBDtfjMiQNegacnZNdNKxHAkMhYmx3t7dJ/oU8amxXUXLJTzQDu1VQg0ZXn4UXSM3tbPNLO3j5J5cQsyPhJ+pfu0lgfu64X2THZLquq7jS7pXxrSCOgRdRIta9POsywcM5L21jLH1DzQRb7bwUVJB1BSdnr0RFdBhC2EkrxpB3W2jpViKb+O/LgTDQX+kPvMhAzgxL3vxB1ZC8qDMIbb77Jqvf/CFHRWhB7oqYUk5huQwXpc5oP6sGWewxpj7OnlzKZo9L7mimeNufAtxvJ51PqqZ0qQlTi41nQbBMwSvQxocbyaK225uAECG3TpfAUkPl0/n3ELS5bk4BpDDjgirL+qeNnM/Fzc+mARG9w3Yd/JLUs7sAgzS0dCnZDPs/T3LphSkIZ8YBqPQgZ7hljldsZW2XbFsWyo32txNkeqVBDh/ruq4nhIHi40AzXSeFIOAw4RyLWDNT9VKimGiLl5H+n7hF2MPOeg38WtC4oolOb21Q44b+Xb67W3zCU4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(376005)(52116005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZI+tp247zAGIidTkCLLV0Cwk5V63?= =?utf-8?q?/JIK8uQ6h8IEpJEBHhUOd5Oqi3t7CMw/zHqLilgDNZEb/p/mtlMqO9C1AnvYcdlCa?= =?utf-8?q?pK3Q3uEAEW8drSYX0nz6s89ISpg8327okTpYPVpeTwLcYfz59mQqa4392f7PCgUT5?= =?utf-8?q?Smia0EV26xDP//oP6mHUbLlLhmOtuZ7tk5cwW4NsO+qJwzrY3J+KhPI1ekMSgnDmO?= =?utf-8?q?kciZg4+y1iL27N5nK0e8O+2ZZm2Wy71SbjgkQ8VJiscEWgQ3CUIUXXSHWILojgOCe?= =?utf-8?q?SmK/+wlRvn+rZZfh+ehFQ7bspCOXml3X53WFMJxFqAzL62rL7sGHQ0ngLlcPuv9OR?= =?utf-8?q?qzEEcNjdGy62/NKCh9W+yCrouJToiVmpbDjCmH2G5IGtlNPRZQ3t+pW6G7PV8i0Dc?= =?utf-8?q?1PN86m3AFLNZkmjEL6ZtRPhSqtMFnmBAjgPJ6mnTavJl+AFu6McrzYM5ny6BQO218?= =?utf-8?q?0hvv8GP2N5nlRIzGXI+OEqDW0WCaFeur7NfYq75uQjlm0VrPO/pqHtXgeA6NfrEfB?= =?utf-8?q?4ZztOvA3XhnYwTsa0BZvJLTLebSNRAR++CFYu6ZgDtDNgUkDt7GcWrURI//6rHX9j?= =?utf-8?q?J2nN+g4LKMeGtpTCaodX2idfKYuTv+xOHHTv/tHCQiOLXenpfE9Ief9m879mI8rxG?= =?utf-8?q?AZLQS9bCtEQfROzwosRqGWZbDkHEA5LWIO+sTH8VxPnO6/DPD8tyHa+ASncACmueX?= =?utf-8?q?ONHI61AKyQ+JklPDLHjFH7M60LBEAniGIn4moDtdhFvLanjZDaY1jiYDGD0YyuHQS?= =?utf-8?q?LnJFoGAAiSd7yuJCl+tAB0oyMVd8OKCmY5o2cX7VdMCW5al+WfoWvGWdf0pnYp6sR?= =?utf-8?q?PIzcdYi+6Vyk2iF8cIMsUAd8tKflk1II9BZTBwzZ64+I0qZ7KeknxKXKNdcXtz9bS?= =?utf-8?q?tR48ogcmfvjnhdwH28SKyqVkt5qeY42EPyRHTIvXvWx6jnXAB24kykV3Hv5pThNzn?= =?utf-8?q?Ek/iLKN3ejA3vj5Kn2VfvlN/qbIj8o1N2/i3S1w9qlWZbY3rkxZn5NxjmjaWWSvon?= =?utf-8?q?rwl7940W3w4b3VWc/zo/HWdKErwWMGHTCiG+66XPRS0bpM2ez2RONS1Cu4yP7rnFm?= =?utf-8?q?nJBWdSgG+u+1bRQbJQ9UH39FgoEqbV3CphnDLKqmLrXGTBW15HKsxGCNdhR1IgxlV?= =?utf-8?q?swvd5XsDAIUz7W17hFwFANq9iheU6Cx/rfnqU2QOBwLW9/Rp34nxSXnjhtZbDXDK0?= =?utf-8?q?+S6xnLWD1jR/ycZwXzTZvRhGzqKhSXV8ODTSIy5piERKSVI7uEmRhVDEkioQgcu6d?= =?utf-8?q?s0f6RpdKAdOXga3T6DKXXyxd1rSUlpBN4aDKtJNydx/47O7HnHmcUouKJPjoIOGP5?= =?utf-8?q?sVMN++B2ilhQWUriR2bQ/crALb5E5xYEDJr1uqWgfi6o/WG7SWPLZcY7TkwPlEf+x?= =?utf-8?q?HbFUgAL3ywGsPnxjjrtwLMkAmIF30fPLGJtNmyscFT+KW45N3RCXSvhS8Dr5xHRNM?= =?utf-8?q?IORnxsDCfKiu7qyadaACJl9qqmtrlZgeol28PTBqRarEoqPa0yMTPFnLrbJafFeoA?= =?utf-8?q?xiTzCAsegy4F?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95ec8319-b82f-4c92-8d55-08dc5effdf72 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2024 17:00:23.8954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 19hHVRk8W3H+IGuYldYxRgveWbV6I+D+C7TPHmeQ/JKT/37M5kB/ijDW+5CBMOSPS9ac3QMNwkyl1yPC0jD1TQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8080 Instead of relying on the vendor specific implementations to send the PME_Turn_Off message, let's introduce a generic way of sending the message using the MSG TLP. This is achieved by reserving a region for MSG TLP of size 'pci->region_align', at the end of the first IORESOURCE_MEM window of the host bridge. And then sending the PME_Turn_Off message during system suspend with the help of iATU. The reason for reserving the MSG TLP region at the end of the IORESOURCE_MEM is to avoid generating holes in between. Because, when the region is allocated using allocate_resource(), memory will be allocated from the start of the window. Later, if memory gets allocated for an endpoint of size bigger than 'region_align', there will be a hole between MSG TLP region and endpoint memory. It should be noted that this generic implementation is optional for the glue drivers and can be overridden by a custom 'pme_turn_off' callback. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-designware-host.c | 102 ++++++++++++++++++++-- drivers/pci/controller/dwc/pcie-designware.h | 3 + 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 3a9cb4be22ab2..f57805b21ef53 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -398,6 +398,34 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) return 0; } +static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct resource_entry *win; + struct resource *res; + + win = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); + if (win) { + res = devm_kzalloc(pci->dev, sizeof(*res), GFP_KERNEL); + if (!res) + return; + + /* + * Allocate MSG TLP region of size 'region_align' at the end of + * the host bridge window. + */ + res->start = win->res->end - pci->region_align + 1; + res->end = win->res->end; + res->name = "msg"; + res->flags = win->res->flags | IORESOURCE_BUSY; + + if (!request_resource(win->res, res)) + pp->msg_res = res; + else + devm_kfree(pci->dev, res); + } +} + int dw_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -484,6 +512,18 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) dw_pcie_iatu_detect(pci); + /* + * Allocate the resource for MSG TLP before programming the iATU + * outbound window in dw_pcie_setup_rc(). Since the allocation depends + * on the value of 'region_align', this has to be done after + * dw_pcie_iatu_detect(). + * + * Glue drivers need to set 'use_atu_msg' before dw_pcie_host_init() to + * make use of the generic MSG TLP implementation. + */ + if (pp->use_atu_msg) + dw_pcie_host_request_msg_tlp_res(pp); + ret = dw_pcie_edma_detect(pci); if (ret) goto err_free_msi; @@ -541,6 +581,11 @@ void dw_pcie_host_deinit(struct dw_pcie_rp *pp) dw_pcie_edma_remove(pci); + if (pp->msg_res) { + release_resource(pp->msg_res); + devm_kfree(pci->dev, pp->msg_res); + } + if (pp->has_msi_ctrl) dw_pcie_free_msi(pp); @@ -700,7 +745,13 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) atu.type = PCIE_ATU_TYPE_MEM; atu.cpu_addr = entry->res->start; atu.pci_addr = entry->res->start - entry->offset; - atu.size = resource_size(entry->res); + + /* Adjust iATU size if MSG TLP region was allocated before */ + if (pp->msg_res && pp->msg_res->parent == entry->res) + atu.size = resource_size(entry->res) - + resource_size(pp->msg_res); + else + atu.size = resource_size(entry->res); ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) { @@ -733,6 +784,8 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) dev_warn(pci->dev, "Ranges exceed outbound iATU size (%d)\n", pci->num_ob_windows); + pp->msg_atu_index = i; + i = 0; resource_list_for_each_entry(entry, &pp->bridge->dma_ranges) { if (resource_type(entry->res) != IORESOURCE_MEM) @@ -838,11 +891,47 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp) } EXPORT_SYMBOL_GPL(dw_pcie_setup_rc); +static int dw_pcie_pme_turn_off(struct dw_pcie *pci) +{ + struct dw_pcie_ob_atu_cfg atu = { 0 }; + void __iomem *mem; + int ret; + + if (pci->num_ob_windows <= pci->pp.msg_atu_index) + return -ENOSPC; + + if (!pci->pp.msg_res) + return -ENOSPC; + + atu.code = PCIE_MSG_CODE_PME_TURN_OFF; + atu.routing = PCIE_MSG_TYPE_R_BC; + atu.type = PCIE_ATU_TYPE_MSG; + atu.size = resource_size(pci->pp.msg_res); + atu.index = pci->pp.msg_atu_index; + + atu.cpu_addr = pci->pp.msg_res->start; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); + if (ret) + return ret; + + mem = ioremap(atu.cpu_addr, pci->region_align); + if (!mem) + return -ENOMEM; + + /* A dummy write is converted to a Msg TLP */ + writel(0, mem); + + iounmap(mem); + + return 0; +} + int dw_pcie_suspend_noirq(struct dw_pcie *pci) { u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); u32 val; - int ret; + int ret = 0; /* * If L1SS is supported, then do not put the link into L2 as some @@ -854,10 +943,13 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci) if (dw_pcie_get_ltssm(pci) <= DW_PCIE_LTSSM_DETECT_ACT) return 0; - if (!pci->pp.ops->pme_turn_off) - return 0; + if (pci->pp.ops->pme_turn_off) + pci->pp.ops->pme_turn_off(&pci->pp); + else + ret = dw_pcie_pme_turn_off(pci); - pci->pp.ops->pme_turn_off(&pci->pp); + if (ret) + return ret; ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE, PCIE_PME_TO_L2_TIMEOUT_US/10, diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 703b50bc5e0f1..dca5de4c6e877 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -341,6 +341,9 @@ struct dw_pcie_rp { struct pci_host_bridge *bridge; raw_spinlock_t lock; DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); + bool use_atu_msg; + int msg_atu_index; + struct resource *msg_res; }; struct dw_pcie_ep_ops {