[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YxnbRq5vaP/OL0ra@nvidia.com>
Date: Thu, 8 Sep 2022 09:08:38 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: "Tian, Kevin" <kevin.tian@...el.com>
Cc: Robin Murphy <robin.murphy@....com>,
Joerg Roedel <joro@...tes.org>,
Nicolin Chen <nicolinc@...dia.com>,
"will@...nel.org" <will@...nel.org>,
"alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
"marcan@...can.st" <marcan@...can.st>,
"sven@...npeter.dev" <sven@...npeter.dev>,
"alyssa@...enzweig.io" <alyssa@...enzweig.io>,
"robdclark@...il.com" <robdclark@...il.com>,
"dwmw2@...radead.org" <dwmw2@...radead.org>,
"baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>,
"mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
"gerald.schaefer@...ux.ibm.com" <gerald.schaefer@...ux.ibm.com>,
"orsonzhai@...il.com" <orsonzhai@...il.com>,
"baolin.wang@...ux.alibaba.com" <baolin.wang@...ux.alibaba.com>,
"zhang.lyra@...il.com" <zhang.lyra@...il.com>,
"thierry.reding@...il.com" <thierry.reding@...il.com>,
"vdumpa@...dia.com" <vdumpa@...dia.com>,
"jonathanh@...dia.com" <jonathanh@...dia.com>,
"jean-philippe@...aro.org" <jean-philippe@...aro.org>,
"cohuck@...hat.com" <cohuck@...hat.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"shameerali.kolothum.thodi@...wei.com"
<shameerali.kolothum.thodi@...wei.com>,
"thunder.leizhen@...wei.com" <thunder.leizhen@...wei.com>,
"christophe.jaillet@...adoo.fr" <christophe.jaillet@...adoo.fr>,
"yangyingliang@...wei.com" <yangyingliang@...wei.com>,
"jon@...id-run.com" <jon@...id-run.com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"asahi@...ts.linux.dev" <asahi@...ts.linux.dev>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-arm-msm@...r.kernel.org" <linux-arm-msm@...r.kernel.org>,
"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
"linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>,
"virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>
Subject: Re: [PATCH v6 1/5] iommu: Return -EMEDIUMTYPE for incompatible
domain and device/group
On Thu, Sep 08, 2022 at 09:30:57AM +0000, Tian, Kevin wrote:
> > But OK, I'm on board, lets use more common errnos with specific
> > meaning, that can be documented in a comment someplace:
> > ENOMEM - out of memory
> > ENODEV - no domain can attach, device or iommu is messed up
> > EINVAL - the domain is incompatible with the device
> > <others> - Same behavior as ENODEV, use is discouraged.
>
> There are also cases where common kAPIs are called in the attach
> path which may return -EINVAL and random errno, e.g.:
>
> omap_iommu_attach_dev()
> omap_iommu_attach()
> iommu_enable()
> pm_runtime_get_sync()
> __pm_runtime_resume()
> rpm_resume()
> if (dev->power.runtime_error) {
> retval = -EINVAL;
>
> viommu_attach_dev()
> viommu_domain_finalise()
> ida_alloc_range()
> if ((int)min < 0)
> return -ENOSPC;
Yes, this is was also on my mind with choosing an unpopular return
code, it has a higher chance of not coming out of some other kernel
API
> If we think attach_dev is a slow path and having unnecessary retries
> doesn't hurt then -EINVAL sounds a simpler option. We probably can
> just go using -EINVAL as retry indicator in vfio even w/o changing
> iommu drivers at this point. Then improve them to use consistent
> errno gradually and in a separate effort.
Given Joerg's objection I think we will do EINVAL and just live with
the imperfection.
It is not just slow path, but being inaccurate can mean extra domains
are created when they were not needed. But I think we are getting into
sufficiently unlikely territory that issue can be ignored to make
progress.
Jason
Powered by blists - more mailing lists