Skip to contentSkip to conversation

Synopsys ARC Linux kernel Port

PATCH Superseded Vineet Gupta 10 participants 148 messages Jan 18, 2013 – Jan 24, 2013 Page 1 of 2

Subsystems (13)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Synopsys ARC Linux kernel Port

This patchset based off-of 3.8-rc4, adds the Linux kernel port to ARC700 processor family (750D and 770D) from Synopsys. I would be greatful for further review and feedback.

Salient points about v2 patchset
-------------------------------
* All of the feedback from v1 RFC patchseries has been addressed.

* Some of the major fixes for v1 review comments such as Device Tree support, multi-platform-image and syscall-restart issues, have not been squashed into relevent patches, but instead have been applied as slap-on patches on orig ones. This is merely to build up some revision history into the final-upstream-merged version. If people think it's too ugly, I can do the chop-n-dice-n-squash, but my preference would be the style we have now.

* Unlike RFC v1 series (split into 2 part) this one includes the complete port (still the minimal kernel at halfway checkpoint, builds/runs fine). This combined with prev point, make the full patchset a touch large, for which I appologize in advance.

* The entire series however is also available at
git://github.com/foss-for-synopsys-dwc-arc-processors/linux.git arc-3.8-lkml-v2

About ARC Cores
----------------
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

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.

---
v2:

Changes for RFC v1 review:

* Reworked arc_local_irq_enable() with WARN_ONCE for buggy drivers (tglx)
* struct pt_regs wrapped under #ifdef __KERNEL__ (Jonas)
* returning to user mode (Al Viro)
* re-enable interrupts before handling TIF_SIGPENDING/TIF_NOTIFY_RESUME
* Don't discard callee-regs after handling signal
* After TIF_NOTIFY_RESUME processing, loop back to start of TIF_* checks
* Reworked init_IRQ() to not use irq_modify_status() at all (tglx)
* Removed legacy syscalls (Arnd)
* cpu_idle to use schedule_preempt_disabled API (tglx)
* clocksource/clockevent code renamed/reworked (tglx)
* Removed possible live-lock in sched_clock() (tglx)
* Ensured that syscalls are not restarted multiple times (Al Viro)
* Support for DeviceTree based dynamic platform device registration (Arnd)
* clock-speed / mem-size extracted from Device Tree (Arnd)
* multi-platform-image - Non-exclusive platform selection in build (Arnd)
* multi-platform-image - Non-exclusive boards selection in build (Arnd)
* Fix the issue in switch to generic_execve (Al Viro)
* defconfigs need to be created using savedefconfig (Arnd)
* Remove support for legacy ptrace POKEUSR/PEEKUSR ABI (Arnd)
* module stubs need not be defined in Arch code (Arnd)
* Low Level Event Capture completely taken out (Arnd)
* Unaligned access runtime controlled using 2 sysctl knobs (Arnd)
* using io accessors for programming BVCI Latency Unit (Arnd)

Other fixes:

* 3.7 -> 3.8 upstream changes
* Rebased off of 3.8-rc4
* UAPI Disintegration using scripts provided David Howells
* Generic clone/fork/vfork
* switch to saner kernel_execve semantics (GENERIC_KERNEL_EXECVE)
* Altstack consolidation tracking changes
* trace_clock.h introduction, cacheflush.h inclusion removal from io.h
* bitops
* test_and_clear_bit() was SETing the bit instead of CLEARing
* test_and_*_bit() workaround a gas bug where a bitpos > 31 is not reported by doing __builtin_constant_p() check early
* uaccess
* Added support for non-inline copy_{to,from}_user() for -Os
* Optimised {get,put}_user() by overriding asm-generic versions
* Timers
* split Process scheduling/Timers patch into two.
* Add support for 64bit timestamp counter using RTSC instruction.
* Others
* Move the incore intc chip handler out of platform code into common code
* cpu_ide() to use the rcu_idle_* calls

Gilad Ben-Yossef (1):
ARC: Add support for ioremap_prot API

Mischa Jonker (1):
ARC: kgdb support

Vineet Gupta (74):
ARC: Generic Headers
ARC: irqflags - Interrupt enabling/disabling at in-core intc
ARC: Atomic/bitops/cmpxchg/barriers
asm-generic headers: uaccess.h to conditionally define segment_eq()
ARC: uaccess friends
asm-generic: uaccess: Allow arches to over-ride __{get,put}_user_fn()
ARC: [optim] uaccess __{get,put}_user() optimised 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 Handling
ARC: Interrupt Handling
ARC: Non-MMU Exception Handling
ARC: Syscall support (no-legacy-syscall ABI)
ARC: Process-creation/scheduling/idle-loop
ARC: Timers/counters/delay management
ARC: Signal handling
ARC: [Review] Preparing to fix incorrect syscall restarts due to
signals
ARC: [Review] Prevent incorrect syscall restarts
ARC: Cache Flush Management
ARC: Page Table Management
ARC: MMU Context Management
ARC: MMU Exception Handling
ARC: TLB flush Handling
ARC: Page Fault handling
ARC: I/O and DMA Mappings
ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init
ARC: [plat-arcfpga] Static platform device for CONFIG_SERIAL_ARC
ARC: Build system: Makefiles, Kconfig, Linker script
ARC: [DeviceTree] Basic support
ARC: [DeviceTree] Convert some Kconfig items to runtime values
ARC: [plat-arcfpga]: Enabling DeviceTree for Angel4 board
ARC: Last bits (stubs) to get to a running kernel with UART
ARC: Switch to generic kernel_thread() - split ret_from_fork
ARC: Switch to generic kernel_execve() and sys_execve()
ARC: Switch to saner kernel_execve() semantics #1
ARC: Switch to saner kernel_execve() semantics #2
ARC: Switch to generic sys_clone, fork, vfork
ARC: [3.8 tracking] altstack consolidation, trace_clock, cacheflush.h
ARC: [plat-arcfpga] defconfig
ARC: [optim] Cache "current" in Register r25
ARC: ptrace support
ARC: Futex support
ARC: OProfile support
ARC: Support for high priority interrupts in the in-core intc
ARC: Module support
ARC: Diagnostics: show_regs() etc
ARC: SMP support
ARC: DWARF2 .debug_frame based stack unwinder
ARC: stacktracing APIs based on dw2 unwinder
ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul)
ARC: kprobes support
sysctl: Enable PARISC "unaligned-trap" to be used cross-arch
ARC: Unaligned access emulation
ARC: Boot #2: Verbose Boot reporting / feature verification
ARC: [plat-arfpga] BVCI Latency Unit setup
perf, ARC: Enable building perf tools for ARC
ARC: perf support (software counters only)
ARC: Support for single cycle Close Coupled Mem (CCM)
ARC: Hostlink Pseudo-Driver for Metaware Debugger
ARC: Add self to MAINTAINERS
ARC: UAPI Disintegrate arch/arc/include/asm
ARC: [Review] Multi-platform image #1: Kconfig enablement
ARC: Fold boards sub-menu into platform/SoC menu
ARC: [Review] Multi-platform image #2: Board callback Infrastructure
ARC: [Review] Multi-platform image #3: switch to board callback
ARC: [Review] Multi-platform image #4: Isolate platform headers
ARC: [Review] Multi-platform image #5: NR_IRQS defined by ARC core
ARC: [Review] Multi-platform image #6: cpu-to-dma-addr optional
ARC: [Review] Multi-platform image #7: SMP common code to use
callbacks
ARC: [Review] Multi-platform image #8: platform registers SMP
callbacks
ARC: [plat-arcfpga] defconfig for fully loaded ARC Linux

 .../devicetree/bindings/arc/interrupts.txt         |   24 +
 MAINTAINERS                                        |    6 +
 arch/arc/Kbuild                                    |    2 +
 arch/arc/Kconfig                                   |  461 +++++++
 arch/arc/Kconfig.debug                             |   34 +
 arch/arc/Makefile                                  |  126 ++
 arch/arc/boot/Makefile                             |   26 +
 arch/arc/boot/dtb/Makefile                         |   22 +
 arch/arc/boot/dts/angel4.dts                       |   55 +
 arch/arc/boot/dts/skeleton.dts                     |   10 +
 arch/arc/boot/dts/skeleton.dtsi                    |   37 +
 arch/arc/configs/fpga_defconfig                    |   51 +
 arch/arc/include/asm/Kbuild                        |   49 +
 arch/arc/include/asm/arcregs.h                     |  433 +++++++
 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                      |  516 ++++++++
 arch/arc/include/asm/bug.h                         |   37 +
 arch/arc/include/asm/cache.h                       |   75 ++
 arch/arc/include/asm/cacheflush.h                  |   67 +
 arch/arc/include/asm/checksum.h                    |  101 ++
 arch/arc/include/asm/clk.h                         |   22 +
 arch/arc/include/asm/cmpxchg.h                     |  143 +++
 arch/arc/include/asm/current.h                     |   32 +
 arch/arc/include/asm/defines.h                     |   56 +
 arch/arc/include/asm/delay.h                       |   68 +
 arch/arc/include/asm/disasm.h                      |  116 ++
 arch/arc/include/asm/dma-mapping.h                 |  193 +++
 arch/arc/include/asm/dma.h                         |   14 +
 arch/arc/include/asm/elf.h                         |   97 ++
 arch/arc/include/asm/entry.h                       |  724 +++++++++++
 arch/arc/include/asm/exec.h                        |   15 +
 arch/arc/include/asm/futex.h                       |  151 +++
 arch/arc/include/asm/io.h                          |   28 +
 arch/arc/include/asm/irq.h                         |   25 +
 arch/arc/include/asm/irqflags.h                    |  153 +++
 arch/arc/include/asm/kdebug.h                      |   19 +
 arch/arc/include/asm/kgdb.h                        |   61 +
 arch/arc/include/asm/kprobes.h                     |   62 +
 arch/arc/include/asm/linkage.h                     |   63 +
 arch/arc/include/asm/mach_desc.h                   |   85 ++
 arch/arc/include/asm/mmu.h                         |   23 +
 arch/arc/include/asm/mmu_context.h                 |  213 ++++
 arch/arc/include/asm/module.h                      |   28 +
 arch/arc/include/asm/mutex.h                       |   18 +
 arch/arc/include/asm/page.h                        |  109 ++
 arch/arc/include/asm/perf_event.h                  |   13 +
 arch/arc/include/asm/pgalloc.h                     |  134 ++
 arch/arc/include/asm/pgtable.h                     |  405 ++++++
 arch/arc/include/asm/processor.h                   |  151 +++
 arch/arc/include/asm/prom.h                        |   14 +
 arch/arc/include/asm/ptrace.h                      |  125 ++
 arch/arc/include/asm/sections.h                    |   18 +
 arch/arc/include/asm/segment.h                     |   24 +
 arch/arc/include/asm/setup.h                       |   37 +
 arch/arc/include/asm/smp.h                         |  130 ++
 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/switch_to.h                   |   41 +
 arch/arc/include/asm/syscall.h                     |   72 ++
 arch/arc/include/asm/syscalls.h                    |   29 +
 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                     |  751 +++++++++++
 arch/arc/include/asm/unaligned.h                   |   29 +
 arch/arc/include/asm/unwind.h                      |  163 +++
 arch/arc/include/asm/vmlinux.lds.h                 |   12 +
 arch/arc/include/uapi/asm/Kbuild                   |   11 +
 arch/arc/include/uapi/asm/byteorder.h              |   18 +
 arch/arc/include/uapi/asm/cachectl.h               |   28 +
 arch/arc/include/uapi/asm/page.h                   |   39 +
 arch/arc/include/uapi/asm/ptrace.h                 |   46 +
 arch/arc/include/uapi/asm/sigcontext.h             |   23 +
 arch/arc/include/uapi/asm/signal.h                 |   27 +
 arch/arc/include/uapi/asm/swab.h                   |   98 ++
 arch/arc/include/uapi/asm/unistd.h                 |   34 +
 arch/arc/kernel/Makefile                           |   33 +
 arch/arc/kernel/arc_hostlink.c                     |  114 ++
 arch/arc/kernel/arcksyms.c                         |   56 +
 arch/arc/kernel/asm-offsets.c                      |   49 +
 arch/arc/kernel/clk.c                              |   21 +
 arch/arc/kernel/ctx_sw.c                           |  109 ++
 arch/arc/kernel/ctx_sw_asm.S                       |   58 +
 arch/arc/kernel/devtree.c                          |  113 ++
 arch/arc/kernel/disasm.c                           |  538 ++++++++
 arch/arc/kernel/entry.S                            |  844 +++++++++++++
 arch/arc/kernel/fpu.c                              |   55 +
 arch/arc/kernel/head.S                             |  111 ++
 arch/arc/kernel/irq.c                              |  273 ++++
 arch/arc/kernel/kgdb.c                             |  205 +++
 arch/arc/kernel/kprobes.c                          |  525 ++++++++
 arch/arc/kernel/module.c                           |  145 +++
 arch/arc/kernel/process.c                          |  228 ++++
 arch/arc/kernel/ptrace.c                           |  158 +++
 arch/arc/kernel/reset.c                            |   33 +
 arch/arc/kernel/setup.c                            |  471 +++++++
 arch/arc/kernel/signal.c                           |  363 ++++++
 arch/arc/kernel/smp.c                              |  331 +++++
 arch/arc/kernel/stacktrace.c                       |  254 ++++
 arch/arc/kernel/sys.c                              |   18 +
 arch/arc/kernel/time.c                             |  295 +++++
 arch/arc/kernel/traps.c                            |  170 +++
 arch/arc/kernel/troubleshoot.c                     |  322 +++++
 arch/arc/kernel/unaligned.c                        |  245 ++++
 arch/arc/kernel/unwind.c                           | 1329 ++++++++++++++++++++
 arch/arc/kernel/vmlinux.lds.S                      |  164 +++
 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                         |  771 ++++++++++++
 arch/arc/mm/dma.c                                  |   91 ++
 arch/arc/mm/extable.c                              |   63 +
 arch/arc/mm/fault.c                                |  228 ++++
 arch/arc/mm/init.c                                 |  197 +++
 arch/arc/mm/ioremap.c                              |   86 ++
 arch/arc/mm/tlb.c                                  |  645 ++++++++++
 arch/arc/mm/tlbex.S                                |  408 ++++++
 arch/arc/oprofile/Makefile                         |    9 +
 arch/arc/oprofile/common.c                         |   22 +
 arch/arc/plat-arcfpga/Kconfig                      |   83 ++
 arch/arc/plat-arcfpga/Makefile                     |   12 +
 arch/arc/plat-arcfpga/include/plat/irq.h           |   31 +
 arch/arc/plat-arcfpga/include/plat/memmap.h        |   31 +
 arch/arc/plat-arcfpga/include/plat/smp.h           |  118 ++
 arch/arc/plat-arcfpga/irq.c                        |   25 +
 arch/arc/plat-arcfpga/platform.c                   |  235 ++++
 arch/arc/plat-arcfpga/smp.c                        |  171 +++
 arch/parisc/Kconfig                                |    1 +
 include/asm-generic/checksum.h                     |    4 +
 include/asm-generic/uaccess.h                      |   14 +-
 init/Kconfig                                       |    8 +
 kernel/sysctl.c                                    |    7 +-
 lib/checksum.c                                     |    2 +
 tools/perf/perf.h                                  |    6 +
 145 files changed, 19488 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arc/interrupts.txt
 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/boot/dtb/Makefile
 create mode 100644 arch/arc/boot/dts/angel4.dts
 create mode 100644 arch/arc/boot/dts/skeleton.dts
 create mode 100644 arch/arc/boot/dts/skeleton.dtsi
 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/cache.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/clk.h
 create mode 100644 arch/arc/include/asm/cmpxchg.h
 create mode 100644 arch/arc/include/asm/current.h
 create mode 100644 arch/arc/include/asm/defines.h
 create mode 100644 arch/arc/include/asm/delay.h
 create mode 100644 arch/arc/include/asm/disasm.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/futex.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/kgdb.h
 create mode 100644 arch/arc/include/asm/kprobes.h
 create mode 100644 arch/arc/include/asm/linkage.h
 create mode 100644 arch/arc/include/asm/mach_desc.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/perf_event.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/prom.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/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/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/unaligned.h
 create mode 100644 arch/arc/include/asm/unwind.h
 create mode 100644 arch/arc/include/asm/vmlinux.lds.h
 create mode 100644 arch/arc/include/uapi/asm/Kbuild
 create mode 100644 arch/arc/include/uapi/asm/byteorder.h
 create mode 100644 arch/arc/include/uapi/asm/cachectl.h
 create mode 100644 arch/arc/include/uapi/asm/page.h
 create mode 100644 arch/arc/include/uapi/asm/ptrace.h
 create mode 100644 arch/arc/include/uapi/asm/setup.h
 create mode 100644 arch/arc/include/uapi/asm/sigcontext.h
 create mode 100644 arch/arc/include/uapi/asm/signal.h
 create mode 100644 arch/arc/include/uapi/asm/swab.h
 create mode 100644 arch/arc/include/uapi/asm/unistd.h
 create mode 100644 arch/arc/kernel/Makefile
 create mode 100644 arch/arc/kernel/arc_hostlink.c
 create mode 100644 arch/arc/kernel/arcksyms.c
 create mode 100644 arch/arc/kernel/asm-offsets.c
 create mode 100644 arch/arc/kernel/clk.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/devtree.c
 create mode 100644 arch/arc/kernel/disasm.c
 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/kgdb.c
 create mode 100644 arch/arc/kernel/kprobes.c
 create mode 100644 arch/arc/kernel/module.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/smp.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/unaligned.c
 create mode 100644 arch/arc/kernel/unwind.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/tlb.c
 create mode 100644 arch/arc/mm/tlbex.S
 create mode 100644 arch/arc/oprofile/Makefile
 create mode 100644 arch/arc/oprofile/common.c
 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/irq.h
 create mode 100644 arch/arc/plat-arcfpga/include/plat/memmap.h
 create mode 100644 arch/arc/plat-arcfpga/include/plat/smp.h
 create mode 100644 arch/arc/plat-arcfpga/irq.c
 create mode 100644 arch/arc/plat-arcfpga/platform.c
 create mode 100644 arch/arc/plat-arcfpga/smp.c
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v2 1/76 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

PATCH v2 2/76 ARC: irqflags - Interrupt enabling/disabling at in-core intc

In reply to Vineet Gupta

ARC700 has an in-core intc which provides 2 priorities (a.k.a.) "levels" of interrupts (per IRQ) hencforth referred to as L1/L2 interrupts.

CPU flags register STATUS32 has Interrupt Enable bits per level (E1/E2) to globally enable (or disable) all IRQs at a level. Hence the implementation of arch_local_irq_{save,restore,enable,disable}( )

The STATUS32 reg can be r/w only using the AUX Interface of ARC, hence the use of LR/SR instructions. Further, E1/E2 bits in there can only be updated using the FLAG insn.

The intc supports 32 interrupts - and per IRQ enabling is controlled by a bit in the AUX_IENABLE register, hence the implmentation of arch_{,un}mask_irq( ) routines.

Cc Thomas Gleixner <[email protected]>
---
 arch/arc/include/asm/arcregs.h  |  114 ++++++++++++++++++++++++++++++
 arch/arc/include/asm/irqflags.h |  149 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/irq.c           |   32 ++++++++
 3 files changed, 295 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 +149 -0

149 lines not on this page · raw message

arch/arc/kernel/irq.c new file +32 -0
new file mode 100644
index 0000000..c4e9b25
@@ -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;
+
+	/*
+	 * ARC IDE Drivers tries to re-enable interrupts from hard-isr
+	 * context which is simply wrong
+	 */
+	if (in_irq()) {
+		WARN_ONCE(1, "IRQ enabled from hard-isr");
+		return;
+	}
+
+	flags = arch_local_save_flags();
+	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
#3 lore raw

PATCH v2 3/76 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  |  516 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/cmpxchg.h |  143 +++++++++++
 arch/arc/include/asm/smp.h     |   34 +++
 5 files changed, 967 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..83f03ca
@@ -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
+
+#ifdef __KERNEL__
+
+#ifndef __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 +516 -0

516 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
#4 lore raw

PATCH v2 4/76 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
#5 lore raw

PATCH v2 5/76 ARC: uaccess friends

In reply to Vineet Gupta
---
 arch/arc/include/asm/segment.h |   24 ++
 arch/arc/include/asm/uaccess.h |  646 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/mm/extable.c          |   63 ++++
 3 files changed, 733 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/segment.h
 create mode 100644 arch/arc/include/asm/uaccess.h
 create mode 100644 arch/arc/mm/extable.c
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 +646 -0

646 lines not on this page · raw message

arch/arc/mm/extable.c new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#6 lore raw

PATCH v2 6/76 asm-generic: uaccess: Allow arches to over-ride __{get,put}_user_fn()

In reply to Vineet Gupta

As of now these default to calling the arch provided __copy_{to,from}_user() routines which being general purpose (w.r.t buffer alignment and lengths) would lead to alignment checks in generated code (for arches which don't support unaligned load/stores).

Given that in this case we already know that data involved is "unit" sized and aligned, using the vanilla copy backend is a bit wasteful.

This change thus allows arches to over-ride the aforementioned routines.

---
 include/asm-generic/uaccess.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
include/asm-generic/uaccess.h +11 -0
index 5f6ee61..c184aa8 100644
@@ -169,12 +169,18 @@ static inline __must_check long __copy_to_user(void __user *to,
 		-EFAULT;					\
 })
 
+#ifndef __put_user_fn
+
 static inline int __put_user_fn(size_t size, void __user *ptr, void *x)
 {
 	size = __copy_to_user(ptr, x, size);
 	return size ? -EFAULT : size;
 }
 
+#define __put_user_fn(sz, u, k)	__put_user_fn(sz, u, k)
+
+#endif
+
 extern int __put_user_bad(void) __attribute__((noreturn));
 
 #define __get_user(x, ptr)					\
@@ -225,12 +231,17 @@ extern int __put_user_bad(void) __attribute__((noreturn));
 		-EFAULT;					\
 })
 
+#ifndef __get_user_fn
 static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
 {
 	size = __copy_from_user(x, ptr, size);
 	return size ? -EFAULT : size;
 }
 
+#define __get_user_fn(sz, u, k)	__get_user_fn(sz, u, k)
+
+#endif
+
 extern int __get_user_bad(void) __attribute__((noreturn));
 
 #ifndef __copy_from_user_inatomic
Signature · 1 line
1.7.4.1
#7 lore raw

PATCH v2 7/76 ARC: [optim] uaccess __{get,put}_user() optimised

In reply to Vineet Gupta

Override asm-generic implementations. We basically gain on 2 fronts

* checks for alignment no longer needed as we are only doing "unit" sized copies.

(Careful observer could argue that While the kernel buffers are aligned,
the user buffer in theory might not be - however in that case the user space is already broken when it tries to deref a hword/word straddling word boundary - so we are not making it any worse).

* __copy_{to,from}_user( ) returns bytes that couldn't be copied, whereas get_user() returns 0 for success or -EFAULT (not size). Thus the code to do leftover bytes calculation can be avoided as well.

The savings were significant: ~17k of code.

bloat-o-meter vmlinux_uaccess_pre vmlinux_uaccess_post add/remove: 0/4 grow/shrink: 8/118 up/down: 1262/-18758 (-17496)

							^^^^^^^^^
---
 arch/arc/include/asm/uaccess.h |  105 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 0 deletions(-)
arch/arc/include/asm/uaccess.h +105 -0
index f13bca4..3242082 100644
@@ -57,6 +57,111 @@
 #define __access_ok(addr, sz)	(unlikely(__kernel_ok) || \
 				 likely(__user_ok((addr), (sz))))
 
+/*********** Single byte/hword/word copies ******************/
+
+#define __get_user_fn(sz, u, k)					\
+({								\
+	long __ret = 0;	/* success by default */	\
+	switch (sz) {						\
+	case 1: __arc_get_user_one(*(k), u, "ldb", __ret); break;	\
+	case 2: __arc_get_user_one(*(k), u, "ldw", __ret); break;	\
+	case 4: __arc_get_user_one(*(k), u, "ld", __ret);  break;	\
+	case 8: __arc_get_user_one_64(*(k), u, __ret);     break;	\
+	}							\
+	__ret;							\
+})
+
+/*
+ * Returns 0 on success, -EFAULT if not.
+ * @ret already contains 0 - given that errors will be less likely
+ * (hence +r asm constraint below).
+ * In case of error, fixup code will make it -EFAULT
+ */
+#define __arc_get_user_one(dst, src, op, ret)	\
+	__asm__ __volatile__(                   \
+	"1:	"op"    %1,[%2]\n"		\
+	"2:	;nop\n"				\
+	"	.section .fixup, \"ax\"\n"	\
+	"	.align 4\n"			\
+	"3:	mov %0, %3\n"			\
+	"	j   2b\n"			\
+	"	.previous\n"			\
+	"	.section __ex_table, \"a\"\n"	\
+	"	.align 4\n"			\
+	"	.word 1b,3b\n"			\
+	"	.previous\n"			\
+						\
+	: "+r" (ret), "=r" (dst)		\
+	: "r" (src), "ir" (-EFAULT))
+
+#define __arc_get_user_one_64(dst, src, ret)	\
+	__asm__ __volatile__(                   \
+	"1:	ld   %1,[%2]\n"			\
+	"4:	ld  %R1,[%2, 4]\n"		\
+	"2:	;nop\n"				\
+	"	.section .fixup, \"ax\"\n"	\
+	"	.align 4\n"			\
+	"3:	mov %0, %3\n"			\
+	"	j   2b\n"			\
+	"	.previous\n"			\
+	"	.section __ex_table, \"a\"\n"	\
+	"	.align 4\n"			\
+	"	.word 1b,3b\n"			\
+	"	.word 4b,3b\n"			\
+	"	.previous\n"			\
+						\
+	: "+r" (ret), "=r" (dst)		\
+	: "r" (src), "ir" (-EFAULT))
+
+#define __put_user_fn(sz, u, k)					\
+({								\
+	long __ret = 0;	/* success by default */	\
+	switch (sz) {						\
+	case 1: __arc_put_user_one(*(k), u, "stb", __ret); break;	\
+	case 2: __arc_put_user_one(*(k), u, "stw", __ret); break;	\
+	case 4: __arc_put_user_one(*(k), u, "st", __ret);  break;	\
+	case 8: __arc_put_user_one_64(*(k), u, __ret);     break;	\
+	}							\
+	__ret;							\
+})
+
+#define __arc_put_user_one(src, dst, op, ret)	\
+	__asm__ __volatile__(                   \
+	"1:	"op"    %1,[%2]\n"		\
+	"2:	;nop\n"				\
+	"	.section .fixup, \"ax\"\n"	\
+	"	.align 4\n"			\
+	"3:	mov %0, %3\n"			\
+	"	j   2b\n"			\
+	"	.previous\n"			\
+	"	.section __ex_table, \"a\"\n"	\
+	"	.align 4\n"			\
+	"	.word 1b,3b\n"			\
+	"	.previous\n"			\
+						\
+	: "+r" (ret)				\
+	: "r" (src), "r" (dst), "ir" (-EFAULT))
+
+#define __arc_put_user_one_64(src, dst, ret)	\
+	__asm__ __volatile__(                   \
+	"1:	st   %1,[%2]\n"			\
+	"4:	st  %R1,[%2, 4]\n"		\
+	"2:	;nop\n"				\
+	"	.section .fixup, \"ax\"\n"	\
+	"	.align 4\n"			\
+	"3:	mov %0, %3\n"			\
+	"	j   2b\n"			\
+	"	.previous\n"			\
+	"	.section __ex_table, \"a\"\n"	\
+	"	.align 4\n"			\
+	"	.word 1b,3b\n"			\
+	"	.word 4b,3b\n"			\
+	"	.previous\n"			\
+						\
+	: "+r" (ret)				\
+	: "r" (src), "r" (dst), "ir" (-EFAULT))
+
+
 static inline unsigned long
 __arc_copy_from_user(void *to, const void __user *from, unsigned long n)
 {
Signature · 1 line
1.7.4.1
maintainer Acked-by on v2 7/76
#8 lore raw

Re: [PATCH v2 07/76] ARC: [optim] uaccess __{get,put}_user() optimised

Quoted 5 lines · Vineet Gupta

Override asm-generic implementations. We basically gain on 2 fronts

* checks for alignment no longer needed as we are only doing "unit" sized copies.

Quoted 8 lines

(Careful observer could argue that While the kernel buffers are aligned,
the user buffer in theory might not be - however in that case the user space is already broken when it tries to deref a hword/word straddling word boundary - so we are not making it any worse).

* __copy_{to,from}_user( ) returns bytes that couldn't be copied, whereas get_user() returns 0 for success or -EFAULT (not size). Thus the code to do leftover bytes calculation can be avoided as well.

Interesting. I had thought that the compiler would be able to simplify the calculation of the return value inline, but of course it cannot because it has to be done inside the asm fixup.

Quoted 6 lines

The savings were significant: ~17k of code.

bloat-o-meter vmlinux_uaccess_pre vmlinux_uaccess_post add/remove: 0/4 grow/shrink: 8/118 up/down: 1262/-18758 (-17496)

                                                        ^^^^^^^^^
#9 lore raw

PATCH v2 8/76 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
#10 lore raw

PATCH v2 9/76 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      |   98 ++++++++++++++++++++++++++++++++++++
 3 files changed, 217 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 +98 -0

98 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer Acked-by on v2 9/76
#11 lore raw

Re: [PATCH v2 09/76] ARC: Checksum/byteorder/swab routines

Quoted 1 line · Vineet Gupta

TBD: do_csum still needs to be written in asm

Do you actually expect a lot of improvement in do_csum? I would hope that gcc can actually generate a pretty good version of it, unless you have some 64-bit add-with-carry instruction or something else that you could make use of.

Quoted 1 line
#12 lore raw

Re: [PATCH v2 09/76] ARC: Checksum/byteorder/swab routines

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

TBD: do_csum still needs to be written in asm

Do you actually expect a lot of improvement in do_csum? I would hope that gcc can actually generate a pretty good version of it, unless you have some 64-bit add-with-carry instruction or something else that you could make use of.

We do have 32bit add-with-carry and it has it's own set of micro-architectural hazards and stalls which deserve careful insn scheduling. So yes the mileage would vary but certainly deserves a try.

Quoted 3 lines
Quoted 2 lines

Thanks,
-Vineet

#13 lore raw

PATCH v2 10/76 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_*

To disallow user-space visibility into some of the core kernel data-types such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h

---
 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      |  132 +++++++++++++++++++++++++++++++++
 arch/arc/include/asm/sections.h    |   17 ++++
 arch/arc/include/asm/thread_info.h |  120 ++++++++++++++++++++++++++++++
 12 files changed, 690 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 +132 -0

132 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
maintainer Acked-by on v2 10/76
#14 lore raw

Re: [PATCH v2 10/76] ARC: Fundamental ARCH data-types/defines

Quoted 9 lines · 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_*

Quoted 6 lines

To disallow user-space visibility into some of the core kernel data-types such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h

#15 lore raw

Re: [PATCH v2 10/76] ARC: Fundamental ARCH data-types/defines

In reply to Vineet Gupta

arch/arc/include/asm/thread_info.h line 110

Quoted 2 lines · Vineet Gupta
arch/arc/include/asm/thread_info.h new file +2 -0
+/* work to do on interrupt/exception return */
+#define _TIF_WORK_MASK		(0x0000FFFF & ~_TIF_SYSCALL_TRACE)

Yuck... Use the real set, please - there's future-proofing and then there's leaving nasty minefields; this is the latter...

#16 lore raw

Re: [PATCH v2 10/76] ARC: Fundamental ARCH data-types/defines

Quoted 6 lines · Al Viro

arch/arc/include/asm/thread_info.h line 110

Quoted 2 lines · Vineet Gupta
arch/arc/include/asm/thread_info.h new file +2 -0
+/* work to do on interrupt/exception return */
+#define _TIF_WORK_MASK		(0x0000FFFF & ~_TIF_SYSCALL_TRACE)

Yuck... Use the real set, please - there's future-proofing and then there's leaving nasty minefields; this is the latter...

Rightly so - fixed in next revision. BTW I'm not bothering with SYSCALL_AUDIT yet, so that's out of those.

-#define _TIF_WORK_MASK (0x0000FFFF & ~_TIF_SYSCALL_TRACE)
+#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING \
+ _TIF_NOTIFY_RESUME)

Thx,
-Vineet

#17 lore raw

PATCH v2 11/76 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
#19 lore raw

PATCH v2 12/76 ARC: String library

In reply to Vineet Gupta

Hand optimised asm code for ARC700 pipeline.
Originally written/optimized by Joern Rennecke

Cc Joern Rennecke <[email protected]>
---
 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
#20 lore raw

PATCH v2 13/76 ARC: Low level IRQ/Trap/Exception Handling

In reply to Vineet Gupta
---
 arch/arc/include/asm/entry.h |  495 ++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/entry.S      |  571 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1066 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..63705b1
@@ -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 with 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_KERNEL:
+ * 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 +571 -0

571 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#21 lore raw

Re: [PATCH v2 13/76] ARC: Low level IRQ/Trap/Exception Handling

arch/arc/kernel/entry.S line 497

