mbox series

[V4,00/27] C-SKY(csky) Linux Kernel Port

Message ID cover.1536757532.git.ren_guo@c-sky.com
Headers show
Series C-SKY(csky) Linux Kernel Port | expand

Message

Guo Ren Sept. 12, 2018, 1:24 p.m. UTC
This is the 3th version patchset to add the Linux kernel port for C-SKY(csky).
Thanks to everyone who provided feedback on the previous version.

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

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 ck860 (16/32-bit variable length instruction, PIPT Cache,
	 SMP ...)

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

I'm from Hangzhou,China C-SKY Microsystems and responsible for C-SKY Linux
port. The development repo is https://gitlab.com/c-sky/csky-linux

We use buildroot as our CI-test enviornment. "LTP, Lmbench ..."
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://gitlab.com/c-sky/buildroot.git
  $ cd buildroot
  $ make qemu_csky_ck807f_4.18_glibc_defconfig
  $ make
It will download "linux glibc gcc binutils qemu busybox" source code and build
them into one image. How to run, See:
https://c-sky.gitlab.io/-/buildroot/-/jobs/95233371/artifacts/output/images/readme.txt

Any feedback is welcome.

Changes in v4:
 - cleanup defconfig
 - use ksys_ in syscall.c
 - remove wrong comment in vdso.c
 - Use GENERIC_IRQ_MULTI_HANDLER
 - optimize the memset.c
 - fixup dts warnings
 - remove big-endian in byteorder.h

Changes in v3:
dc560f1 csky: change to EM_CSKY 252 for elf.h
2ac3ddf csky: remove gx6605s.dts
af00b8c csky: add defconfig and qemu.dts
6c87efb csky: remove the deprecate name.
f6dda39 csky: add dt-bindings doc.
d9f02a8 csky: remove KERNEL_VERSION in upstream branch
7bd663c csky: Use kernel/dma/noncoherent.c
1544c09 csky: bugfix emmc hang up LINS-976
e963271 csky: cleanup include/asm/Kbuild
cd267ba csky: remove CSKY_DEBUG_INFO
78950da csky: remove dcache invalid.
13fe51d csky: remove csum_ipv6_magic(), use generic one.
a7372db csky: bugfix CK810 access twice error.
1bb7c69 csky: bugfix add gcc asm memory for barrier.
5ea3257 csky: add -msoft-float instead of -mfloat-abi=soft.
38b037d csky: bugfix losing cache flush range.
ab5e8c4 csky: Add ticket-spinlock and qrwlock support.
c9aaec5 csky: rename cskyksyms.c to libgcc_ksyms.c
28c5e48 csky: avoid the MB on failure: trylock
f929c97 csky: bugfix idly4 may cause exception.
09dc496 csky: Use GENERIC_ASHLDI3/ASHRDI3 etc
6ecc99d csky: optimize smp boot code.
16f50df csky: asm/bug.h simple implement.
0ba532a csky: csky asm/atomic.h added.
df66947 csky: asm/compat.h added
275a06f csky: String operations optimization
4c021dd csky: ck860 SMP memory barrier optimize
fc39c66 csky: Add wait/doze/stop
d005144 csky: add GENERIC_ALLOCATOR
4a10074 csky: bugfix cma failed for highmem.
9f2ca70 csky: CMA supported :)
53791f4 csky: optimize csky_dma_alloc_nonatomic
974676e csky: optimize the cpuinfo printf.
2538669 csky: bugfix make headers_install error.
1158d0c csky: prevent hard-float and vdsp instructions.
dc3c856 csky: increase Normal Memory to 1GB
6ee5932 csky: bugfix qemu mmu couldn't support 0xffffe000
1d7dfb8 csky: csky_dma_alloc_atomic added.
caf6610 csky: restruct the fixmap memory layout.
5a17eaa csky: use -Wa,-mcpu=ckxxxfv to the as.
4d51829 csky: use Kconfig.hz.
f3f88fa csky: BUGFIX add -mcpu=ck860f support
6192fd1 csky: support ck860 fpu.
7aa5e01 csky: BUGFIX add smp_mb before ldex.
15758e2 csky: BUGFIX tlbi couldn't handle ASID in another CPU core.
d69640d csky: enable tlbi.vas to flush one tlb entry

Changes in v2:
a29bfc8 csky: add pre_mmu_init, move misc mmu setup to mm/init.c
4eab702 csky: no need kmap for !VM_EXEC.
6770eec csky: Use TEE as the name of CPU Trusted Execution Enviornment.
a56c8c7 csky: update the cache flush api.
1a48a95 csky: add C-SKY Trust Zone.
b7a0a44 csky: use CONFIG_RAM_BASE as the same in memory of dts.
15adf81 csky: remove unused code.
35c0d97 csky: bugfix lost a cacheline flush when start isn't cacheline-aligned.
4e82c8d csky: use tlbi.alls for ck860 smp temporary.
ae7149e csky: bugfix use kmap_atomic() to prevent no mapped addr.
5538795 csky: bugfix user access in kernel space.
a7aa591 csky: add 16bit user space bkpt.
0de70ec csky: add sync.is for cmpxchg in SMP.
c5c08a1 csky: seperate sync.is and sync for SMP and Non-SMP.
dbbf4dc csky: use sync.is for ck860 mb().
f33f8da csky: rewrite the alignment implement.
68152c7 csky: bugfix alignment pt_regs error.
d618d43 csky: support set_affinity for irq balance in SMP
ebf86c9 csky: bugfix compile error without CONFIG_SMP.
8537eea csky: remove debug code.
4ebc051 csky: bugfix compile error with linux-4.9.56
75a938e csky: C-SKY SMP supported.
0eebc07 csky: use internal function for map_sg.
3d29751 csky: bugfix can't support highmem
b545d2a csky: bugfix r26 is the link reg for jsri_to_jsr.
9e3313a csky: bugfix sync tls for abiv1 in ptrace.
587a0d2 csky: use __NR_rt_sigreturn in asm-generic.
f562b46 csky: bugfix gpr_set & fpr_set
f57266f csky: bugfix fpu_fpe_helper excute mtcr mfcr.
c676669 csky: bugfix ave is default enable on reset.
d40d34d csky: remove unused sc_mask in sigcontext.h.
274b7a2 csky: redesign the signal's api
7501771 csky: bugfix forget restore usp.
923e2ca csky: re-struct the pt_regs for regset.
2a1e499 csky: fixup config.
ada81ec csky: bugfix abiv1 compile error.
e34acb9 csky: bugfix abiv1 couldn't support -mno-stack-size.
ec53560 csky: change irq map, reserve soft_irq&private_irq space.
c7576f7 csky: bugfix modpost warning with -mno-stack-size
c8ff9d4 csky: support csky mp timer alpha version.
deabaaf csky: update .gitignore.
574815c csky: bugfix compile error with abiv1 in 4.15
0b426a7 csky: bugfix format of cpu verion id.
083435f csky: irq-csky-v2 alpha init.
21209e5 csky: add .gitignore
73e19b4 csky: remove FMFS_FPU_REGS/FMTS_FPU_REGS
07e8fac csky: add fpu regset in ptrace.c
cac779d csky: add CSKY_VECIRQ_LEGENCY for SOC bug.
54bab1d csky: move usp into pt_regs.
b167422 csky: support regset for ptrace.
a098d4c csky: remove ARCH_WANT_IPC_PARSE_VERSION
fe61a84 csky: add timer-of support.
27702e2 csky: bugfix boot error.
ebe3edb csky: bugfix gx6605s boot failed  - add __HEAD to head.section for head.S  - move INIT_SECTION together to fix compile warning.
7138cae csky: coding convension for timer-nationalchip.c
fa7f9bb csky: use ffs instead of fls.
ddc9e81 csky: change to generic irq chip for irq-csky.c
e9be8b9 irqchip: add generic irq chip for irq-nationalchip
2ee83fe csky: add set_handle_irq(), ref from openrisc & arm.
74181d6 csky: use irq_domain_add_linear instead of leagcy.
fa45ae4 csky: bugfix setup stroge order for uncached.
eb8030f csky: add HIGHMEM config in Kconfig
4f983d4 csky: remove "default n" in Kconfig
2467575 csky: use asm-generic/signal.h
77438e5 csky: coding conventions for irq.c
2e4a2b4 csky: optimize the cache flush ops.
96e1c58 csky: add CONFIG_CPU_ASID_BITS.
9339666 csky: add cprcr() cpwcr() for abiv1
ff05be4 csky: add THREAD_SHIFT define in asm/page.h
52ab022 csky: add mfcr() mtcr() in asm/reg_ops.h
bdcd8f3 csky: revert back Kconfig select.
590c7e6 csky: bugfix compile error with CONFIG_AUDIT
1989292 csky: revert some back with cleanup unistd.h
f1454fe csky: cleanup unistd.h
5d2985f csky: cleanup Kconfig and Makefile.
423d97e csky: cancel subdirectories
cae2af4 csky: use asm-generic/fcntl.h

