From patchwork Mon Sep 30 19:42:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13816902 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011019.outbound.protection.outlook.com [52.101.65.19]) (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 CA18515E97; Mon, 30 Sep 2024 19:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727725372; cv=fail; b=vEdaEdzwOQzhVNIYnkuZbXOLMCZKWvMSndjGVA8HXWKtoZg6r3sij69XyF90UghNktoVubtPrqTXcnh1iDL0C3/mcug1hA/hnU1WSi1vCn6W4S+5a+quF8s8em02/s+6Y7BLgKHb9AmCGP/UBZjE22vZT6h8gRkIfibdQtjwrlE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727725372; c=relaxed/simple; bh=Yh64Qguo0ihgOvh0poTbix/udsCMkZDBgeMS9aYupgw=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=A6RIqRmcojhSCxNft5o9IvBKQ442HuSWjlalI1aF/jRNQekxBB4zid2dum5m5EbNuN23RDfIO3+nzsnvrZeiH0lEpXiTje6mq9s5pYf3qKOXPELi/bdRlzLu7p/Nc6Ex22ytntTUbgWWsvOCH+QYrQx49FldM484FdBZURyn5iw= 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=RE+AiYdD; arc=fail smtp.client-ip=52.101.65.19 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="RE+AiYdD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pxn78VSMBZHDM2qrH3/vhlCvbqdEHStzGtbAc97V/Ys/ELgJTis9vIQ/hVsXhcXSOSM37YPH64Hi67cdB0c1oLIbwsQBiKOywe9oy9ajRjeku0iOGJDrVeizkgOAWtbiwN2KdEgM35sSJI1S7N32uNY/F60cD8UifYKqvrMPaxzMgJE4rRGmnmCs6jQi+lPx09e71WbFMWvlGhqNwGqQXiXvY4nd1zXney9AezkQxV2SGef1jr3IRB88nHWkUsPp/a9Jj9ELetYrR7f6BxKNDe6rT4Yd5Nfb8O+0P2D1b+fz/OH+XvMZgoNui/12fJcVOThFaMq0kNPvsVpWfAE1tA== 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=o14ZWgVuo6zwgl1KXXMwtBRXK9B04Ouz3nJxIkhC6Ds=; b=h7Xw2yu845WggyCHhIDqjfXBLKhL4FNpQ9qcKP+51E2tE2/ggkvq6kn1i+zdriGwVWih3d4atyvh3DyWm/uxoT6Z8AQ8/OfWcY1U4Nm54gXT1HA668FmQ1a5U8IKiczWYSJuzVBJlxybbCITutSLg6CYqjZAcmZMJE5arPodnyyzD8PGO//FmddSuxU7lhaRbieNoFy2JsxBteN1m75c4CKOv3MuUAi+FXb9PiB5S7nSTkz+gKoreaXbiJ+gY7gJwaJ+4UBb7iKLH33Jjr+k6IebfWfczmggL0/jEwtB0K6Y/KcutgKNaGy1ik++MQqlrZn+k5xhZM1E+/DulV2E6w== 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=o14ZWgVuo6zwgl1KXXMwtBRXK9B04Ouz3nJxIkhC6Ds=; b=RE+AiYdD+frGqxgF8b9tKTEa8osDvQJlwbkGVHsYIf+gx454Y3koeVoCYgoXiNw2EL9XU/4gvbOk9pNwjAd2R7/kHZ6hKk1WDwRYkba+nlWbKTjYUnSX2X390IUZVP5XRLb7yo9yqEbGpYdcheDYpOiXgueeav+4QIMasrKW+/7bFPTurKlIzn0zQR0VBORgUtQEAtqB1kXSKRcrvK37sLIbkQUzrFpdQvsKBX375Ge+3Z4sWMKcxCpe7Pm03wr09hF5JF0iWoJeSHFMXvPNLHui7hoblzIQ6TI6//iWnQPKN9DyQoNMrhPW8kumE0QvTWKCV+cITdoW2eqxf3ZkKg== 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 AM7PR04MB6806.eurprd04.prod.outlook.com (2603:10a6:20b:103::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 19:42:46 +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.8005.024; Mon, 30 Sep 2024 19:42:46 +0000 From: Frank Li Subject: [PATCH v2 0/2] PCI: add enabe(disable)_device() hook for bridge Date: Mon, 30 Sep 2024 15:42:20 -0400 Message-Id: <20240930-imx95_lut-v2-0-3b6467ba539a@nxp.com> X-B4-Tracking: v=1; b=H4sIABz/+mYC/23MQQ7CIBCF4as0sxZDJ4jFlfcwjWkB7SQWGqgE0 3B3sWuX/8vLt0G0gWyES7NBsIkieVcDDw3oaXBPy8jUBuQouELJaM7qdH+9V9Zq2SGi5UoIqP8 l2Afl3br1tSeKqw+fnU7tb/2npJZxZriWyLuzGYfx6vJy1H6GvpTyBZk9vCegAAAA To: Bjorn Helgaas , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, Frank.li@nxp.com, alyssa@rosenzweig.io, bpf@vger.kernel.org, broonie@kernel.org, jgg@ziepe.ca, joro@8bytes.org, l.stach@pengutronix.de, lgirdwood@gmail.com, maz@kernel.org, p.zabel@pengutronix.de, robin.murphy@arm.com, will@kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1727725360; l=3205; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Yh64Qguo0ihgOvh0poTbix/udsCMkZDBgeMS9aYupgw=; b=B9KCpyiLnH0VYc09V5SLpkcGE8QaFQSp/wsGfLNNX/qMFMQ/b7NxrmYyHaBtzqI51NFDypAho AcM5nHYyA+TAIzvcDUs1DZ6Sa2Fy6n5qUcn6ZXb15dbFeoHd1u7hizd X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY3PR05CA0004.namprd05.prod.outlook.com (2603:10b6:a03:254::9) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM7PR04MB6806:EE_ X-MS-Office365-Filtering-Correlation-Id: 33c1647c-e6fe-4fd0-3e48-08dce1880f0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?DdnvDkCcFr0FRgvKULrKGsK6esLOtTC?= =?utf-8?q?UYfnm3/m1Cj6nqn0P/Et+BHuvtXaKH++3IvSLEpc1att9FN/L+IG3VO15Ot4+YJft?= =?utf-8?q?QOUL3t8IIZYW95OIkz4y+/l9AAQB0jOMlGbwYnhZ12kLnNlsp6kdLANrDK1BPvi8k?= =?utf-8?q?6TNu056wYQFMxZH4mIGqdwuy8VyKMiEhI0mKtUjR4RnO4bWBXj+ApprGKvpinQurM?= =?utf-8?q?FMCsX2CLgyJD8L0T3siEU9XGwcpVYZTpr7NbhYNcJTpt0MKtw9EX/p972Wy2keZ1a?= =?utf-8?q?jBqvwjKdVbaeEC9jB3A0b/mIF6AsNz71NJRfOVPv6vJAJh+DMA7DGrDL0tLSVQUKF?= =?utf-8?q?aTGyRDHkD6fL8deA+bFjbbr+4mI+9SdIfTUbqLFuIRoQh7kcAQQFax5ROoOqxmdB0?= =?utf-8?q?FWMFSI6aXXoOwQhj2jBAFHjPA4ZcOqt6ah2dirLXVItPquwHib8Ao+6vZ2xVKWf8I?= =?utf-8?q?ZKjgcZAw4OGEMtSa0dkOxSGSAFkr5y9NFuEP7VZ6hFJbNkLRwMe84f+sOpFLv2NTE?= =?utf-8?q?dtLXdMfpD9quisXy5Dnf8QVFq3OV0PqmpYad9z5Y6gncP/rinDZXYDhPf3krVHCS8?= =?utf-8?q?AkPLjtIWKfYl1FJPnEP0Jmta4mB1mlSwkCVb3K3sXBvZXoDuGADdfU2mSbp9VQBFc?= =?utf-8?q?RuOD01JTCeCBCitEglp6+GmzOCrlEs0BAfDFaWMZqV6qC88/Ap3L10hrzj5CmYI9V?= =?utf-8?q?38IAABHME28361WbjVRcZCoIZoroPFo12GVF2a0m3Ny+Qk12VZeN2JDhddGVgOb+3?= =?utf-8?q?Pg6LGWS9Addb2wBJ4IHOaAqVPUe8GwtorzUjWwD76yI6kWPPxUzbDZRrZI1dzq28H?= =?utf-8?q?09NL8GoS1dZ9H4jSlxIc70L1X262t1tj5dokQtf8VtH8LmiVQ1YPvZJs+xYgC4aOe?= =?utf-8?q?KMggiczm3De9b1eOFdipzqgZdTzkpzgdNKEJdVg03do1LA8xCsh/amSDyjoQoTlTD?= =?utf-8?q?dkJ7RRzOjVoJPQqDs7ojR2MVqmTI1AYj45dWzZmv3bC314oXk+EbijqUtAvoBDosH?= =?utf-8?q?1TXutqm5D5M4awlF3uCKDrncIUBZZjL3nqSLGbt3ScBIVckdh7SI03BWiaIuCudwm?= =?utf-8?q?7WsG3/hebUIdj8wmKRJy61YhPaWkBnn7TwUUY3SkfOcIED+LKGZw4of9Z3Wc1vVA1?= =?utf-8?q?VhANJyOMDLvNxw4aKIY9wWDmeumB03v80lyN1AczGWjh1KbLVI3tX46MhXIQu02ob?= =?utf-8?q?eVldkiFuX/A3RHN94MPLsddpaudxoMlpvSaa0xxkVKR2+ZDVKnqa4JjNqJi8nlINf?= =?utf-8?q?KNF6NpXzFn0DIN19Mbx6zAUaDeJ2r/hpk6ThH+t+2vdfM5IyzSP1S9Uk=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)(376014)(7416014)(1800799024)(366016)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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mN4FKQqxaE28FtBj/CpJCKiX7mDRkq5K3BwuCct7gaDa8zyX8Lrf1sGu3V?= =?utf-8?q?R71n7qR7icDI+4ITVU+5l62sKSARyCtXQnjEU3DuFApPv1Cp6qR5KtBbsuO8+ncIy?= =?utf-8?q?hkjL1zzAheYwLEKuLRTxDlqdhZF4MgaxJTkDx7OeauncYSe3d3UvFS4YF221i+iAI?= =?utf-8?q?1LaJmhwA1VgHheAmUrHYf5tmIwXrG+Z2OOMwRLs9ECJwidDVkwYGBMgWnfsJszZAd?= =?utf-8?q?Tuhc5TB93Tn5yjnEyNHKkJC0WHo4KGfE2rMMAUCeLLvR/hFnPB8/gQRngQFw+JUEU?= =?utf-8?q?m1RWp+0+1xmWhKLV8V2PEPrjV5T7oTSdl1TNEaTTEF9qCb5Z5airRo1WS9lVDLKW2?= =?utf-8?q?EBJq9cn34xatdSvlXgV+3b0ownMt/kGfWwgCRBFe130Ndm8IbihNCQz0hyarKL7vt?= =?utf-8?q?uHKpcgagkax+cZ17jfg0ut1ppH2v1KIdmfian4Duw5Bh+JewB1QMqKSa+54f5Ydc/?= =?utf-8?q?gfU8QFVAdH07mrrfiqdZWYWKU2vaaNOo34dWN5tbXDNLAC6lC6RYfOAf30mkMRn80?= =?utf-8?q?Dy2cSXfhJDdFZAPglccHjYtHmrhRwrBimVMKR39xwBdQpVkIbbzewEYfedkCIHvO6?= =?utf-8?q?haiOTTehZj6SRw8YuNRXMkcUqLigY1K9c26E/7v34GSwvQMOnK50K44o=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33c1647c-e6fe-4fd0-3e48-08dce1880f0d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 19:42:46.5015 (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: c/0TXkJDVnFncWU/ijChxxf6YEx5sr3J/O2Fnjx5PzN2vAsCEF2VgkobbgBMmN06ul1ZoOMAYrlG8QAS7xAPKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6806 Some system's IOMMU stream(master) ID bits(such as 6bits) less than pci_device_id (16bit). It needs add hardware configuration to enable pci_device_id to stream ID convert. https://lore.kernel.org/imx/20240622173849.GA1432357@bhelgaas/ This ways use pcie bus notifier (like apple pci controller), when new PCIe device added, bus notifier will call register specific callback to handle look up table (LUT) configuration. https://lore.kernel.org/imx/20240429150842.GC1709920-robh@kernel.org/ which parse dt's 'msi-map' and 'iommu-map' property to static config LUT table (qcom use this way). This way is rejected by DT maintainer Rob. Above ways can resolve LUT take or stream id out of usage the problem. If there are not enough stream id resource, not error return, EP hardware still issue DMA to do transfer, which may transfer to wrong possition. Add enable(disable)_device() hook for bridge can return error when not enough resource, and PCI device can't enabled. Basicallly this version can match Bjorn's requirement: 1: simple, because it is rare that there are no LUT resource. 2: EP driver probe failure when no LUT, but lspci can see such device. [ 2.164415] nvme nvme0: pci function 0000:01:00.0 [ 2.169142] pci 0000:00:00.0: Error enabling bridge (-1), continuing [ 2.175654] nvme 0000:01:00.0: probe with driver nvme failed with error -12 > lspci 0000:00:00.0 PCI bridge: Philips Semiconductors Device 0000 0000:01:00.0 Non-Volatile memory controller: Micron Technology Inc 2100AI NVMe SSD [Nitro] (rev 03) To: Bjorn Helgaas To: Richard Zhu To: Lucas Stach To: Lorenzo Pieralisi To: Krzysztof WilczyƄski To: Manivannan Sadhasivam To: Rob Herring To: Shawn Guo To: Sascha Hauer To: Pengutronix Kernel Team To: Fabio Estevam Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: imx@lists.linux.dev Cc: Frank.li@nxp.com \ Cc: alyssa@rosenzweig.io \ Cc: bpf@vger.kernel.org \ Cc: broonie@kernel.org \ Cc: jgg@ziepe.ca \ Cc: joro@8bytes.org \ Cc: l.stach@pengutronix.de \ Cc: lgirdwood@gmail.com \ Cc: maz@kernel.org \ Cc: p.zabel@pengutronix.de \ Cc: robin.murphy@arm.com \ Cc: will@kernel.org \ Signed-off-by: Frank Li --- Changes in v2: - see each patch - Link to v1: https://lore.kernel.org/r/20240926-imx95_lut-v1-0-d0c62087dbab@nxp.com --- Frank Li (2): PCI: Add enable_device() and disable_device() callbacks for bridges PCI: imx6: Add IOMMU and ITS MSI support for i.MX95 drivers/pci/controller/dwc/pci-imx6.c | 133 +++++++++++++++++++++++++++++++++- drivers/pci/pci.c | 14 ++++ include/linux/pci.h | 2 + 3 files changed, 148 insertions(+), 1 deletion(-) --- base-commit: 2849622e7b01d5aea1b060ba3955054798c1e0bb change-id: 20240926-imx95_lut-1c68222e0944 Best regards, --- Frank Li