Re: [PATCH v2 5/5] vt-d/iommu: Enable batching of IOTLB/Dev-IOTLB invalidations

From: Baolu Lu
Date: Fri Aug 09 2024 - 04:22:34 EST


On 2024/8/9 10:54, Tina Zhang wrote:
+static inline void handle_batched_iotlb_descs(struct dmar_domain *domain,
+ struct cache_tag *tag,
+ unsigned long addr,
+ unsigned long pages,
+ unsigned long mask,
+ int ih)
+{
+ struct intel_iommu *iommu = tag->iommu;
+
+ if (domain->use_first_level) {
+ qi_batch_add_piotlb_desc(iommu, tag->domain_id,
+ tag->pasid, addr, pages,
+ ih, domain->qi_batch);
+ } else {
+ /*
+ * Fallback to domain selective flush if no
+ * PSI support or the size is too big.
+ */
+ if (!cap_pgsel_inv(iommu->cap) ||
+ mask > cap_max_amask_val(iommu->cap) ||
+ pages == -1)
+ qi_batch_add_iotlb_desc(iommu, tag->domain_id,
+ 0, 0, DMA_TLB_DSI_FLUSH,
+ domain->qi_batch);
+ else
+ qi_batch_add_iotlb_desc(iommu, tag->domain_id,
+ addr | ih, mask,
+ DMA_TLB_PSI_FLUSH,
+ domain->qi_batch);
+ }
+
+}

What if the iommu driver is running on an early or emulated hardware
where the queued invalidation is not supported?

Thanks,
baolu