From: Nicolin Chen <nicolinc@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "jgg@nvidia.com" <jgg@nvidia.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"will@kernel.org" <will@kernel.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
"shuah@kernel.org" <shuah@kernel.org>,
"Liu, Yi L" <yi.l.liu@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
"farman@linux.ibm.com" <farman@linux.ibm.com>
Subject: Re: [PATCH v5 2/4] iommufd: Add iommufd_access_replace() API
Date: Fri, 24 Mar 2023 10:02:27 -0700 [thread overview]
Message-ID: <ZB3Xo576l33OH/S/@Asurada-Nvidia> (raw)
In-Reply-To: <BN9PR11MB5276E7E2BA88DD54DC5EE99A8C849@BN9PR11MB5276.namprd11.prod.outlook.com>
On Fri, Mar 24, 2023 at 03:02:46AM +0000, Tian, Kevin wrote:
> External email: Use caution opening links or attachments
>
>
> > From: Nicolin Chen <nicolinc@nvidia.com>
> > Sent: Thursday, March 23, 2023 4:33 PM
> >
> > +int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id)
> > +{
> > + struct iommufd_ioas *new_ioas;
> > +
> > + mutex_lock(&access->ioas_lock);
> > + if (!access->ioas) {
> > mutex_unlock(&access->ioas_lock);
> > - iommufd_put_object(obj);
> > - return rc;
> > + return -ENOENT;
> > + }
> > + if (access->ioas->obj.id == ioas_id) {
> > + mutex_unlock(&access->ioas_lock);
> > + return 0;
> > }
> > - iommufd_ref_to_users(obj);
> >
> > + new_ioas = iommufd_access_change_pt(access, ioas_id);
> > + if (IS_ERR(new_ioas)) {
> > + mutex_unlock(&access->ioas_lock);
> > + return PTR_ERR(new_ioas);
> > + }
> > + __iommufd_access_detach(access);
> > access->ioas = new_ioas;
> > access->ioas_unpin = new_ioas;
>
> Above three lines can be moved into iommufd_access_change_pt():
>
> If (access->ioas)
> __iommufd_access_detach(access);
> access->ioas = new_ioas;
> access->ioas_unpin = new_ioas;
>
> Then both attach/replace can end by calling the common function.
OK. Will do that in v6.
Thanks
Nicolin
next prev parent reply other threads:[~2023-03-24 17:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 8:33 [PATCH v5 0/4] cover-letter: Add IO page table replacement support Nicolin Chen
2023-03-23 8:33 ` [PATCH v5 1/4] vfio: Do not allow !ops->dma_unmap in vfio_pin/unpin_pages() Nicolin Chen
2023-03-23 8:33 ` [PATCH v5 2/4] iommufd: Add iommufd_access_replace() API Nicolin Chen
2023-03-24 3:02 ` Tian, Kevin
2023-03-24 17:02 ` Nicolin Chen [this message]
2023-03-23 8:33 ` [PATCH v5 3/4] iommufd/selftest: Add IOMMU_TEST_OP_ACCESS_REPLACE_IOAS coverage Nicolin Chen
2023-03-23 8:33 ` [PATCH v5 4/4] vfio: Support IO page table replacement Nicolin Chen
2023-03-24 3:04 ` Tian, Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZB3Xo576l33OH/S/@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=farman@linux.ibm.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=robin.murphy@arm.com \
--cc=shuah@kernel.org \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox