iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Rick Song <songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	will.deacon-5wv7dgnIgG8@public.gmane.org,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [RFC,v1,2/2] vfio/iommu-type1: set only stage 2 translation
Date: Fri, 21 Oct 2016 08:27:03 -0600	[thread overview]
Message-ID: <20161021082703.4890c419@t450s.home> (raw)
In-Reply-To: <1477024764-79882-2-git-send-email-songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

On Fri, 21 Oct 2016 12:39:24 +0800
Rick Song <songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote:

> Normally, VFIO should use only stage 2 translation of
> iommu, to create the address mapping. If nesting translation
> is disabled from VFIO core, enable iommu domain only stage 2
> attribute, otherwise, enable iommu domain nesting attribute.
> 
> Signed-off-by: Rick Song <songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 2ba1942..c0265fe 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -741,7 +741,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
>  	struct vfio_group *group, *g;
>  	struct vfio_domain *domain, *d;
>  	struct bus_type *bus = NULL;
> -	int ret;
> +	int attr, ret;
>  
>  	mutex_lock(&iommu->lock);
>  
> @@ -775,13 +775,22 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
>  		goto out_free;
>  	}
>  
> +	/*
> +	 * Set iommu nesting domain attribute if nesting translation
> +	 * is enabled from iommu vfio, otherwise set iommu only stage
> +	 * 2 domain attribute.
> +	 */
> +	attr = 1;
>  	if (iommu->nesting) {
> -		int attr = 1;
> -
>  		ret = iommu_domain_set_attr(domain->domain, DOMAIN_ATTR_NESTING,
>  					    &attr);
>  		if (ret)
>  			goto out_domain;
> +	} else {
> +		ret = iommu_domain_set_attr(domain->domain, DOMAIN_ATTR_S2,
> +					    &attr);
> +		if (ret)
> +			goto out_domain;
>  	}

This attribute is not relevant to the majority of current users, why
would we assume that we need to call it for all non-nesting cases?  Why
do we need to set the attribute at all, what benefit does it provide?
If this is the normal case for an IOMMU API domain, why is there an
option for it at all?  Maybe this should be the default and S1
(whatever that means) should be the alternate option.  Thanks,

Alex

>  
>  	ret = iommu_attach_group(domain->domain, iommu_group);

  parent reply	other threads:[~2016-10-21 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21  4:39 [RFC,v1,1/2] iommu/arm-smmu: support s2 domain attribute Rick Song
2016-10-21  4:39 ` [RFC,v1,2/2] vfio/iommu-type1: set only stage 2 translation Rick Song
     [not found]   ` <1477024764-79882-2-git-send-email-songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-10-21 14:27     ` Alex Williamson [this message]
     [not found]       ` <20161021082703.4890c419-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2016-10-21 14:48         ` Robin Murphy

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=20161021082703.4890c419@t450s.home \
    --to=alex.williamson-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@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;
as well as URLs for NNTP newsgroup(s).