On Mon, Oct 17, 2022 at 04:02:21PM -0700, Nicolin Chen wrote: > Following the new rules in include/linux/iommu.h kdocs, update all drivers > ->attach_dev callback functions to return EINVAL in the failure paths that > are related to domain incompatibility. > > Also, drop adjacent error prints to prevent a kernel log spam. > > Reviewed-by: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx> > Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx> > Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> > Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx> > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 +---------- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 --- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +------ > drivers/iommu/intel/iommu.c | 10 +++------- > drivers/iommu/ipmmu-vmsa.c | 2 -- > drivers/iommu/omap-iommu.c | 2 +- > drivers/iommu/sprd-iommu.c | 4 +--- > drivers/iommu/tegra-gart.c | 2 +- > drivers/iommu/virtio-iommu.c | 3 +-- > 9 files changed, 9 insertions(+), 35 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index ba47c73f5b8c..01fd7df16cb9 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -2430,23 +2430,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) > goto out_unlock; > } > } else if (smmu_domain->smmu != smmu) { > - dev_err(dev, > - "cannot attach to SMMU %s (upstream of %s)\n", > - dev_name(smmu_domain->smmu->dev), > - dev_name(smmu->dev)); > - ret = -ENXIO; > + ret = -EINVAL; > goto out_unlock; > } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && > master->ssid_bits != smmu_domain->s1_cfg.s1cdmax) { > - dev_err(dev, > - "cannot attach to incompatible domain (%u SSID bits != %u)\n", > - smmu_domain->s1_cfg.s1cdmax, master->ssid_bits); > ret = -EINVAL; > goto out_unlock; > } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && > smmu_domain->stall_enabled != master->stall_enabled) { > - dev_err(dev, "cannot attach to stall-%s domain\n", > - smmu_domain->stall_enabled ? "enabled" : "disabled"); > ret = -EINVAL; > goto out_unlock; > } I think it would be helpful to preserve these messages using dev_err_ratelimited() so that attach failure can be diagnosed without having to hack the messages back into the driver. With that: Acked-by: Will Deacon <will@xxxxxxxxxx> Will