Quoted 6 lines · Vineet Gupta
arch/arc/kernel/entry.S new file +6 -0
+	; --- (Slow Path #3) notify_resume ---
+.Lchk_notify_resume:
+	btst   r9, TIF_NOTIFY_RESUME
+	blnz   @do_notify_resume
+	b      resume_user_mode_begin	; unconditionally back to U mode ret chks
+					; for single exit point from this block

Umm... Can we even get there without NOTIFY_RESUME? Again, there's future-proofing and there's laying minefields - think what will happen if we *do* get there with some bit in _TIF_WORK_MASK that isn't recognized by any of these cases. Looping forever?

#22 lore raw

Re: [PATCH v2 13/76] ARC: Low level IRQ/Trap/Exception Handling

Quoted 12 lines · Al Viro

arch/arc/kernel/entry.S line 497

Quoted 6 lines · Vineet Gupta
arch/arc/kernel/entry.S new file +6 -0
+	; --- (Slow Path #3) notify_resume ---
+.Lchk_notify_resume:
+	btst   r9, TIF_NOTIFY_RESUME
+	blnz   @do_notify_resume
+	b      resume_user_mode_begin	; unconditionally back to U mode ret chks
+					; for single exit point from this block

Umm... Can we even get there without NOTIFY_RESUME? Again, there's future-proofing and there's laying minefields - think what will happen if we *do* get there with some bit in _TIF_WORK_MASK that isn't recognized by any of these cases. Looping forever?

IMHO, for future safe-ing, the test for TIF_NOTIFY_RESUME is correct (as we will need to add that check the moment a new bit is introduced in _TIF_WORK_MASK).

Regarding the infinite loop, I would assume that _TIF_WORK_MASK is golden (fixed by your prior comment) so anyone touching it needs to add corresponding code here
- IMHO we don't need to handle that scenario (maybe add a comment in thread_info.h). With that assumption, the unconditional branch would go back to start and the re-test for TIF_WORK_MASK will break the loop even if any stray bit was set.

So essentially we don't need any code change ! Am I overlooking something here ?

-Vineet

#23 lore raw

PATCH v2 14/76 ARC: Interrupt Handling

In reply to Vineet Gupta

This contains:
-bootup arch IRQ init: init_IRQ(), arc_init_IRQ()
-generic IRQ subsystem glue: arch_do_IRQ()
-basic IRQ chip setup for in-core intc

Cc Thomas Gleixner <[email protected]>
---
 arch/arc/include/asm/arcregs.h |    3 +
 arch/arc/include/asm/hw_irq.h  |    7 +++
 arch/arc/include/asm/irq.h     |   22 ++++++++
 arch/arc/kernel/irq.c          |  107 +++++++++++++++++++++++++++++++++++++++-
 arch/arc/plat-arcfpga/irq.c    |   15 ++++++
 5 files changed, 152 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 +22 -0
new file mode 100644
index 0000000..ca4aeba
@@ -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 __ASM_ARC_IRQ_H
+#define __ASM_ARC_IRQ_H
+
+/* Platform Independent 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);
+
+#endif
arch/arc/kernel/irq.c +105 -2

113 lines not on this page · raw message

arch/arc/plat-arcfpga/irq.c new file +15 -0
new file mode 100644
index 0000000..ed72636
@@ -0,0 +1,15 @@
+/*
+ * ARC FPGA Platform IRQ hookups
+ *
+ * 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/interrupt.h>
+
+void __init plat_init_IRQ(void)
+{
+}
Signature · 1 line
1.7.4.1
#24 lore raw

PATCH v2 15/76 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
#25 lore raw

PATCH v2 16/76 ARC: Syscall support (no-legacy-syscall ABI)

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   |   29 ++++++++++
 arch/arc/kernel/entry.S         |   49 ++++++++++++++++
 arch/arc/kernel/process.c       |  119 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/sys.c           |   19 ++++++
 7 files changed, 323 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
arch/arc/include/asm/ptrace.h +5 -0
index 561c7eb..9abbb7c 100644
@@ -125,6 +125,11 @@ struct user_regs_struct {
 		sp = -1;	\
 	sp;			\
 })
+
+/* 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 /* __KERNEL__ */
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 +29 -0
new file mode 100644
index 0000000..6a2d101
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+/******** no-legacy-syscalls-ABI *******/
+
+#define sys_mmap2 sys_mmap_pgoff
+
+#include <asm-generic/unistd.h>
+
+#define NR_syscalls	__NR_syscalls
+
+/* ARC specific syscall */
+#define __NR_cacheflush		(__NR_arch_specific_syscall + 0)
+#define __NR_arc_settls		(__NR_arch_specific_syscall + 1)
+#define __NR_arc_gettls		(__NR_arch_specific_syscall + 2)
+
+__SYSCALL(__NR_cacheflush, sys_cacheflush)
+__SYSCALL(__NR_arc_settls, sys_arc_settls)
+__SYSCALL(__NR_arc_gettls, sys_arc_gettls)
+
+
+/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
+#define __NR_sysfs		(__NR_arch_specific_syscall + 3)
+__SYSCALL(__NR_sysfs, sys_sysfs)
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>
+};
Signature · 1 line
1.7.4.1
#27 lore raw

Re: [PATCH v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

In reply to Vineet Gupta

Please, collapse your #36--#40 into that one (and I'd probably fold #17 here as well, to simplify that reordering). Sure, it's not a bisection hazard, but...

#28 lore raw

Re: [PATCH v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

Quoted 3 lines · Al Viro

Please, collapse your #36--#40 into that one (and I'd probably fold #17 here as well, to simplify that reordering). Sure, it's not a bisection hazard, but...

Thanks again for the review Al.

Sure, I can do that - however because those patches have bits in arch/arc/Kconfig, I'll have to move the Build system patch towards start of series, or simply chop off Kconfig bits out of those and add them later - what do you prefer ?

My only reason for chunking those up was to capture the intermediate development of how execve and friends were generalized (and have limited revision history even in initial upstream version). While I was used to the old code, specially copy_thread() between 1st and last change seemed to be almost rewritten. Having said that, I don't have strong opinion either ways.

Thx,
-Vineet

#29 lore raw

Re: [PATCH v2 16/76] ARC: Syscall support (no-legacy-syscall ABI)

In reply to Al Viro
Quoted 4 lines · Al Viro

Please, collapse your #36--#40 into that one (and I'd probably fold #17 here as well, to simplify that reordering). Sure, it's not a bisection hazard, but...

I kept #16 and #17 distinct and

* squashed switch-to-generic-kernel-thread #36 into process creation patch #17
* split generic kernel_execve and sys_execve #37 into two
* squashed sys_execve bits into syscall patch #16
* squashed kernel_execve patch into #17
* squashed switch-to-saner-execve patches #38 and #39 into #17
* squashed generic clone patch #40 into #16

#30 lore raw

PATCH v2 17/76 ARC: Process-creation/scheduling/idle-loop

In reply to Vineet Gupta
Cc Al Viro <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 arch/arc/include/asm/arcregs.h   |   20 ++++
 arch/arc/include/asm/processor.h |    3 +
 arch/arc/include/asm/switch_to.h |   41 ++++++++
 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 ++++++++++++++++++++++++++++++++++++++
 7 files changed, 469 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/switch_to.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
arch/arc/include/asm/arcregs.h +20 -0
index 3fccb04..d764118 100644
@@ -47,6 +47,17 @@
 #define AUX_ITRIGGER		0x40d
 #define AUX_IPULSE		0x415
 
+/*
+ * 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 +121,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/processor.h +3 -0
index bf88cfb..053a639 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/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

Signature · 1 line
1.7.4.1
maintainer
#31 lore raw

Re: [PATCH v2 17/76] ARC: Process-creation/scheduling/idle-loop

Quoted 8 lines · Vineet Gupta
arch/arc/kernel/process.c +8 -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();
+               rcu_idle_enter();

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

Quoted 10 lines
arch/arc/kernel/process.c +10 -0
+
+               while (!need_resched())
+                       arch_idle();
+
+               rcu_idle_exit();
+               tick_nohz_idle_exit();
+
+               schedule_preempt_disabled();
+       }
+}

Unless I'm mistaken, you have introduced the classic sleep race here, where an interrupt can happen between the check for need_resched() and the sleep instruction in arch_idle().

To avoid that, you need to disable interrupts around the inner loop. The sleep instruction should return with interrupts implicitly enabled if ARC behaves like most other architectures doing this.

Arnd

#32 lore raw

Re: [PATCH v2 17/76] ARC: Process-creation/scheduling/idle-loop

Quoted 14 lines · Arnd Bergmann
Quoted 13 lines · Vineet Gupta
arch/arc/kernel/process.c +13 -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();
+               rcu_idle_enter();
+
+               while (!need_resched())
+                       arch_idle();
+
+               rcu_idle_exit();
Quoted 8 lines

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

Quoted 5 lines
arch/arc/kernel/process.c +5 -0
+               tick_nohz_idle_exit();
+
+               schedule_preempt_disabled();
+       }
+}

Unless I'm mistaken, you have introduced the classic sleep race here, where an interrupt can happen between the check for need_resched() and the sleep instruction in arch_idle().

Hmm... there is indeed a race - so we could end up missing a reschedule opportunity, for until next interrupt (so next tick, if NOHZ is not enabled, and indefinitely if system has no other interrupting sources).

Quoted 6 lines

To avoid that, you need to disable interrupts around the inner loop. The sleep instruction should return with interrupts implicitly enabled if ARC behaves like most other architectures doing this.

Arnd

Indeed sleep has option to turn on interrupts before it commits - so this is certainly doable.

static inline void arch_idle(void)
{

-       __asm__("sleep");
+       /* sleep, but enable all interrupts before committing */
+       __asm__("sleep 0x3");

}

- while (!need_resched())
+doze:
+ local_irq_disable();

+               if (!need_resched()) {
                        arch_idle();

+ goto doze;
+ } else {
+ local_irq_enable();
+ }

Thx,
-Vineet

maintainer
#33 lore raw

Re: [PATCH v2 17/76] ARC: Process-creation/scheduling/idle-loop

Review

Quoted 10 lines · Vineet Gupta
(quoted diff) +7 -1
-               while (!need_resched())
+doze:
+               local_irq_disable();
+               if (!need_resched()) {
                        arch_idle();
+                       goto doze;
+               } else {
+                       local_irq_enable();
+               }

Ok, that looks like it will work.

Arnd

#34 lore raw

PATCH v2 18/76 ARC: Timers/counters/delay management

In reply to Vineet Gupta

ARC700 includes 2 in-core 32bit timers TIMER0 and TIMER1. Both have exactly same capabilies.

* programmable to count from TIMER<n>_CNT to TIMER<n>_LIMIT
* for count 0 and LIMIT ~1, provides a free-running counter by auto-wrapping when limit is reached.
* optionally interrupt when LIMIT is reached (oneshot event semantics)
* rearming the interrupt provides periodic semantics
* run at CPU clk

ARC Linux uses TIMER0 for clockevent (periodic/oneshot) and TIMER1 for clocksource (free-running clock).

Newer cores provide RTSC insn which gives a 64bit cpu clk snapshot hence is more apt for clocksource when available.

SMP poses a bit of challenge for global timekeeping clocksource / sched_clock() backend:
-TIMER1 based local clocks are out-of-sync hence can't be used
(thus we default to jiffies based cs as well as sched_clock() one/both of which platform can override with it's specific hardware assist)
-RTSC is only allowed in SMP if it's cross-core-sync (Kconfig glue
ensures that) and thus usable for both requirements.

Cc Thomas Gleixner <[email protected]>
---
 arch/arc/include/asm/arcregs.h |   11 ++
 arch/arc/include/asm/clk.h     |   20 +++
 arch/arc/include/asm/delay.h   |   68 ++++++++++
 arch/arc/include/asm/irq.h     |    2 +
 arch/arc/include/asm/timex.h   |   18 +++
 arch/arc/kernel/clk.c          |   11 ++
 arch/arc/kernel/time.c         |  291 ++++++++++++++++++++++++++++++++++++++++
 7 files changed, 421 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/clk.h
 create mode 100644 arch/arc/include/asm/delay.h
 create mode 100644 arch/arc/include/asm/timex.h
 create mode 100644 arch/arc/kernel/clk.c
 create mode 100644 arch/arc/kernel/time.c
arch/arc/include/asm/arcregs.h +11 -0
index d764118..5131bb3 100644
@@ -47,6 +47,17 @@
 #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
arch/arc/include/asm/clk.h new file +20 -0
new file mode 100644
index 0000000..6195643
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+#ifndef _ASM_ARC_CLK_H
+#define _ASM_ARC_CLK_H
+
+/* Although we can't really hide core_freq, the accessor is still better way */
+extern unsigned long core_freq;
+
+static inline unsigned long arc_get_core_freq(void)
+{
+	return core_freq;
+}
+
+#endif
arch/arc/include/asm/delay.h new file +68 -0

68 lines not on this page · raw message

arch/arc/include/asm/irq.h +2 -0
index ca4aeba..514b302 100644
@@ -19,4 +19,6 @@ 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_local_timer_setup(unsigned int cpu);
+
 #endif
arch/arc/include/asm/timex.h new file +18 -0
new file mode 100644
index 0000000..0a82960
@@ -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	80000000 /* slated to be removed */
+
+#include <asm-generic/timex.h>
+
+/* XXX: get_cycles() to be implemented with RTSC insn */
+
+#endif /* _ASM_ARC_TIMEX_H */
arch/arc/kernel/clk.c new file +11 -0
new file mode 100644
index 0000000..64925db
@@ -0,0 +1,11 @@
+/*
+ * 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 <asm/clk.h>
+
+unsigned long core_freq = CONFIG_ARC_PLAT_CLK;
arch/arc/kernel/time.c new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#35 lore raw

PATCH v2 19/76 ARC: Signal handling

In reply to Vineet Gupta

Includes following fixes courtesy review by Al-Viro

* Tracer poke to Callee-regs were lost

Before going off into do_signal( ) we save the user-mode callee regs (as they are not saved by default as part of pt_regs). This is to make sure that that a Tracer (if tracing related signal) is able to do likes of PEEKUSR(callee-reg).

However in return path we were simply discarding the user-mode callee regs, which would break a POKEUSR(callee-reg) from a tracer.

* Issue related to multiple syscall restarts are addressed in next patch

---
 arch/arc/include/asm/entry.h      |   35 ++++
 arch/arc/include/asm/sigcontext.h |   23 +++
 arch/arc/include/asm/signal.h     |   27 +++
 arch/arc/kernel/entry.S           |   11 +-
 arch/arc/kernel/signal.c          |  369 +++++++++++++++++++++++++++++++++++++
 5 files changed, 462 insertions(+), 3 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/entry.h +35 -0
index 63705b1..6b42bf5 100644
@@ -166,6 +166,41 @@
 .endm
 
 /*--------------------------------------------------------------
+ * RESTORE_CALLEE_SAVED_USER:
+ * This is called after do_signal where tracer might have changed callee regs
+ * thus we need to restore the reg file.
+ * Special case handling is required for r25 in case it is used by kernel
+ *  for caching task ptr. Ptrace would have modified on-kernel-stack value of
+ *  r25, which needs to be shoved back into task->thread.user_r25 where from
+ *  Low level exception/ISR return code will retrieve to populate with rest of
+ *  callee reg-file.
+ *-------------------------------------------------------------*/
+.macro RESTORE_CALLEE_SAVED_USER
+
+	add     sp, sp, 4   /* skip "callee_regs->stack_place_holder" */
+
+#ifdef CONFIG_ARC_CURR_IN_REG
+	ld.ab   r12, [sp, 4]
+	st      r12, [r25, TASK_THREAD + THREAD_USER_R25]
+#else
+	ld.ab   r25, [sp, 4]
+#endif
+
+	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
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/entry.S +8 -3
index d378c8e..efaf3de 100644
@@ -474,7 +474,11 @@ resume_user_mode_begin:
 
 	bbit0  r9, TIF_SIGPENDING, .Lchk_notify_resume
 
-	; save CALLEE Regs.
+	; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
+	; in pt_reg since the "C" ABI (kernel code) will automatically
+	; save/restore callee-saved regs.
+	;
+	; However, here we need to explicitly save callee regs because
 	; (i)  If this signal causes coredump - full regfile needed
 	; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
 	;      tracer might call PEEKUSR(CALLEE reg)
@@ -488,8 +492,9 @@ resume_user_mode_begin:
 
 	bl  @do_signal
 
-	; unwind SP for cheap discard of Callee saved Regs
-	DISCARD_CALLEE_SAVED_USER
+	; Ideally we want to discard the Callee reg above, however if this was
+	; a tracing signal, tracer could have done a POKEUSR(CALLEE reg)
+	RESTORE_CALLEE_SAVED_USER
 
 	b      resume_user_mode_begin	; loop back to start of U mode ret
 
arch/arc/kernel/signal.c new file +369 -0

369 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#36 lore raw

Re: [PATCH v2 19/76] ARC: Signal handling

arch/arc/kernel/signal.c line 114

Quoted 6 lines · Vineet Gupta
arch/arc/kernel/signal.c new file +6 -0
+SYSCALL_DEFINE0(rt_sigreturn)
+{
+	struct rt_sigframe __user *sf;
+	unsigned int magic;
+	int err;
+	struct pt_regs *regs = task_pt_regs(current);

ITYM current_pt_regs()...

arch/arc/kernel/signal.c line 137

Quoted 2 lines
arch/arc/kernel/signal.c new file +2 -0
+	if (unlikely(is_do_ss_needed(magic)))
+		if (do_sigaltstack(&sf->uc.uc_stack, NULL, regs->sp) == -EFAULT)
	if (!restore_altstack(&sf->uc.uc_stack))

please...

arch/arc/kernel/signal.c line 213

Quoted 4 lines
arch/arc/kernel/signal.c new file +4 -0
+		stk.ss_sp = (void __user *)current->sas_ss_sp;
+		stk.ss_flags = sas_ss_flags(regs->sp);
+		stk.ss_size = current->sas_ss_size;
+		err |= __copy_to_user(&sf->uc.uc_stack, &stk, sizeof(stk));

that would be

                err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
#37 lore raw

Re: [PATCH v2 19/76] ARC: Signal handling

Quoted 6 lines · Al Viro

ITYM current_pt_regs()...

arch/arc/kernel/signal.c line 137

Quoted 2 lines
arch/arc/kernel/signal.c new file +2 -0
+	if (unlikely(is_do_ss_needed(magic)))
+		if (do_sigaltstack(&sf->uc.uc_stack, NULL, regs->sp) == -EFAULT)
	if (!restore_altstack(&sf->uc.uc_stack))

please...

... only without the braino - if (restore_altstack(...))

#38 lore raw

Re: [PATCH v2 19/76] ARC: Signal handling

In reply to Al Viro
Quoted 8 lines · Al Viro

arch/arc/kernel/signal.c line 114

Quoted 6 lines · Vineet Gupta
arch/arc/kernel/signal.c new file +6 -0
+SYSCALL_DEFINE0(rt_sigreturn)
+{
+	struct rt_sigframe __user *sf;
+	unsigned int magic;
+	int err;
+	struct pt_regs *regs = task_pt_regs(current);

ITYM current_pt_regs()...

Done.

Quoted 4 lines

arch/arc/kernel/signal.c line 137

Quoted 3 lines
arch/arc/kernel/signal.c new file +2 -0
+	if (unlikely(is_do_ss_needed(magic)))
+		if (do_sigaltstack(&sf->uc.uc_stack, NULL, regs->sp) == -EFAULT)
	if (!restore_altstack(&sf->uc.uc_stack))
Quoted 9 lines

please...

arch/arc/kernel/signal.c line 213

Quoted 4 lines
arch/arc/kernel/signal.c new file +4 -0
+		stk.ss_sp = (void __user *)current->sas_ss_sp;
+		stk.ss_flags = sas_ss_flags(regs->sp);
+		stk.ss_size = current->sas_ss_size;
+		err |= __copy_to_user(&sf->uc.uc_stack, &stk, sizeof(stk));

that would be

                err |= __save_altstack(&frame->uc.uc_stack, regs->sp);

Actually altstack consolidation tracking changes are already present in patch 41/76 - which has other 3.8 specific bits too. This is more of a reflection of my 3.7 baseline and a subsequent migration to 3.8. But you are right, it is creating undue confusion - I'll chop-n-dice-n-squash those bits into appropriate patches.

Thx,
-Vineet

#39 lore raw

PATCH v2 20/76 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 patch only changes how orig_r8 is organised and nothing should change behaviourily.

---
 arch/arc/include/asm/entry.h  |   29 +++++++++++++++++------------
 arch/arc/include/asm/ptrace.h |   15 +++++++++++----
 arch/arc/kernel/entry.S       |    4 ++--
 3 files changed, 30 insertions(+), 18 deletions(-)
arch/arc/include/asm/entry.h +17 -12
index 6b42bf5..d72995b 100644
@@ -343,18 +343,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]
@@ -384,14 +378,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
 
 /*--------------------------------------------------------------
@@ -442,7 +447,7 @@
 	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      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 */
arch/arc/include/asm/ptrace.h +11 -4
index 9abbb7c..ddb9ce7 100644
@@ -81,7 +81,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 */
@@ -126,12 +127,18 @@ struct user_regs_struct {
 	sp;			\
 })
 
-/* 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)
 
 #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 /* __KERNEL__ */
 
 #endif /* __ASM_PTRACE_H */
arch/arc/kernel/entry.S +2 -2
index efaf3de..0324ad1 100644
@@ -354,8 +354,8 @@ ARC_EXIT EV_Extension
 
 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]
Signature · 1 line
1.7.4.1
#40 lore raw

PATCH v2 21/76 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 ddb9ce7..92ef198 100644
@@ -130,6 +130,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)
+
 #endif /* !__ASSEMBLY__ */
 
 #define orig_r8_IS_SCALL		0x0001
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
#41 lore raw

PATCH v2 22/76 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   |   28 ++
 arch/arc/include/asm/cacheflush.h |   67 ++++
 arch/arc/mm/cache_arc700.c        |  725 +++++++++++++++++++++++++++++++++++++
 5 files changed, 954 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 +28 -0
new file mode 100644
index 0000000..51c73f0
@@ -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 __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_FLUSH_INV	0x0020
+
+#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 +725 -0

725 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#42 lore raw

PATCH v2 23/76 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
#43 lore raw

PATCH v2 24/76 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
#44 lore raw

PATCH v2 25/76 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  |   91 ++++++++++
 arch/arc/include/asm/tlb-mmu1.h |  104 ++++++++++++
 arch/arc/include/asm/tlb.h      |   41 +++++
 arch/arc/mm/tlb.c               |  267 +++++++++++++++++++++++++++++
 arch/arc/mm/tlbex.S             |  351 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 854 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 +91 -0
index c12eb9b..1c24485 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,35 @@
 #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_INSN_ERR			0x02
+#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 +88,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 +273,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 +304,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 +267 -0

270 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
#45 lore raw

PATCH v2 26/76 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
#46 lore raw

PATCH v2 27/76 ARC: Page Fault handling

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/fault.c |  228 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/mm/fault.c
arch/arc/mm/fault.c new file +228 -0
new file mode 100644
index 0000000..af55aab
@@ -0,0 +1,228 @@
+/* Page Fault Handling for ARC (TLB Miss / ProtV)
+ *
+ * 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/signal.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/ptrace.h>
+#include <linux/version.h>
+#include <linux/uaccess.h>
+#include <linux/kdebug.h>
+#include <asm/pgalloc.h>
+
+static int handle_vmalloc_fault(struct mm_struct *mm, unsigned long address)
+{
+	/*
+	 * Synchronize this task's top level page-table
+	 * with the 'reference' page table.
+	 */
+	pgd_t *pgd, *pgd_k;
+	pud_t *pud, *pud_k;
+	pmd_t *pmd, *pmd_k;
+
+	pgd = pgd_offset_fast(mm, address);
+	pgd_k = pgd_offset_k(address);
+
+	if (!pgd_present(*pgd_k))
+		goto bad_area;
+
+	pud = pud_offset(pgd, address);
+	pud_k = pud_offset(pgd_k, address);
+	if (!pud_present(*pud_k))
+		goto bad_area;
+
+	pmd = pmd_offset(pud, address);
+	pmd_k = pmd_offset(pud_k, address);
+	if (!pmd_present(*pmd_k))
+		goto bad_area;
+
+	set_pmd(pmd, *pmd_k);
+
+	/* XXX: create the TLB entry here */
+	return 0;
+
+bad_area:
+	return 1;
+}
+
+void do_page_fault(struct pt_regs *regs, int write, unsigned long address,
+		   unsigned long cause_code)
+{
+	struct vm_area_struct *vma = NULL;
+	struct task_struct *tsk = current;
+	struct mm_struct *mm = tsk->mm;
+	siginfo_t info;
+	int fault, ret;
+	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
+				(write ? FAULT_FLAG_WRITE : 0);
+
+	/*
+	 * We fault-in kernel-space virtual memory on-demand. The
+	 * 'reference' page table is init_mm.pgd.
+	 *
+	 * NOTE! We MUST NOT take any locks for this case. We may
+	 * be in an interrupt or a critical region, and should
+	 * only copy the information from the master page table,
+	 * nothing more.
+	 */
+	if (address >= VMALLOC_START && address <= VMALLOC_END) {
+		ret = handle_vmalloc_fault(mm, address);
+		if (unlikely(ret))
+			goto bad_area_nosemaphore;
+		else
+			return;
+	}
+
+	info.si_code = SEGV_MAPERR;
+
+	/*
+	 * If we're in an interrupt or have no user
+	 * context, we must not take the fault..
+	 */
+	if (in_atomic() || !mm)
+		goto no_context;
+
+retry:
+	down_read(&mm->mmap_sem);
+	vma = find_vma(mm, address);
+	if (!vma)
+		goto bad_area;
+	if (vma->vm_start <= address)
+		goto good_area;
+	if (!(vma->vm_flags & VM_GROWSDOWN))
+		goto bad_area;
+	if (expand_stack(vma, address))
+		goto bad_area;
+
+	/*
+	 * Ok, we have a good vm_area for this memory access, so
+	 * we can handle it..
+	 */
+good_area:
+	info.si_code = SEGV_ACCERR;
+
+	/* Handle protection violation, execute on heap or stack */
+
+	if (cause_code == ((ECR_V_PROTV << 16) | ECR_C_PROTV_INST_FETCH))
+		goto bad_area;
+
+	if (write) {
+		if (!(vma->vm_flags & VM_WRITE))
+			goto bad_area;
+	} else {
+		if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
+			goto bad_area;
+	}
+
+survive:
+	/*
+	 * If for any reason at all we couldn't handle the fault,
+	 * make sure we exit gracefully rather than endlessly redo
+	 * the fault.
+	 */
+	fault = handle_mm_fault(mm, vma, address, flags);
+
+	/* If Pagefault was interrupted by SIGKILL, exit page fault "early" */
+	if (unlikely(fatal_signal_pending(current))) {
+		if ((fault & VM_FAULT_ERROR) && !(fault & VM_FAULT_RETRY))
+			up_read(&mm->mmap_sem);
+		if (user_mode(regs))
+			return;
+	}
+
+	if (likely(!(fault & VM_FAULT_ERROR))) {
+		if (flags & FAULT_FLAG_ALLOW_RETRY) {
+			/* To avoid updating stats twice for retry case */
+			if (fault & VM_FAULT_MAJOR)
+				tsk->maj_flt++;
+			else
+				tsk->min_flt++;
+
+			if (fault & VM_FAULT_RETRY) {
+				flags &= ~FAULT_FLAG_ALLOW_RETRY;
+				flags |= FAULT_FLAG_TRIED;
+				goto retry;
+			}
+		}
+
+		/* Fault Handled Gracefully */
+		up_read(&mm->mmap_sem);
+		return;
+	}
+
+	/* TBD: switch to pagefault_out_of_memory() */
+	if (fault & VM_FAULT_OOM)
+		goto out_of_memory;
+	else if (fault & VM_FAULT_SIGBUS)
+		goto do_sigbus;
+
+	/* no man's land */
+	BUG();
+
+	/*
+	 * Something tried to access memory that isn't in our memory map..
+	 * Fix it, but check if it's kernel or user first..
+	 */
+bad_area:
+	up_read(&mm->mmap_sem);
+
+bad_area_nosemaphore:
+	/* User mode accesses just cause a SIGSEGV */
+	if (user_mode(regs)) {
+		tsk->thread.fault_address = address;
+		tsk->thread.cause_code = cause_code;
+		info.si_signo = SIGSEGV;
+		info.si_errno = 0;
+		/* info.si_code has been set above */
+		info.si_addr = (void __user *)address;
+		force_sig_info(SIGSEGV, &info, tsk);
+		return;
+	}
+
+no_context:
+	/* Are we prepared to handle this kernel fault?
+	 *
+	 * (The kernel has valid exception-points in the source
+	 *  when it acesses user-memory. When it fails in one
+	 *  of those points, we find it in a table and do a jump
+	 *  to some fixup code that loads an appropriate error
+	 *  code)
+	 */
+	if (fixup_exception(regs))
+		return;
+
+	die("Oops", regs, address, cause_code);
+
+out_of_memory:
+	if (is_global_init(tsk)) {
+		yield();
+		goto survive;
+	}
+	up_read(&mm->mmap_sem);
+
+	if (user_mode(regs))
+		do_group_exit(SIGKILL);	/* This will never return */
+
+	goto no_context;
+
+do_sigbus:
+	up_read(&mm->mmap_sem);
+
+	if (!user_mode(regs))
+		goto no_context;
+
+	tsk->thread.fault_address = address;
+	tsk->thread.cause_code = cause_code;
+	info.si_signo = SIGBUS;
+	info.si_errno = 0;
+	info.si_code = BUS_ADRERR;
+	info.si_addr = (void __user *)address;
+	force_sig_info(SIGBUS, &info, tsk);
+}
Signature · 1 line
1.7.4.1
#47 lore raw

PATCH v2 28/76 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
maintainer
#48 lore raw

Re: [PATCH v2 28/76] ARC: I/O and DMA Mappings

Quoted 3 lines · Vineet Gupta

TBD: Do we need early ioremap support like openrisc

Can you explain why early ioremap is necessary for you?

I wasn't aware that openrisc has it. In a lot of cases, you can use fixmap as a replacement.

Quoted 7 lines
arch/arc/include/asm/io.h new file +7 -0
+
+#ifndef _ASM_ARC_IO_H
+#define _ASM_ARC_IO_H
+
+#include <asm/byteorder.h>
+#include <asm/page.h>
+

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

Quoted 10 lines
arch/arc/include/asm/io.h new file +10 -0
+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>

I think I commented before that asm-generic/io.h has a number of problems and you should at least override the __raw_{read,write}{b,w,l,q} functions with your own ones using inline assembly.

You should also define a non-NULL PCI_IOBASE.

Arnd

#49 lore raw

Re: [PATCH v2 28/76] ARC: I/O and DMA Mappings

Quoted 10 lines · Arnd Bergmann
Quoted 3 lines · Vineet Gupta

TBD: Do we need early ioremap support like openrisc

Can you explain why early ioremap is necessary for you?

I wasn't aware that openrisc has it. In a lot of cases, you can use fixmap as a replacement.

The two don't need to be mutually exclusive, either. sh implements early ioremap transparently via fixmaps for example:

arch/sh/mm/ioremap.c
arch/sh/mm/ioremap_fixed.c

maintainer
#50 lore raw

Re: [PATCH v2 28/76] ARC: I/O and DMA Mappings

Quoted 8 lines · Paul Mundt
Quoted 7 lines · Arnd Bergmann
Quoted 3 lines · Vineet Gupta

TBD: Do we need early ioremap support like openrisc

Can you explain why early ioremap is necessary for you?

Quoted 8 lines
Quoted 3 lines

I wasn't aware that openrisc has it. In a lot of cases, you can use fixmap as a replacement.

The two don't need to be mutually exclusive, either. sh implements early ioremap transparently via fixmaps for example:

arch/sh/mm/ioremap.c
arch/sh/mm/ioremap_fixed.c

Ah, right. It also seems that openrisc uses the same approach for its early ioremap.

I usually recommend doing as few things as possible "early" though, that's why I was asking. If it's only one or two drivers that need an early mapping and can't be moved to a later stage of bootup, using only hardcoded fixmaps would make it harder to add more users, which one might consider a good thing.

Allowing ioremap to be used before memory_init() adds flexibility but could lead to code being moved into an early stage by accident rather than by necessity.

Arnd

#51 lore raw

Re: [PATCH v2 28/76] ARC: I/O and DMA Mappings

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

TBD: Do we need early ioremap support like openrisc

Can you explain why early ioremap is necessary for you?

I wasn't aware that openrisc has it. In a lot of cases, you can use fixmap as a replacement.

This came about when enabling the early console of arc uart using the early param registration. I prefer console to be up as early as possible because the high configurability of ARC means you get early panics if hardware and software don't match (cache geom, mmu ver, ....) and it's good if we could print it out via uart.

So we do end up calling ioremap very early

setup_arch
machine_desc->init_early
plat_fpga_early_init
arc_fpga_serial_init
early_platform_add_devices
early_platform_driver_probe
arc_serial_probe_earlyprintk
ioremap_nocache()

However, ioremap on ARC typically avoids MMU mappings (hence need for paging_init etc to have run apriori) because memory mapped peripherals are typically wired up in ARC's dedicated uncached address space. So unless the driver needs special access permissions (in addition to uncached semantics), we can simply short-circuit all of MMU routing.

So the comment above can be deleted, and we probably need a check in ioremap_prot() so that early ioremap bails out if called early - probably using slab_is_available()

Quoted 22 lines
Quoted 8 lines
arch/arc/include/asm/io.h new file +7 -0
+
+#ifndef _ASM_ARC_IO_H
+#define _ASM_ARC_IO_H
+
+#include <asm/byteorder.h>
+#include <asm/page.h>
+

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

Quoted 10 lines
arch/arc/include/asm/io.h new file +10 -0
+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>

I think I commented before that asm-generic/io.h has a number of problems and you should at least override the __raw_{read,write}{b,w,l,q} functions with your own ones using inline assembly.

Quoted 1 line

You should also define a non-NULL PCI_IOBASE.

Sorry for missing out on this one - this was indeed suggested in the private pre-list review you did. The 64-bit version certainly needs to be wrapped in a irq safe block.

However others will be exactly same as generic ones. Given that these routines operate on __iomem memory which has to be uncached: either wired in uncached address space, or goes via an uncached MMU mapping, IMHO the inline-asm or 'C' version won't add any value. We do have uncached LD/ST, I've tried to avoid them so far as they have certain micro-architectural quirks and per previous argument it seems they would be redundant.

Having said that I might be over-looking something important - so please let me know.

-Vineet

maintainer
#52 lore raw

Re: [PATCH v2 28/76] ARC: I/O and DMA Mappings

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

...

So the comment above can be deleted, and we probably need a check in ioremap_prot() so that early ioremap bails out if called early - probably using slab_is_available()

Ok.

Quoted 11 lines
Quoted 6 lines
Quoted 1 line

+#include <asm-generic/io.h>

I think I commented before that asm-generic/io.h has a number of problems and you should at least override the __raw_{read,write}{b,w,l,q} functions with your own ones using inline assembly.

You should also define a non-NULL PCI_IOBASE.

Sorry for missing out on this one - this was indeed suggested in the private pre-list review you did. The 64-bit version certainly needs to be wrapped in a irq safe block.

Quoted 8 lines

However others will be exactly same as generic ones. Given that these routines operate on __iomem memory which has to be uncached: either wired in uncached address space, or goes via an uncached MMU mapping, IMHO the inline-asm or 'C' version won't add any value. We do have uncached LD/ST, I've tried to avoid them so far as they have certain micro-architectural quirks and per previous argument it seems they would be redundant.

Having said that I might be over-looking something important - so please let me know.

We just moved ARM to use inline assembly versions here, because there were bugs with some gcc versions and undefined C code in the kernel using 'packed' pointers, as well as problems in KVM interpreting the memory accessor instructions. I would definetely recommend doing inline assembly for these on all architectures to spare you trouble later.

Arnd

#53 lore raw

PATCH v2 29/76 ARC: Boot #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               |  183 ++++++++++++++++++++++++++++++++++++++
 arch/arc/plat-arcfpga/platform.c |   29 ++++++
 7 files changed, 516 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 1c24485..9e42611 100644
@@ -258,6 +258,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 +183 -0

183 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
maintainer
#54 lore raw

Re: [PATCH v2 29/76] ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init

Quoted 8 lines · Vineet Gupta
arch/arc/mm/init.c new file +8 -0
+       /* setup bootmem allocator */
+       bootmap_sz = init_bootmem_node(NODE_DATA(0),
+                                      first_free_pfn,/* bitmap start */
+                                      min_low_pfn,   /* First pg to track */
+                                      max_low_pfn);  /* Last pg to track */
+
+       /*
+        * init_bootmem above marks all tracked Page-frames as inuse "allocated"

arch/arc/mm/init.c line 95

Quoted 10 lines
arch/arc/mm/init.c new file +10 -0
+        * This includes pages occupied by kernel's elf segments.
+        * Beyond that, excluding bootmem bitmap itself, mark the rest of
+        * free-mem as "allocatable"
+        */
+       alloc_start = kernel_img_end + bootmap_sz;
+       free_bootmem(alloc_start, end_mem - alloc_start);
+
+       memset(zones_size, 0, sizeof(zones_size));
+       zones_size[ZONE_NORMAL] = num_physpages;
+

IIRC, the bootmem allocator is no longer recommended for new architecture. You should use the "memblock" interface instead, as arm64 and tile do.

I just saw that this is still listed as TODO for openrisc, sorry if I put you on the wrong track there by recommending to copy from openrisc.

Arnd

#55 lore raw

Re: [PATCH v2 29/76] ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init

Quoted 22 lines · Arnd Bergmann
Quoted 8 lines · Vineet Gupta
(quoted diff) +8 -0
+       /* setup bootmem allocator */
+       bootmap_sz = init_bootmem_node(NODE_DATA(0),
+                                      first_free_pfn,/* bitmap start */
+                                      min_low_pfn,   /* First pg to track */
+                                      max_low_pfn);  /* Last pg to track */
+
+       /*
+        * init_bootmem above marks all tracked Page-frames as inuse "allocated"

Review

Quoted 10 lines
(quoted diff) +10 -0
+        * This includes pages occupied by kernel's elf segments.
+        * Beyond that, excluding bootmem bitmap itself, mark the rest of
+        * free-mem as "allocatable"
+        */
+       alloc_start = kernel_img_end + bootmap_sz;
+       free_bootmem(alloc_start, end_mem - alloc_start);
+
+       memset(zones_size, 0, sizeof(zones_size));
+       zones_size[ZONE_NORMAL] = num_physpages;
+

IIRC, the bootmem allocator is no longer recommended for new architecture. You should use the "memblock" interface instead, as arm64 and tile do.

Quoted 4 lines

I just saw that this is still listed as TODO for openrisc, sorry if I put you on the wrong track there by recommending to copy from openrisc.

