Re: [PATCH v3 7/7] dmaengine/idxd: Re-enable kernel workqueue under DMA API

From: Jacob Pan
Date: Mon Apr 03 2023 - 17:50:59 EST


Hi Baolu,

On Sat, 1 Apr 2023 21:39:32 +0800, Baolu Lu <baolu.lu@xxxxxxxxxxxxxxx>
wrote:

> On 2023/4/1 7:11, Jacob Pan wrote:
> > static void idxd_disable_system_pasid(struct idxd_device *idxd)
> > {
> > + struct pci_dev *pdev = idxd->pdev;
> > + struct device *dev = &pdev->dev;
> > + struct iommu_domain *domain;
> > + union gencfg_reg gencfg;
> > +
> > + domain = iommu_get_domain_for_dev(dev);
> > + if (!domain || domain->type == IOMMU_DOMAIN_BLOCKED)
> > + return;
>
> Out of curiosity, why do you need to check the domain type? And, in
> which case could the domain for the device be changed to a blocking one?
>
> Once a driver is bound to the device, the driver "owns" the DMA of the
> device. No one else could change the domain except the driver itself.
nothing particular just for precaution, I can drop the check or add a
warn_on.

> > +
> > + iommu_detach_device_pasid(domain, dev, idxd->pasid);
> > + iommu_free_global_pasid(idxd->pasid);
> >
> > - iommu_sva_unbind_device(idxd->sva);
> > + gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET);
> > + gencfg.user_int_en = 0;
> > + iowrite32(gencfg.bits, idxd->reg_base + IDXD_GENCFG_OFFSET);
> > idxd->sva = NULL;
> > + idxd->pasid = IOMMU_PASID_INVALID;
> > }
>
> Best regards,
> baolu


Thanks,

Jacob