]> Pileus Git - ~andy/linux/commitdiff
Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 13 Nov 2013 23:51:29 +0000 (08:51 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 13 Nov 2013 23:51:29 +0000 (08:51 +0900)
Pull ARM updates from Russell King:
 "Included in this series are:

   1. BE8 (modern big endian) changes for ARM from Ben Dooks
   2. big.Little support from Nicolas Pitre and Dave Martin
   3. support for LPAE systems with all system memory above 4GB
   4. Perf updates from Will Deacon
   5. Additional prefetching and other performance improvements from Will.
   6. Neon-optimised AES implementation fro Ard.
   7. A number of smaller fixes scattered around the place.

  There is a rather horrid merge conflict in tools/perf - I was never
  notified of the conflict because it originally occurred between Will's
  tree and other stuff.  Consequently I have a resolution which Will
  forwarded me, which I'll forward on immediately after sending this
  mail.

  The other notable thing is I'm expecting some build breakage in the
  crypto stuff on ARM only with Ard's AES patches.  These were merged
  into a stable git branch which others had already pulled, so there's
  little I can do about this.  The problem is caused because these
  patches have a dependency on some code in the crypto git tree - I
  tried requesting a branch I can pull to resolve these, and all I got
  each time from the crypto people was "we'll revert our patches then"
  which would only make things worse since I still don't have the
  dependent patches.  I've no idea what's going on there or how to
  resolve that, and since I can't split these patches from the rest of
  this pull request, I'm rather stuck with pushing this as-is or
  reverting Ard's patches.

  Since it should "come out in the wash" I've left them in - the only
  build problems they seem to cause at the moment are with randconfigs,
  and since it's a new feature anyway.  However, if by -rc1 the
  dependencies aren't in, I think it'd be best to revert Ard's patches"

I resolved the perf conflict roughly as per the patch sent by Russell,
but there may be some differences.  Any errors are likely mine.  Let's
see how the crypto issues work out..

* 'for-linus' of git://git.linaro.org/people/rmk/linux-arm: (110 commits)
  ARM: 7868/1: arm/arm64: remove atomic_clear_mask() in "include/asm/atomic.h"
  ARM: 7867/1: include: asm: use 'int' instead of 'unsigned long' for 'oldval' in atomic_cmpxchg().
  ARM: 7866/1: include: asm: use 'long long' instead of 'u64' within atomic.h
  ARM: 7871/1: amba: Extend number of IRQS
  ARM: 7887/1: Don't smp_cross_call() on UP devices in arch_irq_work_raise()
  ARM: 7872/1: Support arch_irq_work_raise() via self IPIs
  ARM: 7880/1: Clear the IT state independent of the Thumb-2 mode
  ARM: 7878/1: nommu: Implement dummy early_paging_init()
  ARM: 7876/1: clear Thumb-2 IT state on exception handling
  ARM: 7874/2: bL_switcher: Remove cpu_hotplug_driver_{lock,unlock}()
  ARM: footbridge: fix build warnings for netwinder
  ARM: 7873/1: vfp: clear vfp_current_hw_state for dying cpu
  ARM: fix misplaced arch_virt_to_idmap()
  ARM: 7848/1: mcpm: Implement cpu_kill() to synchronise on powerdown
  ARM: 7847/1: mcpm: Factor out logical-to-physical CPU translation
  ARM: 7869/1: remove unused XSCALE_PMU Kconfig param
  ARM: 7864/1: Handle 64-bit memory in case of 32-bit phys_addr_t
  ARM: 7863/1: Let arm_add_memory() always use 64-bit arguments
  ARM: 7862/1: pcpu: replace __get_cpu_var_uses
  ARM: 7861/1: cacheflush: consolidate single-CPU ARMv7 cache disabling code
  ...

18 files changed:
1  2 
arch/arm/Kconfig
arch/arm/Kconfig.debug
arch/arm/Makefile
arch/arm/common/Makefile
arch/arm/include/asm/Kbuild
arch/arm/kernel/module.c
arch/arm/kernel/setup.c
arch/arm/mach-highbank/Kconfig
arch/arm/mach-tegra/Kconfig
arch/arm/mach-vexpress/Kconfig
arch/arm/mm/dma-mapping.c
arch/arm64/kernel/perf_event.c
drivers/bus/arm-cci.c
include/linux/amba/bus.h
tools/perf/config/Makefile
tools/perf/config/feature-checks/Makefile
tools/perf/config/feature-checks/test-all.c
tools/perf/config/feature-checks/test-libunwind-debug-frame.c

diff --combined arch/arm/Kconfig
index acb80708accdb5d9af59aedb89c9a2bfb308e990,9f2d203162b289401973bde75667cd8e6f7fc9e1..603d661b445d4a2690c7bcb5dbd9cb6d282cc0e6
@@@ -5,6 -5,7 +5,7 @@@ config AR
        select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_HAVE_CUSTOM_GPIO_H
+       select ARCH_USE_CMPXCHG_LOCKREF
        select ARCH_WANT_IPC_PARSE_VERSION
        select BUILDTIME_EXTABLE_SORT if MMU
        select CLONE_BACKWARDS
        select HAVE_MOD_ARCH_SPECIFIC if ARM_UNWIND
        select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
        select HAVE_PERF_EVENTS
+       select HAVE_PERF_REGS
+       select HAVE_PERF_USER_STACK_DUMP
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_SYSCALL_TRACEPOINTS
        select HAVE_UID16
 +      select HAVE_VIRT_CPU_ACCOUNTING_GEN
        select IRQ_FORCED_THREADING
        select KTIME_SCALAR
        select MODULES_USE_ELF_REL
@@@ -318,7 -320,6 +321,7 @@@ config ARCH_INTEGRATO
        select NEED_MACH_MEMORY_H
        select PLAT_VERSATILE
        select SPARSE_IRQ
 +      select USE_OF
        select VERSATILE_FPGA_IRQ
        help
          Support for ARM's Integrator platform.
@@@ -360,6 -361,7 +363,6 @@@ config ARCH_AT9
        bool "Atmel AT91"
        select ARCH_REQUIRE_GPIOLIB
        select CLKDEV_LOOKUP
 -      select HAVE_CLK
        select IRQ_DOMAIN
        select NEED_MACH_GPIO_H
        select NEED_MACH_IO_H if PCCARD
@@@ -373,6 -375,7 +376,6 @@@ config ARCH_CLPS711
        bool "Cirrus Logic CLPS711x/EP721x/EP731x-based"
        select ARCH_REQUIRE_GPIOLIB
        select AUTO_ZRELADDR
 -      select CLKDEV_LOOKUP
        select CLKSRC_MMIO
        select COMMON_CLK
        select CPU_ARM720T
  config ARCH_GEMINI
        bool "Cortina Systems Gemini"
        select ARCH_REQUIRE_GPIOLIB
 -      select ARCH_USES_GETTIMEOFFSET
 +      select CLKSRC_MMIO
        select CPU_FA526
 -      select NEED_MACH_GPIO_H
 +      select GENERIC_CLOCKEVENTS
        help
          Support for the Cortina Systems Gemini family SoCs
  
@@@ -457,7 -460,7 +460,7 @@@ config ARCH_IOP32
        depends on MMU
        select ARCH_REQUIRE_GPIOLIB
        select CPU_XSCALE
 -      select NEED_MACH_GPIO_H
 +      select GPIO_IOP
        select NEED_RET_TO_USER
        select PCI
        select PLAT_IOP
@@@ -470,7 -473,7 +473,7 @@@ config ARCH_IOP33
        depends on MMU
        select ARCH_REQUIRE_GPIOLIB
        select CPU_XSCALE
 -      select NEED_MACH_GPIO_H
 +      select GPIO_IOP
        select NEED_RET_TO_USER
        select PCI
        select PLAT_IOP
@@@ -481,6 -484,7 +484,7 @@@ config ARCH_IXP4X
        bool "IXP4xx-based"
        depends on MMU
        select ARCH_HAS_DMA_SET_COHERENT_MASK
+       select ARCH_SUPPORTS_BIG_ENDIAN
        select ARCH_REQUIRE_GPIOLIB
        select CLKSRC_MMIO
        select CPU_XSCALE
@@@ -559,6 -563,7 +563,6 @@@ config ARCH_MM
        select GPIO_PXA
        select IRQ_DOMAIN
        select MULTI_IRQ_HANDLER
 -      select NEED_MACH_GPIO_H
        select PINCTRL
        select PLAT_PXA
        select SPARSE_IRQ
@@@ -621,6 -626,7 +625,6 @@@ config ARCH_PX
        select GPIO_PXA
        select HAVE_IDE
        select MULTI_IRQ_HANDLER
 -      select NEED_MACH_GPIO_H
        select PLAT_PXA
        select SPARSE_IRQ
        help
  config ARCH_MSM
        bool "Qualcomm MSM"
        select ARCH_REQUIRE_GPIOLIB
 -      select CLKDEV_LOOKUP
        select CLKSRC_OF if OF
        select COMMON_CLK
        select GENERIC_CLOCKEVENTS
@@@ -646,6 -653,7 +650,6 @@@ config ARCH_SHMOBIL
        select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
 -      select HAVE_CLK
        select HAVE_MACH_CLKDEV
        select HAVE_SMP
        select MIGHT_HAVE_CACHE_L2X0
@@@ -688,7 -696,6 +692,6 @@@ config ARCH_SA110
        select GENERIC_CLOCKEVENTS
        select HAVE_IDE
        select ISA
-       select NEED_MACH_GPIO_H
        select NEED_MACH_MEMORY_H
        select SPARSE_IRQ
        help
@@@ -702,6 -709,7 +705,6 @@@ config ARCH_S3C24X
        select CLKSRC_SAMSUNG_PWM
        select GENERIC_CLOCKEVENTS
        select GPIO_SAMSUNG
 -      select HAVE_CLK
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_S3C_RTC if RTC_CLASS
@@@ -722,22 -730,21 +725,22 @@@ config ARCH_S3C64X
        select ARM_VIC
        select CLKDEV_LOOKUP
        select CLKSRC_SAMSUNG_PWM
 +      select COMMON_CLK
        select CPU_V6
        select GENERIC_CLOCKEVENTS
        select GPIO_SAMSUNG
 -      select HAVE_CLK
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_TCM
        select NEED_MACH_GPIO_H
        select NO_IOPORT
        select PLAT_SAMSUNG
 +      select PM_GENERIC_DOMAINS
        select S3C_DEV_NAND
        select S3C_GPIO_TRACK
        select SAMSUNG_ATAGS
 -      select SAMSUNG_CLKSRC
        select SAMSUNG_GPIOLIB_4BIT
 +      select SAMSUNG_WAKEMASK
        select SAMSUNG_WDT_RESET
        select USB_ARCH_HAS_OHCI
        help
@@@ -750,6 -757,7 +753,6 @@@ config ARCH_S5P64X
        select CPU_V6
        select GENERIC_CLOCKEVENTS
        select GPIO_SAMSUNG
 -      select HAVE_CLK
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_S3C_RTC if RTC_CLASS
@@@ -768,6 -776,7 +771,6 @@@ config ARCH_S5PC10
        select CPU_V7
        select GENERIC_CLOCKEVENTS
        select GPIO_SAMSUNG
 -      select HAVE_CLK
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_S3C_RTC if RTC_CLASS
@@@ -787,6 -796,7 +790,6 @@@ config ARCH_S5PV21
        select CPU_V7
        select GENERIC_CLOCKEVENTS
        select GPIO_SAMSUNG
 -      select HAVE_CLK
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_S3C_RTC if RTC_CLASS
@@@ -803,9 -813,11 +806,9 @@@ config ARCH_EXYNO
        select ARCH_REQUIRE_GPIOLIB
        select ARCH_SPARSEMEM_ENABLE
        select ARM_GIC
 -      select CLKDEV_LOOKUP
        select COMMON_CLK
        select CPU_V7
        select GENERIC_CLOCKEVENTS
 -      select HAVE_CLK
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_S3C_RTC if RTC_CLASS
        help
          Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5)
  
 -config ARCH_SHARK
 -      bool "Shark"
 -      select ARCH_USES_GETTIMEOFFSET
 -      select CPU_SA110
 -      select ISA
 -      select ISA_DMA
 -      select NEED_MACH_MEMORY_H
 -      select PCI
 -      select VIRT_TO_BUS
 -      select ZONE_DMA
 -      help
 -        Support for the StrongARM based Digital DNARD machine, also known
 -        as "Shark" (<http://www.shark-linux.de/shark.html>).
 -
  config ARCH_DAVINCI
        bool "TI DaVinci"
        select ARCH_HAS_HOLES_MEMORYMODEL
        select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
        select HAVE_IDE
 -      select NEED_MACH_GPIO_H
        select TI_PRIV_EDMA
        select USE_OF
        select ZONE_DMA
@@@ -841,6 -868,7 +844,6 @@@ config ARCH_OMAP
        select CLKSRC_MMIO
        select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
 -      select HAVE_CLK
        select HAVE_IDE
        select IRQ_DOMAIN
        select NEED_MACH_IO_H if PCCARD
@@@ -984,7 -1012,9 +987,7 @@@ source "arch/arm/mach-sti/Kconfig
  
  source "arch/arm/mach-s3c24xx/Kconfig"
  
 -if ARCH_S3C64XX
  source "arch/arm/mach-s3c64xx/Kconfig"
 -endif
  
  source "arch/arm/mach-s5p64x0/Kconfig"
  
@@@ -1064,11 -1094,6 +1067,6 @@@ config IWMMX
          Enable support for iWMMXt context switching at run time if
          running on a CPU that supports it.
  
- config XSCALE_PMU
-       bool
-       depends on CPU_XSCALE
-       default y
  config MULTI_IRQ_HANDLER
        bool
        help
@@@ -1404,6 -1429,12 +1402,6 @@@ config PCI_NANOENGIN
  config PCI_SYSCALL
        def_bool PCI
  
 -# Select the host bridge type
 -config PCI_HOST_VIA82C505
 -      bool
 -      depends on PCI && ARCH_SHARK
 -      default y
 -
  config PCI_HOST_ITE8152
        bool
        depends on PCI && MACH_ARMCORE
@@@ -1516,6 -1547,32 +1514,32 @@@ config MCP
          for (multi-)cluster based systems, such as big.LITTLE based
          systems.
  
+ config BIG_LITTLE
+       bool "big.LITTLE support (Experimental)"
+       depends on CPU_V7 && SMP
+       select MCPM
+       help
+         This option enables support selections for the big.LITTLE
+         system architecture.
+ config BL_SWITCHER
+       bool "big.LITTLE switcher support"
+       depends on BIG_LITTLE && MCPM && HOTPLUG_CPU
+       select CPU_PM
+       select ARM_CPU_SUSPEND
+       help
+         The big.LITTLE "switcher" provides the core functionality to
+         transparently handle transition between a cluster of A15's
+         and a cluster of A7's in a big.LITTLE system.
+ config BL_SWITCHER_DUMMY_IF
+       tristate "Simple big.LITTLE switcher user interface"
+       depends on BL_SWITCHER && DEBUG_KERNEL
+       help
+         This is a simple and dummy char dev interface to control
+         the big.LITTLE switcher core code.  It is meant for
+         debugging purposes only.
  choice
        prompt "Memory split"
        default VMSPLIT_3G
diff --combined arch/arm/Kconfig.debug
index d597c6b8488ba257fa37319d9afc7dc6362933a7,a8f305b07f296c9b352a7f5faa4ee9a56d3d9758..5765abf5ce84576d8de31df83d709160905d7b19
@@@ -318,6 -318,7 +318,7 @@@ choic
        config DEBUG_MSM_UART1
                bool "Kernel low-level debugging messages via MSM UART1"
                depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50
+               select DEBUG_MSM_UART
                help
                  Say Y here if you want the debug print routines to direct
                  their output to the first serial port on MSM devices.
        config DEBUG_MSM_UART2
                bool "Kernel low-level debugging messages via MSM UART2"
                depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50
+               select DEBUG_MSM_UART
                help
                  Say Y here if you want the debug print routines to direct
                  their output to the second serial port on MSM devices.
        config DEBUG_MSM_UART3
                bool "Kernel low-level debugging messages via MSM UART3"
                depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50
+               select DEBUG_MSM_UART
                help
                  Say Y here if you want the debug print routines to direct
                  their output to the third serial port on MSM devices.
                bool "Kernel low-level debugging messages via MSM 8660 UART"
                depends on ARCH_MSM8X60
                select MSM_HAS_DEBUG_UART_HS
+               select DEBUG_MSM_UART
                help
                  Say Y here if you want the debug print routines to direct
                  their output to the serial port on MSM 8660 devices.
                bool "Kernel low-level debugging messages via MSM 8960 UART"
                depends on ARCH_MSM8960
                select MSM_HAS_DEBUG_UART_HS
+               select DEBUG_MSM_UART
                help
                  Say Y here if you want the debug print routines to direct
                  their output to the serial port on MSM 8960 devices.
  
+       config DEBUG_MSM8974_UART
+               bool "Kernel low-level debugging messages via MSM 8974 UART"
+               depends on ARCH_MSM8974
+               select MSM_HAS_DEBUG_UART_HS
+               select DEBUG_MSM_UART
+               help
+                 Say Y here if you want the debug print routines to direct
+                 their output to the serial port on MSM 8974 devices.
        config DEBUG_MVEBU_UART
                bool "Kernel low-level debugging messages via MVEBU UART (old bootloaders)"
                depends on ARCH_MVEBU
                  when u-boot hands over to the kernel, the system
                  silently crashes, with no serial output at all.
  
 +      config DEBUG_VF_UART
 +              bool "Vybrid UART"
 +              depends on SOC_VF610
 +              help
 +                Say Y here if you want kernel low-level debugging support
 +                on Vybrid based platforms.
 +
        config DEBUG_NOMADIK_UART
                bool "Kernel low-level debugging messages via NOMADIK UART"
                depends on ARCH_NOMADIK
                  options; the platform specific options are deprecated
                  and will be soon removed.
  
+       config DEBUG_LL_UART_EFM32
+               bool "Kernel low-level debugging via efm32 UART"
+               depends on ARCH_EFM32
+               help
+                 Say Y here if you want the debug print routines to direct
+                 their output to an UART or USART port on efm32 based
+                 machines. Use the following addresses for DEBUG_UART_PHYS:
+                   0x4000c000 | USART0
+                   0x4000c400 | USART1
+                   0x4000c800 | USART2
+                   0x4000e000 | UART0
+                   0x4000e400 | UART1
        config DEBUG_LL_UART_PL01X
                bool "Kernel low-level debugging via ARM Ltd PL01x Primecell UART"
                help
@@@ -887,11 -908,16 +915,16 @@@ config DEBUG_STI_UAR
        bool
        depends on ARCH_STI
  
+ config DEBUG_MSM_UART
+       bool
+       depends on ARCH_MSM
  config DEBUG_LL_INCLUDE
        string
        default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
        default "debug/pl01x.S" if DEBUG_LL_UART_PL01X || DEBUG_UART_PL01X
        default "debug/exynos.S" if DEBUG_EXYNOS_UART
+       default "debug/efm32.S" if DEBUG_LL_UART_EFM32
        default "debug/icedcc.S" if DEBUG_ICEDCC
        default "debug/imx.S" if DEBUG_IMX1_UART || \
                                 DEBUG_IMX25_UART || \
                                 DEBUG_IMX53_UART ||\
                                 DEBUG_IMX6Q_UART || \
                                 DEBUG_IMX6SL_UART
-       default "debug/msm.S" if DEBUG_MSM_UART1 || \
-                                DEBUG_MSM_UART2 || \
-                                DEBUG_MSM_UART3 || \
-                                DEBUG_MSM8660_UART || \
-                                DEBUG_MSM8960_UART
+       default "debug/msm.S" if DEBUG_MSM_UART
        default "debug/omap2plus.S" if DEBUG_OMAP2PLUS_UART
        default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || DEBUG_SIRFMARCO_UART1
        default "debug/sti.S" if DEBUG_STI_UART
        default "debug/tegra.S" if DEBUG_TEGRA_UART
        default "debug/ux500.S" if DEBUG_UX500_UART
        default "debug/vexpress.S" if DEBUG_VEXPRESS_UART0_DETECT
 +      default "debug/vf.S" if DEBUG_VF_UART
        default "debug/vt8500.S" if DEBUG_VT8500_UART0
        default "debug/zynq.S" if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1
        default "mach/debug-macro.S"
@@@ -959,6 -980,7 +988,7 @@@ config DEBUG_UART_PHY
        default 0x20064000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2
        default 0x20068000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3
        default 0x20201000 if DEBUG_BCM2835
+       default 0x4000e400 if DEBUG_LL_UART_EFM32
        default 0x40090000 if ARCH_LPC32XX
        default 0x40100000 if DEBUG_PXA_UART1
        default 0x42000000 if ARCH_GEMINI
        default 0xfff36000 if DEBUG_HIGHBANK_UART
        default 0xfffff700 if ARCH_IOP33X
        depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
+               DEBUG_LL_UART_EFM32 || \
                DEBUG_UART_8250 || DEBUG_UART_PL01X
  
  config DEBUG_UART_VIRT
diff --combined arch/arm/Makefile
index 8b667132d7b419bb572549d3f5149c7f9e503860,25f45256f098884b501ba6e772547a74c60f6b78..c99b1086d83dfa8c0c407bab392ff5bb12927ab5
@@@ -16,6 -16,7 +16,7 @@@ LDFLAGS               :
  LDFLAGS_vmlinux       :=-p --no-undefined -X
  ifeq ($(CONFIG_CPU_ENDIAN_BE8),y)
  LDFLAGS_vmlinux       += --be8
+ LDFLAGS_MODULE        += --be8
  endif
  
  OBJCOPYFLAGS  :=-O binary -R .comment -S
@@@ -188,6 -189,7 +189,6 @@@ machine-$(CONFIG_ARCH_S5P64X0)             += s5p6
  machine-$(CONFIG_ARCH_S5PC100)                += s5pc100
  machine-$(CONFIG_ARCH_S5PV210)                += s5pv210
  machine-$(CONFIG_ARCH_SA1100)         += sa1100
 -machine-$(CONFIG_ARCH_SHARK)          += shark
  machine-$(CONFIG_ARCH_SHMOBILE)       += shmobile
  machine-$(CONFIG_ARCH_SHMOBILE_MULTI)         += shmobile
  machine-$(CONFIG_ARCH_SIRF)           += prima2
diff --combined arch/arm/common/Makefile
index eaa9cf4705a7179dcb7221aa5f2a29a6c1883b78,5c8584c4944d780f90bcedb40b8224fb60fa364f..4bdc41622c36686df868e2134d6453fe60684b5b
@@@ -6,6 -6,7 +6,6 @@@ obj-y                            += firmware.
  
  obj-$(CONFIG_ICST)            += icst.o
  obj-$(CONFIG_SA1111)          += sa1111.o
 -obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o
  obj-$(CONFIG_DMABOUNCE)               += dmabounce.o
  obj-$(CONFIG_SHARP_LOCOMO)    += locomo.o
  obj-$(CONFIG_SHARP_PARAM)     += sharpsl_param.o
@@@ -16,3 -17,5 +16,5 @@@ obj-$(CONFIG_MCPM)            += mcpm_head.o mcpm
  AFLAGS_mcpm_head.o            := -march=armv7-a
  AFLAGS_vlock.o                        := -march=armv7-a
  obj-$(CONFIG_TI_PRIV_EDMA)    += edma.o
+ obj-$(CONFIG_BL_SWITCHER)     += bL_switcher.o
+ obj-$(CONFIG_BL_SWITCHER_DUMMY_IF) += bL_switcher_dummy_if.o
index 1a7024b413511d6742f6fb928407603c648c77e3,a6395c0277152f74645b8fceb572abc9b1c5a2db..c38b58c8020215f54af8140e97de8467ad3c3c16
@@@ -24,6 -24,7 +24,7 @@@ generic-y += sembuf.
  generic-y += serial.h
  generic-y += shmbuf.h
  generic-y += siginfo.h
+ generic-y += simd.h
  generic-y += sizes.h
  generic-y += socket.h
  generic-y += sockios.h
@@@ -32,4 -33,3 +33,4 @@@ generic-y += termios.
  generic-y += timex.h
  generic-y += trace_clock.h
  generic-y += unaligned.h
 +generic-y += preempt.h
diff --combined arch/arm/kernel/module.c
index c9dfff3b80082e60fa2244efd1a23216293356ec,5fdb4038f9694effd2e93afd482a3604b791ab45..45e478157278e331ac6474ca5dbac859415b0fff
@@@ -24,6 -24,7 +24,7 @@@
  #include <asm/sections.h>
  #include <asm/smp_plat.h>
  #include <asm/unwind.h>
+ #include <asm/opcodes.h>
  
  #ifdef CONFIG_XIP_KERNEL
  /*
@@@ -40,7 -41,7 +41,7 @@@
  void *module_alloc(unsigned long size)
  {
        return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
 -                              GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
 +                              GFP_KERNEL, PAGE_KERNEL_EXEC, NUMA_NO_NODE,
                                __builtin_return_address(0));
  }
  #endif
@@@ -60,6 -61,7 +61,7 @@@ apply_relocate(Elf32_Shdr *sechdrs, con
                Elf32_Sym *sym;
                const char *symname;
                s32 offset;
+               u32 tmp;
  #ifdef CONFIG_THUMB2_KERNEL
                u32 upper, lower, sign, j1, j2;
  #endif
@@@ -95,7 -97,8 +97,8 @@@
                case R_ARM_PC24:
                case R_ARM_CALL:
                case R_ARM_JUMP24:
-                       offset = (*(u32 *)loc & 0x00ffffff) << 2;
+                       offset = __mem_to_opcode_arm(*(u32 *)loc);
+                       offset = (offset & 0x00ffffff) << 2;
                        if (offset & 0x02000000)
                                offset -= 0x04000000;
  
                        }
  
                        offset >>= 2;
+                       offset &= 0x00ffffff;
  
-                       *(u32 *)loc &= 0xff000000;
-                       *(u32 *)loc |= offset & 0x00ffffff;
+                       *(u32 *)loc &= __opcode_to_mem_arm(0xff000000);
+                       *(u32 *)loc |= __opcode_to_mem_arm(offset);
                        break;
  
               case R_ARM_V4BX:
                        * other bits to re-code instruction as
                        * MOV PC,Rm.
                        */
-                      *(u32 *)loc &= 0xf000000f;
-                      *(u32 *)loc |= 0x01a0f000;
+                      *(u32 *)loc &= __opcode_to_mem_arm(0xf000000f);
+                      *(u32 *)loc |= __opcode_to_mem_arm(0x01a0f000);
                       break;
  
                case R_ARM_PREL31:
  
                case R_ARM_MOVW_ABS_NC:
                case R_ARM_MOVT_ABS:
-                       offset = *(u32 *)loc;
+                       offset = tmp = __mem_to_opcode_arm(*(u32 *)loc);
                        offset = ((offset & 0xf0000) >> 4) | (offset & 0xfff);
                        offset = (offset ^ 0x8000) - 0x8000;
  
                        if (ELF32_R_TYPE(rel->r_info) == R_ARM_MOVT_ABS)
                                offset >>= 16;
  
-                       *(u32 *)loc &= 0xfff0f000;
-                       *(u32 *)loc |= ((offset & 0xf000) << 4) |
-                                       (offset & 0x0fff);
+                       tmp &= 0xfff0f000;
+                       tmp |= ((offset & 0xf000) << 4) |
+                               (offset & 0x0fff);
+                       *(u32 *)loc = __opcode_to_mem_arm(tmp);
                        break;
  
  #ifdef CONFIG_THUMB2_KERNEL
                case R_ARM_THM_CALL:
                case R_ARM_THM_JUMP24:
-                       upper = *(u16 *)loc;
-                       lower = *(u16 *)(loc + 2);
+                       upper = __mem_to_opcode_thumb16(*(u16 *)loc);
+                       lower = __mem_to_opcode_thumb16(*(u16 *)(loc + 2));
  
                        /*
                         * 25 bit signed address range (Thumb-2 BL and B.W
                        sign = (offset >> 24) & 1;
                        j1 = sign ^ (~(offset >> 23) & 1);
                        j2 = sign ^ (~(offset >> 22) & 1);
-                       *(u16 *)loc = (u16)((upper & 0xf800) | (sign << 10) |
+                       upper = (u16)((upper & 0xf800) | (sign << 10) |
                                            ((offset >> 12) & 0x03ff));
-                       *(u16 *)(loc + 2) = (u16)((lower & 0xd000) |
-                                                 (j1 << 13) | (j2 << 11) |
-                                                 ((offset >> 1) & 0x07ff));
+                       lower = (u16)((lower & 0xd000) |
+                                     (j1 << 13) | (j2 << 11) |
+                                     ((offset >> 1) & 0x07ff));
+                       *(u16 *)loc = __opcode_to_mem_thumb16(upper);
+                       *(u16 *)(loc + 2) = __opcode_to_mem_thumb16(lower);
                        break;
  
                case R_ARM_THM_MOVW_ABS_NC:
                case R_ARM_THM_MOVT_ABS:
-                       upper = *(u16 *)loc;
-                       lower = *(u16 *)(loc + 2);
+                       upper = __mem_to_opcode_thumb16(*(u16 *)loc);
+                       lower = __mem_to_opcode_thumb16(*(u16 *)(loc + 2));
  
                        /*
                         * MOVT/MOVW instructions encoding in Thumb-2:
                        if (ELF32_R_TYPE(rel->r_info) == R_ARM_THM_MOVT_ABS)
                                offset >>= 16;
  
-                       *(u16 *)loc = (u16)((upper & 0xfbf0) |
-                                           ((offset & 0xf000) >> 12) |
-                                           ((offset & 0x0800) >> 1));
-                       *(u16 *)(loc + 2) = (u16)((lower & 0x8f00) |
-                                                 ((offset & 0x0700) << 4) |
-                                                 (offset & 0x00ff));
+                       upper = (u16)((upper & 0xfbf0) |
+                                     ((offset & 0xf000) >> 12) |
+                                     ((offset & 0x0800) >> 1));
+                       lower = (u16)((lower & 0x8f00) |
+                                     ((offset & 0x0700) << 4) |
+                                     (offset & 0x00ff));
+                       *(u16 *)loc = __opcode_to_mem_thumb16(upper);
+                       *(u16 *)(loc + 2) = __opcode_to_mem_thumb16(lower);
                        break;
  #endif
  
diff --combined arch/arm/kernel/setup.c
index 5d65438685d8516f6455393940e4bdaed107699a,f52150d2ec00bd0b475b6be9bcec6b4d6f0125c8..6a1b8a81b1ae448168572a9558aaf026f9e7e47e
@@@ -73,6 -73,8 +73,8 @@@ __setup("fpe=", fpe_setup)
  #endif
  
  extern void paging_init(const struct machine_desc *desc);
+ extern void early_paging_init(const struct machine_desc *,
+                             struct proc_info_list *);
  extern void sanity_check_meminfo(void);
  extern enum reboot_mode reboot_mode;
  extern void setup_dma_zone(const struct machine_desc *desc);
@@@ -599,6 -601,8 +601,8 @@@ static void __init setup_processor(void
        elf_hwcap &= ~(HWCAP_THUMB | HWCAP_IDIVT);
  #endif
  
+       erratum_a15_798181_init();
        feat_v6_fixup();
  
        cacheid_init();
@@@ -619,9 -623,10 +623,10 @@@ void __init dump_machine_table(void
                /* can't use cpu_relax() here as it may require MMU setup */;
  }
  
