From patchwork Mon Nov 4 19:22:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13861882 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2051.outbound.protection.outlook.com [40.107.104.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 942FE18C342 for ; Mon, 4 Nov 2024 19:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730748205; cv=fail; b=ow/m22JFazldGs/lAX4BBfdUr0I4jK6YZ1bwbkk8I6arByqwJtzjiAtFbVIyQ3EpKO+eHJNd09z53WuLNQLWeR4svCJ5zbFr2bGvN+/22D7U+ydzgph+EumAPm5Hlwp+HTXcyV9ki21t6ulHGCVF/uqZvJklnryg6lAQkA2mRvg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730748205; c=relaxed/simple; bh=DdW+DjHukIg+E2C2bGmc4kgrMM/Gdf+3w7SHubv4zWc=; h=From:Subject:Date:Message-Id:Content-Type:To:Cc:MIME-Version; b=bjSMssi03mM8MvkDOz/qzI+80uFX4lCVZN1szogDTO7IYkkY3NQVhE3KTZDGSoWnkcWlk6Z6Hu8vFgaqh9WnFzaE/d4y8Ejjt1cTXQBN4GWNBHSo8IG2pJsthsUVk6wga+Ke+qtcqVR+1K65nC4kOoqpS5xweWbFJoigkSkPZSU= 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=oB9lqwLP; arc=fail smtp.client-ip=40.107.104.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="oB9lqwLP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wNd3ZZ70105+v6CV1pooE0kkCAOp3zJNn3RXV4HPWCDpsyYacOMnqX25Q9G+IVQfVvN2RyYbbgReEUjaI+JRS0uJY4iIUQv+nSc/JbmkXq1Uxagms5jz4KaG69up5Pz+0bQwrjrYhZpDYRV5IVUvPQt344jNU83q9ESV+wZuKgWLp4DRslEKa2cUDUwQVs5no2vTBujFMR1mHqofiY6vBZJbBAGYNGsD+rw/jlpVzd1UggYnamakruO7fD1KBjGSp52nQ0czspOWp/4byh332dRyVL8O0VCFCUfNP4Pnq6TZi9DAbyra9rOm/RwKKNoTlSnAp8dqL4OLx/5y7OtLUg== 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=T67ILxOoSKqJbYeYHr6Qv4wtB6ddMSM3eSk6wgytURM=; b=c9fFzTIwdw46irYyd6Xi/WHmfrpSMn1pXsICviVwYd2NItkCqgt5ydA07jbeifvM1ZySC58znWBejr+vw3/yXVklUKa58H0lF0GKFJpWLGNKO/5IGUGMCJ+uGgDQDIHZ6YCjfTJ2I1lMpzcmElOWOk0sl6CP4XtPYtuQvtqu/IOSsYAKBeomJ2t1OserCgPBSCmYbEno1CKGo5KBTHLehy5ygcPUmoRYOz0xF7WMIdWsrKCs6ECX5mr1OOH1G/rlgXBV9CcXQ0x1RDa1gxz16qHmpMlhK5pDjhItCZCH5SKRl5LhBoYZ8HpM8B+LNlw5fHDWJQoXytjT2T7Y4tlwGA== 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=T67ILxOoSKqJbYeYHr6Qv4wtB6ddMSM3eSk6wgytURM=; b=oB9lqwLP5gWxXjmnZQgTrJLhYQTROCr0wLo3A7TrCaQ9hvK7Wjv4YHe7fKAzkb6l82ygJ0+6S8L61/zY6X4RCKkQ7z5F9xsHR7wco47DcQM+2WzRC+dBVnccbAThV3HlQQr43+R4c28sSHDUNFiQ2ReqgjydljRDH74LU1X+iJB3Wz9a11wOicY1fqHVTxn8oENtUyn2m7OKmghWhxN5ofAfi/oU1vI3RZtTPmMceHhegsxc4MzgCTaPaPr57ZIwyrTg1/EYeS/gLewhspqA/QNp92umqbt+3zsXEYJucMaFhiX8T83xuTbqY7DtmpduxlwX5EEwYdKkMS+6reapBA== 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 AM7PR04MB6886.eurprd04.prod.outlook.com (2603:10a6:20b:106::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Mon, 4 Nov 2024 19:23:19 +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.8114.028; Mon, 4 Nov 2024 19:23:19 +0000 From: Frank Li Subject: [PATCH v5 0/2] PCI: add enabe(disable)_device() hook for bridge Date: Mon, 04 Nov 2024 14:22:58 -0500 Message-Id: <20241104-imx95_lut-v5-0-feb972f3f13b@nxp.com> X-B4-Tracking: v=1; b=H4sIABMfKWcC/23NTQ6CMBAF4KuQrq2ZTn+grryHMaYtRZoIGFCCM dzd0YVC4mIWbzLfmycbYp/iwHbZk/VxTEPqWgp6k7FQu/YceSopMwRUYNHw1ExWny73GxfBFIg YwSrF6P7axypNn67DkXKdhlvXPz7Vo3hv/7WMggMvIRiEIi+98/t2um5D17B3x4gLJ2HpkJz0R pncOy2tWzv5dYJm6SS5XIMN1tO3wqyd+jkBYukUOajKyjqsYq7Vz83z/AKSCj5NSAEAAA== 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 , Marc Zyngier , Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1730748193; l=4036; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DdW+DjHukIg+E2C2bGmc4kgrMM/Gdf+3w7SHubv4zWc=; b=BeKbg9xkiLhYkWkEsP79+dRCxuyXlZ5GLgy/19ntQ587tMW08rGzet25gKQxwNlvHMViq9GwY zf6iTeV9LQSAfztzhTkBttFOJIN88UJYRhKVx1u7CDpCIFoxQy/w9iM X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR03CA0025.namprd03.prod.outlook.com (2603:10b6:a03:1e0::35) 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_|AM7PR04MB6886:EE_ X-MS-Office365-Filtering-Correlation-Id: ddfa2b03-8707-436d-d452-08dcfd06239b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|1800799024|376014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?LfOr6LJRiA5dJtIMe8h1Irv/DVK6Mzc?= =?utf-8?q?NSxe0z3ndw8kFf6tDrFDFAoNwWk4b95QrEEXj9JEmOP5ea4tvHcNcuRMxKRRfwIus?= =?utf-8?q?sbCyjs9NfY6A28EdYbnp2m5dkRVd9XiAeqZZWiUOl3LEIp8fmH/pG7fHm3ePmydt9?= =?utf-8?q?1IpIzWRP5uEC2oyInYxxScUlf+JWSV200xS485MdZN0kblaPI36fNhAvqlbVLjFYT?= =?utf-8?q?wE4uF+J5ht5v6xmUFhTkGwEurAHpB7dz+CW5e0aVblGYf3R5s8pZitQM+iqi6KaM0?= =?utf-8?q?jmHyHd5PtXyBmZxVyeV/2oxOF684nDDnpPHbFUn1sr61QE9AU6u373f20+vKs6GmI?= =?utf-8?q?XCQgPJ+rJnc0q438rl0rV5XTGN9wnTgfgoLTCP4pKWunrgcQZfhD9fCYF9xpvEig0?= =?utf-8?q?nj3Qu9mSoml7HkakG/MjNrT8FlFWBqmcv6+uNyhg/vGEcBKY0VxrILd9KhVqO7+sv?= =?utf-8?q?o0/mI8YV1LpIrHLec9GOg5Vuz6RCQZynILMvztw5nUoNyiLDDmxcXHJgFuW0emyhZ?= =?utf-8?q?7dvIgK2ZXhuLFHQnNIwikxG53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:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(1800799024)(376014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?guIPCusOw7Rk3WIKKTs7XI+yjEH7?= =?utf-8?q?4yylza+RUycbhP00c1+PBlfET3cKrcrpbgDXyeOYDnkR+V7OfEw0ybCFrpex290/6?= =?utf-8?q?34jQWn9td4HkNeQyZH0vt4a23mknocn4bJF0wmF98Zbx/tg7hHdj6l34CjhAAdn7J?= =?utf-8?q?+Ywsks5WkOs2GX9f2da+rGv1/3lbUVAHMgtdmpk9EjTii45PRnfzOSpxc8+kjt75D?= =?utf-8?q?mNP/TJYeldFApiWKiNMA5g4Ned9Q3ln6WU3wDjFEJNvDwi/aspb2W94fDUg6/H9DC?= =?utf-8?q?K5lULrku2zMkOH5COtkveCRtA6AOqqP+wz0mS7ERMVXOmMBfijwLZhlSBq/024Fww?= =?utf-8?q?C70oCFglJTvMG0Wt02gZfG39IpmqZtsBDitrizI8aDl0vGvHZ18ZbFjdvQ3AUFkVr?= =?utf-8?q?lioPySx9kQKN9x/kVFihZCHxP2hT2z5W8uLH7m/gMQQZ+LKGW4Vz/LpLsDsPv20QA?= =?utf-8?q?+BEsm6blsX8bdxPtIOWGp0VGumJVjFNFaDOZLmoe7PQ284B2XYZ6tq9gYJfVFFwOj?= =?utf-8?q?xuGhfH/PFklz0lSt4OKVM2LT6Dv1BMy32IiCfS7pr6JRGrR23SKbvz3GQG+xP6rZR?= =?utf-8?q?HlEszWR+nLK+y8IWKC8q4CFei1IPlx1K2i3AOczh6k5Dm1NMfliBHY7LJCHvhPjlp?= =?utf-8?q?WOHwnkF8J6K9XOaRBc6PTpAIxmUE7d+DSVvvxXAkTu0e/c4bfqKNMVBc1Xa8eLrHn?= =?utf-8?q?plI4eH06ed2MAUoX8kgNyWmWLtjctB5meMHYB1B46oOwdW0XlJqLFZsaJ9yADudtU?= =?utf-8?q?vXDzr4knY4Fh8wtBQVQB83eVbULEtVoKSujWBXIioPUGOyeOvFdlgT5fDnM8JP9vT?= =?utf-8?q?jrJK3t1BAEVspfgcuMusTKXhMblCea5Ek9LgmSaC+u9M4aHW26aZGdFJvvmg0Rdt+?= =?utf-8?q?dyJsFo7Yk741i/yTuhWisdRREzpbz3L1P5X5c+LvEKCDR1CAonRVf/Ox0OfC/UT5N?= =?utf-8?q?MupB35ctAXpVqtWn5/8lPoZBKFRXHlT6Yst/F2/NTbe/Oqf1Nmk1KOAnFKVUgbvNg?= =?utf-8?q?oV4oSSDY6eRxi3jRNEOlevMo0LlKJKzr75WEQdjFwSV0M9B/3P9sqm5mbb36g5n29?= =?utf-8?q?gSTkHexzMdUcMzP4fMuzdD/ogvJ4bFg0YHsw0pXz+D/jwg44FZ/gS4CgQqSYVR+5l?= =?utf-8?q?gZyMhjYk3qB7Pn4XKJVm/2v+Z2HmV5zKAC0nDJWhT8Q0MB3kNaD+OU3iK6eALAo4A?= =?utf-8?q?n2D3AvgPMJfmpY9stRL6OgEzW2dm3VV2mKrRKJ8QTta67Y6X14Z8MRdeUKvJDzjnm?= =?utf-8?q?iXdgQt5nRk3kXDp15eOdw9Cw88o/UQuFn/QH52R7WXSpaneWmlY4b02kTdcHreN5J?= =?utf-8?q?TIGuRc71TJ1Ll77NI8PN/8PCFy0NB6fjjxh86g5D7tozVmvSKM8i7+OroAPsLylk6?= =?utf-8?q?hS/dXfjOE7fTqOlz8E9kWGi6dEBUkPqYvDSlF532T4eMzLk3tXtaBYWQOsjtJLVWk?= =?utf-8?q?rWh7qC0oDwtxy0N5kq4Rinr3gzcbVi6AS0ak0hY0bWkHsYtO4KEo2OKU=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddfa2b03-8707-436d-d452-08dcfd06239b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2024 19:23:19.0424 (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: R+dDxNLlHek2M9MxKGsKmQQGhe8BFoxoh1UJP4hdYckWacucUdJRQSQLvNG2BBzW3WyEQ0wzG17cBFeL0BnEAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6886 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 Cc: Marc Zyngier Signed-off-by: Frank Li --- Changes in v5: - Add help function of pci_bridge_enable(disable)_device - Because big change, removed Bjorn's review tags and have not added Marc Zyngier't review and test tags - Fix pci-imx6.c according to Mani's feedback - Link to v4: https://lore.kernel.org/r/20241101-imx95_lut-v4-0-0fdf9a2fe754@nxp.com 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 | 176 +++++++++++++++++++++++++++++++++- drivers/pci/pci.c | 36 ++++++- include/linux/pci.h | 2 + 3 files changed, 212 insertions(+), 2 deletions(-) --- base-commit: 06fb071a1aefbe4c6cc8fd41aacd0b9422361721 change-id: 20240926-imx95_lut-1c68222e0944 Best regards, --- Frank Li