Skip to contentSkip to conversation

Andes(nds32) Linux Kernel Port

PATCH Superseded Greentime Hu 5 participants 111 messages Jan 15, 2018 – Feb 6, 2018

Subsystems (11)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Andes(nds32) Linux Kernel Port

This is the 6th version patchset to add the Linux kernel port for Andes(nds32) processors. Almost all of the feedbacks from v5 patchseries has been addressed. Thanks to everyone who provided feedback on the previous version.

This patchset adds core architecture support to Linux for Andestech's N13, N15, D15, N10, D10 processor cores.

Based on the 16/32-bit AndeStar RISC-like architecture, we designed the configurable AndesCore series of embedded processor families. AndesCores range from highly performance-efficient small-footprint cores for microcontrollers and deeply-embedded applications to 1GHz+ cores running Linux, covering general-purpose N-series cores for a wide range of computing need, DSP-capable D-series cores for digital signal control, instruction-extensible E-series cores for application-specific acceleration, and secure S-series cores for best protection of the most valuable.

The patches are based on v4.14-rc8, and can also be found in the following git tree:
https://github.com/andestech/linux.git nds32-4.14-rc8-v6

The build script and toolchain repositories are able to be found here:
https://github.com/andestech/build_script.git

Freely available instruction set and architecture overview documents can be found on the following page:
http://www.andestech.com/product.php?cls=9

Vincent Ren-Wei Chen and I will maintain this port. Thanks to everyone who helped us and contributed to it. :) Any feedback is welcome.

Changes in v6:
- Refine naming for atl2c
- Refine ae3xx.dts
- Remove CONFIG_TIMER_ATCPIT100 in defconfig
- Refine elf.h
- Fix a vdso bug
- Separate arch patchset and timer patchset
- To select TIMER_OF in drivers/clocksource/Kconfig instead of arch/nds32/Kconfig

Changes in v5:
- Remove __NR__llseek and sys_mmap()
- Add a comment to explain that we don't have clocksource cycle counter in the CPU
- Add volatile in iounmap()
- Fix typo Featuretures to Features
- Replace CPU_CACHE_NONALIASING with !CPU_CACHE_ALIASING
- Fix a endian bug when we try to get val = of_get_property(cpu, "clock-frequency", NULL)
- Add screen_info to fix the building error when CONFIG_ VGA_CONSOLE is enabled
- Remove unnecessary msync()
- Add depends on !64BIT || BROKEN for faraday Kconfig because the descriptor only supports 32bit
- Add atl2c binding document
- Remove unnecessary include headers
- Fix a vector table bug. It placed wrong vector handlers for 2 exceptions.
- Fix a vdso bug. It may encounter TLB multi-hit exception because we accidently set it as a global page.
- Add proper isb and barrier after some cache operations
- Fix a bug in system call restart flow. $r0 ~ $r5 does not be recovered before restarting system call
- Fix the build errors for OpenRISC and SPARC because io.h changed.
- Update ae3xx.dts to support atl2c.

Changes in v4:
- Add atcpit100 timer driver due to it include vdso implementations and sent them together with nds32 may help reviewer to review.
- Update ae3xx.dts for atcpit100 clock setting and remove vdso settings.
- To get cycle counter register by timer driver instead of dts.
- Use "depends on NDS32 || COMPILE_TEST" in atcpit100 driver because it is needed for nds32 vdso
- Update defconfig becasue kconfig rename from CONFIG_CLKSRC_ATCPIT100 to CONFIG_TIMER_ATCPIT100
- Remove ag101p.dts because we are not yet ready for ag101p platform.
- Update copyright style to SPDX-License-Identifier
- Include <linux/uaccess.h> instead of <asm/uaccess.h>
- Add local_irq_save()/local_irq_restore() to protect SR_TLB_VPN in update_mmu_cache().
- Update cpu_dcache_inval_all implementation to make sure all level cache are writeback.

Changes in v3:
- Use arch's io.h instead of generic one
- Add andestech-boards binding document
- Update nds32/cpus.txt binding document
- Remove atcpit100 timer drivers
- Select NO_BOOTMEM and delete HAVE_MEMBLOCK_NODE_MAP
- make CPU_BIG_ENDIAN and CPU_LITTLE_ENDIAN are dependent
- Add cpu type to select HWZOL/CPU_CACHE_ALIASING
- Change CPU_CACHE_NONALIASING to CPU_CACHE_ALIASING
- Remove bootarg from device tree script
- Update ag101p.dts and ae3xx.dts for correct board name.
- Clear and simplify defconfig
- Implement L2C_R_REG/ L2C_W_REG with readl/writel instead of __raw_readl/__raw_writel for endian save
- Remove early_init_dt_add_memory_arch/early_init_dt_alloc_memory_arch to use the generic ones
- Refine devicetree.c
- Fix bug https://lkml.kernel.org/r/1499782590-31366-1-git-send-ema...
- Refine irqchip/irq-ativic32.c implementations
- Add COMPILE_TEST in drivers/net/ethernet/faraday/Kconfig
- Refine cache operations
- Add CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS
- Fix ZERO_PAGE define
- Remove SA_RESTORER
- Remove uapi/asm/signal.h
- Redefine user_pt_regs
- Remove spinlock.h
- Remove __ARCH_WANT_RENAMEAT and __ARCH_WANT_SYSCALL_OFF_T from unistd.h
- Remove set_fs(USER_DS) because flush_old_exec() will do this setting
- Replace in_atomic() with faulthandler_disabled()
- Add barrier.h
- Select COMMON_CLK
- Add clk_pll in dts
- Add of_clk_init() in arch/nds32/kernel/time.c

Changes in v2:
- Set GENERIC_CALIBRATE_DELAY default n
- Add earlycon support
- Remove earlyprintk
- Add CPU_BIG_ENDIAN, CPU_LITTLE_ENDIAN support
- Refine unalignment access exception handler
- Add VMSPLIT support
- Use only one defconfig
- Change interrupt-cells from 2 to 1
- Refine andestech cpu names in bindings/nds32/cpus.txt
- Get clock frequency in dts because fpga bitmap doesn't include this feature
- Update MAINTAINERS for bindings
- Remove unused configs in Kconfig
- Refine device tree scripts
- Refine coding style
- Use generic ioremap_nocache
- Remove L2CC_PA_BASE define and its codes in head.S. It will be moved to bootloader.
- Set PHYS_OFFSET to 0x0 instead of CONFIG_MEMORY_START
- Remove unused macros
- Simplify cpu_cache_* API
- Change __asm__ __volatile__ to asm volatile
- Refine uaccess.h
- Remove unused/deprecated syscall
- Use generic posix_types.h
- Remove arch_trace_hardirqs_on/arch_trace_hardirqs_off
- Fix bug of restart syscall
- Refine syscall implementations
- Use IS_ENABLED to replace ifdef as possible
- Remove device_initcall(nds32_device_probe)
- Refine vdso implementations
- Refine copy_from_user()/copy_to_user()/clear_user()/get_user()/memmove()/memcpy()
- Refine ioremap.c
- Refine irq-ativic32.c
- Fix a bug of earlycon.c
- Export ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_wt
- Add atcpit100 driver

Greentime Hu (36):
asm-generic/io.h: move
ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_wt out of ifndef
CONFIG_MMU
openrisc: add ioremap_nocache declaration before include
asm-generic/io.h and sync ioremap prototype with it.
sparc: io: To use the define of ioremap_[nocache|wc|wb] in
asm-generic/io.h
earlycon: add reg-offset to physical address before mapping
nds32: Assembly macros and definitions
nds32: Kernel booting and initialization
nds32: Exception handling
nds32: MMU definitions
nds32: MMU initialization
nds32: MMU fault handling and page table management
nds32: Cache and TLB routines
nds32: Process management
nds32: IRQ handling
nds32: Atomic operations
nds32: Device specific operations
nds32: DMA mapping API
nds32: ELF definitions
nds32: System calls handling
nds32: VDSO support
nds32: Signal handling support
nds32: Library functions
nds32: Debugging support
nds32: L2 cache support
nds32: Loadable modules
nds32: Generic timers support
nds32: Device tree support
nds32: Miscellaneous header files
nds32: defconfig
nds32: Build infrastructure
MAINTAINERS: Add nds32
dt-bindings: nds32 CPU Bindings
dt-bindings: nds32 L2 cache controller Bindings
dt-bindings: nds32 SoC Bindings
dt-bindings: interrupt-controller: Andestech Internal Vector
Interrupt Controller
irqchip: Andestech Internal Vector Interrupt Controller driver
net: faraday add nds32 support.

 .../interrupt-controller/andestech,ativic32.txt    |   19 +
 .../devicetree/bindings/nds32/andestech-boards     |   40 +
 Documentation/devicetree/bindings/nds32/atl2c.txt  |   29 +
 Documentation/devicetree/bindings/nds32/cpus.txt   |   37 +
 MAINTAINERS                                        |   11 +
 arch/nds32/Kconfig                                 |  107 +++
 arch/nds32/Kconfig.cpu                             |  161 ++++
 arch/nds32/Makefile                                |   66 ++
 arch/nds32/boot/Makefile                           |   15 +
 arch/nds32/boot/dts/Makefile                       |    8 +
 arch/nds32/boot/dts/ae3xx.dts                      |   85 ++
 arch/nds32/configs/defconfig                       |  107 +++
 arch/nds32/include/asm/Kbuild                      |   54 ++
 arch/nds32/include/asm/assembler.h                 |   39 +
 arch/nds32/include/asm/barrier.h                   |   15 +
 arch/nds32/include/asm/bitfield.h                  |  963 ++++++++++++++++++++
 arch/nds32/include/asm/cache.h                     |   12 +
 arch/nds32/include/asm/cache_info.h                |   13 +
 arch/nds32/include/asm/cacheflush.h                |   44 +
 arch/nds32/include/asm/current.h                   |   12 +
 arch/nds32/include/asm/delay.h                     |   39 +
 arch/nds32/include/asm/dma-mapping.h               |   14 +
 arch/nds32/include/asm/elf.h                       |  171 ++++
 arch/nds32/include/asm/fixmap.h                    |   29 +
 arch/nds32/include/asm/futex.h                     |  103 +++
 arch/nds32/include/asm/highmem.h                   |   65 ++
 arch/nds32/include/asm/io.h                        |   83 ++
 arch/nds32/include/asm/irqflags.h                  |   36 +
 arch/nds32/include/asm/l2_cache.h                  |  137 +++
 arch/nds32/include/asm/linkage.h                   |   11 +
 arch/nds32/include/asm/memory.h                    |  105 +++
 arch/nds32/include/asm/mmu.h                       |   12 +
 arch/nds32/include/asm/mmu_context.h               |   68 ++
 arch/nds32/include/asm/module.h                    |   11 +
 arch/nds32/include/asm/nds32.h                     |   83 ++
 arch/nds32/include/asm/page.h                      |   67 ++
 arch/nds32/include/asm/pgalloc.h                   |   96 ++
 arch/nds32/include/asm/pgtable.h                   |  409 +++++++++
 arch/nds32/include/asm/proc-fns.h                  |   44 +
 arch/nds32/include/asm/processor.h                 |  102 +++
 arch/nds32/include/asm/ptrace.h                    |   66 ++
 arch/nds32/include/asm/shmparam.h                  |   19 +
 arch/nds32/include/asm/string.h                    |   17 +
 arch/nds32/include/asm/swab.h                      |   35 +
 arch/nds32/include/asm/syscall.h                   |  188 ++++
 arch/nds32/include/asm/syscalls.h                  |   13 +
 arch/nds32/include/asm/thread_info.h               |   78 ++
 arch/nds32/include/asm/tlb.h                       |   28 +
 arch/nds32/include/asm/tlbflush.h                  |   47 +
 arch/nds32/include/asm/uaccess.h                   |  283 ++++++
 arch/nds32/include/asm/unistd.h                    |    6 +
 arch/nds32/include/asm/vdso.h                      |   24 +
 arch/nds32/include/asm/vdso_datapage.h             |   36 +
 arch/nds32/include/asm/vdso_timer_info.h           |   14 +
 arch/nds32/include/uapi/asm/Kbuild                 |   28 +
 arch/nds32/include/uapi/asm/auxvec.h               |   12 +
 arch/nds32/include/uapi/asm/byteorder.h            |   13 +
 arch/nds32/include/uapi/asm/cachectl.h             |   14 +
 arch/nds32/include/uapi/asm/param.h                |   11 +
 arch/nds32/include/uapi/asm/ptrace.h               |   25 +
 arch/nds32/include/uapi/asm/sigcontext.h           |   60 ++
 arch/nds32/include/uapi/asm/unistd.h               |   11 +
 arch/nds32/kernel/Makefile                         |   23 +
 arch/nds32/kernel/asm-offsets.c                    |   28 +
 arch/nds32/kernel/atl2c.c                          |   64 ++
 arch/nds32/kernel/cacheinfo.c                      |   49 +
 arch/nds32/kernel/devtree.c                        |   19 +
 arch/nds32/kernel/dma.c                            |  459 ++++++++++
 arch/nds32/kernel/ex-entry.S                       |  157 ++++
 arch/nds32/kernel/ex-exit.S                        |  193 ++++
 arch/nds32/kernel/ex-scall.S                       |  106 +++
 arch/nds32/kernel/head.S                           |  188 ++++
 arch/nds32/kernel/irq.c                            |    9 +
 arch/nds32/kernel/module.c                         |  286 ++++++
 arch/nds32/kernel/nds32_ksyms.c                    |   31 +
 arch/nds32/kernel/process.c                        |  204 +++++
 arch/nds32/kernel/ptrace.c                         |  311 +++++++
 arch/nds32/kernel/setup.c                          |  387 ++++++++
 arch/nds32/kernel/signal.c                         |  337 +++++++
 arch/nds32/kernel/stacktrace.c                     |   47 +
 arch/nds32/kernel/sys_nds32.c                      |   50 +
 arch/nds32/kernel/syscall_table.c                  |   17 +
 arch/nds32/kernel/time.c                           |   11 +
 arch/nds32/kernel/traps.c                          |  428 +++++++++
 arch/nds32/kernel/vdso.c                           |  230 +++++
 arch/nds32/kernel/vdso/Makefile                    |   82 ++
 arch/nds32/kernel/vdso/datapage.S                  |   21 +
 arch/nds32/kernel/vdso/gen_vdso_offsets.sh         |   15 +
 arch/nds32/kernel/vdso/gettimeofday.c              |  270 ++++++
 arch/nds32/kernel/vdso/note.S                      |   11 +
 arch/nds32/kernel/vdso/sigreturn.S                 |   19 +
 arch/nds32/kernel/vdso/vdso.S                      |   18 +
 arch/nds32/kernel/vdso/vdso.lds.S                  |   76 ++
 arch/nds32/kernel/vmlinux.lds.S                    |   57 ++
 arch/nds32/lib/Makefile                            |    3 +
 arch/nds32/lib/clear_user.S                        |   42 +
 arch/nds32/lib/copy_from_user.S                    |   45 +
 arch/nds32/lib/copy_page.S                         |   37 +
 arch/nds32/lib/copy_template.S                     |   70 ++
 arch/nds32/lib/copy_to_user.S                      |   45 +
 arch/nds32/lib/memcpy.S                            |   30 +
 arch/nds32/lib/memmove.S                           |   70 ++
 arch/nds32/lib/memset.S                            |   33 +
 arch/nds32/lib/memzero.S                           |   18 +
 arch/nds32/mm/Makefile                             |    7 +
 arch/nds32/mm/alignment.c                          |  609 +++++++++++++
 arch/nds32/mm/cacheflush.c                         |  322 +++++++
 arch/nds32/mm/extable.c                            |   16 +
 arch/nds32/mm/fault.c                              |  410 +++++++++
 arch/nds32/mm/highmem.c                            |   79 ++
 arch/nds32/mm/init.c                               |  277 ++++++
 arch/nds32/mm/ioremap.c                            |   62 ++
 arch/nds32/mm/mm-nds32.c                           |   90 ++
 arch/nds32/mm/mmap.c                               |   73 ++
 arch/nds32/mm/proc.c                               |  533 +++++++++++
 arch/nds32/mm/tlb.c                                |   50 +
 arch/openrisc/include/asm/io.h                     |    3 +-
 arch/sparc/include/asm/io_32.h                     |    5 -
 arch/sparc/kernel/ioport.c                         |    4 +-
 drivers/irqchip/Makefile                           |    1 +
 drivers/irqchip/irq-ativic32.c                     |  107 +++
 drivers/net/ethernet/faraday/Kconfig               |    8 +-
 drivers/tty/serial/earlycon.c                      |    3 +-
 include/asm-generic/io.h                           |   18 +-
 124 files changed, 11802 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/andestech,ativic32.txt
 create mode 100644 Documentation/devicetree/bindings/nds32/andestech-boards
 create mode 100644 Documentation/devicetree/bindings/nds32/atl2c.txt
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
 create mode 100644 arch/nds32/Kconfig
 create mode 100644 arch/nds32/Kconfig.cpu
 create mode 100644 arch/nds32/Makefile
 create mode 100644 arch/nds32/boot/Makefile
 create mode 100644 arch/nds32/boot/dts/Makefile
 create mode 100644 arch/nds32/boot/dts/ae3xx.dts
 create mode 100644 arch/nds32/configs/defconfig
 create mode 100644 arch/nds32/include/asm/Kbuild
 create mode 100644 arch/nds32/include/asm/assembler.h
 create mode 100644 arch/nds32/include/asm/barrier.h
 create mode 100644 arch/nds32/include/asm/bitfield.h
 create mode 100644 arch/nds32/include/asm/cache.h
 create mode 100644 arch/nds32/include/asm/cache_info.h
 create mode 100644 arch/nds32/include/asm/cacheflush.h
 create mode 100644 arch/nds32/include/asm/current.h
 create mode 100644 arch/nds32/include/asm/delay.h
 create mode 100644 arch/nds32/include/asm/dma-mapping.h
 create mode 100644 arch/nds32/include/asm/elf.h
 create mode 100644 arch/nds32/include/asm/fixmap.h
 create mode 100644 arch/nds32/include/asm/futex.h
 create mode 100644 arch/nds32/include/asm/highmem.h
 create mode 100644 arch/nds32/include/asm/io.h
 create mode 100644 arch/nds32/include/asm/irqflags.h
 create mode 100644 arch/nds32/include/asm/l2_cache.h
 create mode 100644 arch/nds32/include/asm/linkage.h
 create mode 100644 arch/nds32/include/asm/memory.h
 create mode 100644 arch/nds32/include/asm/mmu.h
 create mode 100644 arch/nds32/include/asm/mmu_context.h
 create mode 100644 arch/nds32/include/asm/module.h
 create mode 100644 arch/nds32/include/asm/nds32.h
 create mode 100644 arch/nds32/include/asm/page.h
 create mode 100644 arch/nds32/include/asm/pgalloc.h
 create mode 100644 arch/nds32/include/asm/pgtable.h
 create mode 100644 arch/nds32/include/asm/proc-fns.h
 create mode 100644 arch/nds32/include/asm/processor.h
 create mode 100644 arch/nds32/include/asm/ptrace.h
 create mode 100644 arch/nds32/include/asm/shmparam.h
 create mode 100644 arch/nds32/include/asm/string.h
 create mode 100644 arch/nds32/include/asm/swab.h
 create mode 100644 arch/nds32/include/asm/syscall.h
 create mode 100644 arch/nds32/include/asm/syscalls.h
 create mode 100644 arch/nds32/include/asm/thread_info.h
 create mode 100644 arch/nds32/include/asm/tlb.h
 create mode 100644 arch/nds32/include/asm/tlbflush.h
 create mode 100644 arch/nds32/include/asm/uaccess.h
 create mode 100644 arch/nds32/include/asm/unistd.h
 create mode 100644 arch/nds32/include/asm/vdso.h
 create mode 100644 arch/nds32/include/asm/vdso_datapage.h
 create mode 100644 arch/nds32/include/asm/vdso_timer_info.h
 create mode 100644 arch/nds32/include/uapi/asm/Kbuild
 create mode 100644 arch/nds32/include/uapi/asm/auxvec.h
 create mode 100644 arch/nds32/include/uapi/asm/byteorder.h
 create mode 100644 arch/nds32/include/uapi/asm/cachectl.h
 create mode 100644 arch/nds32/include/uapi/asm/param.h
 create mode 100644 arch/nds32/include/uapi/asm/ptrace.h
 create mode 100644 arch/nds32/include/uapi/asm/sigcontext.h
 create mode 100644 arch/nds32/include/uapi/asm/unistd.h
 create mode 100644 arch/nds32/kernel/Makefile
 create mode 100644 arch/nds32/kernel/asm-offsets.c
 create mode 100644 arch/nds32/kernel/atl2c.c
 create mode 100644 arch/nds32/kernel/cacheinfo.c
 create mode 100644 arch/nds32/kernel/devtree.c
 create mode 100644 arch/nds32/kernel/dma.c
 create mode 100644 arch/nds32/kernel/ex-entry.S
 create mode 100644 arch/nds32/kernel/ex-exit.S
 create mode 100644 arch/nds32/kernel/ex-scall.S
 create mode 100644 arch/nds32/kernel/head.S
 create mode 100644 arch/nds32/kernel/irq.c
 create mode 100644 arch/nds32/kernel/module.c
 create mode 100644 arch/nds32/kernel/nds32_ksyms.c
 create mode 100644 arch/nds32/kernel/process.c
 create mode 100644 arch/nds32/kernel/ptrace.c
 create mode 100644 arch/nds32/kernel/setup.c
 create mode 100644 arch/nds32/kernel/signal.c
 create mode 100644 arch/nds32/kernel/stacktrace.c
 create mode 100644 arch/nds32/kernel/sys_nds32.c
 create mode 100644 arch/nds32/kernel/syscall_table.c
 create mode 100644 arch/nds32/kernel/time.c
 create mode 100644 arch/nds32/kernel/traps.c
 create mode 100644 arch/nds32/kernel/vdso.c
 create mode 100644 arch/nds32/kernel/vdso/Makefile
 create mode 100644 arch/nds32/kernel/vdso/datapage.S
 create mode 100755 arch/nds32/kernel/vdso/gen_vdso_offsets.sh
 create mode 100644 arch/nds32/kernel/vdso/gettimeofday.c
 create mode 100644 arch/nds32/kernel/vdso/note.S
 create mode 100644 arch/nds32/kernel/vdso/sigreturn.S
 create mode 100644 arch/nds32/kernel/vdso/vdso.S
 create mode 100644 arch/nds32/kernel/vdso/vdso.lds.S
 create mode 100644 arch/nds32/kernel/vmlinux.lds.S
 create mode 100644 arch/nds32/lib/Makefile
 create mode 100644 arch/nds32/lib/clear_user.S
 create mode 100644 arch/nds32/lib/copy_from_user.S
 create mode 100644 arch/nds32/lib/copy_page.S
 create mode 100644 arch/nds32/lib/copy_template.S
 create mode 100644 arch/nds32/lib/copy_to_user.S
 create mode 100644 arch/nds32/lib/memcpy.S
 create mode 100644 arch/nds32/lib/memmove.S
 create mode 100644 arch/nds32/lib/memset.S
 create mode 100644 arch/nds32/lib/memzero.S
 create mode 100644 arch/nds32/mm/Makefile
 create mode 100644 arch/nds32/mm/alignment.c
 create mode 100644 arch/nds32/mm/cacheflush.c
 create mode 100644 arch/nds32/mm/extable.c
 create mode 100644 arch/nds32/mm/fault.c
 create mode 100644 arch/nds32/mm/highmem.c
 create mode 100644 arch/nds32/mm/init.c
 create mode 100644 arch/nds32/mm/ioremap.c
 create mode 100644 arch/nds32/mm/mm-nds32.c
 create mode 100644 arch/nds32/mm/mmap.c
 create mode 100644 arch/nds32/mm/proc.c
 create mode 100644 arch/nds32/mm/tlb.c
 create mode 100644 drivers/irqchip/irq-ativic32.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v6 1/36 asm-generic/io.h: move ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_wt out of ifndef CONFIG_MMU

From: Greentime Hu <[email protected]>

It allows some architectures to use this generic macro instead of defining theirs.

---
 include/asm-generic/io.h |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
include/asm-generic/io.h +9 -9
index b4531e3..7c6a39e 100644
@@ -852,7 +852,16 @@ static inline void __iomem *__ioremap(phys_addr_t offset, size_t size,
 }
 #endif
 
+#ifndef iounmap
+#define iounmap iounmap
+
+static inline void iounmap(void __iomem *addr)
+{
+}
+#endif
+#endif /* CONFIG_MMU */
 #ifndef ioremap_nocache
+void __iomem *ioremap(phys_addr_t phys_addr, size_t size);
 #define ioremap_nocache ioremap_nocache
 static inline void __iomem *ioremap_nocache(phys_addr_t offset, size_t size)
 {
@@ -884,15 +893,6 @@ static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size)
 }
 #endif
 
-#ifndef iounmap
-#define iounmap iounmap
-
-static inline void iounmap(void __iomem *addr)
-{
-}
-#endif
-#endif /* CONFIG_MMU */
-
 #ifdef CONFIG_HAS_IOPORT_MAP
 #ifndef CONFIG_GENERIC_IOMAP
 #ifndef ioport_map
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v6 2/36 openrisc: add ioremap_nocache declaration before include asm-generic/io.h and sync ioremap prototype with it.

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

It will be built failed if commit id: d25ea659 is selected. This patch can fix this build error.

---
 arch/openrisc/include/asm/io.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/openrisc/include/asm/io.h +2 -1
index 7c69139..6709b28 100644
@@ -29,13 +29,14 @@
 #define PIO_OFFSET		0
 #define PIO_MASK		0
 
+#define ioremap_nocache ioremap_nocache
 #include <asm-generic/io.h>
 #include <asm/pgtable.h>
 
 extern void __iomem *__ioremap(phys_addr_t offset, unsigned long size,
 				pgprot_t prot);
 
-static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)
+static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
 {
 	return __ioremap(offset, size, PAGE_KERNEL);
 }
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 2/36
#3 lore raw

Re: [PATCH v6 02/36] openrisc: add ioremap_nocache declaration before include asm-generic/io.h and sync ioremap prototype with it.

Quoted 4 lines · Greentime Hu

From: Greentime Hu <[email protected]>

It will be built failed if commit id: d25ea659 is selected. This patch can fix this build error.

Hello,

As I mentioned last time, can you you change this to not mention the commit id? The ID will probably change when this is actually committed. You might want to do something like:

1. Move this commit before the ioremap_nocache change. This is because we want each commit to result in a buildable kernel.

2. The text here and other changes could read:

A future commit for the nds32 architecture bootstrap ("asm-generic/io.h: move ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_wt out of ifndef CONFIG_MMU") will move the ioremap_nocache out of the CONFIG_MMU ifdef. This means that in order to suppress re-definition errors we need to setup #define's before importing asm-generic/io.h.

Also, the change adds a prototype for ioremap where size is size_t so fix that as well.

I hope that helps. But for the change:

Quoted 28 lines
---
 arch/openrisc/include/asm/io.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/openrisc/include/asm/io.h +2 -1
index 7c69139..6709b28 100644
@@ -29,13 +29,14 @@
 #define PIO_OFFSET		0
 #define PIO_MASK		0
 
+#define ioremap_nocache ioremap_nocache
 #include <asm-generic/io.h>
 #include <asm/pgtable.h>
 
 extern void __iomem *__ioremap(phys_addr_t offset, unsigned long size,
 				pgprot_t prot);
 
-static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size)
+static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
 {
 	return __ioremap(offset, size, PAGE_KERNEL);
 }
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH v6 02/36] openrisc: add ioremap_nocache declaration before include asm-generic/io.h and sync ioremap prototype with it.

2018-01-15 21:07 GMT+08:00 Stafford Horne <[email protected]>:

Quoted 23 lines · Greentime Hu
Quoted 4 lines

From: Greentime Hu <[email protected]>

It will be built failed if commit id: d25ea659 is selected. This patch can fix this build error.

Hello,