Guo Ren (27):
  csky: Build infrastructure
  csky: defconfig
  csky: Kernel booting
  csky: Exception handling
  csky: System Call
  csky: Cache and TLB routines
  csky: MMU and page table management
  csky: Process management and Signal
  csky: VDSO and rt_sigreturn
  csky: IRQ handling
  csky: Atomic operations
  csky: ELF and module probe
  csky: Library functions
  csky: User access
  csky: Debug and Ptrace GDB
  csky: SMP support
  csky: Misc headers
  dt-bindings: csky CPU Bindings
  dt-bindings: timer: gx6605s SOC timer
  dt-bindings: timer: C-SKY Multi-processor timer
  dt-bindings: interrupt-controller: C-SKY APB intc
  dt-bindings: interrupt-controller: C-SKY SMP intc
  clocksource: add gx6605s SOC system timer
  clocksource: add C-SKY SMP timer
  clocksource: add C-SKY timers' build infrastructure
  irqchip: add C-SKY irqchip drivers
  dt-bindings: Add vendor prefix for csky

 Documentation/devicetree/bindings/csky/cpus.txt    |  70 ++++
 .../interrupt-controller/csky,apb-intc.txt         |  45 +++
 .../bindings/interrupt-controller/csky,mpintc.txt  |  40 +++
 .../bindings/timer/csky,gx6605s-timer.txt          |  42 +++
 .../devicetree/bindings/timer/csky,mptimer.txt     |  46 +++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/csky/Kconfig                                  | 231 ++++++++++++
 arch/csky/Kconfig.debug                            |  14 +
 arch/csky/Makefile                                 |  93 +++++
 arch/csky/abiv1/Makefile                           |   8 +
 arch/csky/abiv1/alignment.c                        | 331 +++++++++++++++++
 arch/csky/abiv1/bswapdi.c                          |  18 +
 arch/csky/abiv1/bswapsi.c                          |  14 +
 arch/csky/abiv1/cacheflush.c                       |  50 +++
 arch/csky/abiv1/inc/abi/cacheflush.h               |  41 +++
 arch/csky/abiv1/inc/abi/ckmmu.h                    |  74 ++++
 arch/csky/abiv1/inc/abi/entry.h                    | 159 ++++++++
 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                  |  26 ++
 arch/csky/abiv1/inc/abi/regdef.h                   |  25 ++
 arch/csky/abiv1/inc/abi/string.h                   |  13 +
 arch/csky/abiv1/inc/abi/tlb.h                      |  11 +
 arch/csky/abiv1/inc/abi/vdso.h                     |  17 +
 arch/csky/abiv1/memcpy.S                           | 344 ++++++++++++++++++
 arch/csky/abiv1/memset.c                           |  37 ++
 arch/csky/abiv1/mmap.c                             |  65 ++++
 arch/csky/abiv1/strksyms.c                         |   7 +
 arch/csky/abiv2/Makefile                           |  10 +
 arch/csky/abiv2/cacheflush.c                       |  54 +++
 arch/csky/abiv2/fpu.c                              | 281 +++++++++++++++
 arch/csky/abiv2/inc/abi/cacheflush.h               |  38 ++
 arch/csky/abiv2/inc/abi/ckmmu.h                    |  87 +++++
 arch/csky/abiv2/inc/abi/entry.h                    | 157 ++++++++
 arch/csky/abiv2/inc/abi/fpu.h                      |  66 ++++
 arch/csky/abiv2/inc/abi/page.h                     |  14 +
 arch/csky/abiv2/inc/abi/pgtable-bits.h             |  37 ++
 arch/csky/abiv2/inc/abi/reg_ops.h                  |  17 +
 arch/csky/abiv2/inc/abi/regdef.h                   |  26 ++
 arch/csky/abiv2/inc/abi/string.h                   |  28 ++
 arch/csky/abiv2/inc/abi/tlb.h                      |  12 +
 arch/csky/abiv2/inc/abi/vdso.h                     |  24 ++
 arch/csky/abiv2/memcmp.S                           | 151 ++++++++
 arch/csky/abiv2/memcpy.S                           | 110 ++++++
 arch/csky/abiv2/memcpy.c                           |  40 +++
 arch/csky/abiv2/memmove.S                          | 108 ++++++
 arch/csky/abiv2/memset.S                           |  83 +++++
 arch/csky/abiv2/strcmp.S                           | 168 +++++++++
 arch/csky/abiv2/strcpy.S                           | 123 +++++++
 arch/csky/abiv2/strksyms.c                         |  12 +
 arch/csky/abiv2/strlen.S                           |  97 +++++
 arch/csky/abiv2/sysdep.h                           |  29 ++
 arch/csky/boot/Makefile                            |  24 ++
 arch/csky/boot/dts/Makefile                        |  13 +
 arch/csky/boot/dts/include/dt-bindings             |   1 +
 arch/csky/boot/dts/qemu.dts                        |  77 ++++
 arch/csky/configs/defconfig                        |  61 ++++
 arch/csky/include/asm/Kbuild                       |  69 ++++
 arch/csky/include/asm/addrspace.h                  |  10 +
 arch/csky/include/asm/atomic.h                     | 215 +++++++++++
 arch/csky/include/asm/barrier.h                    |  45 +++
 arch/csky/include/asm/bitops.h                     | 281 +++++++++++++++
 arch/csky/include/asm/bug.h                        |  26 ++
 arch/csky/include/asm/cache.h                      |  28 ++
 arch/csky/include/asm/cacheflush.h                 |   8 +
 arch/csky/include/asm/checksum.h                   |  54 +++
 arch/csky/include/asm/cmpxchg.h                    |  70 ++++
 arch/csky/include/asm/compat.h                     |  11 +
 arch/csky/include/asm/elf.h                        | 149 ++++++++
 arch/csky/include/asm/fixmap.h                     |  26 ++
 arch/csky/include/asm/highmem.h                    |  50 +++
 arch/csky/include/asm/io.h                         |  23 ++
 arch/csky/include/asm/irq.h                        |   8 +
 arch/csky/include/asm/irqflags.h                   |  49 +++
 arch/csky/include/asm/mmu.h                        |  11 +
 arch/csky/include/asm/mmu_context.h                | 148 ++++++++
 arch/csky/include/asm/page.h                       | 101 ++++++
 arch/csky/include/asm/pgalloc.h                    | 108 ++++++
 arch/csky/include/asm/pgtable.h                    | 299 ++++++++++++++++
 arch/csky/include/asm/processor.h                  | 120 +++++++
 arch/csky/include/asm/reg_ops.h                    |  22 ++
 arch/csky/include/asm/segment.h                    |  18 +
 arch/csky/include/asm/shmparam.h                   |  10 +
 arch/csky/include/asm/smp.h                        |  26 ++
 arch/csky/include/asm/spinlock.h                   | 286 +++++++++++++++
 arch/csky/include/asm/spinlock_types.h             |  35 ++
 arch/csky/include/asm/string.h                     |  13 +
 arch/csky/include/asm/switch_to.h                  |  35 ++
 arch/csky/include/asm/syscall.h                    |  69 ++++
 arch/csky/include/asm/syscalls.h                   |  14 +
 arch/csky/include/asm/thread_info.h                |  74 ++++
 arch/csky/include/asm/tlb.h                        |  19 +
 arch/csky/include/asm/tlbflush.h                   |  22 ++
 arch/csky/include/asm/traps.h                      |  39 ++
 arch/csky/include/asm/uaccess.h                    | 398 +++++++++++++++++++++
 arch/csky/include/asm/unistd.h                     |   3 +
 arch/csky/include/asm/vdso.h                       |  12 +
 arch/csky/include/uapi/asm/Kbuild                  |  33 ++
 arch/csky/include/uapi/asm/byteorder.h             |   9 +
 arch/csky/include/uapi/asm/cachectl.h              |  13 +
 arch/csky/include/uapi/asm/ptrace.h                | 103 ++++++
 arch/csky/include/uapi/asm/sigcontext.h            |  13 +
 arch/csky/include/uapi/asm/unistd.h                |  10 +
 arch/csky/kernel/Makefile                          |   8 +
 arch/csky/kernel/asm-offsets.c                     |  85 +++++
 arch/csky/kernel/atomic.S                          |  86 +++++
 arch/csky/kernel/cpu-probe.c                       |  78 ++++
 arch/csky/kernel/dumpstack.c                       |  64 ++++
 arch/csky/kernel/entry.S                           | 396 ++++++++++++++++++++
 arch/csky/kernel/head.S                            |  78 ++++
 arch/csky/kernel/irq.c                             |  21 ++
 arch/csky/kernel/module.c                          |  82 +++++
 arch/csky/kernel/platform.c                        |  17 +
 arch/csky/kernel/power.c                           |  30 ++
 arch/csky/kernel/process.c                         | 134 +++++++
 arch/csky/kernel/ptrace.c                          | 317 ++++++++++++++++
 arch/csky/kernel/setup.c                           | 150 ++++++++
 arch/csky/kernel/signal.c                          | 350 ++++++++++++++++++
 arch/csky/kernel/smp.c                             | 234 ++++++++++++
 arch/csky/kernel/syscall.c                         |  42 +++
 arch/csky/kernel/syscall_table.c                   |  13 +
 arch/csky/kernel/time.c                            |  11 +
 arch/csky/kernel/traps.c                           | 168 +++++++++
 arch/csky/kernel/vdso.c                            |  85 +++++
 arch/csky/kernel/vmlinux.lds.S                     |  64 ++++
 arch/csky/lib/Makefile                             |   1 +
 arch/csky/lib/delay.c                              |  40 +++
 arch/csky/lib/usercopy.c                           | 271 ++++++++++++++
 arch/csky/mm/Makefile                              |  13 +
 arch/csky/mm/cachev1.c                             | 126 +++++++
 arch/csky/mm/cachev2.c                             |  79 ++++
 arch/csky/mm/dma-mapping.c                         | 254 +++++++++++++
 arch/csky/mm/fault.c                               | 220 ++++++++++++
 arch/csky/mm/highmem.c                             | 195 ++++++++++
 arch/csky/mm/init.c                                | 118 ++++++
 arch/csky/mm/ioremap.c                             |  48 +++
 arch/csky/mm/syscache.c                            |  28 ++
 arch/csky/mm/tlb.c                                 | 214 +++++++++++
 drivers/clocksource/Kconfig                        |  15 +
 drivers/clocksource/Makefile                       |   2 +
 drivers/clocksource/csky_mptimer.c                 | 178 +++++++++
 drivers/clocksource/timer-gx6605s.c                | 150 ++++++++
 drivers/irqchip/Makefile                           |   1 +
 drivers/irqchip/irq-csky-apb-intc.c                | 243 +++++++++++++
 drivers/irqchip/irq-csky-mpintc.c                  | 191 ++++++++++
 145 files changed, 11917 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/csky/cpus.txt
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
 create mode 100644 Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt
 create mode 100644 Documentation/devicetree/bindings/timer/csky,mptimer.txt
 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/alignment.c
 create mode 100644 arch/csky/abiv1/bswapdi.c
 create mode 100644 arch/csky/abiv1/bswapsi.c
 create mode 100644 arch/csky/abiv1/cacheflush.c
 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/string.h
 create mode 100644 arch/csky/abiv1/inc/abi/tlb.h
 create mode 100644 arch/csky/abiv1/inc/abi/vdso.h
 create mode 100644 arch/csky/abiv1/memcpy.S
 create mode 100644 arch/csky/abiv1/memset.c
 create mode 100644 arch/csky/abiv1/mmap.c
 create mode 100644 arch/csky/abiv1/strksyms.c
 create mode 100644 arch/csky/abiv2/Makefile
 create mode 100644 arch/csky/abiv2/cacheflush.c
 create mode 100644 arch/csky/abiv2/fpu.c
 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/string.h
 create mode 100644 arch/csky/abiv2/inc/abi/tlb.h
 create mode 100644 arch/csky/abiv2/inc/abi/vdso.h
 create mode 100644 arch/csky/abiv2/memcmp.S
 create mode 100644 arch/csky/abiv2/memcpy.S
 create mode 100644 arch/csky/abiv2/memcpy.c
 create mode 100644 arch/csky/abiv2/memmove.S
 create mode 100644 arch/csky/abiv2/memset.S
 create mode 100644 arch/csky/abiv2/strcmp.S
 create mode 100644 arch/csky/abiv2/strcpy.S
 create mode 100644 arch/csky/abiv2/strksyms.c
 create mode 100644 arch/csky/abiv2/strlen.S
 create mode 100644 arch/csky/abiv2/sysdep.h
 create mode 100644 arch/csky/boot/Makefile
 create mode 100644 arch/csky/boot/dts/Makefile
 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/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/atomic.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/bug.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/cmpxchg.h
 create mode 100644 arch/csky/include/asm/compat.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/reg_ops.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/smp.h
 create mode 100644 arch/csky/include/asm/spinlock.h
 create mode 100644 arch/csky/include/asm/spinlock_types.h
 create mode 100644 arch/csky/include/asm/string.h
 create mode 100644 arch/csky/include/asm/switch_to.h
 create mode 100644 arch/csky/include/asm/syscall.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/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/ptrace.h
 create mode 100644 arch/csky/include/uapi/asm/sigcontext.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/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/smp.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/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 drivers/clocksource/csky_mptimer.c
 create mode 100644 drivers/clocksource/timer-gx6605s.c
 create mode 100644 drivers/irqchip/irq-csky-apb-intc.c
 create mode 100644 drivers/irqchip/irq-csky-mpintc.c

