From nobody Thu Apr 2 20:20:49 2026 Received: from smtpfb2-g21.free.fr (smtpfb2-g21.free.fr [212.27.42.10]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1923450F2 for ; Fri, 13 Feb 2026 04:24:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.27.42.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770956648; cv=none; b=WggVwavTHR+n0JBpkqFTj2FMyKXW/YuNCRhGqfnnxfQ9HYXo+ucGr2bH86QdXWcrln22hGOLSQGoYmdI2wdrJqg9HcpKA9LYsNIGOkZo35jsEOhIJNbokfHppn5WR2Nixjb1cCEgNSTH30zDWKXyF2iGewtr7GytQMDz6rpgrSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770956648; c=relaxed/simple; bh=JVWRif0RpRYK58PBfNLIYEScukds9Y1Q1zzgB+5Us7Y=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=RNfQ8RsI65ZUsG49aMvf+Y5kWh9V+1AqZtW/SmINHiBWf1Ji5+Gv3hR2hwh1y7ucdeDObRygRzU6wuzQEHO8psXXIJb5Z8MTtxiFfhhGN6iqD9pmeV2ZE1Qnz5JasWx2NJyTzXkDIXxdHPQQKgt0BTuh6cdG5omiMq28HRce/1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=free.fr; spf=pass smtp.mailfrom=free.fr; dkim=pass (2048-bit key) header.d=free.fr header.i=@free.fr header.b=hHFf62JI; arc=none smtp.client-ip=212.27.42.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=free.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=free.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=free.fr header.i=@free.fr header.b="hHFf62JI" Received: from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3]) by smtpfb2-g21.free.fr (Postfix) with ESMTP id 1FE604C615 for ; Fri, 13 Feb 2026 05:17:50 +0100 (CET) Received: from [IPV6:2a02:842a:8223:5500::20] (unknown [IPv6:2a02:842a:8223:5500::20]) (Authenticated sender: julien.robin28@free.fr) by smtp3-g21.free.fr (Postfix) with ESMTPSA id 3C42413F88F; Fri, 13 Feb 2026 05:17:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1770956262; bh=JVWRif0RpRYK58PBfNLIYEScukds9Y1Q1zzgB+5Us7Y=; h=Date:To:Cc:From:Subject:From; b=hHFf62JIJF9I0vQ8tc+0fPNut9WzKWOF6HK4XUTYuI+2NVrUDNJEST/3i/qJBIynd DBbIrnQhO0jTKjsrBcBPwDWKlKCnWZJVcntz2SOb5hIidqoQizcBbnsTm9MQFMsm2B yOqT8lxbfdrNDrw2Vw9a95CcVMPl/ly5dqH2xVKigW5lVQEgV9GiKFJxVKDdpYyGWZ MipEU5MH56ZDM5JNxRXskxUAiQe/TLk12gf0EXKJE/GfC3sXwGfkrQj59+YFvBl2+U WnG5ZU9fCH612fvs/Yx4Q3g6u8F7GvxVUo2pX7L4SVi5DIhcO9C3WcyMBOHzGvCbs7 G7BMzQing97lw== Message-ID: <16c95f65-17ee-4bbd-99b3-93406a7801c4@free.fr> Date: Fri, 13 Feb 2026 05:17:34 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" From: Julien ROBIN Subject: [PATCH] x86/pci-dma: swiotlb: Fix a regression since 5.19.0 about iommu=soft kernel parameter Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The following patch fixes a regression introduced since linux-5.19.0 about kernel parameter "iommu=3Dsoft" which, according to kernel-parameters.txt, is expected to enable the use of software bounce buffering (SWIOTLB) and to prevent the usage of an available hardware IOMMU. Since linux-5.19.0 however, iommu=3Dsoft doesn't prevent anymore the usage = of hardware IOMMU implementations, and at least when an AMD GART IOMMU is available, SWIOTLB even gets disabled by "amd_gart_64.c" despite the iommu=3Dsoft parameter. The issue is fixed by adding an "x86_soft_iommu_only" variable which is set when the iommu=3Dsoft parameter is found and processed. If the variable is set, hardware IOMMU detection and allocation is skipped, as these detection and allocation functions could overwrite both x86_init.iommu.iommu_init and x86_platform.iommu_shutdown for later initialization and shutdown of these hardware IOMMU implementations. When the iommu=3Dsoft parameter isn't provided however, the behavior of the kernel is left untouched by this patch. Patch applies from 5.19.0 to 6.19.0, based on mainline as of 2026-02-12. Successfully tested this fix with iommu=3Dsoft parameter on linux-6.1.163 a= nd linux-6.19.0 on a Gigabyte 990FXA-UD3 based computer. Tested the fix and iommu=3Dsoft parameter on linux-6.19 on these 4 machines: Gigabyte 990FXA-UD3 motherboard based computer (AMD FX9590 CPU) Asus TUF B550-PLUS motherboard based computer (AMD Ryzen 5 3700X CPU) HP Victus 16-s1034nf / 8C9C laptop (AMD Ryzen 5 8645HS CPU) Asus X550JK laptop (Intel Core i5-4200H CPU) On the 1st this successfully disables AMD GART IOMMU and enables SWIOTLB. On the 2nd this allows disabling AMD-Vi but SWIOTLB was already enabled. Same for the 3rd one. On the 4th there was no hardware IOMMU enabled, and SWIOTLB was already enabled too: no resulting change for this laptop. Signed-off-by: Julien ROBIN --- arch/x86/kernel/pci-dma.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 6267363e0189..c8762d4f8d54 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -34,6 +34,7 @@ int force_iommu __read_mostly =3D 0; int iommu_merge __read_mostly =3D 0; =20 int no_iommu __read_mostly; +int x86_soft_iommu_only __read_mostly; /* Set this to 1 if there is a HW IOMMU in the system */ int iommu_detected __read_mostly =3D 0; =20 @@ -102,9 +103,15 @@ void __init pci_iommu_alloc(void) return; } pci_swiotlb_detect(); - gart_iommu_hole_init(); - amd_iommu_detect(); - detect_intel_iommu(); + + if (x86_soft_iommu_only) + pr_info("PCI-DMA: skipping hardware IOMMU detection and allocation\n"); + else { + gart_iommu_hole_init(); + amd_iommu_detect(); + detect_intel_iommu(); + } + swiotlb_init(x86_swiotlb_enable, x86_swiotlb_flags); } =20 @@ -151,8 +158,10 @@ static __init int iommu_setup(char *p) return 1; } #ifdef CONFIG_SWIOTLB - if (!strncmp(p, "soft", 4)) + if (!strncmp(p, "soft", 4)) { x86_swiotlb_enable =3D true; + x86_soft_iommu_only =3D 1; + } #endif if (!strncmp(p, "pt", 2)) iommu_set_default_passthrough(true);