Re: [patch 1/7] dma-remap: separate DMA atomic pools from direct remap code

From: Christoph Hellwig
Date: Fri Apr 17 2020 - 03:06:28 EST


On Tue, Apr 14, 2020 at 05:04:52PM -0700, David Rientjes wrote:
> DMA atomic pools will be needed beyond only CONFIG_DMA_DIRECT_REMAP so
> separate them out into their own file.
>
> This also adds a new Kconfig option that can be subsequently used for
> options, such as CONFIG_AMD_MEM_ENCRYPT, that will utilize the coherent
> pools but do not have a dependency on direct remapping.
>
> For this patch alone, there is no functional change introduced.
>
> Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
> ---
> kernel/dma/Kconfig | 6 ++-
> kernel/dma/Makefile | 1 +
> kernel/dma/pool.c | 123 ++++++++++++++++++++++++++++++++++++++++++++
> kernel/dma/remap.c | 114 ----------------------------------------
> 4 files changed, 129 insertions(+), 115 deletions(-)
> create mode 100644 kernel/dma/pool.c
>
> diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
> index 4c103a24e380..d006668c0027 100644
> --- a/kernel/dma/Kconfig
> +++ b/kernel/dma/Kconfig
> @@ -79,10 +79,14 @@ config DMA_REMAP
> select DMA_NONCOHERENT_MMAP
> bool
>
> -config DMA_DIRECT_REMAP
> +config DMA_COHERENT_POOL
> bool
> select DMA_REMAP
>
> +config DMA_DIRECT_REMAP
> + bool
> + select DMA_COHERENT_POOL
> +
> config DMA_CMA
> bool "DMA Contiguous Memory Allocator"
> depends on HAVE_DMA_CONTIGUOUS && CMA
> diff --git a/kernel/dma/Makefile b/kernel/dma/Makefile
> index d237cf3dc181..370f63344e9c 100644
> --- a/kernel/dma/Makefile
> +++ b/kernel/dma/Makefile
> @@ -6,4 +6,5 @@ obj-$(CONFIG_DMA_DECLARE_COHERENT) += coherent.o
> obj-$(CONFIG_DMA_VIRT_OPS) += virt.o
> obj-$(CONFIG_DMA_API_DEBUG) += debug.o
> obj-$(CONFIG_SWIOTLB) += swiotlb.o
> +obj-$(CONFIG_DMA_COHERENT_POOL) += pool.o
> obj-$(CONFIG_DMA_REMAP) += remap.o
> diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
> new file mode 100644
> index 000000000000..6612c2d51d3c
> --- /dev/null
> +++ b/kernel/dma/pool.c
> @@ -0,0 +1,123 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020 Google LLC

This now also lost the ARM copyright in addition to the Linuxfoundation
one, but I can fix that up. Otherwise it looks good to me.