Re: [PATCH v2 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group

Nicolin Chen
2022-06-16T02:40:20Z

On Thu, Jun 16, 2022 at 10:09:49AM +0800, Baolu Lu wrote:
> External email: Use caution opening links or attachments
>
>
> On 2022/6/16 08:03, Nicolin Chen wrote:
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index 44016594831d..0dd13330fe12 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -4323,7 +4323,7 @@ static int prepare_domain_attach_device(struct iommu_domain *domain,
> > return -ENODEV;
> >
> > if (dmar_domain->force_snooping && !ecap_sc_support(iommu->ecap))
> > - return -EOPNOTSUPP;
> > + return -EMEDIUMTYPE;
> >
> > /* check if this iommu agaw is sufficient for max mapped address */
> > addr_width = agaw_to_width(iommu->agaw);
> > @@ -4331,10 +4331,10 @@ static int prepare_domain_attach_device(struct iommu_domain *domain,
> > addr_width = cap_mgaw(iommu->cap);
> >
> > if (dmar_domain->max_addr > (1LL << addr_width)) {
> > - dev_err(dev, "%s: iommu width (%d) is not "
> > + dev_dbg(dev, "%s: iommu width (%d) is not "
> > "sufficient for the mapped address (%llx)\n",
> > __func__, addr_width, dmar_domain->max_addr);
> > - return -EFAULT;
> > + return -EMEDIUMTYPE;
> > }
> > dmar_domain->gaw = addr_width;
>
> Can we simply remove the dev_err()? As the return value has explicitly
> explained the failure reason, putting a print statement won't help much.

Yes. As long as no one has objection, I can remove that in the next
version.