From patchwork Thu Sep 26 22:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13813687 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010070.outbound.protection.outlook.com [52.101.69.70]) (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 27B92189532; Thu, 26 Sep 2024 22:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727388493; cv=fail; b=md5hwzPpRfYihBThkvVJcP8CRLvnZV/6wvsV9dNr/tGYY+9cgtlLWYVnfxjlUS7QJM7atIjeoLuNTbo3bnESAt3wf1Uf/OcdgDZ65Sa3SnhswG7GHkWRbENkoDZnyrF+C9N/S6hFBtAN0W5+DqWqSCwRxntr4h+FEF6OGNhuvHI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727388493; c=relaxed/simple; bh=xQCHUDxSSFv2hklj7OTZlYrdQ4/ub50BGXZ7skDY9Gw=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=Wu5r1kyc3VoDPXC1aYMBW/mEurmedBQLMFbcFfZW54q1YBXrsrimy11xWsghlMwRE2A65yeCQ1uEcjonqapQQZfptcLK+7jnOOSG8UJI7bwaly0AjK5JGWqFN6kR9VhwkITdBwbbPxGlBl3PrF8wLOSB4ilPu/tUTf82yy0g3j4= 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=WwpxerL5; arc=fail smtp.client-ip=52.101.69.70 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="WwpxerL5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XTGivrSmue2XGkQ0RgX9XVirTf7t3jTFLfMHFvcUhfwPqYv9J/3zfDvHPwz0zqXDegGCrEO4WZflhPPsyPYfxJG/a1z6KIxtx9tcYUHE4Gm9Kc1stLxITs8X9L51RcCjNfBckey3t0qYU9yc6COsQBdlW2gNvxdVaercun3zjXmSmPAVGQEAVpcO0BD5ybDCfhKSgrkhwYYzDFlGxHcpPmo5aGo8tFQNW2hyEPZZl21aLy0b8HJ7oUJMfzkklTlWsPSky11YV3PczcWGwXFnHrR1/flSFW2UAzicA2rxc9599oh5jw414zZg70YO8/7W66/3DEpz6CB4TxHcv9vSqQ== 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=2A+AHrCF8kz7jCU/DSOkIRbQdaBgnLw04miwDqH+Y2Q=; b=mvpcZ4+js7W1JOicIFkOv+Y2Llf8vSkJIZJipGB05dFOAyq4O6kqDhcTsaQI1WjulXGmhuj/Q05SRCtNYkb0cJ5zCiVEnHuMK/qcFDa0XtglTprPTUA1ONlPEfRqCmlaBJdoxU0Na+4zRc/QboyNR7q6EUjk95gRTNlOjnBskvpnL5QFeq988OdKyw/97plIuryT4S7Crdgl/zRy90P40zZA5eRBkcoOSggHFRSFuh4V0DhhG1aSuODlnoIc0radFzKnqJAu8BFPWbT7Kj5lRHofaoJhWltB9fTkYOw/uRp15NEV6ZVqfyxHUNbZNMvVT0BttnY9g3liw2q7ejS5Rw== 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=2A+AHrCF8kz7jCU/DSOkIRbQdaBgnLw04miwDqH+Y2Q=; b=WwpxerL5zaqmM3dCJ2URHJcLuiBRKks/gVzoFrq6kDHbvcY88BNWobyL65i2bfahdVsufTek6fTBDRORThUcLMJy7H2rUL5dIH8r2i75gbCRSfbr70ZEnmKv5s6FWgbuXoYC4HB1wvsDgQd12jCOeszdIGpV1yVka2pJ/sUr3W3jREtyyXE40zRTIvYpx98TVScBcua/5HO9OKYg490BTKKUHur7L5ol0emUaBsYy5czguhtPLy8wEU2v933AHH33R1+jaLr5PT8zX69DuoypqcOPK2DDMH5BCzMInw4zkaKJYvh/SmM7x3exNfBJbaU/wXRDAjK6Udj3TUKGytybQ== 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 VE1PR04MB7408.eurprd04.prod.outlook.com (2603:10a6:800:1b3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Thu, 26 Sep 2024 22:08:06 +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.7982.022; Thu, 26 Sep 2024 22:08:06 +0000 From: Frank Li Subject: [PATCH 0/2] PCI: add enabe(disable)_device() hook for bridge Date: Thu, 26 Sep 2024 18:07:46 -0400 Message-Id: <20240926-imx95_lut-v1-0-d0c62087dbab@nxp.com> X-B4-Tracking: v=1; b=H4sIADLb9WYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDSyMz3czcCkvT+JzSEl3DZDMLIyOjVANLExMloPqCotS0zAqwWdGxtbU AQFnrRVsAAAA= 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=1727388480; l=3079; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=xQCHUDxSSFv2hklj7OTZlYrdQ4/ub50BGXZ7skDY9Gw=; b=uuB4rSEkqHP6P7qi1VGEObt5/g4it03QiRazEvtIZy9+rdl9zoOoxgh7EHQL3VCDQ6gZF6JcR rlbOXnCCsIhAzsEG3vcLAesB8AaNBSekgvc8dWyZyT01wyWCLJrX7Cz X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0024.namprd08.prod.outlook.com (2603:10b6:a03:100::37) 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_|VE1PR04MB7408:EE_ X-MS-Office365-Filtering-Correlation-Id: 05f420cd-5955-4720-4f81-08dcde77b296 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|376014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ViRXc1fRWQQH/iBRkn1phsYXZe2enmT?= =?utf-8?q?/IbqMu7y4yd3huIObv29AiwDkb0oURbbubrp0mMALJPQcrch0uD0N+YJhS31m7EaK?= =?utf-8?q?PqO4VYmUjRCZVNkLcQtHxk/P6Pp/dhDXt84eiOkCO6dJsadInYlDFg/SrrV4RXd58?= =?utf-8?q?cTqCgnKSCkKem80zYnTXQKbkIAzEXdFdxmWtWeqyvDKCnE2ZTC+dRvKHym6WPFrec?= =?utf-8?q?thQD45YVQn60np7IgHSc93OLlh93akKjycGKK43VkByNuYT+LyAq02LSxJopcuaXN?= =?utf-8?q?HyCTW9Q7i2wV7jSCqa05SAfc+PVzRlOU3vUmbOS72G+hBvAUQXpR3x17G4S5ju4sW?= =?utf-8?q?r1H8oV57GLyYgehkD1OSBjgaBV33fAKHdUWd9Xwiw9B0oLFGiw/zVT13TglzUAmI6?= =?utf-8?q?8IqjDJkJtUw82UaGl9/Rd83aWOvsxO4G+zrpainbm+cyNAyt/s3qvOIxvbQtBL24D?= =?utf-8?q?ePuLKkq/coqKxhuBNC1cOrcgRrU/wWC1J3va4PVfE3SE2sfqXQTMNSkkTwWSS5Ec8?= =?utf-8?q?SzlJQRd1Rh6EeYZzwtVi31FVuhJbW8s+qgfnrL3CQNtL046e5YPVmazLWqR0zSZ6O?= =?utf-8?q?fxLGDubgTH4Y9qUJOV0AG5FVcVuwJbc2JHYGgUInnxmUTvtcIkkZkKdbEgoV769ak?= =?utf-8?q?APoST5UCvVpK6jRezfsii/aGNTSCDjxrdiHv+06e/40OeqPmPzgxtuPHSQD8aoyZA?= =?utf-8?q?QmI01SZo7BHERktyqRtmT3jHbPfNktxSsgvG8ccXWq6fQVWhV0yDbq73PSJ5PEjQC?= =?utf-8?q?DoZBfqayrR0fz32vgVL5zMaT/CMQRKgiOSP+zd+sVxQJZjJfuQyX5DWhJwKuxGPyZ?= =?utf-8?q?RTeA93prV09KL2nhvImbxxTdfNnxVc5kWDAYyGnCniXYo8O2VJeS69OWRHRsuIr0g?= =?utf-8?q?F/XJjvFaO43uc01/JTIlV+L69OUORkxOqpkHKV/lnVKkWlxx/WCQ772O5I8zZHDJ2?= =?utf-8?q?wx2w/vncLtaK6P77C1XQDzEBDz0QK53M8Tvl1EcdncHEXu1QGZ8dtEUu8fXgx/4AH?= =?utf-8?q?5RB/LdyLwWgSeJZjR9WfNDnmsGwyTdR9erlwR6JdASIghyIEzTtO8h76++jmBo0wO?= =?utf-8?q?i3WvAPnFo8bSiUohwl2cq+K5OtcHIIAzQ2EVrKKSqpUYv6DL8kxD7PuIJeWQf4MCA?= =?utf-8?q?9fL0Fw//p3w/DaZiPzyk64zhXM37eQvRXRKFeyJa6Fd7iKR/14ZQJp+7w2zG6IW/5?= =?utf-8?q?sEONm/Mk3q8rf6OJqoYzKd2Gf02d15ahL2Kwd/T04QbpmvzyNA1P1TDcmgwqlEHYs?= =?utf-8?q?1h/DQGsX22ilhefsu4oR6B8E2f3AEzTiEVq21YB11gMRJlUA3Ocr3c3uRwNy7kJtc?= =?utf-8?q?+k85V8ggKDdohlmDZVs/mIhXvGvs7eibWf3EuTCa+Ur7+Ox0nwqwM54=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)(1800799024)(52116014)(7416014)(376014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange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IxoSPk27WhWSYAG3o4rlxS5gKZU1G3vL+vBg2KqPGSNzvmQPyciZp+dpnPH+ntu?= =?utf-8?q?OHJw1g/gvVT2BJcv8XR8j7DFANA3JJQjtIhQKofn8OpjyDw0UBVc1CTREF+6uC0FZ?= =?utf-8?q?rAZLLI5EPo+bcNocogqytZ27Y8NSXSrV1J8N83iIDGQZofhBF1symsU8AYf1OclqW?= =?utf-8?q?rTvWp3vUByWdwM2CY8hzwdYPRXj5ZXhAgZv6nvaMt/vuRs41MQiD2FOXcyNmLSCKu?= =?utf-8?q?WifaNnc/rPrsOWS4XMOR+e1qbv7nMEBCaWI6JbVOVmnYR9kixSkYsFlUlrpTyFSZr?= =?utf-8?q?PJUGmPq/mKcVdjMzQWl0v0I8f5d3LxUoRvZ0jM6ZaPGHq4WhcjktyqiLKIVuldLe0?= =?utf-8?q?myK/39gzzFtHN7spfoShyXJlyZkLmdgGjfWmttHcKuKKcA4UODsel9RdeBZsd22l0?= =?utf-8?q?BBJRrjk3hi/YWS2I/eERpaxgLCddoIPEMdBsjKgohUxFstpFXj1IZeqKrvvpPyETd?= =?utf-8?q?Fet8wHVbDhBXQaPTfJ4PoYG9y7ICxTjQUhCh5aZvp7+remSTbdcZ9Y5gUx0ESYnCF?= =?utf-8?q?h04Scxpb3dB5+3H/4HzWhtb02Z1E0lSXB2DaYgsd2ntY59BB60IoKup2Z/9ZFeJkV?= =?utf-8?q?S8tCZhM+347EqCnh46hpY0rRSCcB1CGnACz6v813lxqLJa8OSTB22pJw=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05f420cd-5955-4720-4f81-08dcde77b296 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2024 22:08:05.9843 (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: mdFz1IWsMgr6Vvpw4bolxfqrHTY5aQOAqfAz1DRjWdoRGDEgWrveo5ssroIlSt/WblF+I1OJBsXuKLcqId+qAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7408 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 --- 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 | 19 +++++ include/linux/pci.h | 2 + 3 files changed, 153 insertions(+), 1 deletion(-) --- base-commit: 4de3972726b32b9f2a807cd415a15b09044f1911 change-id: 20240926-imx95_lut-1c68222e0944 Best regards, --- Frank Li