- int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
+ int __init arm_add_memory(u64 start, u64 size)
  {
        struct membank *bank = &meminfo.bank[meminfo.nr_banks];
+       u64 aligned_start;
  
        if (meminfo.nr_banks >= NR_BANKS) {
                printk(KERN_CRIT "NR_BANKS too low, "
         * Size is appropriately rounded down, start is rounded up.
         */
        size -= start & ~PAGE_MASK;
-       bank->start = PAGE_ALIGN(start);
+       aligned_start = PAGE_ALIGN(start);
  
- #ifndef CONFIG_ARM_LPAE
-       if (bank->start + size < bank->start) {
+ #ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
+       if (aligned_start > ULONG_MAX) {
+               printk(KERN_CRIT "Ignoring memory at 0x%08llx outside "
+                      "32-bit physical address space\n", (long long)start);
+               return -EINVAL;
+       }
+       if (aligned_start + size > ULONG_MAX) {
                printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
                        "32-bit physical address space\n", (long long)start);
                /*
                 * 32 bits, we use ULONG_MAX as the upper limit rather than 4GB.
                 * This means we lose a page after masking.
                 */
-               size = ULONG_MAX - bank->start;
+               size = ULONG_MAX - aligned_start;
        }
  #endif
  
+       bank->start = aligned_start;
        bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
  
        /*
  static int __init early_mem(char *p)
  {
        static int usermem __initdata = 0;
-       phys_addr_t size;
-       phys_addr_t start;
+       u64 size;
+       u64 start;
        char *endp;
  
        /*
@@@ -878,6 -890,8 +890,8 @@@ void __init setup_arch(char **cmdline_p
        parse_early_param();
  
        sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
+       early_paging_init(mdesc, lookup_processor_type(read_cpuid_id()));
        sanity_check_meminfo();
        arm_memblock_init(&meminfo, mdesc);
  
@@@ -975,7 -989,6 +989,7 @@@ static const char *hwcap_str[] = 
        "idivt",
        "vfpd32",
        "lpae",
 +      "evtstrm",
        NULL
  };
  
index fe98df44579cfa5c22c77ebd53dd9efbee15cf1e,0ca7377746c89a795e3de8f90dfc303b8efad1b1..08332d84144052899382d6d2543dc4d754779e6f
@@@ -4,15 -4,16 +4,16 @@@ config ARCH_HIGHBAN
        select ARCH_HAS_CPUFREQ
        select ARCH_HAS_HOLES_MEMORYMODEL
        select ARCH_HAS_OPP
+       select ARCH_SUPPORTS_BIG_ENDIAN
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_AMBA
        select ARM_ERRATA_764369
        select ARM_ERRATA_775420
-       select ARM_ERRATA_798181
+       select ARM_ERRATA_798181 if SMP
        select ARM_GIC
 +      select ARM_PSCI
        select ARM_TIMER_SP804
        select CACHE_L2X0
 -      select CLKDEV_LOOKUP
        select COMMON_CLK
        select CPU_V7
        select GENERIC_CLOCKEVENTS
index 0bf04a0bca9d5c4d5d831b730de89cff332bb7b4,f26428d8b62a18828a08cd0ff42bc08f35e5b206..09e740f58b274184f0cd22b282def431d037b6d9
@@@ -3,6 -3,7 +3,6 @@@ config ARCH_TEGR
        select ARCH_HAS_CPUFREQ
        select ARCH_REQUIRE_GPIOLIB
        select ARM_GIC
 -      select CLKDEV_LOOKUP
        select CLKSRC_MMIO
        select CLKSRC_OF
        select COMMON_CLK
@@@ -10,6 -11,7 +10,6 @@@
        select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
 -      select HAVE_CLK
        select HAVE_SMP
        select MIGHT_HAVE_CACHE_L2X0
        select MIGHT_HAVE_PCI
@@@ -51,22 -53,14 +51,22 @@@ config ARCH_TEGRA_3x_SO
  
  config ARCH_TEGRA_114_SOC
        bool "Enable support for Tegra114 family"
-       select ARM_ERRATA_798181
 -      select HAVE_ARM_ARCH_TIMER
+       select ARM_ERRATA_798181 if SMP
        select ARM_L1_CACHE_SHIFT_6
 +      select HAVE_ARM_ARCH_TIMER
        select PINCTRL_TEGRA114
        help
          Support for NVIDIA Tegra T114 processor family, based on the
          ARM CortexA15MP CPU
  
 +config ARCH_TEGRA_124_SOC
 +      bool "Enable support for Tegra124 family"
 +      select ARM_L1_CACHE_SHIFT_6
 +      select HAVE_ARM_ARCH_TIMER
 +      help
 +        Support for NVIDIA Tegra T124 processor family, based on the
 +        ARM CortexA15MP CPU
 +
  config TEGRA_AHB
        bool "Enable AHB driver for NVIDIA Tegra SoCs"
        default y
index d7e7422527cac791938e4006873bad4fc8883d64,4fe8ebe5b2d43c4983b3d5ccafb662afcf4f0e41..cbbb81e0e5096f7214e178fbed58b746a8dbf41b
@@@ -1,15 -1,18 +1,16 @@@
  config ARCH_VEXPRESS
        bool "ARM Ltd. Versatile Express family" if ARCH_MULTI_V7
        select ARCH_REQUIRE_GPIOLIB
+       select ARCH_SUPPORTS_BIG_ENDIAN
        select ARM_AMBA
        select ARM_GIC
        select ARM_TIMER_SP804
 -      select CLKDEV_LOOKUP
        select COMMON_CLK
        select COMMON_CLK_VERSATILE
        select CPU_V7
        select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
 -      select HAVE_CLK
        select HAVE_PATA_PLATFORM
        select HAVE_SMP
        select ICST
index 644d91f73b00f3c5663b9e273d91d51a50218dd5,b5a3f603114675f1db7ab57fc2e7977c690f76e4..79f8b39801a8e570bd86ea80e566ee939bbb600b
@@@ -159,7 -159,7 +159,7 @@@ EXPORT_SYMBOL(arm_coherent_dma_ops)
  
  static u64 get_coherent_dma_mask(struct device *dev)
  {
 -      u64 mask = (u64)arm_dma_limit;
 +      u64 mask = (u64)DMA_BIT_MASK(32);
  
        if (dev) {
                mask = dev->coherent_dma_mask;
                        return 0;
                }
  
 -              if ((~mask) & (u64)arm_dma_limit) {
 -                      dev_warn(dev, "coherent DMA mask %#llx is smaller "
 -                               "than system GFP_DMA mask %#llx\n",
 -                               mask, (u64)arm_dma_limit);
 +              /*
 +               * If the mask allows for more memory than we can address,
 +               * and we actually have that much memory, then fail the
 +               * allocation.
 +               */
 +              if (sizeof(mask) != sizeof(dma_addr_t) &&
 +                  mask > (dma_addr_t)~0 &&
 +                  dma_to_pfn(dev, ~0) > arm_dma_pfn_limit) {
 +                      dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n",
 +                               mask);
 +                      dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n");
 +                      return 0;
 +              }
 +
 +              /*
 +               * Now check that the mask, when translated to a PFN,
 +               * fits within the allowable addresses which we can
 +               * allocate.
 +               */
 +              if (dma_to_pfn(dev, mask) < arm_dma_pfn_limit) {
 +                      dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
 +                               mask,
 +                               dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
 +                               arm_dma_pfn_limit + 1);
                        return 0;
                }
        }
