From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCCEFC27C4F for ; Fri, 21 Jun 2024 22:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To: Content-Type:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2B3OA8YmVStHZQ7GGH9WJx/6/DKSSTnpsT84zN8EtQY=; b=BT2s51uSPrRl1tUy/1KG8Ec3fW vFDHAd7zZzD5fbQIZW+cIW8gIj32uLiEM2kneLPNnSLSc6hUHFWOTse/GTaURZdch9QcH/FKcXNBz 4Cb/Epicn4THFb3kOByxCsufo7Zd/pPxedlqxob2DPssspoC1PrnqzXJRRujnFzO2S+3yOnH3ZXAg /8qPBBZoTDNNhZnrvjuIzXytd4pM+koqEHNvrWAVPb0cd4KYnBfZ7C1OOCM2yef9j02ZeU2FGXw8S 5IOOdd4AmHuD6pdTEGUXi+twvRMGbif6A9KN22t0EHLGiUpKX1eq4fZ+Cvx1r5dzKc7wgUZwj38iN GPAz8CBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKn0h-0000000AoEd-1em2; Fri, 21 Jun 2024 22:45:35 +0000 Received: from mail-am6eur05on2060f.outbound.protection.outlook.com ([2a01:111:f403:2612::60f] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKn0c-0000000AoDS-1fQt for linux-arm-kernel@lists.infradead.org; Fri, 21 Jun 2024 22:45:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kRMt+4uVbbd6wDohQRJDqgwTsNYGUm43tXMzin60arGX0k8/q9XBdG+9jY4zRl5URvMuKKfhlg/t9aFkHp9DOz7d9Y3HwdZwE+EyJTTC+aZpixHLlG2cmo/uKrBaIKHY087CkgJIUYQiCt8A9KSQjAf+weytaIpCuG4s+P2NPZTU+WHaVUWMbpn3TUYKp/3/Ake077B6TxL1Mn8I6j8NwplXRLB/UGebzahtPnpKUynqpKhCD3RvVE6iG5msSkcZauIb0JIlXhtmp8yNJQBuQjt2tLdXpgKoihaYkBh/JOWhNHRT/0hi6UqtYJ/DDUG/7jVN97DVu89N49/3Swab5A== 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=2B3OA8YmVStHZQ7GGH9WJx/6/DKSSTnpsT84zN8EtQY=; b=jkPAvEqx+pAf5KlH08F1jEuR7AUgQHy7Sjk1tuPPxP8/af8fx7fEZo6JHVcPuUl0f+h+RG41STF+CUJhHTUAkxTklOVAqsDKa803LjyvOCyy9zCGs/iYeFlwo5LdWoTLt7SXJnE1VyuoLjH7ooP0i+Eq2FgNpvol3Wy01tdAtA9wcfWDctxxF09wKUF8Zy4c6aisRUsryGeB9PGANwhsL5JGtTLpMS8ze7krcRkA+U7UchorqfezIuKk20FLzHKFytCJTikletYAVfAjY/pZo1mT21vU0QChhe3xeboaIXTBj0O3Uvf50uZoBYAyZoENhdvlZHU3+4fpFrF0Z/x4jg== 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=2B3OA8YmVStHZQ7GGH9WJx/6/DKSSTnpsT84zN8EtQY=; b=V+Ol/6q1eH6Lrzs0zUQVlgBIJB/IEVWjAUFHCq1cLF1eqo+HbDU6GtxolruZVLHKGuwdi1g3wG2wm3oK33mETxYW9ENu532YtX+6rfgCdALSmCUi4Yk1VdeLUXry+rC+wlXDvXR7zjkFLXLncK4WZAXiLV/W1hCoE7CyC2v4UmU= 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 PAXPR04MB8879.eurprd04.prod.outlook.com (2603:10a6:102:20e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31; Fri, 21 Jun 2024 22:30:00 +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.7698.020; Fri, 21 Jun 2024 22:30:00 +0000 Date: Fri, 21 Jun 2024 18:29:48 -0400 From: Frank Li To: Bjorn Helgaas Cc: Robin Murphy , 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 , 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: <20240613224125.GA1087289@bhelgaas> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BYAPR21CA0004.namprd21.prod.outlook.com (2603:10b6:a03:114::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8879:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e72bfce-6b2a-4cf8-b0ec-08dc9241aff4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|52116011|1800799021|7416011|366013|376011|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8YFSr9QyYf3vtv6ozrqcFdJy2HxSn75PtMCh5q2XK2dISYwkZldaBTE4BNXB?= =?us-ascii?Q?U89m3ABM5/NvUoAvsFR3rqBsc9jOPppSfmvDCAudW9U/N4SRvyzmEdv3f8Ls?= =?us-ascii?Q?u4CWJnHM/iUM7JhxOxjkM86ST76eW6Sdl1eVXiSX+n21qqYz57LcO4mpURmX?= =?us-ascii?Q?Uwa+S/E4udzpiNEfMvGqYQXSTHCrCOSMy5uoePJ14yagnrNQ/zLd3Fk2d8TZ?= =?us-ascii?Q?Q252WK3/uUL2i8EZ93C/yQv//YIOiPbjGCd4u9o8JNNpEaR6kZ1iNYY0OrOc?= =?us-ascii?Q?NS53CS6zNAmYh0xxqxpEz9d6cBU4CFPlPdO5+e0JAyDPO9Fx/auVMeBz6kpy?= =?us-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2PNMfhBEcSdqt40aT+7tB?= =?us-ascii?Q?v1SUme2JYCScuD+rKruf92xO79Pnc1lDznlJt7RQOTMn/uWFahfNyHMpGeSS?= =?us-ascii?Q?XVTfnih+9CIJ5oge5c6+VDLQsklGzAotcMwnE4kuTzVbN6uSvOQh/XDg+CiX?= =?us-ascii?Q?0EWCtag=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:(13230037)(52116011)(1800799021)(7416011)(366013)(376011)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?WYdD7AhM+WWtG0DlTohIb4SviBDpfjfgxuir2hxQhOSkh0LN40OPeuvN5HQ7?= =?us-ascii?Q?ZTY0QHPaH9JWWYr35t7OXLJL3PqvcMJcjROcO4wEBZdTg2ZwT3R48B6swZAJ?= =?us-ascii?Q?GQh+c+ckjWQZdZiXebKU8jueC7q9Qz17DTP4LJ8nX+0ZqLVRkyzVwp/+sCO8?= =?us-ascii?Q?WZpFEgShiACpbX1NrqVQzf4NKFwFX8Um/W625zgy5CpTpxBT+Jd8L4ApUIlI?= =?us-ascii?Q?SX5LjUOlK1wqQovAGZ1nMrO5Y2sJG+FIK7kcYCyezRaH4dEWy7x7g1XPnOnc?= =?us-ascii?Q?L0b7sY8AIMlSoSpkYIeo5SEu5VjIhNQQn34vqCUD76vkeiz2q+hP+8n7BemE?= =?us-ascii?Q?yrcMuNCSqrP3o+ARURvAM86wGMjWzTXjWRrkywl8STJ3mtvVVIENfoR7kWTY?= =?us-ascii?Q?Qq+vlCW/NM0ZoVOVs/ELIub/jij20iuUp16UNCP+U3TjqbIStbYs+stHvQNF?= =?us-ascii?Q?YXSxHZcOPdL3vh1syg9UIR9GYu5kOe2fJtkC2/qUxPLLtLTdH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X3NUjRazy6IJPm8/4nsFNJI6XA7qc1DLx2UqK4tZ+B0ThRLS?= =?us-ascii?Q?ubv2jikBnEzaHT+fwvD6Oqh8X93mvKG7WEg5cGWtW3rHRC3Gj7gVRrt5zlTs?= =?us-ascii?Q?f0Y9fa7IvS/Ic7s6TTBRnU9UcTd7oXM6uTSEx6sijer9MCmIniIheAIP3F/9?= =?us-ascii?Q?Lw7V7GnTFLSa26fQURAoneCZnA5NbA9qHHkKNJol?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e72bfce-6b2a-4cf8-b0ec-08dc9241aff4 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 22:30:00.3744 (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: VbYCRD7xNQjZ9JnS9Psu5C38IE8XTkRejfMWZVMSmxpwtQ+UY9D4RoXPLlJ5Kh38ShZW6zMKy4oqACqyvef6Ig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8879 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240621_154530_784315_B075464E X-CRM114-Status: GOOD ( 55.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 17, 2024 at 10:26:36AM -0400, Frank Li wrote: > On Thu, Jun 13, 2024 at 05:41:25PM -0500, Bjorn Helgaas wrote: > > On Thu, Jun 06, 2024 at 04:24:17PM -0400, Frank Li wrote: > > > On Mon, Jun 03, 2024 at 04:07:55PM -0400, Frank Li wrote: > > > > On Mon, Jun 03, 2024 at 01:56:27PM -0500, Bjorn Helgaas wrote: > > > > > On Mon, Jun 03, 2024 at 02:42:45PM -0400, Frank Li wrote: > > > > > > On Mon, Jun 03, 2024 at 12:19:21PM -0500, Bjorn Helgaas wrote: > > > > > > > On Fri, May 31, 2024 at 03:58:49PM +0100, Robin Murphy wrote: > > > > > > > > On 2024-05-31 12:08 am, Bjorn Helgaas wrote: > > > > > > > > > [+cc IOMMU and pcie-apple.c folks for comment] > > > > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > > > I don't really know how stream IDs work, but I assume they are used on > > > > > > > > > most or all arm64 platforms, so I'm a little surprised that of all the > > > > > > > > > PCI host drivers used on arm64, only pcie-apple.c and pci-imx6.c need > > > > > > > > > this notifier. > > > > > > > > > > > > > > > > This is one of those things that's mostly at the mercy of the PCIe root > > > > > > > > complex implementation. Typically the SMMU StreamID and/or GIC ITS DeviceID > > > > > > > > is derived directly from the PCI RID, sometimes with additional high-order > > > > > > > > bits hard-wired to disambiguate PCI segments. I believe this RID-translation > > > > > > > > LUT is a particular feature of the the Synopsys IP - I know there's also one > > > > > > > > on the NXP Layerscape platforms, but on those it's programmed by the > > > > > > > > bootloader, which also generates the appropriate "msi-map" and "iommu-map" > > > > > > > > properties to match. Ideally that's what i.MX should do as well, but hey. > > > > > > > > > > > > > > Maybe this RID-translation is a feature of i.MX, not of Synopsys? I > > > > > > > see that the LUT CSR accesses use IMX95_* definitions. > > > > > > > > > > > > Yes, it convert 16bit RID to 6bit stream id. > > > > > > > > > > IIUC, you're saying this is not a Synopsys feature, it's an i.MX > > > > > feature. > > > > > > > > Yes, it is i.MX feature. But I think other vendor should have similar > > > > situation if use old arm smmu. > > > > > > > > > > > > > > > > > If it's really necessary to do this programming from Linux, then there's > > > > > > > > still no point in it being dynamic - the mappings cannot ever change, since > > > > > > > > the rest of the kernel believes that what the DT said at boot time was > > > > > > > > already a property of the hardware. It would be a lot more logical, and > > > > > > > > likely simpler, for the driver to just read the relevant map property and > > > > > > > > program the entire LUT to match, all in one go at controller probe time. > > > > > > > > Rather like what's already commonly done with the parsing of "dma-ranges" to > > > > > > > > program address-translation LUTs for inbound windows. > > > > > > > > > > > > > > > > Plus that would also give a chance of safely dealing with bad DTs specifying > > > > > > > > invalid ID mappings (by refusing to probe at all). As it is, returning an > > > > > > > > error from a child's BUS_NOTIFY_ADD_DEVICE does nothing except prevent any > > > > > > > > further notifiers from running at that point - the device will still be > > > > > > > > added, allowed to bind a driver, and able to start sending DMA/MSI traffic > > > > > > > > without the controller being correctly programmed, which at best won't work > > > > > > > > and at worst may break the whole system. > > > > > > > > > > > > > > Frank, could the imx LUT be programmed once at boot-time instead of at > > > > > > > device-add time? I'm guessing maybe not because apparently there is a > > > > > > > risk of running out of LUT entries? > > > > > > > > > > > > It is not good idea to depend on boot loader so much. > > > > > > > > > > I meant "could this be programmed once when the Linux imx host > > > > > controller driver is probed?" But from the below, it sounds like > > > > > that's not possible in general because you don't have enough stream > > > > > IDs to do that. > > > > > > > > Oh! sorry miss understand what your means. It is possible like what I did > > > > at v3 version. But I think it is not good enough. > > > > > > > > > > > > > > > Some hot plug devics > > > > > > (SD7.0) may plug after system boot. Two PCIe instances shared one set > > > > > > of 6bits stream id (total 64). Assume total 16 assign to two PCIe > > > > > > controllers. each have 8 stream id. If use uboot assign it static, each > > > > > > PCIe controller have below 8 devices. It will be failrue one controller > > > > > > connect 7, another connect 9. but if dynamtic alloc when devices add, both > > > > > > controller can work. > > > > > > > > > > > > Although we have not so much devices now, this way give us possility to > > > > > > improve it in future. > > > > > > > > > > > > > It sounds like the consequences of running out of LUT entries are > > > > > > > catastrophic, e.g., memory corruption from mis-directed DMA? If > > > > > > > that's possible, I think we need to figure out how to prevent the > > > > > > > device from being used, not just dev_warn() about it. > > > > > > > > > > > > Yes, but so far, we have not met such problem now. We can improve it when > > > > > > we really face such problem. > > > > > > > > > > If this controller can only support DMA from a limited number of > > > > > endpoints below it, I think we should figure out how to enforce that > > > > > directly. Maybe we can prevent drivers from enabling bus mastering or > > > > > something. I'm not happy with the idea of waiting for and debugging a > > > > > report of data corruption. > > > > > > > > It may add a pre-add hook function to pci bridge. let me do more research. > > > > > > Hi Bjorn: > > > > > > int pci_setup_device(struct pci_dev *dev) > > > { > > > dev->error_state = pci_channel_io_normal; > > > ... > > > pci_fixup_device(pci_fixup_early, dev); > > > > > > ^^^ I can add fixup hook for pci_fixup_early. If not resource, > > > I can set dev->error_state to pci_channel_io_frozen or > > > pci_channel_io_perm_failure > > > > > > And add below check here after call hook function. > > > > > > if (dev->error_state != pci_channel_io_normal) > > > return -EIO; > > > > > > } > > > > > > How do you think this method? If you agree, I can continue search device > > > remove hook up. > > > > I think this would mean the device would not appear to be enumerated > > at all, right? I.e., it wouldn't show up in lspci? And we couldn't > > use even a pure programmed IO driver with no DMA or MSI? > > Make sense. Let me do more research on this. > > Frank > > > > I wonder if we should have a function pointer in struct > > pci_host_bridge, kind of like the existing ->map_irq(), where we could > > do host bridge-specific setup when enumerating a PCI device. Consider some device may no use MSI or DMA. It'd better set LUT when allocate msi irq. I think insert a irq-domain in irq hierarchy. static const struct irq_domain_ops lut_pcie_msi_domain_ops = { .alloc = lut_pcie_irq_domain_alloc, .free = lut_pcie_irq_domain_free, }; int dw_pcie_allocate_domains(struct dw_pcie_rp *pp) { struct fwnode_handle *fwnode = of_node_to_fwnode(pci->dev->of_node); pp->irq_domain = irq_domain_create_hierarchy(...) pp->msi_domain = pci_msi_create_irq_domain(...); return 0; } Manage lut stream id in lut_pcie_irq_domain_alloc() and lut_pcie_irq_domain_free(). So failure happen only when driver use MSI and no-stream ID avaiable. It should be better than failure when add devices. Some devices may not use at all. How do you think this method? If it is okay, I can try research how to set LUT when do dma_mapping(unmap). Frank Li > > > > We'd still have to solve the issue of preventing DMA, but a hook like > > that might avoid the need for a quirk or the bus notifier approach. > > > > Bjorn