mm/cma: Move dma contiguous changes into a seperate config
Subsystems (8)
RFC PATCH 1/3 mm/cma: Move dma contiguous changes into a seperate config
From: "Aneesh Kumar K.V" <[email protected]>
We want to use CMA for allocating hash page table and real mode area for PPC64. Hence move DMA contiguous related changes into a seperate config so that ppc64 can enable CMA without requiring DMA contiguous.
--- arch/arm/configs/omap2plus_defconfig | 2 +- arch/arm/configs/tegra_defconfig | 2 +- arch/arm/include/asm/dma-contiguous.h | 2 +- arch/arm/mm/dma-mapping.c | 6 +++--- drivers/base/Kconfig | 21 +++++---------------- drivers/base/Makefile | 2 +- include/linux/dma-contiguous.h | 2 +- mm/Kconfig | 20 ++++++++++++++++++++ 8 files changed, 33 insertions(+), 24 deletions(-)
arch/arm/configs/omap2plus_defconfig +1 -1
@@ -71,7 +71,7 @@ CONFIG_MAC80211=m CONFIG_MAC80211_RC_PID=y CONFIG_MAC80211_RC_DEFAULT_PID=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" -CONFIG_CMA=y +CONFIG_DMA_CMA=y CONFIG_CONNECTOR=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y
arch/arm/configs/tegra_defconfig +1 -1
@@ -79,7 +79,7 @@ CONFIG_RFKILL_GPIO=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y # CONFIG_FIRMWARE_IN_KERNEL is not set -CONFIG_CMA=y +CONFIG_DMA_CMA=y CONFIG_MTD=y CONFIG_MTD_CHAR=y CONFIG_MTD_M25P80=y
arch/arm/include/asm/dma-contiguous.h +1 -1
@@ -2,7 +2,7 @@#define ASMARM_DMA_CONTIGUOUS_H #ifdef __KERNEL__ -#ifdef CONFIG_CMA +#ifdef CONFIG_DMA_CMA #include <linux/types.h> #include <asm-generic/dma-contiguous.h>
arch/arm/mm/dma-mapping.c +3 -3
@@ -358,7 +358,7 @@ static int __init atomic_pool_init(void)if (!pages) goto no_pages; -if (IS_ENABLED (CONFIG_CMA )) +if (IS_ENABLED (CONFIG_DMA_CMA )) ptr =__alloc_from_contiguous (NULL , pool->size, prot, &page, atomic_pool_init);else
@@ -670,7 +670,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, addr =__alloc_simple_buffer (dev, size, gfp, &page); else if (!(gfp & __GFP_WAIT)) addr =__alloc_from_pool (size, &page); - else if (!IS_ENABLED(CONFIG_CMA)) + else if (!IS_ENABLED(CONFIG_DMA_CMA)) addr =__alloc_remap_buffer (dev, size, gfp, prot, &page, caller); else addr =__alloc_from_contiguous (dev, size, prot, &page, caller);
@@ -759,7 +759,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,__dma_free_buffer (page, size); }else if (__free_from_pool (cpu_addr, size)) {return ; - }else if (!IS_ENABLED (CONFIG_CMA )) { + }else if (!IS_ENABLED (CONFIG_DMA_CMA )) {__dma_free_remap (cpu_addr, size);__dma_free_buffer (page, size); }else {
drivers/base/Kconfig +5 -16
@@ -202,11 +202,10 @@ config DMA_SHARED_BUFFER APIs extension; the file's descriptor can then be passed on to other driver. -config CMA - bool "Contiguous Memory Allocator" - depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK - select MIGRATION - select MEMORY_ISOLATION +config DMA_CMA + bool "DMA Contiguous Memory Allocator" + depends on HAVE_DMA_CONTIGUOUS + select CMA help This enables the Contiguous Memory Allocator which allows drivers to allocate big physically-contiguous blocks of memory for use with
@@ -215,17 +214,7 @@ config CMA For more information see <include/linux/dma-contiguous.h>. If unsure, say "n". -if CMA - -config CMA_DEBUG - bool "CMA debug messages (DEVELOPMENT)" - depends on DEBUG_KERNEL - help - Turns on debug messages in CMA. This produces KERN_DEBUG - messages for every CMA call as well as various messages while - processing calls such as dma_alloc_from_contiguous(). - This option does not affect warning and error messages. - +if DMA_CMA comment "Default contiguous memory area size:" config CMA_SIZE_MBYTES
drivers/base/Makefile +1 -1
@@ -6,7 +6,7 @@ obj-y := core.o bus.o dd.o syscore.o \ attribute_container.o transport_class.o \ topology.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o -obj-$(CONFIG_CMA) += dma-contiguous.o +obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
include/linux/dma-contiguous.h +1 -1
@@ -57,7 +57,7 @@ struct cma;struct page ;struct device ; -#ifdef CONFIG_CMA +#ifdef CONFIG_DMA_CMA /* * There is always at least global CMA area and a few optional device
mm/Kconfig +20 -0
@@ -477,3 +477,23 @@ config FRONTSWAP and swap data is stored as normal on the matching swap device. If unsure, say Y to enable frontswap. + +config CMA + bool "Contiguous Memory Allocator" + depends on HAVE_MEMBLOCK + select MIGRATION + select MEMORY_ISOLATION + help + This enables the Contiguous Memory Allocator which allows other + subsystem to allocate big physically-contiguous blocks of memory + + If unsure, say "n". + +config CMA_DEBUG + bool "CMA debug messages (DEVELOPMENT)" + depends on DEBUG_KERNEL && CMA + help + Turns on debug messages in CMA. This produces KERN_DEBUG + messages for every CMA call as well as various messages while + processing calls such as dma_alloc_from_contiguous(). + This option does not affect warning and error messages.
Signature · 7 lines
1.8.1.2 -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RFC PATCH 2/3 powerpc: Contiguous memory allocator based hash page allocation
From: "Aneesh Kumar K.V" <[email protected]>
Use CMA for allocation of guest hash page.
--- arch/powerpc/include/asm/kvm_book3s_64.h | 1 - arch/powerpc/include/asm/kvm_host.h | 2 +- arch/powerpc/include/asm/kvm_ppc.h | 8 +- arch/powerpc/kernel/setup_64.c | 2 + arch/powerpc/kvm/Kconfig | 1 + arch/powerpc/kvm/Makefile | 3 + arch/powerpc/kvm/book3s_64_mmu_hv.c | 36 +++-- arch/powerpc/kvm/book3s_hv_builtin.c | 79 +++++++---- arch/powerpc/kvm/book3s_hv_cma.c | 220 +++++++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv_cma.h | 21 +++ 10 files changed, 322 insertions(+), 51 deletions(-) create mode 100644 arch/powerpc/kvm/book3s_hv_cma.c create mode 100644 arch/powerpc/kvm/book3s_hv_cma.h
arch/powerpc/include/asm/kvm_book3s_64.h +0 -1
@@ -37,7 +37,6 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)#ifdef CONFIG_KVM_BOOK3S_64_HV #define KVM_DEFAULT_HPT_ORDER 24/* 16MB HPT by default */ -extern int kvm_hpt_order;/* order of preallocated HPTs */ #endif #define VRMA_VSID 0x1ffffffUL/* 1TB VSID reserved for VRMA */
arch/powerpc/include/asm/kvm_host.h +1 -1
@@ -259,7 +259,7 @@ struct kvm_arch {spinlock_t slot_phys_lock;cpumask_t need_tlb_flush;struct kvmppc_vcore *vcores[KVM_MAX_VCORES ]; -struct kvmppc_linear_info *hpt_li; +int hpt_cma_alloc;#endif /* CONFIG_KVM_BOOK3S_64_HV */ #ifdef CONFIG_PPC_BOOK3S_64 struct list_head spapr_tce_tables;
arch/powerpc/include/asm/kvm_ppc.h +6 -2
@@ -139,8 +139,8 @@ extern long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, struct kvm_allocate_rma *rma);extern struct kvmppc_linear_info *kvm_alloc_rma (void );extern void kvm_release_rma (struct kvmppc_linear_info *ri); -extern struct kvmppc_linear_info *kvm_alloc_hpt (void ); -extern void kvm_release_hpt (struct kvmppc_linear_info *li); +extern struct page *kvm_alloc_hpt (int nr_pages); +extern void kvm_release_hpt (struct page *page,int nr_pages);extern int kvmppc_core_init_vm (struct kvm *kvm);extern void kvmppc_core_destroy_vm (struct kvm *kvm); extern void kvmppc_core_free_memslot(struct kvm_memory_slot *free,
@@ -261,6 +261,7 @@ void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid);struct openpic ;#ifdef CONFIG_KVM_BOOK3S_64_HV +extern void kvm_cma_reserve (void )__init ;static inline void kvmppc_set_xics_phys (int cpu,unsigned long addr) { paca[cpu].kvm_hstate.xics_phys = addr;
@@ -284,6 +285,9 @@ extern void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu);extern void kvm_linear_init (void );#else +static inline void __init kvm_cma_reserve (void ) +{} +static inline void kvmppc_set_xics_phys (int cpu,unsigned long addr) {}
arch/powerpc/kernel/setup_64.c +2 -0
@@ -229,6 +229,8 @@ void __init early_setup(unsigned long dt_ptr)/* Initialize the hash table or TLB handling */ early_init_mmu (); +kvm_cma_reserve (); +/* * Reserve any gigantic pages requested on the command line. * memblock needs to have been initialized by the time this is
arch/powerpc/kvm/Kconfig +1 -0
@@ -72,6 +72,7 @@ config KVM_BOOK3S_64_HV bool "KVM support for POWER7 and PPC970 using hypervisor mode in host" depends on KVM_BOOK3S_64 select MMU_NOTIFIER + select CMA ---help--- Support running unmodified book3s_64 guest kernels in virtual machines on POWER7 and PPC970 processors that have
arch/powerpc/kvm/Makefile +3 -0
@@ -74,12 +74,15 @@ kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \ book3s_64_mmu_hv.o kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \ book3s_hv_rm_xics.o +kvm-book3s_64-builtin-cma-objs-$(CONFIG_CMA) := \ + book3s_hv_cma.o kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \ book3s_hv_rmhandlers.o \ book3s_hv_rm_mmu.o \ book3s_64_vio_hv.o \ book3s_hv_ras.o \ book3s_hv_builtin.o \ + $(kvm-book3s_64-builtin-cma-objs-y) \ $(kvm-book3s_64-builtin-xics-objs-y) kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \
arch/powerpc/kvm/book3s_64_mmu_hv.c +16 -20
@@ -52,8 +52,8 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp) {unsigned long hpt;struct revmap_entry *rev; -struct kvmppc_linear_info *li; -long order = kvm_hpt_order; +struct page *page =NULL ; +long order =KVM_DEFAULT_HPT_ORDER ;if (htab_orderp) { order = *htab_orderp;
@@ -62,25 +62,20 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp) }/* -* If the user wants a different size from default, * try first to allocate it from the kernel page allocator. +* We keep the CMA reserved for failed allocation. */ - hpt =0 ; -if (order != kvm_hpt_order) { - hpt =__get_free_pages (GFP_KERNEL |__GFP_ZERO|__GFP_REPEAT| - __GFP_NOWARN, order -PAGE_SHIFT ); -if (!hpt) - --order; - } + hpt =__get_free_pages (GFP_KERNEL | __GFP_ZERO | __GFP_REPEAT | + __GFP_NOWARN, order -PAGE_SHIFT );/* Next try to allocate from the preallocated pool */ if (!hpt) { - li =kvm_alloc_hpt (); -if (li) { - hpt = (ulong )li->base_virt; - kvm->arch.hpt_li = li; - order = kvm_hpt_order; - } + page =kvm_alloc_hpt (1 << (order -PAGE_SHIFT )); +if (page) { + hpt = (unsigned long )pfn_to_kaddr (page_to_pfn (page)); + kvm->arch.hpt_cma_alloc =1 ; + }else + --order; }/* Lastly try successively smaller sizes from the page allocator */
@@ -118,8 +113,8 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp)return 0 ; out_freehpt: -if (kvm->arch.hpt_li) -kvm_release_hpt (kvm->arch.hpt_li); +if (kvm->arch.hpt_cma_alloc) +kvm_release_hpt (page,1 << (order -PAGE_SHIFT ));else free_pages (hpt, order -PAGE_SHIFT );return -ENOMEM ;
@@ -165,8 +160,9 @@ void kvmppc_free_hpt(struct kvm *kvm) {kvmppc_free_lpid (kvm->arch.lpid);vfree (kvm->arch.revmap); -if (kvm->arch.hpt_li) -kvm_release_hpt (kvm->arch.hpt_li); +if (kvm->arch.hpt_cma_alloc) +kvm_release_hpt (virt_to_page (kvm->arch.hpt_virt), +1 << (kvm->arch.hpt_order -PAGE_SHIFT ));else free_pages (kvm->arch.hpt_virt, kvm->arch.hpt_order -PAGE_SHIFT );
arch/powerpc/kvm/book3s_hv_builtin.c +52 -27
120 lines not on this page · raw message
arch/powerpc/kvm/book3s_hv_cma.c new file +220 -0
220 lines not on this page · raw message
arch/powerpc/kvm/book3s_hv_cma.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Contiguous Memory Allocator for ppc KVM hash pagetable based on CMA +* for DMA mapping framework +* +* Copyright IBM Corporation, 2013 +* Author Aneesh Kumar K.V <[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. +* +*/ + +#ifndef __POWERPC_KVM_CMA_ALLOC_H__ +#define __POWERPC_KVM_CMA_ALLOC_H__ +extern struct page *kvm_alloc_cma (int nr_pages,unsigned long align_order); +extern bool kvm_release_cma (struct page *pages,int nr_pages); +extern long kvm_cma_declare_contiguous (phys_addr_t size, +phys_addr_t alignment)__init ; +#endif
Signature · 7 lines
1.8.1.2 -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RFC PATCH 3/3 powerpc: Contiguous memory allocator based RMA allocation
In reply to Aneesh Kumar K.VFrom: "Aneesh Kumar K.V" <[email protected]>
Use CMA for allocation of RMA region for guest. Also remove linear allocator now that it is not used
--- arch/powerpc/include/asm/kvm_book3s_64.h | 1 + arch/powerpc/include/asm/kvm_host.h | 12 +-- arch/powerpc/include/asm/kvm_ppc.h | 8 +- arch/powerpc/kernel/setup_64.c | 2 - arch/powerpc/kvm/book3s_hv.c | 44 ++++++--- arch/powerpc/kvm/book3s_hv_builtin.c | 164 +++++++------------------------ 6 files changed, 71 insertions(+), 160 deletions(-)
arch/powerpc/include/asm/kvm_book3s_64.h +1 -0
@@ -37,6 +37,7 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)#ifdef CONFIG_KVM_BOOK3S_64_HV #define KVM_DEFAULT_HPT_ORDER 24/* 16MB HPT by default */ +extern unsigned long kvm_rma_pages;#endif #define VRMA_VSID 0x1ffffffUL/* 1TB VSID reserved for VRMA */
arch/powerpc/include/asm/kvm_host.h +4 -8
@@ -183,13 +183,9 @@ struct kvmppc_spapr_tce_table {struct page *pages[0 ]; }; -struct kvmppc_linear_info { -void *base_virt; -unsigned long base_pfn; -unsigned long npages; -struct list_head list; -atomic_t use_count; -int type; +struct kvm_rma_info { +atomic_t use_count; +unsigned long base_pfn; };/* XICS components, defined in book3s_xics.c */
@@ -246,7 +242,7 @@ struct kvm_arch {int tlbie_lock;unsigned long lpcr;unsigned long rmor; -struct kvmppc_linear_info *rma; +struct kvm_rma_info *ri;unsigned long vrma_slb_v;int rma_setup_done;int using_mmu_notifiers;
arch/powerpc/include/asm/kvm_ppc.h +2 -6
@@ -137,8 +137,8 @@ extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, unsigned long ioba, unsigned long tce);extern long kvm_vm_ioctl_allocate_rma (struct kvm *kvm,struct kvm_allocate_rma *rma); -extern struct kvmppc_linear_info *kvm_alloc_rma (void ); -extern void kvm_release_rma (struct kvmppc_linear_info *ri); +extern struct kvm_rma_info *kvm_alloc_rma (void ); +extern void kvm_release_rma (struct kvm_rma_info *ri);extern struct page *kvm_alloc_hpt (int nr_pages);extern void kvm_release_hpt (struct page *page,int nr_pages);extern int kvmppc_core_init_vm (struct kvm *kvm);
@@ -282,7 +282,6 @@ static inline void kvmppc_set_host_ipi(int cpu, u8 host_ipi) }extern void kvmppc_fast_vcpu_kick (struct kvm_vcpu *vcpu); -extern void kvm_linear_init (void );#else static inline void __init kvm_cma_reserve (void )
@@ -291,9 +290,6 @@ static inline void __init kvm_cma_reserve(void)static inline void kvmppc_set_xics_phys (int cpu,unsigned long addr) {} -static inline void kvm_linear_init (void ) -{} -static inline u32 kvmppc_get_xics_latch (void ) {return 0 ;
arch/powerpc/kernel/setup_64.c +0 -2
@@ -611,8 +611,6 @@ void __init setup_arch(char **cmdline_p)/* Initialize the MMU context management stuff */ mmu_context_init (); -kvm_linear_init (); -/* Interrupt code needs to be 64K-aligned */ if ((unsigned long )_stext &0xffff ) panic("Kernelbase not 64K-aligned (0x%lx)!\n",
arch/powerpc/kvm/book3s_hv.c +30 -14
113 lines not on this page · raw message
arch/powerpc/kvm/book3s_hv_builtin.c +34 -130
217 lines not on this page · raw message
Signature · 7 lines
1.8.1.2 -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 18 lines
drivers/base/Makefile +1
-1@@ -6,7 +6,7 @@ obj-y := core.o bus.o dd.o syscore.o \ attribute_container.o transport_class.o \ topology.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o -obj-$(CONFIG_CMA) += dma-contiguous.o +obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.oinclude/linux/dma-contiguous.h +0
-0
include/linux/dma-contiguous.h struct cma; · line 61
Quoted 6 lines
include/linux/dma-contiguous.h +1
-1@@ -57,7 +57,7 @@ struct cma;struct page ;struct device ; -#ifdef CONFIG_CMA +#ifdef CONFIG_DMA_CMA
We have some generic CMA documentation available in this file which need to be moved to a more generic place (generic MM) as we are differentiating it from DMA specific usage. Ideally we should have two documentation
(1) CMA usage for any subsystem
(2) DMA specific CMA usage
Quoted 9 lines
include/linux/dma-contiguous.h +0
-0/* * There is always at least global CMA area and a few optional device mm/Kconfig +0
-0@@ -477,3 +477,23 @@ config FRONTSWAP and swap data is stored as normal on the matching swap device.
mm/Kconfig config FRONTSWAP · line 488
Quoted 10 lines
mm/Kconfig +9
-0If unsure, say Y to enable frontswap. + +config CMA + bool "Contiguous Memory Allocator" + depends on HAVE_MEMBLOCK + select MIGRATION + select MEMORY_ISOLATION + help + This enables the Contiguous Memory Allocator which allows other + subsystem to allocate big physically-contiguous blocks of memory
Should be "any subsystem" instead of "other subsystem"
mm/Kconfig config FRONTSWAP · line 499
Quoted 12 lines
mm/Kconfig +11
-0+ + If unsure, say "n". + +config CMA_DEBUG + bool "CMA debug messages (DEVELOPMENT)" + depends on DEBUG_KERNEL && CMA + help + Turns on debug messages in CMA. This produces KERN_DEBUG + messages for every CMA call as well as various messages while + processing calls such as dma_alloc_from_contiguous(). + This option does not affect warning and error messages.
We should probably split up these debug configs as well to differentiate between generic CMA_DEBUG and DMA_CMA_DEBUG options.
Regards
Anshuman
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello,
Quoted 7 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
We want to use CMA for allocating hash page table and real mode area for PPC64. Hence move DMA contiguous related changes into a seperate config so that ppc64 can enable CMA without requiring DMA contiguous.
Signed-off-by Aneesh Kumar K.V <[email protected]>
It's nice to see that CMA is gaining another client in mainline Linux kernel. I also like the idea of adding CONFIG_DMA_CMA for DMA-mapping related CMA use to let others to use alloc_contig_range() interface.
However I noticed that You have almost copied the whole drivers/base.c for separate use with PPC64 KVM. Is this really necessary? I think it should be possible to isolate some common code, which plays with contiguous region management and use it for both alloc_contig_range() clients (dma-mapping and ppc64 kvm).
Quoted 164 lines
--- arch/arm/configs/omap2plus_defconfig | 2 +- arch/arm/configs/tegra_defconfig | 2 +- arch/arm/include/asm/dma-contiguous.h | 2 +- arch/arm/mm/dma-mapping.c | 6 +++--- drivers/base/Kconfig | 21 +++++---------------- drivers/base/Makefile | 2 +- include/linux/dma-contiguous.h | 2 +- mm/Kconfig | 20 ++++++++++++++++++++ 8 files changed, 33 insertions(+), 24 deletions(-)arch/arm/configs/omap2plus_defconfig +1
-1@@ -71,7 +71,7 @@ CONFIG_MAC80211=m CONFIG_MAC80211_RC_PID=y CONFIG_MAC80211_RC_DEFAULT_PID=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" -CONFIG_CMA=y +CONFIG_DMA_CMA=y CONFIG_CONNECTOR=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=yarch/arm/configs/tegra_defconfig +1
-1@@ -79,7 +79,7 @@ CONFIG_RFKILL_GPIO=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y # CONFIG_FIRMWARE_IN_KERNEL is not set -CONFIG_CMA=y +CONFIG_DMA_CMA=y CONFIG_MTD=y CONFIG_MTD_CHAR=y CONFIG_MTD_M25P80=yarch/arm/include/asm/dma-contiguous.h +1
-1@@ -2,7 +2,7 @@#define ASMARM_DMA_CONTIGUOUS_H #ifdef __KERNEL__ -#ifdef CONFIG_CMA +#ifdef CONFIG_DMA_CMA #include <linux/types.h> #include <asm-generic/dma-contiguous.h> arch/arm/mm/dma-mapping.c +3
-3@@ -358,7 +358,7 @@ static int __init atomic_pool_init(void)if (!pages) goto no_pages; -if (IS_ENABLED (CONFIG_CMA )) +if (IS_ENABLED (CONFIG_DMA_CMA )) ptr =__alloc_from_contiguous (NULL , pool->size, prot, &page, atomic_pool_init);else @@ -670,7 +670,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, addr =__alloc_simple_buffer (dev, size, gfp, &page); else if (!(gfp & __GFP_WAIT)) addr =__alloc_from_pool (size, &page); - else if (!IS_ENABLED(CONFIG_CMA)) + else if (!IS_ENABLED(CONFIG_DMA_CMA)) addr =__alloc_remap_buffer (dev, size, gfp, prot, &page, caller); else addr =__alloc_from_contiguous (dev, size, prot, &page, caller);@@ -759,7 +759,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,__dma_free_buffer (page, size); }else if (__free_from_pool (cpu_addr, size)) {return ; - }else if (!IS_ENABLED (CONFIG_CMA )) { + }else if (!IS_ENABLED (CONFIG_DMA_CMA )) {__dma_free_remap (cpu_addr, size);__dma_free_buffer (page, size); }else {drivers/base/Kconfig +5
-16@@ -202,11 +202,10 @@ config DMA_SHARED_BUFFER APIs extension; the file's descriptor can then be passed on to other driver. -config CMA - bool "Contiguous Memory Allocator" - depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK - select MIGRATION - select MEMORY_ISOLATION +config DMA_CMA + bool "DMA Contiguous Memory Allocator" + depends on HAVE_DMA_CONTIGUOUS + select CMA help This enables the Contiguous Memory Allocator which allows drivers to allocate big physically-contiguous blocks of memory for use with@@ -215,17 +214,7 @@ config CMA For more information see <include/linux/dma-contiguous.h>. If unsure, say "n". -if CMA - -config CMA_DEBUG - bool "CMA debug messages (DEVELOPMENT)" - depends on DEBUG_KERNEL - help - Turns on debug messages in CMA. This produces KERN_DEBUG - messages for every CMA call as well as various messages while - processing calls such as dma_alloc_from_contiguous(). - This option does not affect warning and error messages. - +if DMA_CMA comment "Default contiguous memory area size:" config CMA_SIZE_MBYTESdrivers/base/Makefile +1
-1@@ -6,7 +6,7 @@ obj-y := core.o bus.o dd.o syscore.o \ attribute_container.o transport_class.o \ topology.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o -obj-$(CONFIG_CMA) += dma-contiguous.o +obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.oinclude/linux/dma-contiguous.h +1
-1@@ -57,7 +57,7 @@ struct cma;struct page ;struct device ; -#ifdef CONFIG_CMA +#ifdef CONFIG_DMA_CMA /* * There is always at least global CMA area and a few optional device mm/Kconfig +10
-0@@ -477,3 +477,23 @@ config FRONTSWAP and swap data is stored as normal on the matching swap device. If unsure, say Y to enable frontswap. + +config CMA + bool "Contiguous Memory Allocator" + depends on HAVE_MEMBLOCK + select MIGRATION + select MEMORY_ISOLATION + help + This enables the Contiguous Memory Allocator which allows other + subsystem to allocate big physically-contiguous blocks of memory +
mm/Kconfig config FRONTSWAP · line 499
Quoted 10 lines
mm/Kconfig +10
-0+ If unsure, say "n". + +config CMA_DEBUG + bool "CMA debug messages (DEVELOPMENT)" + depends on DEBUG_KERNEL && CMA + help + Turns on debug messages in CMA. This produces KERN_DEBUG + messages for every CMA call as well as various messages while + processing calls such as dma_alloc_from_contiguous(). + This option does not affect warning and error messages.
Best regards
Signature · 9 lines
Marek Szyprowski Samsung R&D Institute Poland -- 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/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 16 lines · Marek Szyprowski
Hello,
Quoted 7 lines · Aneesh Kumar K.V
From: "Aneesh Kumar K.V" <[email protected]>
We want to use CMA for allocating hash page table and real mode area for PPC64. Hence move DMA contiguous related changes into a seperate config so that ppc64 can enable CMA without requiring DMA contiguous.
Signed-off-by Aneesh Kumar K.V <[email protected]>It's nice to see that CMA is gaining another client in mainline Linux kernel.
I also like the idea of addingCONFIG_DMA_CMAfor DMA-mapping related CMA use to let others to usealloc_contig_range()interface.
Quoted 6 lines
However I noticed that You have almost copied the whole
drivers/base.cfor separate use with PPC64 KVM. Is this really necessary? I think it should be possible to isolate some common code, which plays with contiguous region management and use it for bothalloc_contig_range()clients (dma-mapping and ppc64 kvm).
One of the reason for having book3s_hv_cma.c is that few specifics vary between dma contiguous. We have different alignment needs. Also i will be switching the allocation to 256K chunks, not page size, in the next update. It is also not large code duplication. I will post V2 soon and may be we can see if it is worth consolidating.
-aneesh
--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>