Skip to content

Commit 490a629

Browse files
committed
ARM: shmobile: rcar-gen2: Remove CMA reservation code
If CONFIG_HIGHMEM=y, two reserved blocks are allocated on R-Car Gen2: cma: Reserved 256 MiB at 0x70000000 on node -1 cma: Reserved 64 MiB at 0x6c000000 on node -1 The first block is reserved by the family-specific rcar_gen2_reserve(), the second by the common arm_memblock_init() (shmobile_defconfig sets CONFIG_CMA_SIZE_MBYTES=64). As both blocks are reserved (eventually) using dma_contiguous_reserve_area(), they both have the same name ("reserved"). Hence if CONFIG_CMA_SYSFS=y: sysfs: cannot create duplicate filename '/kernel/mm/cma/reserved' ... cma_sysfs_init from do_one_initcall+0x84/0x178 ... kobject: kobject_add_internal failed for reserved with -EEXIST, don't try to register things with the same name in the same directory. This causes cma_sysfs_init() to fail completely, and not to create /sys/kernel/mm/cma/ at all. Fix this by dropping the R-Car Gen2-specific reservation. Compared to when it was introduced, now there exist more flexible mechanisms to control the size of memory reserved for CMA. Users can reserve more memory by increasing CONFIG_CMA_SIZE_MBYTES, passing the cma=<N> kernel command line parameter, or adding a reserved-memory/linux,cma node to DT. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Link: https://lore.kernel.org/3d38f4fec20c4af46e4570012de7017eee9a39e9.1736249109.git.geert+renesas@glider.be
1 parent 2014c95 commit 490a629

1 file changed

Lines changed: 0 additions & 76 deletions

File tree

arch/arm/mach-shmobile/setup-rcar-gen2.c

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@
88
*/
99

1010
#include <linux/clocksource.h>
11-
#include <linux/device.h>
12-
#include <linux/dma-map-ops.h>
1311
#include <linux/io.h>
1412
#include <linux/kernel.h>
1513
#include <linux/memblock.h>
1614
#include <linux/of.h>
1715
#include <linux/of_clk.h>
18-
#include <linux/of_fdt.h>
1916
#include <linux/psci.h>
2017
#include <asm/mach/arch.h>
2118
#include <asm/secure_cntvoff.h>
2219
#include "common.h"
23-
#include "rcar-gen2.h"
2420

2521
static const struct of_device_id cpg_matches[] __initconst = {
2622
{ .compatible = "renesas,r8a7742-cpg-mssr", .data = "extal" },
@@ -122,76 +118,6 @@ static void __init rcar_gen2_timer_init(void)
122118
timer_probe();
123119
}
124120

125-
struct memory_reserve_config {
126-
u64 reserved;
127-
u64 base, size;
128-
};
129-
130-
static int __init rcar_gen2_scan_mem(unsigned long node, const char *uname,
131-
int depth, void *data)
132-
{
133-
const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
134-
const __be32 *reg, *endp;
135-
int l;
136-
struct memory_reserve_config *mrc = data;
137-
u64 lpae_start = 1ULL << 32;
138-
139-
/* We are scanning "memory" nodes only */
140-
if (type == NULL || strcmp(type, "memory"))
141-
return 0;
142-
143-
reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
144-
if (reg == NULL)
145-
reg = of_get_flat_dt_prop(node, "reg", &l);
146-
if (reg == NULL)
147-
return 0;
148-
149-
endp = reg + (l / sizeof(__be32));
150-
while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
151-
u64 base, size;
152-
153-
base = dt_mem_next_cell(dt_root_addr_cells, &reg);
154-
size = dt_mem_next_cell(dt_root_size_cells, &reg);
155-
156-
if (base >= lpae_start)
157-
continue;
158-
159-
if ((base + size) >= lpae_start)
160-
size = lpae_start - base;
161-
162-
if (size < mrc->reserved)
163-
continue;
164-
165-
if (base < mrc->base)
166-
continue;
167-
168-
/* keep the area at top near the 32-bit legacy limit */
169-
mrc->base = base + size - mrc->reserved;
170-
mrc->size = mrc->reserved;
171-
}
172-
173-
return 0;
174-
}
175-
176-
static void __init rcar_gen2_reserve(void)
177-
{
178-
struct memory_reserve_config mrc;
179-
180-
/* reserve 256 MiB at the top of the physical legacy 32-bit space */
181-
memset(&mrc, 0, sizeof(mrc));
182-
mrc.reserved = SZ_256M;
183-
184-
of_scan_flat_dt(rcar_gen2_scan_mem, &mrc);
185-
#ifdef CONFIG_DMA_CMA
186-
if (mrc.size && memblock_is_region_memory(mrc.base, mrc.size)) {
187-
static struct cma *rcar_gen2_dma_contiguous;
188-
189-
dma_contiguous_reserve_area(mrc.size, mrc.base, 0,
190-
&rcar_gen2_dma_contiguous, true);
191-
}
192-
#endif
193-
}
194-
195121
static const char * const rcar_gen2_boards_compat_dt[] __initconst = {
196122
"renesas,r8a7790",
197123
"renesas,r8a7791",
@@ -204,7 +130,6 @@ static const char * const rcar_gen2_boards_compat_dt[] __initconst = {
204130
DT_MACHINE_START(RCAR_GEN2_DT, "Generic R-Car Gen2 (Flattened Device Tree)")
205131
.init_late = shmobile_init_late,
206132
.init_time = rcar_gen2_timer_init,
207-
.reserve = rcar_gen2_reserve,
208133
.dt_compat = rcar_gen2_boards_compat_dt,
209134
MACHINE_END
210135

@@ -220,6 +145,5 @@ static const char * const rz_g1_boards_compat_dt[] __initconst = {
220145
DT_MACHINE_START(RZ_G1_DT, "Generic RZ/G1 (Flattened Device Tree)")
221146
.init_late = shmobile_init_late,
222147
.init_time = rcar_gen2_timer_init,
223-
.reserve = rcar_gen2_reserve,
224148
.dt_compat = rz_g1_boards_compat_dt,
225149
MACHINE_END

0 commit comments

Comments
 (0)