Re: [PATCH v10 5/7] iommu/vt-d: Make prq draining code generic

From: Baolu Lu
Date: Thu Jul 13 2023 - 23:28:32 EST


On 2023/7/13 15:49, Tian, Kevin wrote:
From: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
Sent: Thursday, July 13, 2023 12:34 AM

- /* Domain type specific cleanup: */
domain = iommu_get_domain_for_dev_pasid(dev, pasid, 0);
- if (domain) {
- switch (domain->type) {
- case IOMMU_DOMAIN_SVA:
- intel_svm_remove_dev_pasid(dev, pasid);
- break;
- default:
- /* should never reach here */
- WARN_ON(1);
- break;
- }
+ if (!domain)
+ goto out_tear_down;

WARN_ON()

Why?

My understanding is that remve_device_pasid could be call in any context
including no domain attached.


* large and has to be physically contiguous. So it's
* hard to be as defensive as we might like.
*/
- intel_pasid_tear_down_entry(iommu, dev, svm->pasid,
false);
- intel_svm_drain_prq(dev, svm->pasid);

after removing the 2 lines the comment above becomes stale.

Yes.


-static void intel_svm_drain_prq(struct device *dev, u32 pasid)
+void intel_drain_pasid_prq(struct device *dev, u32 pasid)
{
struct device_domain_info *info;
struct dmar_domain *domain;

later we should move generic prq handling logic out of svm.c into
a new prq.c

Yes.

Best regards,
baolu