Comments

Arnd Bergmann Sept. 12, 2018, 2:22 p.m. UTC | #1
On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
>
> Signed-off-by: Guo Ren <ren_guo@c-sky.com>
> diff --git a/arch/csky/boot/dts/qemu.dts b/arch/csky/boot/dts/qemu.dts
> new file mode 100644
> index 0000000..c6643b1
> --- /dev/null
> +++ b/arch/csky/boot/dts/qemu.dts
> @@ -0,0 +1,77 @@

Did you consider renaming the file as I suggested? I think that would help
in the long run when you get new qemu versions that have a different set
of devices and that may provide their own dtbs.

> diff --git a/arch/csky/include/asm/compat.h b/arch/csky/include/asm/compat.h
> new file mode 100644
> index 0000000..59f9297
> --- /dev/null
> +++ b/arch/csky/include/asm/compat.h
> @@ -0,0 +1,11 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
> +
> +#ifndef __ASM_CSKY_COMPAT_H
> +#define __ASM_CSKY_COMPAT_H
> +
> +#ifdef CONFIG_COMPAT
> +#define COMPAT_UTS_MACHINE "csky\0\0"
> +#endif
> +
> +#endif /* __ASM_CSKY_COMPAT_H */

Just noticed this one. I assume there won't be a csky64 architecture,
so you can probably just delete this header.

         Arnd
Arnd Bergmann Sept. 12, 2018, 2:30 p.m. UTC | #2
On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
>
> This is the 3th version patchset to add the Linux kernel port for C-SKY(csky).
> Thanks to everyone who provided feedback on the previous version.
>
> This patchset adds architecture support to Linux for C-SKY's 32-bit embedded
> CPU cores and the patches are based on linux-4.18.4
>
> 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 ck860 (16/32-bit variable length instruction, PIPT Cache,
>          SMP ...)
>
> More information: http://en.c-sky.com

This looks good to me overall. I think a good next step would be to get the port
included in linux-next, by preparing a git tree with all the patches and asking
Stephen Rothwell to include it there. Further comments on the architecture
port itself can be done on top of the existing patches. I would suggest you
base the git tree on an -rc release (either 4.19-rc1 or 4.19-rc3) and then never
rebase again.

You have included a couple of drivers in the submission: two timer and
two irqchip drivers. Please leave those out for the moment, and either have
them merged through the respective subsystem  trees, or get an Ack
from the maintainers to merge them through your tree.

I notice that a lot of the patches have no changeset comments on them.
You should fix that and make a habit of describing every single patch
with a few sentences, even if it seems obvious to you. Have a look at
the changeset descriptions for the nds32 and riscv architectures when
they got merged.

One big question for me is what to do about time_t. Deepa and I are
in the process of finalizing the system call ABI for 32-bit architectures
with 64-bit time_t, but we are not done yet and it won't be complete
for 4.20. If you target 4.21, that could be a chance to make csky the
first architecture to only need the 64-bit time_t interface, with the
corresponding user space changes.

        Arnd
Peter Zijlstra Sept. 12, 2018, 3:55 p.m. UTC | #3
On Wed, Sep 12, 2018 at 09:24:45PM +0800, Guo Ren wrote:

> +#define ATOMIC_OP(op, c_op)						\
> +static inline void atomic_##op(int i, atomic_t *v)			\
> +{									\
> +	unsigned long tmp;						\
> +									\
> +	smp_mb();							\
> +	asm volatile (							\
> +	"1:	ldex.w		%0, (%2) \n"				\
> +	"	" #op "		%0, %1   \n"				\
> +	"	stex.w		%0, (%2) \n"				\
> +	"	bez		%0, 1b   \n"				\
> +		: "=&r" (tmp)						\
> +		: "r" (i), "r"(&v->counter)				\
> +		: "memory");						\
> +	smp_mb();							\
> +}

ATOMIC_OP doesn't need to imply any smp_mb()'s what so ever.

> +#define ATOMIC_OP_RETURN(op, c_op)					\
> +static inline int atomic_##op##_return(int i, atomic_t *v)		\
> +{									\
> +	unsigned long tmp, ret;						\
> +									\
> +	smp_mb();							\
> +	asm volatile (							\
> +	"1:	ldex.w		%0, (%3) \n"				\
> +	"	" #op "		%0, %2   \n"				\
> +	"	mov		%1, %0   \n"				\
> +	"	stex.w		%0, (%3) \n"				\
> +	"	bez		%0, 1b   \n"				\
> +		: "=&r" (tmp), "=&r" (ret)				\
> +		: "r" (i), "r"(&v->counter)				\
> +		: "memory");						\
> +	smp_mb();							\
> +									\
> +	return ret;							\
> +}
> +
> +#define ATOMIC_FETCH_OP(op, c_op)					\
> +static inline int atomic_fetch_##op(int i, atomic_t *v)			\
> +{									\
> +	unsigned long tmp, ret;						\
> +									\
> +	smp_mb();							\
> +	asm volatile (							\
> +	"1:	ldex.w		%0, (%3) \n"				\
> +	"	mov		%1, %0   \n"				\
> +	"	" #op "		%0, %2   \n"				\
> +	"	stex.w		%0, (%3) \n"				\
> +	"	bez		%0, 1b   \n"				\
> +		: "=&r" (tmp), "=&r" (ret)				\
> +		: "r" (i), "r"(&v->counter)				\
> +		: "memory");						\
> +	smp_mb();							\
> +									\
> +	return ret;							\
> +}

