Skip to contentSkip to conversation

C-SKY(csky) Linux Kernel Port

PATCH Superseded Guo Ren 8 participants 63 messages Mar 18, 2018 – Mar 28, 2018

Subsystems (9)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Guo Ren

author
#0 lore raw

cover C-SKY(csky) Linux Kernel Port

This patchset adds architecture support to Linux for C-SKY's 32-bit embedded CPU cores and the patches are based on linux-4.16-rc5.

There are two ABI versions with several CPU cores in this patchset:
ABIv1: ck610 (16-bit instruction, 32-bit data path, VIPT Cache ...)
ABIv2: ck807 ck810 (16/32-bit variable length instruction, PIPT Cache ...)

More information: http://en.c-sky.com

I'm from Hangzhou,China C-SKY Microsystems and responsible for C-SKY Linux port. My development repo is github.com/c-sky/csky-linux and use buildroot as our CI-test enviornment. "LTP, Lmbench, uclibc-ng-test ..." will be tested for every commit. See here for more details:
https://gitlab.com/c-sky/buildroot/pipelines

You can try C-SKY linux in a few steps:

  $ git clone https://github.com/c-sky/buildroot.git
  $ cd buildroot
  $ make qemu_csky_ck807_uclibc_bt_defconfig
  $ make
It will download "linux uclibc-ng gcc binutils qemu busybox" source code and build
them into one image. How to run, See:
  https://github.com/c-sky/buildroot/blob/master/board/qemu/csky/readme.txt

I've finished uClibc-ng.org upstream and "gcc glibc binutils qemu ..." upstream is on going and the source code is here:
https://github.com/c-sky

It's my first patchset to linux and any feedback is welcome :)

Guo Ren (19):
csky: Kernel booting
csky: Exception handling and syscall
csky: Cache and TLB routines
csky: MMU and page talbe management
csky: Process management
csky: IRQ handling
csky: Atomic operations
csky: ELF and module probe
csky: VDSO and rt_sigreturn
csky: Signal handling
csky: Library functions
csky: Debug and Ptrace GDB
csky: User access
csky: Misc headers
csky: Build infrastructure
csky: Device tree
csky: defconfig
clocksource: add timer-nationalchip.c
irqchip: add irq-nationalchip.c and irq-csky.c

 arch/csky/Kconfig                        | 203 ++++++++++++
 arch/csky/Kconfig.debug                  |  22 ++
 arch/csky/Makefile                       |  92 ++++++
 arch/csky/abiv1/Makefile                 |   8 +
 arch/csky/abiv1/inc/abi/cacheflush.h     |  40 +++
 arch/csky/abiv1/inc/abi/ckmmu.h          | 140 ++++++++
 arch/csky/abiv1/inc/abi/entry.h          | 171 ++++++++++
 arch/csky/abiv1/inc/abi/page.h           |  26 ++
 arch/csky/abiv1/inc/abi/pgtable-bits.h   |  36 ++
 arch/csky/abiv1/inc/abi/reg_ops.h        |  79 +++++
 arch/csky/abiv1/inc/abi/regdef.h         |  27 ++
 arch/csky/abiv1/inc/abi/vdso.h           |  19 ++
 arch/csky/abiv1/src/alignment.c          | 513 +++++++++++++++++++++++++++++
 arch/csky/abiv1/src/bswapdi.c            |  18 +
 arch/csky/abiv1/src/bswapsi.c            |  15 +
 arch/csky/abiv1/src/cacheflush.c         |  32 ++
 arch/csky/abiv1/src/memcpy.S             | 344 +++++++++++++++++++
 arch/csky/abiv1/src/mmap.c               |  65 ++++
 arch/csky/abiv2/Makefile                 |   3 +
 arch/csky/abiv2/inc/abi/cacheflush.h     |   9 +
 arch/csky/abiv2/inc/abi/ckmmu.h          | 126 +++++++
 arch/csky/abiv2/inc/abi/entry.h          | 154 +++++++++
 arch/csky/abiv2/inc/abi/fpu.h            | 296 +++++++++++++++++
 arch/csky/abiv2/inc/abi/page.h           |  20 ++
 arch/csky/abiv2/inc/abi/pgtable-bits.h   |  36 ++
 arch/csky/abiv2/inc/abi/reg_ops.h        |  86 +++++
 arch/csky/abiv2/inc/abi/regdef.h         |  28 ++
 arch/csky/abiv2/inc/abi/vdso.h           |  18 +
 arch/csky/abiv2/src/fpu.c                | 312 ++++++++++++++++++
 arch/csky/abiv2/src/memcpy.c             |  43 +++
 arch/csky/boot/Makefile                  |  25 ++
 arch/csky/boot/dts/Makefile              |  14 +
 arch/csky/boot/dts/gx6605s.dts           | 159 +++++++++
 arch/csky/boot/dts/include/dt-bindings   |   1 +
 arch/csky/boot/dts/qemu.dts              |  87 +++++
 arch/csky/configs/gx66xx_defconfig       | 549 +++++++++++++++++++++++++++++++
 arch/csky/configs/qemu_ck807_defconfig   | 541 ++++++++++++++++++++++++++++++
 arch/csky/include/asm/Kbuild             |  71 ++++
 arch/csky/include/asm/addrspace.h        |  10 +
 arch/csky/include/asm/barrier.h          |  14 +
 arch/csky/include/asm/bitops.h           |  83 +++++
 arch/csky/include/asm/cache.h            |  32 ++
 arch/csky/include/asm/cacheflush.h       |   9 +
 arch/csky/include/asm/checksum.h         |  77 +++++
 arch/csky/include/asm/dma-mapping.h      |  17 +
 arch/csky/include/asm/elf.h              | 151 +++++++++
 arch/csky/include/asm/fixmap.h           |  65 ++++
 arch/csky/include/asm/highmem.h          |  50 +++
 arch/csky/include/asm/io.h               |  23 ++
 arch/csky/include/asm/irq.h              |  12 +
 arch/csky/include/asm/irqflags.h         |  55 ++++
 arch/csky/include/asm/mmu.h              |  11 +
 arch/csky/include/asm/mmu_context.h      | 140 ++++++++
 arch/csky/include/asm/page.h             | 108 ++++++
 arch/csky/include/asm/pgalloc.h          | 113 +++++++
 arch/csky/include/asm/pgtable.h          | 309 +++++++++++++++++
 arch/csky/include/asm/processor.h        | 140 ++++++++
 arch/csky/include/asm/segment.h          |  18 +
 arch/csky/include/asm/shmparam.h         |  10 +
 arch/csky/include/asm/string.h           |  19 ++
 arch/csky/include/asm/syscalls.h         |  14 +
 arch/csky/include/asm/thread_info.h      |  77 +++++
 arch/csky/include/asm/tlb.h              |  24 ++
 arch/csky/include/asm/tlbflush.h         |  22 ++
 arch/csky/include/asm/traps.h            |  39 +++
 arch/csky/include/asm/uaccess.h          | 408 +++++++++++++++++++++++
 arch/csky/include/asm/unistd.h           |   4 +
 arch/csky/include/asm/user.h             | 102 ++++++
 arch/csky/include/asm/vdso.h             |  12 +
 arch/csky/include/uapi/asm/Kbuild        |  30 ++
 arch/csky/include/uapi/asm/byteorder.h   |  14 +
 arch/csky/include/uapi/asm/cachectl.h    |  13 +
 arch/csky/include/uapi/asm/fcntl.h       |  13 +
 arch/csky/include/uapi/asm/ptrace.h      |  97 ++++++
 arch/csky/include/uapi/asm/sigcontext.h  |  33 ++
 arch/csky/include/uapi/asm/signal.h      | 164 +++++++++
 arch/csky/include/uapi/asm/stat.h        |  86 +++++
 arch/csky/include/uapi/asm/unistd.h      | 100 ++++++
 arch/csky/kernel/Makefile                |   8 +
 arch/csky/kernel/asm-offsets.c           |  86 +++++
 arch/csky/kernel/atomic.S                |  55 ++++
 arch/csky/kernel/cpu-probe.c             |  63 ++++
 arch/csky/kernel/cskyksyms.c             |  31 ++
 arch/csky/kernel/dumpstack.c             |  65 ++++
 arch/csky/kernel/entry.S                 | 408 +++++++++++++++++++++++
 arch/csky/kernel/head.S                  |  20 ++
 arch/csky/kernel/irq.c                   |  41 +++
 arch/csky/kernel/module.c                | 130 ++++++++
 arch/csky/kernel/platform.c              |  18 +
 arch/csky/kernel/power.c                 |  31 ++
 arch/csky/kernel/process.c               | 147 +++++++++
 arch/csky/kernel/ptrace.c                | 339 +++++++++++++++++++
 arch/csky/kernel/setup.c                 | 157 +++++++++
 arch/csky/kernel/signal.c                | 379 +++++++++++++++++++++
 arch/csky/kernel/syscall.c               |  65 ++++
 arch/csky/kernel/syscall_table.c         |  12 +
 arch/csky/kernel/time.c                  |  15 +
 arch/csky/kernel/traps.c                 | 152 +++++++++
 arch/csky/kernel/vdso.c                  |  89 +++++
 arch/csky/kernel/vmlinux.lds.S           |  67 ++++
 arch/csky/lib/Makefile                   |   1 +
 arch/csky/lib/delay.c                    |  40 +++
 arch/csky/lib/memset.c                   |  38 +++
 arch/csky/lib/usercopy.c                 | 271 +++++++++++++++
 arch/csky/mm/Makefile                    |  13 +
 arch/csky/mm/cachev1.c                   | 146 ++++++++
 arch/csky/mm/cachev2.c                   |  90 +++++
 arch/csky/mm/dma-mapping.c               | 250 ++++++++++++++
 arch/csky/mm/fault.c                     | 246 ++++++++++++++
 arch/csky/mm/highmem.c                   | 210 ++++++++++++
 arch/csky/mm/init.c                      | 101 ++++++
 arch/csky/mm/ioremap.c                   |  49 +++
 arch/csky/mm/syscache.c                  |  50 +++
 arch/csky/mm/tlb.c                       | 207 ++++++++++++
 arch/csky/oprofile/Makefile              |  13 +
 arch/csky/oprofile/init.c                |  16 +
 drivers/clocksource/Makefile             |   1 +
 drivers/clocksource/timer-nationalchip.c | 149 +++++++++
 drivers/irqchip/Makefile                 |   1 +
 drivers/irqchip/irq-csky.c               | 151 +++++++++
 drivers/irqchip/irq-nationalchip.c       | 196 +++++++++++
 121 files changed, 11763 insertions(+)
 create mode 100644 arch/csky/Kconfig
 create mode 100644 arch/csky/Kconfig.debug
 create mode 100644 arch/csky/Makefile
 create mode 100644 arch/csky/abiv1/Makefile
 create mode 100644 arch/csky/abiv1/inc/abi/cacheflush.h
 create mode 100644 arch/csky/abiv1/inc/abi/ckmmu.h
 create mode 100644 arch/csky/abiv1/inc/abi/entry.h
 create mode 100644 arch/csky/abiv1/inc/abi/page.h
 create mode 100644 arch/csky/abiv1/inc/abi/pgtable-bits.h
 create mode 100644 arch/csky/abiv1/inc/abi/reg_ops.h
 create mode 100644 arch/csky/abiv1/inc/abi/regdef.h
 create mode 100644 arch/csky/abiv1/inc/abi/vdso.h
 create mode 100644 arch/csky/abiv1/src/alignment.c
 create mode 100644 arch/csky/abiv1/src/bswapdi.c
 create mode 100644 arch/csky/abiv1/src/bswapsi.c
 create mode 100644 arch/csky/abiv1/src/cacheflush.c
 create mode 100644 arch/csky/abiv1/src/memcpy.S
 create mode 100644 arch/csky/abiv1/src/mmap.c
 create mode 100644 arch/csky/abiv2/Makefile
 create mode 100644 arch/csky/abiv2/inc/abi/cacheflush.h
 create mode 100644 arch/csky/abiv2/inc/abi/ckmmu.h
 create mode 100644 arch/csky/abiv2/inc/abi/entry.h
 create mode 100644 arch/csky/abiv2/inc/abi/fpu.h
 create mode 100644 arch/csky/abiv2/inc/abi/page.h
 create mode 100644 arch/csky/abiv2/inc/abi/pgtable-bits.h
 create mode 100644 arch/csky/abiv2/inc/abi/reg_ops.h
 create mode 100644 arch/csky/abiv2/inc/abi/regdef.h
 create mode 100644 arch/csky/abiv2/inc/abi/vdso.h
 create mode 100644 arch/csky/abiv2/src/fpu.c
 create mode 100644 arch/csky/abiv2/src/memcpy.c
 create mode 100644 arch/csky/boot/Makefile
 create mode 100644 arch/csky/boot/dts/Makefile
 create mode 100644 arch/csky/boot/dts/gx6605s.dts
 create mode 120000 arch/csky/boot/dts/include/dt-bindings
 create mode 100644 arch/csky/boot/dts/qemu.dts
 create mode 100644 arch/csky/configs/gx66xx_defconfig
 create mode 100644 arch/csky/configs/qemu_ck807_defconfig
 create mode 100644 arch/csky/include/asm/Kbuild
 create mode 100644 arch/csky/include/asm/addrspace.h
 create mode 100644 arch/csky/include/asm/barrier.h
 create mode 100644 arch/csky/include/asm/bitops.h
 create mode 100644 arch/csky/include/asm/cache.h
 create mode 100644 arch/csky/include/asm/cacheflush.h
 create mode 100644 arch/csky/include/asm/checksum.h
 create mode 100644 arch/csky/include/asm/dma-mapping.h
 create mode 100644 arch/csky/include/asm/elf.h
 create mode 100644 arch/csky/include/asm/fixmap.h
 create mode 100644 arch/csky/include/asm/highmem.h
 create mode 100644 arch/csky/include/asm/io.h
 create mode 100644 arch/csky/include/asm/irq.h
 create mode 100644 arch/csky/include/asm/irqflags.h
 create mode 100644 arch/csky/include/asm/mmu.h
 create mode 100644 arch/csky/include/asm/mmu_context.h
 create mode 100644 arch/csky/include/asm/page.h
 create mode 100644 arch/csky/include/asm/pgalloc.h
 create mode 100644 arch/csky/include/asm/pgtable.h
 create mode 100644 arch/csky/include/asm/processor.h
 create mode 100644 arch/csky/include/asm/segment.h
 create mode 100644 arch/csky/include/asm/shmparam.h
 create mode 100644 arch/csky/include/asm/string.h
 create mode 100644 arch/csky/include/asm/syscalls.h
 create mode 100644 arch/csky/include/asm/thread_info.h
 create mode 100644 arch/csky/include/asm/tlb.h
 create mode 100644 arch/csky/include/asm/tlbflush.h
 create mode 100644 arch/csky/include/asm/traps.h
 create mode 100644 arch/csky/include/asm/uaccess.h
 create mode 100644 arch/csky/include/asm/unistd.h
 create mode 100644 arch/csky/include/asm/user.h
 create mode 100644 arch/csky/include/asm/vdso.h
 create mode 100644 arch/csky/include/uapi/asm/Kbuild
 create mode 100644 arch/csky/include/uapi/asm/byteorder.h
 create mode 100644 arch/csky/include/uapi/asm/cachectl.h
 create mode 100644 arch/csky/include/uapi/asm/fcntl.h
 create mode 100644 arch/csky/include/uapi/asm/ptrace.h
 create mode 100644 arch/csky/include/uapi/asm/sigcontext.h
 create mode 100644 arch/csky/include/uapi/asm/signal.h
 create mode 100644 arch/csky/include/uapi/asm/stat.h
 create mode 100644 arch/csky/include/uapi/asm/unistd.h
 create mode 100644 arch/csky/kernel/Makefile
 create mode 100644 arch/csky/kernel/asm-offsets.c
 create mode 100644 arch/csky/kernel/atomic.S
 create mode 100644 arch/csky/kernel/cpu-probe.c
 create mode 100644 arch/csky/kernel/cskyksyms.c
 create mode 100644 arch/csky/kernel/dumpstack.c
 create mode 100644 arch/csky/kernel/entry.S
 create mode 100644 arch/csky/kernel/head.S
 create mode 100644 arch/csky/kernel/irq.c
 create mode 100644 arch/csky/kernel/module.c
 create mode 100644 arch/csky/kernel/platform.c
 create mode 100644 arch/csky/kernel/power.c
 create mode 100644 arch/csky/kernel/process.c
 create mode 100644 arch/csky/kernel/ptrace.c
 create mode 100644 arch/csky/kernel/setup.c
 create mode 100644 arch/csky/kernel/signal.c
 create mode 100644 arch/csky/kernel/syscall.c
 create mode 100644 arch/csky/kernel/syscall_table.c
 create mode 100644 arch/csky/kernel/time.c
 create mode 100644 arch/csky/kernel/traps.c
 create mode 100644 arch/csky/kernel/vdso.c
 create mode 100644 arch/csky/kernel/vmlinux.lds.S
 create mode 100644 arch/csky/lib/Makefile
 create mode 100644 arch/csky/lib/delay.c
 create mode 100644 arch/csky/lib/memset.c
 create mode 100644 arch/csky/lib/usercopy.c
 create mode 100644 arch/csky/mm/Makefile
 create mode 100644 arch/csky/mm/cachev1.c
 create mode 100644 arch/csky/mm/cachev2.c
 create mode 100644 arch/csky/mm/dma-mapping.c
 create mode 100644 arch/csky/mm/fault.c
 create mode 100644 arch/csky/mm/highmem.c
 create mode 100644 arch/csky/mm/init.c
 create mode 100644 arch/csky/mm/ioremap.c
 create mode 100644 arch/csky/mm/syscache.c
 create mode 100644 arch/csky/mm/tlb.c
 create mode 100644 arch/csky/oprofile/Makefile
 create mode 100644 arch/csky/oprofile/init.c
 create mode 100644 drivers/clocksource/timer-nationalchip.c
 create mode 100644 drivers/irqchip/irq-csky.c
 create mode 100644 drivers/irqchip/irq-nationalchip.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/19 csky: Kernel booting

---
 arch/csky/kernel/head.S  |  20 ++++++
 arch/csky/kernel/setup.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+)
 create mode 100644 arch/csky/kernel/head.S
 create mode 100644 arch/csky/kernel/setup.c
arch/csky/kernel/head.S new file +20 -0
new file mode 100644
index 0000000..a746caf
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/linkage.h>
+#include <linux/init.h>
+#include <asm/page.h>
+#include <abi/regdef.h>
+
+ENTRY(_start)
+	/* set super user mode */
+	lrw	a3, DEFAULT_PSR_VALUE
+	mtcr    a3, psr
+	psrset  ee
+
+	/* set stack point */
+	lrw     a3, init_thread_union + THREAD_SIZE
+	mov	sp, a3
+
+	jmpi	csky_start
+END(_start)
+
arch/csky/kernel/setup.c new file +157 -0

157 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/19 csky: Exception handling and syscall

In reply to Guo Ren
---
 arch/csky/abiv1/inc/abi/entry.h     | 171 ++++++++++++
 arch/csky/abiv1/src/alignment.c     | 513 ++++++++++++++++++++++++++++++++++++
 arch/csky/abiv2/inc/abi/entry.h     | 154 +++++++++++
 arch/csky/include/asm/syscalls.h    |  14 +
 arch/csky/include/asm/traps.h       |  39 +++
 arch/csky/include/asm/unistd.h      |   4 +
 arch/csky/include/uapi/asm/unistd.h | 100 +++++++
 arch/csky/kernel/cpu-probe.c        |  63 +++++
 arch/csky/kernel/entry.S            | 408 ++++++++++++++++++++++++++++
 arch/csky/kernel/syscall.c          |  65 +++++
 arch/csky/kernel/syscall_table.c    |  12 +
 arch/csky/kernel/traps.c            | 152 +++++++++++
 arch/csky/mm/fault.c                | 246 +++++++++++++++++
 13 files changed, 1941 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/entry.h
 create mode 100644 arch/csky/abiv1/src/alignment.c
 create mode 100644 arch/csky/abiv2/inc/abi/entry.h
 create mode 100644 arch/csky/include/asm/syscalls.h
 create mode 100644 arch/csky/include/asm/traps.h
 create mode 100644 arch/csky/include/asm/unistd.h
 create mode 100644 arch/csky/include/uapi/asm/unistd.h
 create mode 100644 arch/csky/kernel/cpu-probe.c
 create mode 100644 arch/csky/kernel/entry.S
 create mode 100644 arch/csky/kernel/syscall.c
 create mode 100644 arch/csky/kernel/syscall_table.c
 create mode 100644 arch/csky/kernel/traps.c
 create mode 100644 arch/csky/mm/fault.c
arch/csky/abiv1/inc/abi/entry.h new file +171 -0
new file mode 100644
index 0000000..bff3ff2
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_ENTRY_H
+#define __ASM_CSKY_ENTRY_H
+
+#include <asm/setup.h>
+#include <abi/regdef.h>
+
+/*
+ * Stack layout for exception (sp=r0):
+ *
+ *	 0(sp) - pc
+ *	 4(sp) - orig_a0
+ *	 8(sp) - sr
+ *	 C(sp) - a0/r2
+ *	10(sp) - a1/r3
+ *	14(sp) - a2/r4
+ *	18(sp) - a3/r5
+ *	1C(sp) - r6
+ *	20(sp) - r7
+ *	24(sp) - r8
+ *	28(sp) - r9
+ *	2C(sp) - r10
+ *	30(sp) - r11
+ *	34(sp) - r12
+ *	38(sp) - r13
+ *	3C(sp) - r14
+ *	40(sp) - r1
+ *	44(sp) - r15
+ */
+
+#define LSAVE_A0	0xc
+#define LSAVE_A1	0x10
+#define LSAVE_A2	0x14
+#define LSAVE_A3	0x18
+#define LSAVE_A4	0x1C
+#define LSAVE_A5	0x20
+
+.macro USPTOKSP
+	mtcr	sp, ss1
+	mfcr	sp, ss0
+.endm
+
+.macro KSPTOUSP
+	mtcr	sp, ss0
+	mfcr	sp, ss1
+.endm
+
+.macro GET_USP rx
+	mfcr	\rx, ss1
+.endm
+
+.macro SET_USP rx
+	mtcr	\rx, ss1
+.endm
+
+.macro INCTRAP	rx
+	addi	\rx, 2
+.endm
+
+/*
+ * SAVE_ALL: save the pt_regs to the stack.
+ */
+.macro	SAVE_ALL
+	mtcr    r13, ss2
+	mfcr    r13, epsr
+	btsti   r13, 31
+	bt      1f
+	USPTOKSP
+1:
+	subi    sp, 32
+	subi    sp, 32
+	stw     r13,	(sp, 0)
+	mfcr    r13,	ss2
+	stw     a0,	(sp, 4)
+	stw     a1,	(sp, 8)
+	stw     a2,	(sp, 12)
+	stw     a3,	(sp, 16)
+	stw     r6,	(sp, 20)
+	stw     r7,	(sp, 24)
+	stw     r8,	(sp, 28)
+	stw     r9,	(sp, 32)
+	stw     r10,	(sp, 36)
+	stw     r11,	(sp, 40)
+	stw     r12,	(sp, 44)
+	stw     r13,	(sp, 48)
+	stw     r14,	(sp, 52)
+	stw     r1,	(sp, 56)
+	stw     r15,	(sp, 60)
+
+	subi    sp,	8
+	stw     a0,	(sp, 4)
+	mfcr    r13,	epc
+	stw     r13,	(sp)
+.endm
+
+.macro SAVE_ALL_TRAP
+	SAVE_ALL
+	INCTRAP r13
+	stw     r13,	(sp)
+.endm
+
+.macro	RESTORE_ALL
+	psrclr  ie
+	ldw     a0, (sp)
+	mtcr    a0, epc
+	ldw     a0, (sp, 8)
+	mtcr    a0, epsr
+	btsti   a0, 31
+
+	addi    sp, 12
+	ldw     a0, (sp, 0)
+	ldw     a1, (sp, 4)
+	ldw     a2, (sp, 8)
+	ldw     a3, (sp, 12)
+	ldw     r6, (sp, 16)
+	ldw     r7, (sp, 20)
+	ldw     r8, (sp, 24)
+	ldw     r9, (sp, 28)
+	ldw     r10, (sp, 32)
+	ldw     r11, (sp, 36)
+	ldw     r12, (sp, 40)
+	ldw     r13, (sp, 44)
+	ldw     r14, (sp, 48)
+	ldw     r1, (sp, 52)
+	ldw     r15, (sp, 56)
+	addi    sp, 32
+	addi    sp, 28
+
+	bt      1f
+	KSPTOUSP
+1:
+	rte
+.endm
+
+.macro SAVE_SWITCH_STACK
+	subi    sp, 32
+	stm     r8-r15,(sp)
+.endm
+
+.macro RESTORE_SWITCH_STACK
+        ldm     r8-r15,(sp)
+        addi    sp, 32
+.endm
+
+/* MMU registers operators. */
+.macro RD_MIR	rx
+	cprcr   \rx, cpcr0
+.endm
+
+.macro RD_MEH	rx
+	cprcr   \rx, cpcr4
+.endm
+
+.macro RD_MCIR	rx
+	cprcr   \rx, cpcr8
+.endm
+
+.macro RD_PGDR  rx
+        cprcr   \rx, cpcr29
+.endm
+
+.macro WR_MEH	rx
+	cpwcr   \rx, cpcr4
+.endm
+
+.macro WR_MCIR	rx
+	cpwcr   \rx, cpcr8
+.endm
+
+#endif /* __ASM_CSKY_ENTRY_H */
arch/csky/abiv1/src/alignment.c new file +513 -0

513 lines not on this page · raw message

arch/csky/abiv2/inc/abi/entry.h new file +154 -0

154 lines not on this page · raw message

arch/csky/include/asm/syscalls.h new file +14 -0
new file mode 100644
index 0000000..c478830
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_SYSCALLS_H
+#define __ASM_CSKY_SYSCALLS_H
+
+#include <asm-generic/syscalls.h>
+
+long sys_cacheflush(void __user *, unsigned long, int);
+
+long sys_set_thread_area(unsigned long addr);
+
+long sys_csky_fadvise64_64(int fd, int advice, loff_t offset, loff_t len);
+
+#endif /* __ASM_CSKY_SYSCALLS_H */
arch/csky/include/asm/traps.h new file +39 -0
new file mode 100644
index 0000000..ca82b19
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_TRAPS_H
+#define __ASM_CSKY_TRAPS_H
+
+#define VEC_RESET	0
+#define VEC_ALIGN	1
+#define VEC_ACCESS	2
+#define VEC_ZERODIV	3
+#define VEC_ILLEGAL	4
+#define VEC_PRIV	5
+#define VEC_TRACE	6
+#define VEC_BREAKPOINT	7
+#define VEC_UNRECOVER	8
+#define VEC_SOFTRESET	9
+#define VEC_AUTOVEC	10
+#define VEC_FAUTOVEC	11
+#define VEC_HWACCEL	12
+
+#define	VEC_TLBMISS	14
+#define	VEC_TLBMODIFIED	15
+
+#define VEC_TRAP0	16
+#define VEC_TRAP1	17
+#define VEC_TRAP2	18
+#define VEC_TRAP3	19
+
+#define	VEC_TLBINVALIDL	20
+#define	VEC_TLBINVALIDS	21
+
+#define VEC_PRFL	29
+#define VEC_FPE		30
+
+extern void * vec_base[];
+#define VEC_INIT(i, func) vec_base[i] = (void *)func
+
+void csky_alignment(struct pt_regs*);
+
+#endif /* __ASM_CSKY_TRAPS_H */
arch/csky/include/asm/unistd.h new file +4 -0
new file mode 100644
index 0000000..704526c
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <uapi/asm/unistd.h>
+
arch/csky/include/uapi/asm/unistd.h new file +100 -0

100 lines not on this page · raw message

arch/csky/kernel/cpu-probe.c new file +63 -0

63 lines not on this page · raw message

arch/csky/kernel/entry.S new file +408 -0

408 lines not on this page · raw message

arch/csky/kernel/syscall.c new file +65 -0

65 lines not on this page · raw message

arch/csky/kernel/syscall_table.c new file +12 -0
new file mode 100644
index 0000000..bea8558
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/syscalls.h>
+#include <asm/syscalls.h>
+
+#undef __SYSCALL
+#define __SYSCALL(nr, call) [nr] = (call),
+
+void * const sys_call_table[__NR_syscalls] __page_aligned_data = {
+	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
+#include <asm/unistd.h>
+};
arch/csky/kernel/traps.c new file +152 -0

152 lines not on this page · raw message

arch/csky/mm/fault.c new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH 02/19] csky: Exception handling and syscall

Hi,

arch/csky/abiv1/src/alignment.c line 208

