ARC: Interrupt Handling

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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
ARC: Non-MMU Exception Handling

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: syscall support

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Arnd Bergmann <arnd@arndb.de>
ARC: backend for process-creation/scheduling/idle-task

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Timers/counters/delay management

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).

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: RTSC insn for true 64bit clocksource / sched_clock()

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review] Revert to using setup_irq() for TIMER0 Interrupt

In the good old days we had setup_irq(TIMER0)

With SMP, since the local timer setup was called by each CPU, the static
irqaction was not usable - so we resorted to using request_irq() - which
considered multiple calls for same device (from multiple cpus) as
multiple registrations from same cpu (IRQF_SHARED semantics) and failed
in absence thereof.

So the right APIs for job were request_percpu_irq()/enable_percpu_irq()
but these required an apriori irq_set_percpu_devid() to ensure that the
devid passed to these APIs was indeed percpu. This in turn had a
side-effect of setting IRQ_NOAUTOEN which had to be explicitly cleared.

This patch tries to remove all of the fixups since SMP.

We go back to calling setup_irq(), although this time, only on boot-cpu
and also make sure TIMER0 IRQ is explicitly unmasked per CPU.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Signal handling

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
ARC: [Review] 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 e POKEUSR(callee-reg) from a tracer.

Thanks to Al Viro for pointing this potential issue.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
ARC: [Review] Preparing to fix incorrect syscall restarts due to signals

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.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
ARC: [Review] Prevent incorrect syscall restarts

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.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
ARC: Cache Flush Management

* 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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Page Table Management

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: MMU Context Management

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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: MMU Exception Handling

* 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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: TLB flush Handling

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Page Fault handling

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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: I/O and DMA Mappings

TBD: Do we need early ioremap support like openrisc

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: startup #1: low-level, setup_arch(), /proc/cpuinfo, mem init

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [plat-arcfpga] Hooking up platform to ARC UART

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>