As I mentioned last time, can you you change this to not mention the commit id? The ID will probably change when this is actually committed. You might want to do something like:

1. Move this commit before the ioremap_nocache change. This is because we want each commit to result in a buildable kernel.

2. The text here and other changes could read:

A future commit for the nds32 architecture bootstrap ("asm-generic/io.h: move ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_wt out of ifndef CONFIG_MMU") will move the ioremap_nocache out of the CONFIG_MMU ifdef. This means that in order to suppress re-definition errors we need to setup #define's before importing asm-generic/io.h.

Quoted 7 lines

Also, the change adds a prototype for ioremap where size is size_t so fix that as well.

I hope that helps. But for the change:

Hi, Stafford:

Thanks for the feedback.
I will move this commit before the ioremap_nocache change and use these commit messages.

#5 lore raw

PATCH v6 3/36 sparc: io: To use the define of ioremap_[nocache|wc|wb] in asm-generic/io.h

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

It will be built failed if commit id: d25ea659 is selected. This patch can fix this build error.

---
 arch/sparc/include/asm/io_32.h |    5 -----
 arch/sparc/kernel/ioport.c     |    4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)
arch/sparc/include/asm/io_32.h +0 -5
index cd51a89..df2dc17 100644
@@ -127,12 +127,7 @@ static inline void sbus_memcpy_toio(volatile void __iomem *dst,
  * Bus number may be embedded in the higher bits of the physical address.
  * This is why we have no bus number argument to ioremap().
  */
-void __iomem *ioremap(unsigned long offset, unsigned long size);
-#define ioremap_nocache(X,Y)	ioremap((X),(Y))
-#define ioremap_wc(X,Y)		ioremap((X),(Y))
-#define ioremap_wt(X,Y)		ioremap((X),(Y))
 void iounmap(volatile void __iomem *addr);
-
 /* Create a virtual mapping cookie for an IO port range */
 void __iomem *ioport_map(unsigned long port, unsigned int nr);
 void ioport_unmap(void __iomem *);
arch/sparc/kernel/ioport.c +2 -2
index 7eeef80..3bcef9c 100644
@@ -122,12 +122,12 @@ static void xres_free(struct xresource *xrp) {
  *
  * Bus type is always zero on IIep.
  */
-void __iomem *ioremap(unsigned long offset, unsigned long size)
+void __iomem *ioremap(phys_addr_t offset, size_t size)
 {
 	char name[14];
 
 	sprintf(name, "phys_%08x", (u32)offset);
-	return _sparc_alloc_io(0, offset, size, name);
+	return _sparc_alloc_io(0, (unsigned long)offset, size, name);
 }
 EXPORT_SYMBOL(ioremap);
 
Signature · 1 line
1.7.9.5
maintainer
#6 lore raw

Re: [PATCH v6 03/36] sparc: io: To use the define of ioremap_[nocache|wc|wb] in asm-generic/io.h

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

It will be built failed if commit id: d25ea659 is selected. This patch can fix this build error.

The change is fine, but the reference to commit 'd25ea659' is not for two reasons:

- when you rebase the tree, you will get a different ID
- the recommended format for referring to another commit is to list it with 12 digits and the one-line summary like this:

commit d25ea659bc37 ("asm-generic/io.h: move
ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_…")

- Ideally you use a 'Fixes:' tag in the patch description.

You can add these lines in your .gitconfig to help you here

[alias]

        fixes = show --format='Fixes: %h (\"%s\")' -s
[core]
        abbrev = 12

That will give you a 'git fixes' command to output the Fixes: line in the correct format for future bug fixes. For this particular change, I would actually just merge the two patches into one patch that then doesn't break anything in the first place.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH v6 03/36] sparc: io: To use the define of ioremap_[nocache|wc|wb] in asm-generic/io.h

2018-01-18 17:56 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 23 lines · Greentime Hu
Quoted 6 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

It will be built failed if commit id: d25ea659 is selected. This patch can fix this build error.

The change is fine, but the reference to commit 'd25ea659' is not for two reasons:

- when you rebase the tree, you will get a different ID
- the recommended format for referring to another commit is to list it with 12 digits and the one-line summary like this:

   commit d25ea659bc37 ("asm-generic/io.h: move

ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_…")

- Ideally you use a 'Fixes:' tag in the patch description.

You can add these lines in your .gitconfig to help you here

[alias]

Quoted 9 lines
        fixes = show --format='Fixes: %h (\"%s\")' -s
[core]
        abbrev = 12

That will give you a 'git fixes' command to output the Fixes: line in the correct format for future bug fixes. For this particular change, I would actually just merge the two patches into one patch that then doesn't break anything in the first place.

Hi, Arnd:

Thank you for your comments and teaching me how to add these messages. I will update the commit messages and my .gitconfig.

Since the commit id will be changed after rebasing, I will update the messages like this.

sparc: io: To use the define of ioremap_[nocache|wc|wb] in asm-generic/io.h

A commit for the nds32 architecture bootstrap("asm-generic/io.h: move ioremap_nocache/ioremap_uc/ioremap_wc/ioremap_wt out of ifndef CONFIG_MMU") will move the ioremap_nocache out of the CONFIG_MMU ifdef. This means that in order to suppress re-definition errors we need to remove the #define in io_32.h.

Also, the change adds a prototype for ioremap where size is size_t and offset is phys_addr_t so fix that as well.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

PATCH v6 4/36 earlycon: add reg-offset to physical address before mapping

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

It will get the wrong virtual address because port->mapbase is not added the correct reg-offset yet. We have to update it before earlycon_map() is called

---
 drivers/tty/serial/earlycon.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/earlycon.c +2 -1
index 98928f0..17dba0a 100644
@@ -253,11 +253,12 @@ int __init of_setup_earlycon(const struct earlycon_id *match,
 	}
 	port->mapbase = addr;
 	port->uartclk = BASE_BAUD * 16;
-	port->membase = earlycon_map(port->mapbase, SZ_4K);
 
 	val = of_get_flat_dt_prop(node, "reg-offset", NULL);
 	if (val)
 		port->mapbase += be32_to_cpu(*val);
+	port->membase = earlycon_map(port->mapbase, SZ_4K);
+
 	val = of_get_flat_dt_prop(node, "reg-shift", NULL);
 	if (val)
 		port->regshift = be32_to_cpu(*val);
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 4/36
#9 lore raw

Re: [PATCH v6 04/36] earlycon: add reg-offset to physical address before mapping

Quoted 7 lines · Greentime Hu

From: Greentime Hu <[email protected]>

It will get the wrong virtual address because port->mapbase is not added the correct reg-offset yet. We have to update it before earlycon_map() is called

Cc Peter Hurley <[email protected]>
Fixes 088da2a17619 ("of: earlycon: Initialize port fields from DT properties")

As this is a bugfix for generic code, this might be good to have Greg pick up directly for his serial drivers tree. An Ack from Peter Hurley would also help, as he introduced the reg-offset handling originally.

Arnd

#10 lore raw

PATCH v6 5/36 nds32: Assembly macros and definitions

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes assembly macros, bit field definitions used in .S files across arch/nds32/.

---
 arch/nds32/include/asm/assembler.h |   39 ++
 arch/nds32/include/asm/bitfield.h  |  963 ++++++++++++++++++++++++++++++++++++
 arch/nds32/include/asm/nds32.h     |   83 ++++
 arch/nds32/kernel/asm-offsets.c    |   28 ++
 4 files changed, 1113 insertions(+)
 create mode 100644 arch/nds32/include/asm/assembler.h
 create mode 100644 arch/nds32/include/asm/bitfield.h
 create mode 100644 arch/nds32/include/asm/nds32.h
 create mode 100644 arch/nds32/kernel/asm-offsets.c
arch/nds32/include/asm/assembler.h new file +39 -0
new file mode 100644
index 0000000..c385578
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_ASSEMBLER_H__
+#define __NDS32_ASSEMBLER_H__
+
+.macro gie_disable
+	setgie.d
+	dsb
+.endm
+
+.macro gie_enable
+	setgie.e
+	dsb
+.endm
+
+.macro gie_save oldpsw
+	mfsr \oldpsw, $ir0
+	setgie.d
+        dsb
+.endm
+
+.macro gie_restore oldpsw
+	andi \oldpsw, \oldpsw, #0x1
+	beqz \oldpsw, 7001f
+	setgie.e
+	dsb
+7001:
+.endm
+
+
+#define USER(insn,  reg, addr, opr)	\
+9999:	insn  reg, addr, opr;		\
+	.section __ex_table,"a";	\
+	.align 3;			\
+	.long	9999b, 9001f;		\
+	.previous
+
+#endif /* __NDS32_ASSEMBLER_H__ */
arch/nds32/include/asm/bitfield.h new file +963 -0

963 lines not on this page · raw message

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

83 lines not on this page · raw message

arch/nds32/kernel/asm-offsets.c new file +28 -0
new file mode 100644
index 0000000..3541d59
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/sched.h>
+#include <linux/sched/task_stack.h>
+#include <linux/kbuild.h>
+#include <asm/thread_info.h>
+#include <asm/ptrace.h>
+
+int main(void)
+{
+	DEFINE(TSK_TI_FLAGS, offsetof(struct task_struct, thread_info.flags));
+	DEFINE(TSK_TI_PREEMPT,
+	       offsetof(struct task_struct, thread_info.preempt_count));
+	DEFINE(THREAD_CPU_CONTEXT,
+	       offsetof(struct task_struct, thread.cpu_context));
+	DEFINE(OSP_OFFSET, offsetof(struct pt_regs, osp));
+	DEFINE(SP_OFFSET, offsetof(struct pt_regs, sp));
+	DEFINE(FUCOP_CTL_OFFSET, offsetof(struct pt_regs, fucop_ctl));
+	DEFINE(IPSW_OFFSET, offsetof(struct pt_regs, ipsw));
+	DEFINE(SYSCALLNO_OFFSET, offsetof(struct pt_regs, syscallno));
+	DEFINE(IPC_OFFSET, offsetof(struct pt_regs, ipc));
+	DEFINE(R0_OFFSET, offsetof(struct pt_regs, uregs[0]));
+	DEFINE(R15_OFFSET, offsetof(struct pt_regs, uregs[15]));
+	DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
+	DEFINE(CLOCK_COARSE_RES, LOW_RES_NSEC);
+	return 0;
+}
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 5/36
#11 lore raw

Re: [PATCH v6 05/36] nds32: Assembly macros and definitions

Quoted 7 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch includes assembly macros, bit field definitions used in .S files across arch/nds32/.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

PATCH v6 6/36 nds32: Kernel booting and initialization

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes the kernel startup code. It can get dtb pointer passed from bootloader. It will create a temp mapping by tlb instructions at beginning and goto start_kernel.

---
 arch/nds32/kernel/head.S  |  188 ++++++++++++++++++++++
 arch/nds32/kernel/setup.c |  387 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 575 insertions(+)
 create mode 100644 arch/nds32/kernel/head.S
 create mode 100644 arch/nds32/kernel/setup.c
arch/nds32/kernel/head.S new file +188 -0
new file mode 100644
index 0000000..71f57bd
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+#include <linux/init.h>
+#include <asm/ptrace.h>
+#include <asm/asm-offsets.h>
+#include <asm/page.h>
+#include <asm/pgtable.h>
+#include <asm/sizes.h>
+#include <asm/thread_info.h>
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define OF_DT_MAGIC 0xd00dfeed
+#else
+#define OF_DT_MAGIC 0xedfe0dd0
+#endif
+
+	.globl  swapper_pg_dir
+	.equ    swapper_pg_dir, TEXTADDR - 0x4000
+
+/*
+ * Kernel startup entry point.
+ */
+	.section ".head.text", "ax"
+	.type   _stext, %function
+ENTRY(_stext)
+	setgie.d                            ! Disable interrupt
+	isb
+/*
+ * Disable I/D-cache and enable it at a proper time
+ */
+	mfsr    $r0, $mr8
+	li      $r1, #~(CACHE_CTL_mskIC_EN|CACHE_CTL_mskDC_EN)
+	and     $r0, $r0, $r1
+	mtsr    $r0, $mr8
+
+/*
+ * Process device tree blob
+ */
+	andi 	$r0,$r2,#0x3
+	li	$r10, 0
+	bne     $r0, $r10, _nodtb
+	lwi	$r0, [$r2]
+	li	$r1, OF_DT_MAGIC
+	bne     $r0, $r1, _nodtb
+	move	$r10, $r2
+_nodtb:
+
+/*
+ * Create a temporary mapping area for booting, before start_kernel
+ */
+	sethi   $r4, hi20(swapper_pg_dir)
+	li      $p0, (PAGE_OFFSET - PHYS_OFFSET)
+	sub     $r4, $r4, $p0
+	tlbop   FlushAll            ! invalidate TLB\n"
+	isb
+	mtsr    $r4, $L1_PPTB       ! load page table pointer\n"
+
+/* set NTC0 cacheable/writeback, mutliple page size in use */
+	mfsr    $r3, $MMU_CTL
+	li      $r0, #~MMU_CTL_mskNTC0
+	and     $r3, $r3, $r0
+#ifdef CONFIG_ANDES_PAGE_SIZE_4KB
+	ori     $r3, $r3, #(MMU_CTL_mskMPZIU|(MMU_CTL_CACHEABLE_WB << MMU_CTL_offNTC0))
+#else
+	ori     $r3, $r3, #(MMU_CTL_mskMPZIU|(MMU_CTL_CACHEABLE_WB << MMU_CTL_offNTC0)|MMU_CTL_D8KB)
+#endif
+#ifdef CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS
+	li      $r0, #MMU_CTL_UNA
+	or      $r3, $r3, $r0
+#endif
+	mtsr    $r3, $MMU_CTL
+	isb
+
+/* set page size and size of kernel image */
+        mfsr    $r0, $MMU_CFG
+        srli    $r3, $r0, MMU_CFG_offfEPSZ
+        zeb     $r3, $r3
+        bnez    $r3, _extra_page_size_support
+#ifdef CONFIG_ANDES_PAGE_SIZE_4KB
+        li      $r5, #SZ_4K                 ! Use 4KB page size
+#else
+        li      $r5, #SZ_8K                 ! Use 8KB page size
+        li      $r3, #1
+#endif
+        mtsr    $r3, $TLB_MISC
+        b       _image_size_check
+
+_extra_page_size_support:                    ! Use epzs pages size
+        clz     $r6, $r3
+        subri   $r2, $r6, #31
+        li      $r3, #1
+        sll     $r3, $r3, $r2
+        /* MMU_CFG.EPSZ value -> meaning */
+        mul     $r5, $r3, $r3
+        slli    $r5, $r5, #14
+        /* MMU_CFG.EPSZ  -> TLB_MISC.ACC_PSZ */
+        addi    $r3, $r2, #0x2
+        mtsr    $r3, $TLB_MISC
+
+_image_size_check:
+        /* calculate the image maximum size accepted by TLB config */
+        andi    $r6, $r0, MMU_CFG_mskTBW
+        andi    $r0, $r0, MMU_CFG_mskTBS
+        srli    $r6, $r6, MMU_CFG_offTBW
+        srli    $r0, $r0, MMU_CFG_offTBS
+        /*
+         * we just map the kernel to the maximum way - 1 of tlb
+         * reserver one way for UART VA mapping
+         * it will cause page fault if UART mapping cover the kernel mapping
+         *
+         * direct mapping is not supported now.
+         */
+        li      $r2, 't'
+        beqz    $r6, __error                 ! MMU_CFG.TBW = 0 is direct mappin
+        addi    $r0, $r0, #0x2               ! MMU_CFG.TBS value -> meaning
+        sll     $r0, $r6, $r0                ! entries = k-way * n-set
+        mul     $r6, $r0, $r5                ! max size = entries * page size
+        /* check kernel image size */
+        la      $r3, (_end - PAGE_OFFSET)
+        li      $r2, 's'
+        bgt     $r3, $r6, __error
+
+	li      $r2, #(PHYS_OFFSET + TLB_DATA_kernel_text_attr)
+        li      $r3, PAGE_OFFSET
+        add     $r6, $r6, $r3
+
+_tlb:
+	mtsr    $r3, $TLB_VPN
+	dsb
+	tlbop   $r2, RWR
+	isb
+	add     $r3, $r3, $r5
+	add     $r2, $r2, $r5
+	bgt     $r6, $r3, _tlb
+	mfsr    $r3, $TLB_MISC      ! setup access page size
+	li      $r2, #~0xf
+	and     $r3, $r3, $r2
+#ifdef CONFIG_ANDES_PAGE_SIZE_8KB
+	ori    $r3, $r3, #0x1
+#endif
+	mtsr    $r3, $TLB_MISC
+
+	mfsr    $r0, $MISC_CTL      ! Enable BTB and RTP and shadow sp
+	ori     $r0, $r0, #MISC_init
+	mtsr    $r0, $MISC_CTL
+
+	mfsr    $p1, $PSW
+	li      $r15, #~PSW_clr             ! clear WBNA|DME|IME|DT|IT|POM|INTL|GIE
+	and     $p1, $p1, $r15
+	ori     $p1, $p1, #PSW_init
+	mtsr    $p1, $IPSW                  ! when iret, it will automatically enable MMU
+	la      $lp, __mmap_switched
+	mtsr    $lp, $IPC
+	iret
+	nop
+
+	.type   __switch_data, %object
+__switch_data:
+	.long   __bss_start                 ! $r6
+	.long   _end                        ! $r7
+	.long	__atags_pointer 	    ! $atag_pointer
+	.long   init_task                   ! $r9, move to $r25
+	.long   init_thread_union + THREAD_SIZE    ! $sp
+
+
+/*
+ * The following fragment of code is executed with the MMU on in MMU mode,
+ * and uses absolute addresses; this is not position independent.
+ */
+	.align
+	.type   __mmap_switched, %function
+__mmap_switched:
+	la  $r3, __switch_data
+	lmw.bim $r6, [$r3], $r9, #0b0001
+	move	$r25, $r9
+	move    $fp, #0             ! Clear  BSS (and zero $fp)
+	beq $r7, $r6, _RRT
+1:	swi.bi  $fp, [$r6], #4
+	bne $r7, $r6, 1b
+	swi	$r10, [$r8]
+
+_RRT:
+	b   start_kernel
+
+__error:
+	b   __error
arch/nds32/kernel/setup.c new file +387 -0

387 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#13 lore raw

Re: [PATCH v6 06/36] nds32: Kernel booting and initialization

On Mon, Jan 15, 2018 at 6:53 AM, Greentime Hu <[email protected]> wrote:

I had not looked at this patch in enough detail earlier, sorry about that. It should be
easy enough to fix though.

arch/nds32/kernel/setup.c line 45

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+#ifdef CONFIG_VGA_CONSOLE
+struct screen_info screen_info;
+#endif

I would assume that you can't ever have a VGA console. Just drop all the references
here and instead send a patch to the fbdev maintainer to add the dependency at CONFIG_VGA_CONSOLE to prevent selecting it with nds32.

Quoted 1 line

+extern struct mm_struct init_mm;

init_mm is declared in linux/mm_types.h, so you should need another declaration. In general, you should never put 'extern' declarations in to .c files anyway.

arch/nds32/kernel/setup.c line 57

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+
+extern void __init early_init_devtree(void *params);
+extern void __init early_trap_init(void);

similarly, these are declared in include/linux/of_fdt.h

arch/nds32/kernel/setup.c line 289

Quoted 4 lines
arch/nds32/kernel/setup.c new file +4 -0
+void __init setup_arch(char **cmdline_p)
+{
+       early_init_devtree(__atags_pointer ?
+                          phys_to_virt(__atags_pointer) : __dtb_start);

The reference to '__atags_pointer' appears to be a leftover from pre-DT days. Can you just remove that?

arch/nds32/kernel/setup.c line 332

Quoted 13 lines
arch/nds32/kernel/setup.c new file +13 -0
+void calibrate_delay(void)
+{
+       const int *val;
+       struct device_node *cpu = NULL;
+       cpu = of_find_compatible_node(NULL, NULL, "andestech,nds32v3");
+       val = of_get_property(cpu, "clock-frequency", NULL);
+       if (!val || !*val)
+               panic("no cpu 'clock-frequency' parameter in device tree");
+       loops_per_jiffy = be32_to_cpup(val) / HZ;
+       pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
+               loops_per_jiffy / (500000 / HZ),
+               (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
+}

This seems very odd to me: The 'clock-frequency' property in the cpu node should refer to the actual frequency it is running at, but that tends to be different from the bogomips as needed by the ndelay() function. Can you explain what is going on here?

Arnd

#14 lore raw

Re: [PATCH v6 06/36] nds32: Kernel booting and initialization

Hi, Arnd:

2018-01-18 18:11 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 6 lines · Greentime Hu

I had not looked at this patch in enough detail earlier, sorry about that. It should be
easy enough to fix though.

Quoted 8 lines

arch/nds32/kernel/setup.c line 45

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+#ifdef CONFIG_VGA_CONSOLE
+struct screen_info screen_info;
+#endif

I would assume that you can't ever have a VGA console. Just drop all the references
here and instead send a patch to the fbdev maintainer to add the dependency at CONFIG_VGA_CONSOLE to prevent selecting it with nds32.

I found it can be built pass for now because we disable it in defconfig. Should I send the patch in v7 series?

Quoted 6 lines

arch/nds32/kernel/setup.c line 57

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+
+extern void __init early_init_devtree(void *params);
+extern void __init early_trap_init(void);

similarly, these are declared in include/linux/of_fdt.h

early_trap_init is a nds32 function. I will move it to nds32.h

Quoted 7 lines

arch/nds32/kernel/setup.c line 289

Quoted 4 lines
arch/nds32/kernel/setup.c new file +4 -0
+void __init setup_arch(char **cmdline_p)
+{
+       early_init_devtree(__atags_pointer ?
+                          phys_to_virt(__atags_pointer) : __dtb_start);

The reference to '__atags_pointer' appears to be a leftover from pre-DT days. Can you just remove that?

Yes, I will remove it.

Quoted 10 lines
Quoted 10 lines
arch/nds32/kernel/setup.c new file +10 -0
+void calibrate_delay(void)
+{
+       const int *val;
+       struct device_node *cpu = NULL;
+       cpu = of_find_compatible_node(NULL, NULL, "andestech,nds32v3");
+       val = of_get_property(cpu, "clock-frequency", NULL);
+       if (!val || !*val)
+               panic("no cpu 'clock-frequency' parameter in device tree");
+       loops_per_jiffy = be32_to_cpup(val) / HZ;
+       pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
Quoted 9 lines

arch/nds32/kernel/setup.c line 332

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+               loops_per_jiffy / (500000 / HZ),
+               (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
+}

This seems very odd to me: The 'clock-frequency' property in the cpu node should refer to the actual frequency it is running at, but that tends to be different from the bogomips as needed by the ndelay() function. Can you explain what is going on here?

This implementation is referenced from openrisc.
https://lkml.org/lkml/2017/11/17/228

Thank you.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#15 lore raw

Re: [PATCH v6 06/36] nds32: Kernel booting and initialization

Quoted 18 lines · Greentime Hu

Hi, Arnd:

2018-01-18 18:11 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 6 lines · Greentime Hu

I had not looked at this patch in enough detail earlier, sorry about that. It should be
easy enough to fix though.

Quoted 8 lines

arch/nds32/kernel/setup.c line 45

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+#ifdef CONFIG_VGA_CONSOLE
+struct screen_info screen_info;
+#endif

I would assume that you can't ever have a VGA console. Just drop all the references
here and instead send a patch to the fbdev maintainer to add the dependency at CONFIG_VGA_CONSOLE to prevent selecting it with nds32.

Quoted 2 lines

I found it can be built pass for now because we disable it in defconfig. Should I send the patch in v7 series?

yes, I think that would be best.

Quoted 8 lines
Quoted 6 lines

arch/nds32/kernel/setup.c line 57

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+
+extern void __init early_init_devtree(void *params);
+extern void __init early_trap_init(void);

similarly, these are declared in include/linux/of_fdt.h

early_trap_init is a nds32 function. I will move it to nds32.h

Right, makes sense.

Quoted 20 lines
Quoted 10 lines
Quoted 10 lines
arch/nds32/kernel/setup.c new file +10 -0
+void calibrate_delay(void)
+{
+       const int *val;
+       struct device_node *cpu = NULL;
+       cpu = of_find_compatible_node(NULL, NULL, "andestech,nds32v3");
+       val = of_get_property(cpu, "clock-frequency", NULL);
+       if (!val || !*val)
+               panic("no cpu 'clock-frequency' parameter in device tree");
+       loops_per_jiffy = be32_to_cpup(val) / HZ;
+       pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
Quoted 9 lines

arch/nds32/kernel/setup.c line 332

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+               loops_per_jiffy / (500000 / HZ),
+               (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
+}

This seems very odd to me: The 'clock-frequency' property in the cpu node should refer to the actual frequency it is running at, but that tends to be different from the bogomips as needed by the ndelay() function. Can you explain what is going on here?

Quoted 2 lines

This implementation is referenced from openrisc.
https://lkml.org/lkml/2017/11/17/228

It's correct on openrisc, because that has a reliable cycle counter, and that gets used in its delay function:

void __delay(unsigned long cycles)

{
        cycles_t start = get_cycles();
        while ((get_cycles() - start) < cycles)
                cpu_relax();
}

In my review comment that you cited, I assumed that nds32 had similar hardware.

However, as you explained earlier, the nds32 architecture does not provide a cycle counter and the clocksource resolution is not high enough to be a good replacement, so you have to use the traditional delay calibration.

Arnd

#16 lore raw

Re: [PATCH v6 06/36] nds32: Kernel booting and initialization

2018-01-20 0:41 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 68 lines · Greentime Hu
Quoted 18 lines

Hi, Arnd:

2018-01-18 18:11 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 6 lines · Greentime Hu

I had not looked at this patch in enough detail earlier, sorry about that. It should be
easy enough to fix though.

Quoted 8 lines

arch/nds32/kernel/setup.c line 45

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+#ifdef CONFIG_VGA_CONSOLE
+struct screen_info screen_info;
+#endif

I would assume that you can't ever have a VGA console. Just drop all the references
here and instead send a patch to the fbdev maintainer to add the dependency at CONFIG_VGA_CONSOLE to prevent selecting it with nds32.

Quoted 2 lines

I found it can be built pass for now because we disable it in defconfig. Should I send the patch in v7 series?

yes, I think that would be best.

Quoted 8 lines
Quoted 6 lines

arch/nds32/kernel/setup.c line 57

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+
+extern void __init early_init_devtree(void *params);
+extern void __init early_trap_init(void);

similarly, these are declared in include/linux/of_fdt.h

early_trap_init is a nds32 function. I will move it to nds32.h

Right, makes sense.

Quoted 20 lines
Quoted 10 lines
Quoted 10 lines
arch/nds32/kernel/setup.c new file +10 -0
+void calibrate_delay(void)
+{
+       const int *val;
+       struct device_node *cpu = NULL;
+       cpu = of_find_compatible_node(NULL, NULL, "andestech,nds32v3");
+       val = of_get_property(cpu, "clock-frequency", NULL);
+       if (!val || !*val)
+               panic("no cpu 'clock-frequency' parameter in device tree");
+       loops_per_jiffy = be32_to_cpup(val) / HZ;
+       pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n",
Quoted 9 lines

arch/nds32/kernel/setup.c line 332

Quoted 3 lines
arch/nds32/kernel/setup.c new file +3 -0
+               loops_per_jiffy / (500000 / HZ),
+               (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
+}

This seems very odd to me: The 'clock-frequency' property in the cpu node should refer to the actual frequency it is running at, but that tends to be different from the bogomips as needed by the ndelay() function. Can you explain what is going on here?

Quoted 2 lines

This implementation is referenced from openrisc.
https://lkml.org/lkml/2017/11/17/228

It's correct on openrisc, because that has a reliable cycle counter, and that gets used in its delay function:

void __delay(unsigned long cycles)

{
        cycles_t start = get_cycles();
        while ((get_cycles() - start) < cycles)
                cpu_relax();
}
Quoted 8 lines

In my review comment that you cited, I assumed that nds32 had similar hardware.

However, as you explained earlier, the nds32 architecture does not provide a cycle counter and the clocksource resolution is not high enough to be a good replacement, so you have to use the traditional delay calibration.

Hi, Arnd:

Thank you for your explanation.
Will it be ok if I code it like this?

config GENERIC_CALIBRATE_DELAY
def_bool y
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#17 lore raw

Re: [PATCH v6 06/36] nds32: Kernel booting and initialization

Quoted 24 lines · Greentime Hu

2018-01-20 0:41 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 13 lines
Quoted 2 lines

This implementation is referenced from openrisc.
https://lkml.org/lkml/2017/11/17/228

It's correct on openrisc, because that has a reliable cycle counter, and that gets used in its delay function:

void __delay(unsigned long cycles)

{
        cycles_t start = get_cycles();
        while ((get_cycles() - start) < cycles)
                cpu_relax();
}
Quoted 8 lines

In my review comment that you cited, I assumed that nds32 had similar hardware.

However, as you explained earlier, the nds32 architecture does not provide a cycle counter and the clocksource resolution is not high enough to be a good replacement, so you have to use the traditional delay calibration.

Quoted 7 lines

Hi, Arnd:

Thank you for your explanation.
Will it be ok if I code it like this?

config GENERIC_CALIBRATE_DELAY
def_bool y

Yes, I think that should be sufficient.

Arnd

#18 lore raw

PATCH v6 7/36 nds32: Exception handling

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes the exception/interrupt entries, pt_reg structure and related accessors.

---
 arch/nds32/include/asm/ptrace.h |   66 +++++
 arch/nds32/kernel/ex-entry.S    |  157 ++++++++++
 arch/nds32/kernel/ex-exit.S     |  193 +++++++++++++
 arch/nds32/kernel/stacktrace.c  |   47 +++
 arch/nds32/kernel/traps.c       |  428 +++++++++++++++++++++++++++
 arch/nds32/mm/alignment.c       |  609 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 1500 insertions(+)
 create mode 100644 arch/nds32/include/asm/ptrace.h
 create mode 100644 arch/nds32/kernel/ex-entry.S
 create mode 100644 arch/nds32/kernel/ex-exit.S
 create mode 100644 arch/nds32/kernel/stacktrace.c
 create mode 100644 arch/nds32/kernel/traps.c
 create mode 100644 arch/nds32/mm/alignment.c
arch/nds32/include/asm/ptrace.h new file +66 -0
new file mode 100644
index 0000000..db7856c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_NDS32_PTRACE_H
+#define __ASM_NDS32_PTRACE_H
+
+#define PTRACE_GETREGS		12
+#define PTRACE_SETREGS		13
+#define PTRACE_GETFPREGS	14
+#define PTRACE_SETFPREGS	15
+
+#include <uapi/asm/ptrace.h>
+
+#ifndef __ASSEMBLY__
+
+struct pt_regs {
+	union {
+		struct user_pt_regs user_regs;
+		struct {
+			long uregs[26];
+			long fp;
+			long gp;
+			long lp;
+			long sp;
+			long ipc;
+#if defined(CONFIG_HWZOL)
+			long lb;
+			long le;
+			long lc;
+#else
+			long dummy[3];
+#endif
+			long syscallno;
+		};
+	};
+	long orig_r0;
+	long ir0;
+	long ipsw;
+	long pipsw;
+	long pipc;
+	long pp0;
+	long pp1;
+	long fucop_ctl;
+	long osp;
+};
+
+#include <asm/bitfield.h>
+extern void show_regs(struct pt_regs *);
+/* Avoid circular header include via sched.h */
+struct task_struct;
+extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
+			 int error_code, int si_code);
+
+#define arch_has_single_step()		(1)
+#define user_mode(regs)			(((regs)->ipsw & PSW_mskPOM) == 0)
+#define interrupts_enabled(regs)	(!!((regs)->ipsw & PSW_mskGIE))
+#define valid_user_regs(regs)		(user_mode(regs) && interrupts_enabled(regs))
+#define regs_return_value(regs)		((regs)->uregs[0])
+#define instruction_pointer(regs)	((regs)->ipc)
+#define user_stack_pointer(regs)        ((regs)->sp)
+#define profile_pc(regs) 		instruction_pointer(regs)
+
+#define ARCH_HAS_USER_SINGLE_STEP_INFO
+
+#endif /* __ASSEMBLY__ */
+#endif
arch/nds32/kernel/ex-entry.S new file +157 -0

157 lines not on this page · raw message

arch/nds32/kernel/ex-exit.S new file +193 -0

193 lines not on this page · raw message

arch/nds32/kernel/stacktrace.c new file +47 -0

47 lines not on this page · raw message

arch/nds32/kernel/traps.c new file +428 -0

428 lines not on this page · raw message

arch/nds32/mm/alignment.c new file +609 -0

609 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#19 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

Quoted 7 lines · Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes the exception/interrupt entries, pt_reg structure and related accessors.

Here it would be good to have a more detailed explanation about the alignment trap handling. I remember discussing it with you before, but don't remember the exact outcome. In particular you should explain here why you need to handle alignment traps in the first place, and what the expected defaults are (e.g. always disabled unless a user requests it, or always enabled) and what kind of code runs into the traps (e.g. buggy kernel code, correct kernel code, buggy user space code etc).

Arnd

#20 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 17 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch includes the exception/interrupt entries, pt_reg structure and related accessors.

Here it would be good to have a more detailed explanation about the alignment trap handling. I remember discussing it with you before, but don't remember the exact outcome. In particular you should explain here why you need to handle alignment traps in the first place, and what the expected defaults are (e.g. always disabled unless a user requests it, or always enabled) and what kind of code runs into the traps (e.g. buggy kernel code, correct kernel code, buggy user space code etc).

Quoted 1 line

Arnd

Dear Arnd:

I am plans to add the following description in the git commit's comment

Andes processors cannot load/store information which is not naturally aligned on the bus, i.e., loading a 4 byte data whose start address must be divisible by 4. If unaligned data accessing is happened, data unaligned exception will be triggered and user will get SIGSEGV or kernel oops according to the unaligned address. In order to make user able to load/store data from an unaligned address, software load /store emulation is implemented in arch/nds32/mm/alignment.c to handle data unaligned exception.

Unaligned accessing handling is disable by default because of it is not a normal case. User can follow the steps below to enable this feature.

A. Compile time:
1. Enable kernel config CONFIG_ALIGNMENT_TRAP
B. Run time:
1. Enter /proc/sys/nds32/unaligned_acess folder
2.
a. Write ‘1’ to file enable_mode to enable unaligned accessing handling
for user space
b. Write ‘2’ to file enable_mode to enable unaligned accessing handling
for kernel space
c. Write ‘3’ to file enable_mode to enable unaligned accessing handling
for user and kernel space
d. Write '0' to file enable_mode to disable all unaligned
accessing handling
3.
a. Write ‘1’ to file debug to show which unaligned address is addressed b. Write ‘0’ to file debug to disable all information

However, unaligned accessing handler can’t work on following conditions. A. The corresponding mode for unaligned address is not enabled. B. This unaligned address is not accessible such as protection violation. On these conditions, the default behaviors for data unaligned exception still happen.

Thanks

Vincent
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#21 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

Quoted 53 lines · Vincent Chen

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 17 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <[email protected]>

This patch includes the exception/interrupt entries, pt_reg structure and related accessors.

Here it would be good to have a more detailed explanation about the alignment trap handling. I remember discussing it with you before, but don't remember the exact outcome. In particular you should explain here why you need to handle alignment traps in the first place, and what the expected defaults are (e.g. always disabled unless a user requests it, or always enabled) and what kind of code runs into the traps (e.g. buggy kernel code, correct kernel code, buggy user space code etc).

Quoted 1 line

Arnd

Dear Arnd:

I am plans to add the following description in the git commit's comment

Andes processors cannot load/store information which is not naturally aligned on the bus, i.e., loading a 4 byte data whose start address must be divisible by 4. If unaligned data accessing is happened, data unaligned exception will be triggered and user will get SIGSEGV or kernel oops according to the unaligned address. In order to make user able to load/store data from an unaligned address, software load /store emulation is implemented in arch/nds32/mm/alignment.c to handle data unaligned exception.

Unaligned accessing handling is disable by default because of it is not a normal case. User can follow the steps below to enable this feature.

A. Compile time:
1. Enable kernel config CONFIG_ALIGNMENT_TRAP
B. Run time:
1. Enter /proc/sys/nds32/unaligned_acess folder
2.
a. Write ‘1’ to file enable_mode to enable unaligned accessing handling
for user space
b. Write ‘2’ to file enable_mode to enable unaligned accessing handling
for kernel space
c. Write ‘3’ to file enable_mode to enable unaligned accessing handling
for user and kernel space
d. Write '0' to file enable_mode to disable all unaligned
accessing handling
3.
a. Write ‘1’ to file debug to show which unaligned address is addressed b. Write ‘0’ to file debug to disable all information

Quoted 5 lines

However, unaligned accessing handler can’t work on following conditions. A. The corresponding mode for unaligned address is not enabled. B. This unaligned address is not accessible such as protection violation. On these conditions, the default behaviors for data unaligned exception still happen.

Ok. I still wonder about the kernel part of this though: is it a good idea for user space to configure whether the kernel does unaligned accesses? I would think that the kernel should just be fixed in such a case.

Arnd

maintainer
#22 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

Quoted 7 lines · Arnd Bergmann
Quoted 1 line · Vincent Chen

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Ok. I still wonder about the kernel part of this though: is it a good idea for user space to configure whether the kernel does unaligned accesses? I would think that the kernel should just be fixed in such a case.

To clarify: I'm asking only about unaligned accesses from kernel code itself, which is generally considered a bug when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is disabled.

Arnd

#23 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

2018-01-24 19:10 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Vincent Chen
Quoted 1 line

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Ok. I still wonder about the kernel part of this though: is it a good idea for user space to configure whether the kernel does unaligned accesses? I would think that the kernel should just be fixed in such a case.

Quoted 5 lines

To clarify: I'm asking only about unaligned accesses from kernel code itself, which is generally considered a bug when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is disabled.

Arnd

Thanks for your comments.

For performance, we decide always disable CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS even if hardware supports unaligned accessing. Therefore, I will remove kernel unaligned accessing from nds32/mm/alignment.c. In other words, alignment.c only addresses unaligned accessing for user space.

Vincent

maintainer
#24 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

Quoted 16 lines · Vincent Chen

2018-01-24 19:10 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Vincent Chen
Quoted 1 line

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Ok. I still wonder about the kernel part of this though: is it a good idea for user space to configure whether the kernel does unaligned accesses? I would think that the kernel should just be fixed in such a case.

Quoted 5 lines

To clarify: I'm asking only about unaligned accesses from kernel code itself, which is generally considered a bug when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is disabled.

Arnd

Quoted 7 lines

Thanks for your comments.

For performance, we decide always disable CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS even if hardware supports unaligned accessing. Therefore, I will remove kernel unaligned accessing from nds32/mm/alignment.c. In other words, alignment.c only addresses unaligned accessing for user space.

I'm not really following that logic, let's go through that again so I understand the situation better.

CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS should be set if and only if you have a CPU that does not need to trap on unaligned accesses.

What are the hardware capabilities on nds32? Do you have all three categories:

a) some CPUs that always trap on unaligned access
b) some CPUs that never trap on unaligned access
c) some CPUs that can be configured to either trap or not trap by the kernel?

Arnd

#25 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

Hi, Arnd:

2018-01-30 21:33 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 31 lines · Vincent Chen
Quoted 16 lines

2018-01-24 19:10 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Vincent Chen
Quoted 1 line

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Ok. I still wonder about the kernel part of this though: is it a good idea for user space to configure whether the kernel does unaligned accesses? I would think that the kernel should just be fixed in such a case.

Quoted 5 lines

To clarify: I'm asking only about unaligned accesses from kernel code itself, which is generally considered a bug when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is disabled.

Arnd

Quoted 7 lines

Thanks for your comments.

For performance, we decide always disable CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS even if hardware supports unaligned accessing. Therefore, I will remove kernel unaligned accessing from nds32/mm/alignment.c. In other words, alignment.c only addresses unaligned accessing for user space.

I'm not really following that logic, let's go through that again so I understand the situation better.

CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS should be set if and only if you have a CPU that does not need to trap on unaligned accesses.

Quoted 8 lines

What are the hardware capabilities on nds32? Do you have all three categories:

a) some CPUs that always trap on unaligned access
b) some CPUs that never trap on unaligned access
c) some CPUs that can be configured to either trap or not trap by the kernel?

We have type a and c.
We use CONFIG_ALIGNMENT_TRAP for a and
CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS for c.

Since unaligned access in kernel code itself should be considered as a bug, we will remove the emulation code to handle the kernel code unaligned accessed case.
We think CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS and CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS have different purposes because it will still be more efficient to access by byte even if hardware support unaligned access. CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS is used to prevent generating unaligned access exception.

Thus, we will
1. treat unaligned access in kernel code itself as a bug
2. don't select CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
3. disable CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS as default

maintainer
#26 lore raw

Re: [PATCH v6 07/36] nds32: Exception handling

Quoted 37 lines · Greentime Hu

Hi, Arnd:

2018-01-30 21:33 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 34 lines · Vincent Chen
Quoted 16 lines

2018-01-24 19:10 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · Vincent Chen
Quoted 1 line

2018-01-18 18:14 GMT+08:00 Arnd Bergmann <[email protected]>:

Ok. I still wonder about the kernel part of this though: is it a good idea for user space to configure whether the kernel does unaligned accesses? I would think that the kernel should just be fixed in such a case.

Quoted 5 lines

To clarify: I'm asking only about unaligned accesses from kernel code itself, which is generally considered a bug when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is disabled.

Arnd

Quoted 7 lines

Thanks for your comments.

For performance, we decide always disable CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS even if hardware supports unaligned accessing. Therefore, I will remove kernel unaligned accessing from nds32/mm/alignment.c. In other words, alignment.c only addresses unaligned accessing for user space.

I'm not really following that logic, let's go through that again so I understand the situation better.

CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS should be set if and only if you have a CPU that does not need to trap on unaligned accesses.

What are the hardware capabilities on nds32? Do you have all three categories:

Quoted 8 lines
Quoted 5 lines

a) some CPUs that always trap on unaligned access
b) some CPUs that never trap on unaligned access
c) some CPUs that can be configured to either trap or not trap by the kernel?