Arnd

How does the following look like. This is RFC only and I'll squash it into Boot #1 patch.

From: Vineet Gupta <[email protected]>
Date: Tue, 22 Jan 2013 13:03:50 +0530
Subject: [PATCH] RFC: Convert ARC port from bootmem to memblock

---
 arch/arc/Kconfig          |    2 ++
 arch/arc/kernel/devtree.c |    4 ++--
 arch/arc/mm/init.c        |   35 +++++++++--------------------------
 3 files changed, 13 insertions(+), 28 deletions(-)
arch/arc/Kconfig +2 -0
index e8947c7..76ead56 100644
@@ -29,11 +29,13 @@ config ARC
     select HAVE_IRQ_WORK
     select HAVE_KPROBES
     select HAVE_KRETPROBES
+    select HAVE_MEMBLOCK
     select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND
     select HAVE_OPROFILE
     select HAVE_PERF_EVENTS
     select IRQ_DOMAIN
     select MODULES_USE_ELF_RELA
+    select NO_BOOTMEM
     select OF
     select OF_EARLY_FLATTREE
     select PERF_USE_VMALLOC
arch/arc/kernel/devtree.c +2 -2
index 626fba14..051ec8b 100644
@@ -14,7 +14,7 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/reboot.h>
-#include <linux/bootmem.h>
+#include <linux/memblock.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
 #include <linux/of_irq.h>
@@ -26,7 +26,7 @@
 /* called from unflatten_device_tree() to bootstrap devicetree itself */
 void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
 {
-    return alloc_bootmem_align(size, align);
+    return __va(memblock_alloc(size, align));
 }
 
 /**
arch/arc/mm/init.c +9 -26
index 8c173f9..80dbdc7 100644
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
+#include <linux/memblock.h>
 #ifdef CONFIG_BLOCK_DEV_RAM
 #include <linux/blk.h>
 #endif
@@ -42,6 +43,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 {
     arc_mem_sz = size & PAGE_MASK;
     pr_info("Memory size set via devicetree %ldM\n", TO_MB(arc_mem_sz));
+    memblock_add(CONFIG_LINUX_LINK_BASE, arc_mem_sz);
 }
 
 /*
@@ -52,9 +54,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
  */
 void __init setup_arch_memory(void)
 {
-    int bootmap_sz;
-    unsigned int first_free_pfn;
-    unsigned long kernel_img_end, alloc_start;
     unsigned long zones_size[MAX_NR_ZONES] = { 0, 0 };
     unsigned long end_mem = CONFIG_LINUX_LINK_BASE + arc_mem_sz;
 
@@ -63,39 +62,23 @@ void __init setup_arch_memory(void)
     init_mm.end_data = (unsigned long)_edata;
     init_mm.brk = (unsigned long)_end;
 
-    /* _end needs to be page aligned */
-    kernel_img_end = (unsigned long)_end;
-    BUG_ON(kernel_img_end & ~PAGE_MASK);
+    /*------------- externs in mm need setting up ---------------*/
 
     /* first page of system - kernel .vector starts here */
     min_low_pfn = PFN_DOWN(CONFIG_LINUX_LINK_BASE);
 
-    /* First free page beyond kernel image */
-    first_free_pfn = PFN_DOWN(kernel_img_end);
-
-    /*
-     * Last usable page of low mem (no HIGHMEM yet for ARC port)
-     * -must be BASE + SIZE
-     */
+    /* Last usable page of low mem (no HIGHMEM yet for ARC port) */
     max_low_pfn = max_pfn = PFN_DOWN(end_mem);
 
     max_mapnr = num_physpages = max_low_pfn - min_low_pfn;
 
-    /* setup bootmem allocator */
-    bootmap_sz = init_bootmem_node(NODE_DATA(0),
-                       first_free_pfn,/* bitmap start */
-                       min_low_pfn,   /* First pg to track */
-                       max_low_pfn);  /* Last pg to track */
+    /*------------- reserve kernel image -----------------------*/
+    memblock_reserve(CONFIG_LINUX_LINK_BASE,
+             __pa(_end) - CONFIG_LINUX_LINK_BASE);
 
-    /*
-     * init_bootmem above marks all tracked Page-frames as inuse "allocated"
-     * This includes pages occupied by kernel's elf segments.
-     * Beyond that, excluding bootmem bitmap itself, mark the rest of
-     * free-mem as "allocatable"
-     */
-    alloc_start = kernel_img_end + bootmap_sz;
-    free_bootmem(alloc_start, end_mem - alloc_start);
+    memblock_dump_all();
 
+    /*-------------- node setup --------------------------------*/
     memset(zones_size, 0, sizeof(zones_size));
     zones_size[ZONE_NORMAL] = num_physpages;
 
Signature · 1 line
1.7.4.1
maintainer Acked-by
#56 lore raw

Re: [PATCH v2 29/76] ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init

Quoted 9 lines · Vineet Gupta

How does the following look like. This is RFC only and I'll squash it into Boot #1 patch.

From: Vineet Gupta <[email protected]>
Date: Tue, 22 Jan 2013 13:03:50 +0530
Subject: [PATCH] RFC: Convert ARC port from bootmem to memblock

---

Looks good to me, although I might be missing some details.

Given that everything still seems to work for you,

on the combined patch.

#57 lore raw

Re: [PATCH v2 29/76] ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init

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

How does the following look like. This is RFC only and I'll squash it into Boot #1 patch.

From: Vineet Gupta <[email protected]>
Date: Tue, 22 Jan 2013 13:03:50 +0530
Subject: [PATCH] RFC: Convert ARC port from bootmem to memblock

---

Quoted 8 lines

Looks good to me, although I might be missing some details.

Given that everything still seems to work for you,

on the combined patch.

I haven't done heavy testing on this (just basic boot) and no_bootmem/memblock is not a well-known turf form me yet. But should be sufficient for now ;-)

Thx,
-Vineet

#58 lore raw

PATCH v2 30/76 ARC: [plat-arcfpga] Static platform device for CONFIG_SERIAL_ARC

In reply to Vineet Gupta

N.B. This is old style of hardcoding platform device specific info in code and it's instantiation thererof using platform_add_devices(). Subsequent patches replace this with DeviceTree based runtime probe.

This patch has been retained just as an example of "don't-do-this" for newer kernel ports.

---
 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            |  108 +++++++++++++++++++++++++++
 4 files changed, 167 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 514b302..c91b2e4 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 +108 -0

127 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#59 lore raw

PATCH v2 31/76 ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Vineet Gupta

Arnd in his review pointed out that arch Kconfig organisation has several deficiencies:

* Build time entries for things which can be runtime extracted from DT (e.g. SDRAM size, core clk frequency..)
* Not multi-platform-image-build friendly (choice .. endchoice constructs)
* cpu variants support (750/770) is exclusive.

The first 2 have been fixed in subsequent patches.
Due to the nature of the 750 and 770, it is not possible to build for both together, w/o special runtime glue code which would hurt performance.

---
 arch/arc/Kbuild                    |    2 +
 arch/arc/Kconfig                   |  330 ++++++++++++++++++++++++++++++++++++
 arch/arc/Kconfig.debug             |   34 ++++
 arch/arc/Makefile                  |  115 +++++++++++++
 arch/arc/boot/Makefile             |   26 +++
 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, 816 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 +330 -0

330 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 +26 -0
new file mode 100644
index 0000000..7d514c2
@@ -0,0 +1,26 @@
+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.*)
+
+UIMAGE_LOADADDR    = $(CONFIG_LINUX_LINK_BASE)
+UIMAGE_ENTRYADDR   = $(LINUX_START_TEXT)
+UIMAGE_COMPRESSION = gzip
+
+$(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..ae140e5
@@ -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 clk.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..9e2c1ca
@@ -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 \
+	   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
#60 lore raw

Re: [PATCH v2 31/76] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+#
+
+config ARC
+	def_bool y
+	select ARCH_NO_VIRT_TO_BUS
+	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
+	# DEVTMPS in turn needs HOTPLUG

arch/arc/Kconfig line 23

Quoted 10 lines
arch/arc/Kconfig new file +10 -0
+	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
+	select GENERIC_IRQ_SHOW
+	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_GENERIC_HARDIRQS
+	select HOTPLUG if !INITRAMFS_SOURCE=""

HOTPLUG is alwyas y now.

arch/arc/Makefile line 115

Quoted 9 lines
arch/arc/Makefile new file +9 -0
+# Hacks to enable final link due to absence of link-time branch relexation
+# and gcc choosing optimal(shorter) branches at -O3
+#
+# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
+# However lib/decompress_inflate.o (.init.text) calls
+# zlib_inflate_workspacesize (.text) causing relocation errors.
+# Thus forcing all exten calls in this file to be long calls
+export CFLAGS_decompress_inflate.o = -mmedium-calls
+export CFLAGS_initramfs.o = -mmedium-calls

This is gross..
But I see no better way to do this for now.

arch/arc/kernel/Makefile line 9

Quoted 11 lines

+++ b/arch/arc/kernel/Makefile

arch/arc/kernel/Makefile new file +9 -0
@@ -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 clk.o

For new stuff I usually recommend to drop line continuation using \

Just do the much prettier:
obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o clk.o

arch/arc/lib/Makefile line 9

Quoted 11 lines
arch/arc/lib/Makefile new file +10 -0
+++ b/arch/arc/lib/Makefile
@@ -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

Avoid '\'

Quoted 6 lines
arch/arc/mm/Makefile new file +0 -0
new file mode 100644
index 0000000..9e2c1ca

arch/arc/mm/Makefile line 10

Quoted 10 lines
arch/arc/mm/Makefile new file +10 -0
@@ -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 \
+	   tlb.o tlbex.o cache_arc700.o

Avoid '\'

Other these small nits I did not notice anything.
General impression is that this looks good!

Sam

maintainer
#61 lore raw

Re: [PATCH v2 31/76] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 8 lines · Sam Ravnborg

arch/arc/kernel/Makefile line 9

Quoted 2 lines
arch/arc/kernel/Makefile new file +2 -0
+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 clk.o

For new stuff I usually recommend to drop line continuation using \

Just do the much prettier:
obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o clk.o

Agreed, although we are moving some files to the more verbose

obj-y += arcksyms.o
obj-y += clk.o
obj-y += entry.o
obj-y += ...

and use alphabetical order, both of which help avoid merge conflicts when Makefile changes come in through separate branches. This particular Makefile is likely to remain rather stable though, so it's not necessary to go this far.

Arnd

#62 lore raw

Re: [PATCH v2 31/76] ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Sam Ravnborg
Quoted 10 lines · Sam Ravnborg
Quoted 10 lines
arch/arc/Kconfig new file +10 -0
+#
+
+config ARC
+	def_bool y
+	select ARCH_NO_VIRT_TO_BUS
+	# 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
Quoted 8 lines

arch/arc/Kconfig line 23

Quoted 7 lines
arch/arc/Kconfig new file +7 -0
+	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=""

HOTPLUG is alwyas y now.

Done !

Quoted 11 lines

arch/arc/Makefile line 115

Quoted 9 lines
arch/arc/Makefile new file +9 -0
+# Hacks to enable final link due to absence of link-time branch relexation
+# and gcc choosing optimal(shorter) branches at -O3
+#
+# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
+# However lib/decompress_inflate.o (.init.text) calls
+# zlib_inflate_workspacesize (.text) causing relocation errors.
+# Thus forcing all exten calls in this file to be long calls
+export CFLAGS_decompress_inflate.o = -mmedium-calls
+export CFLAGS_initramfs.o = -mmedium-calls

This is gross..
But I see no better way to do this for now.

Precisely - there's no better way as of now. Our GNU tools team is aware of this and likely to provide us the much needed fix in future. Link time branch relaxation is particularly complicated for ARCompact ISA given that we can have insns which are 2,4,6,8 bytes long in same compilation unit. Internally I have a hack - a build script which extracts the offending file from build errors, appends the corresponding line to makefile and rebuilds - this is done recursively until all relo errors are gone.

Quoted 23 lines

arch/arc/kernel/Makefile line 9

Quoted 4 lines
arch/arc/kernel/Makefile new file +3 -0
+
+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 clk.o

For new stuff I usually recommend to drop line continuation using \

Just do the much prettier:
obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o clk.o

arch/arc/lib/Makefile line 9

Quoted 5 lines

....

arch/arc/lib/Makefile new file +4 -0
+# 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

Avoid '\'

arch/arc/mm/Makefile line 10

Quoted 4 lines

....

arch/arc/mm/Makefile new file +3 -0
+
+obj-y	:= extable.o ioremap.o dma.o fault.o init.o \
+	   tlb.o tlbex.o cache_arc700.o

Avoid '\'

Quoted 4 lines

Other these small nits I did not notice anything.
General impression is that this looks good!

Sam

All line continuations fixed.

Thx for the review,
-Vineet

#63 lore raw

Re: [PATCH v2 31/76] ARC: Build system: Makefiles, Kconfig, Linker script

In reply to Vineet Gupta
Quoted 2 lines
 arch/arc/include/asm/vmlinux.lds.h |   12 ++

I see no reason for this file?

Quoted 5 lines
arch/arc/include/asm/vmlinux.lds.h new file +2 -0
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)

arch/arc/include/asm/vmlinux.lds.h line 12

Quoted 10 lines
arch/arc/include/asm/vmlinux.lds.h new file +10 -0
+ *
+ * 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

It is empty.
Only sh provide one today (which is not empty).

Sam

#64 lore raw

Re: [PATCH v2 31/76] ARC: Build system: Makefiles, Kconfig, Linker script

Quoted 11 lines · Sam Ravnborg
Quoted 1 line
 arch/arc/include/asm/vmlinux.lds.h |   12 ++

I see no reason for this file?

arch/arc/include/asm/vmlinux.lds.h line 12

Quoted 5 lines

.....

arch/arc/include/asm/vmlinux.lds.h new file +4 -0
+#ifndef __ASM_VMLINUX_LDS_H__
+#define __ASM_VMLINUX_LDS_H__
+
+#endif

It is empty.
Only sh provide one today (which is not empty).

Quoted 1 line

Sam

There used to be some code in this file (some section annotations needed in linker script), but that was moved out to linkage.h. Anyhow, as you rightly observe, we don't need this anymore - hence nuked.

Thx,
-Vineet

#65 lore raw

PATCH v2 32/76 ARC: [DeviceTree] Basic support

In reply to Vineet Gupta

This is minimal infrastructure needed for devicetree work. It uses an a sample "skeleton" devicetree - embedded in kernel image - to print the board, manufacturer by parsing the top-level "compatible" string.

As of now we don't need any additional "board" specific "machine_desc".

TODO: support interpreting the command line as boot-loader passed dtb

Cc Arnd Bergmann <[email protected]>
Cc Grant Likely <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arc/Kconfig                |    9 +++++
 arch/arc/Makefile               |    9 +++++
 arch/arc/boot/dtb/Makefile      |   22 ++++++++++++
 arch/arc/boot/dts/skeleton.dts  |   10 ++++++
 arch/arc/boot/dts/skeleton.dtsi |   21 ++++++++++++
 arch/arc/include/asm/prom.h     |   15 ++++++++
 arch/arc/include/asm/sections.h |    1 +
 arch/arc/kernel/Makefile        |    2 +
 arch/arc/kernel/devtree.c       |   69 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/setup.c         |    9 +++++
 arch/arc/mm/init.c              |   13 +++++++
 11 files changed, 180 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/boot/dtb/Makefile
 create mode 100644 arch/arc/boot/dts/skeleton.dts
 create mode 100644 arch/arc/boot/dts/skeleton.dtsi
 create mode 100644 arch/arc/include/asm/prom.h
 create mode 100644 arch/arc/kernel/devtree.c
arch/arc/Kconfig +9 -0
index d457a83..5175cf7 100644
@@ -21,7 +21,10 @@ config ARC
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_GENERIC_HARDIRQS
 	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select IRQ_DOMAIN
 	select MODULES_USE_ELF_RELA
+	select OF
+	select OF_EARLY_FLATTREE
 
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
@@ -316,6 +319,12 @@ config CMDLINE_UBOOT
 	  to it. kernel startup code will copy the string into cmdline buffer
 	  and also append CONFIG_CMDLINE.
 
+config ARC_BUILTIN_DTB_NAME
+	string "Built in DTB"
+	help
+	  Set the name of the DTB to embed in the vmlinux binary
+	  Leaving it blank selects the minimal "skeleton" dtb
+
 source "kernel/Kconfig.preempt"
 
 endmenu	 # "ARC Architecture Configuration"
arch/arc/Makefile +9 -0
index 4d52a3b..d697e9c 100644
@@ -83,6 +83,9 @@ head-y		:= arch/arc/kernel/head.o
 # See arch/arc/Kbuild for content of core part of the kernel
 core-y		+= arch/arc/
 
+# w/o this dtb won't embed into kernel binary
+core-y		+= arch/arc/boot/dtb/
+
 # w/o this ifneq, make ARCH=arc clean was crapping out
 ifneq ($(platform-y),)
 core-y		+= arch/arc/plat-$(PLATFORM)/
@@ -101,6 +104,12 @@ bootpImage: vmlinux
 uImage: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
+%.dtb %.dtb.S %.dtb.o:
+	$(Q)$(MAKE) $(build)=$(boot)/dtb $(boot)/dtb/$@
+
+dtbs:
+	$(Q)$(MAKE) $(build)=$(boot)/dtb $(boot)/dtb/$@
+
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 
arch/arc/boot/dtb/Makefile new file +22 -0
new file mode 100644
index 0000000..825af84
@@ -0,0 +1,22 @@
+ifeq ($(CONFIG_OF),y)
+
+dtb-y	+= skeleton.dtb
+
+# Built-in dtb
+builtindtb-y				:= skeleton
+
+ifneq ($(CONFIG_ARC_BUILTIN_DTB_NAME),"")
+	builtindtb-y			:= $(CONFIG_ARC_BUILTIN_DTB_NAME)
+endif
+
+obj-y	+= $(patsubst "%",%,$(builtindtb-y)).dtb.o
+
+clean-files += $(obj)/$(dtb-y) $(obj)/*.dtb.S $(obj)/*.dtb.o
+
+# Rule to build device tree blobs
+$(obj)/%.dtb: $(src)/../dts/%.dts FORCE
+	$(call if_changed_dep,dtc)
+
+$(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y))
+
+endif
arch/arc/boot/dts/skeleton.dts new file +10 -0
new file mode 100644
index 0000000..25a84fb
@@ -0,0 +1,10 @@
+/*
+ * 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.
+ */
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
arch/arc/boot/dts/skeleton.dtsi new file +21 -0
new file mode 100644
index 0000000..f6a457a
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
+ * add a compatible value.
+ */
+
+/ {
+	compatible = "snps,arc-angel4", "snps,arc-ml509";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	chosen { };
+	aliases { };
+	memory { device_type = "memory"; reg = <0 0>; };
+};
arch/arc/include/asm/prom.h new file +15 -0
new file mode 100644
index 0000000..f54489b
@@ -0,0 +1,15 @@
+/*
+ * 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.
+ */
+
+#ifndef _ASM_ARC_PROM_H_
+#define _ASM_ARC_PROM_H_
+
+#define HAVE_ARCH_DEVTREE_FIXUPS
+extern int __init setup_machine_fdt(void *dt);
+
+#endif
arch/arc/include/asm/sections.h +1 -0
index fc15f2e..6fc1159 100644
@@ -13,5 +13,6 @@
 
 extern char _int_vec_base_lds[];
 extern char __arc_dccm_base[];
+extern char __dtb_start[];
 
 #endif
arch/arc/kernel/Makefile +2 -0
index ae140e5..5fefb7d 100644
@@ -8,6 +8,8 @@
 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 clk.o
 
+obj-$(CONFIG_OF)			+= devtree.o
+
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
 
arch/arc/kernel/devtree.c new file +69 -0

69 lines not on this page · raw message

arch/arc/kernel/setup.c +9 -0
index 82ac206..27aebd6 100644
@@ -13,6 +13,8 @@
 #include <linux/console.h>
 #include <linux/module.h>
 #include <linux/cpu.h>
+#include <linux/of_fdt.h>
+#include <asm/sections.h>
 #include <asm/arcregs.h>
 #include <asm/tlb.h>
 #include <asm/cache.h>
@@ -20,6 +22,7 @@
 #include <asm/page.h>
 #include <asm/irq.h>
 #include <asm/arcregs.h>
+#include <asm/prom.h>
 
 #define FIX_PTR(x)  __asm__ __volatile__(";" : "+r"(x))
 
@@ -57,6 +60,8 @@ void __init __attribute__((weak)) arc_platform_early_init(void)
 
 void __init setup_arch(char **cmdline_p)
 {
+	int rc;
+
 #ifdef CONFIG_CMDLINE_UBOOT
 	/* Make sure that a whitespace is inserted before */
 	strlcat(command_line, " ", sizeof(command_line));
@@ -71,6 +76,8 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
+	rc = setup_machine_fdt(__dtb_start);
+
 	/* To force early parsing of things like mem=xxx */
 	parse_early_param();
 
@@ -81,6 +88,8 @@ void __init setup_arch(char **cmdline_p)
 
 	setup_arch_memory();
 
+	unflatten_device_tree();
+
 	/* Can be issue if someone passes cmd line arg "ro"
 	 * But that is unlikely so keeping it as it is
 	 */
arch/arc/mm/init.c +13 -0
index 9897847..1087a97 100644
@@ -38,6 +38,11 @@ static int __init setup_mem_sz(char *str)
 }
 early_param("mem", setup_mem_sz);
 
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+	pr_err("%s(%llx, %llx)\n", __func__, base, size);
+}
+
 /*
  * First memory setup routine called from setup_arch()
  * 1. setup swapper's mm @init_mm
@@ -181,3 +186,11 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)
 	free_init_pages("initrd memory", start, end);
 }
 #endif
+
+#ifdef CONFIG_OF_FLATTREE
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end)
+{
+	pr_err("%s(%lx, %lx)\n", __func__, start, end);
+}
+#endif /* CONFIG_OF_FLATTREE */
Signature · 1 line
1.7.4.1
#66 lore raw

Re: [PATCH v2 32/76] ARC: [DeviceTree] Basic support

Quoted 14 lines · Vineet Gupta

This is minimal infrastructure needed for devicetree work. It uses an a sample "skeleton" devicetree - embedded in kernel image - to print the board, manufacturer by parsing the top-level "compatible" string.

As of now we don't need any additional "board" specific "machine_desc".

TODO: support interpreting the command line as boot-loader passed dtb

Cc Arnd Bergmann <[email protected]>
Cc Grant Likely <[email protected]>
Cc Rob Herring <[email protected]>
Quoted 4 lines
---
 arch/arc/Kconfig                |    9 +++++
 arch/arc/Makefile               |    9 +++++
 arch/arc/boot/dtb/Makefile      |   22 ++++++++++++

This is .../boot/dts/Makefile on other arches. We should be consistent.

Quoted 84 lines
 arch/arc/boot/dts/skeleton.dts  |   10 ++++++
 arch/arc/boot/dts/skeleton.dtsi |   21 ++++++++++++
 arch/arc/include/asm/prom.h     |   15 ++++++++
 arch/arc/include/asm/sections.h |    1 +
 arch/arc/kernel/Makefile        |    2 +
 arch/arc/kernel/devtree.c       |   69 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/setup.c         |    9 +++++
 arch/arc/mm/init.c              |   13 +++++++
 11 files changed, 180 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/boot/dtb/Makefile
 create mode 100644 arch/arc/boot/dts/skeleton.dts
 create mode 100644 arch/arc/boot/dts/skeleton.dtsi
 create mode 100644 arch/arc/include/asm/prom.h
 create mode 100644 arch/arc/kernel/devtree.c
arch/arc/Kconfig +9 -0
index d457a83..5175cf7 100644
@@ -21,7 +21,10 @@ config ARC
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_GENERIC_HARDIRQS
 	select HOTPLUG if !INITRAMFS_SOURCE=""
+	select IRQ_DOMAIN
 	select MODULES_USE_ELF_RELA
+	select OF
+	select OF_EARLY_FLATTREE
 
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
@@ -316,6 +319,12 @@ config CMDLINE_UBOOT
 	  to it. kernel startup code will copy the string into cmdline buffer
 	  and also append CONFIG_CMDLINE.
 
+config ARC_BUILTIN_DTB_NAME
+	string "Built in DTB"
+	help
+	  Set the name of the DTB to embed in the vmlinux binary
+	  Leaving it blank selects the minimal "skeleton" dtb
+
 source "kernel/Kconfig.preempt"
 
 endmenu	 # "ARC Architecture Configuration"
arch/arc/Makefile +9 -0
index 4d52a3b..d697e9c 100644
@@ -83,6 +83,9 @@ head-y		:= arch/arc/kernel/head.o
 # See arch/arc/Kbuild for content of core part of the kernel
 core-y		+= arch/arc/
 
+# w/o this dtb won't embed into kernel binary
+core-y		+= arch/arc/boot/dtb/
+
 # w/o this ifneq, make ARCH=arc clean was crapping out
 ifneq ($(platform-y),)
 core-y		+= arch/arc/plat-$(PLATFORM)/
@@ -101,6 +104,12 @@ bootpImage: vmlinux
 uImage: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
+%.dtb %.dtb.S %.dtb.o:
+	$(Q)$(MAKE) $(build)=$(boot)/dtb $(boot)/dtb/$@
+
+dtbs:
+	$(Q)$(MAKE) $(build)=$(boot)/dtb $(boot)/dtb/$@
+
 archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 
arch/arc/boot/dtb/Makefile new file +8 -0
new file mode 100644
index 0000000..825af84
@@ -0,0 +1,22 @@
+ifeq ($(CONFIG_OF),y)
+
+dtb-y	+= skeleton.dtb
+
+# Built-in dtb
+builtindtb-y				:= skeleton
+
+ifneq ($(CONFIG_ARC_BUILTIN_DTB_NAME),"")

arch/arc/boot/dtb/Makefile line 18

Quoted 10 lines
arch/arc/boot/dtb/Makefile new file +10 -0
+	builtindtb-y			:= $(CONFIG_ARC_BUILTIN_DTB_NAME)
+endif
+
+obj-y	+= $(patsubst "%",%,$(builtindtb-y)).dtb.o
+
+clean-files += $(obj)/$(dtb-y) $(obj)/*.dtb.S $(obj)/*.dtb.o
+
+# Rule to build device tree blobs
+$(obj)/%.dtb: $(src)/../dts/%.dts FORCE
+	$(call if_changed_dep,dtc)

There are common rules that went into 3.8. Please use them.

Quoted 31 lines
arch/arc/boot/dtb/Makefile new file +4 -0
+
+$(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y))
+
+endif
arch/arc/boot/dts/skeleton.dts new file +10 -0
new file mode 100644
index 0000000..25a84fb
@@ -0,0 +1,10 @@
+/*
+ * 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.
+ */
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
arch/arc/boot/dts/skeleton.dtsi new file +5 -0
new file mode 100644
index 0000000..f6a457a
@@ -0,0 +1,21 @@
+/*
+ * 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

arch/arc/boot/dts/skeleton.dtsi line 15

Quoted 10 lines
arch/arc/boot/dts/skeleton.dtsi new file +10 -0
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
+ * add a compatible value.
+ */
+
+/ {
+	compatible = "snps,arc-angel4", "snps,arc-ml509";

Normally, you wouldn't have this as part of skeleton. If you need something generic, then perhaps generic.dts would be better.

Quoted 179 lines
arch/arc/boot/dts/skeleton.dtsi new file +6 -0
+	#address-cells = <1>;
+	#size-cells = <1>;
+	chosen { };
+	aliases { };
+	memory { device_type = "memory"; reg = <0 0>; };
+};
arch/arc/include/asm/prom.h new file +15 -0
new file mode 100644
index 0000000..f54489b
@@ -0,0 +1,15 @@
+/*
+ * 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.
+ */
+
+#ifndef _ASM_ARC_PROM_H_
+#define _ASM_ARC_PROM_H_
+
+#define HAVE_ARCH_DEVTREE_FIXUPS
+extern int __init setup_machine_fdt(void *dt);
+
+#endif
arch/arc/include/asm/sections.h +1 -0
index fc15f2e..6fc1159 100644
@@ -13,5 +13,6 @@
 
 extern char _int_vec_base_lds[];
 extern char __arc_dccm_base[];
+extern char __dtb_start[];
 
 #endif
arch/arc/kernel/Makefile +2 -0
index ae140e5..5fefb7d 100644
@@ -8,6 +8,8 @@
 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 clk.o
 
+obj-$(CONFIG_OF)			+= devtree.o
+
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
 
arch/arc/kernel/devtree.c new file +69 -0
new file mode 100644
index 0000000..021293d
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Based on highly stipped down version of METAG
+ *
+ * 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/init.h>
+#include <linux/export.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/reboot.h>
+#include <linux/bootmem.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+#include <asm/prom.h>
+
+/* called from unflatten_device_tree() to bootstrap devicetree itself */
+void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+	return alloc_bootmem_align(size, align);
+}
+
+/**
+ * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
+ * @dt:		virtual address pointer to dt blob
+ *
+ * If a dtb was passed to the kernel, then use it to choose the correct
+ * machine_desc and to setup the system.
+ */
+int __init setup_machine_fdt(void *dt)
+{
+	struct boot_param_header *devtree = dt;
+	unsigned long dt_root;
+	char *model, *compat;
+	char manufacturer[16];
+
+	/* check device tree validity */
+	if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
+		return 1;
+
+	/* Search the mdescs for the 'best' compatible value match */
+	initial_boot_params = devtree;
+	dt_root = of_get_flat_dt_root();
+
+	/* compat = "<manufacturer>,<model>" */
+	compat = of_get_flat_dt_prop(dt_root, "compatible", NULL);
+	if (!compat)
+		compat = "<unknown>";
+
+	model = strchr(compat, ',');
+	if (model)
+		model++;
+
+	strlcpy(manufacturer, compat, model ? model - compat : strlen(compat));
+
+	pr_info("Board \"%s\" from %s (Manufacturer)\n", model, manufacturer);
+
+	/* Retrieve various information from the /chosen node */
+	of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
+
+	return 0;
+}
arch/arc/kernel/setup.c +9 -0
index 82ac206..27aebd6 100644
@@ -13,6 +13,8 @@
 #include <linux/console.h>
 #include <linux/module.h>
 #include <linux/cpu.h>
+#include <linux/of_fdt.h>
+#include <asm/sections.h>
 #include <asm/arcregs.h>
 #include <asm/tlb.h>
 #include <asm/cache.h>
@@ -20,6 +22,7 @@
 #include <asm/page.h>
 #include <asm/irq.h>
 #include <asm/arcregs.h>
+#include <asm/prom.h>
 
 #define FIX_PTR(x)  __asm__ __volatile__(";" : "+r"(x))
 
@@ -57,6 +60,8 @@ void __init __attribute__((weak)) arc_platform_early_init(void)
 
 void __init setup_arch(char **cmdline_p)
 {
+	int rc;
+
 #ifdef CONFIG_CMDLINE_UBOOT
 	/* Make sure that a whitespace is inserted before */
 	strlcat(command_line, " ", sizeof(command_line));
@@ -71,6 +76,8 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
+	rc = setup_machine_fdt(__dtb_start);
+
 	/* To force early parsing of things like mem=xxx */
 	parse_early_param();
 
@@ -81,6 +88,8 @@ void __init setup_arch(char **cmdline_p)
 
 	setup_arch_memory();
 
+	unflatten_device_tree();
+
 	/* Can be issue if someone passes cmd line arg "ro"
 	 * But that is unlikely so keeping it as it is
 	 */
arch/arc/mm/init.c +0 -0
index 9897847..1087a97 100644

arch/arc/mm/init.c static int __init setup_mem_sz(char *str) · line 43

Quoted 6 lines
arch/arc/mm/init.c +3 -0
@@ -38,6 +38,11 @@ static int __init setup_mem_sz(char *str)
 }
 early_param("mem", setup_mem_sz);
 
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+	pr_err("%s(%llx, %llx)\n", __func__, base, size);

? Is this todo?

Quoted 6 lines
arch/arc/mm/init.c +2 -0
+}
+
 /*
  * First memory setup routine called from setup_arch()
  * 1. setup swapper's mm @init_mm

arch/arc/mm/init.c void __init free_initrd_mem(unsigned long start, unsigned long end) · line 194

Quoted 9 lines
arch/arc/mm/init.c +6 -0
@@ -181,3 +186,11 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)
 	free_init_pages("initrd memory", start, end);
 }
 #endif
+
+#ifdef CONFIG_OF_FLATTREE
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end)
+{
+	pr_err("%s(%lx, %lx)\n", __func__, start, end);

And this?

Quoted 3 lines
arch/arc/mm/init.c +2 -0
+}
+#endif /* CONFIG_OF_FLATTREE */
#67 lore raw

Re: [PATCH v2 32/76] ARC: [DeviceTree] Basic support

Quoted 20 lines · Rob Herring
Quoted 14 lines · Vineet Gupta

This is minimal infrastructure needed for devicetree work. It uses an a sample "skeleton" devicetree - embedded in kernel image - to print the board, manufacturer by parsing the top-level "compatible" string.

As of now we don't need any additional "board" specific "machine_desc".

TODO: support interpreting the command line as boot-loader passed dtb

Cc Arnd Bergmann <[email protected]>
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc devicetree-discuss-uLR06cmDAlY/[email protected]
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Quoted 4 lines
---
 arch/arc/Kconfig                |    9 +++++
 arch/arc/Makefile               |    9 +++++
 arch/arc/boot/dtb/Makefile      |   22 ++++++++++++
Quoted 1 line

This is .../boot/dts/Makefile on other arches. We should be consistent.

OK, everything moved over to boot/dts folder, boot/dtb nuked, although latter seemed a clean approach - specially given that some arches have billions of source files in them - anyways not a big worry for ARC port.

Quoted 8 lines

Review

Quoted 6 lines

[snip....]

(quoted diff) +4 -0
+
+# Rule to build device tree blobs
+$(obj)/%.dtb: $(src)/../dts/%.dts FORCE
+	$(call if_changed_dep,dtc)

There are common rules that went into 3.8. Please use them.

How does the equivalent of following look like:

arch/arc/boot/dts/Makefile +0 -0

@@ -1,7 +1,5 @@
ifeq ($(CONFIG_OF),y)

-dtb-y += skeleton.dtb
-
# Built-in dtb
builtindtb-y := skeleton

@@ -11,12 +9,6 @@ endif

obj-y += $(patsubst "%",%,$(builtindtb-y)).dtb.o

-clean-files += $(obj)/$(dtb-y) $(obj)/*.dtb.S $(obj)/*.dtb.o -
-# Rule to build device tree blobs
-$(obj)/%.dtb: $(src)/../dts/%.dts FORCE
- $(call if_changed_dep,dtc)
-
-$(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y)) +clean-files += *.dtb

One observation above is that the explicitly build dtb file (make ARCH=arc angel4.dtb) doesn't get cleaned with make {clean,distclean} despite above clean-files and this is true even for orig version.

Quoted 36 lines
Quoted 36 lines
(quoted diff) +4 -0
+
+$(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y))
+
+endif
arch/arc/boot/dts/skeleton.dts new file +10 -0
new file mode 100644
index 0000000..25a84fb
@@ -0,0 +1,10 @@
+/*
+ * 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.
+ */
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
arch/arc/boot/dts/skeleton.dtsi new file +10 -0
new file mode 100644
index 0000000..f6a457a
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
Quoted 8 lines

arch/arc/boot/dts/skeleton.dtsi line 15

