From: Kenneth Lee <liguozhu-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
To: "Tian, Kevin" <kevin.tian-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Kenneth Lee <nek.in.cn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Herbert Xu
<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
"kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
"linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Kumar,
Sanjay K"
<sanjay.k.kumar-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hao Fang <fanghao11-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
"iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org"
<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org"
<linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
Alex Williamson
<alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
"linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Philippe Ombredanne <pombredanne-od1rfyK75/E@public.gmane.org>,
Zaibo Xu <xuzaibo-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
"David S . Miller"
<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
"linux-accelerators-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org"
<linux-accelerators-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: Re: [RFC PATCH 2/7] iommu: Add share domain interface in iommu for spimdev
Date: Thu, 2 Aug 2018 12:15:47 +0800 [thread overview]
Message-ID: <20180802041547.GM160746@Turing-Arch-b> (raw)
In-Reply-To: <AADFC41AFE54684AB9EE6CBC0274A5D191290F49-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
On Thu, Aug 02, 2018 at 03:17:03AM +0000, Tian, Kevin wrote:
> Date: Thu, 2 Aug 2018 03:17:03 +0000
> From: "Tian, Kevin" <kevin.tian@intel.com>
> To: Kenneth Lee <nek.in.cn@gmail.com>, Jonathan Corbet <corbet@lwn.net>,
> Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller"
> <davem@davemloft.net>, Joerg Roedel <joro@8bytes.org>, Alex Williamson
> <alex.williamson@redhat.com>, Kenneth Lee <liguozhu@hisilicon.com>, Hao
> Fang <fanghao11@huawei.com>, Zhou Wang <wangzhou1@hisilicon.com>, Zaibo Xu
> <xuzaibo@huawei.com>, Philippe Ombredanne <pombredanne@nexb.com>, Greg
> Kroah-Hartman <gregkh@linuxfoundation.org>, Thomas Gleixner
> <tglx@linutronix.de>, "linux-doc@vger.kernel.org"
> <linux-doc@vger.kernel.org>, "linux-kernel@vger.kernel.org"
> <linux-kernel@vger.kernel.org>, "linux-crypto@vger.kernel.org"
> <linux-crypto@vger.kernel.org>, "iommu@lists.linux-foundation.org"
> <iommu@lists.linux-foundation.org>, "kvm@vger.kernel.org"
> <kvm@vger.kernel.org>, "linux-accelerators@lists.ozlabs.org"
> <linux-accelerators@lists.ozlabs.org>, Lu Baolu
> <baolu.lu@linux.intel.com>, "Kumar, Sanjay K" <sanjay.k.kumar@intel.com>
> CC: "linuxarm@huawei.com" <linuxarm@huawei.com>
> Subject: RE: [RFC PATCH 2/7] iommu: Add share domain interface in iommu for
> spimdev
> Message-ID: <AADFC41AFE54684AB9EE6CBC0274A5D191290F49@SHSMSX101.ccr.corp.intel.com>
>
> > From: Kenneth Lee
> > Sent: Wednesday, August 1, 2018 6:22 PM
> >
> > From: Kenneth Lee <liguozhu@hisilicon.com>
> >
> > This patch add sharing interface for a iommu_group. The new interface:
> >
> > iommu_group_share_domain()
> > iommu_group_unshare_domain()
> >
> > can be used by some virtual iommu_group (such as iommu_group for
> > spimdev)
> > to share their parent's iommu_group.
> >
> > When the domain of the group is shared, it cannot be changed before
> > unshared. In the future, notification can be added if update is required.
>
> Is it necessary or just asking VFIO to use parent domain directly?
>
Even we add to VFIO, the iommu still need to be changed. We can move the type1
part to VFIO if we have agreement in RFC stage.
> >
> > Signed-off-by: Kenneth Lee <liguozhu@hisilicon.com>
> > ---
> > drivers/iommu/iommu.c | 28 +++++++++++++++++++++++++++-
> > include/linux/iommu.h | 2 ++
> > 2 files changed, 29 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index 63b37563db7e..a832aafe660d 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -54,6 +54,9 @@ struct iommu_group {
> > int id;
> > struct iommu_domain *default_domain;
> > struct iommu_domain *domain;
> > + atomic_t domain_shared_ref; /* Number of user of current domain.
> > + * The domain cannot be modified if ref >
> > 0
> > + */
> > };
> >
> > struct group_device {
> > @@ -353,6 +356,7 @@ struct iommu_group *iommu_group_alloc(void)
> > return ERR_PTR(ret);
> > }
> > group->id = ret;
> > + atomic_set(&group->domain_shared_ref, 0);
> >
> > ret = kobject_init_and_add(&group->kobj, &iommu_group_ktype,
> > NULL, "%d", group->id);
> > @@ -482,6 +486,25 @@ int iommu_group_set_name(struct iommu_group
> > *group, const char *name)
> > }
> > EXPORT_SYMBOL_GPL(iommu_group_set_name);
> >
> > +struct iommu_domain *iommu_group_share_domain(struct
> > iommu_group *group)
> > +{
> > + /* the domain can be shared only when the default domain is used
> > */
> > + /* todo: more shareable check */
> > + if (group->domain != group->default_domain)
> > + return ERR_PTR(-EINVAL);
> > +
> > + atomic_inc(&group->domain_shared_ref);
> > + return group->domain;
> > +}
> > +EXPORT_SYMBOL_GPL(iommu_group_share_domain);
> > +
> > +void iommu_group_unshare_domain(struct iommu_group *group)
> > +{
> > + atomic_dec(&group->domain_shared_ref);
> > + WARN_ON(atomic_read(&group->domain_shared_ref) < 0);
> > +}
> > +EXPORT_SYMBOL_GPL(iommu_group_unshare_domain);
> > +
> > static int iommu_group_create_direct_mappings(struct iommu_group
> > *group,
> > struct device *dev)
> > {
> > @@ -1401,7 +1424,8 @@ static int __iommu_attach_group(struct
> > iommu_domain *domain,
> > {
> > int ret;
> >
> > - if (group->default_domain && group->domain != group-
> > >default_domain)
> > + if ((group->default_domain && group->domain != group-
> > >default_domain) ||
> > + atomic_read(&group->domain_shared_ref) > 0)
> > return -EBUSY;
> >
> > ret = __iommu_group_for_each_dev(group, domain,
> > @@ -1438,6 +1462,8 @@ static void __iommu_detach_group(struct
> > iommu_domain *domain,
> > {
> > int ret;
> >
> > + WARN_ON(atomic_read(&group->domain_shared_ref) > 0);
> > +
> > if (!group->default_domain) {
> > __iommu_group_for_each_dev(group, domain,
> > iommu_group_do_detach_device);
> > diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> > index 19938ee6eb31..278d60e3ec39 100644
> > --- a/include/linux/iommu.h
> > +++ b/include/linux/iommu.h
> > @@ -349,6 +349,8 @@ extern int iommu_domain_get_attr(struct
> > iommu_domain *domain, enum iommu_attr,
> > void *data);
> > extern int iommu_domain_set_attr(struct iommu_domain *domain, enum
> > iommu_attr,
> > void *data);
> > +extern struct iommu_domain *iommu_group_share_domain(struct
> > iommu_group *group);
> > +extern void iommu_group_unshare_domain(struct iommu_group *group);
> >
> > /* Window handling function prototypes */
> > extern int iommu_domain_window_enable(struct iommu_domain
> > *domain, u32 wnd_nr,
> > --
> > 2.17.1
--
-Kenneth(Hisilicon)
================================================================================
本邮件及其附件含有华为公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁
止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中
的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件!
This e-mail and its attachments contain confidential information from HUAWEI,
which is intended only for the person or entity whose address is listed above.
Any use of the
information contained herein in any way (including, but not limited to, total or
partial disclosure, reproduction, or dissemination) by persons other than the
intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify
the sender by phone or email immediately and delete it!
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2018-08-02 4:15 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-01 10:22 [RFC PATCH 0/7] A General Accelerator Framework, WarpDrive Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 1/7] vfio/spimdev: Add documents for WarpDrive framework Kenneth Lee
[not found] ` <20180801102221.5308-2-nek.in.cn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-08-02 3:14 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D191290F04-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-08-02 4:22 ` Kenneth Lee
2018-08-02 4:41 ` Tian, Kevin
2018-08-06 12:27 ` Pavel Machek
[not found] ` <20180806122733.GA17232-5NIqAleC692hcjWhqY66xCZi+YwRKgec@public.gmane.org>
2018-08-08 1:43 ` Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 2/7] iommu: Add share domain interface in iommu for spimdev Kenneth Lee
[not found] ` <20180801102221.5308-3-nek.in.cn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-08-02 3:17 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D191290F49-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-08-02 4:15 ` Kenneth Lee [this message]
2018-08-02 4:39 ` Tian, Kevin
2018-08-08 9:13 ` Joerg Roedel
[not found] ` <20180808091354.ppqgineql3pufwwr-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2018-08-09 1:09 ` Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 3/7] vfio: add spimdev support Kenneth Lee
2018-08-01 16:23 ` Randy Dunlap
[not found] ` <d11c7745-2f31-0f33-1bd8-78379dc66e6e-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2018-08-02 3:07 ` Kenneth Lee
2018-08-02 3:21 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D191290F7B-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-08-02 3:47 ` Kenneth Lee
2018-08-02 4:24 ` Tian, Kevin
2018-08-02 7:34 ` Kenneth Lee
2018-08-02 8:35 ` Cornelia Huck
[not found] ` <20180802103528.0b863030.cohuck-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-08-02 18:43 ` Alex Williamson
[not found] ` <20180802124327.403b10ab-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2018-08-06 1:40 ` Kenneth Lee
2018-08-06 15:49 ` Alex Williamson
2018-08-06 16:34 ` Raj, Ashok
2018-08-06 17:05 ` Alex Williamson
[not found] ` <20180806110521.0b708e0b-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2018-08-08 1:32 ` Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 4/7] crypto: add hisilicon Queue Manager driver Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 5/7] crypto: Add Hisilicon Zip driver Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 6/7] crypto: add spimdev support to Hisilicon QM Kenneth Lee
2018-08-01 10:22 ` [RFC PATCH 7/7] vfio/spimdev: add user sample for spimdev Kenneth Lee
[not found] ` <20180801102221.5308-1-nek.in.cn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-08-01 16:56 ` [RFC PATCH 0/7] A General Accelerator Framework, WarpDrive Jerome Glisse
[not found] ` <20180801165644.GA3820-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-08-02 2:33 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D191290E1A-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-08-02 4:05 ` Kenneth Lee
2018-08-02 14:22 ` Jerome Glisse
[not found] ` <20180802142243.GA3481-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-08-03 3:47 ` Kenneth Lee
2018-08-03 14:39 ` Jerome Glisse
[not found] ` <20180803143944.GA4079-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-08-06 3:12 ` Kenneth Lee
2018-08-06 15:32 ` Jerome Glisse
2018-08-08 1:08 ` Kenneth Lee
[not found] ` <11bace0e-dc14-5d2c-f65c-25b852f4e9ca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-08-08 15:18 ` Jerome Glisse
2018-08-09 8:03 ` Kenneth Lee
2018-08-09 8:31 ` Tian, Kevin
2018-08-10 1:37 ` Kenneth Lee
2018-08-09 14:46 ` Jerome Glisse
[not found] ` <20180809144613.GB3386-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-08-10 3:39 ` Kenneth Lee
2018-08-10 13:12 ` Jean-Philippe Brucker
[not found] ` <0f6bac9b-8381-1874-9367-46b5f4cef56e-5wv7dgnIgG8@public.gmane.org>
2018-08-11 15:26 ` Kenneth Lee
2018-08-13 9:29 ` Kenneth Lee
2018-08-13 19:23 ` Jerome Glisse
2018-08-14 3:46 ` Kenneth Lee
2018-08-10 14:32 ` Jerome Glisse
2018-08-11 14:44 ` Kenneth Lee
2018-08-02 10:10 ` Alan Cox
2018-08-02 12:24 ` Xu Zaibo
2018-08-02 14:46 ` Jerome Glisse
[not found] ` <20180802144627.GB3481-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-08-03 14:20 ` Alan Cox
2018-08-03 14:55 ` Jerome Glisse
2018-08-06 1:26 ` Kenneth Lee
2018-08-02 2:59 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D191290EB3-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-08-02 3:40 ` Kenneth Lee
2018-08-02 4:36 ` Tian, Kevin
2018-08-02 5:35 ` Kenneth Lee
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=20180802041547.GM160746@Turing-Arch-b \
--to=liguozhu-c8/m+/jpzteamjb+lgu22q@public.gmane.org \
--cc=alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=corbet-T1hC0tSOHrs@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=fanghao11-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=kevin.tian-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-accelerators-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=nek.in.cn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=pombredanne-od1rfyK75/E@public.gmane.org \
--cc=sanjay.k.kumar-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
--cc=xuzaibo-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
/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