linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] iommu: Add range flush operation
@ 2015-09-29  5:25 Tomasz Figa
       [not found] ` <1443504379-31841-1-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Tomasz Figa @ 2015-09-29  5:25 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Tomasz Figa, Joerg Roedel, Hiroshi Doyu, Stephen Warren,
	Thierry Reding, Alexandre Courbot, Vince Hsu, Russell King,
	Paul Walmsley, Tomeu Vizoso, Mikko Perttunen, Will Deacon,
	Alex Williamson, Arnd Bergmann, Marek Szyprowski,
	Antonios Motakis, Olav Haugan, Nicolas Iooss,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

Currently the IOMMU subsystem provides 3 basic operations: iommu_map(),
iommu_map_sg() and iommu_unmap(). iommu_map() can be used to map memory
page by page, however it involves flushing the caches (CPU and IOMMU) for
every mapped page separately, which is unsuitable for use cases that
require low mapping latency. Similarly iommu_unmap(), even though it
takes a full IOVA range as its argument, performs unmapping in a page
by page manner.

To make mapping operation more suitable for such use cases, iommu_map_sg()
and .map_sg() callback in iommu_ops struct were introduced, which allowed
particular IOMMU drivers to directly iterate over SG entries, create
necessary mappings and flush everything in one go.

This approach, however, has two drawbacks:
 1) it does not do anything about unmap performance,
 2) it requires each driver willing to have fast map to implement its
    own SG iteration code, even though this is a mostly generic operation.

This series tries to mitigate the two issues above, while acknowledging
the fact that the .map_sg() callback might be still necessary for some
specific platforms, which could have the need to iterate over SG elements
inside driver code. Proposed solution introduces a new .flush() callback,
which expects IOVA range as its argument and is expected to flush all
respective caches (be it CPU, IOMMU TLB or whatever) to make the given
IOVA area mapping change visible to IOMMU clients. Then all the 3 basic
map/unmap operations are modified to call the .flush() callback at the end
of the operation. 

Advantages of proposed approach include:
 1) ability to use default_iommu_map_sg() helper if all the driver needs
    for performance optimization is batching the flush,
 2) completely no effect on existing code - the .flush() callback is made
    optional and if it isn't implemented drivers are expected to do
    necessary flushes on a page by page basis in respective (un)mapping
    callbakcs,
 3) possibility of exporting the iommu_flush() operation and providing
    unsynchronized map/unmap operations for subsystems with even higher
    requirements for performance (e.g. drivers/gpu/drm).

The series includes a generic patch implementing necessary changes in
IOMMU API and two Tegra-specific patches that demonstrate implementation
on driver side and which can be used for further testing.

Last, but not least, some performance numbers on Tegra210:
+-----------+--------------+-------------+------------+
| Operation | Size [bytes] | Before [us] | After [us] |
+-----------+--------------+-------------+------------+
| Map       | 128K         |         139 |         40 |
|           |              |         136 |         34 |
|           |              |         137 |         38 |
|           |              |         136 |         36 |
|           | 4M           |        3939 |       1163 |
|           |              |        3730 |       2389 |
|           |              |        3613 |        997 |
|           |              |        3622 |       1620 |
|           | ~18M         |       18635 |       4741 |
|           |              |       19261 |       6550 |
|           |              |       18473 |       9304 |
|           |              |       18125 |       5120 |
| Unmap     | 128K         |         128 |          7 |
|           |              |         122 |          8 |
|           |              |         119 |         10 |
|           |              |         123 |         12 |
|           | 4M           |        3829 |        151 |
|           |              |        3964 |        150 |
|           |              |        3908 |        145 |
|           |              |        3875 |        155 |
|           | ~18M         |       18570 |        683 |
|           |              |       18473 |        806 |
|           |              |       21020 |        643 |
|           |              |       21764 |        652 |
+-----------+--------------+-------------+------------+
The values are obtained by surrounding the calls to iommu_map_sg()
(with default_iommu_map_sg() helper used as .map_sg() callback) and
iommu_unmap() with ktime-based time measurement code. Taken 4 samples
of every buffer size. ~18M means around 17-19M due do the variance
in requested buffer sizes.

Tomasz Figa (2):
  iommu: Add support for out of band flushing
  iommu/tegra-smmu: Make the driver use out of band flushing

Vince Hsu (1):
  memory: tegra: add TLB cache line size

 drivers/iommu/iommu.c           | 33 +++++++++++++--
 drivers/iommu/tegra-smmu.c      | 91 +++++++++++++++++++++++++++++++++++++----
 drivers/memory/tegra/tegra114.c |  1 +
 drivers/memory/tegra/tegra124.c |  3 ++
 drivers/memory/tegra/tegra210.c |  1 +
 drivers/memory/tegra/tegra30.c  |  1 +
 include/linux/iommu.h           |  2 +
 include/soc/tegra/mc.h          |  1 +
 8 files changed, 122 insertions(+), 11 deletions(-)

-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-09-29 17:13 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29  5:25 [RFC PATCH 0/3] iommu: Add range flush operation 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
     [not found]     ` <1443504379-31841-2-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
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  5:25   ` [RFC PATCH 2/3] memory: tegra: add TLB cache line size Tomasz Figa
     [not found]     ` <1443504379-31841-3-git-send-email-tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
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  5:25   ` [RFC PATCH 3/3] iommu/tegra-smmu: Make the driver use out of band flushing Tomasz Figa
2015-09-29  9:27   ` [RFC PATCH 0/3] iommu: Add range flush operation Thierry Reding
     [not found]     ` <20150929092714.GD9460-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-09-29 11:54       ` Tomasz Figa
2015-09-29 12:22       ` Joerg Roedel
2015-09-29 12:20   ` Joerg Roedel
2015-09-29 14:20   ` Robin Murphy
     [not found]     ` <560A9E36.9030903-5wv7dgnIgG8@public.gmane.org>
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
     [not found]             ` <560ABBE0.8020805-5wv7dgnIgG8@public.gmane.org>
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

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).