All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Chen <Wei.Chen@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Kaly Xin <Kaly.Xin@arm.com>, Julien Grall <Julien.Grall@arm.com>,
	Steve Capper <Steve.Capper@arm.com>, nd <nd@arm.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 2/7] xen/arm: SMMU: Introduce a helper to add DT device to SMMU
Date: Tue, 4 Jul 2017 05:45:13 +0000	[thread overview]
Message-ID: <DB3PR08MB01079FCD623521FCB208DCD49ED70@DB3PR08MB0107.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1707031458340.2919@sstabellini-ThinkPad-X260>

Hi Stefano,

> -----Original Message-----
> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> Sent: 2017年7月4日 6:03
> To: Wei Chen <Wei.Chen@arm.com>
> Cc: xen-devel@lists.xen.org; sstabellini@kernel.org; Steve Capper
> <Steve.Capper@arm.com>; Kaly Xin <Kaly.Xin@arm.com>; Julien Grall
> <Julien.Grall@arm.com>; nd <nd@arm.com>
> Subject: Re: [Xen-devel] [PATCH 2/7] xen/arm: SMMU: Introduce a helper to add
> DT device to SMMU
> 
> On Fri, 30 Jun 2017, Wei Chen wrote:
> > In current code, we only have the iommu_add_device to add PCI device
> > to IOMMU. But for ARM SMMU, we don't have a separate helper to add
> > platform device with device tree to SMMU. This work was included in
> > the iommu_assign_dt_device. But sometimes, we just want to add device
> > to SMMU to do some preparation for further use. In this case, we can't
> > call iommu_assign_dt_device.
> >
> > In previous patch, we have implement the add_device callback for SMMU,
> > so we can separate this work from assign_device now.
> >
> > Signed-off-by: Wei Chen <Wei.Chen@arm.com>
> > ---
> >  xen/drivers/passthrough/device_tree.c | 20 ++++++++++++++++++++
> >  xen/include/xen/iommu.h               |  1 +
> >  2 files changed, 21 insertions(+)
> >
> > diff --git a/xen/drivers/passthrough/device_tree.c
> b/xen/drivers/passthrough/device_tree.c
> > index 99ed49e..a8f403a 100644
> > --- a/xen/drivers/passthrough/device_tree.c
> > +++ b/xen/drivers/passthrough/device_tree.c
> > @@ -24,6 +24,26 @@
> >
> >  static spinlock_t dtdevs_lock = SPIN_LOCK_UNLOCKED;
> >
> > +int iommu_add_dt_device(struct domain *d, struct dt_device_node *dev)
> > +{
> > +    int rc;
> > +
> > +    struct domain_iommu *hd = dom_iommu(d);
> > +
> > +    if ( !iommu_enabled || !hd->platform_ops ||
> > +         !hd->platform_ops->add_device )
> > +        return 0;
> 
> Shouldn't we also have:
> 
>   if ( !dt_device_is_protected(dev) )
>         return 0;
> 
> ?
> 

When we're using the legacy binding, the master IDs will be registered to SMMU and
the protected flag of relevant master devices will be set to true (dt_device_is_protected
will return true). But for generic IOMMU bindings, before we call ops->add_device,
we didn't register the master device's master id to SMMU and hadn't set the protected
flag, The dt_device_is_protected will always return false.

In this case, we can't call dt_device_is_protected(dev) here.

> 
> > +    spin_lock(&dtdevs_lock);
> > +
> > +    /* The devfn field doesn't matter to DT device. */
> > +    rc = hd->platform_ops->add_device(0, dt_to_dev(dev));
> > +
> > +    spin_unlock(&dtdevs_lock);
> > +
> > +    return rc;
> > +}
> > +
> >  int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev)
> >  {
> >      int rc = -EBUSY;
> > diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> > index 5803e3f..ec03faa 100644
> > --- a/xen/include/xen/iommu.h
> > +++ b/xen/include/xen/iommu.h
> > @@ -132,6 +132,7 @@ void iommu_read_msi_from_ire(struct msi_desc *msi_desc,
> struct msi_msg *msg);
> >  #ifdef CONFIG_HAS_DEVICE_TREE
> >  #include <xen/device_tree.h>
> >
> > +int iommu_add_dt_device(struct domain *d, struct dt_device_node *dev);
> >  int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev);
> >  int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev);
> >  int iommu_dt_domain_init(struct domain *d);
> > --
> > 2.7.4
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > https://lists.xen.org/xen-devel
> >

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-07-04  5:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30  3:15 [PATCH 0/7] Generic IOMMU bindings support for Xen platform devices Wei Chen
2017-06-30  3:15 ` [PATCH 1/7] xen/arm: SMMU: Implement the add_device callback in SMMU Wei Chen
2017-07-03 21:58   ` Stefano Stabellini
2017-07-04  5:37     ` Wei Chen
2017-07-05 17:57       ` Stefano Stabellini
2017-07-06  2:16         ` Wei Chen
2017-07-04 15:40   ` Julien Grall
2017-07-05  7:06     ` Wei Chen
2017-06-30  3:15 ` [PATCH 2/7] xen/arm: SMMU: Introduce a helper to add DT device to SMMU Wei Chen
2017-07-03 22:02   ` Stefano Stabellini
2017-07-04  5:45     ` Wei Chen [this message]
2017-07-05 18:02       ` Stefano Stabellini
2017-07-06  2:20         ` Wei Chen
2017-06-30  3:15 ` [PATCH 3/7] xen/arm: Prepare SMMU resources for protected devices Wei Chen
2017-07-03 22:05   ` Stefano Stabellini
2017-06-30  3:15 ` [PATCH 4/7] xen/arm: SMMU: Detect types of device tree binding Wei Chen
2017-07-03 22:30   ` Stefano Stabellini
2017-07-04  6:20     ` Wei Chen
2017-07-05 18:08       ` Stefano Stabellini
2017-07-06  2:25         ` Wei Chen
2017-06-30  3:15 ` [PATCH 5/7] xen/arm: SMMU: Keep registering legacy master in SMMU probe Wei Chen
2017-07-03 22:32   ` Stefano Stabellini
2017-06-30  3:15 ` [PATCH 6/7] xen/arm: SMMU: Support generic IOMMU bindings Wei Chen
2017-07-03 22:59   ` Stefano Stabellini
2017-07-04  6:27     ` Wei Chen
2017-07-04  7:26       ` Julien Grall
2017-07-05  7:04         ` Wei Chen
2017-07-05 13:07           ` Julien Grall
2017-07-06  2:11             ` Wei Chen
2017-07-05 18:15           ` Stefano Stabellini
2017-07-06  2:45             ` Wei Chen
2017-06-30  3:15 ` [PATCH 7/7] xen: Fix a typo in error message of iommu_do_dt_domctl Wei Chen
2017-07-03 21:53   ` Stefano Stabellini

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=DB3PR08MB01079FCD623521FCB208DCD49ED70@DB3PR08MB0107.eurprd08.prod.outlook.com \
    --to=wei.chen@arm.com \
    --cc=Julien.Grall@arm.com \
    --cc=Kaly.Xin@arm.com \
    --cc=Steve.Capper@arm.com \
    --cc=nd@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.