@@@ -707,7 -687,7 +707,7 @@@ static void *__dma_alloc(struct device 
  void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
                    gfp_t gfp, struct dma_attrs *attrs)
  {
-       pgprot_t prot = __get_dma_pgprot(attrs, pgprot_kernel);
+       pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL);
        void *memory;
  
        if (dma_alloc_from_coherent(dev, size, handle, &memory))
  static void *arm_coherent_dma_alloc(struct device *dev, size_t size,
        dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs)
  {
-       pgprot_t prot = __get_dma_pgprot(attrs, pgprot_kernel);
+       pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL);
        void *memory;
  
        if (dma_alloc_from_coherent(dev, size, handle, &memory))
@@@ -1027,27 -1007,8 +1027,27 @@@ void arm_dma_sync_sg_for_device(struct 
   */
  int dma_supported(struct device *dev, u64 mask)
  {
 -      if (mask < (u64)arm_dma_limit)
 +      unsigned long limit;
 +
 +      /*
 +       * If the mask allows for more memory than we can address,
 +       * and we actually have that much memory, then we must
 +       * indicate that DMA to this device is not supported.
 +       */
 +      if (sizeof(mask) != sizeof(dma_addr_t) &&
 +          mask > (dma_addr_t)~0 &&
 +          dma_to_pfn(dev, ~0) > arm_dma_pfn_limit)
 +              return 0;
 +
 +      /*
 +       * Translate the device's DMA mask to a PFN limit.  This
 +       * PFN number includes the page which we can DMA to.
 +       */
 +      limit = dma_to_pfn(dev, mask);
 +
 +      if (limit < arm_dma_pfn_limit)
                return 0;
 +
        return 1;
  }
  EXPORT_SYMBOL(dma_supported);
index 5d14470452ac5959712ef9927b3a093bf8975bf3,6983ed5a351a20597cc27ff8c3cd7b9722a92a2c..0e63c98d224c5756c58ba0a4145c40273bd87e86
@@@ -784,8 -784,8 +784,8 @@@ static const unsigned armv8_pmuv3_perf_
  /*
   * PMXEVTYPER: Event selection reg
   */
 -#define       ARMV8_EVTYPE_MASK       0xc80000ff      /* Mask for writable bits */
 -#define       ARMV8_EVTYPE_EVENT      0xff            /* Mask for EVENT bits */
 +#define       ARMV8_EVTYPE_MASK       0xc80003ff      /* Mask for writable bits */
 +#define       ARMV8_EVTYPE_EVENT      0x3ff           /* Mask for EVENT bits */
  
  /*
   * Event filters for PMUv3
@@@ -1044,7 -1044,7 +1044,7 @@@ static irqreturn_t armv8pmu_handle_irq(
         */
        regs = get_irq_regs();
  
-       cpuc = &__get_cpu_var(cpu_hw_events);
+       cpuc = this_cpu_ptr(&cpu_hw_events);
        for (idx = 0; idx < cpu_pmu->num_events; ++idx) {
                struct perf_event *event = cpuc->events[idx];
                struct hw_perf_event *hwc;
@@@ -1175,8 -1175,7 +1175,8 @@@ static void armv8pmu_reset(void *info
  static int armv8_pmuv3_map_event(struct perf_event *event)
  {
        return map_cpu_event(event, &armv8_pmuv3_perf_map,
 -                              &armv8_pmuv3_perf_cache_map, 0xFF);
 +                              &armv8_pmuv3_perf_cache_map,
 +                              ARMV8_EVTYPE_EVENT);
  }
  
  static struct arm_pmu armv8pmu = {
@@@ -1258,7 -1257,7 +1258,7 @@@ device_initcall(register_pmu_driver)
  
  static struct pmu_hw_events *armpmu_get_cpu_events(void)
  {
-       return &__get_cpu_var(cpu_hw_events);
+       return this_cpu_ptr(&cpu_hw_events);
  }
  
  static void __init cpu_pmu_init(struct arm_pmu *armpmu)
diff --combined drivers/bus/arm-cci.c
index bb5b90e8e7687a0b71d33aae92f7050f741a6fa9,2e6c275322f1c27fe87f6a50a4a31a0cafab7cf6..b6739cb78e320755e4fb9480c875b6cc2890dd4e
  #include <linux/io.h>
  #include <linux/module.h>
  #include <linux/of_address.h>
 +#include <linux/of_irq.h>
 +#include <linux/of_platform.h>
 +#include <linux/platform_device.h>
  #include <linux/slab.h>
 +#include <linux/spinlock.h>
  
  #include <asm/cacheflush.h>
 +#include <asm/irq_regs.h>
 +#include <asm/pmu.h>
  #include <asm/smp_plat.h>
  
 +#define DRIVER_NAME           "CCI-400"
 +#define DRIVER_NAME_PMU               DRIVER_NAME " PMU"
 +#define PMU_NAME              "CCI_400"
 +
  #define CCI_PORT_CTRL         0x0
  #define CCI_CTRL_STATUS               0xc
  
@@@ -64,568 -54,6 +64,568 @@@ static unsigned int nb_cci_ports
  static void __iomem *cci_ctrl_base;
  static unsigned long cci_ctrl_phys;
  
 +#ifdef CONFIG_HW_PERF_EVENTS
 +
 +#define CCI_PMCR              0x0100
 +#define CCI_PID2              0x0fe8
 +
 +#define CCI_PMCR_CEN          0x00000001
 +#define CCI_PMCR_NCNT_MASK    0x0000f800
 +#define CCI_PMCR_NCNT_SHIFT   11
 +
 +#define CCI_PID2_REV_MASK     0xf0
 +#define CCI_PID2_REV_SHIFT    4
 +
 +/* Port ids */
 +#define CCI_PORT_S0   0
 +#define CCI_PORT_S1   1
 +#define CCI_PORT_S2   2
 +#define CCI_PORT_S3   3
 +#define CCI_PORT_S4   4
 +#define CCI_PORT_M0   5
 +#define CCI_PORT_M1   6
 +#define CCI_PORT_M2   7
 +
 +#define CCI_REV_R0            0
 +#define CCI_REV_R1            1
 +#define CCI_REV_R0_P4         4
 +#define CCI_REV_R1_P2         6
 +
 +#define CCI_PMU_EVT_SEL               0x000
 +#define CCI_PMU_CNTR          0x004
 +#define CCI_PMU_CNTR_CTRL     0x008
 +#define CCI_PMU_OVRFLW                0x00c
 +
 +#define CCI_PMU_OVRFLW_FLAG   1
 +
 +#define CCI_PMU_CNTR_BASE(idx)        ((idx) * SZ_4K)
 +
 +/*
 + * Instead of an event id to monitor CCI cycles, a dedicated counter is
 + * provided. Use 0xff to represent CCI cycles and hope that no future revisions
 + * make use of this event in hardware.
 + */
 +enum cci400_perf_events {
 +      CCI_PMU_CYCLES = 0xff
 +};
 +
 +#define CCI_PMU_EVENT_MASK            0xff
 +#define CCI_PMU_EVENT_SOURCE(event)   ((event >> 5) & 0x7)
 +#define CCI_PMU_EVENT_CODE(event)     (event & 0x1f)
 +
 +#define CCI_PMU_MAX_HW_EVENTS 5   /* CCI PMU has 4 counters + 1 cycle counter */
 +
 +#define CCI_PMU_CYCLE_CNTR_IDX                0
 +#define CCI_PMU_CNTR0_IDX             1
 +#define CCI_PMU_CNTR_LAST(cci_pmu)    (CCI_PMU_CYCLE_CNTR_IDX + cci_pmu->num_events - 1)
 +
 +/*
 + * CCI PMU event id is an 8-bit value made of two parts - bits 7:5 for one of 8
 + * ports and bits 4:0 are event codes. There are different event codes
 + * associated with each port type.
 + *
 + * Additionally, the range of events associated with the port types changed
 + * between Rev0 and Rev1.
 + *
 + * The constants below define the range of valid codes for each port type for
 + * the different revisions and are used to validate the event to be monitored.
 + */
 +
 +#define CCI_REV_R0_SLAVE_PORT_MIN_EV  0x00
 +#define CCI_REV_R0_SLAVE_PORT_MAX_EV  0x13
 +#define CCI_REV_R0_MASTER_PORT_MIN_EV 0x14
 +#define CCI_REV_R0_MASTER_PORT_MAX_EV 0x1a
 +
 +#define CCI_REV_R1_SLAVE_PORT_MIN_EV  0x00
 +#define CCI_REV_R1_SLAVE_PORT_MAX_EV  0x14
 +#define CCI_REV_R1_MASTER_PORT_MIN_EV 0x00
 +#define CCI_REV_R1_MASTER_PORT_MAX_EV 0x11
 +
 +struct pmu_port_event_ranges {
 +      u8 slave_min;
 +      u8 slave_max;
 +      u8 master_min;
 +      u8 master_max;
 +};
 +
 +static struct pmu_port_event_ranges port_event_range[] = {
 +      [CCI_REV_R0] = {
 +              .slave_min = CCI_REV_R0_SLAVE_PORT_MIN_EV,
 +              .slave_max = CCI_REV_R0_SLAVE_PORT_MAX_EV,
 +              .master_min = CCI_REV_R0_MASTER_PORT_MIN_EV,
 +              .master_max = CCI_REV_R0_MASTER_PORT_MAX_EV,
 +      },
 +      [CCI_REV_R1] = {
 +              .slave_min = CCI_REV_R1_SLAVE_PORT_MIN_EV,
 +              .slave_max = CCI_REV_R1_SLAVE_PORT_MAX_EV,
 +              .master_min = CCI_REV_R1_MASTER_PORT_MIN_EV,
 +              .master_max = CCI_REV_R1_MASTER_PORT_MAX_EV,
 +      },
 +};
 +
 +struct cci_pmu_drv_data {
 +      void __iomem *base;
 +      struct arm_pmu *cci_pmu;
 +      int nr_irqs;
 +      int irqs[CCI_PMU_MAX_HW_EVENTS];
 +      unsigned long active_irqs;
 +      struct perf_event *events[CCI_PMU_MAX_HW_EVENTS];
 +      unsigned long used_mask[BITS_TO_LONGS(CCI_PMU_MAX_HW_EVENTS)];
 +      struct pmu_port_event_ranges *port_ranges;
 +      struct pmu_hw_events hw_events;
 +};
 +static struct cci_pmu_drv_data *pmu;
 +
 +static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs)
 +{
 +      int i;
 +
 +      for (i = 0; i < nr_irqs; i++)
 +              if (irq == irqs[i])
 +                      return true;
 +
 +      return false;
 +}
 +
 +static int probe_cci_revision(void)
 +{
 +      int rev;
 +      rev = readl_relaxed(cci_ctrl_base + CCI_PID2) & CCI_PID2_REV_MASK;
 +      rev >>= CCI_PID2_REV_SHIFT;
 +
 +      if (rev <= CCI_REV_R0_P4)
 +              return CCI_REV_R0;
 +      else if (rev <= CCI_REV_R1_P2)
 +              return CCI_REV_R1;
 +
 +      return -ENOENT;
 +}
 +
 +static struct pmu_port_event_ranges *port_range_by_rev(void)
 +{
 +      int rev = probe_cci_revision();
 +
 +      if (rev < 0)
 +              return NULL;
 +
 +      return &port_event_range[rev];
 +}
 +
 +static int pmu_is_valid_slave_event(u8 ev_code)
 +{
 +      return pmu->port_ranges->slave_min <= ev_code &&
 +              ev_code <= pmu->port_ranges->slave_max;
 +}
 +
 +static int pmu_is_valid_master_event(u8 ev_code)
 +{
 +      return pmu->port_ranges->master_min <= ev_code &&
 +              ev_code <= pmu->port_ranges->master_max;
 +}
 +
 +static int pmu_validate_hw_event(u8 hw_event)
 +{
 +      u8 ev_source = CCI_PMU_EVENT_SOURCE(hw_event);
 +      u8 ev_code = CCI_PMU_EVENT_CODE(hw_event);
 +
 +      switch (ev_source) {
 +      case CCI_PORT_S0:
 +      case CCI_PORT_S1:
 +      case CCI_PORT_S2:
 +      case CCI_PORT_S3:
 +      case CCI_PORT_S4:
 +              /* Slave Interface */
 +              if (pmu_is_valid_slave_event(ev_code))
 +                      return hw_event;
 +              break;
 +      case CCI_PORT_M0:
 +      case CCI_PORT_M1:
 +      case CCI_PORT_M2:
 +              /* Master Interface */
 +              if (pmu_is_valid_master_event(ev_code))
 +                      return hw_event;
 +              break;
 +      }
 +
 +      return -ENOENT;
 +}
 +
 +static int pmu_is_valid_counter(struct arm_pmu *cci_pmu, int idx)
 +{
 +      return CCI_PMU_CYCLE_CNTR_IDX <= idx &&
 +              idx <= CCI_PMU_CNTR_LAST(cci_pmu);
 +}
 +
 +static u32 pmu_read_register(int idx, unsigned int offset)
 +{
 +      return readl_relaxed(pmu->base + CCI_PMU_CNTR_BASE(idx) + offset);
 +}
 +
 +static void pmu_write_register(u32 value, int idx, unsigned int offset)
 +{
 +      return writel_relaxed(value, pmu->base + CCI_PMU_CNTR_BASE(idx) + offset);
 +}
 +
 +static void pmu_disable_counter(int idx)
 +{
 +      pmu_write_register(0, idx, CCI_PMU_CNTR_CTRL);
 +}
 +
 +static void pmu_enable_counter(int idx)
 +{
 +      pmu_write_register(1, idx, CCI_PMU_CNTR_CTRL);
 +}
 +
 +static void pmu_set_event(int idx, unsigned long event)
 +{
 +      event &= CCI_PMU_EVENT_MASK;
 +      pmu_write_register(event, idx, CCI_PMU_EVT_SEL);
 +}
 +
 +static u32 pmu_get_max_counters(void)
 +{
 +      u32 n_cnts = (readl_relaxed(cci_ctrl_base + CCI_PMCR) &
 +                    CCI_PMCR_NCNT_MASK) >> CCI_PMCR_NCNT_SHIFT;
 +
 +      /* add 1 for cycle counter */
 +      return n_cnts + 1;
 +}
 +
 +static struct pmu_hw_events *pmu_get_hw_events(void)
 +{
 +      return &pmu->hw_events;
 +}
 +
 +static int pmu_get_event_idx(struct pmu_hw_events *hw, struct perf_event *event)
 +{
 +      struct arm_pmu *cci_pmu = to_arm_pmu(event->pmu);
 +      struct hw_perf_event *hw_event = &event->hw;
 +      unsigned long cci_event = hw_event->config_base & CCI_PMU_EVENT_MASK;
 +      int idx;
 +
 +      if (cci_event == CCI_PMU_CYCLES) {
 +              if (test_and_set_bit(CCI_PMU_CYCLE_CNTR_IDX, hw->used_mask))
 +                      return -EAGAIN;
 +
 +              return CCI_PMU_CYCLE_CNTR_IDX;
 +      }
 +
 +      for (idx = CCI_PMU_CNTR0_IDX; idx <= CCI_PMU_CNTR_LAST(cci_pmu); ++idx)
 +              if (!test_and_set_bit(idx, hw->used_mask))
 +                      return idx;
 +
 +      /* No counters available */
 +      return -EAGAIN;
 +}
 +
 +static int pmu_map_event(struct perf_event *event)
 +{
 +      int mapping;
 +      u8 config = event->attr.config & CCI_PMU_EVENT_MASK;
 +
 +      if (event->attr.type < PERF_TYPE_MAX)
 +              return -ENOENT;
 +
 +      if (config == CCI_PMU_CYCLES)
 +              mapping = config;
 +      else
 +              mapping = pmu_validate_hw_event(config);
 +
 +      return mapping;
 +}
 +
 +static int pmu_request_irq(struct arm_pmu *cci_pmu, irq_handler_t handler)
 +{
 +      int i;
 +      struct platform_device *pmu_device = cci_pmu->plat_device;
 +
 +      if (unlikely(!pmu_device))
 +              return -ENODEV;
 +
 +      if (pmu->nr_irqs < 1) {
 +              dev_err(&pmu_device->dev, "no irqs for CCI PMUs defined\n");
 +              return -ENODEV;
 +      }
 +
 +      /*
 +       * Register all available CCI PMU interrupts. In the interrupt handler
 +       * we iterate over the counters checking for interrupt source (the
 +       * overflowing counter) and clear it.
 +       *
 +       * This should allow handling of non-unique interrupt for the counters.
 +       */
 +      for (i = 0; i < pmu->nr_irqs; i++) {
 +              int err = request_irq(pmu->irqs[i], handler, IRQF_SHARED,
 +                              "arm-cci-pmu", cci_pmu);
 +              if (err) {
 +                      dev_err(&pmu_device->dev, "unable to request IRQ%d for ARM CCI PMU counters\n",
 +                              pmu->irqs[i]);
 +                      return err;
 +              }
 +
 +              set_bit(i, &pmu->active_irqs);
 +      }
 +
 +      return 0;
 +}
 +
 +static irqreturn_t pmu_handle_irq(int irq_num, void *dev)
 +{
 +      unsigned long flags;
 +      struct arm_pmu *cci_pmu = (struct arm_pmu *)dev;
 +      struct pmu_hw_events *events = cci_pmu->get_hw_events();
 +      struct perf_sample_data data;
 +      struct pt_regs *regs;
 +      int idx, handled = IRQ_NONE;
 +
 +      raw_spin_lock_irqsave(&events->pmu_lock, flags);
 +      regs = get_irq_regs();
 +      /*
 +       * Iterate over counters and update the corresponding perf events.
 +       * This should work regardless of whether we have per-counter overflow
 +       * interrupt or a combined overflow interrupt.
 +       */
 +      for (idx = CCI_PMU_CYCLE_CNTR_IDX; idx <= CCI_PMU_CNTR_LAST(cci_pmu); idx++) {
 +              struct perf_event *event = events->events[idx];
 +              struct hw_perf_event *hw_counter;
 +
 +              if (!event)
 +                      continue;
 +
 +              hw_counter = &event->hw;
 +
 +              /* Did this counter overflow? */
 +              if (!pmu_read_register(idx, CCI_PMU_OVRFLW) & CCI_PMU_OVRFLW_FLAG)
 +                      continue;
 +
 +              pmu_write_register(CCI_PMU_OVRFLW_FLAG, idx, CCI_PMU_OVRFLW);
 +
 +              handled = IRQ_HANDLED;
 +
 +              armpmu_event_update(event);
 +              perf_sample_data_init(&data, 0, hw_counter->last_period);
 +              if (!armpmu_event_set_period(event))
 +                      continue;
 +
 +              if (perf_event_overflow(event, &data, regs))
 +                      cci_pmu->disable(event);
 +      }
 +      raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
 +
 +      return IRQ_RETVAL(handled);
 +}
 +
 +static void pmu_free_irq(struct arm_pmu *cci_pmu)
 +{
 +      int i;
 +
 +      for (i = 0; i < pmu->nr_irqs; i++) {
 +              if (!test_and_clear_bit(i, &pmu->active_irqs))
 +                      continue;
 +
 +              free_irq(pmu->irqs[i], cci_pmu);
 +      }
 +}
 +
 +static void pmu_enable_event(struct perf_event *event)
 +{
 +      unsigned long flags;
 +      struct arm_pmu *cci_pmu = to_arm_pmu(event->pmu);
 +      struct pmu_hw_events *events = cci_pmu->get_hw_events();
 +      struct hw_perf_event *hw_counter = &event->hw;
 +      int idx = hw_counter->idx;
 +
 +      if (unlikely(!pmu_is_valid_counter(cci_pmu, idx))) {
 +              dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
 +              return;
 +      }
 +
 +      raw_spin_lock_irqsave(&events->pmu_lock, flags);
 +
 +      /* Configure the event to count, unless you are counting cycles */
 +      if (idx != CCI_PMU_CYCLE_CNTR_IDX)
 +              pmu_set_event(idx, hw_counter->config_base);
 +
 +      pmu_enable_counter(idx);
 +
 +      raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
 +}
 +
 +static void pmu_disable_event(struct perf_event *event)
 +{
 +      struct arm_pmu *cci_pmu = to_arm_pmu(event->pmu);
 +      struct hw_perf_event *hw_counter = &event->hw;
 +      int idx = hw_counter->idx;
 +
 +      if (unlikely(!pmu_is_valid_counter(cci_pmu, idx))) {
 +              dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
 +              return;
 +      }
 +
 +      pmu_disable_counter(idx);
 +}
 +
 +static void pmu_start(struct arm_pmu *cci_pmu)
 +{
 +      u32 val;
 +      unsigned long flags;
 +      struct pmu_hw_events *events = cci_pmu->get_hw_events();
 +
 +      raw_spin_lock_irqsave(&events->pmu_lock, flags);
 +
 +      /* Enable all the PMU counters. */
 +      val = readl_relaxed(cci_ctrl_base + CCI_PMCR) | CCI_PMCR_CEN;
 +      writel(val, cci_ctrl_base + CCI_PMCR);
 +
 +      raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
 +}
 +
 +static void pmu_stop(struct arm_pmu *cci_pmu)
 +{
 +      u32 val;
 +      unsigned long flags;
 +      struct pmu_hw_events *events = cci_pmu->get_hw_events();
 +
 +      raw_spin_lock_irqsave(&events->pmu_lock, flags);
 +
 +      /* Disable all the PMU counters. */
 +      val = readl_relaxed(cci_ctrl_base + CCI_PMCR) & ~CCI_PMCR_CEN;
 +      writel(val, cci_ctrl_base + CCI_PMCR);
 +
 +      raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
 +}
 +
 +static u32 pmu_read_counter(struct perf_event *event)
 +{
 +      struct arm_pmu *cci_pmu = to_arm_pmu(event->pmu);
 +      struct hw_perf_event *hw_counter = &event->hw;
 +      int idx = hw_counter->idx;
 +      u32 value;
 +
 +      if (unlikely(!pmu_is_valid_counter(cci_pmu, idx))) {
 +              dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
 +              return 0;
 +      }
 +      value = pmu_read_register(idx, CCI_PMU_CNTR);
 +
 +      return value;
 +}
 +
 +static void pmu_write_counter(struct perf_event *event, u32 value)
 +{
 +      struct arm_pmu *cci_pmu = to_arm_pmu(event->pmu);
 +      struct hw_perf_event *hw_counter = &event->hw;
 +      int idx = hw_counter->idx;
 +
 +      if (unlikely(!pmu_is_valid_counter(cci_pmu, idx)))
 +              dev_err(&cci_pmu->plat_device->dev, "Invalid CCI PMU counter %d\n", idx);
 +      else
 +              pmu_write_register(value, idx, CCI_PMU_CNTR);
 +}
 +
 +static int cci_pmu_init(struct arm_pmu *cci_pmu, struct platform_device *pdev)
 +{
 +      *cci_pmu = (struct arm_pmu){
 +              .name             = PMU_NAME,
 +              .max_period       = (1LLU << 32) - 1,
 +              .get_hw_events    = pmu_get_hw_events,
 +              .get_event_idx    = pmu_get_event_idx,
 +              .map_event        = pmu_map_event,
 +              .request_irq      = pmu_request_irq,
 +              .handle_irq       = pmu_handle_irq,
 +              .free_irq         = pmu_free_irq,
 +              .enable           = pmu_enable_event,
 +              .disable          = pmu_disable_event,
 +              .start            = pmu_start,
 +              .stop             = pmu_stop,
 +              .read_counter     = pmu_read_counter,
 +              .write_counter    = pmu_write_counter,
 +      };
 +
 +      cci_pmu->plat_device = pdev;
 +      cci_pmu->num_events = pmu_get_max_counters();
 +
 +      return armpmu_register(cci_pmu, -1);
 +}
 +
 +static const struct of_device_id arm_cci_pmu_matches[] = {
 +      {
 +              .compatible = "arm,cci-400-pmu",
 +      },
 +      {},
 +};
 +
 +static int cci_pmu_probe(struct platform_device *pdev)
 +{
 +      struct resource *res;
 +      int i, ret, irq;
 +
 +      pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL);
 +      if (!pmu)
 +              return -ENOMEM;
 +
 +      res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 +      pmu->base = devm_ioremap_resource(&pdev->dev, res);
 +      if (IS_ERR(pmu->base))
 +              return -ENOMEM;
 +
 +      /*
 +       * CCI PMU has 5 overflow signals - one per counter; but some may be tied
 +       * together to a common interrupt.
 +       */
 +      pmu->nr_irqs = 0;
 +      for (i = 0; i < CCI_PMU_MAX_HW_EVENTS; i++) {
 +              irq = platform_get_irq(pdev, i);
 +              if (irq < 0)
 +                      break;
 +
 +              if (is_duplicate_irq(irq, pmu->irqs, pmu->nr_irqs))
 +                      continue;
 +
 +              pmu->irqs[pmu->nr_irqs++] = irq;
 +      }
 +
 +      /*
 +       * Ensure that the device tree has as many interrupts as the number
 +       * of counters.
 +       */
 +      if (i < CCI_PMU_MAX_HW_EVENTS) {
 +              dev_warn(&pdev->dev, "In-correct number of interrupts: %d, should be %d\n",
 +                      i, CCI_PMU_MAX_HW_EVENTS);
 +              return -EINVAL;
 +      }
 +
 +      pmu->port_ranges = port_range_by_rev();
 +      if (!pmu->port_ranges) {
 +              dev_warn(&pdev->dev, "CCI PMU version not supported\n");
 +              return -EINVAL;
 +      }
 +
 +      pmu->cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*(pmu->cci_pmu)), GFP_KERNEL);
 +      if (!pmu->cci_pmu)
 +              return -ENOMEM;
 +
 +      pmu->hw_events.events = pmu->events;
 +      pmu->hw_events.used_mask = pmu->used_mask;
 +      raw_spin_lock_init(&pmu->hw_events.pmu_lock);
 +
 +      ret = cci_pmu_init(pmu->cci_pmu, pdev);
 +      if (ret)
 +              return ret;
 +
 +      return 0;
 +}
 +
 +static int cci_platform_probe(struct platform_device *pdev)
 +{
 +      if (!cci_probed())
 +              return -ENODEV;
 +
 +      return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
 +}
 +
 +#endif /* CONFIG_HW_PERF_EVENTS */
 +
  struct cpu_port {
        u64 mpidr;
        u32 port;
@@@ -692,7 -120,7 +692,7 @@@ int cci_ace_get_port(struct device_nod
  }
  EXPORT_SYMBOL_GPL(cci_ace_get_port);
  
 -static void __init cci_ace_init_ports(void)
 +static void cci_ace_init_ports(void)
  {
        int port, cpu;
        struct device_node *cpun;
@@@ -852,7 -280,7 +852,7 @@@ asmlinkage void __naked cci_enable_port
  
        /* Enable the CCI port */
  "     ldr     r0, [r0, %[offsetof_port_phys]] \n"
- "     mov     r3, #"__stringify(CCI_ENABLE_REQ)" \n"
+ "     mov     r3, %[cci_enable_req]\n"                   
  "     str     r3, [r0, #"__stringify(CCI_PORT_CTRL)"] \n"
  
        /* poll the status reg for completion */
  "     ldr     r0, [r1] \n"
  "     ldr     r0, [r0, r1]            @ cci_ctrl_base \n"
  "4:   ldr     r1, [r0, #"__stringify(CCI_CTRL_STATUS)"] \n"
- "     tst     r1, #1 \n"
+ "     tst     r1, %[cci_control_status_bits] \n"                      
  "     bne     4b \n"
  
  "     mov     r0, #0 \n"
  "7:   .word   cci_ctrl_phys - . \n"
        : :
        [sizeof_cpu_port] "i" (sizeof(cpu_port)),
+       [cci_enable_req] "i" cpu_to_le32(CCI_ENABLE_REQ),
+       [cci_control_status_bits] "i" cpu_to_le32(1),
  #ifndef __ARMEB__
        [offsetof_cpu_port_mpidr_lsb] "i" (offsetof(struct cpu_port, mpidr)),
  #else
@@@ -958,7 -388,7 +960,7 @@@ static const struct of_device_id arm_cc
        {},
  };
  
 -static int __init cci_probe(void)
 +static int cci_probe(void)
  {
        struct cci_nb_ports const *cci_config;
        int ret, i, nb_ace = 0, nb_ace_lite = 0;
@@@ -1062,7 -492,7 +1064,7 @@@ memalloc_err
  static int cci_init_status = -EAGAIN;
  static DEFINE_MUTEX(cci_probing);
  
 -static int __init cci_init(void)
 +static int cci_init(void)
  {
        if (cci_init_status != -EAGAIN)
                return cci_init_status;
        return cci_init_status;
  }
  
 +#ifdef CONFIG_HW_PERF_EVENTS
 +static struct platform_driver cci_pmu_driver = {
 +      .driver = {
 +                 .name = DRIVER_NAME_PMU,
 +                 .of_match_table = arm_cci_pmu_matches,
 +                },
 +      .probe = cci_pmu_probe,
 +};
 +
 +static struct platform_driver cci_platform_driver = {
 +      .driver = {
 +                 .name = DRIVER_NAME,
 +                 .of_match_table = arm_cci_matches,
 +                },
 +      .probe = cci_platform_probe,
 +};
 +
 +static int __init cci_platform_init(void)
 +{
 +      int ret;
 +
 +      ret = platform_driver_register(&cci_pmu_driver);
 +      if (ret)
 +              return ret;
 +
 +      return platform_driver_register(&cci_platform_driver);
 +}
 +
 +#else
 +
 +static int __init cci_platform_init(void)
 +{
 +      return 0;
 +}
 +
 +#endif
  /*
   * To sort out early init calls ordering a helper function is provided to
   * check if the CCI driver has beed initialized. Function check if the driver
   * has been initialized, if not it calls the init function that probes
   * the driver and updates the return value.
   */
 -bool __init cci_probed(void)
 +bool cci_probed(void)
  {
        return cci_init() == 0;
  }
  EXPORT_SYMBOL_GPL(cci_probed);
  
  early_initcall(cci_init);
 +core_initcall(cci_platform_init);
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("ARM CCI support");
diff --combined include/linux/amba/bus.h
index 682df0e1954a96718ae1e439db73441681101145,b327a1b1b7e8533ee74ab44e047c827147900d3e..63b5eff0a80f647ffc0c6bdb6064ac56d482fc34
@@@ -21,7 -21,7 +21,7 @@@
  #include <linux/resource.h>
  #include <linux/regulator/consumer.h>
  
- #define AMBA_NR_IRQS  2
+ #define AMBA_NR_IRQS  9
  #define AMBA_CID      0xb105f00d
  
  struct clk;
@@@ -30,6 -30,7 +30,6 @@@ struct amba_device 
        struct device           dev;
        struct resource         res;
        struct clk              *pclk;
 -      u64                     dma_mask;
        unsigned int            periphid;
        unsigned int            irq[AMBA_NR_IRQS];
  };
@@@ -130,6 -131,7 +130,6 @@@ struct amba_device name##_device = 
  struct amba_device name##_device = {                          \
        .dev = __AMBA_DEV(busid, data, ~0ULL),                  \
        .res = DEFINE_RES_MEM(base, SZ_4K),                     \
 -      .dma_mask = ~0ULL,                                      \
        .irq = irqs,                                            \
        .periphid = id,                                         \
  }