We have type a and c.
We use CONFIG_ALIGNMENT_TRAP for a and
CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS for c.

Ok, got it.

Quoted 9 lines

Since unaligned access in kernel code itself should be considered as a bug, we will remove the emulation code to handle the kernel code unaligned accessed case.
We think CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS and CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS have different purposes because it will still be more efficient to access by byte even if hardware support unaligned access. CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS is used to prevent generating unaligned access exception.

Hmm, this is a bit tricky. Most architectures actually assume that those two are the same, and nothing else has a HW_SUPPORT_UNALIGNMENT_ACCESS option.

We do actually have a related problem on 32-bit ARM, where the current generation of processors (ARMv6 and higher) support unaligned accesses for almost all instructions with the exception of those instructions that operate on multiple memory locations (ldm/stm and ldrd/strd). We can control the use of those instructions in inline assembler, and gcc never uses them when it knows that a pointer is unaligned, but when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set, the kernel sometimes intentionally contains code sequences that lead the compiler to believe that a variable is aligned when it is not, so we end up needing a trap handler here.

We might at some point want to clean this up by going through all uses of CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS and changing them in a way that leads to better results on both arm32 and nds32.

Arnd

#27 lore raw

PATCH v6 8/36 nds32: MMU definitions

In reply to Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch includes virtual memory layout, PHYS_OFFSET is defined as 0x0. It also includes the 4KB/8KB page size configurations and pte operations.

---
 arch/nds32/include/asm/fixmap.h   |   29 +++
 arch/nds32/include/asm/highmem.h  |   65 ++++++
 arch/nds32/include/asm/memory.h   |  105 ++++++++++
 arch/nds32/include/asm/mmu.h      |   12 ++
 arch/nds32/include/asm/page.h     |   67 ++++++
 arch/nds32/include/asm/pgalloc.h  |   96 +++++++++
 arch/nds32/include/asm/pgtable.h  |  409 +++++++++++++++++++++++++++++++++++++
 arch/nds32/include/asm/shmparam.h |   19 ++
 8 files changed, 802 insertions(+)
 create mode 100644 arch/nds32/include/asm/fixmap.h
 create mode 100644 arch/nds32/include/asm/highmem.h
 create mode 100644 arch/nds32/include/asm/memory.h
 create mode 100644 arch/nds32/include/asm/mmu.h
 create mode 100644 arch/nds32/include/asm/page.h
 create mode 100644 arch/nds32/include/asm/pgalloc.h
 create mode 100644 arch/nds32/include/asm/pgtable.h
 create mode 100644 arch/nds32/include/asm/shmparam.h
arch/nds32/include/asm/fixmap.h new file +29 -0
new file mode 100644
index 0000000..0e60e15
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_NDS32_FIXMAP_H
+#define __ASM_NDS32_FIXMAP_H
+
+#ifdef CONFIG_HIGHMEM
+#include <linux/threads.h>
+#include <asm/kmap_types.h>
+#endif
+
+enum fixed_addresses {
+	FIX_HOLE,
+	FIX_KMAP_RESERVED,
+	FIX_KMAP_BEGIN,
+#ifdef CONFIG_HIGHMEM
+	FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS),
+#endif
+	FIX_EARLYCON_MEM_BASE,
+	__end_of_fixed_addresses
+};
+#define FIXADDR_TOP             ((unsigned long) (-(16 * PAGE_SIZE)))
+#define FIXADDR_SIZE		((__end_of_fixed_addresses) << PAGE_SHIFT)
+#define FIXADDR_START		(FIXADDR_TOP - FIXADDR_SIZE)
+#define FIXMAP_PAGE_IO		__pgprot(PAGE_DEVICE)
+void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
+
+#include <asm-generic/fixmap.h>
+#endif /* __ASM_NDS32_FIXMAP_H */
arch/nds32/include/asm/highmem.h new file +65 -0

65 lines not on this page · raw message

arch/nds32/include/asm/memory.h new file +105 -0

105 lines not on this page · raw message

arch/nds32/include/asm/mmu.h new file +12 -0
new file mode 100644
index 0000000..88b9ee8
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_MMU_H
+#define __NDS32_MMU_H
+
+typedef struct {
+	unsigned int id;
+	void *vdso;
+} mm_context_t;
+
+#endif
arch/nds32/include/asm/page.h new file +67 -0

67 lines not on this page · raw message

arch/nds32/include/asm/pgalloc.h new file +96 -0

96 lines not on this page · raw message

arch/nds32/include/asm/pgtable.h new file +409 -0

409 lines not on this page · raw message

arch/nds32/include/asm/shmparam.h new file +19 -0
new file mode 100644
index 0000000..fd1cff6
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef _ASMNDS32_SHMPARAM_H
+#define _ASMNDS32_SHMPARAM_H
+
+/*
+ * This should be the size of the virtually indexed cache/ways,
+ * whichever is greater since the cache aliases every size/ways
+ * bytes.
+ */
+#define	SHMLBA	(4 * SZ_8K)	/* attach addr a multiple of this */
+
+/*
+ * Enforce SHMLBA in shmat
+ */
+#define __ARCH_FORCE_SHMLBA
+
+#endif /* _ASMNDS32_SHMPARAM_H */
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#29 lore raw

PATCH v6 9/36 nds32: MMU initialization

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes memory initializations and highmem supporting.

---
 arch/nds32/mm/highmem.c  |   79 +++++++++++++
 arch/nds32/mm/init.c     |  277 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/nds32/mm/mm-nds32.c |   90 +++++++++++++++
 3 files changed, 446 insertions(+)
 create mode 100644 arch/nds32/mm/highmem.c
 create mode 100644 arch/nds32/mm/init.c
 create mode 100644 arch/nds32/mm/mm-nds32.c
arch/nds32/mm/highmem.c new file +79 -0
new file mode 100644
index 0000000..e17cb8a
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/export.h>
+#include <linux/highmem.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/interrupt.h>
+#include <linux/bootmem.h>
+#include <asm/fixmap.h>
+#include <asm/tlbflush.h>
+
+void *kmap(struct page *page)
+{
+	unsigned long vaddr;
+	might_sleep();
+	if (!PageHighMem(page))
+		return page_address(page);
+	vaddr = (unsigned long)kmap_high(page);
+	return (void *)vaddr;
+}
+
+EXPORT_SYMBOL(kmap);
+
+void kunmap(struct page *page)
+{
+	BUG_ON(in_interrupt());
+	if (!PageHighMem(page))
+		return;
+	kunmap_high(page);
+}
+
+EXPORT_SYMBOL(kunmap);
+
+void *kmap_atomic(struct page *page)
+{
+	unsigned int idx;
+	unsigned long vaddr, pte;
+	int type;
+	pte_t *ptep;
+
+	preempt_disable();
+	pagefault_disable();
+	if (!PageHighMem(page))
+		return page_address(page);
+
+	type = kmap_atomic_idx_push();
+
+	idx = type + KM_TYPE_NR * smp_processor_id();
+	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+	pte = (page_to_pfn(page) << PAGE_SHIFT) | (PAGE_KERNEL);
+	ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
+	set_pte(ptep, pte);
+
+	__nds32__tlbop_inv(vaddr);
+	__nds32__mtsr_dsb(vaddr, NDS32_SR_TLB_VPN);
+	__nds32__tlbop_rwr(pte);
+	__nds32__isb();
+	return (void *)vaddr;
+}
+
+EXPORT_SYMBOL(kmap_atomic);
+
+void __kunmap_atomic(void *kvaddr)
+{
+	if (kvaddr >= (void *)FIXADDR_START) {
+		unsigned long vaddr = (unsigned long)kvaddr;
+		pte_t *ptep;
+		kmap_atomic_idx_pop();
+		__nds32__tlbop_inv(vaddr);
+		__nds32__isb();
+		ptep = pte_offset_kernel(pmd_off_k(vaddr), vaddr);
+		set_pte(ptep, 0);
+	}
+	pagefault_enable();
+	preempt_enable();
+}
+
+EXPORT_SYMBOL(__kunmap_atomic);
arch/nds32/mm/init.c new file +277 -0

277 lines not on this page · raw message

arch/nds32/mm/mm-nds32.c new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#31 lore raw

PATCH v6 10/36 nds32: MMU fault handling and page table management

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes page fault handler, mmap and fixup implementations.

---
 arch/nds32/lib/copy_page.S |   37 ++++
 arch/nds32/mm/extable.c    |   16 ++
 arch/nds32/mm/fault.c      |  410 ++++++++++++++++++++++++++++++++++++++++++++
 arch/nds32/mm/mmap.c       |   73 ++++++++
 4 files changed, 536 insertions(+)
 create mode 100644 arch/nds32/lib/copy_page.S
 create mode 100644 arch/nds32/mm/extable.c
 create mode 100644 arch/nds32/mm/fault.c
 create mode 100644 arch/nds32/mm/mmap.c
arch/nds32/lib/copy_page.S new file +37 -0
new file mode 100644
index 0000000..4a2ff85
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+#include <asm/page.h>
+
+	.text
+ENTRY(copy_page)
+	pushm	$r2, $r10
+	movi	$r2, PAGE_SIZE >> 5
+.Lcopy_loop:
+	lmw.bim	$r3, [$r1], $r10
+	smw.bim	$r3, [$r0], $r10
+	subi45	$r2, #1
+	bnez38	$r2, .Lcopy_loop
+	popm	$r2, $r10
+	ret
+ENDPROC(copy_page)
+
+ENTRY(clear_page)
+	pushm	$r1, $r9
+	movi	$r1, PAGE_SIZE >> 5
+	movi55	$r2, #0
+	movi55	$r3, #0
+	movi55	$r4, #0
+	movi55	$r5, #0
+	movi55	$r6, #0
+	movi55	$r7, #0
+	movi55	$r8, #0
+	movi55	$r9, #0
+.Lclear_loop:
+	smw.bim	$r2, [$r0], $r9
+	subi45	$r1, #1
+	bnez38	$r1, .Lclear_loop
+	popm	$r1, $r9
+        ret
+ENDPROC(clear_page)
arch/nds32/mm/extable.c new file +16 -0
new file mode 100644
index 0000000..db7f0a7
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/extable.h>
+#include <linux/uaccess.h>
+
+int fixup_exception(struct pt_regs *regs)
+{
+	const struct exception_table_entry *fixup;
+
+	fixup = search_exception_tables(instruction_pointer(regs));
+	if (fixup)
+		regs->ipc = fixup->fixup;
+
+	return fixup != NULL;
+}
arch/nds32/mm/fault.c new file +410 -0

410 lines not on this page · raw message

arch/nds32/mm/mmap.c new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#33 lore raw

PATCH v6 11/36 nds32: Cache and TLB routines

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch contains cache and TLB maintenance functions.

---
 arch/nds32/include/asm/cache.h         |   12 +
 arch/nds32/include/asm/cache_info.h    |   13 +
 arch/nds32/include/asm/cacheflush.h    |   44 +++
 arch/nds32/include/asm/mmu_context.h   |   68 ++++
 arch/nds32/include/asm/proc-fns.h      |   44 +++
 arch/nds32/include/asm/tlb.h           |   28 ++
 arch/nds32/include/asm/tlbflush.h      |   47 +++
 arch/nds32/include/uapi/asm/cachectl.h |   14 +
 arch/nds32/kernel/cacheinfo.c          |   49 +++
 arch/nds32/mm/cacheflush.c             |  322 +++++++++++++++++++
 arch/nds32/mm/proc.c                   |  533 ++++++++++++++++++++++++++++++++
 arch/nds32/mm/tlb.c                    |   50 +++
 12 files changed, 1224 insertions(+)
 create mode 100644 arch/nds32/include/asm/cache.h
 create mode 100644 arch/nds32/include/asm/cache_info.h
 create mode 100644 arch/nds32/include/asm/cacheflush.h
 create mode 100644 arch/nds32/include/asm/mmu_context.h
 create mode 100644 arch/nds32/include/asm/proc-fns.h
 create mode 100644 arch/nds32/include/asm/tlb.h
 create mode 100644 arch/nds32/include/asm/tlbflush.h
 create mode 100644 arch/nds32/include/uapi/asm/cachectl.h
 create mode 100644 arch/nds32/kernel/cacheinfo.c
 create mode 100644 arch/nds32/mm/cacheflush.c
 create mode 100644 arch/nds32/mm/proc.c
 create mode 100644 arch/nds32/mm/tlb.c
arch/nds32/include/asm/cache.h new file +12 -0
new file mode 100644
index 0000000..347db48
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_CACHE_H__
+#define __NDS32_CACHE_H__
+
+#define L1_CACHE_BYTES	32
+#define L1_CACHE_SHIFT	5
+
+#define ARCH_DMA_MINALIGN   L1_CACHE_BYTES
+
+#endif /* __NDS32_CACHE_H__ */
arch/nds32/include/asm/cache_info.h new file +13 -0
new file mode 100644
index 0000000..38ec458
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+struct cache_info {
+	unsigned char ways;
+	unsigned char line_size;
+	unsigned short sets;
+	unsigned short size;
+#if defined(CONFIG_CPU_CACHE_ALIASING)
+	unsigned short aliasing_num;
+	unsigned int aliasing_mask;
+#endif
+};
arch/nds32/include/asm/cacheflush.h new file +44 -0

44 lines not on this page · raw message

arch/nds32/include/asm/mmu_context.h new file +68 -0

68 lines not on this page · raw message

arch/nds32/include/asm/proc-fns.h new file +44 -0

44 lines not on this page · raw message

