Re: [PATCH 08/19] LoongArch: Add memory management

From
Arnd Bergmann <arnd@kernel.org>
Date
2021-07-06 10:58:00
Reply to
Arnd Bergmann, 2021-07-06
On Tue, Jul 6, 2021 at 6:18 AM Huacai Chen [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/include/asm/kmalloc.h b/arch/loongarch/include/asm/kmalloc.h
new file mode 100644
index 000000000000..b318c41520d8
--- /dev/null
+++ b/arch/loongarch/include/asm/kmalloc.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020-2021 Loongson Technology Corporation Limited
+ */
+#ifndef __ASM_KMALLOC_H
+#define __ASM_KMALLOC_H
+
+#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
+
+#endif /* __ASM_KMALLOC_H */
You wrote elsewhere that DMA is cache-coherent, so this should not
be needed at all.
quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/include/asm/shmparam.h b/arch/loongarch/include/asm/shmparam.h
new file mode 100644
index 000000000000..f726ac537710
--- /dev/null
+++ b/arch/loongarch/include/asm/shmparam.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020-2021 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_SHMPARAM_H
+#define _ASM_SHMPARAM_H
+
+#define __ARCH_FORCE_SHMLBA    1
+
+#define        SHMLBA  (4 * PAGE_SIZE)          /* attach addr a multiple of this */
+
+#endif /* _ASM_SHMPARAM_H */
I think this needs to be defined in a way that is independent of the configured
page size to minimize the differences between kernel configuration visible to
user space.

Maybe make it always 64KB?
quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/include/asm/sparsemem.h b/arch/loongarch/include/asm/sparsemem.h
new file mode 100644
index 000000000000..9b57dc69f523
--- /dev/null
+++ b/arch/loongarch/include/asm/sparsemem.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LOONGARCH_SPARSEMEM_H
+#define _LOONGARCH_SPARSEMEM_H
+
+#ifdef CONFIG_SPARSEMEM
+
+/*
+ * SECTION_SIZE_BITS           2^N: how big each section will be
+ * MAX_PHYSMEM_BITS            2^N: how much memory we can have in that space
+ */
+#define SECTION_SIZE_BITS      29
+#define MAX_PHYSMEM_BITS       48
Maybe add a comment to explain how you got to '29'?
quoted hunk ↗ jump to hunk
+
+#ifdef CONFIG_PAGE_SIZE_4KB
+#define PAGE_SHIFT      12
+#endif
+#ifdef CONFIG_PAGE_SIZE_16KB
+#define PAGE_SHIFT      14
+#endif
+#ifdef CONFIG_PAGE_SIZE_64KB
+#define PAGE_SHIFT      16
+#endif
Shouldn't these be defined in some header?

        Arnd
Thread (110 messages) 110 messages, 12 authors, last reply 2021-08-27
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help