index 58b2d37ae23a19db3719ebfa29c98a79905a4c49,75b93d7f786010000368e299d214717131c67fa1..f5905f2b197d81d7cb2c8e0ee5a3f2cc257d5f20
@@@ -23,17 -23,19 +23,21 @@@ ifeq ($(ARCH),x86_64
    endif
    ifeq (${IS_X86_64}, 1)
      RAW_ARCH := x86_64
 -    CFLAGS += -DARCH_X86_64
 +    CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
      ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
 +    LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
 +  else
 +    LIBUNWIND_LIBS = -lunwind -lunwind-x86
    endif
    NO_PERF_REGS := 0
 -  LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
  endif
+ ifeq ($(ARCH),arm)
+   NO_PERF_REGS := 0
+   LIBUNWIND_LIBS = -lunwind -lunwind-arm
+ endif
  
  ifeq ($(NO_PERF_REGS),0)
 -  CFLAGS += -DHAVE_PERF_REGS
 +  CFLAGS += -DHAVE_PERF_REGS_SUPPORT
  endif
  
  ifeq ($(src-perf),)
@@@ -53,6 -55,7 +57,6 @@@ LIB_INCLUDE := $(srctree)/tools/lib
  # include ARCH specific config
  -include $(src-perf)/arch/$(ARCH)/Makefile
  
 -include $(src-perf)/config/feature-tests.mak
  include $(src-perf)/config/utilities.mak
  
  ifeq ($(call get-executable,$(FLEX)),)
@@@ -68,11 -71,10 +72,11 @@@ ifneq ($(WERROR),0
    CFLAGS += -Werror
  endif
  
 -ifeq ("$(origin DEBUG)", "command line")
 -  PERF_DEBUG = $(DEBUG)
 +ifndef DEBUG
 +  DEBUG := 0
  endif
 -ifndef PERF_DEBUG
 +
 +ifeq ($(DEBUG),0)
    CFLAGS += -O6
  endif
  
@@@ -91,125 -93,20 +95,125 @@@ CFLAGS += -std=gnu9
  
  EXTLIBS = -lelf -lpthread -lrt -lm -ldl
  
 -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
 -  CFLAGS += -fstack-protector-all
 +ifneq ($(OUTPUT),)
 +  OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
 +  $(shell mkdir -p $(OUTPUT_FEATURES))
  endif
  
 -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
 -  CFLAGS += -Wstack-protector
 +feature_check = $(eval $(feature_check_code))
 +define feature_check_code
 +  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
 +endef
 +
 +feature_set = $(eval $(feature_set_code))
 +define feature_set_code
 +  feature-$(1) := 1
 +endef
 +
 +#
 +# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
 +#
 +
 +#
 +# Note that this is not a complete list of all feature tests, just
 +# those that are typically built on a fully configured system.
 +#
 +# [ Feature tests not mentioned here have to be built explicitly in
 +#   the rule that uses them - an example for that is the 'bionic'
 +#   feature check. ]
 +#
 +CORE_FEATURE_TESTS =                  \
 +      backtrace                       \
 +      dwarf                           \
 +      fortify-source                  \
 +      glibc                           \
 +      gtk2                            \
 +      gtk2-infobar                    \
 +      libaudit                        \
 +      libbfd                          \
 +      libelf                          \
 +      libelf-getphdrnum               \
 +      libelf-mmap                     \
 +      libnuma                         \
 +      libperl                         \
 +      libpython                       \
 +      libpython-version               \
 +      libslang                        \
 +      libunwind                       \
 +      on-exit                         \
 +      stackprotector                  \
 +      stackprotector-all
 +
 +#
 +# So here we detect whether test-all was rebuilt, to be able
 +# to skip the print-out of the long features list if the file
 +# existed before and after it was built:
 +#
 +ifeq ($(wildcard $(OUTPUT)config/feature-checks/test-all),)
 +  test-all-failed := 1
 +else
 +  test-all-failed := 0
 +endif
 +
 +#
 +# Special fast-path for the 'all features are available' case:
 +#
 +$(call feature_check,all,$(MSG))
 +
 +#
 +# Just in case the build freshly failed, make sure we print the
 +# feature matrix:
 +#
 +ifeq ($(feature-all), 0)
 +  test-all-failed := 1
 +endif
 +
 +ifeq ($(test-all-failed),1)
 +  $(info )
 +  $(info Auto-detecting system features:)
 +endif
 +
 +ifeq ($(feature-all), 1)
 +  #
 +  # test-all.c passed - just set all the core feature flags to 1:
 +  #
 +  $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
 +else
 +  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
 +  $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
  endif
  
 -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y)
 -  CFLAGS += -Wvolatile-register-var
 +#
 +# Print the result of the feature test:
 +#
 +feature_print = $(eval $(feature_print_code)) $(info $(MSG))
 +
 +define feature_print_code
 +  ifeq ($(feature-$(1)), 1)
 +    MSG = $(shell printf '...%30s: [ \033[32mon\033[m  ]' $(1))
 +  else
 +    MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
 +  endif
 +endef
 +
 +#
 +# Only print out our features if we rebuilt the testcases or if a test failed:
 +#
 +ifeq ($(test-all-failed), 1)
 +  $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_print,$(feat)))
 +  $(info )
 +endif
 +
 +ifeq ($(feature-stackprotector-all), 1)
 +  CFLAGS += -fstack-protector-all
  endif
  
 -ifndef PERF_DEBUG
 -  ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
 +ifeq ($(feature-stackprotector), 1)
 +  CFLAGS += -Wstack-protector
 +endif
 +
 +ifeq ($(DEBUG),0)
 +  ifeq ($(feature-fortify-source), 1)
      CFLAGS += -D_FORTIFY_SOURCE=2
    endif
  endif