arch/nds32/include/asm/tlb.h new file +28 -0
new file mode 100644
index 0000000..b35ae5e
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASMNDS32_TLB_H
+#define __ASMNDS32_TLB_H
+
+#define tlb_start_vma(tlb,vma)						\
+	do {								\
+		if (!tlb->fullmm)					\
+			flush_cache_range(vma, vma->vm_start, vma->vm_end); \
+	} while (0)
+
+#define tlb_end_vma(tlb,vma)				\
+	do { 						\
+		if(!tlb->fullmm)			\
+			flush_tlb_range(vma, vma->vm_start, vma->vm_end); \
+	} while (0)
+
+#define __tlb_remove_tlb_entry(tlb, pte, addr) do { } while (0)
+
+#define tlb_flush(tlb)	flush_tlb_mm((tlb)->mm)
+
+#include <asm-generic/tlb.h>
+
+#define __pte_free_tlb(tlb, pte, addr)	pte_free((tlb)->mm, pte)
+#define __pmd_free_tlb(tlb, pmd, addr)	pmd_free((tln)->mm, pmd)
+
+#endif
arch/nds32/include/asm/tlbflush.h new file +47 -0

47 lines not on this page · raw message

arch/nds32/include/uapi/asm/cachectl.h new file +14 -0
new file mode 100644
index 0000000..4cdca9b
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 1994, 1995, 1996 by Ralf Baechle
+// Copyright (C) 2005-2017 Andes Technology Corporation
+#ifndef	_ASM_CACHECTL
+#define	_ASM_CACHECTL
+
+/*
+ * Options for cacheflush system call
+ */
+#define	ICACHE	0		/* flush instruction cache        */
+#define	DCACHE	1		/* writeback and flush data cache */
+#define	BCACHE	2		/* flush instruction cache + writeback and flush data cache */
+
+#endif /* _ASM_CACHECTL */
arch/nds32/kernel/cacheinfo.c new file +49 -0

49 lines not on this page · raw message

arch/nds32/mm/cacheflush.c new file +322 -0

322 lines not on this page · raw message

arch/nds32/mm/proc.c new file +533 -0

533 lines not on this page · raw message

arch/nds32/mm/tlb.c new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 11/36
#34 lore raw

Re: [PATCH v6 11/36] nds32: Cache and TLB routines

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch contains cache and TLB maintenance functions.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#35 lore raw

PATCH v6 12/36 nds32: Process management

In reply to Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch includes copy_thread(), start_thread() implementation and cpu_context structure definition. nds32 uses $r25 to get current task_struct.

---
 arch/nds32/include/asm/current.h     |   12 ++
 arch/nds32/include/asm/processor.h   |  102 +++++++++++++++++
 arch/nds32/include/asm/thread_info.h |   78 +++++++++++++
 arch/nds32/kernel/process.c          |  204 ++++++++++++++++++++++++++++++++++
 4 files changed, 396 insertions(+)
 create mode 100644 arch/nds32/include/asm/current.h
 create mode 100644 arch/nds32/include/asm/processor.h
 create mode 100644 arch/nds32/include/asm/thread_info.h
 create mode 100644 arch/nds32/kernel/process.c
arch/nds32/include/asm/current.h new file +12 -0
new file mode 100644
index 0000000..b4dcd22
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef _ASM_NDS32_CURRENT_H
+#define _ASM_NDS32_CURRENT_H
+
+#ifndef __ASSEMBLY__
+register struct task_struct *current asm("$r25");
+#endif /* __ASSEMBLY__ */
+#define tsk $r25
+
+#endif /* _ASM_NDS32_CURRENT_H */
arch/nds32/include/asm/processor.h new file +102 -0

102 lines not on this page · raw message

arch/nds32/include/asm/thread_info.h new file +78 -0

78 lines not on this page · raw message

arch/nds32/kernel/process.c new file +204 -0

204 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer Acked-by on v6 12/36
#36 lore raw

Re: [PATCH v6 12/36] nds32: Process management

Quoted 17 lines · Greentime Hu
arch/nds32/kernel/process.c new file +17 -0
+void machine_restart(char *__unused)
+{
+       /*
+        * Clean and disable cache, and turn off interrupts
+        */
+       cpu_proc_fin();
+
+       /*
+        * Tell the mm system that we are going to reboot -
+        * we may need it to insert some 1:1 mappings so that
+        * soft boot works.
+        */
+       setup_mm_for_reboot(reboot_mode);
+
+       /*
+        * Now call the architecture specific reboot code.
+        */

arch/nds32/kernel/process.c line 87

Quoted 10 lines
arch/nds32/kernel/process.c new file +10 -0
+       arch_reset(reboot_mode);
+
+       /*
+        * Whoops - the architecture was unable to reboot.
+        * Tell the user!
+        */
+       mdelay(1000);
+       pr_info("Reboot failed -- System halted\n");
+       while (1) ;
+}

You should insert a call to do_kernel_restart() in this function to allow e.g. a watchdog driver to provide a machine-specific reboot method. Otherwise the patch looks good to me,

#37 lore raw

PATCH v6 13/36 nds32: IRQ handling

In reply to Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch includes irq related functions and irqchip_init().

---
 arch/nds32/include/asm/irqflags.h |   36 ++++++++++++++++++++++++++++++++++++
 arch/nds32/kernel/irq.c           |    9 +++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 arch/nds32/include/asm/irqflags.h
 create mode 100644 arch/nds32/kernel/irq.c
arch/nds32/include/asm/irqflags.h new file +36 -0
new file mode 100644
index 0000000..2bfd00f
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <asm/nds32.h>
+#include <nds32_intrinsic.h>
+
+#define arch_local_irq_disable()	\
+	GIE_DISABLE();
+
+#define arch_local_irq_enable()	\
+	GIE_ENABLE();
+static inline unsigned long arch_local_irq_save(void)
+{
+	unsigned long flags;
+	flags = __nds32__mfsr(NDS32_SR_PSW) & PSW_mskGIE;
+	GIE_DISABLE();
+	return flags;
+}
+
+static inline unsigned long arch_local_save_flags(void)
+{
+	unsigned long flags;
+	flags = __nds32__mfsr(NDS32_SR_PSW) & PSW_mskGIE;
+	return flags;
+}
+
+static inline void arch_local_irq_restore(unsigned long flags)
+{
+	if(flags)
+		GIE_ENABLE();
+}
+
+static inline int arch_irqs_disabled_flags(unsigned long flags)
+{
+	return !flags;
+}
arch/nds32/kernel/irq.c new file +9 -0
new file mode 100644
index 0000000..6ff5a67
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/irqchip.h>
+
+void __init init_IRQ(void)
+{
+	irqchip_init();
+}
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#39 lore raw

PATCH v6 14/36 nds32: Atomic operations

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch includes the atomic and futex operations. Many atomic operations use the load-lock word(llw) and store-condition word(scw) operations.

---
 arch/nds32/include/asm/barrier.h |   15 ++++++
 arch/nds32/include/asm/futex.h   |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+)
 create mode 100644 arch/nds32/include/asm/barrier.h
 create mode 100644 arch/nds32/include/asm/futex.h
arch/nds32/include/asm/barrier.h new file +15 -0
new file mode 100644
index 0000000..faafc37
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_ASM_BARRIER_H
+#define __NDS32_ASM_BARRIER_H
+
+#ifndef __ASSEMBLY__
+#define mb()		asm volatile("msync all":::"memory")
+#define rmb()		asm volatile("msync all":::"memory")
+#define wmb()		asm volatile("msync store":::"memory")
+#include <asm-generic/barrier.h>
+
+#endif	/* __ASSEMBLY__ */
+
+#endif	/* __NDS32_ASM_BARRIER_H */
arch/nds32/include/asm/futex.h new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#41 lore raw

PATCH v6 15/36 nds32: Device specific operations

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch introduces ioremap implementations.

---
 arch/nds32/include/asm/io.h |   83 +++++++++++++++++++++++++++++++++++++++++++
 arch/nds32/mm/ioremap.c     |   62 ++++++++++++++++++++++++++++++++
 2 files changed, 145 insertions(+)
 create mode 100644 arch/nds32/include/asm/io.h
 create mode 100644 arch/nds32/mm/ioremap.c
arch/nds32/include/asm/io.h new file +83 -0
new file mode 100644
index 0000000..966e71b
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_NDS32_IO_H
+#define __ASM_NDS32_IO_H
+
+extern void iounmap(volatile void __iomem *addr);
+#define __raw_writeb __raw_writeb
+static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
+{
+	asm volatile("sbi %0, [%1]" : : "r" (val), "r" (addr));
+}
+
+#define __raw_writew __raw_writew
+static inline void __raw_writew(u16 val, volatile void __iomem *addr)
+{
+	asm volatile("shi %0, [%1]" : : "r" (val), "r" (addr));
+}
+
+#define __raw_writel __raw_writel
+static inline void __raw_writel(u32 val, volatile void __iomem *addr)
+{
+	asm volatile("swi %0, [%1]" : : "r" (val), "r" (addr));
+}
+
+#define __raw_readb __raw_readb
+static inline u8 __raw_readb(const volatile void __iomem *addr)
+{
+	u8 val;
+
+	asm volatile("lbi %0, [%1]" : "=r" (val) : "r" (addr));
+	return val;
+}
+
+#define __raw_readw __raw_readw
+static inline u16 __raw_readw(const volatile void __iomem *addr)
+{
+	u16 val;
+
+	asm volatile("lhi %0, [%1]" : "=r" (val) : "r" (addr));
+	return val;
+}
+
+#define __raw_readl __raw_readl
+static inline u32 __raw_readl(const volatile void __iomem *addr)
+{
+	u32 val;
+
+	asm volatile("lwi %0, [%1]" : "=r" (val) : "r" (addr));
+	return val;
+}
+
+#define __iormb()               rmb()
+#define __iowmb()               wmb()
+
+#define mmiowb()        __asm__ __volatile__ ("msync all" : : : "memory");
+
+/*
+ * {read,write}{b,w,l,q}_relaxed() are like the regular version, but
+ * are not guaranteed to provide ordering against spinlocks or memory
+ * accesses.
+ */
+
+#define readb_relaxed(c)	({ u8  __v = __raw_readb(c); __v; })
+#define readw_relaxed(c)	({ u16 __v = le16_to_cpu((__force __le16)__raw_readw(c)); __v; })
+#define readl_relaxed(c)	({ u32 __v = le32_to_cpu((__force __le32)__raw_readl(c)); __v; })
+#define writeb_relaxed(v,c)	((void)__raw_writeb((v),(c)))
+#define writew_relaxed(v,c)	((void)__raw_writew((__force u16)cpu_to_le16(v),(c)))
+#define writel_relaxed(v,c)	((void)__raw_writel((__force u32)cpu_to_le32(v),(c)))
+
+/*
+ * {read,write}{b,w,l,q}() access little endian memory and return result in
+ * native endianness.
+ */
+#define readb(c)	({ u8  __v = readb_relaxed(c); __iormb(); __v; })
+#define readw(c)	({ u16 __v = readw_relaxed(c); __iormb(); __v; })
+#define readl(c)	({ u32 __v = readl_relaxed(c); __iormb(); __v; })
+
+#define writeb(v,c)	({ __iowmb(); writeb_relaxed((v),(c)); })
+#define writew(v,c)	({ __iowmb(); writew_relaxed((v),(c)); })
+#define writel(v,c)	({ __iowmb(); writel_relaxed((v),(c)); })
+#include <asm-generic/io.h>
+#endif /* __ASM_NDS32_IO_H */
arch/nds32/mm/ioremap.c new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#43 lore raw

PATCH v6 16/36 nds32: DMA mapping API

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for the DMA mapping API. It uses dma_map_ops for flexibility.

---
 arch/nds32/include/asm/dma-mapping.h |   14 ++
 arch/nds32/kernel/dma.c              |  459 ++++++++++++++++++++++++++++++++++
 2 files changed, 473 insertions(+)
 create mode 100644 arch/nds32/include/asm/dma-mapping.h
 create mode 100644 arch/nds32/kernel/dma.c
arch/nds32/include/asm/dma-mapping.h new file +14 -0
new file mode 100644
index 0000000..2dd47d24
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef ASMNDS32_DMA_MAPPING_H
+#define ASMNDS32_DMA_MAPPING_H
+
+extern struct dma_map_ops nds32_dma_ops;
+
+static inline struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
+{
+	return &nds32_dma_ops;
+}
+
+#endif
arch/nds32/kernel/dma.c new file +459 -0

459 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#45 lore raw

Re: [PATCH v6 16/36] nds32: DMA mapping API

Hi, Arnd:

2018-01-18 18:26 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 11 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <[email protected]>

This patch adds support for the DMA mapping API. It uses dma_map_ops for flexibility.

I'm still unhappy about the way the cache flushes are done here as discussed before. It's not a show-stopped, but no Ack from me.

How about this implementation?

static void
nds32_dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)

{
        switch (direction) {
        case DMA_TO_DEVICE:     /* writeback only */
                break;
        case DMA_FROM_DEVICE:   /* invalidate only */
        case DMA_BIDIRECTIONAL: /* writeback and invalidate */
                cpu_dma_inval_range(start, end);
                break;
        default:
                BUG();
        }
}

static void
nds32_dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)

{
        switch (direction) {
        case DMA_FROM_DEVICE:   /* invalidate only */
                break;
        case DMA_TO_DEVICE:     /* writeback only */
        case DMA_BIDIRECTIONAL: /* writeback and invalidate */
                cpu_dma_wb_range(start, end);
                break;
        default:
                BUG();
        }
}
#46 lore raw

Re: [PATCH v6 16/36] nds32: DMA mapping API

Hi, Arnd:

2018-01-23 16:23 GMT+08:00 Greentime Hu <[email protected]>:

Quoted 36 lines

Hi, Arnd:

2018-01-18 18:26 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 11 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for the DMA mapping API. It uses dma_map_ops for flexibility.

I'm still unhappy about the way the cache flushes are done here as discussed before. It's not a show-stopped, but no Ack from me.

How about this implementation?

static void
nds32_dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)

{
        switch (direction) {
        case DMA_TO_DEVICE:     /* writeback only */
                break;
        case DMA_FROM_DEVICE:   /* invalidate only */
        case DMA_BIDIRECTIONAL: /* writeback and invalidate */
                cpu_dma_inval_range(start, end);
                break;
        default:
                BUG();
        }
}

static void
nds32_dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)

Quoted 12 lines
{
        switch (direction) {
        case DMA_FROM_DEVICE:   /* invalidate only */
                break;
        case DMA_TO_DEVICE:     /* writeback only */
        case DMA_BIDIRECTIONAL: /* writeback and invalidate */
                cpu_dma_wb_range(start, end);
                break;
        default:
                BUG();
        }
}

I am not sure if I understand it correctly.
I list all the combinations.

RAM to DEVICE
before DMA => writeback cache
after DMA => nop

DEVICE to RAM
before DMA => nop
after DMA => invalidate cache

static void consistent_sync(void *vaddr, size_t size, int direction, int master)

{
        unsigned long start = (unsigned long)vaddr;
        unsigned long end = start + size;

        if (master == FOR_CPU) {
                switch (direction) {
                case DMA_TO_DEVICE:
                        break;
                case DMA_FROM_DEVICE:
                case DMA_BIDIRECTIONAL:
                        cpu_dma_inval_range(start, end);
                        break;
                default:
                        BUG();
                }
        } else {
                /* FOR_DEVICE */
                switch (direction) {
                case DMA_FROM_DEVICE:
                        break;
                case DMA_TO_DEVICE:
                case DMA_BIDIRECTIONAL:
                        cpu_dma_wb_range(start, end);
                        break;
                default:
                        BUG();
                }
        }
}

static void
nds32_dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)

{
        consistent_sync((void *)phys_to_virt(handle), size, dir, FOR_CPU);
}

static void
nds32_dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir)

{
        consistent_sync((void *)phys_to_virt(handle), size, dir, FOR_DEVICE);
}

static dma_addr_t nds32_dma_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long attrs)
{
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
consistent_sync((void *)(page_address(page) + offset),

size, dir, FOR_DEVICE);
        return page_to_phys(page) + offset;
}

static void nds32_dma_unmap_page(struct device *dev, dma_addr_t handle,
size_t size, enum dma_data_direction dir, unsigned long attrs)

{
        if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
                consistent_sync(phys_to_virt(handle), size, dir, FOR_CPU);
}

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#47 lore raw

Re: [PATCH v6 16/36] nds32: DMA mapping API

Quoted 53 lines · Greentime Hu

Hi, Arnd:

2018-01-23 16:23 GMT+08:00 Greentime Hu <[email protected]>:

Quoted 9 lines

Hi, Arnd:

2018-01-18 18:26 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 6 lines · Greentime Hu
Quoted 5 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for the DMA mapping API. It uses dma_map_ops for flexibility.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I'm still unhappy about the way the cache flushes are done here as discussed before. It's not a show-stopped, but no Ack from me.

How about this implementation?

I am not sure if I understand it correctly.
I list all the combinations.

RAM to DEVICE
before DMA => writeback cache
after DMA => nop

DEVICE to RAM
before DMA => nop
after DMA => invalidate cache

static void consistent_sync(void *vaddr, size_t size, int direction, int master)

{
        unsigned long start = (unsigned long)vaddr;
        unsigned long end = start + size;

        if (master == FOR_CPU) {
                switch (direction) {
                case DMA_TO_DEVICE:
                        break;
                case DMA_FROM_DEVICE:
                case DMA_BIDIRECTIONAL:
                        cpu_dma_inval_range(start, end);
                        break;
                default:
                        BUG();
                }
        } else {
                /* FOR_DEVICE */
                switch (direction) {
                case DMA_FROM_DEVICE:
                        break;
                case DMA_TO_DEVICE:
Quoted 8 lines
                case DMA_BIDIRECTIONAL:
                        cpu_dma_wb_range(start, end);
                        break;
                default:
                        BUG();
                }
        }
}

That looks reasonable enough, but it does depend on a number of factors, and the dma-mapping.h implementation is not just about cache flushes.

As I don't know the microarchitecture, can you answer these questions:

- are caches always write-back, or could they be write-through?
- can the cache be shared with another CPU or a device?
- if the cache is shared, is it always coherent, never coherent, or either of them?
- could the same memory be visible at different physical addresses and have conflicting caches?
- is the CPU physical address always the same as the address visible to the device?
- are there devices that can only see a subset of the physical memory?
- can there be an IOMMU?
- are there write-buffers in the CPU that might need to get flushed before flushing the cache?
- could cache lines be loaded speculatively or with read-ahead while a buffer is owned by a device?

Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#48 lore raw

Re: [PATCH v6 16/36] nds32: DMA mapping API

Hi, Arnd:

2018-01-24 19:36 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 63 lines · Greentime Hu
Quoted 53 lines

Hi, Arnd:

2018-01-23 16:23 GMT+08:00 Greentime Hu <[email protected]>:

Quoted 9 lines

Hi, Arnd:

2018-01-18 18:26 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 6 lines · Greentime Hu
Quoted 5 lines

From: Greentime Hu <[email protected]>

This patch adds support for the DMA mapping API. It uses dma_map_ops for flexibility.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I'm still unhappy about the way the cache flushes are done here as discussed before. It's not a show-stopped, but no Ack from me.

How about this implementation?

I am not sure if I understand it correctly.
I list all the combinations.

RAM to DEVICE
before DMA => writeback cache
after DMA => nop

DEVICE to RAM
before DMA => nop
after DMA => invalidate cache

static void consistent_sync(void *vaddr, size_t size, int direction, int master)

{
        unsigned long start = (unsigned long)vaddr;
        unsigned long end = start + size;

        if (master == FOR_CPU) {
                switch (direction) {
                case DMA_TO_DEVICE:
                        break;
                case DMA_FROM_DEVICE:
                case DMA_BIDIRECTIONAL:
                        cpu_dma_inval_range(start, end);
                        break;
                default:
                        BUG();
                }
        } else {
                /* FOR_DEVICE */
                switch (direction) {
                case DMA_FROM_DEVICE:
                        break;
                case DMA_TO_DEVICE:
Quoted 8 lines
                case DMA_BIDIRECTIONAL:
                        cpu_dma_wb_range(start, end);
                        break;
                default:
                        BUG();
                }
        }
}
Quoted 6 lines

That looks reasonable enough, but it does depend on a number of factors, and the dma-mapping.h implementation is not just about cache flushes.

As I don't know the microarchitecture, can you answer these questions:

- are caches always write-back, or could they be write-through?

Yes, we can config it to write-back or write-through.

Quoted 1 line

- can the cache be shared with another CPU or a device?

No, we don't support it.

Quoted 2 lines

- if the cache is shared, is it always coherent, never coherent, or either of them?

We don't support SMP and the device will access memory through bus. I think the cache is not shared.

Quoted 2 lines

- could the same memory be visible at different physical addresses and have conflicting caches?

We currently don't have such kind of SoC memory map.

Quoted 2 lines

- is the CPU physical address always the same as the address visible to the device?

Yes, it is always the same unless the CPU uses local memory. The physical address of local memory will overlap the original bus address.
I think the local memory case can be ignored because we don't use it for now.

Quoted 1 line

- are there devices that can only see a subset of the physical memory?

All devices are able to see the whole physical memory in our current SoC, but I think other SoC may support such kind of HW behavior.

Quoted 1 line

- can there be an IOMMU?

No.

Quoted 2 lines

- are there write-buffers in the CPU that might need to get flushed before flushing the cache?

Yes, there are write-buffers in front of CPU caches but it should be transparent to SW. We don't need to flush it.

Quoted 2 lines

- could cache lines be loaded speculatively or with read-ahead while a buffer is owned by a device?

No.

maintainer Acked-by
#49 lore raw

Re: [PATCH v6 16/36] nds32: DMA mapping API

Quoted 6 lines · Greentime Hu

2018-01-24 19:36 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 5 lines · Greentime Hu
Quoted 3 lines

2018-01-23 16:23 GMT+08:00 Greentime Hu <[email protected]>:

Quoted 2 lines

2018-01-18 18:26 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 1 line · Greentime Hu
Quoted 7 lines
Quoted 6 lines

That looks reasonable enough, but it does depend on a number of factors, and the dma-mapping.h implementation is not just about cache flushes.

As I don't know the microarchitecture, can you answer these questions:

- are caches always write-back, or could they be write-through?

Yes, we can config it to write-back or write-through.

Ok. If a WT-cache is common enough, you could optimize for that case by skipping the explicit writeback here and just doing a synchronizing instruction. Usually if the cache is configurable, one would pick the writeback option though, so it's probably not important.

Quoted 6 lines
Quoted 2 lines

- is the CPU physical address always the same as the address visible to the device?

Yes, it is always the same unless the CPU uses local memory. The physical address of local memory will overlap the original bus address.
I think the local memory case can be ignored because we don't use it for now.

Ok, makes sense.

Quoted 3 lines
Quoted 1 line

- are there devices that can only see a subset of the physical memory?

All devices are able to see the whole physical memory in our current SoC, but I think other SoC may support such kind of HW behavior.

This is one area that might need a more complex implementation then, depending on what devices are used in other SoCs. For network or storage devices, it's usually sufficient to configure a DMA mask from the "dma-ranges" property of the parent bus in the device tree, the kernel code will then use bounce buffers.

For other types of drivers, using the streaming DMA interfaces can require using the swiotlb helper that performs the bounce buffering at in place of the cache operations. With a bit of luck, you won't ever need to worry about it, just mentioning it here in case you run into that problem later.

The consistent_sync() implementaiton you showed earlier should be good enough then. With that change,

#50 lore raw

Re: [PATCH v6 16/36] nds32: DMA mapping API

Hi, Arnd:

2018-01-25 18:42 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 12 lines · Greentime Hu
Quoted 11 lines

2018-01-24 19:36 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 10 lines · Greentime Hu
Quoted 3 lines

2018-01-23 16:23 GMT+08:00 Greentime Hu <[email protected]>:

Quoted 2 lines

2018-01-18 18:26 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 1 line · Greentime Hu

That looks reasonable enough, but it does depend on a number of factors, and the dma-mapping.h implementation is not just about cache flushes.

As I don't know the microarchitecture, can you answer these questions:

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

- are caches always write-back, or could they be write-through?

Yes, we can config it to write-back or write-through.

Ok. If a WT-cache is common enough, you could optimize for that case by skipping the explicit writeback here and just doing a synchronizing instruction. Usually if the cache is configurable, one would pick the writeback option though, so it's probably not important.

Thank you for this suggestion.
We have optimized in cpu_dcache_wb_range() and it will be called from cpu_dma_wb_range().
It will do nothing if it is a write-through config cache.

Quoted 25 lines
Quoted 6 lines
Quoted 2 lines

- is the CPU physical address always the same as the address visible to the device?

Yes, it is always the same unless the CPU uses local memory. The physical address of local memory will overlap the original bus address.
I think the local memory case can be ignored because we don't use it for now.

Ok, makes sense.

Quoted 3 lines
Quoted 1 line

- are there devices that can only see a subset of the physical memory?

All devices are able to see the whole physical memory in our current SoC, but I think other SoC may support such kind of HW behavior.

This is one area that might need a more complex implementation then, depending on what devices are used in other SoCs. For network or storage devices, it's usually sufficient to configure a DMA mask from the "dma-ranges" property of the parent bus in the device tree, the kernel code will then use bounce buffers.

For other types of drivers, using the streaming DMA interfaces can require using the swiotlb helper that performs the bounce buffering at in place of the cache operations. With a bit of luck, you won't ever need to worry about it, just mentioning it here in case you run into that problem later.

Quoted 4 lines

The consistent_sync() implementaiton you showed earlier should be good enough then. With that change,

Thank you. :)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#51 lore raw

PATCH v6 17/36 nds32: ELF definitions

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds definitions for the ELF format, relocation types, vdso locations and EXEC_PAGESIZE.

---
 arch/nds32/include/asm/elf.h         |  171 ++++++++++++++++++++++++++++++++++
 arch/nds32/include/uapi/asm/auxvec.h |   12 +++
 arch/nds32/include/uapi/asm/param.h  |   11 +++
 3 files changed, 194 insertions(+)
 create mode 100644 arch/nds32/include/asm/elf.h
 create mode 100644 arch/nds32/include/uapi/asm/auxvec.h
 create mode 100644 arch/nds32/include/uapi/asm/param.h
