Skip to contentSkip to conversation

Synopsys ARC Linux kernel Port

RFC PATCH In review Vineet Gupta 10 participants 107 messages Nov 7, 2012 – Mar 11, 2013

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

cover Synopsys ARC Linux kernel Port

Hi,

This patchset based off-of 3.7-rc3, introduces the Linux kernel port to ARC700 processor family (750D and 770D) from Synopsys.

ARC700 is highly configurable and power efficient 32-bit RISC core with MMU. It is embedded in SoCs deployed in TV Set Top boxes, Digital Media Players, all the way to Network-on-Chips.

More information is available @
http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/Pages/default.aspx

This series is part #1 of the entire port - just enough to build the kernel and bring up a Busybox shell on console (on ARCAngel4 FPGA ref platform) The console driver has already been accepted/merged into tty-next tree for 3.8

The part #2 series containing additional features ptrace/SMP/perf/OProfile.. will follow as we move along the review cycle. It has been withheld just to make it easier for reviewers.

The entire series however is available at
git://github.com/foss-for-synopsys-dwc-arc-processors/linux.git arc-3.7-rc3

The GNU tool-chain, based off of gcc 4.4 + uClibc 0.9.30.3 is also available from github. Please refer to Readme.md in "toolchain" repository also in same hierarchy as kernel above.

We are already working on a buildroot based distro, to be made available soon.

More info about the kernel port can also be found in the ELCE-Barclone '12 talk on same topic.

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

P.S. Despite 3.7 based, we are still short of the UAPI split for arch headers. That is also being worked upon with help from David. That will show up in v2 of the patchseries.

Thx,
-Vineet

Vineet Gupta (31):
ARC: Generic Headers
ARC: irqflags
ARC: atomic/bitops/cmpxchg/barriers
asm-generic headers: uaccess.h to conditionally define segment_eq()
ARC: uaccess friends
asm-generic headers: Allow yet more arch overrides in checksum.h
ARC: checksum/byteorder/swab routines
ARC: Fundamental ARCH data-types/defines
ARC: spinlock/rwlock/mutex primitives
ARC: string library
ARC: Low level IRQ/Trap/Exception(non-MMU) Handling
ARC: Interrupt Handling
ARC: Non-MMU Exception Handling
ARC: syscall support
ARC: Process/scheduling/clock/Timers/Delay Management
ARC: Signal handling
ARC: Cache Flush Management
ARC: Page Table Management
ARC: MMU Context Management
ARC: MMU Exception Handling
ARC: TLB flush Handling
ARC: Page Fault handling (incl uaccess fixup)
ARC: I/O and DMA Mappings
ARC: startup #1: low-level, setup_arch(), /proc/cpuinfo, mem init
ARC: [plat-arcfpga] Hooking up platform to ARC UART
ARC: Build system: Makefiles, Kconfig, Linker script
ARC: Last bits (stubs) to get to a running kernel with UART
ARC: split ret_from_fork, simplify kernel_thread()
ARC: switch to generic kernel_thread()
ARC: switch to generic kernel_execve() and sys_execve()
ARC: [plat-arcfpga] defconfig

 arch/arc/Kbuild                               |    2 +
 arch/arc/Kconfig                              |  338 ++++++++++
 arch/arc/Kconfig.debug                        |   34 +
 arch/arc/Makefile                             |  115 ++++
 arch/arc/boot/Makefile                        |   27 +
 arch/arc/configs/fpga_defconfig               |  607 ++++++++++++++++++
 arch/arc/include/asm/Kbuild                   |   58 ++
 arch/arc/include/asm/arcregs.h                |  330 ++++++++++
 arch/arc/include/asm/asm-offsets.h            |    9 +
 arch/arc/include/asm/atomic.h                 |  232 +++++++
 arch/arc/include/asm/barrier.h                |   42 ++
 arch/arc/include/asm/bitops.h                 |  507 +++++++++++++++
 arch/arc/include/asm/bug.h                    |   37 ++
 arch/arc/include/asm/byteorder.h              |   18 +
 arch/arc/include/asm/cache.h                  |   75 +++
 arch/arc/include/asm/cachectl.h               |   30 +
 arch/arc/include/asm/cacheflush.h             |   67 ++
 arch/arc/include/asm/checksum.h               |  101 +++
 arch/arc/include/asm/cmpxchg.h                |  143 +++++
 arch/arc/include/asm/delay.h                  |   68 ++
 arch/arc/include/asm/dma-mapping.h            |  176 ++++++
 arch/arc/include/asm/dma.h                    |   14 +
 arch/arc/include/asm/elf.h                    |   97 +++
 arch/arc/include/asm/entry.h                  |  495 +++++++++++++++
 arch/arc/include/asm/exec.h                   |   15 +
 arch/arc/include/asm/io.h                     |   26 +
 arch/arc/include/asm/irq.h                    |   26 +
 arch/arc/include/asm/irqflags.h               |  143 +++++
 arch/arc/include/asm/kdebug.h                 |   19 +
 arch/arc/include/asm/linkage.h                |   30 +
 arch/arc/include/asm/mmu.h                    |   23 +
 arch/arc/include/asm/mmu_context.h            |  209 ++++++
 arch/arc/include/asm/module.h                 |   17 +
 arch/arc/include/asm/mutex.h                  |    9 +
 arch/arc/include/asm/page.h                   |  134 ++++
 arch/arc/include/asm/pgalloc.h                |  134 ++++
 arch/arc/include/asm/pgtable.h                |  401 ++++++++++++
 arch/arc/include/asm/processor.h              |  146 +++++
 arch/arc/include/asm/ptrace.h                 |  133 ++++
 arch/arc/include/asm/sections.h               |   17 +
 arch/arc/include/asm/segment.h                |   24 +
 arch/arc/include/asm/setup.h                  |   22 +
 arch/arc/include/asm/sigcontext.h             |   23 +
 arch/arc/include/asm/signal.h                 |   27 +
 arch/arc/include/asm/smp.h                    |   34 +
 arch/arc/include/asm/spinlock.h               |  144 +++++
 arch/arc/include/asm/spinlock_types.h         |   35 +
 arch/arc/include/asm/string.h                 |   40 ++
 arch/arc/include/asm/swab.h                   |   99 +++
 arch/arc/include/asm/switch_to.h              |   41 ++
 arch/arc/include/asm/syscall.h                |   72 +++
 arch/arc/include/asm/syscalls.h               |   30 +
 arch/arc/include/asm/thread_info.h            |  120 ++++
 arch/arc/include/asm/timex.h                  |   18 +
 arch/arc/include/asm/tlb-mmu1.h               |  104 +++
 arch/arc/include/asm/tlb.h                    |   58 ++
 arch/arc/include/asm/tlbflush.h               |   28 +
 arch/arc/include/asm/uaccess.h                |  605 ++++++++++++++++++
 arch/arc/include/asm/unistd.h                 |   46 ++
 arch/arc/include/asm/vmlinux.lds.h            |   12 +
 arch/arc/kernel/Makefile                      |   16 +
 arch/arc/kernel/arcksyms.c                    |   56 ++
 arch/arc/kernel/asm-offsets.c                 |   46 ++
 arch/arc/kernel/ctx_sw.c                      |   91 +++
 arch/arc/kernel/ctx_sw_asm.S                  |   58 ++
 arch/arc/kernel/entry.S                       |  635 +++++++++++++++++++
 arch/arc/kernel/fpu.c                         |   55 ++
 arch/arc/kernel/head.S                        |   78 +++
 arch/arc/kernel/irq.c                         |  107 ++++
 arch/arc/kernel/process.c                     |  259 ++++++++
 arch/arc/kernel/ptrace.c                      |   26 +
 arch/arc/kernel/reset.c                       |   33 +
 arch/arc/kernel/setup.c                       |  166 +++++
 arch/arc/kernel/signal.c                      |  360 +++++++++++
 arch/arc/kernel/stacktrace.c                  |   43 ++
 arch/arc/kernel/sys.c                         |   18 +
 arch/arc/kernel/time.c                        |  237 +++++++
 arch/arc/kernel/traps.c                       |  125 ++++
 arch/arc/kernel/troubleshoot.c                |   17 +
 arch/arc/kernel/vmlinux.lds.S                 |  117 ++++
 arch/arc/lib/Makefile                         |    9 +
 arch/arc/lib/memcmp.S                         |  124 ++++
 arch/arc/lib/memcpy-700.S                     |   66 ++
 arch/arc/lib/memset.S                         |   59 ++
 arch/arc/lib/strchr-700.S                     |  123 ++++
 arch/arc/lib/strcmp.S                         |   96 +++
 arch/arc/lib/strcpy-700.S                     |   70 ++
 arch/arc/lib/strlen.S                         |   83 +++
 arch/arc/mm/Makefile                          |   10 +
 arch/arc/mm/cache_arc700.c                    |  838 +++++++++++++++++++++++++
 arch/arc/mm/dma.c                             |   91 +++
 arch/arc/mm/extable.c                         |   26 +
 arch/arc/mm/fault.c                           |  228 +++++++
 arch/arc/mm/init.c                            |  185 ++++++
 arch/arc/mm/ioremap.c                         |   62 ++
 arch/arc/mm/mmap.c                            |   21 +
 arch/arc/mm/tlb.c                             |  586 +++++++++++++++++
 arch/arc/mm/tlbex.S                           |  351 +++++++++++
 arch/arc/plat-arcfpga/Kconfig                 |   33 +
 arch/arc/plat-arcfpga/Makefile                |    9 +
 arch/arc/plat-arcfpga/include/plat/dma_addr.h |   45 ++
 arch/arc/plat-arcfpga/include/plat/irq.h      |   27 +
 arch/arc/plat-arcfpga/include/plat/memmap.h   |   31 +
 arch/arc/plat-arcfpga/irq.c                   |   41 ++
 arch/arc/plat-arcfpga/platform.c              |  134 ++++
 include/asm-generic/checksum.h                |    4 +
 include/asm-generic/uaccess.h                 |    3 +-
 lib/checksum.c                                |    2 +
 108 files changed, 12585 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/Kbuild
 create mode 100644 arch/arc/Kconfig
 create mode 100644 arch/arc/Kconfig.debug
 create mode 100644 arch/arc/Makefile
 create mode 100644 arch/arc/boot/Makefile
 create mode 100644 arch/arc/configs/fpga_defconfig
 create mode 100644 arch/arc/include/asm/Kbuild
 create mode 100644 arch/arc/include/asm/arcregs.h
 create mode 100644 arch/arc/include/asm/asm-offsets.h
 create mode 100644 arch/arc/include/asm/atomic.h
 create mode 100644 arch/arc/include/asm/barrier.h
 create mode 100644 arch/arc/include/asm/bitops.h
 create mode 100644 arch/arc/include/asm/bug.h
 create mode 100644 arch/arc/include/asm/byteorder.h
 create mode 100644 arch/arc/include/asm/cache.h
 create mode 100644 arch/arc/include/asm/cachectl.h
 create mode 100644 arch/arc/include/asm/cacheflush.h
 create mode 100644 arch/arc/include/asm/checksum.h
 create mode 100644 arch/arc/include/asm/cmpxchg.h
 create mode 100644 arch/arc/include/asm/delay.h
 create mode 100644 arch/arc/include/asm/dma-mapping.h
 create mode 100644 arch/arc/include/asm/dma.h
 create mode 100644 arch/arc/include/asm/elf.h
 create mode 100644 arch/arc/include/asm/entry.h
 create mode 100644 arch/arc/include/asm/exec.h
 create mode 100644 arch/arc/include/asm/io.h
 create mode 100644 arch/arc/include/asm/irq.h
 create mode 100644 arch/arc/include/asm/irqflags.h
 create mode 100644 arch/arc/include/asm/kdebug.h
 create mode 100644 arch/arc/include/asm/linkage.h
 create mode 100644 arch/arc/include/asm/mmu.h
 create mode 100644 arch/arc/include/asm/mmu_context.h
 create mode 100644 arch/arc/include/asm/module.h
 create mode 100644 arch/arc/include/asm/mutex.h
 create mode 100644 arch/arc/include/asm/page.h
 create mode 100644 arch/arc/include/asm/pgalloc.h
 create mode 100644 arch/arc/include/asm/pgtable.h
 create mode 100644 arch/arc/include/asm/processor.h
 create mode 100644 arch/arc/include/asm/ptrace.h
 create mode 100644 arch/arc/include/asm/sections.h
 create mode 100644 arch/arc/include/asm/segment.h
 create mode 100644 arch/arc/include/asm/setup.h
 create mode 100644 arch/arc/include/asm/sigcontext.h
 create mode 100644 arch/arc/include/asm/signal.h
 create mode 100644 arch/arc/include/asm/smp.h
 create mode 100644 arch/arc/include/asm/spinlock.h
 create mode 100644 arch/arc/include/asm/spinlock_types.h
 create mode 100644 arch/arc/include/asm/string.h
 create mode 100644 arch/arc/include/asm/swab.h
 create mode 100644 arch/arc/include/asm/switch_to.h
 create mode 100644 arch/arc/include/asm/syscall.h
 create mode 100644 arch/arc/include/asm/syscalls.h
 create mode 100644 arch/arc/include/asm/thread_info.h
 create mode 100644 arch/arc/include/asm/timex.h
 create mode 100644 arch/arc/include/asm/tlb-mmu1.h
 create mode 100644 arch/arc/include/asm/tlb.h
 create mode 100644 arch/arc/include/asm/tlbflush.h
 create mode 100644 arch/arc/include/asm/uaccess.h
 create mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/include/asm/vmlinux.lds.h
 create mode 100644 arch/arc/kernel/Makefile
 create mode 100644 arch/arc/kernel/arcksyms.c
 create mode 100644 arch/arc/kernel/asm-offsets.c
 create mode 100644 arch/arc/kernel/ctx_sw.c
 create mode 100644 arch/arc/kernel/ctx_sw_asm.S
 create mode 100644 arch/arc/kernel/entry.S
 create mode 100644 arch/arc/kernel/fpu.c
 create mode 100644 arch/arc/kernel/head.S
 create mode 100644 arch/arc/kernel/irq.c
 create mode 100644 arch/arc/kernel/process.c
 create mode 100644 arch/arc/kernel/ptrace.c
 create mode 100644 arch/arc/kernel/reset.c
 create mode 100644 arch/arc/kernel/setup.c
 create mode 100644 arch/arc/kernel/signal.c
 create mode 100644 arch/arc/kernel/stacktrace.c
 create mode 100644 arch/arc/kernel/sys.c
 create mode 100644 arch/arc/kernel/time.c
 create mode 100644 arch/arc/kernel/traps.c
 create mode 100644 arch/arc/kernel/troubleshoot.c
 create mode 100644 arch/arc/kernel/vmlinux.lds.S
 create mode 100644 arch/arc/lib/Makefile
 create mode 100644 arch/arc/lib/memcmp.S
 create mode 100644 arch/arc/lib/memcpy-700.S
 create mode 100644 arch/arc/lib/memset.S
 create mode 100644 arch/arc/lib/strchr-700.S
 create mode 100644 arch/arc/lib/strcmp.S
 create mode 100644 arch/arc/lib/strcpy-700.S
 create mode 100644 arch/arc/lib/strlen.S
 create mode 100644 arch/arc/mm/Makefile
 create mode 100644 arch/arc/mm/cache_arc700.c
 create mode 100644 arch/arc/mm/dma.c
 create mode 100644 arch/arc/mm/extable.c
 create mode 100644 arch/arc/mm/fault.c
 create mode 100644 arch/arc/mm/init.c
 create mode 100644 arch/arc/mm/ioremap.c
 create mode 100644 arch/arc/mm/mmap.c
 create mode 100644 arch/arc/mm/tlb.c
 create mode 100644 arch/arc/mm/tlbex.S
 create mode 100644 arch/arc/plat-arcfpga/Kconfig
 create mode 100644 arch/arc/plat-arcfpga/Makefile
 create mode 100644 arch/arc/plat-arcfpga/include/plat/dma_addr.h
 create mode 100644 arch/arc/plat-arcfpga/include/plat/irq.h
 create mode 100644 arch/arc/plat-arcfpga/include/plat/memmap.h
 create mode 100644 arch/arc/plat-arcfpga/irq.c
 create mode 100644 arch/arc/plat-arcfpga/platform.c
Signature · 1 line
1.7.4.1
#1 lore raw

RFC PATCH 1/31 ARC: Generic Headers

---
 arch/arc/include/asm/Kbuild        |   57 ++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/asm-offsets.h |    9 ++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/Kbuild
 create mode 100644 arch/arc/include/asm/asm-offsets.h
arch/arc/include/asm/Kbuild new file +57 -0
new file mode 100644
index 0000000..d6c037a
@@ -0,0 +1,57 @@
+include include/asm-generic/Kbuild.asm
+
+# 7-Oct-12: Jeremy Bennett <[email protected]>. Some of these
+# headers, beyond those specified in the generic set are needed by user code.
+
+header-y += page.h
+header-y += cachectl.h
+
+generic-y += auxvec.h
+generic-y += bugs.h
+generic-y += bitsperlong.h
+generic-y += clkdev.h
+generic-y += cputime.h
+generic-y += current.h
+generic-y += device.h
+generic-y += div64.h
+generic-y += emergency-restart.h
+generic-y += errno.h
+generic-y += fcntl.h
+generic-y += fb.h
+generic-y += ftrace.h
+generic-y += hardirq.h
+generic-y += hw_irq.h
+generic-y += ioctl.h
+generic-y += ioctls.h
+generic-y += ipcbuf.h
+generic-y += irq_regs.h
+generic-y += kmap_types.h
+generic-y += kvm_para.h
+generic-y += local.h
+generic-y += local64.h
+generic-y += mman.h
+generic-y += msgbuf.h
+generic-y += param.h
+generic-y += parport.h
+generic-y += percpu.h
+generic-y += poll.h
+generic-y += posix_types.h
+generic-y += resource.h
+generic-y += scatterlist.h
+generic-y += sembuf.h
+generic-y += shmbuf.h
+generic-y += shmparam.h
+generic-y += siginfo.h
+generic-y += socket.h
+generic-y += sockios.h
+generic-y += stat.h
+generic-y += statfs.h
+generic-y += termbits.h
+generic-y += termios.h
+generic-y += topology.h
+generic-y += types.h
+generic-y += ucontext.h
+generic-y += unaligned.h
+generic-y += user.h
+generic-y += vga.h
+generic-y += xor.h
arch/arc/include/asm/asm-offsets.h new file +9 -0
new file mode 100644
index 0000000..dad1876
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <generated/asm-offsets.h>
Signature · 1 line
1.7.4.1
#2 lore raw

RFC PATCH 2/31 ARC: irqflags

In reply to Vineet Gupta
---
 arch/arc/include/asm/arcregs.h  |  114 +++++++++++++++++++++++++++++++
 arch/arc/include/asm/irqflags.h |  143 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/irq.c           |   32 +++++++++
 3 files changed, 289 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/arcregs.h
 create mode 100644 arch/arc/include/asm/irqflags.h
 create mode 100644 arch/arc/kernel/irq.c
arch/arc/include/asm/arcregs.h new file +114 -0
new file mode 100644
index 0000000..8ca8faf
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_ARCREGS_H
+#define _ASM_ARC_ARCREGS_H
+
+#ifdef __KERNEL__
+
+/* status32 Bits Positions */
+#define STATUS_H_BIT		0	/* CPU Halted */
+#define STATUS_E1_BIT		1	/* Int 1 enable */
+#define STATUS_E2_BIT		2	/* Int 2 enable */
+#define STATUS_A1_BIT		3	/* Int 1 active */
+#define STATUS_A2_BIT		4	/* Int 2 active */
+#define STATUS_AE_BIT		5	/* Exception active */
+#define STATUS_DE_BIT		6	/* PC is in delay slot */
+#define STATUS_U_BIT		7	/* User/Kernel mode */
+#define STATUS_L_BIT		12	/* Loop inhibit */
+
+/* These masks correspond to the status word(STATUS_32) bits */
+#define STATUS_H_MASK		(1<<STATUS_H_BIT)
+#define STATUS_E1_MASK		(1<<STATUS_E1_BIT)
+#define STATUS_E2_MASK		(1<<STATUS_E2_BIT)
+#define STATUS_A1_MASK		(1<<STATUS_A1_BIT)
+#define STATUS_A2_MASK		(1<<STATUS_A2_BIT)
+#define STATUS_AE_MASK		(1<<STATUS_AE_BIT)
+#define STATUS_DE_MASK		(1<<STATUS_DE_BIT)
+#define STATUS_U_MASK		(1<<STATUS_U_BIT)
+#define STATUS_L_MASK		(1<<STATUS_L_BIT)
+
+/* Auxiliary registers */
+#define AUX_IDENTITY		4
+#define AUX_INTR_VEC_BASE	0x25
+#define AUX_IRQ_LEV		0x200	/* IRQ Priority: L1 or L2 */
+#define AUX_IRQ_HINT		0x201	/* For generating Soft Interrupts */
+#define AUX_IRQ_LV12		0x43	/* interrupt level register */
+
+#define AUX_IENABLE		0x40c
+#define AUX_ITRIGGER		0x40d
+#define AUX_IPULSE		0x415
+
+#ifndef __ASSEMBLY__
+
+/*
+ ******************************************************************
+ *      Inline ASM macros to read/write AUX Regs
+ *      Essentially invocation of lr/sr insns from "C"
+ */
+
+#if 1
+
+#define read_aux_reg(reg)	__builtin_arc_lr(reg)
+
+/* gcc builtin sr needs reg param to be long immediate */
+#define write_aux_reg(reg_immed, val)		\
+		__builtin_arc_sr((unsigned int)val, reg_immed)
+
+#else
+
+#define read_aux_reg(reg)		\
+({					\
+	unsigned int __ret;		\
+	__asm__ __volatile__(		\
+	"	lr    %0, [%1]"		\
+	: "=r"(__ret)			\
+	: "i"(reg));			\
+	__ret;				\
+})
+
+/*
+ * Aux Reg address is specified as long immediate by caller
+ * e.g.
+ *    write_aux_reg(0x69, some_val);
+ * This generates tightest code.
+ */
+#define write_aux_reg(reg_imm, val)	\
+({					\
+	__asm__ __volatile__(		\
+	"	sr   %0, [%1]	\n"	\
+	:				\
+	: "ir"(val), "i"(reg_imm));	\
+})
+
+/*
+ * Aux Reg address is specified in a variable
+ *  * e.g.
+ *      reg_num = 0x69
+ *      write_aux_reg2(reg_num, some_val);
+ * This has to generate glue code to load the reg num from
+ *  memory to a reg hence not recommended.
+ */
+#define write_aux_reg2(reg_in_var, val)		\
+({						\
+	unsigned int tmp;			\
+						\
+	__asm__ __volatile__(			\
+	"	ld   %0, [%2]	\n\t"		\
+	"	sr   %1, [%0]	\n\t"		\
+	: "=&r"(tmp)				\
+	: "r"(val), "memory"(&reg_in_var));	\
+})
+
+#endif
+
+#endif /* __ASEMBLY__ */
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_ARC_ARCREGS_H */
arch/arc/include/asm/irqflags.h new file +143 -0

143 lines not on this page · raw message

arch/arc/kernel/irq.c new file +32 -0
new file mode 100644
index 0000000..16fcbe8
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-12 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <asm/irqflags.h>
+#include <asm/arcregs.h>
+
+void arch_local_irq_enable(void)
+{
+
+	unsigned long flags;
+	flags = arch_local_save_flags();
+	flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
+
+	/*
+	 * If called from hard ISR (between irq_enter and irq_exit)
+	 * don't allow Level 1. In Soft ISR we allow further Level 1s
+	 */
+
+	if (in_irq())
+		flags &= ~(STATUS_E1_MASK | STATUS_E2_MASK);
+
+	arch_local_irq_restore(flags);
+}
+EXPORT_SYMBOL(arch_local_irq_enable);
Signature · 1 line
1.7.4.1
#5 lore raw

RFC PATCH 3/31 ARC: atomic/bitops/cmpxchg/barriers

In reply to Vineet Gupta

This covers the UP / SMP (with no hardware assist for atomic r-m-w) as well as ARC700 LLOCK/SCOND insns based.

---
 arch/arc/include/asm/atomic.h  |  232 ++++++++++++++++++
 arch/arc/include/asm/barrier.h |   42 ++++
 arch/arc/include/asm/bitops.h  |  507 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/cmpxchg.h |  143 +++++++++++
 arch/arc/include/asm/smp.h     |   34 +++
 5 files changed, 958 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/atomic.h
 create mode 100644 arch/arc/include/asm/barrier.h
 create mode 100644 arch/arc/include/asm/bitops.h
 create mode 100644 arch/arc/include/asm/cmpxchg.h
 create mode 100644 arch/arc/include/asm/smp.h
arch/arc/include/asm/atomic.h new file +232 -0
new file mode 100644
index 0000000..543d496
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_ATOMIC_H
+#define _ASM_ARC_ATOMIC_H
+
+#if defined(__KERNEL__)
+
+#if !defined(__ASSEMBLY__)
+
+#include <linux/types.h>
+#include <linux/compiler.h>
+#include <asm/cmpxchg.h>
+#include <asm/barrier.h>
+#include <asm/smp.h>
+
+#define atomic_read(v)  ((v)->counter)
+
+#ifdef CONFIG_ARC_HAS_LLSC
+
+#define atomic_set(v, i) (((v)->counter) = (i))
+
+static inline void atomic_add(int i, atomic_t *v)
+{
+	unsigned int temp;
+
+	__asm__ __volatile__(
+	"1:	llock   %0, [%1]	\n"
+	"	add     %0, %0, %2	\n"
+	"	scond   %0, [%1]	\n"
+	"	bnz     1b		\n"
+	: "=&r"(temp)	/* Early clobber, to prevent reg reuse */
+	: "r"(&v->counter), "ir"(i)
+	: "cc");
+}
+
+static inline void atomic_sub(int i, atomic_t *v)
+{
+	unsigned int temp;
+
+	__asm__ __volatile__(
+	"1:	llock   %0, [%1]	\n"
+	"	sub     %0, %0, %2	\n"
+	"	scond   %0, [%1]	\n"
+	"	bnz     1b		\n"
+	: "=&r"(temp)
+	: "r"(&v->counter), "ir"(i)
+	: "cc");
+}
+
+/* add and also return the new value */
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+	unsigned int temp;
+
+	__asm__ __volatile__(
+	"1:	llock   %0, [%1]	\n"
+	"	add     %0, %0, %2	\n"
+	"	scond   %0, [%1]	\n"
+	"	bnz     1b		\n"
+	: "=&r"(temp)
+	: "r"(&v->counter), "ir"(i)
+	: "cc");
+
+	return temp;
+}
+
+static inline int atomic_sub_return(int i, atomic_t *v)
+{
+	unsigned int temp;
+
+	__asm__ __volatile__(
+	"1:	llock   %0, [%1]	\n"
+	"	sub     %0, %0, %2	\n"
+	"	scond   %0, [%1]	\n"
+	"	bnz     1b		\n"
+	: "=&r"(temp)
+	: "r"(&v->counter), "ir"(i)
+	: "cc");
+
+	return temp;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+	unsigned int temp;
+
+	__asm__ __volatile__(
+	"1:	llock   %0, [%1]	\n"
+	"	bic     %0, %0, %2	\n"
+	"	scond   %0, [%1]	\n"
+	"	bnz     1b		\n"
+	: "=&r"(temp)
+	: "r"(addr), "ir"(mask)
+	: "cc");
+}
+
+#else	/* !CONFIG_ARC_HAS_LLSC */
+
+#ifndef CONFIG_SMP
+
+ /* violating atomic_xxx API locking protocol in UP for optimization sake */
+#define atomic_set(v, i) (((v)->counter) = (i))
+
+#else
+
+static inline void atomic_set(atomic_t *v, int i)
+{
+	/*
+	 * Independent of hardware support, all of the atomic_xxx() APIs need
+	 * to follow the same locking rules to make sure that a "hardware"
+	 * atomic insn (e.g. LD) doesn't clobber an "emulated" atomic insn
+	 * sequence
+	 *
+	 * Thus atomic_set() despite being 1 insn (and seemingly atomic)
+	 * requires the locking.
+	 */
+	unsigned long flags;
+
+	atomic_ops_lock(flags);
+	v->counter = i;
+	atomic_ops_unlock(flags);
+}
+#endif
+
+/*
+ * Non hardware assisted Atomic-R-M-W
+ * Locking would change to irq-disabling only (UP) and spinlocks (SMP)
+ */
+
+static inline void atomic_add(int i, atomic_t *v)
+{
+	unsigned long flags;
+
+	atomic_ops_lock(flags);
+	v->counter += i;
+	atomic_ops_unlock(flags);
+}
+
+static inline void atomic_sub(int i, atomic_t *v)
+{
+	unsigned long flags;
+
+	atomic_ops_lock(flags);
+	v->counter -= i;
+	atomic_ops_unlock(flags);
+}
+
+static inline int atomic_add_return(int i, atomic_t *v)
+{
+	unsigned long flags;
+	unsigned long temp;
+
+	atomic_ops_lock(flags);
+	temp = v->counter;
+	temp += i;
+	v->counter = temp;
+	atomic_ops_unlock(flags);
+
+	return temp;
+}
+
+static inline int atomic_sub_return(int i, atomic_t *v)
+{
+	unsigned long flags;
+	unsigned long temp;
+
+	atomic_ops_lock(flags);
+	temp = v->counter;
+	temp -= i;
+	v->counter = temp;
+	atomic_ops_unlock(flags);
+
+	return temp;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+	unsigned long flags;
+
+	atomic_ops_lock(flags);
+	*addr &= ~mask;
+	atomic_ops_unlock(flags);
+}
+
+#endif /* !CONFIG_ARC_HAS_LLSC */
+
+/**
+ * __atomic_add_unless - add unless the number is a given value
+ * @v: pointer of type atomic_t
+ * @a: the amount to add to v...
+ * @u: ...unless v is equal to u.
+ *
+ * Atomically adds @a to @v, so long as it was not @u.
+ * Returns the old value of @v
+ */
+#define __atomic_add_unless(v, a, u)					\
+({									\
+	int c, old;							\
+	c = atomic_read(v);						\
+	while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c)\
+		c = old;						\
+	c;								\
+})
+
+#define atomic_inc_not_zero(v)		atomic_add_unless((v), 1, 0)
+
+#define atomic_inc(v)			atomic_add(1, v)
+#define atomic_dec(v)			atomic_sub(1, v)
+
+#define atomic_inc_and_test(v)		(atomic_add_return(1, v) == 0)
+#define atomic_dec_and_test(v)		(atomic_sub_return(1, v) == 0)
+#define atomic_inc_return(v)		atomic_add_return(1, (v))
+#define atomic_dec_return(v)		atomic_sub_return(1, (v))
+#define atomic_sub_and_test(i, v)	(atomic_sub_return(i, v) == 0)
+
+#define atomic_add_negative(i, v)	(atomic_add_return(i, v) < 0)
+
+#define ATOMIC_INIT(i)			{ (i) }
+
+#include <asm-generic/atomic64.h>
+
+#endif
+
+#endif
+
+#endif
arch/arc/include/asm/barrier.h new file +42 -0

42 lines not on this page · raw message

arch/arc/include/asm/bitops.h new file +507 -0

507 lines not on this page · raw message

arch/arc/include/asm/cmpxchg.h new file +143 -0

143 lines not on this page · raw message

arch/arc/include/asm/smp.h new file +34 -0
new file mode 100644
index 0000000..4341f3b
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_SMP_H
+#define __ASM_ARC_SMP_H
+
+/*
+ * ARC700 doesn't support atomic Read-Modify-Write ops.
+ * Originally Interrupts had to be disabled around code to gaurantee atomicity.
+ * The LLOCK/SCOND insns allow writing interrupt-hassle-free based atomic ops
+ * based on retry-if-irq-in-atomic (with hardware assist).
+ * However despite these, we provide the IRQ disabling variant
+ *
+ * (1) These insn were introduced only in 4.10 release. So for older released
+ *	support needed.
+ */
+#ifndef CONFIG_ARC_HAS_LLSC
+
+#include <linux/irqflags.h>
+
+#define atomic_ops_lock(flags)		local_irq_save(flags)
+#define atomic_ops_unlock(flags)	local_irq_restore(flags)
+
+#define bitops_lock(flags)		local_irq_save(flags)
+#define bitops_unlock(flags)		local_irq_restore(flags)
+
+#endif	/* !CONFIG_ARC_HAS_LLSC */
+
+#endif
Signature · 1 line
1.7.4.1
#6 lore raw

RFC PATCH 4/31 asm-generic headers: uaccess.h to conditionally define segment_eq()

In reply to Vineet Gupta

This is because mm_segment_t is exported by arch code, while seqment_eq assumes it will have .seg element.

---
 include/asm-generic/uaccess.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/asm-generic/uaccess.h +2 -1
index 9788568..5f6ee61 100644
@@ -7,7 +7,6 @@
  * address space, e.g. all NOMMU machines.
  */
 #include <linux/sched.h>
-#include <linux/mm.h>
 #include <linux/string.h>
 
 #include <asm/segment.h>
@@ -32,7 +31,9 @@ static inline void set_fs(mm_segment_t fs)
 }
 #endif
 
+#ifndef segment_eq
 #define segment_eq(a, b) ((a).seg == (b).seg)
+#endif
 
 #define VERIFY_READ	0
 #define VERIFY_WRITE	1
Signature · 1 line
1.7.4.1
#8 lore raw

RFC PATCH 6/31 asm-generic headers: Allow yet more arch overrides in checksum.h

In reply to Vineet Gupta

arches can have more efficient implementation of these routines

---
 include/asm-generic/checksum.h |    4 ++++
 lib/checksum.c                 |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
include/asm-generic/checksum.h +4 -0
index c084767..59811df 100644
@@ -38,12 +38,15 @@ extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
 	csum_partial_copy((src), (dst), (len), (sum))
 #endif
 
+#ifndef ip_fast_csum
 /*
  * This is a version of ip_compute_csum() optimized for IP headers,
  * which always checksum on 4 octet boundaries.
  */
 extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+#endif
 
+#ifndef csum_fold
 /*
  * Fold a partial checksum
  */
@@ -54,6 +57,7 @@ static inline __sum16 csum_fold(__wsum csum)
 	sum = (sum & 0xffff) + (sum >> 16);
 	return (__force __sum16)~sum;
 }
+#endif
 
 #ifndef csum_tcpudp_nofold
 /*
lib/checksum.c +2 -0
index 12dceb2..129775e 100644
@@ -102,6 +102,7 @@ out:
 }
 #endif
 
+#ifndef ip_fast_csum
 /*
  *	This is a version of ip_compute_csum() optimized for IP headers,
  *	which always checksum on 4 octet boundaries.
@@ -111,6 +112,7 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
 	return (__force __sum16)~do_csum(iph, ihl*4);
 }
 EXPORT_SYMBOL(ip_fast_csum);
+#endif
 
 /*
  * computes the checksum of a memory block at buff, length len,
Signature · 1 line
1.7.4.1
#9 lore raw

RFC PATCH 7/31 ARC: checksum/byteorder/swab routines

In reply to Vineet Gupta

TBD: do_csum still needs to be written in asm

---
 arch/arc/include/asm/byteorder.h |   18 +++++++
 arch/arc/include/asm/checksum.h  |  101 ++++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/swab.h      |   99 +++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/byteorder.h
 create mode 100644 arch/arc/include/asm/checksum.h
 create mode 100644 arch/arc/include/asm/swab.h
arch/arc/include/asm/byteorder.h new file +18 -0
new file mode 100644
index 0000000..9da71d4
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_BYTEORDER_H
+#define __ASM_ARC_BYTEORDER_H
+
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#include <linux/byteorder/big_endian.h>
+#else
+#include <linux/byteorder/little_endian.h>
+#endif
+
+#endif /* ASM_ARC_BYTEORDER_H */
arch/arc/include/asm/checksum.h new file +101 -0

101 lines not on this page · raw message

arch/arc/include/asm/swab.h new file +99 -0

99 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#10 lore raw

RFC PATCH 8/31 ARC: Fundamental ARCH data-types/defines

In reply to Vineet Gupta

* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*

