tile: avoid overflow in ns2cycles

In commit 4cecf6d401a ("sched, x86: Avoid unnecessary overflow in
sched_clock") and in recent patch "clocksource: avoid unnecessary
overflow in cyclecounter_cyc2ns()" https://lkml.org/lkml/2014/3/4/17,
the mult-shift approach is replaced by 2 steps to avoid storing a large,
intermediate value that could overflow.

arch/tile/kernel/time.c has a similar pattern in cycles2ns, and this
copies the same pattern in this function

CC: John Stultz <johnstul@us.ibm.com>
CC: Mike Galbraith <bitbucket@online.de>
CC: Salman Qazi <sqazi@google.com>
Signed-off-by: Henrik Austad <henrik@austad.us>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
tile: don't use __get_cpu_var() with structure-typed arguments

This no longer works with the new per-cpu infrastructure.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
tile: Add support for handling PMC hardware

The PMC module is used by perf_events, oprofile and watchdogs.

Signed-off-by: Zhigang Lu <zlu@tilera.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
tile: Enable NMIs on return from handle_nmi() without errors

NMI interrupts mask ALL interrupts before calling the handler,
so we need to unmask NMIs according to the value handle_nmi() returns.
If it returns zero, the NMIs should be re-enabled; if it returns
a non-zero error, the NMIs should be disabled.

Signed-off-by: Zhigang Lu <zlu@tilera.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
tile/perf: Support perf_events on tilegx and tilepro

Add perf support for tile architecture.

Signed-off-by: Zhigang Lu <zlu@tilera.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
perf tools: Allow building for tile

Tested by building perf:
- Cross-compiled for tile on x86_64
- Built natively on tile

Signed-off-by: Zhigang Lu <zlu@tilera.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
tile: Fix vDSO compilation issue with allyesconfig

make allyesconfig give the following build error on tile:
 tilegx-linux-gcc: error: arch/tile/kernel/vdso/vgettimeofday32.o: No such file or directory
 tilegx-linux-objcopy: 'arch/tile/kernel/vdso/vdso32.so.dbg': No such file or directory

In case with CONFIG_MODVERSIONS, cmd_cc_o_c generate .tmp_<file>.o from
<file>.c only. Fix it by execute rule_cc_o_c instead.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Kerry Sheh <ksheh@tilera.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
arch/tile: remove unused variable 'devcap'

Commit 503275bf37 removed the use of the variable but not
the variable itself.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile

Pull arch/tile updates from Chris Metcalf:
 "These fix a few stray build issues seen in linux-next, and also add
  the minimal required support for perf to tilegx"

* git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile:
  arch/tile: remove unused variable 'devcap'
  tile: Fix vDSO compilation issue with allyesconfig
  perf tools: Allow building for tile
  tile/perf: Support perf_events on tilegx and tilepro
  tile: Enable NMIs on return from handle_nmi() without errors
  tile: Add support for handling PMC hardware
  tile: don't use __get_cpu_var() with structure-typed arguments
  tile: avoid overflow in ns2cycles