Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1105143lqj; Mon, 3 Jun 2024 10:12:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSvWgW5l5GTt7fWXrLflwxs6OCsqoJq9GpvVtSMc510Z6AKk/KJ+4tY46PWAr85NbdeAFSLK2BkD7gHb9hUCM4zNbli0c4RsRKgZoaUA== X-Google-Smtp-Source: AGHT+IFUIsAlya7kVb3qe4IgqyDI3KGi9K+AsFVPlPUjswU0QqEvIrsll/Kyy1pThjyylAjfM/op X-Received: by 2002:a1f:fe8a:0:b0:4ea:edac:3ae4 with SMTP id 71dfb90a1353d-4eb02dcb6acmr8662518e0c.9.1717434723086; Mon, 03 Jun 2024 10:12:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717434723; cv=pass; d=google.com; s=arc-20160816; b=AcuhpNss7YsZN8Dg7j23K7S496m9nDF+0gY/9huQZKkIs5Il2AnCnw2bv/rbSCBJFr Szi91fDshNnne3uBzCFjYv/bIaqIce1UbjdStStmnRGxA8D74v2XCruoITPVeebXt1O3 0dz/+uT1l4ggWKHaI1dpxAOClyqh0NNSH/vSqljESJBRsCf0VlDVqquRc274Ai30Os0s phHMv4aXIp9nj4P1nYd08pY2QUUGbbJpjNUFchbQB2TJWJ8YBWXNrcmJnZPt4axVqJRI u8MyT7F5xAsS6Xs3yy64lM6cMwZyzm5A6gIRvsjJy1P6HFsXTcfzrPGHF+x3HmZTD6NX wjyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=gFYodcJgxBMfVLdak1huguhheUm7Fq1jSwjhpSWTVCY=; fh=y1fSHcJD7jFhuMVp83kV3xt9VqgLf4Cpz/0clQToMHM=; b=FqIa4ffsoMEsjVwYX6rGcaoQ1ykDZCklbeVVizk0/rLJx2Xo9EXyn/9/OKqWaYzTxk d6A1DEvwReDu8z3s1feGZtkexVC75BkPdpr7FJtbysJJnrjmR8SpyUyO5fzuifVHk2Nz kUZE+gSa6bmqYVi6g8UaZEo6NprwMJ5j3NWW8/mNZPaGwFxCyjC9gUenqUP3QuAodsDG ND5MewE81s2nmplEz0D0l5OvZOzSPnK9Iiy0NUong7NcLceN7FjauZhimZa85gfs+qbm NvvyZyvS2sGGVvHa5XrDjZp5FmGJf1iebedPtN7Nlf2RBwmdpp6j6Idiqz/FgIUwajSn ZP5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IskPVtkR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 71dfb90a1353d-4eafef4ca31si1343448e0c.238.2024.06.03.10.12.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 10:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IskPVtkR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C8EF91C22204 for ; Mon, 3 Jun 2024 17:12:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1B71137746; Mon, 3 Jun 2024 17:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IskPVtkR" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C056012EBCA; Mon, 3 Jun 2024 17:11:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717434711; cv=none; b=e22L1we2FdgaX3mbFu+8h8B5vdY22O4szrtOfjtSSPAeNvTlY/0tZBVlzBgSegS9nnDL3jsaBLqCTEADfjAgOK9NL5YpUgVMzOS0UmJcjXGJCO0dlSboH5P2fJxtVDLpMm2nV4WeceLabAmNpujsYi/sD+qn9vOdAHNeohAvIz8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717434711; c=relaxed/simple; bh=i4qNqKBBW9MS/3cabi3B6YUjPjcvwTN3tabqpknsbok=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=GmcfXsDjsC5unGgWfPDC/O18Ld91yPErlrTvH2nBVsRfe8P/HliT9JKanHUIp4T+T+CwLGr6H9gOId6JAKpBcJJ9RfnYIN7ag31UJDE+V02d9d+qxS1ozbz+Ep+Yz66CJtd7kCRtH2obdEo2tB2QRHzwK0itkkhoH6SmV92jd/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IskPVtkR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09183C2BD10; Mon, 3 Jun 2024 17:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717434711; bh=i4qNqKBBW9MS/3cabi3B6YUjPjcvwTN3tabqpknsbok=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=IskPVtkRLcXqswqt5Z9Yt26xtJugDU7NoYLA91Xz03aHeSf/68YOcGpeyet22K/uN CGJKU4Ax6gmVP+obsNuJYi7dLS8e9l6ikQQ90IkHuNMKf5SoHLo9nE+NfggMAjev9k U/byZZkYySDjwi0TZ3xGln2UbTSnd5sfIZMNIHEm1GRs4/LSVHe5Opn7S+l9+0cJK+ mu+RXG9X3oFm5sXPwDXDSO7oeIVGdYZuNtdGN8PCh3PaFXdZdk/c/pFAyZL7vdowqb +kmhi3NJoYyTFwyIQFYsz8d2bophoijGhIb0k4JqhWe7qCwFI7ZEmhzsRxx1OVoR8l yfQkIEXIb7H5Q== Date: Mon, 3 Jun 2024 12:11:49 -0500 From: Bjorn Helgaas To: Frank Li 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: <20240603171149.GA685507@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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) - naming BUS_NOTIFY_DEL_DEVICE function: apple_pcie_release_device() imx_pcie_del_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 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