---
 arch/arc/include/asm/bug.h         |   37 +++++++++
 arch/arc/include/asm/cache.h       |   21 +++++
 arch/arc/include/asm/elf.h         |   97 ++++++++++++++++++++++++
 arch/arc/include/asm/exec.h        |   15 ++++
 arch/arc/include/asm/kdebug.h      |   19 +++++
 arch/arc/include/asm/linkage.h     |   30 ++++++++
 arch/arc/include/asm/module.h      |   17 ++++
 arch/arc/include/asm/page.h        |   42 +++++++++++
 arch/arc/include/asm/processor.h   |  143 ++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/ptrace.h      |  120 ++++++++++++++++++++++++++++++
 arch/arc/include/asm/sections.h    |   17 ++++
 arch/arc/include/asm/thread_info.h |  120 ++++++++++++++++++++++++++++++
 12 files changed, 678 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/bug.h
 create mode 100644 arch/arc/include/asm/cache.h
 create mode 100644 arch/arc/include/asm/elf.h
 create mode 100644 arch/arc/include/asm/exec.h
 create mode 100644 arch/arc/include/asm/kdebug.h
 create mode 100644 arch/arc/include/asm/linkage.h
 create mode 100644 arch/arc/include/asm/module.h
 create mode 100644 arch/arc/include/asm/page.h
 create mode 100644 arch/arc/include/asm/processor.h
 create mode 100644 arch/arc/include/asm/ptrace.h
 create mode 100644 arch/arc/include/asm/sections.h
 create mode 100644 arch/arc/include/asm/thread_info.h
arch/arc/include/asm/bug.h new file +37 -0
new file mode 100644
index 0000000..2ad8f9b
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_BUG_H
+#define _ASM_ARC_BUG_H
+
+#ifndef __ASSEMBLY__
+
+#include <asm/ptrace.h>
+
+struct task_struct;
+
+void show_regs(struct pt_regs *regs);
+void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs);
+void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
+			    unsigned long address, unsigned long cause_reg);
+void die(const char *str, struct pt_regs *regs, unsigned long address,
+	 unsigned long cause_reg);
+
+#define BUG()	do {				\
+	dump_stack();					\
+	pr_warn("Kernel BUG in %s: %s: %d!\n",	\
+		__FILE__, __func__,  __LINE__);	\
+} while (0)
+
+#define HAVE_ARCH_BUG
+
+#include <asm-generic/bug.h>
+
+#endif	/* !__ASSEMBLY__ */
+
+#endif
arch/arc/include/asm/cache.h new file +21 -0
new file mode 100644
index 0000000..30c72a4
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ARC_ASM_CACHE_H
+#define __ARC_ASM_CACHE_H
+
+/* In case $$ not config, setup a dummy number for rest of kernel */
+#ifndef CONFIG_ARC_CACHE_LINE_SHIFT
+#define L1_CACHE_SHIFT		6
+#else
+#define L1_CACHE_SHIFT		CONFIG_ARC_CACHE_LINE_SHIFT
+#endif
+
+#define L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
+
+#endif /* _ASM_CACHE_H */
arch/arc/include/asm/elf.h new file +97 -0

97 lines not on this page · raw message

arch/arc/include/asm/exec.h new file +15 -0
new file mode 100644
index 0000000..28abc69
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_EXEC_H
+#define __ASM_ARC_EXEC_H
+
+/* Align to 16b */
+#define arch_align_stack(p) ((unsigned long)(p) & ~0xf)
+
+#endif
arch/arc/include/asm/kdebug.h new file +19 -0
new file mode 100644
index 0000000..3fbe6c4
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_KDEBUG_H
+#define _ASM_ARC_KDEBUG_H
+
+enum die_val {
+	DIE_UNUSED,
+	DIE_TRAP,
+	DIE_IERR,
+	DIE_OOPS
+};
+
+#endif
arch/arc/include/asm/linkage.h new file +30 -0
new file mode 100644
index 0000000..a45d1bb
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+#ifdef __ASSEMBLY__
+
+/* Can't use the ENTRY macro in linux/linkage.h
+ * gas considers ';' as comment vs. newline
+ */
+.macro ARC_ENTRY name
+	.global \name
+	.align 4
+	\name:
+.endm
+
+.macro ARC_EXIT name
+#define ASM_PREV_SYM_ADDR(name)  .-##name
+	.size \ name, ASM_PREV_SYM_ADDR(\name)
+.endm
+
+#endif /* __ASSEMBLY__ */
+
+#endif
arch/arc/include/asm/module.h new file +17 -0
new file mode 100644
index 0000000..165d768
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+
+ */
+
+#ifndef _ASM_ARC_MODULE_H
+#define _ASM_ARC_MODULE_H
+
+#include <asm-generic/module.h>
+
+#endif /* _ASM_ARC_MODULE_H */
arch/arc/include/asm/page.h new file +42 -0

42 lines not on this page · raw message

arch/arc/include/asm/processor.h new file +143 -0

143 lines not on this page · raw message

arch/arc/include/asm/ptrace.h new file +120 -0

120 lines not on this page · raw message

arch/arc/include/asm/sections.h new file +17 -0
new file mode 100644
index 0000000..fc15f2e
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SECTIONS_H
+#define _ASM_ARC_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+extern char _int_vec_base_lds[];
+extern char __arc_dccm_base[];
+
+#endif
arch/arc/include/asm/thread_info.h new file +120 -0

120 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#16 lore raw

RFC PATCH 9/31 ARC: spinlock/rwlock/mutex primitives

In reply to Vineet Gupta
---
 arch/arc/include/asm/mutex.h          |    9 ++
 arch/arc/include/asm/spinlock.h       |  144 +++++++++++++++++++++++++++++++++
 arch/arc/include/asm/spinlock_types.h |   35 ++++++++
 3 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/mutex.h
 create mode 100644 arch/arc/include/asm/spinlock.h
 create mode 100644 arch/arc/include/asm/spinlock_types.h
arch/arc/include/asm/mutex.h new file +9 -0
new file mode 100644
index 0000000..3be5e64
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <asm-generic/mutex-xchg.h>
arch/arc/include/asm/spinlock.h new file +144 -0

144 lines not on this page · raw message

arch/arc/include/asm/spinlock_types.h new file +35 -0
new file mode 100644
index 0000000..8276bfd
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_SPINLOCK_TYPES_H
+#define __ASM_SPINLOCK_TYPES_H
+
+typedef struct {
+	volatile unsigned int slock;
+} arch_spinlock_t;
+
+#define __ARCH_SPIN_LOCK_UNLOCKED__	0
+#define __ARCH_SPIN_LOCK_LOCKED__	1
+
+#define __ARCH_SPIN_LOCK_UNLOCKED	{ __ARCH_SPIN_LOCK_UNLOCKED__ }
+#define __ARCH_SPIN_LOCK_LOCKED		{ __ARCH_SPIN_LOCK_LOCKED__ }
+
+/*
+ * Unlocked:     0x01_00_00_00
+ * Read lock(s): 0x00_FF_00_00 to say 0x01
+ * Write lock:   0x0, but only possible if prior value "unlocked" 0x0100_0000
+ */
+typedef struct {
+	volatile unsigned int	counter;
+	arch_spinlock_t		lock_mutex;
+} arch_rwlock_t;
+
+#define __ARCH_RW_LOCK_UNLOCKED__	0x01000000
+#define __ARCH_RW_LOCK_UNLOCKED		{ .counter = __ARCH_RW_LOCK_UNLOCKED__ }
+
+#endif
Signature · 1 line
1.7.4.1
#17 lore raw

RFC PATCH 10/31 ARC: string library

In reply to Vineet Gupta
---
 arch/arc/include/asm/string.h |   40 +++++++++++++
 arch/arc/lib/memcmp.S         |  124 +++++++++++++++++++++++++++++++++++++++++
 arch/arc/lib/memcpy-700.S     |   66 ++++++++++++++++++++++
 arch/arc/lib/memset.S         |   59 +++++++++++++++++++
 arch/arc/lib/strchr-700.S     |  123 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/lib/strcmp.S         |   96 +++++++++++++++++++++++++++++++
 arch/arc/lib/strcpy-700.S     |   70 +++++++++++++++++++++++
 arch/arc/lib/strlen.S         |   83 +++++++++++++++++++++++++++
 8 files changed, 661 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/string.h
 create mode 100644 arch/arc/lib/memcmp.S
 create mode 100644 arch/arc/lib/memcpy-700.S
 create mode 100644 arch/arc/lib/memset.S
 create mode 100644 arch/arc/lib/strchr-700.S
 create mode 100644 arch/arc/lib/strcmp.S
 create mode 100644 arch/arc/lib/strcpy-700.S
 create mode 100644 arch/arc/lib/strlen.S
arch/arc/include/asm/string.h new file +40 -0
new file mode 100644
index 0000000..87676c8
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: May 2011
+ *  -We had half-optimised memset/memcpy, got better versions of those
+ *  -Added memcmp, strchr, strcpy, strcmp, strlen
+ *
+ * Amit Bhor: Codito Technologies 2004
+ */
+
+#ifndef _ASM_ARC_STRING_H
+#define _ASM_ARC_STRING_H
+
+#include <linux/types.h>
+
+#ifdef __KERNEL__
+
+#define __HAVE_ARCH_MEMSET
+#define __HAVE_ARCH_MEMCPY
+#define __HAVE_ARCH_MEMCMP
+#define __HAVE_ARCH_STRCHR
+#define __HAVE_ARCH_STRCPY
+#define __HAVE_ARCH_STRCMP
+#define __HAVE_ARCH_STRLEN
+
+extern void *memset(void *ptr, int, __kernel_size_t);
+extern void *memcpy(void *, const void *, __kernel_size_t);
+extern void memzero(void *ptr, __kernel_size_t n);
+extern int memcmp(const void *, const void *, __kernel_size_t);
+extern char *strchr(const char *s, int c);
+extern char *strcpy(char *dest, const char *src);
+extern int strcmp(const char *cs, const char *ct);
+extern __kernel_size_t strlen(const char *);
+
+#endif /* __KERNEL__ */
+#endif /* _ASM_ARC_STRING_H */
arch/arc/lib/memcmp.S new file +124 -0

124 lines not on this page · raw message

arch/arc/lib/memcpy-700.S new file +66 -0

66 lines not on this page · raw message

arch/arc/lib/memset.S new file +59 -0

59 lines not on this page · raw message

arch/arc/lib/strchr-700.S new file +123 -0

123 lines not on this page · raw message

arch/arc/lib/strcmp.S new file +96 -0

96 lines not on this page · raw message

arch/arc/lib/strcpy-700.S new file +70 -0

70 lines not on this page · raw message

arch/arc/lib/strlen.S new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#18 lore raw

RFC PATCH 11/31 ARC: Low level IRQ/Trap/Exception(non-MMU) Handling

In reply to Vineet Gupta
---
 arch/arc/include/asm/entry.h |  495 ++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/entry.S      |  577 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1072 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/entry.h
 create mode 100644 arch/arc/kernel/entry.S
arch/arc/include/asm/entry.h new file +495 -0
new file mode 100644
index 0000000..3e0a9f4
@@ -0,0 +1,495 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Vineetg: Aug 28th 2008: Bug #94984
+ *  -Zero Overhead Loop Context shd be cleared when entering IRQ/EXcp/Trap
+ *   Normally CPU does this automatically, however when doing FAKE rtie,
+ *   we also need to explicitly do this. The problem in macros
+ *   FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit
+ *   was being "CLEARED" rather then "SET". Actually "SET" clears ZOL context
+ *
+ * Vineetg: May 5th 2008
+ *  - Defined Stack Switching Macro to be reused in all intr/excp hdlrs
+ *  - Shaved off 11 instructions from RESTORE_ALL_INT1 by using the
+ *      address Write back load ld.ab instead of seperate ld/add instn
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+ */
+
+#ifndef __ASM_ARC_ENTRY_H
+#define __ASM_ARC_ENTRY_H
+
+#ifdef __ASSEMBLY__
+#include <asm/unistd.h>		/* For NR_syscalls defination */
+#include <asm/asm-offsets.h>
+#include <asm/arcregs.h>
+#include <asm/ptrace.h>
+#include <asm/thread_info.h>	/* For THREAD_SIZE */
+
+/* Note on the LD/ST addr modes with addr reg wback
+ *
+ * LD.a same as LD.aw
+ *
+ * LD.a    reg1, [reg2, x]  => Pre Incr
+ *      Eff Addr for load = [reg2 + x]
+ *
+ * LD.ab   reg1, [reg2, x]  => Post Incr
+ *      Eff Addr for load = [reg2]
+ */
+
+/*--------------------------------------------------------------
+ * Save caller saved registers (scratch registers) ( r0 - r12 )
+ * Registers are pushed / popped in the order defined in struct ptregs
+ * in asm/ptrace.h
+ *-------------------------------------------------------------*/
+.macro  SAVE_CALLER_SAVED
+	st.a    r0, [sp, -4]
+	st.a    r1, [sp, -4]
+	st.a    r2, [sp, -4]
+	st.a    r3, [sp, -4]
+	st.a    r4, [sp, -4]
+	st.a    r5, [sp, -4]
+	st.a    r6, [sp, -4]
+	st.a    r7, [sp, -4]
+	st.a    r8, [sp, -4]
+	st.a    r9, [sp, -4]
+	st.a    r10, [sp, -4]
+	st.a    r11, [sp, -4]
+	st.a    r12, [sp, -4]
+.endm
+
+/*--------------------------------------------------------------
+ * Restore caller saved registers (scratch registers)
+ *-------------------------------------------------------------*/
+.macro RESTORE_CALLER_SAVED
+	ld.ab   r12, [sp, 4]
+	ld.ab   r11, [sp, 4]
+	ld.ab   r10, [sp, 4]
+	ld.ab   r9, [sp, 4]
+	ld.ab   r8, [sp, 4]
+	ld.ab   r7, [sp, 4]
+	ld.ab   r6, [sp, 4]
+	ld.ab   r5, [sp, 4]
+	ld.ab   r4, [sp, 4]
+	ld.ab   r3, [sp, 4]
+	ld.ab   r2, [sp, 4]
+	ld.ab   r1, [sp, 4]
+	ld.ab   r0, [sp, 4]
+.endm
+
+
+/*--------------------------------------------------------------
+ * Save callee saved registers (non scratch registers) ( r13 - r25 )
+ *  on kernel stack.
+ * User mode callee regs need to be saved in case of
+ *    -fork and friends for replicating from parent to child
+ *    -before going into do_signal( ) for ptrace/core-dump
+ * Special case handling is required for r25 in case it is used by kernel
+ *  for caching task ptr. Low level exception/ISR save user mode r25
+ *  into task->thread.user_r25. So it needs to be retrieved from there and
+ *  saved into kernel stack wit rest of callee reg-file
+ *-------------------------------------------------------------*/
+.macro SAVE_CALLEE_SAVED_USER
+	st.a    r13, [sp, -4]
+	st.a    r14, [sp, -4]
+	st.a    r15, [sp, -4]
+	st.a    r16, [sp, -4]
+	st.a    r17, [sp, -4]
+	st.a    r18, [sp, -4]
+	st.a    r19, [sp, -4]
+	st.a    r20, [sp, -4]
+	st.a    r21, [sp, -4]
+	st.a    r22, [sp, -4]
+	st.a    r23, [sp, -4]
+	st.a    r24, [sp, -4]
+	st.a    r25, [sp, -4]
+
+	/* move up by 1 word to "create" callee_regs->"stack_place_holder" */
+	sub sp, sp, 4
+.endm
+
+/*--------------------------------------------------------------
+ * Save callee saved registers (non scratch registers) ( r13 - r25 )
+ * kernel mode callee regs needed to be saved in case of context switch
+ * If r25 is used for caching task pointer then that need not be saved
+ * as it can be re-created from current task global
+ *-------------------------------------------------------------*/
+.macro SAVE_CALLEE_SAVED_KERNEL
+	st.a    r13, [sp, -4]
+	st.a    r14, [sp, -4]
+	st.a    r15, [sp, -4]
+	st.a    r16, [sp, -4]
+	st.a    r17, [sp, -4]
+	st.a    r18, [sp, -4]
+	st.a    r19, [sp, -4]
+	st.a    r20, [sp, -4]
+	st.a    r21, [sp, -4]
+	st.a    r22, [sp, -4]
+	st.a    r23, [sp, -4]
+	st.a    r24, [sp, -4]
+	st.a    r25, [sp, -4]
+	sub     sp, sp, 4
+.endm
+
+/*--------------------------------------------------------------
+ * RESTORE_CALLEE_SAVED:
+ * Loads callee (non scratch) Reg File by popping from Kernel mode stack.
+ *  This is reverse of SAVE_CALLEE_SAVED,
+ *
+ * NOTE:
+ * Ideally this shd only be called in switch_to for loading
+ *  switched-IN task's CALLEE Reg File.
+ *  For all other cases RESTORE_CALLEE_SAVED_FAST must be used
+ *  which simply pops the stack w/o touching regs.
+ *-------------------------------------------------------------*/
+.macro RESTORE_CALLEE_SAVED_KERNEL
+
+	add     sp, sp, 4   /* skip "callee_regs->stack_place_holder" */
+	ld.ab   r25, [sp, 4]
+	ld.ab   r24, [sp, 4]
+	ld.ab   r23, [sp, 4]
+	ld.ab   r22, [sp, 4]
+	ld.ab   r21, [sp, 4]
+	ld.ab   r20, [sp, 4]
+	ld.ab   r19, [sp, 4]
+	ld.ab   r18, [sp, 4]
+	ld.ab   r17, [sp, 4]
+	ld.ab   r16, [sp, 4]
+	ld.ab   r15, [sp, 4]
+	ld.ab   r14, [sp, 4]
+	ld.ab   r13, [sp, 4]
+
+.endm
+
+/*--------------------------------------------------------------
+ * Super FAST Restore callee saved regs by simply re-adjusting SP
+ *-------------------------------------------------------------*/
+.macro DISCARD_CALLEE_SAVED_USER
+	add     sp, sp, 14 * 4
+.endm
+
+/*--------------------------------------------------------------
+ * Restore User mode r25 saved in task_struct->thread.user_r25
+ *-------------------------------------------------------------*/
+.macro RESTORE_USER_R25
+	ld  r25, [r25, TASK_THREAD + THREAD_USER_R25]
+.endm
+
+/*-------------------------------------------------------------
+ * given a tsk struct, get to the base of it's kernel mode stack
+ * tsk->thread_info is really a PAGE, whose bottom hoists stack
+ * which grows upwards towards thread_info
+ *------------------------------------------------------------*/
+
+.macro GET_TSK_STACK_BASE tsk, out
+
+	/* Get task->thread_info (this is essentially start of a PAGE) */
+	ld  \out, [\tsk, TASK_THREAD_INFO]
+
+	/* Go to end of page where stack begins (grows upwards) */
+	add2 \out, \out, (THREAD_SIZE - 4)/4   /* one word GUTTER */
+
+.endm
+
+/*--------------------------------------------------------------
+ * Switch to Kernel Mode stack if SP points to User Mode stack
+ *
+ * Entry   : r9 contains pre-IRQ/exception/trap status32
+ * Exit    : SP is set to kernel mode stack pointer
+ * Clobbers: r9
+ *-------------------------------------------------------------*/
+
+.macro SWITCH_TO_KERNEL_STK
+
+	/* User Mode when this happened ? Yes: Proceed to switch stack */
+	bbit1   r9, STATUS_U_BIT, 88f
+
+	/* OK we were already in kernel mode when this event happened, thus can
+	 * assume SP is kernel mode SP. _NO_ need to do any stack switching
+	 */
+
+	/* Save Pre Intr/Exception KERNEL MODE SP on kernel stack
+	 * safe-keeping not really needed, but it keeps the epilogue code
+	 * (SP restore) simpler/uniform.
+	 */
+	b.d	77f
+
+	st.a	sp, [sp, -12]	; Make room for orig_r0 and orig_r8
+
+88: /*------Intr/Ecxp happened in user mode, "switch" stack ------ */
+
+	GET_CURR_TASK_ON_CPU   r9
+
+	/* With current tsk in r9, get it's kernel mode stack base */
+	GET_TSK_STACK_BASE  r9, r9
+
+#ifdef PT_REGS_CANARY
+	st	0xabcdabcd, [r9, 0]
+#endif
+
+	/* Save Pre Intr/Exception User SP on kernel stack */
+	st.a    sp, [r9, -12]	; Make room for orig_r0 and orig_r8
+
+	/* CAUTION:
+	 * SP should be set at the very end when we are done with everything
+	 * In case of 2 levels of interrupt we depend on value of SP to assume
+	 * that everything else is done (loading r25 etc)
+	 */
+
+	/* set SP to point to kernel mode stack */
+	mov sp, r9
+
+77: /* ----- Stack Switched to kernel Mode, Now save REG FILE ----- */
+
+.endm
+
+/*------------------------------------------------------------
+ * "FAKE" a rtie to return from CPU Exception context
+ * This is to re-enable Exceptions within exception
+ * Look at EV_ProtV to see how this is actually used
+ *-------------------------------------------------------------*/
+
+.macro FAKE_RET_FROM_EXCPN  reg
+
+	ld  \reg, [sp, PT_status32]
+	bic  \reg, \reg, (STATUS_U_MASK|STATUS_DE_MASK)
+	bset \reg, \reg, STATUS_L_BIT
+	sr  \reg, [erstatus]
+	mov \reg, 55f
+	sr  \reg, [eret]
+
+	rtie
+55:
+.endm
+
+/*
+ * @reg [OUT] &thread_info of "current"
+ */
+.macro GET_CURR_THR_INFO_FROM_SP  reg
+	and \reg, sp, ~(THREAD_SIZE - 1)
+.endm
+
+/*
+ * @reg [OUT] thread_info->flags of "current"
+ */
+.macro GET_CURR_THR_INFO_FLAGS  reg
+	GET_CURR_THR_INFO_FROM_SP  \reg
+	ld  \reg, [\reg, THREAD_INFO_FLAGS]
+.endm
+
+/*--------------------------------------------------------------
+ * For early Exception Prologue, a core reg is temporarily needed to
+ * code the rest of prolog (stack switching). This is done by stashing
+ * it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP).
+ *
+ * Before saving the full regfile - this reg is restored back, only
+ * to be saved again on kernel mode stack, as part of ptregs.
+ *-------------------------------------------------------------*/
+.macro EXCPN_PROLOG_FREEUP_REG	reg
+	st  \reg, [@ex_saved_reg1]
+.endm
+
+.macro EXCPN_PROLOG_RESTORE_REG	reg
+	ld  \reg, [@ex_saved_reg1]
+.endm
+
+/*--------------------------------------------------------------
+ * Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc)
+ * Requires SP to be already switched to kernel mode Stack
+ * sp points to the next free element on the stack at exit of this macro.
+ * Registers are pushed / popped in the order defined in struct ptregs
+ * in asm/ptrace.h
+ * Note that syscalls are implemented via TRAP which is also a exception
+ * from CPU's point of view
+ *-------------------------------------------------------------*/
+.macro SAVE_ALL_EXCEPTION   marker
+
+	/* Restore r9 used to code the early prologue */
+	EXCPN_PROLOG_RESTORE_REG  r9
+
+	/* Save the complete regfile now */
+
+	/* orig_r8 marker:
+	 * syscalls   -> 1 to NR_SYSCALLS
+	 * Exceptions -> NR_SYSCALLS + 1
+	 * Break-point-> NR_SYSCALLS + 2
+	 */
+	st      \marker, [sp, 8]
+	st      r0, [sp, 4]    /* orig_r0, needed only for sys calls */
+	SAVE_CALLER_SAVED
+	st.a    r26, [sp, -4]   /* gp */
+	st.a    fp, [sp, -4]
+	st.a    blink, [sp, -4]
+	lr	r9, [eret]
+	st.a    r9, [sp, -4]
+	lr	r9, [erstatus]
+	st.a    r9, [sp, -4]
+	st.a    lp_count, [sp, -4]
+	lr	r9, [lp_end]
+	st.a    r9, [sp, -4]
+	lr	r9, [lp_start]
+	st.a    r9, [sp, -4]
+	lr	r9, [erbta]
+	st.a    r9, [sp, -4]
+
+#ifdef PT_REGS_CANARY
+	mov   r9, 0xdeadbeef
+	st    r9, [sp, -4]
+#endif
+
+	/* move up by 1 word to "create" pt_regs->"stack_place_holder" */
+	sub sp, sp, 4
+.endm
+
+/*--------------------------------------------------------------
+ * Save scratch regs for exceptions
+ *-------------------------------------------------------------*/
+.macro SAVE_ALL_SYS
+	SAVE_ALL_EXCEPTION  (NR_syscalls + 1)
+.endm
+
+/*--------------------------------------------------------------
+ * Save scratch regs for sys calls
+ *-------------------------------------------------------------*/
+.macro SAVE_ALL_TRAP
+	SAVE_ALL_EXCEPTION  r8
+.endm
+
+/*--------------------------------------------------------------
+ * Restore all registers used by system call or Exceptions
+ * SP should always be pointing to the next free stack element
+ * when entering this macro.
+ *
+ * NOTE:
+ *
+ * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg
+ * for memory load operations. If used in that way interrupts are deffered
+ * by hardware and that is not good.
+ *-------------------------------------------------------------*/
+.macro RESTORE_ALL_SYS
+
+	add sp, sp, 4       /* hop over unused "pt_regs->stack_place_holder" */
+
+	ld.ab   r9, [sp, 4]
+	sr	r9, [erbta]
+	ld.ab   r9, [sp, 4]
+	sr	r9, [lp_start]
+	ld.ab   r9, [sp, 4]
+	sr	r9, [lp_end]
+	ld.ab   r9, [sp, 4]
+	mov	lp_count, r9
+	ld.ab   r9, [sp, 4]
+	sr	r9, [erstatus]
+	ld.ab   r9, [sp, 4]
+	sr	r9, [eret]
+	ld.ab   blink, [sp, 4]
+	ld.ab   fp, [sp, 4]
+	ld.ab   r26, [sp, 4]    /* gp */
+	RESTORE_CALLER_SAVED
+
+	ld  sp, [sp] /* restore original sp */
+	/* orig_r0 and orig_r8 skipped automatically */
+.endm
+
+
+/*--------------------------------------------------------------
+ * Save all registers used by interrupt handlers.
+ *-------------------------------------------------------------*/
+.macro SAVE_ALL_INT1
+
+	/* restore original r9 , saved in int1_saved_reg
+	* It will be saved on stack in macro: SAVE_CALLER_SAVED
+	*/
+	ld  r9, [@int1_saved_reg]
+
+	/* now we are ready to save the remaining context :) */
+	st     -1, [sp, 8]    /* orig_r8, -1 for interuppt level one */
+	st      0, [sp, 4]    /* orig_r0 , N/A for IRQ */
+	SAVE_CALLER_SAVED
+	st.a    r26, [sp, -4]   /* gp */
+	st.a    fp, [sp, -4]
+	st.a    blink, [sp, -4]
+	st.a    ilink1, [sp, -4]
+	lr	r9, [status32_l1]
+	st.a    r9, [sp, -4]
+	st.a    lp_count, [sp, -4]
+	lr	r9, [lp_end]
+	st.a    r9, [sp, -4]
+	lr	r9, [lp_start]
+	st.a    r9, [sp, -4]
+	lr	r9, [bta_l1]
+	st.a    r9, [sp, -4]
+
+#ifdef PT_REGS_CANARY
+	mov   r9, 0xdeadbee1
+	st    r9, [sp, -4]
+#endif
+	/* move up by 1 word to "create" pt_regs->"stack_place_holder" */
+	sub sp, sp, 4
+.endm
+
+/*--------------------------------------------------------------
+ * Restore all registers used by interrupt handlers.
+ *
+ * NOTE:
+ *
+ * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg
+ * for memory load operations. If used in that way interrupts are deffered
+ * by hardware and that is not good.
+ *-------------------------------------------------------------*/
+
+.macro RESTORE_ALL_INT1
+	add sp, sp, 4       /* hop over unused "pt_regs->stack_place_holder" */
+
+	ld.ab   r9, [sp, 4] /* Actual reg file */
+	sr	r9, [bta_l1]
+	ld.ab   r9, [sp, 4]
+	sr	r9, [lp_start]
+	ld.ab   r9, [sp, 4]
+	sr	r9, [lp_end]
+	ld.ab   r9, [sp, 4]
+	mov	lp_count, r9
+	ld.ab   r9, [sp, 4]
+	sr	r9, [status32_l1]
+	ld.ab   r9, [sp, 4]
+	mov	ilink1, r9
+	ld.ab   blink, [sp, 4]
+	ld.ab   fp, [sp, 4]
+	ld.ab   r26, [sp, 4]    /* gp */
+	RESTORE_CALLER_SAVED
+
+	ld  sp, [sp] /* restore original sp */
+	/* orig_r0 and orig_r8 skipped automatically */
+.endm
+
+/* Get CPU-ID of this core */
+.macro  GET_CPU_ID  reg
+	lr  \reg, [identity]
+	lsr \reg, \reg, 8
+	bmsk \reg, \reg, 7
+.endm
+
+.macro  GET_CURR_TASK_ON_CPU    reg
+	ld  \reg, [@_current_task]
+.endm
+
+.macro  SET_CURR_TASK_ON_CPU    tsk, tmp
+	st  \tsk, [@_current_task]
+.endm
+
+/* ------------------------------------------------------------------
+ * Get the ptr to some field of Current Task at @off in task struct
+ */
+
+.macro GET_CURR_TASK_FIELD_PTR  off,  reg
+	GET_CURR_TASK_ON_CPU  \reg
+	add \reg, \reg, \off
+.endm
+
+#endif  /* __ASSEMBLY__ */
+
+#endif  /* __ASM_ARC_ENTRY_H */
arch/arc/kernel/entry.S new file +577 -0

577 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#22 lore raw

RFC PATCH 12/31 ARC: Interrupt Handling

In reply to Vineet Gupta
---
 arch/arc/include/asm/arcregs.h |    3 ++
 arch/arc/include/asm/hw_irq.h  |    7 ++++
 arch/arc/include/asm/irq.h     |   25 +++++++++++++
 arch/arc/kernel/irq.c          |   79 +++++++++++++++++++++++++++++++++++++++-
 arch/arc/plat-arcfpga/irq.c    |   41 +++++++++++++++++++++
 5 files changed, 153 insertions(+), 2 deletions(-)
 create mode 100644 arch/arc/include/asm/hw_irq.h
 create mode 100644 arch/arc/include/asm/irq.h
 create mode 100644 arch/arc/plat-arcfpga/irq.c
arch/arc/include/asm/arcregs.h +3 -0
index 8ca8faf..3fccb04 100644
@@ -11,6 +11,9 @@
 
 #ifdef __KERNEL__
 
+/* Build Configuration Registers */
+#define ARC_REG_VECBASE_BCR	0x68
+
 /* status32 Bits Positions */
 #define STATUS_H_BIT		0	/* CPU Halted */
 #define STATUS_E1_BIT		1	/* Int 1 enable */
arch/arc/include/asm/hw_irq.h new file +7 -0
new file mode 100644
index 0000000..fd565ab
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
arch/arc/include/asm/irq.h new file +25 -0
new file mode 100644
index 0000000..633416c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_IRQ_H
+#define __ASM_ARC_IRQ_H
+
+/* Platform Inependent IRQs */
+#define TIMER0_IRQ      3
+#define TIMER1_IRQ      4
+
+#include <asm-generic/irq.h>
+
+extern void __init arc_init_IRQ(void);
+extern void __init plat_init_IRQ(void);
+extern int __init get_hw_config_num_irq(void);
+
+void __cpuinit arc_clockevent_init(void);
+void __cpuinit arc_clock_counter_setup(void);
+
+#endif
arch/arc/kernel/irq.c +77 -2

85 lines not on this page · raw message

arch/arc/plat-arcfpga/irq.c new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#25 lore raw

RFC PATCH 13/31 ARC: Non-MMU Exception Handling

In reply to Vineet Gupta
---
 arch/arc/include/asm/hw_irq.h |    7 --
 arch/arc/kernel/traps.c       |  125 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 125 insertions(+), 7 deletions(-)
 delete mode 100644 arch/arc/include/asm/hw_irq.h
 create mode 100644 arch/arc/kernel/traps.c
arch/arc/include/asm/hw_irq.h deleted +0 -7
deleted file mode 100644
index fd565ab..0000000
@@ -1,7 +0,0 @@
-/*
- * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
arch/arc/kernel/traps.c new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#26 lore raw

RFC PATCH 14/31 ARC: syscall support

In reply to Vineet Gupta
---
 arch/arc/include/asm/ptrace.h   |    5 ++
 arch/arc/include/asm/syscall.h  |   72 +++++++++++++++++++++++
 arch/arc/include/asm/syscalls.h |   30 ++++++++++
 arch/arc/include/asm/unistd.h   |   44 ++++++++++++++
 arch/arc/kernel/entry.S         |   49 ++++++++++++++++
 arch/arc/kernel/process.c       |  119 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/sys.c           |   19 ++++++
 arch/arc/mm/mmap.c              |   21 +++++++
 8 files changed, 359 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/syscall.h
 create mode 100644 arch/arc/include/asm/syscalls.h
 create mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/kernel/process.c
 create mode 100644 arch/arc/kernel/sys.c
 create mode 100644 arch/arc/mm/mmap.c
arch/arc/include/asm/ptrace.h +5 -0
index c178357..ee31d8a 100644
@@ -115,6 +115,11 @@ struct user_regs_struct {
 /* return 1 if user mode or 0 if kernel mode */
 #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
 
