From cc9e390f8f79431af67d8ccf177187660d1c36a9 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Wed, 31 Aug 2011 00:03:13 +0800 Subject: usb: ehci: make HC see up-to-date qh/qtd descriptor ASAP This patch introduces the helper of ehci_sync_mem to flush qtd/qh into memory immediately on some ARM, so that HC can see the up-to-date qtd/qh descriptor asap. This patch fixs one performance bug on ARM Cortex A9 dual core platform, which has been reported on quite a few ARM machines (OMAP4, Tegra 2, snowball...), see details from link of https://bugs.launchpad.net/bugs/709245. The patch has been tested ok on OMAP4 panda A1 board, and the performance of 'dd' over usb mass storage can be increased from 4~5MB/sec to 14~16MB/sec after applying this patch. Cc: Russell King Signed-off-by: Ming Lei Signed-off-by: Alan Stern --- drivers/usb/host/ehci-q.c | 18 ++++++++++++++++++ drivers/usb/host/ehci.h | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 4b66374bdc8e..940a63f67a21 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -1018,6 +1018,12 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh) head->qh_next.qh = qh; head->hw->hw_next = dma; + /* + * flush qh descriptor into memory immediately, + * see comments in qh_append_tds. + */ + ehci_sync_mem(); + qh->xacterrs = 0; qh->qh_state = QH_STATE_LINKED; /* qtd completions reported later by interrupt */ @@ -1106,6 +1112,18 @@ static struct ehci_qh *qh_append_tds ( wmb (); dummy->hw_token = token; + /* + * Writing to dma coherent buffer on ARM may + * be delayed to reach memory, so HC may not see + * hw_token of dummy qtd in time, which can cause + * the qtd transaction to be executed very late, + * and degrade performance a lot. ehci_sync_mem + * is added to flush 'token' immediatelly into + * memory, so that ehci can execute the transaction + * ASAP. + */ + ehci_sync_mem(); + urb->hcpriv = qh; } } diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index da07d98f7d1d..53ed57567ce5 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -760,6 +760,23 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) #endif +/* + * Writing to dma coherent memory on ARM may be delayed via L2 + * writing buffer, so introduce the helper which can flush L2 writing + * buffer into memory immediately, especially used to flush ehci + * descriptor to memory. + */ +#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE +static inline void ehci_sync_mem() +{ + mb(); +} +#else +static inline void ehci_sync_mem() +{ +} +#endif + /*-------------------------------------------------------------------------*/ #ifdef CONFIG_PCI -- cgit v1.2.3 From d8f7c4ede0454eff447f2a5e51b5bfe99c826d47 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Wed, 31 Oct 2012 13:32:51 +0400 Subject: ARM: dtb: add versatile dtb target to common Makefile Makes 'make dtbs' build the versatile .dtb files when versatile is enabled. Signed-off-by: Andrey Konovalov --- arch/arm/boot/dts/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index f37cf9fa5fa0..b24372a6fdec 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -95,6 +95,8 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ tegra20-whistler.dtb \ tegra30-cardhu-a02.dtb \ tegra30-cardhu-a04.dtb +dtb-$(CONFIG_ARCH_VERSATILE) += versatile-ab.dtb \ + versatile-pb.dtb dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \ vexpress-v2p-ca9.dtb \ vexpress-v2p-ca15-tc1.dtb \ -- cgit v1.2.3 From af2e1e7cd8adc16ce07348cba5358a1a627239e9 Mon Sep 17 00:00:00 2001 From: James Westby Date: Tue, 24 Apr 2012 14:34:24 +0530 Subject: Support kernel cross build with deb-pkg Signed-off-by: Avik Sil --- scripts/package/builddeb | 80 ++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index acb86507828a..88eabb6120b7 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -12,6 +12,43 @@ set -e +# Attempt to find the correct Debian architecture +forcearch="" +debarch="" +case "$UTS_MACHINE" in +i386|ia64|alpha) + debarch="$UTS_MACHINE" ;; +x86_64) + debarch=amd64 ;; +sparc*) + debarch=sparc ;; +s390*) + debarch=s390 ;; +ppc*) + debarch=powerpc ;; +parisc*) + debarch=hppa ;; +mips*) + debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; +arm*) + debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; +*) + echo "" >&2 + echo "** ** ** WARNING ** ** **" >&2 + echo "" >&2 + echo "Your architecture doesn't have it's equivalent" >&2 + echo "Debian userspace architecture defined!" >&2 + echo "Falling back to using your current userspace instead!" >&2 + echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 + echo "" >&2 +esac +if [ -n "$KBUILD_DEBARCH" ] ; then + debarch="$KBUILD_DEBARCH" +fi +if [ -n "$debarch" ] ; then + forcearch="-DArchitecture=$debarch" +fi + create_package() { local pname="$1" pdir="$2" @@ -25,42 +62,6 @@ create_package() { chown -R root:root "$pdir" chmod -R go-w "$pdir" - # Attempt to find the correct Debian architecture - local forcearch="" debarch="" - case "$UTS_MACHINE" in - i386|ia64|alpha) - debarch="$UTS_MACHINE" ;; - x86_64) - debarch=amd64 ;; - sparc*) - debarch=sparc ;; - s390*) - debarch=s390 ;; - ppc*) - debarch=powerpc ;; - parisc*) - debarch=hppa ;; - mips*) - debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; - arm*) - debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; - *) - echo "" >&2 - echo "** ** ** WARNING ** ** **" >&2 - echo "" >&2 - echo "Your architecture doesn't have it's equivalent" >&2 - echo "Debian userspace architecture defined!" >&2 - echo "Falling back to using your current userspace instead!" >&2 - echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 - echo "" >&2 - esac - if [ -n "$KBUILD_DEBARCH" ] ; then - debarch="$KBUILD_DEBARCH" - fi - if [ -n "$debarch" ] ; then - forcearch="-DArchitecture=$debarch" - fi - # Create the package dpkg-gencontrol -isp $forcearch -p$pname -P"$pdir" dpkg --build "$pdir" .. @@ -252,15 +253,14 @@ mkdir -p "$destdir" (cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -) ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" -arch=$(dpkg --print-architecture) cat <> debian/control Package: $kernel_headers_packagename Provides: linux-headers, linux-headers-2.6 -Architecture: $arch -Description: Linux kernel headers for $KERNELRELEASE on $arch - This package provides kernel header files for $KERNELRELEASE on $arch +Architecture: $debarch +Description: Linux kernel headers for $KERNELRELEASE on $debarch + This package provides kernel header files for $KERNELRELEASE on $debarch . This is useful for people who need to build external modules EOF -- cgit v1.2.3 From 6fbe81aac01c28a9632bd326c3c05331f3707cc4 Mon Sep 17 00:00:00 2001 From: Avik Sil Date: Tue, 24 Apr 2012 14:05:55 +0530 Subject: Add device tree files to deb package Signed-off-by: Avik Sil --- scripts/package/builddeb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 88eabb6120b7..7621018a538b 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -119,6 +119,11 @@ else else cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" fi + # Copy device tree files if generated + stat arch/$ARCH/boot/*.dtb && { + mkdir -p "$tmpdir/boot/dt-$version" + cp arch/$ARCH/boot/*.dtb "$tmpdir/boot/dt-$version" + } fi if grep -q '^CONFIG_MODULES=y' .config ; then -- cgit v1.2.3 From d84732ee6f1e180be1a909e0fc69728c58b77353 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Mon, 8 Oct 2012 23:15:49 +0400 Subject: Leave the DT blob in the kernel image package, but move to /lib/firmware Signed-off-by: Andrey Konovalov --- scripts/package/builddeb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 7621018a538b..22686b9c156e 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -119,11 +119,6 @@ else else cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" fi - # Copy device tree files if generated - stat arch/$ARCH/boot/*.dtb && { - mkdir -p "$tmpdir/boot/dt-$version" - cp arch/$ARCH/boot/*.dtb "$tmpdir/boot/dt-$version" - } fi if grep -q '^CONFIG_MODULES=y' .config ; then @@ -286,6 +281,12 @@ EOF create_package "$fwpackagename" "$fwdir" fi +# Copy device tree files if generated +stat arch/$ARCH/boot/*.dtb && { + mkdir -p "$tmpdir/lib/firmware/$version/device-tree" + cp arch/$ARCH/boot/*.dtb "$tmpdir/lib/firmware/$version/device-tree" +} + cat <> debian/control Package: $libc_headers_packagename -- cgit v1.2.3 From 1943f3850ddf7afb774dc9a09d4d3fab50178c90 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Thu, 1 Nov 2012 14:06:00 +0400 Subject: Make omapdrm to compile after UAPI changes Commit 718dcedd7e87f448a1eeeda4d1a986284c243110 "UAPI: (Scripted) Disintegrate include/drm" moved drm_mode.h into different directory. Fortunately drm_crtc.h includes drm_mode.h, so this is enough just to remove one #include line. Signed-off-by: Andrey Konovalov --- drivers/staging/omapdrm/omap_crtc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/omapdrm/omap_crtc.c b/drivers/staging/omapdrm/omap_crtc.c index 732f2ad34036..35ab9a993ff4 100644 --- a/drivers/staging/omapdrm/omap_crtc.c +++ b/drivers/staging/omapdrm/omap_crtc.c @@ -19,7 +19,6 @@ #include "omap_drv.h" -#include "drm_mode.h" #include "drm_crtc.h" #include "drm_crtc_helper.h" -- cgit v1.2.3 From 7d85440887bf00d704c0e940fb3d3799bfff7011 Mon Sep 17 00:00:00 2001 From: John Rigby Date: Tue, 10 Jan 2012 12:01:41 -0700 Subject: KBuild: Allow scripts/* to be cross compiled Cross compiling the binaries in scripts/* is not possible because various makefiles assume that $(obj)/whatever is executable on the build host. This patch introduces a new variable called KBUILD_SCRIPTROOT that points to script/binaries to use while cross compiling. Usage: Build scripts for the build host: make O=path/to/buildhost/buildscripts \ silentoldconfig prepare scripts Then cross build script for target: make O=path/to/target/buildscripts \ HOSTCC=$CROSS_COMPILE \ KBUILD_SCRIPTROOT=path/to/buildhost/buildscripts silentoldconfig prepare scripts This patch does not use KBUILD_SCRIPTROOT for all script invocations it only redefines the following if KBUILD_SCRIPTROOT is defined. scripts/Makefile.build scripts/basic/fixdep --> $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep scripts/kconfig/Makefile $(obj)/conf --> $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf scripts/mod/Makefile $(obj)mk_elfconfig --> $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig Signed-off-by: John Rigby --- scripts/Kbuild.include | 6 +++++- scripts/Makefile.build | 6 +++++- scripts/kconfig/Makefile | 30 ++++++++++++++++++------------ scripts/mod/Makefile | 10 ++++++++-- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 978416dd31ca..5ecac2ae6fd3 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -222,11 +222,15 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ $(echo-cmd) $(cmd_$(1)); \ echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) +ifeq ($(KBUILD_SCRIPTROOT),) +KBUILD_SCRIPTROOT=. +endif + # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ + $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 0e801c3cdaf8..641a7bbdaad9 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -290,13 +290,17 @@ cmd_record_mcount = \ fi; endif +ifeq ($(KBUILD_SCRIPTROOT),) +KBUILD_SCRIPTROOT=. +endif + define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ $(cmd_modversions) \ $(call echo-cmd,record_mcount) \ $(cmd_record_mcount) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ + $(KBUILD_SCRIPTROOT)/scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ $(dot-target).tmp; \ rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 3091794e9354..ee7797d9eaf1 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -11,6 +11,12 @@ else Kconfig := Kconfig endif +ifdef KBUILD_SCRIPTROOT +CONF = $(KBUILD_SCRIPTROOT)/scripts/kconfig/conf +else +CONF = $(obj)/conf +endif + xconfig: $(obj)/qconf $< $(Kconfig) @@ -20,31 +26,31 @@ gconfig: $(obj)/gconf menuconfig: $(obj)/mconf $< $(Kconfig) -config: $(obj)/conf +config: $(CONF) $< --oldaskconfig $(Kconfig) nconfig: $(obj)/nconf $< $(Kconfig) -oldconfig: $(obj)/conf +oldconfig: $(CONF) $< --$@ $(Kconfig) -silentoldconfig: $(obj)/conf +silentoldconfig: $(CONF) $(Q)mkdir -p include/generated $< --$@ $(Kconfig) -localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf +localyesconfig localmodconfig: $(obj)/streamline_config.pl $(CONF) $(Q)mkdir -p include/generated $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ (mv -f .config .config.old.1; \ mv -f .tmp.config .config; \ - $(obj)/conf --silentoldconfig $(Kconfig); \ + $(CONF) --silentoldconfig $(Kconfig); \ mv -f .config.old.1 .config.old) \ else \ mv -f .tmp.config .config; \ - $(obj)/conf --silentoldconfig $(Kconfig); \ + $(CONF) --silentoldconfig $(Kconfig); \ fi $(Q)rm -f .tmp.config @@ -73,24 +79,24 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig -allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf +allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(CONF) $< --$@ $(Kconfig) PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig -listnewconfig olddefconfig: $(obj)/conf +listnewconfig olddefconfig: $(CONF) $< --$@ $(Kconfig) # oldnoconfig is an alias of olddefconfig, because people already are dependent # on its behavior(sets new symbols to their default value but not 'n') with the # counter-intuitive name. -oldnoconfig: $(obj)/conf +oldnoconfig: $(CONF) $< --olddefconfig $(Kconfig) -savedefconfig: $(obj)/conf +savedefconfig: $(CONF) $< --$@=defconfig $(Kconfig) -defconfig: $(obj)/conf +defconfig: $(CONF) ifeq ($(KBUILD_DEFCONFIG),) $< --defconfig $(Kconfig) else @@ -98,7 +104,7 @@ else $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) endif -%_defconfig: $(obj)/conf +%_defconfig: $(CONF) $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) # Help text used by make help diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index ff954f8168c1..258d4ba32d51 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile @@ -1,6 +1,12 @@ hostprogs-y := modpost mk_elfconfig always := $(hostprogs-y) empty.o +ifdef KBUILD_SCRIPTROOT +MKELFCONFIG = $(KBUILD_SCRIPTROOT)/scripts/mod/mk_elfconfig +else +MKELFCONFIG = $(obj)/mk_elfconfig +endif + modpost-objs := modpost.o file2alias.o sumversion.o # dependencies on generated files need to be listed explicitly @@ -8,9 +14,9 @@ modpost-objs := modpost.o file2alias.o sumversion.o $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h quiet_cmd_elfconfig = MKELF $@ - cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ + cmd_elfconfig = $(MKELFCONFIG) < $< > $@ -$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE +$(obj)/elfconfig.h: $(obj)/empty.o $(MKELFCONFIG) FORCE $(call if_changed,elfconfig) targets += elfconfig.h -- cgit v1.2.3 From eb1164dbda13dd44ddbd3fc0a41233dd1c3cf08f Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 22 Nov 2012 15:13:45 +0100 Subject: perf: Allow building for Android Signed-off-by: Bernhard Rosenkraenzer --- tools/perf/Makefile | 15 ++++- tools/perf/builtin-record.c | 33 +++++++++++ tools/perf/builtin-test.c | 7 +++ tools/perf/builtin.h | 1 + tools/perf/compat-android.h | 106 ++++++++++++++++++++++++++++++++++++ tools/perf/config/feature-tests.mak | 13 +++++ tools/perf/util/event.c | 1 + tools/perf/util/event.h | 1 + tools/perf/util/util.h | 2 + 9 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 tools/perf/compat-android.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 00deed4d6159..267ffb1a71aa 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -104,7 +104,7 @@ ifdef PARSER_DEBUG endif CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) -EXTLIBS = -lpthread -lrt -lelf -lm +EXTLIBS = -lpthread -lelf -lm ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE ALL_LDFLAGS = $(LDFLAGS) STRIP ?= strip @@ -471,7 +471,14 @@ FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y) - msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); + ifeq ($(call try-cc,$(SOURCE_BIONIC),$(FLAGS_GLIBC)),y) + # Found Bionic instead of glibc... + # That works too, but needs a bit of special treatment + BASIC_CFLAGS += -DANDROID -include compat-android.h + ANDROID := 1 + else + msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); + endif else NO_LIBELF := 1 NO_DWARF := 1 @@ -486,6 +493,10 @@ else endif # SOURCE_LIBELF endif # NO_LIBELF +ifneq ($(ANDROID),1) +EXTLIBS += -lrt +endif + ifndef NO_LIBUNWIND # for linking with debug library, run like: # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e9231659754d..451db235c1c9 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -27,10 +27,43 @@ #include "util/cpumap.h" #include "util/thread_map.h" +#include #include #include #include +#ifdef ANDROID +/* While stdlib.h has a prototype for it, + Bionic doesn't actually implement on_exit() */ +#ifndef ATEXIT_MAX +#define ATEXIT_MAX 32 +#endif +static int __on_exit_count = 0; +typedef void (*on_exit_func_t)(int, void*); +static on_exit_func_t __on_exit_funcs[ATEXIT_MAX]; +static void *__on_exit_args[ATEXIT_MAX]; +static int __exitcode = 0; +static void __handle_on_exit_funcs(); +static int on_exit(on_exit_func_t function, void *arg); +#define exit(x) (exit)(__exitcode = (x)) + +static int on_exit(on_exit_func_t function, void *arg) { + if(__on_exit_count == ATEXIT_MAX) + return ENOMEM; + else if(__on_exit_count == 0) + atexit(__handle_on_exit_funcs); + __on_exit_funcs[__on_exit_count] = function; + __on_exit_args[__on_exit_count++] = arg; + return 0; +} + +static void __handle_on_exit_funcs() { + for(int i=0; i<__on_exit_count; i++) { + __on_exit_funcs[i](__exitcode, __on_exit_args[i]); + } +} +#endif + enum write_mode_t { WRITE_FORCE, WRITE_APPEND diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 484f26cc0c00..70a9cd63c6e6 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c @@ -471,10 +471,17 @@ static int test__basic_mmap(void) .watermark = 0, }; cpu_set_t cpu_set; +#ifndef ANDROID const char *syscall_names[] = { "getsid", "getppid", "getpgrp", "getpgid", }; pid_t (*syscalls[])(void) = { (void *)getsid, getppid, getpgrp, (void*)getpgid }; +#else + /* No getsid() on Android */ + const char *syscall_names[] = { "getppid", "getpgrp", + "getpgid", }; + pid_t (*syscalls[])(void) = { getppid, getpgrp, (void*)getpgid }; +#endif #define nsyscalls ARRAY_SIZE(syscall_names) int ids[nsyscalls]; unsigned int nr_events[nsyscalls], diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h index 08143bd854c7..5e5ec41494eb 100644 --- a/tools/perf/builtin.h +++ b/tools/perf/builtin.h @@ -1,6 +1,7 @@ #ifndef BUILTIN_H #define BUILTIN_H +#include "compat-android.h" #include "util/util.h" #include "util/strbuf.h" diff --git a/tools/perf/compat-android.h b/tools/perf/compat-android.h new file mode 100644 index 000000000000..b8fb93679329 --- /dev/null +++ b/tools/perf/compat-android.h @@ -0,0 +1,106 @@ +/* Android compatibility header + * Provides missing bits in Bionic on Android, ignored + * on regular Linux. + * + * Written by Bernhard.Rosenkranzer@linaro.org + * + * Released into the public domain. Do with this file + * whatever you want. + */ +#ifdef ANDROID +/* Bionic has its own idea about ALIGN, and kills other definitions. + * Done outside the multiple-inclusion wrapper to make sure we + * can override Bionic's ALIGN by simply including compat-android.h + * again after including Bionic headers. + */ +#undef ALIGN +#undef __ALIGN_MASK +#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) + +#ifndef _COMPAT_ANDROID_H_ +#define _COMPAT_ANDROID_H_ 1 +#include +#include +#include /* for PAGE_SIZE */ +#include /* for winsize */ + +#ifndef __WORDSIZE +#include +#define __WORDSIZE _BITSIZE +#endif + +#ifndef roundup +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#endif + +#ifndef __force +#define __force +#endif + +#ifndef __le32 +#define __le32 uint32_t +#endif + +/* Assorted functions that are missing from Bionic */ +/* Android prior to 4.2 lacks psignal(). + * What we're doing here is fairly evil - but necessary since + * Bionic doesn't export any version identifier or the likes. + * We do know that 4.2 is the version introducing psignal() and + * also KLOG_CONSOLE_OFF -- completely unrelated, but something + * we can check for... + */ +#include +#ifndef KLOG_CONSOLE_OFF +static void psignal(int sig, const char *s) +{ + if(sig >= 0 && sig < NSIG) { + if(s) + fprintf(stderr, "%s: %s\n", s, sys_siglist[sig]); + else + fprintf(stderr, "%s\n", sys_siglist[sig]); + } else { + if(s) + fprintf(stderr, "%s: invalid signal\n", s); + else + fputs("invalid signal\n", stderr); + } +} +#endif + +static ssize_t getline(char **lineptr, size_t *n, FILE *stream) +{ + size_t ret = 0; + + if (!lineptr || !n || !stream) + return -1; + + if(!*lineptr) { + *n = 128; + *lineptr = (char*)malloc(*n); + if(!*lineptr) + return -1; + } + + while(!feof(stream) && !ferror(stream)) { + int c; + if(ret == *n) { + *n += 128; + *lineptr = (char*)realloc(*lineptr, *n); + if(!*lineptr) { + *n = 0; + return -1; + } + } + c = fgetc(stream); + if(c == EOF) + break; + *lineptr[ret++] = c; + if(c == '\n') + break; + } + *lineptr[ret] = 0; + return ret; +} +#endif +#endif diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 4add41bb0c7e..76ec8bf24783 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -43,6 +43,19 @@ int main(void) } endef +define SOURCE_BIONIC +#include + +int main(void) +{ +#ifndef __ANDROID_API__ + error out +#else + return 0; +#endif +} +endef + define SOURCE_ELF_MMAP #include int main(void) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 6715b1938725..1b33d0168996 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -6,6 +6,7 @@ #include "strlist.h" #include "thread.h" #include "thread_map.h" +#include "../compat-android.h" static const char *perf_event__names[] = { [0] = "TOTAL", diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 21b99e741a87..892d0340278b 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -6,6 +6,7 @@ #include "../perf.h" #include "map.h" +#include "../compat-android.h" /* * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 70fa70b535b2..10e8a478ae4c 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -72,7 +72,9 @@ #include #include #include "types.h" +#ifndef ANDROID #include +#endif extern const char *graph_line; extern const char *graph_dotted_line; -- cgit v1.2.3 From 1d5f527a245b2081342b5b5ec6eac09160bf4e63 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Wed, 28 Nov 2012 17:36:50 +0400 Subject: perf: fix up building libtraceevent Signed-off-by: Bernhard Rosenkraenzer --- tools/perf/Makefile | 4 ++-- tools/perf/util/event.c | 1 - tools/perf/util/event.h | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 267ffb1a71aa..5a797c681aac 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -474,7 +474,7 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) ifeq ($(call try-cc,$(SOURCE_BIONIC),$(FLAGS_GLIBC)),y) # Found Bionic instead of glibc... # That works too, but needs a bit of special treatment - BASIC_CFLAGS += -DANDROID -include compat-android.h + BASIC_CFLAGS += -DANDROID -DHAVE_STRLCPY -include $(CURDIR)/compat-android.h ANDROID := 1 else msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); @@ -931,7 +931,7 @@ $(LIB_FILE): $(LIB_OBJS) # libtraceevent.a $(LIBTRACEEVENT): - $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a + $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) VERBOSE=2 CFLAGS="$(ALL_CFLAGS)" O=$(OUTPUT) libtraceevent.a $(LIBTRACEEVENT)-clean: $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1b33d0168996..6715b1938725 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -6,7 +6,6 @@ #include "strlist.h" #include "thread.h" #include "thread_map.h" -#include "../compat-android.h" static const char *perf_event__names[] = { [0] = "TOTAL", diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 892d0340278b..21b99e741a87 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -6,7 +6,6 @@ #include "../perf.h" #include "map.h" -#include "../compat-android.h" /* * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * -- cgit v1.2.3 From b094e87525ee4e42777bcca1d8369aed232a377a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 1 Dec 2012 00:29:17 +0400 Subject: clk: ux500: fix bit error This fixes a bit error in the U8500 clock implementation: the unused p2_pclk12 registered at bit 12 in periphereral group 6 was defined as using bit 11 rather than bit 12. When walking over and disabling the unused clocks in the tree at late init time, p2_pclk12 was disabled, by effectively clearing the but for p2_pclk11 instead of bit 12 as it should have, thus disabling gpio block 6 and 7. Reported-by: Lee Jones Cc: Ulf Hansson Cc: Philippe Begnic Signed-off-by: Linus Walleij --- drivers/clk/ux500/u8500_clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/ux500/u8500_clk.c b/drivers/clk/ux500/u8500_clk.c index e2c17d187d98..6939009521f8 100644 --- a/drivers/clk/ux500/u8500_clk.c +++ b/drivers/clk/ux500/u8500_clk.c @@ -323,7 +323,7 @@ void u8500_clk_init(void) clk_register_clkdev(clk, NULL, "gpioblock1"); clk = clk_reg_prcc_pclk("p2_pclk12", "per2clk", U8500_CLKRST2_BASE, - BIT(11), 0); + BIT(12), 0); clk = clk_reg_prcc_pclk("p3_pclk0", "per3clk", U8500_CLKRST3_BASE, BIT(0), 0); -- cgit v1.2.3 From 179a4539b1d5ebe3f7838fe19179c56a0a17d2ad Mon Sep 17 00:00:00 2001 From: Jon Medhurst Date: Tue, 27 Nov 2012 15:29:55 +0000 Subject: ARM: ftrace: Ensure code modifications are synchronised across all cpus When the generic ftrace implementation modifies code for trace-points it uses stop_machine() to call ftrace_modify_all_code() on one CPU. This ultimately calls the ARM specific function ftrace_modify_code() which updates the instruction and then does flush_icache_range(). As this cache flushing only operates on the local CPU then other cores may end up execute the old instruction if it's still in their icaches. This may or may not cause problems for the use of ftrace on kernels compiled for ARM instructions. However, Thumb2 instructions can straddle two cache lines so its possible for half the old instruction to be in the cache and half the new one, leading the the CPU executing garbage. This patch fixes this situation by providing and arch specific implementation of arch_ftrace_update_code() which ensures that after one core has modified all the code, the other cores invalidate their icaches before continuing. Signed-off-by: Jon Medhurst --- arch/arm/kernel/ftrace.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 34e56647dcee..38b670cea08c 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -156,6 +157,39 @@ int ftrace_make_nop(struct module *mod, return ret; } +struct afmc_data { + int command; + atomic_t cpu; + atomic_t done; +}; + +static int __arch_ftrace_modify_code(void *data) +{ + struct afmc_data *afmcd = data; + + if (atomic_inc_return(&afmcd->cpu) == num_online_cpus()) { + /* Last cpu to get into this function does the actual work */ + ftrace_modify_all_code(afmcd->command); + wmb(); + atomic_set(&afmcd->done, true); + } else { + /* Other cpus wait for the code modifications to be done */ + rmb(); + while (!atomic_read(&afmcd->done)) + cpu_relax(); + /* Ensure icache is consistent with the code changes */ + __flush_icache_all(); + } + + return 0; +} + +void arch_ftrace_update_code(int command) +{ + struct afmc_data afmcd = { command }; + stop_machine(__arch_ftrace_modify_code, &afmcd, cpu_online_mask); +} + int __init ftrace_dyn_arch_init(void *data) { *(unsigned long *)data = 0; -- cgit v1.2.3 From 3fee42da5abb697f84d493c751e1bec76838907e Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Mon, 3 Dec 2012 15:36:10 +0800 Subject: merge_config.sh: Add option to specify output dir Provide a -O option to specify dir to put generated .config Then merge_config.sh does not need to be copied to target dir, for easy re-usage in other script Signed-off-by: Zhangfei Gao Tested-by: Jon Medhurst (Tixy) Acked-by: John Stultz --- scripts/kconfig/merge_config.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index 974d5cb7e30a..05274fccb88e 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -32,11 +32,13 @@ usage() { echo " -m only merge the fragments, do not execute the make command" echo " -n use allnoconfig instead of alldefconfig" echo " -r list redundant entries when merging fragments" + echo " -O dir to put generated output files" } MAKE=true ALLTARGET=alldefconfig WARNREDUN=false +OUTPUT=. while true; do case $1 in @@ -59,6 +61,16 @@ while true; do shift continue ;; + "-O") + if [ -d $2 ];then + OUTPUT=$(echo $2 | sed 's/\/*$//') + else + echo "output directory $2 does not exist" 1>&2 + exit 1 + fi + shift 2 + continue + ;; *) break ;; @@ -100,9 +112,9 @@ for MERGE_FILE in $MERGE_LIST ; do done if [ "$MAKE" = "false" ]; then - cp $TMP_FILE .config + cp $TMP_FILE $OUTPUT/.config echo "#" - echo "# merged configuration written to .config (needs make)" + echo "# merged configuration written to $OUTPUT/.config (needs make)" echo "#" clean_up exit @@ -111,14 +123,14 @@ fi # Use the merged file as the starting point for: # alldefconfig: Fills in any missing symbols with Kconfig default # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set -make KCONFIG_ALLCONFIG=$TMP_FILE $ALLTARGET +make KCONFIG_ALLCONFIG=$TMP_FILE O=$OUTPUT $ALLTARGET # Check all specified config values took (might have missed-dependency issues) for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) - ACTUAL_VAL=$(grep -w -e "$CFG" .config) + ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config) if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then echo "Value requested for $CFG not in final .config" echo "Requested value: $REQUESTED_VAL" -- cgit v1.2.3