On Tue, 25 Sep 2018 15:16:47 +0200 Joerg Roedel <joro@xxxxxxxxxx> wrote: > On Sun, Sep 23, 2018 at 10:39:25AM +0800, Lu Baolu wrote: > > > +int iommu_sva_init_device(struct device *dev, unsigned long > > > features, > > > + unsigned int min_pasid, unsigned int > > > max_pasid) +{ > > > + int ret; > > > + struct iommu_sva_param *param; > > > + struct iommu_domain *domain = > > > iommu_get_domain_for_dev(dev); > > > > This doesn't work for vt-d. The domains for host iova are > > self-managed by vt-d driver itself. Hence, > > iommu_get_domain_for_dev() will always return NULL unless an > > UNMANAGED domain is attached to the device. > > > > How about > > > > const struct iommu_ops *ops = dev->bus->iommu_ops; > > > > instead? > > The per-bus iommu-ops might go away sooner or later as we move to > per-device iommu-ops. How about fixing the VT-d driver to not keep > that domain internal to itself? > Just to understand more specifically, you mean let VT-d driver also support IOMMU_DOMAIN_DMA as default domain? But I think the ordering issue is still there in that the DOMAIN_DMA domain will not be created until DMA map call is invoked. I think sva_init_device should not depend on the default domain. > Regards, > > Joerg [Jacob Pan]