On Mon, Jul 08, 2019 at 09:58:16AM +0200, Auger Eric wrote: > > + ret = pci_enable_pasid(pdev, features); > > + if (!ret) > > + master->ssid_bits = min_t(u8, ilog2(num_pasids), > > + master->smmu->ssid_bits); > I don't really get why this setting is conditional to the success of > pci_enabled_pasid and not num_pasids > 0. num_pasids only contains the value of the PCIe PASID capability. If pci_enable_pasid() fails then we want to leave master->ssid_bits to 0 so that we report to users that SVA and AUXD aren't supported. > If it fails the ssid_bits is set to min(smmu->ssid_bits, > fwspec->num_pasid_bits) anyway. > > > + 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; > > + > > + pci_disable_pasid(pdev); > > + master->ssid_bits = 0; > in case of a platform device you leave the ssid_bits to a value != 0. Is > that what you want? Yes, this is only for PCI devices, there is no standard way of disabling PASID in platform devices. We just take whatever the firmware gives us. > > +} > > + > > static void arm_smmu_detach_dev(struct arm_smmu_master *master) > > { > > unsigned long flags; > > @@ -2413,6 +2456,9 @@ 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); > In case the call fails, don't you want to handle the error and reset the > ssid_bits? This function fails if the device doesn't support PASID, and we leave ssid_bits to 0. That said, I think it would be nicer to move the above line (that deals with fwspec) into arm_smmu_enable_pasid() Thanks, Jean