+ dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: kernel/dma: remove unsupported gfp_mask parameter from dma_alloc_from_contiguous()
has been added to the -mm tree.  Its filename is
     dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Subject: kernel/dma: remove unsupported gfp_mask parameter from dma_alloc_from_contiguous()

The CMA memory allocator doesn't support standard gfp flags for memory
allocation, so there is no point having it as a parameter for
dma_alloc_from_contiguous() function.  Replace it by a boolean no_warn
argument, which covers all the underlaying cma_alloc() function supports.

This will help to avoid giving false feeling that this function supports
standard gfp flags and callers can pass __GFP_ZERO to get zeroed buffer,
what has already been an issue: see commit dd65a941f6ba ("arm64:
dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag").

Link: http://lkml.kernel.org/r/20180709122020eucas1p21a71b092975cb4a3b9954ffc63f699d1~-sqUFoa-h2939329393eucas1p2Y@xxxxxxxxxxxxxxxxxxxx
Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Acked-by: Acked-by: Michał Nazarewicz <mina86@xxxxxxxxxx>
Cc: Laura Abbott <labbott@xxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 arch/arm/mm/dma-mapping.c      |    5 +++--
 arch/arm64/mm/dma-mapping.c    |    4 ++--
 arch/xtensa/kernel/pci-dma.c   |    2 +-
 drivers/iommu/amd_iommu.c      |    2 +-
 drivers/iommu/intel-iommu.c    |    3 ++-
 include/linux/dma-contiguous.h |    4 ++--
 kernel/dma/contiguous.c        |    7 +++----
 kernel/dma/direct.c            |    3 ++-
 8 files changed, 16 insertions(+), 14 deletions(-)

diff -puN arch/arm64/mm/dma-mapping.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous arch/arm64/mm/dma-mapping.c
--- a/arch/arm64/mm/dma-mapping.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/arch/arm64/mm/dma-mapping.c
@@ -355,7 +355,7 @@ static int __init atomic_pool_init(void)
 
 	if (dev_get_cma_area(NULL))
 		page = dma_alloc_from_contiguous(NULL, nr_pages,
-						 pool_size_order, GFP_KERNEL);
+						 pool_size_order, false);
 	else
 		page = alloc_pages(GFP_DMA32, pool_size_order);
 
@@ -573,7 +573,7 @@ static void *__iommu_alloc_attrs(struct
 		struct page *page;
 
 		page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
-						 get_order(size), gfp);
+					get_order(size), gfp & __GFP_NOWARN);
 		if (!page)
 			return NULL;
 
diff -puN arch/arm/mm/dma-mapping.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous arch/arm/mm/dma-mapping.c
--- a/arch/arm/mm/dma-mapping.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/arch/arm/mm/dma-mapping.c
@@ -594,7 +594,7 @@ static void *__alloc_from_contiguous(str
 	struct page *page;
 	void *ptr = NULL;
 
-	page = dma_alloc_from_contiguous(dev, count, order, gfp);
+	page = dma_alloc_from_contiguous(dev, count, order, gfp & __GFP_NOWARN);
 	if (!page)
 		return NULL;
 
@@ -1294,7 +1294,8 @@ static struct page **__iommu_alloc_buffe
 		unsigned long order = get_order(size);
 		struct page *page;
 
-		page = dma_alloc_from_contiguous(dev, count, order, gfp);
+		page = dma_alloc_from_contiguous(dev, count, order,
+						 gfp & __GFP_NOWARN);
 		if (!page)
 			goto error;
 
diff -puN arch/xtensa/kernel/pci-dma.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous arch/xtensa/kernel/pci-dma.c
--- a/arch/xtensa/kernel/pci-dma.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/arch/xtensa/kernel/pci-dma.c
@@ -137,7 +137,7 @@ static void *xtensa_dma_alloc(struct dev
 
 	if (gfpflags_allow_blocking(flag))
 		page = dma_alloc_from_contiguous(dev, count, get_order(size),
-						 flag);
+						 flag & __GFP_NOWARN);
 
 	if (!page)
 		page = alloc_pages(flag, get_order(size));
diff -puN drivers/iommu/amd_iommu.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous drivers/iommu/amd_iommu.c
--- a/drivers/iommu/amd_iommu.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/drivers/iommu/amd_iommu.c
@@ -2620,7 +2620,7 @@ static void *alloc_coherent(struct devic
 			return NULL;
 
 		page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
-						 get_order(size), flag);
+					get_order(size), flag & __GFP_NOWARN);
 		if (!page)
 			return NULL;
 	}
