iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Magnus Damm <magnus.damm@gmail.com>,
	iommu@lists.linux-foundation.org,
	laurent.pinchart+renesas@ideasonboard.com,
	geert+renesas@glider.be, joro@8bytes.org,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	horms+renesas@verge.net.au, m.szyprowski@samsung.com
Subject: Re: [PATCH v6 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access
Date: Fri, 11 Nov 2016 03:27:38 +0200	[thread overview]
Message-ID: <4483634.D6YpsPD8PO@avalon> (raw)
In-Reply-To: <792320ab-13ae-741e-7202-1e7983e0b7a4@arm.com>

Hello,

On Friday 21 Oct 2016 18:32:54 Robin Murphy wrote:
> On 20/10/16 00:36, Magnus Damm wrote:
> > From: Magnus Damm <damm+renesas@opensource.se>
> > 
> > Not all architectures have an iommu member in their archdata, so
> > use #ifdefs support build wit COMPILE_TEST on any architecture.
> 
> As an alternative to this we could now use iommu_fwspec in place of the
> custom ipmmu_vmsa_archdata - that's deliberately
> architecture-independent. I converted the Mediatek drivers[1] as an
> example to stand separately from the big SMMU rework, as those are the
> ones I'm most familiar with, but it looks like the IPMMU is a similarly
> perfect fit.
> 
> Of course, that could always come afterwards as a cleanup - I wouldn't
> consider it a blocker at this point - but it does look like it might
> simplify some of the code being moved around in this series if it were
> to be done beforehand.

I like the suggestion, it looks much cleaner. It would also allow implementing 
.of_xlate() in a cleaner fashion. I don't think it needs to block this series, 
but if Magnus ends up sending a v7 to address all the other small comments, it 
would be worth a shot.

> [1]:http://www.mail-archive.com/iommu@lists.linux-foundation.org/msg14577.ht
> ml
> > Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
> > Reviewed-by: Joerg Roedel <jroedel@suse.de>
> > ---
> > 
> >  Changes since V5:
> >  - None
> >  
> >  Changes since V4:
> >  - None
> >  
> >  Changes since V3:
> >  - New patch
> >  
> >  drivers/iommu/ipmmu-vmsa.c |   37 +++++++++++++++++++++++++++----------
> >  1 file changed, 27 insertions(+), 10 deletions(-)
> > 
> > --- 0012/drivers/iommu/ipmmu-vmsa.c
> > +++ work/drivers/iommu/ipmmu-vmsa.c	2016-09-20 21:59:21.690607110 +0900
> > @@ -70,6 +70,25 @@ static struct ipmmu_vmsa_domain *to_vmsa
> > 
> >  	return container_of(dom, struct ipmmu_vmsa_domain, io_domain);
> >  
> >  }
> > 
> > +#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
> > +static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev)
> > +{
> > +	return dev->archdata.iommu;
> > +}
> > +static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata
> > *p) +{
> > +	dev->archdata.iommu = p;
> > +}
> > +#else
> > +static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev)
> > +{
> > +	return NULL;
> > +}
> > +static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata
> > *p) +{
> > +}
> > +#endif
> > +
> > 
> >  #define TLB_LOOP_TIMEOUT		100	/* 100us */
> >  
> >  /*
> >  ------------------------------------------------------------------------
> >  -----> 
> > @@ -539,7 +558,7 @@ static void ipmmu_domain_free(struct iom
> > 
> >  static int ipmmu_attach_device(struct iommu_domain *io_domain,
> >  
> >  			       struct device *dev)
> >  
> >  {
> > 
> > -	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
> > +	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
> > 
> >  	struct ipmmu_vmsa_device *mmu = archdata->mmu;
> >  	struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
> >  	unsigned long flags;
> > 
> > @@ -581,7 +600,7 @@ static int ipmmu_attach_device(struct io
> > 
> >  static void ipmmu_detach_device(struct iommu_domain *io_domain,
> >  
> >  				struct device *dev)
> >  
> >  {
> > 
> > -	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
> > +	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
> > 
> >  	struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
> >  	unsigned int i;
> > 
> > @@ -701,7 +720,7 @@ static int ipmmu_init_platform_device(st
> > 
> >  	archdata->mmu = mmu;
> >  	archdata->utlbs = utlbs;
> >  	archdata->num_utlbs = num_utlbs;
> > 
> > -	dev->archdata.iommu = archdata;
> > +	set_archdata(dev, archdata);
> > 
> >  	return 0;
> >  
> >  error:
> > @@ -713,12 +732,11 @@ error:
> >  static int ipmmu_add_device(struct device *dev)
> >  {
> > 
> > -	struct ipmmu_vmsa_archdata *archdata;
> > 
> >  	struct ipmmu_vmsa_device *mmu = NULL;
> >  	struct iommu_group *group;
> >  	int ret;
> > 
> > -	if (dev->archdata.iommu) {
> > +	if (to_archdata(dev)) {
> > 
> >  		dev_warn(dev, "IOMMU driver already assigned to device %s\n",
> >  		
> >  			 dev_name(dev));
> >  		
> >  		return -EINVAL;
> > 
> > @@ -754,8 +772,7 @@ static int ipmmu_add_device(struct devic
> > 
> >  	 * - Make the mapping size configurable ? We currently use a 2GB 
mapping
> >  	 *   at a 1GB offset to ensure that NULL VAs will fault.
> >  	 */
> > 
> > -	archdata = dev->archdata.iommu;
> > -	mmu = archdata->mmu;
> > +	mmu = to_archdata(dev)->mmu;
> > 
> >  	if (!mmu->mapping) {
> >  	
> >  		struct dma_iommu_mapping *mapping;
> > 
> > @@ -783,7 +800,7 @@ error:
> >  	if (mmu)
> >  	
> >  		arm_iommu_release_mapping(mmu->mapping);
> > 
> > -	dev->archdata.iommu = NULL;
> > +	set_archdata(dev, NULL);
> > 
> >  	if (!IS_ERR_OR_NULL(group))
> >  	
> >  		iommu_group_remove_device(dev);
> > 
> > @@ -793,7 +810,7 @@ error:
> >  static void ipmmu_remove_device(struct device *dev)
> >  {
> > 
> > -	struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
> > +	struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
> > 
> >  	arm_iommu_detach_device(dev);
> >  	iommu_group_remove_device(dev);
> > 
> > @@ -801,7 +818,7 @@ static void ipmmu_remove_device(struct d
> > 
> >  	kfree(archdata->utlbs);
> >  	kfree(archdata);
> > 
> > -	dev->archdata.iommu = NULL;
> > +	set_archdata(dev, NULL);
> > 
> >  }
> >  
> >  static struct iommu_domain *ipmmu_domain_alloc(unsigned type)

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2016-11-11  1:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19 23:35 [PATCH v6 00/07] iommu/ipmmu-vmsa: IPMMU multi-arch update V6 Magnus Damm
2016-10-19 23:35 ` [PATCH v6 01/07] iommu/ipmmu-vmsa: Remove platform data handling Magnus Damm
2016-10-19 23:35 ` [PATCH v6 02/07] iommu/ipmmu-vmsa: Rework interrupt code and use bitmap for context Magnus Damm
2016-11-11  0:46   ` Laurent Pinchart
2016-10-19 23:36 ` [PATCH v6 03/07] iommu/ipmmu-vmsa: Break out utlb parsing code Magnus Damm
2016-11-11  1:00   ` Laurent Pinchart
2016-10-19 23:36 ` [PATCH v6 04/07] iommu/ipmmu-vmsa: Break out domain allocation code Magnus Damm
2016-11-11  1:02   ` Laurent Pinchart
2016-10-19 23:36 ` [PATCH v6 05/07] iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops Magnus Damm
2016-10-21 17:52   ` Robin Murphy
2016-11-10 11:42     ` Joerg Roedel
     [not found]       ` <20161110114206.GC9996-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2016-11-11  1:13         ` Laurent Pinchart
2016-11-11 10:37           ` Joerg Roedel
2016-11-11  1:50     ` Laurent Pinchart
2016-11-11 14:44       ` Robin Murphy
     [not found]         ` <dbb87293-4760-607f-841c-368a5692ecc9-5wv7dgnIgG8@public.gmane.org>
2016-11-12  1:57           ` Laurent Pinchart
2016-11-11  1:24   ` Laurent Pinchart
2016-11-11  2:01   ` [PATCH] iommu/ipmmu-vmsa: Unify domain alloc/free implementations Laurent Pinchart
2016-10-19 23:36 ` [PATCH v6 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access Magnus Damm
2016-10-21 17:32   ` Robin Murphy
2016-11-11  1:27     ` Laurent Pinchart [this message]
2016-10-19 23:36 ` [PATCH v6 07/07] iommu/ipmmu-vmsa: Drop LPAE Kconfig dependency Magnus Damm
2016-11-10 11:42 ` [PATCH v6 00/07] iommu/ipmmu-vmsa: IPMMU multi-arch update V6 Joerg Roedel

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=4483634.D6YpsPD8PO@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=geert+renesas@glider.be \
    --cc=horms+renesas@verge.net.au \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=magnus.damm@gmail.com \
    --cc=robin.murphy@arm.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;
as well as URLs for NNTP newsgroup(s).