Re: [PATCH v3 2/5] iommu/amd: Fix DTE clearing and rename iommu_ignore_device()
From: Pranjal Shrivastava
Date: Tue Aug 25 2026 - 13:30:41 EST
On Tue, Aug 25, 2026 at 08:49:16AM -0300, Jason Gunthorpe wrote:
> On Tue, Aug 25, 2026 at 10:32:07AM +0000, Pranjal Shrivastava wrote:
> > 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).
>
> There is no reason to do that, the DTE isn't written by
> amd_iommu_probe_device(), so there is no reason to clear it on an
> error path.
>
> It is wrong to write to the DTE table without flushing the
> HW cache.
>
I agree, but I wonder why the existing code used memset here
(in ignore_device):
memset(&dev_table[devid], 0, sizeof(struct dev_table_entry));
I was thinking it might've been done for probe failures in a kdump
kernel (normal kexec would've called shutdown for clearing all DTEs).
(I see this was added long time back and existed when PCI segments were
added [1]).
Are you suggesting to remove the DTE clearing from this path entirely?
Thanks,
Praan
[1] https://lore.kernel.org/all/20220706113825.25582-23-vasant.hegde@xxxxxxx/