Re: [PATCH v4 08/18] iommu/vt-d: Clear unpreserved context entries during shutdown

From: Pranjal Shrivastava

Date: Wed Aug 26 2026 - 08:30:57 EST


On Wed, Aug 26, 2026 at 04:05:51PM +0800, Baolu Lu wrote:
> On 8/8/26 10:27, Samiullah Khawaja wrote:
> > During normal shutdown the iommu translation is disabled. Since the root
> > table is preserved during live update, it needs to be cleaned up and the
> > context entries of the unpreserved devices and root entries for the
> > unpreserved context tables need to be cleared.
>
> The key assumption here seems to be that, during a live-update kexec,
> most devices do not go through the normal iommu release path. Otherwise,
> their context entries should already be torn down in the
> iommu_release_device path.
>
> Could you please confirm this assumption and add some short note in the
> comments or commit message?
>

Yes, that's correct

During the normal shutdown paths (i.e power-off, normal reboot, & kexec),
the kernel only calls device_shutdown(). This path bypasses driver
unbinding, as a result, devres_release_all() and iommu_release_device()
are never called. Those devres teardown paths are only triggered when a
driver is explicitly unloaded / device is unplugged.

Since live-update piggybacks on the kexec/shutdown path the unpreserved
devices never have their context entries naturally torn down by the core
driver's devres model, necessitating this explicit cleanup.

I think we can add a line in the commit msg for this because comments
might create confusion if similar comments don't exist in other drivers
performing Live Update. What do you think, Sami?

Thanks,
Praan