@@@ -235,111 -132,123 +239,115 @@@ CFLAGS += -I$(LIB_INCLUDE
  CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
  
  ifndef NO_BIONIC
 -ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y)
 -  BIONIC := 1
 -  EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
 -  EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
 +  $(call feature_check,bionic)
 +  ifeq ($(feature-bionic), 1)
 +    BIONIC := 1
 +    EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
 +    EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
 +  endif
  endif
 -endif # NO_BIONIC
  
  ifdef NO_LIBELF
    NO_DWARF := 1
    NO_DEMANGLE := 1
    NO_LIBUNWIND := 1
  else
 -FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
 -ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y)
 -  FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS)
 -  ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y)
 -    LIBC_SUPPORT := 1
 -  endif
 -  ifeq ($(BIONIC),1)
 -    LIBC_SUPPORT := 1
 -  endif
 -  ifeq ($(LIBC_SUPPORT),1)
 -    msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
 +  ifeq ($(feature-libelf), 0)
 +    ifeq ($(feature-glibc), 1)
 +      LIBC_SUPPORT := 1
 +    endif
 +    ifeq ($(BIONIC),1)
 +      LIBC_SUPPORT := 1
 +    endif
 +    ifeq ($(LIBC_SUPPORT),1)
 +      msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
  
 -    NO_LIBELF := 1
 -    NO_DWARF := 1
 -    NO_DEMANGLE := 1
 +      NO_LIBELF := 1
 +      NO_DWARF := 1
 +      NO_DEMANGLE := 1
 +    else
 +      msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
 +    endif
    else
 -    msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
 -  endif
 -else
 -  # for linking with debug library, run like:
 -  # make DEBUG=1 LIBDW_DIR=/opt/libdw/
 -  ifdef LIBDW_DIR
 -    LIBDW_CFLAGS  := -I$(LIBDW_DIR)/include
 -    LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
 -  endif
 +    # for linking with debug library, run like:
 +    # make DEBUG=1 LIBDW_DIR=/opt/libdw/
 +    ifdef LIBDW_DIR
 +      LIBDW_CFLAGS  := -I$(LIBDW_DIR)/include
 +      LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
 +    endif
  
 -  FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS)
 -  ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y)
 -    msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
 -    NO_DWARF := 1
 -  endif # Dwarf support
 -endif # SOURCE_LIBELF
 +    ifneq ($(feature-dwarf), 1)
 +      msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
 +      NO_DWARF := 1
 +    endif # Dwarf support
 +  endif # libelf support
  endif # NO_LIBELF
  
  ifndef NO_LIBELF
 -CFLAGS += -DLIBELF_SUPPORT
 -FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
 -ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
 -  CFLAGS += -DLIBELF_MMAP
 -endif
 -ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM),y)
 -  CFLAGS += -DHAVE_ELF_GETPHDRNUM
 -endif
 +  CFLAGS += -DHAVE_LIBELF_SUPPORT
  
 -# include ARCH specific config
 --include $(src-perf)/arch/$(ARCH)/Makefile
 +  ifeq ($(feature-libelf-mmap), 1)
 +    CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
 +  endif
  
 -ifndef NO_DWARF
 -ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
 -  msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
 -  NO_DWARF := 1
 -else
 -  CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS)
 -  LDFLAGS += $(LIBDW_LDFLAGS)
 -  EXTLIBS += -lelf -ldw
 -endif # PERF_HAVE_DWARF_REGS
 -endif # NO_DWARF
 +  ifeq ($(feature-libelf-getphdrnum), 1)
 +    CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
 +  endif
  
 -endif # NO_LIBELF
 +  # include ARCH specific config
 +  -include $(src-perf)/arch/$(ARCH)/Makefile
  
 -ifndef NO_LIBELF
 -CFLAGS += -DLIBELF_SUPPORT
 -FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
 -ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
 -  CFLAGS += -DLIBELF_MMAP
 -endif # try-cc
 +  ifndef NO_DWARF
 +    ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
 +      msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
 +      NO_DWARF := 1
 +    else
 +      CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
 +      LDFLAGS += $(LIBDW_LDFLAGS)
 +      EXTLIBS += -lelf -ldw
 +    endif # PERF_HAVE_DWARF_REGS
 +  endif # NO_DWARF
  endif # NO_LIBELF
  
