From: Christoph Hellwig <hch@lst.de>
To: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: Christoph Hellwig <hch@lst.de>,
Bruno Gravato <bgravato@gmail.com>, Stefan <linux-kernel@simg.de>,
Keith Busch <kbusch@kernel.org>,
bugzilla-daemon@kernel.org, Adrian Huang <ahuang12@lenovo.com>,
Linux kernel regressions list <regressions@lists.linux.dev>,
linux-nvme@lists.infradead.org, Jens Axboe <axboe@fb.com>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
LKML <linux-kernel@vger.kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: Re: [Bug 219609] File corruptions on SSD in 1st M.2 socket of AsRock X600M-STX + Ryzen 8700G
Date: Tue, 4 Feb 2025 07:26:05 +0100 [thread overview]
Message-ID: <20250204062605.GB29300@lst.de> (raw)
In-Reply-To: <266965cf-9cf9-4434-be42-458e92d7366d@leemhuis.info>
On Fri, Jan 17, 2025 at 11:30:47AM +0100, Thorsten Leemhuis wrote:
> >> Side note: that "PCI-DMA: Using software bounce buffering for IO
> >>>> (SWIOTLB)" message does show up on two other AMD machines I own as
> >> well. One also has a Ryzen 8000, the other one a much older one.
The message will aways show with > 4G of memory. It only implies swiotlb
is initialized, not that any device actually uses it.
> >> And BTW a few bits of the latest development in the bugzilla ticket
> >> (https://bugzilla.kernel.org/show_bug.cgi?id=219609 ):
> >>
> >> * iommu=pt and amd_iommu=off seems to work around the problem (in
> >> addition to disabling the iommu in the BIOS setup).
iommu_pt calls iommu_set_default_passthrough, which sets
iommu_def_domain_type to IOMMU_DOMAIN_IDENTITY. I.e. the hardware
IOMMu is left on, but treated as a 1:1 mapping by Linux.
amd_iommu=off sets amd_iommu_disabled, which calls disable_iommus,
which from a quick read disables the hardware IOMMU.
In either case we'll end up using dma-direct instead of dma-iommu.
> >
> > That suggests the problem is related to the dma-iommu code, and
> > my strong suspect is the swiotlb bounce buffering for untrusted
> > device. If you feel adventurous, can you try building a kernel
> > where dev_use_swiotlb() in drivers/iommu/dma-iommu.c is hacked
> > to always return false?
>
> Tried that, did not help: I still get corrupted data.
.. which together with this implies that the problem only happens
when using the dma-iommu code (with or without swiotlb buffering
for unaligned / untrusted data), and does not happen with
dma-direct.
If we assume it also is related to the optimal dma size, which
the original report suggests, the values for that might be
interesting. For dma-iommu this is:
PAGE_SIZE << (IOVA_RANGE_CACHE_MAX_SIZE - 1);
where IOVA_RANGE_CACHE_MAX_SIZE is 6, i.e.
PAGE_SIZE << 5 or 131072 for x86_64.
for dma-direct it falls back to dma_max_mapping_size, which is
SIZE_MAX without swiotlb, or swiotlb_max_mapping_size, which
is a bit complicate due to minimum alignment, but in this case
should evaluate to: 258048, which is almost twice as big.
And all this unfortunately leaves me really confused. If someone is
interested in playing around with at the risk of data corruption it would
be interesting to hack hardcoded values into dma_opt_mapping_size, e.g.
plug in the 131072 used by dma-iommu while using dma-direct with the
above iommu disable options.
next prev parent reply other threads:[~2025-02-04 6:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 14:38 [Regression] File corruptions on SSD in 1st M.2 socket of AsRock X600M-STX Thorsten Leemhuis
2025-01-08 15:07 ` Keith Busch
2025-01-09 8:28 ` Christoph Hellwig
2025-01-09 8:52 ` Thorsten Leemhuis
2025-01-09 15:44 ` [Bug 219609] File corruptions on SSD in 1st M.2 socket of AsRock X600M-STX + Ryzen 8700G Stefan
2025-01-10 11:17 ` Bruno Gravato
2025-01-15 6:37 ` Bruno Gravato
2025-01-15 8:40 ` Thorsten Leemhuis
2025-01-16 17:29 ` Thorsten Leemhuis
2025-01-17 8:05 ` Christoph Hellwig
2025-01-17 9:51 ` Thorsten Leemhuis
2025-01-17 9:55 ` Christoph Hellwig
2025-01-17 10:30 ` Thorsten Leemhuis
2025-02-04 6:26 ` Christoph Hellwig [this message]
2025-01-17 13:36 ` Bruno Gravato
2025-01-20 14:31 ` Thorsten Leemhuis
2025-01-28 7:41 ` Christoph Hellwig
2025-01-28 12:00 ` Stefan
2025-01-28 12:52 ` Dr. David Alan Gilbert
2025-01-28 14:24 ` Stefan
2025-02-02 8:32 ` Bruno Gravato
2025-02-04 6:12 ` Christoph Hellwig
2025-02-04 9:12 ` Bruno Gravato
2025-02-03 18:48 ` Stefan
2025-02-06 15:58 ` Stefan
2025-01-17 21:31 ` Stefan
2025-01-18 1:03 ` Keith Busch
2025-01-15 10:47 ` Stefan
2025-01-15 13:14 ` Bruno Gravato
2025-01-15 16:26 ` Stefan
2025-01-10 0:10 ` [Regression] File corruptions on SSD in 1st M.2 socket of AsRock X600M-STX Keith Busch
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=20250204062605.GB29300@lst.de \
--to=hch@lst.de \
--cc=ahuang12@lenovo.com \
--cc=axboe@fb.com \
--cc=bgravato@gmail.com \
--cc=bugzilla-daemon@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=kbusch@kernel.org \
--cc=linux-kernel@simg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mario.limonciello@amd.com \
--cc=regressions@leemhuis.info \
--cc=regressions@lists.linux.dev \
/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