mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Julien ROBIN <julien.robin28@free.fr>, linux-kernel@vger.kernel.org
Cc: x86@kernel.org, Thomas Gleixner <tglx@kernel.org>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2 RESEND] x86/pci-dma: swiotlb: Fix a regression since 5.19.0 about iommu=soft kernel parameter
Date: Thu, 8 Oct 2026 12:27:38 +0200	[thread overview]
Message-ID: <e9ffaa7d-26be-4d19-95d6-e2f039119978@samsung.com> (raw)
In-Reply-To: <f921c2ca-e083-41ad-90a9-e54816427a50@free.fr>

On 04.10.2026 12:12, Julien ROBIN wrote:
> The following patch fixes a regression introduced since linux-5.19.0 about
> kernel parameter "iommu=soft" 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=soft 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=soft parameter.
>
> The issue is fixed by adding an "x86_soft_iommu_only" variable which is set
> when the iommu=soft 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=soft 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=soft parameter on linux-6.1.163 and
> linux-6.19.0 on a Gigabyte 990FXA-UD3 based computer.
>
> Tested the fix and iommu=soft 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 <julien.robin28@free.fr>
I assume that this needs the following tags:
Fixes: 78013eaadf69 ("x86: remove the IOMMU table infrastructure")
Cc: stable@vger.kernel.org

It would be great if one of the x86 maintainers or developers involved into that
commit could comment on this patch. I would also like to know if it is safe to skip
gart, amd and intel iommu related calls.

> ---
> Changes since v1:
>  - Added static keyword to 'x86_soft_iommu_only' (only used locally).
> ---
>  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 75cf8f6ae8cd..c3dad499cd27 100644
> --- a/arch/x86/kernel/pci-dma.c
> +++ b/arch/x86/kernel/pci-dma.c
> @@ -34,6 +34,7 @@ int force_iommu __read_mostly = 0;
>  int iommu_merge __read_mostly = 0;
>  
>  int no_iommu __read_mostly;
> +static 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 = 0;
>  
> @@ -100,9 +101,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);
>  }
>  
> @@ -149,8 +156,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 = true;
> +			x86_soft_iommu_only = 1;
> +		}
>  #endif
>  		if (!strncmp(p, "pt", 2))
>  			iommu_set_default_passthrough(true);
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


      reply	other threads:[~2026-10-08 10:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261004101223eucas1p218a04ee0955798705f0e450ec74678a9@eucas1p2.samsung.com>
2026-10-04 10:12 ` Julien ROBIN
2026-10-08 10:27   ` Marek Szyprowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9ffaa7d-26be-4d19-95d6-e2f039119978@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=julien.robin28@free.fr \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®