From 6c015c95aec617bb5efffc524efc3d9307d40112 Mon Sep 17 00:00:00 2001 From: Valentin Marinov Date: Fri, 12 Oct 2018 21:59:03 +0300 Subject: [PATCH] linux-sony-amami: modernize with new gcc8 linux aportgen code --- .../02_mdss_fb_refresh_rate.patch | 13 -- device/linux-sony-amami/APKBUILD | 135 ++++++------------ device/linux-sony-amami/compiler-gcc6.h | 69 --------- ...give-up-on-ilog2-const-optimizations.patch | 1 + .../linux-sony-amami/gcc8-fix-put-user.patch | 13 ++ 5 files changed, 61 insertions(+), 170 deletions(-) delete mode 100644 device/linux-sony-amami/02_mdss_fb_refresh_rate.patch delete mode 100644 device/linux-sony-amami/compiler-gcc6.h create mode 120000 device/linux-sony-amami/gcc7-give-up-on-ilog2-const-optimizations.patch create mode 100644 device/linux-sony-amami/gcc8-fix-put-user.patch diff --git a/device/linux-sony-amami/02_mdss_fb_refresh_rate.patch b/device/linux-sony-amami/02_mdss_fb_refresh_rate.patch deleted file mode 100644 index 78e7cfbba..000000000 --- a/device/linux-sony-amami/02_mdss_fb_refresh_rate.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/drivers/video/msm/mdss/mdss_fb.c b/drivers/video/msm/mdss/mdss_fb.c -index b37fd1e07ac1..1f091a261d22 100644 ---- a/drivers/video/msm/mdss/mdss_fb.c -+++ b/drivers/video/msm/mdss/mdss_fb.c -@@ -2668,7 +2668,7 @@ static int mdss_fb_register(struct msm_fb_data_type *mfd) - var->left_margin = panel_info->lcdc.h_back_porch; - var->right_margin = panel_info->lcdc.h_front_porch; - var->hsync_len = panel_info->lcdc.h_pulse_width; -- var->pixclock = panel_info->clk_rate / 1000; -+ var->pixclock = 1000000 / 60; - - /* - * Store the cont splash state in the var reserved[3] field. diff --git a/device/linux-sony-amami/APKBUILD b/device/linux-sony-amami/APKBUILD index 09cd9433b..5feb07083 100644 --- a/device/linux-sony-amami/APKBUILD +++ b/device/linux-sony-amami/APKBUILD @@ -1,108 +1,67 @@ -# APKBUILD based on linux-vanilla aport. Changes: -# - disabled module installation -# - add !check !tracedeps -# - package: just install zImage-dtb and kernel.release, because the kernel config -# does not generate modules or dtb files -# - do not create -dev subpackage (makes no sense without module support) -# -# Kernel config changes, based on: arch/arm/configs/aosp_rhine_amami_defconfig -# - enable devtmpfs (needed for udev -> touch support in weston) -# - change compression from CONFIG_KERNEL_LZMA=y to -# CONFIG_KERNEL_GZIP=y (so it works with busybox) -# - disable proprietary graphics driver -# - disable ANDROID_PARANOID_NETWORK (removes network restrictions) +# Reference: +# Kernel config based on: arch/arm/configs/aosp_rhine_amami_defconfig -_vendor=sony -_flavor=sony-amami -_hash="d78970c1afd9fad52cb4402c7bcb9701e8a06d41" -_config="config-${_flavor}.armhf" - -pkgname=linux-${_flavor} +pkgname="linux-sony-amami" pkgver=3.10.84 -case $pkgver in - *.*.*) _kernver=${pkgver%.*};; - *.*) _kernver=$pkgver;; -esac -pkgrel=11 +pkgrel=2 +pkgdesc="Sony Xperia Z1 Compact kernel fork" arch="armhf" -pkgdesc="Sony Xperia Z1 Compact kernel" -url="https://github.com/sonyxperiadev/kernel" -depends="" -makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev gcc6" -options="!strip !check !tracedeps" -install= -source=" - $pkgname-$_hash.tar.gz::https://github.com/sonyxperiadev/kernel/archive/${_hash}.tar.gz - $_config - compiler-gcc6.h - 02_mdss_fb_refresh_rate.patch -" -subpackages="" -license="GPL2" - -_abi_release=${pkgver} _carch="arm" +_flavor="sony-amami" +url="https://kernel.org" +license="GPL-2.0-only" +options="!strip !check !tracedeps" +makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev" -# Compiler: this kernel was only tested with GCC6. Feel free to make a merge -# request if you find out that it is booting working with newer GCCs as -# well. See for instructions. -if [ "${CC:0:5}" != "gcc6-" ]; then - CC="gcc6-$CC" - HOSTCC="gcc6-gcc" - CROSS_COMPILE="gcc6-$CROSS_COMPILE" -fi +# Compiler: latest GCC from Alpine +HOSTCC="${CC:-gcc}" +HOSTCC="${HOSTCC#${CROSS_COMPILE}}" -ksrcdir="$srcdir/kernel-${_hash}" +# Source +_repository="kernel" +_commit="2134cafba220b32c43701368413ee333b41b7fe0" +_config="config-${_flavor}.${arch}" +source=" + $pkgname-$_commit.tar.gz::https://github.com/sonyxperiadev/${_repository}/archive/${_commit}.tar.gz + $_config + gcc7-give-up-on-ilog2-const-optimizations.patch + gcc8-fix-put-user.patch +" + +builddir="$srcdir/${_repository}-${_commit}" prepare() { - local _patch_failed= - cd "$ksrcdir" - - # first apply patches in specified order - for i in $source; do - case $i in - *.patch) - msg "Applying $i..." - if ! patch -s -p1 -N -i "$srcdir"/$i; then - echo $i >>failed - _patch_failed=1 - fi - ;; - esac - done - - if ! [ -z "$_patch_failed" ]; then - error "The following patches failed:" - cat failed - return 1 - fi - - # gcc6 support - cp -v "$srcdir/compiler-gcc6.h" "$ksrcdir/include/linux/" - - mkdir -p "$srcdir"/build - cp "$srcdir"/$_config "$srcdir"/build/.config - make -C "$ksrcdir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \ - silentoldconfig + default_prepare + downstreamkernel_prepare "$srcdir" "$builddir" "$_config" "$_carch" "$HOSTCC" } build() { - cd "$srcdir"/build unset LDFLAGS - make ARCH="$_carch" CC="${CC:-gcc}" \ - KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" + KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" } package() { - install -Dm644 "$srcdir/build/arch/arm/boot/zImage-dtb" \ - "$pkgdir/boot/vmlinuz-$_flavor" - - install -D "$srcdir/build/include/config/kernel.release" \ + # kernel.release + install -D "$builddir/include/config/kernel.release" \ "$pkgdir/usr/share/kernel/$_flavor/kernel.release" + + # zImage (find the right one) + cd "$builddir/arch/$_carch/boot" + _target="$pkgdir/boot/vmlinuz-$_flavor" + for _zimg in zImage-dtb Image.gz-dtb *zImage Image; do + [ -e "$_zimg" ] || continue + msg "zImage found: $_zimg" + install -Dm644 "$_zimg" "$_target" + break + done + if ! [ -e "$_target" ]; then + error "Could not find zImage in $PWD!" + return 1 + fi } -sha512sums="b76641c07489712d393f1d318b0d4138e5c7126d4b78cfc23bcde07911cba185d3872e886f69197bd3912e8b4c646b74fb6992dee0ce3829d2995531ac4f257e linux-sony-amami-d78970c1afd9fad52cb4402c7bcb9701e8a06d41.tar.gz +sha512sums="fae2299d9d36956be71f40ae724ac0a5069b53d440c114184f82495550c76743e9275e37ad00f6d4a012d32e91a580f424cdb1a1222647c5f2fd678a405a225f linux-sony-amami-2134cafba220b32c43701368413ee333b41b7fe0.tar.gz 0896618a3bb536dc5f8d9932fe704e8f279000207054039bf8df25e89fb9b2d7d70175cbc4af2ee42982ff7af39fd98c41ec5d79d517a36d9ac3fad5344ce615 config-sony-amami.armhf -d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc compiler-gcc6.h -a8c955bf718f155011e980f3d0948be98e1fee5649f418299a4851780543019daf7afa406aa7b0829375645107e4e6fbf241026b0cabe2b2ac895a47df83d2d8 02_mdss_fb_refresh_rate.patch" +77eba606a71eafb36c32e9c5fe5e77f5e4746caac292440d9fb720763d766074a964db1c12bc76fe583c5d1a5c864219c59941f5e53adad182dbc70bf2bc14a7 gcc7-give-up-on-ilog2-const-optimizations.patch +00ef6044df2e904289fcbbe268c0200e94b085c374e6126b7f8ff7763285c689bafe9781dc17b85b3684d1d438f3839891925d6ca892ddb6610e68f12e3784a2 gcc8-fix-put-user.patch" diff --git a/device/linux-sony-amami/compiler-gcc6.h b/device/linux-sony-amami/compiler-gcc6.h deleted file mode 100644 index 844706318..000000000 --- a/device/linux-sony-amami/compiler-gcc6.h +++ /dev/null @@ -1,69 +0,0 @@ -// SOURCE: -// https://github.com/NextThingCo/CHIP-u-boot/issues/10#issuecomment-287515505 - -#ifndef __LINUX_COMPILER_H -#error "Please don't include directly, include instead." -#endif - -#define __used __attribute__((__used__)) -#define __must_check __attribute__((warn_unused_result)) -#define __compiler_offsetof(a, b) __builtin_offsetof(a, b) - -/* Mark functions as cold. gcc will assume any path leading to a call - to them will be unlikely. This means a lot of manual unlikely()s - are unnecessary now for any paths leading to the usual suspects - like BUG(), printk(), panic() etc. [but let's keep them for now for - older compilers] - - Early snapshots of gcc 4.3 don't support this and we can't detect this - in the preprocessor, but we can live with this because they're unreleased. - Maketime probing would be overkill here. - - gcc also has a __attribute__((__hot__)) to move hot functions into - a special section, but I don't see any sense in this right now in - the kernel context */ -#define __cold __attribute__((__cold__)) - -#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) - -#ifndef __CHECKER__ -# define __compiletime_warning(message) __attribute__((warning(message))) -# define __compiletime_error(message) __attribute__((error(message))) -#endif /* __CHECKER__ */ - -/* - * Mark a position in code as unreachable. This can be used to - * suppress control flow warnings after asm blocks that transfer - * control elsewhere. - * - * Early snapshots of gcc 4.5 don't support this and we can't detect - * this in the preprocessor, but we can live with this because they're - * unreleased. Really, we need to have autoconf for the kernel. - */ -#define unreachable() __builtin_unreachable() - -/* Mark a function definition as prohibited from being cloned. */ -#define __noclone __attribute__((__noclone__)) - -/* - * Tell the optimizer that something else uses this function or variable. - */ -#define __visible __attribute__((externally_visible)) - -/* - * GCC 'asm goto' miscompiles certain code sequences: - * - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 - * - * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. - * - * (asm goto is automatically volatile - the naming reflects this.) - */ -#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) - -#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP -#define __HAVE_BUILTIN_BSWAP32__ -#define __HAVE_BUILTIN_BSWAP64__ -#define __HAVE_BUILTIN_BSWAP16__ -#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ - diff --git a/device/linux-sony-amami/gcc7-give-up-on-ilog2-const-optimizations.patch b/device/linux-sony-amami/gcc7-give-up-on-ilog2-const-optimizations.patch new file mode 120000 index 000000000..da3d1ed41 --- /dev/null +++ b/device/linux-sony-amami/gcc7-give-up-on-ilog2-const-optimizations.patch @@ -0,0 +1 @@ +../../.shared-patches/linux/gcc7-give-up-on-ilog2-const-optimizations.patch \ No newline at end of file diff --git a/device/linux-sony-amami/gcc8-fix-put-user.patch b/device/linux-sony-amami/gcc8-fix-put-user.patch new file mode 100644 index 000000000..81109a0d7 --- /dev/null +++ b/device/linux-sony-amami/gcc8-fix-put-user.patch @@ -0,0 +1,13 @@ +diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h +index 272c4072..fad6c342 100644 +--- a/arch/arm/include/asm/uaccess.h ++++ b/arch/arm/include/asm/uaccess.h +@@ -177,7 +177,7 @@ extern int __put_user_8(void *, unsigned long long); + ({ \ + unsigned long __limit = current_thread_info()->addr_limit - 1; \ + const typeof(*(p)) __user *__tmp_p = (p); \ +- register const typeof(*(p)) __r2 asm("r2") = (x); \ ++ register typeof(*(p)) __r2 asm("r2") = (x); \ + register const typeof(*(p)) __user *__p asm("r0") = __tmp_p; \ + register unsigned long __l asm("r1") = __limit; \ + register int __e asm("r0"); \