+
+/* return 1 if in syscall, 0 if Intr or Exception */
+#define in_syscall(regs) (((regs->orig_r8) >= 0 && \
+			   (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_PTRACE_H */
arch/arc/include/asm/syscall.h new file +72 -0

72 lines not on this page · raw message

arch/arc/include/asm/syscalls.h new file +30 -0
new file mode 100644
index 0000000..cf5d2f5
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SYSCALLS_H
+#define _ASM_ARC_SYSCALLS_H  1
+
+#ifdef __KERNEL__
+
+#include <linux/compiler.h>
+#include <linux/linkage.h>
+#include <linux/types.h>
+
+int sys_execve_wrapper(int, int, int);
+int sys_clone_wrapper(int, int, int, int, int);
+int sys_fork_wrapper(void);
+int sys_vfork_wrapper(void);
+int sys_cacheflush(uint32_t, uint32_t uint32_t);
+int sys_arc_settls(void *);
+int sys_arc_gettls(void);
+
+#include <asm-generic/syscalls.h>
+
+#endif	/* __KERNEL__ */
+
+#endif
arch/arc/include/asm/unistd.h new file +44 -0

44 lines not on this page · raw message

arch/arc/kernel/entry.S +49 -0

58 lines not on this page · raw message

arch/arc/kernel/process.c new file +119 -0

119 lines not on this page · raw message

arch/arc/kernel/sys.c new file +19 -0
new file mode 100644
index 0000000..4c30345
@@ -0,0 +1,19 @@
+
+#include <linux/syscalls.h>
+#include <linux/signal.h>
+#include <linux/unistd.h>
+
+#include <asm/syscalls.h>
+
+#define sys_execve	sys_execve_wrapper
+#define sys_clone	sys_clone_wrapper
+#define sys_fork	sys_fork_wrapper
+#define sys_vfork	sys_vfork_wrapper
+
+#undef __SYSCALL
+#define __SYSCALL(nr, call) [nr] = (call),
+
+void *sys_call_table[NR_syscalls] = {
+	[0 ... NR_syscalls-1] = sys_ni_syscall,
+#include <asm/unistd.h>
+};
arch/arc/mm/mmap.c new file +21 -0
new file mode 100644
index 0000000..e1a9d61
@@ -0,0 +1,21 @@
+/* mmap for ARC
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/syscalls.h>
+
+/* Gets dragged in due to __ARCH_WANT_SYSCALL_OFF_T */
+SYSCALL_DEFINE6(mmap, unsigned long, addr_hint, unsigned long, len,
+		unsigned long, prot, unsigned long, flags, unsigned long, fd,
+		unsigned long, off)
+{
+	pr_err("old mmap not supported\n");
+	return -EINVAL;
+}
Signature · 1 line
1.7.4.1
#39 lore raw

RFC PATCH 15/31 ARC: Process/scheduling/clock/Timers/Delay Management

In reply to Vineet Gupta
---
 arch/arc/include/asm/arcregs.h   |   31 +++++
 arch/arc/include/asm/delay.h     |   68 +++++++++++
 arch/arc/include/asm/processor.h |    3 +
 arch/arc/include/asm/switch_to.h |   41 +++++++
 arch/arc/include/asm/timex.h     |   18 +++
 arch/arc/kernel/ctx_sw.c         |   91 +++++++++++++++
 arch/arc/kernel/ctx_sw_asm.S     |   58 +++++++++
 arch/arc/kernel/fpu.c            |   55 +++++++++
 arch/arc/kernel/process.c        |  201 ++++++++++++++++++++++++++++++++
 arch/arc/kernel/time.c           |  237 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 803 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/delay.h
 create mode 100644 arch/arc/include/asm/switch_to.h
 create mode 100644 arch/arc/include/asm/timex.h
 create mode 100644 arch/arc/kernel/ctx_sw.c
 create mode 100644 arch/arc/kernel/ctx_sw_asm.S
 create mode 100644 arch/arc/kernel/fpu.c
 create mode 100644 arch/arc/kernel/time.c
arch/arc/include/asm/arcregs.h +31 -0
index 3fccb04..5131bb3 100644
@@ -47,6 +47,28 @@
 #define AUX_ITRIGGER		0x40d
 #define AUX_IPULSE		0x415
 
+/* Timer related Aux registers */
+#define ARC_REG_TIMER0_LIMIT	0x23	/* timer 0 limit */
+#define ARC_REG_TIMER0_CTRL	0x22	/* timer 0 control */
+#define ARC_REG_TIMER0_CNT	0x21	/* timer 0 count */
+#define ARC_REG_TIMER1_LIMIT	0x102	/* timer 1 limit */
+#define ARC_REG_TIMER1_CTRL	0x101	/* timer 1 control */
+#define ARC_REG_TIMER1_CNT	0x100	/* timer 1 count */
+
+#define TIMER_CTRL_IE		(1 << 0) /* Interupt when Count reachs limit */
+#define TIMER_CTRL_NH		(1 << 1) /* Count only when CPU NOT halted */
+
+/*
+ * Floating Pt Registers
+ * Status regs are read-only (build-time) so need not be saved/restored
+ */
+#define ARC_AUX_FP_STAT         0x300
+#define ARC_AUX_DPFP_1L         0x301
+#define ARC_AUX_DPFP_1H         0x302
+#define ARC_AUX_DPFP_2L         0x303
+#define ARC_AUX_DPFP_2H         0x304
+#define ARC_AUX_DPFP_STAT       0x305
+
 #ifndef __ASSEMBLY__
 
 /*
@@ -110,6 +132,15 @@
 
 #endif
 
+#ifdef CONFIG_ARC_FPU_SAVE_RESTORE
+/* These DPFP regs need to be saved/restored across ctx-sw */
+struct arc_fpu {
+	struct {
+		unsigned int l, h;
+	} aux_dpfp[2];
+};
+#endif
+
 #endif /* __ASEMBLY__ */
 
 #endif /* __KERNEL__ */
arch/arc/include/asm/delay.h new file +68 -0

68 lines not on this page · raw message

arch/arc/include/asm/processor.h +3 -0
index e2445bc..38ea5fb 100644
@@ -29,6 +29,9 @@ struct thread_struct {
 	unsigned long callee_reg;	/* pointer to callee regs */
 	unsigned long fault_address;	/* dbls as brkpt holder as well */
 	unsigned long cause_code;	/* Exception Cause Code (ECR) */
+#ifdef CONFIG_ARC_FPU_SAVE_RESTORE
+	struct arc_fpu fpu;
+#endif
 };
 
 #define INIT_THREAD  {                          \
arch/arc/include/asm/switch_to.h new file +41 -0

41 lines not on this page · raw message

arch/arc/include/asm/timex.h new file +18 -0
new file mode 100644
index 0000000..2c9bfb2
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_TIMEX_H
+#define _ASM_ARC_TIMEX_H
+
+#define CLOCK_TICK_RATE	CONFIG_ARC_PLAT_CLK	/* Underlying HZ */
+
+#include <asm-generic/timex.h>
+
+/* XXX: get_cycles() to be implemented with RTSC insn */
+
+#endif /* _ASM_ARC_TIMEX_H */
arch/arc/kernel/ctx_sw.c new file +91 -0

91 lines not on this page · raw message

arch/arc/kernel/ctx_sw_asm.S new file +58 -0

58 lines not on this page · raw message

arch/arc/kernel/fpu.c new file +55 -0

55 lines not on this page · raw message

arch/arc/kernel/process.c +201 -0

204 lines not on this page · raw message

arch/arc/kernel/time.c new file +237 -0

237 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#44 lore raw

RFC PATCH 16/31 ARC: Signal handling

In reply to Vineet Gupta
---
 arch/arc/include/asm/sigcontext.h |   23 +++
 arch/arc/include/asm/signal.h     |   27 +++
 arch/arc/kernel/signal.c          |  360 +++++++++++++++++++++++++++++++++++++
 3 files changed, 410 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/sigcontext.h
 create mode 100644 arch/arc/include/asm/signal.h
 create mode 100644 arch/arc/kernel/signal.c
arch/arc/include/asm/sigcontext.h new file +23 -0
new file mode 100644
index 0000000..f21b541
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_SIGCONTEXT_H
+#define _ASM_ARC_SIGCONTEXT_H
+
+#include <asm/ptrace.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 sigcontext {
+	struct pt_regs regs;
+};
+
+#endif /* _ASM_ARC_SIGCONTEXT_H */
arch/arc/include/asm/signal.h new file +27 -0
new file mode 100644
index 0000000..fad62f7
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
+ */
+
+#ifndef _ASM_ARC_SIGNAL_H
+#define _ASM_ARC_SIGNAL_H
+
+/*
+ * This is much needed for ARC sigreturn optimization.
+ * This allows uClibc to piggback the addr of a sigreturn stub in sigaction,
+ * which allows sigreturn based re-entry into kernel after handling signal.
+ * W/o this kernel needs to "synthesize" the sigreturn trampoline on user
+ * mode stack which in turn forces the following:
+ * -TLB Flush (after making the stack page executable)
+ * -Cache line Flush (to make I/D Cache lines coherent)
+ */
+#define SA_RESTORER	0x04000000
+
+#include <asm-generic/signal.h>
+
+#endif /* _ASM_ARC_SIGNAL_H */
arch/arc/kernel/signal.c new file +360 -0

360 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#49 lore raw

RFC PATCH 17/31 ARC: Cache Flush Management

In reply to Vineet Gupta

* ARC700 has VIPT L1 Caches (L1 only)
* Caches don't snoop and are not coherent
* Given the PAGE_SIZE and Cache associativity, we don't support aliasing D$ configurations, but so allow aliasing I$ configs

---
 arch/arc/include/asm/arcregs.h    |   80 ++++
 arch/arc/include/asm/cache.h      |   54 +++
 arch/arc/include/asm/cachectl.h   |   30 ++
 arch/arc/include/asm/cacheflush.h |   67 +++
 arch/arc/mm/cache_arc700.c        |  838 +++++++++++++++++++++++++++++++++++++
 5 files changed, 1069 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/cachectl.h
 create mode 100644 arch/arc/include/asm/cacheflush.h
 create mode 100644 arch/arc/mm/cache_arc700.c
arch/arc/include/asm/arcregs.h +80 -0
index 5131bb3..c6e2805 100644
@@ -58,6 +58,33 @@
 #define TIMER_CTRL_IE		(1 << 0) /* Interupt when Count reachs limit */
 #define TIMER_CTRL_NH		(1 << 1) /* Count only when CPU NOT halted */
 
+/* Instruction cache related Auxiliary registers */
+#define ARC_REG_IC_BCR		0x77	/* Build Config reg */
+#define ARC_REG_IC_IVIC		0x10
+#define ARC_REG_IC_CTRL		0x11
+#define ARC_REG_IC_IVIL		0x19
+#if (CONFIG_ARC_MMU_VER > 2)
+#define ARC_REG_IC_PTAG		0x1E
+#endif
+
+/* Bit val in IC_CTRL */
+#define IC_CTRL_CACHE_DISABLE   0x1
+
+/* Data cache related Auxiliary registers */
+#define ARC_REG_DC_BCR		0x72
+#define ARC_REG_DC_IVDC		0x47
+#define ARC_REG_DC_CTRL		0x48
+#define ARC_REG_DC_IVDL		0x4A
+#define ARC_REG_DC_FLSH		0x4B
+#define ARC_REG_DC_FLDL		0x4C
+#if (CONFIG_ARC_MMU_VER > 2)
+#define ARC_REG_DC_PTAG		0x5C
+#endif
+
+/* Bit val in DC_CTRL */
+#define DC_CTRL_INV_MODE_FLUSH  0x40
+#define DC_CTRL_FLUSH_STATUS    0x100
+
 /*
  * Floating Pt Registers
  * Status regs are read-only (build-time) so need not be saved/restored
@@ -132,6 +159,31 @@
 
 #endif
 
+#define READ_BCR(reg, into)				\
+{							\
+	unsigned int tmp;				\
+	tmp = read_aux_reg(reg);			\
+	if (sizeof(tmp) == sizeof(into)) {		\
+		into = *((typeof(into) *)&tmp);		\
+	} else {					\
+		extern void bogus_undefined(void);	\
+		bogus_undefined();			\
+	}						\
+}
+
+#define WRITE_BCR(reg, into)				\
+{							\
+	unsigned int tmp;				\
+	if (sizeof(tmp) == sizeof(into)) {		\
+		tmp = (*(unsigned int *)(into));	\
+		write_aux_reg(reg, tmp);		\
+	} else  {					\
+		extern void bogus_undefined(void);	\
+		bogus_undefined();			\
+	}						\
+}
+
+
 #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
 /* These DPFP regs need to be saved/restored across ctx-sw */
 struct arc_fpu {
@@ -141,6 +193,34 @@ struct arc_fpu {
 };
 #endif
 
+/*
+ ***************************************************************
+ * Build Configuration Registers, with encoded hardware config
+ */
+
+struct bcr_cache {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
+#else
+	unsigned int ver:8, config:4, sz:4, line_len:4, pad:12;
+#endif
+};
+
+/*
+ *******************************************************************
+ * Generic structures to hold build configuration used at runtime
+ */
+
+struct cpuinfo_arc_cache {
+	unsigned int has_aliasing, sz, line_len, assoc, ver;
+};
+
+struct cpuinfo_arc {
+	struct cpuinfo_arc_cache icache, dcache;
+};
+
+extern struct cpuinfo_arc cpuinfo_arc700[];
+
 #endif /* __ASEMBLY__ */
 
 #endif /* __KERNEL__ */
arch/arc/include/asm/cache.h +54 -0

58 lines not on this page · raw message

arch/arc/include/asm/cachectl.h new file +30 -0
new file mode 100644
index 0000000..d0ba876
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ARC_ASM_CACHECTL_H
+#define __ARC_ASM_CACHECTL_H
+
+/*
+ * ARC ABI flags defined for Android's finegrained cacheflush requirements
+ */
+#define CF_I_INV	0x0002
+#define CF_D_FLUSH	0x0010
+#define CF_D_INV	0x0020
+#define CF_D_FLUSH_INV	0x0030
+#define CF_PHY_ADDR	0x1000
+
+#define CF_DEFAULT	(CF_I_INV | CF_D_FLUSH)
+
+/*
+ * Standard flags expected by cacheflush system call users
+ */
+#define ICACHE	CF_I_INV
+#define DCACHE	CF_D_FLUSH
+#define BCACHE	(CF_I_INV | CF_D_FLUSH)
+
+#endif
arch/arc/include/asm/cacheflush.h new file +67 -0

67 lines not on this page · raw message

arch/arc/mm/cache_arc700.c new file +838 -0

838 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#50 lore raw

RFC PATCH 18/31 ARC: Page Table Management

In reply to Vineet Gupta
---
 arch/arc/include/asm/page.h    |   92 +++++++++
 arch/arc/include/asm/pgalloc.h |  134 +++++++++++++
 arch/arc/include/asm/pgtable.h |  401 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 627 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/pgalloc.h
 create mode 100644 arch/arc/include/asm/pgtable.h
arch/arc/include/asm/page.h +92 -0
index 7cd1224..d111d0c 100644
@@ -35,6 +35,98 @@
 
 #define PAGE_MASK	(~(PAGE_SIZE-1))
 
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+#define get_user_page(vaddr)		__get_free_page(GFP_KERNEL)
+#define free_user_page(page, addr)	free_page(addr)
+
+/* TBD: for now don't worry about VIPT D$ aliasing */
+#define clear_page(paddr)		memset((paddr), 0, PAGE_SIZE)
+#define copy_page(to, from)		memcpy((to), (from), PAGE_SIZE)
+
+#define clear_user_page(addr, vaddr, pg)	clear_page(addr)
+#define copy_user_page(vto, vfrom, vaddr, pg)	copy_page(vto, vfrom)
+
+#undef STRICT_MM_TYPECHECKS
+
+#ifdef STRICT_MM_TYPECHECKS
+/*
+ * These are used to make use of C type-checking..
+ */
+typedef struct {
+	unsigned long pte;
+} pte_t;
+typedef struct {
+	unsigned long pgd;
+} pgd_t;
+typedef struct {
+	unsigned long pgprot;
+} pgprot_t;
+typedef unsigned long pgtable_t;
+
+#define pte_val(x)      ((x).pte)
+#define pgd_val(x)      ((x).pgd)
+#define pgprot_val(x)   ((x).pgprot)
+
+#define __pte(x)        ((pte_t) { (x) })
+#define __pgd(x)        ((pgd_t) { (x) })
+#define __pgprot(x)     ((pgprot_t) { (x) })
+
+#else /* !STRICT_MM_TYPECHECKS */
+
+typedef unsigned long pte_t;
+typedef unsigned long pgd_t;
+typedef unsigned long pgprot_t;
+typedef unsigned long pgtable_t;
+
+#define pte_val(x)	(x)
+#define pgd_val(x)	(x)
+#define pgprot_val(x)	(x)
+#define __pte(x)	(x)
+#define __pgprot(x)	(x)
+
+#endif
+
+#define ARCH_PFN_OFFSET     (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT)
+
+#define pfn_valid(pfn)      (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
+
+/*
+ * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
+ *
+ * These macros have historically been misnamed
+ * virt here means link-address/program-address as embedded in object code.
+ * So if kernel img is linked at 0x8000_0000 onwards, 0x8010_0000 will be
+ * 128th page, and virt_to_page( ) will return the struct page corresp to it.
+ * mem_map[ ] is an array of struct page for each page frame in the system
+ *
+ * Independent of where linux is linked at, link-addr = physical address
+ * So the old macro  __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE
+ * would have been wrong in case kernel is not at 0x8zs
+ */
+#define __pa(vaddr)  ((unsigned long)vaddr)
+#define __va(paddr)  ((void *)((unsigned long)(paddr)))
+
+#define virt_to_page(kaddr)	\
+	(mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT))
+
+#define virt_addr_valid(kaddr)  pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
+
+/* Default Permissions for page, used in mmap.c */
+#ifdef CONFIG_ARC_STACK_NONEXEC
+#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE)
+#else
+#define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_EXEC | \
+				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+#endif
+
+#define WANT_PAGE_VIRTUAL   1
+
+#include <asm-generic/memory_model.h>   /* page_to_pfn, pfn_to_page */
+#include <asm-generic/getorder.h>
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
arch/arc/include/asm/pgalloc.h new file +134 -0

134 lines not on this page · raw message

arch/arc/include/asm/pgtable.h new file +401 -0

401 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#51 lore raw

RFC PATCH 19/31 ARC: MMU Context Management

In reply to Vineet Gupta

ARC700 MMU provides for tagging TLB entries with a 8-bit ASID to avoid having to flush the TLB every task switch.

It also allows for a quick way to invalidate all the TLB entries for task useful for:
* COW sementics during fork()
* task exit()ing

---
 arch/arc/include/asm/arcregs.h     |    7 ++
 arch/arc/include/asm/mmu.h         |   23 ++++
 arch/arc/include/asm/mmu_context.h |  209 ++++++++++++++++++++++++++++++++++++
 arch/arc/mm/tlb.c                  |   23 ++++
 4 files changed, 262 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/mmu.h
 create mode 100644 arch/arc/include/asm/mmu_context.h
 create mode 100644 arch/arc/mm/tlb.c
arch/arc/include/asm/arcregs.h +7 -0
index c6e2805..c12eb9b 100644
@@ -85,6 +85,13 @@
 #define DC_CTRL_INV_MODE_FLUSH  0x40
 #define DC_CTRL_FLUSH_STATUS    0x100
 
+/* MMU Management regs */
+#define ARC_REG_PID		0x409
+#define ARC_REG_SCRATCH_DATA0	0x418
+
+/* Bits in MMU PID register */
+#define MMU_ENABLE		(1 << 31)	/* Enable MMU for process */
+
 /*
  * Floating Pt Registers
  * Status regs are read-only (build-time) so need not be saved/restored
arch/arc/include/asm/mmu.h new file +23 -0
new file mode 100644
index 0000000..56b0232
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_MMU_H
+#define _ASM_ARC_MMU_H
+
+#ifndef __ASSEMBLY__
+
+typedef struct {
+	unsigned long asid;	/* Pvt Addr-Space ID for mm */
+#ifdef CONFIG_ARC_TLB_DBG
+	struct task_struct *tsk;
+#endif
+} mm_context_t;
+
+#endif
+
+#endif
arch/arc/include/asm/mmu_context.h new file +209 -0

209 lines not on this page · raw message

arch/arc/mm/tlb.c new file +23 -0
new file mode 100644
index 0000000..f1edae2
@@ -0,0 +1,23 @@
+/*
+ * TLB Management (flush/create/diagnostics) for ARC700
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <asm/arcregs.h>
+#include <asm/mmu_context.h>
+#include <asm/tlb.h>
+
+/* A copy of the ASID from the PID reg is kept in asid_cache */
+int asid_cache = FIRST_ASID;
+
+/* ASID to mm struct mapping. We have one extra entry corresponding to
+ * NO_ASID to save us a compare when clearing the mm entry for old asid
+ * see get_new_mmu_context (asm-arc/mmu_context.h)
+ */
+struct mm_struct *asid_mm_map[NUM_ASID + 1];
Signature · 1 line
1.7.4.1
#53 lore raw

RFC PATCH 21/31 ARC: TLB flush Handling

In reply to Vineet Gupta
---
 arch/arc/include/asm/tlb.h      |   17 ++
 arch/arc/include/asm/tlbflush.h |   28 ++++
 arch/arc/mm/tlb.c               |  311 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 356 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/tlbflush.h
arch/arc/include/asm/tlb.h +17 -0
index b571e12..3eb2ce0 100644
@@ -21,6 +21,23 @@
 
 #ifndef __ASSEMBLY__
 
+#define tlb_flush(tlb) local_flush_tlb_mm((tlb)->mm)
+
+/*
+ * This pair is called at time of munmap/exit to flush cache and TLB entries
+ * for mappings being torn down.
+ * 1) cache-flush part -implemented via tlb_start_vma( ) can be NOP (for now)
+ *    as we don't support aliasing configs in our VIPT D$.
+ * 2) tlb-flush part - implemted via tlb_end_vma( ) can be NOP as well-
+ *    albiet for difft reasons - its better handled by moving to new ASID
+ *
+ * Note, read http://lkml.org/lkml/2004/1/15/6
+ */
+#define tlb_start_vma(tlb, vma)
+#define tlb_end_vma(tlb, vma)
+
+#define __tlb_remove_tlb_entry(tlb, ptep, address)
+
 #include <linux/pagemap.h>
 #include <asm-generic/tlb.h>
 
arch/arc/include/asm/tlbflush.h new file +28 -0
new file mode 100644
index 0000000..b2f9bc7
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARC_TLBFLUSH__
+#define __ASM_ARC_TLBFLUSH__
+
+#include <linux/mm.h>
+
+void local_flush_tlb_all(void);
+void local_flush_tlb_mm(struct mm_struct *mm);
+void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
+void local_flush_tlb_kernel_range(unsigned long start, unsigned long end);
+void local_flush_tlb_range(struct vm_area_struct *vma,
+			   unsigned long start, unsigned long end);
+
+/* XXX: Revisit for SMP */
+#define flush_tlb_range(vma, s, e)	local_flush_tlb_range(vma, s, e)
+#define flush_tlb_page(vma, page)	local_flush_tlb_page(vma, page)
+#define flush_tlb_kernel_range(s, e)	local_flush_tlb_kernel_range(s, e)
+#define flush_tlb_all()			local_flush_tlb_all()
+#define flush_tlb_mm(mm)		local_flush_tlb_mm(mm)
+
+#endif
arch/arc/mm/tlb.c +311 -0

330 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#54 lore raw

RFC PATCH 22/31 ARC: Page Fault handling (incl uaccess fixup)

In reply to Vineet Gupta

This includes recent changes to make handler "retry" and/or "killable"

The killable (early exit) logic is loosely based on how SH implements it
return if SIGKILL + either of VM_FAULT_OOM or VM_FAULT_RETRY
which is different from Hexagon implementation which would NOT early exit for
SIGKILL + VM_FAULT_OOM + !VM_FAULT_RETRY

---
 arch/arc/mm/extable.c |   26 ++++++
 arch/arc/mm/fault.c   |  228 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 254 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/mm/extable.c
 create mode 100644 arch/arc/mm/fault.c
arch/arc/mm/extable.c new file +26 -0
new file mode 100644
index 0000000..f05b677
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Borrowed heavily from MIPS
+ */
+
+#include <linux/module.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->ret = fixup->fixup;
+
+		return 1;
+	}
+
+	return 0;
+}
arch/arc/mm/fault.c new file +228 -0

228 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#55 lore raw

RFC PATCH 23/31 ARC: I/O and DMA Mappings

In reply to Vineet Gupta

TBD: Do we need early ioremap support like openrisc

---
 arch/arc/include/asm/dma-mapping.h            |  176 +++++++++++++++++++++++++
 arch/arc/include/asm/dma.h                    |   14 ++
 arch/arc/include/asm/io.h                     |   26 ++++
 arch/arc/mm/dma.c                             |   91 +++++++++++++
 arch/arc/mm/ioremap.c                         |   62 +++++++++
 arch/arc/plat-arcfpga/include/plat/dma_addr.h |   45 +++++++
 6 files changed, 414 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/dma-mapping.h
 create mode 100644 arch/arc/include/asm/dma.h
 create mode 100644 arch/arc/include/asm/io.h
 create mode 100644 arch/arc/mm/dma.c
 create mode 100644 arch/arc/mm/ioremap.c
 create mode 100644 arch/arc/plat-arcfpga/include/plat/dma_addr.h
arch/arc/include/asm/dma-mapping.h new file +176 -0
new file mode 100644
index 0000000..ea0f56f
@@ -0,0 +1,176 @@
+/*
+ * DMA Mapping glue for ARC
+ *
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ASM_ARC_DMA_MAPPING_H
+#define ASM_ARC_DMA_MAPPING_H
+
+#include <asm-generic/dma-coherent.h>
+#include <plat/dma_addr.h>
+
+void *dma_alloc_noncoherent(struct device *dev, size_t size,
+			    dma_addr_t *dma_handle, gfp_t gfp);
+
+void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
+			  dma_addr_t dma_handle);
+
+void *dma_alloc_coherent(struct device *dev, size_t size,
+			 dma_addr_t *dma_handle, gfp_t gfp);
+
+void dma_free_coherent(struct device *dev, size_t size, void *kvaddr,
+		       dma_addr_t dma_handle);
+
+/*
+ * streaming DMA Mapping API...
+ * CPU accesses page via normal paddr, thus needs to explicitly made
+ * consistent before each use
+ */
+
+static inline void __inline_dma_cache_sync(unsigned long paddr, size_t size,
+					   enum dma_data_direction dir)
+{
+	switch (dir) {
+	case DMA_FROM_DEVICE:
+		dma_cache_inv(paddr, size);
+		break;
+	case DMA_TO_DEVICE:
+		dma_cache_wback(paddr, size);
+		break;
+	case DMA_BIDIRECTIONAL:
+		dma_cache_wback_inv(paddr, size);
+		break;
+	default:
+		pr_err("Invalid DMA dir [%d] for OP @ %lx\n", dir, paddr);
+	}
+}
+
+void __arc_dma_cache_sync(unsigned long paddr, size_t size,
+			  enum dma_data_direction dir);
+
+#define _dma_cache_sync(addr, sz, dir)			\
+do {							\
+	if (__builtin_constant_p(dir))			\
+		__inline_dma_cache_sync(addr, sz, dir);	\
+	else						\
+		__arc_dma_cache_sync(addr, sz, dir);	\
+}							\
+while (0);
+
+static inline dma_addr_t
+dma_map_single(struct device *dev, void *cpu_addr, size_t size,
+	       enum dma_data_direction dir)
+{
+	_dma_cache_sync((unsigned long)cpu_addr, size, dir);
+	return plat_kernel_addr_to_dma(dev, cpu_addr);
+}
+
+static inline void
+dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
+		 size_t size, enum dma_data_direction dir)
+{
+}
+
+static inline dma_addr_t
+dma_map_page(struct device *dev, struct page *page,
+	     unsigned long offset, size_t size,
+	     enum dma_data_direction dir)
+{
+	unsigned long paddr = page_to_phys(page) + offset;
+	return dma_map_single(dev, (void *)paddr, size, dir);
+}
+
+static inline void
+dma_unmap_page(struct device *dev, dma_addr_t dma_handle,
+	       size_t size, enum dma_data_direction dir)
+{
+}
+
+static inline int
+dma_map_sg(struct device *dev, struct scatterlist *sg,
+	   int nents, enum dma_data_direction dir)
+{
+	struct scatterlist *s;
+	int i;
+
+	for_each_sg(sg, s, nents, i)
+		sg->dma_address = dma_map_page(dev, sg_page(s), s->offset,
+					       s->length, dir);
+
+	return nents;
+}
+
+static inline void
+dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+	     int nents, enum dma_data_direction dir)
+{
+	struct scatterlist *s;
+	int i;
+
+	for_each_sg(sg, s, nents, i)
+		dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
+}
+
+static inline void
+dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+			size_t size, enum dma_data_direction dir)
+{
+	_dma_cache_sync(plat_dma_addr_to_kernel(dev, dma_handle), size,
+			DMA_FROM_DEVICE);
+}
+
+static inline void
+dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+			   size_t size, enum dma_data_direction dir)
+{
+	_dma_cache_sync(plat_dma_addr_to_kernel(dev, dma_handle), size,
+			DMA_TO_DEVICE);
+}
+
+static inline void
+dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
+		    enum dma_data_direction dir)
+{
+	int i;
+
+	for (i = 0; i < nelems; i++, sg++)
+		_dma_cache_sync((unsigned int)sg_virt(sg), sg->length, dir);
+}
+
+static inline void
+dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
+		       enum dma_data_direction dir)
+{
+	int i;
+
+	for (i = 0; i < nelems; i++, sg++)
+		_dma_cache_sync((unsigned int)sg_virt(sg), sg->length, dir);
+}
+
+static inline int dma_supported(struct device *dev, u64 dma_mask)
+{
+	/* Support 32 bit DMA mask exclusively */
+	return dma_mask == DMA_BIT_MASK(32);
+}
+
+static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+	return 0;
+}
+
+static inline int dma_set_mask(struct device *dev, u64 dma_mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+		return -EIO;
+
+	*dev->dma_mask = dma_mask;
+
+	return 0;
+}
+
+#endif
arch/arc/include/asm/dma.h new file +14 -0
new file mode 100644
index 0000000..ca7c451
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ASM_ARC_DMA_H
+#define ASM_ARC_DMA_H
+
+#define MAX_DMA_ADDRESS 0xC0000000
+
+#endif
arch/arc/include/asm/io.h new file +26 -0
new file mode 100644
index 0000000..b2221f5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_ARC_IO_H
+#define _ASM_ARC_IO_H
+
+#include <asm/byteorder.h>
+#include <asm/page.h>
+
+extern void __iomem *ioremap(unsigned long physaddr, unsigned long size);
+extern void iounmap(const void __iomem *addr);
+
+#define ioremap_nocache(phy, sz)	ioremap(phy, sz)
+#define ioremap_wc(phy, sz)		ioremap(phy, sz)
+
+/* Change struct page to physical address */
+#define page_to_phys(page)		(page_to_pfn(page) << PAGE_SHIFT)
+
+#include <asm-generic/io.h>
+
+#endif /* _ASM_ARC_IO_H */
arch/arc/mm/dma.c new file +91 -0

91 lines not on this page · raw message

arch/arc/mm/ioremap.c new file +62 -0

62 lines not on this page · raw message

arch/arc/plat-arcfpga/include/plat/dma_addr.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#57 lore raw

RFC PATCH 25/31 ARC: [plat-arcfpga] Hooking up platform to ARC UART

In reply to Vineet Gupta
---
 arch/arc/include/asm/irq.h                  |    1 +
 arch/arc/plat-arcfpga/include/plat/irq.h    |   27 +++++++
 arch/arc/plat-arcfpga/include/plat/memmap.h |   31 ++++++++
 arch/arc/plat-arcfpga/platform.c            |  105 +++++++++++++++++++++++++++
 4 files changed, 164 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/plat-arcfpga/include/plat/irq.h
 create mode 100644 arch/arc/plat-arcfpga/include/plat/memmap.h
arch/arc/include/asm/irq.h +1 -0
index 633416c..8e771f6 100644
@@ -13,6 +13,7 @@
 #define TIMER0_IRQ      3
 #define TIMER1_IRQ      4
 
+#include <plat/irq.h>		/* Board Specific IRQ assignments */
 #include <asm-generic/irq.h>
 
 extern void __init arc_init_IRQ(void);
arch/arc/plat-arcfpga/include/plat/irq.h new file +27 -0
new file mode 100644
index 0000000..b34e087
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: Feb 2009
+ *  -For AA4 board, IRQ assignments to peripherals
+ */
+
+#ifndef __PLAT_IRQ_H
+#define __PLAT_IRQ_H
+
+#define NR_IRQS		16
+
+#define UART0_IRQ	5
+#define UART1_IRQ	10
+#define UART2_IRQ	11
+
+#define VMAC_IRQ	6
+
+#define IDE_IRQ		13
+#define PCI_IRQ		14
+#define PS2_IRQ		15
+
+#endif
arch/arc/plat-arcfpga/include/plat/memmap.h new file +31 -0
new file mode 100644
index 0000000..1663f33
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: Feb 2009
+ *  -For AA4 board, System Memory Map for Peripherals etc
+ */
+
+#ifndef __PLAT_MEMMAP_H
+#define __PLAT_MEMMAP_H
+
+#define UART0_BASE              0xC0FC1000
+#define UART1_BASE              0xC0FC1100
+
+#define VMAC_REG_BASEADDR       0xC0FC2000
+
+#define IDE_CONTROLLER_BASE     0xC0FC9000
+
+#define AHB_PCI_HOST_BRG_BASE   0xC0FD0000
+
+#define PGU_BASEADDR            0xC0FC8000
+#define VLCK_ADDR               0xC0FCF028
+
+#define BVCI_LAT_UNIT_BASE      0xC0FED000
+
+#define PS2_BASE_ADDR		0xC0FCC000
+
+#endif
arch/arc/plat-arcfpga/platform.c +105 -0

124 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#85 lore raw

RFC PATCH 27/31 ARC: Last bits (stubs) to get to a running kernel with UART

In reply to Vineet Gupta

=========================>8============================= Linux version 3.7.0-rc3+ (vineetg@vineetg-Latitude) (gcc version 4.4.7 (ARCompact elf32 toolchain (built 20120928)) ) #5 Tue Nov 6 17:05:37 CET 2012
[plat-arcfpga]: registering early dev resources
bootconsole [early_ARCuart0] enabled
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages:
32624
Kernel command line: print-fatal-signals=1
PID hash table entries: 1024 (order: -1, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 4, 131072 bytes) Inode-cache hash table entries: 16384 (order: 3, 65536 bytes) Memory Available: 248M / 256M (1219K code, 412K data, 4192K init, 1400K reserv)
SLUB: Genslabs=12, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 NR_IRQS:16
Device [ARC Timer0] clockevent mode now [1]
Device [ARC Timer0] clockevent mode now [2]
Console: colour dummy device 80x25
Calibrating delay loop... 39.73 BogoMIPS (lpj=198656)
pid_max: default: 4096 minimum: 301
Mount-cache hash table entries: 1024
devtmpfs: initialized
[plat-arcfpga]: registering device resources
bio: create slab <bio-0> at 0
Switching to clocksource ARC Timer1
Device [ARC Timer0] clockevent mode now [3]
io scheduler noop registered (default)
arc-uart.0: ttyARC0 at MMIO 0xc0fc1000 (irq = 5) is a arc-uart console [ttyARC0] enabled, bootconsole disabled
console [ttyARC0] enabled, bootconsole disabled
Warning: unable to open an initial console.
Freeing unused kernel memory: 4192k [80002000] to [8041a000] Mounting proc
Mounting sysfs
Mounting devpts
Setting hostname to ARCLinux
Starting System logger (syslogd)
Bringing up loopback device
ifconfig: socket: Function not implemented
route: socket: Function not implemented
Disk not detected !
Mounting tmpfs
/etc/init.d/rcS: line 76: can't create /proc/sys/kernel/msgmni:
nonexistent directory

Please press Enter to activate this console.
***********************************************************************
Welcome to ARCLinux
***********************************************************************
[ARCLinux]$

=========================>8=============================

---
 arch/arc/kernel/ptrace.c       |   26 ++++++++++++++++++++++++
 arch/arc/kernel/stacktrace.c   |   43 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/troubleshoot.c |   17 +++++++++++++++
 3 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/kernel/ptrace.c
 create mode 100644 arch/arc/kernel/stacktrace.c
 create mode 100644 arch/arc/kernel/troubleshoot.c
arch/arc/kernel/ptrace.c new file +26 -0
new file mode 100644
index 0000000..1cf944a
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/ptrace.h>
+
+void ptrace_disable(struct task_struct *child)
+{
+}
+
+long arch_ptrace(struct task_struct *child, long request,
+		 unsigned long addr, unsigned long data)
+{
+	int ret = -EIO;
+	return ret;
+}
+
+
+const struct user_regset_view *task_user_regset_view(struct task_struct *task)
+{
+	return (const struct user_regset_view *)NULL;
+}
arch/arc/kernel/stacktrace.c new file +43 -0

43 lines not on this page · raw message

arch/arc/kernel/troubleshoot.c new file +17 -0
new file mode 100644
index 0000000..80bfe2a
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ */
+
+#include <linux/ptrace.h>
+
+void show_regs(struct pt_regs *regs)
+{
+}
+
+void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
+			    unsigned long address, unsigned long cause_reg)
+{
+}
Signature · 1 line
1.7.4.1
#86 lore raw

RFC PATCH 28/31 ARC: split ret_from_fork, simplify kernel_thread()

In reply to Vineet Gupta
---
 arch/arc/kernel/entry.S   |    8 ++++++++
 arch/arc/kernel/process.c |   32 +++++++++++++-------------------
 2 files changed, 21 insertions(+), 19 deletions(-)
arch/arc/kernel/entry.S +8 -0
index fe9a17c..46d0280 100644
@@ -580,6 +580,14 @@ ARC_ENTRY ret_from_fork
 	b @ret_from_exception
 ARC_EXIT ret_from_fork
 
+ARC_ENTRY ret_from_kernel_thread
+	bl  @schedule_tail
+	ld  r1, [sp, PT_r1]
+	j.d [r1]
+	ld  r0, [sp, PT_r0]
+	j   @sys_exit
+ARC_EXIT ret_from_kernel_thread
+
 ;################### Special Sys Call Wrappers ##########################
 
 ARC_ENTRY sys_execve_wrapper
arch/arc/kernel/process.c +13 -19
index c116fa5..fee3e11 100644
@@ -142,24 +142,13 @@ void cpu_idle(void)
 	}
 }
 