- # There's only x86 (both 32 and 64) support for CFI unwind so far
- ifneq ($(ARCH),x86)
+ ifeq ($(LIBUNWIND_LIBS),)
    NO_LIBUNWIND := 1
  endif
  
  ifndef NO_LIBUNWIND
 -# for linking with debug library, run like:
 -# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
 -ifdef LIBUNWIND_DIR
 -  LIBUNWIND_CFLAGS  := -I$(LIBUNWIND_DIR)/include
 -  LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
 -endif
 +  #
 +  # For linking with debug library, run like:
 +  #
 +  #   make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
 +  #
 +  ifdef LIBUNWIND_DIR
 +    LIBUNWIND_CFLAGS  := -I$(LIBUNWIND_DIR)/include
 +    LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
 +  endif
  
 -FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS)
 -ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y)
 -  msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1);
 -  NO_LIBUNWIND := 1
 -endif # Libunwind support
 -ifneq ($(call try-cc,$(SOURCE_LIBUNWIND_DEBUG_FRAME),$(FLAGS_UNWIND),libunwind debug_frame),y)
 -  msg := $(warning No debug_frame support found in libunwind);
 -CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
 -endif # debug_frame support in libunwind
 -endif # NO_LIBUNWIND
 +  ifneq ($(feature-libunwind), 1)
