All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Tomasz Figa <tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: Olav Haugan <ohaugan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Alexandre Courbot
	<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Tomeu Vizoso
	<tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>,
	Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	Antonios Motakis
	<a.motakis-lrHrjnjw1UfHK3s98zE1ajGjJy/sRE9J@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
	Mikko Perttunen
	<mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>,
	Russell King <rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Vince Hsu <vince.h-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [RFC PATCH 1/3] iommu: Add support for out of band flushing
Date: Tue, 29 Sep 2015 11:32:57 +0200	[thread overview]
Message-ID: <20150929093257.GE9460@ulmo.nvidia.com> (raw)
In-Reply-To: <1443504379-31841-2-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 2148 bytes --]

On Tue, Sep 29, 2015 at 02:25:24PM +0900, Tomasz Figa wrote:
> This patch adds a new "flush" callback to iommu_ops, which is supposed
> to perform any necessary flushes within given IOMMU domain to make any
> changes to mappings of given area [iova; iova + size) be reflected to
> IOMMU clients.
> 
> The purpose is to let IOMMU drivers skip page-by-page flushes and
> replace it with one flush of full address range on devices which support
> it.
> 
> Signed-off-by: Tomasz Figa <tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> ---
>  drivers/iommu/iommu.c | 33 ++++++++++++++++++++++++++++++---
>  include/linux/iommu.h |  2 ++
>  2 files changed, 32 insertions(+), 3 deletions(-)

I seem to remember that Rob Clark had proposed something like this back
before it was decided to introduce the ->map_sg() callback instead. I
can't find a reference to the discussion, so perhaps I'm misremembering
but adding Rob Clark in case he has any recollection of why the outcome
was what it was.

> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
[...]
> @@ -1389,6 +1410,7 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
>  		unmapped += unmapped_page;
>  	}
>  
> +	iommu_flush(domain, orig_iova, unmapped);
>  	trace_unmap(orig_iova, size, unmapped);
>  	return unmapped;
>  }
> @@ -1419,19 +1441,24 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
>  		if (!IS_ALIGNED(s->offset, min_pagesz))
>  			goto out_err;
>  
> -		ret = iommu_map(domain, iova + mapped, phys, s->length, prot);
> +		ret = __iommu_map(domain, iova + mapped, phys, s->length, prot);
>  		if (ret)
>  			goto out_err;
>  
>  		mapped += s->length;
>  	}
>  
> +	iommu_flush(domain, iova, mapped);
> +
>  	return mapped;
>  
>  out_err:
>  	/* undo mappings already done */
>  	iommu_unmap(domain, iova, mapped);
>  
> +	/* flush in case part of our mapping already got cached */
> +	iommu_flush(domain, iova, mapped);
> +
>  	return 0;
>  
>  }

iommu_unmap() already does an iommu_flush(), so why flush again after
iommu_unmap()?

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: Tomasz Figa <tfiga@chromium.org>
Cc: iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>,
	Hiroshi Doyu <hdoyu@nvidia.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	Vince Hsu <vince.h@nvidia.com>,
	Russell King <rmk+kernel@arm.linux.org.uk>,
	Paul Walmsley <paul@pwsan.com>,
	Mikko Perttunen <mperttunen@nvidia.com>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Will Deacon <will.deacon@arm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Antonios Motakis <a.motakis@virtualopensystems.com>,
	Olav Haugan <ohaugan@codeaurora.org>,
	Nicolas Iooss <nicolas.iooss_linux@m4x.org>,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Rob Clark <robdclark@gmail.com>
Subject: Re: [RFC PATCH 1/3] iommu: Add support for out of band flushing
Date: Tue, 29 Sep 2015 11:32:57 +0200	[thread overview]
Message-ID: <20150929093257.GE9460@ulmo.nvidia.com> (raw)
In-Reply-To: <1443504379-31841-2-git-send-email-tfiga@chromium.org>

