Re: [PATCH v3 2/5] iommu/amd: Fix DTE clearing and rename iommu_ignore_device()
From: Pranjal Shrivastava
Date: Tue Aug 25 2026 - 06:32:23 EST
On Mon, Aug 24, 2026 at 03:13:21PM -0300, Jason Gunthorpe wrote:
> > [ ... 52 lines skipped ... ]
> > +/*
> > + * Invalidate a DTE by clearing the Valid bit first.
> > + * Note: Lockless; Not to be used on a fully probed
> > + * device with live dev_data.
> > + */
> > +static void amd_iommu_disable_dte(struct dev_table_entry *ptr)
> > +{
> > + struct dev_table_entry new = {};
> > +
> > + write_dte_lower128(ptr, &new);
> > + write_dte_upper128(ptr, &new);
> > +}
>
> No need just call update_dte256() with a 0'd new. This is how all the
> update flows work, and it flushes the DTE which this looks like it has
> been missing all long.
>
I originally considered using update_dte256(), but iommu_disable_device
is called from the early probe error path (err_deinit).
If iommu_init_device() fails before dev_data is fully allocated and
attached to dev->iommu->priv, we don't have a valid dev_data pointer.
Passing NULL into update_dte256() would cause a NULL pointer deref when
it tries to acquire dev_data->dte_lock.
That's why I introduced this helper amd_iommu_disable_dte(),
specifically for this early teardown scenario where the device isn't
fully live yet.
Thanks,
Praan