-void kernel_thread_helper(void)
-{
-	__asm__ __volatile__(
-		"mov   r0, r2	\n\t"
-		"mov   r1, r3	\n\t"
-		"j     [r1]	\n\t");
-}
-
 int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
 {
-	struct pt_regs regs;
+	struct pt_regs regs = {
+		.r0 = (unsigned long)arg,
+		.r1 = (unsigned long)fn
+	};
 
-	memset(&regs, 0, sizeof(regs));
-
-	regs.r2 = (unsigned long)arg;
-	regs.r3 = (unsigned long)fn;
-	regs.blink = (unsigned long)do_exit;
-	regs.ret = (unsigned long)kernel_thread_helper;
 	regs.status32 = read_aux_reg(0xa);
 
 	/* Ok, create the new process.. */
@@ -170,6 +159,7 @@ int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
 EXPORT_SYMBOL(kernel_thread);
 
 asmlinkage void ret_from_fork(void);
+asmlinkage void ret_from_kernel_thread(void) __attribute__((noreturn));
 
 /* Layout of Child kernel mode stack as setup at the end of this function is
  *
@@ -226,18 +216,22 @@ int copy_thread(unsigned long clone_flags,
 	/* Copy parents pt regs on child's kernel mode stack */
 	*c_regs = *regs;
 
-	/* __switch_to expects FP(0), BLINK(return addr) at top of stack */
-	childksp[0] = 0;				/* for POP fp */
-	childksp[1] = (unsigned long)ret_from_fork;	/* for POP blink */
-
 	if (!(user_mode(regs))) {
 		c_regs->sp =
 		    (unsigned long)task_thread_info(p) + (THREAD_SIZE - 4);
+
+		/* __switch_to expects FP(0), BLINK(return addr) at top */
+		childksp[0] = 0;			/* fp */
+		childksp[1] = (unsigned long)ret_from_kernel_thread; /* blink */
 		return 0;
 	}
 
 	/*--------- User Task Only --------------*/
 
+	/* __switch_to expects FP(0), BLINK(return addr) at top of stack */
+	childksp[0] = 0;				/* for POP fp */
+	childksp[1] = (unsigned long)ret_from_fork;	/* for POP blink */
+
 	c_regs->sp = usp;
 	c_regs->r0 = 0;		/* fork returns 0 in child */
 
Signature · 1 line
1.7.4.1
#87 lore raw

RFC PATCH 29/31 ARC: switch to generic kernel_thread()

In reply to Vineet Gupta
---
 arch/arc/Kconfig          |    1 +
 arch/arc/kernel/process.c |   29 +++++++++--------------------
 2 files changed, 10 insertions(+), 20 deletions(-)
arch/arc/Kconfig +1 -0
index d6983afa..f3aacfc 100644
@@ -17,6 +17,7 @@ config ARC
 	select GENERIC_FIND_FIRST_BIT
 	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_SHOW
+	select GENERIC_KERNEL_THREAD
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_GENERIC_HARDIRQS
arch/arc/kernel/process.c +9 -20
index fee3e11..d2bb27f 100644
@@ -142,22 +142,6 @@ void cpu_idle(void)
 	}
 }
 
-int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
-{
-	struct pt_regs regs = {
-		.r0 = (unsigned long)arg,
-		.r1 = (unsigned long)fn
-	};
-
-	regs.status32 = read_aux_reg(0xa);
-
-	/* Ok, create the new process.. */
-	return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL,
-		       NULL);
-
-}
-EXPORT_SYMBOL(kernel_thread);
-
 asmlinkage void ret_from_fork(void);
 asmlinkage void ret_from_kernel_thread(void) __attribute__((noreturn));
 