Quoted 5 lines
arch/arc/boot/dts/skeleton.dtsi new file +5 -0
+ * add a compatible value.
+ */
+
+/ {
+	compatible = "snps,arc-angel4", "snps,arc-ml509";

Normally, you wouldn't have this as part of skeleton. If you need something generic, then perhaps generic.dts would be better.

So you mean rename arc/arc/boot/dts/skeleton.dts to arch/arc/boot/dts/generic.dts as that's what the semantics are here. I agree.

However I think skeleton semantics are better: I'll take out the specific boards name from it, and for empty CONFIG_ARC_BUILTIN_DTB_NAME, include a real board DT file rather than skeleton. OK ?

Quoted 8 lines

arch/arc/boot/dts/skeleton.dtsi

Quoted 6 lines

[snipped...]
early_param("mem", setup_mem_sz);

arch/arc/boot/dts/skeleton.dtsi new file +3 -0
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+	pr_err("%s(%llx, %llx)\n", __func__, base, size);

? Is this todo?

Yes, ARC port currently doesn't handle the cmdline provided by DT - given that I added the the DT support itself very recently. I plan to fix this soon, but assume it not absolutely must in terms of requirements.

Quoted 7 lines

arch/arc/boot/dts/skeleton.dtsi

Quoted 5 lines
arch/arc/boot/dts/skeleton.dtsi new file +5 -0
+#ifdef CONFIG_OF_FLATTREE
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+					    unsigned long end)
+{
+	pr_err("%s(%lx, %lx)\n", __func__, start, end);

And this?

Ditto !

Many thanks for your review.
-Vineet

#68 lore raw

PATCH v2 33/76 ARC: [DeviceTree] Convert some Kconfig items to runtime values

In reply to Vineet Gupta

* mem size now runtime configured (prev CONFIG_ARC_PLAT_SDRAM_SIZE)
* core cpu clk runtime configured (prev CONFIG_ARC_PLAT_CLK)

Cc Arnd Bergmann <[email protected]>
Cc Grant Likely <[email protected]>
---
 arch/arc/Kconfig                |   12 ------------
 arch/arc/boot/dts/skeleton.dtsi |    6 +++++-
 arch/arc/include/asm/clk.h      |    2 ++
 arch/arc/kernel/clk.c           |   12 +++++++++++-
 arch/arc/kernel/devtree.c       |   13 +++++++++++++
 arch/arc/mm/init.c              |    5 +++--
 6 files changed, 34 insertions(+), 16 deletions(-)
arch/arc/Kconfig +0 -12
index 5175cf7..548b89e 100644
@@ -245,10 +245,6 @@ 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"
@@ -262,14 +258,6 @@ config LINUX_LINK_BASE
 	  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
-	  all software purposes, this is the amt of memory.
-
 endmenu # "Platform Board Configuration"
 
 config ARC_STACK_NONEXEC
arch/arc/boot/dts/skeleton.dtsi +5 -1
index f6a457a..8e4ec00 100644
@@ -13,9 +13,13 @@
 
 / {
 	compatible = "snps,arc-angel4", "snps,arc-ml509";
+	clock-frequency = <80000000>;	/* 80 MHZ */
 	#address-cells = <1>;
 	#size-cells = <1>;
 	chosen { };
 	aliases { };
-	memory { device_type = "memory"; reg = <0 0>; };
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x10000000>;	/* 256M */
+	};
 };
arch/arc/include/asm/clk.h +2 -0
index 6195643..bf9d29f 100644
@@ -17,4 +17,6 @@ static inline unsigned long arc_get_core_freq(void)
 	return core_freq;
 }
 
+extern int arc_set_core_freq(unsigned long);
+
 #endif
arch/arc/kernel/clk.c +11 -1
index 64925db..66ce0dc 100644
@@ -8,4 +8,14 @@
 
 #include <asm/clk.h>
 
-unsigned long core_freq = CONFIG_ARC_PLAT_CLK;
+unsigned long core_freq = 800000000;
+
+/*
+ * As of now we default to device-tree provided clock
+ * In future we can determine this in early boot
+ */
+int arc_set_core_freq(unsigned long freq)
+{
+	core_freq = freq;
+	return 0;
+}
arch/arc/kernel/devtree.c +13 -0
index 021293d..fd49394 100644
@@ -20,6 +20,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <asm/prom.h>
+#include <asm/clk.h>
 
 /* called from unflatten_device_tree() to bootstrap devicetree itself */
 void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
@@ -39,7 +40,9 @@ int __init setup_machine_fdt(void *dt)
 	struct boot_param_header *devtree = dt;
 	unsigned long dt_root;
 	char *model, *compat;
+	void *clk;
 	char manufacturer[16];
+	unsigned long len;
 
 	/* check device tree validity */
 	if (be32_to_cpu(devtree->magic) != OF_DT_HEADER)
@@ -65,5 +68,15 @@ int __init setup_machine_fdt(void *dt)
 	/* Retrieve various information from the /chosen node */
 	of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
 
+	/* Initialize {size,address}-cells info */
+	of_scan_flat_dt(early_init_dt_scan_root, NULL);
+
+	/* Setup memory, calling early_init_dt_add_memory_arch */
+	of_scan_flat_dt(early_init_dt_scan_memory, NULL);
+
+	clk = of_get_flat_dt_prop(dt_root, "clock-frequency", &len);
+	if (clk)
+		arc_set_core_freq(of_read_ulong(clk, len/4));
+
 	return 0;
 }
arch/arc/mm/init.c +3 -2
index 1087a97..8c173f9 100644
@@ -24,7 +24,7 @@ char empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE);
 EXPORT_SYMBOL(empty_zero_page);
 
 /* Default tot mem from .config */
-static unsigned long arc_mem_sz = CONFIG_ARC_PLAT_SDRAM_SIZE;
+static unsigned long arc_mem_sz = 0x20000000;  /* some default */
 
 /* User can over-ride above with "mem=nnn[KkMm]" in cmdline */
 static int __init setup_mem_sz(char *str)
@@ -40,7 +40,8 @@ early_param("mem", setup_mem_sz);
 
 void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 {
-	pr_err("%s(%llx, %llx)\n", __func__, base, size);
+	arc_mem_sz = size & PAGE_MASK;
+	pr_info("Memory size set via devicetree %ldM\n", TO_MB(arc_mem_sz));
 }
 
 /*
Signature · 1 line
1.7.4.1
#69 lore raw

PATCH v2 34/76 ARC: [plat-arcfpga]: Enabling DeviceTree for Angel4 board

In reply to Vineet Gupta

* arc-uart platform device now populated dynamically, using of_platform_populate() - applies to any other device whatsoever.

* uart in turn requires incore arc-intc to be also present in DT

* A irq-domain needs to be instantiated for IRQ requests by DT probed device (e.g. arc-uart)

TODO: switch over to linear irq domain once all devs have been
transitioned to DT

Cc Grant Likely <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 .../devicetree/bindings/arc/interrupts.txt         |   24 +++++++++
 arch/arc/boot/dts/angel4.dts                       |   55 ++++++++++++++++++++
 arch/arc/boot/dts/skeleton.dtsi                    |   12 ++++
 arch/arc/kernel/irq.c                              |   38 +++++++++++--
 arch/arc/plat-arcfpga/platform.c                   |   22 +++++---
 5 files changed, 136 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arc/interrupts.txt
 create mode 100644 arch/arc/boot/dts/angel4.dts
Documentation/devicetree/bindings/arc/interrupts.txt new file +24 -0
new file mode 100644
index 0000000..9a5d562
@@ -0,0 +1,24 @@
+* ARC700 incore Interrupt Controller
+
+  The core interrupt controller provides 32 prioritised interrupts (2 levels)
+  to ARC700 core.
+
+Properties:
+
+- compatible: "snps,arc700-intc"
+- interrupt-controller: This is an interrupt controller.
+- #interrupt-cells: Must be <1>.
+
+  Single Cell "interrupts" property of a device specifies the IRQ number
+  between 0 to 31
+
+  intc accessed via the special ARC AUX register interface, hence "reg" property
+  is not specified.
+
+Example:
+
+	intc: interrupt-controller {
+		compatible = "snps,arc700-intc";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+	};
arch/arc/boot/dts/angel4.dts new file +55 -0

55 lines not on this page · raw message

arch/arc/boot/dts/skeleton.dtsi +12 -0
index 8e4ec00..f5d2b52 100644
@@ -18,6 +18,18 @@
 	#size-cells = <1>;
 	chosen { };
 	aliases { };
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "snps,arc770d";
+			reg = <0>;
+		};
+	};
+
 	memory {
 		device_type = "memory";
 		reg = <0x00000000 0x10000000>;	/* 256M */
arch/arc/kernel/irq.c +32 -6
index 2f399eb..3c18e66 100644
@@ -9,6 +9,8 @@
 
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/irqdomain.h>
 #include <asm/sections.h>
 #include <asm/irq.h>
 
@@ -59,16 +61,40 @@ static struct irq_chip onchip_intc = {
 	.irq_unmask	= arc_unmask_irq,
 };
 
+static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq,
+				irq_hw_number_t hw)
+{
+	if (irq == TIMER0_IRQ)
+		irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq);
+	else
+		irq_set_chip_and_handler(irq, &onchip_intc, handle_level_irq);
+
+	return 0;
+}
+
+static const struct irq_domain_ops arc_intc_domain_ops = {
+	.xlate = irq_domain_xlate_onecell,
+	.map = arc_intc_domain_map,
+};
+
+static struct irq_domain *root_domain;
+
 void __init init_onchip_IRQ(void)
 {
-	int i;
+	struct device_node *intc = NULL;
+
+	intc = of_find_compatible_node(NULL, NULL, "snps,arc700-intc");
+	if(!intc)
+		panic("DeviceTree Missing incore intc\n");
+
+	root_domain = irq_domain_add_legacy(intc, NR_IRQS, 0, 0,
+					    &arc_intc_domain_ops, NULL);
 
-	for (i = 0; i < NR_IRQS; i++)
-		irq_set_chip_and_handler(i, &onchip_intc, handle_level_irq);
+	if (!root_domain)
+		panic("root irq domain not avail\n");
 
-#ifdef CONFIG_SMP
-	irq_set_chip_and_handler(TIMER0_IRQ, &onchip_intc, handle_percpu_irq);
-#endif
+	/* with this we don't need to export root_domain */
+	irq_set_default_host(root_domain);
 }
 
 /*
arch/arc/plat-arcfpga/platform.c +13 -9
index 5388b31..d98028c 100644
@@ -13,6 +13,7 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/console.h>
+#include <linux/of_platform.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/clk.h>
@@ -23,9 +24,9 @@
 #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE)
 
 static unsigned long arc_uart_info[] = {
-	CONFIG_ARC_SERIAL_BAUD,	/* uart->baud */
-	-1,			/* uart->port.uartclk */
 	-1,			/* uart->is_emulated (runtime @running_on_hw) */
+	-1,			/* uart->port.uartclk */
+	CONFIG_ARC_SERIAL_BAUD,	/* uart->baud */
 	0
 };
 
@@ -70,7 +71,7 @@ static void arc_fpga_serial_init(void)
 	arc_uart_info[1] = arc_get_core_freq();
 
 	/* To let driver workaround ISS bug: baudh Reg can't be set to 0 */
-	arc_uart_info[2] = !running_on_hw;
+	arc_uart_info[0] = !running_on_hw;
 
 	early_platform_add_devices(fpga_early_devs,
 				   ARRAY_SIZE(fpga_early_devs));
@@ -117,20 +118,23 @@ void __init arc_platform_early_init(void)
 	arc_fpga_serial_init();
 }
 
-static struct platform_device *fpga_devs[] __initdata = {
+static struct of_dev_auxdata plat_auxdata_lookup[] __initdata = {
 #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE)
-	&arc_uart0_dev,
-#if CONFIG_SERIAL_ARC_NR_PORTS > 1
-	&arc_uart1_dev,
-#endif
+	OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info),
 #endif
+	{}
 };
 
 int __init fpga_plat_init(void)
 {
 	pr_info("[plat-arcfpga]: registering device resources\n");
 
-	platform_add_devices(fpga_devs, ARRAY_SIZE(fpga_devs));
+	/*
+	 * Traverses flattened DeviceTree - registering platform devices
+	 * complete with their resources
+	 */
+	of_platform_populate(NULL, of_default_bus_match_table,
+			     plat_auxdata_lookup, NULL);
 
 	return 0;
 }
Signature · 1 line
1.7.4.1
#70 lore raw

PATCH v2 35/76 ARC: Last bits (stubs) to get to a running kernel with UART

In reply to Vineet Gupta

This was part of port buildup strategy from Arnd to have a minimal kernel at first and then add optional features (stacktracing, ptrace, smp, kprobes, oprofile....)

---
 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
#71 lore raw

PATCH v2 36/76 ARC: Switch to generic kernel_thread() - split ret_from_fork

In reply to Vineet Gupta

Originally the jump to kernel_thread "payload" or entry-point happened via a return from exception (RTIE) using stuff from specially carved pt_regs (pt_regs->status32 enabled Kernel mode, pt_regs->ret pointed to a kernel thread helper to jump to entry point)

Now copy_thread() sets up __switch_to() to ret to a small asm trampoline ret_from_kernel_thread() which simply jumps to thread entry point.

It also setsup thread entry point in callee regs (vs. pt_regs) which are anyways unwound by __switch_to, keeping things ready-to-go for ret_from_kernel_thread.

This eliminates any involvement of pt_regs altogether.

---
 arch/arc/Kconfig                 |    1 +
 arch/arc/include/asm/processor.h |    6 ----
 arch/arc/kernel/entry.S          |    7 ++++
 arch/arc/kernel/process.c        |   62 +++++++++++++------------------------
 4 files changed, 30 insertions(+), 46 deletions(-)
arch/arc/Kconfig +1 -0
index 548b89e..5588cee 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/include/asm/processor.h +0 -6
index 053a639..860252e 100644
@@ -57,12 +57,6 @@ unsigned long thread_saved_pc(struct task_struct *t);
 
 #define cpu_relax()	do { } while (0)
 
-/*
- * Create a new kernel thread
- */
-
-extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
-
 #define copy_segments(tsk, mm)      do { } while (0)
 #define release_segments(mm)        do { } while (0)
 
arch/arc/kernel/entry.S +7 -0
index 0324ad1..e76b432 100644
@@ -579,6 +579,13 @@ ARC_ENTRY ret_from_fork
 	b @ret_from_exception
 ARC_EXIT ret_from_fork
 
+ARC_ENTRY ret_from_kernel_thread
+	bl  @schedule_tail
+	jl.d [r14]		; kernel_thread "payload"
+	mov  r0, r13		; arg to payload
+	j   @sys_exit
+ARC_EXIT ret_from_kernel_thread
+
 ;################### Special Sys Call Wrappers ##########################
 
 ARC_ENTRY sys_execve_wrapper
arch/arc/kernel/process.c +22 -40

91 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#72 lore raw

PATCH v2 37/76 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/syscalls.h |    1 -
 arch/arc/include/asm/unistd.h   |    3 ++
 arch/arc/kernel/entry.S         |   18 ++++++++-------
 arch/arc/kernel/process.c       |   44 ---------------------------------------
 arch/arc/kernel/sys.c           |    1 -
 6 files changed, 21 insertions(+), 54 deletions(-)
arch/arc/include/asm/ptrace.h +8 -0
index 92ef198..e4e1ac6 100644
@@ -133,6 +133,14 @@ struct user_regs_struct {
 #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() */			\
+	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__ */
 
 #define orig_r8_IS_SCALL		0x0001
arch/arc/include/asm/syscalls.h +0 -1
index cf5d2f5..e53a534 100644
@@ -15,7 +15,6 @@
 #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);
arch/arc/include/asm/unistd.h +3 -0
index 6a2d101..003b2cf 100644
@@ -8,6 +8,9 @@
 
 /******** no-legacy-syscalls-ABI *******/
 
+#define __ARCH_WANT_KERNEL_EXECVE
+#define __ARCH_WANT_SYS_EXECVE
+
 #define sys_mmap2 sys_mmap_pgoff
 
 #include <asm-generic/unistd.h>
arch/arc/kernel/entry.S +10 -8
index e76b432..d2cad3c 100644
@@ -586,15 +586,17 @@ 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
+; for return to user mode.
+; However the call stack leading to kernel_execve() from say
+; ____call_usermodehelper() would make SP != pt_regs.
+; Thus we need to set SP to pt_regs as passed by kernel_execve() to us.
+ARC_ENTRY ret_from_kernel_execve
+	b.d   ret_from_exception
+	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
#73 lore raw

PATCH v2 38/76 ARC: Switch to saner kernel_execve() semantics #1

In reply to Vineet Gupta

Prev kernel_execve() ensured return to userland using asm glue ret_from_kernel_execve(). However given that
-kernel_execve() is always called from inside a kernel_thread -and that a real kernel thread never directly "falls-off" into
ret_from_kernel_thread() - either never return such as kthreadd or use kthread() wrapper which ensures tailing to do_exit.
-core kernel enables returning from kernel_execve( ) path - by removing
__init annotation from kernel_init()

Thus we can utilize the thread-falling-off for returning to userland.

In summary:
A thread starts from ret_from_kernel_thread trampoline - leading to kernel_execve. By making sure kernel_execve returns we end back into ret_from_kernel_thread - which now returns as if from syscall - enabling return to usermode.

---
 arch/arc/Kconfig              |    1 +
 arch/arc/include/asm/unistd.h |    1 -
 arch/arc/kernel/entry.S       |   12 +-----------
 3 files changed, 2 insertions(+), 12 deletions(-)
arch/arc/Kconfig +1 -0
index 5588cee..3d5f940 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_EXECVE
 	select GENERIC_KERNEL_THREAD
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SMP_IDLE_THREAD
arch/arc/include/asm/unistd.h +0 -1
index 003b2cf..7841827 100644
@@ -8,7 +8,6 @@
 
 /******** no-legacy-syscalls-ABI *******/
 
-#define __ARCH_WANT_KERNEL_EXECVE
 #define __ARCH_WANT_SYS_EXECVE
 
 #define sys_mmap2 sys_mmap_pgoff
arch/arc/kernel/entry.S +1 -11
index d2cad3c..b2291fc 100644
@@ -583,19 +583,9 @@ ARC_ENTRY ret_from_kernel_thread
 	bl  @schedule_tail
 	jl.d [r14]		; kernel_thread "payload"
 	mov  r0, r13		; arg to payload
-	j   @sys_exit
+	b    ret_from_exception
 ARC_EXIT ret_from_kernel_thread
 
-; When we land here, pt_regs have already been updated in-place correctly
-; for return to user mode.
-; However the call stack leading to kernel_execve() from say
-; ____call_usermodehelper() would make SP != pt_regs.
-; Thus we need to set SP to pt_regs as passed by kernel_execve() to us.
-ARC_ENTRY ret_from_kernel_execve
-	b.d   ret_from_exception
-	mov   sp, r0
-ARC_EXIT ret_from_kernel_execve
-
 ;################### Special Sys Call Wrappers ##########################
 
 ; TBD: call do_fork directly from here
Signature · 1 line
1.7.4.1
#74 lore raw

PATCH v2 39/76 ARC: Switch to saner kernel_execve() semantics #2

In reply to Vineet Gupta

fold ret_from_kernel_thread into ret_from_fork

The only difference is former needs to call thread entry point which can be detected inside ret_from_fork too.

---
 arch/arc/kernel/entry.S   |   18 +++++++++++-------
 arch/arc/kernel/process.c |    8 ++++----
 2 files changed, 15 insertions(+), 11 deletions(-)
arch/arc/kernel/entry.S +11 -7
index b2291fc..69a0c9f 100644
@@ -575,16 +575,20 @@ ARC_ENTRY ret_from_fork
 	; when the forked child comes here from the __switch_to function
 	; r0 has the last task pointer.
 	; put last task in scheduler queue
-	bl  @schedule_tail
-	b @ret_from_exception
-ARC_EXIT ret_from_fork
+	bl   @schedule_tail
+
+	; If kernel thread, jump to it's entry-point
+	ld   r9, [sp, PT_status32]
+	brne r9, 0, 1f
 
-ARC_ENTRY ret_from_kernel_thread
-	bl  @schedule_tail
-	jl.d [r14]		; kernel_thread "payload"
+	jl.d [r14]
 	mov  r0, r13		; arg to payload
+
+1:
+	; special case of kernel_thread entry point returning back due to
+	; kernel_execve() - pretend return from syscall to ret to userland
 	b    ret_from_exception
-ARC_EXIT ret_from_kernel_thread
+ARC_EXIT ret_from_fork
 
 ;################### Special Sys Call Wrappers ##########################
 
arch/arc/kernel/process.c +4 -4
index 20d8b4d..403de7e 100644
@@ -99,7 +99,6 @@ void cpu_idle(void)
 }
 
 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
  *
