ARC: [Review/signals] Re-enable IRQs before do_signal/notify_resume

Also remove the misleading comment - as we should not rely on
intermediate functions to re-enable interrupts.

This also fixes a bootup warning seen with initial 3.7 ARC port

------------------>8------------------------------------------
NET: Registered protocol family 17
Freeing unused kernel memory: 4576k [80002000] to [8047a000]
------------[ cut here ]------------
WARNING: at kernel/softirq.c:160 local_bh_enable+0x68/0x84()
Modules linked in:

Stack Trace:
  arc_unwind_core+0xa8/0x108
  warn_slowpath_common+0x56/0xf8
  local_bh_enable+0x68/0x84
  unix_release_sock+0x70/0x21c
  sock_close+0x22/0xac
  __fput+0x4c/0x154
  task_work_run+0x50/0x98
  chk_next_work+0x8/0xc
---[ end trace e4b36c66ca115416 ]---
init started: BusyBox v1.20.2 (2012-12-04 15:01:18 CET)
------------------>8------------------------------------------

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review/signals] Re-check for pending signals after notify_resume

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
modpost: Add both ARC sections

ARC object files contain multiple .gnu.linkonce.arcext* sections, while
we need a single aggregated .arcextmap section for external debuggers.

kernel/vmlinux.lds has been doing this aggregation forever, however it
only applies to vmlinux.o => vmlinux linkage, vmlinux.o still has the
non-aggregated .gnu.* sections, which is the one scanned by modpost,
hence we were ok with corresponding entry in modprobe ignore list.

GNU Linker scripts recently started aggregating them into .arcextmap
section, thus vmlinux.o now has aggregated .arcextmap. Thus in theory
we now only need .arcextmap entry is modprobe ignore list. The prev
commit did just that.

The issue however is, when building loadable modules, modprobe scans
each object file individually, which still have the non-aggregated
.gnu.* sections.

Thus we need both the entries in ignore list.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review/signals] 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>
ARC: [Review/signals] Preparing to fix incorrect syscall restarts

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>
ARC: [Review/signals] 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>
ARC: [Review/IRQ] local_irq_enable to not enable IRQs in hard isr ctxt

While the prev version also semantically did that - this one is more
clearer about intentions and also warns about the offending caller.

ARC IDE Disk Driver is one of the last few callers who still tries to do
that.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review/IRQ] Use different API for clearing IRQ status flag

-from tglx

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review/timers] Renames and other cosmetics

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review/timers] Revert back to jiffies based sched_clock()

Per tglx, the current getrawmonotic() based sched_clock() can livelock
if called from inside a write seqlocked section (e.g. tracer).

We need true 64bit monotonically increasing semantics which the 32bit
ARC timers (TIMER0/1) can't gaurantee - w/o a clone implementation of
clocksources code in ARCH code (to avoid locking)

Hence falling back to orig jiffie based implementation which despite
NOT being very granular - gaurantees above semantics.

(Note that we need to use jiffies_64 and not jiffies, as latter only
uses the lower word of 64 bit value).

This will improve once we have support for the newer 64bit RTSC insn.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Move timer high priority setting into common code

* No need to duplicate it in every arch
* If high priority interrupts enabled, timer HAS to be high priority.
* Makign serial high prioity doesn't make sense at all

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Move on-chip intc setting into common code

This reduces duplication in platforms which don't have external intc

Even if they have intc, not all IRQs are cascaded, so the internal ones
are taken care of by common ARC code

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

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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [Review] Use right APIs in cpu_idle()

Tracks
* 1268fbc746 "nohz: Remove tick_nohz_idle_enter_norcu()" and
* bd2f55361f "sched/rt: Use schedule_preempt_disabled()"

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: 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: [DeviceTree] Basic support

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

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Preparing to eliminate CONFIG_ARC_PLAT_SDRAM_SIZE

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: [DeviceTree] mem size now runtime configured

Gets rid of CONFIG_ARC_PLAT_SDRAM_SIZE

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
ARC: Preparing to eliminate CONFIG_ARC_PLAT_CLK

Abstracting references to core CPU clk to enable it runtime configurable

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