arch/nds32/include/asm/elf.h new file +171 -0
new file mode 100644
index 0000000..56c4790
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASMNDS32_ELF_H
+#define __ASMNDS32_ELF_H
+
+/*
+ * ELF register definitions..
+ */
+
+#include <asm/ptrace.h>
+
+typedef unsigned long elf_greg_t;
+typedef unsigned long elf_freg_t[3];
+
+extern unsigned int elf_hwcap;
+
+#define EM_NDS32			167
+
+#define R_NDS32_NONE			0
+#define R_NDS32_16_RELA			19
+#define R_NDS32_32_RELA			20
+#define R_NDS32_9_PCREL_RELA		22
+#define R_NDS32_15_PCREL_RELA		23
+#define R_NDS32_17_PCREL_RELA		24
+#define R_NDS32_25_PCREL_RELA		25
+#define R_NDS32_HI20_RELA		26
+#define R_NDS32_LO12S3_RELA		27
+#define R_NDS32_LO12S2_RELA		28
+#define R_NDS32_LO12S1_RELA		29
+#define R_NDS32_LO12S0_RELA		30
+#define R_NDS32_SDA15S3_RELA    	31
+#define R_NDS32_SDA15S2_RELA    	32
+#define R_NDS32_SDA15S1_RELA    	33
+#define R_NDS32_SDA15S0_RELA    	34
+#define R_NDS32_GOT20			37
+#define R_NDS32_25_PLTREL		38
+#define R_NDS32_COPY			39
+#define R_NDS32_GLOB_DAT		40
+#define R_NDS32_JMP_SLOT		41
+#define R_NDS32_RELATIVE		42
+#define R_NDS32_GOTOFF			43
+#define R_NDS32_GOTPC20			44
+#define R_NDS32_GOT_HI20		45
+#define R_NDS32_GOT_LO12		46
+#define R_NDS32_GOTPC_HI20		47
+#define R_NDS32_GOTPC_LO12		48
+#define R_NDS32_GOTOFF_HI20		49
+#define R_NDS32_GOTOFF_LO12		50
+#define R_NDS32_INSN16			51
+#define R_NDS32_LABEL			52
+#define R_NDS32_LONGCALL1		53
+#define R_NDS32_LONGCALL2		54
+#define R_NDS32_LONGCALL3		55
+#define R_NDS32_LONGJUMP1		56
+#define R_NDS32_LONGJUMP2		57
+#define R_NDS32_LONGJUMP3		58
+#define R_NDS32_LOADSTORE		59
+#define R_NDS32_9_FIXED_RELA		60
+#define R_NDS32_15_FIXED_RELA		61
+#define R_NDS32_17_FIXED_RELA		62
+#define R_NDS32_25_FIXED_RELA		63
+#define R_NDS32_PLTREL_HI20		64
+#define R_NDS32_PLTREL_LO12		65
+#define R_NDS32_PLT_GOTREL_HI20		66
+#define R_NDS32_PLT_GOTREL_LO12		67
+#define R_NDS32_LO12S0_ORI_RELA		72
+#define R_NDS32_DWARF2_OP1_RELA     	77
+#define R_NDS32_DWARF2_OP2_RELA     	78
+#define R_NDS32_DWARF2_LEB_RELA     	79
+#define R_NDS32_WORD_9_PCREL_RELA	94
+#define R_NDS32_LONGCALL4 		107
+#define R_NDS32_RELA_NOP_MIX		192
+#define R_NDS32_RELA_NOP_MAX		255
+
+#define ELF_NGREG (sizeof (struct user_pt_regs) / sizeof(elf_greg_t))
+#define ELF_CORE_COPY_REGS(dest, regs)	\
+	*(struct user_pt_regs *)&(dest) = (regs)->user_regs;
+
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+/* Core file format: The core file is written in such a way that gdb
+   can understand it and provide useful information to the user (under
+   linux we use the 'trad-core' bfd).  There are quite a number of
+   obstacles to being able to view the contents of the floating point
+   registers, and until these are solved you will not be able to view the
+   contents of them.  Actually, you can read in the core file and look at
+   the contents of the user struct to find out what the floating point
+   registers contain.
+   The actual file contents are as follows:
+   UPAGE: 1 page consisting of a user struct that tells gdb what is present
+   in the file.  Directly after this is a copy of the task_struct, which
+   is currently not used by gdb, but it may come in useful at some point.
+   All of the registers are stored as part of the upage.  The upage should
+   always be only one page.
+   DATA: The data area is stored.  We use current->end_text to
+   current->brk to pick up all of the user variables, plus any memory
+   that may have been malloced.  No attempt is made to determine if a page
+   is demand-zero or if a page is totally unused, we just cover the entire
+   range.  All of the addresses are rounded in such a way that an integral
+   number of pages is written.
+   STACK: We need the stack information in order to get a meaningful
+   backtrace.  We need to write the data from (esp) to
+   current->start_stack, so we round each of these off in order to be able
+   to write an integer number of pages.
+   The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+struct user_fp {
+        unsigned long long fd_regs[32];
+        unsigned long fpcsr;
+};
+
+typedef struct user_fp elf_fpregset_t;
+
+struct elf32_hdr;
+#define elf_check_arch(x)		((x)->e_machine == EM_NDS32)
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#define ELF_CLASS	ELFCLASS32
+#ifdef __NDS32_EB__
+#define ELF_DATA	ELFDATA2MSB;
+#else
+#define ELF_DATA	ELFDATA2LSB;
+#endif
+#define ELF_ARCH	EM_NDS32
+#define USE_ELF_CORE_DUMP
+#define ELF_EXEC_PAGESIZE	PAGE_SIZE
+
+/* 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	(2 * TASK_SIZE / 3)
+
+/* When the program starts, a1 contains a pointer to a function to be
+   registered with atexit, as per the SVR4 ABI.  A value of 0 means we
+   have no such handler.  */
+#define ELF_PLAT_INIT(_r, load_addr)	(_r)->uregs[0] = 0
+
+/* This yields a mask that user programs can use to figure out what
+   instruction set this cpu supports. */
+
+#define ELF_HWCAP	(elf_hwcap)
+
+#ifdef __KERNEL__
+
+#define ELF_PLATFORM    (NULL)
+
+/* Old NetWinder binaries were compiled in such a way that the iBCS
+   heuristic always trips on them.  Until these binaries become uncommon
+   enough not to care, don't trust the `ibcs' flag here.  In any case
+   there is no other ELF system currently supported by iBCS.
+   @@ Could print a warning message to encourage users to upgrade.  */
+#define SET_PERSONALITY(ex)	set_personality(PER_LINUX)
+
+#endif
+
+#define ARCH_DLINFO						\
+do {								\
+	NEW_AUX_ENT(AT_SYSINFO_EHDR,				\
+		    (elf_addr_t)current->mm->context.vdso);	\
+} while (0)
+#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
+struct linux_binprm;
+int arch_setup_additional_pages(struct linux_binprm *, int);
+
+#endif
arch/nds32/include/uapi/asm/auxvec.h new file +12 -0
new file mode 100644
index 0000000..56043ce
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_AUXVEC_H
+#define __ASM_AUXVEC_H
+
+/* VDSO location */
+#define AT_SYSINFO_EHDR	33
+
+#define AT_VECTOR_SIZE_ARCH 1
+
+#endif
arch/nds32/include/uapi/asm/param.h new file +11 -0
new file mode 100644
index 0000000..e3fb723
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_NDS32_PARAM_H
+#define __ASM_NDS32_PARAM_H
+
+#define EXEC_PAGESIZE	8192
+
+#include <asm-generic/param.h>
+
+#endif /* __ASM_NDS32_PARAM_H */
Signature · 1 line
1.7.9.5
#53 lore raw

PATCH v6 18/36 nds32: System calls handling

In reply to Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for system calls.

---
 arch/nds32/include/asm/syscall.h     |  188 ++++++++++++++++++++++++++++++++++
 arch/nds32/include/asm/syscalls.h    |   13 +++
 arch/nds32/include/asm/unistd.h      |    6 ++
 arch/nds32/include/uapi/asm/unistd.h |   11 ++
 arch/nds32/kernel/ex-scall.S         |  106 +++++++++++++++++++
 arch/nds32/kernel/sys_nds32.c        |   50 +++++++++
 arch/nds32/kernel/syscall_table.c    |   17 +++
 7 files changed, 391 insertions(+)
 create mode 100644 arch/nds32/include/asm/syscall.h
 create mode 100644 arch/nds32/include/asm/syscalls.h
 create mode 100644 arch/nds32/include/asm/unistd.h
 create mode 100644 arch/nds32/include/uapi/asm/unistd.h
 create mode 100644 arch/nds32/kernel/ex-scall.S
 create mode 100644 arch/nds32/kernel/sys_nds32.c
 create mode 100644 arch/nds32/kernel/syscall_table.c
arch/nds32/include/asm/syscall.h new file +188 -0
new file mode 100644
index 0000000..f7e5e86
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2008-2009 Red Hat, Inc.  All rights reserved.
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef _ASM_NDS32_SYSCALL_H
+#define _ASM_NDS32_SYSCALL_H	1
+
+#include <linux/err.h>
+struct task_struct;
+struct pt_regs;
+
+/**
+ * syscall_get_nr - find what system call a task is executing
+ * @task:	task of interest, must be blocked
+ * @regs:	task_pt_regs() of @task
+ *
+ * If @task is executing a system call or is at system call
+ * tracing about to attempt one, returns the system call number.
+ * If @task is not executing a system call, i.e. it's blocked
+ * inside the kernel for a fault or signal, returns -1.
+ *
+ * Note this returns int even on 64-bit machines.  Only 32 bits of
+ * system call number can be meaningful.  If the actual arch value
+ * is 64 bits, this truncates to 32 bits so 0xffffffff means -1.
+ *
+ * It's only valid to call this when @task is known to be blocked.
+ */
+int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
+{
+	return regs->syscallno;
+}
+
+/**
+ * syscall_rollback - roll back registers after an aborted system call
+ * @task:	task of interest, must be in system call exit tracing
+ * @regs:	task_pt_regs() of @task
+ *
+ * It's only valid to call this when @task is stopped for system
+ * call exit tracing (due to TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT),
+ * after tracehook_report_syscall_entry() returned nonzero to prevent
+ * the system call from taking place.
+ *
+ * This rolls back the register state in @regs so it's as if the
+ * system call instruction was a no-op.  The registers containing
+ * the system call number and arguments are as they were before the
+ * system call instruction.  This may not be the same as what the
+ * register state looked like at system call entry tracing.
+ */
+void syscall_rollback(struct task_struct *task, struct pt_regs *regs)
+{
+	regs->uregs[0] = regs->orig_r0;
+}
+
+/**
+ * syscall_get_error - check result of traced system call
+ * @task:	task of interest, must be blocked
+ * @regs:	task_pt_regs() of @task
+ *
+ * Returns 0 if the system call succeeded, or -ERRORCODE if it failed.
+ *
+ * It's only valid to call this when @task is stopped for tracing on exit
+ * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
+ */
+long syscall_get_error(struct task_struct *task, struct pt_regs *regs)
+{
+	unsigned long error = regs->uregs[0];
+	return IS_ERR_VALUE(error) ? error : 0;
+}
+
+/**
+ * syscall_get_return_value - get the return value of a traced system call
+ * @task:	task of interest, must be blocked
+ * @regs:	task_pt_regs() of @task
+ *
+ * Returns the return value of the successful system call.
+ * This value is meaningless if syscall_get_error() returned nonzero.
+ *
+ * It's only valid to call this when @task is stopped for tracing on exit
+ * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
+ */
+long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs)
+{
+	return regs->uregs[0];
+}
+
+/**
+ * syscall_set_return_value - change the return value of a traced system call
+ * @task:	task of interest, must be blocked
+ * @regs:	task_pt_regs() of @task
+ * @error:	negative error code, or zero to indicate success
+ * @val:	user return value if @error is zero
+ *
+ * This changes the results of the system call that user mode will see.
+ * If @error is zero, the user sees a successful system call with a
+ * return value of @val.  If @error is nonzero, it's a negated errno
+ * code; the user sees a failed system call with this errno code.
+ *
+ * It's only valid to call this when @task is stopped for tracing on exit
+ * from a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
+ */
+void syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
+			      int error, long val)
+{
+	regs->uregs[0] = (long)error ? error : val;
+}
+
+/**
+ * syscall_get_arguments - extract system call parameter values
+ * @task:	task of interest, must be blocked
+ * @regs:	task_pt_regs() of @task
+ * @i:		argument index [0,5]
+ * @n:		number of arguments; n+i must be [1,6].
+ * @args:	array filled with argument values
+ *
+ * Fetches @n arguments to the system call starting with the @i'th argument
+ * (from 0 through 5).  Argument @i is stored in @args[0], and so on.
+ * An arch inline version is probably optimal when @i and @n are constants.
+ *
+ * It's only valid to call this when @task is stopped for tracing on
+ * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
+ * It's invalid to call this with @i + @n > 6; we only support system calls
+ * taking up to 6 arguments.
+ */
+#define SYSCALL_MAX_ARGS 6
+void syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
+			   unsigned int i, unsigned int n, unsigned long *args)
+{
+	if (n == 0)
+		return;
+	if (i + n > SYSCALL_MAX_ARGS) {
+		unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
+		unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
+		pr_warning("%s called with max args %d, handling only %d\n",
+			   __func__, i + n, SYSCALL_MAX_ARGS);
+		memset(args_bad, 0, n_bad * sizeof(args[0]));
+		memset(args_bad, 0, n_bad * sizeof(args[0]));
+	}
+
+	if (i == 0) {
+		args[0] = regs->orig_r0;
+		args++;
+		i++;
+		n--;
+	}
+
+	memcpy(args, &regs->uregs[0] + i, n * sizeof(args[0]));
+}
+
+/**
+ * syscall_set_arguments - change system call parameter value
+ * @task:	task of interest, must be in system call entry tracing
+ * @regs:	task_pt_regs() of @task
+ * @i:		argument index [0,5]
+ * @n:		number of arguments; n+i must be [1,6].
+ * @args:	array of argument values to store
+ *
+ * Changes @n arguments to the system call starting with the @i'th argument.
+ * Argument @i gets value @args[0], and so on.
+ * An arch inline version is probably optimal when @i and @n are constants.
+ *
+ * It's only valid to call this when @task is stopped for tracing on
+ * entry to a system call, due to %TIF_SYSCALL_TRACE or %TIF_SYSCALL_AUDIT.
+ * It's invalid to call this with @i + @n > 6; we only support system calls
+ * taking up to 6 arguments.
+ */
+void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
+			   unsigned int i, unsigned int n,
+			   const unsigned long *args)
+{
+	if (n == 0)
+		return;
+
+	if (i + n > SYSCALL_MAX_ARGS) {
+		pr_warn("%s called with max args %d, handling only %d\n",
+			__func__, i + n, SYSCALL_MAX_ARGS);
+		n = SYSCALL_MAX_ARGS - i;
+	}
+
+	if (i == 0) {
+		regs->orig_r0 = args[0];
+		args++;
+		i++;
+		n--;
+	}
+
+	memcpy(&regs->uregs[0] + i, args, n * sizeof(args[0]));
+}
+#endif /* _ASM_NDS32_SYSCALL_H */
arch/nds32/include/asm/syscalls.h new file +13 -0
new file mode 100644
index 0000000..78778ec
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_NDS32_SYSCALLS_H
+#define __ASM_NDS32_SYSCALLS_H
+
+asmlinkage long sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op);
+asmlinkage long sys_fadvise64_64_wrapper(int fd, int advice, loff_t offset, loff_t len);
+asmlinkage long sys_rt_sigreturn_wrapper(void);
+
+#include <asm-generic/syscalls.h>
+
+#endif /* __ASM_NDS32_SYSCALLS_H */
arch/nds32/include/asm/unistd.h new file +6 -0
new file mode 100644
index 0000000..b586a28
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#define __ARCH_WANT_SYS_CLONE
+
+#include <uapi/asm/unistd.h>
arch/nds32/include/uapi/asm/unistd.h new file +11 -0
new file mode 100644
index 0000000..6e95901
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#define __ARCH_WANT_SYNC_FILE_RANGE2
+
+/* Use the standard ABI for syscalls */
+#include <asm-generic/unistd.h>
+
+/* Additional NDS32 specific syscalls. */
+#define __NR_cacheflush		(__NR_arch_specific_syscall)
+__SYSCALL(__NR_cacheflush, sys_cacheflush)
arch/nds32/kernel/ex-scall.S new file +106 -0

106 lines not on this page · raw message

arch/nds32/kernel/sys_nds32.c new file +50 -0

50 lines not on this page · raw message

arch/nds32/kernel/syscall_table.c new file +17 -0
new file mode 100644
index 0000000..7879c06
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/syscalls.h>
+#include <linux/signal.h>
+#include <linux/unistd.h>
+#include <asm/syscalls.h>
+
+#undef __SYSCALL
+#define __SYSCALL(nr, call) [nr] = (call),
+
+#define sys_rt_sigreturn sys_rt_sigreturn_wrapper
+#define sys_fadvise64_64 sys_fadvise64_64_wrapper
+void *sys_call_table[__NR_syscalls] __aligned(8192) = {
+	[0 ... __NR_syscalls - 1] = sys_ni_syscall,
+#include <asm/unistd.h>
+};
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer Reviewed-by on v6 18/36
#54 lore raw

Re: [PATCH v6 18/36] nds32: System calls handling

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for system calls.

You seem to have finally addressed all my previous concerns, looks good.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#55 lore raw

PATCH v6 19/36 nds32: VDSO support

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds VDSO support. The VDSO code is currently used for sys_rt_sigreturn() and optimised gettimeofday() (using the SoC timer counter).

---
 arch/nds32/include/asm/vdso.h              |   24 +++
 arch/nds32/include/asm/vdso_datapage.h     |   36 ++++
 arch/nds32/include/asm/vdso_timer_info.h   |   14 ++
 arch/nds32/kernel/vdso.c                   |  230 ++++++++++++++++++++++++
 arch/nds32/kernel/vdso/Makefile            |   82 +++++++++
 arch/nds32/kernel/vdso/datapage.S          |   21 +++
 arch/nds32/kernel/vdso/gen_vdso_offsets.sh |   15 ++
 arch/nds32/kernel/vdso/gettimeofday.c      |  270 ++++++++++++++++++++++++++++
 arch/nds32/kernel/vdso/note.S              |   11 ++
 arch/nds32/kernel/vdso/sigreturn.S         |   19 ++
 arch/nds32/kernel/vdso/vdso.S              |   18 ++
 arch/nds32/kernel/vdso/vdso.lds.S          |   76 ++++++++
 12 files changed, 816 insertions(+)
 create mode 100644 arch/nds32/include/asm/vdso.h
 create mode 100644 arch/nds32/include/asm/vdso_datapage.h
 create mode 100644 arch/nds32/include/asm/vdso_timer_info.h
 create mode 100644 arch/nds32/kernel/vdso.c
 create mode 100644 arch/nds32/kernel/vdso/Makefile
 create mode 100644 arch/nds32/kernel/vdso/datapage.S
 create mode 100755 arch/nds32/kernel/vdso/gen_vdso_offsets.sh
 create mode 100644 arch/nds32/kernel/vdso/gettimeofday.c
 create mode 100644 arch/nds32/kernel/vdso/note.S
 create mode 100644 arch/nds32/kernel/vdso/sigreturn.S
 create mode 100644 arch/nds32/kernel/vdso/vdso.S
 create mode 100644 arch/nds32/kernel/vdso/vdso.lds.S
