From patchwork Thu Oct 24 22:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13849819 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2062.outbound.protection.outlook.com [40.107.22.62]) (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 152D822B641; Thu, 24 Oct 2024 22:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729809306; cv=fail; b=G6BUU1YrY8x1h37QfOrFsP6Vync3aB0h6b7yAyBbiGGlUg8NRx/6Bzq0lx/69Jm1W73ptAse8TLhfgdBDY1goHSUXTmXQKhPGzd6bStUgPFdExyL9TwQSutfrE15XHKIg8jfN6e4y44thFDogjCPt1ImFxtHoczNjVRrIt92ZB8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729809306; c=relaxed/simple; bh=N8dAoRXaPbcI1CqA/wPzjz+zuwliwQimyLiLRuqZYiU=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=ZxP0ubXlBd9yOYiMBaJmZWjN+AW5gLHQGzr7KO/ucJrKtV3b0vVUVzcMYCF+vXO2fTUe6rOw2CrW5GwU+YKkgH1vNFV77CdzSG0Td4rJaac2sb88icPQyW2QwRFOlfmcCniKzVdpzwpeIC8QtrHO+Hzh28vVbJf1AMesQpU5+LU= 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=Ncc3KK1S; arc=fail smtp.client-ip=40.107.22.62 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="Ncc3KK1S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZUuwXc2O0eAgamE88qccEwGi1PE4708Z8iseB+GqBBGAMkuqbRRJwYhTAVnJD2DgbFXy8Ao2YsphL6MZJ3PptkAtB9pkb3FKAwWwT2HMAne4LO5xOKOnUsMJQjpVbcyxxX17NrVcT39svjsjkBDW5/9zbt4IgOzO+QcL3Xj2L/skAoJJpwrzUKqYVy4izmYwFT6nL7+Ic4WKifkf0Sur1Tj1+KOoLF/s/WL2NKoYyKa9ZaypolbxLAyVgLDQcGCW4pKWkpBF+zdGirrAo0T8RUFVbH9a7iX/Xftt5LxMzPFvZCs8MCfq8WO9t8jZl0VivwqWOGINySq4alEsc/sr+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=ALlYyFxJUoh2fcdeG+r1juTV/kIcZrsE9a5YT2fDmpQ=; b=KcpsbP9ntVkKJnFNqh1IE/6/J3lZyHtaKz4eJyQHJZCvKO/bYULvMAqOj8B3VfcqG8bFFqgJFvJWj8Hq0SZRcAjKcfYLzq/xrVA8i2PCbiP4WKHWZRlpAFgNebpuUpzPegmlJ6uHHk10RHWeZCDkksEZweGmkmtGH1n9IckJSVSScPqdQuPpmfYEVXY0o+3KDLXvtqU4rSFxPRQb8AHSx5ZrGbfJ1FOLunT8WzIDZEpm1aMLgY2hOo7PhGX21DSjTkR86S4QgjnbSBmmC7gUZ1T0QmaxizD48Y5omsFVRuRf+dEfSIqBnoS/GBhl6GPxRXarUzyPwZMItc8COk3ICg== 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=ALlYyFxJUoh2fcdeG+r1juTV/kIcZrsE9a5YT2fDmpQ=; b=Ncc3KK1Sc9tq7pt8HAVRyKdG+G3rUxzcuS+OhaGxvtwpDJnNdhdF6xuHJj0w8xEImhIcmdoyWz7QwKiHM+RZIQwfCudFCDvQFqWcSt2O+ioFcLkaMc1zjIVTfPQf2jIgco9gWg7IyTEbH82+iILwJhFKrWIjJ5P4oORSQwfGEYk/Nimge27gmTD21CTQ87hLAqWJWIeSfRk5sg0nJuNUjuCzE9F1CK2mdfeJtYWemcbAdz0Z/VNpmHVFW6WPYdSwX6f8z5nO1JXoC5sht7nuamqj7nJkz7KH/q3PZN7UvEPvhSjrBxDJdrzQn3cvlU5zikjwQcp5KxRlpiVkQC4I+A== 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 AM7PR04MB7189.eurprd04.prod.outlook.com (2603:10a6:20b:116::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Thu, 24 Oct 2024 22:34:59 +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.024; Thu, 24 Oct 2024 22:34:59 +0000 From: Frank Li Subject: [PATCH v3 0/2] PCI: add enabe(disable)_device() hook for bridge Date: Thu, 24 Oct 2024 18:34:43 -0400 Message-Id: <20241024-imx95_lut-v3-0-7509c9bbab86@nxp.com> X-B4-Tracking: v=1; b=H4sIAIPLGmcC/22Myw6DIBQFf8XcdWnwgiiu+h9N0wDSSlIfAUtsj P9edFMXXc7JmVkgWO9sgDpbwNvoghv6BOyUgWlV/7TENYkBKXIqURDXzbK4v94TyY2oENFSyTm k/+jtw81763pL3LowDf6zp2O+rf8qMSeUNNQIpFXZaKUv/TyezdDB1oh48Bg9epg8pgUXpVYFk +rnrev6Bb+pNArYAAAA 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=1729809293; l=3473; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=N8dAoRXaPbcI1CqA/wPzjz+zuwliwQimyLiLRuqZYiU=; b=huGbZ5hWOHq7NpH9VsBva3O5e+3z7dGkb+O+o/Jd1m5hXIII1GXpoTMejiqeuOeb2hSWPIaIH BWI6suqnspZCGfjFH1nJu7gUJP3Q6/wNCcfFBrmyiP6yv/8yLJ9aGgi X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR05CA0001.namprd05.prod.outlook.com (2603:10b6:a03:c0::14) 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_|AM7PR04MB7189:EE_ X-MS-Office365-Filtering-Correlation-Id: 603d5253-6a45-4568-1c94-08dcf47c17e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|7416014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Nw+QYqA39V4f65taseReedxn4ol/osO?= =?utf-8?q?9QYYcT4eELHDR7tTR6WQH7rHt8bsU80S0+6NQR3podm2IMF3iE6tsUCVxcTXtTr7e?= =?utf-8?q?5T1Aog08ZsiPI48e0KlVU0hHgO4sIY3aEL3ka7qPV42Ss/XEhngSxSvm1IhULHjjT?= =?utf-8?q?WcQs+Byz6YBb6leteEBHpIvsGJJgssjEBDLKNPdcm518pkoe61FdKvfyhhhu1uhwm?= =?utf-8?q?rO0S8PFJHvEVgzx4N6m5qSiTKQAH+/UYgGVEzj+mfS9d6F2m898a/x0lw3Tn7j3rJ?= =?utf-8?q?7dioCNmJrCFDwLJp9/6iAbvw2NXV7laW7jWpy3P8Gfrtuluu25kx+KF58tmB+yFGm?= =?utf-8?q?PHbjb2ZjjNSHR7dfsopM402PJfuf4oR0c94zznTTEfXZzYp1Yjt5A02yCo4Ea94z2?= =?utf-8?q?1x5wtwBTdH5AqB+sXuE9ExK8nWXsqH9hfflMQ00gqc/uQcPkyMEdup+cJY3iut/cM?= =?utf-8?q?/3QH6VT8wC26gq9pXVOzGKV6DQVcioCEqAljTKBlvE52/okuBN/MkAHjlm7c1EcQ2?= =?utf-8?q?EhGVwAoeaMwK3+d0yNoBGHBHRQ88ca5bwenfUnCpFhpqSwaKxbUGWxHNSq3P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B9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(7416014)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AErhOWpEohSdfJBa/a85RSSZUGwi?= =?utf-8?q?MhOoS4Wz4/2tZAMhdAUWsjZfUBQnz+Yf6Y62Fq4xA6AWWkbEdQoIFQEmP8/pQxChp?= =?utf-8?q?p5uPs9uRs/OJ/u6hbiRA4f59uLlQAsKSQgZjFbDkt+Wu7nv1FCs9Ii6i9OytbmIaD?= =?utf-8?q?zEH0gOMkonNDTv8bVBsjgZnUJQ9fERkf8U2q9d9fxt7uKPNxYMZk3tX/iJx2Zn8FZ?= =?utf-8?q?Q+oB0XOXAJY1yUh9ZzfK6L6V4KaURR2P9Nq1N/d4sZsBU3XSUAZ7v2db9a7qjL/9q?= =?utf-8?q?RmbYSc3u6vXYVjOVmzG2rUbfsH296DkP3TZpctoK/gO2CTamqmM0lKuQ/qzZqn3fN?= =?utf-8?q?xTltiW7gXrVJubDPA6/Jc0bnqELvfnPAWJuVNzpOEMQCrTUrSNhXPTT78hH6IuOU8?= =?utf-8?q?aowHyaO8DBJ3TW/cMmlumW7NNwzQa5dgV3GxPhODqS5smbSj6Rtd3z10BjAgn7XG2?= =?utf-8?q?HCNDbkW3IufLCSDszMPwkyn6z/AHbs1ci47TG5xT8/0nEN+Lf/TOfHh4HSNncdLzr?= =?utf-8?q?OEFNMDvGT35FLdO/6bpB2yeOQQg7QWAuGx96beI41JX2SIHRxhWN1NVHSICxAJyLe?= =?utf-8?q?6u0G/Q/iMvb8VYLFtN6T8GMC1ZZ79p4vnU2bta8ii3rMa5auW44CGJ3fkxei1g6v+?= =?utf-8?q?L6gAkJotM70byU8Ldxp4fzHiqB+02fy1WAWRGeV1bhHMdbi4Ddc1bIgGVJwsabKwE?= =?utf-8?q?zrZZvBTQIQa01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Source: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 22:34:59.4689 (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: AoKG1UzGMbzKRM469JAW8F9RYRyOHPsyZfnmkWzwiB6MctQGS+CWZCoRkhvT1c/zmF1uhM5ooTD+IyNP3Y64+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7189 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 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 | 159 +++++++++++++++++++++++++++++++++- drivers/pci/pci.c | 23 ++++- include/linux/pci.h | 2 + 3 files changed, 182 insertions(+), 2 deletions(-) --- base-commit: 9a6b4af5bc27c1d3e5dc9f7fb0edd26047bb74ed change-id: 20240926-imx95_lut-1c68222e0944 Best regards, --- Frank Li