For these you could generate _relaxed variants and not provide smp_mb()
inside them.

> +#else /* CONFIG_CPU_HAS_LDSTEX */
> +
> +#include <linux/irqflags.h>
> +

> +#define ATOMIC_OP(op, c_op)						\
> +static inline void atomic_##op(int i, atomic_t *v)			\
> +{									\
> +	unsigned long tmp, flags;					\
> +									\
> +	raw_local_irq_save(flags);					\
> +									\
> +	asm volatile (							\
> +	"	ldw		%0, (%2) \n"				\
> +	"	" #op "		%0, %1   \n"				\
> +	"	stw		%0, (%2) \n"				\
> +		: "=&r" (tmp)						\
> +		: "r" (i), "r"(&v->counter)				\
> +		: "memory");						\
> +									\
> +	raw_local_irq_restore(flags);					\
> +}

Is this really 'better' than the generic UP fallback implementation?





> diff --git a/arch/csky/include/asm/spinlock.h b/arch/csky/include/asm/spinlock.h
> new file mode 100644
> index 0000000..f1081bb
> --- /dev/null
> +++ b/arch/csky/include/asm/spinlock.h
> @@ -0,0 +1,286 @@
> +#ifndef __ASM_CSKY_SPINLOCK_H
> +#define __ASM_CSKY_SPINLOCK_H
> +
> +#include <linux/spinlock_types.h>
> +#include <asm/barrier.h>
> +
> +#ifdef CONFIG_QUEUED_RWLOCKS
> +
> +/*
> + * Ticket-based spin-locking.
> + */
> +static inline void arch_spin_lock(arch_spinlock_t *lock)
> +{
> +	arch_spinlock_t lockval;
> +	u32 ticket_next = 1 << TICKET_NEXT;
> +	u32 *p = &lock->lock;
> +	u32 tmp;
> +
> +	smp_mb();

spin_lock() doesn't need smp_mb() before.

> +	asm volatile (
> +		"1:	ldex.w		%0, (%2) \n"
> +		"	mov		%1, %0	 \n"
> +		"	add		%0, %3	 \n"
> +		"	stex.w		%0, (%2) \n"
> +		"	bez		%0, 1b   \n"
> +		: "=&r" (tmp), "=&r" (lockval)
> +		: "r"(p), "r"(ticket_next)
> +		: "cc");
> +
> +	while (lockval.tickets.next != lockval.tickets.owner) {
> +		lockval.tickets.owner = READ_ONCE(lock->tickets.owner);
> +	}
> +
> +	smp_mb();
> +}
> +
> +static inline int arch_spin_trylock(arch_spinlock_t *lock)
> +{
> +	u32 tmp, contended, res;
> +	u32 ticket_next = 1 << TICKET_NEXT;
> +	u32 *p = &lock->lock;
> +
> +	smp_mb();

idem.

> +	do {
> +		asm volatile (
> +		"	ldex.w		%0, (%3)   \n"
> +		"	movi		%2, 1	   \n"
> +		"	rotli		%1, %0, 16 \n"
> +		"	cmpne		%1, %0     \n"
> +		"	bt		1f         \n"
> +		"	movi		%2, 0	   \n"
> +		"	add		%0, %0, %4 \n"
> +		"	stex.w		%0, (%3)   \n"
> +		"1:				   \n"
> +		: "=&r" (res), "=&r" (tmp), "=&r" (contended)
> +		: "r"(p), "r"(ticket_next)
> +		: "cc");
> +	} while (!res);
> +
> +	if (!contended)
> +		smp_mb();
> +
> +	return !contended;
> +}
> +
> +static inline void arch_spin_unlock(arch_spinlock_t *lock)
> +{
> +	smp_mb();
> +	lock->tickets.owner++;
> +	smp_mb();

spin_unlock() doesn't need smp_mb() after.

> +}
> +
> +static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
> +{
> +	return lock.tickets.owner == lock.tickets.next;
> +}
> +
> +static inline int arch_spin_is_locked(arch_spinlock_t *lock)
> +{
> +	return !arch_spin_value_unlocked(READ_ONCE(*lock));
> +}
> +
> +static inline int arch_spin_is_contended(arch_spinlock_t *lock)
> +{
> +	struct __raw_tickets tickets = READ_ONCE(lock->tickets);
> +	return (tickets.next - tickets.owner) > 1;
> +}
> +#define arch_spin_is_contended	arch_spin_is_contended
> +
> +#include <asm/qrwlock.h>
> +
> +/* See include/linux/spinlock.h */
> +#define smp_mb__after_spinlock()	smp_mb()
> +
> +#else /* CONFIG_QUEUED_RWLOCKS */
> +
> +/*
> + * Test-and-set spin-locking.
> + */

Why retain that?

same comments; it has far too many smp_mb()s in.

> +#endif /* CONFIG_QUEUED_RWLOCKS */
> +#endif /* __ASM_CSKY_SPINLOCK_H */
> diff --git a/arch/csky/include/asm/spinlock_types.h b/arch/csky/include/asm/spinlock_types.h
> new file mode 100644
> index 0000000..7e825c2
> --- /dev/null
> +++ b/arch/csky/include/asm/spinlock_types.h
> @@ -0,0 +1,35 @@
> +#ifndef __ASM_CSKY_SPINLOCK_TYPES_H
> +#define __ASM_CSKY_SPINLOCK_TYPES_H
> +
> +#ifndef __LINUX_SPINLOCK_TYPES_H
> +# error "please don't include this file directly"
> +#endif
> +
> +#define TICKET_NEXT	16
> +
> +typedef struct {
> +	union {
> +		u32 lock;
> +		struct __raw_tickets {
> +			/* little endian */
> +			u16 owner;
> +			u16 next;
> +		} tickets;
> +	};
> +} arch_spinlock_t;
> +
> +#define __ARCH_SPIN_LOCK_UNLOCKED	{ { 0 } }
> +
> +#ifdef CONFIG_QUEUED_RWLOCKS
> +#include <asm-generic/qrwlock_types.h>
> +
> +#else /* CONFIG_NR_CPUS > 2 */
> +
> +typedef struct {
> +	u32 lock;
> +} arch_rwlock_t;
> +
> +#define __ARCH_RW_LOCK_UNLOCKED		{ 0 }
> +
> +#endif /* CONFIG_QUEUED_RWLOCKS */
> +#endif /* __ASM_CSKY_SPINLOCK_TYPES_H */
Guo Ren Sept. 14, 2018, 2:37 p.m. UTC | #4
On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > This is the 3th version patchset to add the Linux kernel port for C-SKY(csky).
> > Thanks to everyone who provided feedback on the previous version.
> >
> > This patchset adds architecture support to Linux for C-SKY's 32-bit embedded
> > CPU cores and the patches are based on linux-4.18.4
> >
> > 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 ck860 (16/32-bit variable length instruction, PIPT Cache,
> >          SMP ...)
> >
> > More information: http://en.c-sky.com
> 
> This looks good to me overall. I think a good next step would be to get the port
> included in linux-next, by preparing a git tree with all the patches and asking
> Stephen Rothwell to include it there. Further comments on the architecture
> port itself can be done on top of the existing patches. I would suggest you
> base the git tree on an -rc release (either 4.19-rc1 or 4.19-rc3) and then never
> rebase again.
Nice :) I'll follow the rules.

> 
> You have included a couple of drivers in the submission: two timer and
> two irqchip drivers. Please leave those out for the moment, and either have
> them merged through the respective subsystem  trees, or get an Ack
> from the maintainers to merge them through your tree.
Ok. 

> 
> I notice that a lot of the patches have no changeset comments on them.
> You should fix that and make a habit of describing every single patch
> with a few sentences, even if it seems obvious to you. Have a look at
> the changeset descriptions for the nds32 and riscv architectures when
> they got merged.
Ok, I'll fixup them.

> 
> One big question for me is what to do about time_t. Deepa and I are
> in the process of finalizing the system call ABI for 32-bit architectures
> with 64-bit time_t, but we are not done yet and it won't be complete
> for 4.20. If you target 4.21, that could be a chance to make csky the
> first architecture to only need the 64-bit time_t interface, with the
> corresponding user space changes.
y2038 is very important and csky32 has the issue. But 4.21 is too late for
us, we really want to get into kernel.org as soon as possible.
We could remove 32-bit time_t in future.

Best Regards
 Guo Ren
Arnd Bergmann Sept. 14, 2018, 2:46 p.m. UTC | #5
On Fri, Sep 14, 2018 at 4:37 PM Guo Ren <ren_guo@c-sky.com> wrote:
> On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> > On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > One big question for me is what to do about time_t. Deepa and I are
> > in the process of finalizing the system call ABI for 32-bit architectures
> > with 64-bit time_t, but we are not done yet and it won't be complete
> > for 4.20. If you target 4.21, that could be a chance to make csky the
> > first architecture to only need the 64-bit time_t interface, with the
> > corresponding user space changes.
> y2038 is very important and csky32 has the issue. But 4.21 is too late for
> us, we really want to get into kernel.org as soon as possible.
> We could remove 32-bit time_t in future.

