On Wed, Dec 18, 2019 at 11:17:55AM +0100, Auger Eric wrote: > > +static int arm_smmu_enable_pasid(struct arm_smmu_master *master) > > +{ > > + int ret; > > + int features; > > + int num_pasids; > > + struct pci_dev *pdev; > > + > > + if (!dev_is_pci(master->dev)) > > + return -ENODEV; > > + > > + pdev = to_pci_dev(master->dev); > > + > > + features = pci_pasid_features(pdev); > > + if (features < 0) > > + return -ENODEV; > why -ENODEV? Right that should return features. The below should return num_pasids. > > + > > + num_pasids = pci_max_pasids(pdev); > > + if (num_pasids <= 0) > > + return -ENODEV; > > + > > + ret = pci_enable_pasid(pdev, features); > > + if (!ret) > > + master->ssid_bits = min_t(u8, ilog2(num_pasids), > > + master->smmu->ssid_bits); > so here we are ;-) > > + return ret; > > +} > > + > > +static void arm_smmu_disable_pasid(struct arm_smmu_master *master) > > +{ > > + struct pci_dev *pdev; > > + > > + if (!dev_is_pci(master->dev)) > > + return; > > + > > + pdev = to_pci_dev(master->dev); > > + > > + if (!pdev->pasid_enabled) > > + return; > > + > > + master->ssid_bits = 0; > > + pci_disable_pasid(pdev); > > +} > > + > > static void arm_smmu_detach_dev(struct arm_smmu_master *master) > > { > > unsigned long flags; > > @@ -2851,13 +2894,16 @@ static int arm_smmu_add_device(struct device *dev) > > > > master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits); > > > > + /* Note that PASID must be enabled before, and disabled after ATS */ > > + arm_smmu_enable_pasid(master); > No error handling? The device still works if PASID isn't supported or cannot be enabled, it just won't have some capabilities (IOMMU_DEV_FEAT_AUX and IOMMU_DEV_FEAT_SVA), so I don't think add_device should return an error. But it's a good point, I think at least printing an error like arm_smmu_enable_ats() does would be better. Thanks, Jean