@@ -155,15 +154,16 @@ int copy_thread(unsigned long clone_flags,
 	 */
 	p->thread.ksp = (unsigned long)c_callee;	/* THREAD_KSP */
 
+	/* __switch_to expects FP(0), BLINK(return addr) at top */
+	childksp[0] = 0;			/* fp */
+	childksp[1] = (unsigned long)ret_from_fork; /* blink */
+
 	if (unlikely(p->flags & PF_KTHREAD)) {
 		memset(c_regs, 0, sizeof(struct pt_regs));
 
 		c_callee->r13 = arg; /* argument to kernel thread */
 		c_callee->r14 = usp;  /* function */
 
-		/* __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;
 	}
 
Signature · 1 line
1.7.4.1
#75 lore raw

PATCH v2 40/76 ARC: Switch to generic sys_clone, fork, vfork

In reply to Vineet Gupta

We still need the low level asm wrappers to save CALLEE regs, however the core handlers sys_xxx now come from generic code

---
 arch/arc/Kconfig              |    1 +
 arch/arc/include/asm/unistd.h |    3 +++
 arch/arc/kernel/entry.S       |   10 ----------
 arch/arc/kernel/process.c     |   40 +++++-----------------------------------
 4 files changed, 9 insertions(+), 45 deletions(-)
arch/arc/Kconfig +1 -0
index 3d5f940..8fb9264 100644
@@ -9,6 +9,7 @@
 config ARC
 	def_bool y
 	select ARCH_NO_VIRT_TO_BUS
+	select CLONE_BACKWARDS
 	# ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
 	# DEVTMPS in turn needs HOTPLUG
 	select DEVTMPFS if !INITRAMFS_SOURCE=""
arch/arc/include/asm/unistd.h +3 -0
index 7841827..6f30484 100644
@@ -9,6 +9,9 @@
 /******** no-legacy-syscalls-ABI *******/
 
 #define __ARCH_WANT_SYS_EXECVE
+#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_SYS_VFORK
+#define __ARCH_WANT_SYS_FORK
 
 #define sys_mmap2 sys_mmap_pgoff
 
arch/arc/kernel/entry.S +0 -10
index 69a0c9f..6823f30 100644
@@ -594,8 +594,6 @@ ARC_EXIT ret_from_fork
 
 ; TBD: call do_fork directly from here
 ARC_ENTRY sys_fork_wrapper
-	; copy pointer to pt_regs as a parameter
-	mov  r0, sp
 	SAVE_CALLEE_SAVED_USER
 	bl  @sys_fork
 	DISCARD_CALLEE_SAVED_USER
@@ -604,8 +602,6 @@ ARC_ENTRY sys_fork_wrapper
 ARC_EXIT sys_fork_wrapper
 
 ARC_ENTRY sys_vfork_wrapper
-	; copy pointer to pt_regs as a parameter
-	mov  r0, sp
 	SAVE_CALLEE_SAVED_USER
 	bl  @sys_vfork
 	DISCARD_CALLEE_SAVED_USER
@@ -614,12 +610,6 @@ ARC_ENTRY sys_vfork_wrapper
 ARC_EXIT sys_vfork_wrapper
 
 ARC_ENTRY sys_clone_wrapper
-	; clone sys-call takes 2 mandatary args: @flags and @child-stack
-	; and it can take 3 var-args, depending on flags
-	; To keep sys_clone( ) signature constant, we assume all 5 args
-	; and set the helper @prtegs in next free reg
-	; this is cheap since our args are in regs, not on stack
-	mov r5, sp  ; pt_regs
 	SAVE_CALLEE_SAVED_USER
 	bl  @sys_clone
 	DISCARD_CALLEE_SAVED_USER
arch/arc/kernel/process.c +5 -35
index 403de7e..e2b119d 100644
@@ -20,39 +20,6 @@
 #include <linux/elf.h>
 #include <linux/tick.h>
 
-asmlinkage int sys_fork(struct pt_regs *regs)
-{
-	return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL);
-}
-
-asmlinkage int sys_vfork(struct pt_regs *regs)
-{
-	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0,
-		       NULL, NULL);
-}
-
-/* Per man, C-lib clone( ) is as follows
- *
- * int clone(int (*fn)(void *), void *child_stack,
- *           int flags, void *arg, ...
- *           pid_t *ptid, struct user_desc *tls, pid_t *ctid);
- *
- * @fn and @arg are of userland thread-hnalder and thus of no use
- * in sys-call, hence excluded in sys_clone arg list.
- * The only addition is ptregs, needed by fork core, although now-a-days
- * task_pt_regs() can be called anywhere to get that.
- */
-asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
-			 int __user *parent_tidptr, void *tls,
-			 int __user *child_tidptr, struct pt_regs *regs)
-{
-	if (!newsp)
-		newsp = regs->sp;
-
-	return do_fork(clone_flags, newsp, regs, 0, parent_tidptr,
-		       child_tidptr);
-}
-
 SYSCALL_DEFINE1(arc_settls, void *, user_tls_data_ptr)
 {
 	task_thread_info(current)->thr_ptr = (unsigned int)user_tls_data_ptr;
@@ -132,12 +99,13 @@ asmlinkage void ret_from_fork(void);
  */
 int copy_thread(unsigned long clone_flags,
 		unsigned long usp, unsigned long arg,
-		struct task_struct *p, struct pt_regs *regs)
+		struct task_struct *p)
 {
 	struct pt_regs *c_regs;        /* child's pt_regs */
 	unsigned long *childksp;       /* to unwind out of __switch_to() */
 	struct callee_regs *c_callee;  /* child's callee regs */
 	struct callee_regs *parent_callee;  /* paren't callee */
+	struct pt_regs *regs = current_pt_regs();
 
 	/* Mark the specific anchors to begin with (see pic above) */
 	c_regs = task_pt_regs(p);
@@ -176,7 +144,9 @@ int copy_thread(unsigned long clone_flags,
 	/* Copy parents pt regs on child's kernel mode stack */
 	*c_regs = *regs;
 
-	c_regs->sp = usp;
+	if (usp)
+		c_regs->sp = usp;
+
 	c_regs->r0 = 0;		/* fork returns 0 in child */
 
 	parent_callee = ((struct callee_regs *)regs) - 1;
Signature · 1 line
1.7.4.1
#76 lore raw

PATCH v2 41/76 ARC: [3.8 tracking] altstack consolidation, trace_clock, cacheflush.h

In reply to Vineet Gupta

* 64d8f41 "switch rt_sigreturn instances to restore_altstack"
* b1c4c5a "unify native sigaltstack"
* f4a94f2 "new helpers: __save_altstack/__compat_save_altstack"

* 8cbd9cc "tracing,x86: Add a TSC trace_clock"
* 9b04ebd "asm-generic/io.h: remove asm/cacheflush.h include"

---
 arch/arc/Kconfig                   |    1 +
 arch/arc/include/asm/Kbuild        |    1 +
 arch/arc/include/asm/dma-mapping.h |    1 +
 arch/arc/kernel/signal.c           |   14 ++------------
 4 files changed, 5 insertions(+), 12 deletions(-)
arch/arc/Kconfig +1 -0
index 8fb9264..3adc87b 100644
@@ -21,6 +21,7 @@ config ARC
 	select GENERIC_KERNEL_EXECVE
 	select GENERIC_KERNEL_THREAD
 	select GENERIC_PENDING_IRQ if SMP
+	select GENERIC_SIGALTSTACK
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_GENERIC_HARDIRQS
 	select HOTPLUG if !INITRAMFS_SOURCE=""
arch/arc/include/asm/Kbuild +1 -0
index 148dfcf..105ec11 100644
@@ -50,6 +50,7 @@ generic-y += statfs.h
 generic-y += termbits.h
 generic-y += termios.h
 generic-y += topology.h
+generic-y += trace_clock.h
 generic-y += types.h
 generic-y += ucontext.h
 generic-y += unaligned.h
arch/arc/include/asm/dma-mapping.h +1 -0
index ea0f56f..96e4316 100644
@@ -12,6 +12,7 @@
 #define ASM_ARC_DMA_MAPPING_H
 
 #include <asm-generic/dma-coherent.h>
+#include <asm/cacheflush.h>
 #include <plat/dma_addr.h>
 
 void *dma_alloc_noncoherent(struct device *dev, size_t size,
arch/arc/kernel/signal.c +2 -12
index 6671968..9d97040 100644
@@ -57,12 +57,6 @@
 
 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
 
-asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
-{
-	struct pt_regs *regs = task_pt_regs(current);
-	return do_sigaltstack(uss, uoss, regs->sp);
-}
-
 struct rt_sigframe {
 	struct siginfo info;
 	struct ucontext uc;
@@ -134,7 +128,7 @@ SYSCALL_DEFINE0(rt_sigreturn)
 		goto badframe;
 
 	if (unlikely(is_do_ss_needed(magic)))
-		if (do_sigaltstack(&sf->uc.uc_stack, NULL, regs->sp) == -EFAULT)
+		if (restore_altstack(&sf->uc.uc_stack))
 			goto badframe;
 
 	/* Don't restart from sigreturn */
@@ -193,7 +187,6 @@ setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info,
 {
 	struct rt_sigframe __user *sf;
 	unsigned int magic = 0;
-	stack_t stk;
 	int err = 0;
 
 	sf = get_sigframe(ka, regs, sizeof(struct rt_sigframe));
@@ -210,10 +203,7 @@ setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info,
 		err |= copy_siginfo_to_user(&sf->info, info);
 		err |= __put_user(0, &sf->uc.uc_flags);
 		err |= __put_user(NULL, &sf->uc.uc_link);
-		stk.ss_sp = (void __user *)current->sas_ss_sp;
-		stk.ss_flags = sas_ss_flags(regs->sp);
-		stk.ss_size = current->sas_ss_size;
-		err |= __copy_to_user(&sf->uc.uc_stack, &stk, sizeof(stk));
+		err |= __save_altstack(&sf->uc.uc_stack, regs->sp);
 
 		/* setup args 2 and 3 fo ruse rmode handler */
 		regs->r1 = (unsigned long)&sf->info;
Signature · 1 line
1.7.4.1
#77 lore raw

PATCH v2 42/76 ARC: [plat-arcfpga] defconfig

In reply to Vineet Gupta

With this we get to a running kernel on ISS

---------------------------------->8----------------------------------- Linux version 3.8.0-rc3+ (vineetg@vineetg-Latitude) (gcc version 4.4.7 (ARCompact elf32 toolchain (built 20121213)) ) #3 Thu Jan 17 14:22:05 IST 2013
Board "arc-angel4" from snps (Manufacturer)
Memory size set via devicetree 256M
[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: console=ttyARC0,115200n8
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 (1312K code, 463K data, 4184K init, 1400K reserv)
SLUB: Genslabs=12, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 NR_IRQS:16
Console: colour dummy device 80x25
Calibrating delay loop... 39.73 BogoMIPS (lpj=198656)
pid_max: default: 32768 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 RTSC
io scheduler noop registered (default)
arc-uart: ttyARC0 at MMIO 0xc0fc1000 (irq = 5) is a arc-uart console [ttyARC0] enabled, bootconsole disabled
console [ttyARC0] enabled, bootconsole disabled
mousedev: PS/2 mouse device common for all mice
Warning: unable to open an initial console.
Freeing unused kernel memory: 4184k [80002000] to [80418000] 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
mount: mounting tmpfs on /dev/shm failed: Invalid argument /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/configs/fpga_defconfig |   46 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/configs/fpga_defconfig
arch/arc/configs/fpga_defconfig new file +46 -0
new file mode 100644
index 0000000..8638e101f
@@ -0,0 +1,46 @@
+CONFIG_CROSS_COMPILE="arc-elf32-"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_DEFAULT_HOSTNAME="ARCLinux"
+# CONFIG_SWAP is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="../arc_initramfs"
+CONFIG_EXPERT=y
+# CONFIG_FUTEX is not set
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+CONFIG_ARC_BUILTIN_DTB_NAME="angel4"
+# CONFIG_COMPACTION is not set
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+# CONFIG_BLK_DEV is not set
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_ARC=y
+CONFIG_SERIAL_ARC_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_HID is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_IOMMU_SUPPORT is not set
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_XZ_DEC=y
Signature · 1 line
1.7.4.1
#78 lore raw

PATCH v2 43/76 ARC: [optim] Cache "current" in Register r25

In reply to Vineet Gupta
---
 arch/arc/Kconfig                 |    7 ++++++
 arch/arc/Makefile                |    9 +++++++
 arch/arc/include/asm/Kbuild      |    1 -
 arch/arc/include/asm/current.h   |   32 +++++++++++++++++++++++++++
 arch/arc/include/asm/entry.h     |   45 ++++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/processor.h |    3 ++
 arch/arc/kernel/asm-offsets.c    |    3 ++
 arch/arc/kernel/ctx_sw.c         |    7 ++++++
 arch/arc/kernel/entry.S          |   14 +++++++++++
 9 files changed, 120 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/current.h
arch/arc/Kconfig +7 -0
index 3adc87b..7e191b9 100644
@@ -264,6 +264,13 @@ config LINUX_LINK_BASE
 
 endmenu # "Platform Board Configuration"
 
+config ARC_CURR_IN_REG
+	bool "Dedicate Register r25 for current_task pointer"
+	default y
+	help
+	  This reserved Register R25 to point to Current Task in
+	  kernel mode. This saves memory access for each such access
+
 config ARC_STACK_NONEXEC
 	bool "Make stack non-executable"
 	default n
arch/arc/Makefile +9 -0
index d697e9c..49460cc 100644
@@ -20,6 +20,15 @@ export PLATFORM
 cflags-y	+= -Iarch/arc/plat-$(PLATFORM)/include
 cflags-y	+= -mA7 -fno-common -pipe -fno-builtin -D__linux__
 
+ifdef CONFIG_ARC_CURR_IN_REG
+# For a global register defintion, make sure it gets passed to every file
+# We had a customer reported bug where some code built in kernel was NOT using
+# any kernel headers, and missing the r25 global register
+# Can't do unconditionally (like above) because of recursive include issues
+# due to <linux/thread_info.h>
+LINUXINCLUDE	+=  -include ${src}/arch/arc/include/asm/current.h
+endif
+
 atleast_gcc44 :=  $(call cc-ifversion, -gt, 0402, y)
 cflags-$(atleast_gcc44)			+= -fsection-anchors
 
arch/arc/include/asm/Kbuild +0 -1
index 105ec11..78e982d 100644
@@ -11,7 +11,6 @@ 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
arch/arc/include/asm/current.h new file +32 -0
new file mode 100644
index 0000000..87b9185
@@ -0,0 +1,32 @@
+/*
+ * 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 16th, 2008
+ *  - Current macro is now implemented as "global register" r25
+ */
+
+#ifndef _ASM_ARC_CURRENT_H
+#define _ASM_ARC_CURRENT_H
+
+#ifdef __KERNEL__
+
+#ifndef __ASSEMBLY__
+
+#ifdef CONFIG_ARC_CURR_IN_REG
+
+register struct task_struct *curr_arc asm("r25");
+#define current (curr_arc)
+
+#else
+#include <asm-generic/current.h>
+#endif /* ! CONFIG_ARC_CURR_IN_REG */
+
+#endif /* ! __ASSEMBLY__ */
+
+#endif	/* __KERNEL__ */
+
+#endif /* _ASM_ARC_CURRENT_H */
arch/arc/include/asm/entry.h +45 -0

109 lines not on this page · raw message

arch/arc/include/asm/processor.h +3 -0
index 860252e..b7b1556 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_CURR_IN_REG
+	unsigned long user_r25;
+#endif
 #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
 	struct arc_fpu fpu;
 #endif
arch/arc/kernel/asm-offsets.c +3 -0
index 7f3f611..b0e7254 100644
@@ -23,6 +23,9 @@ int main(void)
 
 	DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
 	DEFINE(THREAD_CALLEE_REG, offsetof(struct thread_struct, callee_reg));
+#ifdef CONFIG_ARC_CURR_IN_REG
+	DEFINE(THREAD_USER_R25, offsetof(struct thread_struct, user_r25));
+#endif
 	DEFINE(THREAD_FAULT_ADDR,
 	       offsetof(struct thread_struct, fault_address));
 
arch/arc/kernel/ctx_sw.c +7 -0
index 647e37a..fbf739c 100644
@@ -24,6 +24,9 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 	unsigned int prev = (unsigned int)prev_task;
 	unsigned int next = (unsigned int)next_task;
 	int num_words_to_skip = 1;
+#ifdef CONFIG_ARC_CURR_IN_REG
+	num_words_to_skip++;
+#endif
 
 	__asm__ __volatile__(
 		/* FP/BLINK save generated by gcc (standard function prologue */
@@ -39,7 +42,9 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 		"st.a    r22, [sp, -4]   \n\t"
 		"st.a    r23, [sp, -4]   \n\t"
 		"st.a    r24, [sp, -4]   \n\t"
+#ifndef CONFIG_ARC_CURR_IN_REG
 		"st.a    r25, [sp, -4]   \n\t"
+#endif
 		"sub     sp, sp, %4      \n\t"	/* create gutter at top */
 
 		/* set ksp of outgoing task in tsk->thread.ksp */
@@ -62,7 +67,9 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 
 		"add    sp, sp, %4     \n\t"	/* skip gutter at top */
 
+#ifndef CONFIG_ARC_CURR_IN_REG
 		"ld.ab   r25, [sp, 4]   \n\t"
+#endif
 		"ld.ab   r24, [sp, 4]   \n\t"
 		"ld.ab   r23, [sp, 4]   \n\t"
 		"ld.ab   r22, [sp, 4]   \n\t"
arch/arc/kernel/entry.S +14 -0
index 6823f30..6566e66 100644
@@ -36,6 +36,9 @@
  *   was being "CLEARED" rather then "SET". Since it is Loop INHIBIT Bit,
  *   setting it and not clearing it clears ZOL context
  *
+ * Vineetg: May 16th, 2008
+ *  - r25 now contains the Current Task when in kernel
+ *
  * Vineetg: Dec 22, 2007
  *    Minor Surgery of Low Level ISR to make it SMP safe
  *    - MMU_SCRATCH0 Reg used for freeing up r9 in Level 1 ISR
@@ -539,6 +542,17 @@ restore_regs :
 	; XXX can this be optimised out
 	IRQ_DISABLE_SAVE    r9, r10	;@r10 has prisitine (pre-disable) copy
 
+#ifdef CONFIG_ARC_CURR_IN_REG
+	; Restore User R25
+	; Earlier this used to be only for returning to user mode
+	; However with 2 levels of IRQ this can also happen even if
+	; in kernel mode
+	ld r9, [sp, PT_sp]
+	brhs r9, VMALLOC_START, 8f
+	RESTORE_USER_R25
+8:
+#endif
+
 	; Restore REG File. In case multiple Events outstanding,
 	; use the same priorty as rtie: EXCPN, L2 IRQ, L1 IRQ, None
 	; Note that we use realtime STATUS32 (not pt_regs->status32) to
Signature · 1 line
1.7.4.1
#79 lore raw

PATCH v2 44/76 ARC: ptrace support

In reply to Vineet Gupta
---
 arch/arc/Kconfig         |    1 +
 arch/arc/kernel/Makefile |    3 +
 arch/arc/kernel/entry.S  |   69 +++++++++++++++++++++++
 arch/arc/kernel/ptrace.c |  136 +++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 207 insertions(+), 2 deletions(-)
arch/arc/Kconfig +1 -0
index 7e191b9..0224fd0 100644
@@ -23,6 +23,7 @@ config ARC
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SIGALTSTACK
 	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
 	select HOTPLUG if !INITRAMFS_SOURCE=""
 	select IRQ_DOMAIN
arch/arc/kernel/Makefile +3 -0
index 5fefb7d..a3c4a31 100644
@@ -5,6 +5,9 @@
 # it under the terms of the GNU General Public License version 2 as
 # published by the Free Software Foundation.
 
+# Pass UTS_MACHINE for user_regset definition
+CFLAGS_ptrace.o		+= -DUTS_MACHINE='"$(UTS_MACHINE)"'
+
 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 clk.o
 
arch/arc/kernel/entry.S +69 -0

104 lines not on this page · raw message

arch/arc/kernel/ptrace.c +134 -2

151 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer Acked-by on v2 44/76
#80 lore raw

Re: [PATCH v2 44/76] ARC: ptrace support

Quoted 7 lines · Vineet Gupta
---
 arch/arc/Kconfig         |    1 +
 arch/arc/kernel/Makefile |    3 +
 arch/arc/kernel/entry.S  |   69 +++++++++++++++++++++++
 arch/arc/kernel/ptrace.c |  136 +++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 207 insertions(+), 2 deletions(-)
#81 lore raw

PATCH v2 45/76 ARC: Futex support

In reply to Vineet Gupta
---
 arch/arc/include/asm/futex.h |  151 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/futex.h
arch/arc/include/asm/futex.h new file +151 -0
new file mode 100644
index 0000000..4dc64dd
@@ -0,0 +1,151 @@
+/*
+ * 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: August 2010: From Android kernel work
+ */
+
+#ifndef _ASM_FUTEX_H
+#define _ASM_FUTEX_H
+
+#include <linux/futex.h>
+#include <linux/preempt.h>
+#include <linux/uaccess.h>
+#include <asm/errno.h>
+
+#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\
+							\
+	__asm__ __volatile__(				\
+	"1:	ld  %1, [%2]			\n"	\
+		insn				"\n"	\
+	"2:	st  %0, [%2]			\n"	\
+	"	mov %0, 0			\n"	\
+	"3:					\n"	\
+	"	.section .fixup,\"ax\"		\n"	\
+	"	.align  4			\n"	\
+	"4:	mov %0, %4			\n"	\
+	"	b   3b				\n"	\
+	"	.previous			\n"	\
+	"	.section __ex_table,\"a\"	\n"	\
+	"	.align  4			\n"	\
+	"	.word   1b, 4b			\n"	\
+	"	.word   2b, 4b			\n"	\
+	"	.previous			\n"	\
+							\
+	: "=&r" (ret), "=&r" (oldval)			\
+	: "r" (uaddr), "r" (oparg), "ir" (-EFAULT)	\
+	: "cc", "memory")
+
+static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
+{
+	int op = (encoded_op >> 28) & 7;
+	int cmp = (encoded_op >> 24) & 15;
+	int oparg = (encoded_op << 8) >> 20;
+	int cmparg = (encoded_op << 20) >> 20;
+	int oldval = 0, ret;
+
+	if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
+		oparg = 1 << oparg;
+
+	if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
+		return -EFAULT;
+
+	pagefault_disable();	/* implies preempt_disable() */
+
+	switch (op) {
+	case FUTEX_OP_SET:
+		__futex_atomic_op("mov %0, %3", ret, oldval, uaddr, oparg);
+		break;
+	case FUTEX_OP_ADD:
+		__futex_atomic_op("add %0, %1, %3", ret, oldval, uaddr, oparg);
+		break;
+	case FUTEX_OP_OR:
+		__futex_atomic_op("or  %0, %1, %3", ret, oldval, uaddr, oparg);
+		break;
+	case FUTEX_OP_ANDN:
+		__futex_atomic_op("bic %0, %1, %3", ret, oldval, uaddr, oparg);
+		break;
+	case FUTEX_OP_XOR:
+		__futex_atomic_op("xor %0, %1, %3", ret, oldval, uaddr, oparg);
+		break;
+	default:
+		ret = -ENOSYS;
+	}
+
+	pagefault_enable();	/* subsumes preempt_enable() */
+
+	if (!ret) {
+		switch (cmp) {
+		case FUTEX_OP_CMP_EQ:
+			ret = (oldval == cmparg);
+			break;
+		case FUTEX_OP_CMP_NE:
+			ret = (oldval != cmparg);
+			break;
+		case FUTEX_OP_CMP_LT:
+			ret = (oldval < cmparg);
+			break;
+		case FUTEX_OP_CMP_GE:
+			ret = (oldval >= cmparg);
+			break;
+		case FUTEX_OP_CMP_LE:
+			ret = (oldval <= cmparg);
+			break;
+		case FUTEX_OP_CMP_GT:
+			ret = (oldval > cmparg);
+			break;
+		default:
+			ret = -ENOSYS;
+		}
+	}
+	return ret;
+}
+
+/* Compare-xchg with preemption disabled.
+ *  Notes:
+ *      -Best-Effort: Exchg happens only if compare succeeds.
+ *          If compare fails, returns; leaving retry/looping to upper layers
+ *      -successful cmp-xchg: return orig value in @addr (same as cmp val)
+ *      -Compare fails: return orig value in @addr
+ *      -user access r/w fails: return -EFAULT
+ */
+static inline int
+futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval,
+					u32 newval)
+{
+	u32 val;
+
+	if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
+		return -EFAULT;
+
+	pagefault_disable();	/* implies preempt_disable() */
+
+	/* TBD : can use llock/scond */
+	__asm__ __volatile__(
+	"1:	ld    %0, [%3]	\n"
+	"	brne  %0, %1, 3f	\n"
+	"2:	st    %2, [%3]	\n"
+	"3:	\n"
+	"	.section .fixup,\"ax\"	\n"
+	"4:	mov %0, %4	\n"
+	"	b   3b	\n"
+	"	.previous	\n"
+	"	.section __ex_table,\"a\"	\n"
+	"	.align  4	\n"
+	"	.word   1b, 4b	\n"
+	"	.word   2b, 4b	\n"
+	"	.previous\n"
+	: "=&r"(val)
+	: "r"(oldval), "r"(newval), "r"(uaddr), "ir"(-EFAULT)
+	: "cc", "memory");
+
+	pagefault_enable();	/* subsumes preempt_enable() */
+
+	*uval = val;
+	return val;
+}
+
+#endif
Signature · 1 line
1.7.4.1
#82 lore raw

PATCH v2 46/76 ARC: OProfile support

In reply to Vineet Gupta
---
 arch/arc/Kconfig           |    1 +
 arch/arc/Makefile          |    2 ++
 arch/arc/oprofile/Makefile |    9 +++++++++
 arch/arc/oprofile/common.c |   22 ++++++++++++++++++++++
 4 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/oprofile/Makefile
 create mode 100644 arch/arc/oprofile/common.c
arch/arc/Kconfig +1 -0
index 0224fd0..ae126a7 100644
@@ -25,6 +25,7 @@ config ARC
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
+	select HAVE_OPROFILE
 	select HOTPLUG if !INITRAMFS_SOURCE=""
 	select IRQ_DOMAIN
 	select MODULES_USE_ELF_RELA
arch/arc/Makefile +2 -0
index 49460cc..ca4b58c 100644
@@ -100,6 +100,8 @@ ifneq ($(platform-y),)
 core-y		+= arch/arc/plat-$(PLATFORM)/
 endif
 
+drivers-$(CONFIG_OPROFILE)	+= arch/arc/oprofile/
+
 libs-y		+= arch/arc/lib/ $(LIBGCC)
 
 #default target for make without any arguements.
arch/arc/oprofile/Makefile new file +9 -0
new file mode 100644
index 0000000..ce417a6
@@ -0,0 +1,9 @@
+obj-$(CONFIG_OPROFILE) += oprofile.o
+
+DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
+		oprof.o cpu_buffer.o buffer_sync.o \
+		event_buffer.o oprofile_files.o \
+		oprofilefs.o oprofile_stats.o \
+		timer_int.o )
+
+oprofile-y	:= $(DRIVER_OBJS) common.o
arch/arc/oprofile/common.c new file +22 -0
new file mode 100644
index 0000000..917ae16
@@ -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.
+ *
+ * Based on orig code from @author John Levon <[email protected]>
+ */
+
+#include <linux/oprofile.h>
+#include <linux/perf_event.h>
+
+int __init oprofile_arch_init(struct oprofile_operations *ops)
+{
+	return oprofile_perf_init(ops);
+}
+
+void oprofile_arch_exit(void)
+{
+	oprofile_perf_exit();
+}
Signature · 1 line
1.7.4.1
#83 lore raw

PATCH v2 47/76 ARC: Support for high priority interrupts in the in-core intc

In reply to Vineet Gupta

There is a bit of hack/kludge right now where we disable preemption if a L2 (High prio) IRQ is taken while L1 (Low prio) is active.

Need to revisit this

---
 arch/arc/Kconfig                |   19 ++++++
 arch/arc/include/asm/entry.h    |   95 +++++++++++++++++++++++++++++++
 arch/arc/include/asm/irqflags.h |    6 ++-
 arch/arc/kernel/entry.S         |  117 +++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/irq.c           |  104 ++++++++++++++++++++++++++++++++++-
 5 files changed, 339 insertions(+), 2 deletions(-)
arch/arc/Kconfig +19 -0
index ae126a7..20f3c4a 100644
@@ -208,6 +208,25 @@ config ARC_PAGE_SIZE_4K
 
 endchoice
 
+config ARC_COMPACT_IRQ_LEVELS
+	bool "ARCompact IRQ Priorities: High(2)/Low(1)"
+	default n
+	# Timer HAS to be high priority, for any other high priority config
+	select ARC_IRQ3_LV2
+
+if ARC_COMPACT_IRQ_LEVELS
+
+config ARC_IRQ3_LV2
+	bool
+
+config ARC_IRQ5_LV2
+	bool
+
+config ARC_IRQ6_LV2
+	bool
+
+endif
+
 config ARC_FPU_SAVE_RESTORE
 	bool "Enable FPU state persistence across context switch"
 	default n
arch/arc/include/asm/entry.h +95 -0

119 lines not on this page · raw message

arch/arc/include/asm/irqflags.h +5 -1
index 5cc1080..ccd8480 100644
@@ -95,7 +95,11 @@ static inline long arch_local_save_flags(void)
  */
 static inline int arch_irqs_disabled_flags(unsigned long flags)
 {
-	return !(flags & (STATUS_E1_MASK));
+	return !(flags & (STATUS_E1_MASK
+#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
+			| STATUS_E2_MASK
+#endif
+		));
 }
 
 static inline int arch_irqs_disabled(void)
arch/arc/kernel/entry.S +117 -0

154 lines not on this page · raw message

arch/arc/kernel/irq.c +103 -1

128 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#84 lore raw

PATCH v2 48/76 ARC: Module support

In reply to Vineet Gupta
---
 arch/arc/include/asm/module.h |    4 ++
 arch/arc/kernel/Makefile      |    1 +
 arch/arc/kernel/module.c      |  103 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/kernel/module.c
arch/arc/include/asm/module.h +4 -0
index 165d768..234b435 100644
@@ -14,4 +14,8 @@
 
 #include <asm-generic/module.h>
 
+#define MODULE_PROC_FAMILY "ARC700"
+
+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
+
 #endif /* _ASM_ARC_MODULE_H */
arch/arc/kernel/Makefile +1 -0
index a3c4a31..b4b9ab6 100644
@@ -12,6 +12,7 @@ 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 clk.o
 
 obj-$(CONFIG_OF)			+= devtree.o
+obj-$(CONFIG_MODULES)			+= arcksyms.o module.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/module.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer
#85 lore raw

Re: [PATCH v2 48/76] ARC: Module support

Quoted 5 lines · Vineet Gupta
arch/arc/kernel/module.c new file +5 -0
+int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+			      char *secstr, struct module *mod)
+{
+    return 0;
+}

arch/arc/kernel/module.c line 103

Quoted 10 lines
arch/arc/kernel/module.c new file +10 -0
+
+void module_arch_cleanup(struct module *mod)
+{
+}
+
+int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
+		    struct module *mod)
+{
+    return 0;
+}

These three empty functions are already defined __weak in kernel/module.c so you can simply omit them here.

Arnd

#86 lore raw

Re: [PATCH v2 48/76] ARC: Module support

Quoted 20 lines · Arnd Bergmann
Quoted 5 lines · Vineet Gupta
arch/arc/kernel/module.c new file +5 -0
+int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+			      char *secstr, struct module *mod)
+{
+    return 0;
+}

arch/arc/kernel/module.c line 103

Quoted 10 lines
arch/arc/kernel/module.c new file +10 -0
+
+void module_arch_cleanup(struct module *mod)
+{
+}
+
+int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
+		    struct module *mod)
+{
+    return 0;
+}

These three empty functions are already defined __weak in kernel/module.c so you can simply omit them here.

Quoted 1 line

Arnd

Actually a subsequent patch to do dwarf unwinding out of modules has valid code in those. But yes I can take them out from this patch and introduce in the the one which really needs it.

Thx,
-Vineet

#87 lore raw

PATCH v2 49/76 ARC: Diagnostics: show_regs() etc

In reply to Vineet Gupta
---
 arch/arc/kernel/troubleshoot.c |  305 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/mm/tlbex.S            |   20 +++
 2 files changed, 325 insertions(+), 0 deletions(-)
arch/arc/kernel/troubleshoot.c +305 -0
index 80bfe2a..7c10873 100644
@@ -6,12 +6,317 @@
  */
 
 #include <linux/ptrace.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
+#include <linux/kdev_t.h>
+#include <linux/fs_struct.h>
+#include <linux/proc_fs.h>
+#include <linux/file.h>
+#include <asm/arcregs.h>
+
+/*
+ * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25)
+ *   -Prints 3 regs per line and a CR.
+ *   -To continue, callee regs right after scratch, special handling of CR
+ */
+static noinline void print_reg_file(long *reg_rev, int start_num)
+{
+	unsigned int i;
+	char buf[512];
+	int n = 0, len = sizeof(buf);
+
+	/* weird loop because pt_regs regs rev r12..r0, r25..r13 */
+	for (i = start_num; i < start_num + 13; i++) {
+		n += scnprintf(buf + n, len - n, "r%02u: 0x%08lx\t",
+			       i, (unsigned long)*reg_rev);
+
+		if (((i + 1) % 3) == 0)
+			n += scnprintf(buf + n, len - n, "\n");
+
+		reg_rev--;
+	}
+
+	if (start_num != 0)
+		n += scnprintf(buf + n, len - n, "\n\n");
+
+	pr_info("%s", buf);
+}
+
+static void show_callee_regs(struct callee_regs *cregs)
+{
+	print_reg_file(&(cregs->r13), 13);
+}
+
+void print_task_path_n_nm(struct task_struct *tsk, char *buf)
+{
+	struct path path;
+	char *path_nm = NULL;
+	struct mm_struct *mm;
+	struct file *exe_file;
+
+	mm = get_task_mm(tsk);
+	if (!mm)
+		goto done;
+
+	exe_file = get_mm_exe_file(mm);
+	mmput(mm);
+
+	if (exe_file) {
+		path = exe_file->f_path;
+		path_get(&exe_file->f_path);
+		fput(exe_file);
+		path_nm = d_path(&path, buf, 255);
+		path_put(&path);
+	}
+
+done:
+	pr_info("%s, TGID %u\n", path_nm, tsk->tgid);
+}
+EXPORT_SYMBOL(print_task_path_n_nm);
+
+static void show_faulting_vma(unsigned long address, char *buf)
+{
+	struct vm_area_struct *vma;
+	struct inode *inode;
+	unsigned long ino = 0;
+	dev_t dev = 0;
+	char *nm = buf;
+
+	vma = find_vma(current->active_mm, address);
+
+	/* check against the find_vma( ) behaviour which returns the next VMA
+	 * if the container VMA is not found
+	 */
+	if (vma && (vma->vm_start <= address)) {
+		struct file *file = vma->vm_file;
+		if (file) {
+			struct path *path = &file->f_path;
+			nm = d_path(path, buf, PAGE_SIZE - 1);
+			inode = vma->vm_file->f_path.dentry->d_inode;
+			dev = inode->i_sb->s_dev;
+			ino = inode->i_ino;
+		}
+		pr_info("    @off 0x%lx in [%s]\n"
+			"    VMA: 0x%08lx to 0x%08lx\n\n",
+		       address - vma->vm_start, nm, vma->vm_start, vma->vm_end);
+	} else
+		pr_info("    @No matching VMA found\n");
+}
+
+static void show_ecr_verbose(struct pt_regs *regs)
+{
+	unsigned int vec, cause_code, cause_reg;
+	unsigned long address;
+
+	cause_reg = current->thread.cause_code;
+	pr_info("\n[ECR]: 0x%08x => ", cause_reg);
+
+	/* For Data fault, this is data address not instruction addr */
+	address = current->thread.fault_address;
+
+	vec = cause_reg >> 16;
+	cause_code = (cause_reg >> 8) & 0xFF;
+
+	/* For DTLB Miss or ProtV, display the memory involved too */
+	if (vec == ECR_V_DTLB_MISS) {
+		pr_cont("Invalid (%s) @ 0x%08lx by insn @ 0x%08lx\n",
+		       (cause_code == 0x01) ? "Read From" :
+		       ((cause_code == 0x02) ? "Write to" : "EX"),
+		       address, regs->ret);
+	} else if (vec == ECR_V_ITLB_MISS) {
+		pr_cont("Insn could not be fetched\n");
+	} else if (vec == ECR_V_MACH_CHK) {
+		pr_cont("%s\n", (cause_code == 0x0) ?
+					"Double Fault" : "Other Fatal Err");
+
+	} else if (vec == ECR_V_PROTV) {
+		if (cause_code == ECR_C_PROTV_INST_FETCH)
+			pr_cont("Execute from Non-exec Page\n");
+		else if (cause_code == ECR_C_PROTV_LOAD)
+			pr_cont("Read from Non-readable Page\n");
+		else if (cause_code == ECR_C_PROTV_STORE)
+			pr_cont("Write to Non-writable Page\n");
+		else if (cause_code == ECR_C_PROTV_XCHG)
+			pr_cont("Data exchange protection violation\n");
+		else if (cause_code == ECR_C_PROTV_MISALIG_DATA)
+			pr_cont("Misaligned r/w from 0x%08lx\n", address);
+	} else if (vec == ECR_V_INSN_ERR) {
+		pr_cont("Illegal Insn\n");
+	} else {
+		pr_cont("Check Programmer's Manual\n");
+	}
+}
+
+/************************************************************************
+ *  API called by rest of kernel
+ ***********************************************************************/
 
 void show_regs(struct pt_regs *regs)
 {
+	struct task_struct *tsk = current;
+	struct callee_regs *cregs;
+	char *buf;
+
+	buf = (char *)__get_free_page(GFP_TEMPORARY);
+	if (!buf)
+		return;
+
+	print_task_path_n_nm(tsk, buf);
+
+	if (current->thread.cause_code)
+		show_ecr_verbose(regs);
+
+	pr_info("[EFA]: 0x%08lx\n", current->thread.fault_address);
+	pr_info("[ERET]: 0x%08lx (PC of Faulting Instr)\n", regs->ret);
+
+	show_faulting_vma(regs->ret, buf);	/* faulting code, not data */
+
+	/* can't use print_vma_addr() yet as it doesn't check for
+	 * non-inclusive vma
+	 */
+
+	/* print special regs */
+	pr_info("status32: 0x%08lx\n", regs->status32);
+	pr_info(" SP: 0x%08lx\tFP: 0x%08lx\n", regs->sp, regs->fp);
+	pr_info("BTA: 0x%08lx\tBLINK: 0x%08lx\n",
+		regs->bta, regs->blink);
+	pr_info("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
+	       regs->lp_start, regs->lp_end, regs->lp_count);
+
+	/* print regs->r0 thru regs->r12
+	 * Sequential printing was generating horrible code
+	 */
+	print_reg_file(&(regs->r0), 0);
+
+	/* If Callee regs were saved, display them too */
+	cregs = (struct callee_regs *)current->thread.callee_reg;
+	if (cregs)
+		show_callee_regs(cregs);
+
+	free_page((unsigned long)buf);
 }
 
 void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
 			    unsigned long address, unsigned long cause_reg)
 {
+	current->thread.fault_address = address;
+	current->thread.cause_code = cause_reg;
+
+	/* Caller and Callee regs */
+	show_regs(regs);
+
+	/* Show stack trace if this Fatality happened in kernel mode */
+	if (!user_mode(regs))
+		show_stacktrace(current, regs);
 }
+
+#ifdef CONFIG_DEBUG_FS
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/mount.h>
+#include <linux/pagemap.h>
+#include <linux/init.h>
+#include <linux/namei.h>
+#include <linux/debugfs.h>
+
+static struct dentry *test_dentry;
+static struct dentry *test_dir;
+static struct dentry *test_u32_dentry;
+
+static u32 clr_on_read = 1;
+
+#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
+u32 numitlb, numdtlb, num_pte_not_present;
+
+static int fill_display_data(char *kbuf)
+{
+	size_t num = 0;
+	num += sprintf(kbuf + num, "I-TLB Miss %x\n", numitlb);
+	num += sprintf(kbuf + num, "D-TLB Miss %x\n", numdtlb);
+	num += sprintf(kbuf + num, "PTE not present %x\n", num_pte_not_present);
+
+	if (clr_on_read)
+		numitlb = numdtlb = num_pte_not_present = 0;
+
+	return num;
+}
+
+static int tlb_stats_open(struct inode *inode, struct file *file)
+{
+	file->private_data = (void *)__get_free_page(GFP_KERNEL);
+	return 0;
+}
+
+/* called on user read(): display the couters */
+static ssize_t tlb_stats_output(struct file *file,	/* file descriptor */
+				char __user *user_buf,	/* user buffer */
+				size_t len,		/* length of buffer */
+				loff_t *offset)		/* offset in the file */
+{
+	size_t num;
+	char *kbuf = (char *)file->private_data;
+
+	/* All of the data can he shoved in one iteration */
+	if (*offset != 0)
+		return 0;
+
+	num = fill_display_data(kbuf);
+
+	/* simple_read_from_buffer() is helper for copy to user space
+	   It copies up to @2 (num) bytes from kernel buffer @4 (kbuf) at offset
+	   @3 (offset) into the user space address starting at @1 (user_buf).
+	   @5 (len) is max size of user buffer
+	 */
+	return simple_read_from_buffer(user_buf, num, offset, kbuf, len);
+}
+
+/* called on user write : clears the counters */
+static ssize_t tlb_stats_clear(struct file *file, const char __user *user_buf,
+			       size_t length, loff_t *offset)
+{
+	numitlb = numdtlb = num_pte_not_present = 0;
+	return length;
+}
+
+static int tlb_stats_close(struct inode *inode, struct file *file)
+{
+	free_page((unsigned long)(file->private_data));
+	return 0;
+}
+
+static const struct file_operations tlb_stats_file_ops = {
+	.read = tlb_stats_output,
+	.write = tlb_stats_clear,
+	.open = tlb_stats_open,
+	.release = tlb_stats_close
+};
+#endif
+
+static int __init arc_debugfs_init(void)
+{
+	test_dir = debugfs_create_dir("arc", NULL);
+
+#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
+	test_dentry = debugfs_create_file("tlb_stats", 0444, test_dir, NULL,
+					  &tlb_stats_file_ops);
+#endif
+
+	test_u32_dentry =
+	    debugfs_create_u32("clr_on_read", 0444, test_dir, &clr_on_read);
+
+	return 0;
+}
+
+module_init(arc_debugfs_init);
+
+static void __exit arc_debugfs_exit(void)
+{
+	debugfs_remove(test_u32_dentry);
+	debugfs_remove(test_dentry);
+	debugfs_remove(test_dir);
+}
+module_exit(arc_debugfs_exit);
+
+#endif
arch/arc/mm/tlbex.S +20 -0
index fc5b971..164b021 100644
@@ -133,6 +133,14 @@ ex_saved_reg1:
 	lsr     r0, r2, (PAGE_SHIFT - 2)
 	and     r0, r0, ( (PTRS_PER_PTE - 1) << 2)
 	ld.aw   r0, [r1, r0]            ; get PTE and PTE ptr for fault addr
+#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
+	and.f 0, r0, _PAGE_PRESENT
+	bz   1f
+	ld   r2, [num_pte_not_present]
+	add  r2, r2, 1
+	st   r2, [num_pte_not_present]
+1:
+#endif
 
 .endm
 
@@ -219,6 +227,12 @@ ARC_ENTRY EV_TLBMissI
 
 	TLBMISS_FREEUP_REGS
 
+#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
+	ld  r0, [@numitlb]
+	add r0, r0, 1
+	st  r0, [@numitlb]
+#endif
+
 	;----------------------------------------------------------------
 	; Get the PTE corresponding to V-addr accessed
 	LOAD_FAULT_PTE
@@ -252,6 +266,12 @@ ARC_ENTRY EV_TLBMissD
 
 	TLBMISS_FREEUP_REGS
 
+#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT
+	ld  r0, [@numdtlb]
+	add r0, r0, 1
+	st  r0, [@numdtlb]
+#endif
+
 	;----------------------------------------------------------------
 	; Get the PTE corresponding to V-addr accessed
 	; If PTE exists, it will setup, r0 = PTE, r1 = Ptr to PTE
Signature · 1 line
1.7.4.1
#88 lore raw

PATCH v2 50/76 ARC: SMP support

In reply to Vineet Gupta

ARC common code to enable a SMP system + ISS provided SMP extensions.

ARC700 natively lacks SMP support, hence some of the core features are are only enabled if SoCs have the necessary h/w pixie-dust. This includes:
-Inter Processor Interrupts (IPI)
-Cache coherency
-load-locked/store-conditional
...

The low level exception handling would be completely broken in SMP because we don't have hardware assisted stack switching. Thus a fair bit of this code is repurposing the MMU_SCRATCH reg for event handler prologues to keep them re-entrant.

Many thanks to Rajeshwar Range for his initial "major" contributions to SMP Port (back in 2008), and to Noam Camus and Gilad Ben-Yossef for help with resurrecting that in 3.2 kernel (2012).

Note that this platform code is again singleton design pattern - so multiple SMP platforms won't build at the moment - this deficiency is addressed in subsequent patches within this series.

Cc Arnd Bergmann <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Rajeshwar Ranga <[email protected]>
Cc Noam Camus <[email protected]>
Cc Gilad Ben-Yossef <[email protected]>
---
 arch/arc/Kconfig                         |   44 ++++-
 arch/arc/Makefile                        |    3 +
 arch/arc/include/asm/entry.h             |   49 +++++
 arch/arc/include/asm/mmu_context.h       |    4 +
 arch/arc/include/asm/mutex.h             |    9 +
 arch/arc/include/asm/pgtable.h           |    4 +
 arch/arc/include/asm/processor.h         |    8 +
 arch/arc/include/asm/smp.h               |  107 ++++++++++
 arch/arc/kernel/Makefile                 |    1 +
 arch/arc/kernel/ctx_sw.c                 |   11 +
 arch/arc/kernel/entry.S                  |    4 +
 arch/arc/kernel/head.S                   |   33 +++
 arch/arc/kernel/irq.c                    |    5 +
 arch/arc/kernel/setup.c                  |    4 +
 arch/arc/kernel/smp.c                    |  319 ++++++++++++++++++++++++++++++
 arch/arc/mm/tlb.c                        |    6 +
 arch/arc/mm/tlbex.S                      |   38 ++++
 arch/arc/plat-arcfpga/Kconfig            |   13 ++
 arch/arc/plat-arcfpga/Makefile           |    1 +
 arch/arc/plat-arcfpga/include/plat/irq.h |   10 +-
 arch/arc/plat-arcfpga/include/plat/smp.h |  115 +++++++++++
 arch/arc/plat-arcfpga/irq.c              |   10 +
 arch/arc/plat-arcfpga/smp.c              |  167 ++++++++++++++++
 23 files changed, 963 insertions(+), 2 deletions(-)
 create mode 100644 arch/arc/kernel/smp.c
 create mode 100644 arch/arc/plat-arcfpga/include/plat/smp.h
 create mode 100644 arch/arc/plat-arcfpga/smp.c
arch/arc/Kconfig +43 -1
index 20f3c4a..c8a7c09 100644
@@ -116,9 +116,47 @@ config CPU_BIG_ENDIAN
 	help
 	  Build kernel for Big Endian Mode of ARC CPU
 
+# If a plat can do IPI, same core(s) can do minimal SMP
+config ARC_HAS_IPI
+	bool
+
+config SMP
+	bool "Symmetric Multi-Processing (Incomplete)"
+	default y
+	depends on ARC_HAS_IPI
+	select USE_GENERIC_SMP_HELPERS
+	help
+	  This enables support for systems with more than one CPU. If you have
+	  a system with only one CPU, like most personal computers, say N. If
+	  you have a system with more than one CPU, say Y.
+
+if SMP
+
+config ARC_HAS_COH_CACHES
+	def_bool n
+
+config ARC_HAS_COH_LLSC
+	def_bool n
+
+config ARC_HAS_COH_RTSC
+	def_bool n
+
+config ARC_HAS_REENTRANT_IRQ_LV2
+	def_bool n
+
+endif
+
+config NR_CPUS
+	int "Maximum number of CPUs (2-32)"
+	range 2 32
+	depends on SMP
+	default "2"
+
 menuconfig ARC_CACHE
 	bool "Enable Cache Support"
 	default y
+	# if SMP, cache enabled ONLY if ARC implementation has cache coherency
+	depends on !SMP || ARC_HAS_COH_CACHES
 
 if ARC_CACHE
 
@@ -213,6 +251,8 @@ config ARC_COMPACT_IRQ_LEVELS
 	default n
 	# Timer HAS to be high priority, for any other high priority config
 	select ARC_IRQ3_LV2
+	# if SMP, LV2 enabled ONLY if ARC implementation has LV2 re-entrancy
+	depends on !SMP || ARC_HAS_REENTRANT_IRQ_LV2
 
 if ARC_COMPACT_IRQ_LEVELS
 
@@ -261,6 +301,8 @@ config ARC_HAS_RTSC
 	bool "Insn: RTSC (64-bit r/o cycle counter)"
 	default y
 	depends on ARC_CPU_REL_4_10
+	# if SMP, enable RTSC only if counter is coherent across cores
+	depends on !SMP || ARC_HAS_COH_RTSC
 
 endmenu   # "ARC CPU Configuration"
 
@@ -309,7 +351,7 @@ menuconfig ARC_DBG
 
 config ARC_DBG_TLB_PARANOIA
 	bool "Paranoia Checks in Low Level TLB Handlers"
-	depends on ARC_DBG
+	depends on ARC_DBG && !SMP
 	default n
 
 config ARC_DBG_TLB_MISS_COUNT
arch/arc/Makefile +3 -0
index ca4b58c..507e797 100644
@@ -133,3 +133,6 @@ archclean:
 # Thus forcing all exten calls in this file to be long calls
 export CFLAGS_decompress_inflate.o = -mmedium-calls
 export CFLAGS_initramfs.o = -mmedium-calls
+ifdef CONFIG_SMP
+export CFLAGS_core.o = -mmedium-calls
+endif
arch/arc/include/asm/entry.h +49 -0

79 lines not on this page · raw message

