static int attach_device(struct device *dev,
                         struct protection_domain *domain)
 {
-       struct pci_dev *pdev;
        struct iommu_dev_data *dev_data;
+       struct pci_dev *pdev;
        unsigned long flags;
        int ret;
 
 
        pdev = to_pci_dev(dev);
        if (domain->flags & PD_IOMMUV2_MASK) {
+               struct iommu_domain *def_domain = iommu_get_dma_domain(dev);
+
                ret = -EINVAL;
-               if (!dev_data->passthrough)
+               if (def_domain->type != IOMMU_DOMAIN_IDENTITY)
                        goto out;
 
                if (dev_data->iommu_v2) {
 
        /* Domains are initialized for this device - have a look what we ended up with */
        domain = iommu_get_domain_for_dev(dev);
-       if (domain->type == IOMMU_DOMAIN_IDENTITY)
-               dev_data->passthrough = true;
-       else if (domain->type == IOMMU_DOMAIN_DMA)
+       if (domain->type == IOMMU_DOMAIN_DMA)
                iommu_setup_dma_ops(dev, IOVA_START_PFN << PAGE_SHIFT, 0);
 
 out: