samsung-goyawifi: new device (MR 3258)

Bring up support for Samsung T110 Goyawifi.
Working: Display (framebuffer), touchscreen, buttons and Wi-Fi.
Include: kernel source and necesarry firmware for Wi-Fi and Bluetooth.

samsung-goyawifi: fix patch names

samsung-goyawifi: remove mesa-dri-gallium

samsung-goyawifi: fix keyboard in deviceinfo

samsung-goyawifi: fix lightdm

samsung-goyawifi: editor-config ci tabs

samsung-goyawifi: add linux kernel as depends

[ci:skip-build]: Already built successfully in CI
This commit is contained in:
cheadrian 2022-06-27 16:14:13 -04:00 committed by Newbyte
parent b7c3d41b9a
commit eb0896b170
No known key found for this signature in database
GPG key ID: 990600ED1DB95E02
15 changed files with 3851 additions and 0 deletions

View file

@ -0,0 +1 @@
ATTRS{name}=="sec_touchscreen", ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1"

View file

@ -0,0 +1,87 @@
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-samsung-goyawifi
pkgdesc="Samsung Galaxy Tab 3 Lite"
pkgver=0.1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="armv7"
options="!check !archcheck"
depends="
linux-samsung-goyawifi
mkbootimg
postmarketos-base
"
makedepends="devicepkg-dev"
source="
deviceinfo
98-touchscreen-cal.rules
goyawifi.conf
sd8xxx.conf
dhcp-client.conf
ipv4-workaround.sh
etc-lightdm-lightdm.conf
"
subpackages="
$pkgname-nonfree-firmware:nonfree_firmware
$pkgname-networkmanager-dhclient:networkmanager_dhclient
$pkgname-fix-lightdm:fix_lightdm
"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
# Calibrate touchscreen rotation
install -D -m644 "$srcdir"/98-touchscreen-cal.rules \
"$pkgdir"/etc/udev/rules.d/98-touchscreen-cal.rules
# Add module rules for Wi-Fi (mbt8xxx kernel panic)
install -D -m644 "$srcdir"/goyawifi.conf \
"$pkgdir"/etc/modprobe.d/goyawifi.conf
install -D -m644 "$srcdir"/sd8xxx.conf \
"$pkgdir"/lib/modules-load.d/sd8xxx.conf
}
nonfree_firmware() {
pkgdesc="Samsung T110 (goyawifi) WiFi & BT firmware"
depends="firmware-samsung-goyawifi"
mkdir "$subpkgdir"
}
networkmanager_dhclient() {
install_if="$pkgname networkmanager"
pkgdesc="Install and use dhclient for networkmanager to get IP throught DHCP"
depends="dhclient"
# Use DHCLIENT for networkmanager as internal client would not work on goyawifi
install -D -m644 "$srcdir"/dhcp-client.conf \
"$subpkgdir"/etc/NetworkManager/conf.d/dhcp-client.conf
install -D -m755 "$srcdir"/ipv4-workaround.sh \
"$subpkgdir"/etc/NetworkManager/dispatcher.d/ipv4-workaround.sh
}
fix_lightdm() {
install_if="$pkgname lightdm"
pkgdesc="Fix the problem for CanGraphical=no in LightDM according to Display Manager in PMOS Wiki"
depends="lightdm"
replaces="lightdm"
# Install lightdm configuration with logind-check-graphical=false
install -D -m644 "$srcdir"/etc-lightdm-lightdm.conf \
"$subpkgdir"/etc/lightdm/lightdm.conf
}
sha512sums="
10fd6444d5d8a9a67eca2fa063f135aa25e992c137291bc38e200fb7d1772efa98dbeea94648ee87a73c871c5d06abe65ca495618f8103b7f79b77326a351838 deviceinfo
79162e1d82bfa6cad52a17a1950d56ecddf00b99db69ff08eed7402927e32690f8bdd7e8b4e27f1cf1c5b1e09e1b70f1ba11979b3112aed35968924ef33d98e7 98-touchscreen-cal.rules
73d03f53e08a650b3073e33653d3bcfa6951042203dde7104ffddbe59e29bafbb26c0e41cd9357ede8f01abe0049b190a2acae82e5a5b92868129ab66b118a8d goyawifi.conf
4bb1136341de6584baeffafe166ceca1c883ba36eebe8d3d5ac95db7d4dfc243e2988be429f8f4e1e98385701598806730debc6cc2f502e2b98bf7a9a444b129 sd8xxx.conf
c1c9b58b5325ad11afc98bf1b20179c725b7627416270fe87558bdc259fbb996628d404aaaef6e8c9ea41c21b015ae767ce1c3054490481c24cc97d0002d69bb dhcp-client.conf
6d7178d18288f4ca9b8ad70b9fd9a28882c1a724448c9e4866224d6ffb5d1e7580ef402701b59cc67f880c7edcecd24ba37deba461ec1ed51889c5eb6bf2350a ipv4-workaround.sh
861270c6bc0b2a3e6cd389c21c8c895e62de8cf8bec6fcf23c178f8cbaae855d62b0ee98692671ab4f518d84cb43dd0b2fe46f5a609f65af6a6c06e0fdbb6d0c etc-lightdm-lightdm.conf
"

View file

@ -0,0 +1,30 @@
# Reference: <https://postmarketos.org/deviceinfo>
# Please use double quotes only. You can source this file in shell
# scripts.
deviceinfo_format_version="0"
deviceinfo_name="Samsung Galaxy Tab 3 Lite"
deviceinfo_manufacturer="Samsung"
deviceinfo_codename="samsung-goyawifi"
deviceinfo_year="2014"
deviceinfo_arch="armv7"
# Device related
deviceinfo_chassis="tablet"
deviceinfo_keyboard="false"
deviceinfo_external_storage="true"
deviceinfo_screen_width="1024"
deviceinfo_screen_height="600"
# Bootloader related
deviceinfo_flash_method="heimdall-bootimg"
deviceinfo_generate_bootimg="true"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_mtk_mkimage="false"
deviceinfo_bootimg_dtb_second="false"
deviceinfo_flash_pagesize="2048"
deviceinfo_flash_offset_base="0x10000000"
deviceinfo_flash_offset_kernel="0x00008000"
deviceinfo_flash_offset_ramdisk="0x01000000"
deviceinfo_flash_offset_second="0x00f00000"
deviceinfo_flash_offset_tags="0x00000100"

View file

@ -0,0 +1,2 @@
[main]
dhcp=dhclient

View file