@@ -192,7 +176,7 @@ asmlinkage void ret_from_kernel_thread(void) __attribute__((noreturn));
  * ------------------  <===== END of PAGE
  */
 int copy_thread(unsigned long clone_flags,
-		unsigned long usp, unsigned long topstk,
+		unsigned long usp, unsigned long arg,
 		struct task_struct *p, struct pt_regs *regs)
 {
 	struct pt_regs *c_regs;        /* child's pt_regs */
@@ -213,10 +197,12 @@ int copy_thread(unsigned long clone_flags,
 	 */
 	p->thread.ksp = (unsigned long)c_callee;	/* THREAD_KSP */
 
-	/* Copy parents pt regs on child's kernel mode stack */
-	*c_regs = *regs;
+	if (unlikely(p->flags & PF_KTHREAD)) {
+		memset(c_regs, 0, sizeof(struct pt_regs));
+		c_regs->r0 = arg; /* argument to kernel thread */
+		c_regs->r1 = usp;  /* function */
+		c_regs->status32 = read_aux_reg(0xa);
 
-	if (!(user_mode(regs))) {
 		c_regs->sp =
 		    (unsigned long)task_thread_info(p) + (THREAD_SIZE - 4);
 
@@ -232,6 +218,9 @@ int copy_thread(unsigned long clone_flags,
 	childksp[0] = 0;				/* for POP fp */
 	childksp[1] = (unsigned long)ret_from_fork;	/* for POP blink */
 
+	/* Copy parents pt regs on child's kernel mode stack */
+	*c_regs = *regs;
+
 	c_regs->sp = usp;
 	c_regs->r0 = 0;		/* fork returns 0 in child */
 
Signature · 1 line
1.7.4.1
#88 lore raw

RFC PATCH 30/31 ARC: switch to generic kernel_execve() and sys_execve()

In reply to Vineet Gupta
---
 arch/arc/include/asm/ptrace.h |    8 +++++++
 arch/arc/include/asm/unistd.h |    2 +
 arch/arc/kernel/entry.S       |   17 ++++++++-------
 arch/arc/kernel/process.c     |   44 -----------------------------------------
 arch/arc/kernel/sys.c         |    1 -
 5 files changed, 19 insertions(+), 53 deletions(-)
arch/arc/include/asm/ptrace.h +8 -0
index ee31d8a..bc2229f 100644
@@ -120,6 +120,14 @@ struct user_regs_struct {
 #define in_syscall(regs) (((regs->orig_r8) >= 0 && \
 			   (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
 
+#define current_pt_regs()					\
+({								\
+	/* open-coded current_thread_info() */			\
+	register unsigned long sp asm ("sp");			\
+	unsigned long pg_start = (sp & ~(THREAD_SIZE - 1));	\
+	(struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1;	\
+})
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_PTRACE_H */
arch/arc/include/asm/unistd.h +2 -0
index 754d588..09144a8 100644
@@ -22,6 +22,8 @@
 #define __ARCH_WANT_SYSCALL_NO_FLAGS
 #define __ARCH_WANT_SYSCALL_OFF_T
 #define __ARCH_WANT_SYSCALL_DEPRECATED
+#define __ARCH_WANT_KERNEL_EXECVE
+#define __ARCH_WANT_SYS_EXECVE
 
 #define sys_mmap2 sys_mmap_pgoff
 
arch/arc/kernel/entry.S +9 -8
index 46d0280..deb2652 100644
@@ -588,15 +588,16 @@ ARC_ENTRY ret_from_kernel_thread
 	j   @sys_exit
 ARC_EXIT ret_from_kernel_thread
 
-;################### Special Sys Call Wrappers ##########################
-
-ARC_ENTRY sys_execve_wrapper
-	; copy pointer to pt_regs as a parameter
-	mov  r3, sp
-	bl  @sys_execve
+; When we land here, pt_regs have already been updated in-place correctly
+; A pointer to them is also passed by kernel_execve, we just need to make sure
+; that SP is set to point to them.
+ARC_ENTRY ret_from_kernel_execve
+	; Force SP to "normal" pt_regs just populated.
+	b.d   ret_from_system_call
+	mov   sp, r0
+ARC_EXIT ret_from_kernel_execve
 
-	b ret_from_system_call
-ARC_EXIT sys_execve_wrapper
+;################### Special Sys Call Wrappers ##########################
 
 ; TBD: call do_fork directly from here
 ARC_ENTRY sys_fork_wrapper
arch/arc/kernel/process.c +0 -44

50 lines not on this page · raw message

arch/arc/kernel/sys.c +0 -1
index 4c30345..f6bdd07 100644
@@ -5,7 +5,6 @@
 
 #include <asm/syscalls.h>
 
-#define sys_execve	sys_execve_wrapper
 #define sys_clone	sys_clone_wrapper
 #define sys_fork	sys_fork_wrapper
 #define sys_vfork	sys_vfork_wrapper
Signature · 1 line
1.7.4.1
#91 lore raw

RFC PATCH 31/31 ARC: [plat-arcfpga] defconfig

In reply to Vineet Gupta
---
 arch/arc/configs/fpga_defconfig |  607 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 607 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/configs/fpga_defconfig
arch/arc/configs/fpga_defconfig new file +607 -0
new file mode 100644
index 0000000..cfdca3c
@@ -0,0 +1,607 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arc 3.7.0-rc3 Kernel Configuration
+#
+CONFIG_ARC=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_UID16=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_MMU=y
+CONFIG_NO_IOPORT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_BINFMT_ELF=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+# CONFIG_NO_DMA is not set
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+# CONFIG_EXPERIMENTAL is not set
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_CROSS_COMPILE="arc-elf32-"
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_DEFAULT_HOSTNAME="(none)"
+# CONFIG_SWAP is not set
+# CONFIG_SYSVIPC is not set
+# CONFIG_FHANDLE is not set
+CONFIG_HAVE_GENERIC_HARDIRQS=y
+
+#
+# IRQ subsystem
+#
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+
+#
+# Timers subsystem
+#
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+
+#
+# CPU/Task time and stats accounting
+#
+CONFIG_TICK_CPU_ACCOUNTING=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TINY_RCU=y
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=17
+# CONFIG_CHECKPOINT_RESTORE is not set
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_UIDGID_CONVERTED=y
+# CONFIG_UIDGID_STRICT_TYPE_CHECKS is not set
+# CONFIG_SCHED_AUTOGROUP is not set
+# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_RELAY is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="../arc_initramfs"
+CONFIG_INITRAMFS_ROOT_UID=0
+CONFIG_INITRAMFS_ROOT_GID=0
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+CONFIG_INITRAMFS_COMPRESSION_NONE=y
+# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_EXPERT=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_BASE_FULL is not set
+# CONFIG_FUTEX is not set
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_SHMEM is not set
+# CONFIG_AIO is not set
+CONFIG_EMBEDDED=y
+
+#
+# Kernel Performance Events And Counters
+#
+# CONFIG_VM_EVENT_COUNTERS is not set
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
+CONFIG_GENERIC_KERNEL_THREAD=y
+CONFIG_MODULES_USE_ELF_RELA=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_BASE_SMALL=1
+# CONFIG_MODULES is not set
+CONFIG_BLOCK=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_BSGLIB is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_DEFAULT_NOOP=y
+CONFIG_DEFAULT_IOSCHED="noop"
+CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
+CONFIG_INLINE_READ_UNLOCK=y
+CONFIG_INLINE_READ_UNLOCK_IRQ=y
+CONFIG_INLINE_WRITE_UNLOCK=y
+CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
+# CONFIG_FREEZER is not set
+
+#
+# ARC Architecture Configuration
+#
+CONFIG_ARC_PLAT_FPGA_LEGACY=y
+
+#
+# ARC CPU Configuration
+#
+# CONFIG_ARC_CPU_750D is not set
+CONFIG_ARC_CPU_770=y
+# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_ARC_CACHE=y
+CONFIG_ARC_CACHE_LINE_SHIFT=6
+CONFIG_ARC_HAS_ICACHE=y
+CONFIG_ARC_HAS_DCACHE=y
+CONFIG_ARC_CACHE_PAGES=y
+CONFIG_ARC_HAS_HW_MPY=y
+# CONFIG_ARC_MMU_V1 is not set
+# CONFIG_ARC_MMU_V2 is not set
+CONFIG_ARC_MMU_V3=y
+CONFIG_ARC_PAGE_SIZE_8K=y
+# CONFIG_ARC_PAGE_SIZE_16K is not set
+# CONFIG_ARC_PAGE_SIZE_4K is not set
+# CONFIG_ARC_FPU_SAVE_RESTORE is not set
+CONFIG_ARC_CPU_REL_4_10=y
+CONFIG_ARC_HAS_LLSC=y
+CONFIG_ARC_HAS_SWAPE=y
+CONFIG_ARC_HAS_RTSC=y
+
+#
+# Platform Board Configuration
+#
+CONFIG_ARC_BOARD_ANGEL4=y
+# CONFIG_ARC_BOARD_ML509 is not set
+CONFIG_ARC_SERIAL_BAUD=115200
+CONFIG_ARC_PLAT_CLK=80000000
+CONFIG_LINUX_LINK_BASE=0x80000000
+CONFIG_ARC_PLAT_SDRAM_SIZE=0x10000000
+# CONFIG_ARC_STACK_NONEXEC is not set
+CONFIG_HZ=100
+# CONFIG_ARC_DBG is not set
+CONFIG_CMDLINE="print-fatal-signals=1"
+# CONFIG_CMDLINE_UBOOT is not set
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_COMPACTION is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+CONFIG_NEED_PER_CPU_KM=y
+# CONFIG_CLEANCACHE is not set
+# CONFIG_NET is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_STANDALONE=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+CONFIG_FW_LOADER=y
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_GENERIC_CPU_DEVICES is not set
+
+#
+# Bus devices
+#
+# CONFIG_OMAP_OCP2SCP is not set
+# CONFIG_MTD is not set
+# CONFIG_PARPORT is not set
+# CONFIG_BLK_DEV is not set
+
+#
+# Misc devices
+#
+# CONFIG_SENSORS_LIS3LV02D is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_93CX6 is not set
+
+#
+# Texas Instruments shared transport line discipline
+#
+
+#
+# Altera FPGA firmware download module
+#
+
+#
+# SCSI device support
+#
+CONFIG_SCSI_MOD=y
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+# CONFIG_INPUT_SPARSEKMAP is not set
+# CONFIG_INPUT_MATRIXKMAP is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_TRACE_SINK is not set
+# CONFIG_DEVKMEM is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_SCCNXP is not set
+# CONFIG_SERIAL_TIMBERDALE is not set
+# CONFIG_SERIAL_ALTERA_JTAGUART is not set
+# CONFIG_SERIAL_ALTERA_UART is not set
+# CONFIG_SERIAL_XILINX_PS_UART is not set
+CONFIG_SERIAL_ARC=y
+CONFIG_SERIAL_ARC_CONSOLE=y
+CONFIG_SERIAL_ARC_NR_PORTS=1
+# CONFIG_TTY_PRINTK is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_RTC is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_R3964 is not set
+
+#
+# PCMCIA character devices
+#
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+# CONFIG_I2C is not set
+# CONFIG_SPI is not set
+# CONFIG_HSI is not set
+
+#
+# PPS support
+#
+
+#
+# PPS generators support
+#
+
+#
+# PTP clock support
+#
+
+#
+# Enable Device Drivers -> PPS to see the PTP clock options.
+#
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_POWER_AVS is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+CONFIG_BCMA_POSSIBLE=y
+
+#
+# Broadcom specific AMBA
+#
+# CONFIG_BCMA is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_ABX500_CORE is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_DRM is not set
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+# CONFIG_FB is not set
+# CONFIG_EXYNOS_VIDEO is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_SOUND is not set
+
+#
+# HID support
+#
+# CONFIG_HID is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_ARCH_HAS_XHCI is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
+# CONFIG_RTC_CLASS is not set
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# Virtio drivers
+#
+
+#
+# Microsoft Hyper-V guest support
+#
+# CONFIG_STAGING is not set
+
+#
+# Hardware Spinlock drivers
+#
+# CONFIG_IOMMU_SUPPORT is not set
+
+#
+# Remoteproc drivers (EXPERIMENTAL)
+#
+
+#
+# Rpmsg drivers (EXPERIMENTAL)
+#
+# CONFIG_VIRT_DRIVERS is not set
+# CONFIG_PM_DEVFREQ is not set
+# CONFIG_EXTCON is not set
+# CONFIG_MEMORY is not set
+# CONFIG_IIO is not set
+# CONFIG_PWM is not set
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+CONFIG_FILE_LOCKING=y
+# CONFIG_FSNOTIFY is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_FANOTIFY is not set
+# CONFIG_QUOTA is not set
+# CONFIG_QUOTACTL is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+# CONFIG_NLS is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_READABLE_ASM is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_HEADERS_CHECK is not set
+# CONFIG_DEBUG_SECTION_MISMATCH is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+# CONFIG_LOCKUP_DETECTOR is not set
+# CONFIG_PANIC_ON_OOPS is not set
+CONFIG_PANIC_ON_OOPS_VALUE=0
+# CONFIG_DETECT_HUNG_TASK is not set
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_SLUB_STATS is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_SPARSE_RCU_POINTER is not set
+# CONFIG_DEBUG_ATOMIC_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_TEST_LIST_SORT is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_NOTIFIER_ERROR_INJECTION is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_ATOMIC64_SELFTEST is not set
+# CONFIG_SAMPLES is not set
+# CONFIG_TEST_KSTRTOX is not set
+CONFIG_EARLY_PRINTK=y
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_16KSTACKS is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY_DMESG_RESTRICT is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_DEFAULT_SECURITY=""
+# CONFIG_CRYPTO is not set
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_GENERIC_FIND_FIRST_BIT=y
+CONFIG_GENERIC_IO=y
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+# CONFIG_CRC32 is not set
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+# CONFIG_CRC8 is not set
+CONFIG_ZLIB_INFLATE=y
+# CONFIG_XZ_DEC is not set
+# CONFIG_XZ_DEC_BCJ is not set
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_DMA=y
+CONFIG_GENERIC_ATOMIC64=y
+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
+# CONFIG_AVERAGE is not set
+# CONFIG_CORDIC is not set
+# CONFIG_DDR is not set
Signature · 1 line
1.7.4.1
#7 lore raw

RFC PATCH 5/31 ARC: uaccess friends

In reply to Vineet Gupta
---
 arch/arc/include/asm/segment.h |   24 ++
 arch/arc/include/asm/uaccess.h |  605 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 629 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/segment.h
 create mode 100644 arch/arc/include/asm/uaccess.h
arch/arc/include/asm/segment.h new file +24 -0
new file mode 100644
index 0000000..da2c459
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASMARC_SEGMENT_H
+#define __ASMARC_SEGMENT_H
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned long mm_segment_t;
+
+#define MAKE_MM_SEG(s)	((mm_segment_t) { (s) })
+
+#define KERNEL_DS		MAKE_MM_SEG(0)
+#define USER_DS			MAKE_MM_SEG(TASK_SIZE)
+
+#define segment_eq(a, b)	((a) == (b))
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ASMARC_SEGMENT_H */
arch/arc/include/asm/uaccess.h new file +605 -0

605 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#56 lore raw

RFC PATCH 24/31 ARC: startup #1: low-level, setup_arch(), /proc/cpuinfo, mem init

In reply to Vineet Gupta
---
 arch/arc/include/asm/arcregs.h   |    5 +
 arch/arc/include/asm/setup.h     |   22 +++++
 arch/arc/kernel/head.S           |   78 ++++++++++++++++
 arch/arc/kernel/reset.c          |   33 +++++++
 arch/arc/kernel/setup.c          |  166 ++++++++++++++++++++++++++++++++++
 arch/arc/mm/init.c               |  185 ++++++++++++++++++++++++++++++++++++++
 arch/arc/plat-arcfpga/platform.c |   29 ++++++
 7 files changed, 518 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/setup.h
 create mode 100644 arch/arc/kernel/head.S
 create mode 100644 arch/arc/kernel/reset.c
 create mode 100644 arch/arc/kernel/setup.c
 create mode 100644 arch/arc/mm/init.c
 create mode 100644 arch/arc/plat-arcfpga/platform.c
arch/arc/include/asm/arcregs.h +5 -0
index aedfbf1..725b94c 100644
@@ -257,6 +257,11 @@
 	}						\
 }
 
+/* Helpers */
+#define TO_KB(bytes)		((bytes) >> 10)
+#define TO_MB(bytes)		(TO_KB(bytes) >> 10)
+#define PAGES_TO_KB(n_pages)	((n_pages) << (PAGE_SHIFT - 10))
+#define PAGES_TO_MB(n_pages)	(PAGES_TO_KB(n_pages) >> 10)
 
 #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
 /* These DPFP regs need to be saved/restored across ctx-sw */
arch/arc/include/asm/setup.h new file +22 -0
new file mode 100644
index 0000000..ab427e6
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASMARC_SETUP_H
+#define __ASMARC_SETUP_H
+
+#include <linux/types.h>
+
+#define COMMAND_LINE_SIZE 256
+
+extern int root_mountflags, end_mem;
+extern int running_on_hw;
+
+void __init setup_processor(void);
+void __init setup_arch_memory(void);
+
+#endif /* __ASMARC_SETUP_H */
arch/arc/kernel/head.S new file +78 -0

78 lines not on this page · raw message

arch/arc/kernel/reset.c new file +33 -0
new file mode 100644
index 0000000..e227a2b
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/printk.h>
+#include <linux/reboot.h>
+#include <linux/pm.h>
+
+void machine_halt(void)
+{
+	/* Halt the processor */
+	__asm__ __volatile__("flag  1\n");
+}
+
+void machine_restart(char *__unused)
+{
+	/* Soft reset : jump to reset vector */
+	pr_info("Put your restart handler here\n");
+	machine_halt();
+}
+
+void machine_power_off(void)
+{
+	/* FIXME ::  power off ??? */
+	machine_halt();
+}
+
+void (*pm_power_off) (void) = NULL;
arch/arc/kernel/setup.c new file +166 -0

166 lines not on this page · raw message

arch/arc/mm/init.c new file +185 -0

185 lines not on this page · raw message

arch/arc/plat-arcfpga/platform.c new file +29 -0
new file mode 100644
index 0000000..7b5dcab
@@ -0,0 +1,29 @@
+/*
+ * ARC FPGA Platform support code
+ *
+ * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+/*
+ * Early Platform Initialization called from setup_arch()
+ */
+void __init arc_platform_early_init(void)
+{
+	pr_info("[plat-arcfpga]: registering early dev resources\n");
+}
+
+int __init fpga_plat_init(void)
+{
+	pr_info("[plat-arcfpga]: registering device resources\n");
+
+	return 0;
+}
+arch_initcall(fpga_plat_init);
Signature · 1 line
1.7.4.1
#52 lore raw

RFC PATCH 20/31 ARC: MMU Exception Handling

In reply to Vineet Gupta

* MMU I-TLB / D-TLB Miss Exceptions
- Fast Path TLB Refill Handler
- slowpath TLB creation via do_page_fault() -> update_mmu_cache()
* Duplicate PD Exception Handler

---
 arch/arc/include/asm/arcregs.h  |   90 ++++++++++
 arch/arc/include/asm/tlb-mmu1.h |  104 ++++++++++++
 arch/arc/include/asm/tlb.h      |   41 +++++
 arch/arc/mm/tlb.c               |  252 ++++++++++++++++++++++++++++
 arch/arc/mm/tlbex.S             |  351 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 838 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/tlb-mmu1.h
 create mode 100644 arch/arc/include/asm/tlb.h
 create mode 100644 arch/arc/mm/tlbex.S
arch/arc/include/asm/arcregs.h +90 -0
index c12eb9b..aedfbf1 100644
@@ -13,6 +13,7 @@
 
 /* Build Configuration Registers */
 #define ARC_REG_VECBASE_BCR	0x68
+#define ARC_REG_MMU_BCR		0x6f
 
 /* status32 Bits Positions */
 #define STATUS_H_BIT		0	/* CPU Halted */
@@ -36,6 +37,34 @@
 #define STATUS_U_MASK		(1<<STATUS_U_BIT)
 #define STATUS_L_MASK		(1<<STATUS_L_BIT)
 
+/*
+ * ECR: Exception Cause Reg bits-n-pieces
+ * [23:16] = Exception Vector
+ * [15: 8] = Exception Cause Code
+ * [ 7: 0] = Exception Parameters (for certain types only)
+ */
+#define ECR_VEC_MASK			0xff0000
+#define ECR_CODE_MASK			0x00ff00
+#define ECR_PARAM_MASK			0x0000ff
+
+/* Exception Cause Vector Values */
+#define ECR_V_MACH_CHK			0x20
+#define ECR_V_ITLB_MISS			0x21
+#define ECR_V_DTLB_MISS			0x22
+#define ECR_V_PROTV			0x23
+
+/* Protection Violation Exception Cause Code Values */
+#define ECR_C_PROTV_INST_FETCH		0x00
+#define ECR_C_PROTV_LOAD		0x01
+#define ECR_C_PROTV_STORE		0x02
+#define ECR_C_PROTV_XCHG		0x03
+#define ECR_C_PROTV_MISALIG_DATA	0x04
+
+/* DTLB Miss Exception Cause Code Values */
+#define ECR_C_BIT_DTLB_LD_MISS		8
+#define ECR_C_BIT_DTLB_ST_MISS		9
+
+
 /* Auxiliary registers */
 #define AUX_IDENTITY		4
 #define AUX_INTR_VEC_BASE	0x25
@@ -58,6 +87,44 @@
 #define TIMER_CTRL_IE		(1 << 0) /* Interupt when Count reachs limit */
 #define TIMER_CTRL_NH		(1 << 1) /* Count only when CPU NOT halted */
 
+#if defined(CONFIG_ARC_MMU_V1)
+#define CONFIG_ARC_MMU_VER 1
+#elif defined(CONFIG_ARC_MMU_V2)
+#define CONFIG_ARC_MMU_VER 2
+#elif defined(CONFIG_ARC_MMU_V3)
+#define CONFIG_ARC_MMU_VER 3
+#else
+#error "Error: MMU ver"
+#endif
+
+/* MMU Management regs */
+#define ARC_REG_TLBPD0		0x405
+#define ARC_REG_TLBPD1		0x406
+#define ARC_REG_TLBINDEX	0x407
+#define ARC_REG_TLBCOMMAND	0x408
+#define ARC_REG_PID		0x409
+#define ARC_REG_SCRATCH_DATA0	0x418
+
+/* Bits in MMU PID register */
+#define MMU_ENABLE		(1 << 31)	/* Enable MMU for process */
+
+/* Error code if probe fails */
+#define TLB_LKUP_ERR		0x80000000
+
+/* TLB Commands */
+#define TLBWrite    0x1
+#define TLBRead     0x2
+#define TLBGetIndex 0x3
+#define TLBProbe    0x4
+
+#if (CONFIG_ARC_MMU_VER >= 2)
+#define TLBWriteNI  0x5		/* write JTLB without inv uTLBs */
+#define TLBIVUTLB   0x6		/* explicitly inv uTLBs */
+#else
+#undef TLBWriteNI		/* These cmds don't exist on older MMU */
+#undef TLBIVUTLB
+#endif
+
 /* Instruction cache related Auxiliary registers */
 #define ARC_REG_IC_BCR		0x77	/* Build Config reg */
 #define ARC_REG_IC_IVIC		0x10
@@ -205,6 +272,24 @@ struct arc_fpu {
  * Build Configuration Registers, with encoded hardware config
  */
 
+struct bcr_mmu_1_2 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int ver:8, ways:4, sets:4, u_itlb:8, u_dtlb:8;
+#else
+	unsigned int u_dtlb:8, u_itlb:8, sets:4, ways:4, ver:8;
+#endif
+};
+
+struct bcr_mmu_3 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	unsigned int ver:8, ways:4, sets:4, osm:1, reserv:3, pg_sz:4,
+		     u_itlb:4, u_dtlb:4;
+#else
+	unsigned int u_dtlb:4, u_itlb:4, pg_sz:4, reserv:3, osm:1, sets:4,
+		     ways:4, ver:8;
+#endif
+};
+
 struct bcr_cache {
 #ifdef CONFIG_CPU_BIG_ENDIAN
 	unsigned int pad:12, line_len:4, sz:4, config:4, ver:8;
@@ -218,12 +303,17 @@ struct bcr_cache {
  * Generic structures to hold build configuration used at runtime
  */
 
+struct cpuinfo_arc_mmu {
+	unsigned int ver, pg_sz, sets, ways, u_dtlb, u_itlb, num_tlb;
+};
+
 struct cpuinfo_arc_cache {
 	unsigned int has_aliasing, sz, line_len, assoc, ver;
 };
 
 struct cpuinfo_arc {
 	struct cpuinfo_arc_cache icache, dcache;
+	struct cpuinfo_arc_mmu mmu;
 };
 
 extern struct cpuinfo_arc cpuinfo_arc700[];
arch/arc/include/asm/tlb-mmu1.h new file +104 -0

104 lines not on this page · raw message

arch/arc/include/asm/tlb.h new file +41 -0

41 lines not on this page · raw message

arch/arc/mm/tlb.c +252 -0

255 lines not on this page · raw message

arch/arc/mm/tlbex.S new file +351 -0

351 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#69 lore raw

RFC PATCH 26/31 ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Vineet Gupta
---
 arch/arc/Kbuild                    |    2 +
 arch/arc/Kconfig                   |  337 ++++++++++++++++++++++++++++++++++++
 arch/arc/Kconfig.debug             |   34 ++++
 arch/arc/Makefile                  |  115 ++++++++++++
 arch/arc/boot/Makefile             |   27 +++
 arch/arc/include/asm/Kbuild        |    1 +
 arch/arc/include/asm/vmlinux.lds.h |   12 ++
 arch/arc/kernel/Makefile           |   16 ++
 arch/arc/kernel/arcksyms.c         |   56 ++++++
 arch/arc/kernel/asm-offsets.c      |   46 +++++
 arch/arc/kernel/vmlinux.lds.S      |  117 +++++++++++++
 arch/arc/lib/Makefile              |    9 +
 arch/arc/mm/Makefile               |   10 +
 arch/arc/plat-arcfpga/Kconfig      |   33 ++++
 arch/arc/plat-arcfpga/Makefile     |    9 +
 15 files changed, 824 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/Kbuild
 create mode 100644 arch/arc/Kconfig
 create mode 100644 arch/arc/Kconfig.debug
 create mode 100644 arch/arc/Makefile
 create mode 100644 arch/arc/boot/Makefile
 create mode 100644 arch/arc/include/asm/vmlinux.lds.h
 create mode 100644 arch/arc/kernel/Makefile
 create mode 100644 arch/arc/kernel/arcksyms.c
 create mode 100644 arch/arc/kernel/asm-offsets.c
 create mode 100644 arch/arc/kernel/vmlinux.lds.S
 create mode 100644 arch/arc/lib/Makefile
 create mode 100644 arch/arc/mm/Makefile
 create mode 100644 arch/arc/plat-arcfpga/Kconfig
 create mode 100644 arch/arc/plat-arcfpga/Makefile
arch/arc/Kbuild new file +2 -0
new file mode 100644
index 0000000..082d329
@@ -0,0 +1,2 @@
+obj-y += kernel/
+obj-y += mm/
arch/arc/Kconfig new file +337 -0

337 lines not on this page · raw message

arch/arc/Kconfig.debug new file +34 -0
new file mode 100644
index 0000000..962c609
@@ -0,0 +1,34 @@
+menu "Kernel hacking"
+
+source "lib/Kconfig.debug"
+
+config EARLY_PRINTK
+	bool "Early printk" if EMBEDDED
+	default y
+	help
+	  Write kernel log output directly into the VGA buffer or to a serial
+	  port.
+
+	  This is useful for kernel debugging when your machine crashes very
+	  early before the console code is initialized. For normal operation
+	  it is not recommended because it looks ugly and doesn't cooperate
+	  with klogd/syslogd or the X server. You should normally N here,
+	  unless you want to debug such a crash.
+
+config DEBUG_STACKOVERFLOW
+	bool "Check for stack overflows"
+	depends on DEBUG_KERNEL
+	help
+	  This option will cause messages to be printed if free stack space
+	  drops below a certain limit.
+
+config 16KSTACKS
+	bool "Use 16Kb for kernel stacks instead of 8Kb"
+	help
+	  If you say Y here the kernel will use a  16Kb stacksize for the
+	  kernel stack attached to each process/thread. The default is 8K.
+	  This increases the resident kernel footprint and will cause less
+	  threads to run on the system and also increase the pressure
+	  on the VM subsystem for higher order allocations.
+
+endmenu
arch/arc/Makefile new file +115 -0

115 lines not on this page · raw message

arch/arc/boot/Makefile new file +27 -0
new file mode 100644
index 0000000..4ff734d
@@ -0,0 +1,27 @@
+targets := vmlinux.bin vmlinux.bin.gz uImage
+
+# uImage build relies on mkimage being availble on your host for ARC target
+# You will need to build u-boot for ARC, rename mkimage to arc-elf32-mkimage
+# and make sure it's reacable from your PATH
+MKIMAGE := $(srctree)/scripts/mkuboot.sh
+
+OBJCOPYFLAGS= -O binary -R .note -R .note.gnu.build-id -R .comment -S
+
+LINUX_START_TEXT = $$(readelf -h vmlinux | \
+			grep "Entry point address" | grep -o 0x.*)
+
+quiet_cmd_uimage = UIMAGE $@
+	cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arc -O linux -T kernel \
+			-C gzip -a $(CONFIG_LINUX_LINK_BASE) \
+			-e $(LINUX_START_TEXT) -d $< $@
+
+$(obj)/vmlinux.bin: vmlinux FORCE
+	$(call if_changed,objcopy)
+
+$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
+	$(call if_changed,gzip)
+
+$(obj)/uImage: $(obj)/vmlinux.bin.gz FORCE
+	$(call if_changed,uimage)
+
+PHONY += FORCE
arch/arc/include/asm/Kbuild +1 -0
index d6c037a..148dfcf 100644
@@ -33,6 +33,7 @@ generic-y += mman.h
 generic-y += msgbuf.h
 generic-y += param.h
 generic-y += parport.h
+generic-y += pci.h
 generic-y += percpu.h
 generic-y += poll.h
 generic-y += posix_types.h
arch/arc/include/asm/vmlinux.lds.h new file +12 -0
new file mode 100644
index 0000000..12c8e42
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_VMLINUX_LDS_H__
+#define __ASM_VMLINUX_LDS_H__
+
+#endif
arch/arc/kernel/Makefile new file +16 -0
new file mode 100644
index 0000000..47f6b33
@@ -0,0 +1,16 @@
+#
+# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+
+obj-y	:= arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \
+	   signal.o traps.o sys.o troubleshoot.o stacktrace.o
+
+obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
+CFLAGS_fpu.o   += -mdpfp
+
+obj-y += ctx_sw_asm.o
+
+extra-y := vmlinux.lds head.o
arch/arc/kernel/arcksyms.c new file +56 -0

56 lines not on this page · raw message

arch/arc/kernel/asm-offsets.c new file +46 -0

46 lines not on this page · raw message

arch/arc/kernel/vmlinux.lds.S new file +117 -0

117 lines not on this page · raw message

arch/arc/lib/Makefile new file +9 -0
new file mode 100644
index 0000000..f4eaaf4
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+
+lib-y	:= strchr-700.o strcmp.o strcpy-700.o strlen.o \
+	   memcmp.o memcpy-700.o memset.o
arch/arc/mm/Makefile new file +10 -0
new file mode 100644
index 0000000..303f567
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+
+obj-y	:= extable.o ioremap.o dma.o fault.o init.o mmap.o \
+	   tlb.o tlbex.o cache_arc700.o
arch/arc/plat-arcfpga/Kconfig new file +33 -0
new file mode 100644
index 0000000..3b41a0e
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+
+if ARC_PLAT_FPGA_LEGACY
+
+choice
+	prompt "FPGA Board"
+
+config ARC_BOARD_ANGEL4
+	bool "ARC Angel4"
+	help
+	  ARC Angel4 FPGA Ref Platform (Xilinx Virtex Based)
+
+config ARC_BOARD_ML509
+	bool "ML509"
+	help
+	  ARC ML509 FPGA Ref Platform (Xilinx Virtex-5 Based)
+
+endchoice
+
+config ARC_SERIAL_BAUD
+	int "UART Baud rate"
+	default "115200"
+	depends on SERIAL_ARC
+	help
+	  Baud rate for the ARC UART
+
+endif
arch/arc/plat-arcfpga/Makefile new file +9 -0
new file mode 100644
index 0000000..385eb9d
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2011-2012 Synopsys, Inc. (www.synopsys.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+
+obj-y := platform.o irq.o
Signature · 1 line
1.7.4.1
maintainer
#92 lore raw

Re: [RFC PATCH v1 31/31] ARC: [plat-arcfpga] defconfig

In reply to Vineet Gupta
Quoted 12 lines · Vineet Gupta
---
 arch/arc/configs/fpga_defconfig |  607 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 607 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/configs/fpga_defconfig
arch/arc/configs/fpga_defconfig new file +0 -0
new file mode 100644
index 0000000..cfdca3c

arch/arc/configs/fpga_defconfig line 4

Quoted 4 lines
arch/arc/configs/fpga_defconfig new file +4 -0
@@ -0,0 +1,607 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arc 3.7.0-rc3 Kernel Configuration
+#

Please use "make defconfig" to generate minimal defconfig files, instead of copying the entire file here.

Arnd

maintainer
#70 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Vineet Gupta
Quoted 7 lines · Vineet Gupta
arch/arc/Kconfig new file +7 -0
+
+config ARC
+	def_bool y
+	select ARCH_WANT_IPC_PARSE_VERSION
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG
+	select DEVTMPFS if !INITRAMFS_SOURCE=""

arch/arc/Kconfig line 24

Quoted 10 lines
arch/arc/Kconfig new file +10 -0
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_FIND_FIRST_BIT
+	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select MODULES_USE_ELF_RELA

You should not need ARCH_WANT_IPC_PARSE_VERSION

arch/arc/Kconfig line 37

Quoted 3 lines
arch/arc/Kconfig new file +3 -0
+# for old_[ug]id_t - do we need this ?
+config UID16
+	def_bool y

No, not needed either.

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+menu "ARC Architecture Configuration"
+
+choice
+	prompt "ARC Platform"
+	default ARC_PLAT_FPGA_LEGACY
+
+config ARC_PLAT_FPGA_LEGACY

arch/arc/Kconfig line 86

Quoted 10 lines
arch/arc/Kconfig new file +10 -0
+	bool "\"Legacy\" ARC FPGA dev platform"
+	help
+	  Support for ARC development platforms, provided by Synopsys.
+	  These are based on FPGA or ISS. e.g.
+	  - ARCAngel4
+	  - ML509
+	  - MetaWare ISS
+
+#New platform adds here
+endchoice

Platform selection should generally be non-exclusive. Just remove the "choice" statement here, and make sure that any platforms can be enabled together to build a single kernel.

Quoted 13 lines
arch/arc/Kconfig new file +13 -0
+menu "ARC CPU Configuration"
+
+choice
+	prompt "ARC Core"
+	default ARC_CPU_770
+
+config ARC_CPU_750D
+	bool "ARC750D"
+	help
+	  Support for ARC750 core
+
+config ARC_CPU_770
+	bool "ARC770"

arch/arc/Kconfig line 110

Quoted 10 lines
arch/arc/Kconfig new file +10 -0
+	select ARC_CPU_REL_4_10
+	help
+	  Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
+	  This core has a bunch of cool new features:
+	  -MMU-v3: Variable Page Sz (4k, 8k, 16k), bigger J-TLB (128x4)
+                   Shared Address Spaces (for sharing TLB entires in MMU)
+	  -Caches: New Prog Model, Region Flush
+	  -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr
+
+endchoice

Same thing here: If the different CPUs can in theory run the same kernel code, they should allow that. It doesn't stop you from making the default to enable only one of them and optimize for that case.

Quoted 6 lines
arch/arc/Kconfig new file +6 -0
+
+choice
+	prompt "ARC700 MMU Version"
+	default ARC_MMU_V3 if ARC_CPU_770
+	default ARC_MMU_V2 if ARC_CPU_750D
+

arch/arc/Kconfig line 208

Quoted 10 lines
arch/arc/Kconfig new file +7 -0
 
+endchoice
 
+choice
+	prompt "MMU Page Size"
+	default ARC_PAGE_SIZE_8K
+
 
+
+endchoice

For MMU, page size and endianess, I would not expect that to work though, so they probably need to remain mutually exclusive.

Quoted 21 lines
arch/arc/Kconfig new file +21 -0
+menu "Platform Board Configuration"
+
+source "arch/arc/plat-arcfpga/Kconfig"
+#New platform adds here
+
+config ARC_PLAT_CLK
+	int "Clk speed in Hz"
+	default "80000000"
+
+config LINUX_LINK_BASE
+	hex "Linux Link Address"
+	default "0x80000000"
+	help
+	  ARC700 divides the 32 bit phy address space into two equal halves
+	  -Lower 2G (0 - 0x7FFF_FFFF ) is user virtual, translated by MMU
+	  -Upper 2G (0x8000_0000 onwards) is untranslated, for kernel
+	  Typically Linux kernel is linked at the start of untransalted addr,
+	  hence the default value of 0x8zs.
+	  However some customers have peripherals mapped at this addr, so
+	  Linux needs to be scooted a bit.
+	  If you don't know what the above means, leave this setting alone.

arch/arc/Kconfig line 277

Quoted 10 lines
arch/arc/Kconfig new file +10 -0
+
+config ARC_PLAT_SDRAM_SIZE
+	hex "SD RAM Size"
+	default "0x10000000"
+	help
+	  Implies the amount of SDRAM/DRAM Linux is going to claim/own.
+	  The actual memory itself could be larger than this number. But for
+	  all software purposes, this is the amt of memory.
+
+endmenu # "Platform Board Configuration"

Clock speed and memory size are things that the kernel should normally be able to find out itself, if not from the hardware then from looking at the device tree binary that gets passed from the boot loader, or some other boot protocol that is already established.

Quoted 6 lines
arch/arc/plat-arcfpga/Kconfig new file +6 -0
+if ARC_PLAT_FPGA_LEGACY
+
+choice
+	prompt "FPGA Board"
+
+config ARC_BOARD_ANGEL4

arch/arc/plat-arcfpga/Kconfig line 24

Quoted 10 lines
arch/arc/plat-arcfpga/Kconfig new file +10 -0
+	bool "ARC Angel4"
+	help
+	  ARC Angel4 FPGA Ref Platform (Xilinx Virtex Based)
+
+config ARC_BOARD_ML509
+	bool "ML509"
+	help
+	  ARC ML509 FPGA Ref Platform (Xilinx Virtex-5 Based)
+
+endchoice

Board files again should not be mutually exclusive.

Arnd

maintainer
#58 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

In reply to Vineet Gupta
Quoted 10 lines · Vineet Gupta
arch/arc/plat-arcfpga/platform.c +10 -0
+static struct platform_device arc_uart##n##_dev = {    \
+       .name = "arc-uart",                             \
+       .id = n,                                        \
+       .num_resources = ARRAY_SIZE(arc_uart##n##_res), \
+       .resource = arc_uart##n##_res,                  \
+       .dev = {                                        \
+               .platform_data = &arc_uart_info,        \
+       },                                              \
+}
+

arch/arc/plat-arcfpga/platform.c line 65

Quoted 10 lines
arch/arc/plat-arcfpga/platform.c +10 -0
+ARC_UART_DEV(0);
+#if CONFIG_SERIAL_ARC_NR_PORTS > 1
+ARC_UART_DEV(1);
+#endif
+
+static struct platform_device *fpga_early_devs[] __initdata = {
+#if defined(CONFIG_SERIAL_ARC_CONSOLE)
+       &arc_uart0_dev,
+#endif
+};

statically defining platform devices like this is considered very bad style, especially since it prevents you from doing proper boot-time configuration. Please get the available devices from the boot loader. Normally this is done using a flattened device tree blob that gets passed, unless you can probe the hardware directly.

Arnd

maintainer
#27 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

In reply to Vineet Gupta
Quoted 11 lines · Vineet Gupta

+ * Being uClibc based we need some of the deprecated syscalls:
+ * -Not emulated by uClibc at all
+ * unlink, mkdir,... (needed by Busybox, LTP etc)
+ * times (needed by LTP pan test harness)
+ * -Not emulated efficiently
+ * select: emulated using pselect (but extra code to chk usec > 1sec)
+ *
+ * some (send/recv) correctly emulated using (recfrom/sendto) and
+ * some arch specific ones (fork/vfork)can easily be emulated using clone but
+ * thats the price of using common-denominator....
+ */

arch/arc/include/asm/unistd.h line 24

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

I'm pretty sure that this has been solved before, best get in contact with the maintainers of the openrisc/c6x/hexagon platforms, that probably all use uClibc without needing these.

You have to remove the legacy calls here.

Arnd

maintainer
#95 lore raw
In reply to Vineet Gupta
Quoted 6 lines · Vineet Gupta

This patchset based off-of 3.7-rc3, introduces the Linux kernel port to ARC700 processor family (750D and 770D) from Synopsys.

ARC700 is highly configurable and power efficient 32-bit RISC core with MMU. It is embedded in SoCs deployed in TV Set Top boxes, Digital Media Players, all the way to Network-on-Chips.

Hi Vineet,

I'm largely quite happy with how the series has turned out, having looked at earlier versions of the ARC kernel a couple of years ago. I've commented already on individual patches, but overall, I see two main issues that need to be resolved in order to merge the port:

* You have to use the generic syscall interface, and that means not using any of the legacy system calls that have since been replaced by newer versions of the same.

* You are missing dynamic hardware detection. Rather than building a kernel with everything known about the hardware at compile time, new ports these days are normally able to run on all kinds of hardware and detect the differences by looking at configuration registers (e.g. PCI), asking firmware (Open Firmware, ACPI, ...) or by interpreting a device tree that is passed by the boot loader (most embedded systems).
I assume that device tree is the right solution for you because a lot of the hardware you use is likely shared with ARM, PowerPC or MIPS based SoCs and they are all using (or getting migrated to) DT now instead of static platform devices,

Arnd

Tested-by on the v1 series
#97 lore raw
In reply to Vineet Gupta
Quoted 4 lines · Vineet Gupta

Hi,

This patchset based off-of 3.7-rc3, introduces the Linux kernel port to ARC700 processor family (750D and 770D) from Synopsys.

We've been using the port for 6 month now at Ezchip running on top of FPGA in 4 way SMP configuration (support for which will no doubt follow later) and have subjected it to various stress tests (hackbench and such) and it is working up quite well over all.

I realize some code style or organization changes might be in order but at the same time wanted to attest the nature of its good and behavior performance on real hardware; so for what it's worth:

Cheers,
Gilad

Signature · 10 lines
Gilad Ben-Yossef
Chief Coffee Drinker
[email protected]
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru
#11 lore raw

Re: [RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines

In reply to Vineet Gupta

arch/arc/include/asm/ptrace.h line 3

Quoted 9 lines · Vineet Gupta
arch/arc/include/asm/ptrace.h new file +3 -0
new file mode 100644
index 0000000..c178357
@@ -0,0 +1,120 @@
+/* THE pt_regs: Defines how regs are saved during entry into kernel */
+
+struct pt_regs {

I'd recommend not exporting the pt_regs structure to userspace. This struct is used heavily within the kernel and it's nice to have the leeway to be able to modify it as things evolve. GDB doesn't need to know about this struct anymore as it should be using regset's for any recent architectures anyway, so it's the regset layout that should be ABI stable instead of pt_regs.

You can check the openrisc architecture as an example of how to do this.

/Jonas

#12 lore raw

RE: [RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines

Quoted 17 lines · Vineet Gupta

arch/arc/include/asm/ptrace.h line 3

Quoted 9 lines
arch/arc/include/asm/ptrace.h new file +3 -0
new file mode 100644
index 0000000..c178357
@@ -0,0 +1,120 @@
+/* THE pt_regs: Defines how regs are saved during entry into kernel */
+
+struct pt_regs {

I'd recommend not exporting the pt_regs structure to userspace. This struct is used heavily within the kernel and it's nice to have the leeway to be able to modify it as things evolve. GDB doesn't need to know about this struct anymore as it should be using regset's for any recent architectures anyway, so it's the regset layout that should be ABI stable instead of pt_regs.

Quoted 1 line

You can check the openrisc architecture as an example of how to do this.

Hi Jonas,

thanks for your review comment. I completely agree that pt_regs should not be exported and very recently a change in pt_regs forced a gdbserver change too (ABI incompatibility) which goes along what you are recommending. Infact the ptrace patch for kernel (which will follow in series #2) provides a stable regset ABI - extracting information from pt_regs.

However our current gdb/gdbserver is 6.8 based and making it switch to regset interface might not be possible for this release of tools. Since customers are already using our stuff, we can not have a broken ABI. We do have ABI versioning, so in next release we can fix gdb and remove this.

Please note that an additional reason for exporting pt_regs is due to the fact that it is part of sigcontext. Keeping it exactly same as pt_regs helps us do batch save/restore of user context in signal handling (please look at my signal handling patch) but the flip side is that userspace SA_SIGINFO needs to be able to have access to sigcontext and hence we explicitly need pt_regs. We could arguably opencode pt_regs there - but that won't be clean IMHO.

What do you think !

-Vineet

#96 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Thanks for your valuable comments I will rework the port.

P.S. Sorry for top-posting.

Thanks,
Vineet

Quoted 6 lines · Vineet Gupta

This patchset based off-of 3.7-rc3, introduces the Linux kernel port to ARC700 processor family (750D and 770D) from Synopsys.

ARC700 is highly configurable and power efficient 32-bit RISC core with MMU. It is embedded in SoCs deployed in TV Set Top boxes, Digital Media Players, all the way to Network-on-Chips.

Hi Vineet,

I'm largely quite happy with how the series has turned out, having looked at earlier versions of the ARC kernel a couple of years ago. I've commented already on individual patches, but overall, I see two main issues that need to be resolved in order to merge the port:

* You have to use the generic syscall interface, and that means not using any of the legacy system calls that have since been replaced by newer versions of the same.

* You are missing dynamic hardware detection. Rather than building a kernel with everything known about the hardware at compile time, new ports these days are normally able to run on all kinds of hardware and detect the differences by looking at configuration registers (e.g. PCI), asking firmware (Open Firmware, ACPI, ...) or by interpreting a device tree that is passed by the boot loader (most embedded systems).
I assume that device tree is the right solution for you because a lot of the hardware you use is likely shared with ARM, PowerPC or MIPS based SoCs and they are all using (or getting migrated to) DT now instead of static platform devices,

Arnd

#13 lore raw

Re: [RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines

In reply to Vineet Gupta
Quoted 8 lines · Vineet Gupta
Quoted 7 lines · Vineet Gupta

I'd recommend not exporting the pt_regs structure to userspace. This struct is used heavily within the kernel and it's nice to have the leeway to be able to modify it as things evolve. GDB doesn't need to know about this struct anymore as it should be using regset's for any recent architectures anyway, so it's the regset layout that should be ABI stable instead of pt_regs.

Quoted 7 lines
Quoted 1 line

You can check the openrisc architecture as an example of how to do this.

Hi Jonas,

thanks for your review comment. I completely agree that pt_regs should not be exported and very recently a change in pt_regs forced a gdbserver change too (ABI incompatibility) which goes along what you are recommending. Infact the ptrace patch for kernel (which will follow in series #2) provides a stable regset ABI - extracting information from pt_regs.

However our current gdb/gdbserver is 6.8 based and making it switch to regset interface might not be possible for this release of tools. Since customers are already using our stuff, we can not have a broken ABI. We do have ABI versioning, so in next release we can fix gdb and remove this.

For generic syscalls it was generally decided that the upstream kernel would drop support for legacy syscalls, _even though_ userspace bits like uClibc required them. For _new_ architectures, userspace would need to adapt to the _mainline_ kernel; and as a stop-gap for existing software, external patches could be carried in an external git repository where _non-mainline_ kernel patches could be carried to provide a working kernel until userspace could catch up.

I'd say the same applies here: GDB 6.8 may continue work with a mainline kernel plus a patch that restores the export of pt_regs, but GDB 7.2 (or whatever version you move on to) would be the one that fully supports an unpatched mainline.

Quoted 2 lines

Please note that an additional reason for exporting pt_regs is due to the fact that it is part of sigcontext. Keeping it exactly same as pt_regs helps us do batch save/restore of user context in signal handling (please look at my signal handling patch) but the flip side is that userspace SA_SIGINFO needs to be able to have access to sigcontext and hence we explicitly need pt_regs. We could arguably opencode pt_regs there - but that won't be clean IMHO.

It's not really pt_regs you need here, but the userspace equivalent thereof. On OpenRISC, for example, we have user_regs_struct which is an ABI stable version of pt_regs. These may even be identical to begin with, but at least the distinction can be made now between the kernel-internal struct and the ABI stable one.

/Jonas

#28 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

In reply to Arnd Bergmann
Quoted 21 lines · Arnd Bergmann
Quoted 11 lines · Vineet Gupta

+ * Being uClibc based we need some of the deprecated syscalls:
+ * -Not emulated by uClibc at all
+ * unlink, mkdir,... (needed by Busybox, LTP etc)
+ * times (needed by LTP pan test harness)
+ * -Not emulated efficiently
+ * select: emulated using pselect (but extra code to chk usec > 1sec)
+ *
+ * some (send/recv) correctly emulated using (recfrom/sendto) and
+ * some arch specific ones (fork/vfork)can easily be emulated using clone but
+ * thats the price of using common-denominator....
+ */

arch/arc/include/asm/unistd.h line 24

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

I'm pretty sure that this has been solved before, best get in contact with the maintainers of the openrisc/c6x/hexagon platforms, that probably all use uClibc without needing these.

Quoted 1 line

You have to remove the legacy calls here.

Hi Vineet,

FYI, we'll soon be making some uClibc patches available so that it can work without these deprecated syscalls and with the newer IPC interface (the work was needed for metag too). It's based roughly on the OpenRisc patches from last year, but with a fair few changes.

Thanks
James

#14 lore raw

Re: [RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines

In reply to Jonas Bonn
Quoted 23 lines · Jonas Bonn
Quoted 8 lines · Vineet Gupta
Quoted 7 lines · Vineet Gupta

I'd recommend not exporting the pt_regs structure to userspace. This struct is used heavily within the kernel and it's nice to have the leeway to be able to modify it as things evolve. GDB doesn't need to know about this struct anymore as it should be using regset's for any recent architectures anyway, so it's the regset layout that should be ABI stable instead of pt_regs.

Quoted 6 lines
Quoted 1 line

You can check the openrisc architecture as an example of how to do this.

Hi Jonas,

thanks for your review comment. I completely agree that pt_regs should not be exported and very recently a change in pt_regs forced a gdbserver change too (ABI incompatibility) which goes along what you are recommending. Infact the ptrace patch for kernel (which will follow in series #2) provides a stable regset ABI - extracting information from pt_regs.

However our current gdb/gdbserver is 6.8 based and making it switch to regset interface might not be possible for this release of tools. Since customers are already using our stuff, we can not have a broken ABI. We do have ABI versioning, so in next release we can fix gdb and remove this.

For generic syscalls it was generally decided that the upstream kernel would drop support for legacy syscalls, _even though_ userspace bits like uClibc required them. For _new_ architectures, userspace would need to adapt to the _mainline_ kernel; and as a stop-gap for existing software, external patches could be carried in an external git repository where _non-mainline_ kernel patches could be carried to provide a working kernel until userspace could catch up.

Quoted 4 lines

I'd say the same applies here: GDB 6.8 may continue work with a mainline kernel plus a patch that restores the export of pt_regs, but GDB 7.2 (or whatever version you move on to) would be the one that fully supports an unpatched mainline.

So there are 2 points/issues to discuss here.
1. Not exporting pt_regs
2. Asking customers to refer to a non mainline tree.

Will adding a #ifdef __KERNEL__ guard over pt_regs (which my ptrace patch posted today as 33/55 already does), help serve the cause. So we don't export any real "C" structs (pt_regs and/or user_regs_struct....). All we export now is just a bunch of #defs called PT_xxx, to refer to offsets with user_regs_struct.
And it doesn't matter if user_regs_struct has pt_regs as an element - since we don't export the struct at all.

But just to clarify, gdbserver will still use ARC specific ptrace(PEEKUSR) as opposed to regset interface. The switch to new gdb version is non trivial and I can't ask our active customers to go to some out-of-mainline tree until that gets fixed.

Quoted 8 lines
Quoted 1 line

Please note that an additional reason for exporting pt_regs is due to the fact that it is part of sigcontext. Keeping it exactly same as pt_regs helps us do batch save/restore of user context in signal handling (please look at my signal handling patch) but the flip side is that userspace SA_SIGINFO needs to be able to have access to sigcontext and hence we explicitly need pt_regs. We could arguably opencode pt_regs there - but that won't be clean IMHO.

It's not really pt_regs you need here, but the userspace equivalent thereof. On OpenRISC, for example, we have user_regs_struct which is an ABI stable version of pt_regs. These may even be identical to begin with, but at least the distinction can be made now between the kernel-internal struct and the ABI stable one.

/Jonas

maintainer
#15 lore raw

Re: [RFC PATCH v1 08/31] ARC: Fundamental ARCH data-types/defines

Quoted 4 lines · Vineet Gupta

But just to clarify, gdbserver will still use ARC specific ptrace(PEEKUSR) as opposed to regset interface. The switch to new gdb version is non trivial and I can't ask our active customers to go to some out-of-mainline tree until that gets fixed.

But your customers could use an out-of-tree kernel patch to put the implementation of PEEKUSR back into their kernels, right?

Over time, they could just drop that patch once they move to a newer gdb version.

Arnd

#93 lore raw

Re: [RFC PATCH v1 31/31] ARC: [plat-arcfpga] defconfig

In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · Vineet Gupta
---
 arch/arc/configs/fpga_defconfig |  607 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 607 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/configs/fpga_defconfig
Quoted 13 lines

arch/arc/configs/fpga_defconfig line 4

Quoted 10 lines
arch/arc/configs/fpga_defconfig new file +4 -0
new file mode 100644
index 0000000..cfdca3c
@@ -0,0 +1,607 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arc 3.7.0-rc3 Kernel Configuration
+#

Please use "make defconfig" to generate minimal defconfig files, instead of copying the entire file here.

Hi Arnd,

I think you mean "make savedefconfig"? (I think "make defconfig" loads the default defconfig).

Cheers
James

maintainer
#94 lore raw

Re: [RFC PATCH v1 31/31] ARC: [plat-arcfpga] defconfig

Quoted 6 lines · James Hogan
Quoted 3 lines

Please use "make defconfig" to generate minimal defconfig files, instead of copying the entire file here.

I think you mean "make savedefconfig"? (I think "make defconfig" loads the default defconfig).

Yes, that's right. Sorry for the typo.

Arnd

#3 lore raw

Re: [RFC PATCH v1 02/31] ARC: irqflags

In reply to Vineet Gupta

Review

Quoted 6 lines · Vineet Gupta

+ ******************************************************************
+ * Inline ASM macros to read/write AUX Regs
+ * Essentially invocation of lr/sr insns from "C"
+ */

(quoted diff) +2 -0
+
+#if 1

Leftover ???

arch/arc/include/asm/arcregs.h

Quoted 9 lines
arch/arc/include/asm/arcregs.h new file +9 -0
+#define read_aux_reg(reg)	__builtin_arc_lr(reg)
+
+/* gcc builtin sr needs reg param to be long immediate */
+#define write_aux_reg(reg_immed, val)		\
+		__builtin_arc_sr((unsigned int)val, reg_immed)
+
+#else
+/*
+ * Conditionally Enable IRQs

Unconditionally methinks

The following two functions are related to irq chips I guess. So why would you want them here ?

Quoted 7 lines
arch/arc/include/asm/irqflags.h new file +7 -0
+static inline void arch_mask_irq(unsigned int irq)
+{
+	unsigned int ienb;
+
+	ienb = read_aux_reg(AUX_IENABLE);
+	ienb &= ~(1 << irq);
+	write_aux_reg(AUX_IENABLE, ienb);

arch/arc/include/asm/irqflags.h line 122

Quoted 10 lines
arch/arc/include/asm/irqflags.h new file +10 -0
+}
+
+static inline void arch_unmask_irq(unsigned int irq)
+{
+	unsigned int ienb;
+
+	ienb = read_aux_reg(AUX_IENABLE);
+	ienb |= (1 << irq);
+	write_aux_reg(AUX_IENABLE, ienb);
+}

The only user is the interrupt controller code, right?

Quoted 24 lines
arch/arc/kernel/irq.c new file +18 -0
new file mode 100644
index 0000000..16fcbe8
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-12 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <asm/irqflags.h>
+#include <asm/arcregs.h>
+
+void arch_local_irq_enable(void)
+{
+
+	unsigned long flags;

arch/arc/kernel/irq.c line 28

Quoted 10 lines
arch/arc/kernel/irq.c new file +10 -0
+	flags = arch_local_save_flags();
+	flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
+
+	/*
+	 * If called from hard ISR (between irq_enter and irq_exit)
+	 * don't allow Level 1. In Soft ISR we allow further Level 1s
+	 */
+
+	if (in_irq())
+		flags &= ~(STATUS_E1_MASK | STATUS_E2_MASK);

Hmm. This looks weird and the comment is not very helpful. So using my crystal ball you want to enforce, that nothing enables interrupts while a hard interrupt handler is running, right?

Is there a chip limitation which you have to enforce here? If yes, then please explain it.

Btw, all hard interrupt handlers in Linux run with interrupts disabled and they are not supposed to reenable interrupts, which is true for almost all drivers except for a few archaic IDE drivers. In fact you might even WARN about it at least once, so the offending code gets fixed.

Also the code flow is backwards. What about:

     unsigned long flags;

     if (in_irq())
	    return;

     flags = ....	    

arch/arc/kernel/irq.c line 31

Quoted 2 lines
arch/arc/kernel/irq.c new file +2 -0
+	arch_local_irq_restore(flags);
+}

Thanks,

tglx

#23 lore raw

Re: [RFC PATCH v1 12/31] ARC: Interrupt Handling

In reply to Vineet Gupta

arch/arc/kernel/irq.c line 51

Quoted 11 lines · Vineet Gupta
arch/arc/kernel/irq.c +11 -0
+void __init init_IRQ(void)
+{
+	const int irq = TIMER0_IRQ;
+
+	/*
+	 * Each CPU needs to register irq of it's private TIMER0.
+	 * The APIs request_percpu_irq()/enable_percpu_irq() will not be
+	 * functional, if we don't "prep" the generic IRQ sub-system with
+	 * the following:
+	 * -Ensure that devid passed to request_percpu_irq() is indeed per cpu
+	 * -disable NOAUTOEN, w/o which the device handler never gets called

What sets NOAUTOEN in the first place? The core code definitely does not.

arch/arc/kernel/irq.c line 54

Quoted 3 lines
arch/arc/kernel/irq.c +3 -0
+	 */
+	irq_set_percpu_devid(irq);
+	irq_modify_status(irq, IRQ_NOAUTOEN, 0);

Aside of that we have irq_clear_status_flags() for this.

arch/arc/kernel/irq.c

Quoted 4 lines
arch/arc/kernel/irq.c +3 -0
+	plat_init_IRQ();
+}
 
+int __init get_hw_config_num_irq(void)

How is that function used ?

Quoted 6 lines
arch/arc/kernel/irq.c +6 -0
+{
+	uint32_t val = read_aux_reg(ARC_REG_VECBASE_BCR);
+
+	switch (val & 0x03) {
+	case 0:
+		return 16;

arch/arc/kernel/irq.c line 88

Quoted 10 lines
arch/arc/kernel/irq.c +10 -0
+	case 1:
+		return 32;
+	case 2:
+		return 8;
+	default:
+		return 0;
+	}
+
+	return 0;
+}

Thanks,

tglx

#40 lore raw

Re: [RFC PATCH v1 15/31] ARC: Process/scheduling/clock/Timers/Delay Management

In reply to Vineet Gupta
Quoted 6 lines · Vineet Gupta
arch/arc/kernel/process.c +6 -0
+void cpu_idle(void)
+{
+	/* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
+
+	/* endless idle loop with no priority at all */
+	while (1) {

arch/arc/kernel/process.c SYSCALL_DEFINE0(arc_gettls) · line 141

Quoted 10 lines
arch/arc/kernel/process.c +10 -0
+		tick_nohz_idle_enter();
+
+		while (!need_resched())
+			arch_idle();
+
+		tick_nohz_idle_exit();
+
+		preempt_enable_no_resched();
+		schedule();
+		preempt_disable();

schedule_preempt_disabled() please

Quoted 34 lines
(quoted diff) +1 -0
+	}
arch/arc/kernel/time.c +30 -0
 
+static void arc_periodic_timer_setup(unsigned int limit)
+{
+	/* setup start and end markers */
+	write_aux_reg(ARC_REG_TIMER0_LIMIT, limit);
+	write_aux_reg(ARC_REG_TIMER0_CNT, 0);	/* start from 0 */
+
+	/* IE: Interrupt on count = limit,
+	 * NH: Count cycles only when CPU running (NOT Halted)
+	 */
+	write_aux_reg(ARC_REG_TIMER0_CTRL, TIMER_CTRL_IE | TIMER_CTRL_NH);
+}
+
+/*
+ * Acknowledge the interrupt & enable/disable the interrupt
+ */
+static void arc_periodic_timer_ack(unsigned int irq_reenable)
+{
+	/* 1. Ack the interrupt by writing to CTRL reg.
+	 *    Any write will cause intr to be ack, however it has to be one of
+	 *    writable bits (NH: Count when not halted)
+	 * 2. If required by caller, re-arm timer to Interrupt at the end of
+	 *    next cycle.
+	 *
+	 * Small optimisation:
+	 * Normal code would have been
+	 *  if (irq_reenable) CTRL_REG = (IE | NH); else CTRL_REG = NH;
+	 * However since IE is BIT0 we can fold the branch
+	 */
+	write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | TIMER_CTRL_NH);
+}

....

arch/arc/kernel/time.c line 128

Quoted 6 lines
arch/arc/kernel/time.c +6 -0
+/********** Clock Event Device *********/
+
+static int arc_clkevent_set_next_event(unsigned long delta,
+				    struct clock_event_device *dev)
+{
+	arc_periodic_timer_setup(delta);

This is confusing. Is arc_periodic_timer_setup() setting up a periodic timer or a oneshot timer? It looks you use it for both and the differentiation happens in arc_periodic_timer_ack(). So I assume the timer only knows about periodic mode, but you trick it into oneshot with the ack function, right ? So it's just me being confused about the function names, but that could do with some explanatory comments.

arch/arc/kernel/time.c line 135

Quoted 7 lines
arch/arc/kernel/time.c +7 -0
+	return 0;
+}
+
+static void arc_clkevent_set_mode(enum clock_event_mode mode,
+			       struct clock_event_device *dev)
+{
+	pr_info("Device [%s] clockevent mode now [%d]\n", dev->name, mode);

Please remove the debug leftover.

Quoted 14 lines
arch/arc/kernel/time.c +14 -0
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		arc_periodic_timer_setup(CONFIG_ARC_PLAT_CLK / HZ);
+		break;
+	case CLOCK_EVT_MODE_ONESHOT:
+		break;
+	default:
+		break;
+	}
+
+	return;
+}
+
+static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {

arch/arc/kernel/time.c line 159

Quoted 10 lines
arch/arc/kernel/time.c +10 -0
+	.name		= "ARC Timer0",
+	.features	= CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
+	.mode		= CLOCK_EVT_MODE_UNUSED,
+	.rating		= 300,
+	.irq		= TIMER0_IRQ,	/* hardwired, no need for resources */
+	.set_next_event = arc_clkevent_set_next_event,
+	.set_mode	= arc_clkevent_set_mode,
+};
+
+irqreturn_t timer_irq_handler(int irq, void *dev_id)

static please

Quoted 12 lines
arch/arc/kernel/time.c +12 -0
+static int arc_finished_booting;
+
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ * It's return value must NOT wrap around.
+ *
+ * Although the return value is nanosec units based, what's more important
+ * is whats the "source" of this value. The orig jiffies based computation
+ * was only as granular as jiffies itself (10ms on ARC).
+ * We need something that is more granular, so use the same mechanism as
+ * gettimeofday(), which uses ARC Timer T1 wrapped as a clocksource.
+ * Unfortunately the first call to sched_clock( ) is way before that subsys

arch/arc/kernel/time.c line 226

Quoted 10 lines
arch/arc/kernel/time.c +10 -0
+ * is initialiased, thus use the jiffies based value in the interim.
+ */
+unsigned long long sched_clock(void)
+{
+	if (!arc_finished_booting) {
+		return (unsigned long long)(jiffies - INITIAL_JIFFIES)
+		    * (NSEC_PER_SEC / HZ);
+	} else {
+		struct timespec ts;
+		getrawmonotonic(&ts);

This can live lock. sched_clock() is used by the tracer. So assume you are function tracing and you trace a function called from within the timekeeping seqcount write "locked" region. You spin forever in getrawmonotonic(). Not what you want, right ?

Thanks,

tglx

#34 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Vineet Gupta

+ * Being uClibc based we need some of the deprecated syscalls:
+ * -Not emulated by uClibc at all
+ * unlink, mkdir,... (needed by Busybox, LTP etc)
+ * times (needed by LTP pan test harness)
+ * -Not emulated efficiently
+ * select: emulated using pselect (but extra code to chk usec > 1sec)
+ *

Quoted 6 lines

...
I'm pretty sure that this has been solved before, best get in contact with the maintainers of the openrisc/c6x/hexagon platforms, that probably all use uClibc without needing these.

You have to remove the legacy calls here.

So, I completely agree about not adding more deprecated system call or ABIs (thinking about the ptrace regset issues in another patch in the same patchset), but on the other hand I have to wonder if having a port in the tree that doesn't have a working C library or a debugger makes sense.

I mean, it is not quite the same thing as saying: "well, users of the old versions of the user tools will need to maintain out of tree patches". That makes sense - it puts the burden of maintenance on people clinging to new versions when newer one exists, but this is not what is happening with Arc. Right now, there are no working version of the tools for Arc, so everyone will need to use the out of tree patches.

I wonder what is worse - having an in tree port that no one (can) use or adding some deprecated crap (sorry...), clearly marked for deletion the minute a version of the relevant user tools exists that can be used with the new mechanisms?

Just my 2c as an Arc kernel port user,
Gilad

Signature · 10 lines
Gilad Ben-Yossef
Chief Coffee Drinker
[email protected]
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru
maintainer
#35 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

Quoted 14 lines · Gilad Ben-Yossef

So, I completely agree about not adding more deprecated system call or ABIs (thinking about the ptrace regset issues in another patch in the same patchset), but on the other hand I have to wonder if having a port in the tree that doesn't have a working C library or a debugger makes sense.

I mean, it is not quite the same thing as saying: "well, users of the old versions of the user tools will need to maintain out of tree patches". That makes sense - it puts the burden of maintenance on people clinging to new versions when newer one exists, but this is not what is happening with Arc. Right now, there are no working version of the tools for Arc, so everyone will need to use the out of tree patches.

Quoted 4 lines

I wonder what is worse - having an in tree port that no one (can) use or adding some deprecated crap (sorry...), clearly marked for deletion the minute a version of the relevant user tools exists that can be used with the new mechanisms?

The point is that all existing users already need to rebuild all their user space since the upstream version is using the generic system call numbers. What I want to avoid is breaking everything twice, and the most logical point to do that is when moving from an out-of-tree kernel fork to the mainline version.

If mainline doesn't work for you yet, the most logical choice is to stay on whatever kernel you have working right now, and only change over to the upstream version once it works with an ABI that we want to maintain in the long term. Obviously I can't stop from using a mix of the two while you are waiting for (or working on) getting gdb and uclibc supported with the new interface, but my recommendation is not to ship that in products to end-users that would suffer from another ABI change later on.

What I'm trying to enforce here is that the upstream version follows the exact same rules that we apply to all other ports, which is that we don't break existing user space that was running with an older upstream kernel.

Arnd

#29 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

In reply to James Hogan
Quoted 22 lines · James Hogan
Quoted 21 lines · Arnd Bergmann
Quoted 11 lines · Vineet Gupta

+ * Being uClibc based we need some of the deprecated syscalls:
+ * -Not emulated by uClibc at all
+ * unlink, mkdir,... (needed by Busybox, LTP etc)
+ * times (needed by LTP pan test harness)
+ * -Not emulated efficiently
+ * select: emulated using pselect (but extra code to chk usec > 1sec)
+ *
+ * some (send/recv) correctly emulated using (recfrom/sendto) and
+ * some arch specific ones (fork/vfork)can easily be emulated using clone but
+ * thats the price of using common-denominator....
+ */

arch/arc/include/asm/unistd.h line 24

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

I'm pretty sure that this has been solved before, best get in contact with the maintainers of the openrisc/c6x/hexagon platforms, that probably all use uClibc without needing these.

Quoted 6 lines
Quoted 1 line

You have to remove the legacy calls here.

FYI, we'll soon be making some uClibc patches available so that it can work without these deprecated syscalls and with the newer IPC interface (the work was needed for metag too). It's based roughly on the OpenRisc patches from last year, but with a fair few changes.

Hi Vineet,

The uClibc patches I mentioned have been posted, see here:

http://lists.busybox.net/pipermail/uclibc/2012-November/047110.html

Please do try them out and provide any feedback.

Cheers
James

#30 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

Quoted 6 lines · James Hogan

The uClibc patches I mentioned have been posted, see here:

http://lists.busybox.net/pipermail/uclibc/2012-November/047110.html

Please do try them out and provide any feedback.

Hi James,

Many thanks for picking this up...

This is the third time around for trying to get this into uClibc as Mark Salter also pushed a patch set which got about as much feedback (almost none) on the list as mine did. His patchset, like yours, preferred the "old" syscalls when present.

...and that gets me around to the question: why should the "old" syscalls be preferred? I'm specifically asking this here because I'm curious what the kernel developers' take on this is.

Regards,
Jonas

#31 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

Quoted 12 lines · Jonas Bonn
Quoted 6 lines · James Hogan

The uClibc patches I mentioned have been posted, see here:

http://lists.busybox.net/pipermail/uclibc/2012-November/047110.html

Please do try them out and provide any feedback.

Hi James,

Many thanks for picking this up...

Quoted 8 lines

This is the third time around for trying to get this into uClibc as Mark Salter also pushed a patch set which got about as much feedback (almost none) on the list as mine did. His patchset, like yours, preferred the "old" syscalls when present.

...and that gets me around to the question: why should the "old" syscalls be preferred? I'm specifically asking this here because I'm curious what the kernel developers' take on this is.

Hi Jonas,

Hopefully with several architecture maintainers asking for this it might get somewhere, but indeed we're aware of the feedback problem on that list.

The points that I've considered for defaulting to old syscalls:
* doesn't change existing behaviour of other architectures, so is simply less risk of breaking them.
* could possibly make uClibc slightly smaller if it doesn't have to add extra arguments.

against:
* if defaulted to new syscalls, could give customers a chance to rebuild their libc so that when deprecated syscalls are removed they don't notice.

Cheers
James

maintainer
#32 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

Quoted 8 lines · James Hogan

Hopefully with several architecture maintainers asking for this it might get somewhere, but indeed we're aware of the feedback problem on that list.

The points that I've considered for defaulting to old syscalls:
* doesn't change existing behaviour of other architectures, so is simply less risk of breaking them.
* could possibly make uClibc slightly smaller if it doesn't have to add extra arguments.

The second argument is not very good when you consider that it means adding the same wrapper into the kernel rather than into uClibc, where it can be stripped out when unused (e.g. for static compilation) and doesn't have to be present in memory since the library is in pageable user space memory, while the kernel side implementation would always have to present.

Arnd

#33 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · James Hogan

Hopefully with several architecture maintainers asking for this it might get somewhere, but indeed we're aware of the feedback problem on that list.

The points that I've considered for defaulting to old syscalls:
* doesn't change existing behaviour of other architectures, so is simply less risk of breaking them.
* could possibly make uClibc slightly smaller if it doesn't have to add extra arguments.

Quoted 6 lines

The second argument is not very good when you consider that it means adding the same wrapper into the kernel rather than into uClibc, where it can be stripped out when unused (e.g. for static compilation) and doesn't have to be present in memory since the library is in pageable user space memory, while the kernel side implementation would always have to present.

The context is existing architectures which already have to support the deprecated syscalls pretty much forever (in addition to the new ones), and therefore can't strip out the kernel side implementation anyway.

I don't see any of these arguments (either way) as holding too much weight to be honest though.

Cheers
James

#36 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

In reply to Arnd Bergmann
Quoted 19 lines · Arnd Bergmann
Quoted 14 lines · Gilad Ben-Yossef

So, I completely agree about not adding more deprecated system call or ABIs (thinking about the ptrace regset issues in another patch in the same patchset), but on the other hand I have to wonder if having a port in the tree that doesn't have a working C library or a debugger makes sense.

I mean, it is not quite the same thing as saying: "well, users of the old versions of the user tools will need to maintain out of tree patches". That makes sense - it puts the burden of maintenance on people clinging to new versions when newer one exists, but this is not what is happening with Arc. Right now, there are no working version of the tools for Arc, so everyone will need to use the out of tree patches.

Quoted 4 lines

I wonder what is worse - having an in tree port that no one (can) use or adding some deprecated crap (sorry...), clearly marked for deletion the minute a version of the relevant user tools exists that can be used with the new mechanisms?

Quoted 5 lines

The point is that all existing users already need to rebuild all their user space since the upstream version is using the generic system call numbers. What I want to avoid is breaking everything twice, and the most logical point to do that is when moving from an out-of-tree kernel fork to the mainline version.

I completely agree.

Quoted 9 lines

If mainline doesn't work for you yet, the most logical choice is to stay on whatever kernel you have working right now, and only change over to the upstream version once it works with an ABI that we want to maintain in the long term. Obviously I can't stop from using a mix of the two while you are waiting for (or working on) getting gdb and uclibc supported with the new interface, but my recommendation is not to ship that in products to end-users that would suffer from another ABI change later on.

Quoted 4 lines

What I'm trying to enforce here is that the upstream version follows the exact same rules that we apply to all other ports, which is that we don't break existing user space that was running with an older upstream kernel.

So the primary concern here is not breaking the userspace ABI - right ?

For syscalls I agree that we will indeed need to fix the ABI - by fixing uClibc. And if uClibc doesn't merge the fixes we can stay out of tree for uClibc - as we currently already are.

For gdbserver, the kernel provides the complete regset ABI. However it also provides a very limited version of old ABI - i.e. ptrace with PEEKUSR/POKEUSR. Note that latter is just a shim layer and it reuses the regset callbacks. This allows us to support the legacy gdbserver. If and when gdbserver upgrades it can switch over to new interface. So all along there will be NO ABI breakage at all. The cost is couple extra functions in kernel which we might have to maintain for some foreseeable future. Agree ?

-Vineet

maintainer
#37 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

Quoted 5 lines · Vineet Gupta

So the primary concern here is not breaking the userspace ABI - right ?

For syscalls I agree that we will indeed need to fix the ABI - by fixing uClibc. And if uClibc doesn't merge the fixes we can stay out of tree for uClibc - as we currently already are.

I'm sure we can find a solution for uClibc. We already have seven architectures using the generic syscalls, including at least one (arm64) that is going to run on a large number of installations in the future.

Quoted 8 lines

For gdbserver, the kernel provides the complete regset ABI. However it also provides a very limited version of old ABI - i.e. ptrace with PEEKUSR/POKEUSR. Note that latter is just a shim layer and it reuses the regset callbacks. This allows us to support the legacy gdbserver. If and when gdbserver upgrades it can switch over to new interface. So all along there will be NO ABI breakage at all. The cost is couple extra functions in kernel which we might have to maintain for some foreseeable future. Agree ?

It's more a question of principle. The rule is that we don't break user space, and ptrace is just another user space interface is this. If we merge it now, we will keep it around forever, taking it out later is not an option IMHO. My preference would be not to merge the backwards compatibility layer for ptrace at all, but I'm willing to listen to other people that support your view if you want to keep it. In one way, ptrace is less critical than the other system calls, and that is because it's already architecture specific.

Arnd

#82 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Vineet Gupta

Hi Vineet,

Quoted 1 line · Vineet Gupta

+config ARC

I just came across arch/mips/Kconfig which also defines ARC (and ARC32). It's only used within arch/mips/, however it's probably more likely that your ARC/CONFIG_ARC will find it's way into the generic bits of the kernel which could get hit when the other ARC is defined.

Perhaps it's worth getting the other ARC renamed just in case?

Cheers
James

#83 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 9 lines · James Hogan
Quoted 1 line · Vineet Gupta

+config ARC

I just came across arch/mips/Kconfig which also defines ARC (and ARC32). It's only used within arch/mips/, however it's probably more likely that your ARC/CONFIG_ARC will find it's way into the generic bits of the kernel which could get hit when the other ARC is defined.

Perhaps it's worth getting the other ARC renamed just in case?

The MIPS world surely isn't as attached to the CONFIG_ARC config symbol as Synopsis so I'm going to rename CONFIG_ARC and a few other firmware related config symbols to use a consistent prefix of CONFIG_FW_.

Ralf

#89 lore raw

Re: [RFC PATCH v1 30/31] ARC: switch to generic kernel_execve() and sys_execve()

In reply to Vineet Gupta

arch/arc/kernel/entry.S ARC_ENTRY ret_from_kernel_thread · line 597

Quoted 7 lines · Vineet Gupta
arch/arc/kernel/entry.S +7 -0
+; When we land here, pt_regs have already been updated in-place correctly
+; A pointer to them is also passed by kernel_execve, we just need to make sure
+; that SP is set to point to them.
+ARC_ENTRY ret_from_kernel_execve
+	; Force SP to "normal" pt_regs just populated.
+	b.d   ret_from_system_call
+	mov   sp, r0

won't that splatter crap into regs->r0? IOW, why not branch to ret_from_exception here?

Quoted 1 line

+ARC_EXIT ret_from_kernel_execve

Another thing: why not fold that branch to ret_from_exception into the end of ret_from_kernel_thread() (instead of calling sys_exit()), select GENERIC_KERNEL_EXECVE and lose __ARCH_WANT_KERNEL_EXECVE.

Actually, now that I look at your ret_from_kernel_thread... How the hell will it cope with kernel_thread() payload trying to return? AFAICS, this j.d [r1] will lose the return address, won't it? And while we are at it, I would suggest passing callback and its argument via callee-saved registers - makes for simpler life in ret_from_kernel_thread(), since switch_to() itself will take care of loading those...

#19 lore raw

Re: [RFC PATCH v1 11/31] ARC: Low level IRQ/Trap/Exception(non-MMU) Handling

In reply to Vineet Gupta
Quoted 9 lines
arch/arc/kernel/entry.S new file +9 -0
+	; --------- check for signals/restore-sigmask ------------
+	bbit0  r9, TIF_SIGPENDING, chk_next_work
+
+	; save CALLEE Regs.
+	; (i)  If this signal causes coredump - full regfile needed
+	; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
+	;      tracer might call PEEKUSR for a CALLEE reg
+	;
+	; NOTE: SP will grow up by size of CALLEE Reg-File

arch/arc/kernel/entry.S line 492

Quoted 10 lines
arch/arc/kernel/entry.S new file +10 -0
+	SAVE_CALLEE_SAVED_USER		; clobbers r12
+
+	; save location of saved Callee Regs @ thread_struct->callee
+	GET_CURR_TASK_FIELD_PTR   TASK_THREAD, r10
+	st  sp, [r10, THREAD_CALLEE_REG]
+
+	bl  @do_signal
+
+	; unwind SP for cheap discard of Callee saved Regs
+	DISCARD_CALLEE_SAVED_USER

Uh-oh... And what if tracer wanted to modify callee-saved regs?

arch/arc/kernel/entry.S line 503

Quoted 10 lines
arch/arc/kernel/entry.S new file +10 -0
+	b      resume_user_mode_begin	; loop back to start of U mode ret
+
+	; --- notify_resume ---
+chk_next_work:
+	btst   r9, TIF_NOTIFY_RESUME
+	blnz   @do_notify_resume
+
+	;--------- All things done, go back to Userland ------
+
+	b restore_regs

No. After NOTIFY_RESUME stuff you need to recheck SIGPENDING. This should go to resume_user_mode_begin, not restore regs. Another problem here is IRQ handling - you hit do_signal()/do_notify_resume() with IRQs disabled, which is broken - you need to re-enable it before going into either.

#45 lore raw

Re: [RFC PATCH v1 16/31] ARC: Signal handling

In reply to Vineet Gupta

arch/arc/kernel/signal.c line 345

Quoted 10 lines
arch/arc/kernel/signal.c new file +10 -0
+	if (insyscall) {
+		/* No handler for syscall: restart it */
+		if (regs->r0 == -ERESTARTNOHAND ||
+		    regs->r0 == -ERESTARTSYS || regs->r0 == -ERESTARTNOINTR) {
+			regs->r0 = regs->orig_r0;
+			regs->ret -= 4;
+		} else if (regs->r0 == -ERESTART_RESTARTBLOCK) {
+			regs->r8 = __NR_restart_syscall;
+			regs->ret -= 4;
+		}

What's to prevent double decrement on ->ret if two signals arrive? Note
that e.g. x86 gets away with similar code only because it uses the same register for syscall number and return value; since none of -ERESTART... is a valid syscall number, we either won't get into an analog of that code at all (-ENOSYS is not restart-worthy) or will revert to a value that is a valid syscall number, so all subsequent do_signal() calls will not hit that code. This is subtle and unfortunately not spelled out in the architectures where it is enough.

You need to make sure that after the first restart in_syscall() will be false. Same ought to be done in sigreturn(), BTW...

#84 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Ralf Baechle
Quoted 9 lines · Ralf Baechle
Quoted 7 lines · James Hogan
Quoted 1 line · Vineet Gupta

+config ARC

I just came across arch/mips/Kconfig which also defines ARC (and ARC32). It's only used within arch/mips/, however it's probably more likely that your ARC/CONFIG_ARC will find it's way into the generic bits of the kernel which could get hit when the other ARC is defined.

Quoted 4 lines
Quoted 1 line

Perhaps it's worth getting the other ARC renamed just in case?

The MIPS world surely isn't as attached to the CONFIG_ARC config symbol as Synopsis so I'm going to rename CONFIG_ARC and a few other firmware related config symbols to use a consistent prefix of CONFIG_FW_.

Thanks Ralf !

-Vineet

Quoted 1 line

Ralf

#90 lore raw

Re: [RFC PATCH v1 30/31] ARC: switch to generic kernel_execve() and sys_execve()

In reply to Al Viro
Quoted 10 lines · Al Viro

arch/arc/kernel/entry.S ARC_ENTRY ret_from_kernel_thread · line 597

Quoted 7 lines · Vineet Gupta
arch/arc/kernel/entry.S +7 -0
+; When we land here, pt_regs have already been updated in-place correctly
+; A pointer to them is also passed by kernel_execve, we just need to make sure
+; that SP is set to point to them.
+ARC_ENTRY ret_from_kernel_execve
+	; Force SP to "normal" pt_regs just populated.
+	b.d   ret_from_system_call
+	mov   sp, r0

won't that splatter crap into regs->r0? IOW, why not branch to ret_from_exception here?

Yes it does - although I didn't notice the ill-effect since execve as an API doesn't expect r0 to have a certain value (like fork for child). Fixed in next revision.

Quoted 5 lines
Quoted 2 lines

+ARC_EXIT ret_from_kernel_execve

Another thing: why not fold that branch to ret_from_exception into the end of ret_from_kernel_thread() (instead of calling sys_exit()), select GENERIC_KERNEL_EXECVE and lose __ARCH_WANT_KERNEL_EXECVE.

If you noticed I only had 3 patches and didn't have the equivalent of "switch to saner kernel_execve() semantics" which would achieve above because the bug you elucidate to below was giving me grief in bring up (and I couldn't spend enough time debugging it).

Quoted 3 lines

Actually, now that I look at your ret_from_kernel_thread... How the hell will it cope with kernel_thread() payload trying to return? AFAICS, this j.d [r1] will lose the return address, won't it?

Exactly so. I was missing the equivalent of following

ARC_ENTRY ret_from_kernel_thread

	bl  @schedule_tail
	ld  r1, [sp, PT_r1]
-	j.d [r1]
+	jl.d [r1]
        ld  r0, [sp, PT_r0]
	j   @sys_exit

ARC_EXIT ret_from_kernel_thread

And since none of the bootup kernel threads took the return path I had a working system - the problem only showed up when kernel_execve( ) started returning to exercise the broken path above.

Quoted 4 lines

And while we are at it,
I would suggest passing callback and its argument via callee-saved registers - makes for simpler life in ret_from_kernel_thread(), since switch_to() itself will take care of loading those...

Absolutely - done that too !

Would you prefer to take a look at the updated patches now or will you rather wait for v2 series which might take a week or two.

Thanks for taking the time to review this stuff.

-Vineet

#98 lore raw
In reply to Vineet Gupta

Hi!

Quoted 3 lines

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

Huh. arch/arc is very similar to arch/arm. So similar that it took me 10 minutes to figure out. I guess theres no alternate name arc could use?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#100 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek

Hi!

Quoted 3 lines

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

Huh. arch/arc is very similar to arch/arm. So similar that it took me 10 minutes to figure out. I guess theres no alternate name arc could use?

Hmm... "Advanced Risc"... :-(.

Ok, plus there's already computing standard called "arc".

https://www.linux-mips.org/wiki/ARC

What about calling the architecture "sarc" or "syarc" ?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#101 lore raw
Quoted 9 lines · Pavel Machek
Quoted 8 lines · Pavel Machek

Hi!

Quoted 3 lines

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

Huh. arch/arc is very similar to arch/arm. So similar that it took me 10 minutes to figure out. I guess theres no alternate name arc could use?

Quoted 7 lines

Hmm... "Advanced Risc"... :-(.

Ok, plus there's already computing standard called "arc".

https://www.linux-mips.org/wiki/ARC

What about calling the architecture "sarc" or "syarc" ?

I think it would be best use of everybody's time if you could focus on the technical content of the port rather than the name. It has been like that for +10 years and I don't intend to make the kernel port name different from THE arch name itself.

Quoted 2 lines

Pavel

#20 lore raw

Re: [RFC PATCH v1 11/31] ARC: Low level IRQ/Trap/Exception(non-MMU) Handling

In reply to Al Viro
Quoted 12 lines · Al Viro
Quoted 12 lines
arch/arc/kernel/entry.S new file +12 -0
+	; --------- check for signals/restore-sigmask ------------
+	bbit0  r9, TIF_SIGPENDING, chk_next_work
+
+	; save CALLEE Regs.
+	; (i)  If this signal causes coredump - full regfile needed
+	; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
+	;      tracer might call PEEKUSR for a CALLEE reg
+	;
+	; NOTE: SP will grow up by size of CALLEE Reg-File
+	SAVE_CALLEE_SAVED_USER		; clobbers r12
+
+	; save location of saved Callee Regs @ thread_struct->callee
Quoted 8 lines

arch/arc/kernel/entry.S line 492

Quoted 7 lines
arch/arc/kernel/entry.S new file +7 -0
+	GET_CURR_TASK_FIELD_PTR   TASK_THREAD, r10
+	st  sp, [r10, THREAD_CALLEE_REG]
+
+	bl  @do_signal
+
+	; unwind SP for cheap discard of Callee saved Regs
+	DISCARD_CALLEE_SAVED_USER

Uh-oh... And what if tracer wanted to modify callee-saved regs?

So the solution would be to either unconditionally restore all the 13 callee regs
- or add additional state (struct thread) where ptrace makes a note that it wrote to a callee reg which is used here to conditional-ize the restore. Former is simpler to do - although it might ill-affect micro-benchmarks such as LMBench lat_sig. Anyhow correctness comes before optimization.

Quoted 13 lines

arch/arc/kernel/entry.S line 503

Quoted 11 lines
arch/arc/kernel/entry.S new file +10 -0
+	b      resume_user_mode_begin	; loop back to start of U mode ret
+
+	; --- notify_resume ---
+chk_next_work:
+	btst   r9, TIF_NOTIFY_RESUME
+	blnz   @do_notify_resume
+
+	;--------- All things done, go back to Userland ------
+
+	b restore_regs

No. After NOTIFY_RESUME stuff you need to recheck SIGPENDING. This should go to resume_user_mode_begin, not restore regs.

Thanks for pointing this - fixed in v2 series.

Quoted 3 lines

Another problem here is
IRQ handling - you hit do_signal()/do_notify_resume() with IRQs disabled, which is broken - you need to re-enable it before going into either.

Thanks - fixed that as well. I presume it is broken for "interrupt latency reasons" and not because IRQs could remain disabled all the way into usermode - since given the way RTIE insn works - that won't happen. Although independently this was indeed cause of a WARN_ON_ONCE when bh were enabled with IRQs disabled.

#21 lore raw

Re: [RFC PATCH v1 11/31] ARC: Low level IRQ/Trap/Exception(non-MMU) Handling

Quoted 22 lines · Vineet Gupta
Quoted 12 lines · Al Viro
Quoted 12 lines
arch/arc/kernel/entry.S new file +12 -0
+	; --------- check for signals/restore-sigmask ------------
+	bbit0  r9, TIF_SIGPENDING, chk_next_work
+
+	; save CALLEE Regs.
+	; (i)  If this signal causes coredump - full regfile needed
+	; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
+	;      tracer might call PEEKUSR for a CALLEE reg
+	;
+	; NOTE: SP will grow up by size of CALLEE Reg-File
+	SAVE_CALLEE_SAVED_USER		; clobbers r12
+
+	; save location of saved Callee Regs @ thread_struct->callee
Quoted 8 lines

arch/arc/kernel/entry.S line 492

Quoted 7 lines
arch/arc/kernel/entry.S new file +7 -0
+	GET_CURR_TASK_FIELD_PTR   TASK_THREAD, r10
+	st  sp, [r10, THREAD_CALLEE_REG]
+
+	bl  @do_signal
+
+	; unwind SP for cheap discard of Callee saved Regs
+	DISCARD_CALLEE_SAVED_USER

Uh-oh... And what if tracer wanted to modify callee-saved regs?

Quoted 5 lines

So the solution would be to either unconditionally restore all the 13 callee regs
- or add additional state (struct thread) where ptrace makes a note that it wrote to a callee reg which is used here to conditional-ize the restore. Former is simpler to do - although it might ill-affect micro-benchmarks such as LMBench lat_sig. Anyhow correctness comes before optimization.

Havign coded above, I just couldn't accept the anti-optimization here. Is it absolute sin to take a look at current->ptrace != 0 in deciding whether to save/restore the regs. However that won't work for coredump case.

#46 lore raw

Re: [RFC PATCH v1 16/31] ARC: Signal handling

In reply to Al Viro
Quoted 11 lines · Al Viro

arch/arc/kernel/signal.c line 345

Quoted 10 lines
arch/arc/kernel/signal.c new file +10 -0
+	if (insyscall) {
+		/* No handler for syscall: restart it */
+		if (regs->r0 == -ERESTARTNOHAND ||
+		    regs->r0 == -ERESTARTSYS || regs->r0 == -ERESTARTNOINTR) {
+			regs->r0 = regs->orig_r0;
+			regs->ret -= 4;
+		} else if (regs->r0 == -ERESTART_RESTARTBLOCK) {
+			regs->r8 = __NR_restart_syscall;
+			regs->ret -= 4;
+		}
Quoted 8 lines

What's to prevent double decrement on ->ret if two signals arrive? Note
that e.g. x86 gets away with similar code only because it uses the same register for syscall number and return value; since none of -ERESTART... is a valid syscall number, we either won't get into an analog of that code at all (-ENOSYS is not restart-worthy) or will revert to a value that is a valid syscall number, so all subsequent do_signal() calls will not hit that code. This is subtle and unfortunately not spelled out in the architectures where it is enough.

Ok that is fixed now, by saving additional state in pt_regs->orig_r8 (which required redoing how we kept information in it).

- long orig_r8; /*to distinguish bet excp, sys call, int1 or int2

-                         * syscalls   -> 1 to NR_SYSCALLS
-                         * Exceptions -> NR_SYSCALLS + 1
-                         * Break-point-> NR_SYSCALLS + 2
-                         */

+ unsigned long event_type:16, orig_r8:16;

Alternately, I could have set orig_r8 to a special value, that would have been simpler, but it would have meant potential breakage if one of the intermediate signals was tracing related - leading to a ptrace(peekxxx) which relies on orig_r8 to have correct state. Also there's tracehook stuff which could enquire for orig syscall number in orig_r8.

Quoted 3 lines

You need to make sure that after the first restart in_syscall() will be false. Same ought to be done in sigreturn(), BTW...

Sure, this becomes very simple given the infrastructure above - patches follow for you to take a quick peek.

Also on the topic, it seems the altstack handling is done unconditionally by most of arches - while ARC Port does it based on a magic value. The reason being to avoid needless calling (only to return) in sigreturn path. What's the recommendation there.

Thx,
Vineet

#48 lore raw

PATCH 2/2 ARC: [Review] Prevent incorrect syscall restarts

In reply to Vineet Gupta

Per Al Viro's "signals for dummies" https://lkml.org/lkml/2012/12/6/366
there are 3 golden rules for (not) restarting syscalls:

" What we need to guarantee is
* restarts do not happen on signals caught in interrupts or exceptions
* restarts do not happen on signals caught in sigreturn()
* restart should happen only once, even if we get through do_signal() many times."

ARC Port already handled #1, this patch fixes #2 and #3.

We use the additional state in pt_regs->orig_r8 to ckh if restarting has already been done once.

Thanks to Al Viro for spotting this.

---
 arch/arc/include/asm/ptrace.h |    3 +++
 arch/arc/kernel/signal.c      |   12 ++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
arch/arc/include/asm/ptrace.h +3 -0
index 7daa3a6..caf216e 100644
@@ -93,6 +93,9 @@ struct user_regs_struct {
 #define in_syscall(regs) (regs->orig_r8 & orig_r8_IS_SCALL)
 #define in_brkpt_trap(regs) (regs->orig_r8 & orig_r8_IS_BRKPT)
 
+#define syscall_wont_restart(regs) (regs->orig_r8 |= orig_r8_IS_SCALL_RESTARTED)
+#define syscall_restartable(regs) !(regs->orig_r8 & orig_r8_IS_SCALL_RESTARTED)
+
 #define current_pt_regs()					\
 ({								\
 	/* open-coded current_thread_info() */			\
arch/arc/kernel/signal.c +8 -4
index 464af3f..6671968 100644
@@ -137,6 +137,9 @@ SYSCALL_DEFINE0(rt_sigreturn)
 		if (do_sigaltstack(&sf->uc.uc_stack, NULL, regs->sp) == -EFAULT)
 			goto badframe;
 
+	/* Don't restart from sigreturn */
+	syscall_wont_restart(regs);
+
 	return regs->r0;
 
 badframe:
@@ -331,13 +334,13 @@ void do_signal(struct pt_regs *regs)
 
 	signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 
-	/* Are we from a system call? */
-	restart_scall = in_syscall(regs);
+	restart_scall = in_syscall(regs) && syscall_restartable(regs);
 
 	if (signr > 0) {
-		if (restart_scall)
+		if (restart_scall) {
 			arc_restart_syscall(&ka, regs);
-
+			syscall_wont_restart(regs);	/* No more restarts */
+		}
 		handle_signal(signr, &ka, &info, regs);
 		return;
 	}
@@ -352,6 +355,7 @@ void do_signal(struct pt_regs *regs)
 			regs->r8 = __NR_restart_syscall;
 			regs->ret -= 4;
 		}
+		syscall_wont_restart(regs);	/* No more restarts */
 	}
 
 	/* If there's no signal to deliver, restore the saved sigmask back */
Signature · 1 line
1.7.4.1
#47 lore raw

PATCH 1/2 ARC: [Review] Preparing to fix incorrect syscall restarts due to signals

In reply to Vineet Gupta

To avoid multiple syscall restarts (multiple signals) or no restart at all (sigreturn), we need just an extra bit of state "literally 1 bit" in struct pt_regs. orig_r8 is the best place to do this, however given the way it is encoded currently, we can't add anything simplistically.

Current orig_r8:
* syscalls -> 1 to NR_SYSCALLS
* Exceptions -> NR_SYSCALLS + 1
* Break-point-> NR_SYSCALLS + 2

In new scheme it is a bit-field
* lower short word contains the exact event type (and a new bit to represent restart semantics : if syscall was already / can't be restarted)
* upper short word optionally containing the syscall num - needed by likes of tracehooks etc

This change only changes the value orig_r8 is organised and nothing should change behaviourily.

---
 arch/arc/include/asm/entry.h  |   31 ++++++++++++++++++-------------
 arch/arc/include/asm/ptrace.h |   17 ++++++++++++-----
 arch/arc/kernel/entry.S       |   10 +++++-----
 3 files changed, 35 insertions(+), 23 deletions(-)
arch/arc/include/asm/entry.h +18 -13
index 4b8619e..414007a 100644
@@ -415,18 +415,12 @@
  *-------------------------------------------------------------*/
 .macro SAVE_ALL_EXCEPTION   marker
 
+	st      \marker, [sp, 8]
+	st      r0, [sp, 4]    /* orig_r0, needed only for sys calls */
+
 	/* Restore r9 used to code the early prologue */
 	EXCPN_PROLOG_RESTORE_REG  r9
 
-	/* Save the complete regfile now */
-
-	/* orig_r8 marker:
-	 * syscalls   -> 1 to NR_SYSCALLS
-	 * Exceptions -> NR_SYSCALLS + 1
-	 * Break-point-> NR_SYSCALLS + 2
-	 */
-	st      \marker, [sp, 8]
-	st      r0, [sp, 4]    /* orig_r0, needed only for sys calls */
 	SAVE_CALLER_SAVED
 	st.a    r26, [sp, -4]   /* gp */
 	st.a    fp, [sp, -4]
@@ -456,14 +450,25 @@
  * Save scratch regs for exceptions
  *-------------------------------------------------------------*/
 .macro SAVE_ALL_SYS
-	SAVE_ALL_EXCEPTION  (NR_syscalls + 1)
+	SAVE_ALL_EXCEPTION  orig_r8_IS_EXCPN
 .endm
 
 /*--------------------------------------------------------------
  * Save scratch regs for sys calls
  *-------------------------------------------------------------*/
 .macro SAVE_ALL_TRAP
-	SAVE_ALL_EXCEPTION  r8
+	/*
+	 * Encode syscall number (r8) in upper short word of event type (r9)
+	 * (r9 is already clobbered when we land here)
+	 */
+#ifndef CONFIG_CPU_BIG_ENDIAN
+	lsl  r9, r8, 16
+	or   r9, r9, orig_r8_IS_SCALL
+#else
+	lsl  r9, orig_r8_IS_SCALL, 16
+	or   r9, r9, r8
+#endif
+	SAVE_ALL_EXCEPTION  r9
 .endm
 
 /*--------------------------------------------------------------
@@ -518,7 +523,7 @@
 #endif
 
 	/* now we are ready to save the remaining context :) */
-	st     -1, [sp, 8]    /* orig_r8, -1 for interuppt level one */
+	st      orig_r8_IS_IRQ1, [sp, 8]    /* Event Type */
 	st      0, [sp, 4]    /* orig_r0 , N/A for IRQ */
 	SAVE_CALLER_SAVED
 	st.a    r26, [sp, -4]   /* gp */
@@ -553,7 +558,7 @@
 	ld  r9, [@int2_saved_reg]
 
 	/* now we are ready to save the remaining context :) */
-	st     -2, [sp, 8]    /* orig_r8, -2 for interrupt level 2 */
+	st      orig_r8_IS_IRQ2, [sp, 8]    /* Event Type */
 	st      0, [sp, 4]    /* orig_r0 , N/A for IRQ */
 	SAVE_CALLER_SAVED
 	st.a    r26, [sp, -4]   /* gp */
arch/arc/include/asm/ptrace.h +12 -5
index f38580c..7daa3a6 100644
@@ -50,7 +50,8 @@ struct pt_regs {
 	long r0;
 	long sp;	/* user/kernel sp depending on where we came from  */
 	long orig_r0;
-	long orig_r8;	/*to distinguish bet excp, sys call, int1 or int2 */
+	/*to distinguish bet excp, syscall, irq */
+	unsigned long event_type:16, orig_r8:16;
 };
 
 /* Callee saved registers - need to be saved only when you are scheduled out */
@@ -89,9 +90,8 @@ struct user_regs_struct {
 /* return 1 if PC in delay slot */
 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
 
-/* return 1 if in syscall, 0 if Intr or Exception */
-#define in_syscall(regs) (((regs->orig_r8) >= 0 && \
-			   (regs->orig_r8 <= NR_syscalls)) ? 1 : 0)
+#define in_syscall(regs) (regs->orig_r8 & orig_r8_IS_SCALL)
+#define in_brkpt_trap(regs) (regs->orig_r8 & orig_r8_IS_BRKPT)
 
 #define current_pt_regs()					\
 ({								\
@@ -101,7 +101,6 @@ struct user_regs_struct {
 	(struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1;	\
 })
 
-#define in_brkpt_trap(regs) (((regs->orig_r8) == (NR_syscalls + 2)) ? 1 : 0)
 
 #define user_stack_pointer(regs)\
 ({  unsigned int sp;		\
@@ -112,6 +111,14 @@ struct user_regs_struct {
 	sp;			\
 })
 
+
 #endif /* !__ASSEMBLY__ */
 
+#define orig_r8_IS_SCALL		0x0001
+#define orig_r8_IS_SCALL_RESTARTED	0x0002
+#define orig_r8_IS_BRKPT		0x0004
+#define orig_r8_IS_EXCPN		0x0004
+#define orig_r8_IS_IRQ1			0x0010
+#define orig_r8_IS_IRQ2			0x0020
+
 #endif /* __ASM_PTRACE_H */
arch/arc/kernel/entry.S +5 -5
index 365a01b..f509306 100644
@@ -500,8 +500,8 @@ tracesys_exit:
 
 trap_with_param:
 
-	;make sure orig_r8 is a positive value
-	st  NR_syscalls + 2, [sp, PT_orig_r8]
+	; stop_pc info by gdb needs this info
+	st  orig_r8_IS_BRKPT, [sp, PT_orig_r8]
 
 	mov r0, r12
 	lr  r1, [efa]
@@ -727,10 +727,10 @@ not_exception:
 	;----------------------------------------------------------------
 
 	ld r9, [sp, PT_orig_r8]        ; get orig_r8 to make sure it is
-	brne r9, -2, 149f              ; infact a L2 ISR ret path
+	brne r9, orig_r8_IS_IRQ2, 149f ; infact a L2 ISR ret path
 
-	ld r9, [sp, PT_status32]        ; get statu32_l2 (saved in pt_regs)
-	bbit0 r9, STATUS_A1_BIT, 149f     ; L1 not active when L2 IRQ, so normal
+	ld r9, [sp, PT_status32]       ; get statu32_l2 (saved in pt_regs)
+	bbit0 r9, STATUS_A1_BIT, 149f  ; L1 not active when L2 IRQ, so normal
 
 	; A1 is set in status32_l2
 	; decrement thread_info->preempt_count (re-enable preemption)
Signature · 1 line
1.7.4.1
#4 lore raw

Re: [RFC PATCH v1 02/31] ARC: irqflags

In reply to Thomas Gleixner
Quoted 9 lines · Thomas Gleixner

Review

Quoted 6 lines · Vineet Gupta

+ ******************************************************************
+ * Inline ASM macros to read/write AUX Regs
+ * Essentially invocation of lr/sr insns from "C"
+ */

(quoted diff) +2 -0
+
+#if 1

Leftover ???

Kind of - the gcc builtins sometimes tend to generate good code and sometimes they don't. I wanted to retain the inline asm version for experimenting sake. But if it's too ugly, I can get rid of one of them.

Quoted 12 lines

arch/arc/include/asm/arcregs.h

Quoted 10 lines
arch/arc/include/asm/arcregs.h new file +9 -0
+#define read_aux_reg(reg)	__builtin_arc_lr(reg)
+
+/* gcc builtin sr needs reg param to be long immediate */
+#define write_aux_reg(reg_immed, val)		\
+		__builtin_arc_sr((unsigned int)val, reg_immed)
+
+#else
+/*
+ * Conditionally Enable IRQs

Unconditionally methinks

ofcourse - fixed !

Quoted 14 lines

The following two functions are related to irq chips I guess. So why would you want them here ?

Quoted 11 lines
arch/arc/include/asm/irqflags.h new file +11 -0
+static inline void arch_mask_irq(unsigned int irq)
+{
+	unsigned int ienb;
+
+	ienb = read_aux_reg(AUX_IENABLE);
+	ienb &= ~(1 << irq);
+	write_aux_reg(AUX_IENABLE, ienb);
+}
+
+static inline void arch_unmask_irq(unsigned int irq)
+{
Quoted 8 lines

arch/arc/include/asm/irqflags.h line 122

Quoted 6 lines
arch/arc/include/asm/irqflags.h new file +6 -0
+	unsigned int ienb;
+
+	ienb = read_aux_reg(AUX_IENABLE);
+	ienb |= (1 << irq);
+	write_aux_reg(AUX_IENABLE, ienb);
+}

The only user is the interrupt controller code, right?

These are the platform agnostic routines which handle the in-core interrupt controller, hence provided as helpers. The simpler plat-arcfpga (PATCH 12/31) uses them as it is while a bunch of other platforms (yet to be submitted) might conditionally use depending upon whether a IRQ is cascaded or not.

Quoted 30 lines
Quoted 30 lines
arch/arc/kernel/irq.c new file +24 -0
new file mode 100644
index 0000000..16fcbe8
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-12 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <asm/irqflags.h>
+#include <asm/arcregs.h>
+
+void arch_local_irq_enable(void)
+{
+
+	unsigned long flags;
+	flags = arch_local_save_flags();
+	flags |= (STATUS_E1_MASK | STATUS_E2_MASK);
+
+	/*
+	 * If called from hard ISR (between irq_enter and irq_exit)
+	 * don't allow Level 1. In Soft ISR we allow further Level 1s
Quoted 8 lines

arch/arc/kernel/irq.c line 28

Quoted 4 lines
arch/arc/kernel/irq.c new file +4 -0
+	 */
+
+	if (in_irq())
+		flags &= ~(STATUS_E1_MASK | STATUS_E2_MASK);

Hmm. This looks weird and the comment is not very helpful. So using my crystal ball you want to enforce, that nothing enables interrupts while a hard interrupt handler is running, right?

Correct. I'll fix the comment.

Quoted 3 lines

Is there a chip limitation which you have to enforce here? If yes, then please explain it.

Yes and No. This is from our 2.6.26 days and AFAIKR, it was indeed ARC IDE driver enabling IRQ from within hard ISR context. The issue however became critical when I added support for the ARC700 in-core interrupt controller which provides 2 levels of interrupts per IRQ (kind of ARM FIQ): L2 (High priority) could interrupt L1 (low). The priority management (among other - don't allow L1 if L2 active) is done with 2 pairs of bits in STATUS32 (CPU flags) register
* A1/A2 (Level-n active)
* E1/E2 (Level-n enabled)

However since the OS is allowed to write to E1/E2 bits, independent of A1/A2, it is possible to re-enable interrupts even from hard-isr context. When IDE driver re-enabled L1 interrupts in L2 ISR - we had the basic low level irq handling messed by because of L1-L2-L1 scenarion

The patch which implements the 2 intc priorities support is separate. It probably fell of your radar since it was in mini-series #2 of v1 patchset @
https://lkml.org/lkml/2012/11/12/125). Once I respin v2 series for review, would request you to please take a look at that one as well (currently has a bad hack of disabling task preemption in a corner case - which of all people, you, would certainly loathe seeing)

Quoted 4 lines

Btw, all hard interrupt handlers in Linux run with interrupts disabled and they are not supposed to reenable interrupts, which is true for almost all drivers except for a few archaic IDE drivers. In fact you might even WARN about it at least once, so the offending code gets fixed.

Sure - did that in next version.

Quoted 10 lines

Also the code flow is backwards. What about:

     unsigned long flags;

     if (in_irq())
	    return;

     flags = ....	    
Quoted 3 lines

arch/arc/kernel/irq.c line 31

Quoted 2 lines
arch/arc/kernel/irq.c new file +2 -0
+	arch_local_irq_restore(flags);
+}

Indeed fixed in v2. Actually the prev version would *disable* the IRQs if in_irq(), now we leave status quo and return - but given that we return - they will not be enabled in first place - so there's no semantical change - assuming everything goes via local_irq_xxx friends.

Honestly I'm a bit ashamed for having had above crappy snippet for years. Thanks for taking time to review this and sincere apologies for coming back to you so late - I was held up with other things including a big ticket item pointed by Arnd in review (no-legacy syscalls).

Quoted 4 lines

Thanks,

tglx

#24 lore raw

Re: [RFC PATCH v1 12/31] ARC: Interrupt Handling

In reply to Thomas Gleixner
Quoted 15 lines · Thomas Gleixner

arch/arc/kernel/irq.c line 51

Quoted 11 lines · Vineet Gupta
arch/arc/kernel/irq.c +11 -0
+void __init init_IRQ(void)
+{
+	const int irq = TIMER0_IRQ;
+
+	/*
+	 * Each CPU needs to register irq of it's private TIMER0.
+	 * The APIs request_percpu_irq()/enable_percpu_irq() will not be
+	 * functional, if we don't "prep" the generic IRQ sub-system with
+	 * the following:
+	 * -Ensure that devid passed to request_percpu_irq() is indeed per cpu
+	 * -disable NOAUTOEN, w/o which the device handler never gets called

What sets NOAUTOEN in the first place? The core code definitely does not.

So this is based off of my orig 3.2 port and I can see similar flow even in 3.7

(1) start_kernel
early_irq_initd
desc_set_defaults
irqd_set(IRQD_IRQ_DISAB)

(2) For setting up IRQ dev to be per-cpu

     irq_set_percpu_devid
         irq_set_percpu_devid_flags
                irq_set_status_flags(IRQ_NOAUTOEN | ....)  <----

Am I missing/overlooking something ?

Quoted 6 lines

arch/arc/kernel/irq.c line 54

Quoted 4 lines
arch/arc/kernel/irq.c +3 -0
+	 */
+	irq_set_percpu_devid(irq);
+	irq_modify_status(irq, IRQ_NOAUTOEN, 0);

Aside of that we have irq_clear_status_flags() for this.

OK ! I can use that.

Quoted 7 lines

arch/arc/kernel/irq.c

Quoted 5 lines
arch/arc/kernel/irq.c +3 -0
+	plat_init_IRQ();
+}
 
+int __init get_hw_config_num_irq(void)

How is that function used ?

This is used in the SMP port patch to verify that number of IRQs have been configured properly in hardware. This is again in mini-series #2 of v1 patchset
https://lkml.org/lkml/2012/11/12/160

Thx,
-Vineet

#41 lore raw

Re: [RFC PATCH v1 15/31] ARC: Process/scheduling/clock/Timers/Delay Management

In reply to Thomas Gleixner
Quoted 11 lines · Thomas Gleixner
Quoted 10 lines · Vineet Gupta
arch/arc/kernel/process.c +10 -0
+void cpu_idle(void)
+{
+	/* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
+
+	/* endless idle loop with no priority at all */
+	while (1) {
+		tick_nohz_idle_enter();
+
+		while (!need_resched())
+			arch_idle();
Quoted 8 lines

arch/arc/kernel/process.c SYSCALL_DEFINE0(arc_gettls) · line 141

Quoted 6 lines
arch/arc/kernel/process.c +6 -0
+
+		tick_nohz_idle_exit();
+
+		preempt_enable_no_resched();
+		schedule();
+		preempt_disable();

schedule_preempt_disabled() please

OK ! And it seems I was also missing the calls to rcu_idle_enter()/exit() to track commit 1268fbc746ea "nohz: Remove tick_nohz_idle_enter_norcu() / ..."

Quoted 37 lines
Quoted 34 lines
(quoted diff) +1 -0
+	}
arch/arc/kernel/time.c +30 -0
 
+static void arc_periodic_timer_setup(unsigned int limit)
+{
+	/* setup start and end markers */
+	write_aux_reg(ARC_REG_TIMER0_LIMIT, limit);
+	write_aux_reg(ARC_REG_TIMER0_CNT, 0);	/* start from 0 */
+
+	/* IE: Interrupt on count = limit,
+	 * NH: Count cycles only when CPU running (NOT Halted)
+	 */
+	write_aux_reg(ARC_REG_TIMER0_CTRL, TIMER_CTRL_IE | TIMER_CTRL_NH);
+}
+
+/*
+ * Acknowledge the interrupt & enable/disable the interrupt
+ */
+static void arc_periodic_timer_ack(unsigned int irq_reenable)
+{
+	/* 1. Ack the interrupt by writing to CTRL reg.
+	 *    Any write will cause intr to be ack, however it has to be one of
+	 *    writable bits (NH: Count when not halted)
+	 * 2. If required by caller, re-arm timer to Interrupt at the end of
+	 *    next cycle.
+	 *
+	 * Small optimisation:
+	 * Normal code would have been
+	 *  if (irq_reenable) CTRL_REG = (IE | NH); else CTRL_REG = NH;
+	 * However since IE is BIT0 we can fold the branch
+	 */
+	write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | TIMER_CTRL_NH);
+}

....

Quoted 12 lines

arch/arc/kernel/time.c line 128

Quoted 6 lines
arch/arc/kernel/time.c +6 -0
+/********** Clock Event Device *********/
+
+static int arc_clkevent_set_next_event(unsigned long delta,
+				    struct clock_event_device *dev)
+{
+	arc_periodic_timer_setup(delta);

This is confusing. Is arc_periodic_timer_setup() setting up a periodic timer or a oneshot timer? It looks you use it for both and the differentiation happens in arc_periodic_timer_ack(). So I assume the timer only knows about periodic mode, but you trick it into oneshot with the ack function, right ?

I would think it's the other way round - timer counts upto limit and then interrupts - which needs to be acknowledged. And as part of ACKing it we can wiggle an additional bit to re-arm it again (for same limit). Thus it is basically one-shot which can be made periodic w/o much additional effort.

Quoted 3 lines

So it's just me being confused about
the function names, but that could do with some explanatory comments.

Function names updated and more comment added to hopefully clarify it for v2 series.

Quoted 9 lines

arch/arc/kernel/time.c line 135

Quoted 7 lines
arch/arc/kernel/time.c +7 -0
+	return 0;
+}
+
+static void arc_clkevent_set_mode(enum clock_event_mode mode,
+			       struct clock_event_device *dev)
+{
+	pr_info("Device [%s] clockevent mode now [%d]\n", dev->name, mode);

Please remove the debug leftover.

OK !

Quoted 18 lines
Quoted 18 lines
arch/arc/kernel/time.c +18 -0
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		arc_periodic_timer_setup(CONFIG_ARC_PLAT_CLK / HZ);
+		break;
+	case CLOCK_EVT_MODE_ONESHOT:
+		break;
+	default:
+		break;
+	}
+
+	return;
+}
+
+static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {
+	.name		= "ARC Timer0",
+	.features	= CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
+	.mode		= CLOCK_EVT_MODE_UNUSED,
+	.rating		= 300,
Quoted 8 lines

arch/arc/kernel/time.c line 159

Quoted 6 lines
arch/arc/kernel/time.c +6 -0
+	.irq		= TIMER0_IRQ,	/* hardwired, no need for resources */
+	.set_next_event = arc_clkevent_set_next_event,
+	.set_mode	= arc_clkevent_set_mode,
+};
+
+irqreturn_t timer_irq_handler(int irq, void *dev_id)

static please

Done !

Quoted 20 lines
Quoted 20 lines
arch/arc/kernel/time.c +19 -0
+static int arc_finished_booting;
+
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ * It's return value must NOT wrap around.
+ *
+ * Although the return value is nanosec units based, what's more important
+ * is whats the "source" of this value. The orig jiffies based computation
+ * was only as granular as jiffies itself (10ms on ARC).
+ * We need something that is more granular, so use the same mechanism as
+ * gettimeofday(), which uses ARC Timer T1 wrapped as a clocksource.
+ * Unfortunately the first call to sched_clock( ) is way before that subsys
+ * is initialiased, thus use the jiffies based value in the interim.
+ */
+unsigned long long sched_clock(void)
+{
+	if (!arc_finished_booting) {
+		return (unsigned long long)(jiffies - INITIAL_JIFFIES)
+		    * (NSEC_PER_SEC / HZ);
Quoted 8 lines

arch/arc/kernel/time.c line 226

Quoted 3 lines
arch/arc/kernel/time.c +3 -0
+	} else {
+		struct timespec ts;
+		getrawmonotonic(&ts);

This can live lock. sched_clock() is used by the tracer. So assume you are function tracing and you trace a function called from within the timekeeping seqcount write "locked" region. You spin forever in getrawmonotonic(). Not what you want, right ?

Correct- so that means we need an equivalent of partially open-code getrawmonotonic w/o any locks here - read the clocksource directly just as other arches.

Thx,
-Vineet

#42 lore raw

Re: [RFC PATCH v1 15/31] ARC: Process/scheduling/clock/Timers/Delay Management

Quoted 30 lines · Vineet Gupta
Quoted 20 lines · Thomas Gleixner
Quoted 19 lines · Vineet Gupta
arch/arc/kernel/time.c new file +19 -0
+static int arc_finished_booting;
+
+/*
+ * Scheduler clock - returns current time in nanosec units.
+ * It's return value must NOT wrap around.
+ *
+ * Although the return value is nanosec units based, what's more important
+ * is whats the "source" of this value. The orig jiffies based computation
+ * was only as granular as jiffies itself (10ms on ARC).
+ * We need something that is more granular, so use the same mechanism as
+ * gettimeofday(), which uses ARC Timer T1 wrapped as a clocksource.
+ * Unfortunately the first call to sched_clock( ) is way before that subsys
+ * is initialiased, thus use the jiffies based value in the interim.
+ */
+unsigned long long sched_clock(void)
+{
+	if (!arc_finished_booting) {
+		return (unsigned long long)(jiffies - INITIAL_JIFFIES)
+		    * (NSEC_PER_SEC / HZ);
Quoted 8 lines

arch/arc/kernel/time.c line 226

Quoted 3 lines
arch/arc/kernel/time.c new file +3 -0
+	} else {
+		struct timespec ts;
+		getrawmonotonic(&ts);

This can live lock. sched_clock() is used by the tracer. So assume you are function tracing and you trace a function called from within the timekeeping seqcount write "locked" region. You spin forever in getrawmonotonic(). Not what you want, right ?

Quoted 3 lines

Correct- so that means we need an equivalent of partially open-code getrawmonotonic w/o any locks here - read the clocksource directly just as other arches.

Spoke too soon. The desired semantics here are monotonically increasing value using a 32-bit overflowing hardware counter (and not Jiffies based since Android CTS has a test case which requires that back-back calls to clock_gettime(CLOCK_THREAD_CPUTIME_ID) - which simply use sched_clock( ) return different values.

Since counter is overflowing, we need additional state (last snapshot) provided by likes of clocksource. But IMHO, opencoding clocksource code w/o xtime seqlock will be wrong.

I don't see a way out - except to keep using jiffies based versions and use the 64 bit Time-stamp counter available in newer ARC CPUs.

-Vineet

#71 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Arnd Bergmann
Quoted 13 lines · Arnd Bergmann
Quoted 11 lines · Vineet Gupta
arch/arc/Kconfig new file +11 -0
+
+config ARC
+	def_bool y
+	select ARCH_WANT_IPC_PARSE_VERSION
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG
+	select DEVTMPFS if !INITRAMFS_SOURCE=""
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_FIND_FIRST_BIT
+	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
Quoted 8 lines

arch/arc/Kconfig line 24

Quoted 6 lines
arch/arc/Kconfig new file +6 -0
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select MODULES_USE_ELF_RELA

You should not need ARCH_WANT_IPC_PARSE_VERSION

Done !

Quoted 5 lines

arch/arc/Kconfig line 37

Quoted 3 lines
arch/arc/Kconfig new file +3 -0
+# for old_[ug]id_t - do we need this ?
+config UID16
+	def_bool y

No, not needed either.

Done !

Quoted 14 lines
Quoted 14 lines
arch/arc/Kconfig new file +13 -0
+menu "ARC Architecture Configuration"
+
+choice
+	prompt "ARC Platform"
+	default ARC_PLAT_FPGA_LEGACY
+
+config ARC_PLAT_FPGA_LEGACY
+	bool "\"Legacy\" ARC FPGA dev platform"
+	help
+	  Support for ARC development platforms, provided by Synopsys.
+	  These are based on FPGA or ISS. e.g.
+	  - ARCAngel4
+	  - ML509
Quoted 8 lines

arch/arc/Kconfig line 86

Quoted 4 lines
arch/arc/Kconfig new file +4 -0
+	  - MetaWare ISS
+
+#New platform adds here
+endchoice

Platform selection should generally be non-exclusive. Just remove the "choice" statement here, and make sure that any platforms can be enabled together to build a single kernel.

So technically this is not in same league as usage of devicetree. Although it seems to have it's own merits (single image, code coverage,..) but is this a hard requirement for all arches. Here's my problem.

We have default implementations of clocksource using in-core local TIMER1. This however might not suffice for some SMP ARC SoCs which need cross-core synchronized timers. Obviously they want to use their own versions. In orig code (not v1 - but in my new v2) I have a platform specific hook local_counter_setup() called from time_init(). With #def PLAT1 and #def PLAT2, there could be 2 mutually exclusive versions of those. With the "all-platform-build-together" paradigm, this simple design is not possible - not to mention the needless code bloat for a simple run in simulator. So now using devicetree, I first need to find what platform we are on and then need to setup a platform specific function pointer (and same applies to several other platform specific stuff). Is there a better way of doing this - maybe the long dy has taken toll on me :-(

Quoted 19 lines
Quoted 19 lines
arch/arc/Kconfig new file +19 -0
+menu "ARC CPU Configuration"
+
+choice
+	prompt "ARC Core"
+	default ARC_CPU_770
+
+config ARC_CPU_750D
+	bool "ARC750D"
+	help
+	  Support for ARC750 core
+
+config ARC_CPU_770
+	bool "ARC770"
+	select ARC_CPU_REL_4_10
+	help
+	  Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
+	  This core has a bunch of cool new features:
+	  -MMU-v3: Variable Page Sz (4k, 8k, 16k), bigger J-TLB (128x4)
+                   Shared Address Spaces (for sharing TLB entires in MMU)
Quoted 8 lines

arch/arc/Kconfig line 110

Quoted 4 lines
arch/arc/Kconfig new file +4 -0
+	  -Caches: New Prog Model, Region Flush
+	  -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr
+
+endchoice

Same thing here: If the different CPUs can in theory run the same kernel code, they should allow that. It doesn't stop you from making the default to enable only one of them and optimize for that case.

Background: ARC770 supports newer instructions (LOCK/SCOND) + MMUv3 which are not available on ARC750. So code needs to be built differently for each. Having said that above config items don't have any code under them - they are just high level selectors for correct MMU versions and e.g. whether we allow the usage of new insns.

Quoted 15 lines
Quoted 15 lines
arch/arc/Kconfig new file +11 -0
+
+choice
+	prompt "ARC700 MMU Version"
+	default ARC_MMU_V3 if ARC_CPU_770
+	default ARC_MMU_V2 if ARC_CPU_750D
+
 
+endchoice
 
+choice
+	prompt "MMU Page Size"
+	default ARC_PAGE_SIZE_8K
+
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+endchoice

For MMU, page size and endianess, I would not expect that to work though, so they probably need to remain mutually exclusive.

Ofcourse - given that PAGE_SIZE needs to be a compile time constant.

Quoted 29 lines
Quoted 29 lines
arch/arc/Kconfig new file +28 -0
+menu "Platform Board Configuration"
+
+source "arch/arc/plat-arcfpga/Kconfig"
+#New platform adds here
+
+config ARC_PLAT_CLK
+	int "Clk speed in Hz"
+	default "80000000"
+
+config LINUX_LINK_BASE
+	hex "Linux Link Address"
+	default "0x80000000"
+	help
+	  ARC700 divides the 32 bit phy address space into two equal halves
+	  -Lower 2G (0 - 0x7FFF_FFFF ) is user virtual, translated by MMU
+	  -Upper 2G (0x8000_0000 onwards) is untranslated, for kernel
+	  Typically Linux kernel is linked at the start of untransalted addr,
+	  hence the default value of 0x8zs.
+	  However some customers have peripherals mapped at this addr, so
+	  Linux needs to be scooted a bit.
+	  If you don't know what the above means, leave this setting alone.
+
+config ARC_PLAT_SDRAM_SIZE
+	hex "SD RAM Size"
+	default "0x10000000"
+	help
+	  Implies the amount of SDRAM/DRAM Linux is going to claim/own.
+	  The actual memory itself could be larger than this number. But for
Quoted 8 lines

arch/arc/Kconfig line 277

Quoted 3 lines
arch/arc/Kconfig new file +3 -0
+	  all software purposes, this is the amt of memory.
+
+endmenu # "Platform Board Configuration"

Clock speed and memory size are things that the kernel should normally be able to find out itself, if not from the hardware then from looking at the device tree binary that gets passed from the boot loader, or some other boot protocol that is already established.

Sure - both will come from devicetree. LINUX_LINK_BASE however is a fundamental constant, used in linker script for final layout so it will have to be a .config item.

Quoted 11 lines
Quoted 11 lines
arch/arc/plat-arcfpga/Kconfig new file +10 -0
+if ARC_PLAT_FPGA_LEGACY
+
+choice
+	prompt "FPGA Board"
+
+config ARC_BOARD_ANGEL4
+	bool "ARC Angel4"
+	help
+	  ARC Angel4 FPGA Ref Platform (Xilinx Virtex Based)
+
Quoted 8 lines

arch/arc/plat-arcfpga/Kconfig line 24

Quoted 6 lines
arch/arc/plat-arcfpga/Kconfig new file +6 -0
+config ARC_BOARD_ML509
+	bool "ML509"
+	help
+	  ARC ML509 FPGA Ref Platform (Xilinx Virtex-5 Based)
+
+endchoice

Board files again should not be mutually exclusive.

OK ! Actually this hunk should not be present in initial upstream submission as these only differ in a peripheral which is not yet submitted. This will be dropped.

Quoted 3 lines

Arnd

maintainer
#72 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 11 lines · Vineet Gupta
Quoted 5 lines · Arnd Bergmann

On Wednesday 07 November 2012, Vineet Gupta wrote:

Platform selection should generally be non-exclusive. Just remove the "choice" statement here, and make sure that any platforms can be enabled together to build a single kernel.

So technically this is not in same league as usage of devicetree. Although it seems to have it's own merits (single image, code coverage,..) but is this a hard requirement for all arches. Here's my problem.

Quoted 11 lines

We have default implementations of clocksource using in-core local TIMER1. This however might not suffice for some SMP ARC SoCs which need cross-core synchronized timers. Obviously they want to use their own versions. In orig code (not v1 - but in my new v2) I have a platform specific hook local_counter_setup() called from time_init(). With #def PLAT1 and #def PLAT2, there could be 2 mutually exclusive versions of those. With the "all-platform-build-together" paradigm, this simple design is not possible - not to mention the needless code bloat for a simple run in simulator. So now using devicetree, I first need to find what platform we are on and then need to setup a platform specific function pointer (and same applies to several other platform specific stuff). Is there a better way of doing this - maybe the long dy has taken toll on me :-(

Regarding the code bloat, there should be practically no run-time cost, because all the decisions are made in __init functions that are discarded after boot. There will be a little vmlinux size overhead from turning build-time into run-time configuration though. Of course you don't have to always build everything together, it's totally fine to have a separate defconfig file for each platform that just enables the parts that are required, as long as it's also possible to build an allyesconfig that enables everything (or most things, in cases where there are hard reasons not to make something a run-time decision)

The generic timer code is already quite flexible and allows plugging in clocksources at run-time, as this is essential to do on x86.

The way to do this with device tree is normally not to identify a global "platform", but rather to identify the individual devices. E.g. when you have an SMP system with a synchronized timer, there would be a device node describing that timer and your driver looks for that node.

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
arch/arc/Kconfig new file +19 -0
+menu "ARC CPU Configuration"
+
+choice
+	prompt "ARC Core"
+	default ARC_CPU_770
+
+config ARC_CPU_750D
+	bool "ARC750D"
+	help
+	  Support for ARC750 core
+
+config ARC_CPU_770
+	bool "ARC770"
+	select ARC_CPU_REL_4_10
+	help
+	  Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
+	  This core has a bunch of cool new features:
+	  -MMU-v3: Variable Page Sz (4k, 8k, 16k), bigger J-TLB (128x4)
+                   Shared Address Spaces (for sharing TLB entires in MMU)
Quoted 8 lines

arch/arc/Kconfig line 110

Quoted 4 lines
arch/arc/Kconfig new file +4 -0
+	  -Caches: New Prog Model, Region Flush
+	  -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr
+
+endchoice

Same thing here: If the different CPUs can in theory run the same kernel code, they should allow that. It doesn't stop you from making the default to enable only one of them and optimize for that case.

Quoted 4 lines

Background: ARC770 supports newer instructions (LOCK/SCOND) + MMUv3 which are not available on ARC750. So code needs to be built differently for each. Having said that above config items don't have any code under them - they are just high level selectors for correct MMU versions and e.g. whether we allow the usage of new insns.

So a kernel built for ARC750 could potentially run on an ARC770, but not use all the features, right?

The way we handle this on ARM and PowerPC is to allow selecting each CPU individually, but falling back on the common subset. So you could build a kernel that supports running on ARC750 and on ARC770, but that would make it impossible to use SMP, so on an ARC770 SMP machine, it would only run on the first CPU.

If ARC770 cannot actually run the MMU_V2 code, that would mean that they are indeed mutually exclusive by design, unless you also support a NOMMU kernel. In that case you could only build a kernel for both 750 and 770 if you don't use the MMU. That would be much less interesting for actually running things, but it could still make sense for build testing.

If you don't need NOMMU support otherwise (I forgot whether or not you have this), you should of course not implement it just for this.

Quoted 5 lines
Quoted 3 lines

For MMU, page size and endianess, I would not expect that to work though, so they probably need to remain mutually exclusive.

Ofcourse - given that PAGE_SIZE needs to be a compile time constant.

Actually, it is possible to support multiple page sizes (I think IA64 does this), but I don't recommend implementing it unless you have a specific need for that.

Arnd

#73 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 33 lines · Arnd Bergmann
Quoted 24 lines · Vineet Gupta
Quoted 23 lines · Arnd Bergmann

On Wednesday 07 November 2012, Vineet Gupta wrote:

arch/arc/Kconfig new file +22 -0
+menu "ARC CPU Configuration"
+
+choice
+	prompt "ARC Core"
+	default ARC_CPU_770
+
+config ARC_CPU_750D
+	bool "ARC750D"
+	help
+	  Support for ARC750 core
+
+config ARC_CPU_770
+	bool "ARC770"
+	select ARC_CPU_REL_4_10
+	help
+	  Support for ARC770 core introduced with Rel 4.10 (Summer 2011)
+	  This core has a bunch of cool new features:
+	  -MMU-v3: Variable Page Sz (4k, 8k, 16k), bigger J-TLB (128x4)
+                   Shared Address Spaces (for sharing TLB entires in MMU)
+	  -Caches: New Prog Model, Region Flush
+	  -Insns: endian swap, load-locked/store-conditional, time-stamp-ctr
+
Quoted 8 lines
Quoted 4 lines

+endchoice
Same thing here: If the different CPUs can in theory run the same kernel code, they should allow that. It doesn't stop you from making the default to enable only one of them and optimize for that case.

Background: ARC770 supports newer instructions (LOCK/SCOND) + MMUv3 which are not available on ARC750. So code needs to be built differently for each. Having said that above config items don't have any code under them - they are just high level selectors for correct MMU versions and e.g. whether we allow the usage of new insns.

Quoted 2 lines

So a kernel built for ARC750 could potentially run on an ARC770, but not use all the features, right?

Only for features which are non conflicting - so even now a CONFIG_ARC_CPU_750 built kernel (so no LLOCK/SCOND support) will run fine on 770 hardware (which has LLOCK/SCOND)- assuming everything else being constant. However MMUv3 (770 only) has a different programming model vs. MMUv2 (e.g. TLB descriptor layout among others) hence a kernel for MMU v2 "simply" can't run on MMUv3 w/o making runtime-checks or runtime-overrides (akin to function pointers) in things like TLB refill handlers and such.

Quoted 7 lines

The way we handle this on ARM and PowerPC is to allow selecting each CPU individually,

but falling back on the common subset. So you could build
a kernel that supports running on ARC750 and on ARC770, but that would make it impossible to use SMP, so on an ARC770 SMP machine, it would only run on the first CPU.

Good for pre-built distros and such ! Nice concept - I like it.

Quoted 2 lines

If ARC770 cannot actually run the MMU_V2 code, that would mean that they are indeed mutually exclusive by design,

Given the immense hardware configurability of ARC, all crazy combinations are possible - how many are practically used is a different topic. So someone could in theory build 770 with MMUv2 and infact the current build system even allows that. See ARC_CPU_{750,770} are only about selecting a bunch of defaults (MMU ver, LLOCK) - to prevent the user from hand doing that. So lets say we rip off both of these (to emulate kernel built for one running on other) - then it would boil down to letting support for both v2 and v3 co-exist (not to forget there's also an arcane historic v1). Now these fellows really are mutually exclusive by design:
* code written for v3 won't work on v2 (e.g. ARC_REG_IC_PTAG doesn't exist)
* code written for v2 won't work on v3 (e.g ARC_REG_IC_PTAG needs to be written for correct behaviour)

Quoted 7 lines

unless you also support a NOMMU
kernel. In that case you could only build a kernel for both 750 and 770 if you don't use the MMU. That would be much less interesting for actually running things, but it could still make sense for build testing.

If you don't need NOMMU support otherwise (I forgot whether or not you have this), you should of course not implement it just for this.

NOMMU is not supported yet.

So how do we conclude on this topic - given the caveats above ?

Thx,
-Vineet

maintainer
#74 lore raw

Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 7 lines · Vineet Gupta
Quoted 5 lines · Arnd Bergmann
Quoted 1 line · Vineet Gupta

On Wednesday 07 November 2012 07:43 PM, Arnd Bergmann wrote:

So a kernel built for ARC750 could potentially run on an ARC770, but not use all the features, right?

Quoted 7 lines

Only for features which are non conflicting - so even now a CONFIG_ARC_CPU_750 built kernel (so no LLOCK/SCOND support) will run fine on 770 hardware (which has LLOCK/SCOND)- assuming everything else being constant. However MMUv3 (770 only) has a different programming model vs. MMUv2 (e.g. TLB descriptor layout among others) hence a kernel for MMU v2 "simply" can't run on MMUv3 w/o making runtime-checks or runtime-overrides (akin to function pointers) in things like TLB refill handlers and such.

Ok.

Quoted 14 lines
Quoted 2 lines

If ARC770 cannot actually run the MMU_V2 code, that would mean that they are indeed mutually exclusive by design,

Given the immense hardware configurability of ARC, all crazy combinations are possible - how many are practically used is a different topic. So someone could in theory build 770 with MMUv2 and infact the current build system even allows that. See ARC_CPU_{750,770} are only about selecting a bunch of defaults (MMU ver, LLOCK) - to prevent the user from hand doing that. So lets say we rip off both of these (to emulate kernel built for one running on other) - then it would boil down to letting support for both v2 and v3 co-exist (not to forget there's also an arcane historic v1). Now these fellows really are mutually exclusive by design:
* code written for v3 won't work on v2 (e.g. ARC_REG_IC_PTAG doesn't exist)
* code written for v2 won't work on v3 (e.g ARC_REG_IC_PTAG needs to be written for correct behaviour)

I think in a case like this, it's pretty clearly not worth supporting both in the same kernel. This is very similar to the difference between ARMv5 and ARMv6, or between PowerPC Classic (6xx) and BookE (4xx), which are never supported in a single kernel because the cost of doing it would be much bigger than the benefit.

Quoted 11 lines
Quoted 7 lines

unless you also support a NOMMU
kernel. In that case you could only build a kernel for both 750 and 770 if you don't use the MMU. That would be much less interesting for actually running things, but it could still make sense for build testing.

If you don't need NOMMU support otherwise (I forgot whether or not you have this), you should of course not implement it just for this.

NOMMU is not supported yet.

So how do we conclude on this topic - given the caveats above ?

For the CPU options, you should leave 750 and 770 mutually exclusive, but for each other option, you should first see if it can reasonably be a run-time option. It may not be possible to eliminate incompatible compile-time options, but you should reduce the number of those options as much as possible.

Arnd

#43 lore raw

Re: [RFC PATCH v1 15/31] ARC: Process/scheduling/clock/Timers/Delay Management

In reply to Vineet Gupta

2013/1/2 Vineet Gupta <[email protected]>:

Quoted 22 lines · Thomas Gleixner
Quoted 11 lines · Vineet Gupta
Quoted 10 lines
arch/arc/kernel/process.c +10 -0
+void cpu_idle(void)
+{
+    /* Since we SLEEP in idle loop, TIF_POLLING_NRFLAG can't be set */
+
+    /* endless idle loop with no priority at all */
+    while (1) {
+            tick_nohz_idle_enter();
+
+            while (!need_resched())
+                    arch_idle();
Quoted 8 lines

arch/arc/kernel/process.c SYSCALL_DEFINE0(arc_gettls) · line 141

Quoted 6 lines
arch/arc/kernel/process.c +6 -0
+
+            tick_nohz_idle_exit();
+
+            preempt_enable_no_resched();
+            schedule();
+            preempt_disable();

schedule_preempt_disabled() please

Quoted 2 lines

OK ! And it seems I was also missing the calls to rcu_idle_enter()/exit() to track commit 1268fbc746ea "nohz: Remove tick_nohz_idle_enter_norcu() / ..."

Right!

They must be placed around the code that sets the low power mode, when you know there is no use of RCU between rcu_idle_enter() / rcu_idle_exit(). Here this would be likely:

while (1) {
        tick_nohz_idle_enter();
+      rcu_idle_enter();
        while (!need_resched())
                arch_idle();

+ rcu_idle_exit()

        tick_nohz_idle_exit();
        schedule_preempt_disabled();
}
#59 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

In reply to Arnd Bergmann
Quoted 29 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/plat-arcfpga/platform.c +10 -0
+static struct platform_device arc_uart##n##_dev = {    \
+       .name = "arc-uart",                             \
+       .id = n,                                        \
+       .num_resources = ARRAY_SIZE(arc_uart##n##_res), \
+       .resource = arc_uart##n##_res,                  \
+       .dev = {                                        \
+               .platform_data = &arc_uart_info,        \
+       },                                              \
+}
+

arch/arc/plat-arcfpga/platform.c line 65

Quoted 10 lines
arch/arc/plat-arcfpga/platform.c +10 -0
+ARC_UART_DEV(0);
+#if CONFIG_SERIAL_ARC_NR_PORTS > 1
+ARC_UART_DEV(1);
+#endif
+
+static struct platform_device *fpga_early_devs[] __initdata = {
+#if defined(CONFIG_SERIAL_ARC_CONSOLE)
+       &arc_uart0_dev,
+#endif
+};

statically defining platform devices like this is considered very bad style, especially since it prevents you from doing proper boot-time configuration. Please get the available devices from the boot loader. Normally this is done using a flattened device tree blob that gets passed, unless you can probe the hardware directly.

Quoted 2 lines

Arnd

I have a first pass at device tree implementation: extracting plat-clk and sdram-size as runtime values was relatively easy. However adding arc-uart device is turning out to be non-trivial and I'm hitting a bunch of blockers which I hope you and/or Grant will help me with. Please rest assured that I'm only seeking help after enough grepping and debuggign this for whole day (with -DDEBUG) in much of device model code.

I used following as refs:
[1] http://www.devicetree.org/Device_Tree_Usage
[2] Documentation/devicetrre/usage_model.txt
[3] metag's implementation which helped to some extent.
[4] drivers/tty/serial/arc_uart.c (merged in 3.8)
[5] lots and lots of grep in arch/*

I have a very minimal device tree file for Angel4 board with just arc-uart device.

---------------------->8--------------------------------

/ {
	compatible = "snps,angel4";
	clock-frequency = <80000000>;	/* 80 MHZ */
	#address-cells = <1>;
	#size-cells = <1>;

	chosen {
		bootargs = "console=ttyARC0,115200n8";
	};

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		cpu@0 {
			device_type = "cpu";
			compatible = "snps,arc770d";
			reg = <0>;
		};
	};

	memory {
		device_type = "memory";
		reg = <0x00000000 0x20000000>;	/* 512M */
	};

	fpga {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		serial@c0fc1000 {
			compatible = "snps,arc-uart";
			reg = <0xc0fc1000 0x100>;
			interrupts = <5>;
			status = "okay";
		};
	};
};

---------------------->8--------------------------------

(1) Although I don't need the container "fpga" I'm forced to - because of_platform_populate( ) -> of_match_node( ) expects the @match arg to be NOT NULL. So we pass of_default_bus_match_table and have the compat string "simple-bus" in the container. Per [1] it seemed it was possible to add the serial device directly w/o the container.

(2) I need the following OF_DEV_AUXDATA to be able to "name" the device correctly so that the registered driver [4] can bind with device. How do I match the driver and devicetree node w/o this glue - it seems compatible="<manuf>,<model>" is not enough. This also requires the uart base address to be specified (otherwise of_dev_lookup() fails to identify the auxdata) which IMHO defeats the purpose of devicetree in first place.

static struct of_dev_auxdata arcuart_auxdata_lookup[] __initdata = {
	OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info),
	{}
};

(3) After above, driver's probe routine is getting called with platform_device->id = -1 and it seems of_device_add() is doing that purposely. How do I handle that.

(4) Is above standalone "interrupts" string OK, or do I have to explicitly instantiate the in-core intc as well. Since it is integral part of cpu, I really don't need any support code to explicitly instantiate it. Also it is not accessed via mem map - but special ARC instructions in aux address space of cpu.

TIA,
-Vineet

maintainer
#60 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

Quoted 8 lines · Vineet Gupta
Quoted 1 line · Arnd Bergmann

On Wednesday 07 November 2012, Vineet Gupta wrote:

(1) Although I don't need the container "fpga" I'm forced to - because of_platform_populate( ) -> of_match_node( ) expects the @match arg to be NOT NULL. So we pass of_default_bus_match_table and have the compat string "simple-bus" in the container. Per [1] it seemed it was possible to add the serial device directly w/o the container.

You could in theory make the serial port device itself be compatible to somthing that is being probed by of_platform_populate, but putting it under a bus is the preferred way. Usually each system has at least one bus that devices are connected to and I would recommend to represent all buses in the device tree like they are in hardware.

Quoted 11 lines

(2) I need the following OF_DEV_AUXDATA to be able to "name" the device correctly so that the registered driver [4] can bind with device. How do I match the driver and devicetree node w/o this glue - it seems compatible="<manuf>,<model>" is not enough. This also requires the uart base address to be specified (otherwise of_dev_lookup() fails to identify the auxdata) which IMHO defeats the purpose of devicetree in first place.
b

static struct of_dev_auxdata arcuart_auxdata_lookup[] __initdata = {
	OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info),
	{}
};

It should be enough to fill the drv->of_match_table member of the platform_driver with the match table.

Quoted 2 lines

(3) After above, driver's probe routine is getting called with platform_device->id = -1 and it seems of_device_add() is doing that purposely. How do I handle that.

What do you need the id for?

Quoted 4 lines

(4) Is above standalone "interrupts" string OK, or do I have to explicitly instantiate the in-core intc as well. Since it is integral part of cpu, I really don't need any support code to explicitly instantiate it. Also it is not accessed via mem map - but special ARC instructions in aux address space of cpu.

Interrupts are a little tricky. You need to create a bindind for your interrupt controller first and make the irqchip driver use irq domains in order for the irq description in the device tree to be mapped into a linux-internal irq number.

In the simple case where you only have one irqchip in the system, you can use a "legacy" irq domain that simply translates the numbers 1:1. In some cases, it does make sense though (even with the legacy domain) to include additional flags in the device tree irq descriptor, e.g. the irq polarity and edge/level/message indication. Please read up on these and ask again if you have more questions.

Arnd

#61 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Vineet Gupta
Quoted 1 line · Arnd Bergmann

On Wednesday 07 November 2012, Vineet Gupta wrote:

(1) Although I don't need the container "fpga" I'm forced to - because of_platform_populate( ) -> of_match_node( ) expects the @match arg to be NOT NULL. So we pass of_default_bus_match_table and have the compat string "simple-bus" in the container. Per [1] it seemed it was possible to add the serial device directly w/o the container.

Quoted 5 lines

You could in theory make the serial port device itself be compatible to somthing that is being probed by of_platform_populate, but putting it under a bus is the preferred way. Usually each system has at least one bus that devices are connected to and I would recommend to represent all buses in the device tree like they are in hardware.

OK.

Quoted 11 lines
Quoted 11 lines

(2) I need the following OF_DEV_AUXDATA to be able to "name" the device correctly so that the registered driver [4] can bind with device. How do I match the driver and devicetree node w/o this glue - it seems compatible="<manuf>,<model>" is not enough. This also requires the uart base address to be specified (otherwise of_dev_lookup() fails to identify the auxdata) which IMHO defeats the purpose of devicetree in first place.
b

static struct of_dev_auxdata arcuart_auxdata_lookup[] __initdata = {
	OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info),
	{}
};
Quoted 2 lines

It should be enough to fill the drv->of_match_table member of the platform_driver with the match table.

Not sure if I understand. My concern is the #define UART0_BASE (=0xc0fc1000) which needs to be defined in code despite that value being present in the device tree. And this is needed so that framework could match the device against the driver. I would have thought that some device property (in device tree) could enable the matching with Linux name (actually DRIVER_NAME defined in the uart driver). Am I missing something ?

Quoted 3 lines
Quoted 2 lines

(3) After above, driver's probe routine is getting called with platform_device->id = -1 and it seems of_device_add() is doing that purposely. How do I handle that.

What do you need the id for?

In case of multiple instances of UART, driver uses this value to index into struct arc_uart_port [ ]

struct arc_uart_port {
    struct uart_port port;
    unsigned long baud;
    int is_emulated;
};

static struct arc_uart_port arc_uart_ports[CONFIG_SERIAL_ARC_NR_PORTS];

arc_serial_probe(struct platform_device *pdev)

    uart = &arc_uart_ports[pdev->id];
    arc_uart_init_one(pdev, ..)
          if (pdev->id < 0 ...)
                  return -ENOENT;

Although the current driver is flawed in that it checks for -ve value after already indexing into the array :-(
I'll send a patch to serial list to fix that.

Quoted 8 lines
Quoted 4 lines

(4) Is above standalone "interrupts" string OK, or do I have to explicitly instantiate the in-core intc as well. Since it is integral part of cpu, I really don't need any support code to explicitly instantiate it. Also it is not accessed via mem map - but special ARC instructions in aux address space of cpu.

Interrupts are a little tricky. You need to create a bindind for your interrupt controller first and make the irqchip driver use irq domains in order for the irq description in the device tree to be mapped into a linux-internal irq number.

Quoted 6 lines

In the simple case where you only have one irqchip in the system, you can use a "legacy" irq domain that simply translates the numbers 1:1. In some cases, it does make sense though (even with the legacy domain) to include additional flags in the device tree irq descriptor, e.g. the irq polarity and edge/level/message indication. Please read up on these and ask again if you have more questions.

Will do.

Thx,
-Vineet

Quoted 2 lines

Arnd

maintainer
#62 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

Quoted 9 lines · On Monday 07 January 2013 19:34:35 Vineet Gupta wrote:
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines
static struct of_dev_auxdata arcuart_auxdata_lookup[] __initdata = {
	OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info),
	{}
};

It should be enough to fill the drv->of_match_table member of the platform_driver with the match table.

Quoted 6 lines

Not sure if I understand. My concern is the #define UART0_BASE (=0xc0fc1000) which needs to be defined in code despite that value being present in the device tree. And this is needed so that framework could match the device against the driver. I would have thought that some device property (in device tree) could enable the matching with Linux name (actually DRIVER_NAME defined in the uart driver). Am I missing something ?

I mean you should not need the auxdata entry if the driver does everything right, and you get rid of the platform_data.

Quoted 16 lines
Quoted 3 lines
Quoted 2 lines

(3) After above, driver's probe routine is getting called with platform_device->id = -1 and it seems of_device_add() is doing that purposely. How do I handle that.

What do you need the id for?

In case of multiple instances of UART, driver uses this value to index into struct arc_uart_port [ ]

struct arc_uart_port {
    struct uart_port port;
    unsigned long baud;
    int is_emulated;
};

static struct arc_uart_port arc_uart_ports[CONFIG_SERIAL_ARC_NR_PORTS];

arc_serial_probe(struct platform_device *pdev)

Quoted 8 lines
    uart = &arc_uart_ports[pdev->id];
    arc_uart_init_one(pdev, ..)
          if (pdev->id < 0 ...)
                  return -ENOENT;

Although the current driver is flawed in that it checks for -ve value after already indexing into the array :-(
I'll send a patch to serial list to fix that.

(adding linux-serial to Cc)

Generally speaking, drivers should not have static or fixed-size arrays of devices in them. What you should do instead is to allocate the arc_uart_port at from arc_serial_probe() and remove all the references to the global array. I'm not completely sure if that's possible with the uart_port yet, maybe someone else can comment on that.

For the id value, have a look at the drivers/tty/serial/mxs-auart.c and how it gets the id from the /aliases node in the device tree using of_alias_get_id().

Arnd

#63 lore raw

early init dt for earlyprintk (was Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART)

In reply to Arnd Bergmann

Hi Arnd,

Quoted 29 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/plat-arcfpga/platform.c +10 -0
+static struct platform_device arc_uart##n##_dev = {    \
+       .name = "arc-uart",                             \
+       .id = n,                                        \
+       .num_resources = ARRAY_SIZE(arc_uart##n##_res), \
+       .resource = arc_uart##n##_res,                  \
+       .dev = {                                        \
+               .platform_data = &arc_uart_info,        \
+       },                                              \
+}
+

arch/arc/plat-arcfpga/platform.c line 65

Quoted 10 lines
arch/arc/plat-arcfpga/platform.c +10 -0
+ARC_UART_DEV(0);
+#if CONFIG_SERIAL_ARC_NR_PORTS > 1
+ARC_UART_DEV(1);
+#endif
+
+static struct platform_device *fpga_early_devs[] __initdata = {
+#if defined(CONFIG_SERIAL_ARC_CONSOLE)
+       &arc_uart0_dev,
+#endif
+};

statically defining platform devices like this is considered very bad style, especially since it prevents you from doing proper boot-time configuration. Please get the available devices from the boot loader. Normally this is done using a flattened device tree blob that gets passed, unless you can probe the hardware directly.

Quoted 2 lines

Arnd

OK, I have DeviceTree infrastructure in place. After wrapping my head around irq-domains, the whole thing indeed seems like a nice abstraction. ARC Port converted to it and patches to arc-uart driver to that effect posted to serial lists. Thanks for your ACK to the arc-uart DT binding patch for same.

Couple of things though:

1. While I've eliminated the platform_device population for SERIAL_ARC, we still need the static resource definitions and aux platform data for early_platform_add_devices() for SERIAL_ARC_CONSOLE since it uses the early param based driver registration and device probe. AFAIKS, there's no existing way to scan a special "earlyprintk" node (from flat tree) which at a minimum contains a "reg" property and some device specific platform info. There are only a few other drivers which uses the same design (e.g. tty/serial/sh-sci.c) but they don't seem to be DT enabled. Thus in the short term we will have to live with static coding for early platform device. Later on we can clean it up - I can take a stab at adding earlyprintk based bits to fdt.c - if that makes sense.

2. We really need a Documentation/dt-for-new-linux-arches.txt, as the existing refs - while very helpful - fail to mention subtleties such as you absolutely need a intc instance and a default irq domain ..... before the driver can start using the DT. Also the board specific callbacks etc are not really fundamental to the DT concept (at least I initially thought so) causing a distraction when adding the initial implementation. The minimal dynamic device population can very well be done in a arch initcall. I'll sum these up in a documentation-for-dummies and float around.

Thx,
-Vineet

#64 lore raw

Re: early init dt for earlyprintk (was Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART)

Hi Vineet

Quoted 4 lines · Vineet Gupta

2. We really need a Documentation/dt-for-new-linux-arches.txt, as the existing refs - while very helpful - fail to mention subtleties such as you absolutely need a intc instance and a default irq domain ..... before the driver can start using the DT.

Sounds like a good idea. I'm curious about what you say about default IRQ domains though. Do you mean irq_set_default_host? In what way is that required to use DT?

Cheers
James

#65 lore raw

Re: early init dt for earlyprintk (was Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART)

Quoted 8 lines · James Hogan

Hi Vineet

Quoted 4 lines · Vineet Gupta

2. We really need a Documentation/dt-for-new-linux-arches.txt, as the existing refs - while very helpful - fail to mention subtleties such as you absolutely need a intc instance and a default irq domain ..... before the driver can start using the DT.

Quoted 7 lines

Sounds like a good idea. I'm curious about what you say about default IRQ domains though. Do you mean irq_set_default_host? In what way is that required to use DT?

Cheers
James

Nope, the fact that we need a irq_domain_add_*( ) call corresponding to atleast one interrupt-controller node in the DT. In absence of that, the following callstack returns - with RESOURCE_IRQ unpopulated - causing driver to eventually fail the probe.

of_platform_populate
...
of_irq_to_resource

      irq_of_parse_and_map
        irq_create_of_mapping  -> Needs "some" irq domain.

Prior to introducing DT in ARC Port, I didn't have any of CONFIG_IRQ_DOMAIN and still it used to work fine. Enabling CONFIG_OF forced me to enable CONFIG_IRQ_DOMAIN (merely to resolve link errors) but I had no clue (call me stupid if you will) that I needed an actual domain setup.

The irq_set_default_host( ) is a nice design pattern though which avoids exporting the root domain outside of the specific compilation unit.

-Vineet

maintainer
#66 lore raw

Re: early init dt for earlyprintk (was Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART)

In reply to Vineet Gupta
Quoted 8 lines · Vineet Gupta

On Wednesday 07 November 2012 07:46 PM, Arnd Bergmann wrote:

OK, I have DeviceTree infrastructure in place. After wrapping my head around irq-domains, the whole thing indeed seems like a nice abstraction. ARC Port converted to it and patches to arc-uart driver to that effect posted to serial lists.

Ok, very good.

Quoted 12 lines

Couple of things though:

1. While I've eliminated the platform_device population for SERIAL_ARC, we still need the static resource definitions and aux platform data for early_platform_add_devices() for SERIAL_ARC_CONSOLE since it uses the early param based driver registration and device probe. AFAIKS, there's no existing way to scan a special "earlyprintk" node (from flat tree) which at a minimum contains a "reg" property and some device specific platform info. There are only a few other drivers which uses the same design (e.g. tty/serial/sh-sci.c) but they don't seem to be DT enabled. Thus in the short term we will have to live with static coding for early platform device. Later on we can clean it up - I can take a stab at adding earlyprintk based bits to fdt.c - if that makes sense.

There is always a question of how early you want the early printk to be -- the earlier you want it, the more hacks you end up needing.

The early_platform_device infrastructure is not used by a lot of architectures, so things can get a little hairy. Something you can do though is have an early_console without a platform_device attached to it, and scan the device tree for the nodes manually in order to find the registers. It would be good if we could eventually agree on a common approach for this, but right now just use whatever works for you.

Quoted 8 lines

2. We really need a Documentation/dt-for-new-linux-arches.txt, as the existing refs - while very helpful - fail to mention subtleties such as you absolutely need a intc instance and a default irq domain ..... before the driver can start using the DT. Also the board specific callbacks etc are not really fundamental to the DT concept (at least I initially thought so) causing a distraction when adding the initial implementation. The minimal dynamic device population can very well be done in a arch initcall. I'll sum these up in a documentation-for-dummies and float around.

Ok, great! That is very much appreciated.

Arnd

#38 lore raw

Re: [RFC PATCH v1 14/31] ARC: syscall support

In reply to Arnd Bergmann
Quoted 30 lines · Arnd Bergmann
Quoted 5 lines · Vineet Gupta

So the primary concern here is not breaking the userspace ABI - right ?

For syscalls I agree that we will indeed need to fix the ABI - by fixing uClibc. And if uClibc doesn't merge the fixes we can stay out of tree for uClibc - as we currently already are.

I'm sure we can find a solution for uClibc. We already have seven architectures using the generic syscalls, including at least one (arm64) that is going to run on a large number of installations in the future.

Quoted 8 lines

For gdbserver, the kernel provides the complete regset ABI. However it also provides a very limited version of old ABI - i.e. ptrace with PEEKUSR/POKEUSR. Note that latter is just a shim layer and it reuses the regset callbacks. This allows us to support the legacy gdbserver. If and when gdbserver upgrades it can switch over to new interface. So all along there will be NO ABI breakage at all. The cost is couple extra functions in kernel which we might have to maintain for some foreseeable future. Agree ?

It's more a question of principle. The rule is that we don't break user space, and ptrace is just another user space interface is this. If we merge it now, we will keep it around forever, taking it out later is not an option IMHO. My preference would be not to merge the backwards compatibility layer for ptrace at all, but I'm willing to listen to other people that support your view if you want to keep it. In one way, ptrace is less critical than the other system calls, and that is because it's already architecture specific.

Quoted 2 lines

Arnd

OK as of now the legacy syscall ABI and ptrace PEEKUSR/POKEUSR are taken out of submissions tree - we'll carry these out-of-tree for sometime before eventually moving to newer uClibc/gdbserver which don't need these O-O-T patches.

-Vineet

#67 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

In reply to Arnd Bergmann
Quoted 29 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/plat-arcfpga/platform.c +10 -0
+static struct platform_device arc_uart##n##_dev = {    \
+       .name = "arc-uart",                             \
+       .id = n,                                        \
+       .num_resources = ARRAY_SIZE(arc_uart##n##_res), \
+       .resource = arc_uart##n##_res,                  \
+       .dev = {                                        \
+               .platform_data = &arc_uart_info,        \
+       },                                              \
+}
+

arch/arc/plat-arcfpga/platform.c line 65

Quoted 10 lines
arch/arc/plat-arcfpga/platform.c +10 -0
+ARC_UART_DEV(0);
+#if CONFIG_SERIAL_ARC_NR_PORTS > 1
+ARC_UART_DEV(1);
+#endif
+
+static struct platform_device *fpga_early_devs[] __initdata = {
+#if defined(CONFIG_SERIAL_ARC_CONSOLE)
+       &arc_uart0_dev,
+#endif
+};

statically defining platform devices like this is considered very bad style, especially since it prevents you from doing proper boot-time configuration. Please get the available devices from the boot loader. Normally this is done using a flattened device tree blob that gets passed, unless you can probe the hardware directly.

Quoted 2 lines

Arnd

So my strategy for v2 series (based off 3.8-rcx) is to introduce devicetree, multi-platform-image support (and other key fixes such as syscall restart issues) as slap-on patches on top of old code. This is not to avoid any chop-n-dice of fixing patches (I've done that in plenty between v1 and v2). Its just that, in absence of revision history for ARC port (in upstream later on) - it helps capture the evolution of some key features and also for the community it serves as a live documentation of bad designs and how they can be fixed.

Is that a reasonable approach for new port which is non-bisectable anyways ?

Thx,
-Vineet

maintainer
#68 lore raw

Re: [RFC PATCH v1 25/31] ARC: [plat-arcfpga] Hooking up platform to ARC UART

Quoted 10 lines · Vineet Gupta

So my strategy for v2 series (based off 3.8-rcx) is to introduce devicetree, multi-platform-image support (and other key fixes such as syscall restart issues) as slap-on patches on top of old code. This is not to avoid any chop-n-dice of fixing patches (I've done that in plenty between v1 and v2). Its just that, in absence of revision history for ARC port (in upstream later on) - it helps capture the evolution of some key features and also for the community it serves as a live documentation of bad designs and how they can be fixed.

Is that a reasonable approach for new port which is non-bisectable anyways ?

Yes, I think that's fine. you should make that clear in the introductory email though, as well as in the description of any patches that get changed significantly by a later patch, to make sure people don't comment on the same things again when you have already fixed them.

Arnd

#102 lore raw
In reply to Vineet Gupta
Quoted 14 lines · Vineet Gupta
Quoted 13 lines · Pavel Machek
Quoted 8 lines · Pavel Machek

Hi!

Quoted 3 lines

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

Huh. arch/arc is very similar to arch/arm. So similar that it took me 10 minutes to figure out. I guess theres no alternate name arc could use?

Hmm... "Advanced Risc"... :-(.

Ok, plus there's already computing standard called "arc".

Quoted 8 lines
Quoted 3 lines

https://www.linux-mips.org/wiki/ARC

What about calling the architecture "sarc" or "syarc" ?

I think it would be best use of everybody's time if you could focus on the technical content of the port rather than the name. It has been like that for +10 years and I don't intend to make the kernel port name different from THE arch name itself.

Yeah, and it is best use of reviewers time to confuse them with one-letter difference to very popular architecture... and use three letter acronym that was already taken.

In this state, I hope your port never gets merged. Yes, I got used to do cd a<tab>/ar<tab>.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#103 lore raw
Quoted 6 lines · Pavel Machek

Yeah, and it is best use of reviewers time to confuse them with one-letter difference to very popular architecture... and use three letter acronym that was already taken.

In this state, I hope your port never gets merged. Yes, I got used to do cd a<tab>/ar<tab>.

You already lost that capability with the addition of arm64. As you may remember, that one was proposed to be called arch/aarch64 at first, which wasn't very popular ;-)

A lot of people are familiar with the ARC name, it's been around for decades and has sold billions of CPUs under that name, likely more than x86 or mips (still dwarfed by ARM of course). They've just kept a low profile so far and never tried to upstream their Linux port (unlike their gcc port, which was merged in 1997).

I'm sure there are a lot of bad things one can say about Synopsys, but they are doing the right thing here, and calling their CPU architecture by a different name is not going to be helpful to their users.

Arnd

#104 lore raw

Hi!

Quoted 10 lines
Quoted 6 lines

Yeah, and it is best use of reviewers time to confuse them with one-letter difference to very popular architecture... and use three letter acronym that was already taken.

In this state, I hope your port never gets merged. Yes, I got used to do cd a<tab>/ar<tab>.

You already lost that capability with the addition of arm64. As you may remember, that one was proposed to be called arch/aarch64 at first, which wasn't very popular ;-)

Actually, with arm26, which is older IIRC. But tab still works there, just will not fill the last /, and you can't mistake arm64 with arm in filenames etc -- different length.

Quoted 3 lines

A lot of people are familiar with the ARC name, it's been around for decades and has sold billions of CPUs under that name, likely more than x86 or mips (still dwarfed by ARM of course). They've just

Well, it seems that mips people were aware of the ARC name, it just meant something different:

https://www.linux-mips.org/wiki/ARC

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#105 lore raw
In reply to Pavel Machek
Quoted 22 lines · Pavel Machek
Quoted 14 lines · Vineet Gupta
Quoted 13 lines · Pavel Machek
Quoted 8 lines · Pavel Machek

Hi!

Quoted 3 lines

https://raw.github.com/vineetgarc/publish/master/ELCE-2012-ARC-Linux.pdf

All comments/criticisms are welcome !

Huh. arch/arc is very similar to arch/arm. So similar that it took me 10 minutes to figure out. I guess theres no alternate name arc could use?

Hmm... "Advanced Risc"... :-(.

Ok, plus there's already computing standard called "arc".

Quoted 7 lines
Quoted 3 lines

https://www.linux-mips.org/wiki/ARC

What about calling the architecture "sarc" or "syarc" ?

I think it would be best use of everybody's time if you could focus on the technical content of the port rather than the name. It has been like that for +10 years and I don't intend to make the kernel port name different from THE arch name itself.

Quoted 7 lines

Yeah, and it is best use of reviewers time to confuse them with one-letter difference to very popular architecture... and use three letter acronym that was already taken.

In this state, I hope your port never gets merged. Yes, I got used to do cd a<tab>/ar<tab>.
Pavel

Although I really don't want to spend time arguing with you but still ...... if you had a neighbor with same name as your friend your strategy most likely would be to force one of them to change names - kind of seems funny and stupid.

Having said that, despite all the ranting so far, you've not managed to comment on a single line of the actual code, which is more funny and stupid. So please stop blathering and do some constructive work. I won't go around asking ARC name to be changed because someone's Tab completion doesn't work anymore.

And I'm sorry dude, that alone won't prevent the port from being merged.

-Vineet

#106 lore raw

Hi!

Quoted 13 lines
Quoted 13 lines
Quoted 9 lines
Quoted 5 lines

Ok, plus there's already computing standard called "arc".

https://www.linux-mips.org/wiki/ARC

What about calling the architecture "sarc" or "syarc" ?

I think it would be best use of everybody's time if you could focus on the technical content of the port rather than the name. It has been like that for +10 years and I don't intend to make the kernel port name different from THE arch name itself.

Yeah, and it is best use of reviewers time to confuse them with one-letter difference to very popular architecture... and use three letter acronym that was already taken.

Quoted 7 lines
Quoted 2 lines

In this state, I hope your port never gets merged. Yes, I got used to do cd a<tab>/ar<tab>.

Although I really don't want to spend time arguing with you but still ...... if you had a neighbor with same name as your friend your strategy most likely would be to force one of them to change names - kind of seems funny and stupid.

Yeah, imagine creating "/bin/mr" that would be du equivalent. How many people would delete their files by mistake?

Quoted 2 lines

Having said that, despite all the ranting so far, you've not managed to comment on a single line of the actual code, which is more funny and stupid. So

Yeah, you tricked me into reviewing your code. No, I will not do more reviews for you. Yes, I bet I'm not the only one, and I bet that mistake will happen about once per developer.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#75 lore raw

SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

In reply to Arnd Bergmann

Hi Arnd,

Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/Kconfig new file +10 -0
+
+config ARC
+	def_bool y
+	select ARCH_WANT_IPC_PARSE_VERSION
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG
+	select DEVTMPFS if !INITRAMFS_SOURCE=""
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_FIND_FIRST_BIT
Quoted 8 lines

arch/arc/Kconfig line 24

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select MODULES_USE_ELF_RELA

You should not need ARCH_WANT_IPC_PARSE_VERSION

It seems, we have a small bug in sysV IPC.
A lot of LTP tests have started failing on ARC 3.9-rc1 kernel due to absence of ARCH_WANT_IPC_PARSE_VERSION.

I'm assuming that for newer arches, msgctl(2) and friends need to have need to have @cmd of type 0x01nn where 0x0100 is IPC_64.
However for ! ARCH_WANT_IPC_PARSE_VERSION, ipc/util.h seems to be defining a dummy version of ipc_parse_version(), which doesn't strip out the 0x0100 from @cmds, causing the code to not enter the switch block in SYSCALL_DEFINE3(msgctl) making it fail.
Adding the above item to arch/arc/Kconfig obviously fixes the breakage.

It seems there is some bogosity in the way ipc_parse_version() is defined. Given the way it is used, to strip out the 0x0100 bit, it seems we always need the function variant - the IA-64 ish comment in there seems to be bit-rot.

What do you think ?

-Vineet

#76 lore raw

Re: SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

Hi Vineet,

Quoted 34 lines · Vineet Gupta
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/Kconfig new file +10 -0
+
+config ARC
+	def_bool y
+	select ARCH_WANT_IPC_PARSE_VERSION
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG
+	select DEVTMPFS if !INITRAMFS_SOURCE=""
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_FIND_FIRST_BIT
Quoted 8 lines

arch/arc/Kconfig line 24

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select MODULES_USE_ELF_RELA

You should not need ARCH_WANT_IPC_PARSE_VERSION

It seems, we have a small bug in sysV IPC.
A lot of LTP tests have started failing on ARC 3.9-rc1 kernel due to absence of ARCH_WANT_IPC_PARSE_VERSION.

I'm assuming that for newer arches, msgctl(2) and friends need to have need to have @cmd of type 0x01nn where 0x0100 is IPC_64.
However for ! ARCH_WANT_IPC_PARSE_VERSION, ipc/util.h seems to be defining a dummy version of ipc_parse_version(), which doesn't strip out the 0x0100 from @cmds, causing the code to not enter the switch block in SYSCALL_DEFINE3(msgctl) making it fail.
Adding the above item to arch/arc/Kconfig obviously fixes the breakage.

Quoted 5 lines

It seems there is some bogosity in the way ipc_parse_version() is defined. Given the way it is used, to strip out the 0x0100 bit, it seems we always need the function variant - the IA-64 ish comment in there seems to be bit-rot.

What do you think ?

FYI, for metag we assumed this was intentional and that IPC_64 shouldn't be passed since it is the default behaviour for new arches. You may find the following uClibc commit relevant:
http://git.uclibc.org/uClibc/commit/?id=6c2fa3451f35f8d78a31689044b2d19efa4eaca2

Cheers
James

#77 lore raw

Re: SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

Hi James,

Quoted 40 lines · James Hogan

Hi Vineet,

Quoted 37 lines · Vineet Gupta
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/Kconfig new file +10 -0
+
+config ARC
+	def_bool y
+	select ARCH_WANT_IPC_PARSE_VERSION
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG
+	select DEVTMPFS if !INITRAMFS_SOURCE=""
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_FIND_FIRST_BIT
Quoted 8 lines

arch/arc/Kconfig line 24

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select MODULES_USE_ELF_RELA

You should not need ARCH_WANT_IPC_PARSE_VERSION

It seems, we have a small bug in sysV IPC.
A lot of LTP tests have started failing on ARC 3.9-rc1 kernel due to absence of ARCH_WANT_IPC_PARSE_VERSION.

I'm assuming that for newer arches, msgctl(2) and friends need to have need to have @cmd of type 0x01nn where 0x0100 is IPC_64.
However for ! ARCH_WANT_IPC_PARSE_VERSION, ipc/util.h seems to be defining a dummy version of ipc_parse_version(), which doesn't strip out the 0x0100 from @cmds, causing the code to not enter the switch block in SYSCALL_DEFINE3(msgctl) making it fail.
Adding the above item to arch/arc/Kconfig obviously fixes the breakage.

It seems there is some bogosity in the way ipc_parse_version() is defined. Given the way it is used, to strip out the 0x0100 bit, it seems we always need the function variant - the IA-64 ish comment in there seems to be bit-rot.

Quoted 5 lines
Quoted 1 line

What do you think ?

FYI, for metag we assumed this was intentional and that IPC_64 shouldn't be passed since it is the default behaviour for new arches. You may find the following uClibc commit relevant:
http://git.uclibc.org/uClibc/commit/?id=6c2fa3451f35f8d78a31689044b2d19efa4eaca2

I've been using uClibc trunk - ported to ARC - for my testing, so I already have that change. Looking at Markos' uClibc branch he is indeed defining __IPC_64 to 0 in metag port.
However, looking at the kernel code, it seems newer style is to do the other way round - i.e. pass 0x0100 in those cmds - unless the comments in there are bogus.

include/uapi/linux/ipc.h

/*
* Version flags for semctl, msgctl, and shmctl commands
* These are passed as bitflags or-ed with the actual command */
#define IPC_OLD 0 /* Old version (no 32-bit UID support on many
architectures) */
#define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger
message sizes, etc. */

So someone with more ABI wisdom needs to suggest what is the right approach.

-Vineet

#78 lore raw

Re: SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

Quoted 66 lines · Vineet Gupta

Hi James,

Quoted 40 lines · James Hogan

Hi Vineet,

Quoted 37 lines · Vineet Gupta
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Vineet Gupta
arch/arc/Kconfig new file +10 -0
+
+config ARC
+	def_bool y
+	select ARCH_WANT_IPC_PARSE_VERSION
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG
+	select DEVTMPFS if !INITRAMFS_SOURCE=""
+	select GENERIC_ATOMIC64
+	select GENERIC_CLOCKEVENTS
+	select GENERIC_FIND_FIRST_BIT
Quoted 8 lines

arch/arc/Kconfig line 24

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select MODULES_USE_ELF_RELA

You should not need ARCH_WANT_IPC_PARSE_VERSION

It seems, we have a small bug in sysV IPC.
A lot of LTP tests have started failing on ARC 3.9-rc1 kernel due to absence of ARCH_WANT_IPC_PARSE_VERSION.

I'm assuming that for newer arches, msgctl(2) and friends need to have need to have @cmd of type 0x01nn where 0x0100 is IPC_64.
However for ! ARCH_WANT_IPC_PARSE_VERSION, ipc/util.h seems to be defining a dummy version of ipc_parse_version(), which doesn't strip out the 0x0100 from @cmds, causing the code to not enter the switch block in SYSCALL_DEFINE3(msgctl) making it fail.
Adding the above item to arch/arc/Kconfig obviously fixes the breakage.

It seems there is some bogosity in the way ipc_parse_version() is defined. Given the way it is used, to strip out the 0x0100 bit, it seems we always need the function variant - the IA-64 ish comment in there seems to be bit-rot.

Quoted 5 lines
Quoted 1 line

What do you think ?

FYI, for metag we assumed this was intentional and that IPC_64 shouldn't be passed since it is the default behaviour for new arches. You may find the following uClibc commit relevant:
http://git.uclibc.org/uClibc/commit/?id=6c2fa3451f35f8d78a31689044b2d19efa4eaca2

I've been using uClibc trunk - ported to ARC - for my testing, so I already have that change. Looking at Markos' uClibc branch he is indeed defining __IPC_64 to 0 in metag port.
However, looking at the kernel code, it seems newer style is to do the other way round - i.e. pass 0x0100 in those cmds - unless the comments in there are bogus.

include/uapi/linux/ipc.h

/*
* Version flags for semctl, msgctl, and shmctl commands
* These are passed as bitflags or-ed with the actual command */
#define IPC_OLD 0 /* Old version (no 32-bit UID support on many
architectures) */
#define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger
message sizes, etc. */

Quoted 1 line

So someone with more ABI wisdom needs to suggest what is the right approach.

Agreed.

Note that in uClibc, 64bit arches (excl alpha/mips for some reason) were already defining __IPC_64 as 0, so there's some precedent for it working the way it does.

Cheers
James

maintainer
#79 lore raw

Re: SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

Quoted 9 lines · James Hogan
Quoted 9 lines

/*
* Version flags for semctl, msgctl, and shmctl commands
* These are passed as bitflags or-ed with the actual command */
#define IPC_OLD 0 /* Old version (no 32-bit UID support on many
architectures) */
#define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger
message sizes, etc. */

Quoted 7 lines
Quoted 1 line

So someone with more ABI wisdom needs to suggest what is the right approach.

Agreed.

Note that in uClibc, 64bit arches (excl alpha/mips for some reason) were already defining __IPC_64 as 0, so there's some precedent for it working the way it does.

Yes, there is no reason to need the distinction. If LTP is checking for IPC_OLD compatibility on anything but really old architectures, that is a bug in LTP, or possibly in the libc.

Arnd

#80 lore raw

Re: SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

Hi Arnd,

Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · James Hogan
Quoted 10 lines

/*
* Version flags for semctl, msgctl, and shmctl commands
* These are passed as bitflags or-ed with the actual command */
#define IPC_OLD 0 /* Old version (no 32-bit UID support on many
architectures) */
#define IPC_64 0x0100 /* New version (support 32-bit UIDs, bigger
message sizes, etc. */

So someone with more ABI wisdom needs to suggest what is the right approach.

Agreed.

Quoted 8 lines
Quoted 3 lines

Note that in uClibc, 64bit arches (excl alpha/mips for some reason) were already defining __IPC_64 as 0, so there's some precedent for it working the way it does.

Yes, there is no reason to need the distinction. If LTP is checking for IPC_OLD compatibility on anything but really old architectures, that is a bug in LTP, or possibly in the libc.

Arnd

I'm sorrry - I don't quite understand what you mean.

The question is what should the msgctl(2) ABI be w.r.t. @cmd arg. Does it need to be of type 0x01NN (i.e. IPC_64 ORed) or should it be be 0xNN. If it's 0x01NN, then ARCH_WANT_IPC_PARSE_VERSION is needed in Kconfig, otherwise, I need to fix uClibc.

The reason for confusion seems to be a comment in existing uapi/linux/ipc.h which seems to suggest that IPC_OLD is 0 and IPC_64 is newer version.

Thx,
-Vineet

maintainer
#81 lore raw

Re: SYSV IPC broken for no-legacy syscall kernels (was Re: [RFC PATCH v1 26/31] ARC: Build system: Makefiles, Kconfig, Linker script)

Quoted 7 lines · Vineet Gupta

The question is what should the msgctl(2) ABI be w.r.t. @cmd arg. Does it need to be of type 0x01NN (i.e. IPC_64 ORed) or should it be be 0xNN. If it's 0x01NN, then ARCH_WANT_IPC_PARSE_VERSION is needed in Kconfig, otherwise, I need to fix uClibc.

The reason for confusion seems to be a comment in existing uapi/linux/ipc.h which seems to suggest that IPC_OLD is 0 and IPC_64 is newer version.

Modern architecture ports should ignore this flag and always use the IPC_64 API, there is no reason to maintain backwards compatibility with old binaries.

Arnd