Re: [PATCH] iommu/vt-d: Check for non-NULL domain on device release

From: Baolu Lu
Date: Thu Feb 22 2024 - 06:55:16 EST


On 2024/2/21 23:40, Jason Gunthorpe wrote:
On Wed, Jan 31, 2024 at 03:10:53PM +0800, Baolu Lu wrote:
I like this suggestion.

Currently, the device_release callback for an iommu driver does the
following:

a) Silent IOMMU DMA translation. This is done by detaching the existing
domain from the IOMMU and bringing the IOMMU into a blocking state
(some drivers might be in identity state);
b) Releases the resources allocated in the probe callback and restores
the device to its previous state before the probe.

From my understanding of your suggestion, we should move a) out of the
release callback and make it a special domain, which could be a blocking
domain or identity domain, depending on the iommu hardware.

In the end, the release_device callback of an iommu driver should focus
on the opposite operation of device_probe. This makes the concept
clearer.
Right

Can someone make some patches to fix Eric's bug? We don't really need
to do the release_domain stuff if the driver just self-attaches one of
its known static domain types (blocking/identity)

I will follow up with a formal patch series.

Best regards,
baolu