@ -0,0 +1,164 @@
#
# General configuration
#
# start-default-seat = True to always start one seat if none are defined in the configuration
# greeter-user = User to run greeter as
# minimum-display-number = Minimum display number to use for X servers
# minimum-vt = First VT to run displays on
# lock-memory = True to prevent memory from being paged to disk
# user-authority-in-system-dir = True if session authority should be in the system location
# guest-account-script = Script to be run to setup guest account
# logind-check-graphical = True to on start seats that are marked as graphical by logind
# log-directory = Directory to log information to
# run-directory = Directory to put running state in
# cache-directory = Directory to cache to
# sessions-directory = Directory to find sessions
# remote-sessions-directory = Directory to find remote sessions
# greeters-directory = Directory to find greeters
# backup-logs = True to move add a .old suffix to old log files when opening new ones
# dbus-service = True if LightDM provides a D-Bus service to control it
#
[LightDM]
#start-default-seat=true
#greeter-user=lightdm
#minimum-display-number=0
#minimum-vt=7
#lock-memory=true
#user-authority-in-system-dir=false
#guest-account-script=guest-account
# Next line: elogind reports that the session CanGraphical=no. Let lightdm ignore that bogus status.
logind-check-graphical=false
#log-directory=/var/log/lightdm
#run-directory=/var/run/lightdm
#cache-directory=/var/cache/lightdm
#sessions-directory=/usr/share/lightdm/sessions:/usr/share/xsessions:/usr/share/wayland-sessions
#remote-sessions-directory=/usr/share/lightdm/remote-sessions
#greeters-directory=$XDG_DATA_DIRS/lightdm/greeters:$XDG_DATA_DIRS/xgreeters
#backup-logs=true
#dbus-service=true
#
# Seat configuration
#
# Seat configuration is matched against the seat name glob in the section, for example:
# [Seat:*] matches all seats and is applied first.
# [Seat:seat0] matches the seat named "seat0".
# [Seat:seat-thin-client*] matches all seats that have names that start with "seat-thin-client".
#
# type = Seat type (local, xremote)
# pam-service = PAM service to use for login
# pam-autologin-service = PAM service to use for autologin
# pam-greeter-service = PAM service to use for greeters
# xserver-command = X server command to run (can also contain arguments e.g. X -special-option)
# xmir-command = Xmir server command to run (can also contain arguments e.g. Xmir -special-option)
# xserver-config = Config file to pass to X server
# xserver-layout = Layout to pass to X server
# xserver-allow-tcp = True if TCP/IP connections are allowed to this X server
# xserver-share = True if the X server is shared for both greeter and session
# xserver-hostname = Hostname of X server (only for type=xremote)
# xserver-display-number = Display number of X server (only for type=xremote)
# xdmcp-manager = XDMCP manager to connect to (implies xserver-allow-tcp=true)
# xdmcp-port = XDMCP UDP/IP port to communicate on
# xdmcp-key = Authentication key to use for XDM-AUTHENTICATION-1 (stored in keys.conf)
# greeter-session = Session to load for greeter
# greeter-hide-users = True to hide the user list
# greeter-allow-guest = True if the greeter should show a guest login option
# greeter-show-manual-login = True if the greeter should offer a manual login option
# greeter-show-remote-login = True if the greeter should offer a remote login option
# user-session = Session to load for users
# allow-user-switching = True if allowed to switch users
# allow-guest = True if guest login is allowed
# guest-session = Session to load for guests (overrides user-session)
# session-wrapper = Wrapper script to run session with
# greeter-wrapper = Wrapper script to run greeter with
# guest-wrapper = Wrapper script to run guest sessions with
# display-setup-script = Script to run when starting a greeter session (runs as root)
# display-stopped-script = Script to run after stopping the display server (runs as root)
# greeter-setup-script = Script to run when starting a greeter (runs as root)
# session-setup-script = Script to run when starting a user session (runs as root)
# session-cleanup-script = Script to run when quitting a user session (runs as root)
# autologin-guest = True to log in as guest by default
# autologin-user = User to log in with by default (overrides autologin-guest)
# autologin-user-timeout = Number of seconds to wait before loading default user
# autologin-session = Session to load for automatic login (overrides user-session)
# autologin-in-background = True if autologin session should not be immediately activated
# exit-on-failure = True if the daemon should exit if this seat fails
#
[Seat:*]
#type=local
#pam-service=lightdm
#pam-autologin-service=lightdm-autologin
#pam-greeter-service=lightdm-greeter
#xserver-command=X
#xmir-command=Xmir
#xserver-config=
#xserver-layout=
#xserver-allow-tcp=false
#xserver-share=true
#xserver-hostname=
#xserver-display-number=
#xdmcp-manager=
#xdmcp-port=177
#xdmcp-key=
#greeter-session=example-gtk-gnome
#greeter-hide-users=false
#greeter-allow-guest=true
#greeter-show-manual-login=false
#greeter-show-remote-login=true
#user-session=default
#allow-user-switching=true
#allow-guest=false
#guest-session=
#session-wrapper=lightdm-session
#greeter-wrapper=
#guest-wrapper=
#display-setup-script=
#display-stopped-script=
#greeter-setup-script=
#session-setup-script=
#session-cleanup-script=
#autologin-guest=false
#autologin-user=
#autologin-user-timeout=0
#autologin-in-background=false
#autologin-session=
#exit-on-failure=false
#
# XDMCP Server configuration
#
# enabled = True if XDMCP connections should be allowed
# port = UDP/IP port to listen for connections on
# listen-address = Host/address to listen for XDMCP connections (use all addresses if not present)
# key = Authentication key to use for XDM-AUTHENTICATION-1 or blank to not use authentication (stored in keys.conf)
# hostname = Hostname to report to XDMCP clients (defaults to system hostname if unset)
#
# The authentication key is a 56 bit DES key specified in hex as 0xnnnnnnnnnnnnnn. Alternatively
# it can be a word and the first 7 characters are used as the key.
#
[XDMCPServer]
#enabled=false
#port=177
#listen-address=
#key=
#hostname=
#
# VNC Server configuration
#
# enabled = True if VNC connections should be allowed
# command = Command to run Xvnc server with
# port = TCP/IP port to listen for connections on
# listen-address = Host/address to listen for VNC connections (use all addresses if not present)
# width = Width of display to use
# height = Height of display to use
# depth = Color depth of display to use
#
[VNCServer]
#enabled=false
#command=Xvnc
#port=5900
#listen-address=
#width=1024
#height=768
#depth=8