arch/nds32/include/asm/vdso.h new file +24 -0
new file mode 100644
index 0000000..af2c6af
@@ -0,0 +1,24 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ * Copyright (C) 2005-2017 Andes Technology Corporation
+ */
+
+#ifndef __ASM_VDSO_H
+#define __ASM_VDSO_H
+
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+#include <generated/vdso-offsets.h>
+
+#define VDSO_SYMBOL(base, name)						   \
+({									   \
+	(unsigned long)(vdso_offset_##name + (unsigned long)(base)); \
+})
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASM_VDSO_H */
arch/nds32/include/asm/vdso_datapage.h new file +36 -0
new file mode 100644
index 0000000..79db5a1
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2012 ARM Limited
+// Copyright (C) 2005-2017 Andes Technology Corporation
+#ifndef __ASM_VDSO_DATAPAGE_H
+#define __ASM_VDSO_DATAPAGE_H
+
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+struct vdso_data {
+	bool cycle_count_down;	/* timer cyclye counter is decrease with time */
+	u32 cycle_count_offset;	/* offset of timer cycle counter register */
+	u32 seq_count;		/* sequence count - odd during updates */
+	u32 xtime_coarse_sec;	/* coarse time */
+	u32 xtime_coarse_nsec;
+
+	u32 wtm_clock_sec;	/* wall to monotonic offset */
+	u32 wtm_clock_nsec;
+	u32 xtime_clock_sec;	/* CLOCK_REALTIME - seconds */
+	u32 cs_mult;		/* clocksource multiplier */
+	u32 cs_shift;		/* Cycle to nanosecond divisor (power of two) */
+
+	u64 cs_cycle_last;	/* last cycle value */
+	u64 cs_mask;		/* clocksource mask */
+
+	u64 xtime_clock_nsec;	/* CLOCK_REALTIME sub-ns base */
+	u32 tz_minuteswest;	/* timezone info for gettimeofday(2) */
+	u32 tz_dsttime;
+};
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+#endif /* __ASM_VDSO_DATAPAGE_H */
arch/nds32/include/asm/vdso_timer_info.h new file +14 -0
new file mode 100644
index 0000000..50ba117
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+extern struct timer_info_t timer_info;
+#define EMPTY_VALUE ~(0UL)
+#define EMPTY_TIMER_MAPPING EMPTY_VALUE
+#define EMPTY_REG_OFFSET EMPTY_VALUE
+
+struct timer_info_t
+{
+	bool cycle_count_down;
+	unsigned long mapping_base;
+	unsigned long cycle_count_reg_offset;
+};
arch/nds32/kernel/vdso.c new file +230 -0

230 lines not on this page · raw message

arch/nds32/kernel/vdso/Makefile new file +82 -0

82 lines not on this page · raw message

arch/nds32/kernel/vdso/datapage.S new file +21 -0
new file mode 100644
index 0000000..4a62c3c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+#include <asm/page.h>
+
+ENTRY(__get_timerpage)
+	sethi	$r0, hi20(. + PAGE_SIZE + 8)
+	ori	$r0, $r0, lo12(. + PAGE_SIZE + 4)
+	mfusr	$r1, $pc
+	sub	$r0, $r1, $r0
+	ret
+ENDPROC(__get_timerpage)
+
+ENTRY(__get_datapage)
+	sethi	$r0, hi20(. + 2*PAGE_SIZE + 8)
+	ori	$r0, $r0, lo12(. + 2*PAGE_SIZE + 4)
+	mfusr	$r1, $pc
+	sub	$r0, $r1, $r0
+	ret
+ENDPROC(__get_datapage)
arch/nds32/kernel/vdso/gen_vdso_offsets.sh new file +15 -0
new file mode 100755
index 0000000..01924ff
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#
+# Match symbols in the DSO that look like VDSO_*; produce a header file
+# of constant offsets into the shared object.
+#
+# Doing this inside the Makefile will break the $(filter-out) function,
+# causing Kbuild to rebuild the vdso-offsets header file every time.
+#
+# Author: Will Deacon <[email protected]
+#
+
+LC_ALL=C
+sed -n -e 's/^00*/0/' -e \
+'s/^\([0-9a-fA-F]*\) . VDSO_\([a-zA-Z0-9_]*\)$/\#define vdso_offset_\2\t0x\1/p'
arch/nds32/kernel/vdso/gettimeofday.c new file +270 -0

270 lines not on this page · raw message

arch/nds32/kernel/vdso/note.S new file +11 -0
new file mode 100644
index 0000000..0aeaa19
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2012 ARM Limited
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/uts.h>
+#include <linux/version.h>
+#include <linux/elfnote.h>
+
+ELFNOTE_START(Linux, 0, "a")
+	.long LINUX_VERSION_CODE
+ELFNOTE_END
arch/nds32/kernel/vdso/sigreturn.S new file +19 -0
new file mode 100644
index 0000000..67e4d1d
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2012 ARM Limited
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+#include <asm/unistd.h>
+
+	.text
+
+ENTRY(__kernel_rt_sigreturn)
+	.cfi_startproc
+	movi $r15, __NR_rt_sigreturn
+	/*
+	 * The SWID of syscall should be __NR_rt_sigreturn to synchronize
+	 * the unwinding scheme in gcc
+	 */
+	syscall	__NR_rt_sigreturn
+	.cfi_endproc
+ENDPROC(__kernel_rt_sigreturn)
arch/nds32/kernel/vdso/vdso.S new file +18 -0
new file mode 100644
index 0000000..16737c1
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2012 ARM Limited
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/const.h>
+#include <asm/page.h>
+
+	.globl vdso_start, vdso_end
+	.section .rodata
+	.balign PAGE_SIZE
+vdso_start:
+	.incbin "arch/nds32/kernel/vdso/vdso.so"
+	.balign PAGE_SIZE
+vdso_end:
+
+	.previous
arch/nds32/kernel/vdso/vdso.lds.S new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 19/36
#56 lore raw

Re: [PATCH v6 19/36] nds32: VDSO support

Quoted 7 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds VDSO support. The VDSO code is currently used for sys_rt_sigreturn() and optimised gettimeofday() (using the SoC timer counter).

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#57 lore raw

Re: [PATCH v6 19/36] nds32: VDSO support

2018-01-18 18:28 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 10 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <[email protected]>

This patch adds VDSO support. The VDSO code is currently used for sys_rt_sigreturn() and optimised gettimeofday() (using the SoC timer counter).

Dear Arnd Bergmann:

We find a small bug here which make LTP 20170929 clock_getres01 fail. The bug is in __vdso_clock_getres() function. When argument res is NULL, -EFAULT error code is returned now. But, the returned value is 0 for SyS_clock_getres under the same conditions. Therefore, testcase thinks it is a bug.

I will modify the code as below and add it in the next version patch if you think it is OK.

@@ -209,7 +209,7 @@ static notrace int clock_getres_fallback( ...

 {
         if (res == NULL)

- return -EFAULT;
+ return 0;

Thanks

Vincnet

maintainer
#58 lore raw

Re: [PATCH v6 19/36] nds32: VDSO support

Quoted 24 lines · Vincent Chen

2018-01-18 18:28 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 10 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <[email protected]>

This patch adds VDSO support. The VDSO code is currently used for sys_rt_sigreturn() and optimised gettimeofday() (using the SoC timer counter).

Dear Arnd Bergmann:

We find a small bug here which make LTP 20170929 clock_getres01 fail. The bug is in __vdso_clock_getres() function. When argument res is NULL, -EFAULT error code is returned now. But, the returned value is 0 for SyS_clock_getres under the same conditions. Therefore, testcase thinks it is a bug.

I will modify the code as below and add it in the next version patch if you think it is OK.

Review static notrace int clock_getres_fallback( ... · line 212

Quoted 5 lines
(quoted diff) +1 -1
@@ -209,7 +209,7 @@ static notrace int clock_getres_fallback( ...
 {
         if (res == NULL)
-                return -EFAULT;
+                return 0;
 

Ok. I don't know why that is the expected behavior (clock_getres with a NULL argument makes little sense), but I can see that it matches the regular syscall implementation.

Arnd

#59 lore raw

PATCH v6 20/36 nds32: Signal handling support

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for signal handling.

---
 arch/nds32/include/uapi/asm/sigcontext.h |   60 ++++++
 arch/nds32/kernel/signal.c               |  337 ++++++++++++++++++++++++++++++
 2 files changed, 397 insertions(+)
 create mode 100644 arch/nds32/include/uapi/asm/sigcontext.h
 create mode 100644 arch/nds32/kernel/signal.c
arch/nds32/include/uapi/asm/sigcontext.h new file +60 -0
new file mode 100644
index 0000000..00567b2
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef _ASMNDS32_SIGCONTEXT_H
+#define _ASMNDS32_SIGCONTEXT_H
+
+/*
+ * Signal context structure - contains all info to do with the state
+ * before the signal handler was invoked.  Note: only add new entries
+ * to the end of the structure.
+ */
+
+struct zol_struct {
+	unsigned long nds32_lc;	/* $LC */
+	unsigned long nds32_le;	/* $LE */
+	unsigned long nds32_lb;	/* $LB */
+};
+
+struct sigcontext {
+	unsigned long trap_no;
+	unsigned long error_code;
+	unsigned long oldmask;
+	unsigned long nds32_r0;
+	unsigned long nds32_r1;
+	unsigned long nds32_r2;
+	unsigned long nds32_r3;
+	unsigned long nds32_r4;
+	unsigned long nds32_r5;
+	unsigned long nds32_r6;
+	unsigned long nds32_r7;
+	unsigned long nds32_r8;
+	unsigned long nds32_r9;
+	unsigned long nds32_r10;
+	unsigned long nds32_r11;
+	unsigned long nds32_r12;
+	unsigned long nds32_r13;
+	unsigned long nds32_r14;
+	unsigned long nds32_r15;
+	unsigned long nds32_r16;
+	unsigned long nds32_r17;
+	unsigned long nds32_r18;
+	unsigned long nds32_r19;
+	unsigned long nds32_r20;
+	unsigned long nds32_r21;
+	unsigned long nds32_r22;
+	unsigned long nds32_r23;
+	unsigned long nds32_r24;
+	unsigned long nds32_r25;
+	unsigned long nds32_fp;	/* $r28 */
+	unsigned long nds32_gp;	/* $r29 */
+	unsigned long nds32_lp;	/* $r30 */
+	unsigned long nds32_sp;	/* $r31 */
+	unsigned long nds32_ipc;
+	unsigned long fault_address;
+	unsigned long used_math_flag;
+	/* FPU Registers */
+	struct zol_struct zol;
+};
+
+#endif
arch/nds32/kernel/signal.c new file +337 -0

337 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#60 lore raw

Re: [PATCH v6 20/36] nds32: Signal handling support

Quoted 6 lines · Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for signal handling.

I never feel qualified enough to properly review signal handling code, so no Ack from me for this code even though I don't see anything wrong with it. Hopefully someone else can give an Ack after looking more closely.

Arnd

#61 lore raw

Re: [PATCH v6 20/36] nds32: Signal handling support

2018-01-18 18:30 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 5 lines · Greentime Hu
Quoted 4 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for signal handling.

Quoted 8 lines
Quoted 2 lines

I never feel qualified enough to properly review signal handling code, so no Ack from me for this code even though I don't see anything wrong with it. Hopefully someone else can give an Ack after looking more closely.

Arnd

Dear Arnd:

We'd be glad to improve signal handling code to meet your requirement. Could you
tell us which part we need to refine or which implementation is good for us to refer?

Thanks.

Vincent
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#62 lore raw

Re: [PATCH v6 20/36] nds32: Signal handling support

Quoted 14 lines · Vincent Chen

2018-01-18 18:30 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 12 lines · Greentime Hu
Quoted 6 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for signal handling.

I never feel qualified enough to properly review signal handling code, so no Ack from me for this code even though I don't see anything wrong with it. Hopefully someone else can give an Ack after looking more closely.

Quoted 6 lines

Dear Arnd:

We'd be glad to improve signal handling code to meet your requirement. Could you
tell us which part we need to refine or which implementation is good for us to refer?

No, as I said, the problem is on my side, I just don't understand enough of it. I would assume that the arm64 and risc-v implementations are the most thoroughly reviewed, but haven't looked at those in enough detail either. If your code does something that risc-v doesn't do, try to understand whether there should be a difference or not.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#63 lore raw

Re: [PATCH v6 20/36] nds32: Signal handling support

Thanks, I got it.

After referring to arm64 and risc-v, we try to refine our code, such as removing unneeded checking and refining syscall restart flow. We hope these modifications can enhance the reliability and readability. However, the following 2 files which you had acked are included in this modification.
1. arch/nds32/include/asm/nds32.h
(patch: Assembly macros and definitions)
The definition of macro tbl and why are removed.
- Now, we use pt_reg->syscallno instead of 'why' to determine whether entering kernel is via syscall or not. Therefore, macro 'why' is unneeded.

arch/nds32/include/asm/nds32.h +0 -4
@@ -66,10 +66,6 @@ static inline unsigned long CACHE_LINE_SIZE
 
 #endif /* __ASSEMBLY__ */
 
-/* tbl and why is used in ex-scall.S and ex-exit.S */
-#define tbl $r8
-#define why $r8
-
 #define IVB_BASE               PHYS_OFFSET
 
 

2. arch/nds32/kernel/ex-scall.S (patch: System calls handling)
a. Define macro tbl
- The marco tbl is used only in this file. So, I move its definition from arch/nds32/include/asm/nds32.h to here.
b. Remove 'set why = 0' when issuing syscall number is invalid c. Adjust input arguments of syscall_trace_enter

--- a/arch/nds32/kernel/ex-scall.S
+++ b/arch/nds32/kernel/ex-scall.S
...
+#define tbl $r8

/*
* $r7 will be writen as syscall nr
- * by retrieving from $ITYPE 'SWID' bitfiled
*/

        .macro  get_scno
        lwi     $r7, [$sp + R15_OFFSET]

@@ -54,7 +49,6 @@ ENTRY(eh_syscall)
get_scno
gie_enable

-ENTRY(eh_syscall_phase_2)

        lwi     $p0, [tsk+#TSK_TI_FLAGS]

        andi    $p1, $p0, #_TIF_WORK_SYSCALL_ENTRY

@@ -71,7 +65,6 @@ jmp_systbl:
jr $p1 ! no return

_SCNO_EXCEED:
- movi why, 0

        ori     $r0, $r7, #0
        ori    $r1, $sp, #0
        b       bad_syscall

@@ -81,8 +74,7 @@ _SCNO_EXCEED:
* context switches, and waiting for our parent to respond. */
__sys_trace:

-       move    $r1, $sp
-       move    $r0, $r7                        ! trace entry [IP = 0]
+       move    $r0, $sp
        bal     syscall_trace_enter
        move    $r7, $r0
        la      $lp, __sys_trace_return         ! return address

If you think these modifications in acked files are not permitted, we will recover it.

We verify all modifications by LTP 2017 related cases and glibc 2.26 testsuite. We plan to add it in the next version patch and hope you can give us some comments as before.

Thanks

Vincent

2018-01-24 19:13 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 29 lines · Vincent Chen
Quoted 14 lines

2018-01-18 18:30 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 12 lines · Greentime Hu
Quoted 6 lines

From: Greentime Hu <[email protected]>

This patch adds support for signal handling.

I never feel qualified enough to properly review signal handling code, so no Ack from me for this code even though I don't see anything wrong with it. Hopefully someone else can give an Ack after looking more closely.

Quoted 6 lines

Dear Arnd:

We'd be glad to improve signal handling code to meet your requirement. Could you
tell us which part we need to refine or which implementation is good for us to refer?

No, as I said, the problem is on my side, I just don't understand enough of it. I would assume that the arm64 and risc-v implementations are the most thoroughly reviewed, but haven't looked at those in enough detail either. If your code does something that risc-v doesn't do, try to understand whether there should be a difference or not.

Arnd

#64 lore raw

PATCH v6 21/36 nds32: Library functions

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch add support for various library functions.

---
 arch/nds32/include/asm/string.h  |   17 +++
 arch/nds32/include/asm/swab.h    |   35 +++++
 arch/nds32/include/asm/uaccess.h |  283 ++++++++++++++++++++++++++++++++++++++
 arch/nds32/kernel/nds32_ksyms.c  |   31 +++++
 arch/nds32/lib/Makefile          |    3 +
 arch/nds32/lib/clear_user.S      |   42 ++++++
 arch/nds32/lib/copy_from_user.S  |   45 ++++++
 arch/nds32/lib/copy_template.S   |   70 ++++++++++
 arch/nds32/lib/copy_to_user.S    |   45 ++++++
 arch/nds32/lib/memcpy.S          |   30 ++++
 arch/nds32/lib/memmove.S         |   70 ++++++++++
 arch/nds32/lib/memset.S          |   33 +++++
 arch/nds32/lib/memzero.S         |   18 +++
 13 files changed, 722 insertions(+)
 create mode 100644 arch/nds32/include/asm/string.h
 create mode 100644 arch/nds32/include/asm/swab.h
 create mode 100644 arch/nds32/include/asm/uaccess.h
 create mode 100644 arch/nds32/kernel/nds32_ksyms.c
 create mode 100644 arch/nds32/lib/Makefile
 create mode 100644 arch/nds32/lib/clear_user.S
 create mode 100644 arch/nds32/lib/copy_from_user.S
 create mode 100644 arch/nds32/lib/copy_template.S
 create mode 100644 arch/nds32/lib/copy_to_user.S
 create mode 100644 arch/nds32/lib/memcpy.S
 create mode 100644 arch/nds32/lib/memmove.S
 create mode 100644 arch/nds32/lib/memset.S
 create mode 100644 arch/nds32/lib/memzero.S
arch/nds32/include/asm/string.h new file +17 -0
new file mode 100644
index 0000000..179272c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_NDS32_STRING_H
+#define __ASM_NDS32_STRING_H
+
+#define __HAVE_ARCH_MEMCPY
+extern void *memcpy(void *, const void *, __kernel_size_t);
+
+#define __HAVE_ARCH_MEMMOVE
+extern void *memmove(void *, const void *, __kernel_size_t);
+
+#define __HAVE_ARCH_MEMSET
+extern void *memset(void *, int, __kernel_size_t);
+
+extern void *memzero(void *ptr, __kernel_size_t n);
+#endif
arch/nds32/include/asm/swab.h new file +35 -0
new file mode 100644
index 0000000..e01a755
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_SWAB_H__
+#define __NDS32_SWAB_H__
+
+#include <linux/types.h>
+#include <linux/compiler.h>
+
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
+{
+	__asm__("wsbh   %0, %0\n\t"	/* word swap byte within halfword */
+		"rotri  %0, %0, #16\n"
+		:"=r"(x)
+		:"0"(x));
+	return x;
+}
+
+static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
+{
+	__asm__("wsbh   %0, %0\n"	/* word swap byte within halfword */
+		:"=r"(x)
+		:"0"(x));
+	return x;
+}
+
+#define __arch_swab32(x) ___arch__swab32(x)
+#define __arch_swab16(x) ___arch__swab16(x)
+
+#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
+#define __BYTEORDER_HAS_U64__
+#define __SWAB_64_THRU_32__
+#endif
+
+#endif /* __NDS32_SWAB_H__ */
arch/nds32/include/asm/uaccess.h new file +283 -0

283 lines not on this page · raw message

arch/nds32/kernel/nds32_ksyms.c new file +31 -0
new file mode 100644
index 0000000..5ecebd0
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/in6.h>
+#include <linux/syscalls.h>
+#include <linux/uaccess.h>
+
+#include <asm/checksum.h>
+#include <asm/io.h>
+#include <asm/ftrace.h>
+#include <asm/proc-fns.h>
+
+/* mem functions */
+EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memmove);
+EXPORT_SYMBOL(memzero);
+
+/* user mem (segment) */
+EXPORT_SYMBOL(__arch_copy_from_user);
+EXPORT_SYMBOL(__arch_copy_to_user);
+EXPORT_SYMBOL(__arch_clear_user);
+
+/* cache handling */
+EXPORT_SYMBOL(cpu_icache_inval_all);
+EXPORT_SYMBOL(cpu_dcache_wbinval_all);
+EXPORT_SYMBOL(cpu_dma_inval_range);
+EXPORT_SYMBOL(cpu_dma_wb_range);
arch/nds32/lib/Makefile new file +3 -0
new file mode 100644
index 0000000..0f98401
@@ -0,0 +1,3 @@
+lib-y		:= copy_page.o memcpy.o memmove.o   \
+		   memset.o memzero.o \
+		   copy_from_user.o copy_to_user.o clear_user.o
arch/nds32/lib/clear_user.S new file +42 -0

42 lines not on this page · raw message

arch/nds32/lib/copy_from_user.S new file +45 -0

45 lines not on this page · raw message

arch/nds32/lib/copy_template.S new file +70 -0

70 lines not on this page · raw message

arch/nds32/lib/copy_to_user.S new file +45 -0

45 lines not on this page · raw message

arch/nds32/lib/memcpy.S new file +30 -0
new file mode 100644
index 0000000..a2345ea
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+
+
+.macro 	lbi1 dst, addr, adj
+lbi.bi	\dst, [\addr], \adj
+.endm
+
+.macro 	sbi1 src, addr, adj
+sbi.bi	\src, [\addr], \adj
+.endm
+
+.macro	lmw1 start_reg, addr, end_reg
+lmw.bim \start_reg, [\addr], \end_reg
+.endm
+
+.macro	smw1 start_reg, addr, end_reg
+smw.bim \start_reg, [\addr], \end_reg
+.endm
+
+.text
+ENTRY(memcpy)
+	move	$r5, $r0
+#include "copy_template.S"
+	move	$r0, $r5
+	ret
+
+ENDPROC(memcpy)
arch/nds32/lib/memmove.S new file +70 -0

70 lines not on this page · raw message

arch/nds32/lib/memset.S new file +33 -0
new file mode 100644
index 0000000..193cb6c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+
+	.text
+ENTRY(memset)
+	move	$r5, $r0		! Return value
+	beqz	$r2, end_memset		! Exit when len = 0
+	srli	$p1, $r2, 2		! $p1 is how many words to copy
+	andi	$r2, $r2, 3		! How many bytes are less than a word
+	beqz	$p1, byte_set		! When n is less than a word
+
+	! set $r1 from ??????ab to abababab
+	andi	$r1, $r1, #0x00ff	! $r1 = 000000ab
+	slli	$p0, $r1, #8		! $p0 = 0000ab00
+	or	$r1, $r1, $p0		! $r1 = 0000abab
+	slli	$p0, $r1, #16		! $p0 = abab0000
+	or	$r1, $r1, $p0		! $r1 = abababab
+word_set:
+	addi	$p1, $p1, #-1		! How many words left to copy
+	smw.bim	$r1, [$r0], $r1		! Copy the word to det
+	bnez	$p1, word_set		! Still words to set, continue looping
+	beqz	$r2, end_memset		! No left byte to set
+byte_set:				! Less than 4 bytes left to set
+	addi	$r2, $r2, #-1		! Decrease len by 1
+	sbi.bi	$r1, [$r0], #1		! Set data of the next byte to $r1
+	bnez	$r2, byte_set		! Still bytes left to set
+end_memset:
+	move	$r0, $r5
+	ret
+
+ENDPROC(memset)
arch/nds32/lib/memzero.S new file +18 -0
new file mode 100644
index 0000000..f055972
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/linkage.h>
+
+	.text
+ENTRY(memzero)
+	beqz	$r1, 1f
+	push	$lp
+	move    $r2, $r1
+	move    $r1, #0
+	push	$r0
+	bal     memset
+	pop	$r0
+	pop	$lp
+1:
+        ret
+ENDPROC(memzero)
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 21/36
#65 lore raw

Re: [PATCH v6 21/36] nds32: Library functions

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch add support for various library functions.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#66 lore raw

PATCH v6 22/36 nds32: Debugging support

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds ptrace support.

---
 arch/nds32/include/uapi/asm/ptrace.h |   25 +++
 arch/nds32/kernel/ptrace.c           |  311 ++++++++++++++++++++++++++++++++++
 2 files changed, 336 insertions(+)
 create mode 100644 arch/nds32/include/uapi/asm/ptrace.h
 create mode 100644 arch/nds32/kernel/ptrace.c
arch/nds32/include/uapi/asm/ptrace.h new file +25 -0
new file mode 100644
index 0000000..358c99e
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __UAPI_ASM_NDS32_PTRACE_H
+#define __UAPI_ASM_NDS32_PTRACE_H
+
+#ifndef __ASSEMBLY__
+
+/*
+ * User structures for general purpose register.
+ */
+struct user_pt_regs {
+	long uregs[26];
+	long fp;
+	long gp;
+	long lp;
+	long sp;
+	long ipc;
+	long lb;
+	long le;
+	long lc;
+	long syscallno;
+};
+#endif
+#endif
arch/nds32/kernel/ptrace.c new file +311 -0

311 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#67 lore raw

Re: [PATCH v6 22/36] nds32: Debugging support

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds ptrace support.

I must have missed this patch earlier, unfortunately I don't think this is ready:

Quoted 28 lines
arch/nds32/kernel/ptrace.c new file +28 -0
+long arch_ptrace(struct task_struct *child, long request, unsigned long addr,
+                unsigned long data)
+{
+       int ret;
+
+       switch (request) {
+       case PTRACE_PEEKUSR:
+               ret =
+                   ptrace_read_user(child, addr, (unsigned long __user *)data);
+               break;
+
+       case PTRACE_POKEUSR:
+               ret = ptrace_write_user(child, addr, data);
+               break;
+
+       case PTRACE_GETREGS:
+               ret = ptrace_getregs(child, (void __user *)data);
+               break;
+
+       case PTRACE_SETREGS:
+               ret = ptrace_setregs(child, (void __user *)data);
+               break;
+
+       case PTRACE_GETFPREGS:
+               ret = ptrace_getfpregs(child, (void __user *)data);
+               break;
+
+       case PTRACE_SETFPREGS:

arch/nds32/kernel/ptrace.c line 273

Quoted 10 lines
arch/nds32/kernel/ptrace.c new file +10 -0
+               ret = ptrace_setfpregs(child, (void __user *)data);
+               break;
+
+       default:
+               ret = ptrace_request(child, request, addr, data);
+               break;
+       }
+
+       return ret;
+}

It appears that you are implementing the old-style ptrace handling with architecture specific commands. Please have a look at how this is done in risc-v or arm64. If this takes more too much time to address, I'd suggest using an empty stub function for sys_ptrace and adding it back at a later point, but not send the current version upstream.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#68 lore raw

Re: [PATCH v6 22/36] nds32: Debugging support

2018-01-18 18:37 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 57 lines · Greentime Hu
Quoted 6 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds ptrace support.

I must have missed this patch earlier, unfortunately I don't think this is ready:

Quoted 28 lines
arch/nds32/kernel/ptrace.c new file +28 -0
+long arch_ptrace(struct task_struct *child, long request, unsigned long addr,
+                unsigned long data)
+{
+       int ret;
+
+       switch (request) {
+       case PTRACE_PEEKUSR:
+               ret =
+                   ptrace_read_user(child, addr, (unsigned long __user *)data);
+               break;
+
+       case PTRACE_POKEUSR:
+               ret = ptrace_write_user(child, addr, data);
+               break;
+
+       case PTRACE_GETREGS:
+               ret = ptrace_getregs(child, (void __user *)data);
+               break;
+
+       case PTRACE_SETREGS:
+               ret = ptrace_setregs(child, (void __user *)data);
+               break;
+
+       case PTRACE_GETFPREGS:
+               ret = ptrace_getfpregs(child, (void __user *)data);
+               break;
+
+       case PTRACE_SETFPREGS:

arch/nds32/kernel/ptrace.c line 273

Quoted 10 lines
arch/nds32/kernel/ptrace.c new file +10 -0
+               ret = ptrace_setfpregs(child, (void __user *)data);
+               break;
+
+       default:
+               ret = ptrace_request(child, request, addr, data);
+               break;
+       }
+
+       return ret;
+}

It appears that you are implementing the old-style ptrace handling with architecture specific commands. Please have a look at how this is done in risc-v or arm64. If this takes more too much time to address, I'd suggest using an empty stub function for sys_ptrace and adding it back at a later point, but not send the current version upstream.

Quoted 1 line

Arnd

Dear Arnd:

Thanks for your comments.

After referring to risc-v and arm64, I realize that PTRACE_GETREGSET and PTRACE_SETREGSET is used to replace arch specific command. The needed port for the two ptrace commands had done in current version patch.

Could I keep them and just removing the code for old-style ptrace handling in the next version patch?

Thanks

Vincent
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#69 lore raw

Re: [PATCH v6 22/36] nds32: Debugging support

Quoted 13 lines · Vincent Chen

2018-01-18 18:37 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 11 lines · Greentime Hu
Quoted 1 line

From: Greentime Hu <[email protected]>

It appears that you are implementing the old-style ptrace handling with architecture specific commands. Please have a look at how this is done in risc-v or arm64. If this takes more too much time to address, I'd suggest using an empty stub function for sys_ptrace and adding it back at a later point, but not send the current version upstream.

Quoted 7 lines

After referring to risc-v and arm64, I realize that PTRACE_GETREGSET and PTRACE_SETREGSET is used to replace arch specific command. The needed port for the two ptrace commands had done in current version patch.

Could I keep them and just removing the code for old-style ptrace handling in the next version patch?

The important part is to not merge a user space interface into the upstream kernel that we still want to change. It's clear that it takes some time to update gdb and other programs using the ptrace interface, so I'd suggest to simply not have any ptrace interface submitted for inclusion until that is complete.

In the meantime, you can keep the existing version as an add-on kernel patch, you probably have other patches that are not ready to get merged yet, so just keep this one in the same tree as the others.

Arnd

#70 lore raw

PATCH v6 23/36 nds32: L2 cache support

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds L2 cache support.

---
 arch/nds32/include/asm/l2_cache.h |  137 +++++++++++++++++++++++++++++++++++++
 arch/nds32/kernel/atl2c.c         |   64 +++++++++++++++++
 2 files changed, 201 insertions(+)
 create mode 100644 arch/nds32/include/asm/l2_cache.h
 create mode 100644 arch/nds32/kernel/atl2c.c
arch/nds32/include/asm/l2_cache.h new file +137 -0
new file mode 100644
index 0000000..37dd5ef
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef L2_CACHE_H
+#define L2_CACHE_H
+
+/* CCTL_CMD_OP */
+#define L2_CA_CONF_OFF		0x0
+#define L2_IF_CONF_OFF		0x4
+#define L2CC_SETUP_OFF		0x8
+#define L2CC_PROT_OFF		0xC
+#define L2CC_CTRL_OFF		0x10
+#define L2_INT_EN_OFF           0x20
+#define L2_STA_OFF              0x24
+#define RDERR_ADDR_OFF		0x28
+#define WRERR_ADDR_OFF		0x2c
+#define EVDPTERR_ADDR_OFF	0x30
+#define IMPL3ERR_ADDR_OFF	0x34
+#define L2_CNT0_CTRL_OFF        0x40
+#define L2_EVNT_CNT0_OFF        0x44
+#define L2_CNT1_CTRL_OFF        0x48
+#define L2_EVNT_CNT1_OFF        0x4c
+#define L2_CCTL_CMD_OFF		0x60
+#define L2_CCTL_STATUS_OFF	0x64
+#define L2_LINE_TAG_OFF		0x68
+#define L2_LINE_DPT_OFF		0x70
+
+#define CCTL_CMD_L2_IX_INVAL    0x0
+#define CCTL_CMD_L2_PA_INVAL    0x1
+#define CCTL_CMD_L2_IX_WB       0x2
+#define CCTL_CMD_L2_PA_WB       0x3
+#define CCTL_CMD_L2_PA_WBINVAL  0x5
+#define CCTL_CMD_L2_SYNC        0xa
+
+/* CCTL_CMD_TYPE */
+#define CCTL_SINGLE_CMD         0
+#define CCTL_BLOCK_CMD          0x10
+#define CCTL_ALL_CMD		0x10
+
+/******************************************************************************
+ * L2_CA_CONF (Cache architecture configuration)
+ *****************************************************************************/
+#define L2_CA_CONF_offL2SET		0
+#define L2_CA_CONF_offL2WAY		4
+#define L2_CA_CONF_offL2CLSZ            8
+#define L2_CA_CONF_offL2DW		11
+#define L2_CA_CONF_offL2PT		14
+#define L2_CA_CONF_offL2VER		16
+
+#define L2_CA_CONF_mskL2SET	(0xFUL << L2_CA_CONF_offL2SET)
+#define L2_CA_CONF_mskL2WAY	(0xFUL << L2_CA_CONF_offL2WAY)
+#define L2_CA_CONF_mskL2CLSZ    (0x7UL << L2_CA_CONF_offL2CLSZ)
+#define L2_CA_CONF_mskL2DW	(0x7UL << L2_CA_CONF_offL2DW)
+#define L2_CA_CONF_mskL2PT	(0x3UL << L2_CA_CONF_offL2PT)
+#define L2_CA_CONF_mskL2VER	(0xFFFFUL << L2_CA_CONF_offL2VER)
+
+/******************************************************************************
+ * L2CC_SETUP (L2CC Setup register)
+ *****************************************************************************/
+#define L2CC_SETUP_offPART              0
+#define L2CC_SETUP_mskPART              (0x3UL << L2CC_SETUP_offPART)
+#define L2CC_SETUP_offDDLATC            4
+#define L2CC_SETUP_mskDDLATC            (0x3UL << L2CC_SETUP_offDDLATC)
+#define L2CC_SETUP_offTDLATC            8
+#define L2CC_SETUP_mskTDLATC            (0x3UL << L2CC_SETUP_offTDLATC)
+
+/******************************************************************************
+ * L2CC_PROT (L2CC Protect register)
+ *****************************************************************************/
+#define L2CC_PROT_offMRWEN              31
+#define L2CC_PROT_mskMRWEN      (0x1UL << L2CC_PROT_offMRWEN)
+
+/******************************************************************************
+ * L2_CCTL_STATUS_Mn (The L2CCTL command working status for Master n)
+ *****************************************************************************/
+#define L2CC_CTRL_offEN                 31
+#define L2CC_CTRL_mskEN                 (0x1UL << L2CC_CTRL_offEN)
+
+/******************************************************************************
+ * L2_CCTL_STATUS_Mn (The L2CCTL command working status for Master n)
+ *****************************************************************************/
+#define L2_CCTL_STATUS_offCMD_COMP      31
+#define L2_CCTL_STATUS_mskCMD_COMP      (0x1 << L2_CCTL_STATUS_offCMD_COMP)
+
+extern void __iomem *atl2c_base;
+#include <linux/smp.h>
+#include <asm/io.h>
+#include <asm/bitfield.h>
+
+#define L2C_R_REG(offset)               readl(atl2c_base + offset)
+#define L2C_W_REG(offset, value)        writel(value, atl2c_base + offset)
+
+#define L2_CMD_RDY()    \
+        do{;}while((L2C_R_REG(L2_CCTL_STATUS_OFF) & L2_CCTL_STATUS_mskCMD_COMP) == 0)
+
+static inline unsigned long L2_CACHE_SET(void)
+{
+	return 64 << ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2SET) >>
+		      L2_CA_CONF_offL2SET);
+}
+
+static inline unsigned long L2_CACHE_WAY(void)
+{
+	return 1 +
+	    ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2WAY) >>
+	     L2_CA_CONF_offL2WAY);
+}
+
+static inline unsigned long L2_CACHE_LINE_SIZE(void)
+{
+
+	return 4 << ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2CLSZ) >>
+		     L2_CA_CONF_offL2CLSZ);
+}
+
+static inline unsigned long GET_L2CC_CTRL_CPU(unsigned long cpu)
+{
+	if (cpu == smp_processor_id())
+		return L2C_R_REG(L2CC_CTRL_OFF);
+	return L2C_R_REG(L2CC_CTRL_OFF + (cpu << 8));
+}
+
+static inline void SET_L2CC_CTRL_CPU(unsigned long cpu, unsigned long val)
+{
+	if (cpu == smp_processor_id())
+		L2C_W_REG(L2CC_CTRL_OFF, val);
+	else
+		L2C_W_REG(L2CC_CTRL_OFF + (cpu << 8), val);
+}
+
+static inline unsigned long GET_L2CC_STATUS_CPU(unsigned long cpu)
+{
+	if (cpu == smp_processor_id())
+		return L2C_R_REG(L2_CCTL_STATUS_OFF);
+	return L2C_R_REG(L2_CCTL_STATUS_OFF + (cpu << 8));
+}
+#endif
arch/nds32/kernel/atl2c.c new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#72 lore raw

PATCH v6 24/36 nds32: Loadable modules

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for loadable modules.

---
 arch/nds32/include/asm/module.h |   11 ++
 arch/nds32/kernel/module.c      |  286 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 297 insertions(+)
 create mode 100644 arch/nds32/include/asm/module.h
 create mode 100644 arch/nds32/kernel/module.c
arch/nds32/include/asm/module.h new file +11 -0
new file mode 100644
index 0000000..16cf9c7
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef _ASM_NDS32_MODULE_H
+#define _ASM_NDS32_MODULE_H
+
+#include <asm-generic/module.h>
+
+#define MODULE_ARCH_VERMAGIC	"NDS32v3"
+
+#endif /* _ASM_NDS32_MODULE_H */
arch/nds32/kernel/module.c new file +286 -0

286 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 24/36
#73 lore raw

Re: [PATCH v6 24/36] nds32: Loadable modules

Quoted 3 lines · Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for loadable modules.

One detail:

You still seem to have both the ELF_REL and ELF_RELA based functions implemented here, you should drop the unused ELF_REL version:

Quoted 6 lines
arch/nds32/kernel/module.c new file +0 -0
new file mode 100644
index 0000000..714a6d6

arch/nds32/kernel/module.c line 8

Quoted 8 lines
arch/nds32/kernel/module.c new file +8 -0
@@ -0,0 +1,286 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/module.h>
+#include <linux/elf.h>
+#include <linux/vmalloc.h>
+
+#include <asm/pgtable.h>

include <linux/moduleloader.h> to catch this.

arch/nds32/kernel/module.c line 275

Quoted 7 lines
arch/nds32/kernel/module.c new file +7 -0
+int
+apply_relocate(Elf32_Shdr * sechdrs, const char *strtab,
+              unsigned int symindex, unsigned int relsec,
+              struct module *module)
+{
+       return 0;
+}

