From patchwork Fri Nov 1 21:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13859765 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2051.outbound.protection.outlook.com [40.107.21.51]) (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 9D7861E2609 for ; Fri, 1 Nov 2024 21:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730495104; cv=fail; b=J74XB4pqQJOsCXYdi4W5PXy10lkSHAi1r1cDMLRRQAzm+l/FommOPR3YDeBPJOOKztJaJDcs5YddPOIakEsoTNbDqC285dlvgd63nmvDEntanx39GSyJtAqjkpdPraL2dDZTDmoDt4lZte3pD2/jyUsChMgl008aq2DT0FzpqWE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730495104; c=relaxed/simple; bh=4p8lEaTgoJLNoLN5Blpp9G5ER+NKuLVgu/8fl9wrMng=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=nQOZKaZJCNt1LudqkSxs9BPlnN7PQL+du90XKi6hD3fpKc623R5EtMhAFohm8GQ45HimUwvboC1KJI9xxCc1IwitEGnzcIqGVPXO2flSaScK0Tohvr3FiwOBs5qg6eoZOv1ZN8BbDQGchBocYQq1lULEn86+U0a4WIZTR88witk= 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=cj6PQfIV; arc=fail smtp.client-ip=40.107.21.51 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="cj6PQfIV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bs4o+/Mt7Mfr89+HDdSdXukAUKr4sMQfWKvQaTYB6oqf/lE+EOQ4KM6Ucn05ptQU+or7PwcgBnJwi0MwCwzzbcyD/hCbQwfb59kHT1opqtmY4N8N3iOkpH1x7HA8Jke7eLK02L1omZeFcx+8R15cI94iPwm393Dj3pFhy0kQeRo/udvV77EDtsXE7R+be/OjIFxpdmR1GdyasEoaBLXw5w9MB+VLbSRAlCJIy/T1CEpZXwkYmOWJTIwNLizRpnFfffreNs/zewwAlFYJ6YNMkdXCfHhEl80yupag1rdrKASPHchiVXfq0CXdjWVlENOmEGUcNgYlomYGo6Bs7AgRug== 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=vZaCV9fnw62B9gZxPc9IhfJqEzdCFKLJef6xlrBUrhQ=; b=W2jlGbYz0dKJwvDbvBurnP+ubMxnQ/buJtLhRadt8DG0MFYGaecnsq3y95JvAqtFfsfvUDyKrR1IRpjAt/MGentmHazKku+ofbTEy9uHbTTufMWIdybWv1T6/CCFdGzI2NPJ2ZR7a+WigyEV25+kdN1fX1ZeQWa0DYlhWaNyYi2MwU5YIUzDnRPYVyw88CzKo/8H4kS9lVKW7wFrHbboP/s4QuoM9Gy8ak3hWLyD+iPGbEI7EMEGreGs2g8VIxwRww9XTsJmBmEbTb6zL141EpQElfHLIu9MjLoIOpjhCmyALl6gfJCULfa9BduXeQGeSvwj2yJ58eNqIbA8MijnQw== 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=vZaCV9fnw62B9gZxPc9IhfJqEzdCFKLJef6xlrBUrhQ=; b=cj6PQfIVXvqIoGYIElzpn4poX2DN3az9pP7Q2HvfI5+cZzu68PIxfkf86Dc8PBm/VHjEw3Fu2tMGb/QE9qTctT/S5iuuxChLh3yiwcqKO+8W5a2fL9/pK78xrUsp/Ml7zydg0IOT1ytj0SSwyNMxuEwihXu7KpZj+EFZ6Dc3OTwR647TWo93YXApGy2bCxl8FGZFo09A6qGhANjUwYUbr6WbURSENcW4hDuhbnTsTHJYqfQyhRIdjC9ipmEfrsb+M0DO0rin6+adjDWPG7m+YB1mxB0fuG2mpHt1NyngQeGG1SgDY8a03niQhXsjH5IYx2J+/d6DGmeSZqkcPDj2Ug== 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 PA1PR04MB10502.eurprd04.prod.outlook.com (2603:10a6:102:44f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Fri, 1 Nov 2024 21:04: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%4]) with mapi id 15.20.8093.027; Fri, 1 Nov 2024 21:04:56 +0000 From: Frank Li Subject: [PATCH v4 0/2] PCI: add enabe(disable)_device() hook for bridge Date: Fri, 01 Nov 2024 17:04:38 -0400 Message-Id: <20241101-imx95_lut-v4-0-0fdf9a2fe754@nxp.com> X-B4-Tracking: v=1; b=H4sIAGZCJWcC/23NTQ7CIBAF4KsY1mKmA6XFlfcwxgBFS2J/ApXUN L27tAutiYtZvMl8byYSrHc2kONuIt5GF1zXpsD3O2Jq1d4tdVXKBAE5SBTUNaPMr4/nQDMjSkS 0IDkn6b739ubGtet8Sbl2Yej8a62O2bL91xIzCrQCIxDKotJKn9qxP5iuIUtHxI1jsHWYHNOCi 0KrnEn169jHZWm2jiVX5CCN1OlbKb5unuc3e0JaMxABAAA= 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, Robin Murphy , Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1730495090; l=3682; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=4p8lEaTgoJLNoLN5Blpp9G5ER+NKuLVgu/8fl9wrMng=; b=TNPZc196qUdgLUJgKgkVSKQN5ig+Qz+yTB6Nz4tWblFH909y4o/DmapJ0HcdQnynPvJuOt3m5 JSxq7KIiibMBw3T90QG4xlwhestzQ0aFHacQR4iksoNDQVMxSY6YOpJ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0092.namprd13.prod.outlook.com (2603:10b6:a03:2c5::7) 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_|PA1PR04MB10502:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f858fe7-7152-4aa8-d94d-08dcfab8d6aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|376014|1800799024|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ibNnoDNNb0eKZUyd/9s63UJTp/ujNIY?= =?utf-8?q?ryXhvtIDPZLPKw6dw/IWGFLYZME+sSY9M7kXSNcHuir23SFg3GJKroGgHIKrTQvsr?= =?utf-8?q?dmDy7rwQ3+NFKXeRotRWSNXydM6u9hbkQVMRwxVYIIfZzPf8VfDazOg0xGriPw8QD?= =?utf-8?q?yLvyeILXv8ICsueX+ql5cJ46GNDT2x6OrrfGIIdgTSZKHd3AF6qn0Ud3b7RACEK8D?= =?utf-8?q?nOZ7O8UV79wgR9A9IHbuhMmkmnpU8iotzSnb7LmZFdcVmkN5/tFkXv9mdgjlqGWh1?= =?utf-8?q?Hv+DqGy13DhsCOeAhn+q1k+bjONVjnxJc3a2YCzQSN5x4eM5VIhOp+vn7iVnXoP31?= =?utf-8?q?VXSmv3pbnIVb5QStgIzXBLIUboKQCAu1BdpBWQOB0VNTmMKuqHMMa2SIilM6yl2j1?= =?utf-8?q?acF7YqGINW4BFuU5qaT2Bp/JuQBAA0SHYN5QZ+dOCY2vXTOe9NsRChDD39SAC8agR?= =?utf-8?q?4yz5QupFn5NpgNlLzyH+XtROY+Ys/J4Cr6mp7V0w6C3NWM0xgOzp4j475vC9Lq4+q?= =?utf-8?q?kL0q4JH3X/7ywChxDxAMdowa11LyELa1ydY1O/rMhMrii3GDHz6Q83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eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(376014)(1800799024)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RRLSuJJJKCWoPnJ2nKyp+Gbkkivh?= =?utf-8?q?OSOgAcaD5xfc3HjI+V3GztIKqHJiPTjAbcaco2A4x06A5RUx8gE1NCPgQhebEsflg?= =?utf-8?q?Y0d00Xp+nwEcbB/hmT3o98Wh/LjA5wcizzhCa2zm3YjdrajyzQaZQEveLZAvlUtsW?= =?utf-8?q?8w/lcUE732mwVDg2005N1SJRMLD6ffq2b9+uFzuSRYfEhznqnQBMW8gYl9LF7/Wsu?= =?utf-8?q?mW+6oV/gu9JRckd1yTiK5wDV4NSdmj9vm6k4MP++nq1wGf1xQN7FEjND53LTlriEK?= =?utf-8?q?7OmosUP/lGaSxzlZKkuUjl5Mnvo+wqdvCU1O+SwqDjJJG4UfHACal3i+AasHDvDh1?= =?utf-8?q?BTl5NtTIWz86lr415TH+Yw32w5UBHmEo90oLG2YtFzZ8cYbEsBVZqM9lSCVDfeC/M?= =?utf-8?q?SdpKBtLq9ybf3MymseURo+llbye5y0RYyQzPIK1oCQ17CxQrm7oGLEA2xMvrAsKJ3?= =?utf-8?q?jzutkm7zYmlOeKhOq/DNm99cIfo7jGPKgnXNJd66ILXCpFkw/ni/Dd7Kb9Zrk//4d?= =?utf-8?q?qmG7OAn4pBQqT6K/0DzjHC+vWmI5AZo4uvWfsK3cOBv/IrM6p70UkwhVQOnBQhMCy?= =?utf-8?q?9wn50OURFfJNQqSgJIV/cRAmpJebpFw6HkvoiQQVqJPrHIAVmIUobKxrMQntNDQxJ?= =?utf-8?q?1lfQflYn1YW8heJRblV/h8w9mL6MqwDX78Dj7k+aw/oKzXfuTKIUlUKfU7jks2Hg9?= =?utf-8?q?Shw2V8o4mof2qCv+OY+e2LJnli/pVx2gf7xE6XH4XRkY/6wAOo777/gm1QgI0wvyi?= =?utf-8?q?icnd9+jpc+9fl+3jeomAtuFP22cifrfJq9FIu4oh6jXvLGZXnGdPRY63rLB9YjdIi?= =?utf-8?q?j5rLizWVcu6hmG4VyzbkSgdFdr7w+SlSMIsmRm9MmBH6GCAjlMNvXCd1oj0yPn4z0?= =?utf-8?q?U23KVaYqmRa04xd9lYw7X0S1ccraMlQP+gUWnpO2XokTFp+2EqN3Ueh5O5+Kiop/0?= =?utf-8?q?JxpRuqi244l/3iudkzV/QjrQlq4qGCbaMH8Vcogrb5fFtMd64lm+pxxh9IDP99jsa?= =?utf-8?q?zVBqueTrdPEhmS5bC9DZSG2qyUmWmOOeTd9ZUctpc0sHiE2GLfCWWRE9c+NiKS78/?= =?utf-8?q?XleiDMXBw9entdXZ1S2vyxafPm0kMhEFiyGIRe0JfIh14jMDpa18g+U3HQwD19ANv?= =?utf-8?q?MvYsPsVb0G6teYCW54UjVNuv5/Y20CGtl31Kj5j7qDBCBe9wbAMWBbsbuV7LQOAJR?= =?utf-8?q?gFZY/OTd+elnJrzWaCbf8wFalFT1wA5gVoaN5q/at+YLEXBuWjgC9+act7kgQYTki?= =?utf-8?q?70iaGktPhsKLqap2XT0yPsTfcL6JXdueCGj9e9QXKK5DIoIrHAOpAevQAPy7x5AtZ?= =?utf-8?q?8CG6XPVAS7APDlccwFS4Et5Nwx/LEx6GYfaLwx7ityEmy7UtX++vBKUpoqzNdZyCD?= =?utf-8?q?QyBOc4Y7GOWk7XfJKYR7N9TTvVqH+JNpyLMjackzJFKfLVXks+YWG8SdkFAa59i0Z?= =?utf-8?q?UQKKCZogMnhEwgahogWZfIPMJE/8rBnC4gZHLxz16j3fthjzum9kZDkw=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f858fe7-7152-4aa8-d94d-08dcfab8d6aa X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 21:04:56.3270 (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: XgKtz+IAIVZKpd0/jO0TDqos2Pkok6YxZLLSG3fBlyX06t6GLt3joy+HKgee6ThOUC5VooS61esiqavBvdoBGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10502 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 \ Cc: Robin Murphy Signed-off-by: Frank Li --- Changes in v4: - Add Bjorn Helgaas review tag for patch1 - check 'target' value for patch2 - detail see each patches - Link to v3: https://lore.kernel.org/r/20241024-imx95_lut-v3-0-7509c9bbab86@nxp.com Changes in v3: - disable_device when error happen - use target for of_map_id - Check if rid already in lut table when enable deviced - Link to v2: https://lore.kernel.org/r/20240930-imx95_lut-v2-0-3b6467ba539a@nxp.com 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 | 177 +++++++++++++++++++++++++++++++++- drivers/pci/pci.c | 23 ++++- include/linux/pci.h | 2 + 3 files changed, 200 insertions(+), 2 deletions(-) --- base-commit: 9a6b4af5bc27c1d3e5dc9f7fb0edd26047bb74ed change-id: 20240926-imx95_lut-1c68222e0944 Best regards, --- Frank Li