[-- Attachment #1: Type: text/plain, Size: 2121 bytes --]

On Tue, Sep 29, 2015 at 02:25:24PM +0900, Tomasz Figa wrote:
> This patch adds a new "flush" callback to iommu_ops, which is supposed
> to perform any necessary flushes within given IOMMU domain to make any
> changes to mappings of given area [iova; iova + size) be reflected to
> IOMMU clients.
> 
> The purpose is to let IOMMU drivers skip page-by-page flushes and
> replace it with one flush of full address range on devices which support
> it.
> 
> Signed-off-by: Tomasz Figa <tfiga@chromium.org>
> ---
>  drivers/iommu/iommu.c | 33 ++++++++++++++++++++++++++++++---
>  include/linux/iommu.h |  2 ++
>  2 files changed, 32 insertions(+), 3 deletions(-)

I seem to remember that Rob Clark had proposed something like this back
before it was decided to introduce the ->map_sg() callback instead. I
can't find a reference to the discussion, so perhaps I'm misremembering
but adding Rob Clark in case he has any recollection of why the outcome
was what it was.

> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
[...]
> @@ -1389,6 +1410,7 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
>  		unmapped += unmapped_page;
>  	}
>  
> +	iommu_flush(domain, orig_iova, unmapped);
>  	trace_unmap(orig_iova, size, unmapped);
>  	return unmapped;
>  }
> @@ -1419,19 +1441,24 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
>  		if (!IS_ALIGNED(s->offset, min_pagesz))
>  			goto out_err;
>  
> -		ret = iommu_map(domain, iova + mapped, phys, s->length, prot);
> +		ret = __iommu_map(domain, iova + mapped, phys, s->length, prot);
>  		if (ret)
>  			goto out_err;
>  
>  		mapped += s->length;
>  	}
>  
> +	iommu_flush(domain, iova, mapped);
> +
>  	return mapped;
>  
>  out_err:
>  	/* undo mappings already done */
>  	iommu_unmap(domain, iova, mapped);
>  
> +	/* flush in case part of our mapping already got cached */
> +	iommu_flush(domain, iova, mapped);
> +
>  	return 0;
>  
>  }

iommu_unmap() already does an iommu_flush(), so why flush again after
iommu_unmap()?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-09-29  9:32 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29  5:25 [RFC PATCH 0/3] iommu: Add range flush operation Tomasz Figa
2015-09-29  5:25 ` Tomasz Figa
     [not found] ` <1443504379-31841-1-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-09-29  5:25   ` [RFC PATCH 1/3] iommu: Add support for out of band flushing Tomasz Figa
2015-09-29  5:25     ` Tomasz Figa
     [not found]     ` <1443504379-31841-2-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-09-29  9:32       ` Thierry Reding [this message]
2015-09-29  9:32         ` Thierry Reding
     [not found]         ` <20150929093257.GE9460-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-09-29 11:56           ` Tomasz Figa
2015-09-29 11:56             ` Tomasz Figa
2015-09-29  5:25   ` [RFC PATCH 2/3] memory: tegra: add TLB cache line size Tomasz Figa
2015-09-29  5:25     ` Tomasz Figa
     [not found]     ` <1443504379-31841-3-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-09-29  9:43       ` Thierry Reding
2015-09-29  9:43         ` Thierry Reding
     [not found]         ` <20150929094348.GF9460-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-09-29 12:11           ` Tomasz Figa
2015-09-29 12:11             ` Tomasz Figa
2015-09-29  5:25   ` [RFC PATCH 3/3] iommu/tegra-smmu: Make the driver use out of band flushing Tomasz Figa
2015-09-29  5:25     ` Tomasz Figa
2015-09-29  9:27   ` [RFC PATCH 0/3] iommu: Add range flush operation Thierry Reding
2015-09-29  9:27     ` Thierry Reding
     [not found]     ` <20150929092714.GD9460-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-09-29 11:54       ` Tomasz Figa
2015-09-29 11:54         ` Tomasz Figa
2015-09-29 12:22       ` Joerg Roedel
2015-09-29 12:22         ` Joerg Roedel
2015-09-29 12:20   ` Joerg Roedel
2015-09-29 12:20     ` Joerg Roedel
2015-09-29 14:20   ` Robin Murphy
2015-09-29 14:20     ` Robin Murphy
     [not found]     ` <560A9E36.9030903-5wv7dgnIgG8@public.gmane.org>
2015-09-29 14:32       ` Russell King - ARM Linux
2015-09-29 14:32         ` Russell King - ARM Linux
     [not found]         ` <20150929143241.GI21513-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2015-09-29 16:27           ` Robin Murphy
2015-09-29 16:27             ` Robin Murphy
     [not found]             ` <560ABBE0.8020805-5wv7dgnIgG8@public.gmane.org>
2015-09-29 16:40               ` Russell King - ARM Linux
2015-09-29 16:40                 ` Russell King - ARM Linux
     [not found]                 ` <20150929164014.GL21513-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2015-09-29 17:13                   ` Robin Murphy
2015-09-29 17:13                     ` 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=20150929093257.GE9460@ulmo.nvidia.com \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=a.motakis-lrHrjnjw1UfHK3s98zE1ajGjJy/sRE9J@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org \
    --cc=ohaugan-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=rmk+kernel-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
    --cc=vince.h-DDmLM1+adcrQT0dZR+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 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.