Not really: the way we deal with user-visible APIs in the kernel, it's
practically impossible to remove something that was working before,
since there may always be users relying on it. This is why it is so
important that we get the ABI right at the first try.

We can always add new ABIs later, and that's what we're doing with
all the other 32-bit architectures as well: each system call that takes a
32-bit time_t argument also needs to get the corresponding 64-bit
replacement, and then we have to keep them both around.

However, once the 64-bit syscalls are there, you don't need to
use them, so if you merge the glibc port after both csky and
the time64 syscalls are merged upstream, you can choose
to only support the time64 syscalls rather than making it a compile
time decision in each application. If you merge the glibc port
before migrating to 64-bit syscalls, glibc will also have to support
both indefinitely for compatibility with existing binaries.

One level below that, you can of course choose to build
a distro with only 64-bit time_t regardless of whether there
is still support for 32-bit time_t in kernel and glibc or not.

        Arnd
Guo Ren Sept. 14, 2018, 4:02 p.m. UTC | #6
On Fri, Sep 14, 2018 at 04:46:56PM +0200, Arnd Bergmann wrote:
> On Fri, Sep 14, 2018 at 4:37 PM Guo Ren <ren_guo@c-sky.com> wrote:
> > On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> > > On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> > >
> > > One big question for me is what to do about time_t. Deepa and I are
> > > in the process of finalizing the system call ABI for 32-bit architectures
> > > with 64-bit time_t, but we are not done yet and it won't be complete
> > > for 4.20. If you target 4.21, that could be a chance to make csky the
> > > first architecture to only need the 64-bit time_t interface, with the
> > > corresponding user space changes.
> > y2038 is very important and csky32 has the issue. But 4.21 is too late for
> > us, we really want to get into kernel.org as soon as possible.
> > We could remove 32-bit time_t in future.
> 
> Not really: the way we deal with user-visible APIs in the kernel, it's
> practically impossible to remove something that was working before,
> since there may always be users relying on it. This is why it is so
> important that we get the ABI right at the first try.
> 
> We can always add new ABIs later, and that's what we're doing with
> all the other 32-bit architectures as well: each system call that takes a
> 32-bit time_t argument also needs to get the corresponding 64-bit
> replacement, and then we have to keep them both around.
> 
> However, once the 64-bit syscalls are there, you don't need to
> use them, so if you merge the glibc port after both csky and
> the time64 syscalls are merged upstream, you can choose
> to only support the time64 syscalls rather than making it a compile
> time decision in each application. If you merge the glibc port
> before migrating to 64-bit syscalls, glibc will also have to support
> both indefinitely for compatibility with existing binaries.
> 
> One level below that, you can of course choose to build
> a distro with only 64-bit time_t regardless of whether there
> is still support for 32-bit time_t in kernel and glibc or not.
Do you mean I could merge kernel port into linux-4.19 or linux-4.20.
But let glibc merged after linux-4.21 and csky glibc only support
time64 syscalls ?

Best Regards
 Guo Ren
Arnd Bergmann Sept. 14, 2018, 4:09 p.m. UTC | #7
On Fri, Sep 14, 2018 at 6:02 PM Guo Ren <ren_guo@c-sky.com> wrote:
>
> On Fri, Sep 14, 2018 at 04:46:56PM +0200, Arnd Bergmann wrote:
> > On Fri, Sep 14, 2018 at 4:37 PM Guo Ren <ren_guo@c-sky.com> wrote:
>
> > One level below that, you can of course choose to build
> > a distro with only 64-bit time_t regardless of whether there
> > is still support for 32-bit time_t in kernel and glibc or not.
> Do you mean I could merge kernel port into linux-4.19 or linux-4.20.
> But let glibc merged after linux-4.21 and csky glibc only support
> time64 syscalls ?

Yes, that's what I meant. Note that it won't get merged into 4.19:
the merge window for that was after the 4.18 release and no
new features are getting merged for 4.19 that have not made it
into 4.19-rc1 already.

Getting your code into linux-next now is the prerequisite for you
sending a pull request during the 4.20 window.

     Arnd
Guo Ren Sept. 14, 2018, 11:28 p.m. UTC | #8
On Fri, Sep 14, 2018 at 06:09:35PM +0200, Arnd Bergmann wrote:
> On Fri, Sep 14, 2018 at 6:02 PM Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > On Fri, Sep 14, 2018 at 04:46:56PM +0200, Arnd Bergmann wrote:
> > > On Fri, Sep 14, 2018 at 4:37 PM Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > > One level below that, you can of course choose to build
> > > a distro with only 64-bit time_t regardless of whether there
> > > is still support for 32-bit time_t in kernel and glibc or not.
> > Do you mean I could merge kernel port into linux-4.19 or linux-4.20.
> > But let glibc merged after linux-4.21 and csky glibc only support
> > time64 syscalls ?
> 
> Yes, that's what I meant. Note that it won't get merged into 4.19:
> the merge window for that was after the 4.18 release and no
> new features are getting merged for 4.19 that have not made it
> into 4.19-rc1 already.
> 
> Getting your code into linux-next now is the prerequisite for you
> sending a pull request during the 4.20 window.
Got it, thank you very much.

 Guo Ren
Guo Ren Sept. 15, 2018, 2:55 p.m. UTC | #9
Thx for the review, that's very helpful.

On Wed, Sep 12, 2018 at 05:55:14PM +0200, Peter Zijlstra wrote:
> On Wed, Sep 12, 2018 at 09:24:45PM +0800, Guo Ren wrote:
> 
> > +#define ATOMIC_OP(op, c_op)						\
> > +static inline void atomic_##op(int i, atomic_t *v)			\
> > +{									\
> > +	unsigned long tmp;						\
> > +									\
> > +	smp_mb();							\
> > +	asm volatile (							\
> > +	"1:	ldex.w		%0, (%2) \n"				\
> > +	"	" #op "		%0, %1   \n"				\
> > +	"	stex.w		%0, (%2) \n"				\
> > +	"	bez		%0, 1b   \n"				\
> > +		: "=&r" (tmp)						\
> > +		: "r" (i), "r"(&v->counter)				\
> > +		: "memory");						\
> > +	smp_mb();							\
> > +}
> 
> ATOMIC_OP doesn't need to imply any smp_mb()'s what so ever.
Ok.

> > +#define ATOMIC_OP_RETURN(op, c_op)					\
> > +static inline int atomic_##op##_return(int i, atomic_t *v)		\
> > +{									\
> > +	unsigned long tmp, ret;						\
> > +									\
> > +	smp_mb();							\
> > +	asm volatile (							\
> > +	"1:	ldex.w		%0, (%3) \n"				\
> > +	"	" #op "		%0, %2   \n"				\
> > +	"	mov		%1, %0   \n"				\
> > +	"	stex.w		%0, (%3) \n"				\
> > +	"	bez		%0, 1b   \n"				\
> > +		: "=&r" (tmp), "=&r" (ret)				\
> > +		: "r" (i), "r"(&v->counter)				\
> > +		: "memory");						\
> > +	smp_mb();							\
> > +									\
> > +	return ret;							\
> > +}
> > +
> > +#define ATOMIC_FETCH_OP(op, c_op)					\
> > +static inline int atomic_fetch_##op(int i, atomic_t *v)			\
> > +{									\
> > +	unsigned long tmp, ret;						\
> > +									\
> > +	smp_mb();							\
> > +	asm volatile (							\
> > +	"1:	ldex.w		%0, (%3) \n"				\
> > +	"	mov		%1, %0   \n"				\
> > +	"	" #op "		%0, %2   \n"				\
> > +	"	stex.w		%0, (%3) \n"				\
> > +	"	bez		%0, 1b   \n"				\
> > +		: "=&r" (tmp), "=&r" (ret)				\
> > +		: "r" (i), "r"(&v->counter)				\
> > +		: "memory");						\
> > +	smp_mb();							\
> > +									\
> > +	return ret;							\
> > +}
> 
> For these you could generate _relaxed variants and not provide smp_mb()
> inside them.
Ok, but I'll modify it in next commit.
 
