From patchwork Wed Dec 11 20:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904139 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2049.outbound.protection.outlook.com [40.107.105.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 7E0962368F2; Wed, 11 Dec 2024 20:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950680; cv=fail; b=Y7i9Pm5rppXNsaQcfYcs4LjE1jKQg7wpSR0LYQ8EhzId0ZYqM0sPn8vs6WX0z6UvLDsQifx0F5Id6OV1NBNSsbX2xuwBenbUHa2rPfFEuDY5ttLnA/ffXjlARSK4JKnuCkH3ZHJLF5Z5/kS1h6BSKwnBis8PNH9bP6o79pyzOHc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950680; c=relaxed/simple; bh=h9rTyIw7JBTy1EJzxkuF1XAJdSITdDV9rguxRpQSuCE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=iwEDw3tYulLtpRTJ/HYeoKyjtTGkjP27x+YpLdJ+8sKlAe2LqxJobhBe9f73amYSmcZ6sOHtkJrbWuTTnCAN5FcUpwcNa6nEqvqiUGxjJAEMFG/OUmJlzMruUUVs1GZaOydRP0tF8RBKaF1FuwUwvnMUizXN+P4QikyeNoLyy0I= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=XkuOxkTm; arc=fail smtp.client-ip=40.107.105.49 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="XkuOxkTm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JutavMd2AbjR7Al0Z6/mYaqOwXP/wG87mNQOd6mWs1mCOELekf0Adl/bQzcUPrfMDs56Uql7YqTYpFWOQ62rN0Th7a0YdiAyMKzCxPWSE75avHsmT+BmBUaeKo6WxtwdH+eYXBv51wto98G6Ic9WxX+CEjvKDTH9yWs/4bCrs7gptwQNy/RfrXdAQoKhgW2m6qUn/32fJcdxUEhbwO8bIiSrBjI3gDoBYGzxNTjLb0AAvQnrFdmBDcjZ1mY2KWuuQ73eK75xEGQ9cXRBVhYlRIjY8L0VLRttXRQHaF6/tX02qLmGRM0bDSCMEfHVjnDGHAWUhRjKF0nUo63N2+Yq/Q== 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=Zg17DPPYOTuadjG+VkqD69CJqHyQvuSbj4mlECIwRQQ=; b=h397yoB125+bEMC0nmOP2p43mXrs/cmMRyf2wadW3rUo+U3P2QMSC0V0HNX59UMdlerbZYURgu/BZcwq041azthZT4aZStc4whIyUVaZfukjdqKqV0tjperKSeRN1x8fa8Q/rMwEuzbhYHBFV2UdxJdIpPIzROS1/DhI7ira37ivTe7EtA6GKAdyaNJ03Cg/lhYvp8Y1WBs0NYHmZ0QvnZwxVgv7LqINj3FxQ5e1jd4TsypcOwE8lq6+pCBjQv0NSbybcHi6W87OBV3o43PVOTptUQTR/wmLnjp4JGN4iTzPKIeA6BJ2pP3dp6PfPYiNlUj92UBEznC6HyoKPIa0fw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zg17DPPYOTuadjG+VkqD69CJqHyQvuSbj4mlECIwRQQ=; b=XkuOxkTmzRSjcu1arez24AsI9ewQVEPvV5RLGP3boUpHuMDJ0xfqF7a3ohMnsk1taBt9JBWP5Q9wTHImvraOdoIuRs0mW6AO/uW/hi8XoqugBIdMNjGDjaOkrzNf7PPMsEpT4DqIFoIbCTOQiF3qOVm33kCrxr5HMV8u04ytF3lu2Qht8+daLjB8p+sFHhjZgQM0y1pywLuwNJf8GFBsNBqrxFfZ86F7sJ8nmkWJfWxmdB+xcejTYujSmYNmTr9Gzw3s0D3fUrEgFJfSpltNn/yY0nhtFcd6zb4NuylvM0AGnIJxfuoqjCwnNwZo+KQXz2R6f1IpY2eGA7el1+smPg== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:57:54 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:57:52 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:29 -0500 Subject: [PATCH v12 1/9] irqchip/gic-v3-its: Avoid overwriting msi_prepare callback if provided by msi_domain_info Message-Id: <20241211-ep-msi-v12-1-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=2559; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=h9rTyIw7JBTy1EJzxkuF1XAJdSITdDV9rguxRpQSuCE=; b=2aRlvWumyidpf84WG24Qliz1Q9qLqiUdSsjcTrwNvTPPY3x2ktuzFuXMSb/6iwZFHnNVfmnUt yv9QILwBLtcCSGExXA40qui42uvNU/gexQNhy4K0gsrsaeSO/LvPRhG X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: a224c0da-b0f9-4ac6-2aaa-08dd1a267a66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WqZHC0vJV9mJKVKLj3JUVLQ5nYbdd6e?= =?utf-8?q?+tFrYHzhvRr5XD9Tfx2606bG5DP2lY6gdxZFJYxCKl4i6KrZR4SD+xxKgySGHpnGi?= =?utf-8?q?C+oGptY4GTc2Y3Dpqf3pndV8OSsFq6CcxM2bNELJcPvKqXSdC+TFy6oADmZUH0/S2?= =?utf-8?q?7uQt720eL6KzwItYR0JQJ4rPtOSlPOI0WbP182HRHt/uS+EsQwr8kTLBAYrkMv1gA?= =?utf-8?q?ri6gJPQy4qRs+NxECPTwjPsAwq9DlhkMKfOtt2LYXuyldSLQOvp3t9beR+SiksuL4?= =?utf-8?q?4U8iVetH/hSoQzd6bFID90E4N4v4Z8jan0UO8wmGBOfy4jb1ObNxCN1kmOBFcakLq?= =?utf-8?q?19+KqNQ3/PjRppnWjv71thoGMvTTVujExTUseJOkxOSnOtgAvdrww7d9WsqZr65eT?= =?utf-8?q?GeVTEH11DL1/+eSmh75r8L1HkAP1VMZBwZ886xsIAhCWFpK63BXDnfdJ46i7swC1w?= =?utf-8?q?QZ3AkgHQFm/LJ825aArWMo4gdwe/F2mHpahIz+uwyqbJzOHzHaI0adpTxBEGSmTVk?= =?utf-8?q?M8AKjtt1cUiJ/IARTR+xqEJpUDN5d3Aw7tK2Qs/Mo2FrXYBPPcIBj2slF0UhWuGjq?= =?utf-8?q?4q2abJyWoxy5G8FKB9ywnErY7Y3qETrCxDLGzhfg8astOqqf48iUkeKau1tQihuIc?= =?utf-8?q?/1wFuw6U8wPfN4PZtBgAqWllEOfSpeYWZ3D5t+rBz109ncVNvLNu1JfdDV+SduOAQ?= =?utf-8?q?z1OctnOF4acTi4TQV+0zdVEHD7Rrwsa4J01GE7jzKCfHXWjc6TAutvTJqlRcGKTlV?= =?utf-8?q?NTJTRmocjXdO3Nbic2PK62Oq5GgSUXZCceaOk0mfIYajocYhChX14axgyEXNuhZt5?= =?utf-8?q?hNJpDdisz2Tg102jkKADIzlh5MKq5ITttY/Cxtdd62lz/0y7nWPJ7f37fBKGcRD5v?= =?utf-8?q?LUc2XSV4Komk6IexhHr7xgWdvwzRo6gRTxZeFPNagtPgN/m+L48g7JdNkTLkOrF/t?= =?utf-8?q?DckoJ+tBGjjta1/6Uz0TYjFoS98JbaC8FxuAHSfk+KKJVN2pXlitaGSjLQ9cJ+ncP?= =?utf-8?q?ILg6xiod2I3ZqYvR54yFkS1uFAzb8zIqJbjbGl7HTXPW3OVc51yHokJgsFpH4edh1?= =?utf-8?q?wDRv1gW9exgojDdTWUjvRXzs3MmK2ziXLg+V851yci21M/a9ABty2dEHS84Ckztdx?= =?utf-8?q?Y4AbZ851J3PJY65wwbaz2iET6hFZmSGgcF7pzIJdm5x1cRyG6q8a2Up11r7ecvMh9?= =?utf-8?q?LmO1k4IIfn08KabsefIfyJmyizg0iIjCf2PkPcxNQYQy94jbJ4pD1UfdMEnVcnKEn?= =?utf-8?q?JLKnSvfdg2u63xMUYuWvlv/eS/aGDtPdbsH+eC2HNgeuSM4SRFUQ3HzMnWebSX9x7?= =?utf-8?q?pu9ubK8mmc9/sUdHm8ZF91olwW9Hjhp+qWQwahzB+1v2PPXRtb5hPzU=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?iXGL35JdSaGUeTfBGK67vND1HG4b?= =?utf-8?q?fGVNKIrTw833a8sf1dZaB0UbDBIVXdK1FEu5jlHcDt+92LsY0UYOB18I2Hsop5/9u?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n5mmN5AzJVaCcSoM1YmAr8kIUaYOjSa3y+4bwjqK/xzyDPT64bkz?= =?utf-8?q?3Sqh+VFwrLpLMLrKhv7JIaVAqf/ifigRd1zKa+743MF5ahm0NHVIs6AYJ0ggT1SFk?= =?utf-8?q?cATMRJOOaYWV6KS/aV2aoS++BqUiPReMM/KT8j0ViOkFc+Zl/1B6x/W7D30TqZyNl?= =?utf-8?q?qcW0EWhLGhDfh0qZ7J9YWRv3paFpBvKlXuKct75CjXLEtRj6Nzk1afntX00mAr7Pn?= =?utf-8?q?W4BUkE9Uudl3NhZ6h+jPtxh0cjGUlHpPmtXxcOYlClAnKPbi1Bj/6Jsk1hyDq5A6V?= =?utf-8?q?obRtJimtwMfvDZAhjupi8gRjcsR2ipGOnFU2q5VgLJw2dpcQdCXCj0cKEyijmNvc2?= =?utf-8?q?wGgF2wyUe956pnZZJpXk0cRDZ+OQ3GIIZ99rIs5+ARoIN9KvgeMOe8QP9pxiAn0zI?= =?utf-8?q?7Cmnlq3atgnzCcGzX2XAKEAy0Ear5gHVKigltuYvSsKTByg4Tu7O4qlLMTdknBOlZ?= =?utf-8?q?yT1Ie/fX8zW4RKL7B0IpAePjvgQmQacGzw2NKtWt5mAw7WP8SXW38EEAFvu3nskxR?= =?utf-8?q?LpgeJ8Ab2ARQ?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a224c0da-b0f9-4ac6-2aaa-08dd1a267a66 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:57:52.2212 (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: u9k7tLyGnIuJkTWZacOAhkqmg/m7GLDV35alYdLgRrOSZ2NO36vd0Gt54vH+RTAXGIOnPX8fABa/KRltnejoLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 ┌───────────────────────────────┐ ┌───────┐ │ │ │ │ │ PCI Endpoint Controller (1) ├───►│ ITS │ │ │ │ │ └───────────────────────────────┘ └───────┘ ▲ ▲ │ │ ┌───┴──┐ ┌──┴───┐ │ │ │ │ │Func1 │ │Func2 │ │ (2) │ │ │ └──────┘ └──────┘ ▲ ▲ │ │ └─────────┴─────────────── PCIe Bus (1) is platform device, which is generally descripted by Device Tree(DT). (2) Func1 and Func2 is created by configfs The current platform MSI API supports only a single device. For instance, a platform device (e.g., PCI Endpoint Controller) calls platform_device_msi_init_and_alloc_irqs() to allocate MSI IRQs. Child devices (e.g., function devices created by configfs) require individual MSI domains, with the same MSI parent domain as the parent device. These individual domains need specialized msi_prepare callbacks to set msi_alloc_info_t. However, the current ITS implementation overwrites the msi_prepare callback with its_pmsi_prepare(). Modify the implementation to assign its_pmsi_prepare() only if msi_domain_info::msi_prepare is NULL, allowing customized callbacks where needed. Signed-off-by: Frank Li --- Change from v11 to v12 - none Change from v9 to v11 - new patch --- drivers/irqchip/irq-gic-v3-its-msi-parent.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its-msi-parent.c b/drivers/irqchip/irq-gic-v3-its-msi-parent.c index 75aa0d4bd1346..33e94cfc4d506 100644 --- a/drivers/irqchip/irq-gic-v3-its-msi-parent.c +++ b/drivers/irqchip/irq-gic-v3-its-msi-parent.c @@ -195,7 +195,8 @@ static bool its_init_dev_msi_info(struct device *dev, struct irq_domain *domain, * FIXME: See the above PCI prepare comment. The domain * size is also known at domain creation time. */ - info->ops->msi_prepare = its_pmsi_prepare; + if (!info->ops->msi_prepare) + info->ops->msi_prepare = its_pmsi_prepare; break; default: /* Confused. How did the lib return true? */ From patchwork Wed Dec 11 20:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904140 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2049.outbound.protection.outlook.com [40.107.105.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 D5125236F9E; Wed, 11 Dec 2024 20:58:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950683; cv=fail; b=XDEb9rHIjHTHb8+EtEGFlkrvZMMrc3cDdFyJWmaDNtU1xiMUf6KQz2B7LgQoCY5fBEKlYqC41yx5ek0yAvLS+GQmOge2pC6BsrrUMqW7CJGwHIVCLZbos8tl6XAKIIrKhaWWhR1LC/M0pGwSzIbNjlXpS3bmALt9IBxy997rXZg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950683; c=relaxed/simple; bh=Udf092p8YjxrnQN11gltHeyiotoRRFrXWEdyz1BjlZI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=heFNE0pJ/x/r4PTaQsFbrkGELmRHX1PKztBAB0nC6k+85iYrR8a7mPGElJk+zbxygiwcIRH9DnkZtFkNto6EViBiyS4w61caSwU1W+OXQ9eXiSuCMrAZ12zNmPZyJw4fuMOxaU5BKA8/iHN4ZID3769JJuSt1Z1EEFUoP5IWMSU= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=iTc+YW1t; arc=fail smtp.client-ip=40.107.105.49 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="iTc+YW1t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wOO1sI0CuvMXkg9lwYysUU7z9xjxEVgAxgUV1bgcd5xmvgI2A83M48NdLqf2BaCjL6ovtD43+b7VZ1rnMhzlKsQYNh/LmJTDO1Seg5mIaKaTocB6XoI4/GBff2ZSeyM9+GKUQIdIQdaqkmxNZinWg92YW/aV/awqa8nEkPElRBnI8lJ2EKLbHB2LNx202kmL87m64+SRFEDKXkZF1QLQhY7C/eBuUw2S/gVpJO55Th+4NqgJiCLNs3Mo45pFqoNtSyHKvB0pyXdKv8zCz1AWs4TD1fH1P/lRkR3NJZ9DXgDuJitBY/i9lxHhqVaR4v+Jfajh8vYZYiteSXoqZMZH+g== 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=oSjI2OUg9zpkx5v2mVQeZQbwxanG9aTvPl/3UjNHnHk=; b=W8WtlFClJ4eEfmlVbvcTB2UNzHBc1FqrpfXZZ8/p1UrD8bjrgZ1iDX6T4Lozhv15tKsSeaxC5izRwsQul9eX1gM6wW0I5rCC3bhKskvr79eEgNVOj3X+qMI77iQxrzn4YU/JQo56NDfuxGFDJGKUmSsaj7CgxA1OlzFQGvZRINw57ZBqLml4nbRxpPfc6cOEI4UZV+36BIbp78Yku0YLr4xQ/Q+XliRiLalmF9CEdg1jfxj8077QkoKY4iHMRszk3jD7uPYqbHgEhMmur9tpqtcN29SYSZ2kjELSsFM+wAaApZ1Uc1DHtAJuBmpMAvVGa5z3xNoNyrTmUaIkodKoVA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oSjI2OUg9zpkx5v2mVQeZQbwxanG9aTvPl/3UjNHnHk=; b=iTc+YW1tQHH+GXA18yVgyxlODIRzWvmcQtxKxdQO0wyEdBwNwO0FqJI+8wmS1P/Z5R864OC5j/DDgbHFYayYNo2BKabHEHx865zmZ0y8H4Lzp6O4NFgCCRW6AL6+mvLh3P5ijRdVS8U4gIvOR7PykkKtMxPKmf1O+wSFeibUYDoQnsbNHa1bYZBpRXZgHgnqZyTUW9CXYiGRI57zcRup6hp7tcGG1qMPkY8iiZwrN2kRlSTq9O92S9S+icHV6yMHQLGzTIkOdbKJ9zhDn7P5a+NDPWVFTM94dOkGJqhhgVLLtY1An7TJw4ayuIgihce5xUxzsuthCFUjHwP9Jt4XvA== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:57:56 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:57:56 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:30 -0500 Subject: [PATCH v12 2/9] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Message-Id: <20241211-ep-msi-v12-2-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=8536; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Udf092p8YjxrnQN11gltHeyiotoRRFrXWEdyz1BjlZI=; b=uBHyPAj0CEvZaks+WEu1KQpI8LXbt4CPR/bd0UABXhGiJTkjOsHSaRUtZ+10g3No16A7PEmLc t9TrdVoy4NgA2ZM5ThbbpU5795ZXeXzSPzAKJnnd5ayMHmwT2R6zDqb X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: caedd752-9a95-4b9b-10e1-08dd1a267cf4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?djrcfthH0fS14JQwTpW5hzR1bfmCCzk?= =?utf-8?q?TCNpigttIeclyy1VcHVIA1+icgZPyeCrX0zZJ09BrkJm0bNJ5HR5zAtEWPSLyY1Yt?= =?utf-8?q?WEanxHaFOyQEaX77fRTen19L9hESrjjLAzJ82CIiUFUeg1PjOcerba/EgMyHlfDY7?= =?utf-8?q?A0VNAvLp6FMEe5zY7HY/XCP0OhRerb9X9rOb1dM5wz3unkQXw2zKx0a67M0ngOTAo?= =?utf-8?q?QhsRNYFmMIHZW+CVtxGzWAcKpzDylonaBYwbMe4TZv1tWuz6k/SVm1/MZnXHuBYEz?= =?utf-8?q?2LpYilRTsey9J6d55mDHy1ewobKGaqkJhr3jKz3PqplL1inWOwxVK9ipfetD5k75I?= =?utf-8?q?65GGMPRhS1BG0ubv/G8+v/J6vk7kD50stfKVf1cnXG/GRdQm3M/F9GuLVwu/2oEc0?= =?utf-8?q?vp/F7jHERcPH9GBCXf+am2jHVJkMC2z2zoqTXS92yFPfvvMt0Xu6aeo+PBLp4Jizu?= =?utf-8?q?kIxgEoj7/Q73tY2qB/8igDB7iR9coF1tQV7lPYFK+h37F/IpLpze0f3fGHN1CfXlH?= =?utf-8?q?8UpwDY21ztWznEilEsiwkHm5oTshc8ZEoiPlJR6JViXeRz8mEc5MX5ywLOrRxlLRb?= =?utf-8?q?7uBE0P16ShebWewm+DJVPatefAwQUOHWTjncdld0jB/PONl2MIRoTfaf/ylYnh3t1?= =?utf-8?q?q3EzmzMqjM/o9Um1FahI0Jis1qEWCvH+VwgnTM7+Ne9/sovbT7dznhFAlAxIP8D52?= =?utf-8?q?PpNYpKErM5w+aOgsN1XqPedaRy+enrwodH49r4t8NVrG5KBfXJBF3xmYZOc8L8YIr?= =?utf-8?q?5vQEcLdJDmJiGIdnJmsmBbD/HMnCNSyHKscL0UefmtKEP7JTooktwDYHPgxn9XE/x?= =?utf-8?q?zbLEzdSFjHcjUymP4Gcp0VlBiFkFRBYZDDI8FjDiVbRKxdFPFtETSnKT/hzYYmk3/?= =?utf-8?q?UbLMFYzlGCBnhIF+tGm3w3iWEe/rGd4/nnE4W1vr2RRCFSReihPnm8TusjGWLEqjn?= =?utf-8?q?q/nhLdWpPgrxwcpKw6n1U0wGaHbi9beoMlaacrJjXFAJ87S+mRiXGgPByb+ft4Aqa?= =?utf-8?q?K5rXaAxiey5RXuXnbov9r+ad2gGXNw+dugxjOiaMIIloFW9euLOGLRRtT+VB7r/cr?= =?utf-8?q?oREyWu+WeGHbx8z9xXg1CsM95KR0QDIfNI4J6oUWoRjyneJvGNhzZXIYbRjklDNU4?= =?utf-8?q?AAAT8S1WVGdqiQBleANTM+lwTdvT7qBMX34NRVUMsi8pVvOghHy2pcgQGHGVusf2/?= =?utf-8?q?4uGi4ctoWQ+RL8PfPae1n87ZwQY6qA5hZBYbwg1+6dCopUnnoX5+CP/ohTztQ6Ico?= =?utf-8?q?pTZ4XpCBUTSIH4MY39vYYHbgNP8GnKrcFZAdRmDr1q69kAhtyLRK1Z3oxEasOqWw3?= =?utf-8?q?ZuDug81hRSBgcjGXbQgtD2c6amrfFN88KtwHAOPVzl8zaYJDjeoMQ1g=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Zhd1rSxAJQTKxwMEvm1xLIgnAESS?= =?utf-8?q?GmWstWTrpeau1CovGxHeVfZLHAD+K0nIyw/jQnjGXEGugCQ5z7EPwnaZxhmtqAv/1?= =?utf-8?q?za2gHyu5xdduG13LyTAus4pOarFSJ643AOltNkU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ca5md10zGTfOdcn/XdbOFNCziUWR?= =?utf-8?q?lUGcJwzW04gTST8tsve18sw/NAeVUJsFyFHdd0bwjQOcZt/ofYBaLYihakLVgzkY/?= =?utf-8?q?yqHvytwDAtwb6E2MD0KN2yrgCCeZ3lFPkgdkup9nZlDSesTmM7XnK8hp8AW8iAaJq?= =?utf-8?q?lo1abir6zQ62XytJSqKnhXWQMrvYQh1T245R7v13TPS50aDoEDM5HGujwhLI5oK5F?= =?utf-8?q?FCUkrNbNCVE6MF3wCIa5g+ZwQFxd3k1eTW1C7CEocOcnSgqylcTKN0i4t+Clvv76/?= =?utf-8?q?fd9Uajt5DSiDeoZHG52pskub3Ka/esv/Pc9fWEZ4LjmtKP9viXzpfp09ACnECHBB8?= =?utf-8?q?EGXXhbAp9wz292AtMh3E4xaVv3J06v3UUwv9DZxX3Kx+Bu+Xld+X61tykmO8Va3vR?= =?utf-8?q?lHQGW3pGgmLh34OR1UbxuPpjkeL2tnM2P0qpcwjbgPY2CPXPRnNh44ZheNRHZecRK?= =?utf-8?q?qJh14gJyot95Bq0EVOqj8vO5LD36tXxRAG4bTN3gdIoUYBfPMAaoPq/9kfRGiEKCj?= =?utf-8?q?TO36b/8cHk0q?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: caedd752-9a95-4b9b-10e1-08dd1a267cf4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:57:56.5230 (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: ym669mySxWsqdPziA77iKhfxbUrt+JOGu65kxPpZCEdSBeK9tWbusEkX9QuD8KcMBGfe+pJ/0CFl2cq6bIIKQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Doorbell feature is implemented by mapping the EP's MSI interrupt controller message address to a dedicated BAR in the EPC core. It is the responsibility of the EPF driver to pass the actual message data to be written by the host to the doorbell BAR region through its own logic. Tested-by: Niklas Cassel Signed-off-by: Frank Li --- Change from v10 to v12 - none Change from v9 to v10 - Create msi domain for each function device. - Remove only function support limiation. My hardware only support one function, so not test more than one case. - use "msi-map" descript msi information msi-map = ; Chagne from v8 to v9 - sort header file - use pci_epc_get(dev_name(msi_desc_to_dev(desc))); - check epf number at pci_epf_alloc_doorbell - Add comments for miss msi-parent case change from v5 to v8 -none Change from v4 to v5 - Remove request_irq() in pci_epc_alloc_doorbell() and leave to EP function driver, so ep function driver can register differece call back function for difference doorbell events and set irq affinity to differece CPU core. - Improve error message when MSI allocate failure. Change from v3 to v4 - msi change to use msi_get_virq() avoid use msi_for_each_desc(). - add new struct for pci_epf_doorbell_msg to msi msg,virq and irq name. - move mutex lock to epc function - initialize variable at declear place. - passdown epf to epc*() function to simplify code. --- drivers/pci/endpoint/Makefile | 2 +- drivers/pci/endpoint/pci-ep-msi.c | 148 ++++++++++++++++++++++++++++++++++++++ include/linux/pci-ep-msi.h | 15 ++++ include/linux/pci-epf.h | 16 +++++ 4 files changed, 180 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile index 95b2fe47e3b06..a1ccce440c2c5 100644 --- a/drivers/pci/endpoint/Makefile +++ b/drivers/pci/endpoint/Makefile @@ -5,4 +5,4 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) += pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ - pci-epc-mem.o functions/ + pci-epc-mem.o pci-ep-msi.o functions/ diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c new file mode 100644 index 0000000000000..b0a91fde202f3 --- /dev/null +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCI Endpoint *Controller* (EPC) MSI library + * + * Copyright (C) 2024 NXP + * Author: Frank Li + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void pci_epf_write_msi_msg(struct irq_data *d, struct msi_msg *msg) +{ + struct msi_desc *desc = irq_data_get_msi_desc(d); + struct pci_epf *epf = to_pci_epf(desc->dev); + + if (epf && epf->db_msg && desc->msi_index < epf->num_db) + memcpy(&epf->db_msg[desc->msi_index].msg, msg, sizeof(*msg)); +} + +static void pci_epf_msi_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc) +{ + arg->desc = desc; + arg->hwirq = desc->msi_index; +} + +static int pci_epf_msi_prepare(struct irq_domain *domain, struct device *dev, + int nvec, msi_alloc_info_t *arg) +{ + struct pci_epf *epf = to_pci_epf(dev); + struct msi_domain_info *msi_info; + struct pci_epc *epc = epf->epc; + + memset(arg, 0, sizeof(*arg)); + arg->scratchpad[0].ul = of_msi_map_id(epc->dev.parent, NULL, + (epf->func_no << 8) | epf->vfunc_no); + + /* + * @domain->msi_domain_info->hwsize contains the size of the device + * domain, but vector allocation happens one by one. + */ + msi_info = msi_get_domain_info(domain); + if (msi_info->hwsize > nvec) + nvec = msi_info->hwsize; + + /* Allocate at least 32 MSIs, and always as a power of 2 */ + nvec = max_t(int, 32, roundup_pow_of_two(nvec)); + + msi_info = msi_get_domain_info(domain->parent); + return msi_info->ops->msi_prepare(domain->parent, dev, nvec, arg); +} + +static const struct msi_domain_template pci_epf_msi_template = { + .chip = { + .name = "EP-MSI", + .irq_mask = irq_chip_mask_parent, + .irq_unmask = irq_chip_unmask_parent, + .irq_write_msi_msg = pci_epf_write_msi_msg, + /* The rest is filled in by the MSI parent */ + }, + + .ops = { + .msi_prepare = pci_epf_msi_prepare, + .set_desc = pci_epf_msi_set_desc, + }, + + .info = { + .bus_token = DOMAIN_BUS_DEVICE_MSI, + }, +}; + +static int pci_epf_device_msi_init_and_alloc_irqs(struct device *dev, unsigned int nvec) +{ + struct irq_domain *domain = dev->msi.domain; + + if (!domain) + return -EINVAL; + + if (!msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN, + &pci_epf_msi_template, nvec, NULL, NULL)) + return -ENODEV; + + return msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0, nvec - 1); +} + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) +{ + struct pci_epc *epc = epf->epc; + struct device *dev = &epf->dev; + struct irq_domain *dom; + void *msg; + u32 rid; + int ret; + int i; + + rid = (epf->func_no << 8) | epf->vfunc_no; + dom = of_msi_map_get_device_domain(epc->dev.parent, rid, DOMAIN_BUS_PLATFORM_MSI); + if (!dom) { + dev_err(dev, "Can't find msi domain\n"); + return -EINVAL; + } + + dev_set_msi_domain(dev, dom); + + msg = kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL); + if (!msg) + return -ENOMEM; + + epf->num_db = num_db; + epf->db_msg = msg; + + ret = pci_epf_device_msi_init_and_alloc_irqs(dev, num_db); + if (ret) { + /* + * The pcie_ep DT node has to specify 'msi-parent' for EP + * doorbell support to work. Right now only GIC ITS is + * supported. If you have GIC ITS and reached this print, + * perhaps you are missing 'msi-map' in DT. + */ + dev_err(dev, "Failed to allocate MSI\n"); + kfree(msg); + return -ENOMEM; + } + + for (i = 0; i < num_db; i++) + epf->db_msg[i].virq = msi_get_virq(dev, i); + + return ret; +} +EXPORT_SYMBOL_GPL(pci_epf_alloc_doorbell); + +void pci_epf_free_doorbell(struct pci_epf *epf) +{ + msi_domain_free_irqs_all(&epf->dev, MSI_DEFAULT_DOMAIN); + msi_remove_device_irq_domain(&epf->dev, MSI_DEFAULT_DOMAIN); + + kfree(epf->db_msg); + epf->db_msg = NULL; + epf->num_db = 0; +} +EXPORT_SYMBOL_GPL(pci_epf_free_doorbell); diff --git a/include/linux/pci-ep-msi.h b/include/linux/pci-ep-msi.h new file mode 100644 index 0000000000000..f0cfecf491199 --- /dev/null +++ b/include/linux/pci-ep-msi.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * PCI Endpoint *Function* side MSI header file + * + * Copyright (C) 2024 NXP + * Author: Frank Li + */ + +#ifndef __PCI_EP_MSI__ +#define __PCI_EP_MSI__ + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 nums); +void pci_epf_free_doorbell(struct pci_epf *epf); + +#endif /* __PCI_EP_MSI__ */ diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 18a3aeb62ae4e..5374e6515ffa0 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -12,6 +12,7 @@ #include #include #include +#include #include struct pci_epf; @@ -125,6 +126,17 @@ struct pci_epf_bar { int flags; }; +/** + * struct pci_epf_doorbell_msg - represents doorbell message + * @msi_msg: MSI message + * @virq: irq number of this doorbell MSI message + * @name: irq name for doorbell interrupt + */ +struct pci_epf_doorbell_msg { + struct msi_msg msg; + int virq; +}; + /** * struct pci_epf - represents the PCI EPF device * @dev: the PCI EPF device @@ -152,6 +164,8 @@ struct pci_epf_bar { * @vfunction_num_map: bitmap to manage virtual function number * @pci_vepf: list of virtual endpoint functions associated with this function * @event_ops: Callbacks for capturing the EPC events + * @db_msg: data for MSI from RC side + * @num_db: number of doorbells */ struct pci_epf { struct device dev; @@ -182,6 +196,8 @@ struct pci_epf { unsigned long vfunction_num_map; struct list_head pci_vepf; const struct pci_epc_event_ops *event_ops; + struct pci_epf_doorbell_msg *db_msg; + u16 num_db; }; /** From patchwork Wed Dec 11 20:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904141 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2049.outbound.protection.outlook.com [40.107.105.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 4BEEF237FCB; Wed, 11 Dec 2024 20:58:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950685; cv=fail; b=etfvDxg1jEHsTbkq4S9N/YZceqVGjiuCL2u7MwTrsW30N/e0jwl5yqEqk7UpSpLrGm0FjIlqi6apKpMW6rBj2PWBFtLypiiYBI3asp5AtgZwiX52iangKE8qmQlptT/lhjRkcHY/xtZI8ZjMvAtKoAPez43ErIAtS2xXwtTUms0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950685; c=relaxed/simple; bh=9MukYG83d9aOMQcFVfHOi1d9Wyi9uvJG5YjZivBzTwY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=s8Pa8aPwJHo64QwY6zxLrr3tWg0JJ24CfyC6yQ20cVSgOAgFnQGg5zzxyXqbTmyMP53Np0Lb4gWUlb1juFQE4WvM7HyiCYqjHZZ/CMvmaEIaTdd6WeWclyZgPxRJLpyJG87D5qxSHju+7W2R+lvz8SsIfTXFa1+MjvSxmqkpOXw= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=k4Uczbtz; arc=fail smtp.client-ip=40.107.105.49 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="k4Uczbtz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CgebTg1x7Qh3Ks2Pn/T45WngaC0EoinTlC0ZeVcYR6RZhOZHazoSVdsKemKEXvNfAUVA8ZlR2h8nE/qufWsI5oFowG/XeF8Fki2C9x9UuMT9zfgNbsVtcz1zk4+tPECP9lvqTb4ZcOjVBs3SEVHb6g3nqOXmMvNgBHdR25VJL1jqVKcnN1oMMoE4KovAO7D8Kok/172whRF/Ywq98yfJHluDXs0GOk9jrOHfDZLYtWMm1V1v6c/HyNSMh4RO7LTQdOFHbJQa3z6rPgroRaZtXpouyhu3ha2eW0+Vxv5bcaSuKx5SDiUpAbvP+ZoEMg0LGGqkOgH4XPEHyImC+vn3Sw== 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=8rHiESil2o4GbVOYFQ7zKfqjJLUUmLHnPeQkTukgKiA=; b=mPi97jM5rQPQNlkZD9evyAcuGOBxBN4SAv3v6khQbiTQQdJNPCT4tyM0JSdhP6YzKKI+dMaiiMA1KE8s/rFB5nTWPvfD3bztSZeYMcFr/wTkIK5PsgFzXSMXAiGwHVsoDJoeid+EazzazazrY/M6+KDEj0RQVZGyqy7YNSu3AWURDq8tM/pHA2QJrIHJWiK3G3PP+JdWl/zups3wBihSPOhHzWZf3qCX3So1sWWZKZ4hIXbu1RUsn2IF3ngI+STNOXzn3/fwHJnzOROURjIVSkcx8zVRh9IDRDbwq7YE4w+N5n6Er5/H6YSikkGq/HvCSgKl3R8pU1x1Vul4AdcNxQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8rHiESil2o4GbVOYFQ7zKfqjJLUUmLHnPeQkTukgKiA=; b=k4UczbtzKHIZL4xBCfilESkWLAkrGJS/dceN1TH0ZbbgpHrj4V/UqYFtmXA3p0ApYzskETtYJhZ5KRq0Uj52ecI3svFXC/j9/i9/47ZfpGS/dllcfdmrpRl6fj2/2WCSKiRREc8c3B4112BjDZksHnN12NT0vjzBa16x9B2F9HG2KDxM0eKLr0WXB1vmASYraGb3PnCpXfTkTLr7CylKVh6DzMCbKmPgVh4kVBrzWlYiM29C/jyPbbFOFTfiKPp37F3VczFMd5HVwgvBVQxAqwB52+dx7LqgmPEavCX8LS2KOqT9P5whCenG3EixanKJUuD5QNYSgVT/cwzpMxXTZw== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:00 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:00 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:31 -0500 Subject: [PATCH v12 3/9] irqdomain: Add IRQ_DOMAIN_FLAG_MSI_IMMUTABLE and irq_domain_is_msi_immutable() Message-Id: <20241211-ep-msi-v12-3-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=1853; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=9MukYG83d9aOMQcFVfHOi1d9Wyi9uvJG5YjZivBzTwY=; b=Fb3dWhQjs0wMRJeR9Rgmc45PlhjuOYIJ98UBQhBCRcCQwpCXcrxFdvXuy5IhZ7UCjV+3pggm4 1hN/K69HGbzDZAhCIqalLf9rskSXVUh53UX25n8DdMf5TublZOJTE38 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: b5c96464-778e-4563-e086-08dd1a267f84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Say5jcyGMDebQ7vl4J9sAVWQ6XmXZK4?= =?utf-8?q?c4hzklJYc51lWra8OFEBoMHwfWhBpoOEq14vzYPtWrWrEt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n32WmwOpRogCdJn?= =?utf-8?q?DhQuSMT6cdiDECvCNG1zdOHPsy5YczW4Ms/zAD38mCw+Wjtljk1N1ba4EodxxgRlz?= =?utf-8?q?17wp3oKx2bO50IFUcYzB8MqG8SKH0S++aQRWQH0zNh8gSR3IgFaOmu0+KFa5jRScK?= =?utf-8?q?8JwBwym6j6A39F0XeTjToy3EVNzubQaqeRzxM/IKbv+e6OKaM4JLJuk4B158clvME?= =?utf-8?q?uPUoCCIObc2Z1HjPTRo4tJcOY9hfWmvolDPUZDxIakwVo0d4Jc1YA16LQADln0jI2?= =?utf-8?q?6fz6Nag4xqF5nGXWaaHYZrrDnZBeBAuNkjeTt299BFdJbYUp+NeRuLQaxLlpe2jKA?= =?utf-8?q?w+nNoWDmdmgMZc/XAGX8SdyGzZzaV3z/IDXXyrvzgV+Nu/+SjPFa8EuXKj0+O40jn?= =?utf-8?q?U3apfarszuVFzC/+PFRULG8zrXaCaZfSj6r8ly3Aw3rB2lyVut+w5jI=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zYG0exypmTWg7/Mv0ynePr8Szb7v?= =?utf-8?q?3l0yMex+a1JLy/Lpyb5W3is7MmeMbedfKVkO0JlakfyEVHGdOAn+tXnT7hDNS0HEM?= =?utf-8?q?RyPsk4WQ7BOGmGAbbPA0I9xd+wsZAVbogl3UV1FZx33KlGabMEvlU7LWG0JwvpIof?= =?utf-8?q?T6cSy+X4Kb3YPqhvQZ7IDx/NlFHadKwmQVuSOo8Yvl6yqOzquQVOVwh3wQDIXZaDS?= =?utf-8?q?212ZR6KeNJJ2jU50/xa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nwoDObKDi1vqIeqb8AIVJpf7Y8VFGX?= =?utf-8?q?wuuHdAPD+ls5AVOHPOxKZxS6KZWFWlvOV1vffdt5+OiWnAOAUexmEVtKRXeb8HmBR?= =?utf-8?q?Rt1754FudDYbFXhH+07hJXSdoxv1dcJ75k0EupUHJen/t/oXuJTMPJdp5WsPLLIvc?= =?utf-8?q?t6VXsWWZj/3u70EWS2byTZc0uiKe16GzK8CrXanJfsK8dqlVo4LPEqKr7z5zKLNXB?= =?utf-8?q?hyLRVSDfPwQGT25MQTOkOhBb95gWC4cMv0dIIo+n83goKqNhGVtn0hoGSAe4liYCj?= =?utf-8?q?WP7HT4oFKou1wDwK7S1ITYOj8SACIR2ugDaSt64cjRuzSP5t5Wzkl7pzCVtvGogi8?= =?utf-8?q?NmS69FELHv6bq4r645cymmYrhmUNRRHL1fBFNbxVgrZ6kA/Ov793aUQx8Q4A5vBVR?= =?utf-8?q?5OIzYa8dCFAl?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5c96464-778e-4563-e086-08dd1a267f84 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:00.8211 (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: 1lOlnrQ6Rew14b5qaCep7jMOVKiOcCji09xhkIV2XiM6h7iMlb564UYTqyHFerdhtPvD4BsoiwLaUJ/jhP6H8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Add the flag IRQ_DOMAIN_FLAG_MSI_IMMUTABLE and the API function irq_domain_is_msi_immutable() to check if the MSI controller retains an immutable address/data pair during irq_set_affinity(). Ensure compatibility with MSI users like PCIe Endpoint Doorbell, which require the address/data pair to remain unchanged after setup. Use this function to verify if the MSI controller is immutable. Signed-off-by: Frank Li --- Change from v11 to v12 - change to IRQ_DOMAIN_FLAG_MSI_IMMUTABLE to minimized the code change. Thomas Gleixner: I move IRQ_DOMAIN_FLAG_MSI_IMMUTABLE to irqdomain.h to simplify helper function's implement. But I am not sure if it is reasonable. If you have any concern, let me know. --- include/linux/irqdomain.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index e432b6a12a32f..e63652604b621 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -231,6 +231,9 @@ enum { /* Irq domain must destroy generic chips when removed */ IRQ_DOMAIN_FLAG_DESTROY_GC = (1 << 10), + /* Address and data pair is mutable when irq_set_affinity() */ + IRQ_DOMAIN_FLAG_MSI_IMMUTABLE = (1 << 11), + /* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the @@ -692,6 +695,11 @@ static inline bool irq_domain_is_msi_device(struct irq_domain *domain) return domain->flags & IRQ_DOMAIN_FLAG_MSI_DEVICE; } +static inline bool irq_domain_is_msi_immutable(struct irq_domain *domain) +{ + return domain->flags & IRQ_DOMAIN_FLAG_MSI_IMMUTABLE; +} + #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */ static inline int irq_domain_alloc_irqs(struct irq_domain *domain, unsigned int nr_irqs, int node, void *arg) From patchwork Wed Dec 11 20:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904142 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2069.outbound.protection.outlook.com [40.107.104.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 BA085238E34; Wed, 11 Dec 2024 20:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950689; cv=fail; b=EFG/UKjUHJKlvGdugM24btAU6iMRoUrnKygFqIDWQ1oX2bfacGwnfwgX1xVkAG/pvSdZLTwEjNZR9vqHl/tQz4wg16+w2KTYviap5rxrFMJJVkSm2vUIlHxdhhbesWBDjqiHFBeHhcifJ1PAmVtQdL71lXsZ7PS53x1G5MZMSC8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950689; c=relaxed/simple; bh=5pjdUm+qdlHFHhK7ZyIpeEGf+O4vh3vaMbBm61oH25Q=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=OUA2pGCBtvGJhJF8f/J5E4UMp7yBWXaLmelpXRSyS+H64xShp81P1LMhEztV2dym+3WAgRFWxx6WnxP4ZAZjqvgwiDZwz7CxmX452H8Ut2LLjhCBEqLcf8mdwyh3dWSgpSSZgSy8L73S/rErWNrfNqv008+7Bpr2obCyOxQQsQk= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=YwdiLg4t; arc=fail smtp.client-ip=40.107.104.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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="YwdiLg4t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sHoDfkrEBRrWGNkexEPEysHIfN6Dfm5DqTEInPYdvmtUF9XIFD3oJcphZG9+cvfDZOmgvQ4cgUGNClAPo50qbyYTKYVzXx5d6KtkmtjdxH5zPTb/gLt7/rJULD0q2nqFfBaAmtGlVbkFxD8jyzQtmqDMcCPc5+9udqrhWkUUGU8hhM1kOjUDy4b2feEYNlTU73qB/9235uceQgCQnK7XWaayNNDMwXfdrJNHfF1p16NPojxn+cF3Y5QeuYPAYEAqqwcX6ofNtqIdeIZb8LHNanUnn8Bk9Qy5vzXX8Uporv/2bEnZsLdCnOffbC3MlP8wwT0UxnjOGfQtLaVabfyjBQ== 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=reEdFfm5r8CECXTiigkGpsrZkbeQGvaWHv5MjgKBfkw=; b=C7ntj5IeBGRFm01RpegzljK5fTS53zJBbhJSc9xpertr4X3l5//QYxBpIKpYmsnPka4pbiv+LFVQMqvNKggCJI20XYGNHGlQodnamerFV0EitJCVYqmIZKywbqD5k7bKQVcbeQT5AZylLaOwt2NDS2vidHCTR2SUHvwXkaoo14Xtc6VrPLHxYoK2qo2U/y2PTn3FI5HufRlC8ZGgHtoliAqU8hLhrvbOIXwyMNnvximzE2ueo8ImCqMrGE+KfnWEMbxyA7kLrvuu2Qqtou0i3H/UitCCf6/H5Vs4s80L9WgxytM4SA86I7V63B86UXapf/gvk5er5HOVrSsWYP1Vfw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=reEdFfm5r8CECXTiigkGpsrZkbeQGvaWHv5MjgKBfkw=; b=YwdiLg4tHpoCVurMc+sFt89iGiLyFZGAWYezSQ2MAQzrr3nXMYjnkewdzCrP//CaVw8D8D5vZ6Hv5ZG+rowqbJidcxyH2DYTwzQwTPTYm0PlTr83U5OQjVp7an8UbXG6bOiT+jtjswh/L3GnOne0RUwJfJpg9OKMbGgV06H+9lsVDYnFwVnBzU7YCuFd+bZmBYwUA3JebvapmUpvDapWESnWDfYwxOWINKJXZmKGaVoFmCBLYd3GwhKzNp+6b9A9masVBIpyHi/5ql5nIdKX6oj5I96jM5Z2BH3sTqjhsmFv6nufke1rAMfG7a8iw/1bSahLBb0eHqg+eKLcgNWQKw== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:05 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:05 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:32 -0500 Subject: [PATCH v12 4/9] irqchip/gic-v3-its: Set IRQ_DOMAIN_FLAG_MSI_IMMUTABLE for ITS Message-Id: <20241211-ep-msi-v12-4-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=1104; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=5pjdUm+qdlHFHhK7ZyIpeEGf+O4vh3vaMbBm61oH25Q=; b=mkzVt8ks8Sx225sdryqVfv2jrzObaDIjUCPU3nr/ZROfKBw0r9KBwNhQURWC9A+VFYL3Ps+F+ HzKUpY2p3qvC7sjGAAARJ3r+sZ/DOgk6jMIKNCh3Pec2auhQHvuSvWd X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: 45a3c0b3-b1dc-4dcf-6aee-08dd1a268213 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?EyxX9qEqbkHu2qbDAV2fGWt5TUElVDI?= =?utf-8?q?ghhM+5qwAJRM9TZhWbesUcrfzlGJf7qQp8789CspS+5eMuL+VyyC7M9cviIguV28K?= =?utf-8?q?wt78XfwoV2EA20z5sRAZ40GxChJkFQWqdxiy6GeckFYtRfLbpz+XVrWbHhN0TSQ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?= =?utf-8?q?8M72YOpbtiHo98YNwO1BlyDlTtbeJiI2GA0HCQ+x6PdRQSQShzLporaF8Qk2vR4+r?= =?utf-8?q?tYkXyNsT6Q/eQf11sWIraccaKjsdqrRzfmNUNIAEsFUdk2HJaVieoEIZXj43NSufZ?= =?utf-8?q?Rqu/IaU01UDW4fZWg9rp32dbRx6zCRZihgPaIecoCYnZY26xC412wgHlBltEPhXf6?= =?utf-8?q?wHPyFKMjFfa0UwwAeH22zv1KRfGpemfRjeOJ2I4HMxPD/g4efNDG30kRkTkhQV5gz?= =?utf-8?q?RypNBaABYX/q3ESB5mVrHthTVf+866yMxoe7OT8K64CZzVVWNG7T3B/6yPqozvHNf?= =?utf-8?q?INyxijWo27lbGoAL6iMNmnx56crEKy4rBIKoWI5B/Q/PlmKjJud6cLY=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0hpgsH6vD9jThl8s2BM/laqeakTZ?= =?utf-8?q?ShHS1XPvYS3liXo0aiqIM1clkldfh+DUs4Ysl5ktETMJ5/2Hq+rQhSLdMuNrY8YrT?= =?utf-8?q?3SWECo/Y7A8Mjfz9aBqDhMB3HYyzCrFCUxoaHYqRh3qNuTjoKFB3tFXN4t3NAG7yn?= =?utf-8?q?prJzO3wxl/ul4hX+MSr/nsZrgOb+8CehDCm19CnRLtgDLq3Lpbb2j7Pfh86bAgLzA?= =?utf-8?q?cWNMtdUHeDf0cqbWThiNNdhxaizigXI4AAeLcVvxw4FeHHfifx6qB9DIj9XHqUhpl?= =?utf-8?q?i0DxWWCz07Eh9CQeSfsE4aG9lp08bv7ytMHDd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EAHIHmjLfb1Ge3z?= =?utf-8?q?zusP6+vBnkV/eAq9rTb5TRz9SWA1Aj3OpohLSqw55oJlZ0De4VeMr/PZd3EaCgS6V?= =?utf-8?q?TO1+du/OtuiVD0BMgYexT0mXvaC61hCGfrASFtEObMM49bqwHbUV/HLbAFdYdD9+/?= =?utf-8?q?5ZCYzzQBvGyWGbfRA+EuUlibtFb5fDGuxkAeD/XP+Ub2aGJAd11KQF4wTk2SQDqZm?= =?utf-8?q?oXWnWCjtGdxDyWJ+H+VIKFVTipQAF121nLsdshfX9mRgxWMVxWXmFMbuFA/cJNPNn?= =?utf-8?q?+egsHc4EdgvF/MUsCik/PmyySIigmhqLABiBK8Pyeb0ssGIDbYJFTwJAbMtSRFUJ9?= =?utf-8?q?53/1iKgk8GE5?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45a3c0b3-b1dc-4dcf-6aee-08dd1a268213 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:05.0999 (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: R92AL37QBhU+oPloxhySVsSMUrNCVxTI9bfBxKBoNHXSFvEUC9X+LgSKAqofNpDuwqCz5bn56HYDbhtinoJwCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Set the IRQ_DOMAIN_FLAG_MSI_IMMUTABLE flag for ITS, as it does not change the address/data pair after setup. Ensure compatibility with MSI users, such as PCIe Endpoint Doorbell, which require the address/data pair to remain unchanged. Enable PCIe endpoints to use ITS for triggering doorbells from the PCIe Root Complex (RC) side. Signed-off-by: Frank Li --- change from v11 to v12 - new patch --- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 92244cfa04647..edaae13bbd3cc 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -5126,7 +5126,7 @@ static int its_init_domain(struct its_node *its) irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); inner_domain->msi_parent_ops = &gic_v3_its_msi_parent_ops; - inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT; + inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT | IRQ_DOMAIN_FLAG_MSI_IMMUTABLE; return 0; } From patchwork Wed Dec 11 20:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904143 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2053.outbound.protection.outlook.com [40.107.104.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA628239BB2; Wed, 11 Dec 2024 20:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950693; cv=fail; b=O3cs5gawom8wkWFdUSJ8zGD8/qtd7Z+lYRwwAa91Z0waP3LaDvQwyUVB3xyIna50cmFkuAy5ZSyQh78fU00iuE6PNRDB4czQW6wjU5Vw1r5f3lsgFKfoQAYBmHdXrs8SyerzAybSz9EHLKpzt9POQg3Caon6YZqSWalbaZKt/dE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950693; c=relaxed/simple; bh=D50BZ5miN8e3VcmEA4cRlQ94cGINq2BVNdkDZoLWxHU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=s1tefaIA/yirGJGqnmUVHqMzWUywBnhHymVJ9A64R1ObUh7WhoD9U3dHnWyEXQC/g3ruS4GLuFK5Ntu25Qkj8TiZV/vF/oQyhi9+Sji3/jKL9/E4arnfUa1ShZLcv6jtXjauBonqiZq1/fhFD+c9akQv9g9c5CuXD+ZUuo/LeYo= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Vv0YXuVq; arc=fail smtp.client-ip=40.107.104.53 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Vv0YXuVq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o3sVGIpZ29YiCGDxXBjg4Rkj8OAC0PgBfgezjnIX+z0YLV04fBV/JNZa2QJoGgwQKonUNuq+MVvv6Nw/2T4khvnQ9GaywtRtMw43ZFDC0OVapCsodeevA/N+Z49oTeZJZHkpTRxvBWSpdXjF3gkcUM0QBix/DyZl2ABQhi6txEF+BXoVvLD2K09pyDT5VP8JthDDlkMZP+dqOBIUrxxBw5LE8EyS8V4emxicj0Dxu3mIIUjtMTYW73ZNb6K4ETF3rxdwEbk/iuPO9Om0BK5xqgaO823mi2InF9MI5eYpt1kKwkuXLmqhJMICrrt382RPFBNYzIgVDvrMMgfTDAnAkQ== 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=36Izu18hCRGkuhjDFOd9R0YMGeiuE6syosxzvqdXwDI=; b=YU5zBA8jk4eEEA/05AB+sOclZwZEiIvsFai8AMVRMeJjdNIBu4XiPDOzx56bBQQyP3pazjNzOTLEMdHP4kot/102o++8c4C0hvhhaVrVOvNeztTgbGIMUohksFUdoR4vtgv74hgnZ4VE8LxTU3iWYLBBLU7QplMurVSEYpfZVJfoq4Z1P0fP/j/vFP7OCJM8fwvdg6BcNDid53MTxFqugeAtrGPq2ocIovfIBPGb+QWy0SkcP+fQyrHwiHQiuP4wv6Fu07V0DdrO5NbIcoIv41yeyfeF9pAVB17cyYUc9UbO5TdXV4k7L7CwFWc2SdFa0uLzVxayv+Em6XAPERApFg== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=36Izu18hCRGkuhjDFOd9R0YMGeiuE6syosxzvqdXwDI=; b=Vv0YXuVqpYUA8F9pWeHCl3lZPc7dqRDO6l+r+hpnQLax6joQeDQelvu4O9cyW5D3FDHgVTGb8LFE3FpYNpWlmehLeA0nVqmtF1hXUpP7fOaOl3UDhOQsTcSUEfOTf+fqtyW6ygcuudsyiU9BqeAN7+yloVwr85MVkBxfo0+Y4OaM9Kb3PewZkd/lnpTVPvXTm2oL8GCexTuVJn2qMH5uBLWy8ycqtpvWIHRPflP/nYFds0uj9N9MQv/1jmYUqZuQtePzCymwd7O7gOr+HaQ1+ycJ5hCZeEd0kqEeiDpfGD0+8fjXZTa8gexhwcPJ3a5dsP1bTsCrDKHuJbQ6LEjjwQ== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:09 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:09 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:33 -0500 Subject: [PATCH v12 5/9] PCI: endpoint: pci-ep-msi: Add check for MSI address/data pair immutability Message-Id: <20241211-ep-msi-v12-5-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=1254; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=D50BZ5miN8e3VcmEA4cRlQ94cGINq2BVNdkDZoLWxHU=; b=1sb9dAGttqH8P7CjUNrMxsMzRP0NEC+vA4sl2/yVV3DBxkKNXbba9W9FhU+m4Am6vJ+q6eUZ8 PIoONzggDPMBcArX/Sl7byxm2BuatYebiIdx1mUpu5DS4UDtwqAmPan X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: d157aaf6-9c68-4bdf-8e98-08dd1a26849e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?RbQnUWX/faU5bRo8J8SEov9e9r0SzZu?= =?utf-8?q?wr8kdKdQm+kSrAawJNINaSBeKPO+cHOz6tlFin/4ikqB6+18WGWQ864AH2ahS9+Vp?= =?utf-8?q?mo8+yBeTR8C/EGaYo326Fyd+1I8MfTVZwvfUvxP2igG+5pqYtvCLescy/Vlol+lBJ?= =?utf-8?q?uys1uv3w4bvNPNc88myXV/9DPAT8mo9rCpYNtxyjxYSPd2wZ6w6GziPQ/h72b/XHz?= =?utf-8?q?xtBlBXSxJxRJOuZ+3wiHOKwh+bnBs28ph0nwggd/Kxay7rjhPoz/IR1b6qFzYr0TS?= =?utf-8?q?hRWYnxy03SchrnyNOoKn/ne3REEl3PtrdpTtz/BsFsBgzvD+S6kwexFhmeWudqdgF?= =?utf-8?q?cOC00MCdL+8r9ORGukh6f9y2sbjfyMjqKzM74pQP1Ih3EsFqIg3cwIl9+xYXmwsrQ?= =?utf-8?q?pPUhE57r7TcD4jTZ9sJkskEg1RCNYw/8reM1MJTiv6hBK+NlvGJV+dfabIZM/8b32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= =?utf-8?q?p60lSjTx4rjbBm5RB0E4T/0XF5qbRzRs/oz4xRhWR1Aj5vdxOJWmVhw=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LX9k7XPUwN2V97vBzkqYCF6R8ZR8?= =?utf-8?q?1ZF05FcrHAxNyoYSGgVL/TqvmjBNtPgZN6p1I0ugGCWfUEuiktrKRceRhFs+aW16I?= =?utf-8?q?+GtT1BAGlCZ92sQGae1inm3dZEm8kD15JX4mAg6QFj8/6RG1yJVA8ZK/JznbxJWsX?= =?utf-8?q?guCY5eIKq6QJHShsmF/aE9mD8g19nzaUB3YerauzZFE1mwpEbAWKyqb38gRyZbviQ?= =?utf-8?q?YpKAbGZ7+v783Gfq/U/RZRj//cUE03mnzdL4tltbj2rhAlZloab1dsp2Y7r9Et+xr?= =?utf-8?q?bXmvFIhRhpdcWKfKMm67Bz8WTtgYptYwSmxibBSwzV7fGvOL1Er+e/iRFqmUCRZHH?= =?utf-8?q?KbdhZ1rmgGjPx8RiM+motsvj0y8SLRVBQxOxrDHHORsqO1uuunPDH2pDcAelNDYoh?= =?utf-8?q?zBp6UEVYvHNe08QHd4bHP4U9j85lfpC+1qH23NA6tyzuFMOrcMIAQXGwaouKNyoCu?= =?utf-8?q?G7Zk0i2zZryXA3GLoW+ww2EeIrFknciMcx0XDfxJ8SBhLiQGzpvi2lWEojASZvI27?= =?utf-8?q?BuIB7dtkdFzaNXlHcbrXKwnAu9r7+gbVZT+M7i/OV5NexNMVgrM2bc1ih04q4Qv17?= =?utf-8?q?jdPuI0mMhCSa3GQTTP0Kk/oMA7y6MGU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4PnntE1NzEBWZj1BBUZ10ZvD?= =?utf-8?q?ZCG4wSvO97dY?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d157aaf6-9c68-4bdf-8e98-08dd1a26849e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:09.4363 (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: Vjhu8a1hR7Svg1/4FA5bk4oqG/BH0RLafNwgODUG3KTn1F+gMG+htGawKRALGEhPfLZu8vzeHNDZ0JacJmsCgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Check the immutability of the MSI address/data pair by calling irq_domain_is_msi_immutable() when allocating a doorbell. Prevent the use of MSI controllers that change the address/data pair during irq_set_affinity(), as the current PCI endpoint implementation does not support such behavior. Signed-off-by: Frank Li --- Change from v11 to v12 - use helper function irq_domain_is_msi_immutable(). - remove msi parent check. - split msi header, its and endpoint to 3 patches. - rework commit message. Change from v9 to v11 - new patch --- drivers/pci/endpoint/pci-ep-msi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c index b0a91fde202f3..eda027b734b73 100644 --- a/drivers/pci/endpoint/pci-ep-msi.c +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -107,6 +107,11 @@ int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) return -EINVAL; } + if (!irq_domain_is_msi_immutable(dom)) { + dev_err(dev, "Can't support mutable address/data pair MSI controller\n"); + return -EINVAL; + } + dev_set_msi_domain(dev, dom); msg = kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL); From patchwork Wed Dec 11 20:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904144 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2048.outbound.protection.outlook.com [40.107.104.48]) (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 59EA723A185; Wed, 11 Dec 2024 20:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950699; cv=fail; b=Mg4qlKxJP8r9Z0lhFMaTyei8v/7UJbav8ziONy1cKqApwsyiqktxQzAm96JpPLYIKJw+j2/Iwee1f6bGAMHeM7gCJ84uMWBIvQwtXEZaBzN08eDlJWq68RH04CKEgdQ9B5czhMvZdFOuSmVukTEzt97jV4bOYL1UAUd2IFhRjZ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950699; c=relaxed/simple; bh=ATnxL3MtlZvwsNg/rnjJY7VKdXtCjc5uSP/3WxbH5ls=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Ud/P7g7pZXl2+YV9OPMxigRsxL37RkCbEJ5lnCVUxuQCJ0rCfMxih3+L4LixPmpJsOPj5N7pI7Zb/5/xwXzuEe6DZAE52es12jcC06Q2CkgGGpq4C4n/gRaewOlcgnLuLOGOD58FRPHN2Lt+bOv2SoXcfwz5GiFKgORDDIRy5f0= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=KrEXKY/O; arc=fail smtp.client-ip=40.107.104.48 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="KrEXKY/O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sBwhkYFtls6et2fxQGCKgJ6tE6dBACoousVa9353oneihsatBNMggzN4Yu55IJE4+r+7C44sQwZHmwcmivN1ntRB5S+3xBcEZmA930yQRMejyICMHJfSzxGqrShTeS19/rYW4DvlwRhodvxsK9Z+A8Zu5ivu0RHt8y8JS9ETPCaUgPht4NKUd2biIQZW8ENFpDtQb/wRQ8e9RIG5BOEQjGJYir4EQ0cEhFBTlFKyDgYd5e0nzNbgiH1wltoxIhlPu/tOxQuIwSZNwdLlJ2mOCPA3o23MclHPrBTw9IiOzZ1SgYvKH0m7qjr3CXQMlMGGHMLVZtZkYdFrvhyLQEf3uA== 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=e8pqhqg1rJbKFFLKPcwz4vZVPUqET3tTJLjryUl1peg=; b=fhifroqeAuRpCU8mL8ls0AQHSVMxuHtbVYDBFra4nIoEzowh6VOkslVGKuZDrIt6AUhJyMZW6wsMKGcFpTsD6RjhSp2cFezupepf4GRCu3lg4RfxT5H0N1zw+6Odzo2rq0o7cDfcsyr09F1JH7b7Wf5dzQGSvftqHsGn2hWf/MZ+9x7Bwdc/cG0GLXDpcw9sQwfdC417L/3tF3RFLaEF4SkY8QsyQMsA4VJZxmSwywDOqq4qHOKvIFgEx9JSLRumRydjhPzgJscH4cgNYTctlhoIliSNkCDDgNsSrhMCvIf/V0GxJ5beE7yQ5MG+SlKn927TZItmzRx60T/a4sKXHQ== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e8pqhqg1rJbKFFLKPcwz4vZVPUqET3tTJLjryUl1peg=; b=KrEXKY/OpaeShP/6JcshukbMIzyF0H3Hra6ZbvNNj9hEyNDBMCxCMsjj1RFsSYWMtikdKAG6xsKgKZ4HEac7NJLIfPFMtIrcmMcv7ypPcq/bJCZ4liL7TyXic4LiB9xQJsC5qHbS0pT2ZlWgkDrdfjGeEuq4KyIPlfDB6mZG3FiDa3WGdd1fqgROB5XGMUmh9h3cysT4l7+OtBITrnrlvnnpCiPBsoN7eW04iExWx8lbOTY6t9SpKIgsxMwnlmjig5MvQVPqeKua+1JZOZKLos1LBMBNcp/AQC0Uk0z3QER2Y2JHmcptMvL9VlNSBW656MPrapnj2mWeLqvU+0DPAw== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:13 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:13 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:34 -0500 Subject: [PATCH v12 6/9] PCI: endpoint: Add pci_epf_align_inbound_addr() helper for address alignment Message-Id: <20241211-ep-msi-v12-6-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=3395; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ATnxL3MtlZvwsNg/rnjJY7VKdXtCjc5uSP/3WxbH5ls=; b=HXiGHHTwwx7E5UQgOBkgSKnHF98cvOYYzQEFoScg0AbvTUrMm41/UCTDdaHC0QMJITRoJTUlU Jcjjz7xPgelCGAH0nzFH2nlAC1JVQzGmrf2G5Kivg5JSE5W+gkqaGCH X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: dc2c9820-8dee-4915-0731-08dd1a268735 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?B8d1gNJFR2Ebs7VTt1DZVNVP8CP379H?= =?utf-8?q?0XTAlJUIu1LEHZHbSoQEeSn6VWoK4TSMbjqXwBUyHFpHR7zIoIUYhg1M5qubOnex8?= =?utf-8?q?oui0w1OY0kar32u2myYvnQGzY8pXsFmpOSTunPLNUGF9OYiEUzpTqTaIQKJ1Uu+b8?= =?utf-8?q?mPq7L3wNXVJFppQQezaAJtQahLZLs7sYRCxT3SVi9L5ttGo6oV+NY33CADuR3iC2H?= =?utf-8?q?MshckJMKEiLrnSy6Zp1thx71RklLreBBGPAqZGJo81mh5RtYyMwmkeANVR7W0np5O?= =?utf-8?q?90Z6CvoW0EJ60m3VCM3fMBgD7V4D9NOlMPV+yQm84441d27wlJNHVY+XSCshc4wQ8?= =?utf-8?q?n4Ay12B9Bc9rDXx7TRYATCe4VxDbpQ2pHlOAN5QXIFptXflwM7boSm+YAAIYcHz+9?= =?utf-8?q?YUFvvvVBZs3X0P+HI4jPZKFQugAs6IdHn1q9d0mNkMhog+w1l8lDkJwPvecBo8Q9n?= =?utf-8?q?oCzOD+qSewco5o66t23otMUr3E22yMdp0FkOoVUbbT+eVffVTjEqNWJP84PGLyo2N?= =?utf-8?q?1hJ1rgUhRtdCXAPY1fa+NzKYGvCC+Yjff91jxh//NYPsuuQRHj3StNJ2T/BcHcb02?= =?utf-8?q?G4W6j1TDFFAGxbaPx3y8T9UGj0HFh+Rg4DZvyZuFTVZzvo4cCigo5U9HhHIa0DXc5?= =?utf-8?q?VKiEjqQ7DTca666p54K1PC+1+C2Op6fzCxw/kWqKhq0OJdI3xjIkYVZVNYHYXYH9H?= =?utf-8?q?87wayOR/dEOxKmHCZVvJ0bkDUUauyx3+eGvPdRGXZ1VSJ54PRFcRiSVavwe2NA42J?= =?utf-8?q?9b7n27IA8883OAovU4P19Lvek66G0vRCqtrZQOOAUjAjP9v+lpsDfLXKlE7ygGs/d?= =?utf-8?q?M0h5BMEroMCiqHfJUATGRLo5j4Amm9L5TYf7iTNOO2i1HdjA0b9zgzUUb4q9UXXy2?= =?utf-8?q?ERsD2wwPTANh6BiJIp8mxi3fOKoWrdzUmkd3IMqjSquElClNUjegz1BqA7LhErgQk?= =?utf-8?q?K34spGJ67Lwd1nnlwxyFzuCkOtQtq6fBZlXQrjtni+ZF6DoE64Df0QNHIHBackrLh?= =?utf-8?q?pl+zoCiaNGfihxl1c+YkMhep1wuEUl/1QW0V8lvkwguOgIMAJf5DmmAeIl7XbtTNl?= =?utf-8?q?Etf0Lc5T7sfe4FAkafYU/nU44f8Drksvs9ZIRrXfz6yfbuaXTKhoKRPLQ3Es+8+r+?= =?utf-8?q?KAXSm1LtTkENazDJtMhei6Bi4CMuIbHb+W9h4qtN6u7Un1Zmyr6E4yPgNfYPPl8VP?= =?utf-8?q?mXjQsTp3WLiSkRYghH4SN3qE8bn4yXpuzxZXzAwsBFR/LXk9iCudnG+E2ZhdwAxev?= =?utf-8?q?x1QdycGaGaCNUzGoBHNTZ/ruuUPKkbdH+3qw+4nB+MC68AAtncPZbmDee4movUnMt?= =?utf-8?q?R336rKYd2ZT9vfn1j3Yj1qmVDS2nsdsohbZbs5GmTMU2g/VJmt8rbTM=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?g7KE0Uiztm9KSL3xz0kwymkD+Fpk?= =?utf-8?q?akVOf6jhWe+mqqSRzK45STzHRN9tsESozZzQJ1l2m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YEStPBgAf?= =?utf-8?q?jfd7m2lQcdZXUO3wl52BtSFv+sXZQi7Px4Ai4jmhDEv6hnzFouiJMBl54jUS2UqKX?= =?utf-8?q?NP+HBGLut4OUORTMPN1r3sS5TbAYNhwCFuj5kj6NHX4Sj3NYnGK7tyXCeYDwNJMwG?= =?utf-8?q?76vo5Mg34dW5oXedOs93HCkMFcaWiq+QPntqfhDBMgfAI9pC6TAPdIokj06CZWsid?= =?utf-8?q?V3D3P8fCBaNi0i9YICNpIaz5YAcTEeSShj5wpPk0s9qyMZD7oEi2UoFF/BfOVFQyP?= =?utf-8?q?NQqWrdDPnk9eQQLdp7A38vi2VCABN9oNs/KqDrVSQHsneoB3g1y6lgQV9istEqSrr?= =?utf-8?q?0L7ajDFamRHBMosojVT9eMzi09PrO7wjQ8tOE+HZmmorUYvw6fnGiLDx+IF0fHwRB?= =?utf-8?q?1n2yo7Yk2iBMvJ1oiZBwC0QXXASZ9JfL9N7RspZU+g/a0BagEWEFJhDoq1ehIiws9?= =?utf-8?q?29S81jwhfrraIu17ZWrZhHeW3osNPIK/gxUX+EGA7RYXZiiESntSsSZgwOMSTWFyB?= =?utf-8?q?9fDaZUqVaqxdq73IiQK505DJ0D8h6ZM29UhegjWnmTLuSw9hmbke6nPPFoQLPj8ws?= =?utf-8?q?nGa1ncprWdgE?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc2c9820-8dee-4915-0731-08dd1a268735 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:13.7067 (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: AZeV8ebavj4SakSMGU0C416Fyl03txeHhFu8lB3d58d48Ex6qtRTBWmwEz5DbI574GNdaW8lD9QlzW2Q5qstxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Introduce the helper function pci_epf_align_inbound_addr() to adjust addresses according to PCI BAR alignment requirements, converting addresses into base and offset values. Signed-off-by: Frank Li --- Change form v9 to v12 - none change from v8 to v9 - pci_epf_align_inbound_addr(), base and off must be not NULL - rm pci_epf_align_inbound_addr_lo_hi() change from v7 to v8 - change name to pci_epf_align_inbound_addr() - update comment said only need for memory, which not allocated by pci_epf_alloc_space(). change from v6 to v7 - new patch --- drivers/pci/endpoint/pci-epf-core.c | 44 +++++++++++++++++++++++++++++++++++++ include/linux/pci-epf.h | 3 +++ 2 files changed, 47 insertions(+) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 8fa2797d4169a..d7a80f9c1e661 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -464,6 +464,50 @@ struct pci_epf *pci_epf_create(const char *name) } EXPORT_SYMBOL_GPL(pci_epf_create); +/** + * pci_epf_align_inbound_addr() - Get base address and offset that match BAR's + * alignment requirement + * @epf: the EPF device + * @addr: the address of the memory + * @bar: the BAR number corresponding to map addr + * @base: return base address, which match BAR's alignment requirement. + * @off: return offset. + * + * Helper function to convert input 'addr' to base and offset, which match + * BAR's alignment requirement. + * + * The pci_epf_alloc_space() function already accounts for alignment. This is + * primarily intended for use with other memory regions not allocated by + * pci_epf_alloc_space(), such as peripheral register spaces or the trigger + * address for a platform MSI controller. + */ +int pci_epf_align_inbound_addr(struct pci_epf *epf, enum pci_barno bar, + u64 addr, u64 *base, size_t *off) +{ + const struct pci_epc_features *epc_features; + u64 align; + + if (!base || !off) + return -EINVAL; + + epc_features = pci_epc_get_features(epf->epc, epf->func_no, epf->vfunc_no); + if (!epc_features) { + dev_err(&epf->dev, "epc_features not implemented\n"); + return -EOPNOTSUPP; + } + + align = epc_features->align; + align = align ? align : 128; + if (epc_features->bar[bar].type == BAR_FIXED) + align = max(epc_features->bar[bar].fixed_size, align); + + *base = round_down(addr, align); + *off = addr & (align - 1); + + return 0; +} +EXPORT_SYMBOL_GPL(pci_epf_align_inbound_addr); + static void pci_epf_dev_release(struct device *dev) { struct pci_epf *epf = to_pci_epf(dev); diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 5374e6515ffa0..2847d195433bf 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -238,6 +238,9 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, enum pci_epc_interface_type type); void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar, enum pci_epc_interface_type type); + +int pci_epf_align_inbound_addr(struct pci_epf *epf, enum pci_barno bar, + u64 addr, u64 *base, size_t *off); int pci_epf_bind(struct pci_epf *epf); void pci_epf_unbind(struct pci_epf *epf); int pci_epf_add_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf); From patchwork Wed Dec 11 20:57:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904145 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2048.outbound.protection.outlook.com [40.107.104.48]) (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 6BBD6240363; Wed, 11 Dec 2024 20:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950701; cv=fail; b=SpWLxAB/FBk1sLqnjnIfKIIA6y7wAk85yF8hNZ0jt52IHAMUhVfaI4cv3zd+51HmP7+vCGS9bApfypEk1OfCt7SpFEsjF8v1JmKoZp3Uro4G3nOYZavGXhdtpqBhHfnxGK9Mxs3WE2shMznLbdVL3CpBRcM5nvkSa/E0UrctTzo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950701; c=relaxed/simple; bh=NSt1w7/3wmlPaEh5ctXXeRua0ok+RFcPLkw2FWIyCuo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Mm7MlhGX/bZ0R4X6WpaMZRVOvymwtbkO7VEVx0WRe7MvYqaYokxnf8hcWfkxjpbsmm1mQA5wFatYH6XucYOGIh+n93q04DeDwkjQD/U15ExhhvFuRrCJHPBgqKIOBci/2aNA9qy/Wrl1fiKiKC9+TDDbX6it/6YSjnlMkdczovg= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Ztx7JL0o; arc=fail smtp.client-ip=40.107.104.48 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ztx7JL0o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hk9JGHQXyUaq5PxBDwg7NvuWtwh+Khw6k3ixAjtQ3nOo70YU149ZPd1XDLxSFk3pOx6LQfeCTrJMJVg2/26bn41km4DDos/1W9FUIWKewkYciUN2enFkHOMz+xVheaD/oPO7jFCReUPBzmja8n+KAJggH06gm9WlTOYXCzVQdQMWcIcNK0pjG0uvWt9A9m9pTM5IPvftSQL/4/2isoB9W7CCKesgsxrMHrlaGqcd1rlXGHVrtuQzGS0DUB41x41wGG8ijB9KUHQZojlE8sWbeaTyARPcOq/LO7owT82i/bnlXq0ZYQWl2mJaLym0ePTRUPRdL9xXhGMSDP64BQZSdw== 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=PvGhWu8Gge+T262HkUIK7US4UiQybpzMJMwLoHNGRwU=; b=XW0mBMqG2INDVwf+wprT1zaRFonCaaGYoMVOQuUZskpl77Q31iGdXpTjSogV43HMoBFbTjI5C3C8pGRYq43xYTGejhOTQtiUpPB6vnADVyTUwx5SUeF7OuLQEP6NbXorWcQ1qtnc0o8SDrWrvSkX/CE8qNHZbGTQiyhg8x8aQB9KCXw/nOII1UGG9X9IRQmnDsvDb7nfodBRKxKOPrpZLvq7wiwIOXiyjgi49w3Oise0OqaYRquz/d66tf6tMjerqRVVe4CQ0/Yz8Hf9kVNsWttsTa13JEBWnaHLV4ctN2zeVWBqZQkYv6ovmXqm+YfAs7IjJN6kXlWWcfH6odVxnA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PvGhWu8Gge+T262HkUIK7US4UiQybpzMJMwLoHNGRwU=; b=Ztx7JL0oRheYfL8mkw4IWxVH8FjXov1hSIh8NAp3I17w6OWJvS4Tz4868HnfogH4NhtK/yxiHlgFacdHudumIqtFJandZRszYFQedPq6kFlKxKzrLrGGpnCSI73SdVhXGdaT0xJbfByXQSkmaMlxcdJOSGmcW7dP83OzC+/gtAVqyMXtrRxd0wIh+dt5fkiwTqwq0XR2fCwQRGy3k7PbdbEO4HRh3U1u4tVhg3ZNvd/BQ/JkRt1Eje1IxE4K9GVWEDpegCD4k2Gz70eVXTalfLTnZoRk//oq4OwkXVY7yyOLimmPdj719gzXOMOVBey6VM3p7iGZIKBBpVOWL3P5mg== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:18 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:18 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:35 -0500 Subject: [PATCH v12 7/9] PCI: endpoint: pci-epf-test: Add doorbell test support Message-Id: <20241211-ep-msi-v12-7-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=7892; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=NSt1w7/3wmlPaEh5ctXXeRua0ok+RFcPLkw2FWIyCuo=; b=naHZNzdpwoG3x0/z5Q6iRQMjrj4BbsUwmHXU2VzDjweC/9l9EY1MwTeZ5H3BdQHT7kFF8DV2g oCqWk3zyeaeB4egXZPNE+AIjc887RVYAt5GW4BjYDGoSLGNuyAaPuCA X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a8b3db8-4504-4b4d-be26-08dd1a2689c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CPMZ1fkKx33ntkZW+zIhP7+bfrMsRoz?= =?utf-8?q?L432qwH3PBBa8CqUpYKfZ3qrvFYEwK6k50vswqYKD9iqY1aR8kMgZFksBkUE05zm8?= =?utf-8?q?URxPkdtBlak5II5XRefSStAcxgly6Qo6jaZYqGbXO7VlmW+Q0e/7T0ftma2u+JH7D?= =?utf-8?q?2+RpTmr+5LHVLXlxoU3LSjHT7IlCBFCcy0caLm/Ys0YXKC52WTKBYJDRXKi48zdUZ?= =?utf-8?q?qLlFjwK+sO0Qm4Nr+a9nrJMiYO/BkCiKYqX3OD2NRmNv4JEU5+cm2/YpetfFZw/H5?= =?utf-8?q?D5pGC62+Lgbu8qsBtOvPHtioUXBHts0LlaC5lq3vQOCy51DIM0SvwsZkp3mafWl1l?= =?utf-8?q?me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I5KMowis5kOHDAlY/B899RWQAXhJFTHsgbhWG1Oxxk+kX0zyshbs/EDfjyAUL?= =?utf-8?q?42TGOQ/AvKnZAJxtvmk1ZEIk5IxN6idFj0ifcUxheUG0EJHSVQh0TmPBD4Hc4/VVD?= =?utf-8?q?xqpEw8IIIOSmhm1mUByGXkoFxSiyN8ySWQVkibtmgvZZcvDjW3U8O3c=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?oi110hS9gs9FBlE79QueNmBx5N+8?= =?utf-8?q?VmEYKe8JffsDauwPGFOB4TbHNKaofIar4bfbrms5anIpryqPIMwhZGh3C5FSudgQm?= =?utf-8?q?tlqltUozv+jFFAQEQnU2kIkg0BLorqyzsvfAaFae3S4YbVnAmkVGcwuFw8Y3cm4zz?= =?utf-8?q?7IOZKMLCsOBr5JcfnJWPx1dLIAQAWfiqeYqPtZ4Jkexp85AoOZqN0jdYQ0vJGWYTT?= =?utf-8?q?n45VQPPtBZ0AHqNKU2PoigypZ1KMylGBlw/Naip6jc3tG145qxibwV3310QblYLwH?= =?utf-8?q?V82syGPxD9v+CEtl81G7blYj/2bar3HD1sl3QVixuXpQMb2UOQxQMbOtgb23vjO9X?= =?utf-8?q?BiwNaNjPvmXZadXbb/RdKfk14iTN9XgzoLaDGlbsYTSCnqkN3MnW2XhvREbm8QgDR?= =?utf-8?q?Y9FR61jW34e7bwA/jJhO1hmLBv2ENav1JFDOVvrEE2RmaLv5hyTJAr8My16fCrneM?= =?utf-8?q?POycAYwAKAR5o7OxMi6XHg0Ti7FR5v63S6kVIYtx+xkYn/3gDIko8Q8bYAkm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?tVCC9ONZ/pbVWGuLiv9jSeo1DQsw/wfXiVJWfnbCYXqbw1YGWDNruC9t3JgNdwEEf?= =?utf-8?q?iLQtiekkfVlF0XKJdsRcjx5C+8Nzxu8h4a0Qv5XOPhyJ2S4gcCoJJfKDQ5Ni/GkKB?= =?utf-8?q?O1VUryNyKhzB?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a8b3db8-4504-4b4d-be26-08dd1a2689c3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:17.9984 (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: 7+vszG+Xg4m2TwbvnOpMwDrpAlHuU97ryr0GGGRzMFN35n9INtRL97BBBxqRF7mYk+12weDMXWQo1lufnrdBMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Add three registers: doorbell_bar, doorbell_addr, and doorbell_data. Use pci_epf_alloc_doorbell() to allocate a doorbell address space. Enable the Root Complex (RC) side driver to trigger pci-epc-test's doorbell callback handler by writing doorbell_data to the mapped doorbell_bar's address space. Set STATUS_DOORBELL_SUCCESS in the doorbell callback to indicate completion. Avoid breaking compatibility between host and endpoint, add new command COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. Host side need send COMMAND_ENABLE_DOORBELL to map one bar's inbound address to MSI space. the command COMMAND_DISABLE_DOORBELL to recovery original inbound address mapping. Host side new driver Host side old driver EP: new driver S F EP: old driver F F S: If EP side support MSI, 'pcitest -B' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pcitest -B' return failure, other case as usual. Tested-by: Niklas Cassel Signed-off-by: Frank Li --- Change from v9 to v12 - none Change from v8 to v9 - move pci_epf_alloc_doorbell() into pci_epf_{enable/disable}_doorbell(). - remove doorbell_done in commit message. - rename pci_epf_{enable/disable}_doorbell() to pci_epf_test_{enable/disable}_doorbell() to align corrent code style. Change from v7 to v8 - rename to pci_epf_align_inbound_addr_lo_hi() Change from v6 to v7 - use help function pci_epf_align_addr_lo_hi() Change from v5 to v6 - rename doorbell_addr to doorbell_offset Chagne from v4 to v5 - Add doorbell free at unbind function. - Move msi irq handler to here to more complex user case, such as differece doorbell can use difference handler function. - Add Niklas's code to handle fixed bar's case. If need add your signed-off tag or co-developer tag, please let me know. change from v3 to v4 - remove revid requirement - Add command COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. - call pci_epc_set_bar() to map inbound address to MSI space only at COMMAND_ENABLE_DOORBELL. --- drivers/pci/endpoint/functions/pci-epf-test.c | 132 ++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index ef6677f34116e..a0a0e86a081cb 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include #include #include +#include #include #define IRQ_TYPE_INTX 0 @@ -29,6 +31,8 @@ #define COMMAND_READ BIT(3) #define COMMAND_WRITE BIT(4) #define COMMAND_COPY BIT(5) +#define COMMAND_ENABLE_DOORBELL BIT(6) +#define COMMAND_DISABLE_DOORBELL BIT(7) #define STATUS_READ_SUCCESS BIT(0) #define STATUS_READ_FAIL BIT(1) @@ -39,6 +43,11 @@ #define STATUS_IRQ_RAISED BIT(6) #define STATUS_SRC_ADDR_INVALID BIT(7) #define STATUS_DST_ADDR_INVALID BIT(8) +#define STATUS_DOORBELL_SUCCESS BIT(9) +#define STATUS_DOORBELL_ENABLE_SUCCESS BIT(10) +#define STATUS_DOORBELL_ENABLE_FAIL BIT(11) +#define STATUS_DOORBELL_DISABLE_SUCCESS BIT(12) +#define STATUS_DOORBELL_DISABLE_FAIL BIT(13) #define FLAG_USE_DMA BIT(0) @@ -74,6 +83,9 @@ struct pci_epf_test_reg { u32 irq_type; u32 irq_number; u32 flags; + u32 doorbell_bar; + u32 doorbell_offset; + u32 doorbell_data; } __packed; static struct pci_epf_header test_header = { @@ -642,6 +654,117 @@ static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, } } +static irqreturn_t pci_epf_test_doorbell_handler(int irq, void *data) +{ + struct pci_epf_test *epf_test = data; + enum pci_barno test_reg_bar = epf_test->test_reg_bar; + struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar]; + + reg->status |= STATUS_DOORBELL_SUCCESS; + pci_epf_test_raise_irq(epf_test, reg); + + return IRQ_HANDLED; +} + +static void pci_epf_test_doorbell_cleanup(struct pci_epf_test *epf_test) +{ + struct pci_epf_test_reg *reg = epf_test->reg[epf_test->test_reg_bar]; + struct pci_epf *epf = epf_test->epf; + + if (reg->doorbell_bar > 0) { + free_irq(epf->db_msg[0].virq, epf_test); + reg->doorbell_bar = NO_BAR; + } + + if (epf->db_msg) + pci_epf_free_doorbell(epf); +} + +static void pci_epf_test_enable_doorbell(struct pci_epf_test *epf_test, + struct pci_epf_test_reg *reg) +{ + struct pci_epf *epf = epf_test->epf; + struct pci_epf_bar db_bar = {}; + struct pci_epc *epc = epf->epc; + struct msi_msg *msg; + enum pci_barno bar; + size_t offset; + int ret; + + ret = pci_epf_alloc_doorbell(epf, 1); + if (ret) { + reg->status |= STATUS_DOORBELL_ENABLE_FAIL; + return; + } + + msg = &epf->db_msg[0].msg; + bar = pci_epc_get_next_free_bar(epf_test->epc_features, epf_test->test_reg_bar + 1); + if (bar < BAR_0 || bar == epf_test->test_reg_bar || !epf->db_msg) { + reg->status |= STATUS_DOORBELL_ENABLE_FAIL; + return; + } + + ret = request_irq(epf->db_msg[0].virq, pci_epf_test_doorbell_handler, 0, + "pci-test-doorbell", epf_test); + if (ret) { + dev_err(&epf->dev, + "Failed to request irq %d, doorbell feature is not supported\n", + epf->db_msg[0].virq); + reg->status |= STATUS_DOORBELL_ENABLE_FAIL; + pci_epf_test_doorbell_cleanup(epf_test); + return; + } + + reg->doorbell_data = msg->data; + reg->doorbell_bar = bar; + + msg = &epf->db_msg[0].msg; + ret = pci_epf_align_inbound_addr(epf, bar, ((u64)msg->address_hi << 32) | msg->address_lo, + &db_bar.phys_addr, &offset); + + if (ret) { + reg->status |= STATUS_DOORBELL_ENABLE_FAIL; + pci_epf_test_doorbell_cleanup(epf_test); + return; + } + + reg->doorbell_offset = offset; + + db_bar.barno = bar; + db_bar.size = epf->bar[bar].size; + db_bar.flags = epf->bar[bar].flags; + + ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &db_bar); + if (ret) { + reg->status |= STATUS_DOORBELL_ENABLE_FAIL; + pci_epf_test_doorbell_cleanup(epf_test); + } else { + reg->status |= STATUS_DOORBELL_ENABLE_SUCCESS; + } +} + +static void pci_epf_test_disable_doorbell(struct pci_epf_test *epf_test, + struct pci_epf_test_reg *reg) +{ + enum pci_barno bar = reg->doorbell_bar; + struct pci_epf *epf = epf_test->epf; + struct pci_epc *epc = epf->epc; + int ret; + + if (bar < BAR_0 || bar == epf_test->test_reg_bar || !epf->db_msg) { + reg->status |= STATUS_DOORBELL_DISABLE_FAIL; + return; + } + + ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf->bar[bar]); + if (ret) + reg->status |= STATUS_DOORBELL_DISABLE_FAIL; + else + reg->status |= STATUS_DOORBELL_DISABLE_SUCCESS; + + pci_epf_test_doorbell_cleanup(epf_test); +} + static void pci_epf_test_cmd_handler(struct work_struct *work) { u32 command; @@ -688,6 +811,14 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) pci_epf_test_copy(epf_test, reg); pci_epf_test_raise_irq(epf_test, reg); break; + case COMMAND_ENABLE_DOORBELL: + pci_epf_test_enable_doorbell(epf_test, reg); + pci_epf_test_raise_irq(epf_test, reg); + break; + case COMMAND_DISABLE_DOORBELL: + pci_epf_test_disable_doorbell(epf_test, reg); + pci_epf_test_raise_irq(epf_test, reg); + break; default: dev_err(dev, "Invalid command 0x%x\n", command); break; @@ -934,6 +1065,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf) pci_epf_test_clean_dma_chan(epf_test); pci_epf_test_clear_bar(epf); } + pci_epf_test_doorbell_cleanup(epf_test); pci_epf_test_free_space(epf); } From patchwork Wed Dec 11 20:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904146 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2057.outbound.protection.outlook.com [40.107.104.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 BEAB423A19A; Wed, 11 Dec 2024 20:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950706; cv=fail; b=gjM1Nfp5t89oLpic3Ysy3rMLXR3tvnH5q8Hf3iOa+eeXMLZ9s0xCF7mnmgRn4/FoSW/ETGYEnixFC0YWF5Mu5LMmOaPhGStDAUUmUNKTDJZvB3qFkQnmRdUpWRn5QtBVqlCZDjO0COYGXiFzXMP7kRWsDOvW2/nf6k8GMQApuKY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950706; c=relaxed/simple; bh=04o8LvhgcqnX+pJqL3zaiO6sBmMiaAG+qaGRFs84x70=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=OVO7uPgRXm9BpXJZSAHnUI8mCYHhy3/tHSMNndVVPhOFQiwksS5ZiP5AEeer1Erry7xGk2BiOgwkS3iCl+ztBkTtcbRLoi5gkDavnZy8CTGdQVPNwe3tRV7a+pWKT/wUbUtVP3vmYeVNzQmPAkySLjOlTuUusTL9PnhALx/E4rM= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LQnoO+l1; arc=fail smtp.client-ip=40.107.104.57 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LQnoO+l1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=COTJ7rskr2zHJMgsM8N1axEoimLxnBwW8tx6BvpSt63Xcq3OVF/EHlVReF83lg1n0SaUQi5SfsfMjC0z+aQOtH1BOLzOEdnctjj4QHc3XK6FA+Yqo5kJD3Slne4bG0FdxgSjNHevqFEn/1FooE3AuuagI4ZbV8QpgDVBK0e75f6AYV4EYqbUw7gw//3I8XDLFFxTKrjvMbfaQVNxkMkWAb/fpMrIKUN9WjqmZC4xoMZ+rogcdq9a498S1Ub5Z3Q07kVTgFkmnlH8OSBWofUPB8r4lJanmWs9JUvDNYCarwKAHjv8R2nTLxFhMRUORiNjKkk5YJnQaJzb0WzYpyn+nw== 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=vUfOoPgd7QzvV0XqY7bT7dT8x4B/BnsNnIWzUIpaNGg=; b=RBtG/J02M+pOFJA8l9H6KfqIG7FVWlpNNlBCaWUodmB+bI3kO6hkb0aWIdePx/GzWUlZsdfaK138Qty1OppUmNARMjbNpJLlEkiittrqT1l9AV1j4ik+MKoZGm+XehhupdoW/z1UTWm4vDXBd/T8B3S/Z8SR8YU0N6fRqseoHFafI49jGv72jgOHcONsn07SWRG09yqQRL7lcpmhwlVTWOm9Vk8lxyGpLyRZ+X/DEgYOFxJTosVLKSHlZmanAxBv2HZ1aJCAe+efyVsvN8dZuzLaZtDOpmYs75TY8fGHdSpRXvUMfAokw4KT11mrfTbJs+A/dUIZmY5OhGj4LkII7A== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vUfOoPgd7QzvV0XqY7bT7dT8x4B/BnsNnIWzUIpaNGg=; b=LQnoO+l1o1X2u+PLvm094ZeTk5qZBdjM6NIblFnfEiTQtj2hICaGFsnYwEvLFP26Ed45bbwDL5tdOATHy7Wvgb3IwP1xKI64eR1QX0hFDPUkh3SVMf/pMU38sngePUWaOi3uJyot7gJIOIQVWRXG9ih1buGBbfFGDzBEDfA87JTjJa6D9ASQHebic9PqJHLr517NssJLa+F1jSswfpLSyMyR/RPEgEAzbnteIcHH3M5j7MZ71XGek5/pjJXxXvGDDX136iwgJxf4FbojQy7noTbUtP4wio8cGK0CHqXnu6QivhgJuAk0Y7xvjYLgdfLASAsgWaBRa6VEBmgF4jx0Aw== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:22 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:22 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:36 -0500 Subject: [PATCH v12 8/9] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241211-ep-msi-v12-8-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=5981; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=04o8LvhgcqnX+pJqL3zaiO6sBmMiaAG+qaGRFs84x70=; b=o9THKM1FJ1ALGXrUdJMBKl5faPEvR8P2Saya/aNWf0aFH2hPH/sQ7Jda8LeCquwk22LC70lzH dJ0jxOYf3KVAaMFAGYHOyye8fRVChQgQTmSTFyOOgq5rCKj11SD5Mpf X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: de14f161-19a4-47f1-bb74-08dd1a268c51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BQiS6ey9H0qxrVve6OIgMW24m95AWob?= =?utf-8?q?DdE4bej1+ZVD7ZjbCSRFuvrEVPD+wLpZGWVM+4KcYNUNvBbZF8kTSDw/W4slosI9f?= =?utf-8?q?zKU2yzc/nFByjx0GinfvWF4RQCPzQXLugccUvJjO2YHhr7wPsURsgry8Oq1tZ4h+M?= =?utf-8?q?K5ceQ/b/hPwDMwl0KWbFuO86dYQdguSAhLCfitzd+5/gBeY2+sDJzwuLR6+6/Z80I?= =?utf-8?q?Uczlq+Fss9SGKvr36/OMZsJO7g3Cy/jwnLGEjdS9nitiMI4FEr8d1Iv88yaOeCue/?= =?utf-8?q?C7FLutCw+iV8rTWcxPT3LkgJXUn/QnlpljM66Jmc0HZUbYE5sGyTlEfRlSgGtHmu6?= =?utf-8?q?sfwUJmfe1f6orRCpX7rlf4edonwGffN++jn3AUwLQSotPwMM7FH/dN4FQgy932U1K?= =?utf-8?q?wJAmzuosWgS9RXOvqIkFl8awpDY41darF6EN9ww2b53/m2FMZ88fbMo68MIGqXuCN?= =?utf-8?q?aHXzG/Oin7fFQEu6Yj1QVgHpN1//h9G4kDRaucLj0qd3u/3gtc/xtbUtSrq36f6t9?= =?utf-8?q?bGABHi/SjkpJ/ITGS72DpdaMB3Rz9vex3gCw8mUGP0uB1bcKc3LGtaBzXIJUMW9YZ?= =?utf-8?q?UAXcxlvgjD44Z/msfwbNnf+2Ac3vv4KPXfoRbNVAxd1LF/xHSlgWDz2fi+Zq8tLH3?= =?utf-8?q?fvMrbvrmgDb9fBOYr81oxGTw2cq6bfJJM3V1+mMyJeCz+PWy2w8eZvQ1Flq6hsrUb?= =?utf-8?q?yl3fkFchp8Q/0B5E+kpTcyIDoHS+mENQ/1V7STmMY+qVAXwWvmjhldMRpssenuhLq?= =?utf-8?q?U2q5/DdDjKA/v7/Jk75pdK+q3/DAl6FbXrYzGjun+VrehGCcElFp4V6enKiJGRu+8?= =?utf-8?q?2m0Ttl52171Cve1tZAdzxkI8TcqaiARFQdrgPRUhUGdkDuPzIQ6+cVPd3NUlOxc1/?= =?utf-8?q?O8pnKLBkKHe3tfcE7ZvZWCj0s5jLemTIra28ua8mlaD/UJW9xuwufM8EooETUk4cX?= =?utf-8?q?/IKHC07I9AfObiW+JLkcvZw24lzrA4WFWePV3p2De0wBR+E1ABRpypO2kSgfGxCwK?= =?utf-8?q?ZjgcIKljreDl+xTOmENxXU8Vgv4ESYqSkI7QRTHCdhwCv1swgJbMQgoLn5Z171diu?= =?utf-8?q?6ubpOANLhxq7OAOCsZcWQ7t9GJfJtnrjKfAJF6gmabyxt/neyVGuI1sxn/dsqLik7?= =?utf-8?q?QbDBt/z0hrv8NSg+P8XisWPa6vLPEEQAo8YdLU2davcDSx01AoK+GvveNkmEwQkWQ?= =?utf-8?q?iGgqMDzTjI0EYyJXu6FaFdTObTr3JG+naOYd7wm5MVO4DM+70ug1DblNQjlYAD0os?= =?utf-8?q?mvvtK/cwKNKwUDErgezdfMXplIdJkweF4LuIne3oL3eEz/ZX9lBluAtcCov7CBB6d?= =?utf-8?q?c5ifzSkC0ntk4evt6Z/uWEvkaLbOdZOC64BYa37b29C4sJ2iLOVsfN4=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vFr5DLB5hZe+vRen43039+DKNlTA?= =?utf-8?q?uIcSoowNQHRAJN707DVYpSuohgdSRas63T0p8KGLZb2DmkJJK5XYiovQzWKzb8WYJ?= =?utf-8?q?2znONXnMZ7J9QohxKnO0tmrfX2OThDJqbkrm9N4YvBDSwV06+Eede9zHcAOGX+Dpj?= =?utf-8?q?C6O5F1eIfCoLBLK/nqPWjxpsu5Lv+C7rHuZY0+7rO8APuR4DxhxM+e/e4/816ob8O?= =?utf-8?q?VjHM3Ge+kdS51dbaYRIm39OFFXQaJtJM1V0K1RFJhVyp/QewXZrcE2h/GNV8yHF5V?= =?utf-8?q?kgm2dvpVckmrsZ7uhQnXxfc+Wz0WC8MVPFk6TzFJnmRp/RwvMRbnKTecr6KBv01yt?= =?utf-8?q?DwtMhiTgPviXw9HOD7VkVpkxRw8zYpaDn8XZQW+c+uG2MnxStmTH1y7wIrbUP41rX?= =?utf-8?q?rlmUoCYHtvrZaydyOsL1OSFI4KW2bg6oc9bXWc4O+mul7LPGSnpBDwg64bMGQJKdM?= =?utf-8?q?feww+kLiLFSvQpNES8qF8x8DunX2XiQB4t7X0e+oBTG5ltCZHh5CEUygsxLg8AWbv?= =?utf-8?q?ZYpKfkuFAN6B/06KLg/L6i2rDRlA6G+R0tgH73gsFS+gCtlwJrlgnxmu3s34sqsV/?= =?utf-8?q?5H2NcetXe9b4OqcD7Kn3nlA/l1N8XSGemHmnIu4irX1agwbWrpyDSAwNuOWUvNv6F?= =?utf-8?q?FKzl+Em2SLXEbmAW8/p7k5BhmWyGDqNoNzPyDK5MnNtnCuLxEt9nImYMs61sWmC4Q?= =?utf-8?q?3WDF1vF+p5oZgoIM3K8zb7yMA+zTIYQfTFq+WRg9eBqAJrsrkBwddtfkH+SRsdE1P?= =?utf-8?q?lDcN3YJBgS1h8JstFtcBzLDyDRKc1tq5Rp+krh9JPPNXd9MMUdmbP/pBzrXR0OLq3?= =?utf-8?q?1OVAsztLn0sqlD+0aV1HKacB/HQerE611xA2c1Lyda2zLr9ilnBvyWUGjz4NTYB/m?= =?utf-8?q?bianrEgwYU6cuacLWioTwu5ZB54N8ezcF/BbZ6311FDTvACopK1ebgIOeBYYiDgF7?= =?utf-8?q?clJLj+dMRq13njSfgF775tGzH2twifMSkfZ3ljqmS4Nv8xCtI7S2eIpZfNRQvjEyK?= =?utf-8?q?TxvxXJbpBbPyoTWfQVrwdPAw2kEU9Yz3ir81VjmGKxgfVShgxUlfuljBb+OzUVycx?= =?utf-8?q?PwCuo3kxkSUOwaTFSlOkExXH1cnxLot3ifd6eOROfiqBb7pN40ZEDI6SVbnstvx3W?= =?utf-8?q?yE08sCvDETqDoDh923m1OO8w4sPP7tiYyVQ4uvpDx94me4kpwfSS/DdT7CJOC1fqH?= =?utf-8?q?a3CMZeGKF5u1zj3hH1hPo4r+5CD/AFiBiEhRDWUNsdkuFPeZ8ZnnCuw2RZ0q/P9p6?= =?utf-8?q?L6w12kK3x+3V0tWJ71UY/FAN7Npho/E3oFlr7Tc+FGqsX8v88a+HkHbLBUmWybCwc?= =?utf-8?q?iT7MmbZQQS2MRVVvY0NmEldAOeuFKD0glzUgqvtacwMT/DhJcfkTIX+zu6nqzInMa?= =?utf-8?q?bRliG5Dn8pSNcYiddDdmtcC5ZmlZAhY9VOD1EGOOa+KlH+K6Nrl3wmWetb9KUaSn5?= =?utf-8?q?HXozK5vEYKxgxmz3v/6ZUn6zwhgxQtJ1wJwAsrI/8YDy7uVXQt73+8V3DQag2GI2d?= =?utf-8?q?3whTR4v4mj8S?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de14f161-19a4-47f1-bb74-08dd1a268c51 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:22.2635 (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: xf5HYn82wiVBTzk01WXTtkfpga7Yrs4rjfAycQR1tKG7Iz3nJlwoKmOLp5ttvv1KLqVKjoZY4ccjU/M6m1Ry8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Add three registers: PCIE_ENDPOINT_TEST_DB_BAR, PCIE_ENDPOINT_TEST_DB_ADDR, and PCIE_ENDPOINT_TEST_DB_DATA. Trigger the doorbell by writing data from PCI_ENDPOINT_TEST_DB_DATA to the address provided by PCI_ENDPOINT_TEST_DB_OFFSET and wait for endpoint feedback. Add two command to COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL to enable EP side's doorbell support and avoid compatible problem, which host side driver miss-match with endpoint side function driver. See below table: Host side new driver Host side old driver EP: new driver S F EP: old driver F F S: If EP side support MSI, 'pcitest -B' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pcitest -B' return failure, other case as usual. Tested-by: Niklas Cassel Signed-off-by: Frank Li --- Change from v9 to v12 - none Change from v8 to v9 - change PCITEST_DOORBELL to 0xa Change form v6 to v8 - none Change from v5 to v6 - %s/PCI_ENDPOINT_TEST_DB_ADDR/PCI_ENDPOINT_TEST_DB_OFFSET/g Change from v4 to v5 - remove unused varible - add irq_type at pci_endpoint_test_doorbell(); change from v3 to v4 - Add COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. - Remove new DID requirement. --- drivers/misc/pci_endpoint_test.c | 80 ++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 81 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 3aaaf47fa4ee2..b3f36b6ba8ba2 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -42,6 +42,8 @@ #define COMMAND_READ BIT(3) #define COMMAND_WRITE BIT(4) #define COMMAND_COPY BIT(5) +#define COMMAND_ENABLE_DOORBELL BIT(6) +#define COMMAND_DISABLE_DOORBELL BIT(7) #define PCI_ENDPOINT_TEST_STATUS 0x8 #define STATUS_READ_SUCCESS BIT(0) @@ -53,6 +55,11 @@ #define STATUS_IRQ_RAISED BIT(6) #define STATUS_SRC_ADDR_INVALID BIT(7) #define STATUS_DST_ADDR_INVALID BIT(8) +#define STATUS_DOORBELL_SUCCESS BIT(9) +#define STATUS_DOORBELL_ENABLE_SUCCESS BIT(10) +#define STATUS_DOORBELL_ENABLE_FAIL BIT(11) +#define STATUS_DOORBELL_DISABLE_SUCCESS BIT(12) +#define STATUS_DOORBELL_DISABLE_FAIL BIT(13) #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 @@ -67,6 +74,10 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 #define PCI_ENDPOINT_TEST_FLAGS 0x2c +#define PCI_ENDPOINT_TEST_DB_BAR 0x30 +#define PCI_ENDPOINT_TEST_DB_OFFSET 0x34 +#define PCI_ENDPOINT_TEST_DB_DATA 0x38 + #define FLAG_USE_DMA BIT(0) #define PCI_DEVICE_ID_TI_AM654 0xb00c @@ -108,6 +119,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR = -1, }; struct pci_endpoint_test { @@ -746,6 +758,71 @@ static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test, return false; } +static bool pci_endpoint_test_doorbell(struct pci_endpoint_test *test) +{ + struct pci_dev *pdev = test->pdev; + struct device *dev = &pdev->dev; + int irq_type = test->irq_type; + enum pci_barno bar; + u32 data, status; + u32 addr; + + if (irq_type < IRQ_TYPE_INTX || irq_type > IRQ_TYPE_MSIX) { + dev_err(dev, "Invalid IRQ type option\n"); + return false; + } + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, + COMMAND_ENABLE_DOORBELL); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + if (status & STATUS_DOORBELL_ENABLE_FAIL) { + dev_err(dev, "Failed to enable doorbell\n"); + return false; + } + + data = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_DATA); + addr = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_OFFSET); + bar = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS, 0); + + bar = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + + writel(data, test->bar[bar] + addr); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + + if (!(status & STATUS_DOORBELL_SUCCESS)) + dev_err(dev, "Endpoint have not received Doorbell\n"); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, + COMMAND_DISABLE_DOORBELL); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status |= pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + + if (status & STATUS_DOORBELL_DISABLE_FAIL) { + dev_err(dev, "Failed to disable doorbell\n"); + return false; + } + + if (!(status & STATUS_DOORBELL_SUCCESS)) + return false; + + return true; +} + static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -793,6 +870,9 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, case PCITEST_CLEAR_IRQ: ret = pci_endpoint_test_clear_irq(test); break; + case PCITEST_DOORBELL: + ret = pci_endpoint_test_doorbell(test); + break; } ret: diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index 94b46b043b536..b82e7f2ed937d 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -20,6 +20,7 @@ #define PCITEST_MSIX _IOW('P', 0x7, int) #define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) #define PCITEST_GET_IRQTYPE _IO('P', 0x9) +#define PCITEST_DOORBELL _IO('P', 0xa) #define PCITEST_CLEAR_IRQ _IO('P', 0x10) #define PCITEST_FLAGS_USE_DMA 0x00000001 From patchwork Wed Dec 11 20:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904147 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2086.outbound.protection.outlook.com [40.107.104.86]) (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 629E2243B6A; Wed, 11 Dec 2024 20:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950711; cv=fail; b=cxi1b40Wp0PE7dir6uYGNzIPl9FgmAjELWUQTXJ7p8EPwvHmLwUkiv5EzEQsAdiAHWwlG5xUYUJsB2QFyB1yYFYuS6qHeN0wUkC/Z30kZcm7y//8bbB3f4ZGt+j31TqG7ju61v2/Uy737Iw43xoKV8tSczh2nRSYh2yXzSJLWe0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950711; c=relaxed/simple; bh=mJBGb3x/IT3kU6QxbS0pDIxty8JwWoRws5fh7D2yIVI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=NRQOm27M/qJgal4YaLNEJO+sXS8z00QYV7rRiG6DnAh887/ZCtumcrpOjMCtZLUr9HtOnZt2yJvq5K7Xdsu8NhQSixcRPP+MoFsoGrSIchnAcfSqRmtEo+XVFWLWIzScetvACOgixjB+pZKcnNva9CMVm6ZvxgDdU2nYukCo4Sk= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=mL1ASNKs; arc=fail smtp.client-ip=40.107.104.86 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="mL1ASNKs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ogpN0wttNWCz5UQFWsjrq73gWObgToDadaTKTQfrS2mYPAFkXY15I1LLrdHhllhOVWtNyi6GhRaPZd5RS/eDwxXSgKUGI9jsi9GMKUUb7M+UMVNg+RS/B7X1AYijs1gmrTrWM1VrHpD8Kpj6xw6S4XONH0w806AS2DO+IzCcV++ULB95jk8Ipla7ERaLEVi+8HmDcURLRx/2IsWcbh/C8O+K9XdSUAUbbOKyX7CoVNbN2pnWNxS8VdoaR3xZPTWyKGz48l58PGeSmt3WH6pcz1RmKmTp6cPk4e/13QIC9VtIiVIer3R4+w6e5uuJ77iq/i/RGPuq4p64Q5hdp7Hktg== 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=MQ34FODL+rWvjEXX2BjWCcNtXyZaoeDOc5977Me123c=; b=sMnXMwAvjNR+QWA1x0aDUGzcj+cYparvKTQENJ0ACnv9muExQHt9tlVPsh50j/68n4Dmjes6IsE2W9gOmH6O7pKYJnlPco9To6U8XeXNKmo+ARxp8+HTcmARM7MqnOdzY8a2RR6Wyonu9FjpmKjfBMSRDymXdhEQFai7GOtjHFmWdcoxVc+PHksSuC8Y0k72wfO7loKI+A5PLPHXd1DJF4T7nNisZZuhRrOnla+FESwNnZ6lFsqEAYJvdxm/3aGUO18oZFW1W6/sTwakYjLfeQHEAsFbD/FdZm/6iQKmxwlg9vjk/EQrux96BVXvu7PvSEHtp+sxLn+dYcYnoyBuiw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MQ34FODL+rWvjEXX2BjWCcNtXyZaoeDOc5977Me123c=; b=mL1ASNKso2qgrThMujzMRmg+cHSGlTax23hthvA3EiC9T2qwR7H6c3hl6t4/RBdkQ5ZYo4kbndtP4Jm+coknIwOV6F8gGuCcrDwawGg3VGXLYXl6dPAtN11gNdo4m7Aa3GTECQI4QS9KSjDOYPFRt9nRLo7oiyQekGmZ58ALZt4MFKDH3IB0BGLgqtsQitmAPLOJWmc8YogLN6YMdYLQrSoToAnsTplcobE5A7KYn09H7Q1JICHpRaCV3ifyRKONYBzOwrTVGFN7J/B50OYh8DiK2PN/PsvwXYwIO4NW4tjCkU+HtV6V/6Qth+QCtxhmMEhKJyZllOXuObXcmw3NNg== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:26 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Wed, 11 Dec 2024 20:58:26 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:37 -0500 Subject: [PATCH v12 9/9] tools: PCI: Add 'B' option for test doorbell Message-Id: <20241211-ep-msi-v12-9-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=1851; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mJBGb3x/IT3kU6QxbS0pDIxty8JwWoRws5fh7D2yIVI=; b=QFLvfupamU6j1m6GC7+ti6gAF9Lji2I/ymk1eSE3p5fzudCDf3+vupHDN3ZmLnRNTbtBXTsSI 3K+V2/zfZ5zBNOmUiQmemeCheOGXGKqBO+y2GZeNxfCCsQtQZgB5XU9 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: 83310109-7cd7-4036-3e4d-08dd1a268edb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?vFVV0o9Hq1dLMOrQwLLHRfrHMUou7vN?= =?utf-8?q?bAZYJjjyVUpr5YQ+I1T8PYGw+T+ZofQ3bpb/pDcHe96gcmiLwhPPu9DEIoZXH4b4l?= =?utf-8?q?kqt16F6WrZibm76WUw+Fq0jQOPdg0orde6Osm2zZSdH6ACriaB9aI1r3S49I/phWr?= =?utf-8?q?aVzPaIwoyqr2rzNijwEoxGaXb/zW5oxm5tiAzyEwVlPBDVEdPKDpqzS7eXkexhgFd?= =?utf-8?q?MXaqANa59M4UAhtq75UKRbjcMati2Mer2QoHqlgGdR8da6ZSnO56SjbH68WyaeEdE?= =?utf-8?q?3rK8L3w0ItLfMkXPNDP3um3Lzzz4ilSEWk9BqGkrsMgFWXxmWi7pQnVVHYgB7Ox3M?= =?utf-8?q?UcPqdpaSGD51T6dCU4IytjGuzvzGEOWFucwBkTHL/GzhfJ9jvLBN4h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A8RrW?= =?utf-8?q?RACRi53sN85YDsLsAFKyES10UGnpmtceEHVmWK5m5D/DlbPzuovG4WYanBq0ljVRb?= =?utf-8?q?Qjo3RnHpKvRzaGlQlJUBhg6ij/STgz6IWhxk+2dsml0xkfmKhjRFLT4=3D?= 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:(13230040)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xQbjasFv14VNZhM9quxPQR2qAwxs?= =?utf-8?q?ZBcRYx42I7qLwjnu+rYxNxzVjRYOg7E7w++SBJ5SN4viitu6fSTAN95XRBIm5Ucha?= =?utf-8?q?Rrdyq0sIPnzFvsttcqtJ8DluR6iGnAVEMI0RW3X0VCOghKVkvzBcVVIbmYRqj0cxe?= =?utf-8?q?kSJhUNfNQgjGYNub9mNVurWVaNQvrG07roTK6xohlUExxPp1uFu9ORedV1lnnbjwd?= =?utf-8?q?ln1Qnq2L8I9gXBoSNyyU4ik7aswP7fz/NTIfuQFYFjll+uEiN42K9MigTE3n9yUaE?= =?utf-8?q?ciA3RVPWGMu8Ya6d+PQ3PvCeYZwLuD8/W3mtyG4lH/uRqGHoGVr+kPkh4W9MSCnOP?= =?utf-8?q?DLRzq3jHHofrp89uZDF3xHCvn7kyr20T30w/2ir7awAEkza1Rf4FYdfmi9GZmXhZG?= =?utf-8?q?Sw4kz72Rci2prySPxIfIodbJKSVAaPicJ4cIY9NAljVkv1oY+MPKkoisocp9IIBF5?= =?utf-8?q?7mqWc+gtsrAXOHxeQnPXfBU8iNI225Sk2iArRoXJErMrlKg+/NHZvaiRL755XWALu?= =?utf-8?q?kxSFVm4ATg1e0DtQDN458HdOAFT80CMEBYT6+na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vF+PvlIR8LhKjFyQx+X?= =?utf-8?q?9owiG/m+XnmHh5jT45kA0hch7SE9OMYhx/7IGxxrgL3QYhh/f3lUWvVraTNsV7uA5?= =?utf-8?q?o19gN/9cL2gz?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83310109-7cd7-4036-3e4d-08dd1a268edb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:26.6438 (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: 1mlrP60UE2o5Qo0UxGw6QTaE2cUh1weyHkujOFprdYB/Gh5oHGN2aI1ypgSurTzsokoymrsBfiUUQwmBvana6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Add doorbell test support. Tested-by: Niklas Cassel Signed-off-by: Frank Li --- Change from v3 to v12 - none --- tools/pci/pcitest.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 7b530d838d408..fcff0224a3381 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -34,6 +34,7 @@ struct pci_test { bool copy; unsigned long size; bool use_dma; + bool doorbell; }; static int run_test(struct pci_test *test) @@ -147,6 +148,15 @@ static int run_test(struct pci_test *test) fprintf(stdout, "%s\n", result[ret]); } + if (test->doorbell) { + ret = ioctl(fd, PCITEST_DOORBELL, 0); + fprintf(stdout, "Ringing doorbell on the EP\t\t"); + if (ret < 0) + fprintf(stdout, "TEST FAILED\n"); + else + fprintf(stdout, "%s\n", result[ret]); + } + fflush(stdout); close(fd); return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */ @@ -172,7 +182,7 @@ int main(int argc, char **argv) /* set default endpoint device */ test->device = "/dev/pci-endpoint-test.0"; - while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF) + while ((c = getopt(argc, argv, "D:b:m:x:i:BdeIlhrwcs:")) != EOF) switch (c) { case 'D': test->device = optarg; @@ -222,6 +232,9 @@ int main(int argc, char **argv) case 'd': test->use_dma = true; continue; + case 'B': + test->doorbell = true; + continue; case 'h': default: usage: @@ -241,6 +254,7 @@ int main(int argc, char **argv) "\t-w Write buffer test\n" "\t-c Copy buffer test\n" "\t-s Size of buffer {default: 100KB}\n" + "\t-B Doorbell test\n" "\t-h Print this help message\n", argv[0]); return -EINVAL;