-     msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
++    msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1);
 +    NO_LIBUNWIND := 1
++  else
++    ifneq ($(feature-libunwind-debug-frame), 1)
++      msg := $(warning No debug_frame support found in libunwind);
++      CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
++    endif
 +  endif
 +endif
  
  ifndef NO_LIBUNWIND
 -  CFLAGS += -DLIBUNWIND_SUPPORT
 +  CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
    EXTLIBS += $(LIBUNWIND_LIBS)
    CFLAGS += $(LIBUNWIND_CFLAGS)
    LDFLAGS += $(LIBUNWIND_LDFLAGS)
 -endif # NO_LIBUNWIND
 +endif
  
  ifndef NO_LIBAUDIT
 -  FLAGS_LIBAUDIT = $(CFLAGS) $(LDFLAGS) -laudit
 -  ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y)
 +  ifneq ($(feature-libaudit), 1)
      msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
      NO_LIBAUDIT := 1
    else
 -    CFLAGS += -DLIBAUDIT_SUPPORT
 +    CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
      EXTLIBS += -laudit
    endif
  endif
@@@ -349,30 -258,30 +357,30 @@@ ifdef NO_NEW
  endif
  
  ifndef NO_SLANG
 -  FLAGS_SLANG=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang
 -  ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y)
 +  ifneq ($(feature-libslang), 1)
      msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
      NO_SLANG := 1
    else
      # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
      CFLAGS += -I/usr/include/slang
 -    CFLAGS += -DSLANG_SUPPORT
 +    CFLAGS += -DHAVE_SLANG_SUPPORT
      EXTLIBS += -lslang
    endif
  endif
  
  ifndef NO_GTK2
    FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
 -  ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y)
 +  ifneq ($(feature-gtk2), 1)
      msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
      NO_GTK2 := 1
    else
 -    ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y)
 -      CFLAGS += -DHAVE_GTK_INFO_BAR
 +    ifeq ($(feature-gtk2-infobar), 1)
 +      GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
      endif
 -    CFLAGS += -DGTK2_SUPPORT
 -    CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
 -    EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
 +    CFLAGS += -DHAVE_GTK2_SUPPORT
 +    GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
 +    GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
 +    EXTLIBS += -ldl
    endif
  endif
  
