FAILED: patch "[PATCH] drivers: add Contiguous Memory Allocator" failed to apply to 4.19-stable tree
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c64be2bb1c6eb43c838b2c6d57b074078be208dd Mon Sep 17 00:00:00 2001
From: Marek Szyprowski <[email protected]>
Date: Thu, 29 Dec 2011 13:09:51 +0100
Subject: [PATCH] drivers: add Contiguous Memory Allocator
The Contiguous Memory Allocator is a set of helper functions for DMA mapping framework that improves allocations of contiguous memory chunks.
CMA grabs memory on system boot, marks it with MIGRATE_CMA migrate type and gives back to the system. Kernel is allowed to allocate only movable pages within CMA's managed memory so that it can be used for example for page cache when DMA mapping do not use it. On dma_alloc_from_contiguous() request such pages are migrated out of CMA area to free required contiguous block and fulfill the request. This allows to allocate large contiguous chunks of memory at any time assuming that there is enough free memory available in the system.
This code is heavily based on earlier works by Michal Nazarewicz.
Documentation/kernel-parameters.txt +5 -0
@@ -508,6 +508,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted. Also note the kernel might malfunction if you disable some critical bits. + cma=nn[MG] [ARM,KNL] + Sets the size of kernel global memory area for contiguous + memory allocations. For more information, see + include/linux/dma-contiguous.h + cmo_free_hint= [PPC] Format: { yes | no } Specify whether pages are marked as being inactive when they are freed. This is used in CMO environments
arch/Kconfig +3 -0
@@ -142,6 +142,9 @@ config HAVE_ARCH_TRACEHOOK config HAVE_DMA_ATTRS bool +config HAVE_DMA_CONTIGUOUS + bool + config USE_GENERIC_SMP_HELPERS bool
drivers/base/Kconfig +89 -0
93 lines not on this page · raw message
drivers/base/Makefile +1 -0
@@ -6,6 +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-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
drivers/base/dma-contiguous.c new file +401 -0
401 lines not on this page · raw message
include/asm-generic/dma-contiguous.h new file +28 -0
@@ -0,0 +1,28 @@ +#ifndef ASM_DMA_CONTIGUOUS_H +#define ASM_DMA_CONTIGUOUS_H + +#ifdef __KERNEL__ +#ifdef CONFIG_CMA + +#include <linux/device.h> +#include <linux/dma-contiguous.h> + +static inline struct cma *dev_get_cma_area (struct device *dev) +{ +if (dev && dev->cma_area) +return dev->cma_area; +return dma_contiguous_default_area; +} + +static inline void dev_set_cma_area (struct device *dev,struct cma *cma) +{ +if (dev) + dev->cma_area = cma; +if (!dev || !dma_contiguous_default_area) + dma_contiguous_default_area = cma; +} + +#endif +#endif + +#endif
include/linux/device.h +4 -0
@@ -661,6 +661,10 @@ struct device {struct dma_coherent_mem *dma_mem;/* internal for coherent mem override */ +#ifdef CONFIG_CMA +struct cma *cma_area;/* contiguous memory area for dma +allocations */ +#endif /* arch specific additions */ struct dev_archdata archdata;
include/linux/dma-contiguous.h new file +110 -0
110 lines not on this page · raw message