arch/arc/include/asm/mmu_context.h +4 -0
index d12f3de..0d71fb1 100644
@@ -147,8 +147,10 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
 			     struct task_struct *tsk)
 {
+#ifndef CONFIG_SMP
 	/* PGD cached in MMU reg to avoid 3 mem lookups: task->mm->pgd */
 	write_aux_reg(ARC_REG_SCRATCH_DATA0, next->pgd);
+#endif
 
 	/*
 	 * Get a new ASID if task doesn't have a valid one. Possible when
@@ -197,7 +199,9 @@ static inline void destroy_context(struct mm_struct *mm)
 
 static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
 {
+#ifndef CONFIG_SMP
 	write_aux_reg(ARC_REG_SCRATCH_DATA0, next->pgd);
+#endif
 
 	/* Unconditionally get a new ASID */
 	get_new_mmu_context(next);
arch/arc/include/asm/mutex.h +9 -0
index 3be5e64..a2f88ff 100644
@@ -6,4 +6,13 @@
  * published by the Free Software Foundation.
  */
 
+/*
+ * xchg() based mutex fast path maintains a state of 0 or 1, as opposed to
+ * atomic dec based which can "count" any number of lock contenders.
+ * This ideally needs to be fixed in core, but for now switching to dec ver.
+ */
+#if defined(CONFIG_SMP) && (CONFIG_NR_CPUS > 2)
+#include <asm-generic/mutex-dec.h>
+#else
 #include <asm-generic/mutex-xchg.h>
+#endif
arch/arc/include/asm/pgtable.h +4 -0
index dcb07015..b7e3668 100644
@@ -354,11 +354,15 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
  * Thus use this macro only when you are certain that "current" is current
  * e.g. when dealing with signal frame setup code etc
  */
+#ifndef CONFIG_SMP
 #define pgd_offset_fast(mm, addr)	\
 ({					\
 	pgd_t *pgd_base = (pgd_t *) read_aux_reg(ARC_REG_SCRATCH_DATA0);  \
 	pgd_base + pgd_index(addr);	\
 })
+#else
+#define pgd_offset_fast(mm, addr)	pgd_offset(mm, addr)
+#endif
 
 extern void paging_init(void);
 extern pgd_t swapper_pg_dir[] __aligned(PAGE_SIZE);
arch/arc/include/asm/processor.h +8 -0
index b7b1556..5f26b2c 100644
@@ -58,7 +58,15 @@ unsigned long thread_saved_pc(struct task_struct *t);
 /* Prepare to copy thread state - unlazy all lazy status */
 #define prepare_to_copy(tsk)    do { } while (0)
 
+/*
+ * A lot of busy-wait loops in SMP are based off of non-volatile data otherwise
+ * get optimised away by gcc
+ */
+#ifdef CONFIG_SMP
+#define cpu_relax()	__asm__ __volatile__ ("" : : : "memory")
+#else
 #define cpu_relax()	do { } while (0)
+#endif
 
 #define copy_segments(tsk, mm)      do { } while (0)
 #define release_segments(mm)        do { } while (0)
arch/arc/include/asm/smp.h +107 -0

129 lines not on this page · raw message

arch/arc/kernel/Makefile +1 -0
index b4b9ab6..65915dd 100644
@@ -13,6 +13,7 @@ obj-y	:= arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \
 
 obj-$(CONFIG_OF)			+= devtree.o
 obj-$(CONFIG_MODULES)			+= arcksyms.o module.o
+obj-$(CONFIG_SMP) 			+= smp.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/ctx_sw.c +11 -0
index fbf739c..60844da 100644
@@ -58,7 +58,18 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)
 		 * For SMP extra work to get to &_current_task[cpu]
 		 * (open coded SET_CURR_TASK_ON_CPU)
 		 */
+#ifndef CONFIG_SMP
 		"st  %2, [@_current_task]	\n\t"
+#else
+		"lr   r24, [identity]		\n\t"
+		"lsr  r24, r24, 8		\n\t"
+		"bmsk r24, r24, 7		\n\t"
+		"add2 r24, @_current_task, r24	\n\t"
+		"st   %2,  [r24]		\n\t"
+#endif
+#ifdef CONFIG_ARC_CURR_IN_REG
+		"mov r25, %2   \n\t"
+#endif
 
 		/* get ksp of incoming task from tsk->thread.ksp */
 		"ld.as  sp, [%2, %1]   \n\t"
arch/arc/kernel/entry.S +4 -0
index 36172a4..c7b6002 100644
@@ -237,7 +237,11 @@ ARC_EXIT handle_interrupt_level2
 ARC_ENTRY handle_interrupt_level1
 
 	/* free up r9 as scratchpad */
+#ifdef CONFIG_SMP
+	sr  r9, [ARC_REG_SCRATCH_DATA0]
+#else
 	st   r9, [@int1_saved_reg]
+#endif
 
 	;Which mode (user/kernel) was the system in when intr occured
 	lr  r9, [status32_l1]
arch/arc/kernel/head.S +33 -0
index e63f6a4..006dec3 100644
@@ -27,6 +27,15 @@ stext:
 	; Don't clobber r0-r4 yet. It might have bootloader provided info
 	;-------------------------------------------------------------------
 
+#ifdef CONFIG_SMP
+	; Only Boot (Master) proceeds. Others wait in platform dependent way
+	;	IDENTITY Reg [ 3  2  1  0 ]
+	;	(cpu-id)             ^^^	=> Zero for UP ARC700
+	;					=> #Core-ID if SMP (Master 0)
+	GET_CPU_ID  r5
+	cmp	r5, 0
+	jnz	arc_platform_smp_wait_to_boot
+#endif
 	; Clear BSS before updating any globals
 	; XXX: use ZOL here
 	mov	r5, __bss_start
@@ -76,3 +85,27 @@ stext:
 	GET_TSK_STACK_BASE r9, sp	; r9 = tsk, sp = stack base(output)
 
 	j	start_kernel	; "C" entry point
+
+#ifdef CONFIG_SMP
+;----------------------------------------------------------------
+;     First lines of code run by secondary before jumping to 'C'
+;----------------------------------------------------------------
+	.section .init.text, "ax",@progbits
+	.type first_lines_of_secondary, @function
+	.globl first_lines_of_secondary
+
+first_lines_of_secondary:
+
+	; setup per-cpu idle task as "current" on this CPU
+	ld	r0, [@secondary_idle_tsk]
+	SET_CURR_TASK_ON_CPU  r0, r1
+
+	; setup stack (fp, sp)
+	mov	fp, 0
+
+	; set it's stack base to tsk->thread_info bottom
+	GET_TSK_STACK_BASE r0, sp
+
+	j	start_kernel_secondary
+
+#endif
arch/arc/kernel/irq.c +5 -0
index ca70894..df7da2b 100644
@@ -124,6 +124,11 @@ void __init init_IRQ(void)
 {
 	init_onchip_IRQ();
 	plat_init_IRQ();
+
+#ifdef CONFIG_SMP
+	/* Master CPU can initialize it's side of IPI */
+	arc_platform_smp_init_cpu();
+#endif
 }
 
 /*
arch/arc/kernel/setup.c +4 -0
index 27aebd6..4026b5a 100644
@@ -86,6 +86,10 @@ void __init setup_arch(char **cmdline_p)
 
 	setup_processor();
 
+#ifdef CONFIG_SMP
+	smp_init_cpus();
+#endif
+
 	setup_arch_memory();
 
 	unflatten_device_tree();
arch/arc/kernel/smp.c new file +319 -0

319 lines not on this page · raw message

arch/arc/mm/tlb.c +6 -0
index 232a0ff..e96030c 100644
@@ -474,6 +474,12 @@ void __init arc_mmu_init(void)
 
 	/* Enable the MMU */
 	write_aux_reg(ARC_REG_PID, MMU_ENABLE);
+
+	/* In smp we use this reg for interrupt 1 scratch */
+#ifndef CONFIG_SMP
+	/* swapper_pg_dir is the pgd for the kernel, used by vmalloc */
+	write_aux_reg(ARC_REG_SCRATCH_DATA0, swapper_pg_dir);
+#endif
 }
 
 /*
arch/arc/mm/tlbex.S +38 -0
index 164b021..4b1ad2d 100644
@@ -57,9 +57,15 @@
 	.global ex_saved_reg1
 	.align 1 << L1_CACHE_SHIFT	; IMP: Must be Cache Line aligned
 	.type   ex_saved_reg1, @object
+#ifdef CONFIG_SMP
+	.size   ex_saved_reg1, (CONFIG_NR_CPUS << L1_CACHE_SHIFT)
+ex_saved_reg1:
+	.zero (CONFIG_NR_CPUS << L1_CACHE_SHIFT)
+#else
 	.size   ex_saved_reg1, 16
 ex_saved_reg1:
 	.zero 16
+#endif
 
 ;============================================================================
 ;  Troubleshooting Stuff
@@ -116,7 +122,13 @@ ex_saved_reg1:
 
 	lr  r2, [efa]
 
+#ifndef CONFIG_SMP
 	lr  r1, [ARC_REG_SCRATCH_DATA0] ; current pgd
+#else
+	GET_CURR_TASK_ON_CPU  r1
+	ld  r1, [r1, TASK_ACT_MM]
+	ld  r1, [r1, MM_PGD]
+#endif
 
 	lsr     r0, r2, PGDIR_SHIFT     ; Bits for indexing into PGD
 	ld.as   r1, [r1, r0]            ; PGD entry corresp to faulting addr
@@ -192,12 +204,28 @@ ex_saved_reg1:
 ;	".size   ex_saved_reg1, 16"
 ; [All of this dance is to avoid stack switching for each TLB Miss, since we
 ; only need to save only a handful of regs, as opposed to complete reg file]
+;
+; For ARC700 SMP, the "global" obviously can't be used for free up the FIRST
+; core reg as it will not be SMP safe.
+; Thus scratch AUX reg is used (and no longer used to cache task PGD).
+; To save the rest of 3 regs - per cpu, the global is made "per-cpu".
+; Epilogue thus has to locate the "per-cpu" storage for regs.
+; To avoid cache line bouncing the per-cpu global is aligned/sized per
+; L1_CACHE_SHIFT, despite fundamentally needing to be 12 bytes only. Hence
+;	".size   ex_saved_reg1, (CONFIG_NR_CPUS << L1_CACHE_SHIFT)"
 
 ; As simple as that....
 
 .macro TLBMISS_FREEUP_REGS
+#ifdef CONFIG_SMP
+	sr  r0, [ARC_REG_SCRATCH_DATA0]	; freeup r0 to code with
+	GET_CPU_ID  r0			; get to per cpu scratch mem,
+	lsl r0, r0, L1_CACHE_SHIFT	; cache line wide per cpu
+	add r0, @ex_saved_reg1, r0
+#else
 	st    r0, [@ex_saved_reg1]
 	mov_s r0, @ex_saved_reg1
+#endif
 	st_s  r1, [r0, 4]
 	st_s  r2, [r0, 8]
 	st_s  r3, [r0, 12]
@@ -210,11 +238,21 @@ ex_saved_reg1:
 
 ;-----------------------------------------------------------------
 .macro TLBMISS_RESTORE_REGS
+#ifdef CONFIG_SMP
+	GET_CPU_ID  r0			; get to per cpu scratch mem
+	lsl r0, r0, L1_CACHE_SHIFT	; each is cache line wide
+	add r0, @ex_saved_reg1, r0
+	ld_s  r3, [r0,12]
+	ld_s  r2, [r0, 8]
+	ld_s  r1, [r0, 4]
+	lr    r0, [ARC_REG_SCRATCH_DATA0]
+#else
 	mov_s r0, @ex_saved_reg1
 	ld_s  r3, [r0,12]
 	ld_s  r2, [r0, 8]
 	ld_s  r1, [r0, 4]
 	ld_s  r0, [r0]
+#endif
 .endm
 
 .section .text, "ax",@progbits	;Fast Path Code, candidate for ICCM
arch/arc/plat-arcfpga/Kconfig +13 -0
index 3b41a0e..8a1334c 100644
@@ -21,6 +21,19 @@ config ARC_BOARD_ML509
 	help
 	  ARC ML509 FPGA Ref Platform (Xilinx Virtex-5 Based)
 
+config ISS_SMP_EXTN
+	bool "ARC SMP Extensions (ISS Models only)"
+	default n
+	select ARC_HAS_IPI
+	select ARC_HAS_COH_RTSC
+	help
+	  SMP Extensions to ARC700, in a "simulation only" Model, supported in
+	  ARC ISS (Instruction Set Simulator).
+	  The SMP extensions include:
+	  -IDU (Interrupt Distribution Unit)
+	  -XTL (To enable CPU start/stop/set-PC for another CPU)
+	  It doesn't provide coherent Caches and/or Atomic Ops (LLOCK/SCOND)
+
 endchoice
 
 config ARC_SERIAL_BAUD
arch/arc/plat-arcfpga/Makefile +1 -0
index 385eb9d..2a828be 100644
@@ -7,3 +7,4 @@
 #
 
 obj-y := platform.o irq.o
+obj-$(CONFIG_SMP)		+= smp.o
arch/arc/plat-arcfpga/include/plat/irq.h +9 -1
index b34e087..255b90e 100644
@@ -12,7 +12,11 @@
 #ifndef __PLAT_IRQ_H
 #define __PLAT_IRQ_H
 
-#define NR_IRQS		16
+#ifdef CONFIG_SMP
+#define NR_IRQS 32
+#else
+#define NR_IRQS 16
+#endif
 
 #define UART0_IRQ	5
 #define UART1_IRQ	10
@@ -24,4 +28,8 @@
 #define PCI_IRQ		14
 #define PS2_IRQ		15
 
+#ifdef CONFIG_SMP
+#define IDU_INTERRUPT_0 16
+#endif
+
 #endif
arch/arc/plat-arcfpga/include/plat/smp.h new file +115 -0

115 lines not on this page · raw message

arch/arc/plat-arcfpga/irq.c +10 -0
index ed72636..590edd1 100644
@@ -9,7 +9,17 @@
  */
 
 #include <linux/interrupt.h>
+#include <asm/irq.h>
 
 void __init plat_init_IRQ(void)
 {
+	/*
+	 * SMP Hack because UART IRQ hardwired to cpu0 (boot-cpu) but if the
+	 * request_irq() comes from any other CPU, the low level IRQ unamsking
+	 * essential for getting Interrupts won't be enabled on cpu0, locking
+	 * up the UART state machine.
+	 */
+#ifdef CONFIG_SMP
+	arch_unmask_irq(UART0_IRQ);
+#endif
 }
arch/arc/plat-arcfpga/smp.c new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer
#89 lore raw

Re: [PATCH v2 50/76] ARC: SMP support

arch/arc/Kconfig config CPU_BIG_ENDIAN · line 122

Quoted 4 lines · Vineet Gupta
arch/arc/Kconfig +4 -0
+# If a plat can do IPI, same core(s) can do minimal SMP
+config ARC_HAS_IPI
+       bool
+

I think it would be better to turn the logic around here, otherwise you get into trouble when enabling multiple platforms, out of which some have IPI support and others don't.

Instead, you can mark the platforms that lack IPI support (or multiple CPUs) as 'depends on !SMP'.

Arnd

#90 lore raw

Re: [PATCH v2 50/76] ARC: SMP support

Quoted 10 lines · Arnd Bergmann

Review

Quoted 4 lines · Vineet Gupta
(quoted diff) +4 -0
+# If a plat can do IPI, same core(s) can do minimal SMP
+config ARC_HAS_IPI
+       bool
+

I think it would be better to turn the logic around here, otherwise you get into trouble when enabling multiple platforms, out of which some have IPI support and others don't.

Quoted 2 lines

Instead, you can mark the platforms that lack IPI support (or multiple CPUs) as 'depends on !SMP'.

Or slightly different way - something like below:

The only issue is platform specific SMP extensions - instead of helping enable CONFIG_SMP are now dependent on it (so hidden if SMP is not enabled at top level)
- but given that CONFIG_SMP is the only common denominator across platforms, that's how it will work in multi-platform-img paradigm.

arch/arc/Kconfig +0 -5
index 6729480..ab854af 100644
@@ -126,14 +126,9 @@ config CPU_BIG_ENDIAN
 config ARC_PLAT_NEEDS_CPU_TO_DMA
        bool
 
-# If a plat can do IPI, same core(s) can do minimal SMP
-config ARC_HAS_IPI
-       bool
-
 config SMP
        bool "Symmetric Multi-Processing (Incomplete)"
        default y
-       depends on ARC_HAS_IPI
        select USE_GENERIC_SMP_HELPERS
        help
          This enables support for systems with more than one CPU. If you have
arch/arc/plat-arcfpga/Kconfig +2 -2
index 6001784..526cdfe 100644
@@ -8,6 +8,7 @@
 
 menuconfig ARC_PLAT_FPGA_LEGACY
        bool "\"Legacy\" ARC FPGA dev Boards"
+       select ISS_SMP_EXTN if SMP
        help
          Support for ARC development boards, provided by Synopsys.
          These are based on FPGA or ISS. e.g.
@@ -30,8 +31,7 @@ config ARC_BOARD_ML509
 
 config ISS_SMP_EXTN
        bool "ARC SMP Extensions (ISS Models only)"
-       default n
-       select ARC_HAS_IPI
+       depends on SMP
        select ARC_HAS_COH_RTSC
        help
          SMP Extensions to ARC700, in a "simulation only" Model, supported in
#91 lore raw

PATCH v2 51/76 ARC: DWARF2 .debug_frame based stack unwinder

In reply to Vineet Gupta

-Originally contributed by Rajeshwar Range <rajeshwar.ranga> -Derived off of generic unwinder in 2.6.19 and adapted to ARC

Cc Rajeshwar Range <rajeshwar.ranga>
---
 arch/arc/Kconfig              |   15 +
 arch/arc/include/asm/module.h |    7 +
 arch/arc/include/asm/unwind.h |  163 +++++
 arch/arc/kernel/Makefile      |    6 +
 arch/arc/kernel/entry.S       |    9 +
 arch/arc/kernel/module.c      |   42 ++
 arch/arc/kernel/setup.c       |    3 +
 arch/arc/kernel/unwind.c      | 1329 +++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/vmlinux.lds.S |   23 +-
 9 files changed, 1596 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/unwind.h
 create mode 100644 arch/arc/kernel/unwind.c
arch/arc/Kconfig +15 -0
index c8a7c09..cd99825 100644
@@ -25,6 +25,7 @@ config ARC
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
+	select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND
 	select HAVE_OPROFILE
 	select HOTPLUG if !INITRAMFS_SOURCE=""
 	select IRQ_DOMAIN
@@ -349,6 +350,20 @@ menuconfig ARC_DBG
 	bool "ARC debugging"
 	default y
 
+config ARC_DW2_UNWIND
+	bool "Enable DWARF specific kernel stack unwind"
+	depends on ARC_DBG
+	default y
+	select KALLSYMS
+	help
+	  Compiles the kernel with DWARF unwind information and can be used
+	  to get stack backtraces.
+
+	  If you say Y here the resulting kernel image will be slightly larger
+	  but not slower, and it will give very useful debugging information.
+	  If you don't debug the kernel, you can say N, but we may not be able
+	  to solve problems without frame unwind information
+
 config ARC_DBG_TLB_PARANOIA
 	bool "Paranoia Checks in Low Level TLB Handlers"
 	depends on ARC_DBG && !SMP
arch/arc/include/asm/module.h +7 -0
index 234b435..518222b 100644
@@ -14,6 +14,13 @@
 
 #include <asm-generic/module.h>
 
+#ifdef CONFIG_ARC_DW2_UNWIND
+struct mod_arch_specific {
+	void *unw_info;
+	int unw_sec_idx;
+};
+#endif
+
 #define MODULE_PROC_FAMILY "ARC700"
 
 #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
arch/arc/include/asm/unwind.h new file +163 -0

163 lines not on this page · raw message

arch/arc/kernel/Makefile +6 -0
index 65915dd..30a5f7e 100644
@@ -14,10 +14,16 @@ obj-y	:= arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \
 obj-$(CONFIG_OF)			+= devtree.o
 obj-$(CONFIG_MODULES)			+= arcksyms.o module.o
 obj-$(CONFIG_SMP) 			+= smp.o
+obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
 
+ifdef CONFIG_ARC_DW2_UNWIND
+CFLAGS_ctx_sw.o += -fno-omit-frame-pointer
+obj-y += ctx_sw.o
+else
 obj-y += ctx_sw_asm.o
+endif
 
 extra-y := vmlinux.lds head.o
arch/arc/kernel/entry.S +9 -0
index c7b6002..7e392d4 100644
@@ -820,3 +820,12 @@ ARC_ENTRY sys_clone_wrapper
 
 	b ret_from_system_call
 ARC_EXIT sys_clone_wrapper
+
+#ifdef CONFIG_ARC_DW2_UNWIND
+; Workaround for bug 94179 (STAR ):
+; Despite -fasynchronous-unwind-tables, linker is not making dwarf2 unwinder
+; section (.debug_frame) as loadable. So we force it here.
+; This also fixes STAR 9000487933 where the prev-workaround (objcopy --setflag)
+; would not work after a clean build due to kernel build system dependencies.
+.section .debug_frame, "wa",@progbits
+#endif
arch/arc/kernel/module.c +42 -0

70 lines not on this page · raw message

arch/arc/kernel/setup.c +3 -0
index 4026b5a..6e3996c 100644
@@ -23,6 +23,7 @@
 #include <asm/irq.h>
 #include <asm/arcregs.h>
 #include <asm/prom.h>
+#include <asm/unwind.h>
 
 #define FIX_PTR(x)  __asm__ __volatile__(";" : "+r"(x))
 
@@ -105,6 +106,8 @@ void __init setup_arch(char **cmdline_p)
 	conswitchp = &dummy_con;
 #endif
 
+	arc_unwind_init();
+	arc_unwind_setup();
 }
 
 /*
arch/arc/kernel/unwind.c new file +1329 -0

1,329 lines not on this page · raw message

arch/arc/kernel/vmlinux.lds.S +22 -1
index 67c35bd..56c074e 100644
@@ -101,17 +101,38 @@ SECTIONS
 
 	BSS_SECTION(0, 0, 0)
 
+#ifdef CONFIG_ARC_DW2_UNWIND
+	. = ALIGN(PAGE_SIZE);
+	.debug_frame  : {
+		__start_unwind = .;
+		*(.debug_frame)
+		__end_unwind = .;
+	}
+#else
+	/DISCARD/ : {	*(.debug_frame) }
+#endif
+
 	NOTES
 
 	. = ALIGN(PAGE_SIZE);
 	_end = . ;
 
 	STABS_DEBUG
-	DWARF_DEBUG
 	DISCARDS
 
 	.arcextmap 0 : {
 		*(.gnu.linkonce.arcextmap.*)
 		*(.arcextmap.*)
 	}
+
+	/* open-coded because we need .debug_frame seperately for unwinding */
+	.debug_aranges 0 : { *(.debug_aranges) }
+	.debug_pubnames 0 : { *(.debug_pubnames) }
+	.debug_info 0 : { *(.debug_info) }
+	.debug_abbrev 0 : { *(.debug_abbrev) }
+	.debug_line 0 : { *(.debug_line) }
+	.debug_str 0 : { *(.debug_str) }
+	.debug_loc 0 : { *(.debug_loc) }
+	.debug_macinfo 0 : { *(.debug_macinfo) }
+
 }
Signature · 1 line
1.7.4.1
#92 lore raw

PATCH v2 52/76 ARC: stacktracing APIs based on dw2 unwinder

In reply to Vineet Gupta
---
 arch/arc/Kconfig             |    4 +
 arch/arc/kernel/stacktrace.c |  215 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 217 insertions(+), 2 deletions(-)
arch/arc/Kconfig +4 -0
index cd99825..86fc0c9 100644
@@ -60,6 +60,10 @@ config GENERIC_HWEIGHT
 config BINFMT_ELF
 	def_bool y
 
+config STACKTRACE_SUPPORT
+	def_bool y
+	select STACKTRACE
+
 config HAVE_LATENCYTOP_SUPPORT
 	def_bool y
 
arch/arc/kernel/stacktrace.c +213 -2

238 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#93 lore raw

PATCH v2 53/76 ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul)

In reply to Vineet Gupta

In-kernel disassembler

Due Credits
* Orig written by Rajeshwar Ranga <[email protected]>
* Consolidation/cleanups by Mischa Jonker <[email protected]>

Cc Rajeshwar Ranga <[email protected]>
Cc Mischa Jonker <[email protected]>
---
 arch/arc/include/asm/disasm.h |  116 +++++++++
 arch/arc/kernel/Makefile      |    2 +-
 arch/arc/kernel/disasm.c      |  539 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 656 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/disasm.h
 create mode 100644 arch/arc/kernel/disasm.c
arch/arc/include/asm/disasm.h new file +116 -0
new file mode 100644
index 0000000..f1cce3d
@@ -0,0 +1,116 @@
+/*
+ * several functions that help interpret ARC instructions
+ * used for unaligned accesses, kprobes and kgdb
+ *
+ * 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_DISASM_H__
+#define __ARC_DISASM_H__
+
+enum {
+	op_Bcc = 0, op_BLcc = 1, op_LD = 2, op_ST = 3, op_MAJOR_4 = 4,
+	op_MAJOR_5 = 5, op_LD_ADD = 12, op_ADD_SUB_SHIFT = 13,
+	op_ADD_MOV_CMP = 14, op_S = 15, op_LD_S = 16, op_LDB_S = 17,
+	op_LDW_S = 18, op_LDWX_S = 19, op_ST_S = 20, op_STB_S = 21,
+	op_STW_S = 22, op_Su5 = 23, op_SP = 24, op_GP = 25,
+	op_Pcl = 26, op_MOV_S = 27, op_ADD_CMP = 28, op_BR_S = 29,
+	op_B_S = 30, op_BL_S = 31
+};
+
+enum flow {
+	noflow,
+	direct_jump,
+	direct_call,
+	indirect_jump,
+	indirect_call,
+	invalid_instr
+};
+
+#define IS_BIT(word, n)		((word) & (1<<n))
+#define BITS(word, s, e)	(((word) >> (s)) & (~((-2) << ((e) - (s)))))
+
+#define MAJOR_OPCODE(word)	(BITS((word), 27, 31))
+#define MINOR_OPCODE(word)	(BITS((word), 16, 21))
+#define FIELD_A(word)		(BITS((word), 0, 5))
+#define FIELD_B(word)		((BITS((word), 12, 14)<<3) | \
+				(BITS((word), 24, 26)))
+#define FIELD_C(word)		(BITS((word), 6, 11))
+#define FIELD_u6(word)		FIELDC(word)
+#define FIELD_s12(word)		sign_extend(((BITS((word), 0, 5) << 6) | \
+					BITS((word), 6, 11)), 12)
+
+/* note that for BL/BRcc these two macro's need another AND statement to mask
+ * out bit 1 (make the result a multiple of 4) */
+#define FIELD_s9(word)		sign_extend(((BITS(word, 15, 15) << 8) | \
+					BITS(word, 16, 23)), 9)
+#define FIELD_s21(word)		sign_extend(((BITS(word, 6, 15) << 11) | \
+					(BITS(word, 17, 26) << 1)), 12)
+#define FIELD_s25(word)		sign_extend(((BITS(word, 0, 3) << 21) | \
+					(BITS(word, 6, 15) << 11) | \
+					(BITS(word, 17, 26) << 1)), 12)
+
+/* note: these operate on 16 bits! */
+#define FIELD_S_A(word)		((BITS((word), 2, 2)<<3) | BITS((word), 0, 2))
+#define FIELD_S_B(word)		((BITS((word), 10, 10)<<3) | \
+				BITS((word), 8, 10))
+#define FIELD_S_C(word)		((BITS((word), 7, 7)<<3) | BITS((word), 5, 7))
+#define FIELD_S_H(word)		((BITS((word), 0, 2)<<3) | BITS((word), 5, 8))
+#define FIELD_S_u5(word)	(BITS((word), 0, 4))
+#define FIELD_S_u6(word)	(BITS((word), 0, 4) << 1)
+#define FIELD_S_u7(word)	(BITS((word), 0, 4) << 2)
+#define FIELD_S_u10(word)	(BITS((word), 0, 7) << 2)
+#define FIELD_S_s7(word)	sign_extend(BITS((word), 0, 5) << 1, 9)
+#define FIELD_S_s8(word)	sign_extend(BITS((word), 0, 7) << 1, 9)
+#define FIELD_S_s9(word)	sign_extend(BITS((word), 0, 8), 9)
+#define FIELD_S_s10(word)	sign_extend(BITS((word), 0, 8) << 1, 10)
+#define FIELD_S_s11(word)	sign_extend(BITS((word), 0, 8) << 2, 11)
+#define FIELD_S_s13(word)	sign_extend(BITS((word), 0, 10) << 2, 13)
+
+#define STATUS32_L		0x00000100
+#define REG_LIMM		62
+
+struct disasm_state {
+	/* generic info */
+	unsigned long words[2];
+	int instr_len;
+	int major_opcode;
+	/* info for branch/jump */
+	int is_branch;
+	int target;
+	int delay_slot;
+	enum flow flow;
+	/* info for load/store */
+	int src1, src2, src3, dest, wb_reg;
+	int zz, aa, x, pref, di;
+	int fault, write;
+};
+
+static inline int sign_extend(int value, int bits)
+{
+	if (IS_BIT(value, (bits - 1)))
+		value |= (0xffffffff << bits);
+
+	return value;
+}
+
+static inline int is_short_instr(unsigned long addr)
+{
+	uint16_t word = *((uint16_t *)addr);
+	int opcode = (word >> 11) & 0x1F;
+	return (opcode >= 0x0B);
+}
+
+void disasm_instr(unsigned long addr, struct disasm_state *state,
+	int userspace, struct pt_regs *regs, struct callee_regs *cregs);
+int disasm_next_pc(unsigned long pc, struct pt_regs *regs, struct callee_regs
+	*cregs, unsigned long *fall_thru, unsigned long *target);
+long get_reg(int reg, struct pt_regs *regs, struct callee_regs *cregs);
+void set_reg(int reg, long val, struct pt_regs *regs,
+		struct callee_regs *cregs);
+
+#endif	/* __ARC_DISASM_H__ */
arch/arc/kernel/Makefile +1 -1
index 30a5f7e..899642b 100644
@@ -9,7 +9,7 @@
 CFLAGS_ptrace.o		+= -DUTS_MACHINE='"$(UTS_MACHINE)"'
 
 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 clk.o
+	   signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o
 
 obj-$(CONFIG_OF)			+= devtree.o
 obj-$(CONFIG_MODULES)			+= arcksyms.o module.o
arch/arc/kernel/disasm.c new file +539 -0

539 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#94 lore raw

PATCH v2 54/76 ARC: kprobes support

In reply to Vineet Gupta

Origin port done by Rajeshwar Ranga <[email protected]>

---
 arch/arc/Kconfig               |    2 +
 arch/arc/include/asm/kprobes.h |   62 +++++
 arch/arc/kernel/Makefile       |    1 +
 arch/arc/kernel/disasm.c       |    5 +-
 arch/arc/kernel/kprobes.c      |  525 ++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/traps.c        |   13 +
 6 files changed, 605 insertions(+), 3 deletions(-)
 create mode 100644 arch/arc/include/asm/kprobes.h
 create mode 100644 arch/arc/kernel/kprobes.c
arch/arc/Kconfig +2 -0
index 86fc0c9..c34f3c3 100644
@@ -25,6 +25,8 @@ config ARC
 	select GENERIC_SMP_IDLE_THREAD
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
+	select HAVE_KPROBES
+	select HAVE_KRETPROBES
 	select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND
 	select HAVE_OPROFILE
 	select HOTPLUG if !INITRAMFS_SOURCE=""
arch/arc/include/asm/kprobes.h new file +62 -0

62 lines not on this page · raw message

arch/arc/kernel/Makefile +1 -0
index 899642b..f11318f 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_OF)			+= devtree.o
 obj-$(CONFIG_MODULES)			+= arcksyms.o module.o
 obj-$(CONFIG_SMP) 			+= smp.o
 obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
