Skip to contentSkip to conversation

mm: vcm: The Virtual Memory Manager for multiple IOMMUs

RFC Superseded KyongHo Cho 1 participant 8 messages Dec 11, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#5 lore raw

RFC 5/7 mm: vcm: VCM One-to-One wrapper added

In reply to KyongHo Cho

From: Michal Nazarewicz <[email protected]>

This commits adds a VCM One-to-One wrapper which is meant to be a helper code for creating VCM drivers for "fake" MMUs, ie. situation where there is no real hardware MMU and memory must be contiguous physically and mapped directly to "virtual" address space.

---
 Documentation/virtual-contiguous-memory.txt |   33 ++++++++++
 include/linux/vcm-drv.h                     |   41 ++++++++++++
 mm/Kconfig                                  |   10 +++
 mm/vcm.c                                    |   90 +++++++++++++++++++++++++++
 4 files changed, 174 insertions(+), 0 deletions(-)
Documentation/virtual-contiguous-memory.txt +33 -0
index 768e029..70c1c06 100644
@@ -836,6 +836,39 @@ rather then the whole mapping.  It basically incorporates call to the
 vcm_phys_walk() function so driver does not need to call it
 explicitly.
 
+** Writing a one-to-one VCM driver
+
+Similarly to a wrapper for a real hardware MMU a wrapper for
+one-to-one VCM contexts has been created.  It implements all of the
+houskeeping operations and leaves only contiguous memory management
+(that is allocating and freeing contiguous regions) to the VCM O2O
+driver.
+
+As with other drivers, one-to-one driver needs to provide a context
+creation function.  It needs to allocate space for vcm_o2o structure
+and initialise its vcm.start, vcm.end and driver fields.  Calling
+vcm_o2o_init() will fill the other fields and validate entered values:
+
+	struct vcm *__must_check vcm_o2o_init(struct vcm_o2o *o2o);
+
+There are the following two operations used by the wrapper:
+
+	void (*cleanup)(struct vcm *vcm);
+	struct vcm_phys *(*phys)(struct vcm *vcm, resource_size_t size,
+				 unsigned flags);
+
+The cleanup operation cleans the context and frees all resources.  If
+not provided, kfree() is used.
+
+The phys operation is used in the same way as the core driver's phys
+operation.  The only difference is that it must return a physically
+contiguous memory block -- ie. returned structure must have only one
+part.  On error, the operation must return an error-pointer.  It is
+required.
+
+Note that to use the VCM one-to-one wrapper one needs to select the
+VCM_O2O Kconfig option or otherwise the wrapper won't be available.
+
 * Epilogue
 
 The initial version of the VCM framework was written by Zach Pfeffer
include/linux/vcm-drv.h +41 -0

47 lines not on this page · raw message

mm/Kconfig +10 -0
index d4d4f74..bd046c0 100644
@@ -406,6 +406,16 @@ config VCM_MMU
  	  will be automatically selected.  You select it if you are going to
  	  build external modules that will use this functionality.
 
+config VCM_O2O
+ 	bool "VCM O2O wrapper"
+ 	depends on VCM && MODULES
+ 	help
+ 	  This enables the VCM one-to-one wrapper which helps creating VCM
+ 	  drivers for devices without IO MMUs.  If a VCM driver is built that
+ 	  requires this option, it will be automatically selected.  You select
+ 	  it if you are going to build external modules that will use this
+ 	  functionality.
+
 #
 # UP and nommu archs use km based percpu allocator
 #
mm/vcm.c +90 -0

96 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#0 lore raw

cover mm: vcm: The Virtual Memory Manager for multiple IOMMUs

Hello,

