From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF49E606A31C for ; Mon, 16 Nov 2026 18:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ZwC2Jw14; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=b4T6egBj 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:In-Reply-To:Content-Type: MIME-Version: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-Unsubscribe-Post:List-Owner; bh=i0+NdK/YeASsZuhz7coPXNHnm1YViQRZlPGWrC7m3dY=; b=ZwC2Jw145mayWKbV+6prBdCgjY ZYaM+7Ff/Fm2Kwehl4AmcLiPXIA2BiYu5Zd3e8kaMn4HwYrsVwBZlwrkAvFYPKQ5QJQiqBrWwxO8y 5ugykrEzslA9oBRw6h7p47Tr3T8AsxRz9MWK4l3hHpzQmUao97ygQVlQOR8SSia6xwiHDmxRp+ZIi qL3WayYA5+qVizSEK9T59FjNkk34ejqVLKe9r8sky3RinbdBGKGAowk+qwY0xCVVJ88qnQote5nMC Z3FhKGk/v5ylbhNgV98QU2MlaT4QSXB4Ra2cDuXV+qKzo2Vv98EZ3Q4xj6TuPyS3eatkxMRF4L1LD QFD9h37w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xT1QA-00000003YEn-2MZc; Mon, 16 Nov 2026 18:27:14 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xT1Q7-00000003YCe-2cri for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2026 18:27:13 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4a018493d57so3885e9.0 for ; Mon, 16 Nov 2026 10:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1794853629; x=1795458429; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=i0+NdK/YeASsZuhz7coPXNHnm1YViQRZlPGWrC7m3dY=; b=b4T6egBjWiDklaGAJwMTJ/E2dnKVoY9nt0U5ymb8RNR4VpbCK8otLWUJ0xOoFSPVZQ A30rU0+arOqdDbCXLQO3C6ncW49QZyi7dnsybn+CjbgkytwJPpVLuHry7+cS5eXmXB/b 5X8U+HVulGJlqtlvKZ/1is39R1QU502lOtnGZ8tEMJvHf+qiG5ym20aoOAvkdYSH8JaJ Vc1qdkfUAFOSm4V6uSrKGGnAJJ0uGDhnjjHsRu6Ht4WV+2C1Leji3dhRUaLtVVHsFc0j l0umOViel1GncKCeTF5L/p2txsYV0xGptznlMzDtdQer0FNnzTZNG+1AoLBfV3oubHZx dhVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794853629; x=1795458429; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=i0+NdK/YeASsZuhz7coPXNHnm1YViQRZlPGWrC7m3dY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3CJdvva/5n5cIi2rq8vSlCTilRKRyicVYr2zUiMXU6aCo4u3nH5P mi9L7cb9dXsF/cdRacO5gazwSbcR01lqoTMHp70aIlQe8A7/GRdXtT2xYN/tCjRpt/sfBvxiWiN YuC3aump+PxXeNRpVNxIYAyIva5VSZLIK2+Lwrmya1taOuX3owtMvArXvnTf0pWQWqAgQRYg38B viQSR2Tb0of1Rs2iZ X-Received: by 2002:a05:600c:491c:b0:4a1:d2f2:9fbd with SMTP id 5b1f17b1804b1-4bb7894d9bfmr42925e9.0.1794853627708; Mon, 16 Nov 2026 10:27:07 -0800 (PST) Received: from google.com (250.192.189.35.bc.googleusercontent.com. [35.189.192.250]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-49c5f1c1968sm24006935f8f.10.2026.11.16.10.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2026 10:27:06 -0800 (PST) Date: Mon, 16 Nov 2026 18:27:02 +0000 From: Mostafa Saleh To: Peter Griffin Cc: Jonathan Corbet , Shuah Khan , Randy Dunlap , "Joerg Roedel (AMD)" , Will Deacon , Robin Murphy , =?iso-8859-1?Q?Andr=E9?= Draszik , Tudor Ambarus , Jason Gunthorpe , Daniel Mentz , Juan Yescas , kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: Re: [PATCH] iommu: Add iommu.passthrough_devs early command line parameter Message-ID: References: <20261116-b4-iommu-passthrough-devs-v1-1-dc5b493f7551@linaro.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261116-b4-iommu-passthrough-devs-v1-1-dc5b493f7551@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261116_102711_743076_6A7B251B X-CRM114-Status: GOOD ( 53.06 ) X-Spam-Score: -17.6 (-----------------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-23.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Mon, Nov 16, 2026 at 05:37:45PM +0000, Peter Griffin wrote: > Currently, the generic IOMMU core only provides an all-or-nothing global > switch ('iommu.passthrough={0,1}' and CONFIG_IOMMU_DEFAULT_PASSTHROUGH) > to configure default DMA domains in passthrough (IOMMU_DOMAIN_IDENTITY) > mode at boot time. > > Add an 'iommu.passthrough_devs=[,...]' early > command-line parameter. When allocating the default domain for a group in > iommu_group_alloc_default_domain(), if no mandatory domain type override > is present, check whether any device in the group (or any of its > parent/bridge devices via dev->parent) matches 'iommu.passthrough_devs' > and request IOMMU_DOMAIN_IDENTITY, warning and falling back to > IOMMU_DOMAIN_DMA if identity domains are unsupported (consistent with > 'iommu.passthrough=1'). > > Device names match dev_name(), such as PCI BDFs ('0000:01:00.0'), I believe BDFs are not reliable as they can change based on how Linux enumerates the bus and hotplug. Probably we'd need something as pci_dev_str_match() which is used in other cmdline options. Thanks, Mostafa > Device Tree platform devices ('3c400000.ufs'), or ACPI platform > devices ('AMDI0010:00'). Walking dev->parent also allows specifying a > parent PCIe host controller or root port (e.g. '3c500000.pcie' or > '0000:00:1c.0') to cover its downstream endpoints. > > Note: Untrusted PCI devices ('pdev->untrusted') and explicit IOMMU > driver '.def_domain_type' requirements continue to take precedence. > > Configuring per-device passthrough mode at boot is needed for several > use cases: > > - Performance tuning and benchmarking: high-throughput storage > workloads (e.g. fio benchmarks on UFS) can incur measurable > IOPS/latency and CPU overhead from IOMMU page table management and > TLB invalidations. Selective device passthrough allows bypassing > translation for these devices while keeping IOMMU isolation enabled > for other devices in the system. > > - SoC/board bringup and debugging: isolating whether a DMA fault or > regression is caused by a specific device's IOMMU translation without > disabling the IOMMU globally across the entire platform. > > Implementing this in the generic IOMMU core allows it to work with > ACPI and Device Tree (DT) systems as well as across all IOMMU drivers. > > Signed-off-by: Peter Griffin > --- > Hi folks, > > This patch follows up on a conversation with Jason Gunthorpe at > Linux Plumbers regarding how to upstream support for configuring > per-device IOMMU passthrough (IOMMU_DOMAIN_IDENTITY) at boot without > abusing Device Tree properties. > > Downstream on Google Pixel G5 Laguna platforms, we have historically > carried a custom 'iommu-idmapped' DT property parsed by the arm-smmu-v3 > driver to place specific client devices into bypass mode. As discussed > at Plumbers, Device Tree seems the wrong place for this because choosing > passthrough vs. translation for a given device can sometimes be an OS > policy trade-off where we choose device peak performance at the expense > of DMA isolation. This is the case for UFS and PCIe WLAN on Laguna, > which share a common SMMU instance with other peripherals (such as DMA > controllers, VPU, and ISP) where we want DMA isolation to remain > enabled. > > A secondary benefit is it could be useful during device bringup and > debugging for fault isolation and to work around firmware/device issues > before a proper driver quirk is in place. > > Instead, I propose handling this in the generic IOMMU core via a > kernel command-line parameter. This makes it available uniformly > across both Device Tree and ACPI systems and across all IOMMU drivers. > > In terms of upstream Laguna support, initial DT support has already > landed in tree, along with USB and phy support. Other support for > mailbox, clocks, powerdomains, reset is under review in the following > series with more to follow. > > https://lore.kernel.org/lkml/20261023235408.3063350-1-dianders@chromium.org/ > https://lore.kernel.org/lkml/20261026214359.3122870-1-briannorris@chromium.org/ > > Feedback and suggestions are very welcome. > > Thanks, > > Peter > --- > Documentation/admin-guide/kernel-parameters.txt | 11 ++++ > drivers/iommu/iommu.c | 76 +++++++++++++++++++++++-- > 2 files changed, 82 insertions(+), 5 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index c343bc9a0d28..926380cb1e99 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -2689,6 +2689,17 @@ Kernel parameters > 1 - Bypass the IOMMU for DMA. > unset - Use value of CONFIG_IOMMU_DEFAULT_PASSTHROUGH. > > + iommu.passthrough_devs= > + [KNL,EARLY] Configure DMA to bypass the IOMMU by default > + for specific devices. > + Format: [,...] > + Specify a comma-separated list of device names (matching > + dev_name() of the client device or any of its parent/bridge > + devices) whose IOMMU groups should default to passthrough > + (identity) mode (e.g. "0000:01:00.0" for PCI, > + "3c400000.ufs" for Device Tree, or > + "AMDI0010:00" for ACPI). > + > iommu.debug_pagealloc= > [KNL,EARLY] When CONFIG_IOMMU_DEBUG_PAGEALLOC is set, this > parameter enables the feature at boot time. By default, it > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index b486b8bbd1fc..0a7796e0311e 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -43,9 +44,12 @@ static struct kset *iommu_group_kset; > static DEFINE_IDA(iommu_group_ida); > static DEFINE_IDA(iommu_global_pasid_ida); > > +#define IOMMU_PASSTHROUGH_DEVS_MAX_LEN 256 > + > static unsigned int iommu_def_domain_type __read_mostly; > static bool iommu_dma_strict __read_mostly = IS_ENABLED(CONFIG_IOMMU_DEFAULT_DMA_STRICT); > static u32 iommu_cmd_line __read_mostly; > +static char iommu_passthrough_devs[IOMMU_PASSTHROUGH_DEVS_MAX_LEN] __read_mostly; > > /* Tags used with xa_tag_pointer() in group->pasid_array */ > enum { IOMMU_PASID_ARRAY_DOMAIN = 0, IOMMU_PASID_ARRAY_HANDLE = 1 }; > @@ -805,6 +809,27 @@ static int __init iommu_set_def_domain_type(char *str) > } > early_param("iommu.passthrough", iommu_set_def_domain_type); > > +static int __init iommu_set_passthrough_devs(char *str) > +{ > + size_t len; > + > + if (!str || !*str) > + return -EINVAL; > + > + len = strlen(iommu_passthrough_devs); > + if (len + (len ? 1 : 0) + strlen(str) >= IOMMU_PASSTHROUGH_DEVS_MAX_LEN) { > + pr_warn("Too long list of device names for 'iommu.passthrough_devs'!\n"); > + return -EINVAL; > + } > + if (len) > + iommu_passthrough_devs[len++] = ','; > + > + strscpy(iommu_passthrough_devs + len, str, > + IOMMU_PASSTHROUGH_DEVS_MAX_LEN - len); > + return 0; > +} > +early_param("iommu.passthrough_devs", iommu_set_passthrough_devs); > + > static int __init iommu_dma_setup(char *str) > { > int ret = kstrtobool(str, &iommu_dma_strict); > @@ -1750,14 +1775,45 @@ __iommu_group_alloc_default_domain(struct iommu_group *group, int req_type) > return ERR_PTR(-EINVAL); > } > > +static bool iommu_is_passthrough_dev(struct device *dev) > +{ > + for (; dev; dev = dev->parent) { > + const char *name = dev_name(dev); > + > + if (name && *name && > + parse_option_str(iommu_passthrough_devs, name)) > + return true; > + } > + > + return false; > +} > + > +static struct device *iommu_group_passthrough_dev(struct iommu_group *group) > +{ > + struct group_device *gdev; > + > + if (!iommu_passthrough_devs[0]) > + return NULL; > + > + for_each_group_device(group, gdev) { > + if (iommu_is_passthrough_dev(gdev->dev)) > + return gdev->dev; > + } > + > + return NULL; > +} > + > /* > * req_type of 0 means "auto" which means to select a domain based on > - * iommu_def_domain_type or what the driver actually supports. > + * iommu.passthrough_devs, iommu_def_domain_type, or what the driver > + * actually supports. > */ > static struct iommu_domain * > iommu_group_alloc_default_domain(struct iommu_group *group, int req_type) > { > const struct iommu_ops *ops = dev_iommu_ops(iommu_group_first_dev(group)); > + unsigned int def_type = iommu_def_domain_type; > + struct device *pt_dev = NULL; > struct iommu_domain *dom; > > lockdep_assert_held(&group->mutex); > @@ -1777,19 +1833,29 @@ iommu_group_alloc_default_domain(struct iommu_group *group, int req_type) > return __iommu_group_alloc_default_domain(group, req_type); > > /* The driver gave no guidance on what type to use, try the default */ > - dom = __iommu_group_alloc_default_domain(group, iommu_def_domain_type); > - if (!IS_ERR(dom)) > + if (def_type != IOMMU_DOMAIN_IDENTITY) { > + pt_dev = iommu_group_passthrough_dev(group); > + if (pt_dev) > + def_type = IOMMU_DOMAIN_IDENTITY; > + } > + > + dom = __iommu_group_alloc_default_domain(group, def_type); > + if (!IS_ERR(dom)) { > + if (pt_dev && dom != group->default_domain) > + dev_info(pt_dev, > + "Setting default IOMMU domain to passthrough via command line\n"); > return dom; > + } > > /* Otherwise IDENTITY and DMA_FQ defaults will try DMA */ > - if (iommu_def_domain_type == IOMMU_DOMAIN_DMA) > + if (def_type == IOMMU_DOMAIN_DMA) > return ERR_PTR(-EINVAL); > dom = __iommu_group_alloc_default_domain(group, IOMMU_DOMAIN_DMA); > if (IS_ERR(dom)) > return dom; > > pr_warn("Failed to allocate default IOMMU domain of type %u for group %s - Falling back to IOMMU_DOMAIN_DMA", > - iommu_def_domain_type, group->name); > + def_type, group->name); > return dom; > } > > > --- > base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b > change-id: 20261106-b4-iommu-passthrough-devs-03b7c957ac69 > > Best regards, > -- > Peter Griffin >