diff -puN drivers/iommu/intel-iommu.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous drivers/iommu/intel-iommu.c
--- a/drivers/iommu/intel-iommu.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/drivers/iommu/intel-iommu.c
@@ -3730,7 +3730,8 @@ static void *intel_alloc_coherent(struct
 	if (gfpflags_allow_blocking(flags)) {
 		unsigned int count = size >> PAGE_SHIFT;
 
-		page = dma_alloc_from_contiguous(dev, count, order, flags);
+		page = dma_alloc_from_contiguous(dev, count, order,
+						 flags & __GFP_NOWARN);
 		if (page && iommu_no_mapping(dev) &&
 		    page_to_phys(page) + size > dev->coherent_dma_mask) {
 			dma_release_from_contiguous(dev, page, count);
diff -puN include/linux/dma-contiguous.h~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous include/linux/dma-contiguous.h
--- a/include/linux/dma-contiguous.h~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/include/linux/dma-contiguous.h
@@ -112,7 +112,7 @@ static inline int dma_declare_contiguous
 }
 
 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
-				       unsigned int order, gfp_t gfp_mask);
+				       unsigned int order, bool no_warn);
 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
 				 int count);
 
@@ -145,7 +145,7 @@ int dma_declare_contiguous(struct device
 
 static inline
 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
-				       unsigned int order, gfp_t gfp_mask)
+				       unsigned int order, bool no_warn)
 {
 	return NULL;
 }
diff -puN kernel/dma/contiguous.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous kernel/dma/contiguous.c
--- a/kernel/dma/contiguous.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/kernel/dma/contiguous.c
@@ -178,7 +178,7 @@ int __init dma_contiguous_reserve_area(p
  * @dev:   Pointer to device for which the allocation is performed.
  * @count: Requested number of pages.
  * @align: Requested alignment of pages (in PAGE_SIZE order).
- * @gfp_mask: GFP flags to use for this allocation.
+ * @no_warn: Avoid printing message about failed allocation.
  *
  * This function allocates memory buffer for specified device. It uses
  * device specific contiguous memory area if available or the default
@@ -186,13 +186,12 @@ int __init dma_contiguous_reserve_area(p
  * function.
  */
 struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
-				       unsigned int align, gfp_t gfp_mask)
+				       unsigned int align, bool no_warn)
 {
 	if (align > CONFIG_CMA_ALIGNMENT)
 		align = CONFIG_CMA_ALIGNMENT;
 
-	return cma_alloc(dev_get_cma_area(dev), count, align,
-			 gfp_mask & __GFP_NOWARN);
+	return cma_alloc(dev_get_cma_area(dev), count, align, no_warn);
 }
 
 /**
diff -puN kernel/dma/direct.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous kernel/dma/direct.c
--- a/kernel/dma/direct.c~dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous
+++ a/kernel/dma/direct.c
@@ -78,7 +78,8 @@ void *dma_direct_alloc(struct device *de
 again:
 	/* CMA can be used only in the context which permits sleeping */
 	if (gfpflags_allow_blocking(gfp)) {
-		page = dma_alloc_from_contiguous(dev, count, page_order, gfp);
+		page = dma_alloc_from_contiguous(dev, count, page_order,
+						 gfp & __GFP_NOWARN);
 		if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) {
 			dma_release_from_contiguous(dev, page, count);
 			page = NULL;
_

Patches currently in -mm which might be from m.szyprowski@xxxxxxxxxxx are

mm-cma-remove-unsupported-gfp_mask-parameter-from-cma_alloc.patch
dma-remove-unsupported-gfp_mask-parameter-from-dma_alloc_from_contiguous.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux