Messages in this thread | | | Date | Sun, 29 May 2022 13:22:47 +0800 | Subject | Re: [PATCH 03/12] iommu/vt-d: Remove clearing translation data in disable_dmar_iommu() | From | Baolu Lu <> |
| |
On 2022/5/27 23:01, Jason Gunthorpe wrote: > On Fri, May 27, 2022 at 02:30:10PM +0800, Lu Baolu wrote: >> The disable_dmar_iommu() is called when IOMMU initialzation fails or >> the IOMMU is hot-removed from the system. In both cases, there is no >> need to clear the IOMMU translation data structures for devices. >> >> On the initialization path, the device probing only happens after the >> IOMMU is initialized successfully, hence there're no translation data >> structures. >> >> On the hot-remove path, there is no real use case where the IOMMU is >> hot-removed, but the devices that it manages are still alive in the >> system. The translation data structures were torn down during device >> release, hence there's no need to repeat it in IOMMU hot-remove path >> either. > > Can you leave behind a 1 statement WARN_ON of some kind to check this?
Sure. As the default domain is the first domain allocated for a device and the last one freed. We can WARN_ON the case where there's still domain IDs in use. How do you like this?
+ /* + * All iommu domains must have been detached from the devices, + * hence there should be no domain IDs in use. + */ + if (WARN_ON(bitmap_weight(iommu->domain_ids, cap_ndoms(iommu->cap)) + != NUM_RESERVED_DID)) + return;
Best regards, baolu
| |