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 1/7] xen/arm: SMMU: Implement the add_device callback in SMMU
Date: Thu, 6 Jul 2017 02:16:33 +0000	[thread overview]
Message-ID: <DB3PR08MB01078BABEEAB1F26EC7420A49ED50@DB3PR08MB0107.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1707051056340.2919@sstabellini-ThinkPad-X260>



> -----Original Message-----
> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> Sent: 2017年7月6日 1:58
> To: Wei Chen <Wei.Chen@arm.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>; xen-devel@lists.xen.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 1/7] xen/arm: SMMU: Implement the add_device
> callback in SMMU
> 
> On Tue, 4 Jul 2017, Wei Chen wrote:
> > Hi Stefano,
> >
> > > -----Original Message-----
> > > From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> > > Sent: 2017年7月4日 5:58
> > > 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 1/7] xen/arm: SMMU: Implement the
> add_device
> > > callback in SMMU
> > >
> > > On Fri, 30 Jun 2017, Wei Chen wrote:
> > > > This add_device callback function is taking care of adding a device
> > > > to SMMU and make sure it is fully prepare to be used by the SMMU
> > > > afterwards.
> > > >
> > > > In previous code, we don't implement the add_device callback in
> > > > iommu_ops for ARM SMMU. We placed the work of add_device to
> > > > assign_device callback. The function assign_device should not care
> > > > about adding the device to an iommu_group. It might not even be
> > > > able to decide how to do that. In this patch, we move this work
> > > > back to add_device callback.
> > > >
> > > > This add_device callback is only called while we are handling all
> > > > devices for constructing the Domain0.
> > > >
> > > > Signed-off-by: Wei Chen <Wei.Chen@arm.com>
> > > > ---
> > > >  xen/drivers/passthrough/arm/smmu.c | 34 +++++++++++++++++++++++--------
> ---
> > > >  1 file changed, 23 insertions(+), 11 deletions(-)
> > > >
> > > > diff --git a/xen/drivers/passthrough/arm/smmu.c
> > > b/xen/drivers/passthrough/arm/smmu.c
> > > > index 74c09b0..2efa52d 100644
> > > > --- a/xen/drivers/passthrough/arm/smmu.c
> > > > +++ b/xen/drivers/passthrough/arm/smmu.c
> > > > @@ -2591,6 +2591,26 @@ static void arm_smmu_destroy_iommu_domain(struct
> > > iommu_domain *domain)
> > > >  	xfree(domain);
> > > >  }
> > > >
> > > > +static int arm_smmu_xen_add_device(u8 devfn, struct device*dev)
> > > > +{
> > > > +	if (dt_device_is_protected(dev->of_node)) {
> > > > +		if (!dev->archdata.iommu) {
> > > > +			dev->archdata.iommu = xzalloc(struct
> arm_smmu_xen_device);
> > > > +			if (!dev->archdata.iommu)
> > > > +				return -ENOMEM;
> > > > +		}
> > > > +
> > > > +		if (!dev_iommu_group(dev))
> > > > +			return arm_smmu_add_device(dev);
> > > > +	}
> > > > +
> > > > +	/*
> > > > +	 * Return 0 if the device is not protected to follow the behavior
> > > > +	 * of PCI add device.
> > >
> > > What does this comment mean?
> > >
> >
> > While I was looking at the iommu_add_device which is used by PCI counterpart.
> > I found it will always return 0 even for device that are not protected by an
> IOMMU.
> > I would much prefer to keep platform devices have similar behavior as PCI
> devices.
> >
> > So while I was implementing iommu_add_dt_device and arm_smmu_xen_add_device,
> I
> > returned 0 if the device is not protected by IOMMU.
> 
> I understand now. Please rephrase to:
> 
>   "Return 0 (not an error) if the device is not protected by an SMMU, to
>   match the behavior of iommu_add_device."
> 

Ok, I will do it in next version.

> 
> > >
> > > > +	 */
> > > > +	return 0;
> > > > +}
> > > > +
> > > >  static int arm_smmu_assign_dev(struct domain *d, u8 devfn,
> > > >  			       struct device *dev, u32 flag)
> > > >  {
> > > > @@ -2600,17 +2620,8 @@ static int arm_smmu_assign_dev(struct domain *d,
> u8
> > > devfn,
> > > >
> > > >  	xen_domain = dom_iommu(d)->arch.priv;
> > > >
> > > > -	if (!dev->archdata.iommu) {
> > > > -		dev->archdata.iommu = xzalloc(struct arm_smmu_xen_device);
> > > > -		if (!dev->archdata.iommu)
> > > > -			return -ENOMEM;
> > > > -	}
> > > > -
> > > > -	if (!dev_iommu_group(dev)) {
> > > > -		ret = arm_smmu_add_device(dev);
> > > > -		if (ret)
> > > > -			return ret;
> > > > -	}
> > > > +	if (!dev_iommu_group(dev))
> > > > +	    return -ENODEV;
> > > >
> > > >  	spin_lock(&xen_domain->lock);
> > > >
> > > > @@ -2784,6 +2795,7 @@ static const struct iommu_ops arm_smmu_iommu_ops =
> {
> > > >      .teardown = arm_smmu_iommu_domain_teardown,
> > > >      .iotlb_flush = arm_smmu_iotlb_flush,
> > > >      .iotlb_flush_all = arm_smmu_iotlb_flush_all,
> > > > +    .add_device = arm_smmu_xen_add_device,
> > > >      .assign_device = arm_smmu_assign_dev,
> > > >      .reassign_device = arm_smmu_reassign_dev,
> > > >      .map_page = arm_smmu_map_page,
> > > > --
> > > > 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-06  2:16 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 [this message]
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
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=DB3PR08MB01078BABEEAB1F26EC7420A49ED50@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.