dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Dave Airlie <airlied@gmail.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	iommu@lists.linux-foundation.org,
	Alistair Popple <apopple@nvidia.com>,
	Matthew Brost <matthew.brost@intel.com>,
	"Koenig, Christian" <Christian.Koenig@amd.com>
Subject: Re: iommu/smmu/PCI ATS + TTM unmaps + nouveau best way forward
Date: Tue, 30 Jun 2026 08:39:19 -0300	[thread overview]
Message-ID: <20260630113919.GC7481@nvidia.com> (raw)
In-Reply-To: <CAPM=9tyu7JAF9GD8GbSbeb++i-UqX59_OcBVY-cFyDyB4tBO8A@mail.gmail.com>

On Tue, Jun 30, 2026 at 07:39:44PM +1000, Dave Airlie wrote:
> I've been bringing up nouveau on NVIDIA Spark GB10 and fallen down a
> hole of why is the GPU writing to pages I've released back to the CPU
> page allocator. I've wasted a lot of time on GPU L2 cache and explicit
> handling for it, which might be needed but hasn't solved my problem.
> I've also invalidated and flushed the GPU TLB excessively.
>
> Today I finally hit up iommu.strict=1 makes things a lot happier,
> non-strict IOMMU seems to allow a race between dma_unmap_page and
> free_page where the unmap goes into the IOMMU flush queue, where the
> actual unmap are delayed until something triggers a flush later, and
> the ATS translations stay alive past when they should, and after the
> page has been allocated by some subsequent user.

It is a driver/device bug if it continues to DMA to memory after
dma_unmap is called. Strict mode is intended to increase security
against malicious devices and to aid debugging buggy drivers, it must
not be relied upon to have any functional effect on a correct driver.

This is not an API issue or an impedence mismatch, you have to follow
the DMA API contract when using the DMA API - meaning before unmap is
called the device is not doing DMA any more. It is a purely a
driver/device bug that the device is not quieted prior to unmapping.

You cannot fix this with any of your proposed hacks, the driver must
have control over the device and it must know when the device is done
DMA. Presumably there is a missing flush or fence that is allowing the
GPU to continue to DMA even after the OS thinks it has told it to
stop. There are many unique things about the coherent GPUs, I would
not be surprised if the driver needs some additional fencing
operations to clear the fabric beyond simple cache invalidation, but I
don't know.

Normally strict would convert these bugs from quiet corruptions into
noisy IOMMU logging, however in this case the GPU is using ATS and the
IOMMU does not log non-present ATS responses. Instead the GPU's
internal attempt to DMA will fail and the GPU will do whatever it does
to propogate that failure. Probably the driver has not noticed the
fall out, or it ignored it.

Jason

  parent reply	other threads:[~2026-06-30 11:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30  9:39 iommu/smmu/PCI ATS + TTM unmaps + nouveau best way forward Dave Airlie
2026-06-30 11:24 ` Christian König
2026-06-30 11:51   ` Jason Gunthorpe
2026-06-30 20:45     ` Dave Airlie
2026-06-30 21:00       ` Dave Airlie
2026-07-01  0:17         ` Jason Gunthorpe
2026-07-01  1:22           ` Alistair Popple
2026-06-30 23:59       ` Jason Gunthorpe
2026-06-30 11:39 ` Jason Gunthorpe [this message]
2026-06-30 23:21   ` Matthew Brost
2026-07-01  1:30     ` Alistair Popple
2026-07-01 23:34       ` Jason Gunthorpe

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=20260630113919.GC7481@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=Christian.Koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=apopple@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=matthew.brost@intel.com \
    /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