Quoted 8 lines · Guo Ren
arch/csky/abiv1/src/alignment.c new file +8 -0
+inline static unsigned int
+get_regs_value(unsigned int rx, struct pt_regs *regs)
+{
+	unsigned int value;
+
+	if(rx == 0){
+		if(user_mode(regs)){
+			asm volatile("mfcr %0, ss1\n":"=r"(value));

Here you open code an MFCR instruction.

I guess MFCR stands for something like move-from-control-register, and MTCR stands for move-to-control-register?

I see that later on you have helpers for specific registers, e.g. mfcr_cpuidrr().

You might want to follow the example of arm64's read_sysreg() and write_sysreg(), and have general purpose helpers for thos instructions, e.g.

#define mfcr(reg) \

({								\
	unsigned long __mfcr_val;				\
	asm volatile("mfcr %0, " #reg "\n" : "=r" (__mfr_val));	\
	__mfcr_val;						\
})

... which avoids needing helpers for each register, as you can do:

ss1_val = mfcr(ss1);
cpuidrr_val = mfcr(cpuidrr);

[...]

arch/csky/kernel/cpu-probe.c line 16

Quoted 8 lines
arch/csky/kernel/cpu-probe.c new file +8 -0
+static __init void setup_cpu_msa(void)
+{
+	if (memblock_start_of_DRAM() != (PHYS_OFFSET + CONFIG_RAM_BASE)) {
+		pr_err("C-SKY: dts-DRAM doesn't fit .config: %x-%x.\n",
+			memblock_start_of_DRAM(),
+			PHYS_OFFSET + CONFIG_RAM_BASE);
+		return;
+	}

If this is a problem, is it safe to continue at all?

Why does the base address of RAM matter?

arch/csky/kernel/cpu-probe.c line 19

Quoted 3 lines
arch/csky/kernel/cpu-probe.c new file +3 -0
+
+	mtcr_msa0(PHYS_OFFSET | 0xe);
+	mtcr_msa1(PHYS_OFFSET | 0x6);

As with MFCR, you could use a generic helper here, e.g.

#define mtcr(val, reg) \

do {										\
	asm volatile("mtcr %0, " #reg "\n" : "=r" ((unsigned long)val));	\
} while (0);

mtcr(PHYS_OFFSET | 0xe, msa0)
mtcr(PHYS_OFFSET | 0x6, msa1)

Quoted 6 lines
arch/csky/kernel/cpu-probe.c new file +6 -0
+}
+
+__init void cpu_dt_probe(void)
+{
+	setup_cpu_msa();
+}

arch/csky/kernel/cpu-probe.c line 35

Quoted 10 lines
arch/csky/kernel/cpu-probe.c new file +10 -0
+
+static int c_show(struct seq_file *m, void *v)
+{
+	seq_printf(m, "C-SKY CPU : %s\n", CSKYCPU_DEF_NAME);
+	seq_printf(m, "revision  : 0x%08x\n", mfcr_cpuidrr());
+	seq_printf(m, "ccr reg   : 0x%08x\n", mfcr_ccr());
+	seq_printf(m, "ccr2 reg  : 0x%08x\n", mfcr_ccr2());
+	seq_printf(m, "hint reg  : 0x%08x\n", mfcr_hint());
+	seq_printf(m, "msa0 reg  : 0x%08x\n", mfcr_msa0());
+	seq_printf(m, "msa1 reg  : 0x%08x\n", mfcr_msa1());

Do these need to be exposed to userspace?

Does this arch support SMP? I see you don't log information per-cpu.

[...]

arch/csky/kernel/entry.S

Quoted 3 lines
arch/csky/kernel/entry.S +1 -0
 
+#define THREADSIZE_MASK_BIT 13

You might want to define this as THREAD_SHIFT, and define THREAD_SIZE in terms of it, so that they're guaranteed to be in sync

e.g. in your <asm/thread_info.h> have:

#define THREAD_SHIFT 13
#define THREAD_SIZE (1 << THREAD_SHIFT)

[...]

Quoted 18 lines
arch/csky/kernel/entry.S +18 -0
+ENTRY(csky_systemcall)
+	SAVE_ALL_TRAP
+
+	psrset  ee, ie
+
+	/* Stack frame for syscall, origin call set_esp0 */
+	mov     r12, sp
+
+	bmaski  r11, 13
+	andn    r12, r11
+	bgeni   r11, 9
+	addi    r11, 32
+	addu    r12, r11
+	st      sp, (r12, 0)
+
+	lrw     r11, __NR_syscalls
+	cmphs   syscallid, r11                 /* Check nr of syscall */
+	bt      ret_from_exception

arch/csky/kernel/entry.S line 143

Quoted 10 lines
arch/csky/kernel/entry.S +10 -0
+
+	lrw     r13, sys_call_table
+	ixw     r13, syscallid                 /* Index into syscall table */
+	ldw     r11, (r13)               /* Get syscall function */
+	cmpnei  r11, 0                  /* Check for not null */
+	bf      ret_from_exception
+
+	mov     r9, sp				 /* Get task pointer */
+	bmaski  r10, THREADSIZE_MASK_BIT
+	andn    r9, r10                      /* Get thread_info */

If you have a spare register that you can point at the current task (or you have preemption-safe percpu ops), I'd recommend moving the thread_info off of the stack, and implementing THREAD_INFO_IN_TASK_STRUCT.

[...]

arch/csky/kernel/entry.S line 285

Quoted 10 lines
arch/csky/kernel/entry.S +10 -0
+ENTRY(csky_get_tls)
+	USPTOKSP
+
+	/* increase epc for continue */
+	mfcr	a0, epc
+	INCTRAP	a0
+	mtcr	a0, epc
+
+	/* get current task thread_info with kernel 8K stack */
+	bmaski   a0, (PAGE_SHIFT + 1)

For consistency, and in case you change your stack size in future, this should be THREADSIZE_MASK_BIT.

[...]

Quoted 18 lines
arch/csky/kernel/entry.S +18 -0
+/*
+ * This routine handles page faults.  It determines the address,
+ * and the problem, and then passes it off to one of the appropriate
+ * routines.
+ */
+asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
+                              unsigned long mmu_meh)
+{
+        struct vm_area_struct * vma = NULL;
+        struct task_struct *tsk = current;
+        struct mm_struct *mm = tsk->mm;
+        siginfo_t info;
+	int fault;
+	unsigned long address = mmu_meh & PAGE_MASK;
+
+        info.si_code = SEGV_MAPERR;
+
+        /*

arch/csky/kernel/entry.S

Quoted 10 lines
arch/csky/kernel/entry.S +10 -0
+         * We fault-in kernel-space virtual memory on-demand. The
+         * 'reference' page table is init_mm.pgd.
+         *
+         * NOTE! We MUST NOT take any locks for this case. We may
+         * be in an interrupt or a critical region, and should
+         * only copy the information from the master page table,
+         * nothing more.
+         */
+        if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
+                goto vmalloc_fault;

You might want to check if this was a user mode fault here, so that users can't trigger vmalloc faults.

Thanks,
Mark.

Quoted 45 lines
arch/csky/kernel/entry.S +42 -0
+vmalloc_fault:
+        {
+                /*
+                 * Synchronize this task's top level page-table
+                 * with the 'reference' page table.
+                 *
+                 * Do _not_ use "tsk" here. We might be inside
+                 * an interrupt in the middle of a task switch..
+                 */
+                int offset = __pgd_offset(address);
+                pgd_t *pgd, *pgd_k;
+                pud_t *pud, *pud_k;
+                pmd_t *pmd, *pmd_k;
+                pte_t *pte_k;
+
+                unsigned long pgd_base;
+		pgd_base = tlb_get_pgd();
+                pgd = (pgd_t *)pgd_base + offset;
+                pgd_k = init_mm.pgd + offset;
+
+                if (!pgd_present(*pgd_k))
+                        goto no_context;
+                set_pgd(pgd, *pgd_k);
+
+                pud = (pud_t *)pgd;
+                pud_k = (pud_t *)pgd_k;
+                if (!pud_present(*pud_k))
+                        goto no_context;
+
+                pmd = pmd_offset(pud, address);
+                pmd_k = pmd_offset(pud_k, address);
+                if (!pmd_present(*pmd_k))
+                        goto no_context;
+                set_pmd(pmd, *pmd_k);
+
+                pte_k = pte_offset_kernel(pmd_k, address);
+                if (!pte_present(*pte_k))
+                        goto no_context;
+                return;
+        }
+}
+
Signature · 1 line
2.7.4
author
#4 lore raw

Re: [PATCH 02/19] csky: Exception handling and syscall

Hi Mark,

Quoted 17 lines

Here you open code an MFCR instruction.

I guess MFCR stands for something like move-from-control-register, and MTCR stands for move-to-control-register?

I see that later on you have helpers for specific registers, e.g. mfcr_cpuidrr().

You might want to follow the example of arm64's read_sysreg() and write_sysreg(), and have general purpose helpers for thos instructions, e.g.

#define mfcr(reg) \

({								\
	unsigned long __mfcr_val;				\
	asm volatile("mfcr %0, " #reg "\n" : "=r" (__mfr_val));	\
	__mfcr_val;						\
})
Quoted 5 lines

... which avoids needing helpers for each register, as you can do:

ss1_val = mfcr(ss1);
cpuidrr_val = mfcr(cpuidrr);

OK, good idea.

Quoted 11 lines

arch/csky/kernel/cpu-probe.c line 16

Quoted 6 lines
arch/csky/kernel/cpu-probe.c new file +6 -0
+	if (memblock_start_of_DRAM() != (PHYS_OFFSET + CONFIG_RAM_BASE)) {
+		pr_err("C-SKY: dts-DRAM doesn't fit .config: %x-%x.\n",
+			memblock_start_of_DRAM(),
+			PHYS_OFFSET + CONFIG_RAM_BASE);
+		return;
+	}

If this is a problem, is it safe to continue at all?

Why does the base address of RAM matter?

We use mips-like direct-mapping tech, and it need 512MB boundary alignment. And few users need non-512MB boundary phy-addr start, so we give the CONFIG_RAM_BASE for determine the offset to PHYS_OFFSET.

Quoted 6 lines

arch/csky/kernel/cpu-probe.c line 19

Quoted 3 lines
arch/csky/kernel/cpu-probe.c new file +3 -0
+
+	mtcr_msa0(PHYS_OFFSET | 0xe);
+	mtcr_msa1(PHYS_OFFSET | 0x6);

As with MFCR, you could use a generic helper here, e.g.

Quoted 8 lines

#define mtcr(val, reg) \

do {										\
	asm volatile("mtcr %0, " #reg "\n" : "=r" ((unsigned long)val));	\
} while (0);

mtcr(PHYS_OFFSET | 0xe, msa0)
mtcr(PHYS_OFFSET | 0x6, msa1)

OK

Quoted 10 lines

arch/csky/kernel/cpu-probe.c line 35

Quoted 7 lines
arch/csky/kernel/cpu-probe.c new file +7 -0
+	seq_printf(m, "C-SKY CPU : %s\n", CSKYCPU_DEF_NAME);
+	seq_printf(m, "revision  : 0x%08x\n", mfcr_cpuidrr());
+	seq_printf(m, "ccr reg   : 0x%08x\n", mfcr_ccr());
+	seq_printf(m, "ccr2 reg  : 0x%08x\n", mfcr_ccr2());
+	seq_printf(m, "hint reg  : 0x%08x\n", mfcr_hint());
+	seq_printf(m, "msa0 reg  : 0x%08x\n", mfcr_msa0());
+	seq_printf(m, "msa1 reg  : 0x%08x\n", mfcr_msa1());

Do these need to be exposed to userspace?

Yes, I'll add more explain info.

Quoted 1 line

Does this arch support SMP? I see you don't log information per-cpu.

This patch-set doesn't support SMP.

Quoted 5 lines

arch/csky/kernel/entry.S

Quoted 4 lines
arch/csky/kernel/entry.S +1 -0
 
+#define THREADSIZE_MASK_BIT 13
Quoted 7 lines

You might want to define this as THREAD_SHIFT, and define THREAD_SIZE in terms of it, so that they're guaranteed to be in sync

e.g. in your <asm/thread_info.h> have:

#define THREAD_SHIFT 13
#define THREAD_SIZE (1 << THREAD_SHIFT)

OK

Quoted 4 lines

If you have a spare register that you can point at the current task (or you have preemption-safe percpu ops), I'd recommend moving the thread_info off of the stack, and implementing THREAD_INFO_IN_TASK_STRUCT.

Em... I'll think about it.

Quoted 3 lines

For consistency, and in case you change your stack size in future, this should be THREADSIZE_MASK_BIT.

OK

Quoted 4 lines

arch/csky/kernel/entry.S

Quoted 2 lines
arch/csky/kernel/entry.S +2 -0
+        if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
+                goto vmalloc_fault;

You might want to check if this was a user mode fault here, so that users can't trigger vmalloc faults.

Is it necessary to check user mode? If a user-process touch a kernel-addr, it will cause a supervisor exception.

Best Regards
Guo Ren

#5 lore raw

Re: [PATCH 02/19] csky: Exception handling and syscall

In reply to Guo Ren

arch/csky/include/uapi/asm/unistd.h line 34

Quoted 4 lines
arch/csky/include/uapi/asm/unistd.h new file +4 -0
+#define __ARCH_WANT_SYSCALL_DEPRECATED
+#define __ARCH_WANT_SYSCALL_OFF_T
+#define __ARCH_WANT_SYSCALL_NO_AT
+#define __ARCH_WANT_SYSCALL_NO_FLAGS

Does this arch *really* want these deprecated and obsolete syscalls? See the commend in include/uapi/asm-generic/unistd.h

* All syscalls below here should go away really,
* these are provided for both review and as a porting
* help for the C library version.

Thanks,
Dominik

author
#6 lore raw

Re: [PATCH 02/19] csky: Exception handling and syscall

Hi Dominik,

Quoted 8 lines · Dominik Brodowski

arch/csky/include/uapi/asm/unistd.h line 34

Quoted 4 lines
arch/csky/include/uapi/asm/unistd.h new file +4 -0
+#define __ARCH_WANT_SYSCALL_DEPRECATED
+#define __ARCH_WANT_SYSCALL_OFF_T
+#define __ARCH_WANT_SYSCALL_NO_AT
+#define __ARCH_WANT_SYSCALL_NO_FLAGS

Does this arch *really* want these deprecated and obsolete syscalls? See the commend in include/uapi/asm-generic/unistd.h

Quoted 4 lines

* All syscalls below here should go away really,
* these are provided for both review and as a porting
* help for the C library version.

OK, I will cleanup them next and check the unistd.h again.

Best Regards
Guo Ren

author
#7 lore raw

PATCH 3/19 csky: Cache and TLB routines

In reply to Guo Ren
---
 arch/csky/abiv1/inc/abi/cacheflush.h  |  40 +++++++
 arch/csky/abiv1/src/cacheflush.c      |  32 ++++++
 arch/csky/abiv2/inc/abi/cacheflush.h  |   9 ++
 arch/csky/include/asm/barrier.h       |  14 +++
 arch/csky/include/asm/cache.h         |  32 ++++++
 arch/csky/include/asm/cacheflush.h    |   9 ++
 arch/csky/include/asm/dma-mapping.h   |  17 +++
 arch/csky/include/asm/io.h            |  23 ++++
 arch/csky/include/asm/segment.h       |  18 +++
 arch/csky/include/asm/tlb.h           |  24 ++++
 arch/csky/include/asm/tlbflush.h      |  22 ++++
 arch/csky/include/uapi/asm/cachectl.h |  13 +++
 arch/csky/mm/cachev1.c                | 146 ++++++++++++++++++++++++
 arch/csky/mm/cachev2.c                |  90 +++++++++++++++
 arch/csky/mm/syscache.c               |  50 ++++++++
 arch/csky/mm/tlb.c                    | 207 ++++++++++++++++++++++++++++++++++
 16 files changed, 746 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/cacheflush.h
 create mode 100644 arch/csky/abiv1/src/cacheflush.c
 create mode 100644 arch/csky/abiv2/inc/abi/cacheflush.h
 create mode 100644 arch/csky/include/asm/barrier.h
 create mode 100644 arch/csky/include/asm/cache.h
 create mode 100644 arch/csky/include/asm/cacheflush.h
 create mode 100644 arch/csky/include/asm/dma-mapping.h
 create mode 100644 arch/csky/include/asm/io.h
 create mode 100644 arch/csky/include/asm/segment.h
 create mode 100644 arch/csky/include/asm/tlb.h
 create mode 100644 arch/csky/include/asm/tlbflush.h
 create mode 100644 arch/csky/include/uapi/asm/cachectl.h
 create mode 100644 arch/csky/mm/cachev1.c
 create mode 100644 arch/csky/mm/cachev2.c
 create mode 100644 arch/csky/mm/syscache.c
 create mode 100644 arch/csky/mm/tlb.c
arch/csky/abiv1/inc/abi/cacheflush.h new file +40 -0
new file mode 100644
index 0000000..94c31b4
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ABI_CSKY_CACHEFLUSH_H
+#define __ABI_CSKY_CACHEFLUSH_H
+
+#include <linux/compiler.h>
+#include <asm/string.h>
+#include <asm/cache.h>
+
+#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
+extern void flush_dcache_page(struct page *);
+
+#define flush_cache_mm(mm)		cache_wbinv_all()
+#define flush_cache_page(vma,page,pfn)	cache_wbinv_all()
+#define flush_cache_dup_mm(mm)		cache_wbinv_all()
+#define flush_icache_page(vma, page)	icache_inv_all()
+
+#define flush_cache_range(mm,start,end)	cache_wbinv_range(start, end)
+#define flush_cache_vmap(start, end)	cache_wbinv_range(start, end)
+#define flush_cache_vunmap(start, end)  cache_wbinv_range(start, end)
+#define flush_icache_range(start, end)	icache_inv_range(start, end)
+
+#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
+do{ \
+	cache_wbinv_all(); \
+	memcpy(dst, src, len); \
+	icache_inv_all(); \
+}while(0)
+
+#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
+do{ \
+	cache_wbinv_all(); \
+	memcpy(dst, src, len); \
+}while(0)
+
+#define flush_dcache_mmap_lock(mapping)		do{}while(0)
+#define flush_dcache_mmap_unlock(mapping)	do{}while(0)
+
+#endif /* __ABI_CSKY_CACHEFLUSH_H */
+
arch/csky/abiv1/src/cacheflush.c new file +32 -0
new file mode 100644
index 0000000..caa095a
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
+#include <linux/syscalls.h>
+#include <linux/spinlock.h>
+#include <asm/page.h>
+#include <asm/cache.h>
+#include <asm/cacheflush.h>
+#include <asm/cachectl.h>
+#include <abi/reg_ops.h>
+
+void flush_dcache_page(struct page *page)
+{
+	struct address_space *mapping = page_mapping(page);
+	unsigned long addr;
+
+	if (mapping && !mapping_mapped(mapping)) {
+		set_bit(PG_arch_1, &(page)->flags);
+		return;
+	}
+
+	/*
+	 * We could delay the flush for the !page_mapping case too.  But that
+	 * case is for exec env/arg pages and those are %99 certainly going to
+	 * get faulted into the tlb (and thus flushed) anyways.
+	 */
+	addr = (unsigned long) page_address(page);
+	dcache_wbinv_range(addr, addr + PAGE_SIZE);
+}
+
arch/csky/abiv2/inc/abi/cacheflush.h new file +9 -0
new file mode 100644
index 0000000..f5a1b18
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ABI_CSKY_CACHEFLUSH_H
+#define __ABI_CSKY_CACHEFLUSH_H
+
+#include <asm-generic/cacheflush.h>
+
+#endif /* __ABI_CSKY_CACHEFLUSH_H */
+
arch/csky/include/asm/barrier.h new file +14 -0
new file mode 100644
index 0000000..beea9a0
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_BARRIER_H
+#define __ASM_CSKY_BARRIER_H
+
+#ifndef __ASSEMBLY__
+
+#define nop()	asm volatile ("nop")
+#define mb()	asm volatile ("sync":::"memory")
+
+#include <asm-generic/barrier.h>
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ASM_CSKY_BARRIER_H */
arch/csky/include/asm/cache.h new file +32 -0
new file mode 100644
index 0000000..9742347
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_CACHE_H
+#define __ASM_CSKY_CACHE_H
+
+/* bytes per L1 cache line */
+#define L1_CACHE_SHIFT	CONFIG_L1_CACHE_SHIFT
+
+#define L1_CACHE_BYTES	(1 << L1_CACHE_SHIFT)
+
+#define ARCH_DMA_MINALIGN	L1_CACHE_BYTES
+
+#ifndef __ASSEMBLY__
+
+void dcache_wb_line(unsigned long start);
+
+void icache_inv_range(unsigned long start, unsigned long end);
+void icache_inv_all(void);
+
+void dcache_wb_range(unsigned long start, unsigned long end);
+void dcache_wbinv_range(unsigned long start, unsigned long end);
+void dcache_inv_range(unsigned long start, unsigned long end);
+void dcache_wbinv_all(void);
+
+void cache_wbinv_range(unsigned long start, unsigned long end);
+void cache_wbinv_all(void);
+
+void dma_wbinv_range(unsigned long start, unsigned long end);
+void dma_wb_range(unsigned long start, unsigned long end);
+
+#endif
+#endif  /* __ASM_CSKY_CACHE_H */
arch/csky/include/asm/cacheflush.h new file +9 -0
new file mode 100644
index 0000000..6a4233b
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_CACHEFLUSH_H
+#define __ASM_CSKY_CACHEFLUSH_H
+
+#include <abi/cacheflush.h>
+
+#endif /* __ASM_CSKY_CACHEFLUSH_H */
+
arch/csky/include/asm/dma-mapping.h new file +17 -0
new file mode 100644
index 0000000..f901e2d
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_DMA_MAPPING_H
+#define __ASM_DMA_MAPPING_H
+
+extern struct dma_map_ops csky_dma_map_ops;
+
+#ifdef COMPAT_KERNEL_4_9
+static inline struct dma_map_ops *get_dma_ops(struct device *dev)
+#else
+static inline struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
+#endif
+{
+	return &csky_dma_map_ops;
+}
+
+#endif /* __ASM_DMA_MAPPING_H */
arch/csky/include/asm/io.h new file +23 -0
new file mode 100644
index 0000000..fcb2142
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_IO_H
+#define __ASM_CSKY_IO_H
+
+#include <abi/pgtable-bits.h>
+#include <linux/types.h>
+#include <linux/version.h>
+
+extern void __iomem *ioremap(phys_addr_t offset, size_t size);
+
+extern void iounmap(void *addr);
+
+extern int remap_area_pages(unsigned long address, phys_addr_t phys_addr,
+		size_t size, unsigned long flags);
+
+#define ioremap_nocache(phy, sz)	ioremap(phy, sz)
+#define ioremap_wc ioremap_nocache
+#define ioremap_wt ioremap_nocache
+
+#include <asm-generic/io.h>
+
+#endif /* __ASM_CSKY_IO_H */
arch/csky/include/asm/segment.h new file +18 -0
new file mode 100644
index 0000000..cf1440c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_SEGMENT_H
+#define __ASM_CSKY_SEGMENT_H
+
+typedef struct {
+	unsigned long seg;
+} mm_segment_t;
+
+#define KERNEL_DS		((mm_segment_t) { 0xFFFFFFFF })
+#define get_ds()		KERNEL_DS
+
+#define USER_DS			((mm_segment_t) { 0x80000000UL })
+#define get_fs()		(current_thread_info()->addr_limit)
+#define set_fs(x)		(current_thread_info()->addr_limit = (x))
+#define segment_eq(a,b)		((a).seg == (b).seg)
+
+#endif /* __ASM_CSKY_SEGMENT_H */
arch/csky/include/asm/tlb.h new file +24 -0
new file mode 100644
index 0000000..428e2b2
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_TLB_H
+#define __ASM_CSKY_TLB_H
+
+#include <asm/cacheflush.h>
+
+#define tlb_start_vma(tlb, vma) \
+	do { \
+		if (!tlb->fullmm) \
+		cache_wbinv_range(vma->vm_start, vma->vm_end); \
+	}  while (0)
+
+#define tlb_end_vma(tlb, vma) \
+	do { \
+		if (!tlb->fullmm) \
+		cache_wbinv_range(vma->vm_start, vma->vm_end); \
+	}  while (0)
+
+#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
+
+#include <asm-generic/tlb.h>
+
+#endif /* __ASM_CSKY_TLB_H */
arch/csky/include/asm/tlbflush.h new file +22 -0
new file mode 100644
index 0000000..d44cb07
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_TLBFLUSH_H
+#define __ASM_TLBFLUSH_H
+/*
+ * TLB flushing:
+ *
+ *  - flush_tlb_all() flushes all processes TLB entries
+ *  - flush_tlb_mm(mm) flushes the specified mm context TLB entries
+ *  - flush_tlb_page(vma, vmaddr) flushes one page
+ *  - flush_tlb_range(vma, start, end) flushes a range of pages
+ *  - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
+ */
+extern void flush_tlb_all(void);
+extern void flush_tlb_mm(struct mm_struct *mm);
+extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
+extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end);
+extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
+
+extern void flush_tlb_one(unsigned long vaddr);
+
+#endif
arch/csky/include/uapi/asm/cachectl.h new file +13 -0
new file mode 100644
index 0000000..38a1a28
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_CACHECTL_H
+#define __ASM_CSKY_CACHECTL_H
+
+/*
+ * See "man cacheflush"
+ */
+#define ICACHE  (1<<0)
+#define DCACHE  (1<<1)
+#define BCACHE  (ICACHE|DCACHE)
+
+#endif /* __ASM_CSKY_CACHECTL_H */
arch/csky/mm/cachev1.c new file +146 -0

146 lines not on this page · raw message

arch/csky/mm/cachev2.c new file +90 -0

90 lines not on this page · raw message

arch/csky/mm/syscache.c new file +50 -0

50 lines not on this page · raw message

arch/csky/mm/tlb.c new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#8 lore raw

PATCH 4/19 csky: MMU and page talbe management

In reply to Guo Ren
---
 arch/csky/abiv1/inc/abi/ckmmu.h        | 140 +++++++++++++++
 arch/csky/abiv1/inc/abi/page.h         |  26 +++
 arch/csky/abiv1/inc/abi/pgtable-bits.h |  36 ++++
 arch/csky/abiv1/src/mmap.c             |  65 +++++++
 arch/csky/abiv2/inc/abi/ckmmu.h        | 126 ++++++++++++++
 arch/csky/abiv2/inc/abi/page.h         |  20 +++
 arch/csky/abiv2/inc/abi/pgtable-bits.h |  36 ++++
 arch/csky/include/asm/addrspace.h      |  10 ++
 arch/csky/include/asm/fixmap.h         |  65 +++++++
 arch/csky/include/asm/highmem.h        |  50 ++++++
 arch/csky/include/asm/mmu.h            |  11 ++
 arch/csky/include/asm/page.h           | 108 ++++++++++++
 arch/csky/include/asm/pgalloc.h        | 113 ++++++++++++
 arch/csky/include/asm/pgtable.h        | 309 +++++++++++++++++++++++++++++++++
 arch/csky/include/asm/shmparam.h       |  10 ++
 arch/csky/mm/dma-mapping.c             | 250 ++++++++++++++++++++++++++
 arch/csky/mm/highmem.c                 | 210 ++++++++++++++++++++++
 arch/csky/mm/init.c                    | 101 +++++++++++
 arch/csky/mm/ioremap.c                 |  49 ++++++
 19 files changed, 1735 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/ckmmu.h
 create mode 100644 arch/csky/abiv1/inc/abi/page.h
 create mode 100644 arch/csky/abiv1/inc/abi/pgtable-bits.h
 create mode 100644 arch/csky/abiv1/src/mmap.c
 create mode 100644 arch/csky/abiv2/inc/abi/ckmmu.h
 create mode 100644 arch/csky/abiv2/inc/abi/page.h
 create mode 100644 arch/csky/abiv2/inc/abi/pgtable-bits.h
 create mode 100644 arch/csky/include/asm/addrspace.h
 create mode 100644 arch/csky/include/asm/fixmap.h
 create mode 100644 arch/csky/include/asm/highmem.h
 create mode 100644 arch/csky/include/asm/mmu.h
 create mode 100644 arch/csky/include/asm/page.h
 create mode 100644 arch/csky/include/asm/pgalloc.h
 create mode 100644 arch/csky/include/asm/pgtable.h
 create mode 100644 arch/csky/include/asm/shmparam.h
 create mode 100644 arch/csky/mm/dma-mapping.c
 create mode 100644 arch/csky/mm/highmem.c
 create mode 100644 arch/csky/mm/init.c
 create mode 100644 arch/csky/mm/ioremap.c
arch/csky/abiv1/inc/abi/ckmmu.h new file +140 -0
new file mode 100644
index 0000000..5bdba66
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_CKMMUV1_H
+#define __ASM_CSKY_CKMMUV1_H
+
+static inline void select_mmu_cp(void)
+{
+	 asm volatile("cpseti cp15\n");
+}
+
+static inline int read_mmu_index(void)
+{
+	int res;
+	asm volatile(
+		"cprcr %0, cpcr0\n"
+		:"=b" (res));
+	return   res;
+}
+
+static inline void write_mmu_index(int value)
+{
+
+	asm volatile(
+		"cpwcr %0, cpcr0\n"
+		::"b"(value));
+}
+
+static inline int read_mmu_entrylo0(void)
+{
+	int res;
+	asm volatile(
+		"cprcr %0, cpcr2\n"
+		:"=b" (res));
+
+	return res << 6;
+}
+
+static inline int read_mmu_entrylo1(void)
+{
+	int res;
+	asm volatile(
+		"cprcr %0, cpcr3\n"
+		:"=b" (res));
+
+	return res << 6;
+}
+
+static inline void write_mmu_pagemask(int value)
+{
+	asm volatile(
+		"cpwcr %0, cpcr6\n"
+		::"b"(value));
+}
+
+static inline int read_mmu_entryhi(void)
+{
+	int res;
+	asm volatile(
+		"cprcr %0, cpcr4\n"
+		:"=b" (res));
+
+	return res;
+}
+
+static inline void write_mmu_entryhi(int value)
+{
+
+	asm volatile(
+		"cpwcr %0, cpcr4\n"
+		::"b"(value));
+}
+
+/*
+ * TLB operations.
+ */
+static inline void tlb_probe(void)
+{
+	int value = 0x80000000;
+
+	asm volatile(
+		"cpwcr %0, cpcr8\n"
+		::"b"(value));
+}
+
+static inline void tlb_read(void)
+{
+	int value = 0x40000000;
+
+	asm volatile(
+		"cpwcr %0, cpcr8\n"
+		::"b"(value));
+}
+
+static inline void tlb_invalid_all(void)
+{
+	int value = 0x04000000;
+
+	asm volatile(
+		"cpwcr %0, cpcr8\n"
+		::"b"(value));
+}
+
+static inline void tlb_invalid_indexed(void)
+{
+	int value = 0x02000000;
+
+	asm volatile(
+		"cpwcr %0, cpcr8\n"
+		::"b"(value));
+}
+
+/* misc */
+static inline void tlbmiss_handler_setup_pgd(unsigned long pgd)
+{
+	asm volatile(
+		"bseti %0, 0		\n"
+		"bclri %0, 31		\n"
+		"addu  %0, %1		\n"
+		"cpseti cp15		\n"
+		"cpwcr %0, cpcr29	\n"
+		::"b"(pgd), "r"(PHYS_OFFSET)
+		:);
+}
+
+static inline unsigned long tlb_get_pgd(void)
+{
+	unsigned long pgd;
+	asm volatile(
+		"cpseti	cp15		\n"
+		"cprcr	%0, cpcr29	\n"
+		"bclri	%0, 0		\n"
+		"subu	%0, %1		\n"
+                "bseti	%0, 31		\n"
+                :"=&b"(pgd)
+		:"r"(PHYS_OFFSET)
+                :);
+	return pgd;
+}
+#endif /* __ASM_CSKY_CKMMUV1_H */
+
arch/csky/abiv1/inc/abi/page.h new file +26 -0
new file mode 100644
index 0000000..b0d2122
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+extern unsigned long shm_align_mask;
+extern void flush_dcache_page(struct page *);
+
+static inline unsigned long pages_do_alias(unsigned long addr1,
+					   unsigned long addr2)
+{
+	return (addr1 ^ addr2) & shm_align_mask;
+}
+
+static inline void clear_user_page(void *addr, unsigned long vaddr,
+				   struct page *page)
+{
+	clear_page(addr);
+	if (pages_do_alias((unsigned long) addr, vaddr & PAGE_MASK))
+		flush_dcache_page(page);
+}
+
+static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
+				  struct page *page)
+{
+	copy_page(to, from);
+	if (pages_do_alias((unsigned long) to, vaddr & PAGE_MASK))
+		flush_dcache_page(page);
+}
arch/csky/abiv1/inc/abi/pgtable-bits.h new file +36 -0
new file mode 100644
index 0000000..3d614f3
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_PGTABLE_BITS_H
+#define __ASM_CSKY_PGTABLE_BITS_H
+
+/* implemented in software */
+#define _PAGE_ACCESSED		(1<<3)
+#define PAGE_ACCESSED_BIT	(3)
+
+#define _PAGE_READ		(1<<1)
+#define _PAGE_WRITE		(1<<2)
+#define _PAGE_PRESENT		(1<<0)
+
+#define _PAGE_MODIFIED		(1<<4)
+#define PAGE_MODIFIED_BIT	(4)
+
+/* implemented in hardware */
+#define _PAGE_GLOBAL		(1<<6)
+
+#define _PAGE_VALID		(1<<7)
+#define PAGE_VALID_BIT		(7)
+
+#define _PAGE_DIRTY		(1<<8)
+#define PAGE_DIRTY_BIT		(8)
+
+#define _PAGE_CACHE		(3<<9)
+#define _PAGE_UNCACHE		(2<<9)
+
+#define _CACHE_MASK		(7<<9)
+
+#define _CACHE_CACHED		(_PAGE_VALID | _PAGE_CACHE)
+#define _CACHE_UNCACHED		(_PAGE_VALID | _PAGE_UNCACHE)
+
+#define HAVE_ARCH_UNMAPPED_AREA
+
+#endif /* __ASM_CSKY_PGTABLE_BITS_H */
arch/csky/abiv1/src/mmap.c new file +65 -0

65 lines not on this page · raw message

arch/csky/abiv2/inc/abi/ckmmu.h new file +126 -0

126 lines not on this page · raw message

arch/csky/abiv2/inc/abi/page.h new file +20 -0
new file mode 100644
index 0000000..5f25a68
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+static inline unsigned long pages_do_alias(unsigned long addr1,
+					   unsigned long addr2)
+{
+	return 0;
+}
+
+static inline void clear_user_page(void *addr, unsigned long vaddr,
+				   struct page *page)
+{
+	clear_page(addr);
+}
+
+static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
+				  struct page *page)
+{
+	copy_page(to, from);
+}
+
arch/csky/abiv2/inc/abi/pgtable-bits.h new file +36 -0
new file mode 100644
index 0000000..3ca90fa
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_PGTABLE_BITS_H
+#define __ASM_CSKY_PGTABLE_BITS_H
+
+/* implemented in software */
+#define _PAGE_ACCESSED		(1<<7)
+#define PAGE_ACCESSED_BIT	(7)
+
+#define _PAGE_READ		(1<<8)
+#define _PAGE_WRITE		(1<<9)
+#define _PAGE_PRESENT		(1<<10)
+
+#define _PAGE_MODIFIED		(1<<11)
+#define PAGE_MODIFIED_BIT	(11)
+
+/* implemented in hardware */
+#define _PAGE_GLOBAL		(1<<0)
+
+#define _PAGE_VALID		(1<<1)
+#define PAGE_VALID_BIT		(1)
+
+#define _PAGE_DIRTY		(1<<2)
+#define PAGE_DIRTY_BIT		(2)
+
+#define _PAGE_SO		(1<<5)
+#define _PAGE_BUF		(1<<6)
+
+#define _PAGE_CACHE		(1<<3)
+
+#define _CACHE_MASK		_PAGE_CACHE
+
+#define _CACHE_CACHED		(_PAGE_VALID | _PAGE_CACHE | _PAGE_BUF)
+#define _CACHE_UNCACHED		(_PAGE_VALID | _PAGE_SO)
+
+#endif /* __ASM_CSKY_PGTABLE_BITS_H */
arch/csky/include/asm/addrspace.h new file +10 -0
new file mode 100644
index 0000000..63f86ad
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_ADDRSPACE_H
+#define __ASM_CSKY_ADDRSPACE_H
+
+#define KSEG0		0x80000000ul
+#define KSEG0ADDR(a)	(((unsigned long)a & 0x1fffffff) | KSEG0)
+
+#endif /* __ASM_CSKY_ADDRSPACE_H */
+
arch/csky/include/asm/fixmap.h new file +65 -0

65 lines not on this page · raw message

arch/csky/include/asm/highmem.h new file +50 -0

50 lines not on this page · raw message

arch/csky/include/asm/mmu.h new file +11 -0
new file mode 100644
index 0000000..db29c17
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_MMU_H
+#define __ASM_CSKY_MMU_H
+
+typedef struct {
+	unsigned long asid[NR_CPUS];
+	void *vdso;
+} mm_context_t;
+
+#endif /* __ASM_CSKY_MMU_H */
arch/csky/include/asm/page.h new file +108 -0

108 lines not on this page · raw message

arch/csky/include/asm/pgalloc.h new file +113 -0

113 lines not on this page · raw message

arch/csky/include/asm/pgtable.h new file +309 -0

309 lines not on this page · raw message

arch/csky/include/asm/shmparam.h new file +10 -0
new file mode 100644
index 0000000..ecf7b65
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_SHMPARAM_H
+#define __ASM_CSKY_SHMPARAM_H
+
+#define SHMLBA	(4 * PAGE_SIZE)
+
+#define __ARCH_FORCE_SHMLBA
+
+#endif /* __ASM_CSKY_SHMPARAM_H */
arch/csky/mm/dma-mapping.c new file +250 -0

250 lines not on this page · raw message

arch/csky/mm/highmem.c new file +210 -0

210 lines not on this page · raw message

arch/csky/mm/init.c new file +101 -0

101 lines not on this page · raw message

arch/csky/mm/ioremap.c new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#9 lore raw

PATCH 5/19 csky: Process management

In reply to Guo Ren
---
 arch/csky/include/asm/mmu_context.h | 140 ++++++++++++++++++++++++++++++++++
 arch/csky/include/asm/processor.h   | 140 ++++++++++++++++++++++++++++++++++
 arch/csky/include/asm/thread_info.h |  77 +++++++++++++++++++
 arch/csky/kernel/process.c          | 147 ++++++++++++++++++++++++++++++++++++
 arch/csky/kernel/time.c             |  15 ++++
 5 files changed, 519 insertions(+)
 create mode 100644 arch/csky/include/asm/mmu_context.h
 create mode 100644 arch/csky/include/asm/processor.h
 create mode 100644 arch/csky/include/asm/thread_info.h
 create mode 100644 arch/csky/kernel/process.c
 create mode 100644 arch/csky/kernel/time.c
arch/csky/include/asm/mmu_context.h new file +140 -0
new file mode 100644
index 0000000..6eeea85
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_MMU_CONTEXT_H
+#define __ASM_CSKY_MMU_CONTEXT_H
+
+#include <asm-generic/mm_hooks.h>
+#include <asm/setup.h>
+#include <asm/page.h>
+#include <asm/cacheflush.h>
+#include <asm/tlbflush.h>
+
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <abi/ckmmu.h>
+
+/*
+ * For the fast tlb miss handlers, we currently keep a per cpu array
+ * of pointers to the current pgd for each processor. Also, the proc.
+ * id is stuffed into the context register. This should be changed to
+ * use the processor id via current->processor, where current is stored
+ * in watch hi/lo. The context register should be used to contiguously
+ * map the page tables.
+ */
+#define TLBMISS_HANDLER_SETUP_PGD(pgd) tlbmiss_handler_setup_pgd((unsigned long)pgd)
+
+#define cpu_context(cpu, mm)	((mm)->context.asid[cpu])
+#define cpu_asid(cpu, mm)	(cpu_context((cpu), (mm)) & ASID_MASK)
+#define asid_cache(cpu)		(cpu_data[cpu].asid_cache)
+
+#define ASID_INC		0x1
+#define ASID_MASK		0xff
+#define ASID_VERSION_MASK	0xffffff00
+#define ASID_FIRST_VERSION	0x100
+
+#define destroy_context(mm)		do{}while(0)
+#define enter_lazy_tlb(mm,tsk)		do{}while(0)
+#define deactivate_mm(tsk,mm)		do{}while(0)
+
+/*
+ *  All unused by hardware upper bits will be considered
+ *  as a software asid extension.
+ */
+static inline void
+get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
+{
+	unsigned long asid = asid_cache(cpu);
+
+	if (! ((asid += ASID_INC) & ASID_MASK) ) {
+		flush_tlb_all();	/* start new asid cycle */
+		if (!asid)		/* fix version if needed */
+			asid = ASID_FIRST_VERSION;
+	}
+	cpu_context(cpu, mm) = asid_cache(cpu) = asid;
+}
+
+/*
+ * Initialize the context related info for a new mm_struct
+ * instance.
+ */
+static inline int
+init_new_context(struct task_struct *tsk, struct mm_struct *mm)
+{
+	int i;
+
+	for_each_online_cpu(i)
+		cpu_context(i, mm) = 0;
+	return 0;
+}
+
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+                             struct task_struct *tsk)
+{
+	unsigned int cpu = smp_processor_id();
+	unsigned long flags;
+
+	local_irq_save(flags);
+	/* Check if our ASID is of an older version and thus invalid */
+	if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & ASID_VERSION_MASK)
+		get_new_mmu_context(next, cpu);
+	write_mmu_entryhi(cpu_context(cpu, next));
+	TLBMISS_HANDLER_SETUP_PGD(next->pgd);
+
+	/*
+	 * Mark current->active_mm as not "active" anymore.
+	 * We don't want to mislead possible IPI tlb flush routines.
+	 */
+	cpumask_clear_cpu(cpu, mm_cpumask(prev));
+	cpumask_set_cpu(cpu, mm_cpumask(next));
+
+	local_irq_restore(flags);
+}
+
+/*
+ * After we have set current->mm to a new value, this activates
+ * the context for the new mm so we see the new mappings.
+ */
+static inline void
+activate_mm(struct mm_struct *prev, struct mm_struct *next)
+{
+	unsigned long flags;
+	int cpu = smp_processor_id();
+
+	local_irq_save(flags);
+
+	/* Unconditionally get a new ASID.  */
+	get_new_mmu_context(next, cpu);
+
+	write_mmu_entryhi(cpu_context(cpu, next));
+	TLBMISS_HANDLER_SETUP_PGD(next->pgd);
+
+	/* mark mmu ownership change */
+	cpumask_clear_cpu(cpu, mm_cpumask(prev));
+	cpumask_set_cpu(cpu, mm_cpumask(next));
+
+	local_irq_restore(flags);
+}
+
+/*
+ * If mm is currently active_mm, we can't really drop it. Instead,
+ * we will get a new one for it.
+ */
+static inline void
+drop_mmu_context(struct mm_struct *mm, unsigned cpu)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+
+	if (cpumask_test_cpu(cpu, mm_cpumask(mm)))  {
+		get_new_mmu_context(mm, cpu);
+		write_mmu_entryhi(cpu_asid(cpu, mm));
+	} else {
+		/* will get a new context next time */
+		cpu_context(cpu, mm) = 0;
+	}
+
+	local_irq_restore(flags);
+}
+
+#endif /* __ASM_CSKY_MMU_CONTEXT_H */
arch/csky/include/asm/processor.h new file +140 -0

140 lines not on this page · raw message

arch/csky/include/asm/thread_info.h new file +77 -0

77 lines not on this page · raw message

arch/csky/kernel/process.c new file +147 -0

147 lines not on this page · raw message

arch/csky/kernel/time.c new file +15 -0
new file mode 100644
index 0000000..4d9bc05
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/clk-provider.h>
+#include <linux/clocksource.h>
+
+void __init time_init(void)
+{
+	of_clk_init(NULL);
+#ifdef COMPAT_KERNEL_4_9
+	clocksource_probe();
+#else
+	timer_probe();
+#endif
+}
+
Signature · 1 line
2.7.4
author
#10 lore raw

PATCH 6/19 csky: IRQ handling

In reply to Guo Ren
---
 arch/csky/include/asm/irq.h      | 12 +++++++++
 arch/csky/include/asm/irqflags.h | 55 ++++++++++++++++++++++++++++++++++++++++
 arch/csky/kernel/irq.c           | 41 ++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+)
 create mode 100644 arch/csky/include/asm/irq.h
 create mode 100644 arch/csky/include/asm/irqflags.h
 create mode 100644 arch/csky/kernel/irq.c
