All of lore.kernel.org
 help / color / mirror / Atom feed
* CMA reservations have different result in linux 4.1.5 kernel compared to linux 3.14 kernel.
@ 2016-04-29  9:02 Xiaowen Liu
  0 siblings, 0 replies; only message in thread
From: Xiaowen Liu @ 2016-04-29  9:02 UTC (permalink / raw)
  To: laurent.pinchart+renesas; +Cc: m.szyprowski, linux-mm


[-- Attachment #1.1: Type: text/plain, Size: 2623 bytes --]

Hi laurent.pinchart,

I found there is a commit to reserve CMA from high memory first and then falls back to low memory.

commit 16195ddd4ebcc10c30b2f232f8e400df8d464380
Author: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com<mailto:laurent.pinchart+renesas@ideasonboard.com>>
Date:   Fri Oct 24 13:18:41 2014 +0300

    mm: cma: Ensure that reservations never cross the low/high mem boundary

    Commit 95b0e655f914 ("ARM: mm: don't limit default CMA region only to
    low memory") extended CMA memory reservation to allow usage of high
    memory. It relied on commit f7426b983a6a ("mm: cma: adjust address limit
    to avoid hitting low/high memory boundary") to ensure that the reserved
    block never crossed the low/high memory boundary. While the
    implementation correctly lowered the limit, it failed to consider the
    case where the base..limit range crossed the low/high memory boundary
    with enough space on each side to reserve the requested size on either
    low or high memory.

    Rework the base and limit adjustment to fix the problem. The function
    now starts by rejecting the reservation altogether for fixed
    reservations that cross the boundary, tries to reserve from high memory
    first and then falls back to low memory.

The CMA configuration has two paths. One is in DTS and the other in kernel command line.
In order to make convenient to adjust CMA size, we use kernel command line to set CMA size in linux 3.14 kernel.
When the kernel is upgraded from 3.14 to 4.1, there is an strange issue.
The CMA reserved base address is changed from low memory to high memory.
Of course it introduces a lot of issues on our imx6 platform when CMA reserved base address is at high memory.
So, I find your commit listed above that change the CMA reserved base address.
Of course this change itself doesn't have any problem.
But it has different result compared to configuring CMA in DTS.
The CMA reserved base address is at low memory when configure CMA in DTS.

My questions are:
1. the two CMA configuration methods reside in different memory zone which may introduce confusion.
2. This commit breaks the kernel backward compatibility that the same CMA configuration in old kernel version should reside in the same memory zone when kernel upgrade.

There is one patch attached to make CMA reserved memory allocating from low memory firstly and fall back to high memory to be backward compatible.
If the CMA is required to be reserved at high memory, the CMA base should be set to configure CMA memory.

Best Regards,
Ivan.liu



[-- Attachment #1.2: Type: text/html, Size: 6705 bytes --]

[-- Attachment #2: 0001-correct-CMA-reserved-memory-allocating-from-low-memo.patch --]
[-- Type: application/octet-stream, Size: 1618 bytes --]

From 21848309f8c416f3e1ff2187576d02507aa3cc23 Mon Sep 17 00:00:00 2001
From: Xiaowen Liu <xiaowen.liu@nxp.com>
Date: Fri, 29 Apr 2016 17:53:44 -0400
Subject: [PATCH] correct CMA reserved memory allocating from low memory
 firstly and fall back to hight memory.

mm: cma: correct CMA reserved memory allocating from low memory firstly and fall back to hight memory.

Signed-off-by: Xiaowen Liu <xiaowen.liu@nxp.com>
---
 mm/cma.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/mm/cma.c b/mm/cma.c
index 3a7a67b..fd2387e 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -311,18 +311,19 @@ int __init cma_declare_contiguous(phys_addr_t base,
 		/*
 		 * All pages in the reserved area must come from the same zone.
 		 * If the requested region crosses the low/high memory boundary,
-		 * try allocating from high memory first and fall back to low
-		 * memory in case of failure.
+		 * try allocating from low memory first and fall back to high
+		 * memory in case of failure to be backward compatible.
 		 */
-		if (base < highmem_start && limit > highmem_start) {
-			addr = memblock_alloc_range(size, alignment,
-						    highmem_start, limit);
-			limit = highmem_start;
-		}
+		addr = memblock_alloc_range(size, alignment, base,
+					    limit);
 
 		if (!addr) {
-			addr = memblock_alloc_range(size, alignment, base,
-						    limit);
+			if (base < highmem_start && limit > highmem_start) {
+				addr = memblock_alloc_range(size, alignment,
+							    highmem_start, limit);
+				limit = highmem_start;
+			}
+
 			if (!addr) {
 				ret = -ENOMEM;
 				goto err;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-29  9:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29  9:02 CMA reservations have different result in linux 4.1.5 kernel compared to linux 3.14 kernel Xiaowen Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.