+obj-$(CONFIG_KPROBES)      		+= kprobes.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/disasm.c +2 -3
index 254d11a..51bad8f 100644
@@ -497,9 +497,8 @@ void __kprobes set_reg(int reg, long val, struct pt_regs *regs,
  * @pc +2/4/6 (ARCompact ISA allows free intermixing of 16/32 bit insns).
  *
  * If @pc is a branch
- * 	-@tgt_if_br is set to branch target.
- * 	-If branch has delay slot, @next_pc updated with actual next PC.
- *
+ *	-@tgt_if_br is set to branch target.
+ *	-If branch has delay slot, @next_pc updated with actual next PC.
  */
 int __kprobes disasm_next_pc(unsigned long pc, struct pt_regs *regs,
 			     struct callee_regs *cregs,
arch/arc/kernel/kprobes.c new file +525 -0

525 lines not on this page · raw message

arch/arc/kernel/traps.c +13 -0
index fd2457c..c6396b4 100644
@@ -15,6 +15,7 @@
 #include <linux/uaccess.h>
 #include <asm/ptrace.h>
 #include <asm/setup.h>
+#include <asm/kprobes.h>
 
 void __init trap_init(void)
 {
@@ -90,6 +91,7 @@ void do_machine_check_fault(unsigned long cause, unsigned long address,
 	die("Machine Check Exception", regs, address, cause);
 }
 
+
 /*
  * Entry point for traps induced by ARCompact TRAP_S <n> insn
  * This is same family as TRAP0/SWI insn (use the same vector).
@@ -109,6 +111,10 @@ void do_non_swi_trap(unsigned long cause, unsigned long address,
 		trap_is_brkpt(cause, address, regs);
 		break;
 
+	case 2:
+		trap_is_kprobe(param, address, regs);
+		break;
+
 	default:
 		break;
 	}
@@ -116,10 +122,17 @@ void do_non_swi_trap(unsigned long cause, unsigned long address,
 
 /*
  * Entry point for Instruction Error Exception
+ *  -For a corner case, ARC kprobes implementation resorts to using
+ *   this exception, hence the check
  */
 void do_insterror_or_kprobe(unsigned long cause,
 				       unsigned long address,
 				       struct pt_regs *regs)
 {
+	/* Check if this exception is caused by kprobes */
+	if (notify_die(DIE_IERR, "kprobe_ierr", regs, address,
+		       cause, SIGILL) == NOTIFY_STOP)
+		return;
+
 	insterror_is_error(cause, address, regs);
 }
Signature · 1 line
1.7.4.1
#95 lore raw

PATCH v2 55/76 sysctl: Enable PARISC "unaligned-trap" to be used cross-arch

In reply to Vineet Gupta

PARISC defines /proc/sys/kernel/unaligned-trap to runtime toggle unaligned access emulation.

The exact mechanics of enablig/disabling are still arch specific, we can make the sysctl usable by other arches.

Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc Serge Hallyn <[email protected]>
---
 arch/parisc/Kconfig |    1 +
 init/Kconfig        |    8 ++++++++
 kernel/sysctl.c     |    7 ++++++-
 3 files changed, 15 insertions(+), 1 deletions(-)
arch/parisc/Kconfig +1 -0
index b77feff..8c76095 100644
@@ -20,6 +20,7 @@ config PARISC
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_STRNCPY_FROM_USER
+	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
 	select CLONE_BACKWARDS
init/Kconfig +8 -0
index a733964..325df23 100644
@@ -1240,6 +1240,14 @@ config SYSCTL_ARCH_UNALIGN_NO_WARN
 	  unaligned access emulation going on under the hood.
 	  see arch/ia64/kernel/unaligned.c for reference
 
+config SYSCTL_ARCH_UNALIGN_ALLOW
+	bool
+	help
+	  Enable support for /proc/sys/kernel/unaligned-trap
+	  Allows arches to define/use @unaligned_enabled to runtime toggle
+	  the unaligned access emulation.
+	  see arch/parisc/kernel/unaligned.c for reference
+
 config KALLSYMS
 	 bool "Load all symbols for debugging/ksymoops" if EXPERT
 	 default y
kernel/sysctl.c +6 -1
index 840fd5e..c4cd655 100644
@@ -157,13 +157,16 @@ extern int sysctl_tsb_ratio;
 
 #ifdef __hppa__
 extern int pwrsw_enabled;
-extern int unaligned_enabled;
 #endif
 
 #ifdef CONFIG_IA64
 extern int unaligned_dump_stack;
 #endif
 
+#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
+extern int unaligned_enabled;
+#endif
+
 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
 extern int no_unaligned_warning;
 #endif
@@ -548,6 +551,8 @@ static struct ctl_table kern_table[] = {
 	 	.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+#endif
+#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
 	{
 		.procname	= "unaligned-trap",
 		.data		= &unaligned_enabled,
Signature · 1 line
1.7.4.1
#96 lore raw

PATCH v2 56/76 ARC: Unaligned access emulation

In reply to Vineet Gupta

ARC700 doesn't natively support unaligned access, but can be emulated -Unaligned Access Exception
-Disassembly at the Fault address to find the exact insn (long/short)

Also per Arnd's comment, we runtime control it using 2 sysctl knobs:
* SYSCTL_ARCH_UNALIGN_ALLOW: Runtime enable/disble
* SYSCTL_ARCH_UNALIGN_NO_WARN: Warn on each emulation attempt

Originally contributed by Tim Yao <[email protected]>

---
 arch/arc/Kconfig                 |   11 ++
 arch/arc/include/asm/Kbuild      |    1 -
 arch/arc/include/asm/ptrace.h    |    3 +
 arch/arc/include/asm/unaligned.h |   29 +++++
 arch/arc/kernel/Makefile         |    1 +
 arch/arc/kernel/disasm.c         |    2 +-
 arch/arc/kernel/entry.S          |   13 ++
 arch/arc/kernel/traps.c          |   26 ++++
 arch/arc/kernel/unaligned.c      |  245 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 329 insertions(+), 2 deletions(-)
 create mode 100644 arch/arc/include/asm/unaligned.h
 create mode 100644 arch/arc/kernel/unaligned.c
arch/arc/Kconfig +11 -0
index c34f3c3..d735de8 100644
@@ -341,6 +341,17 @@ config ARC_CURR_IN_REG
 	  This reserved Register R25 to point to Current Task in
 	  kernel mode. This saves memory access for each such access
 
+
+config ARC_MISALIGN_ACCESS
+	bool "Emulate unaligned memory access (userspace only)"
+	default N
+	select SYSCTL_ARCH_UNALIGN_NO_WARN
+	select SYSCTL_ARCH_UNALIGN_ALLOW
+	help
+	  This enables misaligned 16 & 32 bit memory access from user space.
+	  Use ONLY-IF-ABS-NECESSARY as it will be very slow and also can hide
+	  potential bugs in code
+
 config ARC_STACK_NONEXEC
 	bool "Make stack non-executable"
 	default n
arch/arc/include/asm/Kbuild +0 -1
index 78e982d..b24089c 100644
@@ -52,7 +52,6 @@ generic-y += topology.h
 generic-y += trace_clock.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/ptrace.h +3 -0
index e4e1ac6..fd68c4b 100644
@@ -127,6 +127,9 @@ struct user_regs_struct {
 	sp;			\
 })
 
+/* return 1 if PC in delay slot */
+#define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
+
 #define in_syscall(regs) (regs->orig_r8 & orig_r8_IS_SCALL)
 #define in_brkpt_trap(regs) (regs->orig_r8 & orig_r8_IS_BRKPT)
 
arch/arc/include/asm/unaligned.h new file +29 -0
new file mode 100644
index 0000000..5dbe63f
@@ -0,0 +1,29 @@
+/*
+ * 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_UNALIGNED_H
+#define _ASM_ARC_UNALIGNED_H
+
+/* ARC700 can't handle unaligned Data accesses. */
+
+#include <asm-generic/unaligned.h>
+#include <asm/ptrace.h>
+
+#ifdef CONFIG_ARC_MISALIGN_ACCESS
+int misaligned_fixup(unsigned long address, struct pt_regs *regs,
+		     unsigned long cause, struct callee_regs *cregs);
+#else
+static inline int
+misaligned_fixup(unsigned long address, struct pt_regs *regs,
+		 unsigned long cause, struct callee_regs *cregs)
+{
+	return 0;
+}
+#endif
+
+#endif /* _ASM_ARC_UNALIGNED_H */
arch/arc/kernel/Makefile +1 -0
index f11318f..eda40d7 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_MODULES)			+= arcksyms.o module.o
 obj-$(CONFIG_SMP) 			+= smp.o
 obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
 obj-$(CONFIG_KPROBES)      		+= kprobes.o
+obj-$(CONFIG_ARC_MISALIGN_ACCESS) 	+= unaligned.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/disasm.c +1 -1
index 51bad8f..2f39028 100644
@@ -15,7 +15,7 @@
 #include <asm/disasm.h>
 #include <asm/uaccess.h>
 
-#if defined(CONFIG_KGDB) || defined(CONFIG_MISALIGN_ACCESS) || \
+#if defined(CONFIG_KGDB) || defined(CONFIG_ARC_MISALIGN_ACCESS) || \
 	defined(CONFIG_KPROBES)
 
 /* disasm_instr: Analyses instruction at addr, stores
arch/arc/kernel/entry.S +13 -0
index 7e392d4..0ef234e 100644
@@ -12,6 +12,9 @@
  *   needed before task_pt_regs was invented. This saves a branch per call
  *   and more importantly allows clean invocation of post-syscall ptrace hook
  *
+ * vineetg: May 2011
+ *  -Userspace unaligned access emulation
+ *
  * vineetg: Feb 2011 (ptrace low level code fixes)
  *  -traced syscall return code (r0) was not saved into pt_regs for restoring
  *   into user reg-file when traded task rets to user space.
@@ -392,7 +395,17 @@ ARC_ENTRY EV_TLBProtV
 	mov r1, r4              ; faulting address
 	mov r2, sp              ; pt_regs
 
+#ifdef  CONFIG_ARC_MISALIGN_ACCESS
+	SAVE_CALLEE_SAVED_USER
+	mov r3, sp              ; callee_regs
+#endif
+
 	bl  do_misaligned_access
+
+#ifdef  CONFIG_ARC_MISALIGN_ACCESS
+	DISCARD_CALLEE_SAVED_USER
+#endif
+
 	b   ret_from_exception
 
 ARC_EXIT EV_TLBProtV
arch/arc/kernel/traps.c +26 -0
index c6396b4..ec802c5 100644
@@ -7,6 +7,9 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
+ * vineetg: May 2011
+ *  -user-space unaligned access emulation
+ *
  * Rahul Trivedi: Codito Technologies 2004
  */
 
@@ -16,6 +19,7 @@
 #include <asm/ptrace.h>
 #include <asm/setup.h>
 #include <asm/kprobes.h>
+#include <asm/unaligned.h>
 
 void __init trap_init(void)
 {
@@ -79,7 +83,29 @@ DO_ERROR_INFO(SIGILL, "Illegal Insn (or Seq)", insterror_is_error, ILL_ILLOPC)
 DO_ERROR_INFO(SIGBUS, "Invalid Mem Access", do_memory_error, BUS_ADRERR)
 DO_ERROR_INFO(SIGTRAP, "Breakpoint Set", trap_is_brkpt, TRAP_BRKPT)
 
+#ifdef CONFIG_ARC_MISALIGN_ACCESS
+/*
+ * Entry Point for Misaligned Data access Exception, for emulating in software
+ */
+int do_misaligned_access(unsigned long cause, unsigned long address,
+			 struct pt_regs *regs, struct callee_regs *cregs)
+{
+	if (misaligned_fixup(address, regs, cause, cregs) != 0) {
+		siginfo_t info;
+
+		info.si_signo = SIGBUS;
+		info.si_errno = 0;
+		info.si_code = BUS_ADRALN;
+		info.si_addr = (void __user *)address;
+		return handle_exception(cause, "Misaligned Access", regs,
+					  &info);
+	}
+	return 0;
+}
+
+#else
 DO_ERROR_INFO(SIGSEGV, "Misaligned Access", do_misaligned_access, SEGV_ACCERR)
+#endif
 
 /*
  * Entry point for miscll errors such as Nested Exceptions
arch/arc/kernel/unaligned.c new file +245 -0

245 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer Acked-by on v2 56/76
#97 lore raw

Re: [PATCH v2 56/76] ARC: Unaligned access emulation

Quoted 4 lines · Vineet Gupta

ARC700 doesn't natively support unaligned access, but can be emulated

(quoted diff) +0 -2
-Unaligned Access Exception
-Disassembly at the Fault address to find the exact insn (long/short)
Quoted 8 lines

Also per Arnd's comment, we runtime control it using 2 sysctl knobs:
* SYSCTL_ARCH_UNALIGN_ALLOW: Runtime enable/disble
* SYSCTL_ARCH_UNALIGN_NO_WARN: Warn on each emulation attempt

Originally contributed by Tim Yao <[email protected]>

#98 lore raw

PATCH v2 57/76 ARC: kgdb support

In reply to Vineet Gupta

From: Mischa Jonker <[email protected]>

---
 arch/arc/Kconfig            |    3 +-
 arch/arc/include/asm/kgdb.h |   61 +++++++++++++
 arch/arc/kernel/Makefile    |    1 +
 arch/arc/kernel/kgdb.c      |  205 +++++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/traps.c     |    6 ++
 5 files changed, 275 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/kgdb.h
 create mode 100644 arch/arc/kernel/kgdb.c
arch/arc/Kconfig +2 -1
index d735de8..b954387 100644
@@ -23,6 +23,7 @@ config ARC
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SIGALTSTACK
 	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
 	select HAVE_KPROBES
@@ -383,7 +384,7 @@ config ARC_DW2_UNWIND
 
 config ARC_DBG_TLB_PARANOIA
 	bool "Paranoia Checks in Low Level TLB Handlers"
-	depends on ARC_DBG && !SMP
+	depends on ARC_DBG
 	default n
 
 config ARC_DBG_TLB_MISS_COUNT
arch/arc/include/asm/kgdb.h new file +61 -0

61 lines not on this page · raw message

arch/arc/kernel/Makefile +1 -0
index eda40d7..8a8518e 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_SMP) 			+= smp.o
 obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
 obj-$(CONFIG_KPROBES)      		+= kprobes.o
 obj-$(CONFIG_ARC_MISALIGN_ACCESS) 	+= unaligned.o
+obj-$(CONFIG_KGDB)			+= kgdb.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/kgdb.c new file +205 -0

205 lines not on this page · raw message

arch/arc/kernel/traps.c +6 -0
index ec802c5..7496995 100644
@@ -20,6 +20,7 @@
 #include <asm/setup.h>
 #include <asm/kprobes.h>
 #include <asm/unaligned.h>
+#include <asm/kgdb.h>
 
 void __init trap_init(void)
 {
@@ -141,6 +142,11 @@ void do_non_swi_trap(unsigned long cause, unsigned long address,
 		trap_is_kprobe(param, address, regs);
 		break;
 
+	case 3:
+	case 4:
+		kgdb_trap(regs, param);
+		break;
+
 	default:
 		break;
 	}
Signature · 1 line
1.7.4.1
Acked-by on v2 57/76
#99 lore raw

Re: [PATCH v2 57/76] ARC: kgdb support

Quoted 5 lines · Vineet Gupta

From: Mischa Jonker <[email protected]>

Quoted 46 lines
---
 arch/arc/Kconfig            |    3 +-
 arch/arc/include/asm/kgdb.h |   61 +++++++++++++
 arch/arc/kernel/Makefile    |    1 +
 arch/arc/kernel/kgdb.c      |  205 +++++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/traps.c     |    6 ++
 5 files changed, 275 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/kgdb.h
 create mode 100644 arch/arc/kernel/kgdb.c
arch/arc/Kconfig +2 -1
index d735de8..b954387 100644
@@ -23,6 +23,7 @@ config ARC
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SIGALTSTACK
 	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
 	select HAVE_KPROBES
@@ -383,7 +384,7 @@ config ARC_DW2_UNWIND
 
 config ARC_DBG_TLB_PARANOIA
 	bool "Paranoia Checks in Low Level TLB Handlers"
-	depends on ARC_DBG && !SMP
+	depends on ARC_DBG
 	default n
 
 config ARC_DBG_TLB_MISS_COUNT
arch/arc/include/asm/kgdb.h new file +9 -0
new file mode 100644
index 0000000..f3c4934
@@ -0,0 +1,61 @@
+/*
+ * kgdb support for ARC
+ *
+ * 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.
+ */

arch/arc/include/asm/kgdb.h line 19

Quoted 10 lines
arch/arc/include/asm/kgdb.h new file +10 -0
+
+#ifndef __ARC_KGDB_H__
+#define __ARC_KGDB_H__
+
+#ifdef CONFIG_KGDB
+
+#include <asm/user.h>
+
+/* to ensure compatibility with Linux 2.6.35, we don't implement the get/set
+ * register API yet */

I did think this note was slightly odd. Is this mainly because you have some kind of out of tree version of this code against an older kernel?

The main thing that you lose by not doing this the ability to display and set registers from the kdb shell.

From the pure gdb only end of things, gdb operates more efficiently for doing things like setting or reading the program counter, frame pointer or variable mapped registers when using a rs232 connection. There is no loss or gain in actual functionality by not implementing the individual get/set register method if you only intend to use gdb.

Cheers,
Jason.

#100 lore raw

Re: [PATCH v2 57/76] ARC: kgdb support

Quoted 58 lines · Jason Wessel
Quoted 5 lines · Vineet Gupta

From: Mischa Jonker <[email protected]>

Quoted 50 lines
---
 arch/arc/Kconfig            |    3 +-
 arch/arc/include/asm/kgdb.h |   61 +++++++++++++
 arch/arc/kernel/Makefile    |    1 +
 arch/arc/kernel/kgdb.c      |  205 +++++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/traps.c     |    6 ++
 5 files changed, 275 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/kgdb.h
 create mode 100644 arch/arc/kernel/kgdb.c
arch/arc/Kconfig +2 -1
index d735de8..b954387 100644
@@ -23,6 +23,7 @@ config ARC
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SIGALTSTACK
 	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
 	select HAVE_KPROBES
@@ -383,7 +384,7 @@ config ARC_DW2_UNWIND
 
 config ARC_DBG_TLB_PARANOIA
 	bool "Paranoia Checks in Low Level TLB Handlers"
-	depends on ARC_DBG && !SMP
+	depends on ARC_DBG
 	default n
 
 config ARC_DBG_TLB_MISS_COUNT
arch/arc/include/asm/kgdb.h new file +13 -0
new file mode 100644
index 0000000..f3c4934
@@ -0,0 +1,61 @@
+/*
+ * kgdb support for ARC
+ *
+ * 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.
+ */
+
+#ifndef __ARC_KGDB_H__
+#define __ARC_KGDB_H__
+
Quoted 8 lines

arch/arc/include/asm/kgdb.h line 19

Quoted 6 lines
arch/arc/include/asm/kgdb.h new file +6 -0
+#ifdef CONFIG_KGDB
+
+#include <asm/user.h>
+
+/* to ensure compatibility with Linux 2.6.35, we don't implement the get/set
+ * register API yet */

I did think this note was slightly odd. Is this mainly because you have some kind of out of tree version of this code against an older kernel?

Thanks for your review and ACK, Jason. We did the initial port against 2.6.35 and later moved over to 3.2 - both of which were out-of-tree. We will take a look at it again and clean this up.

Quoted 6 lines

The main thing that you lose by not doing this the ability to display and set registers from the kdb shell.

From the pure gdb only end of things, gdb operates more efficiently for doing things like setting or reading the program counter, frame pointer or variable mapped registers when using a rs232 connection. There is no loss or gain in actual functionality by not implementing the individual get/set register method if you only intend to use gdb.

Cheers,
Jason.

OK - we will fix this up - but I presume it is not a gating item for the port submission.

Thx,
-Vineet

#101 lore raw

Re: [PATCH v2 57/76] ARC: kgdb support

Quoted 70 lines · Vineet Gupta
Quoted 57 lines · Jason Wessel
Quoted 5 lines · Vineet Gupta

From: Mischa Jonker <[email protected]>

Quoted 49 lines
---
 arch/arc/Kconfig            |    3 +-
 arch/arc/include/asm/kgdb.h |   61 +++++++++++++
 arch/arc/kernel/Makefile    |    1 +
 arch/arc/kernel/kgdb.c      |  205 +++++++++++++++++++++++++++++++++++++++++++
 arch/arc/kernel/traps.c     |    6 ++
 5 files changed, 275 insertions(+), 1 deletions(-)
 create mode 100644 arch/arc/include/asm/kgdb.h
 create mode 100644 arch/arc/kernel/kgdb.c
arch/arc/Kconfig +2 -1
index d735de8..b954387 100644
@@ -23,6 +23,7 @@ config ARC
 	select GENERIC_PENDING_IRQ if SMP
 	select GENERIC_SIGALTSTACK
 	select GENERIC_SMP_IDLE_THREAD
+	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
 	select HAVE_KPROBES
@@ -383,7 +384,7 @@ config ARC_DW2_UNWIND
 
 config ARC_DBG_TLB_PARANOIA
 	bool "Paranoia Checks in Low Level TLB Handlers"
-	depends on ARC_DBG && !SMP
+	depends on ARC_DBG
 	default n
 
 config ARC_DBG_TLB_MISS_COUNT
arch/arc/include/asm/kgdb.h new file +12 -0
new file mode 100644
index 0000000..f3c4934
@@ -0,0 +1,61 @@
+/*
+ * kgdb support for ARC
+ *
+ * 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.
+ */
+
+#ifndef __ARC_KGDB_H__
+#define __ARC_KGDB_H__
Quoted 8 lines

arch/arc/include/asm/kgdb.h line 19

Quoted 7 lines
arch/arc/include/asm/kgdb.h new file +7 -0
+
+#ifdef CONFIG_KGDB
+
+#include <asm/user.h>
+
+/* to ensure compatibility with Linux 2.6.35, we don't implement the get/set
+ * register API yet */

I did think this note was slightly odd. Is this mainly because you have some kind of out of tree version of this code against an older kernel?

Thanks for your review and ACK, Jason. We did the initial port against 2.6.35 and later moved over to 3.2 - both of which were out-of-tree. We will take a look at it again and clean this up.

Quoted 8 lines
Quoted 6 lines

The main thing that you lose by not doing this the ability to display and set registers from the kdb shell.

From the pure gdb only end of things, gdb operates more efficiently for doing things like setting or reading the program counter, frame pointer or variable mapped registers when using a rs232 connection. There is no loss or gain in actual functionality by not implementing the individual get/set register method if you only intend to use gdb.

Cheers,
Jason.

OK - we will fix this up - but I presume it is not a gating item for the port submission.

No gate what so ever. I was just pointing out what you lose access to by without implementing the optional functions. :-)

Cheers,
Jason.

#102 lore raw

PATCH v2 58/76 ARC: Boot #2: Verbose Boot reporting / feature verification

In reply to Vineet Gupta
---
 arch/arc/Makefile              |    2 +
 arch/arc/include/asm/arcregs.h |  122 ++++++++++++++++++++--
 arch/arc/include/asm/defines.h |   56 ++++++++++
 arch/arc/include/asm/setup.h   |   14 +++
 arch/arc/kernel/setup.c        |  223 +++++++++++++++++++++++++++++++++++++++-
 arch/arc/mm/cache_arc700.c     |   46 ++++++++
 arch/arc/mm/tlb.c              |   38 +++++++
 7 files changed, 490 insertions(+), 11 deletions(-)
 create mode 100644 arch/arc/include/asm/defines.h
arch/arc/Makefile +2 -0
index 507e797..ecb87e2 100644
@@ -20,6 +20,8 @@ export PLATFORM
 cflags-y	+= -Iarch/arc/plat-$(PLATFORM)/include
 cflags-y	+= -mA7 -fno-common -pipe -fno-builtin -D__linux__
 
+LINUXINCLUDE	+=  -include ${src}/arch/arc/include/asm/defines.h
+
 ifdef CONFIG_ARC_CURR_IN_REG
 # For a global register defintion, make sure it gets passed to every file
 # We had a customer reported bug where some code built in kernel was NOT using
arch/arc/include/asm/arcregs.h +112 -10

163 lines not on this page · raw message

arch/arc/include/asm/defines.h new file +56 -0

56 lines not on this page · raw message

arch/arc/include/asm/setup.h +14 -0
index ab427e6..fc97411 100644
@@ -13,6 +13,20 @@
 
 #define COMMAND_LINE_SIZE 256
 
+/*
+ * Data structure to map a ID to string
+ * Used a lot for bootup reporting of hardware diversity
+ */
+struct id_to_str {
+	int id;
+	const char *str;
+};
+
+struct cpuinfo_data {
+	struct id_to_str info;
+	int up_range;
+};
+
 extern int root_mountflags, end_mem;
 extern int running_on_hw;
 
arch/arc/kernel/setup.c +222 -1

260 lines not on this page · raw message

arch/arc/mm/cache_arc700.c +46 -0

68 lines not on this page · raw message

arch/arc/mm/tlb.c +38 -0
index e96030c..9b9ce23 100644
@@ -463,8 +463,46 @@ void __init read_decode_mmu_bcr(void)
 	mmu->num_tlb = mmu->sets * mmu->ways;
 }
 
+char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len)
+{
+	int n = 0;
+	struct cpuinfo_arc_mmu *p_mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
+
+	n += scnprintf(buf + n, len - n, "ARC700 MMU [v%x]\t: %dk PAGE, ",
+		       p_mmu->ver, TO_KB(p_mmu->pg_sz));
+
+	n += scnprintf(buf + n, len - n,
+		       "J-TLB %d (%dx%d), uDTLB %d, uITLB %d, %s\n",
+		       p_mmu->num_tlb, p_mmu->sets, p_mmu->ways,
+		       p_mmu->u_dtlb, p_mmu->u_itlb,
+		       __CONFIG_ARC_MMU_SASID_VAL ? "SASID" : "");
+
+	return buf;
+}
+
 void __init arc_mmu_init(void)
 {
+	char str[256];
+	struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
+
+	printk(arc_mmu_mumbojumbo(0, str, sizeof(str)));
+
+	/* For efficiency sake, kernel is compile time built for a MMU ver
+	 * This must match the hardware it is running on.
+	 * Linux built for MMU V2, if run on MMU V1 will break down because V1
+	 *  hardware doesn't understand cmds such as WriteNI, or IVUTLB
+	 * On the other hand, Linux built for V1 if run on MMU V2 will do
+	 *   un-needed workarounds to prevent memcpy thrashing.
+	 * Similarly MMU V3 has new features which won't work on older MMU
+	 */
+	if (mmu->ver != CONFIG_ARC_MMU_VER) {
+		panic("MMU ver %d doesn't match kernel built for %d...\n",
+		      mmu->ver, CONFIG_ARC_MMU_VER);
+	}
+
+	if (mmu->pg_sz != PAGE_SIZE)
+		panic("MMU pg size != PAGE_SIZE (%luk)\n", TO_KB(PAGE_SIZE));
+
 	/*
 	 * ASID mgmt data structures are compile time init
 	 *  asid_cache = FIRST_ASID and asid_mm_map[] all zeroes
Signature · 1 line
1.7.4.1
#103 lore raw

PATCH v2 59/76 ARC: [plat-arfpga] BVCI Latency Unit setup

In reply to Vineet Gupta
---
 arch/arc/plat-arcfpga/Kconfig    |   32 +++++++++++++++++++++
 arch/arc/plat-arcfpga/platform.c |   56 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
arch/arc/plat-arcfpga/Kconfig +32 -0
index 8a1334c..86b7377 100644
@@ -43,4 +43,36 @@ config ARC_SERIAL_BAUD
 	help
 	  Baud rate for the ARC UART
 
+menuconfig ARC_HAS_BVCI_LAT_UNIT
+	bool "BVCI Bus Latency Unit"
+	depends on ARC_BOARD_ML509 || ARC_BOARD_ANGEL4
+	help
+	  IP to add artifical latency to BVCI Bus Based FPGA builds.
+	  The default latency (even worst case) for FPGA is non-realistic
+	  (~10 SDRAM, ~5 SSRAM).
+
+config BVCI_LAT_UNITS
+	hex "Latency Unit(s) Bitmap"
+	default "0x0"
+	depends on ARC_HAS_BVCI_LAT_UNIT
+	help
+	  There are multiple Latency Units corresponding to the many
+	  interfaces of the system bus arbiter (both CPU side as well as
+	  the peripheral side).
+	  To add latency to ALL memory transaction, choose Unit 0, otherwise
+	  for finer grainer - interface wise latency, specify a bitmap (1 bit
+	  per unit) of all units. e.g. 1,2,12 will be 0x1003
+
+	  Unit  0 - System Arb and Mem Controller
+	  Unit  1 - I$ and System Bus
+	  Unit  2 - D$ and System Bus
+	  ..
+	  Unit 12 - IDE Disk controller and System Bus
+
+config BVCI_LAT_CYCLES
+	int "Latency Value in cycles"
+	range 0 63
+	default "30"
+	depends on ARC_HAS_BVCI_LAT_UNIT
+
 endif
arch/arc/plat-arcfpga/platform.c +56 -0

74 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#104 lore raw

PATCH v2 60/76 perf, ARC: Enable building perf tools for ARC

In reply to Vineet Gupta

Although with uClibc there's more we need to do

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/perf.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
tools/perf/perf.h +6 -0
index 2c340e7..8a68ad3 100644
@@ -98,6 +98,12 @@ void get_term_dimensions(struct winsize *ws);
 #define CPUINFO_PROC	"cpu model"
 #endif
 
+#ifdef __arc__
+#define rmb()		asm volatile("" ::: "memory")
+#define cpu_relax()	rmb()
+#define CPUINFO_PROC	"Processor"
+#endif
+
 #include <time.h>
 #include <unistd.h>
 #include <sys/types.h>
Signature · 1 line
1.7.4.1
#105 lore raw

Re: [PATCH v2 60/76] perf, ARC: Enable building perf tools for ARC

Quoted 19 lines · Vineet Gupta

Although with uClibc there's more we need to do

Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/perf.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
tools/perf/perf.h +0 -0
index 2c340e7..8a68ad3 100644
@@ -98,6 +98,12 @@ void get_term_dimensions(struct winsize *ws);
 #define CPUINFO_PROC	"cpu model"
 #endif

tools/perf/perf.h void get_term_dimensions(struct winsize *ws); · line 109

Quoted 10 lines
tools/perf/perf.h +6 -0
 
+#ifdef __arc__
+#define rmb()		asm volatile("" ::: "memory")
+#define cpu_relax()	rmb()
+#define CPUINFO_PROC	"Processor"
+#endif
+
 #include <time.h>
 #include <unistd.h>
 #include <sys/types.h>

Hi Arnaldo,

If this looks OK to you, can you please ACK it.

Thx,
-Vineet

#106 lore raw

PATCH v2 61/76 ARC: perf support (software counters only)

In reply to Vineet Gupta
---
 arch/arc/Kconfig                  |    3 +++
 arch/arc/include/asm/perf_event.h |   13 +++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/include/asm/perf_event.h
arch/arc/Kconfig +3 -0
index b954387..0f21a1c 100644
@@ -26,15 +26,18 @@ config ARC
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
+	select HAVE_IRQ_WORK
 	select HAVE_KPROBES
 	select HAVE_KRETPROBES
 	select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND
 	select HAVE_OPROFILE
+	select HAVE_PERF_EVENTS
 	select HOTPLUG if !INITRAMFS_SOURCE=""
 	select IRQ_DOMAIN
 	select MODULES_USE_ELF_RELA
 	select OF
 	select OF_EARLY_FLATTREE
+	select PERF_USE_VMALLOC
 
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
arch/arc/include/asm/perf_event.h new file +13 -0
new file mode 100644
index 0000000..115ad96
@@ -0,0 +1,13 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef __ASM_PERF_EVENT_H
+#define __ASM_PERF_EVENT_H
+
+#endif /* __ASM_PERF_EVENT_H */
Signature · 1 line
1.7.4.1
#107 lore raw

PATCH v2 62/76 ARC: Support for single cycle Close Coupled Mem (CCM)

In reply to Vineet Gupta

* Includes mapping of CCMs in address space
* Annotations to move arbitrary code/data into CCM
* Moving some of the critical code/data into CCM
* Runtime detection/reporting

---
 arch/arc/Kconfig               |   27 ++++++++++++++++++++
 arch/arc/include/asm/linkage.h |   33 +++++++++++++++++++++++++
 arch/arc/kernel/entry.S        |    4 +-
 arch/arc/kernel/setup.c        |   53 +++++++++++++++++++++++++++++++++++++++-
 arch/arc/kernel/vmlinux.lds.S  |   21 ++++++++++++++++
 arch/arc/mm/tlbex.S            |    5 +--
 6 files changed, 137 insertions(+), 6 deletions(-)
arch/arc/Kconfig +27 -0
index 0f21a1c..bbd48e1 100644
@@ -203,6 +203,33 @@ config ARC_CACHE_PAGES
 
 endif	#ARC_CACHE
 
+config ARC_HAS_ICCM
+	bool "Use ICCM"
+	help
+	  Single Cycle RAMS to store Fast Path Code
+	default n
+
+config ARC_ICCM_SZ
+	int "ICCM Size in KB"
+	default "64"
+	depends on ARC_HAS_ICCM
+
+config ARC_HAS_DCCM
+	bool "Use DCCM"
+	help
+	  Single Cycle RAMS to store Fast Path Data
+	default n
+
+config ARC_DCCM_SZ
+	int "DCCM Size in KB"
+	default "64"
+	depends on ARC_HAS_DCCM
+
+config ARC_DCCM_BASE
+	hex "DCCM map address"
+	default "0xA0000000"
+	depends on ARC_HAS_DCCM
+
 config ARC_HAS_HW_MPY
 	bool "Use Hardware Multiplier (Normal or Faster XMAC)"
 	default y
arch/arc/include/asm/linkage.h +33 -0
index a45d1bb..0283e9e 100644
@@ -25,6 +25,39 @@
 	.size \ name, ASM_PREV_SYM_ADDR(\name)
 .endm
 
+/* annotation for data we want in DCCM - if enabled in .config */
+.macro ARCFP_DATA nm
+#ifdef CONFIG_ARC_HAS_DCCM
+	.section .data.arcfp
+#else
+	.section .data
+#endif
+	.global \nm
+.endm
+
+/* annotation for data we want in DCCM - if enabled in .config */
+.macro ARCFP_CODE
+#ifdef CONFIG_ARC_HAS_ICCM
+	.section .text.arcfp, "ax",@progbits
+#else
+	.section .text, "ax",@progbits
+#endif
+.endm
+
+#else	/* !__ASSEMBLY__ */
+
+#ifdef CONFIG_ARC_HAS_ICCM
+#define __arcfp_code __attribute__((__section__(".text.arcfp")))
+#else
+#define __arcfp_code __attribute__((__section__(".text")))
+#endif
+
+#ifdef CONFIG_ARC_HAS_DCCM
+#define __arcfp_data __attribute__((__section__(".data.arcfp")))
+#else
+#define __arcfp_data __attribute__((__section__(".data")))
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 #endif
arch/arc/kernel/entry.S +2 -2
index 0ef234e..a773b9c 100644
@@ -154,7 +154,7 @@ VECTOR   reserved                ; Reserved Exceptions
 
 ;##################### Scratch Mem for IRQ stack switching #############
 
-	.section .data		; NOT .global
+ARCFP_DATA int1_saved_reg
 	.align 32
 	.type   int1_saved_reg, @object
 	.size   int1_saved_reg, 4
@@ -164,7 +164,7 @@ int1_saved_reg:
 /* Each Interrupt level needs it's own scratch */
 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
 
-	.section .data		; NOT .global
+ARCFP_DATA int2_saved_reg
 	.type   int2_saved_reg, @object
 	.size   int2_saved_reg, 4
 int2_saved_reg:
arch/arc/kernel/setup.c +52 -1

71 lines not on this page · raw message

arch/arc/kernel/vmlinux.lds.S +21 -0
index 56c074e..3b6a21a 100644
@@ -24,6 +24,12 @@ jiffies = jiffies_64;
 
 SECTIONS
 {
+	/*
+	 * ICCM starts at 0x8000_0000. So if kernel is relocated to some other
+	 * address, make sure peripheral at 0x8z doesn't clash with ICCM
+	 * Essentially vector is also in ICCM.
+	 */
+
 	. = CONFIG_LINUX_LINK_BASE;
 
 	_int_vec_base_lds = .;
@@ -32,6 +38,13 @@ SECTIONS
 		. = ALIGN(PAGE_SIZE);
 	}
 
+#ifdef CONFIG_ARC_HAS_ICCM
+	.text.arcfp : {
+		*(.text.arcfp)
+		. = ALIGN(CONFIG_ARC_ICCM_SZ * 1024);
+	}
+#endif
+
 	/*
 	 * The reason for having a seperate subsection .init.ramfs is to
 	 * prevent objump from including it in kernel dumps
@@ -135,4 +148,12 @@ SECTIONS
 	.debug_loc 0 : { *(.debug_loc) }
 	.debug_macinfo 0 : { *(.debug_macinfo) }
 
+#ifdef CONFIG_ARC_HAS_DCCM
+	. = CONFIG_ARC_DCCM_BASE;
+	__arc_dccm_base = .;
+	.data.arcfp : {
+		*(.data.arcfp)
+	}
+	. = ALIGN(CONFIG_ARC_DCCM_SZ * 1024);
+#endif
 }
arch/arc/mm/tlbex.S +2 -3
index 4b1ad2d..9df765d 100644
@@ -53,8 +53,7 @@
 ; For details refer to comments before TLBMISS_FREEUP_REGS below
 ;--------------------------------------------------------------------------
 
-	.section .data
-	.global ex_saved_reg1
+ARCFP_DATA ex_saved_reg1
 	.align 1 << L1_CACHE_SHIFT	; IMP: Must be Cache Line aligned
 	.type   ex_saved_reg1, @object
 #ifdef CONFIG_SMP
@@ -255,7 +254,7 @@ ex_saved_reg1:
 #endif
 .endm
 
-.section .text, "ax",@progbits	;Fast Path Code, candidate for ICCM
+ARCFP_CODE	;Fast Path Code, candidate for ICCM
 
 ;-----------------------------------------------------------------------------
 ; I-TLB Miss Exception Handler
Signature · 1 line
1.7.4.1
#108 lore raw

PATCH v2 63/76 ARC: Hostlink Pseudo-Driver for Metaware Debugger

In reply to Vineet Gupta

This allows ARC Target to do I/O to host in absence of any peripherals whatsoever, assisted by Metaware Hostlink facility.

Further we have a FUSE based filesystem which makes us mount/access host filesystem on target and do fops.

---
 arch/arc/Kconfig               |    9 +++
 arch/arc/kernel/Makefile       |    1 +
 arch/arc/kernel/arc_hostlink.c |  114 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+), 0 deletions(-)
 create mode 100644 arch/arc/kernel/arc_hostlink.c
arch/arc/Kconfig +9 -0
index bbd48e1..9202c1a 100644
@@ -394,6 +394,15 @@ config HZ
 	int "Timer Frequency"
 	default 100
 
+config ARC_METAWARE_HLINK
+	bool "Support for Metaware debugger assisted Host access"
+	default n
+	help
+	  This options allows a Linux userland apps to directly access
+	  host file system (open/creat/read/write etc) with help from
+	  Metaware Debugger. This can come in handy for Linux-host communication
+	  when there is no real usable peripheral such as EMAC.
+
 menuconfig ARC_DBG
 	bool "ARC debugging"
 	default y
arch/arc/kernel/Makefile +1 -0
index 8a8518e..329361d 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_ARC_DW2_UNWIND)		+= unwind.o
 obj-$(CONFIG_KPROBES)      		+= kprobes.o
 obj-$(CONFIG_ARC_MISALIGN_ACCESS) 	+= unaligned.o
 obj-$(CONFIG_KGDB)			+= kgdb.o
+obj-$(CONFIG_ARC_METAWARE_HLINK)	+= arc_hostlink.o
 
 obj-$(CONFIG_ARC_FPU_SAVE_RESTORE)	+= fpu.o
 CFLAGS_fpu.o   += -mdpfp
arch/arc/kernel/arc_hostlink.c new file +114 -0

114 lines not on this page · raw message

Signature · 1 line
1.7.4.1
maintainer
#109 lore raw

Re: [PATCH v2 63/76] ARC: Hostlink Pseudo-Driver for Metaware Debugger

Quoted 1 line · Vineet Gupta

+static int arc_hl_nr_devs = 1;

This seems to be read-only and hardcoded to 1. If this is true, you could simplify the driver significantly by just using misc_register, rather than registering your own major device number.

Arnd

#110 lore raw

Re: [PATCH v2 63/76] ARC: Hostlink Pseudo-Driver for Metaware Debugger

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

+static int arc_hl_nr_devs = 1;

This seems to be read-only and hardcoded to 1. If this is true, you could simplify the driver significantly by just using misc_register, rather than registering your own major device number.

Arnd

:-) Indeed virtually there's nothing left in there after misc_register

Thx,
-Vineet

#111 lore raw

PATCH v2 64/76 ARC: Add self to MAINTAINERS

In reply to Vineet Gupta
---
 MAINTAINERS |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
MAINTAINERS +6 -0
index 3105c48..05cdc99 100644
@@ -7418,6 +7418,12 @@ F:	lib/swiotlb.c
 F:	arch/*/kernel/pci-swiotlb.c
 F:	include/linux/swiotlb.h
 
+SYNOPSYS ARC ARCHITECTURE
+M:	Vineet Gupta <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	arch/arc/
+
 SYSV FILESYSTEM
 M:	Christoph Hellwig <[email protected]>
 S:	Maintained
Signature · 1 line
1.7.4.1
#112 lore raw

Re: [PATCH v2 64/76] ARC: Add self to MAINTAINERS

Quoted 10 lines · Vineet Gupta
---
 MAINTAINERS |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
MAINTAINERS +0 -0
index 3105c48..05cdc99 100644

MAINTAINERS F: lib/swiotlb.c · line 7423

Quoted 6 lines
MAINTAINERS +3 -0
@@ -7418,6 +7418,12 @@ F:	lib/swiotlb.c
 F:	arch/*/kernel/pci-swiotlb.c
 F:	include/linux/swiotlb.h
 
+SYNOPSYS ARC ARCHITECTURE
+M:	Vineet Gupta <[email protected]>
+L:	[email protected]

Is this set up? I don't see it at
http://vger.kernel.org/vger-lists.html

Incidentally, anybody know who to ask about setting up a new list?

Cheers
James

Quoted 7 lines
MAINTAINERS +3 -0
+S:	Supported
+F:	arch/arc/
+
 SYSV FILESYSTEM
 M:	Christoph Hellwig <[email protected]>
 S:	Maintained
#113 lore raw

Re: [PATCH v2 64/76] ARC: Add self to MAINTAINERS

Quoted 8 lines · James Hogan

MAINTAINERS F: lib/swiotlb.c · line 7423

Quoted 5 lines · Vineet Gupta

...

MAINTAINERS +3 -0
+SYNOPSYS ARC ARCHITECTURE
+M:	Vineet Gupta <[email protected]>
+L:	[email protected]

Is this set up? I don't see it at
http://vger.kernel.org/vger-lists.html

Nope, I just added it as a placeholder - I presume when the logistics are sorted out (say the maintainer's branch on LF servers), then this would be set up as well.

Quoted 1 line

Incidentally, anybody know who to ask about setting up a new list?

Some existing maintainer would know !

Thx,
-Vineet

#114 lore raw

PATCH v2 65/76 ARC: UAPI Disintegrate arch/arc/include/asm

In reply to Vineet Gupta

1. ./genfilelist.pl arch/arc/include/asm/

2. Create arch/arc/include/uapi/asm/Kbuild as follows

+# UAPI Header export list
+include include/uapi/asm-generic/Kbuild.asm

3. ./disintegrate-one.pl arch/arc/include/{,uapi/}asm/<above-list>

4. Edit arch/arc/include/asm/Kbuild to remove ref to asm-generic/Kbuild.asm

---
 arch/arc/include/asm/Kbuild            |    8 ---
 arch/arc/include/asm/byteorder.h       |   18 ------
 arch/arc/include/asm/cachectl.h        |   28 ---------
 arch/arc/include/asm/page.h            |   30 +---------
 arch/arc/include/asm/ptrace.h          |   37 +-----------
 arch/arc/include/asm/setup.h           |    3 +-
 arch/arc/include/asm/sigcontext.h      |   23 --------
 arch/arc/include/asm/signal.h          |   27 ---------
 arch/arc/include/asm/swab.h            |   98 --------------------------------
 arch/arc/include/asm/unistd.h          |   34 -----------
 arch/arc/include/uapi/asm/Kbuild       |   11 ++++
 arch/arc/include/uapi/asm/byteorder.h  |   18 ++++++
 arch/arc/include/uapi/asm/cachectl.h   |   28 +++++++++
 arch/arc/include/uapi/asm/page.h       |   39 +++++++++++++
 arch/arc/include/uapi/asm/ptrace.h     |   46 +++++++++++++++
 arch/arc/include/uapi/asm/sigcontext.h |   23 ++++++++
 arch/arc/include/uapi/asm/signal.h     |   27 +++++++++
 arch/arc/include/uapi/asm/swab.h       |   98 ++++++++++++++++++++++++++++++++
 arch/arc/include/uapi/asm/unistd.h     |   34 +++++++++++
 19 files changed, 329 insertions(+), 301 deletions(-)
 delete mode 100644 arch/arc/include/asm/byteorder.h
 delete mode 100644 arch/arc/include/asm/cachectl.h
 delete mode 100644 arch/arc/include/asm/sigcontext.h
 delete mode 100644 arch/arc/include/asm/signal.h
 delete mode 100644 arch/arc/include/asm/swab.h
 delete mode 100644 arch/arc/include/asm/unistd.h
 create mode 100644 arch/arc/include/uapi/asm/Kbuild
 create mode 100644 arch/arc/include/uapi/asm/byteorder.h
 create mode 100644 arch/arc/include/uapi/asm/cachectl.h
 create mode 100644 arch/arc/include/uapi/asm/page.h
 create mode 100644 arch/arc/include/uapi/asm/ptrace.h
 create mode 100644 arch/arc/include/uapi/asm/setup.h
 create mode 100644 arch/arc/include/uapi/asm/sigcontext.h
 create mode 100644 arch/arc/include/uapi/asm/signal.h
 create mode 100644 arch/arc/include/uapi/asm/swab.h
 create mode 100644 arch/arc/include/uapi/asm/unistd.h
arch/arc/include/asm/Kbuild +0 -8
index b24089c..48af742 100644
@@ -1,11 +1,3 @@
-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
arch/arc/include/asm/byteorder.h deleted +0 -18
deleted file mode 100644
index 9da71d4..0000000
@@ -1,18 +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.
- */
-
-#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/cachectl.h deleted +0 -28
deleted file mode 100644
index 51c73f0..0000000
@@ -1,28 +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.
- */
-
-#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_FLUSH_INV	0x0020
-
-#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/page.h +1 -29
index d111d0c..dfe1f8a 100644
@@ -5,37 +5,11 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
 #ifndef __ASM_ARC_PAGE_H
 #define __ASM_ARC_PAGE_H
 
-/* PAGE_SHIFT determines the page size */
-#if defined(CONFIG_ARC_PAGE_SIZE_16K)
-#define PAGE_SHIFT 14
-#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
-#define PAGE_SHIFT 12
-#else
-/*
- * Default 8k
- * done this way (instead of under CONFIG_ARC_PAGE_SIZE_8K) because adhoc
- * user code (busybox appletlib.h) expects PAGE_SHIFT to be defined w/o
- * using the correct uClibc header and in their build our autoconf.h is
- * not available
- */
-#define PAGE_SHIFT 13
-#endif
-
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE	(1 << PAGE_SHIFT)
-#define PAGE_OFFSET	(0x80000000)
-#else
-#define PAGE_SIZE	(1UL << PAGE_SHIFT)	/* Default 8K */
-#define PAGE_OFFSET	(0x80000000UL)	/* Kernel starts at 2G onwards */
-#endif
+#include <uapi/asm/page.h>
 
-#define PAGE_MASK	(~(PAGE_SIZE-1))
-
-#ifdef __KERNEL__
 
 #ifndef __ASSEMBLY__
 
@@ -129,6 +103,4 @@ typedef unsigned long pgtable_t;
 
 #endif /* !__ASSEMBLY__ */
 
-#endif /* __KERNEL__ */
-
 #endif
arch/arc/include/asm/ptrace.h +2 -35
index fd68c4b..a50cfeb 100644
@@ -7,42 +7,11 @@
  *
  * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
  */
-
 #ifndef __ASM_ARC_PTRACE_H
 #define __ASM_ARC_PTRACE_H
 
-/*
- * XXX: ABI hack.
- * The offset calc can be cleanly done in asm-offset.c, however gdb includes
- * this header directly.
- */
-#define PT_bta		4
-#define PT_lp_start	8
-#define PT_lp_end	12
-#define PT_lp_count	16
-#define PT_status32	20
-#define PT_ret		24
-#define PT_blink	28
-#define PT_fp		32
-#define PT_r26		36
-#define PT_r12		40
-#define PT_r11		44
-#define PT_r10		48
-#define PT_r9		52
-#define PT_r8		56
-#define PT_r7		60
-#define PT_r6		64
-#define PT_r5		68
-#define PT_r4		72
-#define PT_r3		76
-#define PT_r2		80
-#define PT_r1		84
-#define PT_r0		88
-#define PT_sp		92
-#define PT_orig_r0	96
-#define PT_orig_r8	100
-
-#ifdef __KERNEL__
+#include <uapi/asm/ptrace.h>
+
 
 #ifndef __ASSEMBLY__
 
@@ -153,6 +122,4 @@ struct user_regs_struct {
 #define orig_r8_IS_IRQ1			0x0010
 #define orig_r8_IS_IRQ2			0x0020
 
-#endif /* __KERNEL__ */
-
 #endif /* __ASM_PTRACE_H */
arch/arc/include/asm/setup.h +2 -1
index fc97411..229e506 100644
@@ -5,11 +5,12 @@
  * 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>
+#include <uapi/asm/setup.h>
 
 #define COMMAND_LINE_SIZE 256
 
arch/arc/include/asm/sigcontext.h deleted +0 -23
deleted file mode 100644
index f21b541..0000000
@@ -1,23 +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.
- */
-
-#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 deleted +0 -27
deleted file mode 100644
index fad62f7..0000000
@@ -1,27 +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.
- *
- * 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/include/asm/swab.h deleted +0 -98

98 lines not on this page · raw message

arch/arc/include/asm/unistd.h deleted +0 -34
deleted file mode 100644
index 6f30484..0000000
@@ -1,34 +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.
- */
-
-/******** no-legacy-syscalls-ABI *******/
-
-#define __ARCH_WANT_SYS_EXECVE
-#define __ARCH_WANT_SYS_CLONE
-#define __ARCH_WANT_SYS_VFORK
-#define __ARCH_WANT_SYS_FORK
-
-#define sys_mmap2 sys_mmap_pgoff
-
-#include <asm-generic/unistd.h>
-
-#define NR_syscalls	__NR_syscalls
-
-/* ARC specific syscall */
-#define __NR_cacheflush		(__NR_arch_specific_syscall + 0)
-#define __NR_arc_settls		(__NR_arch_specific_syscall + 1)
-#define __NR_arc_gettls		(__NR_arch_specific_syscall + 2)
-
-__SYSCALL(__NR_cacheflush, sys_cacheflush)
-__SYSCALL(__NR_arc_settls, sys_arc_settls)
-__SYSCALL(__NR_arc_gettls, sys_arc_gettls)
-
-
-/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
-#define __NR_sysfs		(__NR_arch_specific_syscall + 3)
-__SYSCALL(__NR_sysfs, sys_sysfs)
arch/arc/include/uapi/asm/Kbuild new file +11 -0
new file mode 100644
index 0000000..2736244
@@ -0,0 +1,11 @@
+# UAPI Header export list
+include include/uapi/asm-generic/Kbuild.asm
+header-y += page.h
+header-y += setup.h
+header-y += byteorder.h
+header-y += cachectl.h
+header-y += ptrace.h
+header-y += sigcontext.h
+header-y += signal.h
+header-y += swab.h
+header-y += unistd.h
arch/arc/include/uapi/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/uapi/asm/cachectl.h new file +28 -0
new file mode 100644
index 0000000..51c73f0
@@ -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 __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_FLUSH_INV	0x0020
+
+#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/uapi/asm/page.h new file +39 -0
new file mode 100644
index 0000000..e5d41e0
@@ -0,0 +1,39 @@
+/*
+ * 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 _UAPI__ASM_ARC_PAGE_H
+#define _UAPI__ASM_ARC_PAGE_H
+
+/* PAGE_SHIFT determines the page size */
+#if defined(CONFIG_ARC_PAGE_SIZE_16K)
+#define PAGE_SHIFT 14
+#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
+#define PAGE_SHIFT 12
+#else
+/*
+ * Default 8k
+ * done this way (instead of under CONFIG_ARC_PAGE_SIZE_8K) because adhoc
+ * user code (busybox appletlib.h) expects PAGE_SHIFT to be defined w/o
+ * using the correct uClibc header and in their build our autoconf.h is
+ * not available
+ */
+#define PAGE_SHIFT 13
+#endif
+
+#ifdef __ASSEMBLY__
+#define PAGE_SIZE	(1 << PAGE_SHIFT)
+#define PAGE_OFFSET	(0x80000000)
+#else
+#define PAGE_SIZE	(1UL << PAGE_SHIFT)	/* Default 8K */
+#define PAGE_OFFSET	(0x80000000UL)	/* Kernel starts at 2G onwards */
+#endif
+
+#define PAGE_MASK	(~(PAGE_SIZE-1))
+
+
+#endif /* _UAPI__ASM_ARC_PAGE_H */
arch/arc/include/uapi/asm/ptrace.h new file +46 -0

46 lines not on this page · raw message

arch/arc/include/uapi/asm/setup.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arc/include/uapi/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/uapi/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/include/uapi/asm/swab.h new file +98 -0

98 lines not on this page · raw message

arch/arc/include/uapi/asm/unistd.h new file +34 -0
new file mode 100644
index 0000000..6f30484
@@ -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.
+ */
+
+/******** no-legacy-syscalls-ABI *******/
+
+#define __ARCH_WANT_SYS_EXECVE
+#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_SYS_VFORK
+#define __ARCH_WANT_SYS_FORK
+
+#define sys_mmap2 sys_mmap_pgoff
+
+#include <asm-generic/unistd.h>
+
+#define NR_syscalls	__NR_syscalls
+
+/* ARC specific syscall */
+#define __NR_cacheflush		(__NR_arch_specific_syscall + 0)
+#define __NR_arc_settls		(__NR_arch_specific_syscall + 1)
+#define __NR_arc_gettls		(__NR_arch_specific_syscall + 2)
+
+__SYSCALL(__NR_cacheflush, sys_cacheflush)
+__SYSCALL(__NR_arc_settls, sys_arc_settls)
+__SYSCALL(__NR_arc_gettls, sys_arc_gettls)
+
+
+/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
+#define __NR_sysfs		(__NR_arch_specific_syscall + 3)
+__SYSCALL(__NR_sysfs, sys_sysfs)
Signature · 1 line
1.7.4.1
#115 lore raw

Re: [PATCH v2 65/76] ARC: UAPI Disintegrate arch/arc/include/asm

Quoted 7 lines · Vineet Gupta

1. ./genfilelist.pl arch/arc/include/asm/

2. Create arch/arc/include/uapi/asm/Kbuild as follows

+# UAPI Header export list
+include include/uapi/asm-generic/Kbuild.asm

Quoted 7 lines

3. ./disintegrate-one.pl arch/arc/include/{,uapi/}asm/<above-list>

4. Edit arch/arc/include/asm/Kbuild to remove ref to asm-generic/Kbuild.asm

Hi David,

I generated this patch using the scripts you provided. If these look OK to you, can you please ACK.

Thx,
-Vineet

#116 lore raw

Re: [PATCH v2 65/76] ARC: UAPI Disintegrate arch/arc/include/asm

Quoted 2 lines · Vineet Gupta

I generated this patch using the scripts you provided. If these look OK to you, can you please ACK.

You need to take a look at uapi/asm/setup.h. It's created as an empty file - which will get discarded by patch. Do you actually need a UAPI instance of that?

David

#117 lore raw

Re: [PATCH v2 65/76] ARC: UAPI Disintegrate arch/arc/include/asm

Quoted 9 lines · David Howells
Quoted 2 lines · Vineet Gupta

I generated this patch using the scripts you provided. If these look OK to you, can you please ACK.

You need to take a look at uapi/asm/setup.h. It's created as an empty file - which will get discarded by patch. Do you actually need a UAPI instance of that?

David

Nope, I don't - but ./genfilelist.pl seems to be generating a reference to it (even if I add #ifdef __KERNEL__)
How do I work around this ! Do I skip it when running ./disintegrate-one.pl - but then it won't be completely scripted :-(

-Vineet

#118 lore raw

Re: [PATCH v2 65/76] ARC: UAPI Disintegrate arch/arc/include/asm

In reply to David Howells
Quoted 11 lines · David Howells
Quoted 2 lines · Vineet Gupta

I generated this patch using the scripts you provided. If these look OK to you, can you please ACK.

You need to take a look at uapi/asm/setup.h. It's created as an empty file - which will get discarded by patch. Do you actually need a UAPI instance of that?

David

Given that setup.h is exported by include/uapi/asm-generic/Kbuild.asm (as part of userspace header ABI) there's no way we can avoid it's uapi sibling - even if empty. But to workaround patch discarding it, I will add a placeholder comment in generated setup.h (just like you did for arch/cris). Would that take care of it ?

BTW looking at metag port, it seems that <asm/setup.h> does #include <uapi/asm/setup.h>, but latter doesn't exist in the repository - is it generated for you James or is this same issue which David elucidated to above ?

-Vineet

#119 lore raw

Re: [PATCH v2 65/76] ARC: UAPI Disintegrate arch/arc/include/asm

Hi Vineet,

Quoted 13 lines · Vineet Gupta
Quoted 11 lines · David Howells
Quoted 2 lines · Vineet Gupta

I generated this patch using the scripts you provided. If these look OK to you, can you please ACK.

You need to take a look at uapi/asm/setup.h. It's created as an empty file - which will get discarded by patch. Do you actually need a UAPI instance of that?

David

Quoted 8 lines

Given that setup.h is exported by include/uapi/asm-generic/Kbuild.asm (as part of userspace header ABI) there's no way we can avoid it's uapi sibling - even if empty. But to workaround patch discarding it, I will add a placeholder comment in generated setup.h (just like you did for arch/cris). Would that take care of it ?

BTW looking at metag port, it seems that <asm/setup.h> does #include <uapi/asm/setup.h>, but latter doesn't exist in the repository - is it generated for you James or is this same issue which David elucidated to above ?

We have generic-y += setup.h in arch/metag/include/uapi/asm/Kbuild for this

Cheers
James

#120 lore raw

Re: [PATCH v2 65/76] ARC: UAPI Disintegrate arch/arc/include/asm

Quoted 6 lines · James Hogan
Quoted 4 lines

BTW looking at metag port, it seems that <asm/setup.h> does #include <uapi/asm/setup.h>, but latter doesn't exist in the repository - is it generated for you James or is this same issue which David elucidated to above ?

We have generic-y += setup.h in arch/metag/include/uapi/asm/Kbuild for this

Vineet can't do that as his COMMAND_LINE_SIZE is different to the standard and also not placed in his UAPI setup.h.

So far, only user-mode Linux and x86 don't put COMMAND_LINE_SIZE in uapi/asm/setup.h. Everything else does.

grep -r 'define\s*COMMAND_LINE_SIZE' arch/*/include | grep -v /uapi/

Not sure if that's needed to build a bootloader or not.

David

#121 lore raw

PATCH v2 66/76 ARC: Add support for ioremap_prot API

In reply to Vineet Gupta

From: Gilad Ben-Yossef <[email protected]>

Implement ioremap_prot() to allow mapping IO memory with variable protection via TLB.

Implementing this allows the /dev/mem driver to use its generic access() VMA callback, which in turn allows ptrace to examine data in memory mapped regions mapped via /dev/mem, such as Arc DCCM.

The end result is that it is possible to examine values of variables placed into DCCM in user space programs via GDB.

---
 arch/arc/Kconfig            |    1 +
 arch/arc/include/asm/io.h   |    2 +
 arch/arc/include/asm/page.h |    3 ++
 arch/arc/mm/ioremap.c       |   58 ++++++++++++++++++++++++++++++------------
 4 files changed, 47 insertions(+), 17 deletions(-)
arch/arc/Kconfig +1 -0
index 9202c1a..d73e69b 100644
@@ -26,6 +26,7 @@ config ARC
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_GENERIC_HARDIRQS
+	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_WORK
 	select HAVE_KPROBES
 	select HAVE_KRETPROBES
arch/arc/include/asm/io.h +2 -0
index b2221f5..9ae833c 100644
@@ -13,6 +13,8 @@
 #include <asm/page.h>
 
 extern void __iomem *ioremap(unsigned long physaddr, unsigned long size);
+extern void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
+				  unsigned long flags);
 extern void iounmap(const void __iomem *addr);
 
 #define ioremap_nocache(phy, sz)	ioremap(phy, sz)
arch/arc/include/asm/page.h +3 -0
index dfe1f8a..bdf5461 100644
@@ -48,6 +48,8 @@ typedef unsigned long pgtable_t;
 #define __pgd(x)        ((pgd_t) { (x) })
 #define __pgprot(x)     ((pgprot_t) { (x) })
 
+#define pte_pgprot(x) __pgprot(pte_val(x))
+
 #else /* !STRICT_MM_TYPECHECKS */
 
 typedef unsigned long pte_t;
@@ -60,6 +62,7 @@ typedef unsigned long pgtable_t;
 #define pgprot_val(x)	(x)
 #define __pte(x)	(x)
 #define __pgprot(x)	(x)
+#define pte_pgprot(x)	(x)
 
 #endif
 
arch/arc/mm/ioremap.c +41 -17

82 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#122 lore raw

PATCH v2 67/76 ARC: [Review] Multi-platform image #1: Kconfig enablement

In reply to Vineet Gupta

This mini patchseries addresses the lack of multi-platform-image support in ARC port.

Older build system only supported one platform(soc) to build at a time and further only one board of that platform could be built. There was no technical reason for that - we just didn't have the need.

So the first step towards multi-platform (and multi-board) builds it to allow build system to do that.

So as applicable, <choice .. endchoice> => <menu .. endmenu>

---
 arch/arc/Kconfig              |    6 ++----
 arch/arc/plat-arcfpga/Kconfig |    5 ++---
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/arc/Kconfig +2 -4
index d73e69b..414e53d 100644
@@ -82,9 +82,7 @@ source "kernel/Kconfig.freezer"
 
 menu "ARC Architecture Configuration"
 
-choice
-	prompt "ARC Platform"
-	default ARC_PLAT_FPGA_LEGACY
+menu "ARC Platform/SoC"
 
 config ARC_PLAT_FPGA_LEGACY
 	bool "\"Legacy\" ARC FPGA dev platform"
@@ -96,7 +94,7 @@ config ARC_PLAT_FPGA_LEGACY
 	  - MetaWare ISS
 
 #New platform adds here
-endchoice
+endmenu
 
 menu "ARC CPU Configuration"
 
arch/arc/plat-arcfpga/Kconfig +2 -3
index 86b7377..4b6c042 100644
@@ -8,8 +8,7 @@
 
 if ARC_PLAT_FPGA_LEGACY
 
-choice
-	prompt "FPGA Board"
+menu "FPGA Board"
 
 config ARC_BOARD_ANGEL4
 	bool "ARC Angel4"
@@ -34,7 +33,7 @@ config ISS_SMP_EXTN
 	  -XTL (To enable CPU start/stop/set-PC for another CPU)
 	  It doesn't provide coherent Caches and/or Atomic Ops (LLOCK/SCOND)
 
-endchoice
+endmenu
 
 config ARC_SERIAL_BAUD
 	int "UART Baud rate"
Signature · 1 line
1.7.4.1
maintainer Acked-by on v2 67/76
#123 lore raw

Re: [PATCH v2 67/76] ARC: [Review] Multi-platform image #1: Kconfig enablement

Quoted 7 lines · Vineet Gupta

This mini patchseries addresses the lack of multi-platform-image support in ARC port.

Older build system only supported one platform(soc) to build at a time and further only one board of that platform could be built. There was no technical reason for that - we just didn't have the need.

Quoted 7 lines

So the first step towards multi-platform (and multi-board) builds it to allow build system to do that.

So as applicable, <choice .. endchoice> => <menu .. endmenu>

#124 lore raw

PATCH v2 68/76 ARC: Fold boards sub-menu into platform/SoC menu

In reply to Vineet Gupta

This is more natural and is now doable since the choice constructs are gone.

---
 arch/arc/Kconfig              |   21 +++------------------
 arch/arc/plat-arcfpga/Kconfig |   14 ++++++++++----
 2 files changed, 13 insertions(+), 22 deletions(-)
arch/arc/Kconfig +3 -18
index 414e53d..21ecd2a 100644
@@ -82,18 +82,11 @@ source "kernel/Kconfig.freezer"
 
 menu "ARC Architecture Configuration"
 
-menu "ARC Platform/SoC"
-
-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
-	  - MetaWare ISS
+menu "ARC Platform/SoC/Board"
 
+source "arch/arc/plat-arcfpga/Kconfig"
 #New platform adds here
+
 endmenu
 
 menu "ARC CPU Configuration"
@@ -343,12 +336,6 @@ config ARC_HAS_RTSC
 
 endmenu   # "ARC CPU Configuration"
 
-menu "Platform Board Configuration"
-
-source "arch/arc/plat-arcfpga/Kconfig"
-
-#New platform adds here
-
 config LINUX_LINK_BASE
 	hex "Linux Link Address"
 	default "0x80000000"
@@ -362,8 +349,6 @@ config LINUX_LINK_BASE
 	  Linux needs to be scooted a bit.
 	  If you don't know what the above means, leave this setting alone.
 
-endmenu # "Platform Board Configuration"
-
 config ARC_CURR_IN_REG
 	bool "Dedicate Register r25 for current_task pointer"
 	default y
arch/arc/plat-arcfpga/Kconfig +10 -4
index 4b6c042..6001784 100644
@@ -6,12 +6,20 @@
 # published by the Free Software Foundation.
 #
 
-if ARC_PLAT_FPGA_LEGACY
+menuconfig ARC_PLAT_FPGA_LEGACY
+	bool "\"Legacy\" ARC FPGA dev Boards"
+	help
+	  Support for ARC development boards, provided by Synopsys.
+	  These are based on FPGA or ISS. e.g.
+	  - ARCAngel4
+	  - ML509
+	  - MetaWare ISS
 
-menu "FPGA Board"
+if ARC_PLAT_FPGA_LEGACY
 
 config ARC_BOARD_ANGEL4
 	bool "ARC Angel4"
+	default y
 	help
 	  ARC Angel4 FPGA Ref Platform (Xilinx Virtex Based)
 
@@ -33,8 +41,6 @@ config ISS_SMP_EXTN
 	  -XTL (To enable CPU start/stop/set-PC for another CPU)
 	  It doesn't provide coherent Caches and/or Atomic Ops (LLOCK/SCOND)
 
-endmenu
-
 config ARC_SERIAL_BAUD
 	int "UART Baud rate"
 	default "115200"
Signature · 1 line
1.7.4.1
#126 lore raw

PATCH v2 69/76 ARC: [Review] Multi-platform image #2: Board callback Infrastructure

In reply to Vineet Gupta

The orig platform code orgnaization was singleton design pattern - only one platform (and board thereof) would build at a time.

Thus any platform/board specific code (e.g. irq init, early init ...) expected by ARC common code was exported as well defined set of APIs, with only ONE instance building ever.

Now with multiple-platform build requirement, that design of code no longer holds - multiple board specific calls need to build at the same time - so ARC common code can't use the API approach, it needs a callback based design where each board registers it's specific set of functions, and at runtime, depending on board detection, the callbacks are used from the registry.

This commit adds all the infrastructure, where board specific callbacks are specified as a "machine description".

All the hooks are placed in right spots, no board callbacks registered yet (with MACHINE_STARt/END constructs) so the hooks will not run.

Next commit will actually convert the platform to this infrastructure.

---
 arch/arc/include/asm/mach_desc.h |   85 ++++++++++++++++++++++++++++++++++++++
 arch/arc/include/asm/prom.h      |    1 -
 arch/arc/kernel/devtree.c        |   47 +++++++++++++++++----
 arch/arc/kernel/irq.c            |    7 +++
 arch/arc/kernel/setup.c          |   28 +++++++++++-
 arch/arc/kernel/smp.c            |    3 +
 arch/arc/kernel/time.c           |    4 ++
 arch/arc/kernel/vmlinux.lds.S    |    6 +++
 8 files changed, 169 insertions(+), 12 deletions(-)
 create mode 100644 arch/arc/include/asm/mach_desc.h
arch/arc/include/asm/mach_desc.h new file +85 -0
new file mode 100644
index 0000000..65cde1f
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * based on METAG mach/arch.h (which in turn was based on ARM)
+ *
+ * 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_MACH_DESC_H_
+#define _ASM_ARC_MACH_DESC_H_
+
+/**
+ * struct machine_desc - Board specific callbacks, called from ARC common code
+ *	Provided by each ARC board using MACHINE_START()/MACHINE_END(), so
+ *	a multi-platform kernel builds with array of such descriptors.
+ *	We extend the early DT scan to also match the DT's "compatible" string
+ *	against the @dt_compat of all such descriptors, and one with highest
+ *	"DT score" is selected as global @machine_desc.
+ *
+ * @name:		Board/SoC name
+ * @dt_compat:		Array of device tree 'compatible' strings
+ * 			(XXX: although only 1st entry is looked at)
+ * @init_early:		Very early callback [called from setup_arch()]
+ * @init_irq:		setup external IRQ controllers [called from init_IRQ()]
+ * @init_time:		platform specific clocksource/clockevent registration
+ * 			[called from time_init()]
+ * @init_machine:	arch initcall level callback (e.g. populate static
+ * 			platform devices or parse Devicetree)
+ * @init_late:		Late initcall level callback
+ * @init_smp:		for each CPU (e.g. setup IPI)
+ * 			[(M):init_IRQ(), (o):start_kernel_secondary()]
+ *
+ */
+struct machine_desc {
+	const char		*name;
+	const char		**dt_compat;
+
+	void			(*init_early)(void);
+	void			(*init_irq)(void);
+	void			(*init_time)(void);
+	void			(*init_machine)(void);
+	void			(*init_late)(void);
+
+#ifdef CONFIG_SMP
+	void			(*init_smp)(unsigned int);
+#endif
+};
+
+/*
+ * Current machine - only accessible during boot.
+ */
+extern struct machine_desc *machine_desc;
+
+/*
+ * Machine type table - also only accessible during boot
+ */
+extern struct machine_desc __arch_info_begin[], __arch_info_end[];
+#define for_each_machine_desc(p)			\
+	for (p = __arch_info_begin; p < __arch_info_end; p++)
+
+static inline struct machine_desc *default_machine_desc(void)
+{
+	/* the default machine is the last one linked in */
+	if (__arch_info_end - 1 < __arch_info_begin)
+		return NULL;
+	return __arch_info_end - 1;
+}
+
+/*
+ * Set of macros to define architecture features.
+ * This is built into a table by the linker.
+ */
+#define MACHINE_START(_type, _name)			\
+static const struct machine_desc __mach_desc_##_type	\
+__used							\
+__attribute__((__section__(".arch.info.init"))) = {	\
+	.name		= _name,
+
+#define MACHINE_END				\
+};
+
+extern struct machine_desc *setup_machine_fdt(void *dt);
+#endif
arch/arc/include/asm/prom.h +0 -1
index f54489b..692d0d0 100644
@@ -10,6 +10,5 @@
 #define _ASM_ARC_PROM_H_
 
 #define HAVE_ARCH_DEVTREE_FIXUPS
-extern int __init setup_machine_fdt(void *dt);
 
 #endif
arch/arc/kernel/devtree.c +39 -8

77 lines not on this page · raw message

arch/arc/kernel/irq.c +7 -0
index df7da2b..1198168 100644
@@ -13,6 +13,7 @@
 #include <linux/irqdomain.h>
 #include <asm/sections.h>
 #include <asm/irq.h>
+#include <asm/mach_desc.h>
 
 /*
  * Early Hardware specific Interrupt setup
@@ -125,9 +126,15 @@ void __init init_IRQ(void)
 	init_onchip_IRQ();
 	plat_init_IRQ();
 
+	/* Any external intc can be setup here */
+	if (machine_desc->init_irq)
+		machine_desc->init_irq();
+
 #ifdef CONFIG_SMP
 	/* Master CPU can initialize it's side of IPI */
 	arc_platform_smp_init_cpu();
+	if (machine_desc->init_smp)
+		machine_desc->init_smp(smp_processor_id());
 #endif
 }
 
arch/arc/kernel/setup.c +25 -3
index 6cc361c..20273b8 100644
@@ -25,12 +25,14 @@
 #include <asm/prom.h>
 #include <asm/unwind.h>
 #include <asm/clk.h>
+#include <asm/mach_desc.h>
 
 #define FIX_PTR(x)  __asm__ __volatile__(";" : "+r"(x))
 
 int running_on_hw = 1;	/* vs. on ISS */
 
 char __initdata command_line[COMMAND_LINE_SIZE];
+struct machine_desc *machine_desc __initdata;
 
 struct task_struct *_current_task[NR_CPUS];	/* For stack switching */
 
@@ -323,8 +325,6 @@ void __init __attribute__((weak)) arc_platform_early_init(void)
 
 void __init setup_arch(char **cmdline_p)
 {
-	int rc;
-
 #ifdef CONFIG_CMDLINE_UBOOT
 	/* Make sure that a whitespace is inserted before */
 	strlcat(command_line, " ", sizeof(command_line));
@@ -339,13 +339,17 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
-	rc = setup_machine_fdt(__dtb_start);
+	machine_desc = setup_machine_fdt(__dtb_start);
+	if (!machine_desc)
+		panic("Embedded DT invalid\n");
 
 	/* To force early parsing of things like mem=xxx */
 	parse_early_param();
 
 	/* Platform/board specific: e.g. early console registration */
 	arc_platform_early_init();
+	if (machine_desc->init_early)
+		machine_desc->init_early();
 
 	setup_processor();
 
@@ -372,6 +376,24 @@ void __init setup_arch(char **cmdline_p)
 	arc_unwind_setup();
 }
 
+static int __init customize_machine(void)
+{
+	/* Add platform devices */
+	if (machine_desc->init_machine)
+		machine_desc->init_machine();
+
+	return 0;
+}
+arch_initcall(customize_machine);
+
+static int __init init_late_machine(void)
+{
+	if (machine_desc->init_late)
+		machine_desc->init_late();
+
+	return 0;
+}
+late_initcall(init_late_machine);
 /*
  *  Get CPU information for use by the procfs.
  */
arch/arc/kernel/smp.c +3 -0
index 5530b64..0f6212c 100644
@@ -32,6 +32,7 @@
 #include <linux/reboot.h>
 #include <asm/processor.h>
 #include <asm/setup.h>
+#include <asm/mach_desc.h>
 
 arch_spinlock_t smp_atomic_ops_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 arch_spinlock_t smp_bitops_lock = __ARCH_SPIN_LOCK_UNLOCKED;
@@ -126,6 +127,8 @@ void __cpuinit start_kernel_secondary(void)
 	pr_info("## CPU%u LIVE ##: Executing Code...\n", cpu);
 
 	arc_platform_smp_init_cpu();
+	if (machine_desc->init_smp)
+		machine_desc->init_smp(smp_processor_id());
 
 	arc_local_timer_setup(cpu);
 
arch/arc/kernel/time.c +4 -0
index c068f31..2aee882 100644
@@ -43,6 +43,7 @@
 #include <asm/irq.h>
 #include <asm/arcregs.h>
 #include <asm/clk.h>
+#include <asm/mach_desc.h>
 
 #define ARC_TIMER_MAX	0xFFFFFFFF
 
@@ -254,6 +255,9 @@ void __init time_init(void)
 
 	/* sets up the periodic event timer */
 	arc_local_timer_setup(smp_processor_id());
+
+	if (machine_desc->init_time)
+		machine_desc->init_time();
 }
 
 #ifdef CONFIG_ARC_HAS_RTSC
arch/arc/kernel/vmlinux.lds.S +6 -0
index 3b6a21a..7549b49 100644
@@ -76,6 +76,12 @@ SECTIONS
 		SECURITY_INITCALL
 	}
 
+	.init.arch.info : {
+		__arch_info_begin = .;
+		*(.arch.info.init)
+		__arch_info_end = .;
+	}
+
 	PERCPU_SECTION(L1_CACHE_BYTES)
 
 	/*
Signature · 1 line
1.7.4.1