and drop this.

With that change,

#74 lore raw

Re: [PATCH v6 24/36] nds32: Loadable modules

2018-01-18 18:41 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 37 lines · Greentime Hu
Quoted 3 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for loadable modules.

One detail:

You still seem to have both the ELF_REL and ELF_RELA based functions implemented here, you should drop the unused ELF_REL version:

Quoted 6 lines
arch/nds32/kernel/module.c new file +0 -0
new file mode 100644
index 0000000..714a6d6

arch/nds32/kernel/module.c line 8

Quoted 8 lines
arch/nds32/kernel/module.c new file +8 -0
@@ -0,0 +1,286 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/module.h>
+#include <linux/elf.h>
+#include <linux/vmalloc.h>
+
+#include <asm/pgtable.h>

include <linux/moduleloader.h> to catch this.

arch/nds32/kernel/module.c line 275

Quoted 7 lines
arch/nds32/kernel/module.c new file +7 -0
+int
+apply_relocate(Elf32_Shdr * sechdrs, const char *strtab,
+              unsigned int symindex, unsigned int relsec,
+              struct module *module)
+{
+       return 0;
+}

and drop this.

Quoted 3 lines

With that change,

Hi, Arnd:

Thank you. I will include moduleloader.h and drop apply_relocate(). --
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#75 lore raw

PATCH v6 25/36 nds32: Generic timers support

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for timer.

---
 arch/nds32/kernel/time.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 arch/nds32/kernel/time.c
arch/nds32/kernel/time.c new file +11 -0
new file mode 100644
index 0000000..ac9d78c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/clocksource.h>
+#include <linux/clk-provider.h>
+
+void __init time_init(void)
+{
+	of_clk_init(NULL);
+	timer_probe();
+}
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 25/36
#76 lore raw

Re: [PATCH v6 25/36] nds32: Generic timers support

Quoted 7 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for timer.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#77 lore raw

PATCH v6 26/36 nds32: Device tree support

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds support for device tree.

---
 arch/nds32/boot/dts/Makefile  |    8 ++++
 arch/nds32/boot/dts/ae3xx.dts |   85 +++++++++++++++++++++++++++++++++++++++++
 arch/nds32/kernel/devtree.c   |   19 +++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 arch/nds32/boot/dts/Makefile
 create mode 100644 arch/nds32/boot/dts/ae3xx.dts
 create mode 100644 arch/nds32/kernel/devtree.c
arch/nds32/boot/dts/Makefile new file +8 -0
new file mode 100644
index 0000000..d31faa8
@@ -0,0 +1,8 @@
+ifneq '$(CONFIG_NDS32_BUILTIN_DTB)' '""'
+BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_NDS32_BUILTIN_DTB)).dtb.o
+else
+BUILTIN_DTB :=
+endif
+obj-$(CONFIG_OF) += $(BUILTIN_DTB)
+
+clean-files := *.dtb *.dtb.S
arch/nds32/boot/dts/ae3xx.dts new file +85 -0

85 lines not on this page · raw message

arch/nds32/kernel/devtree.c new file +19 -0
new file mode 100644
index 0000000..bdce0fe
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#include <linux/bug.h>
+#include <linux/printk.h>
+#include <linux/of_fdt.h>
+
+void __init early_init_devtree(void *params)
+{
+	if (!params || !early_init_dt_scan(params)) {
+		pr_crit("\n"
+			"Error: invalid device tree blob at (virtual address 0x%p)\n"
+			"\nPlease check your bootloader.", params);
+
+		BUG_ON(1);
+	}
+
+	dump_stack_set_arch_desc("%s (DT)", of_flat_dt_get_machine_name());
+}
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 26/36
#78 lore raw

Re: [PATCH v6 26/36] nds32: Device tree support

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds support for device tree.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#79 lore raw

PATCH v6 27/36 nds32: Miscellaneous header files

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch introduces some miscellaneous header files.

---
 arch/nds32/include/asm/delay.h          |   39 +++++++++++++++++++++++++++++++
 arch/nds32/include/asm/linkage.h        |   11 +++++++++
 arch/nds32/include/uapi/asm/byteorder.h |   13 +++++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 arch/nds32/include/asm/delay.h
 create mode 100644 arch/nds32/include/asm/linkage.h
 create mode 100644 arch/nds32/include/uapi/asm/byteorder.h
arch/nds32/include/asm/delay.h new file +39 -0
new file mode 100644
index 0000000..519ba97
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_DELAY_H__
+#define __NDS32_DELAY_H__
+
+#include <asm/param.h>
+
+/* There is no clocksource cycle counter in the CPU. */
+static inline void __delay(unsigned long loops)
+{
+	__asm__ __volatile__(".align 2\n"
+			     "1:\n"
+			     "\taddi\t%0, %0, -1\n"
+			     "\tbgtz\t%0, 1b\n"
+			     :"=r"(loops)
+			     :"0"(loops));
+}
+
+static inline void __udelay(unsigned long usecs, unsigned long lpj)
+{
+	usecs *= (unsigned long)(((0x8000000000000000ULL / (500000 / HZ)) +
+				  0x80000000ULL) >> 32);
+	usecs = (unsigned long)(((unsigned long long)usecs * lpj) >> 32);
+	__delay(usecs);
+}
+
+#define udelay(usecs) __udelay((usecs), loops_per_jiffy)
+
+/* make sure "usecs *= ..." in udelay do not overflow. */
+#if HZ >= 1000
+#define MAX_UDELAY_MS	1
+#elif HZ <= 200
+#define MAX_UDELAY_MS	5
+#else
+#define MAX_UDELAY_MS	(1000 / HZ)
+#endif
+
+#endif
arch/nds32/include/asm/linkage.h new file +11 -0
new file mode 100644
index 0000000..e708c8b
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+/* This file is required by include/linux/linkage.h */
+#define __ALIGN .align 2
+#define __ALIGN_STR ".align 2"
+
+#endif
arch/nds32/include/uapi/asm/byteorder.h new file +13 -0
new file mode 100644
index 0000000..a23f6f3a
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2005-2017 Andes Technology Corporation
+
+#ifndef __NDS32_BYTEORDER_H__
+#define __NDS32_BYTEORDER_H__
+
+#ifdef __NDS32_EB__
+#include <linux/byteorder/big_endian.h>
+#else
+#include <linux/byteorder/little_endian.h>
+#endif
+
+#endif /* __NDS32_BYTEORDER_H__ */
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 27/36
#80 lore raw

Re: [PATCH v6 27/36] nds32: Miscellaneous header files

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch introduces some miscellaneous header files.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#81 lore raw

PATCH v6 28/36 nds32: defconfig

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds nds32 defconfig.

---
 arch/nds32/configs/defconfig |  107 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 arch/nds32/configs/defconfig
arch/nds32/configs/defconfig new file +107 -0
new file mode 100644
index 0000000..53d1778
@@ -0,0 +1,107 @@
+CONFIG_CROSS_COMPILE="nds32le-linux-"
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_USER_NS=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_PROFILING=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_CACHE_L2 is not set
+CONFIG_VMSPLIT_3G_OPT=y
+CONFIG_PREEMPT=y
+# CONFIG_COMPACTION is not set
+CONFIG_HZ_100=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_NET_KEY=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_BLK_DEV is not set
+CONFIG_NETDEVICES=y
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+CONFIG_FTMAC100=y
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_SERIO is not set
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_8250=y
+# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=3
+CONFIG_SERIAL_8250_RUNTIME_UARTS=3
+CONFIG_SERIAL_OF_PLATFORM=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_RC_CORE is not set
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_HID_A4TECH is not set
+# CONFIG_HID_APPLE is not set
+# CONFIG_HID_BELKIN is not set
+# CONFIG_HID_CHERRY is not set
+# CONFIG_HID_CHICONY is not set
+# CONFIG_HID_CYPRESS is not set
+# CONFIG_HID_EZKEY is not set
+# CONFIG_HID_ITE is not set
+# CONFIG_HID_KENSINGTON is not set
+# CONFIG_HID_LOGITECH is not set
+# CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MONTEREY is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_GENERIC_PHY=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_EXT4_ENCRYPTION=y
+CONFIG_FUSE_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_CONFIGFS_FS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_V4_1=y
+CONFIG_NFS_USE_LEGACY_DNS=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_INFO_DWARF4=y
+CONFIG_GDB_SCRIPTS=y
+CONFIG_READABLE_ASM=y
+CONFIG_HEADERS_CHECK=y
+CONFIG_DEBUG_SECTION_MISMATCH=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_PANIC_ON_OOPS=y
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_DEBUG_PREEMPT is not set
+CONFIG_STACKTRACE=y
+CONFIG_RCU_CPU_STALL_TIMEOUT=300
+# CONFIG_CRYPTO_HW is not set
Signature · 1 line
1.7.9.5
#83 lore raw

PATCH v6 29/36 nds32: Build infrastructure

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds Makefile, Kconfig and vmlinux.lds.S files required for building an nds32 kernel.

---
 arch/nds32/Kconfig                 |  107 ++++++++++++++++++++++++
 arch/nds32/Kconfig.cpu             |  161 ++++++++++++++++++++++++++++++++++++
 arch/nds32/Makefile                |   66 +++++++++++++++
 arch/nds32/boot/Makefile           |   15 ++++
 arch/nds32/include/asm/Kbuild      |   54 ++++++++++++
 arch/nds32/include/uapi/asm/Kbuild |   28 +++++++
 arch/nds32/kernel/Makefile         |   23 ++++++
 arch/nds32/kernel/vmlinux.lds.S    |   57 +++++++++++++
 arch/nds32/mm/Makefile             |    7 ++
 9 files changed, 518 insertions(+)
 create mode 100644 arch/nds32/Kconfig
 create mode 100644 arch/nds32/Kconfig.cpu
 create mode 100644 arch/nds32/Makefile
 create mode 100644 arch/nds32/boot/Makefile
 create mode 100644 arch/nds32/include/asm/Kbuild
 create mode 100644 arch/nds32/include/uapi/asm/Kbuild
 create mode 100644 arch/nds32/kernel/Makefile
 create mode 100644 arch/nds32/kernel/vmlinux.lds.S
 create mode 100644 arch/nds32/mm/Makefile
arch/nds32/Kconfig new file +107 -0
new file mode 100644
index 0000000..56e1be1
@@ -0,0 +1,107 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+
+config NDS32
+        def_bool y
+	select ARCH_HAS_RAW_COPY_USER
+	select ARCH_WANT_FRAME_POINTERS if FTRACE
+	select ARCH_WANT_IPC_PARSE_VERSION
+	select CLKSRC_MMIO
+	select CLONE_BACKWARDS
+	select COMMON_CLK
+	select FRAME_POINTER
+	select GENERIC_ATOMIC64
+	select GENERIC_CPU_DEVICES
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_PROBE
+	select GENERIC_IRQ_SHOW
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
+	select GENERIC_TIME_VSYSCALL
+	select HANDLE_DOMAIN_IRQ
+	select HAVE_ARCH_TRACEHOOK
+	select HAVE_DEBUG_KMEMLEAK
+	select HAVE_MEMBLOCK
+	select HAVE_REGS_AND_STACK_ACCESS_API
+	select IRQ_DOMAIN
+	select LOCKDEP_SUPPORT
+	select MODULES_USE_ELF_RELA
+	select OF
+	select OF_EARLY_FLATTREE
+	select NO_BOOTMEM
+	select NO_IOPORT_MAP
+	select RTC_LIB
+	select THREAD_INFO_IN_TASK
+	help
+	  Andes(nds32) Linux support.
+
+config GENERIC_CALIBRATE_DELAY
+	def_bool n
+
+config GENERIC_CSUM
+        def_bool y
+
+config GENERIC_HWEIGHT
+        def_bool y
+
+config GENERIC_LOCKBREAK
+        def_bool y
+	depends on PREEMPT
+
+config RWSEM_GENERIC_SPINLOCK
+	def_bool y
+
+config TRACE_IRQFLAGS_SUPPORT
+	def_bool y
+
+config STACKTRACE_SUPPORT
+        def_bool y
+
+config FIX_EARLYCON_MEM
+	def_bool y
+
+config PGTABLE_LEVELS
+	default 2
+
+source "init/Kconfig"
+
+menu "System Type"
+source "arch/nds32/Kconfig.cpu"
+config NR_CPUS
+	int
+	default 1
+
+config MMU
+        def_bool y
+
+config NDS32_BUILTIN_DTB
+        string "Builtin DTB"
+        default ""
+	help
+	  User can use it to specify the dts of the SoC
+endmenu
+
+menu "Kernel Features"
+source "kernel/Kconfig.preempt"
+source "mm/Kconfig"
+source "kernel/Kconfig.hz"
+endmenu
+
+menu "Executable file formats"
+source "fs/Kconfig.binfmt"
+endmenu
+
+source "net/Kconfig"
+source "drivers/Kconfig"
+source "fs/Kconfig"
+
+menu "Kernel hacking"
+source "lib/Kconfig.debug"
+endmenu
+
+source "security/Kconfig"
+source "crypto/Kconfig"
+source "lib/Kconfig"
arch/nds32/Kconfig.cpu new file +161 -0

161 lines not on this page · raw message

arch/nds32/Makefile new file +66 -0

66 lines not on this page · raw message

arch/nds32/boot/Makefile new file +15 -0
new file mode 100644
index 0000000..3f9b86f
@@ -0,0 +1,15 @@
+targets := Image Image.gz
+
+$(obj)/Image: vmlinux FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/Image.gz: $(obj)/Image FORCE
+	$(call if_changed,gzip)
+
+install: $(obj)/Image
+	$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
+	$(obj)/Image System.map "$(INSTALL_PATH)"
+
+zinstall: $(obj)/Image.gz
+	$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
+	$(obj)/Image.gz System.map "$(INSTALL_PATH)"
arch/nds32/include/asm/Kbuild new file +54 -0

54 lines not on this page · raw message

arch/nds32/include/uapi/asm/Kbuild new file +28 -0
new file mode 100644
index 0000000..c4dc909
@@ -0,0 +1,28 @@
+# UAPI Header export list
+include include/uapi/asm-generic/Kbuild.asm
+
+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 += fcntl.h
+generic-y += stat.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 += setup.h
+generic-y += siginfo.h
+generic-y += signal.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += swab.h
+generic-y += statfs.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += types.h
+generic-y += ucontext.h
arch/nds32/kernel/Makefile new file +23 -0
new file mode 100644
index 0000000..4279274
@@ -0,0 +1,23 @@
+#
+# Makefile for the linux kernel.
+#
+
+CPPFLAGS_vmlinux.lds	:= -DTEXTADDR=$(TEXTADDR)
+AFLAGS_head.o		:= -DTEXTADDR=$(TEXTADDR)
+
+# Object file lists.
+
+obj-y			:= ex-entry.o ex-exit.o ex-scall.o irq.o \
+			process.o ptrace.o setup.o signal.o \
+			sys_nds32.o time.o traps.o cacheinfo.o \
+			dma.o syscall_table.o vdso.o
+
+obj-$(CONFIG_MODULES)		+= nds32_ksyms.o module.o
+obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
+obj-$(CONFIG_OF)		+= devtree.o
+obj-$(CONFIG_CACHE_L2)		+= atl2c.o
+
+extra-y := head.o vmlinux.lds
+
+
+obj-y				+= vdso/
arch/nds32/kernel/vmlinux.lds.S new file +57 -0

57 lines not on this page · raw message

arch/nds32/mm/Makefile new file +7 -0
new file mode 100644
index 0000000..6b68558
@@ -0,0 +1,7 @@
+obj-y				:= extable.o tlb.o \
+				   fault.o init.o ioremap.o mmap.o \
+                                   mm-nds32.o cacheflush.o proc.o
+
+obj-$(CONFIG_ALIGNMENT_TRAP)	+= alignment.o
+obj-$(CONFIG_HIGHMEM)           += highmem.o
+CFLAGS_proc-n13.o		+= -fomit-frame-pointer
Signature · 1 line
1.7.9.5
maintainer
#84 lore raw

Re: [PATCH v6 29/36] nds32: Build infrastructure

Quoted 7 lines · Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds Makefile, Kconfig and vmlinux.lds.S files required for building an nds32 kernel.

I find some new details every time I look here ;-)

arch/nds32/Kconfig line 8

Quoted 9 lines
arch/nds32/Kconfig new file +8 -0
@@ -0,0 +1,107 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+
+config NDS32
+        def_bool y
+       select ARCH_HAS_RAW_COPY_USER

I don't think this symbol was ever merged. Do you remember why you added it?

arch/nds32/Kconfig line 10

Quoted 2 lines
arch/nds32/Kconfig new file +2 -0
+       select ARCH_WANT_FRAME_POINTERS if FTRACE
+       select ARCH_WANT_IPC_PARSE_VERSION

You most certainly don't want IPC_PARSE_VERSION, please drop this and adapt your glibc.

arch/nds32/Kconfig line 14

Quoted 4 lines
arch/nds32/Kconfig new file +4 -0
+       select CLKSRC_MMIO
+       select CLONE_BACKWARDS
+       select COMMON_CLK
+       select FRAME_POINTER

Do you need both ARCH_WANT_FRAME_POINTERS and FRAME_POINTER here?

arch/nds32/Kconfig line 19

Quoted 5 lines
arch/nds32/Kconfig new file +5 -0
+       select GENERIC_ATOMIC64
+       select GENERIC_CPU_DEVICES
+       select GENERIC_CLOCKEVENTS
+       select GENERIC_IRQ_CHIP
+       select GENERIC_IRQ_PROBE

I think it's better to drop GENERIC_IRQ_PROBE here, no modern driver should rely on that.

Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+choice
+       prompt "CPU type"
+       default CPU_V3
+config CPU_N15
+       bool "AndesCore N15"
+config CPU_N13
+       bool "AndesCore N13"
+       select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
+config CPU_N10
+       bool "AndesCore N10"

arch/nds32/Kconfig.cpu line 51

Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+       select CPU_CACHE_ALIASING
+config CPU_D15
+       bool "AndesCore D15"
+config CPU_D10
+       bool "AndesCore D10"
+       select CPU_CACHE_ALIASING
+config CPU_V3
+       bool "AndesCore v3 compatible"
+       select ANDES_PAGE_SIZE_8KB
+endchoice

I forget what we discussed here earlier, but at the very least, there should be some help text here to explain what the implications are. I assume that you generally want to be able to build one kernel to run on all of the above, right?

Will selecting 'CPU_V3' result in a kernel binary that can run on all of them? If so, please explain it here as that is not obvious.

For the other CPU types, can you list the what backwards-compatiblity you get? E.g. will a kernel built for N13 run on any of N15, D15 or N10?

I think the 'select ANDES_PAGE_SIZE_8KB' cannot work as expected, since ANDES_PAGE_SIZE_8KB is inside of a 'choice' statement. Since there are only two options (4K and 8K), you can address that by making it a simple bool option and fall back to 4K when ANDES_PAGE_SIZE_8KB is disabled.

arch/nds32/Kconfig.cpu line 137

Quoted 13 lines
arch/nds32/Kconfig.cpu new file +13 -0
+config CACHE_L2
+       bool "Support L2 cache"
+        default y
+       help
+         Say Y here to enable L2 cache if your SoC are integrated with L2CC.
+         If unsure, say N.
+
+menu "Memory configuration"
+
+choice
+       prompt "Memory split"
+       depends on MMU
+       default VMSPLIT_3G

Why not default to VMSPLIT_3G_OPT?

Arnd

#85 lore raw

Re: [PATCH v6 29/36] nds32: Build infrastructure

Hi, Arnd:

2018-01-18 19:00 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 10 lines · Greentime Hu
Quoted 7 lines

From: Greentime Hu <[email protected]>

This patch adds Makefile, Kconfig and vmlinux.lds.S files required for building an nds32 kernel.

I find some new details every time I look here ;-)

Thank you for revewing so detailedly. :)

Quoted 11 lines

arch/nds32/Kconfig line 8

Quoted 9 lines
arch/nds32/Kconfig new file +8 -0
@@ -0,0 +1,107 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+
+config NDS32
+        def_bool y
+       select ARCH_HAS_RAW_COPY_USER

I don't think this symbol was ever merged. Do you remember why you added it?

I will drop it. It must be added in earlier kernel version.

Quoted 5 lines

arch/nds32/Kconfig line 10

Quoted 2 lines
arch/nds32/Kconfig new file +2 -0
+       select ARCH_WANT_FRAME_POINTERS if FTRACE
+       select ARCH_WANT_IPC_PARSE_VERSION

You most certainly don't want IPC_PARSE_VERSION, please drop this and adapt your glibc.

ok. I will drop it.

Quoted 6 lines

arch/nds32/Kconfig line 14

Quoted 4 lines
arch/nds32/Kconfig new file +4 -0
+       select CLKSRC_MMIO
+       select CLONE_BACKWARDS
+       select COMMON_CLK
+       select FRAME_POINTER

Do you need both ARCH_WANT_FRAME_POINTERS and FRAME_POINTER here?

I will drop FRAME_POINTER.

Quoted 8 lines

arch/nds32/Kconfig line 19

Quoted 5 lines
arch/nds32/Kconfig new file +5 -0
+       select GENERIC_ATOMIC64
+       select GENERIC_CPU_DEVICES
+       select GENERIC_CLOCKEVENTS
+       select GENERIC_IRQ_CHIP
+       select GENERIC_IRQ_PROBE

I think it's better to drop GENERIC_IRQ_PROBE here, no modern driver should rely on that.

I will drop it.

Quoted 25 lines
Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+choice
+       prompt "CPU type"
+       default CPU_V3
+config CPU_N15
+       bool "AndesCore N15"
+config CPU_N13
+       bool "AndesCore N13"
+       select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
+config CPU_N10
+       bool "AndesCore N10"

arch/nds32/Kconfig.cpu line 51

Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+       select CPU_CACHE_ALIASING
+config CPU_D15
+       bool "AndesCore D15"
+config CPU_D10
+       bool "AndesCore D10"
+       select CPU_CACHE_ALIASING
+config CPU_V3
+       bool "AndesCore v3 compatible"
+       select ANDES_PAGE_SIZE_8KB
+endchoice

I forget what we discussed here earlier, but at the very least, there should be some help text here to explain what the implications are. I assume that you generally want to be able to build one kernel to run on all of the above, right?

Quoted 6 lines

Will selecting 'CPU_V3' result in a kernel binary that can run on all of them? If so, please explain it here as that is not obvious.

For the other CPU types, can you list the what backwards-compatiblity you get? E.g. will a kernel built for N13 run on any of N15, D15 or N10?

Yes, we would like to build a kernel with CPU_V3 to run on all of the above.

Not sure if these help texts clear enough?

choice
prompt "CPU type"
default CPU_V3
help
The data cache of N15/D15 is implemented as PIPT and it will
not cause the
cache aliasing issue. The rest cpus(N13, N10 and D10) are
implemented as
VIPT data cache. It may cause the cache aliasing issue if
its cache way
size is larger than page size. You can specify the the CPU
type direcly or
choose CPU_V3 if unsure.

A kernel built for N10 is able to run on N15, D15, N13, N10 or D10. A kernel built for N15 is able to run on N15 or D15.
A kernel built for D10 is able to run on D10 or D15.
A kernel built for D15 is able to run on D15.
A kernel built for N13 with CPU_CACHE_ALIASING is able to
run on N15, D15, N13, N10 or D10
A kernel built for N13 without CPU_CACHE_ALIASING is able to
run on N15, N13 or D15

config CPU_N15
bool "AndesCore N15"
config CPU_N13
bool "AndesCore N13"
select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
config CPU_N10
bool "AndesCore N10"
select CPU_CACHE_ALIASING
config CPU_D15
bool "AndesCore D15"
config CPU_D10
bool "AndesCore D10"
select CPU_CACHE_ALIASING
config CPU_V3
bool "AndesCore v3 compatible"
select CPU_CACHE_ALIASING
endchoice

Quoted 5 lines

I think the 'select ANDES_PAGE_SIZE_8KB' cannot work as expected, since ANDES_PAGE_SIZE_8KB is inside of a 'choice' statement. Since there are only two options (4K and 8K), you can address that by making it a simple bool option and fall back to 4K when ANDES_PAGE_SIZE_8KB is disabled.

After reviewing this config, it seems to make much more sense if we select CPU_CACHE_ALIASING.
A kernel with aliasing cache handling should be able to run on aliasing/non-aliasing CPU.

config CPU_V3
bool "AndesCore v3 compatible"
select CPU_CACHE_ALIASING

Quoted 7 lines
Quoted 7 lines
arch/nds32/Kconfig.cpu new file +7 -0
+config CACHE_L2
+       bool "Support L2 cache"
+        default y
+       help
+         Say Y here to enable L2 cache if your SoC are integrated with L2CC.
+         If unsure, say N.
+
Quoted 9 lines

arch/nds32/Kconfig.cpu line 137

Quoted 6 lines
arch/nds32/Kconfig.cpu new file +6 -0
+menu "Memory configuration"
+
+choice
+       prompt "Memory split"
+       depends on MMU
+       default VMSPLIT_3G

Why not default to VMSPLIT_3G_OPT?

I will set default to VMSPLIT_3G_OPT and delete
CONFIG_VMSPLIT_3G_OPT=y in defconfig.

maintainer
#86 lore raw

Re: [PATCH v6 29/36] nds32: Build infrastructure

On Mon, Jan 22, 2018 at 4:20 PM, Greentime Hu <[email protected]> wrote:
BE

Quoted 73 lines
Quoted 3 lines

I think it's better to drop GENERIC_IRQ_PROBE here, no modern driver should rely on that.

I will drop it.

Quoted 25 lines
Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+choice
+       prompt "CPU type"
+       default CPU_V3
+config CPU_N15
+       bool "AndesCore N15"
+config CPU_N13
+       bool "AndesCore N13"
+       select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
+config CPU_N10
+       bool "AndesCore N10"

arch/nds32/Kconfig.cpu line 51

Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+       select CPU_CACHE_ALIASING
+config CPU_D15
+       bool "AndesCore D15"
+config CPU_D10
+       bool "AndesCore D10"
+       select CPU_CACHE_ALIASING
+config CPU_V3
+       bool "AndesCore v3 compatible"
+       select ANDES_PAGE_SIZE_8KB
+endchoice

I forget what we discussed here earlier, but at the very least, there should be some help text here to explain what the implications are. I assume that you generally want to be able to build one kernel to run on all of the above, right?

Quoted 6 lines

Will selecting 'CPU_V3' result in a kernel binary that can run on all of them? If so, please explain it here as that is not obvious.

For the other CPU types, can you list the what backwards-compatiblity you get? E.g. will a kernel built for N13 run on any of N15, D15 or N10?

Yes, we would like to build a kernel with CPU_V3 to run on all of the above.

Not sure if these help texts clear enough?

choice
prompt "CPU type"
default CPU_V3
help
The data cache of N15/D15 is implemented as PIPT and it will
not cause the
cache aliasing issue. The rest cpus(N13, N10 and D10) are
implemented as
VIPT data cache. It may cause the cache aliasing issue if
its cache way
size is larger than page size. You can specify the the CPU
type direcly or
choose CPU_V3 if unsure.

A kernel built for N10 is able to run on N15, D15, N13, N10 or D10. A kernel built for N15 is able to run on N15 or D15.
A kernel built for D10 is able to run on D10 or D15.
A kernel built for D15 is able to run on D15.
A kernel built for N13 with CPU_CACHE_ALIASING is able to
run on N15, D15, N13, N10 or D10
A kernel built for N13 without CPU_CACHE_ALIASING is able to
run on N15, N13 or D15

config CPU_N15
bool "AndesCore N15"
config CPU_N13
bool "AndesCore N13"
select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
config CPU_N10
bool "AndesCore N10"
select CPU_CACHE_ALIASING
config CPU_D15

Quoted 8 lines

bool "AndesCore D15"
config CPU_D10
bool "AndesCore D10"
select CPU_CACHE_ALIASING
config CPU_V3
bool "AndesCore v3 compatible"
select CPU_CACHE_ALIASING
endchoice

