RE: [PATCH v2 18/31] iommu/vt-d: Cache max domain ID to avoid redundant calculation

From: Tian, Kevin

Date: Thu Apr 09 2026 - 03:04:05 EST


> From: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
> Sent: Saturday, March 28, 2026 12:01 AM
>
> From: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
>
> The cap_ndoms() helper calculates the maximum available domain ID from
> the value of capability register, which can be inefficient if called
> repeatedly. Cache the maximum supported domain ID in max_domain_id
> field
> during initialization to avoid redundant calls to cap_ndoms() throughout
> the IOMMU driver.
>
> No functionality change.
>
> Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> Signed-off-by: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>