From patchwork Tue Oct 15 22:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13837316 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010020.outbound.protection.outlook.com [52.101.69.20]) (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 ED25B21E3AC for ; Tue, 15 Oct 2024 22:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.20 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030085; cv=fail; b=kkuHV7XPKQvNdu9/ptVxKDG+v0VQg2q+arcl1uPO+RQg7Or2w+ARsQfn30Gj3DiLglIfDdoPPBru6YKUUu7vGP76Au0eK3xTjhbMrayfpxC8fHZdGwCMog8tVm4TUKLC0lm43sm8TzpIn3WNrL87bOE5DlnBNYqeqcih0UnIFWk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030085; c=relaxed/simple; bh=kWfkK5tGIegwND7N4ToQmqK7Q0IW0URS7ZZA/XfKGDQ=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=owheyGnl7BimxzceKtRmgofOLe3cr48UiyqcmsG1HByHfMO8lVZcXhZeZdgrhkEhNe1HuicaDPFIZcRPuiuJynTnvWIZGm3lhVrOjYHHtnvJOLnN1Hj0cNQ3q6cuS0/g013/mkZEuRqCRzsbX+AbSVStvjvmE8w2ETvMQ6U+wT8= 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=mpJBU+xV; arc=fail smtp.client-ip=52.101.69.20 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="mpJBU+xV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IEsu5yjkU1cJDzELiHq7sKO6rxo4fAehB5p2vHvf/pzfffNHeX0j964N5XMckaeA9j1afATOMvU+joD5GOxweAkTP1dCHs1GC1a/+g2JZTzsx/iFRlk1I680d/m7Uh0iq1zZ9odeDHEgWOpy9K9UxPSJidEflhMtz5/ShsawqM9P0nx+bLBvLesgAmBopSkNGA63tQ0D216m+mtNqnGoH9fkVXonv7J9+bMr3pxD09+sLo66zX2qC8kqYRyjReDEHg/NVU40mF834neCcQ63p5bnBwdaefy6suxAFSAafUyL667W2ftk00j2TBBX1bAYH476/mfVIOy1SRfsuyRLYg== 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=nDPHrNZObOAsbKhZx2DnQpX17gTc1G+ufjCruMErj3w=; b=PM2YSMInSEmKCQICuVITfI8Dshc+XUe+V64h6lq7MQF3I3IPqEmpaz5Nsg8hQqQ/d27w0DmEv+06Y7PQAg8JBxidfuK/ukL5dPKCii4PrFTw2+jsnPVeVeCpO/6ZaPZ5teQvWPkcRp2vZVeRbJEnpgkbFyTDhq9lLcujveIugXANzVqfP61+S9gtjw/tEpAaleJlEXMEaEOV36e78oVNltrkLDg6Dsf5jRgAyWwO04Vsw2K3wAvE+JW5tXjtpytXDlgEoRgG7r51GzGBNp0yw8FtP/AZhF5gd1sYOtx5zIQKT8c4mxZOvv32VQlpqhTlhfuOMgp17UFbrU2yvUVzog== 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=nDPHrNZObOAsbKhZx2DnQpX17gTc1G+ufjCruMErj3w=; b=mpJBU+xVRpu9Xyt8JTaDWP+uFuQUof6NyDuu+e92/ME8r+oDTFFNGXEtV8E8aGuGTgsH2hoVD2Qlj/3wYh1q+GggLTXOfGj4FiTjF2Re3/L3goUiweIOdHNn4nCAzZ/zuHyWs1pd4dE3Bak2FlMzJLWvHKJH0ioxKdKK/j7dDHzKxTDnLlxRabN3PEx4jDt65wo9v1lOVZ7S4geBm23Fp4RO6tbH3YAnd2PMshUnbb/JqeMFYq7kGYFJF+u8qFkC1PWPJUqyNYtqbRQNzHPEZ2JxzBx3eXzlMw+/+o0Ht2qJ7BN4oPopatyyncg20vyKU1Uewgb5xFFDEhVOpjSxNg== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:07:57 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:07:57 +0000 From: Frank Li Subject: [PATCH v3 0/6] PCI: EP: Add RC-to-EP doorbell with platform MSI controller Date: Tue, 15 Oct 2024 18:07:13 -0400 Message-Id: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> X-B4-Tracking: v=1; b=H4sIAJHnDmcC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyjHUUlJIzE vPSU3UzU4B8JSMDIxNDA0MD3dQC3dziTF2LJJPkxCRj4yTDpFQloOKCotS0zAqwQdGxtbUAsn9 wilgAAAA= 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 Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=5417; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=kWfkK5tGIegwND7N4ToQmqK7Q0IW0URS7ZZA/XfKGDQ=; b=8VWmKaUolR/qj/7a7+4DScqQ/BbjQpgxV9yUjujE96e9xXgeNLQtsigb07VZTDyN2Yk7doCJ1 nf/ZWPh/keRB3sMDMvRMXAqeeXqIYILuFb4PRTC1eyYTfRR/98ZAfXm X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: fc96b135-8c48-4952-5be2-08dced65d351 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rpxB8gzWUIy3lvy979li0YZpMCEhavY?= =?utf-8?q?AmqMTYYBfXFdSv2AWunwrOOUBm3i703BXhPAtZEVCDRofYiiaZjHSgim0xhls5QoR?= =?utf-8?q?n0jSo1XpoL9BDZKsYLFHruyRouDnZSK01Mqc0U3BFO6O8XbtPfnApL6vm/whFjT+p?= =?utf-8?q?Cu1taltosXEj8wGp8MbNafvTkBSSO/XyHf/w6xjOykycEhuW+UaZptFpxJE6M5tTi?= =?utf-8?q?jeAn+SzdyL1W2Wjx4mwLZgINQTJ6T3PGdXfQ7+qzpxV4irbb7FBIwCR9QfZdp8JNQ?= =?utf-8?q?gfkRi0je1dGIbZsomPTL6mTB4yJ5pTgxH4n5C8ZP7LmkdzPvRpNSeB22xLF/C5F44?= =?utf-8?q?S+mJ5puZZCEgj4cuohuiQ+Uh3QrqRLgaXMuy2/8zoE1LBu5kudAiwSR4DzcRltsYT?= =?utf-8?q?B+dhZ+WH9KWDVkXed0iboIebIYQds0HHMI1oNf1mY7fVSd/FLs3MpbC01xdkGO+zk?= =?utf-8?q?aYloVjvx1eL15+23GFhemh/5bbUDI3JvcAqQezMviHAW2N8Ljfz6OZQ4fM1thXRA+?= =?utf-8?q?rFndvVkubriE8pETrj9Tzp9xTj58KNsYCMPpxFWudFtot8Q03JY3v6ld2JX+cXL4H?= =?utf-8?q?eWJ9a5GEpddFKPPMy3tmy5kd6y+HPwV05xFSaiyisZ+Z0ecxsermtyvqnYNjfJQYx?= =?utf-8?q?HyPGvKffjAG9LEupq6bm0mOby56Vlx0M4f9/weaEdKvbnBIs1SNOSxles2nMWVcUU?= =?utf-8?q?MRitdU1DYRazmqFxQuiKXnwRL8HrzF80mgkI0GVsaWJaiE4BJZLgowFvi7OIUD3MQ?= =?utf-8?q?JFImJyJj3YkC26M4YR0bBzGg9IkBCcDziBred5G64mDOd1RH2P5ARoFNdFmgRbJRZ?= =?utf-8?q?weAYmaC9SKDMkUtCcMj/AtKQuJV1HgbjZpeuAjjZOaUl9UbcONmUNqmZHpMdVtZbo?= =?utf-8?q?q2FRTt2mxlPDNaR756c4FAiRGs1oHlBON9EkZ9QTO9INZhPm6dyNzF4Ow5Tzx96Aj?= =?utf-8?q?0RGHqxQrfwqP8cGs7LfeI0WJt34QzG6vRtmqPjX0+By5pMA2nxDHhK++J69RVbZQK?= =?utf-8?q?Wp1SgXYt0CeIdjLQpfEjdKMQujTSoHHd0hpFNrDRlqrqDqy0a3tR6xKbs/Wb9gp9J?= =?utf-8?q?h8NLZ7rbcIfz0TZt1fwgXDcYEqDVYFL4JAgDUK88+Absu1Nt+KYN+X0vzYcVxX9w7?= =?utf-8?q?6dX03roFS2PDtteKHmcQ13jaWcZwb3RFcgTFH6yvb1lpTXzH7n6bM1oReyWHu6/2G?= =?utf-8?q?BcRRAIOCZnFbNQZYKzrNjIeKmgIdgd7yoyYXTL0dbxirlqjcKDot5+GHJdxwnVFiY?= =?utf-8?q?JMOgmz/wJjzP0zbmPhnUYAuoSs+nTvzZ6VQ=3D=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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kZVp2ZSqsIRT0QesVrr5iitMvPtp?= =?utf-8?q?QMRmKnXkt/NqiS1ng3HvC23gIpAGDh6wqOOvNb0IWdeYUCtG663y7xHz0KN51E0S8?= =?utf-8?q?ZpnQWBHdnTx/JKfPQYZgTwj6ekPYkOt220aUP5zuNr6YdpIH0FOE8h+7Q9Lxptce4?= =?ut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?q?uv9QoRoBiz0/h/ACLDHlsffLM1GmP/k9CTtjvzPetFXUlNGXTRCNNHGlT4O72JaHn?= =?utf-8?q?uu02bZmti/L276XHUEE7n8qSPy0SwsF3B4pa2qNih6AljYWNrlW/MyqDaSa3L3gUH?= =?utf-8?q?9AeBXGQL764+QK30JW7HzNbmxs5Zr6qr3+Jikkcby30S6q2K4eXjQ+UJrUz/lZZ9e?= =?utf-8?q?+KSaLLM4HU/3Z+5x53Ngz38M2k1vuac4QZ5mlXY61SS++aW/6c2vaKW/erI32TMMH?= =?utf-8?q?VeC9kZn9gPidpOhJvcVGmm92zjADmN0pmiTaK2jPIt1XmdesUPuutjb65wfXfV1/s?= =?utf-8?q?+6Lg5CQrW0X54NwPmloiC8aLg3SAvMz5YUv6/5ag6wlM+/WJnxkTAyY6npRyBckKM?= =?utf-8?q?yJ6JLSuMyl1Sy4SZ+EaKFDptkQmvSLCSHW/y4Im51yR970ikYAzaQJsVaNviLvOyQ?= =?utf-8?q?ZMcGUmtO2DKdwIZrfPFLiBO+YXzdOxY5sDgf/igGfawsXWdRuQJBydUE=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc96b135-8c48-4952-5be2-08dced65d351 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:07:57.3889 (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: MIFH08wfMFilvz2m/43gAGlnebh5V2DT+guN9WtVIdYDKxlBmI3X6KnExoQsjD3YNsMLuUXuWj6b99Xsuf6cZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 ┌────────────┐ ┌───────────────────────────────────┐ ┌────────────────┐ │ │ │ │ │ │ │ │ │ PCI Endpoint │ │ PCI Host │ │ │ │ │ │ │ │ │◄──┤ 1.platform_msi_domain_alloc_irqs()│ │ │ │ │ │ │ │ │ │ MSI ├──►│ 2.write_msi_msg() ├──►├─BAR │ │ Controller │ │ update doorbell register address│ │ │ │ │ │ for BAR │ │ │ │ │ │ │ │ 3. Write BAR│ │ │◄──┼───────────────────────────────────┼───┤ │ │ │ │ │ │ │ │ ├──►│ 4.Irq Handle │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────────┘ └───────────────────────────────────┘ └────────────────┘ This patches based on old https://lore.kernel.org/imx/20221124055036.1630573-1-Frank.Li@nxp.com/ Original patch only target to vntb driver. But actually it is common method. This patches add new API to pci-epf-core, so any EP driver can use it. Previous v2 discussion here. https://lore.kernel.org/imx/20230911220920.1817033-1-Frank.Li@nxp.com/ Change from v2 to v3 - Fixed manivannan's comments - Move common part to pci-ep-msi.c and pci-ep-msi.h - rebase to 6.12-rc1 - use RevID to distingiush old version mkdir /sys/kernel/config/pci_ep/functions/pci_epf_test/func1 echo 16 > /sys/kernel/config/pci_ep/functions/pci_epf_test/func1/msi_interrupts echo 0x080c > /sys/kernel/config/pci_ep/functions/pci_epf_test/func1/deviceid echo 0x1957 > /sys/kernel/config/pci_ep/functions/pci_epf_test/func1/vendorid echo 1 > /sys/kernel/config/pci_ep/functions/pci_epf_test/func1/revid ^^^^^^ to enable platform msi support. ln -s /sys/kernel/config/pci_ep/functions/pci_epf_test/func1 /sys/kernel/config/pci_ep/controllers/4c380000.pcie-ep - use new device ID, which identify support doorbell to avoid broken compatility. Enable doorbell support only for PCI_DEVICE_ID_IMX8_DB, while other devices keep the same behavior as before. EP side RC with old driver RC with new driver PCI_DEVICE_ID_IMX8_DB no probe doorbell enabled Other device ID doorbell disabled* doorbell disabled* * Behavior remains unchanged. Change from v1 to v2 - Add missed patch for endpont/pci-epf-test.c - Move alloc and free to epc driver from epf. - Provide general help function for EPC driver to alloc platform msi irq. - Fixed manivannan's comments. To: Manivannan Sadhasivam To: Krzysztof Wilczyński To: Kishon Vijay Abraham I To: Bjorn Helgaas To: Arnd Bergmann To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org Cc: linux-pci@vger.kernel.org Cc: imx@lists.linux.dev Cc: Niklas Cassel Cc: cassel@kernel.org Cc: dlemoal@kernel.org Cc: maz@kernel.org Cc: tglx@linutronix.de Cc: jdmason@kudzu.us Signed-off-by: Frank Li --- Frank Li (6): genirq/msi: Add cleanup guard define for msi_lock_descs()/msi_unlock_descs() PCI: endpoint: Add pci_epc_get_fn() API for customizable filtering PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller PCI: endpoint: pci-epf-test: Add doorbell test support misc: pci_endpoint_test: Add doorbell test case tools: PCI: Add 'B' option for test doorbell drivers/misc/pci_endpoint_test.c | 60 ++++++++++ drivers/pci/endpoint/Makefile | 2 +- drivers/pci/endpoint/functions/pci-epf-test.c | 58 ++++++++- drivers/pci/endpoint/pci-ep-msi.c | 162 ++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-core.c | 23 +++- include/linux/msi.h | 2 + include/linux/pci-ep-msi.h | 15 +++ include/linux/pci-epc.h | 2 + include/linux/pci-epf.h | 6 + include/uapi/linux/pcitest.h | 1 + tools/pci/pcitest.c | 16 ++- 11 files changed, 341 insertions(+), 6 deletions(-) --- base-commit: f231847d7f5a171be4566099f654521606b3ec37 change-id: 20241010-ep-msi-8b4cab33b1be Best regards, --- Frank Li