> > +#else /* CONFIG_CPU_HAS_LDSTEX */
> > +
> > +#include <linux/irqflags.h>
> > +
> 
> > +#define ATOMIC_OP(op, c_op)						\
> > +static inline void atomic_##op(int i, atomic_t *v)			\
> > +{									\
> > +	unsigned long tmp, flags;					\
> > +									\
> > +	raw_local_irq_save(flags);					\
> > +									\
> > +	asm volatile (							\
> > +	"	ldw		%0, (%2) \n"				\
> > +	"	" #op "		%0, %1   \n"				\
> > +	"	stw		%0, (%2) \n"				\
> > +		: "=&r" (tmp)						\
> > +		: "r" (i), "r"(&v->counter)				\
> > +		: "memory");						\
> > +									\
> > +	raw_local_irq_restore(flags);					\
> > +}
> 
> Is this really 'better' than the generic UP fallback implementation?
There is a lock irq instruction "idly4" with out irq_save. eg:
	asm volatile (							\
	"	idly4			 \n"				\
	"	ldw		%0, (%2) \n"				\
	"	" #op "		%0, %1   \n"				\
	"	stw		%0, (%2) \n"				\
I'll change to that after full tested.

> > +static inline void arch_spin_lock(arch_spinlock_t *lock)
> > +{
> > +	arch_spinlock_t lockval;
> > +	u32 ticket_next = 1 << TICKET_NEXT;
> > +	u32 *p = &lock->lock;
> > +	u32 tmp;
> > +
> > +	smp_mb();
> 
> spin_lock() doesn't need smp_mb() before.
read_lock and write_lock also needn't smp_mb() before, isn't it?

> > +
> > +static inline void arch_spin_unlock(arch_spinlock_t *lock)
> > +{
> > +	smp_mb();
> > +	lock->tickets.owner++;
> > +	smp_mb();
> 
> spin_unlock() doesn't need smp_mb() after.
read_unlock and write_unlock also needn't smp_mb() after, isn't it?

> > +#else /* CONFIG_QUEUED_RWLOCKS */
> > +
> > +/*
> > + * Test-and-set spin-locking.
> > + */
> 
> Why retain that?
> 
> same comments; it has far too many smp_mb()s in.
I'm not sure about queued_rwlocks and just for 2-cores-smp test-and-set is
faster and simpler, isn't it?

Best Regards
 Guo Ren
Guo Ren Sept. 16, 2018, 1:07 a.m. UTC | #10
On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > This is the 3th version patchset to add the Linux kernel port for C-SKY(csky).
> > Thanks to everyone who provided feedback on the previous version.
> >
> > This patchset adds architecture support to Linux for C-SKY's 32-bit embedded
> > CPU cores and the patches are based on linux-4.18.4
> >
> > 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 ck860 (16/32-bit variable length instruction, PIPT Cache,
> >          SMP ...)
> >
> > More information: http://en.c-sky.com
> 
> This looks good to me overall. I think a good next step would be to get the port
> included in linux-next, by preparing a git tree with all the patches and asking
> Stephen Rothwell to include it there. Further comments on the architecture
> port itself can be done on top of the existing patches. I would suggest you
> base the git tree on an -rc release (either 4.19-rc1 or 4.19-rc3) and then never
> rebase again.
Another question:
Could I add "Acked-by: Arnd Bergmann <arnd@arndb.de>" in all my comments?

Best Regards
 Guo Ren
Guo Ren Sept. 16, 2018, 4:53 a.m. UTC | #11
Hello Stephen,

I'm Guo Ren from C-SKY and I'm working on csky linux port upstream.
I've prepared my git-tree based on linux-4.19-rc3:
git clone -b linux-next https://github.com/c-sky/csky-linux.git

Here is the pre-built cross compiler for fast test from our CI:
https://gitlab.com/c-sky/buildroot/-/jobs/97941896/artifacts/file/output/images/csky_toolchain_csky_ck860_platform_defconfig_72371bf75a51f27ea59fc34eeaf236e06b75bf69.tar.xz

You can also build newest gcc, binutils and they are upstreamed but not
released on gnu.org. Glibc is uptreaming now.

Please have a look and any feed back is welcome.

Best Regards
  Guo Ren

On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > This is the 3th version patchset to add the Linux kernel port for C-SKY(csky).
> > Thanks to everyone who provided feedback on the previous version.
> >
> > This patchset adds architecture support to Linux for C-SKY's 32-bit embedded
> > CPU cores and the patches are based on linux-4.18.4
> >
> > 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 ck860 (16/32-bit variable length instruction, PIPT Cache,
> >          SMP ...)
> >
> > More information: http://en.c-sky.com
> 
> This looks good to me overall. I think a good next step would be to get the port
> included in linux-next, by preparing a git tree with all the patches and asking
> Stephen Rothwell to include it there. Further comments on the architecture
> port itself can be done on top of the existing patches. I would suggest you
> base the git tree on an -rc release (either 4.19-rc1 or 4.19-rc3) and then never
> rebase again.
> 
> You have included a couple of drivers in the submission: two timer and
> two irqchip drivers. Please leave those out for the moment, and either have
> them merged through the respective subsystem  trees, or get an Ack
> from the maintainers to merge them through your tree.
> 
> I notice that a lot of the patches have no changeset comments on them.
> You should fix that and make a habit of describing every single patch
> with a few sentences, even if it seems obvious to you. Have a look at
> the changeset descriptions for the nds32 and riscv architectures when
> they got merged.
> 
> One big question for me is what to do about time_t. Deepa and I are
> in the process of finalizing the system call ABI for 32-bit architectures
> with 64-bit time_t, but we are not done yet and it won't be complete
> for 4.20. If you target 4.21, that could be a chance to make csky the
> first architecture to only need the 64-bit time_t interface, with the
> corresponding user space changes.
> 
>         Arnd
Peter Zijlstra Sept. 17, 2018, 8:17 a.m. UTC | #12
On Sat, Sep 15, 2018 at 10:55:13PM +0800, Guo Ren wrote:
> > > +#define ATOMIC_OP_RETURN(op, c_op)					\

> > > +#define ATOMIC_FETCH_OP(op, c_op)					\

> > For these you could generate _relaxed variants and not provide smp_mb()
> > inside them.
> Ok, but I'll modify it in next commit.

That's fine. Just wanted to let you know about _relaxed() since it will
benefit your platform.

> > > +#define ATOMIC_OP(op, c_op)						\
> > > +static inline void atomic_##op(int i, atomic_t *v)			\
> > > +{									\
> > > +	unsigned long tmp, flags;					\
> > > +									\
> > > +	raw_local_irq_save(flags);					\
> > > +									\
> > > +	asm volatile (							\
> > > +	"	ldw		%0, (%2) \n"				\
> > > +	"	" #op "		%0, %1   \n"				\
> > > +	"	stw		%0, (%2) \n"				\
> > > +		: "=&r" (tmp)						\
> > > +		: "r" (i), "r"(&v->counter)				\
> > > +		: "memory");						\
> > > +									\
> > > +	raw_local_irq_restore(flags);					\
> > > +}
> > 
> > Is this really 'better' than the generic UP fallback implementation?
> There is a lock irq instruction "idly4" with out irq_save. eg:
> 	asm volatile (							\
> 	"	idly4			 \n"				\
> 	"	ldw		%0, (%2) \n"				\
> 	"	" #op "		%0, %1   \n"				\
> 	"	stw		%0, (%2) \n"				\
> I'll change to that after full tested.

That is pretty nifty, could you explain (or reference me to a arch doc
that does) the exact semantics of that "idly4" instruction?

> > > +static inline void arch_spin_lock(arch_spinlock_t *lock)
> > > +{
> > > +	arch_spinlock_t lockval;
> > > +	u32 ticket_next = 1 << TICKET_NEXT;
> > > +	u32 *p = &lock->lock;
> > > +	u32 tmp;
> > > +
> > > +	smp_mb();
> > 
> > spin_lock() doesn't need smp_mb() before.
> read_lock and write_lock also needn't smp_mb() before, isn't it?

Correct. The various *_lock() functions only need imply an ACQUIRE
barrier, such that the critical section happens after the lock is taken.

> > > +
> > > +static inline void arch_spin_unlock(arch_spinlock_t *lock)
> > > +{
> > > +	smp_mb();
> > > +	lock->tickets.owner++;
> > > +	smp_mb();
> > 
> > spin_unlock() doesn't need smp_mb() after.
> read_unlock and write_unlock also needn't smp_mb() after, isn't it?

Indeed so, the various *_unlock() functions only need imply a RELEASE
barrier, such that the critical section happend before the lock is
released.

In both cases (lock and unlock) there is a great amount of subtle
details, but most of that is irrelevant if all you have is smp_mb().


> > > +/*
> > > + * Test-and-set spin-locking.
> > > + */
> > 
> > Why retain that?
> > 
> > same comments; it has far too many smp_mb()s in.
> I'm not sure about queued_rwlocks and just for 2-cores-smp test-and-set is
> faster and simpler, isn't it?

Even on 2 cores I think you can create starvation cases with
test-and-set spinlocks. And the maintenace overhead of carrying two lock
implementations is non trivial.

As to performance; I cannot say, but the ticket lock isn't very
expensive, you could benchmark of course.
Stephen Rothwell Sept. 17, 2018, 11:54 a.m. UTC | #13
Hi Guo,

On Sun, 16 Sep 2018 12:53:26 +0800 Guo Ren <ren_guo@c-sky.com> wrote:
>
> I'm Guo Ren from C-SKY and I'm working on csky linux port upstream.
> I've prepared my git-tree based on linux-4.19-rc3:
> git clone -b linux-next https://github.com/c-sky/csky-linux.git
> 
> Here is the pre-built cross compiler for fast test from our CI:
> https://gitlab.com/c-sky/buildroot/-/jobs/97941896/artifacts/file/output/images/csky_toolchain_csky_ck860_platform_defconfig_72371bf75a51f27ea59fc34eeaf236e06b75bf69.tar.xz
> 
> You can also build newest gcc, binutils and they are upstreamed but not
> released on gnu.org. Glibc is uptreaming now.
> 
> Please have a look and any feed back is welcome.

Added from today (called "csky").

Thanks for adding your subsystem tree as a participant of linux-next.  As
you may know, this is not a judgement of your code.  The purpose of
linux-next is for integration testing and to lower the impact of
conflicts between subsystems in the next merge window. 

You will need to ensure that the patches/commits in your tree/series have
been:
     * submitted under GPL v2 (or later) and include the Contributor's
        Signed-off-by,
     * posted to the relevant mailing list,
     * reviewed by you (or another maintainer of your subsystem tree),
     * successfully unit tested, and 
     * destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him
to fetch).  It is allowed to be rebased if you deem it necessary.
Stephen Rothwell Sept. 17, 2018, 12:03 p.m. UTC | #14
Hi Guo,

On Mon, 17 Sep 2018 21:54:43 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Added from today (called "csky").

Actually from tomorrow :-)
Guo Ren Sept. 17, 2018, 2:37 p.m. UTC | #15
On Mon, Sep 17, 2018 at 09:54:43PM +1000, Stephen Rothwell wrote:
> Hi Guo,
> 
> On Sun, 16 Sep 2018 12:53:26 +0800 Guo Ren <ren_guo@c-sky.com> wrote:
> >
> > I'm Guo Ren from C-SKY and I'm working on csky linux port upstream.
> > I've prepared my git-tree based on linux-4.19-rc3:
> > git clone -b linux-next https://github.com/c-sky/csky-linux.git
> > 
> > Here is the pre-built cross compiler for fast test from our CI:
> > https://gitlab.com/c-sky/buildroot/-/jobs/97941896/artifacts/file/output/images/csky_toolchain_csky_ck860_platform_defconfig_72371bf75a51f27ea59fc34eeaf236e06b75bf69.tar.xz
> > 
> > You can also build newest gcc, binutils and they are upstreamed but not
> > released on gnu.org. Glibc is uptreaming now.
> > 
> > Please have a look and any feed back is welcome.
> 
> Added from today (called "csky").
> 
> Thanks for adding your subsystem tree as a participant of linux-next.  As
> you may know, this is not a judgement of your code.  The purpose of
> linux-next is for integration testing and to lower the impact of
> conflicts between subsystems in the next merge window. 
> 
> You will need to ensure that the patches/commits in your tree/series have
> been:
>      * submitted under GPL v2 (or later) and include the Contributor's
>         Signed-off-by,
>      * posted to the relevant mailing list,
>      * reviewed by you (or another maintainer of your subsystem tree),
>      * successfully unit tested, and 
>      * destined for the current or next Linux merge window.
> 
> Basically, this should be just what you would send to Linus (or ask him
> to fetch).  It is allowed to be rebased if you deem it necessary.

 I am very excited to receive your mail. I have been preparing for this
 for nearly 3 years.

 - All files are under GPL v2
 
 - All Contributors have been Signed-off.

 - All have been reviewed.

 - For develop detail you can find in: https://github.com/c-sky/csky-linux
   It records from 'Dec 2015' to 'Sep 2018'.

 - Here is the newest ltp test result: https://gitlab.com/c-sky/buildroot/-/jobs/98061317

 Best Regards
  Guo Ren
Guo Ren Sept. 17, 2018, 2:50 p.m. UTC | #16
On Mon, Sep 17, 2018 at 10:03:57PM +1000, Stephen Rothwell wrote:
> Hi Guo,
> 
> On Mon, 17 Sep 2018 21:54:43 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > Added from today (called "csky").
> 
> Actually from tomorrow :-)
Ok.
Guo Ren Sept. 17, 2018, 3:05 p.m. UTC | #17
On Mon, Sep 17, 2018 at 10:17:55AM +0200, Peter Zijlstra wrote:
> On Sat, Sep 15, 2018 at 10:55:13PM +0800, Guo Ren wrote:
> > > > +#define ATOMIC_OP_RETURN(op, c_op)					\
> 
> > > > +#define ATOMIC_FETCH_OP(op, c_op)					\
> 
> > > For these you could generate _relaxed variants and not provide smp_mb()
> > > inside them.
> > Ok, but I'll modify it in next commit.
> 
> That's fine. Just wanted to let you know about _relaxed() since it will
> benefit your platform.
Thank you.

> > > > +#define ATOMIC_OP(op, c_op)						\
> > > > +static inline void atomic_##op(int i, atomic_t *v)			\
> > > > +{									\
> > > > +	unsigned long tmp, flags;					\
> > > > +									\
> > > > +	raw_local_irq_save(flags);					\
> > > > +									\
> > > > +	asm volatile (							\
> > > > +	"	ldw		%0, (%2) \n"				\
> > > > +	"	" #op "		%0, %1   \n"				\
> > > > +	"	stw		%0, (%2) \n"				\
> > > > +		: "=&r" (tmp)						\
> > > > +		: "r" (i), "r"(&v->counter)				\
> > > > +		: "memory");						\
> > > > +									\
> > > > +	raw_local_irq_restore(flags);					\
> > > > +}
> > > 
> > > Is this really 'better' than the generic UP fallback implementation?
> > There is a lock irq instruction "idly4" with out irq_save. eg:
> > 	asm volatile (							\
> > 	"	idly4			 \n"				\
> > 	"	ldw		%0, (%2) \n"				\
> > 	"	" #op "		%0, %1   \n"				\
> > 	"	stw		%0, (%2) \n"				\
> > I'll change to that after full tested.
> 
> That is pretty nifty, could you explain (or reference me to a arch doc
> that does) the exact semantics of that "idly4" instruction?
The idly4 allows the 4 instructions behind it to not respond to interrupts.
When ldw got exception, it will cause the carry to be 1. So I need
prepare the assemble like this:
1:	cmpne r0, r0
	idly4
	ldw	%0, (%2)
	bt	1b
	" #op " ...
	stw ...

I need more stress test on it and then I'll change to it.

> > > > +static inline void arch_spin_lock(arch_spinlock_t *lock)
> > > > +{
> > > > +	arch_spinlock_t lockval;
> > > > +	u32 ticket_next = 1 << TICKET_NEXT;
> > > > +	u32 *p = &lock->lock;
> > > > +	u32 tmp;
> > > > +
> > > > +	smp_mb();
> > > 
> > > spin_lock() doesn't need smp_mb() before.
> > read_lock and write_lock also needn't smp_mb() before, isn't it?
> 
> Correct. The various *_lock() functions only need imply an ACQUIRE
> barrier, such that the critical section happens after the lock is taken.
> 
> > > > +
> > > > +static inline void arch_spin_unlock(arch_spinlock_t *lock)
> > > > +{
> > > > +	smp_mb();
> > > > +	lock->tickets.owner++;
> > > > +	smp_mb();
> > > 
> > > spin_unlock() doesn't need smp_mb() after.
> > read_unlock and write_unlock also needn't smp_mb() after, isn't it?
> 
> Indeed so, the various *_unlock() functions only need imply a RELEASE
> barrier, such that the critical section happend before the lock is
> released.
> 
> In both cases (lock and unlock) there is a great amount of subtle
> details, but most of that is irrelevant if all you have is smp_mb().
Got it, Thx for the explanation.

> 
> 
> > > > +/*
> > > > + * Test-and-set spin-locking.
> > > > + */
> > > 
> > > Why retain that?
> > > 
> > > same comments; it has far too many smp_mb()s in.
> > I'm not sure about queued_rwlocks and just for 2-cores-smp test-and-set is
> > faster and simpler, isn't it?
> 
> Even on 2 cores I think you can create starvation cases with
> test-and-set spinlocks. And the maintenace overhead of carrying two lock
> implementations is non trivial.
> 
> As to performance; I cannot say, but the ticket lock isn't very
> expensive, you could benchmark of course.
Ticket lock is good.
But How about queued_rwlocks v.s my_test_set_rwlock?
I'm not sure about the queued_rwlocks. I just implement the ticket-spinlock.

Best Regards
 Guo Ren
Palmer Dabbelt Sept. 20, 2018, 5:52 p.m. UTC | #18
On Fri, 14 Sep 2018 07:37:20 PDT (-0700), ren_guo@c-sky.com wrote:
> On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
>> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
>> >
>> > This is the 3th version patchset to add the Linux kernel port for C-SKY(csky).
>> > Thanks to everyone who provided feedback on the previous version.
>> >
>> > This patchset adds architecture support to Linux for C-SKY's 32-bit embedded
>> > CPU cores and the patches are based on linux-4.18.4
>> >
>> > 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 ck860 (16/32-bit variable length instruction, PIPT Cache,
>> >          SMP ...)
>> >
>> > More information: http://en.c-sky.com
>>
>> This looks good to me overall. I think a good next step would be to get the port
>> included in linux-next, by preparing a git tree with all the patches and asking
>> Stephen Rothwell to include it there. Further comments on the architecture
>> port itself can be done on top of the existing patches. I would suggest you
>> base the git tree on an -rc release (either 4.19-rc1 or 4.19-rc3) and then never
>> rebase again.
> Nice :) I'll follow the rules.
>
>>
>> You have included a couple of drivers in the submission: two timer and
>> two irqchip drivers. Please leave those out for the moment, and either have
>> them merged through the respective subsystem  trees, or get an Ack
>> from the maintainers to merge them through your tree.
> Ok.
>
>>
>> I notice that a lot of the patches have no changeset comments on them.
>> You should fix that and make a habit of describing every single patch
>> with a few sentences, even if it seems obvious to you. Have a look at
>> the changeset descriptions for the nds32 and riscv architectures when
>> they got merged.
> Ok, I'll fixup them.
>
>>
>> One big question for me is what to do about time_t. Deepa and I are
>> in the process of finalizing the system call ABI for 32-bit architectures
>> with 64-bit time_t, but we are not done yet and it won't be complete
>> for 4.20. If you target 4.21, that could be a chance to make csky the
>> first architecture to only need the 64-bit time_t interface, with the
>> corresponding user space changes.
> y2038 is very important and csky32 has the issue. But 4.21 is too late for
> us, we really want to get into kernel.org as soon as possible.
> We could remove 32-bit time_t in future.

I don't want to hijack this thread, but in RISC-V land we were hoping to have a 
user ABI free of 32-bit time_t.  Our 32-bit glibc ABI hasn't been finalized 
yet, and when I talked to the glibc guys a few weeks ago they were happy to let 
us wait until 32-bit time_t can be removed before we stabilize the ABI.  We've 
been maintaining out-of-tree glibc patches for a while now, so I'd really like 
to get them into the next glibc release.

Mapping out the schedule more explicitly, as I'm terrible with dates:

* 4.19-rc4 was 2018-09-16
* 4.19 should be 2018-10-21
* 4.20 should be 2019-01-13 (skipping 2 weeks for the holidays)
* 4.21 merge window should close 2019-01-27
* glibc 2.29 is scheduled for 2019-02-01

That's very tight, but assuming we at least have a prototype of the API so we 
can get the rv32i glibc patches in much earlier it might be OK.  There was some 
talk of being able to use some workarounds to do a 32-bit time_t user ABI 
without the cooresponding kernel ABI, so we could always go down that route to 
start and then decide to deprecate or not deprecate the 32-bit kernel ABI at 
the last minute -- not something I'm fond of doing, but an option.

How close to done do you think the 32-bit time_t will be by the end of the 4.20 
merge window?  If it's close enough to start our glibc push then that might be 
OK.
Arnd Bergmann Sept. 21, 2018, 5:18 a.m. UTC | #19
On Thu, Sep 20, 2018 at 10:52 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>
> On Fri, 14 Sep 2018 07:37:20 PDT (-0700), ren_guo@c-sky.com wrote:
> > On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> >> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> I don't want to hijack this thread, but in RISC-V land we were hoping to have a
> user ABI free of 32-bit time_t.  Our 32-bit glibc ABI hasn't been finalized
> yet, and when I talked to the glibc guys a few weeks ago they were happy to let
> us wait until 32-bit time_t can be removed before we stabilize the ABI.  We've
> been maintaining out-of-tree glibc patches for a while now, so I'd really like
> to get them into the next glibc release.
>
> Mapping out the schedule more explicitly, as I'm terrible with dates:
>
> * 4.19-rc4 was 2018-09-16
> * 4.19 should be 2018-10-21
> * 4.20 should be 2019-01-13 (skipping 2 weeks for the holidays)
> * 4.21 merge window should close 2019-01-27
> * glibc 2.29 is scheduled for 2019-02-01
>
> That's very tight, but assuming we at least have a prototype of the API so we
> can get the rv32i glibc patches in much earlier it might be OK.  There was some
> talk of being able to use some workarounds to do a 32-bit time_t user ABI
> without the cooresponding kernel ABI, so we could always go down that route to
> start and then decide to deprecate or not deprecate the 32-bit kernel ABI at
> the last minute -- not something I'm fond of doing, but an option.
>
> How close to done do you think the 32-bit time_t will be by the end of the 4.20
> merge window?  If it's close enough to start our glibc push then that might be
> OK.

It will be a bit of a stretch, but it's possible. Most syscalls are
done in linux-next,
I have a few more pending, and only clock_adjtime is really missing now (I had
some earlier patches that I could revive).

My plan was to get that all into 4.20, and then have a conversation about the
actual syscall table changes in 4.21. If we need it for both csky and rv32,
we might just change the generic syscall table that way in 4.21 without
changing all the other ones along with them. I don't want to drag things out
over too many merge windows though, and my plan was to do all architectures
together to simplify the version checks in the libc code to only have to check
for a single version.

         Arnd
Guo Ren Sept. 21, 2018, 11:48 p.m. UTC | #20
On Thu, Sep 20, 2018 at 10:18:51PM -0700, Arnd Bergmann wrote:
> On Thu, Sep 20, 2018 at 10:52 AM Palmer Dabbelt <palmer@sifive.com> wrote:
> >
> > On Fri, 14 Sep 2018 07:37:20 PDT (-0700), ren_guo@c-sky.com wrote:
> > > On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> > >> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> > I don't want to hijack this thread, but in RISC-V land we were hoping to have a
> > user ABI free of 32-bit time_t.  Our 32-bit glibc ABI hasn't been finalized
> > yet, and when I talked to the glibc guys a few weeks ago they were happy to let
> > us wait until 32-bit time_t can be removed before we stabilize the ABI.  We've
> > been maintaining out-of-tree glibc patches for a while now, so I'd really like
> > to get them into the next glibc release.
> >
> > Mapping out the schedule more explicitly, as I'm terrible with dates:
> >
> > * 4.19-rc4 was 2018-09-16
> > * 4.19 should be 2018-10-21
> > * 4.20 should be 2019-01-13 (skipping 2 weeks for the holidays)
> > * 4.21 merge window should close 2019-01-27
> > * glibc 2.29 is scheduled for 2019-02-01
Thx for the schedule info.

> >
> > That's very tight, but assuming we at least have a prototype of the API so we
> > can get the rv32i glibc patches in much earlier it might be OK.  There was some
> > talk of being able to use some workarounds to do a 32-bit time_t user ABI
> > without the cooresponding kernel ABI, so we could always go down that route to
> > start and then decide to deprecate or not deprecate the 32-bit kernel ABI at
> > the last minute -- not something I'm fond of doing, but an option.
> >
> > How close to done do you think the 32-bit time_t will be by the end of the 4.20
> > merge window?  If it's close enough to start our glibc push then that might be
> > OK.
> 
> It will be a bit of a stretch, but it's possible. Most syscalls are
> done in linux-next,
> I have a few more pending, and only clock_adjtime is really missing now (I had
> some earlier patches that I could revive).
Seems time schedule is OK. If we make csky get into linux-4.20, then csky glibc
port could remove 32-bit time_t in patchset before glibc 2.29 release.

> My plan was to get that all into 4.20, and then have a conversation about the
> actual syscall table changes in 4.21. If we need it for both csky and rv32,
> we might just change the generic syscall table that way in 4.21 without
> changing all the other ones along with them. I don't want to drag things out
> over too many merge windows though, and my plan was to do all architectures
> together to simplify the version checks in the libc code to only have to check
> for a single version.
Seems that's no problem.

Best Regards
 Guo Ren
Geert Uytterhoeven Sept. 24, 2018, 7:21 a.m. UTC | #21
Hi Arnd,

On Fri, Sep 21, 2018 at 7:19 AM Arnd Bergmann <arnd@arndb.de> wrote:
> On Thu, Sep 20, 2018 at 10:52 AM Palmer Dabbelt <palmer@sifive.com> wrote:
> > On Fri, 14 Sep 2018 07:37:20 PDT (-0700), ren_guo@c-sky.com wrote:
> > > On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> > >> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> My plan was to get that all into 4.20, and then have a conversation about the
> actual syscall table changes in 4.21. If we need it for both csky and rv32,
> we might just change the generic syscall table that way in 4.21 without
> changing all the other ones along with them. I don't want to drag things out
> over too many merge windows though, and my plan was to do all architectures
> together to simplify the version checks in the libc code to only have to check
> for a single version.

What happens with the version checks if it is backported to stable?

Gr{oetje,eeting}s,

                        Geert
Arnd Bergmann Sept. 24, 2018, 8:47 a.m. UTC | #22
On Mon, Sep 24, 2018 at 9:21 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Arnd,
>
> On Fri, Sep 21, 2018 at 7:19 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > On Thu, Sep 20, 2018 at 10:52 AM Palmer Dabbelt <palmer@sifive.com> wrote:
> > > On Fri, 14 Sep 2018 07:37:20 PDT (-0700), ren_guo@c-sky.com wrote:
> > > > On Wed, Sep 12, 2018 at 04:30:36PM +0200, Arnd Bergmann wrote:
> > > >> On Wed, Sep 12, 2018 at 3:25 PM Guo Ren <ren_guo@c-sky.com> wrote:
> > My plan was to get that all into 4.20, and then have a conversation about the
> > actual syscall table changes in 4.21. If we need it for both csky and rv32,
> > we might just change the generic syscall table that way in 4.21 without
> > changing all the other ones along with them. I don't want to drag things out
> > over too many merge windows though, and my plan was to do all architectures
> > together to simplify the version checks in the libc code to only have to check
> > for a single version.
>
> What happens with the version checks if it is backported to stable?

They end up as dead code.

The way these version checks are done in glibc, we always try the new
interface first before falling back to the old version, but don't check the
kernel version at runtime.

The compile-time check optimizes out the fallback if glibc is built for
a recent-enough minimum kernel version that is guaranteed to have
the new version.

      Arnd