View file

@ -0,0 +1,9 @@
#
#Blacklist WLAN and Bluetooth modules as device will crash if they are
#loaded at boot toghether
#
#Blacklist Marvell Wireless
blacklist mbt8xxx
blacklist sd8xxx
blacklist mlan

View file

@ -0,0 +1,18 @@
#!/bin/sh
# It's seems that the networkmanager can't properly set the interface IP
# and routes on this device. Setting them using iproute2 or net-tools
# makes the interface to work with network, using static or DHCP ipv4.
IF=$1
STATUS=$2
if [ "$IF" == "mlan0" ]; then
if [ "$STATUS" == "up" ]; then
logger -s "Setting IP on $IF"
logger -s "IP4_ADDRESS_0 $IP4_ADDRESS_0"
logger -s "IP4_GATEWAY $IP4_GATEWAY"
logger -s "IP4_ROUTE_0 $IP4_ROUTE_0"
ip address add ${IP4_ADDRESS_0% *} brd + dev $IF
ip route add default via ${IP4_ADDRESS_0#* } dev $IF
fi
fi

View file

@ -0,0 +1,2 @@
# Load sd8xxx.ko at boot
sd8xxx

View file

@ -0,0 +1,37 @@
pkgname=firmware-samsung-goyawifi
pkgver=1
pkgrel=0
pkgdesc="Firmware for Samsung T110 (goyawifi)"
url="https://github.com/T110-pmOS/marvell_firmware_sd8777"
arch="armv7"
license="custom:proprietary"
options="!check !strip !archcheck !spdx !tracedeps pmb:cross-native"
# Sources
_commit="f2fb533f70b6f9bcf89d170a9822f8035b357024"
source="$pkgname-$_commit.tar.gz::https://github.com/T110-pmOS/marvell_firmware_sd8777/archive/$_commit.tar.gz"
builddir="$srcdir/marvell_firmware_sd8777-$_commit/"
package() {
# Wi-Fi & BT firmware
install -Dm644 "$builddir"/SDIO8777_SDIO_SDIO.bin \
"$pkgdir"/lib/firmware/postmarketos/mrvl/SDIO8777_SDIO_SDIO.bin
install -Dm644 "$builddir"/sd8777_uapsta.bin \
"$pkgdir"/lib/firmware/postmarketos/mrvl/sd8777_uapsta.bin
# Firmware configuration
install -Dm644 "$builddir"/WlanCalData_ext.conf \
"$pkgdir"/lib/firmware/postmarketos/mrvl/WlanCalData_ext.conf
install -Dm644 "$builddir"/bt_cal_data.conf \
"$pkgdir"/lib/firmware/postmarketos/mrvl/bt_cal_data.conf
install -Dm644 "$builddir"/bt_init_cfg.conf \
"$pkgdir"/lib/firmware/postmarketos/mrvl/bt_init_cfg.conf
install -Dm644 "$builddir"/cal_data.conf \
"$pkgdir"/lib/firmware/postmarketos/mrvl/cal_data.conf
install -Dm644 "$builddir"/reg_alpha2 \
"$pkgdir"/lib/firmware/postmarketos/mrvl/reg_alpha2
}
sha512sums="
e1b5f4e136a775d309fb2edf8d6734f0f6442e361b8b6db67b7688cb8bbb02f4c2a945d31f137f77ebdb1de2942c7439a0008a0b6d650f1d531841e148243c2a firmware-samsung-goyawifi-f2fb533f70b6f9bcf89d170a9822f8035b357024.tar.gz
"

View file

@ -0,0 +1,70 @@
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/goyawifi_pmos_etnaviv_defconfig
pkgname=linux-samsung-goyawifi
pkgver=3.4.5
pkgrel=0
pkgdesc="Samsung Galaxy Tab 3 Lite kernel fork"
arch="armv7"
_carch="arm"
_flavor="samsung-goyawifi"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev gcc4"
# Compiler: this kernel was only tested with GCC4. Feel free to make a merge
# request if you find out that it is booting working with newer GCCs as
# well. See <https://postmarketos.org/vendorkernel> for instructions.
if [ "${CC:0:5}" != "gcc4-" ]; then
CC="gcc4-$CC"
HOSTCC="gcc4-gcc"
CROSS_COMPILE="gcc4-$CROSS_COMPILE"
fi
# Source
_repository="linux_kernel_pxa988"
_commit="fb2f8b6cd86864c0fcac790e97a372b1772003c7"
_config="config-$_flavor.$arch"
source="
$pkgname-$_commit.tar.gz::https://github.com/T110-pmOS/$_repository/archive/$_commit.tar.gz
$_config
fix_memset-related_crashes.patch
fix_the_memset_fix.patch
gcc10-extern_YYLOC_global_declaration.patch
fix_makefile.patch
"
builddir="$srcdir/$_repository-$_commit"
prepare() {
default_prepare
. downstreamkernel_prepare
}
build() {
unset LDFLAGS
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}
package() {
downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor"
# Modules
unset LDFLAGS
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS" \
INSTALL_MOD_PATH="$pkgdir" INSTALL_MOD_STRIP=1 \
modules_install
}
sha512sums="
acaa8d554c7c51c5365e98e3c19eedd2b2a24b877ca8ed9d84e547339e9b055165f53d62be47be04e1be5967f14c859254633fd9bd5b9052f428e5e55e8793bf linux-samsung-goyawifi-fb2f8b6cd86864c0fcac790e97a372b1772003c7.tar.gz
0d1d6ea24e473d114041fcfb845a01cb01b94b2079213ca27d705b97aaae7d46fb91ced5394301a3856d45a3c3739d69f39888707c864893291d4ce6de99941e config-samsung-goyawifi.armv7
efd1641c0892fddb9c5feea3e49e534fed311b01f0576688b5af766e0160850822d0eb8e296b08c5f82b586d5d0336a98e8e86707ba9af7fcf36fc89f0b288eb fix_memset-related_crashes.patch
5c080c27716d124616e4e684fc63bffb2665f00de06e894dfd78f58588feec2fec858fe8234b054061e3db14d28cb90fbac53f4b54c4fac5946d843cf038386c fix_the_memset_fix.patch
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb gcc10-extern_YYLOC_global_declaration.patch
fb16404be045f4d9c7bf29512321ec2a4cb17111a8c870adff91889f0e6b314265cddb5dd9caa8088425902d2032e9dac4b6ba8c648b32df0efd78edf24550c1 fix_makefile.patch
"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
diff --git a/Makefile b/Makefile
index 37ada86c..87636345 100644
--- a/Makefile
+++ b/Makefile
@@ -192,10 +192,10 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
export KBUILD_BUILDHOST := $(SUBARCH)
-#ARCH ?= $(SUBARCH)
-ARCH ?= arm
-#CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
-CROSS_COMPILE ?= /usr/bin/arm-linux-gnueabi-
+ARCH ?= $(SUBARCH)
+#ARCH ?= arm
+CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
+#CROSS_COMPILE ?= /usr/bin/arm-linux-gnueabi-
# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
@@ -332,8 +332,9 @@ include $(srctree)/scripts/Kbuild.include
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
-CC = ccache $(CROSS_COMPILE)gcc-4.7
-CPP = ccache $(CC) -E
+#CC = ccache $(CROSS_COMPILE)gcc-4.7
+CC = $(CROSS_COMPILE)gcc
+CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
@@ -689,9 +690,9 @@ export INSTALL_PATH ?= /boot
# makefile but the argument can be passed to make if needed.
#
-#MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
+MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
#MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))
-MODLIB = $(INSTALL_MOD_PATH)/lib/modules
+#MODLIB = $(INSTALL_MOD_PATH)/lib/modules
export MODLIB
#

View file

@ -0,0 +1,252 @@
From 455bd4c430b0c0a361f38e8658a0d6cb469942b5 Mon Sep 17 00:00:00 2001
From: Ivan Djelic <ivan.djelic@parrot.com>
Date: Wed, 6 Mar 2013 20:09:27 +0100
Subject: [PATCH] ARM: 7668/1: fix memset-related crashes caused by recent GCC
(4.7.2) optimizations
Recent GCC versions (e.g. GCC-4.7.2) perform optimizations based on
assumptions about the implementation of memset and similar functions.
The current ARM optimized memset code does not return the value of
its first argument, as is usually expected from standard implementations.
For instance in the following function:
void debug_mutex_lock_common(struct mutex *lock, struct mutex_waiter *waiter)
{
memset(waiter, MUTEX_DEBUG_INIT, sizeof(*waiter));
waiter->magic = waiter;
INIT_LIST_HEAD(&waiter->list);
}
compiled as:
800554d0 <debug_mutex_lock_common>:
800554d0: e92d4008 push {r3, lr}
800554d4: e1a00001 mov r0, r1
800554d8: e3a02010 mov r2, #16 ; 0x10
800554dc: e3a01011 mov r1, #17 ; 0x11
800554e0: eb04426e bl 80165ea0 <memset>
800554e4: e1a03000 mov r3, r0
800554e8: e583000c str r0, [r3, #12]
800554ec: e5830000 str r0, [r3]
800554f0: e5830004 str r0, [r3, #4]
800554f4: e8bd8008 pop {r3, pc}
GCC assumes memset returns the value of pointer 'waiter' in register r0; causing
register/memory corruptions.
This patch fixes the return value of the assembly version of memset.
It adds a 'mov' instruction and merges an additional load+store into
existing load/store instructions.
For ease of review, here is a breakdown of the patch into 4 simple steps:
Step 1
======
Perform the following substitutions:
ip -> r8, then
r0 -> ip,
and insert 'mov ip, r0' as the first statement of the function.
At this point, we have a memset() implementation returning the proper result,
but corrupting r8 on some paths (the ones that were using ip).
Step 2
======
Make sure r8 is saved and restored when (! CALGN(1)+0) == 1:
save r8:
- str lr, [sp, #-4]!
+ stmfd sp!, {r8, lr}
and restore r8 on both exit paths:
- ldmeqfd sp!, {pc} @ Now <64 bytes to go.
+ ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
(...)
tst r2, #16
stmneia ip!, {r1, r3, r8, lr}
- ldr lr, [sp], #4
+ ldmfd sp!, {r8, lr}
Step 3
======
Make sure r8 is saved and restored when (! CALGN(1)+0) == 0:
save r8:
- stmfd sp!, {r4-r7, lr}
+ stmfd sp!, {r4-r8, lr}
and restore r8 on both exit paths:
bgt 3b
- ldmeqfd sp!, {r4-r7, pc}
+ ldmeqfd sp!, {r4-r8, pc}
(...)
tst r2, #16
stmneia ip!, {r4-r7}
- ldmfd sp!, {r4-r7, lr}
+ ldmfd sp!, {r4-r8, lr}
Step 4
======
Rewrite register list "r4-r7, r8" as "r4-r8".
Signed-off-by: Ivan Djelic <ivan.djelic@parrot.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/lib/memset.S | 85 ++++++++++++++++++++++++++-------------------------
1 file changed, 44 insertions(+), 41 deletions(-)
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 650d5923ab83c..d912e7397ecc9 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -19,9 +19,9 @@
1: subs r2, r2, #4 @ 1 do we have enough
blt 5f @ 1 bytes to align with?
cmp r3, #2 @ 1
- strltb r1, [r0], #1 @ 1
- strleb r1, [r0], #1 @ 1
- strb r1, [r0], #1 @ 1
+ strltb r1, [ip], #1 @ 1
+ strleb r1, [ip], #1 @ 1
+ strb r1, [ip], #1 @ 1
add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))
/*
* The pointer is now aligned and the length is adjusted. Try doing the
@@ -29,10 +29,14 @@
*/
ENTRY(memset)
- ands r3, r0, #3 @ 1 unaligned?
+/*
+ * Preserve the contents of r0 for the return value.
+ */
+ mov ip, r0
+ ands r3, ip, #3 @ 1 unaligned?
bne 1b @ 1
/*
- * we know that the pointer in r0 is aligned to a word boundary.
+ * we know that the pointer in ip is aligned to a word boundary.
*/
orr r1, r1, r1, lsl #8
orr r1, r1, r1, lsl #16
@@ -43,29 +47,28 @@ ENTRY(memset)
#if ! CALGN(1)+0
/*
- * We need an extra register for this loop - save the return address and
- * use the LR
+ * We need 2 extra registers for this loop - use r8 and the LR
*/
- str lr, [sp, #-4]!
- mov ip, r1
+ stmfd sp!, {r8, lr}
+ mov r8, r1
mov lr, r1
2: subs r2, r2, #64
- stmgeia r0!, {r1, r3, ip, lr} @ 64 bytes at a time.
- stmgeia r0!, {r1, r3, ip, lr}
- stmgeia r0!, {r1, r3, ip, lr}
- stmgeia r0!, {r1, r3, ip, lr}
+ stmgeia ip!, {r1, r3, r8, lr} @ 64 bytes at a time.
+ stmgeia ip!, {r1, r3, r8, lr}
+ stmgeia ip!, {r1, r3, r8, lr}
+ stmgeia ip!, {r1, r3, r8, lr}
bgt 2b
- ldmeqfd sp!, {pc} @ Now <64 bytes to go.
+ ldmeqfd sp!, {r8, pc} @ Now <64 bytes to go.
/*
* No need to correct the count; we're only testing bits from now on
*/
tst r2, #32
- stmneia r0!, {r1, r3, ip, lr}
- stmneia r0!, {r1, r3, ip, lr}
+ stmneia ip!, {r1, r3, r8, lr}
+ stmneia ip!, {r1, r3, r8, lr}
tst r2, #16
- stmneia r0!, {r1, r3, ip, lr}
- ldr lr, [sp], #4
+ stmneia ip!, {r1, r3, r8, lr}
+ ldmfd sp!, {r8, lr}
#else
@@ -74,54 +77,54 @@ ENTRY(memset)
* whole cache lines at once.
*/
- stmfd sp!, {r4-r7, lr}
+ stmfd sp!, {r4-r8, lr}
mov r4, r1
mov r5, r1
mov r6, r1
mov r7, r1
- mov ip, r1
+ mov r8, r1
mov lr, r1
cmp r2, #96
- tstgt r0, #31
+ tstgt ip, #31
ble 3f
- and ip, r0, #31
- rsb ip, ip, #32
- sub r2, r2, ip
- movs ip, ip, lsl #(32 - 4)
- stmcsia r0!, {r4, r5, r6, r7}
- stmmiia r0!, {r4, r5}
- tst ip, #(1 << 30)
- mov ip, r1
- strne r1, [r0], #4
+ and r8, ip, #31
+ rsb r8, r8, #32
+ sub r2, r2, r8
+ movs r8, r8, lsl #(32 - 4)
+ stmcsia ip!, {r4, r5, r6, r7}
+ stmmiia ip!, {r4, r5}
+ tst r8, #(1 << 30)
+ mov r8, r1
+ strne r1, [ip], #4
3: subs r2, r2, #64
- stmgeia r0!, {r1, r3-r7, ip, lr}
- stmgeia r0!, {r1, r3-r7, ip, lr}
+ stmgeia ip!, {r1, r3-r8, lr}
+ stmgeia ip!, {r1, r3-r8, lr}
bgt 3b
- ldmeqfd sp!, {r4-r7, pc}
+ ldmeqfd sp!, {r4-r8, pc}
tst r2, #32
- stmneia r0!, {r1, r3-r7, ip, lr}
+ stmneia ip!, {r1, r3-r8, lr}
tst r2, #16
- stmneia r0!, {r4-r7}
- ldmfd sp!, {r4-r7, lr}
+ stmneia ip!, {r4-r7}
+ ldmfd sp!, {r4-r8, lr}
#endif
4: tst r2, #8
- stmneia r0!, {r1, r3}
+ stmneia ip!, {r1, r3}
tst r2, #4
- strne r1, [r0], #4
+ strne r1, [ip], #4
/*
* When we get here, we've got less than 4 bytes to zero. We
* may have an unaligned pointer as well.
*/
5: tst r2, #2
- strneb r1, [r0], #1
- strneb r1, [r0], #1
+ strneb r1, [ip], #1
+ strneb r1, [ip], #1
tst r2, #1
- strneb r1, [r0], #1
+ strneb r1, [ip], #1
mov pc, lr
ENDPROC(memset)

View file

@ -0,0 +1,80 @@
From 418df63adac56841ef6b0f1fcf435bc64d4ed177 Mon Sep 17 00:00:00 2001
From: Nicolas Pitre <nicolas.pitre@linaro.org>
Date: Tue, 12 Mar 2013 13:00:42 +0100
Subject: [PATCH] ARM: 7670/1: fix the memset fix
Commit 455bd4c430b0 ("ARM: 7668/1: fix memset-related crashes caused by
recent GCC (4.7.2) optimizations") attempted to fix a compliance issue
with the memset return value. However the memset itself became broken
by that patch for misaligned pointers.
This fixes the above by branching over the entry code from the
misaligned fixup code to avoid reloading the original pointer.
Also, because the function entry alignment is wrong in the Thumb mode
compilation, that fixup code is moved to the end.
While at it, the entry instructions are slightly reworked to help dual
issue pipelines.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Alexander Holler <holler@ahsoftware.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
arch/arm/lib/memset.S | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index d912e7397ecc9..94b0650ea98fd 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -14,31 +14,15 @@
.text
.align 5
- .word 0
-
-1: subs r2, r2, #4 @ 1 do we have enough
- blt 5f @ 1 bytes to align with?
- cmp r3, #2 @ 1
- strltb r1, [ip], #1 @ 1
- strleb r1, [ip], #1 @ 1
- strb r1, [ip], #1 @ 1
- add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))
-/*
- * The pointer is now aligned and the length is adjusted. Try doing the
- * memset again.
- */
ENTRY(memset)
-/*
- * Preserve the contents of r0 for the return value.
- */
- mov ip, r0
- ands r3, ip, #3 @ 1 unaligned?
- bne 1b @ 1
+ ands r3, r0, #3 @ 1 unaligned?
+ mov ip, r0 @ preserve r0 as return value
+ bne 6f @ 1
/*
* we know that the pointer in ip is aligned to a word boundary.
*/
- orr r1, r1, r1, lsl #8
+1: orr r1, r1, r1, lsl #8
orr r1, r1, r1, lsl #16
mov r3, r1
cmp r2, #16
@@ -127,4 +111,13 @@ ENTRY(memset)
tst r2, #1
strneb r1, [ip], #1
mov pc, lr
+
+6: subs r2, r2, #4 @ 1 do we have enough
+ blt 5b @ 1 bytes to align with?
+ cmp r3, #2 @ 1
+ strltb r1, [ip], #1 @ 1
+ strleb r1, [ip], #1 @ 1
+ strb r1, [ip], #1 @ 1
+ add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))
+ b 1b
ENDPROC(memset)

View file

@ -0,0 +1 @@
../../.shared-patches/linux/gcc10-extern_YYLOC_global_declaration.patch