The VCM is a framework to deal with multiple IOMMUs in a system
with intuitive and abstract objects
These patches are the bugfix and enhanced version of previous RFC by Michal Nazarewicz.
(https://patchwork.kernel.org/patch/157451/)

It is introduced by Zach Pfeffer and implemented by Michal Nazarewicz.
These patches include entirely new implementation of VCM than the one submitted by Zach Pfeffer.

The prerequisites of these patches are the followings:
https://patchwork.kernel.org/patch/340281/
https://patchwork.kernel.org/patch/340121/
https://patchwork.kernel.org/patch/340321/

And the prerequisites of "[RFC,6/7] mm: vcm: vcm-cma: VCM CMA driver added" are all 13 patches of RFCv6 submitted by Michal Nazarewicz
(https://patchwork.kernel.org/project/LKML/list/?submitter=2150)
The VCM also works correctly without "[RFC,6/7] mm: vcm: vcm-cma: VCM CMA driver added"

The last patch, "[RFC,7/7] mm: vcm: Sample driver added" is not the one to be submitted but is an example to show how to use the VCM.

The VCM provides generic interfaces and objects to deal with IOMMUs in various architectures especially the ones that embed multiple IOMMUs including GART.

Patch list:
[RFC,1/7] mm: vcm: Virtual Contiguous Memory framework added [RFC,2/7] mm: vcm: physical memory allocator added [RFC,3/7] mm: vcm: VCM VMM driver added
[RFC,4/7] mm: vcm: VCM MMU wrapper added
[RFC,5/7] mm: vcm: VCM One-to-One wrapper added [RFC,6/7] mm: vcm: vcm-cma: VCM CMA driver added [RFC,7/7] mm: vcm: Sample driver added

Summary:

Documentation/00-INDEX                      |    2 +
Documentation/virtual-contiguous-memory.txt |  893 ++++++++++++++++++++++++
include/linux/vcm-cma.h                     |   38 +
include/linux/vcm-drv.h                     |  326 +++++++++
include/linux/vcm-sample.h                  |   30 +
include/linux/vcm.h                         |  288 ++++++++
mm/Kconfig                                  |   72 ++
mm/Makefile                                 |    3 +
mm/vcm-cma.c                                |  103 +++
mm/vcm-sample.c                             |  119 ++++
mm/vcm.c                                    |  970 +++++++++++++++++++++++++++
11 files changed, 2844 insertions(+), 0 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

RFC 1/7 mm: vcm: Virtual Contiguous Memory framework added

From: Michal Nazarewicz <[email protected]>

This commit adds the Virtual Contiguous Memory framework which provides an abstraction for virtual address space provided by various MMUs present on the platform.

The framework uses plugable MMU drivers for hardware MMUs and if drivers obeys some limitations it can be also used on platforms with no MMU.

For more information see
<Documentation/virtual-contiguous-memory.txt>.

---
 Documentation/00-INDEX                      |    2 +
 Documentation/virtual-contiguous-memory.txt |  720 +++++++++++++++++++++++++++
 include/linux/vcm-drv.h                     |  117 +++++
 include/linux/vcm.h                         |  275 ++++++++++
 mm/Kconfig                                  |   15 +
 mm/Makefile                                 |    1 +
 mm/vcm.c                                    |  304 +++++++++++
 7 files changed, 1434 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/virtual-contiguous-memory.txt
 create mode 100644 include/linux/vcm-drv.h
 create mode 100644 include/linux/vcm.h
 create mode 100644 mm/vcm.c
Documentation/00-INDEX +2 -0
index f93e787..7c79ffa 100644
@@ -344,6 +344,8 @@ video-output.txt
 	- sysfs class driver interface to enable/disable a video output device.
 video4linux/
 	- directory with info regarding video/TV/radio cards and linux.
+virtual-contiguous-memory.txt
+	- documentation on virtual contiguous memory manager framework.
 vm/
 	- directory with info on the Linux vm code.
 volatile-considered-harmful.txt
Documentation/virtual-contiguous-memory.txt new file +720 -0

720 lines not on this page · raw message

include/linux/vcm-drv.h new file +117 -0

117 lines not on this page · raw message

include/linux/vcm.h new file +275 -0

275 lines not on this page · raw message

mm/Kconfig +15 -0
index 0656794..cfe1601 100644
@@ -371,6 +371,21 @@ config CMA_BEST_FIT
 	  allocates area from the smallest hole that is big enough for
 	  allocation in question.
 
+config VCM
+ 	bool "Virtual Contiguous Memory framework"
+ 	help
+ 	  This enables the Virtual Contiguous Memory framework which
+ 	  provides an abstraction for virtual address space provided by
+ 	  various MMUs present on the platform.
+ 
+ 	  The framework uses plugable MMU drivers for hardware MMUs and
+ 	  if drivers obeys some limitations it can be also used on
+ 	  platforms with no MMU.
+ 
+ 	  For more information see
+ 	  <Documentation/virtual-contiguous-memory.txt>.  If unsure, say
+ 	  "n".
+
 #
 # UP and nommu archs use km based percpu allocator
 #
mm/Makefile +1 -0
index 62ced96..15b5725 100644
@@ -44,3 +44,4 @@ obj-$(CONFIG_DEBUG_KMEMLEAK) += kmemleak.o
 obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak-test.o
 obj-$(CONFIG_CMA) += cma.o
 obj-$(CONFIG_CMA_BEST_FIT) += cma-best-fit.o
+obj-$(CONFIG_VCM) += vcm.o
mm/vcm.c new file +304 -0

304 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

RFC 4/7 mm: vcm: VCM MMU wrapper added

In reply to KyongHo Cho

From: Michal Nazarewicz <[email protected]>

This commits adds a VCM MMU wrapper which is meant to be a helper code for creating VCM drivers for real hardware MMUs.

---
 Documentation/virtual-contiguous-memory.txt |   80 ++++++++++
 include/linux/vcm-drv.h                     |   80 ++++++++++
 mm/Kconfig                                  |   11 ++
 mm/vcm.c                                    |  219 +++++++++++++++++++++++++++
 4 files changed, 390 insertions(+), 0 deletions(-)
Documentation/virtual-contiguous-memory.txt +80 -0
index c522071..768e029 100644
@@ -756,6 +756,86 @@ automatically reflect new mappings on the hardware MMU.
 Neither of the operations are required and if missing, VCM will
 assume they are a no-operation and no warning will be generated.
 
+** Writing a hardware MMU driver
+
+It may be undesirable to implement all of the operations that are
+required to create a usable driver.  In case of hardware MMUs a helper
+wrapper driver has been created to make writing real drivers as simple
+as possible.
+
+The wrapper implements most of the functionality of the driver leaving
+only implementation of the actual talking to the hardware MMU in hands
+of programmer.  Reservations managements as general housekeeping is
+already there.
+
+Note that to use the VCM MMU wrapper one needs to select the VCM_MMU
+Kconfig option or otherwise the wrapper won't be available.
+
+*** Context creation
+
+Similarly to normal drivers, MMU driver needs to provide a context
+creation function.  Such a function must provide a vcm_mmu object and
+initialise vcm.start, vcm.size and driver fields of the structure.
+When this is done, vcm_mmu_init() should be called which will
+initialise the rest of the fields and validate entered values:
+
+	struct vcm *__must_check vcm_mmu_init(struct vcm_mmu *mmu);
+
+This is, in fact, very similar to the way standard driver is created.
+
+*** Orders
+
+One of the fields of the vcm_mmu_driver structure is orders.  This is
+an array of orders of pages supported by the hardware MMU.  It must be
+sorted from largest to smallest and zero terminated.
+
+The order is the logarithm with the base two of the size of supported
+page size divided by PAGE_SIZE.  For instance, { 8, 4, 0 } means that
+MMU supports 1MiB, 64KiB and 4KiB pages.
+
+*** Operations
+
+The three operations that MMU wrapper driver uses are:
+
+	void (*cleanup)(struct vcm *vcm);
+
+	int (*activate)(struct vcm_res *res, struct vcm_phys *phys);
+	void (*deactivate)(struct vcm_res *res, struct vcm_phys *phys);
+
+	int (*activate_page)(dma_addr_t vaddr, dma_addr_t paddr,
+			     unsigned order, void *vcm),
+	int (*deactivate_page)(dma_addr_t vaddr, dma_addr_t paddr,
+			       unsigned order, void *vcm),
+
+The first one frees all resources allocated by the context creation
+function (including the structure itself).  If this operation is not
+given, kfree() will be called on vcm_mmu structure.
+
+The activate and deactivate operations are required and they are used
+to update mappings in the MMU.  Whenever binding is activated or
+deactivated the respective operation is called.
+
+To divide mapping into physical pages, vcm_phys_walk() function can be
+used:
+
+	int vcm_phys_walk(dma_addr_t vaddr, const struct vcm_phys *phys,
+			  const unsigned char *orders,
+			  int (*callback)(dma_addr_t vaddr, dma_addr_t paddr,
+					  unsigned order, void *priv),
+			  int (*recovery)(dma_addr_t vaddr, dma_addr_t paddr,
+					  unsigned order, void *priv),
+			  void *priv);
+
+It start from given virtual address and tries to divide allocated
+physical memory to as few pages as possible where order of each page
+is one of the orders specified by orders argument.
+
+It may be easier to implement activate_page and deactivate_page
+operations instead thought.  They are called on each individual page
+rather then the whole mapping.  It basically incorporates call to the
+vcm_phys_walk() function so driver does not need to call it
+explicitly.
+
 * Epilogue
 
 The initial version of the VCM framework was written by Zach Pfeffer
include/linux/vcm-drv.h +80 -0

86 lines not on this page · raw message

mm/Kconfig +11 -0
index 70fc7ed..d4d4f74 100644
@@ -395,6 +395,17 @@ config VCM_PHYS
  	  will be automatically selected.  You select it if you are going to
  	  build external modules that will use this functionality.
 
+config VCM_MMU
+ 	bool "VCM MMU wrapper"
+ 	depends on VCM && MODULES
+ 	select VCM_PHYS
+ 	select GENERIC_ALLOCATOR
+ 	help
+ 	  This enables the VCM MMU wrapper which helps creating VCM drivers
+ 	  for IO MMUs.  If a VCM driver is built that requires this option, it
+ 	  will be automatically selected.  You select it if you are going to
+ 	  build external modules that will use this functionality.
+
 #
 # UP and nommu archs use km based percpu allocator
 #
mm/vcm.c +219 -0

231 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw

RFC 7/7 mm: vcm: Sample driver added

In reply to KyongHo Cho

From: Michal Nazarewicz <[email protected]>

This commit adds a sample Virtual Contiguous Memory framework driver. It handles no real hardware and is there only for demonstrating purposes.

* * * THIS COMMIT IS NOT FOR MERGING * * *

---
 Documentation/virtual-contiguous-memory.txt |    3 +
 include/linux/vcm-sample.h                  |   30 +++++++
 mm/Kconfig                                  |   13 +++
 mm/Makefile                                 |    1 +
 mm/vcm-sample.c                             |  119 +++++++++++++++++++++++++++
 5 files changed, 166 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/vcm-sample.h
 create mode 100644 mm/vcm-sample.c
Documentation/virtual-contiguous-memory.txt +3 -0
index 9354c4c..8edd457 100644
@@ -781,6 +781,9 @@ already there.
 Note that to use the VCM MMU wrapper one needs to select the VCM_MMU
 Kconfig option or otherwise the wrapper won't be available.
 
+There is a sample driver provided which provides a template for real
+drivers.  It can be found in [[file:../mm/vcm-sample.c][mm/vcm-sample.c]] file.
+
 *** Context creation
 
 Similarly to normal drivers, MMU driver needs to provide a context
include/linux/vcm-sample.h new file +30 -0
new file mode 100644
index 0000000..86a71ca
@@ -0,0 +1,30 @@
+/*
+ * Virtual Contiguous Memory sample driver header file
+ * Copyright (c) 2010 by Samsung Electronics.
+ * Written by Michal Nazarewicz ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License or (at your optional) any later version of the license.
+ */
+
+/*
+ * See Documentation/virtual-contiguous-memory.txt for details.
+ */
+
+#ifndef __LINUX_VCM_SAMP_H
+#define __LINUX_VCM_SAMP_H
+
+#include <linux/types.h>
+
+struct vcm;
+
+/**
+ * vcm_samp_create() - creates a VCM context
+ *
+ * ... Documentation goes here ...
+ */
+struct vcm *__must_check vcm_samp_create(/* ... */);
+
+#endif
mm/Kconfig +13 -0
index 0f4d893..adb90a8 100644
@@ -430,6 +430,19 @@ config VCM_CMA
  	  For more information see
  	  <Documentation/virtual-contiguous-memory.txt>.  If unsure, say "n".
 
+config VCM_SAMP
+ 	bool "VCM sample driver"
+ 	depends on VCM
+ 	select VCM_MMU
+ 	help
+ 	  This enables a sample driver for the VCM framework.  This driver
+ 	  does not handle any real harwdare.  It's merely an template of
+ 	  how for real drivers.
+ 
+ 	  For more information see
+ 	  <Documentation/virtual-contiguous-memory.txt>.  If unsure, say
+ 	  "n".
+
 #
 # UP and nommu archs use km based percpu allocator
 #
mm/Makefile +1 -0
index 78e1bd5..515c433 100644
@@ -46,3 +46,4 @@ obj-$(CONFIG_CMA) += cma.o
 obj-$(CONFIG_CMA_BEST_FIT) += cma-best-fit.o
 obj-$(CONFIG_VCM) += vcm.o
 obj-$(CONFIG_VCM_CMA) += vcm-cma.o
+obj-$(CONFIG_VCM_SAMPLE) += vcm-sample.o
mm/vcm-sample.c new file +119 -0

119 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

RFC 2/7 mm: vcm: physical memory allocator added

In reply to KyongHo Cho

From: Michal Nazarewicz <[email protected]>

This commits adds vcm_phys_alloc() function with some accompanying functions which allocates physical memory. This should be used from withing alloc or phys callback of a VCM driver if one does not want to provide its own allocator.

---
 Documentation/virtual-contiguous-memory.txt |   31 ++++
 include/linux/vcm-drv.h                     |   88 ++++++++++
 mm/Kconfig                                  |    9 +
 mm/vcm.c                                    |  249 +++++++++++++++++++++++++++
 4 files changed, 377 insertions(+), 0 deletions(-)
Documentation/virtual-contiguous-memory.txt +31 -0
index 9793a86..56924df 100644
@@ -644,6 +644,37 @@ Both phys and alloc callbacks need to provide a free callbakc along
 with the vc_phys structure, which will, as one may imagine, free
 allocated space when user calls vcm_free().
 
+Unless VCM driver needs some special handling of physical memory, the
+vcm_phys_alloc() function can be used:
+
+	struct vcm_phys *__must_check
+	vcm_phys_alloc(resource_size_t size, unsigned flags,
+		       const unsigned char *orders);
+
+The last argument of this function (orders) is an array of orders of
+page sizes that function should try to allocate.  This array must be
+sorted from highest order to lowest and the last entry must be zero.
+
+For instance, an array { 8, 4, 0 } means that the function should try
+and allocate 1MiB, 64KiB and 4KiB pages (this is assuming PAGE_SIZE is
+4KiB which is true for all supported architectures).  For example, if
+requested size is 2MiB and 68 KiB, the function will try to allocate
+two 1MiB pages, one 64KiB page and one 4KiB page.  This may be useful
+when the mapping is written to the MMU since the largest possible
+pages will be used reducing the number of entries.
+
+The function allocates memory from DMA32 zone.  If driver has some
+other requirements (that is require different GFP flags) it can use
+__vcm_phys_alloc() function which, besides arguments that
+vcm_phys_alloc() accepts, take GFP flags as the last argument:
+
+	struct vcm_phys *__must_check
+	__vcm_phys_alloc(resource_size_t size, unsigned flags,
+			 const unsigned char *orders, gfp_t gfp);
+
+However, if those functions are used, VCM driver needs to select an
+VCM_PHYS Kconfig option or oterwise they won't be available.
+
 All those operations may assume that size is a non-zero and divisible
 by PAGE_SIZE.
 
include/linux/vcm-drv.h +88 -0

92 lines not on this page · raw message

mm/Kconfig +9 -0
index cfe1601..70fc7ed 100644
@@ -386,6 +386,15 @@ config VCM
  	  <Documentation/virtual-contiguous-memory.txt>.  If unsure, say
  	  "n".
 
+config VCM_PHYS
+ 	bool "VCM physical allocation wrappers"
+ 	depends on VCM && MODULES
+ 	help
+ 	  This enables the vcm_phys family of functions provided for VCM
+ 	  drivers.  If a VCM driver is built that requires this option, it
+ 	  will be automatically selected.  You select it if you are going to
+ 	  build external modules that will use this functionality.
+
 #
 # UP and nommu archs use km based percpu allocator
 #
mm/vcm.c +249 -0

252 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw

RFC 3/7 mm: vcm: VCM VMM driver added

From: Michal Nazarewicz <[email protected]>

This commit adds a VCM VMM driver that handles kernl virtual address space mappings. The VCM context is available as a static object vcm_vmm. It is mostly just a wrapper around vmap() function.

---
 Documentation/virtual-contiguous-memory.txt |   22 +++++-
 include/linux/vcm.h                         |   13 +++
 mm/vcm.c                                    |  108 +++++++++++++++++++++++++++
 3 files changed, 140 insertions(+), 3 deletions(-)
Documentation/virtual-contiguous-memory.txt +19 -3
index 56924df..c522071 100644
@@ -482,6 +482,25 @@ state.
 
 The following VCM drivers are provided:
 
+** Virtual Memory Manager driver
+
+Virtual Memory Manager driver is available as vcm_vmm and lets one map
+VCM managed physical memory into kernel space.  The calls that this
+driver supports are:
+
+	vcm_make_binding()
+	vcm_destroy_binding()
+
+	vcm_alloc()
+
+	vcm_map()
+	vcm_unmap()
+
+vcm_map() is likely to work with physical memory allocated in context
+of other drivers as well (the only requirement is that "page" field of
+struct vcm_phys_part will be set for all physically contiguous parts
+and that each part's size will be multiply of PAGE_SIZE).
+
 ** Real hardware drivers
 
 There are no real hardware drivers at this time.
@@ -746,6 +765,3 @@ rewritten by Michal Nazarewicz <[email protected]>.
 The new version is still lacking a few important features.  Most
 notably, no real hardware MMU has been implemented yet.  This may be
 ported from original Zach's proposal.
-
-Also, support for VMM is lacking.  This is another thing that can be
-ported from Zach's proposal.
include/linux/vcm.h +13 -0
index 965dc9b..7b183c2 100644
@@ -272,4 +272,17 @@ int  __must_check vcm_activate(struct vcm *vcm);
  */
 void vcm_deactivate(struct vcm *vcm);
 
+/**
+ * vcm_vmm - VMM context
+ *
+ * Context for manipulating kernel virtual mappings.  Reserve as well
+ * as rebinding is not supported by this driver.  Also, all mappings
+ * are always active (till unbound) regardless of calls to
+ * vcm_activate().
+ *
+ * After mapping, the start field of struct vcm_res should be cast to
+ * pointer to void and interpreted as a valid kernel space pointer.
+ */
+extern struct vcm vcm_vmm[1];
+
 #endif
mm/vcm.c +108 -0

120 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#6 lore raw

RFC 6/7 mm: vcm: vcm-cma: VCM CMA driver added

In reply to KyongHo Cho

From: Michal Nazarewicz <[email protected]>

This commit adds a VCM driver that instead of using real hardware MMU emulates one and uses CMA for allocating contiguous memory chunks.

---
 Documentation/virtual-contiguous-memory.txt |   12 +++-
 include/linux/vcm-cma.h                     |   38 ++++++++++
 mm/Kconfig                                  |   14 ++++
 mm/Makefile                                 |    1 +
 mm/vcm-cma.c                                |  103 +++++++++++++++++++++++++++
 5 files changed, 167 insertions(+), 1 deletions(-)
 create mode 100644 include/linux/vcm-cma.h
 create mode 100644 mm/vcm-cma.c
Documentation/virtual-contiguous-memory.txt +11 -1
index 70c1c06..9354c4c 100644
@@ -524,7 +524,17 @@ well:
 If one uses vcm_unbind() then vcm_bind() on the same reservation,
 physical memory pair should also work.
 
-There are no One-to-One drivers at this time.
+*** VCM CMA
+
+VCM CMA driver is a One-to-One driver which uses CMA (see
+[[file:contiguous-memory.txt][contiguous-memory.txt]]) to allocate physically contiguous memory.  VCM
+CMA context is created by calling:
+
+	struct vcm *__must_check
+	vcm_cma_create(const char *regions, dma_addr_t alignment);
+
+Its first argument is the list of regions that CMA should try to
+allocate memory from.  The second argument is required alignment.
 
 * Writing a VCM driver
 
include/linux/vcm-cma.h new file +38 -0
new file mode 100644
index 0000000..19f9534
@@ -0,0 +1,38 @@
+/*
+ * Virtual Contiguous Memory driver for CMA header
+ * Copyright (c) 2010 by Samsung Electronics.
+ * Written by Michal Nazarewicz ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License or (at your optional) any later version of the license.
+ */
+
+/*
+ * See Documentation/virtual-contiguous-memory.txt for details.
+ */
+
+#ifndef __LINUX_VCM_CMA_H
+#define __LINUX_VCM_CMA_H
+
+#include <linux/types.h>
+
+struct vcm;
+
+/**
+ * vcm_cma_create() - creates a VCM context that fakes a hardware MMU
+ * @regions:	list of CMA regions physical allocations should be done
+ *		from.
+ * @alignment:	required alignment of allocations.
+ *
+ * This creates VCM context that can be used on platforms with no
+ * hardware MMU or for devices that aro conected to the bus directly.
+ * Because it does not represent real MMU it has some limitations:
+ * basically, vcm_alloc(), vcm_reserve() and vcm_bind() are likely to
+ * fail so vcm_make_binding() should be used instead.
+ */
+struct vcm *__must_check
+vcm_cma_create(const char *regions, unsigned long alignment);
+
+#endif
mm/Kconfig +14 -0
index bd046c0..0f4d893 100644
@@ -416,6 +416,20 @@ config VCM_O2O
  	  it if you are going to build external modules that will use this
  	  functionality.
 
+config VCM_CMA
+ 	bool "VCM CMA driver"
+ 	depends on VCM && CMA
+ 	select VCM_O2O
+ 	help
+ 	  This enables VCM driver that instead of using a real hardware
+ 	  MMU fakes one and uses a direct mapping.  It provides a subset
+ 	  of functionalities of a real MMU but if drivers limits their
+ 	  use of VCM to only supported operations they can work on
+ 	  both systems with and without MMU with no changes.
+ 
+ 	  For more information see
+ 	  <Documentation/virtual-contiguous-memory.txt>.  If unsure, say "n".
+
 #
 # UP and nommu archs use km based percpu allocator
 #
mm/Makefile +1 -0
index 15b5725..78e1bd5 100644
@@ -45,3 +45,4 @@ obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak-test.o
 obj-$(CONFIG_CMA) += cma.o
 obj-$(CONFIG_CMA_BEST_FIT) += cma-best-fit.o
 obj-$(CONFIG_VCM) += vcm.o
+obj-$(CONFIG_VCM_CMA) += vcm-cma.o
mm/vcm-cma.c new file +103 -0

103 lines not on this page · raw message

Signature · 8 lines
1.6.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>