@@@ -388,7 -297,7 +396,7 @@@ els
    PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
    FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
  
 -  ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y)
 +  ifneq ($(feature-libperl), 1)
      CFLAGS += -DNO_LIBPERL
      NO_LIBPERL := 1
    else
    endif
  endif
  
 +$(call feature_check,timerfd)
 +ifeq ($(feature-timerfd), 1)
 +  CFLAGS += -DHAVE_TIMERFD_SUPPORT
 +else
 +  msg := $(warning No timerfd support. Disables 'perf kvm stat live');
 +endif
 +
  disable-python = $(eval $(disable-python_code))
  define disable-python_code
    CFLAGS += -DNO_LIBPYTHON
@@@ -440,11 -342,11 +448,11 @@@ els
        PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
        FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
  
 -      ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y)
 +      ifneq ($(feature-libpython), 1)
          $(call disable-python,Python.h (for Python 2.x))
        else
  
 -        ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y)
 +        ifneq ($(feature-libpython-version), 1)
            $(warning Python 3 is not yet supported; please set)
            $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
            $(warning If you also have Python 2 installed, then)
    endif
  endif
  
 +ifeq ($(feature-libbfd), 1)
 +  EXTLIBS += -lbfd
 +endif
 +
  ifdef NO_DEMANGLE
    CFLAGS += -DNO_DEMANGLE
  else
 -  ifdef HAVE_CPLUS_DEMANGLE
 +  ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
      EXTLIBS += -liberty
 -    CFLAGS += -DHAVE_CPLUS_DEMANGLE
 +    CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
    else
 -    FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
 -    has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd)
 -    ifeq ($(has_bfd),y)
 -      EXTLIBS += -lbfd
 -    else
 -      FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
 -      has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
 -      ifeq ($(has_bfd_iberty),y)
 +    ifneq ($(feature-libbfd), 1)
 +      $(call feature_check,liberty)
 +      ifeq ($(feature-liberty), 1)
          EXTLIBS += -lbfd -liberty
        else
 -        FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
 -        has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz)
 -        ifeq ($(has_bfd_iberty_z),y)
 +        $(call feature_check,liberty-z)
 +        ifeq ($(feature-liberty-z), 1)
            EXTLIBS += -lbfd -liberty -lz
          else
 -          FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty
 -          has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle)
 -          ifeq ($(has_cplus_demangle),y)
 +          $(call feature_check,cplus-demangle)
 +          ifeq ($(feature-cplus-demangle), 1)
              EXTLIBS += -liberty
 -            CFLAGS += -DHAVE_CPLUS_DEMANGLE
 +            CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
            else
              msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
              CFLAGS += -DNO_DEMANGLE
    endif
  endif
  
 -ifndef NO_STRLCPY
 -  ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y)
 -    CFLAGS += -DHAVE_STRLCPY
 -  endif
 +ifneq ($(filter -lbfd,$(EXTLIBS)),)
 +  CFLAGS += -DHAVE_LIBBFD_SUPPORT
  endif
  
  ifndef NO_ON_EXIT
 -  ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y)
 -    CFLAGS += -DHAVE_ON_EXIT
 +  ifeq ($(feature-on-exit), 1)
 +    CFLAGS += -DHAVE_ON_EXIT_SUPPORT
    endif
  endif
  
  ifndef NO_BACKTRACE
 -  ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y)
 -    CFLAGS += -DBACKTRACE_SUPPORT
 +  ifeq ($(feature-backtrace), 1)
 +    CFLAGS += -DHAVE_BACKTRACE_SUPPORT
    endif
  endif
  
  ifndef NO_LIBNUMA
 -  FLAGS_LIBNUMA = $(CFLAGS) $(LDFLAGS) -lnuma
 -  ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y)
 +  ifeq ($(feature-libnuma), 0)
      msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
      NO_LIBNUMA := 1
    else
 -    CFLAGS += -DLIBNUMA_SUPPORT
 +    CFLAGS += -DHAVE_LIBNUMA_SUPPORT
      EXTLIBS += -lnuma
    endif
  endif
@@@ -558,12 -466,7 +566,12 @@@ els
  sysconfdir = $(prefix)/etc
  ETC_PERFCONFIG = etc/perfconfig
  endif
 +ifeq ($(IS_X86_64),1)
 +lib = lib64
 +else
  lib = lib
 +endif
 +libdir = $(prefix)/$(lib)
  
  # Shell quote (do not use $(call) to accommodate ancient setups);
  ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
@@@ -576,7 -479,6 +584,7 @@@ template_dir_SQ = $(subst ','\'',$(temp
  htmldir_SQ = $(subst ','\'',$(htmldir))
  prefix_SQ = $(subst ','\'',$(prefix))
  sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
 +libdir_SQ = $(subst ','\'',$(libdir))
  
  ifneq ($(filter /%,$(firstword $(perfexecdir))),)
  perfexec_instdir = $(perfexecdir)
index c803f17fb9869648c97ba9efe93e3a05b4e4329d,0000000000000000000000000000000000000000..e8e195f49a4ee7695a80b2a4d535fb35a5aac504
mode 100644,000000..100644
--- /dev/null
@@@ -1,148 -1,0 +1,149 @@@
 +
 +FILES=                                        \
 +      test-all                        \
 +      test-backtrace                  \
 +      test-bionic                     \
 +      test-dwarf                      \
 +      test-fortify-source             \
 +      test-glibc                      \
 +      test-gtk2                       \
 +      test-gtk2-infobar               \
 +      test-hello                      \
 +      test-libaudit                   \
 +      test-libbfd                     \
 +      test-liberty                    \
 +      test-liberty-z                  \
 +      test-cplus-demangle             \
 +      test-libelf                     \
 +      test-libelf-getphdrnum          \
 +      test-libelf-mmap                \
 +      test-libnuma                    \
 +      test-libperl                    \
 +      test-libpython                  \
 +      test-libpython-version          \
 +      test-libslang                   \
 +      test-libunwind                  \
++      test-libunwind-debug-frame      \
 +      test-on-exit                    \
 +      test-stackprotector-all         \
 +      test-stackprotector             \
 +      test-timerfd
 +
 +CC := $(CC) -MD
 +
 +all: $(FILES)
 +
 +BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
 +
 +###############################
 +
 +test-all:
 +      $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
 +
 +test-hello:
 +      $(BUILD)
 +
 +test-stackprotector-all:
 +      $(BUILD) -Werror -fstack-protector-all
 +
 +test-stackprotector:
 +      $(BUILD) -Werror -fstack-protector -Wstack-protector
 +
 +test-fortify-source:
 +      $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
 +
 +test-bionic:
 +      $(BUILD)
 +
 +test-libelf:
 +      $(BUILD) -lelf
 +
 +test-glibc:
 +      $(BUILD)
 +
 +test-dwarf:
 +      $(BUILD) -ldw
 +
 +test-libelf-mmap:
 +      $(BUILD) -lelf
 +
 +test-libelf-getphdrnum:
 +      $(BUILD) -lelf
 +
 +test-libnuma:
 +      $(BUILD) -lnuma
 +
 +test-libunwind:
 +      $(BUILD) $(LIBUNWIND_LIBS) -lelf
 +
 +test-libaudit:
 +      $(BUILD) -laudit
 +
 +test-libslang:
 +      $(BUILD) -I/usr/include/slang -lslang
 +
 +test-gtk2:
 +      $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
 +
 +test-gtk2-infobar:
 +      $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
 +
 +grep-libs  = $(filter -l%,$(1))
 +strip-libs = $(filter-out -l%,$(1))
 +
 +PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
 +PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
 +PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
 +PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
 +FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 +
 +test-libperl:
 +      $(BUILD) $(FLAGS_PERL_EMBED)
 +
 +override PYTHON := python
 +override PYTHON_CONFIG := python-config
 +
 +escape-for-shell-sq =  $(subst ','\'',$(1))
 +shell-sq = '$(escape-for-shell-sq)'
 +
 +PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
 +
 +PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
 +PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
 +PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
 +PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
 +FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
 +
 +test-libpython:
 +      $(BUILD) $(FLAGS_PYTHON_EMBED)
 +
 +test-libpython-version:
 +      $(BUILD) $(FLAGS_PYTHON_EMBED)
 +
 +test-libbfd:
 +      $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
 +
 +test-liberty:
 +      $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
 +
 +test-liberty-z:
 +      $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
 +
 +test-cplus-demangle:
 +      $(BUILD) -liberty
 +
 +test-on-exit:
 +      $(BUILD)
 +
 +test-backtrace:
 +      $(BUILD)
 +
 +test-timerfd:
 +      $(BUILD)
 +
 +-include *.d
 +
 +###############################
 +
 +clean:
 +      rm -f $(FILES) *.d
index 59e7a705e146d4eb8ea029ebf74878411f8e3898,0000000000000000000000000000000000000000..799865b607721e247b847711cf656ef375ada341
mode 100644,000000..100644
--- /dev/null
@@@ -1,111 -1,0 +1,115 @@@
 +/*
 + * test-all.c: Try to build all the main testcases at once.
 + *
 + * A well-configured system will have all the prereqs installed, so we can speed
 + * up auto-detection on such systems.
 + */
 +
 +/*
 + * Quirk: Python and Perl headers cannot be in arbitrary places, so keep
 + * these 3 testcases at the top:
 + */
 +#define main main_test_libpython
 +# include "test-libpython.c"
 +#undef main
 +
 +#define main main_test_libpython_version
 +# include "test-libpython-version.c"
 +#undef main
 +
 +#define main main_test_libperl
 +# include "test-libperl.c"
 +#undef main
 +
 +#define main main_test_hello
 +# include "test-hello.c"
 +#undef main
 +
 +#define main main_test_libelf
 +# include "test-libelf.c"
 +#undef main
 +
 +#define main main_test_libelf_mmap
 +# include "test-libelf-mmap.c"
 +#undef main
 +
 +#define main main_test_glibc
 +# include "test-glibc.c"
 +#undef main
 +
 +#define main main_test_dwarf
 +# include "test-dwarf.c"
 +#undef main
 +
 +#define main main_test_libelf_getphdrnum
 +# include "test-libelf-getphdrnum.c"
 +#undef main
 +
 +#define main main_test_libunwind
 +# include "test-libunwind.c"
 +#undef main
 +
++#define main main_test_libunwind_debug_frame
++# include "test-libunwind-debug-frame.c"
++#undef main
++
 +#define main main_test_libaudit
 +# include "test-libaudit.c"
 +#undef main
 +
 +#define main main_test_libslang
 +# include "test-libslang.c"
 +#undef main
 +
 +#define main main_test_gtk2
 +# include "test-gtk2.c"
 +#undef main
 +
 +#define main main_test_gtk2_infobar
 +# include "test-gtk2-infobar.c"
 +#undef main
 +
 +#define main main_test_libbfd
 +# include "test-libbfd.c"
 +#undef main
 +
 +#define main main_test_on_exit
 +# include "test-on-exit.c"
 +#undef main
 +
 +#define main main_test_backtrace
 +# include "test-backtrace.c"
 +#undef main
 +
 +#define main main_test_libnuma
 +# include "test-libnuma.c"
 +#undef main
 +
 +#define main main_test_timerfd
 +# include "test-timerfd.c"
 +#undef main
 +
 +int main(int argc, char *argv[])
 +{
 +      main_test_libpython();
 +      main_test_libpython_version();
 +      main_test_libperl();
 +      main_test_hello();
 +      main_test_libelf();
 +      main_test_libelf_mmap();
 +      main_test_glibc();
 +      main_test_dwarf();
 +      main_test_libelf_getphdrnum();
 +      main_test_libunwind();
 +      main_test_libaudit();
 +      main_test_libslang();
 +      main_test_gtk2(argc, argv);
 +      main_test_gtk2_infobar(argc, argv);
 +      main_test_libbfd();
 +      main_test_on_exit();
 +      main_test_backtrace();
 +      main_test_libnuma();
 +      main_test_timerfd();
 +
 +      return 0;
 +}
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..0ef8087a104a7c9623b85ac097c3b406e114d405
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,16 @@@
++#include <libunwind.h>
++#include <stdlib.h>
++
++extern int
++UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
++                               unw_word_t ip, unw_word_t segbase,
++                               const char *obj_name, unw_word_t start,
++                               unw_word_t end);
++
++#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
++
++int main(void)
++{
++      dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
++      return 0;
++}