I would drop the description about CPU_CACHE_ALIASING in the list of compatibilities text and simply say 'A kernel built for N13 is able to run on N15, N13 or D15', it's more logical that way, and it gives you the freedom to later change the rules about whether it can or cannot run.

Maybe also change the initial prompt from "CPU type" to "minimum CPU type".

Quoted 6 lines
Quoted 5 lines

I think the 'select ANDES_PAGE_SIZE_8KB' cannot work as expected, since ANDES_PAGE_SIZE_8KB is inside of a 'choice' statement. Since there are only two options (4K and 8K), you can address that by making it a simple bool option and fall back to 4K when ANDES_PAGE_SIZE_8KB is disabled.

Quoted 8 lines

After reviewing this config, it seems to make much more sense if we select CPU_CACHE_ALIASING.
A kernel with aliasing cache handling should be able to run on aliasing/non-aliasing CPU.

config CPU_V3
bool "AndesCore v3 compatible"
select CPU_CACHE_ALIASING

Sure, that's a possible way out.

Arnd

#87 lore raw

Re: [PATCH v6 29/36] nds32: Build infrastructure

Hi, Arnd:

2018-01-22 23:38 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 84 lines · Greentime Hu

BE

Quoted 73 lines
Quoted 3 lines

I think it's better to drop GENERIC_IRQ_PROBE here, no modern driver should rely on that.

I will drop it.

Quoted 25 lines
Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+choice
+       prompt "CPU type"
+       default CPU_V3
+config CPU_N15
+       bool "AndesCore N15"
+config CPU_N13
+       bool "AndesCore N13"
+       select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
+config CPU_N10
+       bool "AndesCore N10"

arch/nds32/Kconfig.cpu line 51

Quoted 10 lines
arch/nds32/Kconfig.cpu new file +10 -0
+       select CPU_CACHE_ALIASING
+config CPU_D15
+       bool "AndesCore D15"
+config CPU_D10
+       bool "AndesCore D10"
+       select CPU_CACHE_ALIASING
+config CPU_V3
+       bool "AndesCore v3 compatible"
+       select ANDES_PAGE_SIZE_8KB
+endchoice

I forget what we discussed here earlier, but at the very least, there should be some help text here to explain what the implications are. I assume that you generally want to be able to build one kernel to run on all of the above, right?

Quoted 6 lines

Will selecting 'CPU_V3' result in a kernel binary that can run on all of them? If so, please explain it here as that is not obvious.

For the other CPU types, can you list the what backwards-compatiblity you get? E.g. will a kernel built for N13 run on any of N15, D15 or N10?

Yes, we would like to build a kernel with CPU_V3 to run on all of the above.

Not sure if these help texts clear enough?

choice
prompt "CPU type"
default CPU_V3
help
The data cache of N15/D15 is implemented as PIPT and it will
not cause the
cache aliasing issue. The rest cpus(N13, N10 and D10) are
implemented as
VIPT data cache. It may cause the cache aliasing issue if
its cache way
size is larger than page size. You can specify the the CPU
type direcly or
choose CPU_V3 if unsure.

A kernel built for N10 is able to run on N15, D15, N13, N10 or D10. A kernel built for N15 is able to run on N15 or D15.
A kernel built for D10 is able to run on D10 or D15.
A kernel built for D15 is able to run on D15.
A kernel built for N13 with CPU_CACHE_ALIASING is able to
run on N15, D15, N13, N10 or D10
A kernel built for N13 without CPU_CACHE_ALIASING is able to
run on N15, N13 or D15

config CPU_N15
bool "AndesCore N15"
config CPU_N13
bool "AndesCore N13"
select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
config CPU_N10
bool "AndesCore N10"
select CPU_CACHE_ALIASING
config CPU_D15

Quoted 8 lines

bool "AndesCore D15"
config CPU_D10
bool "AndesCore D10"
select CPU_CACHE_ALIASING
config CPU_V3
bool "AndesCore v3 compatible"
select CPU_CACHE_ALIASING
endchoice

Quoted 7 lines

I would drop the description about CPU_CACHE_ALIASING in the list of compatibilities text and simply say 'A kernel built for N13 is able to run on N15, N13 or D15', it's more logical that way, and it gives you the freedom to later change the rules about whether it can or cannot run.

Maybe also change the initial prompt from "CPU type" to "minimum CPU type".

Thank you for your suggestion.
I will update it like this.

choice
prompt "minimum CPU type"
default CPU_V3
help
The data cache of N15/D15 is implemented as PIPT and it will not cause the cache aliasing issue. The rest cpus(N13, N10 and D10) are implemented as VIPT data cache. It may cause the cache aliasing issue if its cache way size is larger than page size. You can specify the CPU type direcly or choose CPU_V3 if unsure.

A kernel built for N10 is able to run on N15, D15, N13, N10 or D10. A kernel built for N15 is able to run on N15 or D15.
A kernel built for D10 is able to run on D10 or D15.
A kernel built for D15 is able to run on D15.
A kernel built for N13 is able to run on N15, N13 or D15.

config CPU_N15
bool "AndesCore N15"
config CPU_N13
bool "AndesCore N13"
select CPU_CACHE_ALIASING if ANDES_PAGE_SIZE_4KB
config CPU_N10
bool "AndesCore N10"
select CPU_CACHE_ALIASING
config CPU_D15
bool "AndesCore D15"
config CPU_D10
bool "AndesCore D10"
select CPU_CACHE_ALIASING
config CPU_V3
bool "AndesCore v3 compatible"
select CPU_CACHE_ALIASING
endchoice

#88 lore raw

PATCH v6 30/36 MAINTAINERS: Add nds32

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

---
 MAINTAINERS |   11 +++++++++++
 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
index 2f4e462..20284c8 100644
@@ -857,6 +857,17 @@ X:	drivers/iio/*/adjd*
 F:	drivers/staging/iio/*/ad*
 F:	drivers/staging/iio/trigger/iio-trig-bfin-timer.c
 
+ANDES ARCHITECTURE
+M:	Greentime Hu <[email protected]>
+M:	Vincent Chen <[email protected]>
+T:	git https://github.com/andestech/linux.git
+S:	Supported
+F:	arch/nds32
+F:	Documentation/devicetree/bindings/interrupt-controller/andestech,ativic32.txt
+F:	Documentation/devicetree/bindings/nds32
+K:	nds32
+N:	nds32
+
 ANDROID CONFIG FRAGMENTS
 M:	Rob Herring <[email protected]>
 S:	Supported
Signature · 1 line
1.7.9.5
#90 lore raw

PATCH v6 31/36 dt-bindings: nds32 CPU Bindings

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +37 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+
+	- compatible:
+		Usage: required
+		Value type: <string>
+		Definition: should be one of:
+			"andestech,n13"
+			"andestech,n15"
+			"andestech,d15"
+			"andestech,n10"
+			"andestech,d10"
+			"andestech,nds32v3"
+	- device_type
+		Usage: required
+		Value type: <string>
+		Definition: must be "cpu"
+	- reg: Contains CPU index.
+	- clock-frequency: Contains the clock frequency for CPU, in Hz.
+
+* Examples
+
+/ {
+	cpus {
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "andestech,n13", "andestech,nds32v3";
+			reg = <0x0>;
+			clock-frequency = <60000000>
+		};
+	};
+};
Signature · 1 line
1.7.9.5
maintainer
#91 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Quoted 28 lines · Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Arnd

#92 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 45 lines · Greentime Hu
Quoted 28 lines

From: Greentime Hu <[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 1 line

Arnd

Hi, Arnd:

I will remove the others and just left "andestech,nds32v3" in here.

maintainer
#93 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Quoted 46 lines · Greentime Hu

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 36 lines · Greentime Hu
Quoted 35 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +15 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
Quoted 8 lines

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 3 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +3 -0
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 1 line

I will remove the others and just left "andestech,nds32v3" in here.

No, is not what we want here, the CPU node should list exactly which core is used, what we need in the description is a clarification that andestech,nds32v3 must be used in addition to the more specific string.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#94 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

2018-01-19 22:52 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 47 lines · Greentime Hu
Quoted 45 lines

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 44 lines · Greentime Hu
Quoted 28 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 6 lines
Quoted 1 line

I will remove the others and just left "andestech,nds32v3" in here.

No, is not what we want here, the CPU node should list exactly which core is used, what we need in the description is a clarification that andestech,nds32v3 must be used in addition to the more specific string.

Hi, Arnd:

Sorry I still don't get your point. Do you mean we should always use compatible = "andestech,n13", "andestech,nds32v3"; instead of
compatible = "andestech,n13";

And I need to add the description in this document.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#95 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Hi Greentime,

Quoted 55 lines · Greentime Hu

2018-01-19 22:52 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 47 lines · Greentime Hu
Quoted 45 lines

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 44 lines · Greentime Hu
Quoted 28 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 6 lines
Quoted 1 line

I will remove the others and just left "andestech,nds32v3" in here.

No, is not what we want here, the CPU node should list exactly which core is used, what we need in the description is a clarification that andestech,nds32v3 must be used in addition to the more specific string.

Quoted 6 lines

Hi, Arnd:

Sorry I still don't get your point. Do you mean we should always use compatible = "andestech,n13", "andestech,nds32v3"; instead of
compatible = "andestech,n13";

Exactly. The first value is a device-specific compatible value, the second is a generic fallback.

Quoted 1 line

And I need to add the description in this document.

Indeed. See for example Documentation/devicetree/bindings/power/renesas,apmu.txt

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#96 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

2018-01-19 23:29 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 68 lines

Hi Greentime,

Quoted 55 lines · Greentime Hu

2018-01-19 22:52 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 47 lines · Greentime Hu
Quoted 45 lines

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 44 lines · Greentime Hu
Quoted 28 lines

From: Greentime Hu <[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 6 lines
Quoted 1 line

I will remove the others and just left "andestech,nds32v3" in here.

No, is not what we want here, the CPU node should list exactly which core is used, what we need in the description is a clarification that andestech,nds32v3 must be used in addition to the more specific string.

Quoted 6 lines

Hi, Arnd:

Sorry I still don't get your point. Do you mean we should always use compatible = "andestech,n13", "andestech,nds32v3"; instead of
compatible = "andestech,n13";

Exactly. The first value is a device-specific compatible value, the second is a generic fallback.

Quoted 6 lines
Quoted 1 line

And I need to add the description in this document.

Indeed. See for example Documentation/devicetree/bindings/power/renesas,apmu.txt

Thanks!

Hi, Geert:

Thank you and your example.
I get it. I will update this document like this.
- compatible: Should be "andestech,<core_name>", "andestech,nds32v3" as fallback.

#97 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Hi Greentime,

Quoted 72 lines · Greentime Hu

2018-01-19 23:29 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 71 lines · Greentime Hu
Quoted 55 lines

2018-01-19 22:52 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 47 lines · Greentime Hu
Quoted 45 lines

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 44 lines · Greentime Hu
Quoted 28 lines

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 6 lines
Quoted 1 line

I will remove the others and just left "andestech,nds32v3" in here.

No, is not what we want here, the CPU node should list exactly which core is used, what we need in the description is a clarification that andestech,nds32v3 must be used in addition to the more specific string.

Quoted 6 lines

Hi, Arnd:

Sorry I still don't get your point. Do you mean we should always use compatible = "andestech,n13", "andestech,nds32v3"; instead of
compatible = "andestech,n13";

Exactly. The first value is a device-specific compatible value, the second is a generic fallback.

Quoted 1 line

And I need to add the description in this document.

Indeed. See for example Documentation/devicetree/bindings/power/renesas,apmu.txt

Quoted 8 lines
Quoted 1 line

Thanks!

Hi, Geert:

Thank you and your example.
I get it. I will update this document like this.
- compatible: Should be "andestech,<core_name>", "andestech,nds32v3" as fallback.

And please keep a list of supported values of "andestech,<core_name>" in the DT binding document, so checkpatch can validate compatible values.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#98 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Hi, Geert:

2018-01-19 23:37 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 79 lines

Hi Greentime,

Quoted 76 lines · Greentime Hu

2018-01-19 23:29 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 66 lines · Greentime Hu
Quoted 55 lines

2018-01-19 22:52 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 47 lines · Greentime Hu
Quoted 45 lines

2018-01-18 19:02 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 44 lines · Greentime Hu
Quoted 28 lines

From: Greentime Hu <[email protected]>

This patch adds nds32 CPU binding documents.

---
 Documentation/devicetree/bindings/nds32/cpus.txt |   37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/cpus.txt
Documentation/devicetree/bindings/nds32/cpus.txt new file +8 -0
new file mode 100644
index 0000000..9a52937
@@ -0,0 +1,37 @@
+* Andestech Processor Binding
+
+This binding specifies what properties must be available in the device tree
+representation of a Andestech Processor Core, which is the root node in the
+tree.
+
+Required properties:
+

Documentation/devicetree/bindings/nds32/cpus.txt line 18

Quoted 10 lines
Documentation/devicetree/bindings/nds32/cpus.txt new file +10 -0
+       - compatible:
+               Usage: required
+               Value type: <string>
+               Definition: should be one of:
+                       "andestech,n13"
+                       "andestech,n15"
+                       "andestech,d15"
+                       "andestech,n10"
+                       "andestech,d10"
+                       "andestech,nds32v3"

Based on https://lkml.org/lkml/2017/11/27/1290, this should say that the device tree should always list 'andestech,nds32v3' as the most generic 'compatible' value and list exactly one of the others in addition.

Quoted 6 lines
Quoted 1 line

I will remove the others and just left "andestech,nds32v3" in here.

No, is not what we want here, the CPU node should list exactly which core is used, what we need in the description is a clarification that andestech,nds32v3 must be used in addition to the more specific string.

Quoted 6 lines

Hi, Arnd:

Sorry I still don't get your point. Do you mean we should always use compatible = "andestech,n13", "andestech,nds32v3"; instead of
compatible = "andestech,n13";

Exactly. The first value is a device-specific compatible value, the second is a generic fallback.

Quoted 6 lines
Quoted 1 line

And I need to add the description in this document.

Indeed. See for example Documentation/devicetree/bindings/power/renesas,apmu.txt

Thanks!

Hi, Geert:

Quoted 8 lines
Quoted 4 lines

Thank you and your example.
I get it. I will update this document like this.
- compatible: Should be "andestech,<core_name>", "andestech,nds32v3" as fallback.

And please keep a list of supported values of "andestech,<core_name>" in the DT binding document, so checkpatch can validate compatible values.

Thank you for reminding me this.
I will list it like this.

- compatible:
Usage: required
Value type: <string>
Definition: Should be "andestech,<core_name>",
"andestech,nds32v3" as fallback.

        Examlpes with core_names are:
        "andestech,n13"
        "andestech,n15"
        "andestech,d15"
        "andestech,n10"
        "andestech,d10"
maintainer
#99 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Quoted 22 lines · Greentime Hu

2018-01-19 23:37 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 12 lines · Greentime Hu
Quoted 7 lines

2018-01-19 23:29 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 1 line · Greentime Hu

Thank you and your example.
I get it. I will update this document like this.
- compatible: Should be "andestech,<core_name>", "andestech,nds32v3" as fallback.

And please keep a list of supported values of "andestech,<core_name>" in the DT binding document, so checkpatch can validate compatible values.

Thank you for reminding me this.
I will list it like this.

- compatible:
Usage: required
Value type: <string>
Definition: Should be "andestech,<core_name>",
"andestech,nds32v3" as fallback.

Quoted 6 lines
        Examlpes with core_names are:
        "andestech,n13"
        "andestech,n15"
        "andestech,d15"
        "andestech,n10"
        "andestech,d10"

This is still not written as a proper specification, you should not give "examples"
but give a complete list of the available options. You could write it like:

Must contain "andestech,nds32v3" as the most generic value, in addition to one of the following identifiers for a particular CPU core:

         "andestech,n13"
         "andestech,n15"
         "andestech,d15"
         "andestech,n10"
         "andestech,d10"

It might be helpful to also list all other existing nds32v3 cores, even those that the
current Linux port does not support them.

Arnd

#100 lore raw

Re: [PATCH v6 31/36] dt-bindings: nds32 CPU Bindings

Hi, Arnd:

2018-01-22 19:15 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 42 lines · Greentime Hu
Quoted 22 lines

2018-01-19 23:37 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 12 lines · Greentime Hu
Quoted 7 lines

2018-01-19 23:29 GMT+08:00 Geert Uytterhoeven <[email protected]>:

Quoted 1 line · Greentime Hu

Thank you and your example.
I get it. I will update this document like this.
- compatible: Should be "andestech,<core_name>", "andestech,nds32v3" as fallback.

And please keep a list of supported values of "andestech,<core_name>" in the DT binding document, so checkpatch can validate compatible values.

Thank you for reminding me this.
I will list it like this.

- compatible:
Usage: required
Value type: <string>
Definition: Should be "andestech,<core_name>",
"andestech,nds32v3" as fallback.

Quoted 6 lines
        Examlpes with core_names are:
        "andestech,n13"
        "andestech,n15"
        "andestech,d15"
        "andestech,n10"
        "andestech,d10"

This is still not written as a proper specification, you should not give "examples"
but give a complete list of the available options. You could write it like:

Must contain "andestech,nds32v3" as the most generic value, in addition to one of the following identifiers for a particular CPU core:

         "andestech,n13"
         "andestech,n15"
         "andestech,d15"
         "andestech,n10"
         "andestech,d10"
Quoted 4 lines

It might be helpful to also list all other existing nds32v3 cores, even those that the
current Linux port does not support them.

Thank you for the clear explanation.
I will update it just like you wrote.

#101 lore raw

PATCH v6 32/36 dt-bindings: nds32 L2 cache controller Bindings

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds nds32 L2 cache controller binding documents.

---
 Documentation/devicetree/bindings/nds32/atl2c.txt |   29 +++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/atl2c.txt
Documentation/devicetree/bindings/nds32/atl2c.txt new file +29 -0
new file mode 100644
index 0000000..6b34e04
@@ -0,0 +1,29 @@
+* Andestech L2 cache Controller
+
+The level-2 cache controller plays an important role in reducing memory latency
+for high performance systems, such as thoese designs with AndesCore processors.
+Level-2 cache controller in general enhances overall system performance
+signigicantly and the system power consumption might be reduced as well by
+reducing DRAM accesses.
+
+This binding specifies what properties must be available in the device tree
+representation of an Andestech L2 cache controller.
+
+Required properties:
+	- compatible:
+		Usage: required
+		Value type: <string>
+		Definition: "andestech,atl2c"
+	- reg : Physical base address and size of cache controller's memory mapped
+	- cache-unified : Specifies the cache is a unified cache.
+	- cache-level : Should be set to 2 for a level 2 cache.
+
+* Example
+
+	cache-controller@e0500000 {
+		compatible = "andestech,atl2c";
+		reg = <0xe0500000 0x1000>;
+		cache-unified;
+		cache-level = <2>;
+	};
+
Signature · 1 line
1.7.9.5
#103 lore raw

PATCH v6 33/36 dt-bindings: nds32 SoC Bindings

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds nds32 SoC(AE3XX and AG101P) binding documents.

---
 .../devicetree/bindings/nds32/andestech-boards     |   40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nds32/andestech-boards
Documentation/devicetree/bindings/nds32/andestech-boards new file +40 -0
new file mode 100644
index 0000000..f5d7569
@@ -0,0 +1,40 @@
+Andestech(nds32) AE3XX Platform
+-----------------------------------------------------------------------------
+The AE3XX prototype demonstrates the AE3XX example platform on the FPGA. It
+is composed of one Andestech(nds32) processor and AE3XX.
+
+Required properties (in root node):
+- compatible = "andestech,ae3xx";
+
+Example:
+/dts-v1/;
+/ {
+	compatible = "andestech,ae3xx";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	interrupt-parent = <&intc>;
+};
+
+Andestech(nds32) AG101P Platform
+-----------------------------------------------------------------------------
+AG101P is a generic SoC Platform IP that works with any of Andestech(nds32)
+processors to provide a cost-effective and high performance solution for
+majority of embedded systems in variety of application domains. Users may
+simply attach their IP on one of the system buses together with certain glue
+logics to complete a SoC solution for a specific application. With
+comprehensive simulation and design environments, users may evaluate the
+system performance of their applications and track bugs of their designs
+efficiently. The optional hardware development platform further provides real
+system environment for early prototyping and software/hardware co-development.
+
+Required properties (in root node):
+	compatible = "andestech,ag101p";
+
+Example:
+/dts-v1/;
+/ {
+	compatible = "andestech,ag101p";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	interrupt-parent = <&intc>;
+};
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 33/36
#104 lore raw

Re: [PATCH v6 33/36] dt-bindings: nds32 SoC Bindings

Quoted 6 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds nds32 SoC(AE3XX and AG101P) binding documents.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#105 lore raw

PATCH v6 34/36 dt-bindings: interrupt-controller: Andestech Internal Vector Interrupt Controller

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch adds an irqchip driver document for the Andestech Internal Vector Interrupt Controller.

---
 .../interrupt-controller/andestech,ativic32.txt    |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/andestech,ativic32.txt
Documentation/devicetree/bindings/interrupt-controller/andestech,ativic32.txt new file +19 -0
new file mode 100644
index 0000000..f4b4193
@@ -0,0 +1,19 @@
+* Andestech Internal Vector Interrupt Controller
+
+The Internal Vector Interrupt Controller (IVIC) is a basic interrupt controller
+suitable for a simpler SoC platform not requiring a more sophisticated and
+bigger External Vector Interrupt Controller.
+
+
+Main node required properties:
+
+- compatible : should at least contain  "andestech,ativic32".
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells: 1 cells and refer to interrupt-controller/interrupts
+
+Examples:
+	intc: interrupt-controller {
+		compatible = "andestech,ativic32";
+		#interrupt-cells = <1>;
+		interrupt-controller;
+	};
Signature · 1 line
1.7.9.5
maintainer Acked-by on v6 34/36
#106 lore raw

Re: [PATCH v6 34/36] dt-bindings: interrupt-controller: Andestech Internal Vector Interrupt Controller

Quoted 8 lines · Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds an irqchip driver document for the Andestech Internal Vector Interrupt Controller.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#107 lore raw

PATCH v6 35/36 irqchip: Andestech Internal Vector Interrupt Controller driver

In reply to Greentime Hu

From: Greentime Hu <greentime-MUIXKm3Oiri1Z/[email protected]>

This patch adds the Andestech Internal Vector Interrupt Controller driver. You can find the spec here. Ch4.9 of AndeStar SPA V3 Manual.
http://www.andestech.com/product.php?cls=9

---
 drivers/irqchip/Makefile       |    1 +
 drivers/irqchip/irq-ativic32.c |  107 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
 create mode 100644 drivers/irqchip/irq-ativic32.c
drivers/irqchip/Makefile +1 -0
index b842dfd..201ca9f 100644
@@ -80,3 +80,4 @@ obj-$(CONFIG_ARCH_ASPEED)		+= irq-aspeed-vic.o irq-aspeed-i2c-ic.o
 obj-$(CONFIG_STM32_EXTI) 		+= irq-stm32-exti.o
 obj-$(CONFIG_QCOM_IRQ_COMBINER)		+= qcom-irq-combiner.o
 obj-$(CONFIG_IRQ_UNIPHIER_AIDET)	+= irq-uniphier-aidet.o
+obj-$(CONFIG_NDS32)			+= irq-ativic32.o
drivers/irqchip/irq-ativic32.c new file +107 -0

107 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#108 lore raw

PATCH v6 36/36 net: faraday add nds32 support.

In reply to Greentime Hu

From: Greentime Hu <[email protected]>

This patch is used to support nds32 architecture to use these faraday mac IP.

---
 drivers/net/ethernet/faraday/Kconfig |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/faraday/Kconfig +5 -3
index 040c7f1..0fb8df6 100644
@@ -5,7 +5,7 @@
 config NET_VENDOR_FARADAY
 	bool "Faraday devices"
 	default y
-	depends on ARM
+	depends on ARM || NDS32 || COMPILE_TEST
 	---help---
 	  If you have a network (Ethernet) card belonging to this class, say Y.
 
@@ -18,7 +18,8 @@ if NET_VENDOR_FARADAY
 
 config FTMAC100
 	tristate "Faraday FTMAC100 10/100 Ethernet support"
-	depends on ARM
+	depends on ARM || NDS32 || COMPILE_TEST
+	depends on !64BIT || BROKEN
 	select MII
 	---help---
 	  This driver supports the FTMAC100 10/100 Ethernet controller
@@ -27,7 +28,8 @@ config FTMAC100
 
 config FTGMAC100
 	tristate "Faraday FTGMAC100 Gigabit Ethernet support"
-	depends on ARM
+	depends on ARM || NDS32 || COMPILE_TEST
+	depends on !64BIT || BROKEN
 	select PHYLIB
 	---help---
 	  This driver supports the FTGMAC100 Gigabit Ethernet controller
Signature · 1 line
1.7.9.5
maintainer
#110 lore raw
In reply to Greentime Hu
Quoted 24 lines · Greentime Hu

This is the 6th version patchset to add the Linux kernel port for Andes(nds32) processors. Almost all of the feedbacks from v5 patchseries has been addressed. Thanks to everyone who provided feedback on the previous version.

This patchset adds core architecture support to Linux for Andestech's N13, N15, D15, N10, D10 processor cores.

Based on the 16/32-bit AndeStar RISC-like architecture, we designed the configurable AndesCore series of embedded processor families. AndesCores range from highly performance-efficient small-footprint cores for microcontrollers and deeply-embedded applications to 1GHz+ cores running Linux, covering general-purpose N-series cores for a wide range of computing need, DSP-capable D-series cores for digital signal control, instruction-extensible E-series cores for application-specific acceleration, and secure S-series cores for best protection of the most valuable.

The patches are based on v4.14-rc8, and can also be found in the following git tree:
https://github.com/andestech/linux.git nds32-4.14-rc8-v6

The build script and toolchain repositories are able to be found here:
https://github.com/andestech/build_script.git

Quoted 7 lines

Freely available instruction set and architecture overview documents can be found on the following page:
http://www.andestech.com/product.php?cls=9

Vincent Ren-Wei Chen and I will maintain this port. Thanks to everyone who helped us and contributed to it. :) Any feedback is welcome.

Hi Greentime,

I think it's time to move this to the next step towards inclusion, as you appear to have addressed all major issues, and only smaller details remain.

This is what I'd suggest for moving forward:

- split the patches into two branches in git: one 'next' branch for everything that
is ready to get merged in one pull request that you send to Linus, including drivers that you have received an Ack for from the respective subsystem maintainers, and one 'testing' branch for anything that is either
not quite ready
or that you expect to get merged through someone else's tree (e.g. most device drivers). The 'testing' branch can merge in the 'next' branch or get rebased on it frequently.

- Ask reviewers to send 'Acked-by' or 'Reviewed-by' tags for the patches they are happy with, or to complain if they still see any major issues that should prevent the series from going in. I'll go through the submission once more myself and Ack any patches that I have actually reviewed.

- Decide what base to use for the 'next' branch, rebase it on that release one more time and then plan to never rebase it again. This will be the branch to send to linux-next and to Linus Torvalds. Given the current timing of the merge window, I would suggest to base it on top of v4.16-rc1 once that gets released, and then send it for inclusion in 4.17. Any changes you do in the meantime would be added on top of the original set.

- Ask Stephen Rothwell to include your 'next' branch in linux-next. (if you base on 4.16-rc1, wait until that is out).

- Submit any remaining driver patches that you do not have an 'Ack' for to the respective subsystem maintainers for inclusion in their trees.

- Upload a gpg key (4096 bits) for your [email protected] address to the keyservers, and arrange to have that signed by other kernel developers. You will need to sign git tags for pull requests with your key, and the key itself should be signed for this to work best.

- Once you have at least three signatures on your gpg key, apply for an account on kernel.org and move your git tree there, see https://www.kernel.org/category/faq.html. Alternatively, host the git tree on a web-facing git server from andestech.com (github works initially, but has a couple of shortcomings).

Arnd