arch/csky/include/asm/irq.h new file +12 -0
new file mode 100644
index 0000000..f68e868
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_IRQ_H
+#define __ASM_CSKY_IRQ_H
+
+#define NR_IRQS CONFIG_CSKY_NR_IRQS
+
+#include <asm-generic/irq.h>
+
+extern unsigned int (*csky_get_auto_irqno) (void);
+
+#endif /* __ASM_CSKY_IRQ_H */
arch/csky/include/asm/irqflags.h new file +55 -0

55 lines not on this page · raw message

arch/csky/kernel/irq.c new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.7.4
#11 lore raw

Re: [PATCH 06/19] csky: IRQ handling

Quoted 29 lines · Guo Ren
---
 arch/csky/include/asm/irq.h      | 12 +++++++++
 arch/csky/include/asm/irqflags.h | 55 ++++++++++++++++++++++++++++++++++++++++
 arch/csky/kernel/irq.c           | 41 ++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+)
 create mode 100644 arch/csky/include/asm/irq.h
 create mode 100644 arch/csky/include/asm/irqflags.h
 create mode 100644 arch/csky/kernel/irq.c
arch/csky/include/asm/irq.h new file +12 -0
new file mode 100644
index 0000000..f68e868
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_IRQ_H
+#define __ASM_CSKY_IRQ_H
+
+#define NR_IRQS CONFIG_CSKY_NR_IRQS
+
+#include <asm-generic/irq.h>
+
+extern unsigned int (*csky_get_auto_irqno) (void);
+
+#endif /* __ASM_CSKY_IRQ_H */

arch/csky/include/asm/irqflags.h line 8

