Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1143803lqj; Mon, 3 Jun 2024 11:23:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtCW7cxiAJfiDmObKTbqGGTZZQjkYlh9Q62Yzi4nRy//6WJU8uVVm/2om4T6peiXuK4niI6XL8Ci2EjPV2e9HOXrymeOdyQwLqz1/xMw== X-Google-Smtp-Source: AGHT+IH2MbFd0KS+mY/hDN7W9YvLW1a83UaUNTqZIT+44rouvXKEiB9WPJ+XJUWAozwHmUnilliP X-Received: by 2002:a05:6358:721:b0:19c:c09:2430 with SMTP id e5c5f4694b2df-19c0c092588mr259335655d.12.1717439006795; Mon, 03 Jun 2024 11:23:26 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3542e3b69si6945452a12.181.2024.06.03.11.23.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:23:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="ND/jK1fF"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-199555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1A8F7285E27 for ; Mon, 3 Jun 2024 18:21:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DC8C1386B3; Mon, 3 Jun 2024 18:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ND/jK1fF" Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2069.outbound.protection.outlook.com [40.107.8.69]) (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 F126C12F373; Mon, 3 Jun 2024 18:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.69 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717438906; cv=fail; b=Bx/PjbrFAsa1YwghgDftgJuvfVPVn9YT19pwkkxH/1LgO0dDgbbL9y9l7RJMAuT8eRifYlpQPfncdNQK2uDGpoU6rOAWUToS/iru0mOkRyM6kbCPGC5fz3A6lziF6cnjh6FdZUq30IIkST7ENLbHekf/MDiU83+Rec3grwd6kfY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717438906; c=relaxed/simple; bh=AZfUQDd/BrY+t+8i6oGAnsRqajVLd4dbWiYNkmgn0Pw=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=rOD+X0nL8Lvf+pWxTxB3AnM2ZTB87+oT2FOy2PYEsd2hsdTNqkuSlJxbQLOirzlN9CHyk6azK+ph2lBlA4T5kt2K+DCfAZnfAyWmpPQ9WzOpEjXaVwABQ2OlCrKe4q/GlEb8lJgRY9MlegevquwfamLNKED6XloliMitR0WTNeg= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=ND/jK1fF; arc=fail smtp.client-ip=40.107.8.69 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=InVbNEhJujwBfKQvcWB0blCg2Z88UeTO4FTWhttG7ZVq28tpHmnahneL/BHXsTBeA9WCBtkCQWzohmfp7H16Lo1noNuaPb/xaidMj6baxsb3BMmdGuszbDRyh91YLT3SxtEvYHtIoptCh6tktDPTOrRgGcY2yjeht/hYhrxiesgcVtMNpHhUNPTkh+/GFHHVSan0m6jbRpvLzVOs5k9CPDbYmy/041/x0HKA5PIPXftJLW1U1jlHRSlYbAbZd5t60lonKF1W90QemWDPciiElSgXsuopBlmPBul/OOipjyiKQde6AKUGnp4pMfavJ1a5v9cuYmY7v5Gq938hhGu54Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=YH/unmk0dE4FdvzV+F+MMF9nlm977QDqf28l6h2+SnQ=; b=i7wuFAw758nER3pFQzA3Y00C3N8UZfohuv/HSAHRLkluEBZhrg6vpBr8L4icDYN3Sb9TmpDJqXcxYbvElj0WofbuxLs0Ko7o6oWWIuBlre3bC3NlLZHfayQbUFJi4AqmLmuRNm0tyBTMp0DYsddv/WgJX4LJn0057fMWMSxZwxTTUiXFSR+NICYCrZvKta2Gh+Kz3gn5wl//xgNIn+dbmLVhdbZgXIZEaOEbxsf05c4mStPwD7az8TJsTmUvQWagTTdA0mkqZfkH31nU7A6QKvk/QHEGn9mc/d7i2HvjuDGP+PGUXHtNWazgaGKYFVpP1IKOu9uL3t8FAy+mugPzPA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YH/unmk0dE4FdvzV+F+MMF9nlm977QDqf28l6h2+SnQ=; b=ND/jK1fF5Rf2hdoGKd+gzdwrMrlUBpkBJbwEphrmmccBap2Skgon7sAv82t1yRvJ605a2VtfPqj4KMRfp35UnoafYz2l7KXnLgDZUDkubvEjXesQRcQDvS6xddhGm0p4fxhvye2yita5dOPJMRSfH6JWjckO+9sWPaKZFR736v8= 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 GV1PR04MB10704.eurprd04.prod.outlook.com (2603:10a6:150:205::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Mon, 3 Jun 2024 18:21:40 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.7633.021; Mon, 3 Jun 2024 18:21:39 +0000 Date: Mon, 3 Jun 2024 14:21:27 -0400 From: Frank Li To: Bjorn Helgaas Cc: Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Philipp Zabel , Liam Girdwood , Mark Brown , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , linux-pci@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, devicetree@vger.kernel.org, Will Deacon , Robin Murphy , Joerg Roedel , Jason Gunthorpe , Alyssa Rosenzweig , Marc Zyngier Subject: Re: [PATCH v5 08/12] PCI: imx6: Config look up table(LUT) to support MSI ITS and IOMMU for i.MX95 Message-ID: References: <20240603171149.GA685507@bhelgaas> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240603171149.GA685507@bhelgaas> X-ClientProxiedBy: BY5PR17CA0013.namprd17.prod.outlook.com (2603:10b6:a03:1b8::26) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|GV1PR04MB10704:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d8ff925-b581-4d94-b270-08dc83fa02fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|366007|1800799015|52116005|376005|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?a+H2o8+BumgBL2kecaNIgXLszu9w7HedOX0uoXYsXmkufY1urM3cqPwMm4zo?= =?us-ascii?Q?MFBbMGXtD/AjCpObJxuMF9N4J2oC1UeikY0cxNxRff2/yjv/KWpgF+ThKVgs?= =?us-ascii?Q?gM+gnJ9+8CGlsuF+Rqxg623xAawsdq792M6y9vvcZgc2B7LGcgS7gYsF6tjg?= =?us-ascii?Q?VUP9DfVaWe+dnzu3SNgGgkkaaken6V6qQw7dX2m28B8n3iidnFjxf+BrLA8r?= =?us-ascii?Q?ChfzmR+eWm9cK8eve0qSjGC+hpQg7/HUDwgTCkiItdErdnZ/x+cLEnn9MXAt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5aTaiHAXRZjGiWKHta/aOspla0lqV89J+a?= =?us-ascii?Q?5VYhHtDxeulInjnQjjSRR5PHG6Id//fpgaU5Fo+l40031gnxfMu3bIW2jezw?= =?us-ascii?Q?ahHlg9/phPLTyKKLNZ2a6h5A9E7JBbv9OGAoIRA9BvjsPJnbTVYpeOYGuzoE?= =?us-ascii?Q?yX8lUJm9XaJU6efm64Vzoj9uGUEeUCAdBp1i0uW5fFSIdw=3D=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:(13230031)(7416005)(366007)(1800799015)(52116005)(376005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?w3HmdY6mb5gI2qrctTIBUVTwYGYBQG/Kl0l0iAF2zG9tAB5nN5idYoZGLQy3?= =?us-ascii?Q?75P+ZMXST9WmzNQm6d9zq2BEELInQT2u/p5ndht37gm6PooudOteMM1jCUgL?= =?us-ascii?Q?JbOnA0Xib9lgfOgys9OUZTnrw1NlUPv56+OIrVo4MMxRoQcG0pc/YFJfHx+M?= =?us-ascii?Q?5+T7TE5caL4qEEAC2+wYm75HSQZlYqVT20sE+m4UYlfhCnOXqgBtSP4BL4FB?= =?us-ascii?Q?Kz5TkQKZlNvfiRpJkgEE6xb08rWnPkEPWtPQ8MOJxCNPv3wyelZctBBBi1x9?= =?us-ascii?Q?8gF2Nc+7mEt1zFbfmx4TNf61ILdsv2NCJUq0rQFHJiejCvrptAyc/zRQ2Sin?= =?us-ascii?Q?v18hU7nHSUvkiM9uNc+sxvh9StjU1I72DL+65ObkMPFmhKltk5CzyAcHGBdw?= =?us-ascii?Q?GapVDZY9C4K+eAYHB159F+aMUkCwQYjaH9B2Rly7lOkYo3/1qjVHquVRm7Vn?= =?us-ascii?Q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6uI7a?= =?us-ascii?Q?y2AxrJpFpdhjeTZ+Mc1tmSJOPpLHT3G1F7+4mI/SLzY6vRjINr/1uTx+R6PF?= =?us-ascii?Q?6LKp7UbiTkE7/qpu5gvlaZOtN/4jv4Zm6B1UcegnbOHnnIg0d04h+RvK95SH?= =?us-ascii?Q?OyLwjJzYXicdc/B7g3TkDmL7buJRXmu6tOmCZEGY8J6qaChSd2LIGqNgPMoe?= =?us-ascii?Q?89aZs9M4ssBJ12ols22NeiqYpaTaHKweiyBck8Yv?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d8ff925-b581-4d94-b270-08dc83fa02fa X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 18:21:39.8055 (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: NitoS2m/LAgumKsmc0OGJrGWip0EfonmBY4fkmjadqv6L4oLH1VkBrqOOb56ueqjf0udhO0kXzUC6uh5dZMong== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10704 On Mon, Jun 03, 2024 at 12:11:49PM -0500, Bjorn Helgaas wrote: > On Fri, May 31, 2024 at 12:14:18PM -0400, Frank Li wrote: > > On Thu, May 30, 2024 at 06:08:32PM -0500, Bjorn Helgaas wrote: > > > On Tue, May 28, 2024 at 03:39:21PM -0400, Frank Li wrote: > > > > For the i.MX95, configuration of a LUT is necessary to convert Bus Device > > > > Function (BDF) to stream IDs, which are utilized by both IOMMU and ITS. > > > > This involves examining the msi-map and smmu-map to ensure consistent > > > > mapping of PCI BDF to the same stream IDs. Subsequently, LUT-related > > > > registers are configured. In the absence of an msi-map, the built-in MSI > > > > controller is utilized as a fallback. > > > > > > > > Additionally, register a PCI bus notifier to trigger imx_pcie_add_device() > > > > upon the appearance of a new PCI device and when the bus is an iMX6 PCI > > > > controller. This function configures the correct LUT based on Device Tree > > > > Settings (DTS). > > > > > > This scheme is pretty similar to apple_pcie_bus_notifier(). If we > > > have to do this, I wish it were *more* similar, i.e., copy the > > > function names, bitmap tracking, code structure, etc. > > > > Actually, I refer apple_pcie_bus_notifier(). I can't direct use apple's > > implement because in imx95 have difference PCI host controller, another one > > is PCI ECAM netc controller. At lease function name should be similar with > > apple. > > I know it's different hardware, so obviously it can't be exactly the > same. These are the differences that looked possibly unnecessary: > > - registering from initcall instead of .probe(): > > apple_pcie_probe # .probe() method > bus_register_notifier(&pci_bus_type, &apple_pcie_nb) > > imx_pcie_init # device_initcall() > bus_register_notifier(&pci_bus_type, &imx_pcie_nb) Maybe apple only one PCIe controller with multi ports. One nb just register once. If there are multi PCIe controller instance, second bus_register_notifier() report error. Of course, if you like, I can use global reference counter to handle this. > > - naming BUS_NOTIFY_DEL_DEVICE function: > > apple_pcie_release_device() > imx_pcie_del_device() Okay, I can change to release_device(). > > - tracking entries in use via bitmap vs scanning hardware for > invalid entries: > > bitmap_find_free_region # apple > > imx_pcie_config_lut # imx > for (i = 0; i < IMX95_MAX_LUT; i++) > regmap_read(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA1, &data1) > if (data1 & IMX95_PE0_LUT_VLD) > continue Okay, I can change to use bitmap. > > When we fix a bug in one driver, it's easier to check whether other > drivers also need the fix if they use the same structure and names. > > Bjorn