Quoted 3 lines
arch/csky/include/asm/irqflags.h +3 -0
+static inline unsigned long arch_local_irq_save(void)
+{
+	unsigned long flags;

Newline between declaration and code please.

Quoted 7 lines
arch/csky/include/asm/irqflags.h +5 -0
+	asm volatile(
+		"mfcr	%0, psr	\n"
+		"psrclr	ie	\n"
+		:"=r"(flags));
 
+++ b/arch/csky/kernel/irq.c

arch/csky/include/asm/irqflags.h line 10

Quoted 10 lines
arch/csky/include/asm/irqflags.h +10 -0
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqchip.h>
+
+unsigned int (*csky_get_auto_irqno) (void) = NULL;
+
+void csky_do_IRQ(int irq, struct pt_regs *regs)

static? If not, then it needs a declaration in a header somewhere.

Quoted 12 lines
arch/csky/include/asm/irqflags.h +12 -0
+{
+	struct pt_regs *old_regs = set_irq_regs(regs);
+
+	irq_enter();
+	generic_handle_irq(irq);
+	irq_exit();
+
+	set_irq_regs(old_regs);
+}
+
+asmlinkage void csky_do_auto_IRQ(struct pt_regs *regs)
+{

arch/csky/include/asm/irqflags.h line 32

Quoted 10 lines
arch/csky/include/asm/irqflags.h +10 -0
+	unsigned long irq, psr;
+
+	asm volatile("mfcr %0, psr":"=r"(psr));
+
+	irq = (psr >> 16) & 0xff;
+
+	if (irq == 10)
+		irq = csky_get_auto_irqno();
+	else
+		irq -= 32;

Please add a comment explaining this magic here. Magic numbers w/o explanation are bad.

author
#12 lore raw

Re: [PATCH 06/19] csky: IRQ handling

Hi Thomas,

Quoted 5 lines · Thomas Gleixner

arch/csky/include/asm/irqflags.h line 8

Quoted 3 lines
arch/csky/include/asm/irqflags.h new file +3 -0
+static inline unsigned long arch_local_irq_save(void)
+{
+	unsigned long flags;

Newline between declaration and code please.

OK

Quoted 3 lines
Quoted 1 line

+void csky_do_IRQ(int irq, struct pt_regs *regs)

static? If not, then it needs a declaration in a header somewhere.

Yes, need static.

Quoted 7 lines
Quoted 7 lines
arch/csky/kernel/irq.c new file +7 -0
+asmlinkage void csky_do_auto_IRQ(struct pt_regs *regs)
+{
+	unsigned long irq, psr;
+
+	asm volatile("mfcr %0, psr":"=r"(psr));
+
+	irq = (psr >> 16) & 0xff;
Quoted 8 lines

arch/csky/kernel/irq.c line 32

Quoted 5 lines
arch/csky/kernel/irq.c new file +5 -0
+
+	if (irq == 10)
+		irq = csky_get_auto_irqno();
+	else
+		irq -= 32;

Please add a comment explaining this magic here. Magic numbers w/o explanation are bad.

Yes, you are right. I will fixup them next.

PSR is our Processor Status Register and it store the vector number.

'10' is our auto-interrupt exception entry and we need get the irqno from the interrupt-controller.

The "vector num > 32" is our vector interrupt exception entries, so we can calculate the irq-num by vector-num and no need to access the interrupt-controller's io regs.

Best Regards
Guo Ren

author
#13 lore raw

PATCH 7/19 csky: Atomic operations

In reply to Guo Ren
---
 arch/csky/kernel/atomic.S | 55 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 arch/csky/kernel/atomic.S
arch/csky/kernel/atomic.S new file +55 -0
new file mode 100644
index 0000000..e6e9fd2
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/linkage.h>
+#include <abi/entry.h>
+
+.text
+
+/*
+ * int csky_cmpxchg(int oldval, int newval, int *ptr)
+ *
+ * If *ptr != oldval && return 1,
+ * else *ptr = newval return 0.
+ */
+ENTRY(csky_cmpxchg)
+	USPTOKSP
+	mfcr	a3, epc
+	INCTRAP	a3
+
+	subi    sp, 8
+	stw     a3, (sp, 0)
+	mfcr    a3, epsr
+	stw     a3, (sp, 4)
+
+	psrset	ee
+1:
+	ldw	a3, (a2)
+	cmpne	a0, a3
+	bt16	3f
+2:
+	stw	a1, (a2)
+3:
+	mvc	a0
+	ldw	a3, (sp, 0)
+	mtcr	a3, epc
+	ldw     a3, (sp, 4)
+	mtcr	a3, epsr
+	addi	sp, 8
+	KSPTOUSP
+	rte
+END(csky_cmpxchg)
+
+/*
+ * Called from tlbmodified exception
+ */
+ENTRY(csky_cmpxchg_fixup)
+	mfcr	a0, epc
+	lrw	a1, 2b
+	cmpne	a1, a0
+	bt	1f
+	subi	a1, (2b - 1b)
+	stw	a1, (sp, 0)
+1:
+	rts
+END(csky_cmpxchg_fixup)
+
Signature · 1 line
2.7.4
author
#14 lore raw

PATCH 8/19 csky: ELF and module probe

In reply to Guo Ren
---
 arch/csky/include/asm/elf.h | 151 ++++++++++++++++++++++++++++++++++++++++++++
 arch/csky/kernel/module.c   | 130 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 281 insertions(+)
 create mode 100644 arch/csky/include/asm/elf.h
 create mode 100644 arch/csky/kernel/module.c
arch/csky/include/asm/elf.h new file +151 -0
new file mode 100644
index 0000000..f63a45d
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASMCSKY_ELF_H
+#define __ASMCSKY_ELF_H
+
+/*
+ * ELF register definitions..
+ */
+
+#include <asm/ptrace.h>
+#include <asm/user.h>
+#include <abi/regdef.h>
+
+#define ELF_ARCH 39
+
+/* CSKY Relocations */
+#define R_CSKY_NONE               0
+#define R_CSKY_32                 1
+#define R_CSKY_PCIMM8BY4          2
+#define R_CSKY_PCIMM11BY2         3
+#define R_CSKY_PCIMM4BY2          4
+#define R_CSKY_PC32               5
+#define R_CSKY_PCRELJSR_IMM11BY2  6
+#define R_CSKY_GNU_VTINHERIT      7
+#define R_CSKY_GNU_VTENTRY        8
+#define R_CSKY_RELATIVE           9
+#define R_CSKY_COPY               10
+#define R_CSKY_GLOB_DAT           11
+#define R_CSKY_JUMP_SLOT          12
+#define R_CSKY_ADDR_HI16          24
+#define R_CSKY_ADDR_LO16          25
+#define R_CSKY_PCRELJSR_IMM26BY2  40
+
+typedef unsigned long elf_greg_t;
+
+
+#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
+
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef struct user_cskyfp_struct elf_fpregset_t;
+
+/*
+ * This is used to ensure we don't load something for the wrong architecture.
+ */
+#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE		4096
+#define ELF_CLASS			ELFCLASS32
+#define ELF_PLAT_INIT(_r, load_addr)	_r->a0 = 0
+
+#ifdef  __cskyBE__
+#define ELF_DATA	ELFDATA2MSB
+#else
+#define ELF_DATA	ELFDATA2LSB
+#endif
+
+/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
+   use of this is to invoke "./ld.so someprog" to test out a new version of
+   the loader.  We need to make sure that it is out of the way of the program
+   that it will "exec", and that there is sufficient room for the brk.  */
+
+#define ELF_ET_DYN_BASE	0x0UL
+
+/* The member sort in array pr_reg[x] is pc, r1, r0, psr, r2, r3,r4,
+   r5, r6...... Because GDB difine */
+#if defined(__CSKYABIV2__)
+   #define ELF_CORE_COPY_REGS(pr_reg, regs)     \
+        pr_reg[0] = regs->pc;                   \
+        pr_reg[1] = regs->a1;                   \
+        pr_reg[2] = regs->a0;                   \
+        pr_reg[3] = regs->sr;                   \
+        pr_reg[4] = regs->a2;                   \
+        pr_reg[5] = regs->a3;                   \
+        pr_reg[6] = regs->regs[0];              \
+        pr_reg[7] = regs->regs[1];              \
+        pr_reg[8] = regs->regs[2];              \
+        pr_reg[9] = regs->regs[3];              \
+        pr_reg[10] = regs->regs[4];             \
+        pr_reg[11] = regs->regs[5];             \
+        pr_reg[12] = regs->regs[6];             \
+        pr_reg[13] = regs->regs[7];             \
+        pr_reg[14] = regs->regs[8];             \
+        pr_reg[15] = regs->regs[9];             \
+        pr_reg[16] = rdusp();		        \
+        pr_reg[17] = regs->r15;                 \
+        pr_reg[18] = regs->exregs[0];           \
+        pr_reg[19] = regs->exregs[1];           \
+        pr_reg[20] = regs->exregs[2];           \
+        pr_reg[21] = regs->exregs[3];           \
+        pr_reg[22] = regs->exregs[4];           \
+        pr_reg[23] = regs->exregs[5];           \
+        pr_reg[24] = regs->exregs[6];           \
+        pr_reg[25] = regs->exregs[7];           \
+        pr_reg[26] = regs->exregs[8];           \
+        pr_reg[27] = regs->exregs[9];           \
+        pr_reg[28] = regs->exregs[10];          \
+        pr_reg[29] = regs->exregs[11];          \
+        pr_reg[30] = regs->exregs[12];          \
+        pr_reg[31] = regs->exregs[13];          \
+        pr_reg[32] = regs->exregs[14];          \
+        pr_reg[33] = regs->exregs[15];
+#else
+     #define ELF_CORE_COPY_REGS(pr_reg, regs)   \
+        pr_reg[0] = regs->pc;                   \
+        pr_reg[1] = regs->regs[9];              \
+        pr_reg[2] = rdusp();                    \
+        pr_reg[3] = regs->sr;                   \
+        pr_reg[4] = regs->a0;                   \
+        pr_reg[5] = regs->a1;                   \
+        pr_reg[6] = regs->a2;                   \
+        pr_reg[7] = regs->a3;                   \
+        pr_reg[8] = regs->regs[0];              \
+        pr_reg[9] = regs->regs[1];              \
+        pr_reg[10] = regs->regs[2];             \
+        pr_reg[11] = regs->regs[3];             \
+        pr_reg[12] = regs->regs[4];             \
+        pr_reg[13] = regs->regs[5];             \
+        pr_reg[14] = regs->regs[6];             \
+        pr_reg[15] = regs->regs[7];             \
+        pr_reg[16] = regs->regs[8];             \
+        pr_reg[17] = regs->r15;
+#endif
+
+/* Similar, but for a thread other than current. */
+struct task_struct;
+extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
+#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
+
+/* This yields a mask that user programs can use to figure out what
+   instruction set this cpu supports.  */
+
+#define ELF_HWCAP	(0)
+
+/* This yields a string that ld.so will use to load implementation
+   specific libraries for optimization.  This is more specific in
+   intent than poking at uname or /proc/cpuinfo.  */
+
+#define ELF_PLATFORM	(NULL)
+#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
+#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
+struct linux_binprm;
+extern int arch_setup_additional_pages(
+		struct linux_binprm *bprm,
+		int uses_interp);
+
+#endif
arch/csky/kernel/module.c new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#15 lore raw

PATCH 9/19 csky: VDSO and rt_sigreturn

In reply to Guo Ren
---
 arch/csky/abiv1/inc/abi/vdso.h | 19 +++++++++
 arch/csky/abiv2/inc/abi/vdso.h | 18 +++++++++
 arch/csky/include/asm/vdso.h   | 12 ++++++
 arch/csky/kernel/vdso.c        | 89 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 138 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/vdso.h
 create mode 100644 arch/csky/abiv2/inc/abi/vdso.h
 create mode 100644 arch/csky/include/asm/vdso.h
 create mode 100644 arch/csky/kernel/vdso.c
arch/csky/abiv1/inc/abi/vdso.h new file +19 -0
new file mode 100644
index 0000000..029c4e3
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/uaccess.h>
+
+static inline int setup_vdso_page(unsigned short *ptr)
+{
+	int err;
+
+	/* movi r1, 127 */
+	err |= __put_user(0x6000 + (127 << 4)+1, ptr+0);
+	/* addi r1, 32 */
+	err |= __put_user(0x2000 + ((32-1)  << 4)+1, ptr+1);
+	/* addi r1, 173-127-32 */
+	err |= __put_user(0x2000 + (((173-127-32) -1)<< 4)+1, ptr+2);
+	/* trap 0 */
+	err |= __put_user(0x08, ptr+3);
+
+	return err;
+}
arch/csky/abiv2/inc/abi/vdso.h new file +18 -0
new file mode 100644
index 0000000..f9da48a
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/uaccess.h>
+
+static inline int setup_vdso_page(unsigned short *ptr)
+{
+	int err;
+
+	/* movi r7, 173 */
+	err |= __put_user(0xEA00+7, ptr);
+	err |= __put_user(173,      ptr+1);
+
+	/* trap 0 */
+	err |= __put_user(0xC000,   ptr+2);
+	err |= __put_user(0x2020,   ptr+3);
+
+	return err;
+}
arch/csky/include/asm/vdso.h new file +12 -0
new file mode 100644
index 0000000..b275440
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_VDSO_H
+#define __ASM_CSKY_VDSO_H
+
+#include <abi/vdso.h>
+
+struct csky_vdso {
+	unsigned short rt_signal_retcode[4];
+};
+
+#endif /* __ASM_CSKY_VDSO_H */
arch/csky/kernel/vdso.c new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#16 lore raw

PATCH 10/19 csky: Signal handling

In reply to Guo Ren
---
 arch/csky/include/uapi/asm/sigcontext.h |  33 +++
 arch/csky/include/uapi/asm/signal.h     | 164 ++++++++++++++
 arch/csky/kernel/signal.c               | 379 ++++++++++++++++++++++++++++++++
 3 files changed, 576 insertions(+)
 create mode 100644 arch/csky/include/uapi/asm/sigcontext.h
 create mode 100644 arch/csky/include/uapi/asm/signal.h
 create mode 100644 arch/csky/kernel/signal.c
arch/csky/include/uapi/asm/sigcontext.h new file +33 -0
new file mode 100644
index 0000000..8ef0ce8
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef _ASM_CSKY_SIGCONTEXT_H
+#define _ASM_CSKY_SIGCONTEXT_H
+
+struct sigcontext {
+	unsigned long   sc_mask;     /* old sigmask */
+        unsigned long   sc_usp;      /* old user stack pointer */
+        unsigned long   sc_a0;
+        unsigned long   sc_a1;
+        unsigned long   sc_a2;
+        unsigned long   sc_a3;
+	// ABIV2: r4 ~ r13; ABIV1: r6 ~ r14, r1.
+        unsigned long   sc_regs[10];
+        unsigned long   sc_r15;
+#if (__CSKY__ == 2)                     /* config CPU=cskyv2(ck800) */
+	// r16 ~ r31;
+        unsigned long   sc_exregs[16];
+        unsigned long   sc_rhi;
+        unsigned long   sc_rlo;
+#endif
+        unsigned long   sc_sr;
+        unsigned long   sc_pc;
+	/* fpu */
+        unsigned long   sc_fcr;
+        unsigned long   sc_fsr;		/* Nothing in CPU_CSKYV2 */
+        unsigned long   sc_fesr;
+        unsigned long   sc_feinst1;	/* Nothing in CPU_CSKYV2 */
+        unsigned long   sc_feinst2;	/* Nothing in CPU_CSKYV2 */
+        unsigned long   sc_fpregs[32];
+};
+
+#endif /* _ASM_CSKY_SIGCONTEXT_H */
arch/csky/include/uapi/asm/signal.h new file +164 -0

164 lines not on this page · raw message

arch/csky/kernel/signal.c new file +379 -0

379 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#17 lore raw

Re: [PATCH 10/19] csky: Signal handling

Quoted 6 lines · Guo Ren
---
 arch/csky/include/uapi/asm/sigcontext.h |  33 +++
 arch/csky/include/uapi/asm/signal.h     | 164 ++++++++++++++
 arch/csky/kernel/signal.c               | 379 ++++++++++++++++++++++++++++++++
 3 files changed, 576 insertions(+)

Please have a look at arch/riscv and arch/nds32 for this, I think it can be simplified. This is an incompatible change of course, but when we change the system call ABI anyway, that is the right time to do it.

Quoted 9 lines
arch/csky/include/uapi/asm/signal.h new file +9 -0
+#define NSIG           32
+typedef unsigned long sigset_t;
+
+#endif /* __KERNEL__ */
+
+#define SIGHUP          1
+#define SIGINT          2
+#define SIGQUIT                 3
+#define SIGILL          4

arch/csky/include/uapi/asm/signal.h line 49

Quoted 10 lines
arch/csky/include/uapi/asm/signal.h new file +10 -0
+#define SIGTRAP                 5
+#define SIGABRT                 6
+#define SIGIOT          6
+#define SIGBUS          7
+#define SIGFPE          8
+#define SIGKILL                 9
+#define SIGUSR1                10
+#define SIGSEGV                11
+#define SIGUSR2                12
+#define SIGPIPE                13

In particular the constants should come from the asm-generic headers rather than being duplicated. If you need anything special, it may be better to modify the generic headers.

Arnd

author
#18 lore raw

Re: [PATCH 10/19] csky: Signal handling

Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Guo Ren
---
 arch/csky/include/uapi/asm/sigcontext.h |  33 +++
 arch/csky/include/uapi/asm/signal.h     | 164 ++++++++++++++
 arch/csky/kernel/signal.c               | 379 ++++++++++++++++++++++++++++++++
 3 files changed, 576 insertions(+)

Please have a look at arch/riscv and arch/nds32 for this, I think it can be simplified. This is an incompatible change of course, but when we change the system call ABI anyway, that is the right time to do it.

Ok.

Quoted 17 lines
Quoted 17 lines
arch/csky/include/uapi/asm/signal.h new file +15 -0
+#define NSIG           32
+typedef unsigned long sigset_t;
+
+#endif /* __KERNEL__ */
+
+#define SIGHUP          1
+#define SIGINT          2
+#define SIGQUIT                 3
+#define SIGILL          4
+#define SIGTRAP                 5
+#define SIGABRT                 6
+#define SIGIOT          6
+#define SIGBUS          7
+#define SIGFPE          8
+#define SIGKILL                 9
Quoted 8 lines

arch/csky/include/uapi/asm/signal.h line 49

Quoted 4 lines
arch/csky/include/uapi/asm/signal.h new file +4 -0
+#define SIGUSR1                10
+#define SIGSEGV                11
+#define SIGUSR2                12
+#define SIGPIPE                13

In particular the constants should come from the asm-generic headers rather than being duplicated. If you need anything special, it may be better to modify the generic headers.

Ok, use asm-generic.

Best Regards
Guo Ren

author
#19 lore raw

PATCH 11/19 csky: Library functions

In reply to Guo Ren
---
 arch/csky/abiv1/src/bswapdi.c    |  18 ++
 arch/csky/abiv1/src/bswapsi.c    |  15 ++
 arch/csky/abiv1/src/memcpy.S     | 344 +++++++++++++++++++++++++++++++++++++++
 arch/csky/abiv2/src/fpu.c        | 312 +++++++++++++++++++++++++++++++++++
 arch/csky/abiv2/src/memcpy.c     |  43 +++++
 arch/csky/include/asm/bitops.h   |  83 ++++++++++
 arch/csky/include/asm/checksum.h |  77 +++++++++
 arch/csky/include/asm/string.h   |  19 +++
 arch/csky/kernel/asm-offsets.c   |  86 ++++++++++
 arch/csky/kernel/cskyksyms.c     |  31 ++++
 arch/csky/kernel/platform.c      |  18 ++
 arch/csky/kernel/power.c         |  31 ++++
 arch/csky/lib/delay.c            |  40 +++++
 arch/csky/lib/memset.c           |  38 +++++
 arch/csky/lib/usercopy.c         | 271 ++++++++++++++++++++++++++++++
 arch/csky/oprofile/init.c        |  16 ++
 16 files changed, 1442 insertions(+)
 create mode 100644 arch/csky/abiv1/src/bswapdi.c
 create mode 100644 arch/csky/abiv1/src/bswapsi.c
 create mode 100644 arch/csky/abiv1/src/memcpy.S
 create mode 100644 arch/csky/abiv2/src/fpu.c
 create mode 100644 arch/csky/abiv2/src/memcpy.c
 create mode 100644 arch/csky/include/asm/bitops.h
 create mode 100644 arch/csky/include/asm/checksum.h
 create mode 100644 arch/csky/include/asm/string.h
 create mode 100644 arch/csky/kernel/asm-offsets.c
 create mode 100644 arch/csky/kernel/cskyksyms.c
 create mode 100644 arch/csky/kernel/platform.c
 create mode 100644 arch/csky/kernel/power.c
 create mode 100644 arch/csky/lib/delay.c
 create mode 100644 arch/csky/lib/memset.c
 create mode 100644 arch/csky/lib/usercopy.c
 create mode 100644 arch/csky/oprofile/init.c
arch/csky/abiv1/src/bswapdi.c new file +18 -0
new file mode 100644
index 0000000..7346252
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/export.h>
+#include <linux/compiler.h>
+
+unsigned long long notrace __bswapdi2(unsigned long long u)
+{
+	return (((u) & 0xff00000000000000ull) >> 56) |
+	       (((u) & 0x00ff000000000000ull) >> 40) |
+	       (((u) & 0x0000ff0000000000ull) >> 24) |
+	       (((u) & 0x000000ff00000000ull) >>  8) |
+	       (((u) & 0x00000000ff000000ull) <<  8) |
+	       (((u) & 0x0000000000ff0000ull) << 24) |
+	       (((u) & 0x000000000000ff00ull) << 40) |
+	       (((u) & 0x00000000000000ffull) << 56);
+}
+
+EXPORT_SYMBOL(__bswapdi2);
arch/csky/abiv1/src/bswapsi.c new file +15 -0
new file mode 100644
index 0000000..21958ca
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/export.h>
+#include <linux/compiler.h>
+
+unsigned int notrace __bswapsi2(unsigned int u)
+{
+	return (((u) & 0xff000000) >> 24) |
+	       (((u) & 0x00ff0000) >>  8) |
+	       (((u) & 0x0000ff00) <<  8) |
+	       (((u) & 0x000000ff) << 24);
+}
+
+EXPORT_SYMBOL(__bswapsi2);
+
arch/csky/abiv1/src/memcpy.S new file +344 -0

344 lines not on this page · raw message

arch/csky/abiv2/src/fpu.c new file +312 -0

312 lines not on this page · raw message

arch/csky/abiv2/src/memcpy.c new file +43 -0

43 lines not on this page · raw message

arch/csky/include/asm/bitops.h new file +83 -0

83 lines not on this page · raw message

arch/csky/include/asm/checksum.h new file +77 -0

77 lines not on this page · raw message

arch/csky/include/asm/string.h new file +19 -0
new file mode 100644
index 0000000..2c4878b
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef _CSKY_STRING_MM_H_
+#define _CSKY_STRING_MM_H_
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#include <linux/compiler.h>
+
+#define __HAVE_ARCH_MEMCPY
+extern void * memcpy(void *to, const void *from, size_t l);
+
+/* New and improved.  In arch/csky/lib/memset.c */
+#define __HAVE_ARCH_MEMSET
+extern void * memset(void *dest, int c, size_t l);
+
+#endif
+
+#endif /* _CSKY_STRING_MM_H_ */
arch/csky/kernel/asm-offsets.c new file +86 -0

86 lines not on this page · raw message

arch/csky/kernel/cskyksyms.c new file +31 -0
new file mode 100644
index 0000000..3f13594
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/module.h>
+#include <linux/uaccess.h>
+#include <asm/cacheflush.h>
+
+/*
+ * Defined in libgcc
+ *
+ * See arch/csky/Makefile:
+ *	-print-libgcc-file-name
+ */
+extern void __ashldi3 (void);
+extern void __ashrdi3 (void);
+extern void __lshrdi3 (void);
+extern void __muldi3 (void);
+extern void __ucmpdi2 (void);
+EXPORT_SYMBOL(__ashldi3);
+EXPORT_SYMBOL(__ashrdi3);
+EXPORT_SYMBOL(__lshrdi3);
+EXPORT_SYMBOL(__muldi3);
+EXPORT_SYMBOL(__ucmpdi2);
+
+/*
+ * Defined in abiv1/src/memcpy.S
+ * and abiv2/src/memcpy.c
+ */
+EXPORT_SYMBOL(memcpy);
+
+/* Defined in lib/memset.c */
+EXPORT_SYMBOL(memset);
arch/csky/kernel/platform.c new file +18 -0
new file mode 100644
index 0000000..f51654f
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/init.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/of_fdt.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/sys_soc.h>
+#include <linux/io.h>
+
+static int __init csky_platform_init(void)
+{
+	return of_platform_default_populate(NULL, NULL, NULL);
+}
+device_initcall(csky_platform_init);
+
+
arch/csky/kernel/power.c new file +31 -0
new file mode 100644
index 0000000..d35e882
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/reboot.h>
+
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
+void machine_power_off(void)
+{
+	local_irq_disable();
+	if (pm_power_off)
+		pm_power_off();
+	asm volatile ("bkpt");
+}
+
+void machine_halt(void)
+{
+	local_irq_disable();
+	if (pm_power_off)
+		pm_power_off();
+	asm volatile ("bkpt");
+}
+
+void machine_restart(char *cmd)
+{
+	local_irq_disable();
+	do_kernel_restart(cmd);
+	asm volatile ("bkpt");
+}
+
+
arch/csky/lib/delay.c new file +40 -0
new file mode 100644
index 0000000..34766a4
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+void __delay(unsigned long loops)
+{
+       asm volatile (
+		"mov r0, r0\n"
+		"1:declt %0\n"
+		"bf	1b"
+                :"=r"(loops)
+	        :"0"(loops));
+}
+EXPORT_SYMBOL(__delay);
+
+extern unsigned long loops_per_jiffy;
+
+void __const_udelay(unsigned long xloops)
+{
+	unsigned long long loops;
+
+	loops = (unsigned long long)xloops * loops_per_jiffy * HZ;
+
+	__delay(loops >> 32);
+}
+EXPORT_SYMBOL(__const_udelay);
+
+void __udelay(unsigned long usecs)
+{
+	__const_udelay(usecs * 0x10C7UL); /* 2**32 / 1000000 (rounded up) */
+}
+EXPORT_SYMBOL(__udelay);
+
+void __ndelay(unsigned long nsecs)
+{
+	__const_udelay(nsecs * 0x5UL); /* 2**32 / 1000000000 (rounded up) */
+}
+EXPORT_SYMBOL(__ndelay);
arch/csky/lib/memset.c new file +38 -0
new file mode 100644
index 0000000..b7897af
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/types.h>
+
+void *memset(void *dest, int c, size_t l)
+{
+	char *d = dest;
+	int ch = c;
+	int tmp;
+
+	if ((long)d & 0x3)
+		while (l--) *d++ = ch;
+	else {
+		ch &= 0xff;
+		tmp = (ch | ch << 8 | ch << 16 | ch << 24);
+
+		while (l >= 16) {
+			*(((long *)d)) = tmp;
+			*(((long *)d)+1) = tmp;
+			*(((long *)d)+2) = tmp;
+			*(((long *)d)+3) = tmp;
+			l -= 16;
+			d += 16;
+		}
+
+		while (l > 3) {
+			*(((long *)d)) = tmp;
+			d = d + 4;
+			l -= 4;
+		}
+
+		while (l) {
+			*d++ = ch;
+			l--;
+		}
+	}
+	return dest;
+}
arch/csky/lib/usercopy.c new file +271 -0

271 lines not on this page · raw message

arch/csky/oprofile/init.c new file +16 -0
new file mode 100644
index 0000000..413ad18
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#include <linux/kernel.h>
+#include <linux/oprofile.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+
+int __init oprofile_arch_init(struct oprofile_operations *ops)
+{
+	return oprofile_perf_init(ops);
+}
+
+void oprofile_arch_exit(void)
+{
+	oprofile_perf_exit();
+}
Signature · 1 line
2.7.4
author
#20 lore raw

PATCH 12/19 csky: Debug and Ptrace GDB

In reply to Guo Ren
---
 arch/csky/include/uapi/asm/ptrace.h |  97 +++++++++++
 arch/csky/kernel/dumpstack.c        |  65 +++++++
 arch/csky/kernel/ptrace.c           | 339 ++++++++++++++++++++++++++++++++++++
 3 files changed, 501 insertions(+)
 create mode 100644 arch/csky/include/uapi/asm/ptrace.h
 create mode 100644 arch/csky/kernel/dumpstack.c
 create mode 100644 arch/csky/kernel/ptrace.c
arch/csky/include/uapi/asm/ptrace.h new file +97 -0
new file mode 100644
index 0000000..b8516b2
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef _CSKY_PTRACE_H
+#define _CSKY_PTRACE_H
+
+#define REGNO_SR   	32
+#define REGNO_PC   	33
+
+#ifndef __ASSEMBLY__
+
+/* this struct defines the way the registers are stored on the
+   stack during a system call. */
+struct  pt_regs {
+	unsigned long    pc;
+	long             orig_a0;
+	unsigned long    sr;
+	long             a0;  // ABIV2: r0, ABIV1: r2
+	long             a1;  // ABIV2: r1, ABIV1: r3
+	long             a2;  // ABIV2: r2, ABIV1: r4
+	long             a3;  // ABIV2: r3, ABIV1: r5
+	// ABIV2: r4 ~ r13,  ABIV1: r6 ~ r14, r1.
+	long             regs[10];
+	long             r15;
+#if defined(__CSKYABIV2__)
+	// r16~r31;
+	long             exregs[16];
+	long             rhi;
+	long             rlo;
+#endif
+};
+
+/*
+ * Switch stack for switch_to after push pt_regs.
+ *
+ * ABI_CSKYV2: r4 ~ r11, r15 ~ r17, r26 ~ r30;
+ * ABI_CSKYV1: r8 ~ r14, r15;
+ */
+struct  switch_stack {
+#if defined(__CSKYABIV2__)
+	unsigned long   r4;
+        unsigned long   r5;
+        unsigned long   r6;
+        unsigned long   r7;
+	unsigned long   r8;
+        unsigned long   r9;
+        unsigned long   r10;
+        unsigned long   r11;
+#else
+	unsigned long   r8;
+        unsigned long   r9;
+        unsigned long   r10;
+        unsigned long   r11;
+        unsigned long   r12;
+        unsigned long   r13;
+        unsigned long   r14;
+#endif
+        unsigned long   r15;
+#if defined(__CSKYABIV2__)
+        unsigned long   r16;
+        unsigned long   r17;
+        unsigned long   r26;
+        unsigned long   r27;
+        unsigned long   r28;
+        unsigned long   r29;
+        unsigned long   r30;
+#endif
+};
+
+#define PTRACE_GETREGS            12
+#define PTRACE_SETREGS            13
+#define PTRACE_GETFPREGS          14
+#define PTRACE_SETFPREGS          15
+#define PTRACE_GET_THREAD_AREA    25
+
+#define CSKY_GREG_NUM             35
+#define CSKY_FREG_NUM_HI          72
+#define CSKY_FREG_NUM_LO          40
+#define CSKY_FCR_NUM              74
+
+#ifdef __KERNEL__
+
+#define PS_S            0x80000000              /* Supervisor Mode */
+
+#define arch_has_single_step() (1)
+#define current_pt_regs() \
+	(struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1
+#define current_user_stack_pointer() rdusp()
+
+#define user_mode(regs) (!((regs)->sr & PS_S))
+#define instruction_pointer(regs) ((regs)->pc)
+#define profile_pc(regs) instruction_pointer(regs)
+
+void show_regs(struct pt_regs *);
+
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
+#endif /* _CSKY_PTRACE_H */
arch/csky/kernel/dumpstack.c new file +65 -0

65 lines not on this page · raw message

arch/csky/kernel/ptrace.c new file +339 -0

339 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#21 lore raw

Re: [PATCH 12/19] csky: Debug and Ptrace GDB

Quoted 11 lines · Guo Ren

+ */

arch/csky/kernel/ptrace.c new file +8 -0
+long arch_ptrace(struct task_struct *child, long request, unsigned long addr,
+               unsigned long data)
+{
+       unsigned long tmp = 0, ret = 0;
+       int i;
+
+       switch (request) {
+               /* read the word at location addr in the USER area. */

arch/csky/kernel/ptrace.c line 201

Quoted 10 lines
arch/csky/kernel/ptrace.c new file +7 -0
+       case PTRACE_PEEKUSR:
 
+
+       case PTRACE_POKEUSR:  /* write the word at location addr in the USER area */
 
+       case PTRACE_GETREGS:    /* Get all gp regs from the child. */
 
+       case PTRACE_SETREGS:    /* Set all gp regs in the child. */
+               for (i = 0; i <= CSKY_GREG_NUM; i++) {
+                       ret = get_user(tmp, (unsigned long *)data);

I think all of these should use the regset code like arch/riscv/kernel/ptrace.c does.

Arnd

author
#22 lore raw

PATCH 13/19 csky: User access

In reply to Guo Ren
---
 arch/csky/include/asm/uaccess.h | 408 ++++++++++++++++++++++++++++++++++++++++
 arch/csky/include/asm/user.h    | 102 ++++++++++
 2 files changed, 510 insertions(+)
 create mode 100644 arch/csky/include/asm/uaccess.h
 create mode 100644 arch/csky/include/asm/user.h
arch/csky/include/asm/uaccess.h new file +408 -0
new file mode 100644
index 0000000..b3c3599
@@ -0,0 +1,408 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_UACCESS_H
+#define __ASM_CSKY_UACCESS_H
+
+/*
+ * User space memory access functions
+ */
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/version.h>
+#include <asm/segment.h>
+
+#define VERIFY_READ	0
+#define VERIFY_WRITE	1
+
+static inline int access_ok(int type, const void * addr, unsigned long size)
+{
+    return (((unsigned long)addr < current_thread_info()->addr_limit.seg) &&
+              ((unsigned long)(addr + size) < current_thread_info()->addr_limit.seg));
+}
+
+static inline int verify_area(int type, const void * addr, unsigned long size)
+{
+    return access_ok(type, addr, size) ? 0 : -EFAULT;
+}
+
+#define __addr_ok(addr) (access_ok(VERIFY_READ, addr,0))
+
+extern int __put_user_bad(void);
+
+/*
+ * Tell gcc we read from memory instead of writing: this is because
+ * we do not write to any memory gcc knows about, so there are no
+ * aliasing issues.
+ */
+
+/*
+ * These are the main single-value transfer routines.  They automatically
+ * use the right size if we just have the right pointer type.
+ *
+ * This gets kind of ugly. We want to return _two_ values in "get_user()"
+ * and yet we don't want to do any pointers, because that is too much
+ * of a performance impact. Thus we have a few rather ugly macros here,
+ * and hide all the ugliness from the user.
+ *
+ * The "__xxx" versions of the user access functions are versions that
+ * do not verify the address space, that must have been done previously
+ * with a separate "access_ok()" call (this is used when we do multiple
+ * accesses to the same area of user memory).
+ *
+ * As we use the same address space for kernel and user data on
+ * Ckcore, we can just do these as direct assignments.  (Of course, the
+ * exception handling means that it's no longer "just"...)
+ */
+
+#define put_user(x,ptr) \
+  __put_user_check((x), (ptr), sizeof(*(ptr)))
+
+#define __put_user(x,ptr) \
+  __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
+
+#define __ptr(x) ((unsigned long *)(x))
+
+#define get_user(x,ptr) \
+  __get_user_check((x), (ptr), sizeof(*(ptr)))
+
+#define __get_user(x,ptr) \
+  __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
+
+#define __put_user_nocheck(x, ptr, size)                                \
+({                                                                      \
+	long __pu_err=0;                                                \
+	typeof(*(ptr)) *__pu_addr = (ptr);                              \
+	typeof(*(ptr)) __pu_val = (typeof(*(ptr)))(x);                  \
+	if(__pu_addr){                                                  \
+	    __put_user_size(__pu_val, (__pu_addr), (size), __pu_err);   \
+	}                                                               \
+	__pu_err;                                                       \
+})
+
+#define __put_user_check(x,ptr,size)                                    \
+({                                                                      \
+	long __pu_err = -EFAULT;                                        \
+	typeof(*(ptr)) *__pu_addr = (ptr);                              \
+	typeof(*(ptr)) __pu_val = (typeof(*(ptr)))(x);                  \
+	if (access_ok(VERIFY_WRITE, __pu_addr, size) && __pu_addr)      \
+		__put_user_size(__pu_val, __pu_addr, (size), __pu_err); \
+	__pu_err;                                                       \
+})
+
+#define __put_user_size(x,ptr,size,retval)                              \
+do {                                                                    \
+	retval = 0;                                                     \
+	switch (size) {                                                 \
+		case 1: __put_user_asm_b(x, ptr, retval); break;        \
+		case 2: __put_user_asm_h(x, ptr, retval); break;        \
+		case 4: __put_user_asm_w(x, ptr, retval); break;        \
+		case 8: __put_user_asm_64(x, ptr, retval); break;       \
+		default: __put_user_bad();                              \
+	}	                                                        \
+} while (0)
+
+/*
+ * We don't tell gcc that we are accessing memory, but this is OK
+ * because we do not write to any memory gcc knows about, so there
+ * are no aliasing issues.
+ *
+ * Note that PC at a fault is the address *after* the faulting
+ * instruction.
+ */
+#define __put_user_asm_b(x, ptr, err)                           \
+do{                                                             \
+	int errcode;                                            \
+	asm volatile(                                           \
+	         "1:     stb   %1, (%2,0)        \n"            \
+	         "       br    3f                \n"            \
+	         "2:     mov   %0, %3            \n"            \
+	         "       br    3f                \n"            \
+	         ".section __ex_table,\"a\"      \n"            \
+	         ".align   2                     \n"            \
+	         ".long    1b,2b                 \n"            \
+	         ".previous                      \n"            \
+	          "3:                            \n"            \
+	         : "=r"(err), "=r"(x), "=r"(ptr), "=r"(errcode) \
+	         : "0"(err), "1"(x), "2"(ptr), "3"(-EFAULT)     \
+	         : "memory");                                   \
+}while(0)
+
+#define __put_user_asm_h(x, ptr, err)                           \
+do{                                                             \
+	int errcode;                                            \
+	asm volatile(                                           \
+	         "1:     sth   %1, (%2,0)        \n"            \
+	         "       br    3f                \n"            \
+	         "2:     mov   %0, %3            \n"            \
+	         "       br    3f                \n"            \
+	         ".section __ex_table,\"a\"      \n"            \
+	         ".align   2                     \n"            \
+	         ".long    1b,2b                 \n"            \
+	         ".previous                      \n"            \
+	          "3:                            \n"            \
+	         :"=r"(err), "=r"(x), "=r"(ptr), "=r"(errcode)  \
+	         :"0"(err), "1"(x), "2"(ptr), "3"(-EFAULT)      \
+	         : "memory");                                   \
+}while(0)
+
+#define __put_user_asm_w(x, ptr, err)                           \
+do{                                                             \
+	int errcode;                                            \
+	asm volatile(                                           \
+	         "1:     stw   %1, (%2,0)        \n"            \
+	         "       br    3f                \n"            \
+	         "2:     mov   %0, %3            \n"            \
+	         "       br    3f                \n"            \
+	         ".section __ex_table,\"a\"      \n"            \
+	         ".align   2                     \n"            \
+	         ".long    1b,2b                 \n"            \
+	         ".previous                      \n"            \
+	          "3:                            \n"            \
+	         :"=r"(err), "=r"(x), "=r"(ptr), "=r"(errcode)  \
+	         :"0"(err), "1"(x), "2"(ptr), "3"(-EFAULT)      \
+	         : "memory");                                   \
+}while(0)
+
+
+#define __put_user_asm_64(x, ptr, err)                          \
+do{                                                             \
+	int tmp;                                                \
+	int errcode;                                            \
+	typeof(*(ptr)) src = ( typeof(*(ptr)))x;                \
+	typeof(*(ptr)) *psrc = &src;                            \
+	                                                        \
+	asm volatile(                                           \
+	        "     ldw     %3, (%1, 0)     \n"               \
+	        "1:   stw     %3, (%2, 0)     \n"               \
+	        "     ldw     %3, (%1, 4)     \n"               \
+	        "2:   stw     %3, (%2, 4)     \n"               \
+	        "     br      4f              \n"               \
+	        "3:   mov     %0, %4          \n"               \
+	        "     br      4f              \n"               \
+	        ".section __ex_table, \"a\"   \n"               \
+	        ".align   2                   \n"               \
+	        ".long    1b, 3b              \n"               \
+	        ".long    2b, 3b              \n"               \
+	        ".previous                    \n"               \
+	        "4:                           \n"               \
+	        :"=r"(err),"=r"(psrc),"=r"(ptr),"=r"(tmp),"=r"(errcode) \
+	        : "0"(err), "1"(psrc), "2"(ptr), "3"(0), "4"(-EFAULT) \
+	        : "memory" );                                   \
+}while (0)
+
+#define __get_user_nocheck(x, ptr, size)                        \
+({                                                              \
+	long  __gu_err;	                                        \
+	__get_user_size(x, (ptr), (size), __gu_err);            \
+	__gu_err;                                               \
+})
+
+#define __get_user_check(x, ptr, size)                          \
+({                                                              \
+	int __gu_err = -EFAULT;	                                \
+	const __typeof__(*(ptr)) __user * __gu_ptr = (ptr);     \
+	if (access_ok(VERIFY_READ, __gu_ptr, size) && __gu_ptr) \
+		__get_user_size(x, __gu_ptr, (size), __gu_err); \
+	__gu_err;                                               \
+})
+
+#define __get_user_size(x, ptr, size, retval)                   \
+do {                                                            \
+	switch (size) {                                         \
+		case 1: __get_user_asm_common((x),ptr,"ldb",retval); break; \
+		case 2: __get_user_asm_common((x),ptr,"ldh",retval); break; \
+		case 4: __get_user_asm_common((x),ptr,"ldw",retval); break; \
+		default:                                        \
+			x=0;                                    \
+			(retval) = __get_user_bad();            \
+	}                                                       \
+} while (0)
+
+#define __get_user_asm_common(x, ptr, ins, err)                 \
+do{                                                             \
+	int errcode;                                            \
+	asm volatile(                                           \
+	        "1:   " ins "   %1, (%4,0)      \n"             \
+	        "       br    3f                \n"             \
+	        /* Fix up codes */                              \
+	        "2:     mov   %0, %2            \n"             \
+	        "       movi  %1, 0             \n"             \
+	        "       br    3f                \n"             \
+	        ".section __ex_table,\"a\"      \n"             \
+	        ".align   2                     \n"             \
+	        ".long    1b,2b                 \n"             \
+	        ".previous                      \n"             \
+	        "3:                            \n"              \
+	        :"=r"(err), "=r"(x), "=r"(errcode)              \
+	        :"0"(0), "r"(ptr), "2"(-EFAULT)                 \
+	        : "memory");                                    \
+}while(0)
+
+extern int __get_user_bad(void);
+
+#define __copy_user(to, from, n)                                \
+do{                                                             \
+	int w0, w1, w2, w3;                                     \
+	asm volatile(                                           \
+		"0:     cmpnei  %1, 0           \n"             \
+		"       bf      8f              \n"             \
+		"       mov     %3, %1          \n"             \
+		"       or      %3, %2          \n"             \
+		"       andi    %3, 3           \n"             \
+		"       cmpnei  %3, 0           \n"             \
+		"       bf      1f              \n"             \
+		"       br      5f              \n"             \
+		"1:     cmplti  %0, 16          \n"   /* 4W */  \
+		"       bt      3f              \n"             \
+		"       ldw     %3, (%2, 0)     \n"             \
+		"       ldw     %4, (%2, 4)     \n"             \
+		"       ldw     %5, (%2, 8)     \n"             \
+		"       ldw     %6, (%2, 12)    \n"             \
+		"2:     stw     %3, (%1, 0)     \n"             \
+		"9:     stw     %4, (%1, 4)     \n"             \
+		"10:    stw     %5, (%1, 8)     \n"             \
+		"11:    stw     %6, (%1, 12)    \n"             \
+		"       addi    %2, 16          \n"             \
+		"       addi    %1, 16          \n"             \
+		"       subi    %0, 16          \n"             \
+		"       br      1b              \n"             \
+		"3:     cmplti  %0, 4           \n"  /* 1W */   \
+		"       bt      5f              \n"             \
+		"       ldw     %3, (%2, 0)     \n"             \
+		"4:     stw     %3, (%1, 0)     \n"             \
+		"       addi    %2, 4           \n"             \
+		"       addi    %1, 4           \n"             \
+		"       subi    %0, 4           \n"             \
+		"       br      3b              \n"             \
+		"5:     cmpnei  %0, 0           \n"  /* 1B */   \
+		"       bf      8f              \n"             \
+		"       ldb     %3, (%2, 0)     \n"             \
+		"6:     stb     %3, (%1, 0)     \n"             \
+		"       addi    %2,  1          \n"             \
+		"       addi    %1,  1          \n"             \
+		"       subi    %0,  1          \n"             \
+		"       br      5b              \n"             \
+		"7:     br      8f              \n"             \
+		".section __ex_table, \"a\"     \n"             \
+		".align   2                     \n"             \
+		".long    2b, 7b                \n"             \
+		".long    9b, 7b                \n"             \
+		".long   10b, 7b                \n"             \
+		".long   11b, 7b                \n"             \
+		".long    4b, 7b                \n"             \
+		".long    6b, 7b                \n"             \
+		".previous                      \n"             \
+		"8:                             \n"             \
+	        : "=r"(n), "=r"(to), "=r"(from), "=r"(w0), "=r"(w1), "=r"(w2), "=r"(w3)   \
+		: "0"(n), "1"(to), "2"(from)                    \
+		: "memory" );                                   \
+} while (0)
+
+#define __copy_user_zeroing(to, from, n) \
+do{                                                             \
+	int tmp;                                                \
+	int nsave;                                              \
+	asm volatile(                                           \
+		"0:     cmpnei  %1, 0           \n"             \
+		"       bf      7f              \n"             \
+		"       mov     %3, %1          \n"             \
+		"       or      %3, %2          \n"             \
+		"       andi    %3, 3           \n"             \
+		"       cmpnei  %3, 0           \n"             \
+		"       bf      1f              \n"             \
+		"       br      5f              \n"             \
+		"1:     cmplti  %0, 16          \n"   /* 4W */  \
+		"       bt      3f              \n"             \
+		"2:     ldw     %3, (%2, 0)     \n"             \
+		"10:    ldw     %4, (%2, 4)     \n"             \
+		"       stw     %3, (%1, 0)     \n"             \
+		"       stw     %4, (%1, 4)     \n"             \
+		"11:    ldw     %3, (%2, 8)     \n"             \
+		"12:    ldw     %4, (%2, 12)    \n"             \
+		"       stw     %3, (%1, 8)     \n"             \
+		"       stw     %4, (%1, 12)    \n"             \
+		"       addi    %2, 16          \n"             \
+		"       addi    %1, 16          \n"             \
+		"       subi    %0, 16          \n"             \
+		"       br      1b              \n"             \
+		"3:     cmplti  %0, 4           \n"  /* 1W */   \
+		"       bt      5f              \n"             \
+		"4:     ldw     %3, (%2, 0)     \n"             \
+		"       stw     %3, (%1, 0)     \n"             \
+		"       addi    %2, 4           \n"             \
+		"       addi    %1, 4           \n"             \
+		"       subi    %0, 4           \n"             \
+		"       br      3b              \n"             \
+		"5:     cmpnei  %0, 0           \n"  /* 1B */   \
+		"       bf      7f              \n"             \
+		"6:     ldb     %3, (%2, 0)     \n"             \
+		"       stb     %3, (%1, 0)     \n"             \
+		"       addi    %2,  1          \n"             \
+		"       addi    %1,  1          \n"             \
+		"       subi    %0,  1          \n"             \
+		"       br      5b              \n"             \
+		"8:     mov     %3, %0          \n" /* zero */  \
+		"       movi    %4, 0           \n"             \
+		"9:     stb     %4, (%1, 0)     \n"             \
+		"       addi    %1, 1           \n"             \
+		"       subi    %3, 1           \n"             \
+		"       cmpnei  %3, 0           \n"             \
+		"       bt      9b              \n"             \
+		"       br      7f              \n"             \
+		".section __ex_table, \"a\"     \n"             \
+		".align   2                     \n"             \
+		".long    2b, 8b                \n"             \
+		".long   10b, 8b                \n"             \
+		".long   11b, 8b                \n"             \
+		".long   12b, 8b                \n"             \
+		".long    4b, 8b                \n"             \
+		".long    6b, 8b                \n"             \
+		".previous                      \n"             \
+		"7:                             \n"             \
+		: "=r"(n), "=r"(to), "=r"(from), "=r"(nsave), "=r"(tmp)   \
+		: "0"(n), "1"(to), "2"(from)                    \
+		: "memory" );                                   \
+} while (0)
+
+unsigned long raw_copy_from_user(void *to, const void *from, unsigned long n);
+unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
+
+#ifdef COMPAT_KERNEL_4_9
+#define __copy_from_user(to, from, n) raw_copy_from_user(to, from, n)
+#define __copy_to_user(to, from, n) raw_copy_to_user(to, from, n)
+
+#define __copy_from_user_inatomic	__copy_from_user
+#define __copy_to_user_inatomic		__copy_to_user
+
+#define copy_from_user			__copy_from_user
+#define copy_to_user			__copy_to_user
+#endif
+
+unsigned long clear_user(void *to, unsigned long n);
+unsigned long __clear_user(void __user *to, unsigned long n);
+
+long strncpy_from_user(char *dst, const char *src, long count);
+long __strncpy_from_user(char *dst, const char *src, long count);
+
+/*
+ * Return the size of a string (including the ending 0)
+ *
+ * Return 0 on exception, a value greater than N if too long
+ */
+long strnlen_user(const char *src, long n);
+
+#define strlen_user(str) strnlen_user(str, 32767)
+
+struct exception_table_entry
+{
+	unsigned long insn;
+	unsigned long nextinsn;
+};
+
+extern int fixup_exception(struct pt_regs *regs);
+
+#endif /* __ASM_CSKY_UACCESS_H */
arch/csky/include/asm/user.h new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#23 lore raw

PATCH 14/19 csky: Misc headers

In reply to Guo Ren
---
 arch/csky/abiv1/inc/abi/reg_ops.h      |  79 +++++++++
 arch/csky/abiv1/inc/abi/regdef.h       |  27 +++
 arch/csky/abiv2/inc/abi/fpu.h          | 296 +++++++++++++++++++++++++++++++++
 arch/csky/abiv2/inc/abi/reg_ops.h      |  86 ++++++++++
 arch/csky/abiv2/inc/abi/regdef.h       |  28 ++++
 arch/csky/include/uapi/asm/byteorder.h |  14 ++
 arch/csky/include/uapi/asm/fcntl.h     |  13 ++
 arch/csky/include/uapi/asm/stat.h      |  86 ++++++++++
 8 files changed, 629 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/reg_ops.h
 create mode 100644 arch/csky/abiv1/inc/abi/regdef.h
 create mode 100644 arch/csky/abiv2/inc/abi/fpu.h
 create mode 100644 arch/csky/abiv2/inc/abi/reg_ops.h
 create mode 100644 arch/csky/abiv2/inc/abi/regdef.h
 create mode 100644 arch/csky/include/uapi/asm/byteorder.h
 create mode 100644 arch/csky/include/uapi/asm/fcntl.h
 create mode 100644 arch/csky/include/uapi/asm/stat.h
arch/csky/abiv1/inc/abi/reg_ops.h new file +79 -0
new file mode 100644
index 0000000..224acff
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_REG_OPS_H
+#define __ASM_REG_OPS_H
+
+static inline unsigned int mfcr_cpuidrr(void)
+{
+	unsigned int ret;
+	asm volatile(
+		"mfcr %0, cr13\t\n"
+		:"=r"(ret));
+	return ret;
+}
+
+static inline unsigned int mfcr_hint(void)
+{
+	unsigned int ret;
+	asm volatile(
+		"mfcr %0, cr30\t\n"
+		:"=r"(ret));
+	return ret;
+}
+
+static inline unsigned int mfcr_ccr(void)
+{
+	unsigned int ret;
+	asm volatile(
+		"mfcr %0, cr18\t\n"
+		:"=r"(ret));
+	return ret;
+}
+
+static inline unsigned int mfcr_msa0(void)
+{
+	unsigned int ret;
+	asm volatile(
+		"cprcr %0, cpcr30\t\n"
+		:"=r"(ret));
+	return ret;
+}
+
+static inline void mtcr_msa0(unsigned int value)
+{
+	asm volatile(
+		"cpwcr %0, cpcr30\t\n"
+		::"r"(value));
+}
+
+static inline unsigned int mfcr_msa1(void)
+{
+	unsigned int ret;
+	asm volatile(
+		"cprcr %0, cpcr31\t\n"
+		:"=r"(ret));
+	return ret;
+}
+
+static inline void mtcr_msa1(unsigned int value)
+{
+	asm volatile(
+		"cpwcr %0, cpcr31\t\n"
+		::"r"(value));
+}
+
+static inline unsigned int mfcr_ccr2(void){return 0;}
+
+/* read/write user stack pointer */
+static inline unsigned long rdusp(void) {
+	register unsigned long usp;
+	asm volatile("mfcr %0, ss1\n\r":"=r"(usp));
+	return usp;
+}
+
+static inline void wrusp(unsigned long usp) {
+	asm volatile("mtcr %0, ss1\n\r"::"r"(usp));
+}
+
+#endif /* __ASM_REG_OPS_H */
+
arch/csky/abiv1/inc/abi/regdef.h new file +27 -0
new file mode 100644
index 0000000..f694e8e
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef  __ASM_CSKY_REGDEF_H
+#define  __ASM_CSKY_REGDEF_H
+
+#define syscallid	r1
+#define r11_sig		r11
+
+#define DEFAULT_PSR_VALUE	0x8f000000
+
+#define PTRACE_REGOFF_ABI \
+{ \
+	-1,       PT_REGS9,  PT_A0,    PT_A1,\
+	PT_A2,    PT_A3,     PT_REGS0, PT_REGS1,\
+	PT_REGS2, PT_REGS3,  PT_REGS4, PT_REGS5,\
+	PT_REGS6, PT_REGS7,  PT_REGS8, PT_R15,\
+	-1,       -1,        -1,       -1,\
+	-1,       -1,        -1,       -1,\
+	-1,       -1,        -1,       -1,\
+	-1,       -1,        -1,       -1,\
+	PT_SR,    PT_PC,     -1,       -1,\
+}
+
+#define SYSTRACE_SAVENUM	2
+#define REGNO_USP		0
+
+#endif /* __ASM_CSKY_REGDEF_H */
arch/csky/abiv2/inc/abi/fpu.h new file +296 -0

296 lines not on this page · raw message

arch/csky/abiv2/inc/abi/reg_ops.h new file +86 -0

86 lines not on this page · raw message

arch/csky/abiv2/inc/abi/regdef.h new file +28 -0
new file mode 100644
index 0000000..11bdc3a
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef  __ASM_CSKY_REGDEF_H
+#define  __ASM_CSKY_REGDEF_H
+
+#define syscallid	r7
+#define r11_sig		r11
+
+#define DEFAULT_PSR_VALUE	0x8f000200
+
+#define PTRACE_REGOFF_ABI \
+{ \
+	PT_A0,    PT_A1,     PT_A2,    PT_A3,\
+	PT_REGS0, PT_REGS1,  PT_REGS2, PT_REGS3,\
+	PT_REGS4, PT_REGS5,  PT_REGS6, PT_REGS7,\
+	PT_REGS8, PT_REGS9,  -1,       PT_R15,\
+	PT_R16,   PT_R17,    PT_R18,   PT_R19,\
+	PT_R20,   PT_R21,    PT_R22,   PT_R23,\
+	PT_R24,   PT_R25,    PT_R26,   PT_R27,\
+	PT_R28,   PT_R29,    PT_R30,   PT_R31,\
+	PT_SR,    PT_PC,     PT_RHI,   PT_RLO,\
+}
+
+#define SYSTRACE_SAVENUM	5
+
+#define REGNO_USP		14
+
+#endif /* __ASM_CSKY_REGDEF_H */
arch/csky/include/uapi/asm/byteorder.h new file +14 -0
new file mode 100644
index 0000000..d254522
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_BYTEORDER_H
+#define __ASM_CSKY_BYTEORDER_H
+
+#if defined(__cskyBE__)
+#include <linux/byteorder/big_endian.h>
+#elif defined(__cskyLE__)
+#include <linux/byteorder/little_endian.h>
+#else
+# error "There is no __cskyBE__, __cskyLE__"
+#endif
+
+#endif /* __ASM_CSKY_BYTEORDER_H */
arch/csky/include/uapi/asm/fcntl.h new file +13 -0
new file mode 100644
index 0000000..2ee1af2
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_FCNTL_H
+#define __ASM_CSKY_FCNTL_H
+
+#define O_DIRECTORY	040000
+#define O_NOFOLLOW	0100000
+#define O_DIRECT	0200000
+#define O_LARGEFILE	0400000
+
+#include <asm-generic/fcntl.h>
+
+#endif /* __ASM_CSKY_FCNTL_H */
arch/csky/include/uapi/asm/stat.h new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#24 lore raw

Re: [PATCH 14/19] csky: Misc headers

arch/csky/include/uapi/asm/fcntl.h line 11

Quoted 13 lines · Guo Ren

+++ b/arch/csky/include/uapi/asm/fcntl.h

arch/csky/include/uapi/asm/fcntl.h new file +11 -0
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_FCNTL_H
+#define __ASM_CSKY_FCNTL_H
+
+#define O_DIRECTORY    040000
+#define O_NOFOLLOW     0100000
+#define O_DIRECT       0200000
+#define O_LARGEFILE    0400000
+
+#include <asm-generic/fcntl.h>

This should just use the generic file without overrides: Please don't diverge from the generic syscall ABI.

arch/csky/include/uapi/asm/stat.h line 7

Quoted 10 lines
arch/csky/include/uapi/asm/stat.h new file +7 -0
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef _CSKY_STAT_H
+#define _CSKY_STAT_H
+
+struct __old_kernel_stat {
+       unsigned short st_dev;

Same here: no need for __old_kernel_stat or the headers on new architectures.

Arnd

author
#25 lore raw

Re: [PATCH 14/19] csky: Misc headers

Hi Arnd,

Quoted 18 lines · Arnd Bergmann

arch/csky/include/uapi/asm/fcntl.h line 11

Quoted 13 lines · Guo Ren

+++ b/arch/csky/include/uapi/asm/fcntl.h

arch/csky/include/uapi/asm/fcntl.h new file +11 -0
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_FCNTL_H
+#define __ASM_CSKY_FCNTL_H
+
+#define O_DIRECTORY    040000
+#define O_NOFOLLOW     0100000
+#define O_DIRECT       0200000
+#define O_LARGEFILE    0400000
+
+#include <asm-generic/fcntl.h>

This should just use the generic file without overrides: Please don't diverge from the generic syscall ABI.

It's a stupid copy from arm/include/uapi/asm/fcntl.h and the csky/bits/fcntl.h in uclibc-ng and glibc are also defined with:

#define __O_DIRECTORY 040000 /* Must be a directory. */
#define __O_NOFOLLOW 0100000 /* Do not follow links. */
#define __O_DIRECT 0200000 /* Direct disk access. */
#define __O_LARGEFILE 0400000

So may I keep it for a while?
(I will let glibc uclibc-ng csky/bits/fcntl.h include the linux/uapi/asm/fcntl.h first.)

Quoted 5 lines

Review line 13

Quoted 2 lines
(quoted diff) +2 -0
+struct __old_kernel_stat {
+       unsigned short st_dev;

Same here: no need for __old_kernel_stat or the headers on new architectures.

OK

Best Regards
Guo Ren

maintainer
#26 lore raw

Re: [PATCH 14/19] csky: Misc headers

Quoted 25 lines · Guo Ren

Hi Arnd,

Quoted 18 lines · Arnd Bergmann

arch/csky/include/uapi/asm/fcntl.h line 11

Quoted 13 lines · Guo Ren

+++ b/arch/csky/include/uapi/asm/fcntl.h

arch/csky/include/uapi/asm/fcntl.h new file +11 -0
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+#ifndef __ASM_CSKY_FCNTL_H
+#define __ASM_CSKY_FCNTL_H
+
+#define O_DIRECTORY    040000
+#define O_NOFOLLOW     0100000
+#define O_DIRECT       0200000
+#define O_LARGEFILE    0400000
+
+#include <asm-generic/fcntl.h>

This should just use the generic file without overrides: Please don't diverge from the generic syscall ABI.

It's a stupid copy from arm/include/uapi/asm/fcntl.h and the csky/bits/fcntl.h in uclibc-ng and glibc are also defined with:

Quoted 8 lines

#define __O_DIRECTORY 040000 /* Must be a directory. */

#define __O_NOFOLLOW    0100000 /* Do not follow links.  */
#define __O_DIRECT      0200000 /* Direct disk access.  */
#define __O_LARGEFILE   0400000

So may I keep it for a while?
(I will let glibc uclibc-ng csky/bits/fcntl.h include the linux/uapi/asm/fcntl.h first.)

We generally assume that any upstream kernel ABI cannot be changed, so this has to be changed before the code gets merged upstream.

You can obviously maintain the old and the new ABI in parallel for a while, until the libc supports the new ABI, but you can't do that in the patches you send for integration.

This is more important for the list of system calls, but when you change the ABI, it should be changed all at once.

Arnd

author
#27 lore raw

Re: [PATCH 14/19] csky: Misc headers

Quoted 9 lines · Arnd Bergmann

We generally assume that any upstream kernel ABI cannot be changed, so this has to be changed before the code gets merged upstream.

You can obviously maintain the old and the new ABI in parallel for a while, until the libc supports the new ABI, but you can't do that in the patches you send for integration.

This is more important for the list of system calls, but when you change the ABI, it should be changed all at once.

Ok, follow the rules. I will modify uclibc-ng and glibc now.

author
#28 lore raw

PATCH 15/19 csky: Build infrastructure

In reply to Guo Ren
---
 arch/csky/Kconfig                 | 203 ++++++++++++++++++++++++++++++++++++++
 arch/csky/Kconfig.debug           |  22 +++++
 arch/csky/Makefile                |  92 +++++++++++++++++
 arch/csky/abiv1/Makefile          |   8 ++
 arch/csky/abiv2/Makefile          |   3 +
 arch/csky/boot/Makefile           |  25 +++++
 arch/csky/boot/dts/Makefile       |  14 +++
 arch/csky/include/asm/Kbuild      |  71 +++++++++++++
 arch/csky/include/uapi/asm/Kbuild |  30 ++++++
 arch/csky/kernel/Makefile         |   8 ++
 arch/csky/kernel/vmlinux.lds.S    |  67 +++++++++++++
 arch/csky/lib/Makefile            |   1 +
 arch/csky/mm/Makefile             |  13 +++
 arch/csky/oprofile/Makefile       |  13 +++
 14 files changed, 570 insertions(+)
 create mode 100644 arch/csky/Kconfig
 create mode 100644 arch/csky/Kconfig.debug
 create mode 100644 arch/csky/Makefile
 create mode 100644 arch/csky/abiv1/Makefile
 create mode 100644 arch/csky/abiv2/Makefile
 create mode 100644 arch/csky/boot/Makefile
 create mode 100644 arch/csky/boot/dts/Makefile
 create mode 100644 arch/csky/include/asm/Kbuild
 create mode 100644 arch/csky/include/uapi/asm/Kbuild
 create mode 100644 arch/csky/kernel/Makefile
 create mode 100644 arch/csky/kernel/vmlinux.lds.S
 create mode 100644 arch/csky/lib/Makefile
 create mode 100644 arch/csky/mm/Makefile
 create mode 100644 arch/csky/oprofile/Makefile
arch/csky/Kconfig new file +203 -0
new file mode 100644
index 0000000..694c1f8
@@ -0,0 +1,203 @@
+config CSKY
+	bool
+	default y
+	select ARCH_USE_BUILTIN_BSWAP
+	select ARCH_WANT_IPC_PARSE_VERSION
+	select COMMON_CLK
+	select CLKSRC_MMIO
+	select CLKSRC_OF
+	select DW_APB_TIMER_OF
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_CPU_DEVICES
+	select GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_SHOW
+	select GENERIC_SCHED_CLOCK
+	select HAVE_GENERIC_DMA_COHERENT
+	select HAVE_KERNEL_GZIP
+	select HAVE_KERNEL_LZO
+	select HAVE_KERNEL_LZMA
+	select HAVE_OPROFILE
+	select HAVE_PERF_EVENTS
+	select HAVE_C_RECORDMCOUNT
+	select HAVE_KPROBES
+	select HAVE_KRETPROBES
+	select HAVE_DMA_API_DEBUG
+	select HAVE_MEMBLOCK
+	select MAY_HAVE_SPARSE_IRQ
+	select MODULES_USE_ELF_REL if MODULES
+	select MODULES_USE_ELF_RELA if MODULES
+	select NO_BOOTMEM
+	select OF
+	select OF_EARLY_FLATTREE
+	select OF_RESERVED_MEM
+	select OLD_SIGACTION
+	select OLD_SIGSUSPEND3
+	select PERF_USE_VMALLOC
+	select RTC_LIB
+	select USB_ARCH_HAS_EHCI
+	select USB_ARCH_HAS_OHCI
+
+config CPU_HAS_CACHEV2
+	bool
+	default n
+
+config CPU_HAS_HILO
+	bool
+	default n
+
+config CPU_HAS_TLBI
+	bool
+	default n
+
+config CPU_NEED_TLBSYNC
+	bool
+	default n
+
+config CPU_NEED_SOFTALIGN
+	bool
+	default n
+
+config HIGHMEM
+	bool
+	default n
+
+config HZ
+	int
+	default 100
+
+config GENERIC_CSUM
+	bool
+	default y
+
+config GENERIC_CALIBRATE_DELAY
+	bool
+	default y
+
+config GENERIC_HWEIGHT
+	bool
+	default y
+
+config MMU
+	bool
+	default y
+
+config NR_CPUS
+	int
+	default "1"
+
+config RWSEM_GENERIC_SPINLOCK
+	bool
+	default y
+
+config TIME_LOW_RES
+	bool
+	default y
+
+config TRACE_IRQFLAGS_SUPPORT
+	bool
+	default y
+
+source "init/Kconfig"
+
+source "kernel/Kconfig.freezer"
+
+menu "Processor type and features"
+
+comment "Processor type"
+
+choice
+        prompt "CPU MODEL"
+        default CPU_CK610
+
+config CPU_CK610
+        bool "CSKY CPU ck610"
+	select CPU_NEED_TLBSYNC
+	select CPU_NEED_SOFTALIGN
+
+config CPU_CK810
+        bool "CSKY CPU ck810"
+	select HIGHMEM
+	select CPU_HAS_HILO
+	select CPU_NEED_TLBSYNC
+
+config CPU_CK807
+        bool "CSKY CPU ck807"
+	select HIGHMEM
+	select CPU_HAS_HILO
+
+config CPU_CK860
+        bool "CSKY CPU ck860"
+	select HIGHMEM
+	select CPU_HAS_TLBI
+	select CPU_HAS_CACHEV2
+endchoice
+
+config CPU_TLB_SIZE
+	int
+	default "128"	if(CPU_CK610 || CPU_CK807 || CPU_CK810)
+	default "1024"	if(CPU_CK860)
+
+config L1_CACHE_SHIFT
+	int
+	default "4"	if(CPU_CK610)
+	default "5"	if(CPU_CK807 || CPU_CK810)
+	default "6"	if(CPU_CK860)
+
+menuconfig CPU_HAS_FPU
+	bool "CPU has FPU coprocessor"
+	depends on CPU_CK807 || CPU_CK810 || CPU_CK860
+	default n
+	help
+	  Floating-Point Coprocessor (FPC) is a coprocessor of CK serial processor.
+	  The function of FPC is to provide low-cost high-speed float point computation,
+	  which is full compliance with ANSI/IEEE Std 754, IEEE Standard for Binary
+	  Floating-Point Arithmetic.
+
+comment "*****System type*****"
+
+config SSEG0_BASE
+	hex "Direct mapping physical address"
+	default 0x0
+	help
+	  There are MSAx regs can be used to change the base physical address
+	  of direct mapping. The default base physical address is 0x0.
+
+config RAM_BASE
+	hex "DRAM base address offset from SSEG0_BASE, it must be the same with dts memory."
+	default 0x08000000
+
+config CSKY_NR_IRQS
+	int "NR_IRQS to max virtual interrupt numbers of the whole system"
+	range 64 8192
+	default "128"
+endmenu
+
+menu "Power management options"
+
+source "kernel/power/Kconfig"
+
+config ARCH_SUSPEND_POSSIBLE
+	bool y
+	default y
+endmenu
+
+source "mm/Kconfig"
+
+source "fs/Kconfig.binfmt"
+
+source "kernel/Kconfig.preempt"
+
+source "net/Kconfig"
+
+source "drivers/Kconfig"
+
+source "fs/Kconfig"
+
+source "arch/csky/Kconfig.debug"
+
+source "security/Kconfig"
+
+source "crypto/Kconfig"
+
+source "lib/Kconfig"
arch/csky/Kconfig.debug new file +22 -0
new file mode 100644
index 0000000..c202cfc
@@ -0,0 +1,22 @@
+menu "Kernel hacking"
+
+config CSKY_DEBUG_INFO
+	bool "Compile the kernel with debug info, just add -g"
+	depends on !DEBUG_INFO
+	help
+	  DEBUG_INFO and COMPILE_TEST is conflict, so we provide
+	  another way to support -g.
+	  Some drivers eg: DW_MMC need COMPILE_TEST for new cpu
+	  arch :(
+
+config CSKY_BUILTIN_DTB
+	bool "Use kernel builtin dtb"
+	default n
+
+config CSKY_BUILTIN_DTB_NAME
+	string "kernel builtin dtb name"
+	depends on CSKY_BUILTIN_DTB
+
+source "lib/Kconfig.debug"
+
+endmenu
arch/csky/Makefile new file +92 -0

92 lines not on this page · raw message

arch/csky/abiv1/Makefile new file +8 -0
new file mode 100644
index 0000000..d2cf365
@@ -0,0 +1,8 @@
+obj-y +=	src/bswapdi.o
+obj-y +=	src/bswapsi.o
+obj-y +=	src/cacheflush.o
+obj-y +=	src/memcpy.o
+obj-y +=	src/mmap.o
+
+obj-$(CONFIG_CPU_NEED_SOFTALIGN) +=	src/alignment.o
+
arch/csky/abiv2/Makefile new file +3 -0
new file mode 100644
index 0000000..97f3780
@@ -0,0 +1,3 @@
+obj-$(CONFIG_CPU_HAS_FPU)	+= src/fpu.o
+obj-y				+= src/memcpy.o
+
arch/csky/boot/Makefile new file +25 -0
new file mode 100644
index 0000000..c3301a8
@@ -0,0 +1,25 @@
+targets := Image zImage uImage
+targets += $(dtb-y)
+
+$(obj)/Image: vmlinux FORCE
+	$(call if_changed,objcopy)
+	@echo '  Kernel: $@ is ready'
+
+compress-$(CONFIG_KERNEL_GZIP) = gzip
+compress-$(CONFIG_KERNEL_LZO)  = lzo
+compress-$(CONFIG_KERNEL_LZMA) = lzma
+compress-$(CONFIG_KERNEL_XZ)   = xzkern
+compress-$(CONFIG_KERNEL_LZ4)  = lz4
+
+$(obj)/zImage:  $(obj)/Image FORCE
+	$(call if_changed,$(compress-y))
+	@echo '  Kernel: $@ is ready'
+
+UIMAGE_ARCH		= sandbox
+UIMAGE_COMPRESSION	= $(compress-y)
+UIMAGE_LOADADDR		= $(shell $(NM) vmlinux | awk '$$NF == "_start" {print $$1}')
+
+$(obj)/uImage: $(obj)/zImage
+	$(call if_changed,uimage)
+	@echo 'Image: $@ is ready'
+
arch/csky/boot/dts/Makefile new file +14 -0
new file mode 100644
index 0000000..9afc954
@@ -0,0 +1,14 @@
+dtstree	:= $(srctree)/$(src)
+
+ifdef CONFIG_CSKY_BUILTIN_DTB
+builtindtb-y := $(patsubst "%",%,$(CONFIG_CSKY_BUILTIN_DTB_NAME))
+dtb-y += $(builtindtb-y).dtb
+obj-y += $(builtindtb-y).dtb.o
+.SECONDARY: $(obj)/$(builtindtb-y).dtb.S
+else
+dtb-y := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
+endif
+
+always += $(dtb-y)
+clean-files += *.dtb *.dtb.S
+
arch/csky/include/asm/Kbuild new file +71 -0

71 lines not on this page · raw message

arch/csky/include/uapi/asm/Kbuild new file +30 -0
new file mode 100644
index 0000000..9668182
@@ -0,0 +1,30 @@
+include include/uapi/asm-generic/Kbuild.asm
+
+header-y += cachectl.h
+header-y += stat.h
+
+generic-y += auxvec.h
+generic-y += param.h
+generic-y += bpf_perf_event.h
+generic-y += errno.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += shmbuf.h
+generic-y += bitsperlong.h
+generic-y += mman.h
+generic-y += msgbuf.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += resource.h
+generic-y += sembuf.h
+generic-y += siginfo.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += statfs.h
+generic-y += setup.h
+generic-y += swab.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += types.h
+generic-y += ucontext.h
arch/csky/kernel/Makefile new file +8 -0
new file mode 100644
index 0000000..8df5fd9
@@ -0,0 +1,8 @@
+extra-y := head.o vmlinux.lds
+
+obj-y += entry.o atomic.o signal.o traps.o irq.o time.o vdso.o \
+	 power.o syscall.o platform.o syscall_table.o setup.o \
+	 cskyksyms.o process.o cpu-probe.o ptrace.o dumpstack.o
+
+obj-$(CONFIG_MODULES) += module.o
+
arch/csky/kernel/vmlinux.lds.S new file +67 -0

67 lines not on this page · raw message

arch/csky/lib/Makefile new file +1 -0
new file mode 100644
index 0000000..02aefbc
@@ -0,0 +1 @@
+lib-y  := memset.o usercopy.o delay.o
arch/csky/mm/Makefile new file +13 -0
new file mode 100644
index 0000000..c870eb3
@@ -0,0 +1,13 @@
+ifeq ($(CONFIG_CPU_HAS_CACHEV2),y)
+obj-y +=			cachev2.o
+else
+obj-y +=			cachev1.o
+endif
+
+obj-y +=			dma-mapping.o
+obj-y +=			fault.o
+obj-$(CONFIG_HIGHMEM) +=	highmem.o
+obj-y +=			init.o
+obj-y +=			ioremap.o
+obj-y +=			syscache.o
+obj-y +=			tlb.o
arch/csky/oprofile/Makefile new file +13 -0
new file mode 100644
index 0000000..8b93284
@@ -0,0 +1,13 @@
+obj-$(CONFIG_OPROFILE) += oprofile.o
+
+DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
+		oprof.o cpu_buffer.o buffer_sync.o \
+		event_buffer.o oprofile_files.o \
+		oprofilefs.o oprofile_stats.o \
+		timer_int.o )
+
+ifeq ($(CONFIG_HW_PERF_EVENTS),y)
+DRIVER_OBJS += $(addprefix ../../../drivers/oprofile/, oprofile_perf.o)
+endif
+
+oprofile-y := $(DRIVER_OBJS) init.o
Signature · 1 line
2.7.4
maintainer
#29 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

arch/csky/Kconfig line 5

Quoted 11 lines · Guo Ren
arch/csky/Kconfig new file +5 -0
new file mode 100644
index 0000000..694c1f8
@@ -0,0 +1,203 @@
+config CSKY
+       bool
+       default y
+       select ARCH_USE_BUILTIN_BSWAP
+       select ARCH_WANT_IPC_PARSE_VERSION

Drop ipc_parse_version here, it's only for old architectures.

arch/csky/Kconfig line 21

Quoted 2 lines
arch/csky/Kconfig new file +2 -0
+       select HAVE_OPROFILE
+       select HAVE_PERF_EVENTS

Do you still need oprofile when you have perf?

arch/csky/Kconfig line 29

Quoted 2 lines
arch/csky/Kconfig new file +2 -0
+       select MODULES_USE_ELF_REL if MODULES
+       select MODULES_USE_ELF_RELA if MODULES

You should only need one of these two.

arch/csky/Kconfig line 35

Quoted 2 lines
arch/csky/Kconfig new file +2 -0
+       select OLD_SIGACTION
+       select OLD_SIGSUSPEND3

These should not be needed.

arch/csky/Kconfig line 51

Quoted 11 lines
arch/csky/Kconfig new file +11 -0
+config CPU_HAS_CACHEV2
+       bool
+       default n
+
+config CPU_HAS_HILO
+       bool
+       default n
+
+config CPU_HAS_TLBI
+       bool
+       default n

'default n' is redundant and can be dropped.

arch/csky/Kconfig line 75

Quoted 3 lines
arch/csky/Kconfig new file +3 -0
+config GENERIC_CALIBRATE_DELAY
+       bool
+       default y

Does your architecture provide a reliable high-reslution clocksource? If yes, you
could use that for the delay, rather than a calibrated loop.

Quoted 16 lines
arch/csky/Kconfig new file +16 -0
+choice
+        prompt "CPU MODEL"
+        default CPU_CK610
+
+config CPU_CK610
+        bool "CSKY CPU ck610"
+       select CPU_NEED_TLBSYNC
+       select CPU_NEED_SOFTALIGN
+
+config CPU_CK810
+        bool "CSKY CPU ck810"
+       select HIGHMEM
+       select CPU_HAS_HILO
+       select CPU_NEED_TLBSYNC
+
+config CPU_CK807

arch/csky/Kconfig line 134

Quoted 10 lines
arch/csky/Kconfig new file +10 -0
+        bool "CSKY CPU ck807"
+       select HIGHMEM
+       select CPU_HAS_HILO
+
+config CPU_CK860
+        bool "CSKY CPU ck860"
+       select HIGHMEM
+       select CPU_HAS_TLBI
+       select CPU_HAS_CACHEV2
+endchoice

Why select 'HIGHMEM' based on the CPU type? You should only need it when you have more than 1GB of RAM, and it can be a performance problem when it's enabled without need.

Usually the kernel should allow multiple CPU types to be selected together, or ask for a "minimum architecture" level to be selected by allow newer cores to be used as a superset.

arch/csky/Kconfig line 145

Quoted 10 lines
arch/csky/Kconfig new file +10 -0
+config CPU_TLB_SIZE
+       int
+       default "128"   if(CPU_CK610 || CPU_CK807 || CPU_CK810)
+       default "1024"  if(CPU_CK860)
+
+config L1_CACHE_SHIFT
+       int
+       default "4"     if(CPU_CK610)
+       default "5"     if(CPU_CK807 || CPU_CK810)
+       default "6"     if(CPU_CK860)

I think you then need to reverse the order of the list here: When e.g. CK860 and CK810 are both enabled, L1_CACHE_SHIFT should be the largest possible size.

arch/csky/Kconfig line 168

Quoted 10 lines
arch/csky/Kconfig new file +10 -0
+config SSEG0_BASE
+       hex "Direct mapping physical address"
+       default 0x0
+       help
+         There are MSAx regs can be used to change the base physical address
+         of direct mapping. The default base physical address is 0x0.
+
+config RAM_BASE
+       hex "DRAM base address offset from SSEG0_BASE, it must be the same with dts memory."
+       default 0x08000000

To allow one kernel to run on multiple boards, it's better to detect these two at runtime.

arch/csky/Kconfig line 174

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config CSKY_NR_IRQS
+       int "NR_IRQS to max virtual interrupt numbers of the whole system"
+       range 64 8192
+       default "128"
+endmenu

This should no longer be needed, with the IRQ domain code, any number of interrupts
can be used without noticeable overhead.

arch/csky/Kconfig line 182

Quoted 7 lines
arch/csky/Kconfig new file +7 -0
+menu "Power management options"
+
+source "kernel/power/Kconfig"
+
+config ARCH_SUSPEND_POSSIBLE
+       bool y
+       default y

Make it either

def_bool y

or

bool
default y

arch/csky/Kconfig line 90

Quoted 7 lines
arch/csky/Kconfig new file +7 -0
+config CSKY_BUILTIN_DTB
+       bool "Use kernel builtin dtb"
+       default n
+
+config CSKY_BUILTIN_DTB_NAME
+       string "kernel builtin dtb name"
+       depends on CSKY_BUILTIN_DTB

It's generally better not to use a builtin dtb, but use the bootloader to pass a dtb.

If you need to support existing bootloaders, the best way is to allow appending the dtb to the kernel.

arch/csky/Kconfig line 93

Quoted 3 lines
arch/csky/Kconfig new file +3 -0
+ifeq ($(VERSION)_$(PATCHLEVEL), 4_9)
+COMPAT_KERNEL_4_9 = -DCOMPAT_KERNEL_4_9
+endif

Should not be needed

arch/csky/Kconfig line 94

Quoted 1 line
arch/csky/Kconfig new file +1 -0
+KBUILD_CFLAGS +=       -ffreestanding \

-ffreestanding usually results in worse code and should not be needed

arch/csky/Kconfig line 97

Quoted 3 lines
arch/csky/Kconfig new file +3 -0
+                       -fno-tree-dse \
+                       -pipe \
+                       -Wno-uninitialized \

For -Wno-uninitialized, better fix the bugs properly. Can you explain why you want
-fno-tree-dse?

arch/csky/Kconfig line 7

Quoted 9 lines
arch/csky/Kconfig new file +8 -0
+++ b/arch/csky/abiv1/Makefile
@@ -0,0 +1,8 @@
+obj-y +=       src/bswapdi.o
+obj-y +=       src/bswapsi.o
+obj-y +=       src/cacheflush.o
+obj-y +=       src/memcpy.o
+obj-y +=       src/mmap.o
+
+obj-$(CONFIG_CPU_NEED_SOFTALIGN) +=    src/alignment.o

Better not use subdirectories like that.

Can you explain why you need the alignement fixups?

Arnd

author
#30 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Hi arnd,

Quoted 4 lines · Arnd Bergmann
Quoted 1 line

+ select ARCH_WANT_IPC_PARSE_VERSION

Drop ipc_parse_version here, it's only for old architectures.

I will remove it.

Quoted 4 lines

arch/csky/Kconfig line 21

Quoted 2 lines
arch/csky/Kconfig new file +2 -0
+       select HAVE_OPROFILE
+       select HAVE_PERF_EVENTS

Do you still need oprofile when you have perf?

I'll remove HAVE_OPROFILE and arch/csky/oprofile.

Quoted 4 lines

arch/csky/Kconfig line 29

Quoted 2 lines
arch/csky/Kconfig new file +2 -0
+       select MODULES_USE_ELF_REL if MODULES
+       select MODULES_USE_ELF_RELA if MODULES

You should only need one of these two.

Yes, I will keep RELA and current csky-gcc only give .rela section.

Quoted 4 lines

arch/csky/Kconfig line 35

Quoted 2 lines
arch/csky/Kconfig new file +2 -0
+       select OLD_SIGACTION
+       select OLD_SIGSUSPEND3

These should not be needed.

Ok, remove them.

Quoted 5 lines

arch/csky/Kconfig line 51

Quoted 3 lines
arch/csky/Kconfig new file +3 -0
+config CPU_HAS_TLBI
+       bool
+       default n

'default n' is redundant and can be dropped.

Ok

Quoted 7 lines

arch/csky/Kconfig line 75

Quoted 3 lines
arch/csky/Kconfig new file +3 -0
+config GENERIC_CALIBRATE_DELAY
+       bool
+       default y

Does your architecture provide a reliable high-reslution clocksource? If yes, you
could use that for the delay, rather than a calibrated loop.

Currently, all boards have clocksource drivers and the reslution is depend on SOC. I'll try to remove it.

Quoted 8 lines

arch/csky/Kconfig line 134

Quoted 4 lines
arch/csky/Kconfig new file +4 -0
+       select HIGHMEM
+       select CPU_HAS_TLBI
+       select CPU_HAS_CACHEV2
+endchoice

Why select 'HIGHMEM' based on the CPU type? You should only need it when you have more than 1GB of RAM, and it can be a performance problem when it's enabled without need.

OK, I'll give a HIGHMEM option.

Quoted 3 lines

Usually the kernel should allow multiple CPU types to be selected together, or ask for a "minimum architecture" level to be selected by allow newer cores to be used as a superset.

No, I need keep them seperate.

Quoted 6 lines
Quoted 6 lines
arch/csky/Kconfig new file +6 -0
+config CPU_TLB_SIZE
+       int
+       default "128"   if(CPU_CK610 || CPU_CK807 || CPU_CK810)
+       default "1024"  if(CPU_CK860)
+
+config L1_CACHE_SHIFT
Quoted 8 lines

arch/csky/Kconfig line 145

Quoted 4 lines
arch/csky/Kconfig new file +4 -0
+       int
+       default "4"     if(CPU_CK610)
+       default "5"     if(CPU_CK807 || CPU_CK810)
+       default "6"     if(CPU_CK860)

I think you then need to reverse the order of the list here: When e.g. CK860 and CK810 are both enabled, L1_CACHE_SHIFT should be the largest possible size.

No, I use L1_CACHE_SHIFT to determine the size of cache_line.
When I flush cache for a range of memory, I need the size to loop flush cache line.

Quoted 5 lines
Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config SSEG0_BASE
+       hex "Direct mapping physical address"
+       default 0x0
+       help
+         There are MSAx regs can be used to change the base physical address
Quoted 8 lines

arch/csky/Kconfig line 168

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+         of direct mapping. The default base physical address is 0x0.
+
+config RAM_BASE
+       hex "DRAM base address offset from SSEG0_BASE, it must be the same with dts memory."
+       default 0x08000000

To allow one kernel to run on multiple boards, it's better to detect these two at runtime.

CK-CPUs have a mips-like direct-mapping, and I use the macros to calculate the virtual-addr in headers.

Quoted 9 lines

arch/csky/Kconfig line 174

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config CSKY_NR_IRQS
+       int "NR_IRQS to max virtual interrupt numbers of the whole system"
+       range 64 8192
+       default "128"
+endmenu

This should no longer be needed, with the IRQ domain code, any number of interrupts
can be used without noticeable overhead.

Not I use it, some of our users need it to expand the GPIO irqs. Because they don't use irq domain code properly. I move it to Kconfig.debug, OK?

Quoted 8 lines

Make it either

def_bool y

or

bool
default y

OK

Quoted 11 lines

arch/csky/Kconfig.debug line 18

Quoted 7 lines
arch/csky/Kconfig.debug new file +7 -0
+config CSKY_BUILTIN_DTB
+       bool "Use kernel builtin dtb"
+       default n
+
+config CSKY_BUILTIN_DTB_NAME
+       string "kernel builtin dtb name"
+       depends on CSKY_BUILTIN_DTB

It's generally better not to use a builtin dtb, but use the bootloader to pass a dtb.

Quoted 2 lines

If you need to support existing bootloaders, the best way is to allow appending the dtb to the kernel.

Most of our boards use bootloader to pass the dtb, but Hangzhou Nationalchip want dtb compiled in the vmlinux. So I keep it in Kconfig.debug.

Quoted 5 lines

arch/csky/Makefile line 30

Quoted 3 lines
arch/csky/Makefile new file +3 -0
+ifeq ($(VERSION)_$(PATCHLEVEL), 4_9)
+COMPAT_KERNEL_4_9 = -DCOMPAT_KERNEL_4_9
+endif

Should not be needed

May I keep it? It's a very internal macro for arch/csky and I can maintain the linux-4.9 together.

Quoted 3 lines
Quoted 1 line

+KBUILD_CFLAGS += -ffreestanding \

-ffreestanding usually results in worse code and should not be needed

OK, remove it.

Quoted 6 lines

arch/csky/Makefile line 35

Quoted 3 lines
arch/csky/Makefile new file +3 -0
+                       -fno-tree-dse \
+                       -pipe \
+                       -Wno-uninitialized \

For -Wno-uninitialized, better fix the bugs properly. Can you explain why you want

It will mask some warnings :P, and I will remove it.

Quoted 1 line

-fno-tree-dse?

This is from "gcc-4.5 compile linux-4.7" and it will cause wrong code without -fno-tree-dse for list.h. Now we use gcc-6.3, so I will try to remove it.

Quoted 11 lines

arch/csky/abiv1/Makefile line 7

Quoted 9 lines

+++ b/arch/csky/abiv1/Makefile

arch/csky/abiv1/Makefile new file +7 -0
@@ -0,0 +1,8 @@
+obj-y +=       src/bswapdi.o
+obj-y +=       src/bswapsi.o
+obj-y +=       src/cacheflush.o
+obj-y +=       src/memcpy.o
+obj-y +=       src/mmap.o
+
+obj-$(CONFIG_CPU_NEED_SOFTALIGN) +=    src/alignment.o

Better not use subdirectories like that.

Ok, I will change them like this:
obj-y += bswapdi.o
obj-y += bswapsi.o
...

Quoted 1 line

Can you explain why you need the alignement fixups?

For abiv1 ck610 couldn't handle the unalignment address access, so we need soft-alignment exception to fixup. There is no problem in abiv2 cpus.

Best Regards
Guo Ren

maintainer
#31 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Quoted 8 lines · Guo Ren

Hi arnd,

Quoted 3 lines · Arnd Bergmann

Does your architecture provide a reliable high-reslution clocksource? If yes, you
could use that for the delay, rather than a calibrated loop.

Currently, all boards have clocksource drivers and the reslution is depend on SOC. I'll try to remove it.

If the clocksource depends on a driver rather than a feature of the architecture,
this may not be worth optimizing though, so maybe leave it as it is for now.

Quoted 4 lines
Quoted 3 lines

Usually the kernel should allow multiple CPU types to be selected together, or ask for a "minimum architecture" level to be selected by allow newer cores to be used as a superset.

No, I need keep them seperate.

Can you explain? What is it that makes them all incompatible?

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
arch/csky/Kconfig new file +6 -0
+config CPU_TLB_SIZE
+       int
+       default "128"   if(CPU_CK610 || CPU_CK807 || CPU_CK810)
+       default "1024"  if(CPU_CK860)
+
+config L1_CACHE_SHIFT
Quoted 8 lines

arch/csky/Kconfig line 145

Quoted 4 lines
arch/csky/Kconfig new file +4 -0
+       int
+       default "4"     if(CPU_CK610)
+       default "5"     if(CPU_CK807 || CPU_CK810)
+       default "6"     if(CPU_CK860)

I think you then need to reverse the order of the list here: When e.g. CK860 and CK810 are both enabled, L1_CACHE_SHIFT should be the largest possible size.

Quoted 2 lines

No, I use L1_CACHE_SHIFT to determine the size of cache_line.
When I flush cache for a range of memory, I need the size to loop flush cache line.

This is still relatively easy to fix, you just need a cpu specific loop that uses the actual line size rather than the maximum size.

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config SSEG0_BASE
+       hex "Direct mapping physical address"
+       default 0x0
+       help
+         There are MSAx regs can be used to change the base physical address
Quoted 8 lines

arch/csky/Kconfig line 168

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+         of direct mapping. The default base physical address is 0x0.
+
+config RAM_BASE
+       hex "DRAM base address offset from SSEG0_BASE, it must be the same with dts memory."
+       default 0x08000000

To allow one kernel to run on multiple boards, it's better to detect these two at runtime.

Quoted 2 lines

CK-CPUs have a mips-like direct-mapping, and I use the macros to calculate the virtual-addr in headers.

On many architectures, we detect the offsets at boot time and pass them as variables. On
ARM, we go as far as patching the kernel at boot time to have constant offsets, but usually
it's not worth the effort.

Quoted 11 lines
Quoted 9 lines

arch/csky/Kconfig line 174

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config CSKY_NR_IRQS
+       int "NR_IRQS to max virtual interrupt numbers of the whole system"
+       range 64 8192
+       default "128"
+endmenu

This should no longer be needed, with the IRQ domain code, any number of interrupts
can be used without noticeable overhead.

Not I use it, some of our users need it to expand the GPIO irqs. Because they don't use irq domain code properly. I move it to Kconfig.debug, OK?

It sounds like your GPIO driver should get fixed to use irq domains right, it should not be too hard. The number of GPIOs is typically a compile time constant today, but we also try to turn it into a dynamic allocation that we have for IRQs on most targets.

Quoted 11 lines
Quoted 11 lines

arch/csky/Kconfig.debug line 18

Quoted 7 lines
arch/csky/Kconfig.debug new file +7 -0
+config CSKY_BUILTIN_DTB
+       bool "Use kernel builtin dtb"
+       default n
+
+config CSKY_BUILTIN_DTB_NAME
+       string "kernel builtin dtb name"
+       depends on CSKY_BUILTIN_DTB

It's generally better not to use a builtin dtb, but use the bootloader to pass a dtb.

Quoted 5 lines
Quoted 2 lines

If you need to support existing bootloaders, the best way is to allow appending the dtb to the kernel.

Most of our boards use bootloader to pass the dtb, but Hangzhou Nationalchip want dtb compiled in the vmlinux. So I keep it in Kconfig.debug.

What I meant here is that you can get the same behavior by appending the dtb to the kernel rather than linking it into the kernel. The reason for preferring the appended one is that you can more easily use the same kernel binary across boards with different bootloaders.

Quoted 7 lines
Quoted 5 lines

arch/csky/Makefile line 30

Quoted 3 lines
arch/csky/Makefile new file +3 -0
+ifeq ($(VERSION)_$(PATCHLEVEL), 4_9)
+COMPAT_KERNEL_4_9 = -DCOMPAT_KERNEL_4_9
+endif

Should not be needed

May I keep it? It's a very internal macro for arch/csky and I can maintain the linux-4.9 together.

I'd say it's better to get rid of it for the upstream port, more importantly getting rid of the code that checks for this symbol. Usually what happens with version checks like this one is that they get out of sync quickly as a new kernel version does things differently and diverges more from the old release you were comparing against. In device drivers, we tend to remove all those checks.

Quoted 3 lines
Quoted 1 line

-fno-tree-dse?

This is from "gcc-4.5 compile linux-4.7" and it will cause wrong code without -fno-tree-dse for list.h. Now we use gcc-6.3, so I will try to remove it.

You can also use the cc-ifversion Makefile macro to apply it on the old compiler. That way you can still use gcc-4.5 as long as that remains relevant but don't get worse code generation on modern versions.

Quoted 11 lines
Quoted 11 lines

arch/csky/abiv1/Makefile line 7

Quoted 9 lines

+++ b/arch/csky/abiv1/Makefile

arch/csky/abiv1/Makefile new file +7 -0
@@ -0,0 +1,8 @@
+obj-y +=       src/bswapdi.o
+obj-y +=       src/bswapsi.o
+obj-y +=       src/cacheflush.o
+obj-y +=       src/memcpy.o
+obj-y +=       src/mmap.o
+
+obj-$(CONFIG_CPU_NEED_SOFTALIGN) +=    src/alignment.o

Better not use subdirectories like that.

Quoted 8 lines

Ok, I will change them like this:
obj-y += bswapdi.o
obj-y += bswapsi.o
...

Quoted 1 line

Can you explain why you need the alignement fixups?

For abiv1 ck610 couldn't handle the unalignment address access, so we need soft-alignment exception to fixup. There is no problem in abiv2 cpus.

Ok. Generally speaking, architectures that don't allow unaligned access should have all code built in a way that uses aligned access (gcc normally falls back to byte access when it encounters an unaligned pointer at compile time), but if this is just for old CPUs that are not used in future products, having the fixup does sound simpler, as it allows you to still run new binaries on the old machines. I haven't looked at the implementation for the fixup here, but I remember the same thing from the nds32 port. In that case, we ended up keeping the fixup as an option for old user space, but disabled to softalign fixups for kernel code. Can you do the same thing here?

Arnd

author
#32 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Hi arnd,

Quoted 4 lines · Arnd Bergmann

If the clocksource depends on a driver rather than a feature of the architecture,
this may not be worth optimizing though, so maybe leave it as it is for now.

Ok, I'll keep it.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Usually the kernel should allow multiple CPU types to be selected together, or ask for a "minimum architecture" level to be selected by allow newer cores to be used as a superset.

No, I need keep them seperate.

Can you explain? What is it that makes them all incompatible?

ck610 is abiv1 and its gcc is different from abiv2, they are:
- csky-linux-abiv1-gcc
- csky-linux-abiv2-gcc

ck807/810/860 use the same csky-linux-abiv2-gcc, but their instruction-sets and pipeline schedule are different. So our gcc must&only use '-mcpu=' to determine which cpu series is. They are different cpu series.

    ck610 only  have: ck610
    ck807 could have: ck807 ck807f ck807vf ck807ef
    ck810 could have: ck810 ck810f ck810vf ck810ef
    ck860 could have: ck860 ck860f ck860vf

f: means FPU co-processor
v: means VDSP co-processor just like "ARM-NEON"
e: is our old DSP co-processor which use HI-LO regs for operation. In current ck807/ck810 they default have HI-LO regs, so ck807&ck807e is the same for me.

For this patch-set, we support:
ck610
(ck807/ck807f/ck807ef)
(ck810/ck810e/ck810ef)

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

arch/csky/Kconfig line 145

Quoted 10 lines
arch/csky/Kconfig new file +10 -0
+config CPU_TLB_SIZE
+       int
+       default "128"   if(CPU_CK610 || CPU_CK807 || CPU_CK810)
+       default "1024"  if(CPU_CK860)
+
+config L1_CACHE_SHIFT
+       int
+       default "4"     if(CPU_CK610)
+       default "5"     if(CPU_CK807 || CPU_CK810)
+       default "6"     if(CPU_CK860)

I think you then need to reverse the order of the list here: When e.g. CK860 and CK810 are both enabled, L1_CACHE_SHIFT should be the largest possible size.

Quoted 5 lines
Quoted 2 lines

No, I use L1_CACHE_SHIFT to determine the size of cache_line.
When I flush cache for a range of memory, I need the size to loop flush cache line.

This is still relatively easy to fix, you just need a cpu specific loop that uses the actual line size rather than the maximum size.

Here is my cacheflush code in mm/cachev2.c:

	#define L1_CACHE_BYTES (1<<L1_CACHE_SHIFT)
	for(i=start; i<end; i+=L1_CACHE_BYTES)
		asm volatile("dcache.cval1 %0\n"::"r"(i));
	asm volatile("sync.is\n");

I use L1_CACHE_BYTES as the loop element to increase. So it must be the current CPU cache line size for "correct&performance". Each of our CPU-series has a fixed cache line size:
ck610 is 16Bytes
ck807/ck810 is 32Bytes
ck860 is 64Bytes
So I don't need determine them in .dts or detect on boot, just define them in Kconfig.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

arch/csky/Kconfig line 168

Quoted 10 lines
arch/csky/Kconfig new file +10 -0
+config SSEG0_BASE
+       hex "Direct mapping physical address"
+       default 0x0
+       help
+         There are MSAx regs can be used to change the base physical address
+         of direct mapping. The default base physical address is 0x0.
+
+config RAM_BASE
+       hex "DRAM base address offset from SSEG0_BASE, it must be the same with dts memory."
+       default 0x08000000

To allow one kernel to run on multiple boards, it's better to detect these two at runtime.

Quoted 8 lines
Quoted 2 lines

CK-CPUs have a mips-like direct-mapping, and I use the macros to calculate the virtual-addr in headers.

On many architectures, we detect the offsets at boot time and pass them as variables. On
ARM, we go as far as patching the kernel at boot time to have constant offsets, but usually
it's not worth the effort.

I know it's duplicate setting with dts for users. But now, I still want to keep them. I'll consider your advices in future.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

arch/csky/Kconfig line 174

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config CSKY_NR_IRQS
+       int "NR_IRQS to max virtual interrupt numbers of the whole system"
+       range 64 8192
+       default "128"
+endmenu

This should no longer be needed, with the IRQ domain code, any number of interrupts
can be used without noticeable overhead.

Quoted 7 lines
Quoted 2 lines

Not I use it, some of our users need it to expand the GPIO irqs. Because they don't use irq domain code properly. I move it to Kconfig.debug, OK?

It sounds like your GPIO driver should get fixed to use irq domains right, it should not be too hard. The number of GPIOs is typically a compile time constant today, but we also try to turn it into a dynamic allocation that we have for IRQs on most targets.

Got it, remove the CSKY_NR_IRQS.

Quoted 5 lines

What I meant here is that you can get the same behavior by appending the dtb to the kernel rather than linking it into the kernel. The reason for preferring the appended one is that you can more easily use the same kernel binary across boards with different bootloaders.

Ok, got it. I'll use the dtb passed by bootloader first.

Quoted 6 lines

I'd say it's better to get rid of it for the upstream port, more importantly getting rid of the code that checks for this symbol. Usually what happens with version checks like this one is that they get out of sync quickly as a new kernel version does things differently and diverges more from the old release you were comparing against. In device drivers, we tend to remove all those checks.

Ok, follow the rules.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

-fno-tree-dse?

This is from "gcc-4.5 compile linux-4.7" and it will cause wrong code without -fno-tree-dse for list.h. Now we use gcc-6.3, so I will try to remove it.

You can also use the cc-ifversion Makefile macro to apply it on the old compiler. That way you can still use gcc-4.5 as long as that remains relevant but don't get worse code generation on modern versions.

Thx for advice, but we don't need support gcc-4.5 now. I'll just remove them.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Can you explain why you need the alignement fixups?

For abiv1 ck610 couldn't handle the unalignment address access, so we need soft-alignment exception to fixup. There is no problem in abiv2 cpus.

Quoted 10 lines

Ok. Generally speaking, architectures that don't allow unaligned access should have all code built in a way that uses aligned access (gcc normally falls back to byte access when it encounters an unaligned pointer at compile time), but if this is just for old CPUs that are not used in future products, having the fixup does sound simpler, as it allows you to still run new binaries on the old machines. I haven't looked at the implementation for the fixup here, but I remember the same thing from the nds32 port. In that case, we ended up keeping the fixup as an option for old user space, but disabled to softalign fixups for kernel code. Can you do the same thing here?

Ok. I got it, I'll do the same as nds32.

Best Regards
Guo Ren

maintainer
#33 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Quoted 33 lines · Guo Ren

Hi arnd,

Quoted 4 lines · Arnd Bergmann

If the clocksource depends on a driver rather than a feature of the architecture,
this may not be worth optimizing though, so maybe leave it as it is for now.

Ok, I'll keep it.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Usually the kernel should allow multiple CPU types to be selected together, or ask for a "minimum architecture" level to be selected by allow newer cores to be used as a superset.

No, I need keep them seperate.

Can you explain? What is it that makes them all incompatible?

ck610 is abiv1 and its gcc is different from abiv2, they are:
- csky-linux-abiv1-gcc
- csky-linux-abiv2-gcc

ck807/810/860 use the same csky-linux-abiv2-gcc, but their instruction-sets and pipeline schedule are different. So our gcc must&only use '-mcpu=' to determine which cpu series is. They are different cpu series.

    ck610 only  have: ck610
    ck807 could have: ck807 ck807f ck807vf ck807ef
    ck810 could have: ck810 ck810f ck810vf ck810ef
    ck860 could have: ck860 ck860f ck860vf

f: means FPU co-processor
v: means VDSP co-processor just like "ARM-NEON"
e: is our old DSP co-processor which use HI-LO regs for operation. In current ck807/ck810 they default have HI-LO regs, so ck807&ck807e is the same for me.

Quoted 4 lines

For this patch-set, we support:

   ck610

(ck807/ck807f/ck807ef)
(ck810/ck810e/ck810ef)

Ok, I understand the part about ck610 being incompatible, but I'm still not sure about the 8xx ones: Do you mean it's impossible to have one kernel that runs across all of them for some other reason, or is it something you haven't allowed because you see no use for it?

Quoted 25 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines

arch/csky/Kconfig line 145

Quoted 10 lines
arch/csky/Kconfig new file +10 -0
+config CPU_TLB_SIZE
+       int
+       default "128"   if(CPU_CK610 || CPU_CK807 || CPU_CK810)
+       default "1024"  if(CPU_CK860)
+
+config L1_CACHE_SHIFT
+       int
+       default "4"     if(CPU_CK610)
+       default "5"     if(CPU_CK807 || CPU_CK810)
+       default "6"     if(CPU_CK860)

I think you then need to reverse the order of the list here: When e.g. CK860 and CK810 are both enabled, L1_CACHE_SHIFT should be the largest possible size.

Quoted 5 lines
Quoted 2 lines

No, I use L1_CACHE_SHIFT to determine the size of cache_line.
When I flush cache for a range of memory, I need the size to loop flush cache line.

This is still relatively easy to fix, you just need a cpu specific loop that uses the actual line size rather than the maximum size.

Here is my cacheflush code in mm/cachev2.c:

        #define L1_CACHE_BYTES (1<<L1_CACHE_SHIFT)
        for(i=start; i<end; i+=L1_CACHE_BYTES)
                asm volatile("dcache.cval1 %0\n"::"r"(i));
        asm volatile("sync.is\n");
Quoted 7 lines

I use L1_CACHE_BYTES as the loop element to increase. So it must be the current CPU cache line size for "correct&performance". Each of our CPU-series has a fixed cache line size:
ck610 is 16Bytes
ck807/ck810 is 32Bytes
ck860 is 64Bytes
So I don't need determine them in .dts or detect on boot, just define them in Kconfig.

This is basically the same question as above: For c610, using the fixed value is sufficient, because it's incompatible with the others. But if you want to run the same kernel on both ck810 and ck860, then it needs some form of runtime detection.

On other architectures, the L1_CACHE_BYTES constant is the maximum possible cache line size, and the cache flush function uses the actual size

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+config SSEG0_BASE
+       hex "Direct mapping physical address"
+       default 0x0
+       help
+         There are MSAx regs can be used to change the base physical address
Quoted 8 lines

arch/csky/Kconfig line 168

Quoted 5 lines
arch/csky/Kconfig new file +5 -0
+         of direct mapping. The default base physical address is 0x0.
+
+config RAM_BASE
+       hex "DRAM base address offset from SSEG0_BASE, it must be the same with dts memory."
+       default 0x08000000

To allow one kernel to run on multiple boards, it's better to detect these two at runtime.

CK-CPUs have a mips-like direct-mapping, and I use the macros to calculate the virtual-addr in headers.

Quoted 7 lines
Quoted 5 lines

On many architectures, we detect the offsets at boot time and pass them as variables. On
ARM, we go as far as patching the kernel at boot time to have constant offsets, but usually
it's not worth the effort.

I know it's duplicate setting with dts for users. But now, I still want to keep them. I'll consider your advices in future.

Ok. Just make sure that the DT always has this information as well, so this can be changed in the future when desired, without having to make incompatible changes to the devicetree binary files.

Arnd

author
#34 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Quoted 4 lines · Arnd Bergmann

Ok, I understand the part about ck610 being incompatible, but I'm still not sure about the 8xx ones: Do you mean it's impossible to have one kernel that runs across all of them for some other reason, or is it something you haven't allowed because you see no use for it?

Sorry, Csky gcc need "-mcpu=ck807" or "-mcpu=ck810" or "-mcpu=ck860" to determine the back-end policy. So I must seperate them with different vmlinux.

Quoted 4 lines

This is basically the same question as above: For c610, using the fixed value is sufficient, because it's incompatible with the others. But if you want to run the same kernel on both ck810 and ck860, then it needs some form of runtime detection.

Sorry, currently no runtime detection.
But I agree with you that one vmlinux for all cpus is a good design for compat.

Quoted 2 lines

On other architectures, the L1_CACHE_BYTES constant is the maximum possible cache line size, and the cache flush function uses the actual size

The same with above, we don't detect cpus on runtime. So we just make it simple here.

Quoted 3 lines

Ok. Just make sure that the DT always has this information as well, so this can be changed in the future when desired, without having to make incompatible changes to the devicetree binary files.

Ok

Best Regards
Guo Ren

maintainer
#35 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Quoted 8 lines · Guo Ren
Quoted 4 lines · Arnd Bergmann

Ok, I understand the part about ck610 being incompatible, but I'm still not sure about the 8xx ones: Do you mean it's impossible to have one kernel that runs across all of them for some other reason, or is it something you haven't allowed because you see no use for it?

Sorry, Csky gcc need "-mcpu=ck807" or "-mcpu=ck810" or "-mcpu=ck860" to determine the back-end policy. So I must seperate them with different vmlinux.

Usually the way gcc handles this, either each CPU is a strict superset of another
one, so you just need to specify the one with the smallest instruction set, or you have an option like -mcpu=generic that produces the common subset.

Quoted 11 lines
Quoted 4 lines

This is basically the same question as above: For c610, using the fixed value is sufficient, because it's incompatible with the others. But if you want to run the same kernel on both ck810 and ck860, then it needs some form of runtime detection.

Sorry, currently no runtime detection.
But I agree with you that one vmlinux for all cpus is a good design for compat.

Quoted 2 lines

On other architectures, the L1_CACHE_BYTES constant is the maximum possible cache line size, and the cache flush function uses the actual size

The same with above, we don't detect cpus on runtime. So we just make it simple here.

Ok, fair enough. It's something that can always be added later, as long as we keep this in mind early on.

Arnd

author
#36 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Hi Arnd,

Quoted 5 lines · Arnd Bergmann

Usually the way gcc handles this, either each CPU is a strict superset of another
one, so you just need to specify the one with the smallest instruction set, or you have an option like -mcpu=generic that produces the common subset.

ck807 ck810 ck860 are diffrent architecture, so they can not be strict superset and there is no option like '-mcpu=generic' in our gcc and binutils.

I know you want one vmlinux which could run on all ck807 ck810 ck860 with different dts-setting. But now, may I keep current design for abiv1&abiv2?

In abiv3, we will take your advice seriously.

Best Regards
Guo Ren

maintainer
#37 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Quoted 8 lines · Guo Ren

Hi Arnd,

Quoted 5 lines · Arnd Bergmann

Usually the way gcc handles this, either each CPU is a strict superset of another
one, so you just need to specify the one with the smallest instruction set, or you have an option like -mcpu=generic that produces the common subset.

Quoted 8 lines

ck807 ck810 ck860 are diffrent architecture, so they can not be strict superset and there is no option like '-mcpu=generic' in our gcc and binutils.

I know you want one vmlinux which could run on all ck807 ck810 ck860 with different dts-setting. But now, may I keep current design for abiv1&abiv2?

In abiv3, we will take your advice seriously.

Ok, thanks for the clarification. Obviously if they are mutually incompatible, there is no point in using a common kernel, so your current version is absolutely fine, and this is similar to how we cannot have a common kernel between ARMv5, ARMv7-A and ARMv7-M, which are all incompatible
at the kernel level.

One more question for my understanding: Are the three types of ck8xx CPUs mutually incompatible in user space as well, or are the differences only for the kernel? For the ARM example, ARMv5 and ARMv7 fundamentally require separate kernels, but both can run user space programs built for ARMv5.

Arnd

author
#38 lore raw

Re: [PATCH 15/19] csky: Build infrastructure

Hi Arnd,

Quoted 5 lines · Arnd Bergmann

Ok, thanks for the clarification. Obviously if they are mutually incompatible, there is no point in using a common kernel, so your current version is absolutely fine, and this is similar to how we cannot have a common kernel between ARMv5, ARMv7-A and ARMv7-M, which are all incompatible
at the kernel level.

Yes.

Quoted 5 lines

One more question for my understanding: Are the three types of ck8xx CPUs mutually incompatible in user space as well, or are the differences only for the kernel? For the ARM example, ARMv5 and ARMv7 fundamentally require separate kernels, but both can run user space programs built for ARMv5.

-mcpu=ck807 app could run on ck807, ck810, ck860. -mcpu=ck810 app could run on ck807, ck810, ck860. -mcpu=ck860 app only run on ck860.

They are all incompatible at the kernel level.

Best Regards
Guo Ren

author
#39 lore raw

PATCH 16/19 csky: Device tree

In reply to Guo Ren
---
 arch/csky/boot/dts/gx6605s.dts         | 159 +++++++++++++++++++++++++++++++++
 arch/csky/boot/dts/include/dt-bindings |   1 +
 arch/csky/boot/dts/qemu.dts            |  87 ++++++++++++++++++
 3 files changed, 247 insertions(+)
 create mode 100644 arch/csky/boot/dts/gx6605s.dts
 create mode 120000 arch/csky/boot/dts/include/dt-bindings
 create mode 100644 arch/csky/boot/dts/qemu.dts
arch/csky/boot/dts/gx6605s.dts new file +159 -0
new file mode 100644
index 0000000..0d34d22
@@ -0,0 +1,159 @@
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "Nationalchip gx6605s ck610";
+	compatible = "nationalchip,gx6605s,ck610";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	memory {
+		device_type = "memory";
+		reg = <0x10000000 0x04000000>;
+	};
+
+	cpus {
+		#address-cells = <0>;
+		#size-cells = <0>;
+
+		cpu {
+			device_type = "cpu";
+			ccr	= <0x7d>;
+			hint	= <0x1c>;
+		};
+	};
+
+	soc {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "simple-bus";
+		ranges;
+
+		intc: interrupt-controller {
+			compatible = "nationalchip,intc-v1,ave";
+			reg = <0x00500000 0x400>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+		};
+
+		timer0 {
+			compatible = "nationalchip,timer-v1";
+			reg = <0x0020a000 0x400>;
+			clock-frequency = <1000000>;
+			interrupts = <10>;
+			interrupt-parent = <&intc>;
+		};
+
+		ehci: ehci-hcd {
+			compatible = "generic-ehci";
+			reg = <0x00900000 0x400>;
+			interrupt-parent = <&intc>;
+			interrupts = <59>;
+		};
+
+		ohci0: ohci-hcd0 {
+			compatible = "generic-ohci";
+			reg = <0x00a00000 0x400>;
+			interrupt-parent = <&intc>;
+			interrupts = <58>;
+		};
+
+		ohci1: ohci-hcd1 {
+			compatible = "generic-ohci";
+			reg = <0x00b00000 0x400>;
+			interrupt-parent = <&intc>;
+			interrupts = <57>;
+		};
+
+		uart0: serial {
+			compatible = "ns16550a";
+			reg = <0x00403000 0x400>;
+			interrupt-parent = <&intc>;
+			interrupts = <15>;
+			clock-frequency = <29491200>;
+			baud = <115200>;
+			reg-shift = <2>;
+			reg-io-width = <1>;
+		};
+
+		gpio0: gpio {
+			compatible = "wd,mbl-gpio";
+			reg-names = "dirout", "dat", "set", "clr";
+			reg = <0x305000 4>, <0x305004 4>, <0x305008 4>, <0x30500c 4>;
+			bgpio-base = <0>;
+			#gpio-cells = <2>;
+			gpio-controller;
+		};
+
+		gpio_buttons {
+			compatible = "gpio-keys-polled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			poll-interval = <100>;
+			autorepeat;
+
+			button0 {
+				label = "button8";
+				linux,code = <KEY_LEFT>;
+				gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
+			};
+
+			button1 {
+				label = "button6";
+				linux,code = <KEY_RIGHT>;
+				gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+			};
+
+			button2 {
+				label = "button5";
+				linux,code = <KEY_UP>;
+				gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
+			};
+
+			button3 {
+				label = "button9";
+				linux,code = <KEY_DOWN>;
+				gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
+			};
+
+			button4 {
+				label = "button7";
+				linux,code = <KEY_ENTER>;
+				gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
+			};
+		};
+
+		gpio_leds {
+			compatible = "gpio-leds";
+
+			led0 {
+				label = "led10";
+				gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
+				linux,default-trigger = "heartbeat";
+			};
+
+			led1 {
+				label = "led11";
+				gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
+				linux,default-trigger = "timer";
+			};
+
+			led2 {
+				label = "led12";
+				gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
+				linux,default-trigger = "default-on";
+			};
+
+			led3 {
+				label = "led13";
+				gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
+				linux,default-trigger = "default-on";
+			};
+		};
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200 init=/sbin/init root=/dev/sda2 rw rootwait";
+	};
+};
arch/csky/boot/dts/include/dt-bindings new file +1 -0
new file mode 120000
index 0000000..08c00e4
@@ -0,0 +1 @@
+../../../../../include/dt-bindings
\ No newline at end of file
arch/csky/boot/dts/qemu.dts new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#40 lore raw

Re: [PATCH 16/19] csky: Device tree

Quoted 1 line · Guo Ren

Please add a changelog text to each patch, and send patches that add .dts files or
binding documents to the devicetree mailing list.

Quoted 15 lines
---
 arch/csky/boot/dts/gx6605s.dts         | 159 +++++++++++++++++++++++++++++++++
 arch/csky/boot/dts/include/dt-bindings |   1 +
 arch/csky/boot/dts/qemu.dts            |  87 ++++++++++++++++++
 3 files changed, 247 insertions(+)
 create mode 100644 arch/csky/boot/dts/gx6605s.dts
 create mode 120000 arch/csky/boot/dts/include/dt-bindings
 create mode 100644 arch/csky/boot/dts/qemu.dts
arch/csky/boot/dts/gx6605s.dts new file +0 -0
new file mode 100644
index 0000000..0d34d22

arch/csky/boot/dts/gx6605s.dts line 3

Quoted 3 lines
arch/csky/boot/dts/gx6605s.dts new file +3 -0
@@ -0,0 +1,159 @@
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>

It is usually better for an SoC based board to split the SoC specific into a separate .dtsi file that gets included by the board .dts file.

arch/csky/boot/dts/gx6605s.dts line 7

Quoted 3 lines
arch/csky/boot/dts/gx6605s.dts new file +3 -0
+/ {
+       model = "Nationalchip gx6605s ck610";
+       compatible = "nationalchip,gx6605s,ck610";

Is ck610 the name of the CPU core? The general convention is to have the top-level "compatible" property list first the name of the board, then the name of the soc, but not the name of the CPU core.

Quoted 6 lines
arch/csky/boot/dts/gx6605s.dts new file +6 -0
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       memory {
+               device_type = "memory";
+               reg = <0x10000000 0x04000000>;

arch/csky/boot/dts/gx6605s.dts line 23

Quoted 10 lines
arch/csky/boot/dts/gx6605s.dts new file +10 -0
+       };
+
+       cpus {
+               #address-cells = <0>;
+               #size-cells = <0>;
+
+               cpu {
+                       device_type = "cpu";
+                       ccr     = <0x7d>;
+                       hint    = <0x1c>;

Here you should list the specific type of CPU in the compatible property and document the binding for that string in the Documentations/devicetree/bindings hierarchy. Without a binding, the 'ccr' and 'hint' properties make no sense.

If there is any chance that you could have SMP systems in the future, it would be better to start with #address-cells=<1>, with appropriate reg properties.

arch/csky/boot/dts/gx6605s.dts line 35

Quoted 9 lines
arch/csky/boot/dts/gx6605s.dts new file +9 -0
+       soc {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "simple-bus";
+               ranges;
+
+               intc: interrupt-controller {
+                       compatible = "nationalchip,intc-v1,ave";
+                       reg = <0x00500000 0x400>;

Each node with a register property also needs the address in the node name, e.g. "interrupt-controller@500000"

Try building the dtb file with 'make W=1' to get warnings about when you got that wrong.

arch/csky/boot/dts/gx6605s.dts line 41

Quoted 6 lines
arch/csky/boot/dts/gx6605s.dts new file +6 -0
+                       interrupt-controller;
+                       #interrupt-cells = <1>;
+               };
+
+               timer0 {
+                       compatible = "nationalchip,timer-v1";

This should be "timer@400"

Also, each device node should have a binding documentation to explain the binding associated with that "compatible" string.

Quoted 4 lines
arch/csky/boot/dts/gx6605s.dts new file +4 -0
+                       reg = <0x0020a000 0x400>;
+                       clock-frequency = <1000000>;
+                       interrupts = <10>;
+                       interrupt-parent = <&intc>;

arch/csky/boot/dts/gx6605s.dts line 55

Quoted 10 lines
arch/csky/boot/dts/gx6605s.dts new file +10 -0
+               };
+
+               ehci: ehci-hcd {
+                       compatible = "generic-ehci";
+                       reg = <0x00900000 0x400>;
+                       interrupt-parent = <&intc>;
+                       interrupts = <59>;
+               };
+
+               ohci0: ohci-hcd0 {

The names here should be "usb@...", not "ehci-hcd"

arch/csky/boot/dts/gx6605s.dts line 54

Quoted 3 lines
arch/csky/boot/dts/gx6605s.dts new file +3 -0
+       chosen {
+               bootargs = "console=ttyS0,115200 rdinit=/sbin/init root=/dev/ram0";
+       };

The bootargs should not be in the dts file normally, they should come from the boot loader. For the console, use the "stdout-path" property.

Arnd

author
#41 lore raw

Re: [PATCH 16/19] csky: Device tree

Hi Arnd,

Quoted 3 lines · Arnd Bergmann

Please add a changelog text to each patch, and send patches that add .dts files or
binding documents to the devicetree mailing list.

Ok

Quoted 2 lines

It is usually better for an SoC based board to split the SoC specific into a separate .dtsi file that gets included by the board .dts file.

Ok

Quoted 7 lines

arch/csky/boot/dts/gx6605s.dts line 7

Quoted 3 lines
arch/csky/boot/dts/gx6605s.dts new file +3 -0
+/ {
+       model = "Nationalchip gx6605s ck610";
+       compatible = "nationalchip,gx6605s,ck610";

Is ck610 the name of the CPU core? The general convention is to have the top-level "compatible" property list first the name of the board, then the name of the soc, but not the name of the CPU core.

Yes, ck610 is a cpu core of abiv1. and I will change it like this:

	model = "Zhuxian-sword gx6605s Development Board";
	compatible = "zhuxian-sword,gx6605s";

ref: https://c-sky.github.io/docs/gx6605s.html

Quoted 3 lines

Here you should list the specific type of CPU in the compatible property and document the binding for that string in the Documentations/devicetree/bindings hierarchy. Without a binding, the 'ccr' and 'hint' properties make no sense.

Sorry, I forget remove the cpu region. It's no use now.

Quoted 3 lines

If there is any chance that you could have SMP systems in the future, it would be better to start with #address-cells=<1>, with appropriate reg properties.

Ok

Quoted 2 lines

Each node with a register property also needs the address in the node name, e.g. "interrupt-controller@500000"

Ok

Quoted 2 lines

Try building the dtb file with 'make W=1' to get warnings about when you got that wrong.

Thx

Quoted 4 lines

arch/csky/boot/dts/gx6605s.dts line 41

Quoted 2 lines
arch/csky/boot/dts/gx6605s.dts new file +2 -0
+               timer0 {
+                       compatible = "nationalchip,timer-v1";

This should be "timer@400"

Ok

Quoted 3 lines

Also, each device node should have a binding documentation to explain the binding associated with that "compatible" string.

Ok, I will add them.

Quoted 2 lines
Quoted 1 line

+ ohci0: ohci-hcd0 {

The names here should be "usb@...", not "ehci-hcd"

Ok

Quoted 6 lines

arch/csky/boot/dts/qemu.dts line 86

Quoted 3 lines
arch/csky/boot/dts/qemu.dts new file +3 -0
+       chosen {
+               bootargs = "console=ttyS0,115200 rdinit=/sbin/init root=/dev/ram0";
+       };

The bootargs should not be in the dts file normally, they should come from the boot loader.

I want to keep bootargs in dts, because the bootloader only pass the dtb to kernel.

Quoted 1 line

For the console, use the "stdout-path" property.

Ok

Best Regards
Guo Ren

author
#42 lore raw

PATCH 17/19 csky: defconfig

In reply to Guo Ren
---
 arch/csky/configs/gx66xx_defconfig     | 549 +++++++++++++++++++++++++++++++++
 arch/csky/configs/qemu_ck807_defconfig | 541 ++++++++++++++++++++++++++++++++
 2 files changed, 1090 insertions(+)
 create mode 100644 arch/csky/configs/gx66xx_defconfig
 create mode 100644 arch/csky/configs/qemu_ck807_defconfig
arch/csky/configs/gx66xx_defconfig new file +549 -0
new file mode 100644
index 0000000..7f2a987
@@ -0,0 +1,549 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_DEFAULT_HOSTNAME="github.com/c-sky"
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+# CONFIG_FHANDLE is not set
+CONFIG_USELIB=y
+CONFIG_AUDIT=y
+CONFIG_IRQ_DOMAIN_DEBUG=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_RELAY=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_AIO is not set
+CONFIG_USERFAULTFD=y
+CONFIG_EMBEDDED=y
+# CONFIG_PERF_EVENTS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_BLK_DEV_BSGLIB=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_ACORN_PARTITION=y
+CONFIG_ACORN_PARTITION_ICS=y
+CONFIG_ACORN_PARTITION_RISCIX=y
+CONFIG_AIX_PARTITION=y
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_CMDLINE_PARTITION=y
+CONFIG_DEFAULT_DEADLINE=y
+CONFIG_FB_NATIONALCHIP=y
+CONFIG_RAM_BASE=0x10000000
+# CONFIG_SUSPEND is not set
+# CONFIG_COMPACTION is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+# CONFIG_IPV6 is not set
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_WEXT=y
+CONFIG_MAC80211=y
+CONFIG_MAC80211_DEBUGFS=y
+CONFIG_RFKILL=y
+CONFIG_RFKILL_INPUT=y
+CONFIG_RFKILL_GPIO=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=65536
+CONFIG_VIRTIO_BLK=y
+CONFIG_AD525X_DPOT=m
+CONFIG_AD525X_DPOT_I2C=m
+CONFIG_DUMMY_IRQ=m
+CONFIG_ICS932S401=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_APDS9802ALS=m
+CONFIG_ISL29003=m
+CONFIG_ISL29020=m
+CONFIG_SENSORS_TSL2550=m
+CONFIG_SENSORS_BH1770=m
+CONFIG_SENSORS_APDS990X=m
+CONFIG_HMC6352=m
+CONFIG_DS1682=m
+CONFIG_USB_SWITCH_FSA9480=m
+CONFIG_SRAM=y
+CONFIG_C2PORT=m
+CONFIG_EEPROM_AT24=m
+CONFIG_EEPROM_LEGACY=m
+CONFIG_EEPROM_MAX6875=m
+CONFIG_SENSORS_LIS3_I2C=m
+CONFIG_ALTERA_STAPL=m
+CONFIG_ECHO=m
+CONFIG_SCSI=y
+# CONFIG_SCSI_PROC_FS is not set
+CONFIG_BLK_DEV_SD=y
+CONFIG_SCSI_SPI_ATTRS=y
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SRP_ATTRS=m
+# CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_NETDEVICES=y
+CONFIG_USB_RTL8150=y
+CONFIG_USB_RTL8152=y
+CONFIG_USB_USBNET=y
+# CONFIG_WLAN_VENDOR_ADMTEK is not set
+# CONFIG_WLAN_VENDOR_ATH is not set
+# CONFIG_WLAN_VENDOR_ATMEL is not set
+# CONFIG_WLAN_VENDOR_BROADCOM is not set
+# CONFIG_WLAN_VENDOR_CISCO is not set
+# CONFIG_WLAN_VENDOR_INTEL is not set
+# CONFIG_WLAN_VENDOR_INTERSIL is not set
+# CONFIG_WLAN_VENDOR_MARVELL is not set
+CONFIG_MT7601U=m
+# CONFIG_WLAN_VENDOR_RALINK is not set
+CONFIG_RTL8187=y
+CONFIG_RTL8XXXU=y
+CONFIG_RTL8XXXU_UNTESTED=y
+# CONFIG_WLAN_VENDOR_RSI is not set
+# CONFIG_WLAN_VENDOR_ST is not set
+# CONFIG_WLAN_VENDOR_TI is not set
+# CONFIG_WLAN_VENDOR_ZYDAS is not set
+CONFIG_INPUT_SPARSEKMAP=m
+CONFIG_INPUT_EVDEV=y
+CONFIG_KEYBOARD_ADP5588=m
+CONFIG_KEYBOARD_ADP5589=m
+CONFIG_KEYBOARD_QT1070=m
+CONFIG_KEYBOARD_QT2160=m
+CONFIG_KEYBOARD_LKKBD=m
+CONFIG_KEYBOARD_GPIO_POLLED=m
+CONFIG_KEYBOARD_TCA6416=m
+CONFIG_KEYBOARD_TCA8418=m
+CONFIG_KEYBOARD_LM8323=m
+CONFIG_KEYBOARD_LM8333=m
+CONFIG_KEYBOARD_MAX7359=m
+CONFIG_KEYBOARD_MCS=m
+CONFIG_KEYBOARD_MPR121=m
+CONFIG_KEYBOARD_NEWTON=m
+CONFIG_KEYBOARD_OPENCORES=m
+CONFIG_KEYBOARD_STOWAWAY=m
+CONFIG_KEYBOARD_SUNKBD=m
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_MOUSE_PS2=m
+CONFIG_MOUSE_PS2_ELANTECH=y
+CONFIG_MOUSE_PS2_SENTELIC=y
+CONFIG_MOUSE_PS2_TOUCHKIT=y
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_CYAPA=m
+CONFIG_MOUSE_VSXXXAA=m
+CONFIG_MOUSE_SYNAPTICS_I2C=m
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_ZHENHUA=m
+CONFIG_JOYSTICK_AS5011=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_INPUT_TABLET=y
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_AD7879=m
+CONFIG_TOUCHSCREEN_AD7879_I2C=m
+CONFIG_TOUCHSCREEN_ATMEL_MXT=m
+CONFIG_TOUCHSCREEN_BU21013=m
+CONFIG_TOUCHSCREEN_CYTTSP_CORE=m
+CONFIG_TOUCHSCREEN_CYTTSP_I2C=m
+CONFIG_TOUCHSCREEN_CYTTSP4_CORE=m
+CONFIG_TOUCHSCREEN_CYTTSP4_I2C=m
+CONFIG_TOUCHSCREEN_DYNAPRO=m
+CONFIG_TOUCHSCREEN_HAMPSHIRE=m
+CONFIG_TOUCHSCREEN_EETI=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_ILI210X=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_WACOM_W8001=m
+CONFIG_TOUCHSCREEN_WACOM_I2C=m
+CONFIG_TOUCHSCREEN_MAX11801=m
+CONFIG_TOUCHSCREEN_MCS5000=m
+CONFIG_TOUCHSCREEN_MMS114=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_INEXIO=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_EDT_FT5X06=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_PIXCIR=m
+CONFIG_TOUCHSCREEN_TOUCHIT213=m
+CONFIG_TOUCHSCREEN_TSC_SERIO=m
+CONFIG_TOUCHSCREEN_TSC2007=m
+CONFIG_TOUCHSCREEN_ST1232=m
+CONFIG_TOUCHSCREEN_TPS6507X=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_AD714X=m
+CONFIG_INPUT_BMA150=m
+CONFIG_INPUT_MMA8450=m
+CONFIG_INPUT_MPU3050=m
+CONFIG_INPUT_KXTJ9=m
+CONFIG_INPUT_UINPUT=y
+CONFIG_INPUT_PCF8574=m
+CONFIG_INPUT_ADXL34X=m
+CONFIG_INPUT_CMA3000=m
+CONFIG_INPUT_CMA3000_I2C=m
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_RAW=m
+CONFIG_SERIO_ALTERA_PS2=m
+CONFIG_SERIO_PS2MULT=m
+CONFIG_SERIO_ARC_PS2=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_8250=y
+# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=2
+CONFIG_SERIAL_8250_RUNTIME_UARTS=2
+CONFIG_SERIAL_8250_DW=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_TTY_PRINTK=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_IPMI_HANDLER=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_TIMERIOMEM=m
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_HW_RANDOM_TPM=m
+CONFIG_TCG_TIS_I2C_ATMEL=m
+CONFIG_TCG_TIS_I2C_INFINEON=m
+CONFIG_TCG_TIS_I2C_NUVOTON=m
+CONFIG_TCG_ATMEL=m
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_MUX_PCA9541=m
+CONFIG_I2C_DESIGNWARE_PLATFORM=m
+CONFIG_I2C_OCORES=m
+CONFIG_I2C_PCA_PLATFORM=m
+CONFIG_I2C_SIMTEC=m
+CONFIG_I2C_XILINX=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_STUB=m
+CONFIG_PPS=m
+CONFIG_PPS_CLIENT_LDISC=m
+CONFIG_PPS_CLIENT_GPIO=m
+CONFIG_GPIOLIB=y
+CONFIG_DEBUG_GPIO=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+CONFIG_POWER_RESET=y
+# CONFIG_HWMON is not set
+CONFIG_SSB=m
+CONFIG_BCMA=m
+CONFIG_BCMA_HOST_SOC=y
+CONFIG_BCMA_DRIVER_GMAC_CMN=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_USB_SUPPORT=y
+CONFIG_USB_VIDEO_CLASS=y
+# CONFIG_USB_GSPCA is not set
+CONFIG_FB=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_HID_A4TECH=m
+CONFIG_HID_ACRUX=m
+CONFIG_HID_ACRUX_FF=y
+CONFIG_HID_APPLE=m
+CONFIG_HID_AUREAL=m
+CONFIG_HID_BELKIN=m
+CONFIG_HID_CHERRY=m
+CONFIG_HID_CHICONY=m
+CONFIG_HID_CYPRESS=m
+CONFIG_HID_DRAGONRISE=m
+CONFIG_DRAGONRISE_FF=y
+CONFIG_HID_EMS_FF=m
+CONFIG_HID_ELECOM=m
+CONFIG_HID_EZKEY=m
+CONFIG_HID_KEYTOUCH=m
+CONFIG_HID_KYE=m
+CONFIG_HID_WALTOP=m
+CONFIG_HID_GYRATION=m
+CONFIG_HID_ICADE=m
+CONFIG_HID_TWINHAN=m
+CONFIG_HID_KENSINGTON=m
+CONFIG_HID_LCPOWER=m
+CONFIG_HID_LOGITECH=m
+CONFIG_HID_LOGITECH_HIDPP=m
+CONFIG_LOGITECH_FF=y
+CONFIG_LOGIRUMBLEPAD2_FF=y
+CONFIG_LOGIG940_FF=y
+CONFIG_HID_MAGICMOUSE=m
+CONFIG_HID_MICROSOFT=m
+CONFIG_HID_MONTEREY=m
+CONFIG_HID_MULTITOUCH=m
+CONFIG_HID_ORTEK=m
+CONFIG_HID_PANTHERLORD=m
+CONFIG_PANTHERLORD_FF=y
+CONFIG_HID_PETALYNX=m
+CONFIG_HID_PICOLCD=m
+CONFIG_HID_PICOLCD_LEDS=y
+CONFIG_HID_PRIMAX=m
+CONFIG_HID_SAITEK=m
+CONFIG_HID_SAMSUNG=m
+CONFIG_HID_SPEEDLINK=m
+CONFIG_HID_STEELSERIES=m
+CONFIG_HID_SUNPLUS=m
+CONFIG_HID_RMI=m
+CONFIG_HID_GREENASIA=m
+CONFIG_GREENASIA_FF=y
+CONFIG_HID_SMARTJOYPLUS=m
+CONFIG_SMARTJOYPLUS_FF=y
+CONFIG_HID_TIVO=m
+CONFIG_HID_TOPSEED=m
+CONFIG_HID_THINGM=m
+CONFIG_HID_THRUSTMASTER=m
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_HID_WACOM=m
+CONFIG_HID_WIIMOTE=m
+CONFIG_HID_XINMO=m
+CONFIG_HID_ZEROPLUS=m
+CONFIG_ZEROPLUS_FF=y
+CONFIG_HID_ZYDACRON=m
+CONFIG_HID_SENSOR_HUB=m
+CONFIG_HID_PID=y
+CONFIG_I2C_HID=m
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_HCD_PLATFORM=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_HCD_PLATFORM=y
+CONFIG_USB_STORAGE=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_LM3530=m
+CONFIG_LEDS_LM3642=m
+CONFIG_LEDS_PCA9532=m
+CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_LP3944=m
+CONFIG_LEDS_LP5521=m
+CONFIG_LEDS_LP5523=m
+CONFIG_LEDS_LP5562=m
+CONFIG_LEDS_LP8501=m
+CONFIG_LEDS_PCA955X=m
+CONFIG_LEDS_PCA963X=m
+CONFIG_LEDS_BD2802=m
+CONFIG_LEDS_TCA6507=m
+CONFIG_LEDS_LM355x=m
+CONFIG_LEDS_BLINKM=m
+CONFIG_LEDS_TRIGGER_TIMER=y
+CONFIG_LEDS_TRIGGER_ONESHOT=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+CONFIG_LEDS_TRIGGER_BACKLIGHT=y
+CONFIG_LEDS_TRIGGER_CPU=y
+CONFIG_LEDS_TRIGGER_GPIO=y
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
+CONFIG_LEDS_TRIGGER_TRANSIENT=y
+CONFIG_LEDS_TRIGGER_CAMERA=y
+CONFIG_LEDS_TRIGGER_PANIC=y
+CONFIG_VIRTIO_BALLOON=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_STE_MODEM_RPROC=m
+CONFIG_PM_DEVFREQ=y
+CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
+CONFIG_DEVFREQ_GOV_PERFORMANCE=y
+CONFIG_DEVFREQ_GOV_POWERSAVE=y
+CONFIG_DEVFREQ_GOV_USERSPACE=y
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_FANOTIFY=y
+CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
+CONFIG_QUOTA=y
+# CONFIG_PRINT_QUOTA_WARNING is not set
+CONFIG_FSCACHE=m
+CONFIG_FSCACHE_STATS=y
+CONFIG_CACHEFILES=m
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_UTF8=y
+CONFIG_NTFS_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_CHILDREN=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_CONFIGFS_FS=y
+CONFIG_CRAMFS=y
+CONFIG_ROMFS_FS=y
+CONFIG_NFS_FS=y
+CONFIG_ROOT_NFS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=y
+CONFIG_NLS_CODEPAGE_775=y
+CONFIG_NLS_CODEPAGE_850=y
+CONFIG_NLS_CODEPAGE_852=y
+CONFIG_NLS_CODEPAGE_855=y
+CONFIG_NLS_CODEPAGE_857=y
+CONFIG_NLS_CODEPAGE_860=y
+CONFIG_NLS_CODEPAGE_861=y
+CONFIG_NLS_CODEPAGE_863=y
+CONFIG_NLS_CODEPAGE_864=y
+CONFIG_NLS_CODEPAGE_865=y
+CONFIG_NLS_CODEPAGE_866=y
+CONFIG_NLS_CODEPAGE_869=y
+CONFIG_NLS_CODEPAGE_936=y
+CONFIG_NLS_CODEPAGE_950=y
+CONFIG_NLS_CODEPAGE_932=y
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=y
+CONFIG_NLS_CODEPAGE_1251=y
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_MAC_ROMAN=m
+CONFIG_NLS_MAC_CELTIC=m
+CONFIG_NLS_MAC_CENTEURO=m
+CONFIG_NLS_MAC_CROATIAN=m
+CONFIG_NLS_MAC_CYRILLIC=m
+CONFIG_NLS_MAC_GAELIC=m
+CONFIG_NLS_MAC_GREEK=m
+CONFIG_NLS_MAC_ICELAND=m
+CONFIG_NLS_MAC_INUIT=m
+CONFIG_NLS_MAC_ROMANIAN=m
+CONFIG_NLS_MAC_TURKISH=m
+CONFIG_NLS_UTF8=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DEBUG_INFO=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_LOCKUP_DETECTOR=y
+# CONFIG_SCHED_DEBUG is not set
+CONFIG_RBTREE_TEST=m
+CONFIG_INTERVAL_TREE_TEST=m
+CONFIG_PERCPU_TEST=m
+CONFIG_TEST_STRING_HELPERS=m
+CONFIG_TEST_KSTRTOX=m
+CONFIG_PERSISTENT_KEYRINGS=y
+CONFIG_TRUSTED_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_PATH=y
+CONFIG_SECURITY_YAMA=y
+CONFIG_INTEGRITY_SIGNATURE=y
+CONFIG_INTEGRITY_ASYMMETRIC_KEYS=y
+CONFIG_IMA=y
+CONFIG_IMA_APPRAISE=y
+CONFIG_EVM=y
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=y
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_CMAC=m
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_VMAC=m
+CONFIG_CRYPTO_CRC32=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_RMD128=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_RMD256=m
+CONFIG_CRYPTO_RMD320=m
+CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SALSA20=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_LZO=y
+CONFIG_CRYPTO_LZ4=m
+CONFIG_CRYPTO_LZ4HC=m
+CONFIG_CRYPTO_ANSI_CPRNG=m
+CONFIG_CRC_CCITT=m
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_CRC8=m
+CONFIG_XZ_DEC=y
+CONFIG_XZ_DEC_TEST=m
+CONFIG_CORDIC=m
+CONFIG_DDR=y
arch/csky/configs/qemu_ck807_defconfig new file +541 -0

541 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#43 lore raw

Re: [PATCH 17/19] csky: defconfig

Quoted 7 lines · Guo Ren
---
 arch/csky/configs/gx66xx_defconfig     | 549 +++++++++++++++++++++++++++++++++
 arch/csky/configs/qemu_ck807_defconfig | 541 ++++++++++++++++++++++++++++++++
 2 files changed, 1090 insertions(+)
 create mode 100644 arch/csky/configs/gx66xx_defconfig
 create mode 100644 arch/csky/configs/qemu_ck807_defconfig

These look a lot longer than they should be, they contain many symbols that I suspenc
are not needed or useful for you.

arch/csky/configs/gx66xx_defconfig line 2

Quoted 8 lines
arch/csky/configs/gx66xx_defconfig new file +2 -0
new file mode 100644
index 0000000..7f2a987
@@ -0,0 +1,549 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_DEFAULT_HOSTNAME="github.com/c-sky"

This is not a well-formed hostname

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+# CONFIG_FHANDLE is not set
+CONFIG_USELIB=y

arch/csky/configs/gx66xx_defconfig line 17

Quoted 10 lines
arch/csky/configs/gx66xx_defconfig new file +10 -0
+CONFIG_AUDIT=y
+CONFIG_IRQ_DOMAIN_DEBUG=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_RELAY=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_AIO is not set

Disabling swap, fhandle or AIO seems odd, those are commonly used symbols.

arch/csky/configs/gx66xx_defconfig line 19

Quoted 2 lines
arch/csky/configs/gx66xx_defconfig new file +2 -0
+CONFIG_USERFAULTFD=y
+CONFIG_EMBEDDED=y

CONFIG_EMBEDDED should generally not be selected, it's only for very unusual configurations that need to disable symbols that are normally required.

arch/csky/configs/gx66xx_defconfig line 24

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+# CONFIG_PERF_EVENTS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y

oprofile can go now, since you said you'd remove the code.

Quoted 14 lines
arch/csky/configs/gx66xx_defconfig new file +13 -0
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
 
+CONFIG_BLK_DEV_BSGLIB=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_ACORN_PARTITION=y
+CONFIG_ACORN_PARTITION_ICS=y
+CONFIG_ACORN_PARTITION_RISCIX=y
+CONFIG_AIX_PARTITION=y
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y

arch/csky/configs/gx66xx_defconfig line 47

Quoted 10 lines
arch/csky/configs/gx66xx_defconfig new file +10 -0
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_SYSV68_PARTITION=y

These block device configuration options all seem misplaced here, it's extremely unlikely that you need them.

Quoted 9 lines
arch/csky/configs/gx66xx_defconfig new file +9 -0
+CONFIG_CMDLINE_PARTITION=y
+CONFIG_DEFAULT_DEADLINE=y
+CONFIG_FB_NATIONALCHIP=y
+CONFIG_RAM_BASE=0x10000000
+# CONFIG_SUSPEND is not set
+# CONFIG_COMPACTION is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y

arch/csky/configs/gx66xx_defconfig line 66

Quoted 10 lines
arch/csky/configs/gx66xx_defconfig new file +10 -0
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+# CONFIG_IPV6 is not set
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_WEXT=y

I would guess you want IPV6 but not WEXT here.

arch/csky/configs/gx66xx_defconfig line 74

Quoted 8 lines
arch/csky/configs/gx66xx_defconfig new file +8 -0
+CONFIG_MAC80211=y
+CONFIG_MAC80211_DEBUGFS=y
+CONFIG_RFKILL=y
+CONFIG_RFKILL_INPUT=y
+CONFIG_RFKILL_GPIO=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_STANDALONE is not set

No need to turn this off, it might just get in the way of build testing.

arch/csky/configs/gx66xx_defconfig line 135

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+CONFIG_KEYBOARD_ADP5588=m
+CONFIG_KEYBOARD_ADP5589=m
+CONFIG_KEYBOARD_QT1070=m
+CONFIG_KEYBOARD_QT2160=m
+CONFIG_KEYBOARD_LKKBD=m

There are many input devices listed here, most of which you almost certainly won't need.

arch/csky/configs/gx66xx_defconfig line 248

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+CONFIG_IPMI_HANDLER=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m

Are you sure you have IPMI hardware?

arch/csky/configs/gx66xx_defconfig line 297

Quoted 13 lines
arch/csky/configs/gx66xx_defconfig new file +13 -0
+CONFIG_FB=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set

For new platforms, using the DRM subsystem is the recommend way to do graphics, it mostly replaces the framebuffer subsystem here.

Quoted 1 line

+CONFIG_STE_MODEM_RPROC=m

I think this is no longer there.

arch/csky/configs/gx66xx_defconfig line 408

Quoted 7 lines
arch/csky/configs/gx66xx_defconfig new file +7 -0
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y

Better use EXT4 for the defconfig instead.

Arnd

author
#44 lore raw

Re: [PATCH 17/19] csky: defconfig

Quoted 9 lines · Arnd Bergmann
Quoted 5 lines
 arch/csky/configs/gx66xx_defconfig     | 549 +++++++++++++++++++++++++++++++++
 arch/csky/configs/qemu_ck807_defconfig | 541 ++++++++++++++++++++++++++++++++
 2 files changed, 1090 insertions(+)
 create mode 100644 arch/csky/configs/gx66xx_defconfig
 create mode 100644 arch/csky/configs/qemu_ck807_defconfig

These look a lot longer than they should be, they contain many symbols that I suspenc
are not needed or useful for you.

I'll cleanup the defconfig again.

Quoted 11 lines

arch/csky/configs/gx66xx_defconfig line 2

Quoted 9 lines
arch/csky/configs/gx66xx_defconfig new file +2 -0
new file mode 100644
index 0000000..7f2a987
@@ -0,0 +1,549 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_DEFAULT_HOSTNAME="github.com/c-sky"

This is not a well-formed hostname

I'll remove it.

Quoted 11 lines
Quoted 11 lines
arch/csky/configs/gx66xx_defconfig new file +10 -0
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+# CONFIG_FHANDLE is not set
+CONFIG_USELIB=y
+CONFIG_AUDIT=y
+CONFIG_IRQ_DOMAIN_DEBUG=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BSD_PROCESS_ACCT=y
Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 17

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_RELAY=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_AIO is not set

Disabling swap, fhandle or AIO seems odd, those are commonly used symbols.

I'll try to enable them.

Quoted 6 lines

arch/csky/configs/gx66xx_defconfig line 19

Quoted 2 lines
arch/csky/configs/gx66xx_defconfig new file +2 -0
+CONFIG_USERFAULTFD=y
+CONFIG_EMBEDDED=y

CONFIG_EMBEDDED should generally not be selected, it's only for very unusual configurations that need to disable symbols that are normally required.

I'll try to enable EMBEDDED.

Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 24

Quoted 6 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+# CONFIG_PERF_EVENTS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y

oprofile can go now, since you said you'd remove the code.

Yes, remove it.

Quoted 16 lines
Quoted 16 lines
arch/csky/configs/gx66xx_defconfig new file +16 -0
+CONFIG_BLK_DEV_BSGLIB=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_ACORN_PARTITION=y
+CONFIG_ACORN_PARTITION_ICS=y
+CONFIG_ACORN_PARTITION_RISCIX=y
+CONFIG_AIX_PARTITION=y
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 47

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_SYSV68_PARTITION=y

These block device configuration options all seem misplaced here, it's extremely unlikely that you need them.

I'll try to remove it.

Quoted 1 line

arch/csky/configs/gx66xx_defconfig line 46

Quoted 1 line
arch/csky/configs/gx66xx_defconfig new file +1 -0
+# CONFIG_IPV6 is not set

I'll enable IPV6.

Quoted 5 lines

arch/csky/configs/gx66xx_defconfig line 66

Quoted 3 lines
arch/csky/configs/gx66xx_defconfig new file +3 -0
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_WEXT=y

I would guess you want IPV6 but not WEXT here.

Gx6605s devlepment board support usb-wifi.
Perhaps WEXT is needed by iwconfig or iwlist? So I just enable it. However, I'll consider to remove it.

Quoted 4 lines

arch/csky/configs/gx66xx_defconfig line 50

Quoted 1 line
arch/csky/configs/gx66xx_defconfig new file +1 -0
+# CONFIG_STANDALONE is not set

No need to turn this off, it might just get in the way of build testing.

Ok, I'll try to enable it.

Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 135

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+CONFIG_KEYBOARD_ADP5588=m
+CONFIG_KEYBOARD_ADP5589=m
+CONFIG_KEYBOARD_QT1070=m
+CONFIG_KEYBOARD_QT2160=m
+CONFIG_KEYBOARD_LKKBD=m

There are many input devices listed here, most of which you almost certainly won't need.

Yes, remove them.

Quoted 7 lines

arch/csky/configs/gx66xx_defconfig line 248

Quoted 5 lines
arch/csky/configs/gx66xx_defconfig new file +5 -0
+CONFIG_IPMI_HANDLER=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m

Are you sure you have IPMI hardware?

No IPMI hardware, remove them.

Quoted 9 lines
Quoted 9 lines
arch/csky/configs/gx66xx_defconfig new file +9 -0
+CONFIG_FB=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 297

Quoted 4 lines
arch/csky/configs/gx66xx_defconfig new file +4 -0
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set

For new platforms, using the DRM subsystem is the recommend way to do graphics, it mostly replaces the framebuffer subsystem here.

These used by:
https://github.com/c-sky/addons-linux/tree/master/addons/drivers/video/fbdev/nationalchip

I'll consider the DRM subsystem.

Quoted 3 lines

arch/csky/configs/gx66xx_defconfig line 74

Quoted 1 line
arch/csky/configs/gx66xx_defconfig new file +1 -0
+CONFIG_STE_MODEM_RPROC=m

I think this is no longer there.

Yes, remove it.

Quoted 9 lines

arch/csky/configs/gx66xx_defconfig line 408

Quoted 7 lines
arch/csky/configs/gx66xx_defconfig new file +7 -0
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y

Better use EXT4 for the defconfig instead.

OK.

Best Regards
Guo Ren

maintainer
#45 lore raw

Re: [PATCH 17/19] csky: defconfig

Quoted 10 lines · Guo Ren
Quoted 5 lines · Arnd Bergmann

arch/csky/configs/gx66xx_defconfig line 66

Quoted 3 lines
arch/csky/configs/gx66xx_defconfig new file +3 -0
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_WEXT=y

I would guess you want IPV6 but not WEXT here.

Gx6605s devlepment board support usb-wifi.
Perhaps WEXT is needed by iwconfig or iwlist? So I just enable it. However, I'll consider to remove it.

I think it's only for backwards compatibility with old versions of those tools. There are some older drivers that use WEXT as the native interface, but CFG80211 based drivers have a netlink interface.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
arch/csky/configs/gx66xx_defconfig new file +9 -0
+CONFIG_FB=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 297

Quoted 4 lines
arch/csky/configs/gx66xx_defconfig new file +4 -0
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set

For new platforms, using the DRM subsystem is the recommend way to do graphics, it mostly replaces the framebuffer subsystem here.

Quoted 4 lines

These used by:
https://github.com/c-sky/addons-linux/tree/master/addons/drivers/video/fbdev/nationalchip

I'll consider the DRM subsystem.

It used to be rather hard to write a new DRM driver, but that has improved a lot recently. You might be able to fit your driver into drivers/gpu/drm/tinydrm/, or maybe do something a bit more complex like drivers/gpu/drm/pl111/ or drivers/gpu/drm/stm/.

Arnd

author
#46 lore raw

Re: [PATCH 17/19] csky: defconfig

Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Guo Ren
Quoted 5 lines · Arnd Bergmann

arch/csky/configs/gx66xx_defconfig line 66

Quoted 3 lines
arch/csky/configs/gx66xx_defconfig new file +3 -0
+CONFIG_CFG80211=y
+CONFIG_CFG80211_DEBUGFS=y
+CONFIG_CFG80211_WEXT=y

I would guess you want IPV6 but not WEXT here.

Quoted 8 lines
Quoted 3 lines

Gx6605s devlepment board support usb-wifi.
Perhaps WEXT is needed by iwconfig or iwlist? So I just enable it. However, I'll consider to remove it.

I think it's only for backwards compatibility with old versions of those tools. There are some older drivers that use WEXT as the native interface, but CFG80211 based drivers have a netlink interface.

Thx for remind. I'll check.

Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
arch/csky/configs/gx66xx_defconfig new file +9 -0
+CONFIG_FB=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_SIMPLE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
Quoted 8 lines

arch/csky/configs/gx66xx_defconfig line 297

Quoted 4 lines
arch/csky/configs/gx66xx_defconfig new file +4 -0
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set

For new platforms, using the DRM subsystem is the recommend way to do graphics, it mostly replaces the framebuffer subsystem here.

These used by:
https://github.com/c-sky/addons-linux/tree/master/addons/drivers/video/fbdev/nationalchip

Quoted 6 lines
Quoted 1 line

I'll consider the DRM subsystem.

It used to be rather hard to write a new DRM driver, but that has improved a lot recently. You might be able to fit your driver into drivers/gpu/drm/tinydrm/, or maybe do something a bit more complex like drivers/gpu/drm/pl111/ or drivers/gpu/drm/stm/.

For this patchset, I won't upstream the fbdev driver. I'll remove the CONFIG_FB in defconfig first.

Thx for remind about the develop-tips, and it's very helpful.

Best Regards
Guo Ren

author
#47 lore raw

PATCH 18/19 clocksource: add timer-nationalchip.c

In reply to Guo Ren
---
 drivers/clocksource/Makefile             |   1 +
 drivers/clocksource/timer-nationalchip.c | 149 +++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+)
 create mode 100644 drivers/clocksource/timer-nationalchip.c
drivers/clocksource/Makefile +1 -0
index d6dec44..d091712 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_H8300_TMR16)		+= h8300_timer16.o
 obj-$(CONFIG_H8300_TPU)			+= h8300_tpu.o
 obj-$(CONFIG_CLKSRC_ST_LPC)		+= clksrc_st_lpc.o
 obj-$(CONFIG_X86_NUMACHIP)		+= numachip.o
+obj-$(CONFIG_CSKY)			+= timer-nationalchip.o
drivers/clocksource/timer-nationalchip.c new file +149 -0

149 lines not on this page · raw message

Signature · 1 line
2.7.4
#48 lore raw

Re: [PATCH 18/19] clocksource: add timer-nationalchip.c

Hi Guo,

On 18/03/2018 20:51, Guo Ren wrote:

This patch is a new driver. Please add the hardware details of this timer and optionally a link to the documentation. No need to write a book, just a quick summary of it.

Quoted 22 lines
---
 drivers/clocksource/Makefile             |   1 +
 drivers/clocksource/timer-nationalchip.c | 149 +++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+)
 create mode 100644 drivers/clocksource/timer-nationalchip.c
drivers/clocksource/Makefile +1 -0
index d6dec44..d091712 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_H8300_TMR16)		+= h8300_timer16.o
 obj-$(CONFIG_H8300_TPU)			+= h8300_tpu.o
 obj-$(CONFIG_CLKSRC_ST_LPC)		+= clksrc_st_lpc.o
 obj-$(CONFIG_X86_NUMACHIP)		+= numachip.o
+obj-$(CONFIG_CSKY)			+= timer-nationalchip.o
drivers/clocksource/timer-nationalchip.c new file +0 -0
new file mode 100644
index 0000000..1279d64

drivers/clocksource/timer-nationalchip.c line 5

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
@@ -0,0 +1,149 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou NationalChip Science & Technology Co.,Ltd.
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/param.h>

sched ? param ?

drivers/clocksource/timer-nationalchip.c line 8

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/profile.h>

profile ?

drivers/clocksource/timer-nationalchip.c line 11

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+#include <linux/irq.h>
+#include <linux/rtc.h>
+#include <linux/sizes.h>

rtc ? sizes ?

drivers/clocksource/timer-nationalchip.c line 16

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/delay.h>

Is the delay API defined for this architecture ? I don't see it used below.

Quoted 22 lines
drivers/clocksource/timer-nationalchip.c new file +22 -0
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/sched_clock.h>
+
+#define NC_VA_COUNTER_1_STATUS		(void *)(timer_reg + 0x00)
+#define NC_VA_COUNTER_1_VALUE		(void *)(timer_reg + 0x04)
+#define NC_VA_COUNTER_1_CONTROL		(void *)(timer_reg + 0x10)
+#define NC_VA_COUNTER_1_CONFIG		(void *)(timer_reg + 0x20)
+#define NC_VA_COUNTER_1_PRE		(void *)(timer_reg + 0x24)
+#define NC_VA_COUNTER_1_INI		(void *)(timer_reg + 0x28)
+#define NC_VA_COUNTER_2_STATUS		(void *)(timer_reg + 0x40)
+#define NC_VA_COUNTER_2_VALUE		(void *)(timer_reg + 0x44)
+#define NC_VA_COUNTER_2_CONTROL		(void *)(timer_reg + 0x50)
+#define NC_VA_COUNTER_2_CONFIG		(void *)(timer_reg + 0x60)
+#define NC_VA_COUNTER_2_PRE		(void *)(timer_reg + 0x64)
+#define NC_VA_COUNTER_2_INI		(void *)(timer_reg + 0x68)
+#define NC_VA_COUNTER_3_STATUS		(void *)(timer_reg + 0x80)
+#define NC_VA_COUNTER_3_VALUE		(void *)(timer_reg + 0x84)
+#define NC_VA_COUNTER_3_CONTROL		(void *)(timer_reg + 0x90)
+#define NC_VA_COUNTER_3_CONFIG		(void *)(timer_reg + 0xa0)
+#define NC_VA_COUNTER_3_PRE		(void *)(timer_reg + 0xa4)

drivers/clocksource/timer-nationalchip.c line 48

Quoted 10 lines
drivers/clocksource/timer-nationalchip.c new file +10 -0
+#define NC_VA_COUNTER_3_INI		(void *)(timer_reg + 0xa8)
+
+static unsigned int timer_reg;
+
+static inline void timer_reset(void)
+{
+	__raw_writel(0x1,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x0,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x3,	NC_VA_COUNTER_1_CONFIG);
+	__raw_writel(26,	NC_VA_COUNTER_1_PRE);

Why are you using the __raw_writel instead of writel ?

No values, explicit macros please.

drivers/clocksource/timer-nationalchip.c line 51

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+}
+
+static irqreturn_t timer_interrupt(int irq, void *dev_id)

timer_interrupt is a too generic name, at least nc_timer_interrupt would be more accurate.

Quoted 42 lines
drivers/clocksource/timer-nationalchip.c new file +42 -0
+{
+	struct clock_event_device *dev = (struct clock_event_device *) dev_id;
+
+	__raw_writel(1, NC_VA_COUNTER_1_STATUS);
+
+	dev->event_handler(dev);
+
+	return IRQ_HANDLED;
+}
+
+static int nc_timer_set_periodic(struct clock_event_device *dev)
+{
+	timer_reset();
+
+	__raw_writel(0xFFFFD8EF, NC_VA_COUNTER_1_INI);
+	__raw_writel(0x2, NC_VA_COUNTER_1_CONTROL);
+
+	return 0;
+}
+
+static int nc_timer_set_next_event(unsigned long delta, struct clock_event_device *evt)
+{
+	__raw_writel(0x1,		NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(ULONG_MAX - delta, NC_VA_COUNTER_1_INI);
+	__raw_writel(0x2,		NC_VA_COUNTER_1_CONTROL);
+	return 0;
+}
+
+static int nc_timer_shutdown(struct clock_event_device *dev)
+{
+	__raw_writel(0x0, NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x0, NC_VA_COUNTER_1_CONFIG);
+
+	return 0;
+}
+
+static struct clock_event_device nc_ced = {
+	.name			= "nationalchip-clkevent",
+	.features		= CLOCK_EVT_FEAT_PERIODIC
+				| CLOCK_EVT_FEAT_ONESHOT,
+	.rating			= 200,
+	.set_state_shutdown	= nc_timer_shutdown,

drivers/clocksource/timer-nationalchip.c line 103

Quoted 10 lines
drivers/clocksource/timer-nationalchip.c new file +10 -0
+	.set_state_periodic	= nc_timer_set_periodic,
+	.set_next_event		= nc_timer_set_next_event,
+};
+
+static u64 notrace nc_sched_clock_read(void)
+{
+	return (u64) __raw_readl(NC_VA_COUNTER_2_VALUE);
+}
+
+static void nc_csd_enable(void)

Can you choose a more explicit name than 'csd'?

Quoted 23 lines
drivers/clocksource/timer-nationalchip.c new file +23 -0
+{
+	__raw_writel(0x1, NC_VA_COUNTER_2_CONTROL);
+	__raw_writel(0x0, NC_VA_COUNTER_2_CONTROL);
+	__raw_writel(0x1, NC_VA_COUNTER_2_CONFIG);
+
+	__raw_writel(26,NC_VA_COUNTER_2_PRE);
+	__raw_writel(0, NC_VA_COUNTER_2_INI);
+	__raw_writel(0x2, NC_VA_COUNTER_2_CONTROL);
+}
+
+static int __init nc_timer_init(struct device_node *np)
+{
+	unsigned int irq;
+	unsigned int freq;
+
+	/* parse from devicetree */
+	timer_reg = (unsigned int) of_iomap(np, 0);
+	if (!timer_reg)
+		panic("%s, of_iomap err.\n", __func__);
+
+	irq = irq_of_parse_and_map(np, 0);
+	if (!irq)
+		panic("%s, irq_parse err.\n", __func__);

drivers/clocksource/timer-nationalchip.c line 136

Quoted 10 lines
drivers/clocksource/timer-nationalchip.c new file +9 -0
+
+	if (of_property_read_u32(np, "clock-frequency", &freq))
+		panic("%s, clock-frequency error.\n", __func__);
 
+	pr_info("Nationalchip Timer Init, reg: %x, irq: %d, freq: %d.\n",
+		timer_reg, irq, freq);
+
+	/* setup irq */
+	if (request_irq(irq, timer_interrupt, IRQF_TIMER, np->name, &nc_ced))
+		panic("%s timer_interrupt error.\n", __func__);

Replace the "clock-frequency" property to a clock phandle and use the timer-of API.

That will result on something like that:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/timer-sprd.c#n124

No panic in init function.

drivers/clocksource/timer-nationalchip.c line 142

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
+	/* register */
+	clockevents_config_and_register(&nc_ced, freq, 1, ULONG_MAX);
+
+	nc_csd_enable();
+	clocksource_mmio_init(NC_VA_COUNTER_2_VALUE, "nationalchip-clksource", freq, 200, 32, clocksource_mmio_readl_up);

s/nationalchip-clksource/nationalchip/

line wrap

drivers/clocksource/timer-nationalchip.c line 148

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
+	sched_clock_register(nc_sched_clock_read, 32, freq);
+
+	return 0;
+}
+CLOCKSOURCE_OF_DECLARE(nc_timer, "nationalchip,timer-v1", nc_timer_init);

s/CLOCKSOURCE_OF_DECLARE/TIMER_OF_DECLARE/

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author
#49 lore raw

Re: [PATCH 18/19] clocksource: add timer-nationalchip.c

Hi Daniel,

Quoted 5 lines · Daniel Lezcano

This patch is a new driver. Please add the hardware details of this timer and optionally a link to the documentation. No need to write a book, just a quick summary of it.

OK

Quoted 6 lines

drivers/clocksource/timer-nationalchip.c line 5

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/param.h>

sched ? param ?

I'll cleanup the headers.

Quoted 6 lines

drivers/clocksource/timer-nationalchip.c line 8

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/profile.h>

profile ?

I'll cleanup the headers.

Quoted 6 lines

drivers/clocksource/timer-nationalchip.c line 11

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+#include <linux/irq.h>
+#include <linux/rtc.h>
+#include <linux/sizes.h>

rtc ? sizes ?

I'll cleanup the headers.

Quoted 8 lines

drivers/clocksource/timer-nationalchip.c line 16

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/delay.h>

Is the delay API defined for this architecture ? I don't see it used below.

I'll cleanup the headers.

Quoted 15 lines

drivers/clocksource/timer-nationalchip.c line 48

Quoted 12 lines
drivers/clocksource/timer-nationalchip.c new file +12 -0
+#define NC_VA_COUNTER_3_CONFIG		(void *)(timer_reg + 0xa0)
+#define NC_VA_COUNTER_3_PRE		(void *)(timer_reg + 0xa4)
+#define NC_VA_COUNTER_3_INI		(void *)(timer_reg + 0xa8)
+
+static unsigned int timer_reg;
+
+static inline void timer_reset(void)
+{
+	__raw_writel(0x1,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x0,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x3,	NC_VA_COUNTER_1_CONFIG);
+	__raw_writel(26,	NC_VA_COUNTER_1_PRE);

Why are you using the __raw_writel instead of writel ?

Quoted 2 lines

No values, explicit macros please.

OK

Quoted 7 lines

drivers/clocksource/timer-nationalchip.c line 51

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+}
+
+static irqreturn_t timer_interrupt(int irq, void *dev_id)

timer_interrupt is a too generic name, at least nc_timer_interrupt would be more accurate.

OK

Quoted 9 lines

drivers/clocksource/timer-nationalchip.c line 103

Quoted 6 lines
drivers/clocksource/timer-nationalchip.c new file +6 -0
+static u64 notrace nc_sched_clock_read(void)
+{
+	return (u64) __raw_readl(NC_VA_COUNTER_2_VALUE);
+}
+
+static void nc_csd_enable(void)

Can you choose a more explicit name than 'csd'?

OK, change to nc_clocksource_dev_enable

Quoted 7 lines

drivers/clocksource/timer-nationalchip.c line 136

Quoted 3 lines
drivers/clocksource/timer-nationalchip.c new file +3 -0
+	/* setup irq */
+	if (request_irq(irq, timer_interrupt, IRQF_TIMER, np->name, &nc_ced))
+		panic("%s timer_interrupt error.\n", __func__);

Replace the "clock-frequency" property to a clock phandle and use the timer-of API.

Quoted 6 lines

That will result on something like that:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/timer-sprd.c#n124

No panic in init function.

OK

Quoted 10 lines

drivers/clocksource/timer-nationalchip.c line 142

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
+	/* register */
+	clockevents_config_and_register(&nc_ced, freq, 1, ULONG_MAX);
+
+	nc_csd_enable();
+	clocksource_mmio_init(NC_VA_COUNTER_2_VALUE, "nationalchip-clksource", freq, 200, 32, clocksource_mmio_readl_up);

s/nationalchip-clksource/nationalchip/

line wrap

OK

Quoted 8 lines

drivers/clocksource/timer-nationalchip.c line 148

Quoted 5 lines
drivers/clocksource/timer-nationalchip.c new file +5 -0
+	sched_clock_register(nc_sched_clock_read, 32, freq);
+
+	return 0;
+}
+CLOCKSOURCE_OF_DECLARE(nc_timer, "nationalchip,timer-v1", nc_timer_init);

s/CLOCKSOURCE_OF_DECLARE/TIMER_OF_DECLARE/

OK

Best Regards
Guo Ren

#50 lore raw

Re: [PATCH 18/19] clocksource: add timer-nationalchip.c

In reply to Guo Ren

Hi,

Quoted 8 lines · Guo Ren
drivers/clocksource/timer-nationalchip.c new file +8 -0
+#define NC_VA_COUNTER_1_STATUS		(void *)(timer_reg + 0x00)
+#define NC_VA_COUNTER_1_VALUE		(void *)(timer_reg + 0x04)
+#define NC_VA_COUNTER_1_CONTROL		(void *)(timer_reg + 0x10)
+#define NC_VA_COUNTER_1_CONFIG		(void *)(timer_reg + 0x20)
+#define NC_VA_COUNTER_1_PRE		(void *)(timer_reg + 0x24)
+#define NC_VA_COUNTER_1_INI		(void *)(timer_reg + 0x28)
+#define NC_VA_COUNTER_2_STATUS		(void *)(timer_reg + 0x40)
+#define NC_VA_COUNTER_2_VALUE		(void *)(timer_reg + 0x44)

drivers/clocksource/timer-nationalchip.c line 39

Quoted 10 lines
drivers/clocksource/timer-nationalchip.c new file +10 -0
+#define NC_VA_COUNTER_2_CONTROL		(void *)(timer_reg + 0x50)
+#define NC_VA_COUNTER_2_CONFIG		(void *)(timer_reg + 0x60)
+#define NC_VA_COUNTER_2_PRE		(void *)(timer_reg + 0x64)
+#define NC_VA_COUNTER_2_INI		(void *)(timer_reg + 0x68)
+#define NC_VA_COUNTER_3_STATUS		(void *)(timer_reg + 0x80)
+#define NC_VA_COUNTER_3_VALUE		(void *)(timer_reg + 0x84)
+#define NC_VA_COUNTER_3_CONTROL		(void *)(timer_reg + 0x90)
+#define NC_VA_COUNTER_3_CONFIG		(void *)(timer_reg + 0xa0)
+#define NC_VA_COUNTER_3_PRE		(void *)(timer_reg + 0xa4)
+#define NC_VA_COUNTER_3_INI		(void *)(timer_reg + 0xa8)

Please define the offsets alone, e.g.

#define NC_VA_COUNTER_1_STATUS 0x00
#define NC_VA_COUNTER_1_VALUE 0x04

... the base address should be added when calling the io accessor. Please see below.

Quoted 1 line

+static unsigned int timer_reg;

This should be a void __iomem *, e.g.

static void __iomem *timer_base;

... though it would be better for this to be associated with the instance of the clock_event_device, so that there can be multiple instances in a system.

drivers/clocksource/timer-nationalchip.c line 48

Quoted 7 lines
drivers/clocksource/timer-nationalchip.c new file +7 -0
+
+static inline void timer_reset(void)
+{
+	__raw_writel(0x1,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x0,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x3,	NC_VA_COUNTER_1_CONFIG);
+	__raw_writel(26,	NC_VA_COUNTER_1_PRE);

Should this be 26 or 0x26?

It would be nice to have mnemonics for these magic numbers.

Please use writel_relaxed() rather than __raw_writel(). e.g.

	writel_relaxed(0x1, timer_base + NC_VA_COUNTER_1_CONTROL);
	writel_relaxed(0x0, timer_base + NC_VA_COUNTER_1_CONTROL);
	writel_relaxed(0x3, timer_base + NC_VA_COUNTER_1_CONTROL);
	writel_relaxed(26, timer_base + NC_VA_COUNTER_1_PRE);

[...]

Quoted 25 lines
drivers/clocksource/timer-nationalchip.c new file +25 -0
+static int __init nc_timer_init(struct device_node *np)
+{
+	unsigned int irq;
+	unsigned int freq;
+
+	/* parse from devicetree */
+	timer_reg = (unsigned int) of_iomap(np, 0);
+	if (!timer_reg)
+		panic("%s, of_iomap err.\n", __func__);
+
+	irq = irq_of_parse_and_map(np, 0);
+	if (!irq)
+		panic("%s, irq_parse err.\n", __func__);
+
+	if (of_property_read_u32(np, "clock-frequency", &freq))
+		panic("%s, clock-frequency error.\n", __func__);
+
+	pr_info("Nationalchip Timer Init, reg: %x, irq: %d, freq: %d.\n",
+		timer_reg, irq, freq);
+
+	/* setup irq */
+	if (request_irq(irq, timer_interrupt, IRQF_TIMER, np->name, &nc_ced))
+		panic("%s timer_interrupt error.\n", __func__);
+
+	/* register */

drivers/clocksource/timer-nationalchip.c line 148

Quoted 10 lines
drivers/clocksource/timer-nationalchip.c new file +10 -0
+	clockevents_config_and_register(&nc_ced, freq, 1, ULONG_MAX);
+
+	nc_csd_enable();
+	clocksource_mmio_init(NC_VA_COUNTER_2_VALUE, "nationalchip-clksource", freq, 200, 32, clocksource_mmio_readl_up);
+
+	sched_clock_register(nc_sched_clock_read, 32, freq);
+
+	return 0;
+}
+CLOCKSOURCE_OF_DECLARE(nc_timer, "nationalchip,timer-v1", nc_timer_init);

This needs a devicetree binding document. Please see Documentation/devicetree/bindings/submitting-patches.txt.

Thanks,
Mark

author
#51 lore raw

Re: [PATCH 18/19] clocksource: add timer-nationalchip.c

Hi Mark,

Quoted 13 lines · Mark Rutland

drivers/clocksource/timer-nationalchip.c line 39

Quoted 4 lines
drivers/clocksource/timer-nationalchip.c new file +4 -0
+#define NC_VA_COUNTER_3_CONTROL		(void *)(timer_reg + 0x90)
+#define NC_VA_COUNTER_3_CONFIG		(void *)(timer_reg + 0xa0)
+#define NC_VA_COUNTER_3_PRE		(void *)(timer_reg + 0xa4)
+#define NC_VA_COUNTER_3_INI		(void *)(timer_reg + 0xa8)

Please define the offsets alone, e.g.

#define NC_VA_COUNTER_1_STATUS 0x00
#define NC_VA_COUNTER_1_VALUE 0x04

... the base address should be added when calling the io accessor. Please see below.

Quoted 9 lines
Quoted 1 line

+static unsigned int timer_reg;

This should be a void __iomem *, e.g.

static void __iomem *timer_base;

... though it would be better for this to be associated with the instance of the clock_event_device, so that there can be multiple instances in a system.

OK

Quoted 9 lines

drivers/clocksource/timer-nationalchip.c line 48

Quoted 7 lines
drivers/clocksource/timer-nationalchip.c new file +7 -0
+
+static inline void timer_reset(void)
+{
+	__raw_writel(0x1,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x0,	NC_VA_COUNTER_1_CONTROL);
+	__raw_writel(0x3,	NC_VA_COUNTER_1_CONFIG);
+	__raw_writel(26,	NC_VA_COUNTER_1_PRE);

Should this be 26 or 0x26?

No

Quoted 3 lines

It would be nice to have mnemonics for these magic numbers.

Yes, you are right.

Quoted 7 lines

Please use writel_relaxed() rather than __raw_writel(). e.g.

	writel_relaxed(0x1, timer_base + NC_VA_COUNTER_1_CONTROL);
	writel_relaxed(0x0, timer_base + NC_VA_COUNTER_1_CONTROL);
	writel_relaxed(0x3, timer_base + NC_VA_COUNTER_1_CONTROL);
	writel_relaxed(26, timer_base + NC_VA_COUNTER_1_PRE);

OK

Quoted 4 lines
Quoted 1 line

+CLOCKSOURCE_OF_DECLARE(nc_timer, "nationalchip,timer-v1", nc_timer_init);

This needs a devicetree binding document. Please see Documentation/devicetree/bindings/submitting-patches.txt.

OK

Best Regards
Guo Ren

author
#52 lore raw

PATCH 19/19 irqchip: add irq-nationalchip.c and irq-csky.c

In reply to Guo Ren
---
 drivers/irqchip/Makefile           |   1 +
 drivers/irqchip/irq-csky.c         | 151 ++++++++++++++++++++++++++++
 drivers/irqchip/irq-nationalchip.c | 196 +++++++++++++++++++++++++++++++++++++
 3 files changed, 348 insertions(+)
 create mode 100644 drivers/irqchip/irq-csky.c
 create mode 100644 drivers/irqchip/irq-nationalchip.c
drivers/irqchip/Makefile +1 -0
index d27e3e3..7b98917 100644
@@ -85,3 +85,4 @@ obj-$(CONFIG_IRQ_UNIPHIER_AIDET)	+= irq-uniphier-aidet.o
 obj-$(CONFIG_ARCH_SYNQUACER)		+= irq-sni-exiu.o
 obj-$(CONFIG_MESON_IRQ_GPIO)		+= irq-meson-gpio.o
 obj-$(CONFIG_GOLDFISH_PIC) 		+= irq-goldfish-pic.o
+obj-$(CONFIG_CSKY)			+= irq-csky.o irq-nationalchip.o
drivers/irqchip/irq-csky.c new file +151 -0

151 lines not on this page · raw message

drivers/irqchip/irq-nationalchip.c new file +196 -0

196 lines not on this page · raw message

Signature · 1 line
2.7.4
#53 lore raw

Re: [PATCH 19/19] irqchip: add irq-nationalchip.c and irq-csky.c

Quoted 1 line · Guo Ren

+static unsigned int intc_reg;

This should be a void __iomem *ptr;

drivers/irqchip/irq-csky.c line 23

Quoted 8 lines
drivers/irqchip/irq-csky.c new file +8 -0
+
+#define CK_VA_INTC_ICR		(void *)(intc_reg + 0x00)	/* Interrupt control register(High 16bits) */
+#define CK_VA_INTC_ISR		(void *)(intc_reg + 0x00)	/* Interrupt status register(Low 16bits) */
+#define CK_VA_INTC_NEN31_00	(void *)(intc_reg + 0x10)	/* Normal interrupt enable register Low */
+#define	CK_VA_INTC_NEN63_32	(void *)(intc_reg + 0x28)	/* Normal interrupt enable register High */
+#define CK_VA_INTC_IFR31_00	(void *)(intc_reg + 0x08)	/* Normal interrupt force register Low */
+#define CK_VA_INTC_IFR63_32	(void *)(intc_reg + 0x20)	/* Normal interrupt force register High */
+#define	CK_VA_INTC_SOURCE	(void *)(intc_reg + 0x40)	/* Proiority Level Select Registers 0 */

Please use mnemonics for the offsets, and add the base address in the IO accessors.

[...]

Review

Quoted 1 line
(quoted diff) +1 -0
+		temp = __raw_readl(CK_VA_INTC_NEN31_00);

Please use readl_relaxed() rather than __raw_readl().

Review

Quoted 1 line
(quoted diff) +1 -0
+		__raw_writel(temp, CK_VA_INTC_NEN31_00);

Likewise, please use writel_relaxed() rather than __raw_writel().

[...]

Quoted 46 lines
drivers/irqchip/irq-csky.c new file +46 -0
+static int __init
+__intc_init(struct device_node *np, struct device_node *parent, bool ave)
+{
+	struct irq_domain *root_domain;
+	int i;
+
+	csky_get_auto_irqno = ck_get_irqno;
+
+	if (parent)
+		panic("pic not a root intc\n");
+
+	intc_reg = (unsigned int)of_iomap(np, 0);
+	if (!intc_reg)
+		panic("%s, of_iomap err.\n", __func__);
+
+	__raw_writel(0, CK_VA_INTC_NEN31_00);
+	__raw_writel(0,	CK_VA_INTC_NEN63_32);
+
+	if (ave == true)
+		__raw_writel( 0xc0000000, CK_VA_INTC_ICR);
+	else
+		__raw_writel( 0x0, CK_VA_INTC_ICR);
+	/*
+	 * csky irq ctrl has 64 sources.
+	 */
+	#define INTC_IRQS 64
+	for (i=0; i<INTC_IRQS; i=i+4)
+		__raw_writel((i+3)|((i+2)<<8)|((i+1)<<16)|(i<<24),
+				CK_VA_INTC_SOURCE + i);
+
+	root_domain = irq_domain_add_legacy(np, INTC_IRQS, 0, 0, &ck_irq_ops, NULL);
+	if (!root_domain)
+		panic("root irq domain not available\n");
+
+	irq_set_default_host(root_domain);
+
+	return 0;
+}
+
+static int __init
+intc_init(struct device_node *np, struct device_node *parent)
+{
+
+	return __intc_init(np, parent, false);
+}
+IRQCHIP_DECLARE(csky_intc_v1, "csky,intc-v1", intc_init);

drivers/irqchip/irq-csky.c line 150

Quoted 10 lines
drivers/irqchip/irq-csky.c new file +10 -0
+
+/*
+ * use auto vector exceptions 10 for interrupt.
+ */
+static int __init
+intc_init_ave(struct device_node *np, struct device_node *parent)
+{
+	return __intc_init(np, parent, true);
+}
+IRQCHIP_DECLARE(csky_intc_v1_ave, "csky,intc-v1,ave", intc_init_ave);

These need devicetree bindings. Please see Documentation/devicetree/bindings/submitting-patches.txt.

[...]

Quoted 15 lines
drivers/irqchip/irq-nationalchip.c new file +15 -0
+inline int ff1_64(unsigned int hi, unsigned int lo)
+{
+	int result;
+	asm volatile(
+		"ff1 %0\n"
+		:"=r"(hi)
+		:"r"(hi)
+		:
+	);
+
+	asm volatile(
+		"ff1 %0\n"
+		:"=r"(lo)
+		:"r"(lo)
+		:

drivers/irqchip/irq-nationalchip.c line 131

Quoted 10 lines
drivers/irqchip/irq-nationalchip.c new file +10 -0
+	);
+	if( lo != 32 )
+		result = 31-lo;
+	else if( hi != 32 ) result = 31-hi + 32;
+	else {
+		printk("nc_get_irqno error hi:%x, lo:%x.\n", hi, lo);
+		result = NR_IRQS;
+	}
+	return result;
+}

Please avoid assembly in generic driver code. Here you cna use __ffs64() after combining the two halves into a 64-bit quantity, or you could use ffs() on each half.

Quoted 29 lines
drivers/irqchip/irq-nationalchip.c new file +29 -0
+static int __init
+intc_init(struct device_node *intc, struct device_node *parent)
+{
+	struct irq_domain *root_domain;
+	unsigned int i;
+
+	if (parent)
+		panic("DeviceTree incore intc not a root irq controller\n");
+
+	csky_get_auto_irqno = nc_get_irqno;
+
+	intc_reg = (unsigned int) of_iomap(intc, 0);
+	if (!intc_reg)
+		panic("Nationalchip Intc Reg: %x.\n", intc_reg);
+
+	__raw_writel(0xffffffff, NC_VA_INTC_NENCLR31_00);
+	__raw_writel(0xffffffff, NC_VA_INTC_NENCLR63_32);
+	__raw_writel(0xffffffff, NC_VA_INTC_NMASK31_00);
+	__raw_writel(0xffffffff, NC_VA_INTC_NMASK63_32);
+
+	/*
+	 * nationalchip irq ctrl has 64 sources.
+	 */
+	#define INTC_IRQS 64
+	for (i=0; i<INTC_IRQS; i=i+4)
+		__raw_writel(i|((i+1)<<8)|((i+2)<<16)|((i+3)<<24),
+				NC_VA_INTC_SOURCE + i);
+
+	root_domain = irq_domain_add_legacy(intc, INTC_IRQS, 0, 0,

drivers/irqchip/irq-nationalchip.c line 195

Quoted 10 lines
drivers/irqchip/irq-nationalchip.c new file +10 -0
+			&nc_irq_ops, NULL);
+	if (!root_domain)
+		panic("root irq domain not avail\n");
+
+	irq_set_default_host(root_domain);
+
+	return 0;
+}
+
+IRQCHIP_DECLARE(nationalchip_intc_v1_ave, "nationalchip,intc-v1,ave", intc_init);

This needs a devicetree binding document.

Thanks,
Mark.

author
#54 lore raw

Re: [PATCH 19/19] irqchip: add irq-nationalchip.c and irq-csky.c

Quoted 5 lines · Mark Rutland
Quoted 1 line · Guo Ren

+static unsigned int intc_reg;

This should be a void __iomem *ptr;

OK

Quoted 11 lines

drivers/irqchip/irq-csky.c line 23

Quoted 7 lines
drivers/irqchip/irq-csky.c new file +7 -0
+#define CK_VA_INTC_ICR		(void *)(intc_reg + 0x00)	/* Interrupt control register(High 16bits) */
+#define CK_VA_INTC_ISR		(void *)(intc_reg + 0x00)	/* Interrupt status register(Low 16bits) */
+#define CK_VA_INTC_NEN31_00	(void *)(intc_reg + 0x10)	/* Normal interrupt enable register Low */
+#define	CK_VA_INTC_NEN63_32	(void *)(intc_reg + 0x28)	/* Normal interrupt enable register High */
+#define CK_VA_INTC_IFR31_00	(void *)(intc_reg + 0x08)	/* Normal interrupt force register Low */
+#define CK_VA_INTC_IFR63_32	(void *)(intc_reg + 0x20)	/* Normal interrupt force register High */
+#define	CK_VA_INTC_SOURCE	(void *)(intc_reg + 0x40)	/* Proiority Level Select Registers 0 */

Please use mnemonics for the offsets, and add the base address in the IO accessors.

OK

Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		temp = __raw_readl(CK_VA_INTC_NEN31_00);

Please use readl_relaxed() rather than __raw_readl().

OK

Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+		__raw_writel(temp, CK_VA_INTC_NEN31_00);

Likewise, please use writel_relaxed() rather than __raw_writel().

OK

Quoted 3 lines

These need devicetree bindings. Please see Documentation/devicetree/bindings/submitting-patches.txt.

OK

Quoted 4 lines

Please avoid assembly in generic driver code. Here you cna use __ffs64() after combining the two halves into a 64-bit quantity, or you could use ffs() on each half.

OK

Quoted 3 lines
Quoted 1 line

+IRQCHIP_DECLARE(nationalchip_intc_v1_ave, "nationalchip,intc-v1,ave", intc_init);

This needs a devicetree binding document.

OK
Best Regards
Guo Ren

#55 lore raw

Re: [PATCH 19/19] irqchip: add irq-nationalchip.c and irq-csky.c

In reply to Guo Ren
Quoted 40 lines · Guo Ren
drivers/irqchip/irq-csky.c new file +40 -0
+static void ck_irq_mask(struct irq_data *d)
+{
+	unsigned int temp, irq;
+
+	irq = d->irq;
+
+	if (irq < 32) {
+		temp = __raw_readl(CK_VA_INTC_NEN31_00);
+		temp &= ~(1 << irq);
+		__raw_writel(temp, CK_VA_INTC_NEN31_00);
+	} else {
+		temp = __raw_readl(CK_VA_INTC_NEN63_32);
+		temp &= ~(1 << (irq -32));
+		__raw_writel(temp, CK_VA_INTC_NEN63_32);
+	}
+}
+
+static void ck_irq_unmask(struct irq_data *d)
+{
+	unsigned int temp, irq;
+
+	irq = d->irq;
+
+	/* set IFR to support rising edge triggering */
+	if (irq < 32) {
+		temp = __raw_readl(CK_VA_INTC_IFR31_00);
+		temp &= ~(1 << irq);
+		__raw_writel(temp, CK_VA_INTC_IFR31_00);
+	} else {
+		temp = __raw_readl(CK_VA_INTC_IFR63_32);
+		temp &= ~(1 << (irq -32));
+		__raw_writel(temp, CK_VA_INTC_IFR63_32);
+	}
+
+	if (irq < 32) {
+		temp = __raw_readl(CK_VA_INTC_NEN31_00);
+		temp |= 1 << irq;
+		__raw_writel(temp, CK_VA_INTC_NEN31_00);
+	} else {
+		temp = __raw_readl(CK_VA_INTC_NEN63_32);

drivers/irqchip/irq-csky.c line 74

Quoted 10 lines
drivers/irqchip/irq-csky.c new file +10 -0
+		temp |= 1 << (irq -32);
+		__raw_writel(temp, CK_VA_INTC_NEN63_32);
+	}
+}
+
+static struct irq_chip ck_irq_chip = {
+	.name		= "csky_intc_v1",
+	.irq_mask	= ck_irq_mask,
+	.irq_unmask	= ck_irq_unmask,
+};

Please use the generic interrupt chip infrastructure for this.

drivers/irqchip/irq-csky.c line 90

Quoted 3 lines
drivers/irqchip/irq-csky.c new file +3 -0
+static unsigned int ck_get_irqno(void)
+{
+	unsigned int temp;

newline between declaration and code.

drivers/irqchip/irq-csky.c line 96

Quoted 6 lines
drivers/irqchip/irq-csky.c new file +6 -0
+	temp = __raw_readl(CK_VA_INTC_ISR);
+	return temp & 0x3f;
+};
+
+static int __init
+__intc_init(struct device_node *np, struct device_node *parent, bool ave)

What is 'ave'?

Quoted 7 lines
drivers/irqchip/irq-csky.c new file +7 -0
+{
+	struct irq_domain *root_domain;
+	int i;
+
+	csky_get_auto_irqno = ck_get_irqno;
+
+	if (parent)

drivers/irqchip/irq-csky.c line 113

Quoted 10 lines
drivers/irqchip/irq-csky.c new file +10 -0
+		panic("pic not a root intc\n");
+
+	intc_reg = (unsigned int)of_iomap(np, 0);
+	if (!intc_reg)
+		panic("%s, of_iomap err.\n", __func__);
+
+	__raw_writel(0, CK_VA_INTC_NEN31_00);
+	__raw_writel(0,	CK_VA_INTC_NEN63_32);
+
+	if (ave == true)

if (ave)

drivers/irqchip/irq-csky.c line 114

Quoted 1 line
drivers/irqchip/irq-csky.c new file +1 -0
+		__raw_writel( 0xc0000000, CK_VA_INTC_ICR);

No magic numbers. Please use proper defines.

drivers/irqchip/irq-csky.c line 120

Quoted 6 lines
drivers/irqchip/irq-csky.c new file +6 -0
+	else
+		__raw_writel( 0x0, CK_VA_INTC_ICR);
+	/*
+	 * csky irq ctrl has 64 sources.
+	 */
+	#define INTC_IRQS 64

No defines in code.

Review

Quoted 1 line
(quoted diff) +1 -0
+	for (i=0; i<INTC_IRQS; i=i+4)

checkpatch.pl would have told you what's wrong with the above

drivers/irqchip/irq-csky.c line 122

Quoted 1 line
drivers/irqchip/irq-csky.c new file +1 -0
+		__raw_writel((i+3)|((i+2)<<8)|((i+1)<<16)|(i<<24),

Eew. Tons of magic numbers and a unreadable coding style. Please use an inline function with proper comments to calculate that value

Quoted 5 lines
drivers/irqchip/irq-csky.c new file +5 -0
+				CK_VA_INTC_SOURCE + i);
+
+	root_domain = irq_domain_add_legacy(np, INTC_IRQS, 0, 0, &ck_irq_ops, NULL);
+	if (!root_domain)
+		panic("root irq domain not available\n");

drivers/irqchip/irq-csky.c line 137

Quoted 10 lines
drivers/irqchip/irq-csky.c new file +10 -0
+
+	irq_set_default_host(root_domain);
+
+	return 0;
+}
+
+static int __init
+intc_init(struct device_node *np, struct device_node *parent)
+{
+

Stray newline

drivers/irqchip/irq-csky.c line 148

Quoted 11 lines
drivers/irqchip/irq-csky.c new file +11 -0
+	return __intc_init(np, parent, false);
+}
+IRQCHIP_DECLARE(csky_intc_v1, "csky,intc-v1", intc_init);
+
+/*
+ * use auto vector exceptions 10 for interrupt.
+ */
+static int __init
+intc_init_ave(struct device_node *np, struct device_node *parent)
+{
+	return __intc_init(np, parent, true);

Why is that 'ave' thing not a property of device tree?

Quoted 70 lines
drivers/irqchip/irq-nationalchip.c new file +70 -0
+}
+IRQCHIP_DECLARE(csky_intc_v1_ave, "csky,intc-v1,ave", intc_init_ave);
+
+static unsigned int intc_reg;
+
+static void nc_irq_mask(struct irq_data *d)
+{
+	unsigned int mask, irq;
+
+	irq = d->irq;
+
+	if (irq < 32) {
+		mask = __raw_readl(NC_VA_INTC_NMASK31_00);
+		mask |= 1 << irq;
+		__raw_writel(mask, NC_VA_INTC_NMASK31_00);
+	} else {
+		mask = __raw_readl(NC_VA_INTC_NMASK63_32);
+		mask |= 1 << (irq - 32);
+		__raw_writel(mask, NC_VA_INTC_NMASK63_32);
+	}
+}
+
+static void nc_irq_unmask(struct irq_data *d)
+{
+	unsigned int mask, irq;
+
+	irq = d->irq;
+
+	if (irq < 32) {
+		mask = __raw_readl(NC_VA_INTC_NMASK31_00);
+		mask &= ~( 1 << irq);
+		__raw_writel(mask, NC_VA_INTC_NMASK31_00);
+	} else {
+		mask = __raw_readl( NC_VA_INTC_NMASK63_32);
+		mask &= ~(1 << (irq - 32));
+		__raw_writel(mask, NC_VA_INTC_NMASK63_32);
+	}
+}
+
+static void nc_irq_en(struct irq_data *d)
+{
+	unsigned int mask, irq;
+
+	irq = d->irq;
+
+	if (irq < 32) {
+		mask = 1 << irq;
+		__raw_writel(mask, NC_VA_INTC_NENSET31_00);
+	} else {
+		mask = 1 << (irq - 32);
+		__raw_writel(mask, NC_VA_INTC_NENSET63_32);
+	}
+
+	nc_irq_unmask(d);
+}
+
+static void nc_irq_dis(struct irq_data *d)
+{
+	unsigned int mask, irq;
+
+	irq = d->irq;
+
+	if (irq < 32) {
+		mask = 1 << irq;
+		__raw_writel(mask, NC_VA_INTC_NENCLR31_00);
+	} else {
+		mask = 1 << (irq - 32);
+		__raw_writel(mask, NC_VA_INTC_NENCLR63_32);
+	}
+

drivers/irqchip/irq-nationalchip.c line 105

Quoted 10 lines
drivers/irqchip/irq-nationalchip.c new file +10 -0
+	nc_irq_mask(d);
+}
+
+struct irq_chip nc_irq_chip = {
+	.name =		"nationalchip_intc_v1",
+	.irq_mask =	nc_irq_mask,
+	.irq_unmask =	nc_irq_unmask,
+	.irq_enable =	nc_irq_en,
+	.irq_disable =	nc_irq_dis,
+};

Again. This all can use the generic interrupt chip.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+inline int ff1_64(unsigned int hi, unsigned int lo)

What on earth means ff1_64?

Quoted 5 lines
drivers/irqchip/irq-nationalchip.c new file +5 -0
+{
+	int result;
+	asm volatile(
+		"ff1 %0\n"
+		:"=r"(hi)

drivers/irqchip/irq-nationalchip.c line 122

Quoted 10 lines
drivers/irqchip/irq-nationalchip.c new file +10 -0
+		:"r"(hi)
+		:
+	);
+
+	asm volatile(
+		"ff1 %0\n"
+		:"=r"(lo)
+		:"r"(lo)
+		:
+	);

So you want to decode the interrupt number from a bitfield. What's wrong with ffs()?

drivers/irqchip/irq-nationalchip.c line 124

Quoted 2 lines
drivers/irqchip/irq-nationalchip.c new file +2 -0
+	if( lo != 32 )
+		result = 31-lo;

Why is this subtracted? That code makes no sense w/o comments.

drivers/irqchip/irq-nationalchip.c line 129

Quoted 5 lines
drivers/irqchip/irq-nationalchip.c new file +5 -0
+	else if( hi != 32 ) result = 31-hi + 32;
+	else {
+		printk("nc_get_irqno error hi:%x, lo:%x.\n", hi, lo);
+		result = NR_IRQS;
+	}

Pleas use braces consistently.

drivers/irqchip/irq-nationalchip.c line 133

Quoted 4 lines
drivers/irqchip/irq-nationalchip.c new file +4 -0
+	return result;
+}
+
+unsigned int nc_get_irqno(void)

static?

Quoted 28 lines
drivers/irqchip/irq-nationalchip.c new file +26 -0
+{
+	unsigned int nint64hi, nint64lo, irq_no;
+
+	nint64lo = __raw_readl(NC_VA_INTC_NINT31_00);
+	nint64hi = __raw_readl(NC_VA_INTC_NINT63_32);
+	irq_no = ff1_64(nint64hi, nint64lo);
+
+	return irq_no;
+}
 
 
+static int __init
+intc_init(struct device_node *intc, struct device_node *parent)
+{
+	struct irq_domain *root_domain;
+	unsigned int i;
+
+	if (parent)
+		panic("DeviceTree incore intc not a root irq controller\n");
+
+	csky_get_auto_irqno = nc_get_irqno;
+
+	intc_reg = (unsigned int) of_iomap(intc, 0);
+	if (!intc_reg)
+		panic("Nationalchip Intc Reg: %x.\n", intc_reg);
+
+	__raw_writel(0xffffffff, NC_VA_INTC_NENCLR31_00);
+	__raw_writel(0xffffffff, NC_VA_INTC_NENCLR63_32);

drivers/irqchip/irq-nationalchip.c line 183

Quoted 10 lines
drivers/irqchip/irq-nationalchip.c new file +10 -0
+	__raw_writel(0xffffffff, NC_VA_INTC_NMASK31_00);
+	__raw_writel(0xffffffff, NC_VA_INTC_NMASK63_32);
+
+	/*
+	 * nationalchip irq ctrl has 64 sources.
+	 */
+	#define INTC_IRQS 64
+	for (i=0; i<INTC_IRQS; i=i+4)
+		__raw_writel(i|((i+1)<<8)|((i+2)<<16)|((i+3)<<24),
+				NC_VA_INTC_SOURCE + i);

Same comments as for the other variant.

Thanks,

tglx

author
#56 lore raw

Re: [PATCH 19/19] irqchip: add irq-nationalchip.c and irq-csky.c

Hi Thomas,

Quoted 7 lines · Thomas Gleixner

drivers/irqchip/irq-csky.c line 74

Quoted 5 lines
drivers/irqchip/irq-csky.c new file +5 -0
+static struct irq_chip ck_irq_chip = {
+	.name		= "csky_intc_v1",
+	.irq_mask	= ck_irq_mask,
+	.irq_unmask	= ck_irq_unmask,
+};

Please use the generic interrupt chip infrastructure for this.

Ok, I will learn it.

Quoted 5 lines

drivers/irqchip/irq-csky.c line 90

Quoted 3 lines
drivers/irqchip/irq-csky.c new file +3 -0
+static unsigned int ck_get_irqno(void)
+{
+	unsigned int temp;

newline between declaration and code.

Ok

Quoted 8 lines

drivers/irqchip/irq-csky.c line 96

Quoted 6 lines
drivers/irqchip/irq-csky.c new file +6 -0
+	temp = __raw_readl(CK_VA_INTC_ISR);
+	return temp & 0x3f;
+};
+
+static int __init
+__intc_init(struct device_node *np, struct device_node *parent, bool ave)

What is 'ave'?

Ave means the irq-controller works on auto-vector-handler mode, it will cause 10 exception number and it need read intc-reg to get irq-num.

Quoted 1 line

No magic numbers. Please use proper defines.

Ok

Quoted 8 lines

drivers/irqchip/irq-csky.c line 120

Quoted 6 lines
drivers/irqchip/irq-csky.c new file +6 -0
+	else
+		__raw_writel( 0x0, CK_VA_INTC_ICR);
+	/*
+	 * csky irq ctrl has 64 sources.
+	 */
+	#define INTC_IRQS 64

No defines in code.

Ok

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+	for (i=0; i<INTC_IRQS; i=i+4)

checkpatch.pl would have told you what's wrong with the above

Ok, Thx

Quoted 4 lines

drivers/irqchip/irq-csky.c line 122

Quoted 1 line
drivers/irqchip/irq-csky.c new file +1 -0
+		__raw_writel((i+3)|((i+2)<<8)|((i+1)<<16)|(i<<24),

Eew. Tons of magic numbers and a unreadable coding style. Please use an inline function with proper comments to calculate that value

Ok

Quoted 9 lines
Quoted 9 lines
drivers/irqchip/irq-csky.c new file +9 -0
+				CK_VA_INTC_SOURCE + i);
+
+	root_domain = irq_domain_add_legacy(np, INTC_IRQS, 0, 0, &ck_irq_ops, NULL);
+	if (!root_domain)
+		panic("root irq domain not available\n");
+
+	irq_set_default_host(root_domain);
+
+	return 0;
Quoted 8 lines

drivers/irqchip/irq-csky.c line 137

Quoted 6 lines
drivers/irqchip/irq-csky.c new file +6 -0
+}
+
+static int __init
+intc_init(struct device_node *np, struct device_node *parent)
+{
+

Stray newline

I'll remove, Thx.

Quoted 5 lines
Quoted 5 lines
drivers/irqchip/irq-csky.c new file +5 -0
+	return __intc_init(np, parent, false);
+}
+IRQCHIP_DECLARE(csky_intc_v1, "csky,intc-v1", intc_init);
+
+/*
Quoted 8 lines

drivers/irqchip/irq-csky.c line 148

Quoted 6 lines

+ * use auto vector exceptions 10 for interrupt.
+ */

drivers/irqchip/irq-csky.c new file +4 -0
+static int __init
+intc_init_ave(struct device_node *np, struct device_node *parent)
+{
+	return __intc_init(np, parent, true);

Why is that 'ave' thing not a property of device tree?

I'll change it to a property.

Quoted 9 lines

drivers/irqchip/irq-nationalchip.c line 105

Quoted 7 lines
drivers/irqchip/irq-nationalchip.c new file +7 -0
+struct irq_chip nc_irq_chip = {
+	.name =		"nationalchip_intc_v1",
+	.irq_mask =	nc_irq_mask,
+	.irq_unmask =	nc_irq_unmask,
+	.irq_enable =	nc_irq_en,
+	.irq_disable =	nc_irq_dis,
+};

Again. This all can use the generic interrupt chip.

I'll learn the generic interrupt chip.

Quoted 3 lines
Quoted 1 line

+inline int ff1_64(unsigned int hi, unsigned int lo)

What on earth means ff1_64?

Find the first high bit '1' of the reg :P

Quoted 9 lines

drivers/irqchip/irq-nationalchip.c line 122

Quoted 6 lines
drivers/irqchip/irq-nationalchip.c new file +6 -0
+	asm volatile(
+		"ff1 %0\n"
+		:"=r"(lo)
+		:"r"(lo)
+		:
+	);

So you want to decode the interrupt number from a bitfield. What's wrong with ffs()?

There is no wrong with ffs(). Ok, I will use the ffs().

Quoted 4 lines

drivers/irqchip/irq-nationalchip.c line 124

Quoted 2 lines
drivers/irqchip/irq-nationalchip.c new file +2 -0
+	if( lo != 32 )
+		result = 31-lo;

Why is this subtracted?

ff1 find from high bit, so we need reverse it to get the right num.

Quoted 1 line

That code makes no sense w/o comments.

Sorry, I will add.

Quoted 7 lines

drivers/irqchip/irq-nationalchip.c line 129

Quoted 5 lines
drivers/irqchip/irq-nationalchip.c new file +5 -0
+	else if( hi != 32 ) result = 31-hi + 32;
+	else {
+		printk("nc_get_irqno error hi:%x, lo:%x.\n", hi, lo);
+		result = NR_IRQS;
+	}

Pleas use braces consistently.

Ok

Quoted 3 lines
Quoted 1 line

+unsigned int nc_get_irqno(void)

static?

Yes

Quoted 1 line

Same comments as for the other variant.

Ok

Best Regards
Guo Ren

#57 lore raw
In reply to Guo Ren
Quoted 6 lines · Guo Ren

This patchset adds architecture support to Linux for C-SKY's 32-bit embedded CPU cores and the patches are based on linux-4.16-rc5.

There are two ABI versions with several CPU cores in this patchset:
ABIv1: ck610 (16-bit instruction, 32-bit data path, VIPT Cache ...)
ABIv2: ck807 ck810 (16/32-bit variable length instruction, PIPT Cache ...)

[]

Quoted 1 line

It's my first patchset to linux and any feedback is welcome :)

Hello. You might try to do a git am <series> on a new branch and correct the various git whitespace messages that are produced.

It's also possible to run checkpatch and correct some of the linux-kernel code style conformance nits it lists.

Perhaps something like:

$ git ls-files arch/csky/ | \
  while read file ; do \
    ./scripts/checkpatch.pl --strict --terse --no-summary $file ; \
  done

add --fix-inplace to the checkpatch line if desired.

author
#58 lore raw

Thx Joe,

Quoted 20 lines · Joe Perches
Quoted 6 lines · Guo Ren

This patchset adds architecture support to Linux for C-SKY's 32-bit embedded CPU cores and the patches are based on linux-4.16-rc5.

There are two ABI versions with several CPU cores in this patchset:
ABIv1: ck610 (16-bit instruction, 32-bit data path, VIPT Cache ...)
ABIv2: ck807 ck810 (16/32-bit variable length instruction, PIPT Cache ...)

[]

Quoted 1 line

It's my first patchset to linux and any feedback is welcome :)

Hello. You might try to do a git am <series> on a new branch and correct the various git whitespace messages that are produced.

It's also possible to run checkpatch and correct some of the linux-kernel code style conformance nits it lists.

Quoted 8 lines

Perhaps something like:

$ git ls-files arch/csky/ | \
  while read file ; do \
    ./scripts/checkpatch.pl --strict --terse --no-summary $file ; \
  done

add --fix-inplace to the checkpatch line if desired.

OK

Best Regards
Guo Ren

maintainer
#59 lore raw
In reply to Guo Ren
Quoted 24 lines · Guo Ren

This patchset adds architecture support to Linux for C-SKY's 32-bit embedded CPU cores and the patches are based on linux-4.16-rc5.

There are two ABI versions with several CPU cores in this patchset:
ABIv1: ck610 (16-bit instruction, 32-bit data path, VIPT Cache ...)
ABIv2: ck807 ck810 (16/32-bit variable length instruction, PIPT Cache ...)

More information: http://en.c-sky.com

I'm from Hangzhou,China C-SKY Microsystems and responsible for C-SKY Linux port. My development repo is github.com/c-sky/csky-linux and use buildroot as our CI-test enviornment. "LTP, Lmbench, uclibc-ng-test ..." will be tested for every commit. See here for more details:
https://gitlab.com/c-sky/buildroot/pipelines

You can try C-SKY linux in a few steps:

  $ git clone https://github.com/c-sky/buildroot.git
  $ cd buildroot
  $ make qemu_csky_ck807_uclibc_bt_defconfig
  $ make
It will download "linux uclibc-ng gcc binutils qemu busybox" source code and build
them into one image. How to run, See:
  https://github.com/c-sky/buildroot/blob/master/board/qemu/csky/readme.txt
Quoted 5 lines

I've finished uClibc-ng.org upstream and "gcc glibc binutils qemu ..." upstream is on going and the source code is here:
https://github.com/c-sky

It's my first patchset to linux and any feedback is welcome :)

Thanks for your submission. I had started reviewing it over a week ago, but never
completed since I was travelling in the meantime. I've completed my first pass now and will wait for a new version before I take a more detailed look.

Overall, it looks nice, but changing the rest of the system call interface will take a while, this includes several points I've mentioned already, but to clarify,
every file in arch/csky/include/uapi/asm/ needs to be carefully reviewed to contain only the minimum required additions to the asm-generic version.

Changing the ABI will obviously get in the way of testing, but this should be over as soon as the port is merged.

Another interesting question is the status of your toolchain support. I see your github account contains binutils and gcc repositories, but they are not upstream yet. Are you working on getting those included in the respective upstream projects already?

Arnd

#60 lore raw
Quoted 5 lines · Arnd Bergmann

Another interesting question is the status of your toolchain support. I see your github account contains binutils and gcc repositories, but they are not upstream yet. Are you working on getting those included in the respective upstream projects already?

We at Mentor Graphics are working on preparing the abiv2 binutils and gcc support for upstream submission. The existing gcc back end for abiv1 is actually completely separate from the abiv2 back end and probably eventually needs to be merged with it, but first things first.

-Sandra

maintainer
#61 lore raw
Quoted 11 lines · Sandra Loosemore
Quoted 8 lines · Arnd Bergmann

Another interesting question is the status of your toolchain support. I see your
github account contains binutils and gcc repositories, but they are not upstream
yet. Are you working on getting those included in the respective upstream projects already?

Quoted 4 lines

We at Mentor Graphics are working on preparing the abiv2 binutils and gcc support for upstream submission. The existing gcc back end for abiv1 is actually completely separate from the abiv2 back end and probably eventually needs to be merged with it, but first things first.

Ok, very good. Being able to build abiv2 is probably sufficient for testing the kernel in a meaningful way, and if you are working on getting that upstream, I trust that it will happen quick enough. I can always provide toolchain binaries on kernel.org based a prerelease version like I did for openrisc, which makes it accessible to other kernel developers doing cross-arch changes.

Arnd

author
#62 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

Thanks for your submission. I had started reviewing it over a week ago, but never
completed since I was travelling in the meantime. I've completed my first pass now and will wait for a new version before I take a more detailed look.

Quoted 8 lines

Overall, it looks nice, but changing the rest of the system call interface will take a while, this includes several points I've mentioned already, but to clarify,
every file in arch/csky/include/uapi/asm/ needs to be carefully reviewed to contain only the minimum required additions to the asm-generic version.

Changing the ABI will obviously get in the way of testing, but this should be over as soon as the port is merged.

I entirely agree with you. After modify the unistd.h, we found a lot of ltp-cases failed. We are dealing with them.

Best Regards
Guo Ren