summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2020-01-30 08:20:16 (GMT)
committerWaldemar Brodkorb <wbx@openadk.org>2020-01-30 08:20:16 (GMT)
commit11f569583fa14cc97566d6464635309cdc7b5e35 (patch)
tree1e1ce4cebd1f19dd98077f617ed8e79c79c7524c
parent4d0218cb27d63b4e3d06a9e740348470c8f9e182 (diff)
linux: update 3.16.x kernel, remove unsupported
-rw-r--r--mk/linux-ver.mk16
-rw-r--r--target/linux/Config.in.kernelversion43
-rw-r--r--target/linux/patches/3.10.107/bsd-compatibility.patch2538
-rw-r--r--target/linux/patches/3.10.107/headers-install.patch11
-rw-r--r--target/linux/patches/3.10.107/sgidefs.patch18
-rw-r--r--target/linux/patches/3.10.107/startup.patch34
-rw-r--r--target/linux/patches/3.16.56/initramfs-nosizelimit.patch57
-rw-r--r--target/linux/patches/3.16.56/startup.patch37
-rw-r--r--target/linux/patches/3.16.81/bsd-compatibility.patch (renamed from target/linux/patches/3.16.56/bsd-compatibility.patch)0
-rw-r--r--target/linux/patches/3.16.81/cleankernel.patch (renamed from target/linux/patches/3.16.56/cleankernel.patch)0
-rw-r--r--target/linux/patches/3.16.81/cris-header.patch (renamed from target/linux/patches/3.16.56/cris-header.patch)0
-rw-r--r--target/linux/patches/3.16.81/cris-initramfs.patch (renamed from target/linux/patches/3.16.56/cris-initramfs.patch)0
-rw-r--r--target/linux/patches/3.16.81/defaults.patch (renamed from target/linux/patches/3.16.56/defaults.patch)0
-rw-r--r--target/linux/patches/3.16.81/export-symbol-for-exmap.patch (renamed from target/linux/patches/3.16.56/export-symbol-for-exmap.patch)0
-rw-r--r--target/linux/patches/3.16.81/fblogo.patch (renamed from target/linux/patches/3.16.56/fblogo.patch)0
-rw-r--r--target/linux/patches/3.16.81/gemalto.patch (renamed from target/linux/patches/3.16.56/gemalto.patch)0
-rw-r--r--target/linux/patches/3.16.81/initramfs-nosizelimit.patch (renamed from target/linux/patches/4.1.51/initramfs-nosizelimit.patch)0
-rw-r--r--target/linux/patches/3.16.81/lemote-rfkill.patch (renamed from target/linux/patches/3.16.56/lemote-rfkill.patch)0
-rw-r--r--target/linux/patches/3.16.81/microblaze-ethernet.patch (renamed from target/linux/patches/3.16.56/microblaze-ethernet.patch)0
-rw-r--r--target/linux/patches/3.16.81/mkpiggy.patch (renamed from target/linux/patches/3.16.56/mkpiggy.patch)0
-rw-r--r--target/linux/patches/3.16.81/mtd-rootfs.patch (renamed from target/linux/patches/3.16.56/mtd-rootfs.patch)0
-rw-r--r--target/linux/patches/3.16.81/nfsv3-tcp.patch (renamed from target/linux/patches/3.16.56/nfsv3-tcp.patch)0
-rw-r--r--target/linux/patches/3.16.81/non-static.patch (renamed from target/linux/patches/3.16.56/non-static.patch)0
-rw-r--r--target/linux/patches/3.16.81/ppc64-missing-zlib.patch (renamed from target/linux/patches/3.16.56/ppc64-missing-zlib.patch)0
-rw-r--r--target/linux/patches/3.16.81/relocs.patch (renamed from target/linux/patches/3.16.56/relocs.patch)0
-rw-r--r--target/linux/patches/3.16.81/sgidefs.patch (renamed from target/linux/patches/3.16.56/sgidefs.patch)0
-rw-r--r--target/linux/patches/3.16.81/sortext.patch (renamed from target/linux/patches/3.16.56/sortext.patch)0
-rw-r--r--target/linux/patches/3.16.81/startup.patch (renamed from target/linux/patches/4.1.51/startup.patch)0
-rw-r--r--target/linux/patches/3.16.81/wlan-cf.patch (renamed from target/linux/patches/3.16.56/wlan-cf.patch)0
-rw-r--r--target/linux/patches/3.16.81/xargs.patch (renamed from target/linux/patches/3.16.56/xargs.patch)0
-rw-r--r--target/linux/patches/3.2.101/sparc-aout.patch24
-rw-r--r--target/linux/patches/4.1.51/cleankernel.patch11
-rw-r--r--target/linux/patches/4.1.51/cris-header.patch12
-rw-r--r--target/linux/patches/4.1.51/j2-core.patch2060
-rw-r--r--target/linux/patches/4.1.51/mtd-rootfs.patch26
-rw-r--r--target/linux/patches/4.1.51/patch-realtime30260
-rw-r--r--target/linux/patches/4.1.51/regmap-default-on.patch17
-rw-r--r--target/linux/patches/4.1.51/remove-warn.patch11
-rw-r--r--target/linux/patches/4.1.51/use-gawk.patch24
-rw-r--r--target/linux/patches/4.1.51/use-libgcc-for-sh.patch29
40 files changed, 3 insertions, 35225 deletions
diff --git a/mk/linux-ver.mk b/mk/linux-ver.mk
index 0e5f24d..b61c109 100644
--- a/mk/linux-ver.mk
+++ b/mk/linux-ver.mk
@@ -45,23 +45,11 @@ KERNEL_RELEASE:= 1
KERNEL_VERSION:= $(KERNEL_FILE_VER)-$(KERNEL_RELEASE)
KERNEL_HASH:= 77df6c3c5c512516db444264242cef5370550ed58ef3f198632858b917f9d8b8
endif
-ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_4_1),y)
-KERNEL_FILE_VER:= 4.1.51
-KERNEL_RELEASE:= 1
-KERNEL_VERSION:= $(KERNEL_FILE_VER)-$(KERNEL_RELEASE)
-KERNEL_HASH:= 02285752a9da7a2e05c2a0fc8def00d73088bd3018ad3d7de876a1b81b382a11
-endif
ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_3_16),y)
-KERNEL_FILE_VER:= 3.16.56
-KERNEL_RELEASE:= 1
-KERNEL_VERSION:= $(KERNEL_FILE_VER)-$(KERNEL_RELEASE)
-KERNEL_HASH:= 50a69d586b197b1f0dead9fef7232a39ecb25fafdcd6045e1d80db4d9e753cbb
-endif
-ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_3_2),y)
-KERNEL_FILE_VER:= 3.2.101
+KERNEL_FILE_VER:= 3.16.81
KERNEL_RELEASE:= 1
KERNEL_VERSION:= $(KERNEL_FILE_VER)-$(KERNEL_RELEASE)
-KERNEL_HASH:= 4453686b001685144f44c88d57c716fcb6e85ef8a2aad2f95d36df82fa972c59
+KERNEL_HASH:= 24c21bc7cbd311282362b2e3ebc13417d725b0409ba14d6f9b6f1cf23a9fcbb3
endif
ifeq ($(ADK_TARGET_LINUX_KERNEL_VERSION_2_6_32),y)
KERNEL_FILE_VER:= 2.6.32.70
diff --git a/target/linux/Config.in.kernelversion b/target/linux/Config.in.kernelversion
index f74d5c5..33bfbc1 100644
--- a/target/linux/Config.in.kernelversion
+++ b/target/linux/Config.in.kernelversion
@@ -104,26 +104,8 @@ config ADK_TARGET_LINUX_KERNEL_VERSION_4_4
depends on !ADK_TARGET_SYSTEM_NUMATO_MIMASV2
depends on !ADK_TARGET_SYSTEM_ORANGE_PI0
-config ADK_TARGET_LINUX_KERNEL_VERSION_4_1
- bool "4.1.51"
- depends on !ADK_TARGET_ARCH_ARC
- depends on !ADK_TARGET_ARCH_BFIN
- depends on !ADK_TARGET_ARCH_CSKY
- depends on !ADK_TARGET_ARCH_H8300
- depends on !ADK_TARGET_ARCH_NIOS2
- depends on !ADK_TARGET_ARCH_NDS32
- depends on !ADK_TARGET_ARCH_OR1K
- depends on !ADK_TARGET_ARCH_SPARC
- depends on !ADK_TARGET_ARCH_RISCV32
- depends on !ADK_TARGET_ARCH_RISCV64
- depends on !ADK_TARGET_SYSTEM_KINETIS_K70
- depends on !ADK_TARGET_SYSTEM_QEMU_M68K_MCF5208
- depends on !ADK_TARGET_CPU_MIPS_MIPS32R6
- depends on !ADK_TARGET_CPU_MIPS64_MIPS64R6
- depends on !ADK_TARGET_SYSTEM_ORANGE_PI0
-
config ADK_TARGET_LINUX_KERNEL_VERSION_3_16
- bool "3.16.56"
+ bool "3.16.81"
depends on !ADK_TARGET_ARCH_ARC
depends on !ADK_TARGET_ARCH_BFIN
depends on !ADK_TARGET_ARCH_CSKY
@@ -150,29 +132,6 @@ config ADK_TARGET_LINUX_KERNEL_VERSION_3_10_NDS32
depends on ADK_TARGET_ARCH_NDS32
select ADK_TARGET_LINUX_KERNEL_NO_MIRROR
-config ADK_TARGET_LINUX_KERNEL_VERSION_3_2
- bool "3.2.101"
- depends on !ADK_TARGET_ARCH_ARC
- depends on !ADK_TARGET_ARCH_BFIN
- depends on !ADK_TARGET_ARCH_CSKY
- depends on !ADK_TARGET_ARCH_H8300
- depends on !ADK_TARGET_ARCH_NDS32
- depends on !ADK_TARGET_ARCH_NIOS2
- depends on !ADK_TARGET_ARCH_OR1K
- depends on !ADK_TARGET_ARCH_RISCV32
- depends on !ADK_TARGET_ARCH_RISCV64
- depends on !ADK_TARGET_ARCH_SPARC
- depends on !ADK_TARGET_BOARD_ATH79
- depends on !ADK_TARGET_BOARD_BCM28XX
- depends on !ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK
- depends on !ADK_TARGET_SYSTEM_KINETIS_K70
- depends on !ADK_TARGET_SYSTEM_SOLIDRUN_IMX6
- depends on !ADK_TARGET_SYSTEM_QEMU_M68K_MCF5208
- depends on !ADK_TARGET_SYSTEM_NUMATO_MIMASV2
- depends on !ADK_TARGET_CPU_MIPS_MIPS32R6
- depends on !ADK_TARGET_CPU_MIPS64_MIPS64R6
- depends on !ADK_TARGET_SYSTEM_ORANGE_PI0
-
config ADK_TARGET_LINUX_KERNEL_VERSION_2_6_32
bool "2.6.32.70"
depends on !ADK_TARGET_ARCH_ARC
diff --git a/target/linux/patches/3.10.107/bsd-compatibility.patch b/target/linux/patches/3.10.107/bsd-compatibility.patch
deleted file mode 100644
index b954b65..0000000
--- a/target/linux/patches/3.10.107/bsd-compatibility.patch
+++ /dev/null
@@ -1,2538 +0,0 @@
-diff -Nur linux-3.11.5.orig/scripts/Makefile.lib linux-3.11.5/scripts/Makefile.lib
---- linux-3.11.5.orig/scripts/Makefile.lib 2013-10-14 03:14:45.000000000 +0200
-+++ linux-3.11.5/scripts/Makefile.lib 2013-10-16 18:09:31.000000000 +0200
-@@ -281,7 +281,12 @@
- size_append = printf $(shell \
- dec_size=0; \
- for F in $1; do \
-- fsize=$$(stat -c "%s" $$F); \
-+ if stat -qs .>/dev/null 2>&1; then \
-+ statcmd='stat -f %z'; \
-+ else \
-+ statcmd='stat -c %s'; \
-+ fi; \
-+ fsize=$$($$statcmd $$F); \
- dec_size=$$(expr $$dec_size + $$fsize); \
- done; \
- printf "%08x\n" $$dec_size | \
-diff -Nur linux-3.11.5.orig/scripts/mod/mk_elfconfig.c linux-3.11.5/scripts/mod/mk_elfconfig.c
---- linux-3.11.5.orig/scripts/mod/mk_elfconfig.c 2013-10-14 03:14:45.000000000 +0200
-+++ linux-3.11.5/scripts/mod/mk_elfconfig.c 2013-10-16 18:09:31.000000000 +0200
-@@ -1,7 +1,18 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
--#include <elf.h>
-+
-+#define EI_NIDENT (16)
-+#define ELFMAG "\177ELF"
-+
-+#define SELFMAG 4
-+#define EI_CLASS 4
-+#define ELFCLASS32 1 /* 32-bit objects */
-+#define ELFCLASS64 2 /* 64-bit objects */
-+
-+#define EI_DATA 5 /* Data encoding byte index */
-+#define ELFDATA2LSB 1 /* 2's complement, little endian */
-+#define ELFDATA2MSB 2 /* 2's complement, big endian */
-
- int
- main(int argc, char **argv)
-diff -Nur linux-3.11.5.orig/scripts/mod/modpost.h linux-3.11.5/scripts/mod/modpost.h
---- linux-3.11.5.orig/scripts/mod/modpost.h 2013-10-14 03:14:45.000000000 +0200
-+++ linux-3.11.5/scripts/mod/modpost.h 2013-10-16 18:09:31.000000000 +0200
-@@ -7,7 +7,2453 @@
- #include <sys/mman.h>
- #include <fcntl.h>
- #include <unistd.h>
--#include <elf.h>
-+
-+
-+/* This file defines standard ELF types, structures, and macros.
-+ Copyright (C) 1995-1999,2000,2001,2002,2003 Free Software Foundation, Inc.
-+ This file is part of the GNU C Library.
-+
-+ The GNU C Library is free software; you can redistribute it and/or
-+ modify it under the terms of the GNU Lesser General Public
-+ License as published by the Free Software Foundation; either
-+ version 2.1 of the License, or (at your option) any later version.
-+
-+ The GNU C Library is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ Lesser General Public License for more details.
-+
-+ You should have received a copy of the GNU Lesser General Public
-+ License along with the GNU C Library; if not, write to the Free
-+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-+ 02111-1307 USA. */
-+
-+#ifndef _ELF_H
-+#define _ELF_H 1
-+
-+__BEGIN_DECLS
-+
-+/* Standard ELF types. */
-+
-+#include <stdint.h>
-+
-+/* Type for a 16-bit quantity. */
-+typedef uint16_t Elf32_Half;
-+typedef uint16_t Elf64_Half;
-+
-+/* Types for signed and unsigned 32-bit quantities. */
-+typedef uint32_t Elf32_Word;
-+typedef int32_t Elf32_Sword;
-+typedef uint32_t Elf64_Word;
-+typedef int32_t Elf64_Sword;
-+
-+/* Types for signed and unsigned 64-bit quantities. */
-+typedef uint64_t Elf32_Xword;
-+typedef int64_t Elf32_Sxword;
-+typedef uint64_t Elf64_Xword;
-+typedef int64_t Elf64_Sxword;
-+
-+/* Type of addresses. */
-+typedef uint32_t Elf32_Addr;
-+typedef uint64_t Elf64_Addr;
-+
-+/* Type of file offsets. */
-+typedef uint32_t Elf32_Off;
-+typedef uint64_t Elf64_Off;
-+
-+/* Type for section indices, which are 16-bit quantities. */
-+typedef uint16_t Elf32_Section;
-+typedef uint16_t Elf64_Section;
-+
-+/* Type for version symbol information. */
-+typedef Elf32_Half Elf32_Versym;
-+typedef Elf64_Half Elf64_Versym;
-+
-+
-+/* The ELF file header. This appears at the start of every ELF file. */
-+
-+#define EI_NIDENT (16)
-+
-+typedef struct
-+{
-+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
-+ Elf32_Half e_type; /* Object file type */
-+ Elf32_Half e_machine; /* Architecture */
-+ Elf32_Word e_version; /* Object file version */
-+ Elf32_Addr e_entry; /* Entry point virtual address */
-+ Elf32_Off e_phoff; /* Program header table file offset */
-+ Elf32_Off e_shoff; /* Section header table file offset */
-+ Elf32_Word e_flags; /* Processor-specific flags */
-+ Elf32_Half e_ehsize; /* ELF header size in bytes */
-+ Elf32_Half e_phentsize; /* Program header table entry size */
-+ Elf32_Half e_phnum; /* Program header table entry count */
-+ Elf32_Half e_shentsize; /* Section header table entry size */
-+ Elf32_Half e_shnum; /* Section header table entry count */
-+ Elf32_Half e_shstrndx; /* Section header string table index */
-+} Elf32_Ehdr;
-+
-+typedef struct
-+{
-+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
-+ Elf64_Half e_type; /* Object file type */
-+ Elf64_Half e_machine; /* Architecture */
-+ Elf64_Word e_version; /* Object file version */
-+ Elf64_Addr e_entry; /* Entry point virtual address */
-+ Elf64_Off e_phoff; /* Program header table file offset */
-+ Elf64_Off e_shoff; /* Section header table file offset */
-+ Elf64_Word e_flags; /* Processor-specific flags */
-+ Elf64_Half e_ehsize; /* ELF header size in bytes */
-+ Elf64_Half e_phentsize; /* Program header table entry size */
-+ Elf64_Half e_phnum; /* Program header table entry count */
-+ Elf64_Half e_shentsize; /* Section header table entry size */
-+ Elf64_Half e_shnum; /* Section header table entry count */
-+ Elf64_Half e_shstrndx; /* Section header string table index */
-+} Elf64_Ehdr;
-+
-+/* Fields in the e_ident array. The EI_* macros are indices into the
-+ array. The macros under each EI_* macro are the values the byte
-+ may have. */
-+
-+#define EI_MAG0 0 /* File identification byte 0 index */
-+#define ELFMAG0 0x7f /* Magic number byte 0 */
-+
-+#define EI_MAG1 1 /* File identification byte 1 index */
-+#define ELFMAG1 'E' /* Magic number byte 1 */
-+
-+#define EI_MAG2 2 /* File identification byte 2 index */
-+#define ELFMAG2 'L' /* Magic number byte 2 */
-+
-+#define EI_MAG3 3 /* File identification byte 3 index */
-+#define ELFMAG3 'F' /* Magic number byte 3 */
-+
-+/* Conglomeration of the identification bytes, for easy testing as a word. */
-+#define ELFMAG "\177ELF"
-+#define SELFMAG 4
-+
-+#define EI_CLASS 4 /* File class byte index */
-+#define ELFCLASSNONE 0 /* Invalid class */
-+#define ELFCLASS32 1 /* 32-bit objects */
-+#define ELFCLASS64 2 /* 64-bit objects */
-+#define ELFCLASSNUM 3
-+
-+#define EI_DATA 5 /* Data encoding byte index */
-+#define ELFDATANONE 0 /* Invalid data encoding */
-+#define ELFDATA2LSB 1 /* 2's complement, little endian */
-+#define ELFDATA2MSB 2 /* 2's complement, big endian */
-+#define ELFDATANUM 3
-+
-+#define EI_VERSION 6 /* File version byte index */
-+ /* Value must be EV_CURRENT */
-+
-+#define EI_OSABI 7 /* OS ABI identification */
-+#define ELFOSABI_NONE 0 /* UNIX System V ABI */
-+#define ELFOSABI_SYSV 0 /* Alias. */
-+#define ELFOSABI_HPUX 1 /* HP-UX */
-+#define ELFOSABI_NETBSD 2 /* NetBSD. */
-+#define ELFOSABI_LINUX 3 /* Linux. */
-+#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
-+#define ELFOSABI_AIX 7 /* IBM AIX. */
-+#define ELFOSABI_IRIX 8 /* SGI Irix. */
-+#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
-+#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
-+#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
-+#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
-+#define ELFOSABI_ARM 97 /* ARM */
-+#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
-+
-+#define EI_ABIVERSION 8 /* ABI version */
-+
-+#define EI_PAD 9 /* Byte index of padding bytes */
-+
-+/* Legal values for e_type (object file type). */
-+
-+#define ET_NONE 0 /* No file type */
-+#define ET_REL 1 /* Relocatable file */
-+#define ET_EXEC 2 /* Executable file */
-+#define ET_DYN 3 /* Shared object file */
-+#define ET_CORE 4 /* Core file */
-+#define ET_NUM 5 /* Number of defined types */
-+#define ET_LOOS 0xfe00 /* OS-specific range start */
-+#define ET_HIOS 0xfeff /* OS-specific range end */
-+#define ET_LOPROC 0xff00 /* Processor-specific range start */
-+#define ET_HIPROC 0xffff /* Processor-specific range end */
-+
-+/* Legal values for e_machine (architecture). */
-+
-+#define EM_NONE 0 /* No machine */
-+#define EM_M32 1 /* AT&T WE 32100 */
-+#define EM_SPARC 2 /* SUN SPARC */
-+#define EM_386 3 /* Intel 80386 */
-+#define EM_68K 4 /* Motorola m68k family */
-+#define EM_88K 5 /* Motorola m88k family */
-+#define EM_860 7 /* Intel 80860 */
-+#define EM_MIPS 8 /* MIPS R3000 big-endian */
-+#define EM_S370 9 /* IBM System/370 */
-+#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
-+
-+#define EM_PARISC 15 /* HPPA */
-+#define EM_VPP500 17 /* Fujitsu VPP500 */
-+#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
-+#define EM_960 19 /* Intel 80960 */
-+#define EM_PPC 20 /* PowerPC */
-+#define EM_PPC64 21 /* PowerPC 64-bit */
-+#define EM_S390 22 /* IBM S390 */
-+
-+#define EM_V800 36 /* NEC V800 series */
-+#define EM_FR20 37 /* Fujitsu FR20 */
-+#define EM_RH32 38 /* TRW RH-32 */
-+#define EM_RCE 39 /* Motorola RCE */
-+#define EM_ARM 40 /* ARM */
-+#define EM_FAKE_ALPHA 41 /* Digital Alpha */
-+#define EM_SH 42 /* Hitachi SH */
-+#define EM_SPARCV9 43 /* SPARC v9 64-bit */
-+#define EM_TRICORE 44 /* Siemens Tricore */
-+#define EM_ARC 45 /* Argonaut RISC Core */
-+#define EM_H8_300 46 /* Hitachi H8/300 */
-+#define EM_H8_300H 47 /* Hitachi H8/300H */
-+#define EM_H8S 48 /* Hitachi H8S */
-+#define EM_H8_500 49 /* Hitachi H8/500 */
-+#define EM_IA_64 50 /* Intel Merced */
-+#define EM_MIPS_X 51 /* Stanford MIPS-X */
-+#define EM_COLDFIRE 52 /* Motorola Coldfire */
-+#define EM_68HC12 53 /* Motorola M68HC12 */
-+#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
-+#define EM_PCP 55 /* Siemens PCP */
-+#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
-+#define EM_NDR1 57 /* Denso NDR1 microprocessor */
-+#define EM_STARCORE 58 /* Motorola Start*Core processor */
-+#define EM_ME16 59 /* Toyota ME16 processor */
-+#define EM_ST100 60 /* STMicroelectronic ST100 processor */
-+#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
-+#define EM_X86_64 62 /* AMD x86-64 architecture */
-+#define EM_PDSP 63 /* Sony DSP Processor */
-+
-+#define EM_FX66 66 /* Siemens FX66 microcontroller */
-+#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
-+#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
-+#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
-+#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
-+#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
-+#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
-+#define EM_SVX 73 /* Silicon Graphics SVx */
-+#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */
-+#define EM_VAX 75 /* Digital VAX */
-+#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
-+#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
-+#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
-+#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
-+#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
-+#define EM_HUANY 81 /* Harvard University machine-independent object files */
-+#define EM_PRISM 82 /* SiTera Prism */
-+#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
-+#define EM_FR30 84 /* Fujitsu FR30 */
-+#define EM_D10V 85 /* Mitsubishi D10V */
-+#define EM_D30V 86 /* Mitsubishi D30V */
-+#define EM_V850 87 /* NEC v850 */
-+#define EM_M32R 88 /* Mitsubishi M32R */
-+#define EM_MN10300 89 /* Matsushita MN10300 */
-+#define EM_MN10200 90 /* Matsushita MN10200 */
-+#define EM_PJ 91 /* picoJava */
-+#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
-+#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
-+#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
-+#define EM_NUM 95
-+
-+/* If it is necessary to assign new unofficial EM_* values, please
-+ pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
-+ chances of collision with official or non-GNU unofficial values. */
-+
-+#define EM_ALPHA 0x9026
-+
-+/* Legal values for e_version (version). */
-+
-+#define EV_NONE 0 /* Invalid ELF version */
-+#define EV_CURRENT 1 /* Current version */
-+#define EV_NUM 2
-+
-+/* Section header. */
-+
-+typedef struct
-+{
-+ Elf32_Word sh_name; /* Section name (string tbl index) */
-+ Elf32_Word sh_type; /* Section type */
-+ Elf32_Word sh_flags; /* Section flags */
-+ Elf32_Addr sh_addr; /* Section virtual addr at execution */
-+ Elf32_Off sh_offset; /* Section file offset */
-+ Elf32_Word sh_size; /* Section size in bytes */
-+ Elf32_Word sh_link; /* Link to another section */
-+ Elf32_Word sh_info; /* Additional section information */
-+ Elf32_Word sh_addralign; /* Section alignment */
-+ Elf32_Word sh_entsize; /* Entry size if section holds table */
-+} Elf32_Shdr;
-+
-+typedef struct
-+{
-+ Elf64_Word sh_name; /* Section name (string tbl index) */
-+ Elf64_Word sh_type; /* Section type */
-+ Elf64_Xword sh_flags; /* Section flags */
-+ Elf64_Addr sh_addr; /* Section virtual addr at execution */
-+ Elf64_Off sh_offset; /* Section file offset */
-+ Elf64_Xword sh_size; /* Section size in bytes */
-+ Elf64_Word sh_link; /* Link to another section */
-+ Elf64_Word sh_info; /* Additional section information */
-+ Elf64_Xword sh_addralign; /* Section alignment */
-+ Elf64_Xword sh_entsize; /* Entry size if section holds table */
-+} Elf64_Shdr;
-+
-+/* Special section indices. */
-+
-+#define SHN_UNDEF 0 /* Undefined section */
-+#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
-+#define SHN_LOPROC 0xff00 /* Start of processor-specific */
-+#define SHN_HIPROC 0xff1f /* End of processor-specific */
-+#define SHN_LOOS 0xff20 /* Start of OS-specific */
-+#define SHN_HIOS 0xff3f /* End of OS-specific */
-+#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
-+#define SHN_COMMON 0xfff2 /* Associated symbol is common */
-+#define SHN_XINDEX 0xffff /* Index is in extra table. */
-+#define SHN_HIRESERVE 0xffff /* End of reserved indices */
-+
-+/* Legal values for sh_type (section type). */
-+
-+#define SHT_NULL 0 /* Section header table entry unused */
-+#define SHT_PROGBITS 1 /* Program data */
-+#define SHT_SYMTAB 2 /* Symbol table */
-+#define SHT_STRTAB 3 /* String table */
-+#define SHT_RELA 4 /* Relocation entries with addends */
-+#define SHT_HASH 5 /* Symbol hash table */
-+#define SHT_DYNAMIC 6 /* Dynamic linking information */
-+#define SHT_NOTE 7 /* Notes */
-+#define SHT_NOBITS 8 /* Program space with no data (bss) */
-+#define SHT_REL 9 /* Relocation entries, no addends */
-+#define SHT_SHLIB 10 /* Reserved */
-+#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
-+#define SHT_INIT_ARRAY 14 /* Array of constructors */
-+#define SHT_FINI_ARRAY 15 /* Array of destructors */
-+#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
-+#define SHT_GROUP 17 /* Section group */
-+#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
-+#define SHT_NUM 19 /* Number of defined types. */
-+#define SHT_LOOS 0x60000000 /* Start OS-specific */
-+#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
-+#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
-+#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
-+#define SHT_SUNW_move 0x6ffffffa
-+#define SHT_SUNW_COMDAT 0x6ffffffb
-+#define SHT_SUNW_syminfo 0x6ffffffc
-+#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
-+#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
-+#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
-+#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
-+#define SHT_HIOS 0x6fffffff /* End OS-specific type */
-+#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
-+#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
-+#define SHT_LOUSER 0x80000000 /* Start of application-specific */
-+#define SHT_HIUSER 0x8fffffff /* End of application-specific */
-+
-+/* Legal values for sh_flags (section flags). */
-+
-+#define SHF_WRITE (1 << 0) /* Writable */
-+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
-+#define SHF_EXECINSTR (1 << 2) /* Executable */
-+#define SHF_MERGE (1 << 4) /* Might be merged */
-+#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
-+#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
-+#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
-+#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
-+ required */
-+#define SHF_GROUP (1 << 9) /* Section is member of a group. */
-+#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
-+#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
-+#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
-+
-+/* Section group handling. */
-+#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
-+
-+/* Symbol table entry. */
-+
-+typedef struct
-+{
-+ Elf32_Word st_name; /* Symbol name (string tbl index) */
-+ Elf32_Addr st_value; /* Symbol value */
-+ Elf32_Word st_size; /* Symbol size */
-+ unsigned char st_info; /* Symbol type and binding */
-+ unsigned char st_other; /* Symbol visibility */
-+ Elf32_Section st_shndx; /* Section index */
-+} Elf32_Sym;
-+
-+typedef struct
-+{
-+ Elf64_Word st_name; /* Symbol name (string tbl index) */
-+ unsigned char st_info; /* Symbol type and binding */
-+ unsigned char st_other; /* Symbol visibility */
-+ Elf64_Section st_shndx; /* Section index */
-+ Elf64_Addr st_value; /* Symbol value */
-+ Elf64_Xword st_size; /* Symbol size */
-+} Elf64_Sym;
-+
-+/* The syminfo section if available contains additional information about
-+ every dynamic symbol. */
-+
-+typedef struct
-+{
-+ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
-+ Elf32_Half si_flags; /* Per symbol flags */
-+} Elf32_Syminfo;
-+
-+typedef struct
-+{
-+ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
-+ Elf64_Half si_flags; /* Per symbol flags */
-+} Elf64_Syminfo;
-+
-+/* Possible values for si_boundto. */
-+#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
-+#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
-+#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
-+
-+/* Possible bitmasks for si_flags. */
-+#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
-+#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
-+#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
-+#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
-+ loaded */
-+/* Syminfo version values. */
-+#define SYMINFO_NONE 0
-+#define SYMINFO_CURRENT 1
-+#define SYMINFO_NUM 2
-+
-+
-+/* How to extract and insert information held in the st_info field. */
-+
-+#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
-+#define ELF32_ST_TYPE(val) ((val) & 0xf)
-+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
-+
-+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
-+#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
-+#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
-+#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
-+
-+/* Legal values for ST_BIND subfield of st_info (symbol binding). */
-+
-+#define STB_LOCAL 0 /* Local symbol */
-+#define STB_GLOBAL 1 /* Global symbol */
-+#define STB_WEAK 2 /* Weak symbol */
-+#define STB_NUM 3 /* Number of defined types. */
-+#define STB_LOOS 10 /* Start of OS-specific */
-+#define STB_HIOS 12 /* End of OS-specific */
-+#define STB_LOPROC 13 /* Start of processor-specific */
-+#define STB_HIPROC 15 /* End of processor-specific */
-+
-+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
-+
-+#define STT_NOTYPE 0 /* Symbol type is unspecified */
-+#define STT_OBJECT 1 /* Symbol is a data object */
-+#define STT_FUNC 2 /* Symbol is a code object */
-+#define STT_SECTION 3 /* Symbol associated with a section */
-+#define STT_FILE 4 /* Symbol's name is file name */
-+#define STT_COMMON 5 /* Symbol is a common data object */
-+#define STT_TLS 6 /* Symbol is thread-local data object*/
-+#define STT_NUM 7 /* Number of defined types. */
-+#define STT_LOOS 10 /* Start of OS-specific */
-+#define STT_HIOS 12 /* End of OS-specific */
-+#define STT_LOPROC 13 /* Start of processor-specific */
-+#define STT_HIPROC 15 /* End of processor-specific */
-+
-+
-+/* Symbol table indices are found in the hash buckets and chain table
-+ of a symbol hash table section. This special index value indicates
-+ the end of a chain, meaning no further symbols are found in that bucket. */
-+
-+#define STN_UNDEF 0 /* End of a chain. */
-+
-+
-+/* How to extract and insert information held in the st_other field. */
-+
-+#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
-+
-+/* For ELF64 the definitions are the same. */
-+#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
-+
-+/* Symbol visibility specification encoded in the st_other field. */
-+#define STV_DEFAULT 0 /* Default symbol visibility rules */
-+#define STV_INTERNAL 1 /* Processor specific hidden class */
-+#define STV_HIDDEN 2 /* Sym unavailable in other modules */
-+#define STV_PROTECTED 3 /* Not preemptible, not exported */
-+
-+
-+/* Relocation table entry without addend (in section of type SHT_REL). */
-+
-+typedef struct
-+{
-+ Elf32_Addr r_offset; /* Address */
-+ Elf32_Word r_info; /* Relocation type and symbol index */
-+} Elf32_Rel;
-+
-+/* I have seen two different definitions of the Elf64_Rel and
-+ Elf64_Rela structures, so we'll leave them out until Novell (or
-+ whoever) gets their act together. */
-+/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
-+
-+typedef struct
-+{
-+ Elf64_Addr r_offset; /* Address */
-+ Elf64_Xword r_info; /* Relocation type and symbol index */
-+} Elf64_Rel;
-+
-+/* Relocation table entry with addend (in section of type SHT_RELA). */
-+
-+typedef struct
-+{
-+ Elf32_Addr r_offset; /* Address */
-+ Elf32_Word r_info; /* Relocation type and symbol index */
-+ Elf32_Sword r_addend; /* Addend */
-+} Elf32_Rela;
-+
-+typedef struct
-+{
-+ Elf64_Addr r_offset; /* Address */
-+ Elf64_Xword r_info; /* Relocation type and symbol index */
-+ Elf64_Sxword r_addend; /* Addend */
-+} Elf64_Rela;
-+
-+/* How to extract and insert information held in the r_info field. */
-+
-+#define ELF32_R_SYM(val) ((val) >> 8)
-+#define ELF32_R_TYPE(val) ((val) & 0xff)
-+#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
-+
-+#define ELF64_R_SYM(i) ((i) >> 32)
-+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
-+#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
-+
-+/* Program segment header. */
-+
-+typedef struct
-+{
-+ Elf32_Word p_type; /* Segment type */
-+ Elf32_Off p_offset; /* Segment file offset */
-+ Elf32_Addr p_vaddr; /* Segment virtual address */
-+ Elf32_Addr p_paddr; /* Segment physical address */
-+ Elf32_Word p_filesz; /* Segment size in file */
-+ Elf32_Word p_memsz; /* Segment size in memory */
-+ Elf32_Word p_flags; /* Segment flags */
-+ Elf32_Word p_align; /* Segment alignment */
-+} Elf32_Phdr;
-+
-+typedef struct
-+{
-+ Elf64_Word p_type; /* Segment type */
-+ Elf64_Word p_flags; /* Segment flags */
-+ Elf64_Off p_offset; /* Segment file offset */
-+ Elf64_Addr p_vaddr; /* Segment virtual address */
-+ Elf64_Addr p_paddr; /* Segment physical address */
-+ Elf64_Xword p_filesz; /* Segment size in file */
-+ Elf64_Xword p_memsz; /* Segment size in memory */
-+ Elf64_Xword p_align; /* Segment alignment */
-+} Elf64_Phdr;
-+
-+/* Legal values for p_type (segment type). */
-+
-+#define PT_NULL 0 /* Program header table entry unused */
-+#define PT_LOAD 1 /* Loadable program segment */
-+#define PT_DYNAMIC 2 /* Dynamic linking information */
-+#define PT_INTERP 3 /* Program interpreter */
-+#define PT_NOTE 4 /* Auxiliary information */
-+#define PT_SHLIB 5 /* Reserved */
-+#define PT_PHDR 6 /* Entry for header table itself */
-+#define PT_TLS 7 /* Thread-local storage segment */
-+#define PT_NUM 8 /* Number of defined types */
-+#define PT_LOOS 0x60000000 /* Start of OS-specific */
-+#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
-+#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
-+#define PT_LOSUNW 0x6ffffffa
-+#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
-+#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
-+#define PT_HISUNW 0x6fffffff
-+#define PT_HIOS 0x6fffffff /* End of OS-specific */
-+#define PT_LOPROC 0x70000000 /* Start of processor-specific */
-+#define PT_HIPROC 0x7fffffff /* End of processor-specific */
-+
-+/* Legal values for p_flags (segment flags). */
-+
-+#define PF_X (1 << 0) /* Segment is executable */
-+#define PF_W (1 << 1) /* Segment is writable */
-+#define PF_R (1 << 2) /* Segment is readable */
-+#define PF_MASKOS 0x0ff00000 /* OS-specific */
-+#define PF_MASKPROC 0xf0000000 /* Processor-specific */
-+
-+/* Legal values for note segment descriptor types for core files. */
-+
-+#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
-+#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
-+#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
-+#define NT_PRXREG 4 /* Contains copy of prxregset struct */
-+#define NT_TASKSTRUCT 4 /* Contains copy of task structure */
-+#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
-+#define NT_AUXV 6 /* Contains copy of auxv array */
-+#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
-+#define NT_ASRS 8 /* Contains copy of asrset struct */
-+#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
-+#define NT_PSINFO 13 /* Contains copy of psinfo struct */
-+#define NT_PRCRED 14 /* Contains copy of prcred struct */
-+#define NT_UTSNAME 15 /* Contains copy of utsname struct */
-+#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
-+#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
-+#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/
-+
-+/* Legal values for the note segment descriptor types for object files. */
-+
-+#define NT_VERSION 1 /* Contains a version string. */
-+
-+
-+/* Dynamic section entry. */
-+
-+typedef struct
-+{
-+ Elf32_Sword d_tag; /* Dynamic entry type */
-+ union
-+ {
-+ Elf32_Word d_val; /* Integer value */
-+ Elf32_Addr d_ptr; /* Address value */
-+ } d_un;
-+} Elf32_Dyn;
-+
-+typedef struct
-+{
-+ Elf64_Sxword d_tag; /* Dynamic entry type */
-+ union
-+ {
-+ Elf64_Xword d_val; /* Integer value */
-+ Elf64_Addr d_ptr; /* Address value */
-+ } d_un;
-+} Elf64_Dyn;
-+
-+/* Legal values for d_tag (dynamic entry type). */
-+
-+#define DT_NULL 0 /* Marks end of dynamic section */
-+#define DT_NEEDED 1 /* Name of needed library */
-+#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
-+#define DT_PLTGOT 3 /* Processor defined value */
-+#define DT_HASH 4 /* Address of symbol hash table */
-+#define DT_STRTAB 5 /* Address of string table */
-+#define DT_SYMTAB 6 /* Address of symbol table */
-+#define DT_RELA 7 /* Address of Rela relocs */
-+#define DT_RELASZ 8 /* Total size of Rela relocs */
-+#define DT_RELAENT 9 /* Size of one Rela reloc */
-+#define DT_STRSZ 10 /* Size of string table */
-+#define DT_SYMENT 11 /* Size of one symbol table entry */
-+#define DT_INIT 12 /* Address of init function */
-+#define DT_FINI 13 /* Address of termination function */
-+#define DT_SONAME 14 /* Name of shared object */
-+#define DT_RPATH 15 /* Library search path (deprecated) */
-+#define DT_SYMBOLIC 16 /* Start symbol search here */
-+#define DT_REL 17 /* Address of Rel relocs */
-+#define DT_RELSZ 18 /* Total size of Rel relocs */
-+#define DT_RELENT 19 /* Size of one Rel reloc */
-+#define DT_PLTREL 20 /* Type of reloc in PLT */
-+#define DT_DEBUG 21 /* For debugging; unspecified */
-+#define DT_TEXTREL 22 /* Reloc might modify .text */
-+#define DT_JMPREL 23 /* Address of PLT relocs */
-+#define DT_BIND_NOW 24 /* Process relocations of object */
-+#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
-+#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
-+#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
-+#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
-+#define DT_RUNPATH 29 /* Library search path */
-+#define DT_FLAGS 30 /* Flags for the object being loaded */
-+#define DT_ENCODING 32 /* Start of encoded range */
-+#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
-+#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
-+#define DT_NUM 34 /* Number used */
-+#define DT_LOOS 0x6000000d /* Start of OS-specific */
-+#define DT_HIOS 0x6ffff000 /* End of OS-specific */
-+#define DT_LOPROC 0x70000000 /* Start of processor-specific */
-+#define DT_HIPROC 0x7fffffff /* End of processor-specific */
-+#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
-+
-+/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
-+ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
-+ approach. */
-+#define DT_VALRNGLO 0x6ffffd00
-+#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
-+#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
-+#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
-+#define DT_CHECKSUM 0x6ffffdf8
-+#define DT_PLTPADSZ 0x6ffffdf9
-+#define DT_MOVEENT 0x6ffffdfa
-+#define DT_MOVESZ 0x6ffffdfb
-+#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
-+#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
-+ the following DT_* entry. */
-+#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
-+#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
-+#define DT_VALRNGHI 0x6ffffdff
-+#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
-+#define DT_VALNUM 12
-+
-+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
-+ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
-+
-+ If any adjustment is made to the ELF object after it has been
-+ built these entries will need to be adjusted. */
-+#define DT_ADDRRNGLO 0x6ffffe00
-+#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
-+#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
-+#define DT_CONFIG 0x6ffffefa /* Configuration information. */
-+#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
-+#define DT_AUDIT 0x6ffffefc /* Object auditing. */
-+#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
-+#define DT_MOVETAB 0x6ffffefe /* Move table. */
-+#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
-+#define DT_ADDRRNGHI 0x6ffffeff
-+#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
-+#define DT_ADDRNUM 10
-+
-+/* The versioning entry types. The next are defined as part of the
-+ GNU extension. */
-+#define DT_VERSYM 0x6ffffff0
-+
-+#define DT_RELACOUNT 0x6ffffff9
-+#define DT_RELCOUNT 0x6ffffffa
-+
-+/* These were chosen by Sun. */
-+#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
-+#define DT_VERDEF 0x6ffffffc /* Address of version definition
-+ table */
-+#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
-+#define DT_VERNEED 0x6ffffffe /* Address of table with needed
-+ versions */
-+#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
-+#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
-+#define DT_VERSIONTAGNUM 16
-+
-+/* Sun added these machine-independent extensions in the "processor-specific"
-+ range. Be compatible. */
-+#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
-+#define DT_FILTER 0x7fffffff /* Shared object to get values from */
-+#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
-+#define DT_EXTRANUM 3
-+
-+/* Values of `d_un.d_val' in the DT_FLAGS entry. */
-+#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
-+#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
-+#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
-+#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
-+#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
-+
-+/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
-+ entry in the dynamic section. */
-+#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
-+#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
-+#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
-+#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
-+#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
-+#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
-+#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
-+#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
-+#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
-+#define DF_1_TRANS 0x00000200
-+#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
-+#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
-+#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
-+#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
-+#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
-+#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
-+#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
-+
-+/* Flags for the feature selection in DT_FEATURE_1. */
-+#define DTF_1_PARINIT 0x00000001
-+#define DTF_1_CONFEXP 0x00000002
-+
-+/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
-+#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
-+#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
-+ generally available. */
-+
-+/* Version definition sections. */
-+
-+typedef struct
-+{
-+ Elf32_Half vd_version; /* Version revision */
-+ Elf32_Half vd_flags; /* Version information */
-+ Elf32_Half vd_ndx; /* Version Index */
-+ Elf32_Half vd_cnt; /* Number of associated aux entries */
-+ Elf32_Word vd_hash; /* Version name hash value */
-+ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
-+ Elf32_Word vd_next; /* Offset in bytes to next verdef
-+ entry */
-+} Elf32_Verdef;
-+
-+typedef struct
-+{
-+ Elf64_Half vd_version; /* Version revision */
-+ Elf64_Half vd_flags; /* Version information */
-+ Elf64_Half vd_ndx; /* Version Index */
-+ Elf64_Half vd_cnt; /* Number of associated aux entries */
-+ Elf64_Word vd_hash; /* Version name hash value */
-+ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
-+ Elf64_Word vd_next; /* Offset in bytes to next verdef
-+ entry */
-+} Elf64_Verdef;
-+
-+
-+/* Legal values for vd_version (version revision). */
-+#define VER_DEF_NONE 0 /* No version */
-+#define VER_DEF_CURRENT 1 /* Current version */
-+#define VER_DEF_NUM 2 /* Given version number */
-+
-+/* Legal values for vd_flags (version information flags). */
-+#define VER_FLG_BASE 0x1 /* Version definition of file itself */
-+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
-+
-+/* Versym symbol index values. */
-+#define VER_NDX_LOCAL 0 /* Symbol is local. */
-+#define VER_NDX_GLOBAL 1 /* Symbol is global. */
-+#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
-+#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
-+
-+/* Auxialiary version information. */
-+
-+typedef struct
-+{
-+ Elf32_Word vda_name; /* Version or dependency names */
-+ Elf32_Word vda_next; /* Offset in bytes to next verdaux
-+ entry */
-+} Elf32_Verdaux;
-+
-+typedef struct
-+{
-+ Elf64_Word vda_name; /* Version or dependency names */
-+ Elf64_Word vda_next; /* Offset in bytes to next verdaux
-+ entry */
-+} Elf64_Verdaux;
-+
-+
-+/* Version dependency section. */
-+
-+typedef struct
-+{
-+ Elf32_Half vn_version; /* Version of structure */
-+ Elf32_Half vn_cnt; /* Number of associated aux entries */
-+ Elf32_Word vn_file; /* Offset of filename for this
-+ dependency */
-+ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
-+ Elf32_Word vn_next; /* Offset in bytes to next verneed
-+ entry */
-+} Elf32_Verneed;
-+
-+typedef struct
-+{
-+ Elf64_Half vn_version; /* Version of structure */
-+ Elf64_Half vn_cnt; /* Number of associated aux entries */
-+ Elf64_Word vn_file; /* Offset of filename for this
-+ dependency */
-+ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
-+ Elf64_Word vn_next; /* Offset in bytes to next verneed
-+ entry */
-+} Elf64_Verneed;
-+
-+
-+/* Legal values for vn_version (version revision). */
-+#define VER_NEED_NONE 0 /* No version */
-+#define VER_NEED_CURRENT 1 /* Current version */
-+#define VER_NEED_NUM 2 /* Given version number */
-+
-+/* Auxiliary needed version information. */
-+
-+typedef struct
-+{
-+ Elf32_Word vna_hash; /* Hash value of dependency name */
-+ Elf32_Half vna_flags; /* Dependency specific information */
-+ Elf32_Half vna_other; /* Unused */
-+ Elf32_Word vna_name; /* Dependency name string offset */
-+ Elf32_Word vna_next; /* Offset in bytes to next vernaux
-+ entry */
-+} Elf32_Vernaux;
-+
-+typedef struct
-+{
-+ Elf64_Word vna_hash; /* Hash value of dependency name */
-+ Elf64_Half vna_flags; /* Dependency specific information */
-+ Elf64_Half vna_other; /* Unused */
-+ Elf64_Word vna_name; /* Dependency name string offset */
-+ Elf64_Word vna_next; /* Offset in bytes to next vernaux
-+ entry */
-+} Elf64_Vernaux;
-+
-+
-+/* Legal values for vna_flags. */
-+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
-+
-+
-+/* Auxiliary vector. */
-+
-+/* This vector is normally only used by the program interpreter. The
-+ usual definition in an ABI supplement uses the name auxv_t. The
-+ vector is not usually defined in a standard <elf.h> file, but it
-+ can't hurt. We rename it to avoid conflicts. The sizes of these
-+ types are an arrangement between the exec server and the program
-+ interpreter, so we don't fully specify them here. */
-+
-+typedef struct
-+{
-+ int a_type; /* Entry type */
-+ union
-+ {
-+ long int a_val; /* Integer value */
-+ void *a_ptr; /* Pointer value */
-+ void (*a_fcn) (void); /* Function pointer value */
-+ } a_un;
-+} Elf32_auxv_t;
-+
-+typedef struct
-+{
-+ long int a_type; /* Entry type */
-+ union
-+ {
-+ long int a_val; /* Integer value */
-+ void *a_ptr; /* Pointer value */
-+ void (*a_fcn) (void); /* Function pointer value */
-+ } a_un;
-+} Elf64_auxv_t;
-+
-+/* Legal values for a_type (entry type). */
-+
-+#define AT_NULL 0 /* End of vector */
-+#define AT_IGNORE 1 /* Entry should be ignored */
-+#define AT_EXECFD 2 /* File descriptor of program */
-+#define AT_PHDR 3 /* Program headers for program */
-+#define AT_PHENT 4 /* Size of program header entry */
-+#define AT_PHNUM 5 /* Number of program headers */
-+#define AT_PAGESZ 6 /* System page size */
-+#define AT_BASE 7 /* Base address of interpreter */
-+#define AT_FLAGS 8 /* Flags */
-+#define AT_ENTRY 9 /* Entry point of program */
-+#define AT_NOTELF 10 /* Program is not ELF */
-+#define AT_UID 11 /* Real uid */
-+#define AT_EUID 12 /* Effective uid */
-+#define AT_GID 13 /* Real gid */
-+#define AT_EGID 14 /* Effective gid */
-+#define AT_CLKTCK 17 /* Frequency of times() */
-+
-+/* Some more special a_type values describing the hardware. */
-+#define AT_PLATFORM 15 /* String identifying platform. */
-+#define AT_HWCAP 16 /* Machine dependent hints about
-+ processor capabilities. */
-+
-+/* This entry gives some information about the FPU initialization
-+ performed by the kernel. */
-+#define AT_FPUCW 18 /* Used FPU control word. */
-+
-+/* Cache block sizes. */
-+#define AT_DCACHEBSIZE 19 /* Data cache block size. */
-+#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
-+#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
-+
-+/* A special ignored value for PPC, used by the kernel to control the
-+ interpretation of the AUXV. Must be > 16. */
-+#define AT_IGNOREPPC 22 /* Entry should be ignored. */
-+
-+#define AT_SECURE 23 /* Boolean, was exec setuid-like? */
-+
-+/* Pointer to the global system page used for system calls and other
-+ nice things. */
-+#define AT_SYSINFO 32
-+#define AT_SYSINFO_EHDR 33
-+
-+
-+/* Note section contents. Each entry in the note section begins with
-+ a header of a fixed form. */
-+
-+typedef struct
-+{
-+ Elf32_Word n_namesz; /* Length of the note's name. */
-+ Elf32_Word n_descsz; /* Length of the note's descriptor. */
-+ Elf32_Word n_type; /* Type of the note. */
-+} Elf32_Nhdr;
-+
-+typedef struct
-+{
-+ Elf64_Word n_namesz; /* Length of the note's name. */
-+ Elf64_Word n_descsz; /* Length of the note's descriptor. */
-+ Elf64_Word n_type; /* Type of the note. */
-+} Elf64_Nhdr;
-+
-+/* Known names of notes. */
-+
-+/* Solaris entries in the note section have this name. */
-+#define ELF_NOTE_SOLARIS "SUNW Solaris"
-+
-+/* Note entries for GNU systems have this name. */
-+#define ELF_NOTE_GNU "GNU"
-+
-+
-+/* Defined types of notes for Solaris. */
-+
-+/* Value of descriptor (one word) is desired pagesize for the binary. */
-+#define ELF_NOTE_PAGESIZE_HINT 1
-+
-+
-+/* Defined note types for GNU systems. */
-+
-+/* ABI information. The descriptor consists of words:
-+ word 0: OS descriptor
-+ word 1: major version of the ABI
-+ word 2: minor version of the ABI
-+ word 3: subminor version of the ABI
-+*/
-+#define ELF_NOTE_ABI 1
-+
-+/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI
-+ note section entry. */
-+#define ELF_NOTE_OS_LINUX 0
-+#define ELF_NOTE_OS_GNU 1
-+#define ELF_NOTE_OS_SOLARIS2 2
-+#define ELF_NOTE_OS_FREEBSD 3
-+
-+
-+/* Move records. */
-+typedef struct
-+{
-+ Elf32_Xword m_value; /* Symbol value. */
-+ Elf32_Word m_info; /* Size and index. */
-+ Elf32_Word m_poffset; /* Symbol offset. */
-+ Elf32_Half m_repeat; /* Repeat count. */
-+ Elf32_Half m_stride; /* Stride info. */
-+} Elf32_Move;
-+
-+typedef struct
-+{
-+ Elf64_Xword m_value; /* Symbol value. */
-+ Elf64_Xword m_info; /* Size and index. */
-+ Elf64_Xword m_poffset; /* Symbol offset. */
-+ Elf64_Half m_repeat; /* Repeat count. */
-+ Elf64_Half m_stride; /* Stride info. */
-+} Elf64_Move;
-+
-+/* Macro to construct move records. */
-+#define ELF32_M_SYM(info) ((info) >> 8)
-+#define ELF32_M_SIZE(info) ((unsigned char) (info))
-+#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
-+
-+#define ELF64_M_SYM(info) ELF32_M_SYM (info)
-+#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
-+#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
-+
-+
-+/* Motorola 68k specific definitions. */
-+
-+/* Values for Elf32_Ehdr.e_flags. */
-+#define EF_CPU32 0x00810000
-+
-+/* m68k relocs. */
-+
-+#define R_68K_NONE 0 /* No reloc */
-+#define R_68K_32 1 /* Direct 32 bit */
-+#define R_68K_16 2 /* Direct 16 bit */
-+#define R_68K_8 3 /* Direct 8 bit */
-+#define R_68K_PC32 4 /* PC relative 32 bit */
-+#define R_68K_PC16 5 /* PC relative 16 bit */
-+#define R_68K_PC8 6 /* PC relative 8 bit */
-+#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
-+#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
-+#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
-+#define R_68K_GOT32O 10 /* 32 bit GOT offset */
-+#define R_68K_GOT16O 11 /* 16 bit GOT offset */
-+#define R_68K_GOT8O 12 /* 8 bit GOT offset */
-+#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
-+#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
-+#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
-+#define R_68K_PLT32O 16 /* 32 bit PLT offset */
-+#define R_68K_PLT16O 17 /* 16 bit PLT offset */
-+#define R_68K_PLT8O 18 /* 8 bit PLT offset */
-+#define R_68K_COPY 19 /* Copy symbol at runtime */
-+#define R_68K_GLOB_DAT 20 /* Create GOT entry */
-+#define R_68K_JMP_SLOT 21 /* Create PLT entry */
-+#define R_68K_RELATIVE 22 /* Adjust by program base */
-+/* Keep this the last entry. */
-+#define R_68K_NUM 23
-+
-+/* Intel 80386 specific definitions. */
-+
-+/* i386 relocs. */
-+
-+#define R_386_NONE 0 /* No reloc */
-+#define R_386_32 1 /* Direct 32 bit */
-+#define R_386_PC32 2 /* PC relative 32 bit */
-+#define R_386_GOT32 3 /* 32 bit GOT entry */
-+#define R_386_PLT32 4 /* 32 bit PLT address */
-+#define R_386_COPY 5 /* Copy symbol at runtime */
-+#define R_386_GLOB_DAT 6 /* Create GOT entry */
-+#define R_386_JMP_SLOT 7 /* Create PLT entry */
-+#define R_386_RELATIVE 8 /* Adjust by program base */
-+#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
-+#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
-+#define R_386_32PLT 11
-+#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
-+#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
-+ block offset */
-+#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
-+ offset */
-+#define R_386_TLS_LE 17 /* Offset relative to static TLS
-+ block */
-+#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
-+ general dynamic thread local data */
-+#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
-+ local dynamic thread local data
-+ in LE code */
-+#define R_386_16 20
-+#define R_386_PC16 21
-+#define R_386_8 22
-+#define R_386_PC8 23
-+#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
-+ thread local data */
-+#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
-+#define R_386_TLS_GD_CALL 26 /* Relocation for call to
-+ __tls_get_addr() */
-+#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
-+#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
-+ thread local data in LE code */
-+#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
-+#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
-+ __tls_get_addr() in LDM code */
-+#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
-+#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
-+#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
-+ block offset */
-+#define R_386_TLS_LE_32 34 /* Negated offset relative to static
-+ TLS block */
-+#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
-+#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
-+#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
-+/* Keep this the last entry. */
-+#define R_386_NUM 38
-+
-+/* SUN SPARC specific definitions. */
-+
-+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
-+
-+#define STT_REGISTER 13 /* Global register reserved to app. */
-+
-+/* Values for Elf64_Ehdr.e_flags. */
-+
-+#define EF_SPARCV9_MM 3
-+#define EF_SPARCV9_TSO 0
-+#define EF_SPARCV9_PSO 1
-+#define EF_SPARCV9_RMO 2
-+#define EF_SPARC_LEDATA 0x800000 /* little endian data */
-+#define EF_SPARC_EXT_MASK 0xFFFF00
-+#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
-+#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
-+#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
-+#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
-+
-+/* SPARC relocs. */
-+
-+#define R_SPARC_NONE 0 /* No reloc */
-+#define R_SPARC_8 1 /* Direct 8 bit */
-+#define R_SPARC_16 2 /* Direct 16 bit */
-+#define R_SPARC_32 3 /* Direct 32 bit */
-+#define R_SPARC_DISP8 4 /* PC relative 8 bit */
-+#define R_SPARC_DISP16 5 /* PC relative 16 bit */
-+#define R_SPARC_DISP32 6 /* PC relative 32 bit */
-+#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
-+#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
-+#define R_SPARC_HI22 9 /* High 22 bit */
-+#define R_SPARC_22 10 /* Direct 22 bit */
-+#define R_SPARC_13 11 /* Direct 13 bit */
-+#define R_SPARC_LO10 12 /* Truncated 10 bit */
-+#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
-+#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
-+#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
-+#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
-+#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
-+#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
-+#define R_SPARC_COPY 19 /* Copy symbol at runtime */
-+#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
-+#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
-+#define R_SPARC_RELATIVE 22 /* Adjust by program base */
-+#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
-+
-+/* Additional Sparc64 relocs. */
-+
-+#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
-+#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
-+#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
-+#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
-+#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
-+#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
-+#define R_SPARC_10 30 /* Direct 10 bit */
-+#define R_SPARC_11 31 /* Direct 11 bit */
-+#define R_SPARC_64 32 /* Direct 64 bit */
-+#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
-+#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
-+#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
-+#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
-+#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
-+#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
-+#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
-+#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
-+#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
-+#define R_SPARC_7 43 /* Direct 7 bit */
-+#define R_SPARC_5 44 /* Direct 5 bit */
-+#define R_SPARC_6 45 /* Direct 6 bit */
-+#define R_SPARC_DISP64 46 /* PC relative 64 bit */
-+#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
-+#define R_SPARC_HIX22 48 /* High 22 bit complemented */
-+#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
-+#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
-+#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
-+#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
-+#define R_SPARC_REGISTER 53 /* Global register usage */
-+#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
-+#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
-+#define R_SPARC_TLS_GD_HI22 56
-+#define R_SPARC_TLS_GD_LO10 57
-+#define R_SPARC_TLS_GD_ADD 58
-+#define R_SPARC_TLS_GD_CALL 59
-+#define R_SPARC_TLS_LDM_HI22 60
-+#define R_SPARC_TLS_LDM_LO10 61
-+#define R_SPARC_TLS_LDM_ADD 62
-+#define R_SPARC_TLS_LDM_CALL 63
-+#define R_SPARC_TLS_LDO_HIX22 64
-+#define R_SPARC_TLS_LDO_LOX10 65
-+#define R_SPARC_TLS_LDO_ADD 66
-+#define R_SPARC_TLS_IE_HI22 67
-+#define R_SPARC_TLS_IE_LO10 68
-+#define R_SPARC_TLS_IE_LD 69
-+#define R_SPARC_TLS_IE_LDX 70
-+#define R_SPARC_TLS_IE_ADD 71
-+#define R_SPARC_TLS_LE_HIX22 72
-+#define R_SPARC_TLS_LE_LOX10 73
-+#define R_SPARC_TLS_DTPMOD32 74
-+#define R_SPARC_TLS_DTPMOD64 75
-+#define R_SPARC_TLS_DTPOFF32 76
-+#define R_SPARC_TLS_DTPOFF64 77
-+#define R_SPARC_TLS_TPOFF32 78
-+#define R_SPARC_TLS_TPOFF64 79
-+/* Keep this the last entry. */
-+#define R_SPARC_NUM 80
-+
-+/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
-+
-+#define DT_SPARC_REGISTER 0x70000001
-+#define DT_SPARC_NUM 2
-+
-+/* Bits present in AT_HWCAP, primarily for Sparc32. */
-+
-+#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */
-+#define HWCAP_SPARC_STBAR 2
-+#define HWCAP_SPARC_SWAP 4
-+#define HWCAP_SPARC_MULDIV 8
-+#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */
-+#define HWCAP_SPARC_ULTRA3 32
-+
-+/* MIPS R3000 specific definitions. */
-+
-+/* Legal values for e_flags field of Elf32_Ehdr. */
-+
-+#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */
-+#define EF_MIPS_PIC 2 /* Contains PIC code */
-+#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */
-+#define EF_MIPS_XGOT 8
-+#define EF_MIPS_64BIT_WHIRL 16
-+#define EF_MIPS_ABI2 32
-+#define EF_MIPS_ABI_ON32 64
-+#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
-+
-+/* Legal values for MIPS architecture level. */
-+
-+#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
-+#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
-+#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
-+#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
-+#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
-+#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
-+#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
-+
-+/* The following are non-official names and should not be used. */
-+
-+#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
-+#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
-+#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
-+#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
-+#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
-+#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
-+#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
-+
-+/* Special section indices. */
-+
-+#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
-+#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
-+#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
-+#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
-+#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
-+
-+/* Legal values for sh_type field of Elf32_Shdr. */
-+
-+#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
-+#define SHT_MIPS_MSYM 0x70000001
-+#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
-+#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
-+#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
-+#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/
-+#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
-+#define SHT_MIPS_PACKAGE 0x70000007
-+#define SHT_MIPS_PACKSYM 0x70000008
-+#define SHT_MIPS_RELD 0x70000009
-+#define SHT_MIPS_IFACE 0x7000000b
-+#define SHT_MIPS_CONTENT 0x7000000c
-+#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
-+#define SHT_MIPS_SHDR 0x70000010
-+#define SHT_MIPS_FDESC 0x70000011
-+#define SHT_MIPS_EXTSYM 0x70000012
-+#define SHT_MIPS_DENSE 0x70000013
-+#define SHT_MIPS_PDESC 0x70000014
-+#define SHT_MIPS_LOCSYM 0x70000015
-+#define SHT_MIPS_AUXSYM 0x70000016
-+#define SHT_MIPS_OPTSYM 0x70000017
-+#define SHT_MIPS_LOCSTR 0x70000018
-+#define SHT_MIPS_LINE 0x70000019
-+#define SHT_MIPS_RFDESC 0x7000001a
-+#define SHT_MIPS_DELTASYM 0x7000001b
-+#define SHT_MIPS_DELTAINST 0x7000001c
-+#define SHT_MIPS_DELTACLASS 0x7000001d
-+#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
-+#define SHT_MIPS_DELTADECL 0x7000001f
-+#define SHT_MIPS_SYMBOL_LIB 0x70000020
-+#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
-+#define SHT_MIPS_TRANSLATE 0x70000022
-+#define SHT_MIPS_PIXIE 0x70000023
-+#define SHT_MIPS_XLATE 0x70000024
-+#define SHT_MIPS_XLATE_DEBUG 0x70000025
-+#define SHT_MIPS_WHIRL 0x70000026
-+#define SHT_MIPS_EH_REGION 0x70000027
-+#define SHT_MIPS_XLATE_OLD 0x70000028
-+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
-+
-+/* Legal values for sh_flags field of Elf32_Shdr. */
-+
-+#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
-+#define SHF_MIPS_MERGE 0x20000000
-+#define SHF_MIPS_ADDR 0x40000000
-+#define SHF_MIPS_STRINGS 0x80000000
-+#define SHF_MIPS_NOSTRIP 0x08000000
-+#define SHF_MIPS_LOCAL 0x04000000
-+#define SHF_MIPS_NAMES 0x02000000
-+#define SHF_MIPS_NODUPE 0x01000000
-+
-+
-+/* Symbol tables. */
-+
-+/* MIPS specific values for `st_other'. */
-+#define STO_MIPS_DEFAULT 0x0
-+#define STO_MIPS_INTERNAL 0x1
-+#define STO_MIPS_HIDDEN 0x2
-+#define STO_MIPS_PROTECTED 0x3
-+#define STO_MIPS_SC_ALIGN_UNUSED 0xff
-+
-+/* MIPS specific values for `st_info'. */
-+#define STB_MIPS_SPLIT_COMMON 13
-+
-+/* Entries found in sections of type SHT_MIPS_GPTAB. */
-+
-+typedef union
-+{
-+ struct
-+ {
-+ Elf32_Word gt_current_g_value; /* -G value used for compilation */
-+ Elf32_Word gt_unused; /* Not used */
-+ } gt_header; /* First entry in section */
-+ struct
-+ {
-+ Elf32_Word gt_g_value; /* If this value were used for -G */
-+ Elf32_Word gt_bytes; /* This many bytes would be used */
-+ } gt_entry; /* Subsequent entries in section */
-+} Elf32_gptab;
-+
-+/* Entry found in sections of type SHT_MIPS_REGINFO. */
-+
-+typedef struct
-+{
-+ Elf32_Word ri_gprmask; /* General registers used */
-+ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
-+ Elf32_Sword ri_gp_value; /* $gp register value */
-+} Elf32_RegInfo;
-+
-+/* Entries found in sections of type SHT_MIPS_OPTIONS. */
-+
-+typedef struct
-+{
-+ unsigned char kind; /* Determines interpretation of the
-+ variable part of descriptor. */
-+ unsigned char size; /* Size of descriptor, including header. */
-+ Elf32_Section section; /* Section header index of section affected,
-+ 0 for global options. */
-+ Elf32_Word info; /* Kind-specific information. */
-+} Elf_Options;
-+
-+/* Values for `kind' field in Elf_Options. */
-+
-+#define ODK_NULL 0 /* Undefined. */
-+#define ODK_REGINFO 1 /* Register usage information. */
-+#define ODK_EXCEPTIONS 2 /* Exception processing options. */
-+#define ODK_PAD 3 /* Section padding options. */
-+#define ODK_HWPATCH 4 /* Hardware workarounds performed */
-+#define ODK_FILL 5 /* record the fill value used by the linker. */
-+#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
-+#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
-+#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
-+
-+/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
-+
-+#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
-+#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
-+#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
-+#define OEX_SMM 0x20000 /* Force sequential memory mode? */
-+#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
-+#define OEX_PRECISEFP OEX_FPDBUG
-+#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
-+
-+#define OEX_FPU_INVAL 0x10
-+#define OEX_FPU_DIV0 0x08
-+#define OEX_FPU_OFLO 0x04
-+#define OEX_FPU_UFLO 0x02
-+#define OEX_FPU_INEX 0x01
-+
-+/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
-+
-+#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
-+#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
-+#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
-+#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
-+
-+#define OPAD_PREFIX 0x1
-+#define OPAD_POSTFIX 0x2
-+#define OPAD_SYMBOL 0x4
-+
-+/* Entry found in `.options' section. */
-+
-+typedef struct
-+{
-+ Elf32_Word hwp_flags1; /* Extra flags. */
-+ Elf32_Word hwp_flags2; /* Extra flags. */
-+} Elf_Options_Hw;
-+
-+/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
-+
-+#define OHWA0_R4KEOP_CHECKED 0x00000001
-+#define OHWA1_R4KEOP_CLEAN 0x00000002
-+
-+/* MIPS relocs. */
-+
-+#define R_MIPS_NONE 0 /* No reloc */
-+#define R_MIPS_16 1 /* Direct 16 bit */
-+#define R_MIPS_32 2 /* Direct 32 bit */
-+#define R_MIPS_REL32 3 /* PC relative 32 bit */
-+#define R_MIPS_26 4 /* Direct 26 bit shifted */
-+#define R_MIPS_HI16 5 /* High 16 bit */
-+#define R_MIPS_LO16 6 /* Low 16 bit */
-+#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
-+#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
-+#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
-+#define R_MIPS_PC16 10 /* PC relative 16 bit */
-+#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
-+#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
-+
-+#define R_MIPS_SHIFT5 16
-+#define R_MIPS_SHIFT6 17
-+#define R_MIPS_64 18
-+#define R_MIPS_GOT_DISP 19
-+#define R_MIPS_GOT_PAGE 20
-+#define R_MIPS_GOT_OFST 21
-+#define R_MIPS_GOT_HI16 22
-+#define R_MIPS_GOT_LO16 23
-+#define R_MIPS_SUB 24
-+#define R_MIPS_INSERT_A 25
-+#define R_MIPS_INSERT_B 26
-+#define R_MIPS_DELETE 27
-+#define R_MIPS_HIGHER 28
-+#define R_MIPS_HIGHEST 29
-+#define R_MIPS_CALL_HI16 30
-+#define R_MIPS_CALL_LO16 31
-+#define R_MIPS_SCN_DISP 32
-+#define R_MIPS_REL16 33
-+#define R_MIPS_ADD_IMMEDIATE 34
-+#define R_MIPS_PJUMP 35
-+#define R_MIPS_RELGOT 36
-+#define R_MIPS_JALR 37
-+/* Keep this the last entry. */
-+#define R_MIPS_NUM 38
-+
-+/* Legal values for p_type field of Elf32_Phdr. */
-+
-+#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
-+#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
-+#define PT_MIPS_OPTIONS 0x70000002
-+
-+/* Special program header types. */
-+
-+#define PF_MIPS_LOCAL 0x10000000
-+
-+/* Legal values for d_tag field of Elf32_Dyn. */
-+
-+#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
-+#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
-+#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
-+#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
-+#define DT_MIPS_FLAGS 0x70000005 /* Flags */
-+#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
-+#define DT_MIPS_MSYM 0x70000007
-+#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
-+#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
-+#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
-+#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
-+#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
-+#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
-+#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
-+#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
-+#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
-+#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
-+#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
-+#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
-+ DT_MIPS_DELTA_CLASS. */
-+#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
-+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
-+ DT_MIPS_DELTA_INSTANCE. */
-+#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
-+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
-+ DT_MIPS_DELTA_RELOC. */
-+#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
-+ relocations refer to. */
-+#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
-+ DT_MIPS_DELTA_SYM. */
-+#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
-+ class declaration. */
-+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
-+ DT_MIPS_DELTA_CLASSSYM. */
-+#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
-+#define DT_MIPS_PIXIE_INIT 0x70000023
-+#define DT_MIPS_SYMBOL_LIB 0x70000024
-+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
-+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
-+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
-+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
-+#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
-+#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
-+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
-+#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
-+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
-+ function stored in GOT. */
-+#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
-+ by rld on dlopen() calls. */
-+#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
-+#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
-+#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
-+#define DT_MIPS_NUM 0x32
-+
-+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
-+
-+#define RHF_NONE 0 /* No flags */
-+#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
-+#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
-+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
-+#define RHF_NO_MOVE (1 << 3)
-+#define RHF_SGI_ONLY (1 << 4)
-+#define RHF_GUARANTEE_INIT (1 << 5)
-+#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
-+#define RHF_GUARANTEE_START_INIT (1 << 7)
-+#define RHF_PIXIE (1 << 8)
-+#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
-+#define RHF_REQUICKSTART (1 << 10)
-+#define RHF_REQUICKSTARTED (1 << 11)
-+#define RHF_CORD (1 << 12)
-+#define RHF_NO_UNRES_UNDEF (1 << 13)
-+#define RHF_RLD_ORDER_SAFE (1 << 14)
-+
-+/* Entries found in sections of type SHT_MIPS_LIBLIST. */
-+
-+typedef struct
-+{
-+ Elf32_Word l_name; /* Name (string table index) */
-+ Elf32_Word l_time_stamp; /* Timestamp */
-+ Elf32_Word l_checksum; /* Checksum */
-+ Elf32_Word l_version; /* Interface version */
-+ Elf32_Word l_flags; /* Flags */
-+} Elf32_Lib;
-+
-+typedef struct
-+{
-+ Elf64_Word l_name; /* Name (string table index) */
-+ Elf64_Word l_time_stamp; /* Timestamp */
-+ Elf64_Word l_checksum; /* Checksum */
-+ Elf64_Word l_version; /* Interface version */
-+ Elf64_Word l_flags; /* Flags */
-+} Elf64_Lib;
-+
-+
-+/* Legal values for l_flags. */
-+
-+#define LL_NONE 0
-+#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
-+#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
-+#define LL_REQUIRE_MINOR (1 << 2)
-+#define LL_EXPORTS (1 << 3)
-+#define LL_DELAY_LOAD (1 << 4)
-+#define LL_DELTA (1 << 5)
-+
-+/* Entries found in sections of type SHT_MIPS_CONFLICT. */
-+
-+typedef Elf32_Addr Elf32_Conflict;
-+
-+
-+/* HPPA specific definitions. */
-+
-+/* Legal values for e_flags field of Elf32_Ehdr. */
-+
-+#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
-+#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
-+#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
-+#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
-+#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
-+ prediction. */
-+#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
-+#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
-+
-+/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
-+
-+#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
-+#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
-+#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
-+
-+/* Additional section indeces. */
-+
-+#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
-+ symbols in ANSI C. */
-+#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
-+
-+/* Legal values for sh_type field of Elf32_Shdr. */
-+
-+#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
-+#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
-+#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
-+
-+/* Legal values for sh_flags field of Elf32_Shdr. */
-+
-+#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
-+#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
-+#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
-+
-+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
-+
-+#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
-+
-+#define STT_HP_OPAQUE (STT_LOOS + 0x1)
-+#define STT_HP_STUB (STT_LOOS + 0x2)
-+
-+/* HPPA relocs. */
-+
-+#define R_PARISC_NONE 0 /* No reloc. */
-+#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
-+#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
-+#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
-+#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
-+#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
-+#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
-+#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
-+#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
-+#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
-+#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
-+#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
-+#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
-+#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
-+#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
-+#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
-+#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
-+#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
-+#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
-+#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
-+#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
-+#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
-+#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
-+#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
-+#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
-+#define R_PARISC_FPTR64 64 /* 64 bits function address. */
-+#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
-+#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
-+#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
-+#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
-+#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
-+#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
-+#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
-+#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
-+#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
-+#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
-+#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
-+#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
-+#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
-+#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
-+#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
-+#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
-+#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
-+#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
-+#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
-+#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
-+#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
-+#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
-+#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
-+#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
-+#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
-+#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
-+#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
-+#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
-+#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
-+#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
-+#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
-+#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
-+#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
-+#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
-+#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
-+#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
-+#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
-+#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
-+#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
-+#define R_PARISC_LORESERVE 128
-+#define R_PARISC_COPY 128 /* Copy relocation. */
-+#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
-+#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
-+#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
-+#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
-+#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
-+#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
-+#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
-+#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
-+#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
-+#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
-+#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
-+#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
-+#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
-+#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
-+#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
-+#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
-+#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
-+#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
-+#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
-+#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
-+#define R_PARISC_HIRESERVE 255
-+
-+/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
-+
-+#define PT_HP_TLS (PT_LOOS + 0x0)
-+#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
-+#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
-+#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
-+#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
-+#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
-+#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
-+#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
-+#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
-+#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
-+#define PT_HP_PARALLEL (PT_LOOS + 0x10)
-+#define PT_HP_FASTBIND (PT_LOOS + 0x11)
-+#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
-+#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
-+#define PT_HP_STACK (PT_LOOS + 0x14)
-+
-+#define PT_PARISC_ARCHEXT 0x70000000
-+#define PT_PARISC_UNWIND 0x70000001
-+
-+/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
-+
-+#define PF_PARISC_SBP 0x08000000
-+
-+#define PF_HP_PAGE_SIZE 0x00100000
-+#define PF_HP_FAR_SHARED 0x00200000
-+#define PF_HP_NEAR_SHARED 0x00400000
-+#define PF_HP_CODE 0x01000000
-+#define PF_HP_MODIFY 0x02000000
-+#define PF_HP_LAZYSWAP 0x04000000
-+#define PF_HP_SBP 0x08000000
-+
-+
-+/* Alpha specific definitions. */
-+
-+/* Legal values for e_flags field of Elf64_Ehdr. */
-+
-+#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
-+#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
-+
-+/* Legal values for sh_type field of Elf64_Shdr. */
-+
-+/* These two are primerily concerned with ECOFF debugging info. */
-+#define SHT_ALPHA_DEBUG 0x70000001
-+#define SHT_ALPHA_REGINFO 0x70000002
-+
-+/* Legal values for sh_flags field of Elf64_Shdr. */
-+
-+#define SHF_ALPHA_GPREL 0x10000000
-+
-+/* Legal values for st_other field of Elf64_Sym. */
-+#define STO_ALPHA_NOPV 0x80 /* No PV required. */
-+#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
-+
-+/* Alpha relocs. */
-+
-+#define R_ALPHA_NONE 0 /* No reloc */
-+#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
-+#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
-+#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
-+#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
-+#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
-+#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
-+#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
-+#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
-+#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
-+#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
-+#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
-+#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
-+#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
-+#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
-+#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
-+#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
-+#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
-+#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
-+#define R_ALPHA_TLS_GD_HI 28
-+#define R_ALPHA_TLSGD 29
-+#define R_ALPHA_TLS_LDM 30
-+#define R_ALPHA_DTPMOD64 31
-+#define R_ALPHA_GOTDTPREL 32
-+#define R_ALPHA_DTPREL64 33
-+#define R_ALPHA_DTPRELHI 34
-+#define R_ALPHA_DTPRELLO 35
-+#define R_ALPHA_DTPREL16 36
-+#define R_ALPHA_GOTTPREL 37
-+#define R_ALPHA_TPREL64 38
-+#define R_ALPHA_TPRELHI 39
-+#define R_ALPHA_TPRELLO 40
-+#define R_ALPHA_TPREL16 41
-+/* Keep this the last entry. */
-+#define R_ALPHA_NUM 46
-+
-+/* Magic values of the LITUSE relocation addend. */
-+#define LITUSE_ALPHA_ADDR 0
-+#define LITUSE_ALPHA_BASE 1
-+#define LITUSE_ALPHA_BYTOFF 2
-+#define LITUSE_ALPHA_JSR 3
-+#define LITUSE_ALPHA_TLS_GD 4
-+#define LITUSE_ALPHA_TLS_LDM 5
-+
-+
-+/* PowerPC specific declarations */
-+
-+/* Values for Elf32/64_Ehdr.e_flags. */
-+#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
-+
-+/* Cygnus local bits below */
-+#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
-+#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
-+ flag */
-+
-+/* PowerPC relocations defined by the ABIs */
-+#define R_PPC_NONE 0
-+#define R_PPC_ADDR32 1 /* 32bit absolute address */
-+#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
-+#define R_PPC_ADDR16 3 /* 16bit absolute address */
-+#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
-+#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
-+#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
-+#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
-+#define R_PPC_ADDR14_BRTAKEN 8
-+#define R_PPC_ADDR14_BRNTAKEN 9
-+#define R_PPC_REL24 10 /* PC relative 26 bit */
-+#define R_PPC_REL14 11 /* PC relative 16 bit */
-+#define R_PPC_REL14_BRTAKEN 12
-+#define R_PPC_REL14_BRNTAKEN 13
-+#define R_PPC_GOT16 14
-+#define R_PPC_GOT16_LO 15
-+#define R_PPC_GOT16_HI 16
-+#define R_PPC_GOT16_HA 17
-+#define R_PPC_PLTREL24 18
-+#define R_PPC_COPY 19
-+#define R_PPC_GLOB_DAT 20
-+#define R_PPC_JMP_SLOT 21
-+#define R_PPC_RELATIVE 22
-+#define R_PPC_LOCAL24PC 23
-+#define R_PPC_UADDR32 24
-+#define R_PPC_UADDR16 25
-+#define R_PPC_REL32 26
-+#define R_PPC_PLT32 27
-+#define R_PPC_PLTREL32 28
-+#define R_PPC_PLT16_LO 29
-+#define R_PPC_PLT16_HI 30
-+#define R_PPC_PLT16_HA 31
-+#define R_PPC_SDAREL16 32
-+#define R_PPC_SECTOFF 33
-+#define R_PPC_SECTOFF_LO 34
-+#define R_PPC_SECTOFF_HI 35
-+#define R_PPC_SECTOFF_HA 36
-+
-+/* PowerPC relocations defined for the TLS access ABI. */
-+#define R_PPC_TLS 67 /* none (sym+add)@tls */
-+#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
-+#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
-+#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
-+#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
-+#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
-+#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
-+#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
-+#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
-+#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
-+#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
-+#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
-+#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
-+#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
-+#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
-+#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
-+#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
-+#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
-+#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
-+#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
-+#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
-+#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
-+#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
-+#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
-+#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
-+#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
-+#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
-+#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
-+
-+/* Keep this the last entry. */
-+#define R_PPC_NUM 95
-+
-+/* The remaining relocs are from the Embedded ELF ABI, and are not
-+ in the SVR4 ELF ABI. */
-+#define R_PPC_EMB_NADDR32 101
-+#define R_PPC_EMB_NADDR16 102
-+#define R_PPC_EMB_NADDR16_LO 103
-+#define R_PPC_EMB_NADDR16_HI 104
-+#define R_PPC_EMB_NADDR16_HA 105
-+#define R_PPC_EMB_SDAI16 106
-+#define R_PPC_EMB_SDA2I16 107
-+#define R_PPC_EMB_SDA2REL 108
-+#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
-+#define R_PPC_EMB_MRKREF 110
-+#define R_PPC_EMB_RELSEC16 111
-+#define R_PPC_EMB_RELST_LO 112
-+#define R_PPC_EMB_RELST_HI 113
-+#define R_PPC_EMB_RELST_HA 114
-+#define R_PPC_EMB_BIT_FLD 115
-+#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
-+
-+/* Diab tool relocations. */
-+#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
-+#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
-+#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
-+#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
-+#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
-+#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
-+
-+/* This is a phony reloc to handle any old fashioned TOC16 references
-+ that may still be in object files. */
-+#define R_PPC_TOC16 255
-+
-+
-+/* PowerPC64 relocations defined by the ABIs */
-+#define R_PPC64_NONE R_PPC_NONE
-+#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */
-+#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */
-+#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */
-+#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */
-+#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */
-+#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
-+#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */
-+#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
-+#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
-+#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
-+#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */
-+#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
-+#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
-+#define R_PPC64_GOT16 R_PPC_GOT16
-+#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
-+#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
-+#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
-+
-+#define R_PPC64_COPY R_PPC_COPY
-+#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
-+#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
-+#define R_PPC64_RELATIVE R_PPC_RELATIVE
-+
-+#define R_PPC64_UADDR32 R_PPC_UADDR32
-+#define R_PPC64_UADDR16 R_PPC_UADDR16
-+#define R_PPC64_REL32 R_PPC_REL32
-+#define R_PPC64_PLT32 R_PPC_PLT32
-+#define R_PPC64_PLTREL32 R_PPC_PLTREL32
-+#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
-+#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
-+#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
-+
-+#define R_PPC64_SECTOFF R_PPC_SECTOFF
-+#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
-+#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
-+#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
-+#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */
-+#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
-+#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */
-+#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
-+#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
-+#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */
-+#define R_PPC64_UADDR64 43 /* doubleword64 S + A */
-+#define R_PPC64_REL64 44 /* doubleword64 S + A - P */
-+#define R_PPC64_PLT64 45 /* doubleword64 L + A */
-+#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */
-+#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */
-+#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */
-+#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */
-+#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */
-+#define R_PPC64_TOC 51 /* doubleword64 .TOC */
-+#define R_PPC64_PLTGOT16 52 /* half16* M + A */
-+#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */
-+#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */
-+#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */
-+
-+#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */
-+#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */
-+#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */
-+#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */
-+#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */
-+#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */
-+#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */
-+#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */
-+#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */
-+#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */
-+#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */
-+
-+/* PowerPC64 relocations defined for the TLS access ABI. */
-+#define R_PPC64_TLS 67 /* none (sym+add)@tls */
-+#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
-+#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
-+#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
-+#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
-+#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
-+#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
-+#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
-+#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
-+#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
-+#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
-+#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
-+#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
-+#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
-+#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
-+#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
-+#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
-+#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
-+#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
-+#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
-+#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
-+#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
-+#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
-+#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
-+#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
-+#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
-+#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
-+#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
-+#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
-+#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
-+#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
-+#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
-+#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
-+#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
-+#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
-+#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
-+#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
-+#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
-+#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
-+#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
-+
-+/* Keep this the last entry. */
-+#define R_PPC64_NUM 107
-+
-+/* PowerPC64 specific values for the Dyn d_tag field. */
-+#define DT_PPC64_GLINK (DT_LOPROC + 0)
-+#define DT_PPC64_NUM 1
-+
-+
-+/* ARM specific declarations */
-+
-+/* Processor specific flags for the ELF header e_flags field. */
-+#define EF_ARM_RELEXEC 0x01
-+#define EF_ARM_HASENTRY 0x02
-+#define EF_ARM_INTERWORK 0x04
-+#define EF_ARM_APCS_26 0x08
-+#define EF_ARM_APCS_FLOAT 0x10
-+#define EF_ARM_PIC 0x20
-+#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
-+#define EF_ARM_NEW_ABI 0x80
-+#define EF_ARM_OLD_ABI 0x100
-+
-+/* Other constants defined in the ARM ELF spec. version B-01. */
-+/* NB. These conflict with values defined above. */
-+#define EF_ARM_SYMSARESORTED 0x04
-+#define EF_ARM_DYNSYMSUSESEGIDX 0x08
-+#define EF_ARM_MAPSYMSFIRST 0x10
-+#define EF_ARM_EABIMASK 0XFF000000
-+
-+#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
-+#define EF_ARM_EABI_UNKNOWN 0x00000000
-+#define EF_ARM_EABI_VER1 0x01000000
-+#define EF_ARM_EABI_VER2 0x02000000
-+
-+/* Additional symbol types for Thumb */
-+#define STT_ARM_TFUNC 0xd
-+
-+/* ARM-specific values for sh_flags */
-+#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
-+#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
-+ in the input to a link step */
-+
-+/* ARM-specific program header flags */
-+#define PF_ARM_SB 0x10000000 /* Segment contains the location
-+ addressed by the static base */
-+
-+/* ARM relocs. */
-+#define R_ARM_NONE 0 /* No reloc */
-+#define R_ARM_PC24 1 /* PC relative 26 bit branch */
-+#define R_ARM_ABS32 2 /* Direct 32 bit */
-+#define R_ARM_REL32 3 /* PC relative 32 bit */
-+#define R_ARM_PC13 4
-+#define R_ARM_ABS16 5 /* Direct 16 bit */
-+#define R_ARM_ABS12 6 /* Direct 12 bit */
-+#define R_ARM_THM_ABS5 7
-+#define R_ARM_ABS8 8 /* Direct 8 bit */
-+#define R_ARM_SBREL32 9
-+#define R_ARM_THM_PC22 10
-+#define R_ARM_THM_PC8 11
-+#define R_ARM_AMP_VCALL9 12
-+#define R_ARM_SWI24 13
-+#define R_ARM_THM_SWI8 14
-+#define R_ARM_XPC25 15
-+#define R_ARM_THM_XPC22 16
-+#define R_ARM_COPY 20 /* Copy symbol at runtime */
-+#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
-+#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
-+#define R_ARM_RELATIVE 23 /* Adjust by program base */
-+#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
-+#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
-+#define R_ARM_GOT32 26 /* 32 bit GOT entry */
-+#define R_ARM_PLT32 27 /* 32 bit PLT address */
-+#define R_ARM_ALU_PCREL_7_0 32
-+#define R_ARM_ALU_PCREL_15_8 33
-+#define R_ARM_ALU_PCREL_23_15 34
-+#define R_ARM_LDR_SBREL_11_0 35
-+#define R_ARM_ALU_SBREL_19_12 36
-+#define R_ARM_ALU_SBREL_27_20 37
-+#define R_ARM_GNU_VTENTRY 100
-+#define R_ARM_GNU_VTINHERIT 101
-+#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
-+#define R_ARM_THM_PC9 103 /* thumb conditional branch */
-+#define R_ARM_RXPC25 249
-+#define R_ARM_RSBREL32 250
-+#define R_ARM_THM_RPC22 251
-+#define R_ARM_RREL32 252
-+#define R_ARM_RABS22 253
-+#define R_ARM_RPC24 254
-+#define R_ARM_RBASE 255
-+/* Keep this the last entry. */
-+#define R_ARM_NUM 256
-+
-+/* IA-64 specific declarations. */
-+
-+/* Processor specific flags for the Ehdr e_flags field. */
-+#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
-+#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
-+#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
-+
-+/* Processor specific values for the Phdr p_type field. */
-+#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
-+#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
-+
-+/* Processor specific flags for the Phdr p_flags field. */
-+#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
-+
-+/* Processor specific values for the Shdr sh_type field. */
-+#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
-+#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
-+
-+/* Processor specific flags for the Shdr sh_flags field. */
-+#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
-+#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
-+
-+/* Processor specific values for the Dyn d_tag field. */
-+#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
-+#define DT_IA_64_NUM 1
-+
-+/* IA-64 relocations. */
-+#define R_IA64_NONE 0x00 /* none */
-+#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
-+#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
-+#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
-+#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
-+#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
-+#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
-+#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
-+#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
-+#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
-+#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
-+#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
-+#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
-+#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
-+#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
-+#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
-+#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
-+#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
-+#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
-+#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
-+#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
-+#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
-+#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
-+#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
-+#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
-+#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
-+#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
-+#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
-+#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
-+#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
-+#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
-+#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
-+#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
-+#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
-+#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
-+#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
-+#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
-+#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
-+#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
-+#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
-+#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
-+#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
-+#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
-+#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
-+#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
-+#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
-+#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
-+#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
-+#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
-+#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
-+#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
-+#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
-+#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
-+#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
-+#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
-+#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
-+#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
-+#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
-+#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
-+#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
-+#define R_IA64_COPY 0x84 /* copy relocation */
-+#define R_IA64_SUB 0x85 /* Addend and symbol difference */
-+#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
-+#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
-+#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
-+#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
-+#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
-+#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
-+#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
-+#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
-+#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
-+#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
-+#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
-+#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
-+#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
-+#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
-+#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
-+#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
-+#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
-+#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
-+#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
-+
-+/* SH specific declarations */
-+
-+/* SH relocs. */
-+#define R_SH_NONE 0
-+#define R_SH_DIR32 1
-+#define R_SH_REL32 2
-+#define R_SH_DIR8WPN 3
-+#define R_SH_IND12W 4
-+#define R_SH_DIR8WPL 5
-+#define R_SH_DIR8WPZ 6
-+#define R_SH_DIR8BP 7
-+#define R_SH_DIR8W 8
-+#define R_SH_DIR8L 9
-+#define R_SH_SWITCH16 25
-+#define R_SH_SWITCH32 26
-+#define R_SH_USES 27
-+#define R_SH_COUNT 28
-+#define R_SH_ALIGN 29
-+#define R_SH_CODE 30
-+#define R_SH_DATA 31
-+#define R_SH_LABEL 32
-+#define R_SH_SWITCH8 33
-+#define R_SH_GNU_VTINHERIT 34
-+#define R_SH_GNU_VTENTRY 35
-+#define R_SH_TLS_GD_32 144
-+#define R_SH_TLS_LD_32 145
-+#define R_SH_TLS_LDO_32 146
-+#define R_SH_TLS_IE_32 147
-+#define R_SH_TLS_LE_32 148
-+#define R_SH_TLS_DTPMOD32 149
-+#define R_SH_TLS_DTPOFF32 150
-+#define R_SH_TLS_TPOFF32 151
-+#define R_SH_GOT32 160
-+#define R_SH_PLT32 161
-+#define R_SH_COPY 162
-+#define R_SH_GLOB_DAT 163
-+#define R_SH_JMP_SLOT 164
-+#define R_SH_RELATIVE 165
-+#define R_SH_GOTOFF 166
-+#define R_SH_GOTPC 167
-+/* Keep this the last entry. */
-+#define R_SH_NUM 256
-+
-+/* Additional s390 relocs */
-+
-+#define R_390_NONE 0 /* No reloc. */
-+#define R_390_8 1 /* Direct 8 bit. */
-+#define R_390_12 2 /* Direct 12 bit. */
-+#define R_390_16 3 /* Direct 16 bit. */
-+#define R_390_32 4 /* Direct 32 bit. */
-+#define R_390_PC32 5 /* PC relative 32 bit. */
-+#define R_390_GOT12 6 /* 12 bit GOT offset. */
-+#define R_390_GOT32 7 /* 32 bit GOT offset. */
-+#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
-+#define R_390_COPY 9 /* Copy symbol at runtime. */
-+#define R_390_GLOB_DAT 10 /* Create GOT entry. */
-+#define R_390_JMP_SLOT 11 /* Create PLT entry. */
-+#define R_390_RELATIVE 12 /* Adjust by program base. */
-+#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */
-+#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
-+#define R_390_GOT16 15 /* 16 bit GOT offset. */
-+#define R_390_PC16 16 /* PC relative 16 bit. */
-+#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
-+#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
-+#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
-+#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
-+#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
-+#define R_390_64 22 /* Direct 64 bit. */
-+#define R_390_PC64 23 /* PC relative 64 bit. */
-+#define R_390_GOT64 24 /* 64 bit GOT offset. */
-+#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
-+#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
-+#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */
-+#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */
-+#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */
-+#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */
-+#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */
-+#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */
-+#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */
-+#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */
-+#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */
-+#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */
-+#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */
-+#define R_390_TLS_GDCALL 38 /* Tag for function call in general
-+ dynamic TLS code. */
-+#define R_390_TLS_LDCALL 39 /* Tag for function call in local
-+ dynamic TLS code. */
-+#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic
-+ thread local data. */
-+#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic
-+ thread local data. */
-+#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS
-+ block offset. */
-+#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS
-+ block offset. */
-+#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS
-+ block offset. */
-+#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic
-+ thread local data in LE code. */
-+#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic
-+ thread local data in LE code. */
-+#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for
-+ negated static TLS block offset. */
-+#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for
-+ negated static TLS block offset. */
-+#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for
-+ negated static TLS block offset. */
-+#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to
-+ static TLS block. */
-+#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to
-+ static TLS block. */
-+#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS
-+ block. */
-+#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS
-+ block. */
-+#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */
-+#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */
-+#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS
-+ block. */
-+
-+/* Keep this the last entry. */
-+#define R_390_NUM 57
-+
-+/* CRIS relocations. */
-+#define R_CRIS_NONE 0
-+#define R_CRIS_8 1
-+#define R_CRIS_16 2
-+#define R_CRIS_32 3
-+#define R_CRIS_8_PCREL 4
-+#define R_CRIS_16_PCREL 5
-+#define R_CRIS_32_PCREL 6
-+#define R_CRIS_GNU_VTINHERIT 7
-+#define R_CRIS_GNU_VTENTRY 8
-+#define R_CRIS_COPY 9
-+#define R_CRIS_GLOB_DAT 10
-+#define R_CRIS_JUMP_SLOT 11
-+#define R_CRIS_RELATIVE 12
-+#define R_CRIS_16_GOT 13
-+#define R_CRIS_32_GOT 14
-+#define R_CRIS_16_GOTPLT 15
-+#define R_CRIS_32_GOTPLT 16
-+#define R_CRIS_32_GOTREL 17
-+#define R_CRIS_32_PLT_GOTREL 18
-+#define R_CRIS_32_PLT_PCREL 19
-+
-+#define R_CRIS_NUM 20
-+
-+/* AMD x86-64 relocations. */
-+#define R_X86_64_NONE 0 /* No reloc */
-+#define R_X86_64_64 1 /* Direct 64 bit */
-+#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
-+#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
-+#define R_X86_64_PLT32 4 /* 32 bit PLT address */
-+#define R_X86_64_COPY 5 /* Copy symbol at runtime */
-+#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
-+#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
-+#define R_X86_64_RELATIVE 8 /* Adjust by program base */
-+#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
-+ offset to GOT */
-+#define R_X86_64_32 10 /* Direct 32 bit zero extended */
-+#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
-+#define R_X86_64_16 12 /* Direct 16 bit zero extended */
-+#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
-+#define R_X86_64_8 14 /* Direct 8 bit sign extended */
-+#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
-+#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
-+#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
-+#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
-+#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
-+ to two GOT entries for GD symbol */
-+#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
-+ to two GOT entries for LD symbol */
-+#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
-+#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
-+ to GOT entry for IE symbol */
-+#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
-+
-+#define R_X86_64_NUM 24
-+
-+__END_DECLS
-+
-+#endif /* elf.h */
-
- #include "elfconfig.h"
-
-@@ -185,3 +2631,4 @@
- void fatal(const char *fmt, ...);
- void warn(const char *fmt, ...);
- void merror(const char *fmt, ...);
-+
-diff -Nur linux-3.11.5.orig/scripts/mod/sumversion.c linux-3.11.5/scripts/mod/sumversion.c
---- linux-3.11.5.orig/scripts/mod/sumversion.c 2013-10-14 03:14:45.000000000 +0200
-+++ linux-3.11.5/scripts/mod/sumversion.c 2013-10-16 18:09:31.000000000 +0200
-@@ -1,4 +1,4 @@
--#include <netinet/in.h>
-+/* #include <netinet/in.h> */
- #ifdef __sun__
- #include <inttypes.h>
- #else
-diff -Nur linux-3.11.5.orig/tools/include/tools/linux_types.h linux-3.11.5/tools/include/tools/linux_types.h
---- linux-3.11.5.orig/tools/include/tools/linux_types.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux-3.11.5/tools/include/tools/linux_types.h 2013-10-16 18:09:31.000000000 +0200
-@@ -0,0 +1,22 @@
-+#ifndef __LINUX_TYPES_H
-+#define __LINUX_TYPES_H
-+
-+#include <stdint.h>
-+
-+typedef uint8_t __u8;
-+typedef uint8_t __be8;
-+typedef uint8_t __le8;
-+
-+typedef uint16_t __u16;
-+typedef uint16_t __be16;
-+typedef uint16_t __le16;
-+
-+typedef uint32_t __u32;
-+typedef uint32_t __be32;
-+typedef uint32_t __le32;
-+
-+typedef uint64_t __u64;
-+typedef uint64_t __be64;
-+typedef uint64_t __le64;
-+
-+#endif
diff --git a/target/linux/patches/3.10.107/headers-install.patch b/target/linux/patches/3.10.107/headers-install.patch
deleted file mode 100644
index 46dc9fe..0000000
--- a/target/linux/patches/3.10.107/headers-install.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Nur linux-3.10.37.orig/scripts/Makefile.headersinst linux-3.10.37/scripts/Makefile.headersinst
---- linux-3.10.37.orig/scripts/Makefile.headersinst 2014-04-14 15:42:31.000000000 +0200
-+++ linux-3.10.37/scripts/Makefile.headersinst 2014-04-24 17:04:51.980248954 +0200
-@@ -107,7 +107,6 @@
-
- targets += $(install-file)
- $(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE
-- $(if $(unwanted),$(call cmd,remove),)
- $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
- $(call if_changed,install)
-
diff --git a/target/linux/patches/3.10.107/sgidefs.patch b/target/linux/patches/3.10.107/sgidefs.patch
deleted file mode 100644
index f00a284..0000000
--- a/target/linux/patches/3.10.107/sgidefs.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -Nur linux-3.11.5.orig/arch/mips/include/uapi/asm/sgidefs.h linux-3.11.5/arch/mips/include/uapi/asm/sgidefs.h
---- linux-3.11.5.orig/arch/mips/include/uapi/asm/sgidefs.h 2013-10-14 03:14:45.000000000 +0200
-+++ linux-3.11.5/arch/mips/include/uapi/asm/sgidefs.h 2013-11-08 22:01:28.000000000 +0100
-@@ -11,14 +11,6 @@
- #define __ASM_SGIDEFS_H
-
- /*
-- * Using a Linux compiler for building Linux seems logic but not to
-- * everybody.
-- */
--#ifndef __linux__
--#error Use a Linux compiler or give up.
--#endif
--
--/*
- * Definitions for the ISA levels
- *
- * With the introduction of MIPS32 / MIPS64 instruction sets definitions
diff --git a/target/linux/patches/3.10.107/startup.patch b/target/linux/patches/3.10.107/startup.patch
deleted file mode 100644
index 3ebc5db..0000000
--- a/target/linux/patches/3.10.107/startup.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-diff -Nur linux-3.10.33.orig/init/initramfs.c linux-3.10.33/init/initramfs.c
---- linux-3.10.33.orig/init/initramfs.c 2014-03-07 06:58:45.000000000 +0100
-+++ linux-3.10.33/init/initramfs.c 2014-03-15 18:32:07.240436750 +0100
-@@ -622,6 +622,9 @@
- */
- load_default_modules();
- }
-+#ifdef CONFIG_DEVTMPFS_MOUNT
-+ devtmpfs_mount("dev");
-+#endif
- return 0;
- }
- rootfs_initcall(populate_rootfs);
-diff -Nur linux-3.10.33.orig/init/main.c linux-3.10.33/init/main.c
---- linux-3.10.33.orig/init/main.c 2014-03-07 06:58:45.000000000 +0100
-+++ linux-3.10.33/init/main.c 2014-03-15 18:32:07.240436750 +0100
-@@ -885,6 +885,8 @@
- if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
- pr_err("Warning: unable to open an initial console.\n");
-
-+ printk(KERN_WARNING "Starting Linux (built with OpenADK).\n");
-+
- (void) sys_dup(0);
- (void) sys_dup(0);
- /*
-@@ -893,7 +895,7 @@
- */
-
- if (!ramdisk_execute_command)
-- ramdisk_execute_command = "/init";
-+ ramdisk_execute_command = "/sbin/init";
-
- if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
- ramdisk_execute_command = NULL;
diff --git a/target/linux/patches/3.16.56/initramfs-nosizelimit.patch b/target/linux/patches/3.16.56/initramfs-nosizelimit.patch
deleted file mode 100644
index 40d2f6b..0000000
--- a/target/linux/patches/3.16.56/initramfs-nosizelimit.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From 9a18df7a71bfa620b1278777d64783a359d7eb4e Mon Sep 17 00:00:00 2001
-From: Thorsten Glaser <tg@mirbsd.org>
-Date: Sun, 4 May 2014 01:37:54 +0200
-Subject: [PATCH] mount tmpfs-as-rootfs (initramfs) with -o
- nr_blocks=0,nr_inodes=0
-
-I would have preferred to write this patch to be able to pass
-rootflags=nr_blocks=0,nr_inodes=0 on the kernel command line,
-and then hand these rootflags over to the initramfs (tmpfs)
-mount in the same way the kernel hands them over to the block
-device rootfs mount. But at least the Debian/m68k initrd also
-parses $rootflags from the environment and adds it to the call
-to the user-space mount for the eventual root device, which
-would make the kernel command line rootflags option be used in
-both places (tmpfs and e.g. ext4) which is guaranteed to error
-out in at least one of them.
-
-This change is intended to aid people in a setup where the
-initrd is the final root filesystem, i.e. not mounted over.
-This is especially useful in automated tests running on qemu
-for boards with constrained memory (e.g. 64 MiB on sh4).
-
-Considering that the initramfs is normally emptied out then
-overmounted, this change is probably safe for setups where
-initramfs just hosts early userspace, too, since the tmpfs
-backing it is not accessible any more later on, AFAICT.
-
-Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
----
- init/do_mounts.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/init/do_mounts.c b/init/do_mounts.c
-index 82f2288..55a4cfe 100644
---- a/init/do_mounts.c
-+++ b/init/do_mounts.c
-@@ -594,6 +594,7 @@ out:
- }
-
- static bool is_tmpfs;
-+static char tmpfs_rootflags[] = "nr_blocks=0,nr_inodes=0";
- static struct dentry *rootfs_mount(struct file_system_type *fs_type,
- int flags, const char *dev_name, void *data)
- {
-@@ -606,6 +607,9 @@ static struct dentry *rootfs_mount(struct file_system_type *fs_type,
- if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs)
- fill = shmem_fill_super;
-
-+ if (is_tmpfs)
-+ data = tmpfs_rootflags;
-+
- return mount_nodev(fs_type, flags, data, fill);
- }
-
---
-2.0.0.rc0
-
diff --git a/target/linux/patches/3.16.56/startup.patch b/target/linux/patches/3.16.56/startup.patch
deleted file mode 100644
index d396b75..0000000
--- a/target/linux/patches/3.16.56/startup.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff -Nur linux-3.13.3.orig/init/main.c linux-3.13.3/init/main.c
---- linux-3.13.3.orig/init/main.c 2014-02-13 23:00:14.000000000 +0100
-+++ linux-3.13.3/init/main.c 2014-02-17 11:35:14.000000000 +0100
-@@ -916,6 +917,8 @@
- if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
- pr_err("Warning: unable to open an initial console.\n");
-
-+ printk(KERN_WARNING "Starting Linux (built with OpenADK).\n");
-+
- (void) sys_dup(0);
- (void) sys_dup(0);
- /*
-diff -Nur linux-3.13.6.orig/init/initramfs.c linux-3.13.6/init/initramfs.c
---- linux-3.13.6.orig/init/initramfs.c 2014-03-07 07:07:02.000000000 +0100
-+++ linux-3.13.6/init/initramfs.c 2014-03-15 12:11:31.882731916 +0100
-@@ -622,6 +622,9 @@
- */
- load_default_modules();
- }
-+#ifdef CONFIG_DEVTMPFS_MOUNT
-+ devtmpfs_mount("dev");
-+#endif
- return 0;
- }
- rootfs_initcall(populate_rootfs);
-diff -Nur linux-3.13.6.orig/init/main.c linux-3.13.6/init/main.c
---- linux-3.13.6.orig/init/main.c 2014-03-07 07:07:02.000000000 +0100
-+++ linux-3.13.6/init/main.c 2014-03-15 12:13:16.459024452 +0100
-@@ -924,7 +924,7 @@
- */
-
- if (!ramdisk_execute_command)
-- ramdisk_execute_command = "/init";
-+ ramdisk_execute_command = "/sbin/init";
-
- if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
- ramdisk_execute_command = NULL;
diff --git a/target/linux/patches/3.16.56/bsd-compatibility.patch b/target/linux/patches/3.16.81/bsd-compatibility.patch
index b954b65..b954b65 100644
--- a/target/linux/patches/3.16.56/bsd-compatibility.patch
+++ b/target/linux/patches/3.16.81/bsd-compatibility.patch
diff --git a/target/linux/patches/3.16.56/cleankernel.patch b/target/linux/patches/3.16.81/cleankernel.patch
index d8c055d..d8c055d 100644
--- a/target/linux/patches/3.16.56/cleankernel.patch
+++ b/target/linux/patches/3.16.81/cleankernel.patch
diff --git a/target/linux/patches/3.16.56/cris-header.patch b/target/linux/patches/3.16.81/cris-header.patch
index 3db07e5..3db07e5 100644
--- a/target/linux/patches/3.16.56/cris-header.patch
+++ b/target/linux/patches/3.16.81/cris-header.patch
diff --git a/target/linux/patches/3.16.56/cris-initramfs.patch b/target/linux/patches/3.16.81/cris-initramfs.patch
index b709e70..b709e70 100644
--- a/target/linux/patches/3.16.56/cris-initramfs.patch
+++ b/target/linux/patches/3.16.81/cris-initramfs.patch
diff --git a/target/linux/patches/3.16.56/defaults.patch b/target/linux/patches/3.16.81/defaults.patch
index 6cdca08..6cdca08 100644
--- a/target/linux/patches/3.16.56/defaults.patch
+++ b/target/linux/patches/3.16.81/defaults.patch
diff --git a/target/linux/patches/3.16.56/export-symbol-for-exmap.patch b/target/linux/patches/3.16.81/export-symbol-for-exmap.patch
index 4f0fc84..4f0fc84 100644
--- a/target/linux/patches/3.16.56/export-symbol-for-exmap.patch
+++ b/target/linux/patches/3.16.81/export-symbol-for-exmap.patch
diff --git a/target/linux/patches/3.16.56/fblogo.patch b/target/linux/patches/3.16.81/fblogo.patch
index 5b90702..5b90702 100644
--- a/target/linux/patches/3.16.56/fblogo.patch
+++ b/target/linux/patches/3.16.81/fblogo.patch
diff --git a/target/linux/patches/3.16.56/gemalto.patch b/target/linux/patches/3.16.81/gemalto.patch
index 65f7af1..65f7af1 100644
--- a/target/linux/patches/3.16.56/gemalto.patch
+++ b/target/linux/patches/3.16.81/gemalto.patch
diff --git a/target/linux/patches/4.1.51/initramfs-nosizelimit.patch b/target/linux/patches/3.16.81/initramfs-nosizelimit.patch
index 40d2f6b..40d2f6b 100644
--- a/target/linux/patches/4.1.51/initramfs-nosizelimit.patch
+++ b/target/linux/patches/3.16.81/initramfs-nosizelimit.patch
diff --git a/target/linux/patches/3.16.56/lemote-rfkill.patch b/target/linux/patches/3.16.81/lemote-rfkill.patch
index a614884..a614884 100644
--- a/target/linux/patches/3.16.56/lemote-rfkill.patch
+++ b/target/linux/patches/3.16.81/lemote-rfkill.patch
diff --git a/target/linux/patches/3.16.56/microblaze-ethernet.patch b/target/linux/patches/3.16.81/microblaze-ethernet.patch
index 742ab47..742ab47 100644
--- a/target/linux/patches/3.16.56/microblaze-ethernet.patch
+++ b/target/linux/patches/3.16.81/microblaze-ethernet.patch
diff --git a/target/linux/patches/3.16.56/mkpiggy.patch b/target/linux/patches/3.16.81/mkpiggy.patch
index 751678b..751678b 100644
--- a/target/linux/patches/3.16.56/mkpiggy.patch
+++ b/target/linux/patches/3.16.81/mkpiggy.patch
diff --git a/target/linux/patches/3.16.56/mtd-rootfs.patch b/target/linux/patches/3.16.81/mtd-rootfs.patch
index 775d5fc..775d5fc 100644
--- a/target/linux/patches/3.16.56/mtd-rootfs.patch
+++ b/target/linux/patches/3.16.81/mtd-rootfs.patch
diff --git a/target/linux/patches/3.16.56/nfsv3-tcp.patch b/target/linux/patches/3.16.81/nfsv3-tcp.patch
index d5e07e1..d5e07e1 100644
--- a/target/linux/patches/3.16.56/nfsv3-tcp.patch
+++ b/target/linux/patches/3.16.81/nfsv3-tcp.patch
diff --git a/target/linux/patches/3.16.56/non-static.patch b/target/linux/patches/3.16.81/non-static.patch
index a967703..a967703 100644
--- a/target/linux/patches/3.16.56/non-static.patch
+++ b/target/linux/patches/3.16.81/non-static.patch
diff --git a/target/linux/patches/3.16.56/ppc64-missing-zlib.patch b/target/linux/patches/3.16.81/ppc64-missing-zlib.patch
index c6e0616..c6e0616 100644
--- a/target/linux/patches/3.16.56/ppc64-missing-zlib.patch
+++ b/target/linux/patches/3.16.81/ppc64-missing-zlib.patch
diff --git a/target/linux/patches/3.16.56/relocs.patch b/target/linux/patches/3.16.81/relocs.patch
index 69a7c88..69a7c88 100644
--- a/target/linux/patches/3.16.56/relocs.patch
+++ b/target/linux/patches/3.16.81/relocs.patch
diff --git a/target/linux/patches/3.16.56/sgidefs.patch b/target/linux/patches/3.16.81/sgidefs.patch
index f00a284..f00a284 100644
--- a/target/linux/patches/3.16.56/sgidefs.patch
+++ b/target/linux/patches/3.16.81/sgidefs.patch
diff --git a/target/linux/patches/3.16.56/sortext.patch b/target/linux/patches/3.16.81/sortext.patch
index 8fd4e1d..8fd4e1d 100644
--- a/target/linux/patches/3.16.56/sortext.patch
+++ b/target/linux/patches/3.16.81/sortext.patch
diff --git a/target/linux/patches/4.1.51/startup.patch b/target/linux/patches/3.16.81/startup.patch
index d396b75..d396b75 100644
--- a/target/linux/patches/4.1.51/startup.patch
+++ b/target/linux/patches/3.16.81/startup.patch
diff --git a/target/linux/patches/3.16.56/wlan-cf.patch b/target/linux/patches/3.16.81/wlan-cf.patch
index fc20759..fc20759 100644
--- a/target/linux/patches/3.16.56/wlan-cf.patch
+++ b/target/linux/patches/3.16.81/wlan-cf.patch
diff --git a/target/linux/patches/3.16.56/xargs.patch b/target/linux/patches/3.16.81/xargs.patch
index 2c7b3df..2c7b3df 100644
--- a/target/linux/patches/3.16.56/xargs.patch
+++ b/target/linux/patches/3.16.81/xargs.patch
diff --git a/target/linux/patches/3.2.101/sparc-aout.patch b/target/linux/patches/3.2.101/sparc-aout.patch
deleted file mode 100644
index 6ad2524..0000000
--- a/target/linux/patches/3.2.101/sparc-aout.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -Nur linux-3.2.66.orig/arch/sparc/boot/Makefile linux-3.2.66/arch/sparc/boot/Makefile
---- linux-3.2.66.orig/arch/sparc/boot/Makefile 2014-12-31 19:27:54.000000000 -0600
-+++ linux-3.2.66/arch/sparc/boot/Makefile 2015-02-17 13:21:38.269400789 -0600
-@@ -75,9 +75,6 @@
- $(call if_changed,gzip)
- @echo ' kernel: $@ is ready'
-
--$(obj)/vmlinux.aout: vmlinux FORCE
-- $(call if_changed,elftoaout)
-- @echo ' kernel: $@ is ready'
- else
-
- # The following lines make a readable image for U-Boot.
-@@ -110,6 +107,10 @@
-
- endif
-
-+$(obj)/vmlinux.aout: $(obj)/image FORCE
-+ $(call if_changed,elftoaout)
-+ @echo ' kernel: $@ is ready'
-+
- $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback System.map $(ROOT_IMG) FORCE
- $(call if_changed,elftoaout)
- $(call if_changed,piggy)
diff --git a/target/linux/patches/4.1.51/cleankernel.patch b/target/linux/patches/4.1.51/cleankernel.patch
deleted file mode 100644
index 59693f4..0000000
--- a/target/linux/patches/4.1.51/cleankernel.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Nur linux-4.1.10.orig/scripts/Makefile.headersinst linux-4.1.10/scripts/Makefile.headersinst
---- linux-4.1.10.orig/scripts/Makefile.headersinst 2015-10-03 13:49:38.000000000 +0200
-+++ linux-4.1.10/scripts/Makefile.headersinst 2015-10-15 11:23:35.000000000 +0200
-@@ -107,7 +107,6 @@
-
- targets += $(install-file)
- $(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE
-- $(if $(unwanted),$(call cmd,remove),)
- $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
- $(call if_changed,install)
-
diff --git a/target/linux/patches/4.1.51/cris-header.patch b/target/linux/patches/4.1.51/cris-header.patch
deleted file mode 100644
index 2b5a884..0000000
--- a/target/linux/patches/4.1.51/cris-header.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Nur linux-3.16.2.orig/arch/cris/include/arch-v10/arch/Kbuild linux-3.16.2/arch/cris/include/arch-v10/arch/Kbuild
---- linux-3.16.2.orig/arch/cris/include/arch-v10/arch/Kbuild 2014-09-06 01:37:11.000000000 +0200
-+++ linux-3.16.2/arch/cris/include/arch-v10/arch/Kbuild 2014-09-26 19:24:50.000000000 +0200
-@@ -1 +1,2 @@
- # CRISv10 arch
-+header-y += ptrace.h
-diff -Nur linux-3.16.2.orig/arch/cris/include/arch-v32/arch/Kbuild linux-3.16.2/arch/cris/include/arch-v32/arch/Kbuild
---- linux-3.16.2.orig/arch/cris/include/arch-v32/arch/Kbuild 2014-09-06 01:37:11.000000000 +0200
-+++ linux-3.16.2/arch/cris/include/arch-v32/arch/Kbuild 2014-09-26 19:24:31.000000000 +0200
-@@ -1 +1,2 @@
- # CRISv32 arch
-+header-y += ptrace.h
diff --git a/target/linux/patches/4.1.51/j2-core.patch b/target/linux/patches/4.1.51/j2-core.patch
deleted file mode 100644
index 38136df..0000000
--- a/target/linux/patches/4.1.51/j2-core.patch
+++ /dev/null
@@ -1,2060 +0,0 @@
-diff -Nur linux-4.1.13.orig/arch/sh/Kconfig linux-4.1.13/arch/sh/Kconfig
---- linux-4.1.13.orig/arch/sh/Kconfig 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/Kconfig 2015-12-05 00:16:48.000000000 +0100
-@@ -66,7 +66,7 @@
- select HAVE_MIXED_BREAKPOINTS_REGS
- select PERF_EVENTS
- select ARCH_HIBERNATION_POSSIBLE if MMU
-- select SPARSE_IRQ
-+ select SPARSE_IRQ if !CPU_SUBTYPE_0PF
- select HAVE_CC_STACKPROTECTOR
-
- config SUPERH64
-@@ -108,6 +108,9 @@
- config ARCH_HIBERNATION_POSSIBLE
- def_bool n
-
-+config ARCH_USES_GETTIMEOFFSET
-+ def_bool n
-+
- config SYS_SUPPORTS_APM_EMULATION
- bool
- select ARCH_SUSPEND_POSSIBLE
-@@ -184,6 +187,11 @@
- select CPU_SH2
- select UNCACHED_MAPPING
-
-+config CPU_SH2J
-+ bool
-+ select CPU_SH2
-+ select ARCH_USES_GETTIMEOFFSET
-+
- config CPU_SH3
- bool
- select CPU_HAS_INTEVT
-@@ -303,6 +311,12 @@
- help
- Select MX-G if running on an R8A03022BG part.
-
-+# SH-2J Processor Support
-+
-+config CPU_SUBTYPE_0PF
-+ bool "Support 0PF J2 SoftCore"
-+ select CPU_SH2J
-+
- # SH-3 Processor Support
-
- config CPU_SUBTYPE_SH7705
-@@ -753,6 +767,7 @@
- SH_7751_SOLUTION_ENGINE
- default "0x00004000" if PAGE_SIZE_16KB || SH_SH03
- default "0x00002000" if PAGE_SIZE_8KB
-+ default "0x0003F000" if CPU_SUBTYPE_0PF
- default "0x00001000"
- help
- This sets the default offset of zero page.
-diff -Nur linux-4.1.13.orig/arch/sh/Makefile linux-4.1.13/arch/sh/Makefile
---- linux-4.1.13.orig/arch/sh/Makefile 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/Makefile 2015-12-05 00:16:48.000000000 +0100
-@@ -4,6 +4,7 @@
- # Copyright (C) 1999 Kaz Kojima
- # Copyright (C) 2002 - 2008 Paul Mundt
- # Copyright (C) 2002 M. R. Brown
-+# Copyright (C) 2012 SEI, Inc. (sh2j)
- #
- # This file is subject to the terms and conditions of the GNU General Public
- # License. See the file "COPYING" in the main directory of this archive
-@@ -19,6 +20,7 @@
- isa-$(CONFIG_SH_DSP) := sh
- isa-$(CONFIG_CPU_SH2) := sh2
- isa-$(CONFIG_CPU_SH2A) := sh2a
-+isa-$(CONFIG_CPU_SH2J) := sh2j
- isa-$(CONFIG_CPU_SH3) := sh3
- isa-$(CONFIG_CPU_SH4) := sh4
- isa-$(CONFIG_CPU_SH4A) := sh4a
-@@ -31,6 +33,8 @@
- endif
-
- cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,)
-+cflags-$(CONFIG_CPU_SH2J) := $(call cc-option,-m2,) \
-+ $(call cc-option,-melf,)
- cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
- $(call cc-option,-m2a-nofpu,) \
- $(call cc-option,-m4-nofpu,)
-@@ -91,6 +95,7 @@
- defaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage
- defaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux
- defaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux
-+defaultimage-$(CONFIG_SH_0PF) := vmlinux
-
- # Set some sensible Kbuild defaults
- KBUILD_IMAGE := $(defaultimage-y)
-@@ -173,6 +178,7 @@
- # As an example, in order of preference, SH-2A > SH-2 > common definitions.
- #
- cpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a
-+cpuincdir-$(CONFIG_CPU_SH2J) += cpu-sh2j
- cpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2
- cpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3
- cpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a
-diff -Nur linux-4.1.13.orig/arch/sh/boards/Kconfig linux-4.1.13/arch/sh/boards/Kconfig
---- linux-4.1.13.orig/arch/sh/boards/Kconfig 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/boards/Kconfig 2015-12-05 00:16:48.000000000 +0100
-@@ -90,6 +90,13 @@
- Select 7343 SolutionEngine if configuring for a Hitachi
- SH7343 (SH-Mobile 3AS) evaluation board.
-
-+config 0PF_FPGA
-+ bool "0PF FPGA"
-+ depends on CPU_SUBTYPE_0PF
-+ help
-+ Select 0PF_FPGA if you are configuring for an FPGA with
-+ the SH2j-workalike SoftCore from http://0pf.org
-+
- config SH_HP6XX
- bool "HP6XX"
- select SYS_SUPPORTS_APM_EMULATION
-diff -Nur linux-4.1.13.orig/arch/sh/boards/Makefile linux-4.1.13/arch/sh/boards/Makefile
---- linux-4.1.13.orig/arch/sh/boards/Makefile 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/boards/Makefile 2015-12-05 00:16:48.000000000 +0100
-@@ -15,3 +15,4 @@
- obj-$(CONFIG_SH_SH7757LCR) += board-sh7757lcr.o
- obj-$(CONFIG_SH_APSH4A3A) += board-apsh4a3a.o
- obj-$(CONFIG_SH_APSH4AD0A) += board-apsh4ad0a.o
-+obj-$(CONFIG_0PF_FPGA) += board-0pf.o
-diff -Nur linux-4.1.13.orig/arch/sh/boards/board-0pf.c linux-4.1.13/arch/sh/boards/board-0pf.c
---- linux-4.1.13.orig/arch/sh/boards/board-0pf.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.13/arch/sh/boards/board-0pf.c 2015-12-05 00:16:48.000000000 +0100
-@@ -0,0 +1,270 @@
-+/*
-+ * board-0pf.c
-+ *
-+ * Copyright (C) 2006 Yoshinori Sato
-+ * Copyright (C) 2009 D. Jeff Dionne
-+ *
-+ * 0PF j-series CPU on FPGA
-+ */
-+#include <linux/platform_device.h>
-+#include <linux/sched.h>
-+#include <linux/kernel.h>
-+#include <linux/param.h>
-+#include <linux/interrupt.h>
-+#include <linux/profile.h>
-+#include <linux/init.h>
-+#include <linux/irq.h>
-+#include <linux/device.h>
-+#include <linux/module.h>
-+#include <asm/io.h>
-+#include <asm/irq.h>
-+#include <asm/rtc.h>
-+#include <asm/machvec.h>
-+#include <asm/board-0pf.h>
-+
-+int shj_irq_demux(int irq)
-+{
-+ return irq; /* punt.. */
-+}
-+
-+static void shj_ack_noop(struct irq_data *data)
-+{
-+ asm("nop;nop");
-+ /* Dummy function. */
-+}
-+
-+static inline void shj_enable_irq(struct irq_data *data)
-+{
-+ unsigned int irq = data->irq;
-+ volatile unsigned int vui;
-+
-+// printk("%s: IRQ %d (0x%x)\n", __func__, irq, irq);
-+
-+ switch (irq) {
-+ case PIT_IRQ:
-+ //AQ_PIO = 0x0BB;
-+ /* enable, lvl 2, vector 64 */
-+ AQ_SYS = (1 << 26) | /* enable PIT */
-+ (0x02 << 20) | /* interrupt level 2 */
-+ (PIT_IRQ << 12) | /* vector 64 */
-+ 1; /* turn off interval timer */
-+ break;
-+
-+ case Irq_UART0:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_UART0, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_UART0, 0x7); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_UART1:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_UART1, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_UART1, 0x7); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_GPS:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_GPS, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_GPS, 0x7); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_I2C:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_I2C, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_I2C, 0x7); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_EMAC:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_EMAC, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_EMAC, 0x8); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ printk("EMAC prio is: %x\n", vui);
-+ break;
-+
-+ case Irq_GPIO:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_GPIO, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_GPIO, 0x7); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_1PPS: // prio is higher for 1PPS porposes
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_1PPS, 0xf); /* clear old setting */
-+ vui |= ID2Pri(EIrqID_1PPS, 0x9); /* set interrupt level */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ printk("1PPS prio is: %x\n", vui);
-+ break;
-+
-+ default:
-+ break;
-+
-+ }
-+}
-+
-+static inline void shj_disable_irq(struct irq_data *data)
-+{
-+ volatile unsigned int vui;
-+ unsigned int irq = data->irq;
-+
-+ printk("%s: IRQ %d\n", __func__, irq);
-+
-+ switch (irq) {
-+ case PIT_IRQ:
-+ /* enable, lvl 2, vector 64 */
-+ AQ_SYS = (0 << 26) | /* disable PIT */
-+ (0x02 << 20) | /* interrupt level 2 */
-+ (PIT_IRQ << 12) | /* vector 64 */
-+ 1; /* turn off interval timer */
-+ break;
-+
-+ case Irq_UART0:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_UART0, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_UART1:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_UART1, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_GPS:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_GPS, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_I2C:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_I2C, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_EMAC:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_EMAC, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_GPIO:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_GPIO, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ case Irq_1PPS:
-+ vui = *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri);
-+ vui &= ~ID2Pri(EIrqID_1PPS, 0xf); /* clear setting */
-+ *(volatile unsigned int *)(sys_SYS_BASE + Sys_IntPri) = vui;
-+ break;
-+
-+ default:
-+ break;
-+ }
-+}
-+
-+static struct irq_chip shj_irq_chip = {
-+ .name = "0PF_INTC",
-+ .irq_enable = shj_enable_irq,
-+ .irq_disable = shj_disable_irq,
-+ .irq_ack = shj_ack_noop,
-+};
-+
-+static void __init shj_irq_init(void)
-+{
-+ int c;
-+
-+ printk(KERN_INFO "0PF FPGA interrupt controller...\n");
-+
-+ for (c = 0; c < NR_IRQS; c++) {
-+ //irq_desc[c].action = NULL;
-+ //irq_desc[c].depth = 1;
-+ irq_set_chip_and_handler_name(c, &shj_irq_chip,
-+ handle_simple_irq, "simple");
-+ }
-+}
-+
-+#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
-+// Commit 7b1f62076 switched this to a pointer
-+/*
-+ * Should return nanoseconds since last timer tick
-+ */
-+u32 shj_gettimeoffset(void)
-+{
-+ u32 clocks_counter = readl(SHJ_PIT_PCNTR);
-+
-+ return clocks_counter * readl(SHJ_NSEC_PER_CLOCK);
-+}
-+
-+static void __init shj_board_setup(char **cmdline)
-+{
-+ arch_gettimeoffset = shj_gettimeoffset;
-+}
-+#else
-+#define shj_gettimeoffset 0
-+#endif
-+
-+static struct sh_machine_vector mv_se __initmv = {
-+ .mv_name = "0PF_FPGA",
-+ //.mv_nr_irqs = 256,
-+ .mv_irq_demux = shj_irq_demux,
-+ .mv_init_irq = shj_irq_init,
-+ .mv_setup = shj_board_setup,
-+};
-+
-+static irqreturn_t timer_interrupt(int irq, void *dev_id)
-+{
-+ // AQ_PIO = 0x011; // GREEN
-+
-+ if (current->pid)
-+ profile_tick(CPU_PROFILING);
-+
-+ xtime_update(1);
-+ update_process_times(user_mode(get_irq_regs()));
-+
-+ return IRQ_HANDLED;
-+}
-+
-+static void __init start_pit(void)
-+{
-+ if (request_irq
-+ (PIT_IRQ, timer_interrupt, IRQF_TIMER, "pit", NULL))
-+ printk("irq_desc[%p] : fail to register\n", &irq_desc[PIT_IRQ]);
-+
-+ irq_set_chip_and_handler_name(PIT_IRQ, &shj_irq_chip, handle_edge_irq,
-+ "pit");
-+}
-+
-+static int __init shj_initialise(void)
-+{
-+ struct irq_data *data;
-+
-+ pr_info("0PF Machine setup...\n");
-+
-+ start_pit();
-+
-+ data = irq_get_irq_data(Irq_UART0);
-+ shj_enable_irq(data);
-+
-+ data = irq_get_irq_data(Irq_UART1);
-+ shj_enable_irq(data);
-+
-+ data = irq_get_irq_data(Irq_EMAC);
-+ shj_enable_irq(data);
-+
-+ data = irq_get_irq_data(PIT_IRQ);
-+ shj_enable_irq(data);
-+
-+ pr_info("0PF Machine setup done.\n");
-+
-+ return 0;
-+}
-+
-+arch_initcall(shj_initialise);
-diff -Nur linux-4.1.13.orig/arch/sh/configs/0pf_defconfig linux-4.1.13/arch/sh/configs/0pf_defconfig
---- linux-4.1.13.orig/arch/sh/configs/0pf_defconfig 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.13/arch/sh/configs/0pf_defconfig 2015-12-05 00:16:48.000000000 +0100
-@@ -0,0 +1,945 @@
-+#
-+# Automatically generated file; DO NOT EDIT.
-+# Linux/sh 4.1.0-rc6 Kernel Configuration
-+#
-+CONFIG_SUPERH=y
-+CONFIG_SUPERH32=y
-+# CONFIG_SUPERH64 is not set
-+CONFIG_ARCH_DEFCONFIG="arch/sh/configs/shx3_defconfig"
-+CONFIG_RWSEM_GENERIC_SPINLOCK=y
-+CONFIG_GENERIC_BUG=y
-+CONFIG_GENERIC_HWEIGHT=y
-+# CONFIG_ARCH_SUSPEND_POSSIBLE is not set
-+# CONFIG_ARCH_HIBERNATION_POSSIBLE is not set
-+CONFIG_ARCH_USES_GETTIMEOFFSET=y
-+CONFIG_STACKTRACE_SUPPORT=y
-+CONFIG_LOCKDEP_SUPPORT=y
-+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
-+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
-+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
-+CONFIG_NO_IOPORT_MAP=y
-+CONFIG_DMA_NONCOHERENT=y
-+CONFIG_NEED_DMA_MAP_STATE=y
-+CONFIG_NEED_SG_DMA_LENGTH=y
-+CONFIG_PGTABLE_LEVELS=2
-+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
-+CONFIG_IRQ_WORK=y
-+
-+#
-+# General setup
-+#
-+CONFIG_BROKEN_ON_SMP=y
-+CONFIG_INIT_ENV_ARG_LIMIT=32
-+CONFIG_CROSS_COMPILE=""
-+# CONFIG_COMPILE_TEST is not set
-+CONFIG_LOCALVERSION=""
-+# CONFIG_LOCALVERSION_AUTO is not set
-+CONFIG_HAVE_KERNEL_GZIP=y
-+CONFIG_HAVE_KERNEL_BZIP2=y
-+CONFIG_HAVE_KERNEL_LZMA=y
-+CONFIG_HAVE_KERNEL_XZ=y
-+CONFIG_HAVE_KERNEL_LZO=y
-+CONFIG_KERNEL_GZIP=y
-+# CONFIG_KERNEL_BZIP2 is not set
-+# CONFIG_KERNEL_LZMA is not set
-+# CONFIG_KERNEL_XZ is not set
-+# CONFIG_KERNEL_LZO is not set
-+CONFIG_DEFAULT_HOSTNAME="(none)"
-+# CONFIG_SYSVIPC is not set
-+# CONFIG_FHANDLE is not set
-+# CONFIG_USELIB is not set
-+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
-+
-+#
-+# IRQ subsystem
-+#
-+CONFIG_MAY_HAVE_SPARSE_IRQ=y
-+CONFIG_GENERIC_IRQ_SHOW=y
-+CONFIG_IRQ_DOMAIN=y
-+CONFIG_IRQ_FORCED_THREADING=y
-+# CONFIG_SPARSE_IRQ is not set
-+CONFIG_GENERIC_CLOCKEVENTS=y
-+
-+#
-+# Timers subsystem
-+#
-+CONFIG_HZ_PERIODIC=y
-+
-+#
-+# CPU/Task time and stats accounting
-+#
-+CONFIG_TICK_CPU_ACCOUNTING=y
-+# CONFIG_BSD_PROCESS_ACCT is not set
-+
-+#
-+# RCU Subsystem
-+#
-+CONFIG_TINY_RCU=y
-+CONFIG_SRCU=y
-+# CONFIG_TASKS_RCU is not set
-+# CONFIG_RCU_STALL_COMMON is not set
-+# CONFIG_TREE_RCU_TRACE is not set
-+CONFIG_RCU_KTHREAD_PRIO=0
-+# CONFIG_RCU_EXPEDITE_BOOT is not set
-+# CONFIG_BUILD_BIN2C is not set
-+# CONFIG_IKCONFIG is not set
-+CONFIG_LOG_BUF_SHIFT=17
-+# CONFIG_CGROUPS is not set
-+# CONFIG_CHECKPOINT_RESTORE is not set
-+CONFIG_NAMESPACES=y
-+# CONFIG_UTS_NS is not set
-+# CONFIG_USER_NS is not set
-+# CONFIG_PID_NS is not set
-+# CONFIG_SCHED_AUTOGROUP is not set
-+# CONFIG_SYSFS_DEPRECATED is not set
-+# CONFIG_RELAY is not set
-+CONFIG_BLK_DEV_INITRD=y
-+CONFIG_INITRAMFS_SOURCE="initrd/root-dev initrd/root-files"
-+CONFIG_INITRAMFS_ROOT_UID=0
-+CONFIG_INITRAMFS_ROOT_GID=0
-+# CONFIG_RD_GZIP is not set
-+# CONFIG_RD_BZIP2 is not set
-+# CONFIG_RD_LZMA is not set
-+# CONFIG_RD_XZ is not set
-+# CONFIG_RD_LZO is not set
-+# CONFIG_RD_LZ4 is not set
-+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-+CONFIG_SYSCTL=y
-+CONFIG_ANON_INODES=y
-+CONFIG_HAVE_UID16=y
-+# CONFIG_EXPERT is not set
-+CONFIG_UID16=y
-+CONFIG_MULTIUSER=y
-+CONFIG_SGETMASK_SYSCALL=y
-+CONFIG_SYSFS_SYSCALL=y
-+# CONFIG_SYSCTL_SYSCALL is not set
-+CONFIG_KALLSYMS=y
-+CONFIG_PRINTK=y
-+CONFIG_BUG=y
-+CONFIG_ELF_CORE=y
-+CONFIG_BASE_FULL=y
-+CONFIG_FUTEX=y
-+CONFIG_EPOLL=y
-+CONFIG_SIGNALFD=y
-+CONFIG_TIMERFD=y
-+CONFIG_EVENTFD=y
-+# CONFIG_BPF_SYSCALL is not set
-+CONFIG_AIO=y
-+CONFIG_ADVISE_SYSCALLS=y
-+# CONFIG_EMBEDDED is not set
-+CONFIG_HAVE_PERF_EVENTS=y
-+CONFIG_PERF_USE_VMALLOC=y
-+
-+#
-+# Kernel Performance Events And Counters
-+#
-+CONFIG_PERF_EVENTS=y
-+CONFIG_VM_EVENT_COUNTERS=y
-+CONFIG_SLUB_DEBUG=y
-+# CONFIG_COMPAT_BRK is not set
-+# CONFIG_SLAB is not set
-+CONFIG_SLUB=y
-+# CONFIG_PROFILING is not set
-+CONFIG_HAVE_OPROFILE=y
-+# CONFIG_UPROBES is not set
-+# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
-+CONFIG_HAVE_KPROBES=y
-+CONFIG_HAVE_KRETPROBES=y
-+CONFIG_HAVE_ARCH_TRACEHOOK=y
-+CONFIG_HAVE_DMA_ATTRS=y
-+CONFIG_GENERIC_SMP_IDLE_THREAD=y
-+CONFIG_GENERIC_IDLE_POLL_SETUP=y
-+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
-+CONFIG_HAVE_CLK=y
-+CONFIG_HAVE_DMA_API_DEBUG=y
-+CONFIG_HAVE_HW_BREAKPOINT=y
-+CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y
-+CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
-+CONFIG_HAVE_CC_STACKPROTECTOR=y
-+# CONFIG_CC_STACKPROTECTOR is not set
-+CONFIG_CC_STACKPROTECTOR_NONE=y
-+# CONFIG_CC_STACKPROTECTOR_REGULAR is not set
-+# CONFIG_CC_STACKPROTECTOR_STRONG is not set
-+CONFIG_MODULES_USE_ELF_RELA=y
-+CONFIG_OLD_SIGSUSPEND=y
-+CONFIG_OLD_SIGACTION=y
-+
-+#
-+# GCOV-based kernel profiling
-+#
-+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
-+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
-+CONFIG_SLABINFO=y
-+CONFIG_RT_MUTEXES=y
-+CONFIG_BASE_SMALL=0
-+# CONFIG_MODULES is not set
-+CONFIG_BLOCK=y
-+# CONFIG_LBDAF is not set
-+# CONFIG_BLK_DEV_BSG is not set
-+# CONFIG_BLK_DEV_BSGLIB is not set
-+# CONFIG_BLK_DEV_INTEGRITY is not set
-+# CONFIG_BLK_CMDLINE_PARSER is not set
-+
-+#
-+# Partition Types
-+#
-+# CONFIG_PARTITION_ADVANCED is not set
-+CONFIG_MSDOS_PARTITION=y
-+CONFIG_EFI_PARTITION=y
-+
-+#
-+# IO Schedulers
-+#
-+CONFIG_IOSCHED_NOOP=y
-+# CONFIG_IOSCHED_DEADLINE is not set
-+# CONFIG_IOSCHED_CFQ is not set
-+CONFIG_DEFAULT_NOOP=y
-+CONFIG_DEFAULT_IOSCHED="noop"
-+CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
-+CONFIG_INLINE_READ_UNLOCK=y
-+CONFIG_INLINE_READ_UNLOCK_IRQ=y
-+CONFIG_INLINE_WRITE_UNLOCK=y
-+CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
-+# CONFIG_FREEZER is not set
-+
-+#
-+# System type
-+#
-+CONFIG_CPU_SH2=y
-+CONFIG_CPU_SH2J=y
-+# CONFIG_CPU_SUBTYPE_SH7619 is not set
-+# CONFIG_CPU_SUBTYPE_SH7201 is not set
-+# CONFIG_CPU_SUBTYPE_SH7203 is not set
-+# CONFIG_CPU_SUBTYPE_SH7206 is not set
-+# CONFIG_CPU_SUBTYPE_SH7263 is not set
-+# CONFIG_CPU_SUBTYPE_SH7264 is not set
-+# CONFIG_CPU_SUBTYPE_SH7269 is not set
-+# CONFIG_CPU_SUBTYPE_MXG is not set
-+CONFIG_CPU_SUBTYPE_0PF=y
-+# CONFIG_CPU_SUBTYPE_SH7705 is not set
-+# CONFIG_CPU_SUBTYPE_SH7706 is not set
-+# CONFIG_CPU_SUBTYPE_SH7707 is not set
-+# CONFIG_CPU_SUBTYPE_SH7708 is not set
-+# CONFIG_CPU_SUBTYPE_SH7709 is not set
-+# CONFIG_CPU_SUBTYPE_SH7710 is not set
-+# CONFIG_CPU_SUBTYPE_SH7712 is not set
-+# CONFIG_CPU_SUBTYPE_SH7720 is not set
-+# CONFIG_CPU_SUBTYPE_SH7721 is not set
-+# CONFIG_CPU_SUBTYPE_SH7750 is not set
-+# CONFIG_CPU_SUBTYPE_SH7091 is not set
-+# CONFIG_CPU_SUBTYPE_SH7750R is not set
-+# CONFIG_CPU_SUBTYPE_SH7750S is not set
-+# CONFIG_CPU_SUBTYPE_SH7751 is not set
-+# CONFIG_CPU_SUBTYPE_SH7751R is not set
-+# CONFIG_CPU_SUBTYPE_SH7760 is not set
-+# CONFIG_CPU_SUBTYPE_SH4_202 is not set
-+# CONFIG_CPU_SUBTYPE_SH7723 is not set
-+# CONFIG_CPU_SUBTYPE_SH7724 is not set
-+# CONFIG_CPU_SUBTYPE_SH7734 is not set
-+# CONFIG_CPU_SUBTYPE_SH7757 is not set
-+# CONFIG_CPU_SUBTYPE_SH7763 is not set
-+# CONFIG_CPU_SUBTYPE_SH7770 is not set
-+# CONFIG_CPU_SUBTYPE_SH7780 is not set
-+# CONFIG_CPU_SUBTYPE_SH7785 is not set
-+# CONFIG_CPU_SUBTYPE_SH7786 is not set
-+# CONFIG_CPU_SUBTYPE_SHX3 is not set
-+# CONFIG_CPU_SUBTYPE_SH7343 is not set
-+# CONFIG_CPU_SUBTYPE_SH7722 is not set
-+# CONFIG_CPU_SUBTYPE_SH7366 is not set
-+
-+#
-+# Memory management options
-+#
-+CONFIG_QUICKLIST=y
-+CONFIG_PAGE_OFFSET=0x00000000
-+CONFIG_FORCE_MAX_ZONEORDER=14
-+CONFIG_MEMORY_START=0x10000000
-+CONFIG_MEMORY_SIZE=0x8000000
-+# CONFIG_29BIT is not set
-+CONFIG_32BIT=y
-+CONFIG_ARCH_FLATMEM_ENABLE=y
-+CONFIG_ARCH_SPARSEMEM_ENABLE=y
-+CONFIG_ARCH_SPARSEMEM_DEFAULT=y
-+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
-+CONFIG_PAGE_SIZE_4KB=y
-+# CONFIG_PAGE_SIZE_8KB is not set
-+# CONFIG_PAGE_SIZE_16KB is not set
-+# CONFIG_PAGE_SIZE_64KB is not set
-+CONFIG_SELECT_MEMORY_MODEL=y
-+CONFIG_FLATMEM_MANUAL=y
-+# CONFIG_SPARSEMEM_MANUAL is not set
-+CONFIG_FLATMEM=y
-+CONFIG_FLAT_NODE_MEM_MAP=y
-+CONFIG_SPARSEMEM_STATIC=y
-+CONFIG_HAVE_MEMBLOCK=y
-+CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
-+CONFIG_ARCH_DISCARD_MEMBLOCK=y
-+# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
-+CONFIG_PAGEFLAGS_EXTENDED=y
-+CONFIG_SPLIT_PTLOCK_CPUS=999999
-+# CONFIG_PHYS_ADDR_T_64BIT is not set
-+CONFIG_ZONE_DMA_FLAG=0
-+CONFIG_NR_QUICK=1
-+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=1
-+CONFIG_NEED_PER_CPU_KM=y
-+# CONFIG_CLEANCACHE is not set
-+# CONFIG_ZPOOL is not set
-+# CONFIG_ZBUD is not set
-+
-+#
-+# Cache configuration
-+#
-+# CONFIG_CACHE_WRITEBACK is not set
-+# CONFIG_CACHE_WRITETHROUGH is not set
-+CONFIG_CACHE_OFF=y
-+
-+#
-+# Processor features
-+#
-+# CONFIG_CPU_LITTLE_ENDIAN is not set
-+CONFIG_CPU_BIG_ENDIAN=y
-+# CONFIG_SH_FPU_EMU is not set
-+
-+#
-+# Board support
-+#
-+CONFIG_0PF_FPGA=y
-+
-+#
-+# Timer and clock configuration
-+#
-+CONFIG_SH_PCLK_FREQ=32000000
-+CONFIG_SH_CLK_CPG=y
-+CONFIG_SH_CLK_CPG_LEGACY=y
-+
-+#
-+# CPU Frequency scaling
-+#
-+
-+#
-+# CPU Frequency scaling
-+#
-+# CONFIG_CPU_FREQ is not set
-+
-+#
-+# DMA support
-+#
-+
-+#
-+# Companion Chips
-+#
-+
-+#
-+# Additional SuperH Device Drivers
-+#
-+# CONFIG_HEARTBEAT is not set
-+# CONFIG_PUSH_SWITCH is not set
-+
-+#
-+# Kernel features
-+#
-+CONFIG_HZ_100=y
-+# CONFIG_HZ_250 is not set
-+# CONFIG_HZ_300 is not set
-+# CONFIG_HZ_1000 is not set
-+CONFIG_HZ=100
-+# CONFIG_SCHED_HRTICK is not set
-+# CONFIG_CRASH_DUMP is not set
-+CONFIG_PHYSICAL_START=0x10000000
-+# CONFIG_SECCOMP is not set
-+CONFIG_PREEMPT_NONE=y
-+# CONFIG_PREEMPT_VOLUNTARY is not set
-+# CONFIG_PREEMPT is not set
-+CONFIG_GUSA=y
-+
-+#
-+# SuperH / SH-Mobile Driver Options
-+#
-+CONFIG_SH_INTC=y
-+
-+#
-+# Interrupt controller options
-+#
-+
-+#
-+# Boot options
-+#
-+CONFIG_ZERO_PAGE_OFFSET=0x0003F000
-+CONFIG_BOOT_LINK_OFFSET=0x00800000
-+CONFIG_ENTRY_OFFSET=0x00001000
-+# CONFIG_CMDLINE_OVERWRITE is not set
-+CONFIG_CMDLINE_EXTEND=y
-+CONFIG_CMDLINE="console=ttyUL0"
-+
-+#
-+# Bus options
-+#
-+# CONFIG_PCCARD is not set
-+
-+#
-+# Executable file formats
-+#
-+CONFIG_BINFMT_ELF_FDPIC=y
-+CONFIG_BINFMT_SCRIPT=y
-+CONFIG_BINFMT_FLAT=y
-+# CONFIG_BINFMT_ZFLAT is not set
-+# CONFIG_BINFMT_SHARED_FLAT is not set
-+# CONFIG_HAVE_AOUT is not set
-+# CONFIG_BINFMT_MISC is not set
-+CONFIG_COREDUMP=y
-+
-+#
-+# Power management options (EXPERIMENTAL)
-+#
-+# CONFIG_PM is not set
-+
-+#
-+# CPU Idle
-+#
-+# CONFIG_CPU_IDLE is not set
-+# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set
-+# CONFIG_NET is not set
-+
-+#
-+# Device Drivers
-+#
-+
-+#
-+# Generic Driver Options
-+#
-+# CONFIG_UEVENT_HELPER is not set
-+CONFIG_DEVTMPFS=y
-+CONFIG_DEVTMPFS_MOUNT=y
-+# CONFIG_STANDALONE is not set
-+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
-+CONFIG_FW_LOADER=y
-+# CONFIG_FIRMWARE_IN_KERNEL is not set
-+CONFIG_EXTRA_FIRMWARE=""
-+# CONFIG_FW_LOADER_USER_HELPER_FALLBACK is not set
-+CONFIG_ALLOW_DEV_COREDUMP=y
-+# CONFIG_SYS_HYPERVISOR is not set
-+# CONFIG_GENERIC_CPU_DEVICES is not set
-+# CONFIG_DMA_SHARED_BUFFER is not set
-+
-+#
-+# Bus devices
-+#
-+# CONFIG_MTD is not set
-+CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
-+# CONFIG_PARPORT is not set
-+# CONFIG_BLK_DEV is not set
-+
-+#
-+# Misc devices
-+#
-+# CONFIG_SENSORS_LIS3LV02D is not set
-+# CONFIG_DUMMY_IRQ is not set
-+# CONFIG_ENCLOSURE_SERVICES is not set
-+# CONFIG_SRAM is not set
-+# CONFIG_C2PORT is not set
-+
-+#
-+# EEPROM support
-+#
-+# CONFIG_EEPROM_93CX6 is not set
-+
-+#
-+# Texas Instruments shared transport line discipline
-+#
-+
-+#
-+# Altera FPGA firmware download module
-+#
-+
-+#
-+# Intel MIC Bus Driver
-+#
-+
-+#
-+# Intel MIC Host Driver
-+#
-+
-+#
-+# Intel MIC Card Driver
-+#
-+# CONFIG_ECHO is not set
-+# CONFIG_CXL_BASE is not set
-+
-+#
-+# SCSI device support
-+#
-+CONFIG_SCSI_MOD=y
-+# CONFIG_RAID_ATTRS is not set
-+# CONFIG_SCSI is not set
-+# CONFIG_SCSI_DMA is not set
-+CONFIG_HAVE_PATA_PLATFORM=y
-+# CONFIG_ATA is not set
-+# CONFIG_MD is not set
-+
-+#
-+# Input device support
-+#
-+CONFIG_INPUT=y
-+# CONFIG_INPUT_FF_MEMLESS is not set
-+# CONFIG_INPUT_POLLDEV is not set
-+# CONFIG_INPUT_SPARSEKMAP is not set
-+# CONFIG_INPUT_MATRIXKMAP is not set
-+
-+#
-+# Userland interfaces
-+#
-+# CONFIG_INPUT_MOUSEDEV is not set
-+# CONFIG_INPUT_JOYDEV is not set
-+# CONFIG_INPUT_EVDEV is not set
-+# CONFIG_INPUT_EVBUG is not set
-+
-+#
-+# Input Device Drivers
-+#
-+# CONFIG_INPUT_KEYBOARD is not set
-+# CONFIG_INPUT_MOUSE is not set
-+# CONFIG_INPUT_JOYSTICK is not set
-+# CONFIG_INPUT_TABLET is not set
-+# CONFIG_INPUT_TOUCHSCREEN is not set
-+# CONFIG_INPUT_MISC is not set
-+
-+#
-+# Hardware I/O ports
-+#
-+# CONFIG_SERIO is not set
-+# CONFIG_GAMEPORT is not set
-+
-+#
-+# Character devices
-+#
-+CONFIG_TTY=y
-+CONFIG_VT=y
-+CONFIG_CONSOLE_TRANSLATIONS=y
-+CONFIG_VT_CONSOLE=y
-+CONFIG_HW_CONSOLE=y
-+# CONFIG_VT_HW_CONSOLE_BINDING is not set
-+CONFIG_UNIX98_PTYS=y
-+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
-+# CONFIG_LEGACY_PTYS is not set
-+# CONFIG_SERIAL_NONSTANDARD is not set
-+# CONFIG_TRACE_SINK is not set
-+CONFIG_DEVMEM=y
-+# CONFIG_DEVKMEM is not set
-+
-+#
-+# Serial drivers
-+#
-+# CONFIG_SERIAL_8250 is not set
-+
-+#
-+# Non-8250 serial port support
-+#
-+CONFIG_SERIAL_UARTLITE=y
-+CONFIG_SERIAL_UARTLITE_CONSOLE=y
-+CONFIG_SERIAL_UARTLITE_0PF=y
-+# CONFIG_SERIAL_SH_SCI is not set
-+CONFIG_SERIAL_CORE=y
-+CONFIG_SERIAL_CORE_CONSOLE=y
-+# CONFIG_SERIAL_SCCNXP is not set
-+# CONFIG_SERIAL_ALTERA_JTAGUART is not set
-+# CONFIG_SERIAL_ALTERA_UART is not set
-+# CONFIG_SERIAL_ARC is not set
-+# CONFIG_SERIAL_FSL_LPUART is not set
-+# CONFIG_IPMI_HANDLER is not set
-+# CONFIG_HW_RANDOM is not set
-+# CONFIG_R3964 is not set
-+# CONFIG_RAW_DRIVER is not set
-+# CONFIG_TCG_TPM is not set
-+
-+#
-+# I2C support
-+#
-+# CONFIG_I2C is not set
-+# CONFIG_SPI is not set
-+# CONFIG_SPMI is not set
-+# CONFIG_HSI is not set
-+
-+#
-+# PPS support
-+#
-+# CONFIG_PPS is not set
-+
-+#
-+# PPS generators support
-+#
-+
-+#
-+# PTP clock support
-+#
-+
-+#
-+# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks.
-+#
-+CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
-+# CONFIG_W1 is not set
-+# CONFIG_POWER_SUPPLY is not set
-+# CONFIG_POWER_AVS is not set
-+# CONFIG_HWMON is not set
-+# CONFIG_THERMAL is not set
-+# CONFIG_WATCHDOG is not set
-+CONFIG_SSB_POSSIBLE=y
-+
-+#
-+# Sonics Silicon Backplane
-+#
-+# CONFIG_SSB is not set
-+CONFIG_BCMA_POSSIBLE=y
-+
-+#
-+# Broadcom specific AMBA
-+#
-+# CONFIG_BCMA is not set
-+
-+#
-+# Multifunction device drivers
-+#
-+# CONFIG_MFD_CORE is not set
-+# CONFIG_MFD_CROS_EC is not set
-+# CONFIG_HTC_PASIC3 is not set
-+# CONFIG_MFD_KEMPLD is not set
-+# CONFIG_MFD_MT6397 is not set
-+# CONFIG_MFD_SM501 is not set
-+# CONFIG_ABX500_CORE is not set
-+# CONFIG_MFD_SYSCON is not set
-+# CONFIG_MFD_TI_AM335X_TSCADC is not set
-+# CONFIG_MFD_TMIO is not set
-+# CONFIG_REGULATOR is not set
-+# CONFIG_MEDIA_SUPPORT is not set
-+
-+#
-+# Graphics support
-+#
-+
-+#
-+# Direct Rendering Manager
-+#
-+
-+#
-+# Frame buffer Devices
-+#
-+# CONFIG_FB is not set
-+# CONFIG_FB_SH_MOBILE_MERAM is not set
-+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
-+# CONFIG_VGASTATE is not set
-+
-+#
-+# Console display driver support
-+#
-+CONFIG_DUMMY_CONSOLE=y
-+CONFIG_DUMMY_CONSOLE_COLUMNS=80
-+CONFIG_DUMMY_CONSOLE_ROWS=25
-+# CONFIG_SOUND is not set
-+
-+#
-+# HID support
-+#
-+# CONFIG_HID is not set
-+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
-+# CONFIG_USB_SUPPORT is not set
-+# CONFIG_UWB is not set
-+# CONFIG_MMC is not set
-+# CONFIG_MEMSTICK is not set
-+# CONFIG_NEW_LEDS is not set
-+# CONFIG_ACCESSIBILITY is not set
-+CONFIG_RTC_LIB=y
-+# CONFIG_RTC_CLASS is not set
-+# CONFIG_DMADEVICES is not set
-+# CONFIG_AUXDISPLAY is not set
-+# CONFIG_VIRT_DRIVERS is not set
-+
-+#
-+# Virtio drivers
-+#
-+# CONFIG_VIRTIO_MMIO is not set
-+
-+#
-+# Microsoft Hyper-V guest support
-+#
-+# CONFIG_STAGING is not set
-+CONFIG_CLKDEV_LOOKUP=y
-+
-+#
-+# Hardware Spinlock drivers
-+#
-+
-+#
-+# Clock Source drivers
-+#
-+# CONFIG_ATMEL_PIT is not set
-+# CONFIG_SH_TIMER_CMT is not set
-+# CONFIG_SH_TIMER_MTU2 is not set
-+# CONFIG_SH_TIMER_TMU is not set
-+# CONFIG_EM_TIMER_STI is not set
-+# CONFIG_MAILBOX is not set
-+
-+#
-+# Remoteproc drivers
-+#
-+# CONFIG_STE_MODEM_RPROC is not set
-+
-+#
-+# Rpmsg drivers
-+#
-+
-+#
-+# SOC (System On Chip) specific Drivers
-+#
-+# CONFIG_SOC_TI is not set
-+# CONFIG_PM_DEVFREQ is not set
-+# CONFIG_EXTCON is not set
-+# CONFIG_MEMORY is not set
-+# CONFIG_IIO is not set
-+# CONFIG_PWM is not set
-+# CONFIG_IPACK_BUS is not set
-+# CONFIG_RESET_CONTROLLER is not set
-+# CONFIG_FMC is not set
-+
-+#
-+# PHY Subsystem
-+#
-+# CONFIG_GENERIC_PHY is not set
-+# CONFIG_BCM_KONA_USB2_PHY is not set
-+# CONFIG_POWERCAP is not set
-+# CONFIG_MCB is not set
-+
-+#
-+# Android
-+#
-+# CONFIG_ANDROID is not set
-+
-+#
-+# File systems
-+#
-+# CONFIG_EXT2_FS is not set
-+# CONFIG_EXT3_FS is not set
-+# CONFIG_EXT4_FS is not set
-+# CONFIG_REISERFS_FS is not set
-+# CONFIG_JFS_FS is not set
-+# CONFIG_BTRFS_FS is not set
-+# CONFIG_NILFS2_FS is not set
-+# CONFIG_F2FS_FS is not set
-+# CONFIG_FS_POSIX_ACL is not set
-+CONFIG_FILE_LOCKING=y
-+# CONFIG_FSNOTIFY is not set
-+# CONFIG_DNOTIFY is not set
-+# CONFIG_INOTIFY_USER is not set
-+# CONFIG_FANOTIFY is not set
-+# CONFIG_QUOTA is not set
-+# CONFIG_QUOTACTL is not set
-+# CONFIG_AUTOFS4_FS is not set
-+# CONFIG_FUSE_FS is not set
-+# CONFIG_OVERLAY_FS is not set
-+
-+#
-+# Caches
-+#
-+# CONFIG_FSCACHE is not set
-+
-+#
-+# CD-ROM/DVD Filesystems
-+#
-+# CONFIG_ISO9660_FS is not set
-+# CONFIG_UDF_FS is not set
-+
-+#
-+# DOS/FAT/NT Filesystems
-+#
-+CONFIG_FAT_FS=y
-+# CONFIG_MSDOS_FS is not set
-+CONFIG_VFAT_FS=y
-+CONFIG_FAT_DEFAULT_CODEPAGE=437
-+CONFIG_FAT_DEFAULT_IOCHARSET="utf8"
-+# CONFIG_NTFS_FS is not set
-+
-+#
-+# Pseudo filesystems
-+#
-+CONFIG_PROC_FS=y
-+CONFIG_PROC_SYSCTL=y
-+CONFIG_KERNFS=y
-+CONFIG_SYSFS=y
-+# CONFIG_HUGETLB_PAGE is not set
-+# CONFIG_CONFIGFS_FS is not set
-+# CONFIG_MISC_FILESYSTEMS is not set
-+CONFIG_NLS=y
-+CONFIG_NLS_DEFAULT="utf8"
-+# CONFIG_NLS_CODEPAGE_437 is not set
-+# CONFIG_NLS_CODEPAGE_737 is not set
-+# CONFIG_NLS_CODEPAGE_775 is not set
-+# CONFIG_NLS_CODEPAGE_850 is not set
-+# CONFIG_NLS_CODEPAGE_852 is not set
-+# CONFIG_NLS_CODEPAGE_855 is not set
-+# CONFIG_NLS_CODEPAGE_857 is not set
-+# CONFIG_NLS_CODEPAGE_860 is not set
-+# CONFIG_NLS_CODEPAGE_861 is not set
-+# CONFIG_NLS_CODEPAGE_862 is not set
-+# CONFIG_NLS_CODEPAGE_863 is not set
-+# CONFIG_NLS_CODEPAGE_864 is not set
-+# CONFIG_NLS_CODEPAGE_865 is not set
-+# CONFIG_NLS_CODEPAGE_866 is not set
-+# CONFIG_NLS_CODEPAGE_869 is not set
-+# CONFIG_NLS_CODEPAGE_936 is not set
-+# CONFIG_NLS_CODEPAGE_950 is not set
-+# CONFIG_NLS_CODEPAGE_932 is not set
-+# CONFIG_NLS_CODEPAGE_949 is not set
-+# CONFIG_NLS_CODEPAGE_874 is not set
-+# CONFIG_NLS_ISO8859_8 is not set
-+# CONFIG_NLS_CODEPAGE_1250 is not set
-+# CONFIG_NLS_CODEPAGE_1251 is not set
-+# CONFIG_NLS_ASCII is not set
-+# CONFIG_NLS_ISO8859_1 is not set
-+# CONFIG_NLS_ISO8859_2 is not set
-+# CONFIG_NLS_ISO8859_3 is not set
-+# CONFIG_NLS_ISO8859_4 is not set
-+# CONFIG_NLS_ISO8859_5 is not set
-+# CONFIG_NLS_ISO8859_6 is not set
-+# CONFIG_NLS_ISO8859_7 is not set
-+# CONFIG_NLS_ISO8859_9 is not set
-+# CONFIG_NLS_ISO8859_13 is not set
-+# CONFIG_NLS_ISO8859_14 is not set
-+# CONFIG_NLS_ISO8859_15 is not set
-+# CONFIG_NLS_KOI8_R is not set
-+# CONFIG_NLS_KOI8_U is not set
-+# CONFIG_NLS_MAC_ROMAN is not set
-+# CONFIG_NLS_MAC_CELTIC is not set
-+# CONFIG_NLS_MAC_CENTEURO is not set
-+# CONFIG_NLS_MAC_CROATIAN is not set
-+# CONFIG_NLS_MAC_CYRILLIC is not set
-+# CONFIG_NLS_MAC_GAELIC is not set
-+# CONFIG_NLS_MAC_GREEK is not set
-+# CONFIG_NLS_MAC_ICELAND is not set
-+# CONFIG_NLS_MAC_INUIT is not set
-+# CONFIG_NLS_MAC_ROMANIAN is not set
-+# CONFIG_NLS_MAC_TURKISH is not set
-+CONFIG_NLS_UTF8=y
-+
-+#
-+# Kernel hacking
-+#
-+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
-+
-+#
-+# printk and dmesg options
-+#
-+# CONFIG_PRINTK_TIME is not set
-+CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4
-+
-+#
-+# Compile-time checks and compiler options
-+#
-+# CONFIG_ENABLE_WARN_DEPRECATED is not set
-+# CONFIG_ENABLE_MUST_CHECK is not set
-+CONFIG_FRAME_WARN=1024
-+# CONFIG_STRIP_ASM_SYMS is not set
-+# CONFIG_UNUSED_SYMBOLS is not set
-+# CONFIG_DEBUG_FS is not set
-+# CONFIG_HEADERS_CHECK is not set
-+# CONFIG_DEBUG_SECTION_MISMATCH is not set
-+# CONFIG_MAGIC_SYSRQ is not set
-+# CONFIG_DEBUG_KERNEL is not set
-+
-+#
-+# Memory Debugging
-+#
-+# CONFIG_PAGE_EXTENSION is not set
-+# CONFIG_SLUB_DEBUG_ON is not set
-+# CONFIG_SLUB_STATS is not set
-+CONFIG_HAVE_DEBUG_KMEMLEAK=y
-+CONFIG_DEBUG_MEMORY_INIT=y
-+
-+#
-+# Debug Lockups and Hangs
-+#
-+# CONFIG_PANIC_ON_OOPS is not set
-+CONFIG_PANIC_ON_OOPS_VALUE=0
-+CONFIG_PANIC_TIMEOUT=0
-+# CONFIG_DEBUG_TIMEKEEPING is not set
-+
-+#
-+# Lock Debugging (spinlocks, mutexes, etc...)
-+#
-+# CONFIG_STACKTRACE is not set
-+CONFIG_HAVE_DEBUG_BUGVERBOSE=y
-+CONFIG_DEBUG_BUGVERBOSE=y
-+
-+#
-+# RCU Debugging
-+#
-+# CONFIG_PROVE_RCU is not set
-+# CONFIG_SPARSE_RCU_POINTER is not set
-+# CONFIG_TORTURE_TEST is not set
-+CONFIG_HAVE_FUNCTION_TRACER=y
-+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
-+CONFIG_HAVE_DYNAMIC_FTRACE=y
-+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
-+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
-+CONFIG_TRACING_SUPPORT=y
-+# CONFIG_FTRACE is not set
-+
-+#
-+# Runtime Testing
-+#
-+# CONFIG_ATOMIC64_SELFTEST is not set
-+# CONFIG_TEST_HEXDUMP is not set
-+# CONFIG_TEST_STRING_HELPERS is not set
-+# CONFIG_TEST_KSTRTOX is not set
-+# CONFIG_TEST_RHASHTABLE is not set
-+# CONFIG_DMA_API_DEBUG is not set
-+# CONFIG_TEST_FIRMWARE is not set
-+# CONFIG_TEST_UDELAY is not set
-+# CONFIG_MEMTEST is not set
-+# CONFIG_SAMPLES is not set
-+CONFIG_HAVE_ARCH_KGDB=y
-+# CONFIG_SH_STANDARD_BIOS is not set
-+# CONFIG_DWARF_UNWINDER is not set
-+
-+#
-+# Security options
-+#
-+# CONFIG_KEYS is not set
-+# CONFIG_SECURITY_DMESG_RESTRICT is not set
-+# CONFIG_SECURITY is not set
-+# CONFIG_SECURITYFS is not set
-+CONFIG_DEFAULT_SECURITY_DAC=y
-+CONFIG_DEFAULT_SECURITY=""
-+# CONFIG_CRYPTO is not set
-+# CONFIG_BINARY_PRINTF is not set
-+
-+#
-+# Library routines
-+#
-+CONFIG_BITREVERSE=y
-+# CONFIG_HAVE_ARCH_BITREVERSE is not set
-+CONFIG_GENERIC_STRNCPY_FROM_USER=y
-+CONFIG_GENERIC_STRNLEN_USER=y
-+CONFIG_GENERIC_IO=y
-+# CONFIG_CRC_CCITT is not set
-+# CONFIG_CRC16 is not set
-+# CONFIG_CRC_T10DIF is not set
-+# CONFIG_CRC_ITU_T is not set
-+CONFIG_CRC32=y
-+# CONFIG_CRC32_SELFTEST is not set
-+CONFIG_CRC32_SLICEBY8=y
-+# CONFIG_CRC32_SLICEBY4 is not set
-+# CONFIG_CRC32_SARWATE is not set
-+# CONFIG_CRC32_BIT is not set
-+# CONFIG_CRC7 is not set
-+# CONFIG_LIBCRC32C is not set
-+# CONFIG_CRC8 is not set
-+# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set
-+# CONFIG_RANDOM32_SELFTEST is not set
-+# CONFIG_XZ_DEC is not set
-+# CONFIG_XZ_DEC_BCJ is not set
-+CONFIG_HAS_IOMEM=y
-+CONFIG_HAS_DMA=y
-+CONFIG_GENERIC_ATOMIC64=y
-+CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
-+# CONFIG_AVERAGE is not set
-+# CONFIG_CORDIC is not set
-+# CONFIG_DDR is not set
-+# CONFIG_ARCH_HAS_SG_CHAIN is not set
-diff -Nur linux-4.1.13.orig/arch/sh/include/asm/board-0pf.h linux-4.1.13/arch/sh/include/asm/board-0pf.h
---- linux-4.1.13.orig/arch/sh/include/asm/board-0pf.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.13/arch/sh/include/asm/board-0pf.h 2015-12-05 00:16:48.000000000 +0100
-@@ -0,0 +1,247 @@
-+#ifndef SGM_BOARD_H
-+#define SGM_BOARD_H
-+
-+#define sys_IntTable (*(unsigned*)0x0)
-+#define sys_IntVectors 256
-+
-+/* Some of interrupt is fixed vector */
-+#define Irq_MRES 0x02 /* Manual reset */
-+#define Irq_CPUERR 0x09
-+#define Irq_DMAERR 0x0a
-+#define Irq_NMI 0x0b
-+#define Irq_PIT 0x10 /* 100 Hz PIT */
-+#define Irq_EMAC 0x11 /* irqs(0) */
-+#define Irq_UART0 0x12 /* irqs(1) */
-+#define Irq_GPS 0x13 /* irqs(2) */
-+#define Irq_Ext 0x14 /* irqs(3) use by CS42518*/
-+#define Irq_1PPS 0x16 /* irqs(5) */
-+#define Irq_UART1 0x17 /* irqs(6) */
-+#define Irq_I2C 0x18 /* irqs(7) */
-+#define Irq_TMR 0x19 /* a 12 bit countdown counter */
-+#define Irq_GPIO 0x15
-+
-+/* External interrupt IDs */
-+#define EIrqID_EMAC 0
-+#define EIrqID_UART0 1
-+#define EIrqID_GPS 2
-+#define EIrqID_Ext 3
-+#define EIrqID_GPIO 4
-+#define EIrqID_1PPS 5
-+#define EIrqID_UART1 6
-+#define EIrqID_I2C 7
-+
-+/* External Interrupt ID convert to interrupt vector */
-+#define ID2Vect(x) (0x11 + (x))
-+
-+/* Convert external interupt ID to priority value */
-+#define ID2Pri(id, pri) ((pri) << ((id) <<2))
-+
-+/* Convert vector to interrupt entry address */
-+#define Vect2Irq(x) ((x) << 2)
-+
-+#define PIT_IRQ Vect2Irq(Irq_PIT)
-+#define EMAC_IRQ Vect2Irq(Irq_EMAC)
-+#define UART0_IRQ Vect2Irq(Irq_UART0)
-+#define GPS_IRQ Vect2Irq(Irq_GPS)
-+#define EXT_IRQ Vect2Irq(Irq_Ext)
-+#define UART1_IRQ Vect2Irq(Irq_UART1)
-+#define I2C_IRQ Vect2Irq(Irq_I2C)
-+#define TMR_IRQ Vect2Irq(Irq_TMR)
-+
-+
-+/* End of interrupt definations */
-+#define sys_RAM_BASE 0x10000000
-+#define sys_PIO_BASE 0xabcd0000
-+#define sys_SPI_BASE 0xabcd0040
-+#define sys_I2C_BASE 0xabcd0080 // 0xabcd0020
-+#define sys_UART0_BASE 0xabcd0100
-+#define sys_SYS_BASE 0xabcd0200
-+#define sys_UART1_BASE 0xabcd0300
-+#define sys_GPS_BASE 0xabcd0400
-+#define sys_D2A_BASE 0xabcd0500
-+#define sys_EMAC_BASE 0xabce0000
-+
-+#define AQ_PIO (*(volatile unsigned int *)sys_PIO_BASE)
-+#define AQ_I2C (*(volatile unsigned int *)sys_I2C_BASE)
-+#define AQ_SPI (*(volatile unsigned int *)sys_SPI_BASE)
-+#define AQ_UART0 (*(volatile unsigned int *)sys_UART0_BASE)
-+#define AQ_SYS (*(volatile unsigned int *)sys_SYS_BASE)
-+#define AQ_UART1 (*(volatile unsigned int *)sys_UART1_BASE)
-+#define AQ_GPS (*(volatile unsigned int *)sys_GPS_BASE)
-+#define AQ_D2A (*(volatile unsigned int *)sys_D2A_BASE)
-+#define AQ_EMAC (*(volatile unsigned int *)sys_EMAC_BASE)
-+
-+
-+struct st_uart16550
-+{
-+ unsigned int RTX;
-+ unsigned int IER;
-+ unsigned int IIR;
-+ unsigned int LCR;
-+ unsigned int MCR;
-+ unsigned int LSR;
-+ unsigned int MSR;
-+ unsigned int SCR;
-+};
-+#define uLSRDR 0x01
-+#define uLSROE 0x02
-+#define uLSRPE 0x04
-+#define uLSRFE 0x08
-+#define uLSRBI 0x10
-+#define uLSRTHRE 0x20
-+#define uLSRTEMT 0x40
-+#define uLSRRFE 0x80 /* Error in Revr FIFO */
-+
-+#if 0
-+#define B115200 0x000a
-+#define B38400 0x001e
-+#define B19200 0x003c
-+#define B9600 0x0078
-+#define B4800 0x00f0
-+#endif
-+
-+/* the following is belong to sys_SYS_BASE */
-+#define Sys_IntCon 0x0
-+/* When SIC_BRKON is set, BreadAddress will compare with Bus address to generate NMI interrupt */
-+#define Sys_BRKADR 0x04
-+/* Interrupt priority is 4 bits width, irqs(0) is [3,0], irqs(1) is [7,4] ... */
-+#define Sys_IntPri 0x08
-+/* End of offset define of sys_SYS_BASE */
-+/* Refer to Aquarius datasheet Page 12, NMI is lvl16, and lvl0 will not be accept */
-+/* Refer to define.v, IBit in SR [7:4] */
-+#define SIC_ENMI ((unsigned int) 0x1<<31) /* Emulate NMI */
-+#define SIC EIRQ ((unsigned int) 0x1<<30) /* Emulate IRQ */
-+#define SIC_ECER ((unsigned int) 0x1<<29) /* Emulate CPU Address Error */
-+#define SIC_EDER ((unsigned int) 0x1<<28) /* Emulate DMA Address Error */
-+#define SIC_EMRS ((unsigned int) 0x1<<27) /* Emulate Manual Reset */
-+#define SIC_EPIT ((unsigned int) 0x1<<26) /* Enable Periodical interval timer(PIT) */
-+#define SIC_TMRON ((unsigned int) 0x1<<25) /* Enable timer */
-+#define SIC_BRKON ((unsigned int) 0x1<<24) /* Break ON */
-+#define SIC_ILVL ((unsigned int) 0xF<<20) /* interrupt level for PIT */
-+#define SIC_IVEC ((unsigned int) 0xFF<<12) /* Interrupt Vector for PIT */
-+#define SIC_TMR ((unsigned int)0xFFF) /* Interval Timer when 0x0, it request IRQ*/
-+
-+/* PIO registers offset */
-+#define Poffset_IO 0x00
-+#define Poffset_imask 0x04
-+#define Poffset_redge 0x08
-+#define Poffset_changes 0x0c
-+
-+/* Keys are connected to Parallel Input, Active low */
-+#define Pio_KeyEnter 0x0001
-+#define Pio_KeyESC 0x0002
-+#define Pio_KeyNorth 0x0020
-+#define Pio_KeyEast 0x0040
-+#define Pio_KeySouth 0x0080
-+#define Pio_KeyWest 0x0100
-+
-+/* SD_CD is active high of this bit */
-+#define Pio_SD_CD 0x00200000
-+
-+#define Pio_1PPS 0x00800000
-+
-+/* IMPORTANT!!! Pio_LEDPwr is connected with with reset pins of USB, ETH-PHY
-+ * and GPS. DON'T CHANGE IT or use it for now!!!
-+ * TODO: VHDL needs to fix Power LED to other location with set and reset feature
-+ */
-+#define Pio_LEDPwr 0x0010
-+#define Pio_LEDErr 0x0020
-+#define Pio_TP70 0x0040
-+
-+#if 0
-+ #define I2c_busy 0x8000
-+ #define I2c_next 0x4000
-+ #define I2c_ack 0x2000
-+ #define I2c_timeout 0x1000
-+ #define I2c_timer 0x0800
-+ #define I2c_mask 0xf800
-+#else
-+ #define I2cO_ctrl 0x00
-+ #define I2cO_slen 0x04
-+ #define I2cO_word 0x0C
-+
-+ /* for I2cO_ctrl */
-+ #define I2cC_busy 0x01
-+ #define I2cC_timeout 0x02
-+ #define I2cC_complete 0x04
-+ #define I2cC_reset 0x08
-+ #define I2cC_run 0x10
-+ #define I2cC_irqen 0x20
-+ #define I2cC_clk 0x40
-+ #define I2cC_dat 0x80
-+ #define I2cC_MaskDelay 0xff00
-+ #define I2c_delay(x) ((x)<< 8)
-+ #define I2cC_MaskAckTimeout 0xf0000
-+ #define I2c_timeout(x) ((x) << 16)
-+ /* for I2cO_slen */
-+ #define I2cS_MaskXlen 0x1f
-+ #define I2cS_MaxLen 16
-+ #define I2cS_MaskSpeed 0x30000
-+ #define I2cS_100k 0x0
-+ #define I2cS_400k 0x10000
-+ #define I2cS_1m 0x20000
-+ #define I2cS_3m4 0x30000
-+ #define I2cS_Maskwordcount 0xf80000
-+#endif
-+
-+/***********************************************************/
-+/************************************ EMAC **************/
-+/***********************************************************/
-+
-+#define AQ_EMAC_BASE 0xABCE0000
-+#define AQ_EMAC_CONTROL 0xABCE0000
-+#define AQ_EMAC_STATUS 0xABCE0000
-+
-+/* Control bits */
-+#define AQ_EMAC_ENABLE_RX 0x00000002
-+#define AQ_EMAC_ENABLE_TX 0x00000004
-+#define AQ_EMAC_READ 0x00000010
-+#define AQ_EMAC_ENABLE_INT_RX 0x00000020
-+#define AQ_EMAC_ENABLE_INT_TX 0x00000040
-+
-+/* Status bits */
-+#define AQ_EMAC_TX_BUSY 0x00000004
-+#define AQ_EMAC_COMPLETE 0x00000100
-+#define AQ_EMAC_CRC 0x00000200
-+
-+#define AQ_EMAC_TX_LEN 0xABCE0004
-+#define AQ_EMAC_MACL 0xABCE0008
-+#define AQ_EMAC_MACH 0xABCE000C
-+#define AQ_EMAC_RX_BUF 0xABCE1000
-+#define AQ_EMAC_TX_BUF 0xABCE1800
-+
-+#define Emac_Rbuf 0x1000
-+#define Emac_Xbuf 0x1800
-+#define Emac_Ctrl 0x0000
-+#define Emac_xlen 0x0004
-+#define Emac_MACL 0x0008
-+#define Emac_MACH 0x000c
-+#define ECtrl_RecvEnable 0x2 /* Receive enable */
-+#define ECtrl_Xmit 0x4 /* Read: Transmit busy(1); Write: Start transmit(1) */
-+#define ECtrl_MACReset 0x8 /* Reset MAC address */
-+#define ECtrl_Read 0x10 /* complete read from Receive FIFO */
-+#define ECtrl_RIntEnable 0x20 /* Receive interrupt enable(1) */
-+#define ECtrl_XIntEnable 0x40 /* Transmit interrupt enable(1) */
-+#define ECtrl_PROM 0x80 /* Promiscuous Mode enable(1)/disable(0) */
-+#define ECtrl_Complete 0x100 /* Receive packet waiting in FIFO */
-+#define ECtrl_CRC 0x200 /* Receive packet has CRC error */
-+#define ECtrl_getrxlen(x) ((x) >> 16) /* Length of received package, when ECtrl_Complete is set */
-+
-+#define Spi_Ctrl 0x0
-+#define Spi_Data 0x4
-+#define SpiCtrl_ACS 0x01 /* chipselect for applcation data */
-+#define SpiCtrl_CCS 0x04 /* chipselect for FPGA configure */
-+#define SpiCtrl_DCS 0x10 /* chipselect for D2A or extra SPI device */
-+#define SpiCtrl_setDiv(x) ((x) << 27) /* Div contrl SPI_CK = 12.5/(div + 1), Min: 400KHz for now*/
-+#define SpiCtrl_Xmit 0x02
-+#define SpiCtrl_Busy 0x02
-+#define SpiCtrl_Loop 0x08 /* When it assert, mosi will connect to miso */
-+/* by default SPI run at 12.5 MHz,maxium speed for Spartan 3E, for SPI Flash
-+ * We need a DDS delay for different devices
-+ */
-+
-+#define SHJ_PIT_PMR 0xABCD0210
-+#define SHJ_PIT_PCNTR 0xABCD0214
-+#define SHJ_NSEC_PER_CLOCK 0xABCD0218
-+
-+#endif
-diff -Nur linux-4.1.13.orig/arch/sh/include/asm/processor.h linux-4.1.13/arch/sh/include/asm/processor.h
---- linux-4.1.13.orig/arch/sh/include/asm/processor.h 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/include/asm/processor.h 2015-12-05 00:16:49.000000000 +0100
-@@ -15,7 +15,7 @@
- */
- enum cpu_type {
- /* SH-2 types */
-- CPU_SH7619,
-+ CPU_SH7619, CPU_0PF,
-
- /* SH-2A types */
- CPU_SH7201, CPU_SH7203, CPU_SH7206, CPU_SH7263, CPU_SH7264, CPU_SH7269,
-diff -Nur linux-4.1.13.orig/arch/sh/include/cpu-sh2/cpu/cache.h linux-4.1.13/arch/sh/include/cpu-sh2/cpu/cache.h
---- linux-4.1.13.orig/arch/sh/include/cpu-sh2/cpu/cache.h 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/include/cpu-sh2/cpu/cache.h 2015-12-05 00:16:49.000000000 +0100
-@@ -38,6 +38,10 @@
- #define CCR_CACHE_INVALIDATE CCR_CACHE_CF
- #define CACHE_PHYSADDR_MASK 0x1ffffc00
-
-+#elif defined(CONFIG_CPU_SUBTYPE_0PF)
-+#define CCR 0xabcd00c0
-+#define CCR_CACHE_ENABLE 0x80000000
-+#define CCR_CACHE_RESET 0x101
- #endif
-
- #endif /* __ASM_CPU_SH2_CACHE_H */
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/init.c linux-4.1.13/arch/sh/kernel/cpu/init.c
---- linux-4.1.13.orig/arch/sh/kernel/cpu/init.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/init.c 2015-12-05 00:16:49.000000000 +0100
-@@ -106,7 +106,7 @@
- /*
- * Generic first-level cache init
- */
--#ifdef CONFIG_SUPERH32
-+#if defined(CONFIG_SUPERH32) && !defined(CONFIG_CPU_SUBTYPE_0PF)
- static void cache_init(void)
- {
- unsigned long ccr, flags;
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/proc.c linux-4.1.13/arch/sh/kernel/cpu/proc.c
---- linux-4.1.13.orig/arch/sh/kernel/cpu/proc.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/proc.c 2015-12-05 00:16:49.000000000 +0100
-@@ -26,6 +26,7 @@
- [CPU_SH5_101] = "SH5-101", [CPU_SH5_103] = "SH5-103",
- [CPU_MXG] = "MX-G", [CPU_SH7723] = "SH7723",
- [CPU_SH7366] = "SH7366", [CPU_SH7724] = "SH7724",
-+ [CPU_0PF] = "SH2J-0PF",
- [CPU_SH7372] = "SH7372", [CPU_SH7734] = "SH7734",
- [CPU_SH_NONE] = "Unknown"
- };
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/Makefile linux-4.1.13/arch/sh/kernel/cpu/sh2/Makefile
---- linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/Makefile 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/sh2/Makefile 2015-12-05 00:16:49.000000000 +0100
-@@ -5,3 +5,4 @@
- obj-y := ex.o probe.o entry.o
-
- obj-$(CONFIG_CPU_SUBTYPE_SH7619) += setup-sh7619.o clock-sh7619.o
-+obj-$(CONFIG_CPU_SUBTYPE_0PF) += setup-0pf.o clock-0pf.o
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/clock-0pf.c linux-4.1.13/arch/sh/kernel/cpu/sh2/clock-0pf.c
---- linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/clock-0pf.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/sh2/clock-0pf.c 2015-12-05 00:16:48.000000000 +0100
-@@ -0,0 +1,80 @@
-+/*
-+ * arch/sh/kernel/cpu/sh2/clock-0pf.c
-+ *
-+ * 0PF FPGA support for the clock framework
-+ *
-+ * Copyright (C) 2012 SEI, Inc.
-+ *
-+ * Based on clock-sh4.c
-+ * Copyright (C) 2005 Paul Mundt
-+ * Copyright (C) 2009 D. Jeff Dionne
-+ *
-+ * This file is subject to the terms and conditions of the GNU General Public
-+ * License. See the file "COPYING" in the main directory of this archive
-+ * for more details.
-+ */
-+#include <linux/init.h>
-+#include <linux/kernel.h>
-+#include <asm/clock.h>
-+#include <linux/timex.h>
-+#include <linux/profile.h>
-+#include <linux/interrupt.h>
-+#include <linux/irq.h>
-+
-+#include <asm/freq.h>
-+#include <asm/io.h>
-+
-+static void master_clk_init(struct clk *clk)
-+{
-+ clk->rate = CONFIG_SH_PCLK_FREQ; /* Fixed Rate */
-+}
-+
-+static struct sh_clk_ops shj_master_clk_ops = {
-+ .init = master_clk_init,
-+};
-+
-+static unsigned long module_clk_recalc(struct clk *clk)
-+{
-+ return clk->parent->rate;
-+}
-+
-+static struct sh_clk_ops shj_module_clk_ops = {
-+ .recalc = module_clk_recalc,
-+};
-+
-+static unsigned long bus_clk_recalc(struct clk *clk)
-+{
-+ return clk->parent->rate;
-+}
-+
-+static struct sh_clk_ops shj_bus_clk_ops = {
-+ .recalc = bus_clk_recalc,
-+};
-+
-+static struct sh_clk_ops shj_cpu_clk_ops = {
-+ .recalc = followparent_recalc,
-+};
-+
-+static struct sh_clk_ops *shj_clk_ops[] = {
-+ &shj_master_clk_ops,
-+ &shj_module_clk_ops,
-+ &shj_bus_clk_ops,
-+ &shj_cpu_clk_ops,
-+};
-+
-+void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
-+{
-+ if (idx < ARRAY_SIZE(shj_clk_ops))
-+ *ops = shj_clk_ops[idx];
-+}
-+
-+int __init arch_clk_init()
-+{
-+ int ret;
-+
-+ printk("%s(): 0PF Clock init...\n", __func__);
-+
-+ ret = cpg_clk_init(); /* appease Over-engineered "clock infrastructure" */
-+
-+ return ret;
-+}
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/entry.S linux-4.1.13/arch/sh/kernel/cpu/sh2/entry.S
---- linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/entry.S 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/sh2/entry.S 2015-12-05 00:16:49.000000000 +0100
-@@ -3,6 +3,7 @@
- *
- * The SH-2 exception entry
- *
-+ * Copyright (C) 2012 SEI,Inc.
- * Copyright (C) 2005-2008 Yoshinori Sato
- * Copyright (C) 2005 AXE,Inc.
- *
-@@ -147,7 +148,11 @@
- mov #32,r8
- cmp/hs r8,r9
- bt trap_entry ! 64 > vec >= 32 is trap
--
-+#if defined(CONFIG_CPU_SUBTYPE_0PF)
-+ mov #16,r8
-+ cmp/hs r8,r9
-+ bt interrupt_entry ! 32 > vec >= 16 is interrupt
-+#endif
- mov.l 4f,r8
- mov r9,r4
- shll2 r9
-@@ -245,6 +250,19 @@
- .align 2
- 1: .long do_address_error
-
-+#if defined(CONFIG_CPU_SUBTYPE_0PF)
-+ENTRY(pc_address_error_trap_handler)
-+ mov r15,r4 ! regs
-+ mov #OFF_PC,r0
-+ mov.l @(r0,r15),r6 ! pc
-+ mov.l 1f,r0
-+ jmp @r0
-+ mov #0,r5 ! writeaccess is unknown
-+
-+ .align 2
-+1: .long do_pc_address_error
-+#endif // CONFIG_CPU_SUBTYPE_0PF
-+
- restore_all:
- stc sr,r0
- or #0xf0,r0
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/probe.c linux-4.1.13/arch/sh/kernel/cpu/sh2/probe.c
---- linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/probe.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/sh2/probe.c 2015-12-05 00:16:49.000000000 +0100
-@@ -24,6 +24,12 @@
- boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
- boot_cpu_data.dcache.flags = 0;
- #endif
-+
-+#if defined(CONFIG_CPU_SUBTYPE_0PF)
-+ boot_cpu_data.type = CPU_0PF;
-+ boot_cpu_data.dcache.flags = 0;
-+#endif
-+
- /*
- * SH-2 doesn't have separate caches
- */
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/setup-0pf.c linux-4.1.13/arch/sh/kernel/cpu/sh2/setup-0pf.c
---- linux-4.1.13.orig/arch/sh/kernel/cpu/sh2/setup-0pf.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/cpu/sh2/setup-0pf.c 2015-12-05 00:16:48.000000000 +0100
-@@ -0,0 +1,82 @@
-+/*
-+ * 0PF-FPGA Setup
-+ *
-+ * Copyright (C) 2006 Yoshinori Sato
-+ * Copyright (C) 2009 Paul Mundt
-+ * Copyright (C) 2009 D. Jeff Dionne
-+ * Copyright (C) 2012 SEI, Inc.
-+ * by Oleksandr Zhadan
-+ *
-+ * This file is subject to the terms and conditions of the GNU General Public
-+ * License. See the file "COPYING" in the main directory of this archive
-+ * for more details.
-+ */
-+#include <linux/platform_device.h>
-+#include <linux/init.h>
-+#include <linux/module.h>
-+#include <linux/io.h>
-+#include <linux/interrupt.h>
-+#include <linux/irq.h>
-+#include <linux/serial_8250.h>
-+#include <asm/board-0pf.h>
-+
-+#if defined(CONFIG_SERIAL_UARTLITE_0PF)
-+static struct resource shj_uartlite_resources[] = {
-+ [0] = DEFINE_RES_MEM(0xABCD0100, 16),
-+ [1] = DEFINE_RES_IRQ(0x12),
-+
-+ [2] = DEFINE_RES_MEM(0xABCD0300, 16),
-+ [3] = DEFINE_RES_IRQ(0x17),
-+
-+ [4] = DEFINE_RES_MEM(0xABCD0400, 16),
-+ [5] = DEFINE_RES_IRQ(0x13),
-+};
-+
-+static struct platform_device shj_uartlite_device[] = {
-+ [0] = { .name = "uartlite", .id = 0 },
-+ [1] = { .name = "uartlite", .id = 1 },
-+ [2] = { .name = "uartlite", .id = 2 },
-+};
-+#endif
-+
-+/*****************************************************************************
-+ * 0PF FPGA platform devices
-+ ****************************************************************************/
-+static struct platform_device *shj_devices[] __initdata = {
-+#if defined(CONFIG_SERIAL_UARTLITE_0PF)
-+ shj_uartlite_device,
-+ shj_uartlite_device + 1,
-+ shj_uartlite_device + 2,
-+#endif
-+};
-+
-+static int __init shj_devices_setup(void)
-+{
-+ int i;
-+ pr_info("%s(): registering device resources\n", __func__);
-+
-+#if defined(CONFIG_SERIAL_UARTLITE_0PF)
-+ for (i = 0; i < ARRAY_SIZE(shj_uartlite_device); i++) {
-+ printk("Register UARTLITE resources %d\n", i);
-+ if (platform_device_add_resources(
-+ shj_uartlite_device + i,
-+ shj_uartlite_resources + 2 * i,
-+ 2))
-+ pr_err("Failed to set uartlite %d IRQ and MEM\n", i);
-+
-+ }
-+#endif
-+ platform_add_devices(shj_devices, ARRAY_SIZE(shj_devices));
-+
-+ return 0;
-+}
-+
-+arch_initcall(shj_devices_setup);
-+
-+void __init native_machine_early_platform_add_devices(void)
-+{
-+}
-+
-+void __init plat_irq_setup(void)
-+{
-+}
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/irq.c linux-4.1.13/arch/sh/kernel/irq.c
---- linux-4.1.13.orig/arch/sh/kernel/irq.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/irq.c 2015-12-05 00:16:49.000000000 +0100
-@@ -20,6 +20,8 @@
- #include <asm/thread_info.h>
- #include <cpu/mmu_context.h>
-
-+#include <asm/board-0pf.h>
-+
- atomic_t irq_err_count;
-
- /*
-@@ -175,11 +177,24 @@
- );
- }
- #else
-+#define noinline __attribute__((noinline))
-+static noinline void handle_irq_UART0(unsigned int irq) { generic_handle_irq(irq); }
-+static noinline void handle_irq_UART1(unsigned int irq) { generic_handle_irq(irq); }
-+static noinline void handle_irq_GPS(unsigned int irq) { generic_handle_irq(irq); }
-+static noinline void handle_irq_EMAC(unsigned int irq) { generic_handle_irq(irq); }
- static inline void handle_one_irq(unsigned int irq)
- {
-- generic_handle_irq(irq);
-+ switch(irq) {
-+ case Irq_UART0: handle_irq_UART0(irq); break;
-+ case Irq_UART1: handle_irq_UART1(irq); break;
-+ case Irq_GPS: handle_irq_GPS(irq); break;
-+ case Irq_EMAC: handle_irq_EMAC(irq); break;
-+ default:
-+ generic_handle_irq(irq);
-+ break;
-+ }
- }
--#endif
-+#endif // CONFIG_IRQSTACKS
-
- asmlinkage __irq_entry int do_IRQ(unsigned int irq, struct pt_regs *regs)
- {
-diff -Nur linux-4.1.13.orig/arch/sh/kernel/traps_32.c linux-4.1.13/arch/sh/kernel/traps_32.c
---- linux-4.1.13.orig/arch/sh/kernel/traps_32.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/kernel/traps_32.c 2015-12-05 00:16:49.000000000 +0100
-@@ -34,6 +34,7 @@
- #ifdef CONFIG_CPU_SH2
- # define TRAP_RESERVED_INST 4
- # define TRAP_ILLEGAL_SLOT_INST 6
-+# define TRAP_PC_ADDRESS_ERROR 8 // Aug 20, 2012 ulianov - SEI extension - PC governor
- # define TRAP_ADDRESS_ERROR 9
- # ifdef CONFIG_CPU_SH2A
- # define TRAP_UBC 12
-@@ -458,6 +459,14 @@
- return ret;
- }
-
-+#if defined(CONFIG_CPU_SUBTYPE_0PF)
-+asmlinkage void do_pc_address_error(struct pt_regs *regs,
-+ unsigned long writeaccess,
-+ unsigned long address)
-+{
-+}
-+#endif // CONFIG_CPU_SUBTYPE_0PF
-+
- /*
- * Handle various address error exceptions:
- * - instruction address error:
-@@ -779,6 +788,9 @@
- #endif
-
- #ifdef CONFIG_CPU_SH2
-+ #if defined(CONFIG_CPU_SUBTYPE_0PF)
-+ set_exception_table_vec(TRAP_PC_ADDRESS_ERROR, address_error_trap_handler);
-+ #endif
- set_exception_table_vec(TRAP_ADDRESS_ERROR, address_error_trap_handler);
- #endif
- #ifdef CONFIG_CPU_SH2A
-diff -Nur linux-4.1.13.orig/arch/sh/mm/cache-sh2.c linux-4.1.13/arch/sh/mm/cache-sh2.c
---- linux-4.1.13.orig/arch/sh/mm/cache-sh2.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/mm/cache-sh2.c 2015-12-05 00:16:49.000000000 +0100
-@@ -3,6 +3,7 @@
- *
- * Copyright (C) 2002 Paul Mundt
- * Copyright (C) 2008 Yoshinori Sato
-+ * Copyright (C) 2012 SEI, Inc.
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-@@ -16,6 +17,30 @@
- #include <asm/cacheflush.h>
- #include <asm/io.h>
-
-+#if defined(CONFIG_CPU_SUBTYPE_0PF)
-+
-+// Just flush the whole thing each time
-+static void j2_flush_icache_range(void *fwoosh)
-+{
-+ __raw_writel(CCR_CACHE_RESET, CCR);
-+}
-+
-+// This should never happen, but...
-+static void j2_flush_icache_page(void *fwoosh)
-+{
-+ __raw_writel(CCR_CACHE_RESET, CCR);
-+}
-+
-+void __init sh2_cache_init(void)
-+{
-+ local_flush_icache_range = j2_flush_icache_range;
-+ local_flush_icache_page = j2_flush_icache_page;
-+ boot_cpu_data.dcache.n_aliases = 0;
-+
-+ __raw_writel(CCR_CACHE_RESET, CCR);
-+}
-+
-+#else
- static void sh2__flush_wback_region(void *start, int size)
- {
- unsigned long v;
-@@ -89,3 +114,4 @@
- __flush_purge_region = sh2__flush_purge_region;
- __flush_invalidate_region = sh2__flush_invalidate_region;
- }
-+#endif
-diff -Nur linux-4.1.13.orig/arch/sh/mm/cache.c linux-4.1.13/arch/sh/mm/cache.c
---- linux-4.1.13.orig/arch/sh/mm/cache.c 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/arch/sh/mm/cache.c 2015-12-05 00:16:49.000000000 +0100
-@@ -258,14 +258,16 @@
- boot_cpu_data.icache.entry_mask,
- boot_cpu_data.icache.alias_mask,
- boot_cpu_data.icache.n_aliases);
-- printk(KERN_NOTICE "D-cache : n_ways=%d n_sets=%d way_incr=%d\n",
-- boot_cpu_data.dcache.ways,
-- boot_cpu_data.dcache.sets,
-- boot_cpu_data.dcache.way_incr);
-- printk(KERN_NOTICE "D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
-- boot_cpu_data.dcache.entry_mask,
-- boot_cpu_data.dcache.alias_mask,
-- boot_cpu_data.dcache.n_aliases);
-+ if (boot_cpu_data.dcache.n_aliases) {
-+ printk(KERN_NOTICE "D-cache : n_ways=%d n_sets=%d way_incr=%d\n",
-+ boot_cpu_data.dcache.ways,
-+ boot_cpu_data.dcache.sets,
-+ boot_cpu_data.dcache.way_incr);
-+ printk(KERN_NOTICE "D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
-+ boot_cpu_data.dcache.entry_mask,
-+ boot_cpu_data.dcache.alias_mask,
-+ boot_cpu_data.dcache.n_aliases);
-+ }
-
- /*
- * Emit Secondary Cache parameters if the CPU has a probed L2.
-diff -Nur linux-4.1.13.orig/drivers/tty/serial/Kconfig linux-4.1.13/drivers/tty/serial/Kconfig
---- linux-4.1.13.orig/drivers/tty/serial/Kconfig 2015-11-09 23:34:10.000000000 +0100
-+++ linux-4.1.13/drivers/tty/serial/Kconfig 2015-12-05 00:16:49.000000000 +0100
-@@ -594,7 +594,7 @@
-
- config SERIAL_UARTLITE
- tristate "Xilinx uartlite serial port support"
-- depends on PPC32 || MICROBLAZE || MFD_TIMBERDALE || ARCH_ZYNQ
-+ depends on PPC32 || MICROBLAZE || MFD_TIMBERDALE || ARCH_ZYNQ || CPU_SUBTYPE_0PF
- select SERIAL_CORE
- help
- Say Y here if you want to use the Xilinx uartlite serial controller.
-@@ -611,6 +611,12 @@
- console (the system console is the device which receives all kernel
- messages and warnings and which allows logins in single user mode).
-
-+config SERIAL_UARTLITE_0PF
-+ tristate "Support 0PF UARTLITEs"
-+ depends on SERIAL_UARTLITE = y && CPU_SUBTYPE_0PF
-+ help
-+ Say Y here to set up 0PF's UARTLITEs.
-+
- config SERIAL_SUNCORE
- bool
- depends on SPARC
diff --git a/target/linux/patches/4.1.51/mtd-rootfs.patch b/target/linux/patches/4.1.51/mtd-rootfs.patch
deleted file mode 100644
index 5f6d82b..0000000
--- a/target/linux/patches/4.1.51/mtd-rootfs.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff -Nur linux-4.1.15.orig/drivers/mtd/mtdpart.c linux-4.1.15/drivers/mtd/mtdpart.c
---- linux-4.1.15.orig/drivers/mtd/mtdpart.c 2015-12-15 06:24:51.000000000 +0100
-+++ linux-4.1.15/drivers/mtd/mtdpart.c 2015-12-26 21:02:02.766905805 +0100
-@@ -30,6 +30,7 @@
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/partitions.h>
- #include <linux/err.h>
-+#include <linux/root_dev.h>
- #include <linux/kconfig.h>
-
- #include "mtdcore.h"
-@@ -667,6 +668,14 @@
- if (IS_ERR(slave))
- return PTR_ERR(slave);
-
-+ if (strcmp(parts[i].name, "rootfs") == 0) {
-+ if (ROOT_DEV == 0) {
-+ printk(KERN_NOTICE "mtd: partition \"rootfs\" "
-+ "set to be root filesystem\n");
-+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, i);
-+ }
-+ }
-+
- mutex_lock(&mtd_partitions_mutex);
- list_add(&slave->list, &mtd_partitions);
- mutex_unlock(&mtd_partitions_mutex);
diff --git a/target/linux/patches/4.1.51/patch-realtime b/target/linux/patches/4.1.51/patch-realtime
deleted file mode 100644
index 52f9bd3..0000000
--- a/target/linux/patches/4.1.51/patch-realtime
+++ /dev/null
@@ -1,30260 +0,0 @@
-diff -Nur linux-4.1.39.orig/arch/alpha/mm/fault.c linux-4.1.39/arch/alpha/mm/fault.c
---- linux-4.1.39.orig/arch/alpha/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/alpha/mm/fault.c 2017-04-18 17:56:30.549394649 +0200
-@@ -23,8 +23,7 @@
- #include <linux/smp.h>
- #include <linux/interrupt.h>
- #include <linux/module.h>
--
--#include <asm/uaccess.h>
-+#include <linux/uaccess.h>
-
- extern void die_if_kernel(char *,struct pt_regs *,long, unsigned long *);
-
-@@ -107,7 +106,7 @@
-
- /* If we're in an interrupt context, or have no user context,
- we must not take the fault. */
-- if (!mm || in_atomic())
-+ if (!mm || faulthandler_disabled())
- goto no_context;
-
- #ifdef CONFIG_ALPHA_LARGE_VMALLOC
-diff -Nur linux-4.1.39.orig/arch/arc/include/asm/futex.h linux-4.1.39/arch/arc/include/asm/futex.h
---- linux-4.1.39.orig/arch/arc/include/asm/futex.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arc/include/asm/futex.h 2017-04-18 17:56:30.549394649 +0200
-@@ -53,7 +53,7 @@
- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
- return -EFAULT;
-
-- pagefault_disable(); /* implies preempt_disable() */
-+ pagefault_disable();
-
- switch (op) {
- case FUTEX_OP_SET:
-@@ -75,7 +75,7 @@
- ret = -ENOSYS;
- }
-
-- pagefault_enable(); /* subsumes preempt_enable() */
-+ pagefault_enable();
-
- if (!ret) {
- switch (cmp) {
-@@ -104,7 +104,7 @@
- return ret;
- }
-
--/* Compare-xchg with preemption disabled.
-+/* Compare-xchg with pagefaults disabled.
- * Notes:
- * -Best-Effort: Exchg happens only if compare succeeds.
- * If compare fails, returns; leaving retry/looping to upper layers
-@@ -121,7 +121,7 @@
- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
- return -EFAULT;
-
-- pagefault_disable(); /* implies preempt_disable() */
-+ pagefault_disable();
-
- /* TBD : can use llock/scond */
- __asm__ __volatile__(
-@@ -142,7 +142,7 @@
- : "r"(oldval), "r"(newval), "r"(uaddr), "ir"(-EFAULT)
- : "cc", "memory");
-
-- pagefault_enable(); /* subsumes preempt_enable() */
-+ pagefault_enable();
-
- *uval = val;
- return val;
-diff -Nur linux-4.1.39.orig/arch/arc/mm/fault.c linux-4.1.39/arch/arc/mm/fault.c
---- linux-4.1.39.orig/arch/arc/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arc/mm/fault.c 2017-04-18 17:56:30.549394649 +0200
-@@ -86,7 +86,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/arm/include/asm/cmpxchg.h linux-4.1.39/arch/arm/include/asm/cmpxchg.h
---- linux-4.1.39.orig/arch/arm/include/asm/cmpxchg.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/include/asm/cmpxchg.h 2017-04-18 17:56:30.549394649 +0200
-@@ -129,6 +129,8 @@
-
- #else /* min ARCH >= ARMv6 */
-
-+#define __HAVE_ARCH_CMPXCHG 1
-+
- extern void __bad_cmpxchg(volatile void *ptr, int size);
-
- /*
-diff -Nur linux-4.1.39.orig/arch/arm/include/asm/futex.h linux-4.1.39/arch/arm/include/asm/futex.h
---- linux-4.1.39.orig/arch/arm/include/asm/futex.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/include/asm/futex.h 2017-04-18 17:56:30.549394649 +0200
-@@ -93,6 +93,7 @@
- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
- return -EFAULT;
-
-+ preempt_disable();
- __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
- "1: " TUSER(ldr) " %1, [%4]\n"
- " teq %1, %2\n"
-@@ -104,6 +105,8 @@
- : "cc", "memory");
-
- *uval = val;
-+ preempt_enable();
-+
- return ret;
- }
-
-@@ -124,7 +127,10 @@
- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
- return -EFAULT;
-
-- pagefault_disable(); /* implies preempt_disable() */
-+#ifndef CONFIG_SMP
-+ preempt_disable();
-+#endif
-+ pagefault_disable();
-
- switch (op) {
- case FUTEX_OP_SET:
-@@ -146,7 +152,10 @@
- ret = -ENOSYS;
- }
-
-- pagefault_enable(); /* subsumes preempt_enable() */
-+ pagefault_enable();
-+#ifndef CONFIG_SMP
-+ preempt_enable();
-+#endif
-
- if (!ret) {
- switch (cmp) {
-diff -Nur linux-4.1.39.orig/arch/arm/include/asm/switch_to.h linux-4.1.39/arch/arm/include/asm/switch_to.h
---- linux-4.1.39.orig/arch/arm/include/asm/switch_to.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/include/asm/switch_to.h 2017-04-18 17:56:30.549394649 +0200
-@@ -3,6 +3,13 @@
-
- #include <linux/thread_info.h>
-
-+#if defined CONFIG_PREEMPT_RT_FULL && defined CONFIG_HIGHMEM
-+void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p);
-+#else
-+static inline void
-+switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p) { }
-+#endif
-+
- /*
- * For v7 SMP cores running a preemptible kernel we may be pre-empted
- * during a TLB maintenance operation, so execute an inner-shareable dsb
-@@ -22,6 +29,7 @@
-
- #define switch_to(prev,next,last) \
- do { \
-+ switch_kmaps(prev, next); \
- last = __switch_to(prev,task_thread_info(prev), task_thread_info(next)); \
- } while (0)
-
-diff -Nur linux-4.1.39.orig/arch/arm/include/asm/thread_info.h linux-4.1.39/arch/arm/include/asm/thread_info.h
---- linux-4.1.39.orig/arch/arm/include/asm/thread_info.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/include/asm/thread_info.h 2017-04-18 17:56:30.549394649 +0200
-@@ -50,6 +50,7 @@
- struct thread_info {
- unsigned long flags; /* low level flags */
- int preempt_count; /* 0 => preemptable, <0 => bug */
-+ int preempt_lazy_count; /* 0 => preemptable, <0 => bug */
- mm_segment_t addr_limit; /* address limit */
- struct task_struct *task; /* main task structure */
- __u32 cpu; /* cpu */
-@@ -147,6 +148,7 @@
- #define TIF_SIGPENDING 0
- #define TIF_NEED_RESCHED 1
- #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
-+#define TIF_NEED_RESCHED_LAZY 3
- #define TIF_UPROBE 7
- #define TIF_SYSCALL_TRACE 8
- #define TIF_SYSCALL_AUDIT 9
-@@ -160,6 +162,7 @@
- #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
- #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
- #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
-+#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
- #define _TIF_UPROBE (1 << TIF_UPROBE)
- #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
- #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
-diff -Nur linux-4.1.39.orig/arch/arm/Kconfig linux-4.1.39/arch/arm/Kconfig
---- linux-4.1.39.orig/arch/arm/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/Kconfig 2017-04-18 17:56:30.549394649 +0200
-@@ -31,7 +31,7 @@
- select HARDIRQS_SW_RESEND
- select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT)
- select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
-- select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
-+ select HAVE_ARCH_JUMP_LABEL if (!XIP_KERNEL && !PREEMPT_RT_BASE)
- select HAVE_ARCH_KGDB
- select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT)
- select HAVE_ARCH_TRACEHOOK
-@@ -66,6 +66,7 @@
- select HAVE_PERF_EVENTS
- select HAVE_PERF_REGS
- select HAVE_PERF_USER_STACK_DUMP
-+ select HAVE_PREEMPT_LAZY
- select HAVE_RCU_TABLE_FREE if (SMP && ARM_LPAE)
- select HAVE_REGS_AND_STACK_ACCESS_API
- select HAVE_SYSCALL_TRACEPOINTS
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/asm-offsets.c linux-4.1.39/arch/arm/kernel/asm-offsets.c
---- linux-4.1.39.orig/arch/arm/kernel/asm-offsets.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/asm-offsets.c 2017-04-18 17:56:30.549394649 +0200
-@@ -65,6 +65,7 @@
- BLANK();
- DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
- DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
-+ DEFINE(TI_PREEMPT_LAZY, offsetof(struct thread_info, preempt_lazy_count));
- DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
- DEFINE(TI_TASK, offsetof(struct thread_info, task));
- DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/entry-armv.S linux-4.1.39/arch/arm/kernel/entry-armv.S
---- linux-4.1.39.orig/arch/arm/kernel/entry-armv.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/entry-armv.S 2017-04-18 17:56:30.549394649 +0200
-@@ -208,11 +208,18 @@
- #ifdef CONFIG_PREEMPT
- get_thread_info tsk
- ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
-- ldr r0, [tsk, #TI_FLAGS] @ get flags
- teq r8, #0 @ if preempt count != 0
-+ bne 1f @ return from exeption
-+ ldr r0, [tsk, #TI_FLAGS] @ get flags
-+ tst r0, #_TIF_NEED_RESCHED @ if NEED_RESCHED is set
-+ blne svc_preempt @ preempt!
-+
-+ ldr r8, [tsk, #TI_PREEMPT_LAZY] @ get preempt lazy count
-+ teq r8, #0 @ if preempt lazy count != 0
- movne r0, #0 @ force flags to 0
-- tst r0, #_TIF_NEED_RESCHED
-+ tst r0, #_TIF_NEED_RESCHED_LAZY
- blne svc_preempt
-+1:
- #endif
-
- svc_exit r5, irq = 1 @ return from exception
-@@ -227,8 +234,14 @@
- 1: bl preempt_schedule_irq @ irq en/disable is done inside
- ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS
- tst r0, #_TIF_NEED_RESCHED
-+ bne 1b
-+ tst r0, #_TIF_NEED_RESCHED_LAZY
- reteq r8 @ go again
-- b 1b
-+ ldr r0, [tsk, #TI_PREEMPT_LAZY] @ get preempt lazy count
-+ teq r0, #0 @ if preempt lazy count != 0
-+ beq 1b
-+ ret r8 @ go again
-+
- #endif
-
- __und_fault:
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/patch.c linux-4.1.39/arch/arm/kernel/patch.c
---- linux-4.1.39.orig/arch/arm/kernel/patch.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/patch.c 2017-04-18 17:56:30.549394649 +0200
-@@ -15,7 +15,7 @@
- unsigned int insn;
- };
-
--static DEFINE_SPINLOCK(patch_lock);
-+static DEFINE_RAW_SPINLOCK(patch_lock);
-
- static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
- __acquires(&patch_lock)
-@@ -32,7 +32,7 @@
- return addr;
-
- if (flags)
-- spin_lock_irqsave(&patch_lock, *flags);
-+ raw_spin_lock_irqsave(&patch_lock, *flags);
- else
- __acquire(&patch_lock);
-
-@@ -47,7 +47,7 @@
- clear_fixmap(fixmap);
-
- if (flags)
-- spin_unlock_irqrestore(&patch_lock, *flags);
-+ raw_spin_unlock_irqrestore(&patch_lock, *flags);
- else
- __release(&patch_lock);
- }
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/process.c linux-4.1.39/arch/arm/kernel/process.c
---- linux-4.1.39.orig/arch/arm/kernel/process.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/process.c 2017-04-18 17:56:30.549394649 +0200
-@@ -290,6 +290,30 @@
- }
-
- #ifdef CONFIG_MMU
-+/*
-+ * CONFIG_SPLIT_PTLOCK_CPUS results in a page->ptl lock. If the lock is not
-+ * initialized by pgtable_page_ctor() then a coredump of the vector page will
-+ * fail.
-+ */
-+static int __init vectors_user_mapping_init_page(void)
-+{
-+ struct page *page;
-+ unsigned long addr = 0xffff0000;
-+ pgd_t *pgd;
-+ pud_t *pud;
-+ pmd_t *pmd;
-+
-+ pgd = pgd_offset_k(addr);
-+ pud = pud_offset(pgd, addr);
-+ pmd = pmd_offset(pud, addr);
-+ page = pmd_page(*(pmd));
-+
-+ pgtable_page_ctor(page);
-+
-+ return 0;
-+}
-+late_initcall(vectors_user_mapping_init_page);
-+
- #ifdef CONFIG_KUSER_HELPERS
- /*
- * The vectors page is always readable from user space for the
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/signal.c linux-4.1.39/arch/arm/kernel/signal.c
---- linux-4.1.39.orig/arch/arm/kernel/signal.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/signal.c 2017-04-18 17:56:30.549394649 +0200
-@@ -568,7 +568,8 @@
- do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
- {
- do {
-- if (likely(thread_flags & _TIF_NEED_RESCHED)) {
-+ if (likely(thread_flags & (_TIF_NEED_RESCHED |
-+ _TIF_NEED_RESCHED_LAZY))) {
- schedule();
- } else {
- if (unlikely(!user_mode(regs)))
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/smp.c linux-4.1.39/arch/arm/kernel/smp.c
---- linux-4.1.39.orig/arch/arm/kernel/smp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/smp.c 2017-04-18 17:56:30.549394649 +0200
-@@ -213,8 +213,6 @@
- flush_cache_louis();
- local_flush_tlb_all();
-
-- clear_tasks_mm_cpumask(cpu);
--
- return 0;
- }
-
-@@ -230,6 +228,9 @@
- pr_err("CPU%u: cpu didn't die\n", cpu);
- return;
- }
-+
-+ clear_tasks_mm_cpumask(cpu);
-+
- pr_notice("CPU%u: shutdown\n", cpu);
-
- /*
-diff -Nur linux-4.1.39.orig/arch/arm/kernel/unwind.c linux-4.1.39/arch/arm/kernel/unwind.c
---- linux-4.1.39.orig/arch/arm/kernel/unwind.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kernel/unwind.c 2017-04-18 17:56:30.549394649 +0200
-@@ -93,7 +93,7 @@
- static const struct unwind_idx *__origin_unwind_idx;
- extern const struct unwind_idx __stop_unwind_idx[];
-
--static DEFINE_SPINLOCK(unwind_lock);
-+static DEFINE_RAW_SPINLOCK(unwind_lock);
- static LIST_HEAD(unwind_tables);
-
- /* Convert a prel31 symbol to an absolute address */
-@@ -201,7 +201,7 @@
- /* module unwind tables */
- struct unwind_table *table;
-
-- spin_lock_irqsave(&unwind_lock, flags);
-+ raw_spin_lock_irqsave(&unwind_lock, flags);
- list_for_each_entry(table, &unwind_tables, list) {
- if (addr >= table->begin_addr &&
- addr < table->end_addr) {
-@@ -213,7 +213,7 @@
- break;
- }
- }
-- spin_unlock_irqrestore(&unwind_lock, flags);
-+ raw_spin_unlock_irqrestore(&unwind_lock, flags);
- }
-
- pr_debug("%s: idx = %p\n", __func__, idx);
-@@ -529,9 +529,9 @@
- tab->begin_addr = text_addr;
- tab->end_addr = text_addr + text_size;
-
-- spin_lock_irqsave(&unwind_lock, flags);
-+ raw_spin_lock_irqsave(&unwind_lock, flags);
- list_add_tail(&tab->list, &unwind_tables);
-- spin_unlock_irqrestore(&unwind_lock, flags);
-+ raw_spin_unlock_irqrestore(&unwind_lock, flags);
-
- return tab;
- }
-@@ -543,9 +543,9 @@
- if (!tab)
- return;
-
-- spin_lock_irqsave(&unwind_lock, flags);
-+ raw_spin_lock_irqsave(&unwind_lock, flags);
- list_del(&tab->list);
-- spin_unlock_irqrestore(&unwind_lock, flags);
-+ raw_spin_unlock_irqrestore(&unwind_lock, flags);
-
- kfree(tab);
- }
-diff -Nur linux-4.1.39.orig/arch/arm/kvm/arm.c linux-4.1.39/arch/arm/kvm/arm.c
---- linux-4.1.39.orig/arch/arm/kvm/arm.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kvm/arm.c 2017-04-18 17:56:30.549394649 +0200
-@@ -473,9 +473,9 @@
-
- static void vcpu_pause(struct kvm_vcpu *vcpu)
- {
-- wait_queue_head_t *wq = kvm_arch_vcpu_wq(vcpu);
-+ struct swait_head *wq = kvm_arch_vcpu_wq(vcpu);
-
-- wait_event_interruptible(*wq, !vcpu->arch.pause);
-+ swait_event_interruptible(*wq, !vcpu->arch.pause);
- }
-
- static int kvm_vcpu_initialized(struct kvm_vcpu *vcpu)
-diff -Nur linux-4.1.39.orig/arch/arm/kvm/psci.c linux-4.1.39/arch/arm/kvm/psci.c
---- linux-4.1.39.orig/arch/arm/kvm/psci.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/kvm/psci.c 2017-04-18 17:56:30.549394649 +0200
-@@ -68,7 +68,7 @@
- {
- struct kvm *kvm = source_vcpu->kvm;
- struct kvm_vcpu *vcpu = NULL;
-- wait_queue_head_t *wq;
-+ struct swait_head *wq;
- unsigned long cpu_id;
- unsigned long context_id;
- phys_addr_t target_pc;
-@@ -117,7 +117,7 @@
- smp_mb(); /* Make sure the above is visible */
-
- wq = kvm_arch_vcpu_wq(vcpu);
-- wake_up_interruptible(wq);
-+ swait_wake_interruptible(wq);
-
- return PSCI_RET_SUCCESS;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-at91/at91rm9200.c linux-4.1.39/arch/arm/mach-at91/at91rm9200.c
---- linux-4.1.39.orig/arch/arm/mach-at91/at91rm9200.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-at91/at91rm9200.c 2017-04-18 17:56:30.549394649 +0200
-@@ -13,7 +13,6 @@
- #include <linux/of_platform.h>
-
- #include <asm/mach/arch.h>
--#include <asm/system_misc.h>
-
- #include "generic.h"
- #include "soc.h"
-@@ -34,7 +33,6 @@
-
- of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);
-
-- arm_pm_idle = at91rm9200_idle;
- at91rm9200_pm_init();
- }
-
-diff -Nur linux-4.1.39.orig/arch/arm/mach-at91/at91sam9.c linux-4.1.39/arch/arm/mach-at91/at91sam9.c
---- linux-4.1.39.orig/arch/arm/mach-at91/at91sam9.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-at91/at91sam9.c 2017-04-18 17:56:30.549394649 +0200
-@@ -62,8 +62,6 @@
- soc_dev = soc_device_to_device(soc);
-
- of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);
--
-- arm_pm_idle = at91sam9_idle;
- }
-
- static void __init at91sam9_dt_device_init(void)
-diff -Nur linux-4.1.39.orig/arch/arm/mach-at91/generic.h linux-4.1.39/arch/arm/mach-at91/generic.h
---- linux-4.1.39.orig/arch/arm/mach-at91/generic.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-at91/generic.h 2017-04-18 17:56:30.549394649 +0200
-@@ -11,27 +11,18 @@
- #ifndef _AT91_GENERIC_H
- #define _AT91_GENERIC_H
-
--#include <linux/of.h>
--#include <linux/reboot.h>
--
-- /* Map io */
--extern void __init at91_map_io(void);
--extern void __init at91_alt_map_io(void);
--
--/* idle */
--extern void at91rm9200_idle(void);
--extern void at91sam9_idle(void);
--
- #ifdef CONFIG_PM
- extern void __init at91rm9200_pm_init(void);
- extern void __init at91sam9260_pm_init(void);
- extern void __init at91sam9g45_pm_init(void);
- extern void __init at91sam9x5_pm_init(void);
-+extern void __init sama5_pm_init(void);
- #else
- static inline void __init at91rm9200_pm_init(void) { }
- static inline void __init at91sam9260_pm_init(void) { }
- static inline void __init at91sam9g45_pm_init(void) { }
- static inline void __init at91sam9x5_pm_init(void) { }
-+static inline void __init sama5_pm_init(void) { }
- #endif
-
- #endif /* _AT91_GENERIC_H */
-diff -Nur linux-4.1.39.orig/arch/arm/mach-at91/pm.c linux-4.1.39/arch/arm/mach-at91/pm.c
---- linux-4.1.39.orig/arch/arm/mach-at91/pm.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-at91/pm.c 2017-04-18 17:56:30.549394649 +0200
-@@ -31,10 +31,13 @@
- #include <asm/mach/irq.h>
- #include <asm/fncpy.h>
- #include <asm/cacheflush.h>
-+#include <asm/system_misc.h>
-
- #include "generic.h"
- #include "pm.h"
-
-+static void __iomem *pmc;
-+
- /*
- * FIXME: this is needed to communicate between the pinctrl driver and
- * the PM implementation in the machine. Possibly part of the PM
-@@ -85,7 +88,7 @@
- unsigned long scsr;
- int i;
-
-- scsr = at91_pmc_read(AT91_PMC_SCSR);
-+ scsr = readl(pmc + AT91_PMC_SCSR);
-
- /* USB must not be using PLLB */
- if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
-@@ -99,8 +102,7 @@
-
- if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
- continue;
--
-- css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
-+ css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
- if (css != AT91_PMC_CSS_SLOW) {
- pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
- return 0;
-@@ -143,8 +145,8 @@
- flush_cache_all();
- outer_disable();
-
-- at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0],
-- at91_ramc_base[1], pm_data);
-+ at91_suspend_sram_fn(pmc, at91_ramc_base[0],
-+ at91_ramc_base[1], pm_data);
-
- outer_resume();
- }
-@@ -348,6 +350,21 @@
- at91_pm_set_standby(standby);
- }
-
-+void at91rm9200_idle(void)
-+{
-+ /*
-+ * Disable the processor clock. The processor will be automatically
-+ * re-enabled by an interrupt or by a reset.
-+ */
-+ writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR);
-+}
-+
-+void at91sam9_idle(void)
-+{
-+ writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR);
-+ cpu_do_idle();
-+}
-+
- static void __init at91_pm_sram_init(void)
- {
- struct gen_pool *sram_pool;
-@@ -394,13 +411,36 @@
- &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
- }
-
--static void __init at91_pm_init(void)
-+static const struct of_device_id atmel_pmc_ids[] __initconst = {
-+ { .compatible = "atmel,at91rm9200-pmc" },
-+ { .compatible = "atmel,at91sam9260-pmc" },
-+ { .compatible = "atmel,at91sam9g45-pmc" },
-+ { .compatible = "atmel,at91sam9n12-pmc" },
-+ { .compatible = "atmel,at91sam9x5-pmc" },
-+ { .compatible = "atmel,sama5d3-pmc" },
-+ { .compatible = "atmel,sama5d2-pmc" },
-+ { /* sentinel */ },
-+};
-+
-+static void __init at91_pm_init(void (*pm_idle)(void))
- {
-- at91_pm_sram_init();
-+ struct device_node *pmc_np;
-
- if (at91_cpuidle_device.dev.platform_data)
- platform_device_register(&at91_cpuidle_device);
-
-+ pmc_np = of_find_matching_node(NULL, atmel_pmc_ids);
-+ pmc = of_iomap(pmc_np, 0);
-+ if (!pmc) {
-+ pr_err("AT91: PM not supported, PMC not found\n");
-+ return;
-+ }
-+
-+ if (pm_idle)
-+ arm_pm_idle = pm_idle;
-+
-+ at91_pm_sram_init();
-+
- if (at91_suspend_sram_fn)
- suspend_set_ops(&at91_pm_ops);
- else
-@@ -419,7 +459,7 @@
- at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP;
- at91_pm_data.memctrl = AT91_MEMCTRL_MC;
-
-- at91_pm_init();
-+ at91_pm_init(at91rm9200_idle);
- }
-
- void __init at91sam9260_pm_init(void)
-@@ -427,7 +467,7 @@
- at91_dt_ramc();
- at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
- at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
-- return at91_pm_init();
-+ at91_pm_init(at91sam9_idle);
- }
-
- void __init at91sam9g45_pm_init(void)
-@@ -435,7 +475,7 @@
- at91_dt_ramc();
- at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP;
- at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
-- return at91_pm_init();
-+ at91_pm_init(at91sam9_idle);
- }
-
- void __init at91sam9x5_pm_init(void)
-@@ -443,5 +483,13 @@
- at91_dt_ramc();
- at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
- at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
-- return at91_pm_init();
-+ at91_pm_init(at91sam9_idle);
-+}
-+
-+void __init sama5_pm_init(void)
-+{
-+ at91_dt_ramc();
-+ at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
-+ at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
-+ at91_pm_init(NULL);
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-at91/sama5.c linux-4.1.39/arch/arm/mach-at91/sama5.c
---- linux-4.1.39.orig/arch/arm/mach-at91/sama5.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-at91/sama5.c 2017-04-18 17:56:30.549394649 +0200
-@@ -49,7 +49,7 @@
- soc_dev = soc_device_to_device(soc);
-
- of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);
-- at91sam9x5_pm_init();
-+ sama5_pm_init();
- }
-
- static const char *sama5_dt_board_compat[] __initconst = {
-diff -Nur linux-4.1.39.orig/arch/arm/mach-exynos/platsmp.c linux-4.1.39/arch/arm/mach-exynos/platsmp.c
---- linux-4.1.39.orig/arch/arm/mach-exynos/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-exynos/platsmp.c 2017-04-18 17:56:30.549394649 +0200
-@@ -231,7 +231,7 @@
- return (void __iomem *)(S5P_VA_SCU);
- }
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- static void exynos_secondary_init(unsigned int cpu)
- {
-@@ -244,8 +244,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
-@@ -259,7 +259,7 @@
- * Set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * The secondary processor is waiting to be released from
-@@ -286,7 +286,7 @@
-
- if (timeout == 0) {
- printk(KERN_ERR "cpu1 power enable failed");
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- return -ETIMEDOUT;
- }
- }
-@@ -342,7 +342,7 @@
- * calibrations, then wait for it to finish
- */
- fail:
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return pen_release != -1 ? ret : 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-hisi/platmcpm.c linux-4.1.39/arch/arm/mach-hisi/platmcpm.c
---- linux-4.1.39.orig/arch/arm/mach-hisi/platmcpm.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-hisi/platmcpm.c 2017-04-18 17:56:30.549394649 +0200
-@@ -57,7 +57,7 @@
-
- static void __iomem *sysctrl, *fabric;
- static int hip04_cpu_table[HIP04_MAX_CLUSTERS][HIP04_MAX_CPUS_PER_CLUSTER];
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
- static u32 fabric_phys_addr;
- /*
- * [0]: bootwrapper physical address
-@@ -104,7 +104,7 @@
- if (cluster >= HIP04_MAX_CLUSTERS || cpu >= HIP04_MAX_CPUS_PER_CLUSTER)
- return -EINVAL;
-
-- spin_lock_irq(&boot_lock);
-+ raw_spin_lock_irq(&boot_lock);
-
- if (hip04_cpu_table[cluster][cpu])
- goto out;
-@@ -133,7 +133,7 @@
- udelay(20);
- out:
- hip04_cpu_table[cluster][cpu]++;
-- spin_unlock_irq(&boot_lock);
-+ raw_spin_unlock_irq(&boot_lock);
-
- return 0;
- }
-@@ -149,7 +149,7 @@
-
- __mcpm_cpu_going_down(cpu, cluster);
-
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
- BUG_ON(__mcpm_cluster_state(cluster) != CLUSTER_UP);
- hip04_cpu_table[cluster][cpu]--;
- if (hip04_cpu_table[cluster][cpu] == 1) {
-@@ -162,7 +162,7 @@
-
- last_man = hip04_cluster_is_down(cluster);
- if (last_man && __mcpm_outbound_enter_critical(cpu, cluster)) {
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- /* Since it's Cortex A15, disable L2 prefetching. */
- asm volatile(
- "mcr p15, 1, %0, c15, c0, 3 \n\t"
-@@ -173,7 +173,7 @@
- hip04_set_snoop_filter(cluster, 0);
- __mcpm_outbound_leave_critical(cluster, CLUSTER_DOWN);
- } else {
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- v7_exit_coherency_flush(louis);
- }
-
-@@ -192,7 +192,7 @@
- cpu >= HIP04_MAX_CPUS_PER_CLUSTER);
-
- count = TIMEOUT_MSEC / POLL_MSEC;
-- spin_lock_irq(&boot_lock);
-+ raw_spin_lock_irq(&boot_lock);
- for (tries = 0; tries < count; tries++) {
- if (hip04_cpu_table[cluster][cpu]) {
- ret = -EBUSY;
-@@ -202,10 +202,10 @@
- data = readl_relaxed(sysctrl + SC_CPU_RESET_STATUS(cluster));
- if (data & CORE_WFI_STATUS(cpu))
- break;
-- spin_unlock_irq(&boot_lock);
-+ raw_spin_unlock_irq(&boot_lock);
- /* Wait for clean L2 when the whole cluster is down. */
- msleep(POLL_MSEC);
-- spin_lock_irq(&boot_lock);
-+ raw_spin_lock_irq(&boot_lock);
- }
- if (tries >= count)
- goto err;
-@@ -220,10 +220,10 @@
- }
- if (tries >= count)
- goto err;
-- spin_unlock_irq(&boot_lock);
-+ raw_spin_unlock_irq(&boot_lock);
- return 0;
- err:
-- spin_unlock_irq(&boot_lock);
-+ raw_spin_unlock_irq(&boot_lock);
- return ret;
- }
-
-@@ -235,10 +235,10 @@
- cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
- cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
-
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
- if (!hip04_cpu_table[cluster][cpu])
- hip04_cpu_table[cluster][cpu] = 1;
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static void __naked hip04_mcpm_power_up_setup(unsigned int affinity_level)
-diff -Nur linux-4.1.39.orig/arch/arm/mach-omap2/gpio.c linux-4.1.39/arch/arm/mach-omap2/gpio.c
---- linux-4.1.39.orig/arch/arm/mach-omap2/gpio.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-omap2/gpio.c 2017-04-18 17:56:30.549394649 +0200
-@@ -130,7 +130,6 @@
- }
-
- pwrdm = omap_hwmod_get_pwrdm(oh);
-- pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
-
- pdev = omap_device_build(name, id - 1, oh, pdata, sizeof(*pdata));
- kfree(pdata);
-diff -Nur linux-4.1.39.orig/arch/arm/mach-omap2/omap-smp.c linux-4.1.39/arch/arm/mach-omap2/omap-smp.c
---- linux-4.1.39.orig/arch/arm/mach-omap2/omap-smp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-omap2/omap-smp.c 2017-04-18 17:56:30.549394649 +0200
-@@ -43,7 +43,7 @@
- /* SCU base address */
- static void __iomem *scu_base;
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- void __iomem *omap4_get_scu_base(void)
- {
-@@ -74,8 +74,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
-@@ -89,7 +89,7 @@
- * Set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * Update the AuxCoreBoot0 with boot state for secondary core.
-@@ -166,7 +166,7 @@
- * Now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-omap2/powerdomain.c linux-4.1.39/arch/arm/mach-omap2/powerdomain.c
---- linux-4.1.39.orig/arch/arm/mach-omap2/powerdomain.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-omap2/powerdomain.c 2017-04-18 17:56:30.553394804 +0200
-@@ -1166,43 +1166,3 @@
- return count;
- }
-
--/**
-- * pwrdm_can_ever_lose_context - can this powerdomain ever lose context?
-- * @pwrdm: struct powerdomain *
-- *
-- * Given a struct powerdomain * @pwrdm, returns 1 if the powerdomain
-- * can lose either memory or logic context or if @pwrdm is invalid, or
-- * returns 0 otherwise. This function is not concerned with how the
-- * powerdomain registers are programmed (i.e., to go off or not); it's
-- * concerned with whether it's ever possible for this powerdomain to
-- * go off while some other part of the chip is active. This function
-- * assumes that every powerdomain can go to either ON or INACTIVE.
-- */
--bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm)
--{
-- int i;
--
-- if (!pwrdm) {
-- pr_debug("powerdomain: %s: invalid powerdomain pointer\n",
-- __func__);
-- return 1;
-- }
--
-- if (pwrdm->pwrsts & PWRSTS_OFF)
-- return 1;
--
-- if (pwrdm->pwrsts & PWRSTS_RET) {
-- if (pwrdm->pwrsts_logic_ret & PWRSTS_OFF)
-- return 1;
--
-- for (i = 0; i < pwrdm->banks; i++)
-- if (pwrdm->pwrsts_mem_ret[i] & PWRSTS_OFF)
-- return 1;
-- }
--
-- for (i = 0; i < pwrdm->banks; i++)
-- if (pwrdm->pwrsts_mem_on[i] & PWRSTS_OFF)
-- return 1;
--
-- return 0;
--}
-diff -Nur linux-4.1.39.orig/arch/arm/mach-omap2/powerdomain.h linux-4.1.39/arch/arm/mach-omap2/powerdomain.h
---- linux-4.1.39.orig/arch/arm/mach-omap2/powerdomain.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-omap2/powerdomain.h 2017-04-18 17:56:30.553394804 +0200
-@@ -244,7 +244,6 @@
- int pwrdm_pre_transition(struct powerdomain *pwrdm);
- int pwrdm_post_transition(struct powerdomain *pwrdm);
- int pwrdm_get_context_loss_count(struct powerdomain *pwrdm);
--bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm);
-
- extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u8 state);
-
-diff -Nur linux-4.1.39.orig/arch/arm/mach-prima2/platsmp.c linux-4.1.39/arch/arm/mach-prima2/platsmp.c
---- linux-4.1.39.orig/arch/arm/mach-prima2/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-prima2/platsmp.c 2017-04-18 17:56:30.553394804 +0200
-@@ -22,7 +22,7 @@
-
- static void __iomem *clk_base;
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- static void sirfsoc_secondary_init(unsigned int cpu)
- {
-@@ -36,8 +36,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static const struct of_device_id clk_ids[] = {
-@@ -75,7 +75,7 @@
- /* make sure write buffer is drained */
- mb();
-
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * The secondary processor is waiting to be released from
-@@ -107,7 +107,7 @@
- * now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return pen_release != -1 ? -ENOSYS : 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-qcom/platsmp.c linux-4.1.39/arch/arm/mach-qcom/platsmp.c
---- linux-4.1.39.orig/arch/arm/mach-qcom/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-qcom/platsmp.c 2017-04-18 17:56:30.553394804 +0200
-@@ -46,7 +46,7 @@
-
- extern void secondary_startup_arm(void);
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- #ifdef CONFIG_HOTPLUG_CPU
- static void __ref qcom_cpu_die(unsigned int cpu)
-@@ -60,8 +60,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static int scss_release_secondary(unsigned int cpu)
-@@ -284,7 +284,7 @@
- * set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * Send the secondary CPU a soft interrupt, thereby causing
-@@ -297,7 +297,7 @@
- * now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return ret;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-spear/platsmp.c linux-4.1.39/arch/arm/mach-spear/platsmp.c
---- linux-4.1.39.orig/arch/arm/mach-spear/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-spear/platsmp.c 2017-04-18 17:56:30.553394804 +0200
-@@ -32,7 +32,7 @@
- sync_cache_w(&pen_release);
- }
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- static void __iomem *scu_base = IOMEM(VA_SCU_BASE);
-
-@@ -47,8 +47,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static int spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle)
-@@ -59,7 +59,7 @@
- * set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * The secondary processor is waiting to be released from
-@@ -84,7 +84,7 @@
- * now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return pen_release != -1 ? -ENOSYS : 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-sti/platsmp.c linux-4.1.39/arch/arm/mach-sti/platsmp.c
---- linux-4.1.39.orig/arch/arm/mach-sti/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-sti/platsmp.c 2017-04-18 17:56:30.553394804 +0200
-@@ -34,7 +34,7 @@
- sync_cache_w(&pen_release);
- }
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- static void sti_secondary_init(unsigned int cpu)
- {
-@@ -49,8 +49,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static int sti_boot_secondary(unsigned int cpu, struct task_struct *idle)
-@@ -61,7 +61,7 @@
- * set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * The secondary processor is waiting to be released from
-@@ -92,7 +92,7 @@
- * now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return pen_release != -1 ? -ENOSYS : 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mach-ux500/platsmp.c linux-4.1.39/arch/arm/mach-ux500/platsmp.c
---- linux-4.1.39.orig/arch/arm/mach-ux500/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mach-ux500/platsmp.c 2017-04-18 17:56:30.553394804 +0200
-@@ -51,7 +51,7 @@
- return NULL;
- }
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- static void ux500_secondary_init(unsigned int cpu)
- {
-@@ -64,8 +64,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
-@@ -76,7 +76,7 @@
- * set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * The secondary processor is waiting to be released from
-@@ -97,7 +97,7 @@
- * now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return pen_release != -1 ? -ENOSYS : 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mm/fault.c linux-4.1.39/arch/arm/mm/fault.c
---- linux-4.1.39.orig/arch/arm/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -276,7 +276,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-@@ -430,6 +430,9 @@
- if (addr < TASK_SIZE)
- return do_page_fault(addr, fsr, regs);
-
-+ if (interrupts_enabled(regs))
-+ local_irq_enable();
-+
- if (user_mode(regs))
- goto bad_area;
-
-@@ -497,6 +500,9 @@
- static int
- do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
- {
-+ if (interrupts_enabled(regs))
-+ local_irq_enable();
-+
- do_bad_area(addr, fsr, regs);
- return 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm/mm/highmem.c linux-4.1.39/arch/arm/mm/highmem.c
---- linux-4.1.39.orig/arch/arm/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/mm/highmem.c 2017-04-18 17:56:30.553394804 +0200
-@@ -54,11 +54,13 @@
-
- void *kmap_atomic(struct page *page)
- {
-+ pte_t pte = mk_pte(page, kmap_prot);
- unsigned int idx;
- unsigned long vaddr;
- void *kmap;
- int type;
-
-+ preempt_disable_nort();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -92,7 +94,10 @@
- * in place, so the contained TLB flush ensures the TLB is updated
- * with the new mapping.
- */
-- set_fixmap_pte(idx, mk_pte(page, kmap_prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = pte;
-+#endif
-+ set_fixmap_pte(idx, pte);
-
- return (void *)vaddr;
- }
-@@ -109,27 +114,33 @@
-
- if (cache_is_vivt())
- __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = __pte(0);
-+#endif
- #ifdef CONFIG_DEBUG_HIGHMEM
- BUG_ON(vaddr != __fix_to_virt(idx));
-- set_fixmap_pte(idx, __pte(0));
- #else
- (void) idx; /* to kill a warning */
- #endif
-+ set_fixmap_pte(idx, __pte(0));
- kmap_atomic_idx_pop();
- } else if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) {
- /* this address was obtained through kmap_high_get() */
- kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)]));
- }
- pagefault_enable();
-+ preempt_enable_nort();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-
- void *kmap_atomic_pfn(unsigned long pfn)
- {
-+ pte_t pte = pfn_pte(pfn, kmap_prot);
- unsigned long vaddr;
- int idx, type;
- struct page *page = pfn_to_page(pfn);
-
-+ preempt_disable_nort();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -140,7 +151,10 @@
- #ifdef CONFIG_DEBUG_HIGHMEM
- BUG_ON(!pte_none(get_fixmap_pte(vaddr)));
- #endif
-- set_fixmap_pte(idx, pfn_pte(pfn, kmap_prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = pte;
-+#endif
-+ set_fixmap_pte(idx, pte);
-
- return (void *)vaddr;
- }
-@@ -154,3 +168,28 @@
-
- return pte_page(get_fixmap_pte(vaddr));
- }
-+
-+#if defined CONFIG_PREEMPT_RT_FULL
-+void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p)
-+{
-+ int i;
-+
-+ /*
-+ * Clear @prev's kmap_atomic mappings
-+ */
-+ for (i = 0; i < prev_p->kmap_idx; i++) {
-+ int idx = i + KM_TYPE_NR * smp_processor_id();
-+
-+ set_fixmap_pte(idx, __pte(0));
-+ }
-+ /*
-+ * Restore @next_p's kmap_atomic mappings
-+ */
-+ for (i = 0; i < next_p->kmap_idx; i++) {
-+ int idx = i + KM_TYPE_NR * smp_processor_id();
-+
-+ if (!pte_none(next_p->kmap_pte[i]))
-+ set_fixmap_pte(idx, next_p->kmap_pte[i]);
-+ }
-+}
-+#endif
-diff -Nur linux-4.1.39.orig/arch/arm/plat-versatile/platsmp.c linux-4.1.39/arch/arm/plat-versatile/platsmp.c
---- linux-4.1.39.orig/arch/arm/plat-versatile/platsmp.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm/plat-versatile/platsmp.c 2017-04-18 17:56:30.553394804 +0200
-@@ -30,7 +30,7 @@
- sync_cache_w(&pen_release);
- }
-
--static DEFINE_SPINLOCK(boot_lock);
-+static DEFINE_RAW_SPINLOCK(boot_lock);
-
- void versatile_secondary_init(unsigned int cpu)
- {
-@@ -43,8 +43,8 @@
- /*
- * Synchronise with the boot thread.
- */
-- spin_lock(&boot_lock);
-- spin_unlock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
- }
-
- int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
-@@ -55,7 +55,7 @@
- * Set synchronisation state between this boot processor
- * and the secondary one
- */
-- spin_lock(&boot_lock);
-+ raw_spin_lock(&boot_lock);
-
- /*
- * This is really belt and braces; we hold unintended secondary
-@@ -85,7 +85,7 @@
- * now the secondary core is starting up let it run its
- * calibrations, then wait for it to finish
- */
-- spin_unlock(&boot_lock);
-+ raw_spin_unlock(&boot_lock);
-
- return pen_release != -1 ? -ENOSYS : 0;
- }
-diff -Nur linux-4.1.39.orig/arch/arm64/include/asm/futex.h linux-4.1.39/arch/arm64/include/asm/futex.h
---- linux-4.1.39.orig/arch/arm64/include/asm/futex.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/include/asm/futex.h 2017-04-18 17:56:30.553394804 +0200
-@@ -58,7 +58,7 @@
- if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
- return -EFAULT;
-
-- pagefault_disable(); /* implies preempt_disable() */
-+ pagefault_disable();
-
- switch (op) {
- case FUTEX_OP_SET:
-@@ -85,7 +85,7 @@
- ret = -ENOSYS;
- }
-
-- pagefault_enable(); /* subsumes preempt_enable() */
-+ pagefault_enable();
-
- if (!ret) {
- switch (cmp) {
-diff -Nur linux-4.1.39.orig/arch/arm64/include/asm/thread_info.h linux-4.1.39/arch/arm64/include/asm/thread_info.h
---- linux-4.1.39.orig/arch/arm64/include/asm/thread_info.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/include/asm/thread_info.h 2017-04-18 17:56:30.553394804 +0200
-@@ -47,6 +47,7 @@
- mm_segment_t addr_limit; /* address limit */
- struct task_struct *task; /* main task structure */
- int preempt_count; /* 0 => preemptable, <0 => bug */
-+ int preempt_lazy_count; /* 0 => preemptable, <0 => bug */
- int cpu; /* cpu */
- };
-
-@@ -101,6 +102,7 @@
- #define TIF_NEED_RESCHED 1
- #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
- #define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
-+#define TIF_NEED_RESCHED_LAZY 4
- #define TIF_NOHZ 7
- #define TIF_SYSCALL_TRACE 8
- #define TIF_SYSCALL_AUDIT 9
-@@ -117,6 +119,7 @@
- #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
- #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
- #define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
-+#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
- #define _TIF_NOHZ (1 << TIF_NOHZ)
- #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
- #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
-diff -Nur linux-4.1.39.orig/arch/arm64/Kconfig linux-4.1.39/arch/arm64/Kconfig
---- linux-4.1.39.orig/arch/arm64/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/Kconfig 2017-04-18 17:56:30.553394804 +0200
-@@ -69,8 +69,10 @@
- select HAVE_PERF_REGS
- select HAVE_PERF_USER_STACK_DUMP
- select HAVE_RCU_TABLE_FREE
-+ select HAVE_PREEMPT_LAZY
- select HAVE_SYSCALL_TRACEPOINTS
- select IRQ_DOMAIN
-+ select IRQ_FORCED_THREADING
- select MODULES_USE_ELF_RELA
- select NO_BOOTMEM
- select OF
-@@ -599,7 +601,7 @@
-
- config XEN
- bool "Xen guest support on ARM64"
-- depends on ARM64 && OF
-+ depends on ARM64 && OF && !PREEMPT_RT_FULL
- select SWIOTLB_XEN
- help
- Say Y if you want to run Linux in a Virtual Machine on Xen on ARM64.
-diff -Nur linux-4.1.39.orig/arch/arm64/kernel/asm-offsets.c linux-4.1.39/arch/arm64/kernel/asm-offsets.c
---- linux-4.1.39.orig/arch/arm64/kernel/asm-offsets.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/kernel/asm-offsets.c 2017-04-18 17:56:30.553394804 +0200
-@@ -35,6 +35,7 @@
- BLANK();
- DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
- DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
-+ DEFINE(TI_PREEMPT_LAZY, offsetof(struct thread_info, preempt_lazy_count));
- DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
- DEFINE(TI_TASK, offsetof(struct thread_info, task));
- DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
-diff -Nur linux-4.1.39.orig/arch/arm64/kernel/entry.S linux-4.1.39/arch/arm64/kernel/entry.S
---- linux-4.1.39.orig/arch/arm64/kernel/entry.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/kernel/entry.S 2017-04-18 17:56:30.553394804 +0200
-@@ -380,11 +380,16 @@
- #ifdef CONFIG_PREEMPT
- get_thread_info tsk
- ldr w24, [tsk, #TI_PREEMPT] // get preempt count
-- cbnz w24, 1f // preempt count != 0
-+ cbnz w24, 2f // preempt count != 0
- ldr x0, [tsk, #TI_FLAGS] // get flags
-- tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
-- bl el1_preempt
-+ tbnz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
-+
-+ ldr w24, [tsk, #TI_PREEMPT_LAZY] // get preempt lazy count
-+ cbnz w24, 2f // preempt lazy count != 0
-+ tbz x0, #TIF_NEED_RESCHED_LAZY, 2f // needs rescheduling?
- 1:
-+ bl el1_preempt
-+2:
- #endif
- #ifdef CONFIG_TRACE_IRQFLAGS
- bl trace_hardirqs_on
-@@ -398,6 +403,7 @@
- 1: bl preempt_schedule_irq // irq en/disable is done inside
- ldr x0, [tsk, #TI_FLAGS] // get new tasks TI_FLAGS
- tbnz x0, #TIF_NEED_RESCHED, 1b // needs rescheduling?
-+ tbnz x0, #TIF_NEED_RESCHED_LAZY, 1b // needs rescheduling?
- ret x24
- #endif
-
-@@ -635,6 +641,7 @@
- str x0, [sp, #S_X0] // returned x0
- work_pending:
- tbnz x1, #TIF_NEED_RESCHED, work_resched
-+ tbnz x1, #TIF_NEED_RESCHED_LAZY, work_resched
- /* TIF_SIGPENDING, TIF_NOTIFY_RESUME or TIF_FOREIGN_FPSTATE case */
- ldr x2, [sp, #S_PSTATE]
- mov x0, sp // 'regs'
-diff -Nur linux-4.1.39.orig/arch/arm64/kernel/insn.c linux-4.1.39/arch/arm64/kernel/insn.c
---- linux-4.1.39.orig/arch/arm64/kernel/insn.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/kernel/insn.c 2017-04-18 17:56:30.553394804 +0200
-@@ -77,7 +77,7 @@
- }
- }
-
--static DEFINE_SPINLOCK(patch_lock);
-+static DEFINE_RAW_SPINLOCK(patch_lock);
-
- static void __kprobes *patch_map(void *addr, int fixmap)
- {
-@@ -124,13 +124,13 @@
- unsigned long flags = 0;
- int ret;
-
-- spin_lock_irqsave(&patch_lock, flags);
-+ raw_spin_lock_irqsave(&patch_lock, flags);
- waddr = patch_map(addr, FIX_TEXT_POKE0);
-
- ret = probe_kernel_write(waddr, &insn, AARCH64_INSN_SIZE);
-
- patch_unmap(FIX_TEXT_POKE0);
-- spin_unlock_irqrestore(&patch_lock, flags);
-+ raw_spin_unlock_irqrestore(&patch_lock, flags);
-
- return ret;
- }
-diff -Nur linux-4.1.39.orig/arch/arm64/kernel/perf_event.c linux-4.1.39/arch/arm64/kernel/perf_event.c
---- linux-4.1.39.orig/arch/arm64/kernel/perf_event.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/kernel/perf_event.c 2017-04-18 17:56:30.553394804 +0200
-@@ -488,7 +488,7 @@
- }
-
- err = request_irq(irq, armpmu->handle_irq,
-- IRQF_NOBALANCING,
-+ IRQF_NOBALANCING | IRQF_NO_THREAD,
- "arm-pmu", armpmu);
- if (err) {
- pr_err("unable to request IRQ%d for ARM PMU counters\n",
-diff -Nur linux-4.1.39.orig/arch/arm64/mm/fault.c linux-4.1.39/arch/arm64/mm/fault.c
---- linux-4.1.39.orig/arch/arm64/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/arm64/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -211,7 +211,7 @@
- * If we're in an interrupt or have no user context, we must not take
- * the fault.
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/avr32/include/asm/uaccess.h linux-4.1.39/arch/avr32/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/avr32/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/avr32/include/asm/uaccess.h 2017-04-18 17:56:30.553394804 +0200
-@@ -106,7 +106,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -125,7 +126,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -145,7 +147,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -167,7 +170,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-diff -Nur linux-4.1.39.orig/arch/avr32/mm/fault.c linux-4.1.39/arch/avr32/mm/fault.c
---- linux-4.1.39.orig/arch/avr32/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/avr32/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -14,11 +14,11 @@
- #include <linux/pagemap.h>
- #include <linux/kdebug.h>
- #include <linux/kprobes.h>
-+#include <linux/uaccess.h>
-
- #include <asm/mmu_context.h>
- #include <asm/sysreg.h>
- #include <asm/tlb.h>
--#include <asm/uaccess.h>
-
- #ifdef CONFIG_KPROBES
- static inline int notify_page_fault(struct pt_regs *regs, int trap)
-@@ -81,7 +81,7 @@
- * If we're in an interrupt or have no user context, we must
- * not take the fault...
- */
-- if (in_atomic() || !mm || regs->sr & SYSREG_BIT(GM))
-+ if (faulthandler_disabled() || !mm || regs->sr & SYSREG_BIT(GM))
- goto no_context;
-
- local_irq_enable();
-diff -Nur linux-4.1.39.orig/arch/cris/mm/fault.c linux-4.1.39/arch/cris/mm/fault.c
---- linux-4.1.39.orig/arch/cris/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/cris/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -8,7 +8,7 @@
- #include <linux/interrupt.h>
- #include <linux/module.h>
- #include <linux/wait.h>
--#include <asm/uaccess.h>
-+#include <linux/uaccess.h>
- #include <arch/system.h>
-
- extern int find_fixup_code(struct pt_regs *);
-@@ -109,11 +109,11 @@
- info.si_code = SEGV_MAPERR;
-
- /*
-- * If we're in an interrupt or "atomic" operation or have no
-+ * If we're in an interrupt, have pagefaults disabled or have no
- * user context, we must not take the fault.
- */
-
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/frv/mm/fault.c linux-4.1.39/arch/frv/mm/fault.c
---- linux-4.1.39.orig/arch/frv/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/frv/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -19,9 +19,9 @@
- #include <linux/kernel.h>
- #include <linux/ptrace.h>
- #include <linux/hardirq.h>
-+#include <linux/uaccess.h>
-
- #include <asm/pgtable.h>
--#include <asm/uaccess.h>
- #include <asm/gdb-stub.h>
-
- /*****************************************************************************/
-@@ -78,7 +78,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(__frame))
-diff -Nur linux-4.1.39.orig/arch/frv/mm/highmem.c linux-4.1.39/arch/frv/mm/highmem.c
---- linux-4.1.39.orig/arch/frv/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/frv/mm/highmem.c 2017-04-18 17:56:30.553394804 +0200
-@@ -42,6 +42,7 @@
- unsigned long paddr;
- int type;
-
-+ preempt_disable();
- pagefault_disable();
- type = kmap_atomic_idx_push();
- paddr = page_to_phys(page);
-@@ -85,5 +86,6 @@
- }
- kmap_atomic_idx_pop();
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-diff -Nur linux-4.1.39.orig/arch/hexagon/include/asm/uaccess.h linux-4.1.39/arch/hexagon/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/hexagon/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/hexagon/include/asm/uaccess.h 2017-04-18 17:56:30.553394804 +0200
-@@ -36,7 +36,8 @@
- * @addr: User space pointer to start of block to check
- * @size: Size of block to check
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Checks if a pointer to a block of memory in user space is valid.
- *
-diff -Nur linux-4.1.39.orig/arch/ia64/mm/fault.c linux-4.1.39/arch/ia64/mm/fault.c
---- linux-4.1.39.orig/arch/ia64/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/ia64/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -11,10 +11,10 @@
- #include <linux/kprobes.h>
- #include <linux/kdebug.h>
- #include <linux/prefetch.h>
-+#include <linux/uaccess.h>
-
- #include <asm/pgtable.h>
- #include <asm/processor.h>
--#include <asm/uaccess.h>
-
- extern int die(char *, struct pt_regs *, long);
-
-@@ -96,7 +96,7 @@
- /*
- * If we're in an interrupt or have no user context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- #ifdef CONFIG_VIRTUAL_MEM_MAP
-diff -Nur linux-4.1.39.orig/arch/Kconfig linux-4.1.39/arch/Kconfig
---- linux-4.1.39.orig/arch/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/Kconfig 2017-04-18 17:56:30.549394649 +0200
-@@ -6,6 +6,7 @@
- tristate "OProfile system profiling"
- depends on PROFILING
- depends on HAVE_OPROFILE
-+ depends on !PREEMPT_RT_FULL
- select RING_BUFFER
- select RING_BUFFER_ALLOW_SWAP
- help
-@@ -49,6 +50,7 @@
- config JUMP_LABEL
- bool "Optimize very unlikely/likely branches"
- depends on HAVE_ARCH_JUMP_LABEL
-+ depends on (!INTERRUPT_OFF_HIST && !PREEMPT_OFF_HIST && !WAKEUP_LATENCY_HIST && !MISSED_TIMER_OFFSETS_HIST)
- help
- This option enables a transparent branch optimization that
- makes certain almost-always-true or almost-always-false branch
-diff -Nur linux-4.1.39.orig/arch/m32r/include/asm/uaccess.h linux-4.1.39/arch/m32r/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/m32r/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/m32r/include/asm/uaccess.h 2017-04-18 17:56:30.553394804 +0200
-@@ -91,7 +91,8 @@
- * @addr: User space pointer to start of block to check
- * @size: Size of block to check
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Checks if a pointer to a block of memory in user space is valid.
- *
-@@ -155,7 +156,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -175,7 +177,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -194,7 +197,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -274,7 +278,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -568,7 +573,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -588,7 +594,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space.
- *
-@@ -606,7 +613,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -626,7 +634,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space.
- *
-@@ -677,7 +686,8 @@
- * strlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Get the size of a NUL-terminated string in user space.
- *
-diff -Nur linux-4.1.39.orig/arch/m32r/mm/fault.c linux-4.1.39/arch/m32r/mm/fault.c
---- linux-4.1.39.orig/arch/m32r/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/m32r/mm/fault.c 2017-04-18 17:56:30.553394804 +0200
-@@ -24,9 +24,9 @@
- #include <linux/vt_kern.h> /* For unblank_screen() */
- #include <linux/highmem.h>
- #include <linux/module.h>
-+#include <linux/uaccess.h>
-
- #include <asm/m32r.h>
--#include <asm/uaccess.h>
- #include <asm/hardirq.h>
- #include <asm/mmu_context.h>
- #include <asm/tlbflush.h>
-@@ -111,10 +111,10 @@
- mm = tsk->mm;
-
- /*
-- * If we're in an interrupt or have no user context or are running in an
-- * atomic region then we must not take the fault..
-+ * If we're in an interrupt or have no user context or have pagefaults
-+ * disabled then we must not take the fault.
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto bad_area_nosemaphore;
-
- if (error_code & ACE_USERMODE)
-diff -Nur linux-4.1.39.orig/arch/m68k/mm/fault.c linux-4.1.39/arch/m68k/mm/fault.c
---- linux-4.1.39.orig/arch/m68k/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/m68k/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -10,10 +10,10 @@
- #include <linux/ptrace.h>
- #include <linux/interrupt.h>
- #include <linux/module.h>
-+#include <linux/uaccess.h>
-
- #include <asm/setup.h>
- #include <asm/traps.h>
--#include <asm/uaccess.h>
- #include <asm/pgalloc.h>
-
- extern void die_if_kernel(char *, struct pt_regs *, long);
-@@ -81,7 +81,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/metag/mm/fault.c linux-4.1.39/arch/metag/mm/fault.c
---- linux-4.1.39.orig/arch/metag/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/metag/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -105,7 +105,7 @@
-
- mm = tsk->mm;
-
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/metag/mm/highmem.c linux-4.1.39/arch/metag/mm/highmem.c
---- linux-4.1.39.orig/arch/metag/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/metag/mm/highmem.c 2017-04-18 17:56:30.557394959 +0200
-@@ -43,7 +43,7 @@
- unsigned long vaddr;
- int type;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -82,6 +82,7 @@
- }
-
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-
-@@ -95,6 +96,7 @@
- unsigned long vaddr;
- int type;
-
-+ preempt_disable();
- pagefault_disable();
-
- type = kmap_atomic_idx_push();
-diff -Nur linux-4.1.39.orig/arch/microblaze/include/asm/uaccess.h linux-4.1.39/arch/microblaze/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/microblaze/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/microblaze/include/asm/uaccess.h 2017-04-18 17:56:30.557394959 +0200
-@@ -178,7 +178,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -290,7 +291,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-diff -Nur linux-4.1.39.orig/arch/microblaze/mm/fault.c linux-4.1.39/arch/microblaze/mm/fault.c
---- linux-4.1.39.orig/arch/microblaze/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/microblaze/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -107,14 +107,14 @@
- if ((error_code & 0x13) == 0x13 || (error_code & 0x11) == 0x11)
- is_write = 0;
-
-- if (unlikely(in_atomic() || !mm)) {
-+ if (unlikely(faulthandler_disabled() || !mm)) {
- if (kernel_mode(regs))
- goto bad_area_nosemaphore;
-
-- /* in_atomic() in user mode is really bad,
-+ /* faulthandler_disabled() in user mode is really bad,
- as is current->mm == NULL. */
-- pr_emerg("Page fault in user mode with in_atomic(), mm = %p\n",
-- mm);
-+ pr_emerg("Page fault in user mode with faulthandler_disabled(), mm = %p\n",
-+ mm);
- pr_emerg("r15 = %lx MSR = %lx\n",
- regs->r15, regs->msr);
- die("Weird page fault", regs, SIGSEGV);
-diff -Nur linux-4.1.39.orig/arch/microblaze/mm/highmem.c linux-4.1.39/arch/microblaze/mm/highmem.c
---- linux-4.1.39.orig/arch/microblaze/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/microblaze/mm/highmem.c 2017-04-18 17:56:30.557394959 +0200
-@@ -37,7 +37,7 @@
- unsigned long vaddr;
- int idx, type;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -63,6 +63,7 @@
-
- if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
- pagefault_enable();
-+ preempt_enable();
- return;
- }
-
-@@ -84,5 +85,6 @@
- #endif
- kmap_atomic_idx_pop();
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-diff -Nur linux-4.1.39.orig/arch/mips/include/asm/uaccess.h linux-4.1.39/arch/mips/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/mips/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mips/include/asm/uaccess.h 2017-04-18 17:56:30.557394959 +0200
-@@ -104,7 +104,8 @@
- * @addr: User space pointer to start of block to check
- * @size: Size of block to check
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Checks if a pointer to a block of memory in user space is valid.
- *
-@@ -139,7 +140,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -158,7 +160,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -178,7 +181,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -200,7 +204,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -499,7 +504,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -518,7 +524,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -538,7 +545,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -560,7 +568,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -816,7 +825,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -889,7 +899,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space.
- *
-@@ -1076,7 +1087,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -1108,7 +1120,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space.
- *
-@@ -1332,7 +1345,8 @@
- * strlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Get the size of a NUL-terminated string in user space.
- *
-@@ -1401,7 +1415,8 @@
- * strnlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Get the size of a NUL-terminated string in user space.
- *
-diff -Nur linux-4.1.39.orig/arch/mips/Kconfig linux-4.1.39/arch/mips/Kconfig
---- linux-4.1.39.orig/arch/mips/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mips/Kconfig 2017-04-18 17:56:30.557394959 +0200
-@@ -2367,7 +2367,7 @@
- #
- config HIGHMEM
- bool "High Memory Support"
-- depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM && !CPU_MIPS32_3_5_EVA
-+ depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM && !CPU_MIPS32_3_5_EVA && !PREEMPT_RT_FULL
-
- config CPU_SUPPORTS_HIGHMEM
- bool
-diff -Nur linux-4.1.39.orig/arch/mips/kernel/signal-common.h linux-4.1.39/arch/mips/kernel/signal-common.h
---- linux-4.1.39.orig/arch/mips/kernel/signal-common.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mips/kernel/signal-common.h 2017-04-18 17:56:30.557394959 +0200
-@@ -28,12 +28,7 @@
- extern int fpcsr_pending(unsigned int __user *fpcsr);
-
- /* Make sure we will not lose FPU ownership */
--#ifdef CONFIG_PREEMPT
--#define lock_fpu_owner() preempt_disable()
--#define unlock_fpu_owner() preempt_enable()
--#else
--#define lock_fpu_owner() pagefault_disable()
--#define unlock_fpu_owner() pagefault_enable()
--#endif
-+#define lock_fpu_owner() ({ preempt_disable(); pagefault_disable(); })
-+#define unlock_fpu_owner() ({ pagefault_enable(); preempt_enable(); })
-
- #endif /* __SIGNAL_COMMON_H */
-diff -Nur linux-4.1.39.orig/arch/mips/mm/fault.c linux-4.1.39/arch/mips/mm/fault.c
---- linux-4.1.39.orig/arch/mips/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mips/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -21,10 +21,10 @@
- #include <linux/module.h>
- #include <linux/kprobes.h>
- #include <linux/perf_event.h>
-+#include <linux/uaccess.h>
-
- #include <asm/branch.h>
- #include <asm/mmu_context.h>
--#include <asm/uaccess.h>
- #include <asm/ptrace.h>
- #include <asm/highmem.h> /* For VMALLOC_END */
- #include <linux/kdebug.h>
-@@ -94,7 +94,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto bad_area_nosemaphore;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/mips/mm/highmem.c linux-4.1.39/arch/mips/mm/highmem.c
---- linux-4.1.39.orig/arch/mips/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mips/mm/highmem.c 2017-04-18 17:56:30.557394959 +0200
-@@ -47,7 +47,7 @@
- unsigned long vaddr;
- int idx, type;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -72,6 +72,7 @@
-
- if (vaddr < FIXADDR_START) { // FIXME
- pagefault_enable();
-+ preempt_enable();
- return;
- }
-
-@@ -92,6 +93,7 @@
- #endif
- kmap_atomic_idx_pop();
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-
-@@ -104,6 +106,7 @@
- unsigned long vaddr;
- int idx, type;
-
-+ preempt_disable();
- pagefault_disable();
-
- type = kmap_atomic_idx_push();
-diff -Nur linux-4.1.39.orig/arch/mips/mm/init.c linux-4.1.39/arch/mips/mm/init.c
---- linux-4.1.39.orig/arch/mips/mm/init.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mips/mm/init.c 2017-04-18 17:56:30.557394959 +0200
-@@ -90,6 +90,7 @@
-
- BUG_ON(Page_dcache_dirty(page));
-
-+ preempt_disable();
- pagefault_disable();
- idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
- idx += in_interrupt() ? FIX_N_COLOURS : 0;
-@@ -152,6 +153,7 @@
- write_c0_entryhi(old_ctx);
- local_irq_restore(flags);
- pagefault_enable();
-+ preempt_enable();
- }
-
- void copy_user_highpage(struct page *to, struct page *from,
-diff -Nur linux-4.1.39.orig/arch/mn10300/include/asm/highmem.h linux-4.1.39/arch/mn10300/include/asm/highmem.h
---- linux-4.1.39.orig/arch/mn10300/include/asm/highmem.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mn10300/include/asm/highmem.h 2017-04-18 17:56:30.557394959 +0200
-@@ -75,6 +75,7 @@
- unsigned long vaddr;
- int idx, type;
-
-+ preempt_disable();
- pagefault_disable();
- if (page < highmem_start_page)
- return page_address(page);
-@@ -98,6 +99,7 @@
-
- if (vaddr < FIXADDR_START) { /* FIXME */
- pagefault_enable();
-+ preempt_enable();
- return;
- }
-
-@@ -122,6 +124,7 @@
-
- kmap_atomic_idx_pop();
- pagefault_enable();
-+ preempt_enable();
- }
- #endif /* __KERNEL__ */
-
-diff -Nur linux-4.1.39.orig/arch/mn10300/mm/fault.c linux-4.1.39/arch/mn10300/mm/fault.c
---- linux-4.1.39.orig/arch/mn10300/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/mn10300/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -23,8 +23,8 @@
- #include <linux/interrupt.h>
- #include <linux/init.h>
- #include <linux/vt_kern.h> /* For unblank_screen() */
-+#include <linux/uaccess.h>
-
--#include <asm/uaccess.h>
- #include <asm/pgalloc.h>
- #include <asm/hardirq.h>
- #include <asm/cpu-regs.h>
-@@ -168,7 +168,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
-diff -Nur linux-4.1.39.orig/arch/nios2/mm/fault.c linux-4.1.39/arch/nios2/mm/fault.c
---- linux-4.1.39.orig/arch/nios2/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/nios2/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -77,7 +77,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto bad_area_nosemaphore;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/parisc/include/asm/cacheflush.h linux-4.1.39/arch/parisc/include/asm/cacheflush.h
---- linux-4.1.39.orig/arch/parisc/include/asm/cacheflush.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/parisc/include/asm/cacheflush.h 2017-04-18 17:56:30.557394959 +0200
-@@ -142,6 +142,7 @@
-
- static inline void *kmap_atomic(struct page *page)
- {
-+ preempt_disable();
- pagefault_disable();
- return page_address(page);
- }
-@@ -150,6 +151,7 @@
- {
- flush_kernel_dcache_page_addr(addr);
- pagefault_enable();
-+ preempt_enable();
- }
-
- #define kmap_atomic_prot(page, prot) kmap_atomic(page)
-diff -Nur linux-4.1.39.orig/arch/parisc/kernel/traps.c linux-4.1.39/arch/parisc/kernel/traps.c
---- linux-4.1.39.orig/arch/parisc/kernel/traps.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/parisc/kernel/traps.c 2017-04-18 17:56:30.557394959 +0200
-@@ -26,9 +26,9 @@
- #include <linux/console.h>
- #include <linux/bug.h>
- #include <linux/ratelimit.h>
-+#include <linux/uaccess.h>
-
- #include <asm/assembly.h>
--#include <asm/uaccess.h>
- #include <asm/io.h>
- #include <asm/irq.h>
- #include <asm/traps.h>
-@@ -796,7 +796,7 @@
- * unless pagefault_disable() was called before.
- */
-
-- if (fault_space == 0 && !in_atomic())
-+ if (fault_space == 0 && !faulthandler_disabled())
- {
- /* Clean up and return if in exception table. */
- if (fixup_exception(regs))
-diff -Nur linux-4.1.39.orig/arch/parisc/mm/fault.c linux-4.1.39/arch/parisc/mm/fault.c
---- linux-4.1.39.orig/arch/parisc/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/parisc/mm/fault.c 2017-04-18 17:56:30.557394959 +0200
-@@ -15,8 +15,8 @@
- #include <linux/sched.h>
- #include <linux/interrupt.h>
- #include <linux/module.h>
-+#include <linux/uaccess.h>
-
--#include <asm/uaccess.h>
- #include <asm/traps.h>
-
- /* Various important other fields */
-@@ -208,7 +208,7 @@
- int fault;
- unsigned int flags;
-
-- if (in_atomic())
-+ if (pagefault_disabled())
- goto no_context;
-
- tsk = current;
-diff -Nur linux-4.1.39.orig/arch/powerpc/include/asm/kvm_host.h linux-4.1.39/arch/powerpc/include/asm/kvm_host.h
---- linux-4.1.39.orig/arch/powerpc/include/asm/kvm_host.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/include/asm/kvm_host.h 2017-04-18 17:56:30.557394959 +0200
-@@ -280,7 +280,7 @@
- u8 in_guest;
- struct list_head runnable_threads;
- spinlock_t lock;
-- wait_queue_head_t wq;
-+ struct swait_head wq;
- spinlock_t stoltb_lock; /* protects stolen_tb and preempt_tb */
- u64 stolen_tb;
- u64 preempt_tb;
-@@ -614,7 +614,7 @@
- u8 prodded;
- u32 last_inst;
-
-- wait_queue_head_t *wqp;
-+ struct swait_head *wqp;
- struct kvmppc_vcore *vcore;
- int ret;
- int trap;
-diff -Nur linux-4.1.39.orig/arch/powerpc/include/asm/thread_info.h linux-4.1.39/arch/powerpc/include/asm/thread_info.h
---- linux-4.1.39.orig/arch/powerpc/include/asm/thread_info.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/include/asm/thread_info.h 2017-04-18 17:56:30.557394959 +0200
-@@ -42,6 +42,8 @@
- int cpu; /* cpu we're on */
- int preempt_count; /* 0 => preemptable,
- <0 => BUG */
-+ int preempt_lazy_count; /* 0 => preemptable,
-+ <0 => BUG */
- unsigned long local_flags; /* private flags for thread */
-
- /* low level flags - has atomic operations done on it */
-@@ -82,8 +84,7 @@
- #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
- #define TIF_SIGPENDING 1 /* signal pending */
- #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
--#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
-- TIF_NEED_RESCHED */
-+#define TIF_NEED_RESCHED_LAZY 3 /* lazy rescheduling necessary */
- #define TIF_32BIT 4 /* 32 bit binary */
- #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
- #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
-@@ -101,6 +102,8 @@
- #if defined(CONFIG_PPC64)
- #define TIF_ELF2ABI 18 /* function descriptors must die! */
- #endif
-+#define TIF_POLLING_NRFLAG 19 /* true if poll_idle() is polling
-+ TIF_NEED_RESCHED */
-
- /* as above, but as bit values */
- #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
-@@ -119,14 +122,16 @@
- #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
- #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
- #define _TIF_NOHZ (1<<TIF_NOHZ)
-+#define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)
- #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
- _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
- _TIF_NOHZ)
-
- #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
- _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
-- _TIF_RESTORE_TM)
-+ _TIF_RESTORE_TM | _TIF_NEED_RESCHED_LAZY)
- #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
-+#define _TIF_NEED_RESCHED_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)
-
- /* Bits in local_flags */
- /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
-diff -Nur linux-4.1.39.orig/arch/powerpc/Kconfig linux-4.1.39/arch/powerpc/Kconfig
---- linux-4.1.39.orig/arch/powerpc/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/Kconfig 2017-04-18 17:56:30.557394959 +0200
-@@ -60,10 +60,11 @@
-
- config RWSEM_GENERIC_SPINLOCK
- bool
-+ default y if PREEMPT_RT_FULL
-
- config RWSEM_XCHGADD_ALGORITHM
- bool
-- default y
-+ default y if !PREEMPT_RT_FULL
-
- config GENERIC_LOCKBREAK
- bool
-@@ -138,6 +139,7 @@
- select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
- select GENERIC_STRNCPY_FROM_USER
- select GENERIC_STRNLEN_USER
-+ select HAVE_PREEMPT_LAZY
- select HAVE_MOD_ARCH_SPECIFIC
- select MODULES_USE_ELF_RELA
- select CLONE_BACKWARDS
-@@ -312,7 +314,7 @@
-
- config HIGHMEM
- bool "High memory support"
-- depends on PPC32
-+ depends on PPC32 && !PREEMPT_RT_FULL
-
- source kernel/Kconfig.hz
- source kernel/Kconfig.preempt
-diff -Nur linux-4.1.39.orig/arch/powerpc/kernel/asm-offsets.c linux-4.1.39/arch/powerpc/kernel/asm-offsets.c
---- linux-4.1.39.orig/arch/powerpc/kernel/asm-offsets.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kernel/asm-offsets.c 2017-04-18 17:56:30.557394959 +0200
-@@ -160,6 +160,7 @@
- DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
- DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags));
- DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
-+ DEFINE(TI_PREEMPT_LAZY, offsetof(struct thread_info, preempt_lazy_count));
- DEFINE(TI_TASK, offsetof(struct thread_info, task));
- DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
-
-diff -Nur linux-4.1.39.orig/arch/powerpc/kernel/entry_32.S linux-4.1.39/arch/powerpc/kernel/entry_32.S
---- linux-4.1.39.orig/arch/powerpc/kernel/entry_32.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kernel/entry_32.S 2017-04-18 17:56:30.557394959 +0200
-@@ -813,7 +813,14 @@
- cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
- bne restore
- andi. r8,r8,_TIF_NEED_RESCHED
-+ bne+ 1f
-+ lwz r0,TI_PREEMPT_LAZY(r9)
-+ cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
-+ bne restore
-+ lwz r0,TI_FLAGS(r9)
-+ andi. r0,r0,_TIF_NEED_RESCHED_LAZY
- beq+ restore
-+1:
- lwz r3,_MSR(r1)
- andi. r0,r3,MSR_EE /* interrupts off? */
- beq restore /* don't schedule if so */
-@@ -824,11 +831,11 @@
- */
- bl trace_hardirqs_off
- #endif
--1: bl preempt_schedule_irq
-+2: bl preempt_schedule_irq
- CURRENT_THREAD_INFO(r9, r1)
- lwz r3,TI_FLAGS(r9)
-- andi. r0,r3,_TIF_NEED_RESCHED
-- bne- 1b
-+ andi. r0,r3,_TIF_NEED_RESCHED_MASK
-+ bne- 2b
- #ifdef CONFIG_TRACE_IRQFLAGS
- /* And now, to properly rebalance the above, we tell lockdep they
- * are being turned back on, which will happen when we return
-@@ -1149,7 +1156,7 @@
- #endif /* !(CONFIG_4xx || CONFIG_BOOKE) */
-
- do_work: /* r10 contains MSR_KERNEL here */
-- andi. r0,r9,_TIF_NEED_RESCHED
-+ andi. r0,r9,_TIF_NEED_RESCHED_MASK
- beq do_user_signal
-
- do_resched: /* r10 contains MSR_KERNEL here */
-@@ -1170,7 +1177,7 @@
- MTMSRD(r10) /* disable interrupts */
- CURRENT_THREAD_INFO(r9, r1)
- lwz r9,TI_FLAGS(r9)
-- andi. r0,r9,_TIF_NEED_RESCHED
-+ andi. r0,r9,_TIF_NEED_RESCHED_MASK
- bne- do_resched
- andi. r0,r9,_TIF_USER_WORK_MASK
- beq restore_user
-diff -Nur linux-4.1.39.orig/arch/powerpc/kernel/entry_64.S linux-4.1.39/arch/powerpc/kernel/entry_64.S
---- linux-4.1.39.orig/arch/powerpc/kernel/entry_64.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kernel/entry_64.S 2017-04-18 17:56:30.561395114 +0200
-@@ -636,7 +636,7 @@
- #else
- beq restore
- #endif
--1: andi. r0,r4,_TIF_NEED_RESCHED
-+1: andi. r0,r4,_TIF_NEED_RESCHED_MASK
- beq 2f
- bl restore_interrupts
- SCHEDULE_USER
-@@ -698,10 +698,18 @@
-
- #ifdef CONFIG_PREEMPT
- /* Check if we need to preempt */
-+ lwz r8,TI_PREEMPT(r9)
-+ cmpwi 0,r8,0 /* if non-zero, just restore regs and return */
-+ bne restore
- andi. r0,r4,_TIF_NEED_RESCHED
-+ bne+ check_count
-+
-+ andi. r0,r4,_TIF_NEED_RESCHED_LAZY
- beq+ restore
-+ lwz r8,TI_PREEMPT_LAZY(r9)
-+
- /* Check that preempt_count() == 0 and interrupts are enabled */
-- lwz r8,TI_PREEMPT(r9)
-+check_count:
- cmpwi cr1,r8,0
- ld r0,SOFTE(r1)
- cmpdi r0,0
-@@ -718,7 +726,7 @@
- /* Re-test flags and eventually loop */
- CURRENT_THREAD_INFO(r9, r1)
- ld r4,TI_FLAGS(r9)
-- andi. r0,r4,_TIF_NEED_RESCHED
-+ andi. r0,r4,_TIF_NEED_RESCHED_MASK
- bne 1b
-
- /*
-diff -Nur linux-4.1.39.orig/arch/powerpc/kernel/irq.c linux-4.1.39/arch/powerpc/kernel/irq.c
---- linux-4.1.39.orig/arch/powerpc/kernel/irq.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kernel/irq.c 2017-04-18 17:56:30.561395114 +0200
-@@ -614,6 +614,7 @@
- }
- }
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- void do_softirq_own_stack(void)
- {
- struct thread_info *curtp, *irqtp;
-@@ -631,6 +632,7 @@
- if (irqtp->flags)
- set_bits(irqtp->flags, &curtp->flags);
- }
-+#endif
-
- irq_hw_number_t virq_to_hw(unsigned int virq)
- {
-diff -Nur linux-4.1.39.orig/arch/powerpc/kernel/misc_32.S linux-4.1.39/arch/powerpc/kernel/misc_32.S
---- linux-4.1.39.orig/arch/powerpc/kernel/misc_32.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kernel/misc_32.S 2017-04-18 17:56:30.561395114 +0200
-@@ -40,6 +40,7 @@
- * We store the saved ksp_limit in the unused part
- * of the STACK_FRAME_OVERHEAD
- */
-+#ifndef CONFIG_PREEMPT_RT_FULL
- _GLOBAL(call_do_softirq)
- mflr r0
- stw r0,4(r1)
-@@ -56,6 +57,7 @@
- stw r10,THREAD+KSP_LIMIT(r2)
- mtlr r0
- blr
-+#endif
-
- /*
- * void call_do_irq(struct pt_regs *regs, struct thread_info *irqtp);
-diff -Nur linux-4.1.39.orig/arch/powerpc/kernel/misc_64.S linux-4.1.39/arch/powerpc/kernel/misc_64.S
---- linux-4.1.39.orig/arch/powerpc/kernel/misc_64.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kernel/misc_64.S 2017-04-18 17:56:30.561395114 +0200
-@@ -29,6 +29,7 @@
-
- .text
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- _GLOBAL(call_do_softirq)
- mflr r0
- std r0,16(r1)
-@@ -39,6 +40,7 @@
- ld r0,16(r1)
- mtlr r0
- blr
-+#endif
-
- _GLOBAL(call_do_irq)
- mflr r0
-diff -Nur linux-4.1.39.orig/arch/powerpc/kvm/book3s_hv.c linux-4.1.39/arch/powerpc/kvm/book3s_hv.c
---- linux-4.1.39.orig/arch/powerpc/kvm/book3s_hv.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kvm/book3s_hv.c 2017-04-18 17:56:30.561395114 +0200
-@@ -115,11 +115,11 @@
- static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu)
- {
- int cpu = vcpu->cpu;
-- wait_queue_head_t *wqp;
-+ struct swait_head *wqp;
-
- wqp = kvm_arch_vcpu_wq(vcpu);
-- if (waitqueue_active(wqp)) {
-- wake_up_interruptible(wqp);
-+ if (swaitqueue_active(wqp)) {
-+ swait_wake_interruptible(wqp);
- ++vcpu->stat.halt_wakeup;
- }
-
-@@ -692,8 +692,8 @@
- tvcpu->arch.prodded = 1;
- smp_mb();
- if (vcpu->arch.ceded) {
-- if (waitqueue_active(&vcpu->wq)) {
-- wake_up_interruptible(&vcpu->wq);
-+ if (swaitqueue_active(&vcpu->wq)) {
-+ swait_wake_interruptible(&vcpu->wq);
- vcpu->stat.halt_wakeup++;
- }
- }
-@@ -1438,7 +1438,7 @@
- INIT_LIST_HEAD(&vcore->runnable_threads);
- spin_lock_init(&vcore->lock);
- spin_lock_init(&vcore->stoltb_lock);
-- init_waitqueue_head(&vcore->wq);
-+ init_swait_head(&vcore->wq);
- vcore->preempt_tb = TB_NIL;
- vcore->lpcr = kvm->arch.lpcr;
- vcore->first_vcpuid = core * threads_per_subcore;
-@@ -2085,10 +2085,9 @@
- {
- struct kvm_vcpu *vcpu;
- int do_sleep = 1;
-+ DEFINE_SWAITER(wait);
-
-- DEFINE_WAIT(wait);
--
-- prepare_to_wait(&vc->wq, &wait, TASK_INTERRUPTIBLE);
-+ swait_prepare(&vc->wq, &wait, TASK_INTERRUPTIBLE);
-
- /*
- * Check one last time for pending exceptions and ceded state after
-@@ -2102,7 +2101,7 @@
- }
-
- if (!do_sleep) {
-- finish_wait(&vc->wq, &wait);
-+ swait_finish(&vc->wq, &wait);
- return;
- }
-
-@@ -2110,7 +2109,7 @@
- trace_kvmppc_vcore_blocked(vc, 0);
- spin_unlock(&vc->lock);
- schedule();
-- finish_wait(&vc->wq, &wait);
-+ swait_finish(&vc->wq, &wait);
- spin_lock(&vc->lock);
- vc->vcore_state = VCORE_INACTIVE;
- trace_kvmppc_vcore_blocked(vc, 1);
-@@ -2154,7 +2153,7 @@
- kvmppc_start_thread(vcpu);
- trace_kvm_guest_enter(vcpu);
- } else if (vc->vcore_state == VCORE_SLEEPING) {
-- wake_up(&vc->wq);
-+ swait_wake(&vc->wq);
- }
-
- }
-diff -Nur linux-4.1.39.orig/arch/powerpc/kvm/Kconfig linux-4.1.39/arch/powerpc/kvm/Kconfig
---- linux-4.1.39.orig/arch/powerpc/kvm/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/kvm/Kconfig 2017-04-18 17:56:30.561395114 +0200
-@@ -172,6 +172,7 @@
- config KVM_MPIC
- bool "KVM in-kernel MPIC emulation"
- depends on KVM && E500
-+ depends on !PREEMPT_RT_FULL
- select HAVE_KVM_IRQCHIP
- select HAVE_KVM_IRQFD
- select HAVE_KVM_IRQ_ROUTING
-diff -Nur linux-4.1.39.orig/arch/powerpc/mm/fault.c linux-4.1.39/arch/powerpc/mm/fault.c
---- linux-4.1.39.orig/arch/powerpc/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/mm/fault.c 2017-04-18 17:56:30.561395114 +0200
-@@ -33,13 +33,13 @@
- #include <linux/ratelimit.h>
- #include <linux/context_tracking.h>
- #include <linux/hugetlb.h>
-+#include <linux/uaccess.h>
-
- #include <asm/firmware.h>
- #include <asm/page.h>
- #include <asm/pgtable.h>
- #include <asm/mmu.h>
- #include <asm/mmu_context.h>
--#include <asm/uaccess.h>
- #include <asm/tlbflush.h>
- #include <asm/siginfo.h>
- #include <asm/debug.h>
-@@ -272,15 +272,16 @@
- if (!arch_irq_disabled_regs(regs))
- local_irq_enable();
-
-- if (in_atomic() || mm == NULL) {
-+ if (faulthandler_disabled() || mm == NULL) {
- if (!user_mode(regs)) {
- rc = SIGSEGV;
- goto bail;
- }
-- /* in_atomic() in user mode is really bad,
-+ /* faulthandler_disabled() in user mode is really bad,
- as is current->mm == NULL. */
- printk(KERN_EMERG "Page fault in user mode with "
-- "in_atomic() = %d mm = %p\n", in_atomic(), mm);
-+ "faulthandler_disabled() = %d mm = %p\n",
-+ faulthandler_disabled(), mm);
- printk(KERN_EMERG "NIP = %lx MSR = %lx\n",
- regs->nip, regs->msr);
- die("Weird page fault", regs, SIGSEGV);
-diff -Nur linux-4.1.39.orig/arch/powerpc/mm/highmem.c linux-4.1.39/arch/powerpc/mm/highmem.c
---- linux-4.1.39.orig/arch/powerpc/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/mm/highmem.c 2017-04-18 17:56:30.561395114 +0200
-@@ -34,7 +34,7 @@
- unsigned long vaddr;
- int idx, type;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -59,6 +59,7 @@
-
- if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
- pagefault_enable();
-+ preempt_enable();
- return;
- }
-
-@@ -82,5 +83,6 @@
-
- kmap_atomic_idx_pop();
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-diff -Nur linux-4.1.39.orig/arch/powerpc/platforms/ps3/device-init.c linux-4.1.39/arch/powerpc/platforms/ps3/device-init.c
---- linux-4.1.39.orig/arch/powerpc/platforms/ps3/device-init.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/powerpc/platforms/ps3/device-init.c 2017-04-18 17:56:30.561395114 +0200
-@@ -752,7 +752,7 @@
- }
- pr_debug("%s:%u: notification %s issued\n", __func__, __LINE__, op);
-
-- res = wait_event_interruptible(dev->done.wait,
-+ res = swait_event_interruptible(dev->done.wait,
- dev->done.done || kthread_should_stop());
- if (kthread_should_stop())
- res = -EINTR;
-diff -Nur linux-4.1.39.orig/arch/s390/include/asm/kvm_host.h linux-4.1.39/arch/s390/include/asm/kvm_host.h
---- linux-4.1.39.orig/arch/s390/include/asm/kvm_host.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/s390/include/asm/kvm_host.h 2017-04-18 17:56:30.561395114 +0200
-@@ -419,7 +419,7 @@
- struct kvm_s390_local_interrupt {
- spinlock_t lock;
- struct kvm_s390_float_interrupt *float_int;
-- wait_queue_head_t *wq;
-+ struct swait_head *wq;
- atomic_t *cpuflags;
- DECLARE_BITMAP(sigp_emerg_pending, KVM_MAX_VCPUS);
- struct kvm_s390_irq_payload irq;
-diff -Nur linux-4.1.39.orig/arch/s390/include/asm/uaccess.h linux-4.1.39/arch/s390/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/s390/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/s390/include/asm/uaccess.h 2017-04-18 17:56:30.561395114 +0200
-@@ -98,7 +98,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -118,7 +119,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -264,7 +266,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space.
- *
-@@ -290,7 +293,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space.
- *
-@@ -348,7 +352,8 @@
- * strlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Get the size of a NUL-terminated string in user space.
- *
-diff -Nur linux-4.1.39.orig/arch/s390/kvm/interrupt.c linux-4.1.39/arch/s390/kvm/interrupt.c
---- linux-4.1.39.orig/arch/s390/kvm/interrupt.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/s390/kvm/interrupt.c 2017-04-18 17:56:30.561395114 +0200
-@@ -875,13 +875,13 @@
-
- void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu)
- {
-- if (waitqueue_active(&vcpu->wq)) {
-+ if (swaitqueue_active(&vcpu->wq)) {
- /*
- * The vcpu gave up the cpu voluntarily, mark it as a good
- * yield-candidate.
- */
- vcpu->preempted = true;
-- wake_up_interruptible(&vcpu->wq);
-+ swait_wake_interruptible(&vcpu->wq);
- vcpu->stat.halt_wakeup++;
- }
- }
-@@ -987,7 +987,7 @@
- spin_lock(&li->lock);
- irq.u.pgm.code = code;
- __inject_prog(vcpu, &irq);
-- BUG_ON(waitqueue_active(li->wq));
-+ BUG_ON(swaitqueue_active(li->wq));
- spin_unlock(&li->lock);
- return 0;
- }
-@@ -1006,7 +1006,7 @@
- spin_lock(&li->lock);
- irq.u.pgm = *pgm_info;
- rc = __inject_prog(vcpu, &irq);
-- BUG_ON(waitqueue_active(li->wq));
-+ BUG_ON(swaitqueue_active(li->wq));
- spin_unlock(&li->lock);
- return rc;
- }
-diff -Nur linux-4.1.39.orig/arch/s390/mm/fault.c linux-4.1.39/arch/s390/mm/fault.c
---- linux-4.1.39.orig/arch/s390/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/s390/mm/fault.c 2017-04-18 17:56:30.561395114 +0200
-@@ -399,7 +399,7 @@
- * user context.
- */
- fault = VM_FAULT_BADCONTEXT;
-- if (unlikely(!user_space_fault(regs) || in_atomic() || !mm))
-+ if (unlikely(!user_space_fault(regs) || faulthandler_disabled() || !mm))
- goto out;
-
- address = trans_exc_code & __FAIL_ADDR_MASK;
-diff -Nur linux-4.1.39.orig/arch/score/include/asm/uaccess.h linux-4.1.39/arch/score/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/score/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/score/include/asm/uaccess.h 2017-04-18 17:56:30.561395114 +0200
-@@ -36,7 +36,8 @@
- * @addr: User space pointer to start of block to check
- * @size: Size of block to check
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Checks if a pointer to a block of memory in user space is valid.
- *
-@@ -61,7 +62,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -79,7 +81,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -98,7 +101,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -119,7 +123,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-diff -Nur linux-4.1.39.orig/arch/score/mm/fault.c linux-4.1.39/arch/score/mm/fault.c
---- linux-4.1.39.orig/arch/score/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/score/mm/fault.c 2017-04-18 17:56:30.561395114 +0200
-@@ -34,6 +34,7 @@
- #include <linux/string.h>
- #include <linux/types.h>
- #include <linux/ptrace.h>
-+#include <linux/uaccess.h>
-
- /*
- * This routine handles page faults. It determines the address,
-@@ -73,7 +74,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (pagefault_disabled() || !mm)
- goto bad_area_nosemaphore;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/sh/kernel/irq.c linux-4.1.39/arch/sh/kernel/irq.c
---- linux-4.1.39.orig/arch/sh/kernel/irq.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sh/kernel/irq.c 2017-04-18 17:56:30.561395114 +0200
-@@ -147,6 +147,7 @@
- hardirq_ctx[cpu] = NULL;
- }
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- void do_softirq_own_stack(void)
- {
- struct thread_info *curctx;
-@@ -174,6 +175,7 @@
- "r5", "r6", "r7", "r8", "r9", "r15", "t", "pr"
- );
- }
-+#endif
- #else
- static inline void handle_one_irq(unsigned int irq)
- {
-diff -Nur linux-4.1.39.orig/arch/sh/mm/fault.c linux-4.1.39/arch/sh/mm/fault.c
---- linux-4.1.39.orig/arch/sh/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sh/mm/fault.c 2017-04-18 17:56:30.561395114 +0200
-@@ -17,6 +17,7 @@
- #include <linux/kprobes.h>
- #include <linux/perf_event.h>
- #include <linux/kdebug.h>
-+#include <linux/uaccess.h>
- #include <asm/io_trapped.h>
- #include <asm/mmu_context.h>
- #include <asm/tlbflush.h>
-@@ -438,9 +439,9 @@
-
- /*
- * If we're in an interrupt, have no user context or are running
-- * in an atomic region then we must not take the fault:
-+ * with pagefaults disabled then we must not take the fault:
- */
-- if (unlikely(in_atomic() || !mm)) {
-+ if (unlikely(faulthandler_disabled() || !mm)) {
- bad_area_nosemaphore(regs, error_code, address);
- return;
- }
-diff -Nur linux-4.1.39.orig/arch/sparc/Kconfig linux-4.1.39/arch/sparc/Kconfig
---- linux-4.1.39.orig/arch/sparc/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sparc/Kconfig 2017-04-18 17:56:30.561395114 +0200
-@@ -189,12 +189,10 @@
- source kernel/Kconfig.hz
-
- config RWSEM_GENERIC_SPINLOCK
-- bool
-- default y if SPARC32
-+ def_bool PREEMPT_RT_FULL
-
- config RWSEM_XCHGADD_ALGORITHM
-- bool
-- default y if SPARC64
-+ def_bool !RWSEM_GENERIC_SPINLOCK && !PREEMPT_RT_FULL
-
- config GENERIC_HWEIGHT
- bool
-diff -Nur linux-4.1.39.orig/arch/sparc/kernel/irq_64.c linux-4.1.39/arch/sparc/kernel/irq_64.c
---- linux-4.1.39.orig/arch/sparc/kernel/irq_64.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sparc/kernel/irq_64.c 2017-04-18 17:56:30.561395114 +0200
-@@ -849,6 +849,7 @@
- set_irq_regs(old_regs);
- }
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- void do_softirq_own_stack(void)
- {
- void *orig_sp, *sp = softirq_stack[smp_processor_id()];
-@@ -863,6 +864,7 @@
- __asm__ __volatile__("mov %0, %%sp"
- : : "r" (orig_sp));
- }
-+#endif
-
- #ifdef CONFIG_HOTPLUG_CPU
- void fixup_irqs(void)
-diff -Nur linux-4.1.39.orig/arch/sparc/mm/fault_32.c linux-4.1.39/arch/sparc/mm/fault_32.c
---- linux-4.1.39.orig/arch/sparc/mm/fault_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sparc/mm/fault_32.c 2017-04-18 17:56:30.561395114 +0200
-@@ -21,6 +21,7 @@
- #include <linux/perf_event.h>
- #include <linux/interrupt.h>
- #include <linux/kdebug.h>
-+#include <linux/uaccess.h>
-
- #include <asm/page.h>
- #include <asm/pgtable.h>
-@@ -29,7 +30,6 @@
- #include <asm/setup.h>
- #include <asm/smp.h>
- #include <asm/traps.h>
--#include <asm/uaccess.h>
-
- #include "mm_32.h"
-
-@@ -196,7 +196,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (pagefault_disabled() || !mm)
- goto no_context;
-
- perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-diff -Nur linux-4.1.39.orig/arch/sparc/mm/fault_64.c linux-4.1.39/arch/sparc/mm/fault_64.c
---- linux-4.1.39.orig/arch/sparc/mm/fault_64.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sparc/mm/fault_64.c 2017-04-18 17:56:30.561395114 +0200
-@@ -22,12 +22,12 @@
- #include <linux/kdebug.h>
- #include <linux/percpu.h>
- #include <linux/context_tracking.h>
-+#include <linux/uaccess.h>
-
- #include <asm/page.h>
- #include <asm/pgtable.h>
- #include <asm/openprom.h>
- #include <asm/oplib.h>
--#include <asm/uaccess.h>
- #include <asm/asi.h>
- #include <asm/lsu.h>
- #include <asm/sections.h>
-@@ -330,7 +330,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto intr_or_no_mm;
-
- perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-diff -Nur linux-4.1.39.orig/arch/sparc/mm/highmem.c linux-4.1.39/arch/sparc/mm/highmem.c
---- linux-4.1.39.orig/arch/sparc/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sparc/mm/highmem.c 2017-04-18 17:56:30.561395114 +0200
-@@ -53,7 +53,7 @@
- unsigned long vaddr;
- long idx, type;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -91,6 +91,7 @@
-
- if (vaddr < FIXADDR_START) { // FIXME
- pagefault_enable();
-+ preempt_enable();
- return;
- }
-
-@@ -126,5 +127,6 @@
-
- kmap_atomic_idx_pop();
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-diff -Nur linux-4.1.39.orig/arch/sparc/mm/init_64.c linux-4.1.39/arch/sparc/mm/init_64.c
---- linux-4.1.39.orig/arch/sparc/mm/init_64.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/sparc/mm/init_64.c 2017-04-18 17:56:30.565395270 +0200
-@@ -2738,7 +2738,7 @@
- struct mm_struct *mm = current->mm;
- struct tsb_config *tp;
-
-- if (in_atomic() || !mm) {
-+ if (faulthandler_disabled() || !mm) {
- const struct exception_table_entry *entry;
-
- entry = search_exception_tables(regs->tpc);
-diff -Nur linux-4.1.39.orig/arch/tile/include/asm/uaccess.h linux-4.1.39/arch/tile/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/tile/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/tile/include/asm/uaccess.h 2017-04-18 17:56:30.565395270 +0200
-@@ -78,7 +78,8 @@
- * @addr: User space pointer to start of block to check
- * @size: Size of block to check
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Checks if a pointer to a block of memory in user space is valid.
- *
-@@ -192,7 +193,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -274,7 +276,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -330,7 +333,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -366,7 +370,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -437,7 +442,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to user space. Caller must check
- * the specified blocks with access_ok() before calling this function.
-diff -Nur linux-4.1.39.orig/arch/tile/mm/fault.c linux-4.1.39/arch/tile/mm/fault.c
---- linux-4.1.39.orig/arch/tile/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/tile/mm/fault.c 2017-04-18 17:56:30.565395270 +0200
-@@ -354,9 +354,9 @@
-
- /*
- * If we're in an interrupt, have no user context or are running in an
-- * atomic region then we must not take the fault.
-+ * region with pagefaults disabled then we must not take the fault.
- */
-- if (in_atomic() || !mm) {
-+ if (pagefault_disabled() || !mm) {
- vma = NULL; /* happy compiler */
- goto bad_area_nosemaphore;
- }
-diff -Nur linux-4.1.39.orig/arch/tile/mm/highmem.c linux-4.1.39/arch/tile/mm/highmem.c
---- linux-4.1.39.orig/arch/tile/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/tile/mm/highmem.c 2017-04-18 17:56:30.565395270 +0200
-@@ -201,7 +201,7 @@
- int idx, type;
- pte_t *pte;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable();
- pagefault_disable();
-
- /* Avoid icache flushes by disallowing atomic executable mappings. */
-@@ -259,6 +259,7 @@
- }
-
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-
-diff -Nur linux-4.1.39.orig/arch/um/kernel/trap.c linux-4.1.39/arch/um/kernel/trap.c
---- linux-4.1.39.orig/arch/um/kernel/trap.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/um/kernel/trap.c 2017-04-18 17:56:30.565395270 +0200
-@@ -35,10 +35,10 @@
- *code_out = SEGV_MAPERR;
-
- /*
-- * If the fault was during atomic operation, don't take the fault, just
-+ * If the fault was with pagefaults disabled, don't take the fault, just
- * fail.
- */
-- if (in_atomic())
-+ if (faulthandler_disabled())
- goto out_nosemaphore;
-
- if (is_user)
-diff -Nur linux-4.1.39.orig/arch/unicore32/mm/fault.c linux-4.1.39/arch/unicore32/mm/fault.c
---- linux-4.1.39.orig/arch/unicore32/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/unicore32/mm/fault.c 2017-04-18 17:56:30.565395270 +0200
-@@ -218,7 +218,7 @@
- * If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm)
-+ if (faulthandler_disabled() || !mm)
- goto no_context;
-
- if (user_mode(regs))
-diff -Nur linux-4.1.39.orig/arch/x86/crypto/aesni-intel_glue.c linux-4.1.39/arch/x86/crypto/aesni-intel_glue.c
---- linux-4.1.39.orig/arch/x86/crypto/aesni-intel_glue.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/crypto/aesni-intel_glue.c 2017-04-18 17:56:30.565395270 +0200
-@@ -382,14 +382,14 @@
- err = blkcipher_walk_virt(desc, &walk);
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
-- kernel_fpu_begin();
- while ((nbytes = walk.nbytes)) {
-+ kernel_fpu_begin();
- aesni_ecb_enc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
-- nbytes & AES_BLOCK_MASK);
-+ nbytes & AES_BLOCK_MASK);
-+ kernel_fpu_end();
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-- kernel_fpu_end();
-
- return err;
- }
-@@ -406,14 +406,14 @@
- err = blkcipher_walk_virt(desc, &walk);
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
-- kernel_fpu_begin();
- while ((nbytes = walk.nbytes)) {
-+ kernel_fpu_begin();
- aesni_ecb_dec(ctx, walk.dst.virt.addr, walk.src.virt.addr,
- nbytes & AES_BLOCK_MASK);
-+ kernel_fpu_end();
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-- kernel_fpu_end();
-
- return err;
- }
-@@ -430,14 +430,14 @@
- err = blkcipher_walk_virt(desc, &walk);
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
-- kernel_fpu_begin();
- while ((nbytes = walk.nbytes)) {
-+ kernel_fpu_begin();
- aesni_cbc_enc(ctx, walk.dst.virt.addr, walk.src.virt.addr,
- nbytes & AES_BLOCK_MASK, walk.iv);
-+ kernel_fpu_end();
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-- kernel_fpu_end();
-
- return err;
- }
-@@ -454,14 +454,14 @@
- err = blkcipher_walk_virt(desc, &walk);
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
-- kernel_fpu_begin();
- while ((nbytes = walk.nbytes)) {
-+ kernel_fpu_begin();
- aesni_cbc_dec(ctx, walk.dst.virt.addr, walk.src.virt.addr,
- nbytes & AES_BLOCK_MASK, walk.iv);
-+ kernel_fpu_end();
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-- kernel_fpu_end();
-
- return err;
- }
-@@ -513,18 +513,20 @@
- err = blkcipher_walk_virt_block(desc, &walk, AES_BLOCK_SIZE);
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
-- kernel_fpu_begin();
- while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) {
-+ kernel_fpu_begin();
- aesni_ctr_enc_tfm(ctx, walk.dst.virt.addr, walk.src.virt.addr,
- nbytes & AES_BLOCK_MASK, walk.iv);
-+ kernel_fpu_end();
- nbytes &= AES_BLOCK_SIZE - 1;
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
- if (walk.nbytes) {
-+ kernel_fpu_begin();
- ctr_crypt_final(ctx, &walk);
-+ kernel_fpu_end();
- err = blkcipher_walk_done(desc, &walk, 0);
- }
-- kernel_fpu_end();
-
- return err;
- }
-diff -Nur linux-4.1.39.orig/arch/x86/crypto/cast5_avx_glue.c linux-4.1.39/arch/x86/crypto/cast5_avx_glue.c
---- linux-4.1.39.orig/arch/x86/crypto/cast5_avx_glue.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/crypto/cast5_avx_glue.c 2017-04-18 17:56:30.565395270 +0200
-@@ -60,7 +60,7 @@
- static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
- bool enc)
- {
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
- const unsigned int bsize = CAST5_BLOCK_SIZE;
- unsigned int nbytes;
-@@ -76,7 +76,7 @@
- u8 *wsrc = walk->src.virt.addr;
- u8 *wdst = walk->dst.virt.addr;
-
-- fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes);
-+ fpu_enabled = cast5_fpu_begin(false, nbytes);
-
- /* Process multi-block batch */
- if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) {
-@@ -104,10 +104,9 @@
- } while (nbytes >= bsize);
-
- done:
-+ cast5_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, walk, nbytes);
- }
--
-- cast5_fpu_end(fpu_enabled);
- return err;
- }
-
-@@ -228,7 +227,7 @@
- static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
- struct scatterlist *src, unsigned int nbytes)
- {
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- struct blkcipher_walk walk;
- int err;
-
-@@ -237,12 +236,11 @@
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
- while ((nbytes = walk.nbytes)) {
-- fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes);
-+ fpu_enabled = cast5_fpu_begin(false, nbytes);
- nbytes = __cbc_decrypt(desc, &walk);
-+ cast5_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
--
-- cast5_fpu_end(fpu_enabled);
- return err;
- }
-
-@@ -312,7 +310,7 @@
- static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
- struct scatterlist *src, unsigned int nbytes)
- {
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- struct blkcipher_walk walk;
- int err;
-
-@@ -321,13 +319,12 @@
- desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
-
- while ((nbytes = walk.nbytes) >= CAST5_BLOCK_SIZE) {
-- fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes);
-+ fpu_enabled = cast5_fpu_begin(false, nbytes);
- nbytes = __ctr_crypt(desc, &walk);
-+ cast5_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-
-- cast5_fpu_end(fpu_enabled);
--
- if (walk.nbytes) {
- ctr_crypt_final(desc, &walk);
- err = blkcipher_walk_done(desc, &walk, 0);
-diff -Nur linux-4.1.39.orig/arch/x86/crypto/glue_helper.c linux-4.1.39/arch/x86/crypto/glue_helper.c
---- linux-4.1.39.orig/arch/x86/crypto/glue_helper.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/crypto/glue_helper.c 2017-04-18 17:56:30.565395270 +0200
-@@ -39,7 +39,7 @@
- void *ctx = crypto_blkcipher_ctx(desc->tfm);
- const unsigned int bsize = 128 / 8;
- unsigned int nbytes, i, func_bytes;
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- int err;
-
- err = blkcipher_walk_virt(desc, walk);
-@@ -49,7 +49,7 @@
- u8 *wdst = walk->dst.virt.addr;
-
- fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-- desc, fpu_enabled, nbytes);
-+ desc, false, nbytes);
-
- for (i = 0; i < gctx->num_funcs; i++) {
- func_bytes = bsize * gctx->funcs[i].num_blocks;
-@@ -71,10 +71,10 @@
- }
-
- done:
-+ glue_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, walk, nbytes);
- }
-
-- glue_fpu_end(fpu_enabled);
- return err;
- }
-
-@@ -194,7 +194,7 @@
- struct scatterlist *src, unsigned int nbytes)
- {
- const unsigned int bsize = 128 / 8;
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- struct blkcipher_walk walk;
- int err;
-
-@@ -203,12 +203,12 @@
-
- while ((nbytes = walk.nbytes)) {
- fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-- desc, fpu_enabled, nbytes);
-+ desc, false, nbytes);
- nbytes = __glue_cbc_decrypt_128bit(gctx, desc, &walk);
-+ glue_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-
-- glue_fpu_end(fpu_enabled);
- return err;
- }
- EXPORT_SYMBOL_GPL(glue_cbc_decrypt_128bit);
-@@ -277,7 +277,7 @@
- struct scatterlist *src, unsigned int nbytes)
- {
- const unsigned int bsize = 128 / 8;
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- struct blkcipher_walk walk;
- int err;
-
-@@ -286,13 +286,12 @@
-
- while ((nbytes = walk.nbytes) >= bsize) {
- fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-- desc, fpu_enabled, nbytes);
-+ desc, false, nbytes);
- nbytes = __glue_ctr_crypt_128bit(gctx, desc, &walk);
-+ glue_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, &walk, nbytes);
- }
-
-- glue_fpu_end(fpu_enabled);
--
- if (walk.nbytes) {
- glue_ctr_crypt_final_128bit(
- gctx->funcs[gctx->num_funcs - 1].fn_u.ctr, desc, &walk);
-@@ -347,7 +346,7 @@
- void *tweak_ctx, void *crypt_ctx)
- {
- const unsigned int bsize = 128 / 8;
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- struct blkcipher_walk walk;
- int err;
-
-@@ -360,21 +359,21 @@
-
- /* set minimum length to bsize, for tweak_fn */
- fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-- desc, fpu_enabled,
-+ desc, false,
- nbytes < bsize ? bsize : nbytes);
--
- /* calculate first value of T */
- tweak_fn(tweak_ctx, walk.iv, walk.iv);
-+ glue_fpu_end(fpu_enabled);
-
- while (nbytes) {
-+ fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-+ desc, false, nbytes);
- nbytes = __glue_xts_crypt_128bit(gctx, crypt_ctx, desc, &walk);
-
-+ glue_fpu_end(fpu_enabled);
- err = blkcipher_walk_done(desc, &walk, nbytes);
- nbytes = walk.nbytes;
- }
--
-- glue_fpu_end(fpu_enabled);
--
- return err;
- }
- EXPORT_SYMBOL_GPL(glue_xts_crypt_128bit);
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/preempt.h linux-4.1.39/arch/x86/include/asm/preempt.h
---- linux-4.1.39.orig/arch/x86/include/asm/preempt.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/preempt.h 2017-04-18 17:56:30.565395270 +0200
-@@ -82,17 +82,46 @@
- * a decrement which hits zero means we have no preempt_count and should
- * reschedule.
- */
--static __always_inline bool __preempt_count_dec_and_test(void)
-+static __always_inline bool ____preempt_count_dec_and_test(void)
- {
- GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e");
- }
-
-+static __always_inline bool __preempt_count_dec_and_test(void)
-+{
-+ if (____preempt_count_dec_and_test())
-+ return true;
-+#ifdef CONFIG_PREEMPT_LAZY
-+ if (current_thread_info()->preempt_lazy_count)
-+ return false;
-+ return test_thread_flag(TIF_NEED_RESCHED_LAZY);
-+#else
-+ return false;
-+#endif
-+}
-+
- /*
- * Returns true when we need to resched and can (barring IRQ state).
- */
- static __always_inline bool should_resched(int preempt_offset)
- {
-+#ifdef CONFIG_PREEMPT_LAZY
-+ u32 tmp;
-+
-+ tmp = raw_cpu_read_4(__preempt_count);
-+ if (tmp == preempt_offset)
-+ return true;
-+
-+ /* preempt count == 0 ? */
-+ tmp &= ~PREEMPT_NEED_RESCHED;
-+ if (tmp)
-+ return false;
-+ if (current_thread_info()->preempt_lazy_count)
-+ return false;
-+ return test_thread_flag(TIF_NEED_RESCHED_LAZY);
-+#else
- return unlikely(raw_cpu_read_4(__preempt_count) == preempt_offset);
-+#endif
- }
-
- #ifdef CONFIG_PREEMPT
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/signal.h linux-4.1.39/arch/x86/include/asm/signal.h
---- linux-4.1.39.orig/arch/x86/include/asm/signal.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/signal.h 2017-04-18 17:56:30.565395270 +0200
-@@ -23,6 +23,19 @@
- unsigned long sig[_NSIG_WORDS];
- } sigset_t;
-
-+/*
-+ * Because some traps use the IST stack, we must keep preemption
-+ * disabled while calling do_trap(), but do_trap() may call
-+ * force_sig_info() which will grab the signal spin_locks for the
-+ * task, which in PREEMPT_RT_FULL are mutexes. By defining
-+ * ARCH_RT_DELAYS_SIGNAL_SEND the force_sig_info() will set
-+ * TIF_NOTIFY_RESUME and set up the signal to be sent on exit of the
-+ * trap.
-+ */
-+#if defined(CONFIG_PREEMPT_RT_FULL)
-+#define ARCH_RT_DELAYS_SIGNAL_SEND
-+#endif
-+
- #ifndef CONFIG_COMPAT
- typedef sigset_t compat_sigset_t;
- #endif
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/stackprotector.h linux-4.1.39/arch/x86/include/asm/stackprotector.h
---- linux-4.1.39.orig/arch/x86/include/asm/stackprotector.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/stackprotector.h 2017-04-18 17:56:30.565395270 +0200
-@@ -57,7 +57,7 @@
- */
- static __always_inline void boot_init_stack_canary(void)
- {
-- u64 canary;
-+ u64 uninitialized_var(canary);
- u64 tsc;
-
- #ifdef CONFIG_X86_64
-@@ -68,8 +68,16 @@
- * of randomness. The TSC only matters for very early init,
- * there it already has some randomness on most systems. Later
- * on during the bootup the random pool has true entropy too.
-+ *
-+ * For preempt-rt we need to weaken the randomness a bit, as
-+ * we can't call into the random generator from atomic context
-+ * due to locking constraints. We just leave canary
-+ * uninitialized and use the TSC based randomness on top of
-+ * it.
- */
-+#ifndef CONFIG_PREEMPT_RT_FULL
- get_random_bytes(&canary, sizeof(canary));
-+#endif
- tsc = __native_read_tsc();
- canary += tsc + (tsc << 32UL);
-
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/thread_info.h linux-4.1.39/arch/x86/include/asm/thread_info.h
---- linux-4.1.39.orig/arch/x86/include/asm/thread_info.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/thread_info.h 2017-04-18 17:56:30.565395270 +0200
-@@ -55,6 +55,8 @@
- __u32 status; /* thread synchronous flags */
- __u32 cpu; /* current CPU */
- int saved_preempt_count;
-+ int preempt_lazy_count; /* 0 => lazy preemptable
-+ <0 => BUG */
- mm_segment_t addr_limit;
- void __user *sysenter_return;
- unsigned int sig_on_uaccess_error:1;
-@@ -95,6 +97,7 @@
- #define TIF_SYSCALL_EMU 6 /* syscall emulation active */
- #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
- #define TIF_SECCOMP 8 /* secure computing */
-+#define TIF_NEED_RESCHED_LAZY 9 /* lazy rescheduling necessary */
- #define TIF_USER_RETURN_NOTIFY 11 /* notify kernel of userspace return */
- #define TIF_UPROBE 12 /* breakpointed or singlestepping */
- #define TIF_NOTSC 16 /* TSC is not accessible in userland */
-@@ -119,6 +122,7 @@
- #define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)
- #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
- #define _TIF_SECCOMP (1 << TIF_SECCOMP)
-+#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)
- #define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY)
- #define _TIF_UPROBE (1 << TIF_UPROBE)
- #define _TIF_NOTSC (1 << TIF_NOTSC)
-@@ -168,6 +172,8 @@
- #define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY)
- #define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW)
-
-+#define _TIF_NEED_RESCHED_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)
-+
- #define STACK_WARN (THREAD_SIZE/8)
-
- /*
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/uaccess_32.h linux-4.1.39/arch/x86/include/asm/uaccess_32.h
---- linux-4.1.39.orig/arch/x86/include/asm/uaccess_32.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/uaccess_32.h 2017-04-18 17:56:30.565395270 +0200
-@@ -70,7 +70,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space. Caller must check
- * the specified block with access_ok() before calling this function.
-@@ -117,7 +118,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space. Caller must check
- * the specified block with access_ok() before calling this function.
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/uaccess.h linux-4.1.39/arch/x86/include/asm/uaccess.h
---- linux-4.1.39.orig/arch/x86/include/asm/uaccess.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/uaccess.h 2017-04-18 17:56:30.565395270 +0200
-@@ -74,7 +74,8 @@
- * @addr: User space pointer to start of block to check
- * @size: Size of block to check
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Checks if a pointer to a block of memory in user space is valid.
- *
-@@ -145,7 +146,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -240,7 +242,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-@@ -459,7 +462,8 @@
- * @x: Variable to store result.
- * @ptr: Source address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple variable from user space to kernel
- * space. It supports simple types like char and int, but not larger
-@@ -483,7 +487,8 @@
- * @x: Value to copy to user space.
- * @ptr: Destination address, in user space.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * This macro copies a single simple value from kernel space to user
- * space. It supports simple types like char and int, but not larger
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/uv/uv_bau.h linux-4.1.39/arch/x86/include/asm/uv/uv_bau.h
---- linux-4.1.39.orig/arch/x86/include/asm/uv/uv_bau.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/uv/uv_bau.h 2017-04-18 17:56:30.565395270 +0200
-@@ -615,9 +615,9 @@
- cycles_t send_message;
- cycles_t period_end;
- cycles_t period_time;
-- spinlock_t uvhub_lock;
-- spinlock_t queue_lock;
-- spinlock_t disable_lock;
-+ raw_spinlock_t uvhub_lock;
-+ raw_spinlock_t queue_lock;
-+ raw_spinlock_t disable_lock;
- /* tunables */
- int max_concurr;
- int max_concurr_const;
-@@ -776,15 +776,15 @@
- * to be lowered below the current 'v'. atomic_add_unless can only stop
- * on equal.
- */
--static inline int atomic_inc_unless_ge(spinlock_t *lock, atomic_t *v, int u)
-+static inline int atomic_inc_unless_ge(raw_spinlock_t *lock, atomic_t *v, int u)
- {
-- spin_lock(lock);
-+ raw_spin_lock(lock);
- if (atomic_read(v) >= u) {
-- spin_unlock(lock);
-+ raw_spin_unlock(lock);
- return 0;
- }
- atomic_inc(v);
-- spin_unlock(lock);
-+ raw_spin_unlock(lock);
- return 1;
- }
-
-diff -Nur linux-4.1.39.orig/arch/x86/include/asm/uv/uv_hub.h linux-4.1.39/arch/x86/include/asm/uv/uv_hub.h
---- linux-4.1.39.orig/arch/x86/include/asm/uv/uv_hub.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/include/asm/uv/uv_hub.h 2017-04-18 17:56:30.565395270 +0200
-@@ -492,7 +492,7 @@
- unsigned short nr_online_cpus;
- unsigned short pnode;
- short memory_nid;
-- spinlock_t nmi_lock; /* obsolete, see uv_hub_nmi */
-+ raw_spinlock_t nmi_lock; /* obsolete, see uv_hub_nmi */
- unsigned long nmi_count; /* obsolete, see uv_hub_nmi */
- };
- extern struct uv_blade_info *uv_blade_info;
-diff -Nur linux-4.1.39.orig/arch/x86/Kconfig linux-4.1.39/arch/x86/Kconfig
---- linux-4.1.39.orig/arch/x86/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/Kconfig 2017-04-18 17:56:30.565395270 +0200
-@@ -22,6 +22,7 @@
- ### Arch settings
- config X86
- def_bool y
-+ select HAVE_PREEMPT_LAZY
- select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
- select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
- select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
-@@ -203,8 +204,11 @@
- def_bool y
- depends on ISA_DMA_API
-
-+config RWSEM_GENERIC_SPINLOCK
-+ def_bool PREEMPT_RT_FULL
-+
- config RWSEM_XCHGADD_ALGORITHM
-- def_bool y
-+ def_bool !RWSEM_GENERIC_SPINLOCK && !PREEMPT_RT_FULL
-
- config GENERIC_CALIBRATE_DELAY
- def_bool y
-@@ -838,7 +842,7 @@
- config MAXSMP
- bool "Enable Maximum number of SMP Processors and NUMA Nodes"
- depends on X86_64 && SMP && DEBUG_KERNEL
-- select CPUMASK_OFFSTACK
-+ select CPUMASK_OFFSTACK if !PREEMPT_RT_FULL
- ---help---
- Enable maximum number of CPUS and NUMA Nodes for this architecture.
- If unsure, say N.
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/acpi/boot.c linux-4.1.39/arch/x86/kernel/acpi/boot.c
---- linux-4.1.39.orig/arch/x86/kernel/acpi/boot.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/acpi/boot.c 2017-04-18 17:56:30.565395270 +0200
-@@ -87,7 +87,9 @@
- * ->ioapic_mutex
- * ->ioapic_lock
- */
-+#ifdef CONFIG_X86_IO_APIC
- static DEFINE_MUTEX(acpi_ioapic_lock);
-+#endif
-
- /* --------------------------------------------------------------------------
- Boot-time Configuration
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/apic/io_apic.c linux-4.1.39/arch/x86/kernel/apic/io_apic.c
---- linux-4.1.39.orig/arch/x86/kernel/apic/io_apic.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/apic/io_apic.c 2017-04-18 17:56:30.565395270 +0200
-@@ -1891,7 +1891,8 @@
- static inline bool ioapic_irqd_mask(struct irq_data *data, struct irq_cfg *cfg)
- {
- /* If we are moving the irq we need to mask it */
-- if (unlikely(irqd_is_setaffinity_pending(data))) {
-+ if (unlikely(irqd_is_setaffinity_pending(data) &&
-+ !irqd_irq_inprogress(data))) {
- mask_ioapic(cfg);
- return true;
- }
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/apic/x2apic_uv_x.c linux-4.1.39/arch/x86/kernel/apic/x2apic_uv_x.c
---- linux-4.1.39.orig/arch/x86/kernel/apic/x2apic_uv_x.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/apic/x2apic_uv_x.c 2017-04-18 17:56:30.569395424 +0200
-@@ -949,7 +949,7 @@
- uv_blade_info[blade].pnode = pnode;
- uv_blade_info[blade].nr_possible_cpus = 0;
- uv_blade_info[blade].nr_online_cpus = 0;
-- spin_lock_init(&uv_blade_info[blade].nmi_lock);
-+ raw_spin_lock_init(&uv_blade_info[blade].nmi_lock);
- min_pnode = min(pnode, min_pnode);
- max_pnode = max(pnode, max_pnode);
- blade++;
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/asm-offsets.c linux-4.1.39/arch/x86/kernel/asm-offsets.c
---- linux-4.1.39.orig/arch/x86/kernel/asm-offsets.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/asm-offsets.c 2017-04-18 17:56:30.569395424 +0200
-@@ -32,6 +32,7 @@
- OFFSET(TI_flags, thread_info, flags);
- OFFSET(TI_status, thread_info, status);
- OFFSET(TI_addr_limit, thread_info, addr_limit);
-+ OFFSET(TI_preempt_lazy_count, thread_info, preempt_lazy_count);
-
- BLANK();
- OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
-@@ -71,4 +72,5 @@
-
- BLANK();
- DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
-+ DEFINE(_PREEMPT_ENABLED, PREEMPT_ENABLED);
- }
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/cpu/mcheck/mce.c linux-4.1.39/arch/x86/kernel/cpu/mcheck/mce.c
---- linux-4.1.39.orig/arch/x86/kernel/cpu/mcheck/mce.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/cpu/mcheck/mce.c 2017-04-18 17:56:30.569395424 +0200
-@@ -41,6 +41,8 @@
- #include <linux/debugfs.h>
- #include <linux/irq_work.h>
- #include <linux/export.h>
-+#include <linux/jiffies.h>
-+#include <linux/work-simple.h>
-
- #include <asm/processor.h>
- #include <asm/traps.h>
-@@ -1267,7 +1269,7 @@
- static unsigned long check_interval = INITIAL_CHECK_INTERVAL;
-
- static DEFINE_PER_CPU(unsigned long, mce_next_interval); /* in jiffies */
--static DEFINE_PER_CPU(struct timer_list, mce_timer);
-+static DEFINE_PER_CPU(struct hrtimer, mce_timer);
-
- static unsigned long mce_adjust_timer_default(unsigned long interval)
- {
-@@ -1276,32 +1278,18 @@
-
- static unsigned long (*mce_adjust_timer)(unsigned long interval) = mce_adjust_timer_default;
-
--static void __restart_timer(struct timer_list *t, unsigned long interval)
-+static enum hrtimer_restart __restart_timer(struct hrtimer *timer, unsigned long interval)
- {
-- unsigned long when = jiffies + interval;
-- unsigned long flags;
--
-- local_irq_save(flags);
--
-- if (timer_pending(t)) {
-- if (time_before(when, t->expires))
-- mod_timer_pinned(t, when);
-- } else {
-- t->expires = round_jiffies(when);
-- add_timer_on(t, smp_processor_id());
-- }
--
-- local_irq_restore(flags);
-+ if (!interval)
-+ return HRTIMER_NORESTART;
-+ hrtimer_forward_now(timer, ns_to_ktime(jiffies_to_nsecs(interval)));
-+ return HRTIMER_RESTART;
- }
-
--static void mce_timer_fn(unsigned long data)
-+static enum hrtimer_restart mce_timer_fn(struct hrtimer *timer)
- {
-- struct timer_list *t = this_cpu_ptr(&mce_timer);
-- int cpu = smp_processor_id();
- unsigned long iv;
-
-- WARN_ON(cpu != data);
--
- iv = __this_cpu_read(mce_next_interval);
-
- if (mce_available(this_cpu_ptr(&cpu_info))) {
-@@ -1324,7 +1312,7 @@
-
- done:
- __this_cpu_write(mce_next_interval, iv);
-- __restart_timer(t, iv);
-+ return __restart_timer(timer, iv);
- }
-
- /*
-@@ -1332,7 +1320,7 @@
- */
- void mce_timer_kick(unsigned long interval)
- {
-- struct timer_list *t = this_cpu_ptr(&mce_timer);
-+ struct hrtimer *t = this_cpu_ptr(&mce_timer);
- unsigned long iv = __this_cpu_read(mce_next_interval);
-
- __restart_timer(t, interval);
-@@ -1347,7 +1335,7 @@
- int cpu;
-
- for_each_online_cpu(cpu)
-- del_timer_sync(&per_cpu(mce_timer, cpu));
-+ hrtimer_cancel(&per_cpu(mce_timer, cpu));
- }
-
- static void mce_do_trigger(struct work_struct *work)
-@@ -1357,6 +1345,56 @@
-
- static DECLARE_WORK(mce_trigger_work, mce_do_trigger);
-
-+static void __mce_notify_work(struct swork_event *event)
-+{
-+ /* Not more than two messages every minute */
-+ static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
-+
-+ /* wake processes polling /dev/mcelog */
-+ wake_up_interruptible(&mce_chrdev_wait);
-+
-+ /*
-+ * There is no risk of missing notifications because
-+ * work_pending is always cleared before the function is
-+ * executed.
-+ */
-+ if (mce_helper[0] && !work_pending(&mce_trigger_work))
-+ schedule_work(&mce_trigger_work);
-+
-+ if (__ratelimit(&ratelimit))
-+ pr_info(HW_ERR "Machine check events logged\n");
-+}
-+
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+static bool notify_work_ready __read_mostly;
-+static struct swork_event notify_work;
-+
-+static int mce_notify_work_init(void)
-+{
-+ int err;
-+
-+ err = swork_get();
-+ if (err)
-+ return err;
-+
-+ INIT_SWORK(&notify_work, __mce_notify_work);
-+ notify_work_ready = true;
-+ return 0;
-+}
-+
-+static void mce_notify_work(void)
-+{
-+ if (notify_work_ready)
-+ swork_queue(&notify_work);
-+}
-+#else
-+static void mce_notify_work(void)
-+{
-+ __mce_notify_work(NULL);
-+}
-+static inline int mce_notify_work_init(void) { return 0; }
-+#endif
-+
- /*
- * Notify the user(s) about new machine check events.
- * Can be called from interrupt context, but not from machine check/NMI
-@@ -1364,19 +1402,8 @@
- */
- int mce_notify_irq(void)
- {
-- /* Not more than two messages every minute */
-- static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
--
- if (test_and_clear_bit(0, &mce_need_notify)) {
-- /* wake processes polling /dev/mcelog */
-- wake_up_interruptible(&mce_chrdev_wait);
--
-- if (mce_helper[0])
-- schedule_work(&mce_trigger_work);
--
-- if (__ratelimit(&ratelimit))
-- pr_info(HW_ERR "Machine check events logged\n");
--
-+ mce_notify_work();
- return 1;
- }
- return 0;
-@@ -1649,7 +1676,7 @@
- }
- }
-
--static void mce_start_timer(unsigned int cpu, struct timer_list *t)
-+static void mce_start_timer(unsigned int cpu, struct hrtimer *t)
- {
- unsigned long iv = check_interval * HZ;
-
-@@ -1658,16 +1685,17 @@
-
- per_cpu(mce_next_interval, cpu) = iv;
-
-- t->expires = round_jiffies(jiffies + iv);
-- add_timer_on(t, cpu);
-+ hrtimer_start_range_ns(t, ns_to_ktime(jiffies_to_usecs(iv) * 1000ULL),
-+ 0, HRTIMER_MODE_REL_PINNED);
- }
-
- static void __mcheck_cpu_init_timer(void)
- {
-- struct timer_list *t = this_cpu_ptr(&mce_timer);
-+ struct hrtimer *t = this_cpu_ptr(&mce_timer);
- unsigned int cpu = smp_processor_id();
-
-- setup_timer(t, mce_timer_fn, cpu);
-+ hrtimer_init(t, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ t->function = mce_timer_fn;
- mce_start_timer(cpu, t);
- }
-
-@@ -2345,6 +2373,8 @@
- if (!mce_available(raw_cpu_ptr(&cpu_info)))
- return;
-
-+ hrtimer_cancel(this_cpu_ptr(&mce_timer));
-+
- if (!(action & CPU_TASKS_FROZEN))
- cmci_clear();
- for (i = 0; i < mca_cfg.banks; i++) {
-@@ -2371,6 +2401,7 @@
- if (b->init)
- wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl);
- }
-+ __mcheck_cpu_init_timer();
- }
-
- /* Get notified when a cpu comes on/off. Be hotplug friendly. */
-@@ -2378,7 +2409,6 @@
- mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
- {
- unsigned int cpu = (unsigned long)hcpu;
-- struct timer_list *t = &per_cpu(mce_timer, cpu);
-
- switch (action & ~CPU_TASKS_FROZEN) {
- case CPU_ONLINE:
-@@ -2398,11 +2428,9 @@
- break;
- case CPU_DOWN_PREPARE:
- smp_call_function_single(cpu, mce_disable_cpu, &action, 1);
-- del_timer_sync(t);
- break;
- case CPU_DOWN_FAILED:
- smp_call_function_single(cpu, mce_reenable_cpu, &action, 1);
-- mce_start_timer(cpu, t);
- break;
- }
-
-@@ -2441,6 +2469,10 @@
- goto err_out;
- }
-
-+ err = mce_notify_work_init();
-+ if (err)
-+ goto err_out;
-+
- if (!zalloc_cpumask_var(&mce_device_initialized, GFP_KERNEL)) {
- err = -ENOMEM;
- goto err_out;
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/cpu/perf_event_intel_rapl.c linux-4.1.39/arch/x86/kernel/cpu/perf_event_intel_rapl.c
---- linux-4.1.39.orig/arch/x86/kernel/cpu/perf_event_intel_rapl.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/cpu/perf_event_intel_rapl.c 2017-04-18 17:56:30.569395424 +0200
-@@ -119,7 +119,7 @@
- };
-
- struct rapl_pmu {
-- spinlock_t lock;
-+ raw_spinlock_t lock;
- int n_active; /* number of active events */
- struct list_head active_list;
- struct pmu *pmu; /* pointer to rapl_pmu_class */
-@@ -223,13 +223,13 @@
- if (!pmu->n_active)
- return HRTIMER_NORESTART;
-
-- spin_lock_irqsave(&pmu->lock, flags);
-+ raw_spin_lock_irqsave(&pmu->lock, flags);
-
- list_for_each_entry(event, &pmu->active_list, active_entry) {
- rapl_event_update(event);
- }
-
-- spin_unlock_irqrestore(&pmu->lock, flags);
-+ raw_spin_unlock_irqrestore(&pmu->lock, flags);
-
- hrtimer_forward_now(hrtimer, pmu->timer_interval);
-
-@@ -266,9 +266,9 @@
- struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu);
- unsigned long flags;
-
-- spin_lock_irqsave(&pmu->lock, flags);
-+ raw_spin_lock_irqsave(&pmu->lock, flags);
- __rapl_pmu_event_start(pmu, event);
-- spin_unlock_irqrestore(&pmu->lock, flags);
-+ raw_spin_unlock_irqrestore(&pmu->lock, flags);
- }
-
- static void rapl_pmu_event_stop(struct perf_event *event, int mode)
-@@ -277,7 +277,7 @@
- struct hw_perf_event *hwc = &event->hw;
- unsigned long flags;
-
-- spin_lock_irqsave(&pmu->lock, flags);
-+ raw_spin_lock_irqsave(&pmu->lock, flags);
-
- /* mark event as deactivated and stopped */
- if (!(hwc->state & PERF_HES_STOPPED)) {
-@@ -302,7 +302,7 @@
- hwc->state |= PERF_HES_UPTODATE;
- }
-
-- spin_unlock_irqrestore(&pmu->lock, flags);
-+ raw_spin_unlock_irqrestore(&pmu->lock, flags);
- }
-
- static int rapl_pmu_event_add(struct perf_event *event, int mode)
-@@ -311,14 +311,14 @@
- struct hw_perf_event *hwc = &event->hw;
- unsigned long flags;
-
-- spin_lock_irqsave(&pmu->lock, flags);
-+ raw_spin_lock_irqsave(&pmu->lock, flags);
-
- hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
-
- if (mode & PERF_EF_START)
- __rapl_pmu_event_start(pmu, event);
-
-- spin_unlock_irqrestore(&pmu->lock, flags);
-+ raw_spin_unlock_irqrestore(&pmu->lock, flags);
-
- return 0;
- }
-@@ -594,7 +594,7 @@
- pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
- if (!pmu)
- return -1;
-- spin_lock_init(&pmu->lock);
-+ raw_spin_lock_init(&pmu->lock);
-
- INIT_LIST_HEAD(&pmu->active_list);
-
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/dumpstack_32.c linux-4.1.39/arch/x86/kernel/dumpstack_32.c
---- linux-4.1.39.orig/arch/x86/kernel/dumpstack_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/dumpstack_32.c 2017-04-18 17:56:30.569395424 +0200
-@@ -42,7 +42,7 @@
- unsigned long *stack, unsigned long bp,
- const struct stacktrace_ops *ops, void *data)
- {
-- const unsigned cpu = get_cpu();
-+ const unsigned cpu = get_cpu_light();
- int graph = 0;
- u32 *prev_esp;
-
-@@ -86,7 +86,7 @@
- break;
- touch_nmi_watchdog();
- }
-- put_cpu();
-+ put_cpu_light();
- }
- EXPORT_SYMBOL(dump_trace);
-
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/dumpstack_64.c linux-4.1.39/arch/x86/kernel/dumpstack_64.c
---- linux-4.1.39.orig/arch/x86/kernel/dumpstack_64.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/dumpstack_64.c 2017-04-18 17:56:30.569395424 +0200
-@@ -152,7 +152,7 @@
- unsigned long *stack, unsigned long bp,
- const struct stacktrace_ops *ops, void *data)
- {
-- const unsigned cpu = get_cpu();
-+ const unsigned cpu = get_cpu_light();
- struct thread_info *tinfo;
- unsigned long *irq_stack = (unsigned long *)per_cpu(irq_stack_ptr, cpu);
- unsigned long dummy;
-@@ -241,7 +241,7 @@
- * This handles the process stack:
- */
- bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
-- put_cpu();
-+ put_cpu_light();
- }
- EXPORT_SYMBOL(dump_trace);
-
-@@ -255,7 +255,7 @@
- int cpu;
- int i;
-
-- preempt_disable();
-+ migrate_disable();
- cpu = smp_processor_id();
-
- irq_stack_end = (unsigned long *)(per_cpu(irq_stack_ptr, cpu));
-@@ -291,7 +291,7 @@
- pr_cont(" %016lx", *stack++);
- touch_nmi_watchdog();
- }
-- preempt_enable();
-+ migrate_enable();
-
- pr_cont("\n");
- show_trace_log_lvl(task, regs, sp, bp, log_lvl);
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/entry_32.S linux-4.1.39/arch/x86/kernel/entry_32.S
---- linux-4.1.39.orig/arch/x86/kernel/entry_32.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/entry_32.S 2017-04-18 17:56:30.569395424 +0200
-@@ -359,8 +359,24 @@
- ENTRY(resume_kernel)
- DISABLE_INTERRUPTS(CLBR_ANY)
- need_resched:
-+ # preempt count == 0 + NEED_RS set?
- cmpl $0,PER_CPU_VAR(__preempt_count)
-+#ifndef CONFIG_PREEMPT_LAZY
- jnz restore_all
-+#else
-+ jz test_int_off
-+
-+ # atleast preempt count == 0 ?
-+ cmpl $_PREEMPT_ENABLED,PER_CPU_VAR(__preempt_count)
-+ jne restore_all
-+
-+ cmpl $0,TI_preempt_lazy_count(%ebp) # non-zero preempt_lazy_count ?
-+ jnz restore_all
-+
-+ testl $_TIF_NEED_RESCHED_LAZY, TI_flags(%ebp)
-+ jz restore_all
-+test_int_off:
-+#endif
- testl $X86_EFLAGS_IF,PT_EFLAGS(%esp) # interrupts off (exception path) ?
- jz restore_all
- call preempt_schedule_irq
-@@ -594,7 +610,7 @@
- ALIGN
- RING0_PTREGS_FRAME # can't unwind into user space anyway
- work_pending:
-- testb $_TIF_NEED_RESCHED, %cl
-+ testl $_TIF_NEED_RESCHED_MASK, %ecx
- jz work_notifysig
- work_resched:
- call schedule
-@@ -607,7 +623,7 @@
- andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
- # than syscall tracing?
- jz restore_all
-- testb $_TIF_NEED_RESCHED, %cl
-+ testl $_TIF_NEED_RESCHED_MASK, %ecx
- jnz work_resched
-
- work_notifysig: # deal with pending signals and
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/entry_64.S linux-4.1.39/arch/x86/kernel/entry_64.S
---- linux-4.1.39.orig/arch/x86/kernel/entry_64.S 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/entry_64.S 2017-04-18 17:56:30.569395424 +0200
-@@ -370,8 +370,8 @@
- /* First do a reschedule test. */
- /* edx: work, edi: workmask */
- int_careful:
-- bt $TIF_NEED_RESCHED,%edx
-- jnc int_very_careful
-+ testl $_TIF_NEED_RESCHED_MASK,%edx
-+ jz int_very_careful
- TRACE_IRQS_ON
- ENABLE_INTERRUPTS(CLBR_NONE)
- pushq_cfi %rdi
-@@ -776,7 +776,23 @@
- bt $9,EFLAGS(%rsp) /* interrupts were off? */
- jnc 1f
- 0: cmpl $0,PER_CPU_VAR(__preempt_count)
-+#ifndef CONFIG_PREEMPT_LAZY
- jnz 1f
-+#else
-+ jz do_preempt_schedule_irq
-+
-+ # atleast preempt count == 0 ?
-+ cmpl $_PREEMPT_ENABLED,PER_CPU_VAR(__preempt_count)
-+ jnz 1f
-+
-+ GET_THREAD_INFO(%rcx)
-+ cmpl $0, TI_preempt_lazy_count(%rcx)
-+ jnz 1f
-+
-+ bt $TIF_NEED_RESCHED_LAZY,TI_flags(%rcx)
-+ jnc 1f
-+do_preempt_schedule_irq:
-+#endif
- call preempt_schedule_irq
- jmp 0b
- 1:
-@@ -844,8 +860,8 @@
- /* edi: workmask, edx: work */
- retint_careful:
- CFI_RESTORE_STATE
-- bt $TIF_NEED_RESCHED,%edx
-- jnc retint_signal
-+ testl $_TIF_NEED_RESCHED_MASK,%edx
-+ jz retint_signal
- TRACE_IRQS_ON
- ENABLE_INTERRUPTS(CLBR_NONE)
- pushq_cfi %rdi
-@@ -1118,6 +1134,7 @@
- jmp 2b
- .previous
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- /* Call softirq on interrupt stack. Interrupts are off. */
- ENTRY(do_softirq_own_stack)
- CFI_STARTPROC
-@@ -1137,6 +1154,7 @@
- ret
- CFI_ENDPROC
- END(do_softirq_own_stack)
-+#endif
-
- #ifdef CONFIG_XEN
- idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/irq_32.c linux-4.1.39/arch/x86/kernel/irq_32.c
---- linux-4.1.39.orig/arch/x86/kernel/irq_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/irq_32.c 2017-04-18 17:56:30.569395424 +0200
-@@ -135,6 +135,7 @@
- cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
- }
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- void do_softirq_own_stack(void)
- {
- struct thread_info *curstk;
-@@ -153,6 +154,7 @@
-
- call_on_stack(__do_softirq, isp);
- }
-+#endif
-
- bool handle_irq(unsigned irq, struct pt_regs *regs)
- {
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/kvm.c linux-4.1.39/arch/x86/kernel/kvm.c
---- linux-4.1.39.orig/arch/x86/kernel/kvm.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/kvm.c 2017-04-18 17:56:30.569395424 +0200
-@@ -36,6 +36,7 @@
- #include <linux/kprobes.h>
- #include <linux/debugfs.h>
- #include <linux/nmi.h>
-+#include <linux/wait-simple.h>
- #include <asm/timer.h>
- #include <asm/cpu.h>
- #include <asm/traps.h>
-@@ -91,14 +92,14 @@
-
- struct kvm_task_sleep_node {
- struct hlist_node link;
-- wait_queue_head_t wq;
-+ struct swait_head wq;
- u32 token;
- int cpu;
- bool halted;
- };
-
- static struct kvm_task_sleep_head {
-- spinlock_t lock;
-+ raw_spinlock_t lock;
- struct hlist_head list;
- } async_pf_sleepers[KVM_TASK_SLEEP_HASHSIZE];
-
-@@ -122,17 +123,17 @@
- u32 key = hash_32(token, KVM_TASK_SLEEP_HASHBITS);
- struct kvm_task_sleep_head *b = &async_pf_sleepers[key];
- struct kvm_task_sleep_node n, *e;
-- DEFINE_WAIT(wait);
-+ DEFINE_SWAITER(wait);
-
- rcu_irq_enter();
-
-- spin_lock(&b->lock);
-+ raw_spin_lock(&b->lock);
- e = _find_apf_task(b, token);
- if (e) {
- /* dummy entry exist -> wake up was delivered ahead of PF */
- hlist_del(&e->link);
- kfree(e);
-- spin_unlock(&b->lock);
-+ raw_spin_unlock(&b->lock);
-
- rcu_irq_exit();
- return;
-@@ -141,13 +142,13 @@
- n.token = token;
- n.cpu = smp_processor_id();
- n.halted = is_idle_task(current) || preempt_count() > 1;
-- init_waitqueue_head(&n.wq);
-+ init_swait_head(&n.wq);
- hlist_add_head(&n.link, &b->list);
-- spin_unlock(&b->lock);
-+ raw_spin_unlock(&b->lock);
-
- for (;;) {
- if (!n.halted)
-- prepare_to_wait(&n.wq, &wait, TASK_UNINTERRUPTIBLE);
-+ swait_prepare(&n.wq, &wait, TASK_UNINTERRUPTIBLE);
- if (hlist_unhashed(&n.link))
- break;
-
-@@ -166,7 +167,7 @@
- }
- }
- if (!n.halted)
-- finish_wait(&n.wq, &wait);
-+ swait_finish(&n.wq, &wait);
-
- rcu_irq_exit();
- return;
-@@ -178,8 +179,8 @@
- hlist_del_init(&n->link);
- if (n->halted)
- smp_send_reschedule(n->cpu);
-- else if (waitqueue_active(&n->wq))
-- wake_up(&n->wq);
-+ else if (swaitqueue_active(&n->wq))
-+ swait_wake(&n->wq);
- }
-
- static void apf_task_wake_all(void)
-@@ -189,14 +190,14 @@
- for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++) {
- struct hlist_node *p, *next;
- struct kvm_task_sleep_head *b = &async_pf_sleepers[i];
-- spin_lock(&b->lock);
-+ raw_spin_lock(&b->lock);
- hlist_for_each_safe(p, next, &b->list) {
- struct kvm_task_sleep_node *n =
- hlist_entry(p, typeof(*n), link);
- if (n->cpu == smp_processor_id())
- apf_task_wake_one(n);
- }
-- spin_unlock(&b->lock);
-+ raw_spin_unlock(&b->lock);
- }
- }
-
-@@ -212,7 +213,7 @@
- }
-
- again:
-- spin_lock(&b->lock);
-+ raw_spin_lock(&b->lock);
- n = _find_apf_task(b, token);
- if (!n) {
- /*
-@@ -225,17 +226,17 @@
- * Allocation failed! Busy wait while other cpu
- * handles async PF.
- */
-- spin_unlock(&b->lock);
-+ raw_spin_unlock(&b->lock);
- cpu_relax();
- goto again;
- }
- n->token = token;
- n->cpu = smp_processor_id();
-- init_waitqueue_head(&n->wq);
-+ init_swait_head(&n->wq);
- hlist_add_head(&n->link, &b->list);
- } else
- apf_task_wake_one(n);
-- spin_unlock(&b->lock);
-+ raw_spin_unlock(&b->lock);
- return;
- }
- EXPORT_SYMBOL_GPL(kvm_async_pf_task_wake);
-@@ -486,7 +487,7 @@
- paravirt_ops_setup();
- register_reboot_notifier(&kvm_pv_reboot_nb);
- for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++)
-- spin_lock_init(&async_pf_sleepers[i].lock);
-+ raw_spin_lock_init(&async_pf_sleepers[i].lock);
- if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF))
- x86_init.irqs.trap_init = kvm_apf_trap_init;
-
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/process_32.c linux-4.1.39/arch/x86/kernel/process_32.c
---- linux-4.1.39.orig/arch/x86/kernel/process_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/process_32.c 2017-04-18 17:56:30.569395424 +0200
-@@ -35,6 +35,7 @@
- #include <linux/uaccess.h>
- #include <linux/io.h>
- #include <linux/kdebug.h>
-+#include <linux/highmem.h>
-
- #include <asm/pgtable.h>
- #include <asm/ldt.h>
-@@ -210,6 +211,35 @@
- }
- EXPORT_SYMBOL_GPL(start_thread);
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+static void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p)
-+{
-+ int i;
-+
-+ /*
-+ * Clear @prev's kmap_atomic mappings
-+ */
-+ for (i = 0; i < prev_p->kmap_idx; i++) {
-+ int idx = i + KM_TYPE_NR * smp_processor_id();
-+ pte_t *ptep = kmap_pte - idx;
-+
-+ kpte_clear_flush(ptep, __fix_to_virt(FIX_KMAP_BEGIN + idx));
-+ }
-+ /*
-+ * Restore @next_p's kmap_atomic mappings
-+ */
-+ for (i = 0; i < next_p->kmap_idx; i++) {
-+ int idx = i + KM_TYPE_NR * smp_processor_id();
-+
-+ if (!pte_none(next_p->kmap_pte[i]))
-+ set_pte(kmap_pte - idx, next_p->kmap_pte[i]);
-+ }
-+}
-+#else
-+static inline void
-+switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p) { }
-+#endif
-+
-
- /*
- * switch_to(x,y) should switch tasks from x to y.
-@@ -292,6 +322,8 @@
- task_thread_info(next_p)->flags & _TIF_WORK_CTXSW_NEXT))
- __switch_to_xtra(prev_p, next_p, tss);
-
-+ switch_kmaps(prev_p, next_p);
-+
- /*
- * Leave lazy mode, flushing any hypercalls made here.
- * This must be done before restoring TLS segments so
-diff -Nur linux-4.1.39.orig/arch/x86/kernel/signal.c linux-4.1.39/arch/x86/kernel/signal.c
---- linux-4.1.39.orig/arch/x86/kernel/signal.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kernel/signal.c 2017-04-18 17:56:30.569395424 +0200
-@@ -726,6 +726,14 @@
- {
- user_exit();
-
-+#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
-+ if (unlikely(current->forced_info.si_signo)) {
-+ struct task_struct *t = current;
-+ force_sig_info(t->forced_info.si_signo, &t->forced_info, t);
-+ t->forced_info.si_signo = 0;
-+ }
-+#endif
-+
- if (thread_info_flags & _TIF_UPROBE)
- uprobe_notify_resume(regs);
-
-diff -Nur linux-4.1.39.orig/arch/x86/kvm/lapic.c linux-4.1.39/arch/x86/kvm/lapic.c
---- linux-4.1.39.orig/arch/x86/kvm/lapic.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kvm/lapic.c 2017-04-18 17:56:30.569395424 +0200
-@@ -1106,7 +1106,7 @@
- static void apic_timer_expired(struct kvm_lapic *apic)
- {
- struct kvm_vcpu *vcpu = apic->vcpu;
-- wait_queue_head_t *q = &vcpu->wq;
-+ struct swait_head *q = &vcpu->wq;
- struct kvm_timer *ktimer = &apic->lapic_timer;
-
- if (atomic_read(&apic->lapic_timer.pending))
-@@ -1115,8 +1115,8 @@
- atomic_inc(&apic->lapic_timer.pending);
- kvm_set_pending_timer(vcpu);
-
-- if (waitqueue_active(q))
-- wake_up_interruptible(q);
-+ if (swaitqueue_active(q))
-+ swait_wake_interruptible(q);
-
- if (apic_lvtt_tscdeadline(apic))
- ktimer->expired_tscdeadline = ktimer->tscdeadline;
-@@ -1169,8 +1169,36 @@
- __delay(tsc_deadline - guest_tsc);
- }
-
-+static enum hrtimer_restart apic_timer_fn(struct hrtimer *data);
-+
-+static void __apic_timer_expired(struct hrtimer *data)
-+{
-+ int ret, i = 0;
-+ enum hrtimer_restart r;
-+ struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
-+
-+ r = apic_timer_fn(data);
-+
-+ if (r == HRTIMER_RESTART) {
-+ do {
-+ ret = hrtimer_start_expires(data, HRTIMER_MODE_ABS);
-+ if (ret == -ETIME)
-+ hrtimer_add_expires_ns(&ktimer->timer,
-+ ktimer->period);
-+ i++;
-+ } while (ret == -ETIME && i < 10);
-+
-+ if (ret == -ETIME) {
-+ printk_once(KERN_ERR "%s: failed to reprogram timer\n",
-+ __func__);
-+ WARN_ON_ONCE(1);
-+ }
-+ }
-+}
-+
- static void start_apic_timer(struct kvm_lapic *apic)
- {
-+ int ret;
- ktime_t now;
-
- atomic_set(&apic->lapic_timer.pending, 0);
-@@ -1201,9 +1229,11 @@
- }
- }
-
-- hrtimer_start(&apic->lapic_timer.timer,
-+ ret = hrtimer_start(&apic->lapic_timer.timer,
- ktime_add_ns(now, apic->lapic_timer.period),
- HRTIMER_MODE_ABS);
-+ if (ret == -ETIME)
-+ __apic_timer_expired(&apic->lapic_timer.timer);
-
- apic_debug("%s: bus cycle is %" PRId64 "ns, now 0x%016"
- PRIx64 ", "
-@@ -1235,8 +1265,10 @@
- do_div(ns, this_tsc_khz);
- expire = ktime_add_ns(now, ns);
- expire = ktime_sub_ns(expire, lapic_timer_advance_ns);
-- hrtimer_start(&apic->lapic_timer.timer,
-+ ret = hrtimer_start(&apic->lapic_timer.timer,
- expire, HRTIMER_MODE_ABS);
-+ if (ret == -ETIME)
-+ __apic_timer_expired(&apic->lapic_timer.timer);
- } else
- apic_timer_expired(apic);
-
-@@ -1709,6 +1741,7 @@
- hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
- HRTIMER_MODE_ABS);
- apic->lapic_timer.timer.function = apic_timer_fn;
-+ apic->lapic_timer.timer.irqsafe = 1;
-
- /*
- * APIC is created enabled. This will prevent kvm_lapic_set_base from
-@@ -1836,7 +1869,8 @@
-
- timer = &vcpu->arch.apic->lapic_timer.timer;
- if (hrtimer_cancel(timer))
-- hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
-+ if (hrtimer_start_expires(timer, HRTIMER_MODE_ABS) == -ETIME)
-+ __apic_timer_expired(timer);
- }
-
- /*
-diff -Nur linux-4.1.39.orig/arch/x86/kvm/x86.c linux-4.1.39/arch/x86/kvm/x86.c
---- linux-4.1.39.orig/arch/x86/kvm/x86.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/kvm/x86.c 2017-04-18 17:56:30.569395424 +0200
-@@ -5837,6 +5837,13 @@
- goto out;
- }
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
-+ printk(KERN_ERR "RT requires X86_FEATURE_CONSTANT_TSC\n");
-+ return -EOPNOTSUPP;
-+ }
-+#endif
-+
- r = kvm_mmu_module_init();
- if (r)
- goto out_free_percpu;
-diff -Nur linux-4.1.39.orig/arch/x86/lib/usercopy_32.c linux-4.1.39/arch/x86/lib/usercopy_32.c
---- linux-4.1.39.orig/arch/x86/lib/usercopy_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/lib/usercopy_32.c 2017-04-18 17:56:30.573395579 +0200
-@@ -647,7 +647,8 @@
- * @from: Source address, in kernel space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from kernel space to user space.
- *
-@@ -668,7 +669,8 @@
- * @from: Source address, in user space.
- * @n: Number of bytes to copy.
- *
-- * Context: User context only. This function may sleep.
-+ * Context: User context only. This function may sleep if pagefaults are
-+ * enabled.
- *
- * Copy data from user space to kernel space.
- *
-diff -Nur linux-4.1.39.orig/arch/x86/mm/fault.c linux-4.1.39/arch/x86/mm/fault.c
---- linux-4.1.39.orig/arch/x86/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/mm/fault.c 2017-04-18 17:56:30.573395579 +0200
-@@ -13,6 +13,7 @@
- #include <linux/hugetlb.h> /* hstate_index_to_shift */
- #include <linux/prefetch.h> /* prefetchw */
- #include <linux/context_tracking.h> /* exception_enter(), ... */
-+#include <linux/uaccess.h> /* faulthandler_disabled() */
-
- #include <asm/traps.h> /* dotraplinkage, ... */
- #include <asm/pgalloc.h> /* pgd_*(), ... */
-@@ -1133,9 +1134,9 @@
-
- /*
- * If we're in an interrupt, have no user context or are running
-- * in an atomic region then we must not take the fault:
-+ * in a region with pagefaults disabled then we must not take the fault
- */
-- if (unlikely(in_atomic() || !mm)) {
-+ if (unlikely(faulthandler_disabled() || !mm)) {
- bad_area_nosemaphore(regs, error_code, address);
- return;
- }
-diff -Nur linux-4.1.39.orig/arch/x86/mm/highmem_32.c linux-4.1.39/arch/x86/mm/highmem_32.c
---- linux-4.1.39.orig/arch/x86/mm/highmem_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/mm/highmem_32.c 2017-04-18 17:56:30.573395579 +0200
-@@ -32,10 +32,11 @@
- */
- void *kmap_atomic_prot(struct page *page, pgprot_t prot)
- {
-+ pte_t pte = mk_pte(page, prot);
- unsigned long vaddr;
- int idx, type;
-
-- /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
-+ preempt_disable_nort();
- pagefault_disable();
-
- if (!PageHighMem(page))
-@@ -45,7 +46,10 @@
- idx = type + KM_TYPE_NR*smp_processor_id();
- vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
- BUG_ON(!pte_none(*(kmap_pte-idx)));
-- set_pte(kmap_pte-idx, mk_pte(page, prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = pte;
-+#endif
-+ set_pte(kmap_pte-idx, pte);
- arch_flush_lazy_mmu_mode();
-
- return (void *)vaddr;
-@@ -88,6 +92,9 @@
- * is a bad idea also, in case the page changes cacheability
- * attributes or becomes a protected page in a hypervisor.
- */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = __pte(0);
-+#endif
- kpte_clear_flush(kmap_pte-idx, vaddr);
- kmap_atomic_idx_pop();
- arch_flush_lazy_mmu_mode();
-@@ -100,6 +107,7 @@
- #endif
-
- pagefault_enable();
-+ preempt_enable_nort();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-
-diff -Nur linux-4.1.39.orig/arch/x86/mm/iomap_32.c linux-4.1.39/arch/x86/mm/iomap_32.c
---- linux-4.1.39.orig/arch/x86/mm/iomap_32.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/mm/iomap_32.c 2017-04-18 17:56:30.573395579 +0200
-@@ -56,15 +56,22 @@
-
- void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
- {
-+ pte_t pte = pfn_pte(pfn, prot);
- unsigned long vaddr;
- int idx, type;
-
-+ preempt_disable();
- pagefault_disable();
-
- type = kmap_atomic_idx_push();
- idx = type + KM_TYPE_NR * smp_processor_id();
- vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
-- set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
-+ WARN_ON(!pte_none(*(kmap_pte - idx)));
-+
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = pte;
-+#endif
-+ set_pte(kmap_pte - idx, pte);
- arch_flush_lazy_mmu_mode();
-
- return (void *)vaddr;
-@@ -112,10 +119,14 @@
- * is a bad idea also, in case the page changes cacheability
- * attributes or becomes a protected page in a hypervisor.
- */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ current->kmap_pte[type] = __pte(0);
-+#endif
- kpte_clear_flush(kmap_pte-idx, vaddr);
- kmap_atomic_idx_pop();
- }
-
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL_GPL(iounmap_atomic);
-diff -Nur linux-4.1.39.orig/arch/x86/mm/pageattr.c linux-4.1.39/arch/x86/mm/pageattr.c
---- linux-4.1.39.orig/arch/x86/mm/pageattr.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/mm/pageattr.c 2017-04-18 17:56:30.573395579 +0200
-@@ -209,7 +209,15 @@
- int in_flags, struct page **pages)
- {
- unsigned int i, level;
-+#ifdef CONFIG_PREEMPT
-+ /*
-+ * Avoid wbinvd() because it causes latencies on all CPUs,
-+ * regardless of any CPU isolation that may be in effect.
-+ */
-+ unsigned long do_wbinvd = 0;
-+#else
- unsigned long do_wbinvd = cache && numpages >= 1024; /* 4M threshold */
-+#endif
-
- BUG_ON(irqs_disabled());
-
-diff -Nur linux-4.1.39.orig/arch/x86/platform/uv/tlb_uv.c linux-4.1.39/arch/x86/platform/uv/tlb_uv.c
---- linux-4.1.39.orig/arch/x86/platform/uv/tlb_uv.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/platform/uv/tlb_uv.c 2017-04-18 17:56:30.573395579 +0200
-@@ -714,9 +714,9 @@
-
- quiesce_local_uvhub(hmaster);
-
-- spin_lock(&hmaster->queue_lock);
-+ raw_spin_lock(&hmaster->queue_lock);
- reset_with_ipi(&bau_desc->distribution, bcp);
-- spin_unlock(&hmaster->queue_lock);
-+ raw_spin_unlock(&hmaster->queue_lock);
-
- end_uvhub_quiesce(hmaster);
-
-@@ -736,9 +736,9 @@
-
- quiesce_local_uvhub(hmaster);
-
-- spin_lock(&hmaster->queue_lock);
-+ raw_spin_lock(&hmaster->queue_lock);
- reset_with_ipi(&bau_desc->distribution, bcp);
-- spin_unlock(&hmaster->queue_lock);
-+ raw_spin_unlock(&hmaster->queue_lock);
-
- end_uvhub_quiesce(hmaster);
-
-@@ -759,7 +759,7 @@
- cycles_t tm1;
-
- hmaster = bcp->uvhub_master;
-- spin_lock(&hmaster->disable_lock);
-+ raw_spin_lock(&hmaster->disable_lock);
- if (!bcp->baudisabled) {
- stat->s_bau_disabled++;
- tm1 = get_cycles();
-@@ -772,7 +772,7 @@
- }
- }
- }
-- spin_unlock(&hmaster->disable_lock);
-+ raw_spin_unlock(&hmaster->disable_lock);
- }
-
- static void count_max_concurr(int stat, struct bau_control *bcp,
-@@ -835,7 +835,7 @@
- */
- static void uv1_throttle(struct bau_control *hmaster, struct ptc_stats *stat)
- {
-- spinlock_t *lock = &hmaster->uvhub_lock;
-+ raw_spinlock_t *lock = &hmaster->uvhub_lock;
- atomic_t *v;
-
- v = &hmaster->active_descriptor_count;
-@@ -968,7 +968,7 @@
- struct bau_control *hmaster;
-
- hmaster = bcp->uvhub_master;
-- spin_lock(&hmaster->disable_lock);
-+ raw_spin_lock(&hmaster->disable_lock);
- if (bcp->baudisabled && (get_cycles() >= bcp->set_bau_on_time)) {
- stat->s_bau_reenabled++;
- for_each_present_cpu(tcpu) {
-@@ -980,10 +980,10 @@
- tbcp->period_giveups = 0;
- }
- }
-- spin_unlock(&hmaster->disable_lock);
-+ raw_spin_unlock(&hmaster->disable_lock);
- return 0;
- }
-- spin_unlock(&hmaster->disable_lock);
-+ raw_spin_unlock(&hmaster->disable_lock);
- return -1;
- }
-
-@@ -1901,9 +1901,9 @@
- bcp->cong_reps = congested_reps;
- bcp->disabled_period = sec_2_cycles(disabled_period);
- bcp->giveup_limit = giveup_limit;
-- spin_lock_init(&bcp->queue_lock);
-- spin_lock_init(&bcp->uvhub_lock);
-- spin_lock_init(&bcp->disable_lock);
-+ raw_spin_lock_init(&bcp->queue_lock);
-+ raw_spin_lock_init(&bcp->uvhub_lock);
-+ raw_spin_lock_init(&bcp->disable_lock);
- }
- }
-
-diff -Nur linux-4.1.39.orig/arch/x86/platform/uv/uv_time.c linux-4.1.39/arch/x86/platform/uv/uv_time.c
---- linux-4.1.39.orig/arch/x86/platform/uv/uv_time.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/x86/platform/uv/uv_time.c 2017-04-18 17:56:30.573395579 +0200
-@@ -58,7 +58,7 @@
-
- /* There is one of these allocated per node */
- struct uv_rtc_timer_head {
-- spinlock_t lock;
-+ raw_spinlock_t lock;
- /* next cpu waiting for timer, local node relative: */
- int next_cpu;
- /* number of cpus on this node: */
-@@ -178,7 +178,7 @@
- uv_rtc_deallocate_timers();
- return -ENOMEM;
- }
-- spin_lock_init(&head->lock);
-+ raw_spin_lock_init(&head->lock);
- head->ncpus = uv_blade_nr_possible_cpus(bid);
- head->next_cpu = -1;
- blade_info[bid] = head;
-@@ -232,7 +232,7 @@
- unsigned long flags;
- int next_cpu;
-
-- spin_lock_irqsave(&head->lock, flags);
-+ raw_spin_lock_irqsave(&head->lock, flags);
-
- next_cpu = head->next_cpu;
- *t = expires;
-@@ -244,12 +244,12 @@
- if (uv_setup_intr(cpu, expires)) {
- *t = ULLONG_MAX;
- uv_rtc_find_next_timer(head, pnode);
-- spin_unlock_irqrestore(&head->lock, flags);
-+ raw_spin_unlock_irqrestore(&head->lock, flags);
- return -ETIME;
- }
- }
-
-- spin_unlock_irqrestore(&head->lock, flags);
-+ raw_spin_unlock_irqrestore(&head->lock, flags);
- return 0;
- }
-
-@@ -268,7 +268,7 @@
- unsigned long flags;
- int rc = 0;
-
-- spin_lock_irqsave(&head->lock, flags);
-+ raw_spin_lock_irqsave(&head->lock, flags);
-
- if ((head->next_cpu == bcpu && uv_read_rtc(NULL) >= *t) || force)
- rc = 1;
-@@ -280,7 +280,7 @@
- uv_rtc_find_next_timer(head, pnode);
- }
-
-- spin_unlock_irqrestore(&head->lock, flags);
-+ raw_spin_unlock_irqrestore(&head->lock, flags);
-
- return rc;
- }
-@@ -300,13 +300,18 @@
- static cycle_t uv_read_rtc(struct clocksource *cs)
- {
- unsigned long offset;
-+ cycle_t cycles;
-
-+ preempt_disable();
- if (uv_get_min_hub_revision_id() == 1)
- offset = 0;
- else
- offset = (uv_blade_processor_id() * L1_CACHE_BYTES) % PAGE_SIZE;
-
-- return (cycle_t)uv_read_local_mmr(UVH_RTC | offset);
-+ cycles = (cycle_t)uv_read_local_mmr(UVH_RTC | offset);
-+ preempt_enable();
-+
-+ return cycles;
- }
-
- /*
-diff -Nur linux-4.1.39.orig/arch/xtensa/mm/fault.c linux-4.1.39/arch/xtensa/mm/fault.c
---- linux-4.1.39.orig/arch/xtensa/mm/fault.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/xtensa/mm/fault.c 2017-04-18 17:56:30.573395579 +0200
-@@ -15,10 +15,10 @@
- #include <linux/mm.h>
- #include <linux/module.h>
- #include <linux/hardirq.h>
-+#include <linux/uaccess.h>
- #include <asm/mmu_context.h>
- #include <asm/cacheflush.h>
- #include <asm/hardirq.h>
--#include <asm/uaccess.h>
- #include <asm/pgalloc.h>
-
- DEFINE_PER_CPU(unsigned long, asid_cache) = ASID_USER_FIRST;
-@@ -57,7 +57,7 @@
- /* If we're in an interrupt or have no user
- * context, we must not take the fault..
- */
-- if (in_atomic() || !mm) {
-+ if (faulthandler_disabled() || !mm) {
- bad_page_fault(regs, address, SIGSEGV);
- return;
- }
-diff -Nur linux-4.1.39.orig/arch/xtensa/mm/highmem.c linux-4.1.39/arch/xtensa/mm/highmem.c
---- linux-4.1.39.orig/arch/xtensa/mm/highmem.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/arch/xtensa/mm/highmem.c 2017-04-18 17:56:30.573395579 +0200
-@@ -42,6 +42,7 @@
- enum fixed_addresses idx;
- unsigned long vaddr;
-
-+ preempt_disable();
- pagefault_disable();
- if (!PageHighMem(page))
- return page_address(page);
-@@ -79,6 +80,7 @@
- }
-
- pagefault_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(__kunmap_atomic);
-
-diff -Nur linux-4.1.39.orig/block/blk-core.c linux-4.1.39/block/blk-core.c
---- linux-4.1.39.orig/block/blk-core.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-core.c 2017-04-18 17:56:30.573395579 +0200
-@@ -100,6 +100,9 @@
-
- INIT_LIST_HEAD(&rq->queuelist);
- INIT_LIST_HEAD(&rq->timeout_list);
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ INIT_WORK(&rq->work, __blk_mq_complete_request_remote_work);
-+#endif
- rq->cpu = -1;
- rq->q = q;
- rq->__sector = (sector_t) -1;
-@@ -194,7 +197,7 @@
- **/
- void blk_start_queue(struct request_queue *q)
- {
-- WARN_ON(!irqs_disabled());
-+ WARN_ON_NONRT(!irqs_disabled());
-
- queue_flag_clear(QUEUE_FLAG_STOPPED, q);
- __blk_run_queue(q);
-@@ -663,7 +666,7 @@
- q->bypass_depth = 1;
- __set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags);
-
-- init_waitqueue_head(&q->mq_freeze_wq);
-+ init_swait_head(&q->mq_freeze_wq);
-
- if (blkcg_init_queue(q))
- goto fail_bdi;
-@@ -3079,7 +3082,7 @@
- blk_run_queue_async(q);
- else
- __blk_run_queue(q);
-- spin_unlock(q->queue_lock);
-+ spin_unlock_irq(q->queue_lock);
- }
-
- static void flush_plug_callbacks(struct blk_plug *plug, bool from_schedule)
-@@ -3127,7 +3130,6 @@
- void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
- {
- struct request_queue *q;
-- unsigned long flags;
- struct request *rq;
- LIST_HEAD(list);
- unsigned int depth;
-@@ -3147,11 +3149,6 @@
- q = NULL;
- depth = 0;
-
-- /*
-- * Save and disable interrupts here, to avoid doing it for every
-- * queue lock we have to take.
-- */
-- local_irq_save(flags);
- while (!list_empty(&list)) {
- rq = list_entry_rq(list.next);
- list_del_init(&rq->queuelist);
-@@ -3164,7 +3161,7 @@
- queue_unplugged(q, depth, from_schedule);
- q = rq->q;
- depth = 0;
-- spin_lock(q->queue_lock);
-+ spin_lock_irq(q->queue_lock);
- }
-
- /*
-@@ -3191,8 +3188,6 @@
- */
- if (q)
- queue_unplugged(q, depth, from_schedule);
--
-- local_irq_restore(flags);
- }
-
- void blk_finish_plug(struct blk_plug *plug)
-diff -Nur linux-4.1.39.orig/block/blk-ioc.c linux-4.1.39/block/blk-ioc.c
---- linux-4.1.39.orig/block/blk-ioc.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-ioc.c 2017-04-18 17:56:30.573395579 +0200
-@@ -7,6 +7,7 @@
- #include <linux/bio.h>
- #include <linux/blkdev.h>
- #include <linux/slab.h>
-+#include <linux/delay.h>
-
- #include "blk.h"
-
-@@ -109,7 +110,7 @@
- spin_unlock(q->queue_lock);
- } else {
- spin_unlock_irqrestore(&ioc->lock, flags);
-- cpu_relax();
-+ cpu_chill();
- spin_lock_irqsave_nested(&ioc->lock, flags, 1);
- }
- }
-@@ -187,7 +188,7 @@
- spin_unlock(icq->q->queue_lock);
- } else {
- spin_unlock_irqrestore(&ioc->lock, flags);
-- cpu_relax();
-+ cpu_chill();
- goto retry;
- }
- }
-diff -Nur linux-4.1.39.orig/block/blk-iopoll.c linux-4.1.39/block/blk-iopoll.c
---- linux-4.1.39.orig/block/blk-iopoll.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-iopoll.c 2017-04-18 17:56:30.573395579 +0200
-@@ -35,6 +35,7 @@
- list_add_tail(&iop->list, this_cpu_ptr(&blk_cpu_iopoll));
- __raise_softirq_irqoff(BLOCK_IOPOLL_SOFTIRQ);
- local_irq_restore(flags);
-+ preempt_check_resched_rt();
- }
- EXPORT_SYMBOL(blk_iopoll_sched);
-
-@@ -132,6 +133,7 @@
- __raise_softirq_irqoff(BLOCK_IOPOLL_SOFTIRQ);
-
- local_irq_enable();
-+ preempt_check_resched_rt();
- }
-
- /**
-@@ -201,6 +203,7 @@
- this_cpu_ptr(&blk_cpu_iopoll));
- __raise_softirq_irqoff(BLOCK_IOPOLL_SOFTIRQ);
- local_irq_enable();
-+ preempt_check_resched_rt();
- }
-
- return NOTIFY_OK;
-diff -Nur linux-4.1.39.orig/block/blk-mq.c linux-4.1.39/block/blk-mq.c
---- linux-4.1.39.orig/block/blk-mq.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-mq.c 2017-04-18 17:56:30.573395579 +0200
-@@ -88,7 +88,7 @@
- if (!(gfp & __GFP_WAIT))
- return -EBUSY;
-
-- ret = wait_event_interruptible(q->mq_freeze_wq,
-+ ret = swait_event_interruptible(q->mq_freeze_wq,
- !q->mq_freeze_depth || blk_queue_dying(q));
- if (blk_queue_dying(q))
- return -ENODEV;
-@@ -107,7 +107,7 @@
- struct request_queue *q =
- container_of(ref, struct request_queue, mq_usage_counter);
-
-- wake_up_all(&q->mq_freeze_wq);
-+ swait_wake_all(&q->mq_freeze_wq);
- }
-
- void blk_mq_freeze_queue_start(struct request_queue *q)
-@@ -127,7 +127,7 @@
-
- static void blk_mq_freeze_queue_wait(struct request_queue *q)
- {
-- wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter));
-+ swait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter));
- }
-
- /*
-@@ -151,7 +151,7 @@
- spin_unlock_irq(q->queue_lock);
- if (wake) {
- percpu_ref_reinit(&q->mq_usage_counter);
-- wake_up_all(&q->mq_freeze_wq);
-+ swait_wake_all(&q->mq_freeze_wq);
- }
- }
- EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
-@@ -170,7 +170,7 @@
- * dying, we need to ensure that processes currently waiting on
- * the queue are notified as well.
- */
-- wake_up_all(&q->mq_freeze_wq);
-+ swait_wake_all(&q->mq_freeze_wq);
- }
-
- bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx)
-@@ -217,6 +217,9 @@
- rq->resid_len = 0;
- rq->sense = NULL;
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ INIT_WORK(&rq->work, __blk_mq_complete_request_remote_work);
-+#endif
- INIT_LIST_HEAD(&rq->timeout_list);
- rq->timeout = 0;
-
-@@ -346,6 +349,17 @@
- }
- EXPORT_SYMBOL(blk_mq_end_request);
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+
-+void __blk_mq_complete_request_remote_work(struct work_struct *work)
-+{
-+ struct request *rq = container_of(work, struct request, work);
-+
-+ rq->q->softirq_done_fn(rq);
-+}
-+
-+#else
-+
- static void __blk_mq_complete_request_remote(void *data)
- {
- struct request *rq = data;
-@@ -353,6 +367,8 @@
- rq->q->softirq_done_fn(rq);
- }
-
-+#endif
-+
- static void blk_mq_ipi_complete_request(struct request *rq)
- {
- struct blk_mq_ctx *ctx = rq->mq_ctx;
-@@ -364,19 +380,23 @@
- return;
- }
-
-- cpu = get_cpu();
-+ cpu = get_cpu_light();
- if (!test_bit(QUEUE_FLAG_SAME_FORCE, &rq->q->queue_flags))
- shared = cpus_share_cache(cpu, ctx->cpu);
-
- if (cpu != ctx->cpu && !shared && cpu_online(ctx->cpu)) {
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ schedule_work_on(ctx->cpu, &rq->work);
-+#else
- rq->csd.func = __blk_mq_complete_request_remote;
- rq->csd.info = rq;
- rq->csd.flags = 0;
- smp_call_function_single_async(ctx->cpu, &rq->csd);
-+#endif
- } else {
- rq->q->softirq_done_fn(rq);
- }
-- put_cpu();
-+ put_cpu_light();
- }
-
- void __blk_mq_complete_request(struct request *rq)
-@@ -905,14 +925,14 @@
- return;
-
- if (!async) {
-- int cpu = get_cpu();
-+ int cpu = get_cpu_light();
- if (cpumask_test_cpu(cpu, hctx->cpumask)) {
- __blk_mq_run_hw_queue(hctx);
-- put_cpu();
-+ put_cpu_light();
- return;
- }
-
-- put_cpu();
-+ put_cpu_light();
- }
-
- kblockd_schedule_delayed_work_on(blk_mq_hctx_next_cpu(hctx),
-@@ -1589,7 +1609,7 @@
- {
- struct blk_mq_hw_ctx *hctx = data;
-
-- if (action == CPU_DEAD || action == CPU_DEAD_FROZEN)
-+ if (action == CPU_POST_DEAD)
- return blk_mq_hctx_cpu_offline(hctx, cpu);
-
- /*
-diff -Nur linux-4.1.39.orig/block/blk-mq-cpu.c linux-4.1.39/block/blk-mq-cpu.c
---- linux-4.1.39.orig/block/blk-mq-cpu.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-mq-cpu.c 2017-04-18 17:56:30.573395579 +0200
-@@ -16,7 +16,7 @@
- #include "blk-mq.h"
-
- static LIST_HEAD(blk_mq_cpu_notify_list);
--static DEFINE_RAW_SPINLOCK(blk_mq_cpu_notify_lock);
-+static DEFINE_SPINLOCK(blk_mq_cpu_notify_lock);
-
- static int blk_mq_main_cpu_notify(struct notifier_block *self,
- unsigned long action, void *hcpu)
-@@ -25,7 +25,10 @@
- struct blk_mq_cpu_notifier *notify;
- int ret = NOTIFY_OK;
-
-- raw_spin_lock(&blk_mq_cpu_notify_lock);
-+ if (action != CPU_POST_DEAD)
-+ return NOTIFY_OK;
-+
-+ spin_lock(&blk_mq_cpu_notify_lock);
-
- list_for_each_entry(notify, &blk_mq_cpu_notify_list, list) {
- ret = notify->notify(notify->data, action, cpu);
-@@ -33,7 +36,7 @@
- break;
- }
-
-- raw_spin_unlock(&blk_mq_cpu_notify_lock);
-+ spin_unlock(&blk_mq_cpu_notify_lock);
- return ret;
- }
-
-@@ -41,16 +44,16 @@
- {
- BUG_ON(!notifier->notify);
-
-- raw_spin_lock(&blk_mq_cpu_notify_lock);
-+ spin_lock(&blk_mq_cpu_notify_lock);
- list_add_tail(&notifier->list, &blk_mq_cpu_notify_list);
-- raw_spin_unlock(&blk_mq_cpu_notify_lock);
-+ spin_unlock(&blk_mq_cpu_notify_lock);
- }
-
- void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
- {
-- raw_spin_lock(&blk_mq_cpu_notify_lock);
-+ spin_lock(&blk_mq_cpu_notify_lock);
- list_del(&notifier->list);
-- raw_spin_unlock(&blk_mq_cpu_notify_lock);
-+ spin_unlock(&blk_mq_cpu_notify_lock);
- }
-
- void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,
-diff -Nur linux-4.1.39.orig/block/blk-mq.h linux-4.1.39/block/blk-mq.h
---- linux-4.1.39.orig/block/blk-mq.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-mq.h 2017-04-18 17:56:30.573395579 +0200
-@@ -76,7 +76,10 @@
- static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q,
- unsigned int cpu)
- {
-- return per_cpu_ptr(q->queue_ctx, cpu);
-+ struct blk_mq_ctx *ctx;
-+
-+ ctx = per_cpu_ptr(q->queue_ctx, cpu);
-+ return ctx;
- }
-
- /*
-@@ -87,12 +90,12 @@
- */
- static inline struct blk_mq_ctx *blk_mq_get_ctx(struct request_queue *q)
- {
-- return __blk_mq_get_ctx(q, get_cpu());
-+ return __blk_mq_get_ctx(q, get_cpu_light());
- }
-
- static inline void blk_mq_put_ctx(struct blk_mq_ctx *ctx)
- {
-- put_cpu();
-+ put_cpu_light();
- }
-
- struct blk_mq_alloc_data {
-diff -Nur linux-4.1.39.orig/block/blk-softirq.c linux-4.1.39/block/blk-softirq.c
---- linux-4.1.39.orig/block/blk-softirq.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/blk-softirq.c 2017-04-18 17:56:30.573395579 +0200
-@@ -51,6 +51,7 @@
- raise_softirq_irqoff(BLOCK_SOFTIRQ);
-
- local_irq_restore(flags);
-+ preempt_check_resched_rt();
- }
-
- /*
-@@ -93,6 +94,7 @@
- this_cpu_ptr(&blk_cpu_done));
- raise_softirq_irqoff(BLOCK_SOFTIRQ);
- local_irq_enable();
-+ preempt_check_resched_rt();
- }
-
- return NOTIFY_OK;
-@@ -150,6 +152,7 @@
- goto do_local;
-
- local_irq_restore(flags);
-+ preempt_check_resched_rt();
- }
-
- /**
-diff -Nur linux-4.1.39.orig/block/bounce.c linux-4.1.39/block/bounce.c
---- linux-4.1.39.orig/block/bounce.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/block/bounce.c 2017-04-18 17:56:30.573395579 +0200
-@@ -54,11 +54,11 @@
- unsigned long flags;
- unsigned char *vto;
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- vto = kmap_atomic(to->bv_page);
- memcpy(vto + to->bv_offset, vfrom, to->bv_len);
- kunmap_atomic(vto);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- }
-
- #else /* CONFIG_HIGHMEM */
-diff -Nur linux-4.1.39.orig/crypto/algapi.c linux-4.1.39/crypto/algapi.c
---- linux-4.1.39.orig/crypto/algapi.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/crypto/algapi.c 2017-04-18 17:56:30.573395579 +0200
-@@ -696,13 +696,13 @@
-
- int crypto_register_notifier(struct notifier_block *nb)
- {
-- return blocking_notifier_chain_register(&crypto_chain, nb);
-+ return srcu_notifier_chain_register(&crypto_chain, nb);
- }
- EXPORT_SYMBOL_GPL(crypto_register_notifier);
-
- int crypto_unregister_notifier(struct notifier_block *nb)
- {
-- return blocking_notifier_chain_unregister(&crypto_chain, nb);
-+ return srcu_notifier_chain_unregister(&crypto_chain, nb);
- }
- EXPORT_SYMBOL_GPL(crypto_unregister_notifier);
-
-diff -Nur linux-4.1.39.orig/crypto/api.c linux-4.1.39/crypto/api.c
---- linux-4.1.39.orig/crypto/api.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/crypto/api.c 2017-04-18 17:56:30.573395579 +0200
-@@ -31,7 +31,7 @@
- DECLARE_RWSEM(crypto_alg_sem);
- EXPORT_SYMBOL_GPL(crypto_alg_sem);
-
--BLOCKING_NOTIFIER_HEAD(crypto_chain);
-+SRCU_NOTIFIER_HEAD(crypto_chain);
- EXPORT_SYMBOL_GPL(crypto_chain);
-
- static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg);
-@@ -236,10 +236,10 @@
- {
- int ok;
-
-- ok = blocking_notifier_call_chain(&crypto_chain, val, v);
-+ ok = srcu_notifier_call_chain(&crypto_chain, val, v);
- if (ok == NOTIFY_DONE) {
- request_module("cryptomgr");
-- ok = blocking_notifier_call_chain(&crypto_chain, val, v);
-+ ok = srcu_notifier_call_chain(&crypto_chain, val, v);
- }
-
- return ok;
-diff -Nur linux-4.1.39.orig/crypto/internal.h linux-4.1.39/crypto/internal.h
---- linux-4.1.39.orig/crypto/internal.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/crypto/internal.h 2017-04-18 17:56:30.573395579 +0200
-@@ -48,7 +48,7 @@
-
- extern struct list_head crypto_alg_list;
- extern struct rw_semaphore crypto_alg_sem;
--extern struct blocking_notifier_head crypto_chain;
-+extern struct srcu_notifier_head crypto_chain;
-
- #ifdef CONFIG_PROC_FS
- void __init crypto_init_proc(void);
-@@ -142,7 +142,7 @@
-
- static inline void crypto_notify(unsigned long val, void *v)
- {
-- blocking_notifier_call_chain(&crypto_chain, val, v);
-+ srcu_notifier_call_chain(&crypto_chain, val, v);
- }
-
- #endif /* _CRYPTO_INTERNAL_H */
-diff -Nur linux-4.1.39.orig/Documentation/hwlat_detector.txt linux-4.1.39/Documentation/hwlat_detector.txt
---- linux-4.1.39.orig/Documentation/hwlat_detector.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.39/Documentation/hwlat_detector.txt 2017-04-18 17:56:30.545394493 +0200
-@@ -0,0 +1,64 @@
-+Introduction:
-+-------------
-+
-+The module hwlat_detector is a special purpose kernel module that is used to
-+detect large system latencies induced by the behavior of certain underlying
-+hardware or firmware, independent of Linux itself. The code was developed
-+originally to detect SMIs (System Management Interrupts) on x86 systems,
-+however there is nothing x86 specific about this patchset. It was
-+originally written for use by the "RT" patch since the Real Time
-+kernel is highly latency sensitive.
-+
-+SMIs are usually not serviced by the Linux kernel, which typically does not
-+even know that they are occuring. SMIs are instead are set up by BIOS code
-+and are serviced by BIOS code, usually for "critical" events such as
-+management of thermal sensors and fans. Sometimes though, SMIs are used for
-+other tasks and those tasks can spend an inordinate amount of time in the
-+handler (sometimes measured in milliseconds). Obviously this is a problem if
-+you are trying to keep event service latencies down in the microsecond range.
-+
-+The hardware latency detector works by hogging all of the cpus for configurable
-+amounts of time (by calling stop_machine()), polling the CPU Time Stamp Counter
-+for some period, then looking for gaps in the TSC data. Any gap indicates a
-+time when the polling was interrupted and since the machine is stopped and
-+interrupts turned off the only thing that could do that would be an SMI.
-+
-+Note that the SMI detector should *NEVER* be used in a production environment.
-+It is intended to be run manually to determine if the hardware platform has a
-+problem with long system firmware service routines.
-+
-+Usage:
-+------
-+
-+Loading the module hwlat_detector passing the parameter "enabled=1" (or by
-+setting the "enable" entry in "hwlat_detector" debugfs toggled on) is the only
-+step required to start the hwlat_detector. It is possible to redefine the
-+threshold in microseconds (us) above which latency spikes will be taken
-+into account (parameter "threshold=").
-+
-+Example:
-+
-+ # modprobe hwlat_detector enabled=1 threshold=100
-+
-+After the module is loaded, it creates a directory named "hwlat_detector" under
-+the debugfs mountpoint, "/debug/hwlat_detector" for this text. It is necessary
-+to have debugfs mounted, which might be on /sys/debug on your system.
-+
-+The /debug/hwlat_detector interface contains the following files:
-+
-+count - number of latency spikes observed since last reset
-+enable - a global enable/disable toggle (0/1), resets count
-+max - maximum hardware latency actually observed (usecs)
-+sample - a pipe from which to read current raw sample data
-+ in the format <timestamp> <latency observed usecs>
-+ (can be opened O_NONBLOCK for a single sample)
-+threshold - minimum latency value to be considered (usecs)
-+width - time period to sample with CPUs held (usecs)
-+ must be less than the total window size (enforced)
-+window - total period of sampling, width being inside (usecs)
-+
-+By default we will set width to 500,000 and window to 1,000,000, meaning that
-+we will sample every 1,000,000 usecs (1s) for 500,000 usecs (0.5s). If we
-+observe any latencies that exceed the threshold (initially 100 usecs),
-+then we write to a global sample ring buffer of 8K samples, which is
-+consumed by reading from the "sample" (pipe) debugfs file interface.
-diff -Nur linux-4.1.39.orig/Documentation/sysrq.txt linux-4.1.39/Documentation/sysrq.txt
---- linux-4.1.39.orig/Documentation/sysrq.txt 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/Documentation/sysrq.txt 2017-04-18 17:56:30.545394493 +0200
-@@ -59,10 +59,17 @@
- On other - If you know of the key combos for other architectures, please
- let me know so I can add them to this section.
-
--On all - write a character to /proc/sysrq-trigger. e.g.:
--
-+On all - write a character to /proc/sysrq-trigger, e.g.:
- echo t > /proc/sysrq-trigger
-
-+On all - Enable network SysRq by writing a cookie to icmp_echo_sysrq, e.g.
-+ echo 0x01020304 >/proc/sys/net/ipv4/icmp_echo_sysrq
-+ Send an ICMP echo request with this pattern plus the particular
-+ SysRq command key. Example:
-+ # ping -c1 -s57 -p0102030468
-+ will trigger the SysRq-H (help) command.
-+
-+
- * What are the 'command' keys?
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 'b' - Will immediately reboot the system without syncing or unmounting
-diff -Nur linux-4.1.39.orig/Documentation/trace/histograms.txt linux-4.1.39/Documentation/trace/histograms.txt
---- linux-4.1.39.orig/Documentation/trace/histograms.txt 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.39/Documentation/trace/histograms.txt 2017-04-18 17:56:30.545394493 +0200
-@@ -0,0 +1,186 @@
-+ Using the Linux Kernel Latency Histograms
-+
-+
-+This document gives a short explanation how to enable, configure and use
-+latency histograms. Latency histograms are primarily relevant in the
-+context of real-time enabled kernels (CONFIG_PREEMPT/CONFIG_PREEMPT_RT)
-+and are used in the quality management of the Linux real-time
-+capabilities.
-+
-+
-+* Purpose of latency histograms
-+
-+A latency histogram continuously accumulates the frequencies of latency
-+data. There are two types of histograms
-+- potential sources of latencies
-+- effective latencies
-+
-+
-+* Potential sources of latencies
-+
-+Potential sources of latencies are code segments where interrupts,
-+preemption or both are disabled (aka critical sections). To create
-+histograms of potential sources of latency, the kernel stores the time
-+stamp at the start of a critical section, determines the time elapsed
-+when the end of the section is reached, and increments the frequency
-+counter of that latency value - irrespective of whether any concurrently
-+running process is affected by latency or not.
-+- Configuration items (in the Kernel hacking/Tracers submenu)
-+ CONFIG_INTERRUPT_OFF_LATENCY
-+ CONFIG_PREEMPT_OFF_LATENCY
-+
-+
-+* Effective latencies
-+
-+Effective latencies are actually occuring during wakeup of a process. To
-+determine effective latencies, the kernel stores the time stamp when a
-+process is scheduled to be woken up, and determines the duration of the
-+wakeup time shortly before control is passed over to this process. Note
-+that the apparent latency in user space may be somewhat longer, since the
-+process may be interrupted after control is passed over to it but before
-+the execution in user space takes place. Simply measuring the interval
-+between enqueuing and wakeup may also not appropriate in cases when a
-+process is scheduled as a result of a timer expiration. The timer may have
-+missed its deadline, e.g. due to disabled interrupts, but this latency
-+would not be registered. Therefore, the offsets of missed timers are
-+recorded in a separate histogram. If both wakeup latency and missed timer
-+offsets are configured and enabled, a third histogram may be enabled that
-+records the overall latency as a sum of the timer latency, if any, and the
-+wakeup latency. This histogram is called "timerandwakeup".
-+- Configuration items (in the Kernel hacking/Tracers submenu)
-+ CONFIG_WAKEUP_LATENCY
-+ CONFIG_MISSED_TIMER_OFSETS
-+
-+
-+* Usage
-+
-+The interface to the administration of the latency histograms is located
-+in the debugfs file system. To mount it, either enter
-+
-+mount -t sysfs nodev /sys
-+mount -t debugfs nodev /sys/kernel/debug
-+
-+from shell command line level, or add
-+
-+nodev /sys sysfs defaults 0 0
-+nodev /sys/kernel/debug debugfs defaults 0 0
-+
-+to the file /etc/fstab. All latency histogram related files are then
-+available in the directory /sys/kernel/debug/tracing/latency_hist. A
-+particular histogram type is enabled by writing non-zero to the related
-+variable in the /sys/kernel/debug/tracing/latency_hist/enable directory.
-+Select "preemptirqsoff" for the histograms of potential sources of
-+latencies and "wakeup" for histograms of effective latencies etc. The
-+histogram data - one per CPU - are available in the files
-+
-+/sys/kernel/debug/tracing/latency_hist/preemptoff/CPUx
-+/sys/kernel/debug/tracing/latency_hist/irqsoff/CPUx
-+/sys/kernel/debug/tracing/latency_hist/preemptirqsoff/CPUx
-+/sys/kernel/debug/tracing/latency_hist/wakeup/CPUx
-+/sys/kernel/debug/tracing/latency_hist/wakeup/sharedprio/CPUx
-+/sys/kernel/debug/tracing/latency_hist/missed_timer_offsets/CPUx
-+/sys/kernel/debug/tracing/latency_hist/timerandwakeup/CPUx
-+
-+The histograms are reset by writing non-zero to the file "reset" in a
-+particular latency directory. To reset all latency data, use
-+
-+#!/bin/sh
-+
-+TRACINGDIR=/sys/kernel/debug/tracing
-+HISTDIR=$TRACINGDIR/latency_hist
-+
-+if test -d $HISTDIR
-+then
-+ cd $HISTDIR
-+ for i in `find . | grep /reset$`
-+ do
-+ echo 1 >$i
-+ done
-+fi
-+
-+
-+* Data format
-+
-+Latency data are stored with a resolution of one microsecond. The
-+maximum latency is 10,240 microseconds. The data are only valid, if the
-+overflow register is empty. Every output line contains the latency in
-+microseconds in the first row and the number of samples in the second
-+row. To display only lines with a positive latency count, use, for
-+example,
-+
-+grep -v " 0$" /sys/kernel/debug/tracing/latency_hist/preemptoff/CPU0
-+
-+#Minimum latency: 0 microseconds.
-+#Average latency: 0 microseconds.
-+#Maximum latency: 25 microseconds.
-+#Total samples: 3104770694
-+#There are 0 samples greater or equal than 10240 microseconds
-+#usecs samples
-+ 0 2984486876
-+ 1 49843506
-+ 2 58219047
-+ 3 5348126
-+ 4 2187960
-+ 5 3388262
-+ 6 959289
-+ 7 208294
-+ 8 40420
-+ 9 4485
-+ 10 14918
-+ 11 18340
-+ 12 25052
-+ 13 19455
-+ 14 5602
-+ 15 969
-+ 16 47
-+ 17 18
-+ 18 14
-+ 19 1
-+ 20 3
-+ 21 2
-+ 22 5
-+ 23 2
-+ 25 1
-+
-+
-+* Wakeup latency of a selected process
-+
-+To only collect wakeup latency data of a particular process, write the
-+PID of the requested process to
-+
-+/sys/kernel/debug/tracing/latency_hist/wakeup/pid
-+
-+PIDs are not considered, if this variable is set to 0.
-+
-+
-+* Details of the process with the highest wakeup latency so far
-+
-+Selected data of the process that suffered from the highest wakeup
-+latency that occurred in a particular CPU are available in the file
-+
-+/sys/kernel/debug/tracing/latency_hist/wakeup/max_latency-CPUx.
-+
-+In addition, other relevant system data at the time when the
-+latency occurred are given.
-+
-+The format of the data is (all in one line):
-+<PID> <Priority> <Latency> (<Timeroffset>) <Command> \
-+<- <PID> <Priority> <Command> <Timestamp>
-+
-+The value of <Timeroffset> is only relevant in the combined timer
-+and wakeup latency recording. In the wakeup recording, it is
-+always 0, in the missed_timer_offsets recording, it is the same
-+as <Latency>.
-+
-+When retrospectively searching for the origin of a latency and
-+tracing was not enabled, it may be helpful to know the name and
-+some basic data of the task that (finally) was switching to the
-+late real-tlme task. In addition to the victim's data, also the
-+data of the possible culprit are therefore displayed after the
-+"<-" symbol.
-+
-+Finally, the timestamp of the time when the latency occurred
-+in <seconds>.<microseconds> after the most recent system boot
-+is provided.
-+
-+These data are also reset when the wakeup histogram is reset.
-diff -Nur linux-4.1.39.orig/drivers/acpi/acpica/acglobal.h linux-4.1.39/drivers/acpi/acpica/acglobal.h
---- linux-4.1.39.orig/drivers/acpi/acpica/acglobal.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/acpi/acpica/acglobal.h 2017-04-18 17:56:30.573395579 +0200
-@@ -112,7 +112,7 @@
- * interrupt level
- */
- ACPI_GLOBAL(acpi_spinlock, acpi_gbl_gpe_lock); /* For GPE data structs and registers */
--ACPI_GLOBAL(acpi_spinlock, acpi_gbl_hardware_lock); /* For ACPI H/W except GPE registers */
-+ACPI_GLOBAL(acpi_raw_spinlock, acpi_gbl_hardware_lock); /* For ACPI H/W except GPE registers */
- ACPI_GLOBAL(acpi_spinlock, acpi_gbl_reference_count_lock);
-
- /* Mutex for _OSI support */
-diff -Nur linux-4.1.39.orig/drivers/acpi/acpica/hwregs.c linux-4.1.39/drivers/acpi/acpica/hwregs.c
---- linux-4.1.39.orig/drivers/acpi/acpica/hwregs.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/acpi/acpica/hwregs.c 2017-04-18 17:56:30.573395579 +0200
-@@ -269,14 +269,14 @@
- ACPI_BITMASK_ALL_FIXED_STATUS,
- ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address)));
-
-- lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
-+ raw_spin_lock_irqsave(acpi_gbl_hardware_lock, lock_flags);
-
- /* Clear the fixed events in PM1 A/B */
-
- status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
- ACPI_BITMASK_ALL_FIXED_STATUS);
-
-- acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
-+ raw_spin_unlock_irqrestore(acpi_gbl_hardware_lock, lock_flags);
-
- if (ACPI_FAILURE(status)) {
- goto exit;
-diff -Nur linux-4.1.39.orig/drivers/acpi/acpica/hwxface.c linux-4.1.39/drivers/acpi/acpica/hwxface.c
---- linux-4.1.39.orig/drivers/acpi/acpica/hwxface.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/acpi/acpica/hwxface.c 2017-04-18 17:56:30.577395735 +0200
-@@ -374,7 +374,7 @@
- return_ACPI_STATUS(AE_BAD_PARAMETER);
- }
-
-- lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
-+ raw_spin_lock_irqsave(acpi_gbl_hardware_lock, lock_flags);
-
- /*
- * At this point, we know that the parent register is one of the
-@@ -435,7 +435,7 @@
-
- unlock_and_exit:
-
-- acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
-+ raw_spin_unlock_irqrestore(acpi_gbl_hardware_lock, lock_flags);
- return_ACPI_STATUS(status);
- }
-
-diff -Nur linux-4.1.39.orig/drivers/acpi/acpica/utmutex.c linux-4.1.39/drivers/acpi/acpica/utmutex.c
---- linux-4.1.39.orig/drivers/acpi/acpica/utmutex.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/acpi/acpica/utmutex.c 2017-04-18 17:56:30.577395735 +0200
-@@ -88,7 +88,7 @@
- return_ACPI_STATUS (status);
- }
-
-- status = acpi_os_create_lock (&acpi_gbl_hardware_lock);
-+ status = acpi_os_create_raw_lock (&acpi_gbl_hardware_lock);
- if (ACPI_FAILURE (status)) {
- return_ACPI_STATUS (status);
- }
-@@ -141,7 +141,7 @@
- /* Delete the spinlocks */
-
- acpi_os_delete_lock(acpi_gbl_gpe_lock);
-- acpi_os_delete_lock(acpi_gbl_hardware_lock);
-+ acpi_os_delete_raw_lock(acpi_gbl_hardware_lock);
- acpi_os_delete_lock(acpi_gbl_reference_count_lock);
-
- /* Delete the reader/writer lock */
-diff -Nur linux-4.1.39.orig/drivers/ata/libata-sff.c linux-4.1.39/drivers/ata/libata-sff.c
---- linux-4.1.39.orig/drivers/ata/libata-sff.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ata/libata-sff.c 2017-04-18 17:56:30.577395735 +0200
-@@ -678,9 +678,9 @@
- unsigned long flags;
- unsigned int consumed;
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- consumed = ata_sff_data_xfer32(dev, buf, buflen, rw);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- return consumed;
- }
-@@ -719,7 +719,7 @@
- unsigned long flags;
-
- /* FIXME: use a bounce buffer */
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- buf = kmap_atomic(page);
-
- /* do the actual data transfer */
-@@ -727,7 +727,7 @@
- do_write);
-
- kunmap_atomic(buf);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- } else {
- buf = page_address(page);
- ap->ops->sff_data_xfer(qc->dev, buf + offset, qc->sect_size,
-@@ -864,7 +864,7 @@
- unsigned long flags;
-
- /* FIXME: use bounce buffer */
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- buf = kmap_atomic(page);
-
- /* do the actual data transfer */
-@@ -872,7 +872,7 @@
- count, rw);
-
- kunmap_atomic(buf);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- } else {
- buf = page_address(page);
- consumed = ap->ops->sff_data_xfer(dev, buf + offset,
-diff -Nur linux-4.1.39.orig/drivers/block/zram/zram_drv.c linux-4.1.39/drivers/block/zram/zram_drv.c
---- linux-4.1.39.orig/drivers/block/zram/zram_drv.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/block/zram/zram_drv.c 2017-04-18 17:56:30.577395735 +0200
-@@ -386,6 +386,8 @@
- goto out_error;
- }
-
-+ zram_meta_init_table_locks(meta, disksize);
-+
- return meta;
-
- out_error:
-@@ -484,12 +486,12 @@
- unsigned long handle;
- size_t size;
-
-- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_lock_table(&meta->table[index]);
- handle = meta->table[index].handle;
- size = zram_get_obj_size(meta, index);
-
- if (!handle || zram_test_flag(meta, index, ZRAM_ZERO)) {
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
- clear_page(mem);
- return 0;
- }
-@@ -500,7 +502,7 @@
- else
- ret = zcomp_decompress(zram->comp, cmem, size, mem);
- zs_unmap_object(meta->mem_pool, handle);
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
-
- /* Should NEVER happen. Return bio error if it does. */
- if (unlikely(ret)) {
-@@ -520,14 +522,14 @@
- struct zram_meta *meta = zram->meta;
- page = bvec->bv_page;
-
-- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_lock_table(&meta->table[index]);
- if (unlikely(!meta->table[index].handle) ||
- zram_test_flag(meta, index, ZRAM_ZERO)) {
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
- handle_zero_page(bvec);
- return 0;
- }
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
-
- if (is_partial_io(bvec))
- /* Use a temporary buffer to decompress the page */
-@@ -622,10 +624,10 @@
- if (user_mem)
- kunmap_atomic(user_mem);
- /* Free memory associated with this sector now. */
-- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_lock_table(&meta->table[index]);
- zram_free_page(zram, index);
- zram_set_flag(meta, index, ZRAM_ZERO);
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
-
- atomic64_inc(&zram->stats.zero_pages);
- ret = 0;
-@@ -685,12 +687,12 @@
- * Free memory associated with this sector
- * before overwriting unused sectors.
- */
-- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_lock_table(&meta->table[index]);
- zram_free_page(zram, index);
-
- meta->table[index].handle = handle;
- zram_set_obj_size(meta, index, clen);
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
-
- /* Update stats */
- atomic64_add(clen, &zram->stats.compr_data_size);
-@@ -762,9 +764,9 @@
- }
-
- while (n >= PAGE_SIZE) {
-- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_lock_table(&meta->table[index]);
- zram_free_page(zram, index);
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
- atomic64_inc(&zram->stats.notify_free);
- index++;
- n -= PAGE_SIZE;
-@@ -1007,9 +1009,9 @@
- zram = bdev->bd_disk->private_data;
- meta = zram->meta;
-
-- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_lock_table(&meta->table[index]);
- zram_free_page(zram, index);
-- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value);
-+ zram_unlock_table(&meta->table[index]);
- atomic64_inc(&zram->stats.notify_free);
- }
-
-diff -Nur linux-4.1.39.orig/drivers/block/zram/zram_drv.h linux-4.1.39/drivers/block/zram/zram_drv.h
---- linux-4.1.39.orig/drivers/block/zram/zram_drv.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/block/zram/zram_drv.h 2017-04-18 17:56:30.577395735 +0200
-@@ -78,6 +78,9 @@
- struct zram_table_entry {
- unsigned long handle;
- unsigned long value;
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ spinlock_t lock;
-+#endif
- };
-
- struct zram_stats {
-@@ -122,4 +125,42 @@
- u64 disksize; /* bytes */
- char compressor[10];
- };
-+
-+#ifndef CONFIG_PREEMPT_RT_BASE
-+static inline void zram_lock_table(struct zram_table_entry *table)
-+{
-+ bit_spin_lock(ZRAM_ACCESS, &table->value);
-+}
-+
-+static inline void zram_unlock_table(struct zram_table_entry *table)
-+{
-+ bit_spin_unlock(ZRAM_ACCESS, &table->value);
-+}
-+
-+static inline void zram_meta_init_table_locks(struct zram_meta *meta, u64 disksize) { }
-+#else /* CONFIG_PREEMPT_RT_BASE */
-+static inline void zram_lock_table(struct zram_table_entry *table)
-+{
-+ spin_lock(&table->lock);
-+ __set_bit(ZRAM_ACCESS, &table->value);
-+}
-+
-+static inline void zram_unlock_table(struct zram_table_entry *table)
-+{
-+ __clear_bit(ZRAM_ACCESS, &table->value);
-+ spin_unlock(&table->lock);
-+}
-+
-+static inline void zram_meta_init_table_locks(struct zram_meta *meta, u64 disksize)
-+{
-+ size_t num_pages = disksize >> PAGE_SHIFT;
-+ size_t index;
-+
-+ for (index = 0; index < num_pages; index++) {
-+ spinlock_t *lock = &meta->table[index].lock;
-+ spin_lock_init(lock);
-+ }
-+}
-+#endif /* CONFIG_PREEMPT_RT_BASE */
-+
- #endif
-diff -Nur linux-4.1.39.orig/drivers/char/random.c linux-4.1.39/drivers/char/random.c
---- linux-4.1.39.orig/drivers/char/random.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/char/random.c 2017-04-18 17:56:30.577395735 +0200
-@@ -776,8 +776,6 @@
- } sample;
- long delta, delta2, delta3;
-
-- preempt_disable();
--
- sample.jiffies = jiffies;
- sample.cycles = random_get_entropy();
- sample.num = num;
-@@ -818,7 +816,6 @@
- */
- credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
- }
-- preempt_enable();
- }
-
- void add_input_randomness(unsigned int type, unsigned int code,
-@@ -871,28 +868,27 @@
- return *(ptr + f->reg_idx++);
- }
-
--void add_interrupt_randomness(int irq, int irq_flags)
-+void add_interrupt_randomness(int irq, int irq_flags, __u64 ip)
- {
- struct entropy_store *r;
- struct fast_pool *fast_pool = this_cpu_ptr(&irq_randomness);
-- struct pt_regs *regs = get_irq_regs();
- unsigned long now = jiffies;
- cycles_t cycles = random_get_entropy();
- __u32 c_high, j_high;
-- __u64 ip;
- unsigned long seed;
- int credit = 0;
-
- if (cycles == 0)
-- cycles = get_reg(fast_pool, regs);
-+ cycles = get_reg(fast_pool, NULL);
- c_high = (sizeof(cycles) > 4) ? cycles >> 32 : 0;
- j_high = (sizeof(now) > 4) ? now >> 32 : 0;
- fast_pool->pool[0] ^= cycles ^ j_high ^ irq;
- fast_pool->pool[1] ^= now ^ c_high;
-- ip = regs ? instruction_pointer(regs) : _RET_IP_;
-+ if (!ip)
-+ ip = _RET_IP_;
- fast_pool->pool[2] ^= ip;
- fast_pool->pool[3] ^= (sizeof(ip) > 4) ? ip >> 32 :
-- get_reg(fast_pool, regs);
-+ get_reg(fast_pool, NULL);
-
- fast_mix(fast_pool);
- add_interrupt_bench(cycles);
-diff -Nur linux-4.1.39.orig/drivers/clk/at91/pmc.c linux-4.1.39/drivers/clk/at91/pmc.c
---- linux-4.1.39.orig/drivers/clk/at91/pmc.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/clk/at91/pmc.c 2017-04-18 17:56:30.577395735 +0200
-@@ -27,21 +27,6 @@
- void __iomem *at91_pmc_base;
- EXPORT_SYMBOL_GPL(at91_pmc_base);
-
--void at91rm9200_idle(void)
--{
-- /*
-- * Disable the processor clock. The processor will be automatically
-- * re-enabled by an interrupt or by a reset.
-- */
-- at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
--}
--
--void at91sam9_idle(void)
--{
-- at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
-- cpu_do_idle();
--}
--
- int of_at91_get_clk_range(struct device_node *np, const char *propname,
- struct clk_range *range)
- {
-diff -Nur linux-4.1.39.orig/drivers/clocksource/tcb_clksrc.c linux-4.1.39/drivers/clocksource/tcb_clksrc.c
---- linux-4.1.39.orig/drivers/clocksource/tcb_clksrc.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/clocksource/tcb_clksrc.c 2017-04-18 17:56:30.577395735 +0200
-@@ -23,8 +23,7 @@
- * this 32 bit free-running counter. the second channel is not used.
- *
- * - The third channel may be used to provide a 16-bit clockevent
-- * source, used in either periodic or oneshot mode. This runs
-- * at 32 KiHZ, and can handle delays of up to two seconds.
-+ * source, used in either periodic or oneshot mode.
- *
- * A boot clocksource and clockevent source are also currently needed,
- * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
-@@ -74,6 +73,7 @@
- struct tc_clkevt_device {
- struct clock_event_device clkevt;
- struct clk *clk;
-+ u32 freq;
- void __iomem *regs;
- };
-
-@@ -82,13 +82,6 @@
- return container_of(clkevt, struct tc_clkevt_device, clkevt);
- }
-
--/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
-- * because using one of the divided clocks would usually mean the
-- * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
-- *
-- * A divided clock could be good for high resolution timers, since
-- * 30.5 usec resolution can seem "low".
-- */
- static u32 timer_clock;
-
- static void tc_mode(enum clock_event_mode m, struct clock_event_device *d)
-@@ -111,11 +104,12 @@
- case CLOCK_EVT_MODE_PERIODIC:
- clk_enable(tcd->clk);
-
-- /* slow clock, count up to RC, then irq and restart */
-+ /* count up to RC, then irq and restart */
- __raw_writel(timer_clock
- | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
- regs + ATMEL_TC_REG(2, CMR));
-- __raw_writel((32768 + HZ/2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
-+ __raw_writel((tcd->freq + HZ / 2) / HZ,
-+ tcaddr + ATMEL_TC_REG(2, RC));
-
- /* Enable clock and interrupts on RC compare */
- __raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-@@ -128,7 +122,7 @@
- case CLOCK_EVT_MODE_ONESHOT:
- clk_enable(tcd->clk);
-
-- /* slow clock, count up to RC, then irq and stop */
-+ /* count up to RC, then irq and stop */
- __raw_writel(timer_clock | ATMEL_TC_CPCSTOP
- | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
- regs + ATMEL_TC_REG(2, CMR));
-@@ -157,8 +151,12 @@
- .name = "tc_clkevt",
- .features = CLOCK_EVT_FEAT_PERIODIC
- | CLOCK_EVT_FEAT_ONESHOT,
-+#ifdef CONFIG_ATMEL_TCB_CLKSRC_USE_SLOW_CLOCK
- /* Should be lower than at91rm9200's system timer */
- .rating = 125,
-+#else
-+ .rating = 200,
-+#endif
- .set_next_event = tc_next_event,
- .set_mode = tc_mode,
- },
-@@ -178,8 +176,9 @@
- return IRQ_NONE;
- }
-
--static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
-+static int __init setup_clkevents(struct atmel_tc *tc, int divisor_idx)
- {
-+ unsigned divisor = atmel_tc_divisors[divisor_idx];
- int ret;
- struct clk *t2_clk = tc->clk[2];
- int irq = tc->irq[2];
-@@ -193,7 +192,11 @@
- clkevt.regs = tc->regs;
- clkevt.clk = t2_clk;
-
-- timer_clock = clk32k_divisor_idx;
-+ timer_clock = divisor_idx;
-+ if (!divisor)
-+ clkevt.freq = 32768;
-+ else
-+ clkevt.freq = clk_get_rate(t2_clk) / divisor;
-
- clkevt.clkevt.cpumask = cpumask_of(0);
-
-@@ -203,7 +206,7 @@
- return ret;
- }
-
-- clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
-+ clockevents_config_and_register(&clkevt.clkevt, clkevt.freq, 1, 0xffff);
-
- return ret;
- }
-@@ -340,7 +343,11 @@
- goto err_disable_t1;
-
- /* channel 2: periodic and oneshot timer support */
-+#ifdef CONFIG_ATMEL_TCB_CLKSRC_USE_SLOW_CLOCK
- ret = setup_clkevents(tc, clk32k_divisor_idx);
-+#else
-+ ret = setup_clkevents(tc, best_divisor_idx);
-+#endif
- if (ret)
- goto err_unregister_clksrc;
-
-diff -Nur linux-4.1.39.orig/drivers/clocksource/timer-atmel-pit.c linux-4.1.39/drivers/clocksource/timer-atmel-pit.c
---- linux-4.1.39.orig/drivers/clocksource/timer-atmel-pit.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/clocksource/timer-atmel-pit.c 2017-04-18 17:56:30.577395735 +0200
-@@ -90,6 +90,7 @@
- return elapsed;
- }
-
-+static struct irqaction at91sam926x_pit_irq;
- /*
- * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16)
- */
-@@ -100,6 +101,8 @@
-
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
-+ /* Set up irq handler */
-+ setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
- /* update clocksource counter */
- data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
- pit_write(data->base, AT91_PIT_MR,
-@@ -113,6 +116,7 @@
- /* disable irq, leaving the clocksource active */
- pit_write(data->base, AT91_PIT_MR,
- (data->cycle - 1) | AT91_PIT_PITEN);
-+ remove_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
- break;
- case CLOCK_EVT_MODE_RESUME:
- break;
-diff -Nur linux-4.1.39.orig/drivers/clocksource/timer-atmel-st.c linux-4.1.39/drivers/clocksource/timer-atmel-st.c
---- linux-4.1.39.orig/drivers/clocksource/timer-atmel-st.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/clocksource/timer-atmel-st.c 2017-04-18 17:56:30.577395735 +0200
-@@ -131,6 +131,7 @@
- break;
- case CLOCK_EVT_MODE_SHUTDOWN:
- case CLOCK_EVT_MODE_UNUSED:
-+ remove_irq(NR_IRQS_LEGACY + AT91_ID_SYS, &at91rm9200_timer_irq);
- case CLOCK_EVT_MODE_RESUME:
- irqmask = 0;
- break;
-diff -Nur linux-4.1.39.orig/drivers/cpufreq/cpufreq.c linux-4.1.39/drivers/cpufreq/cpufreq.c
---- linux-4.1.39.orig/drivers/cpufreq/cpufreq.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/cpufreq/cpufreq.c 2017-04-18 17:56:30.577395735 +0200
-@@ -64,12 +64,6 @@
- return cpufreq_driver->target_index || cpufreq_driver->target;
- }
-
--/*
-- * rwsem to guarantee that cpufreq driver module doesn't unload during critical
-- * sections
-- */
--static DECLARE_RWSEM(cpufreq_rwsem);
--
- /* internal prototypes */
- static int __cpufreq_governor(struct cpufreq_policy *policy,
- unsigned int event);
-@@ -215,9 +209,6 @@
- if (cpu >= nr_cpu_ids)
- return NULL;
-
-- if (!down_read_trylock(&cpufreq_rwsem))
-- return NULL;
--
- /* get the cpufreq driver */
- read_lock_irqsave(&cpufreq_driver_lock, flags);
-
-@@ -230,9 +221,6 @@
-
- read_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
-- if (!policy)
-- up_read(&cpufreq_rwsem);
--
- return policy;
- }
- EXPORT_SYMBOL_GPL(cpufreq_cpu_get);
-@@ -240,7 +228,6 @@
- void cpufreq_cpu_put(struct cpufreq_policy *policy)
- {
- kobject_put(&policy->kobj);
-- up_read(&cpufreq_rwsem);
- }
- EXPORT_SYMBOL_GPL(cpufreq_cpu_put);
-
-@@ -765,9 +752,6 @@
- struct freq_attr *fattr = to_attr(attr);
- ssize_t ret;
-
-- if (!down_read_trylock(&cpufreq_rwsem))
-- return -EINVAL;
--
- down_read(&policy->rwsem);
-
- if (fattr->show)
-@@ -776,7 +760,6 @@
- ret = -EIO;
-
- up_read(&policy->rwsem);
-- up_read(&cpufreq_rwsem);
-
- return ret;
- }
-@@ -793,9 +776,6 @@
- if (!cpu_online(policy->cpu))
- goto unlock;
-
-- if (!down_read_trylock(&cpufreq_rwsem))
-- goto unlock;
--
- down_write(&policy->rwsem);
-
- if (fattr->store)
-@@ -804,8 +784,6 @@
- ret = -EIO;
-
- up_write(&policy->rwsem);
--
-- up_read(&cpufreq_rwsem);
- unlock:
- put_online_cpus();
-
-@@ -1117,16 +1095,12 @@
- if (unlikely(policy))
- return 0;
-
-- if (!down_read_trylock(&cpufreq_rwsem))
-- return 0;
--
- /* Check if this cpu was hot-unplugged earlier and has siblings */
- read_lock_irqsave(&cpufreq_driver_lock, flags);
- for_each_policy(policy) {
- if (cpumask_test_cpu(cpu, policy->related_cpus)) {
- read_unlock_irqrestore(&cpufreq_driver_lock, flags);
- ret = cpufreq_add_policy_cpu(policy, cpu, dev);
-- up_read(&cpufreq_rwsem);
- return ret;
- }
- }
-@@ -1269,8 +1243,6 @@
-
- kobject_uevent(&policy->kobj, KOBJ_ADD);
-
-- up_read(&cpufreq_rwsem);
--
- /* Callback for handling stuff after policy is ready */
- if (cpufreq_driver->ready)
- cpufreq_driver->ready(policy);
-@@ -1304,8 +1276,6 @@
- cpufreq_policy_free(policy);
-
- nomem_out:
-- up_read(&cpufreq_rwsem);
--
- return ret;
- }
-
-@@ -2499,19 +2469,20 @@
-
- pr_debug("unregistering driver %s\n", driver->name);
-
-+ /* Protect against concurrent cpu hotplug */
-+ get_online_cpus();
- subsys_interface_unregister(&cpufreq_interface);
- if (cpufreq_boost_supported())
- cpufreq_sysfs_remove_file(&boost.attr);
-
- unregister_hotcpu_notifier(&cpufreq_cpu_notifier);
-
-- down_write(&cpufreq_rwsem);
- write_lock_irqsave(&cpufreq_driver_lock, flags);
-
- cpufreq_driver = NULL;
-
- write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-- up_write(&cpufreq_rwsem);
-+ put_online_cpus();
-
- return 0;
- }
-diff -Nur linux-4.1.39.orig/drivers/cpufreq/Kconfig.x86 linux-4.1.39/drivers/cpufreq/Kconfig.x86
---- linux-4.1.39.orig/drivers/cpufreq/Kconfig.x86 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/cpufreq/Kconfig.x86 2017-04-18 17:56:30.577395735 +0200
-@@ -123,7 +123,7 @@
-
- config X86_POWERNOW_K8
- tristate "AMD Opteron/Athlon64 PowerNow!"
-- depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ
-+ depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ && !PREEMPT_RT_BASE
- help
- This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors.
- Support for K10 and newer processors is now in acpi-cpufreq.
-diff -Nur linux-4.1.39.orig/drivers/gpio/gpio-omap.c linux-4.1.39/drivers/gpio/gpio-omap.c
---- linux-4.1.39.orig/drivers/gpio/gpio-omap.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpio/gpio-omap.c 2017-04-18 17:56:30.577395735 +0200
-@@ -29,6 +29,7 @@
- #include <linux/platform_data/gpio-omap.h>
-
- #define OFF_MODE 1
-+#define OMAP4_GPIO_DEBOUNCINGTIME_MASK 0xFF
-
- static LIST_HEAD(omap_gpio_list);
-
-@@ -50,14 +51,15 @@
- struct gpio_bank {
- struct list_head node;
- void __iomem *base;
-- u16 irq;
-+ int irq;
- u32 non_wakeup_gpios;
- u32 enabled_non_wakeup_gpios;
- struct gpio_regs context;
- u32 saved_datain;
- u32 level_mask;
- u32 toggle_mask;
-- spinlock_t lock;
-+ raw_spinlock_t lock;
-+ raw_spinlock_t wa_lock;
- struct gpio_chip chip;
- struct clk *dbck;
- u32 mod_usage;
-@@ -67,7 +69,7 @@
- struct device *dev;
- bool is_mpuio;
- bool dbck_flag;
-- bool loses_context;
-+
- bool context_valid;
- int stride;
- u32 width;
-@@ -175,7 +177,7 @@
- static inline void omap_gpio_dbck_enable(struct gpio_bank *bank)
- {
- if (bank->dbck_enable_mask && !bank->dbck_enabled) {
-- clk_prepare_enable(bank->dbck);
-+ clk_enable(bank->dbck);
- bank->dbck_enabled = true;
-
- writel_relaxed(bank->dbck_enable_mask,
-@@ -193,7 +195,7 @@
- */
- writel_relaxed(0, bank->base + bank->regs->debounce_en);
-
-- clk_disable_unprepare(bank->dbck);
-+ clk_disable(bank->dbck);
- bank->dbck_enabled = false;
- }
- }
-@@ -204,8 +206,9 @@
- * @offset: the gpio number on this @bank
- * @debounce: debounce time to use
- *
-- * OMAP's debounce time is in 31us steps so we need
-- * to convert and round up to the closest unit.
-+ * OMAP's debounce time is in 31us steps
-+ * <debounce time> = (GPIO_DEBOUNCINGTIME[7:0].DEBOUNCETIME + 1) x 31
-+ * so we need to convert and round up to the closest unit.
- */
- static void omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset,
- unsigned debounce)
-@@ -213,34 +216,33 @@
- void __iomem *reg;
- u32 val;
- u32 l;
-+ bool enable = !!debounce;
-
- if (!bank->dbck_flag)
- return;
-
-- if (debounce < 32)
-- debounce = 0x01;
-- else if (debounce > 7936)
-- debounce = 0xff;
-- else
-- debounce = (debounce / 0x1f) - 1;
-+ if (enable) {
-+ debounce = DIV_ROUND_UP(debounce, 31) - 1;
-+ debounce &= OMAP4_GPIO_DEBOUNCINGTIME_MASK;
-+ }
-
- l = BIT(offset);
-
-- clk_prepare_enable(bank->dbck);
-+ clk_enable(bank->dbck);
- reg = bank->base + bank->regs->debounce;
- writel_relaxed(debounce, reg);
-
- reg = bank->base + bank->regs->debounce_en;
- val = readl_relaxed(reg);
-
-- if (debounce)
-+ if (enable)
- val |= l;
- else
- val &= ~l;
- bank->dbck_enable_mask = val;
-
- writel_relaxed(val, reg);
-- clk_disable_unprepare(bank->dbck);
-+ clk_disable(bank->dbck);
- /*
- * Enable debounce clock per module.
- * This call is mandatory because in omap_gpio_request() when
-@@ -285,7 +287,7 @@
- bank->context.debounce = 0;
- writel_relaxed(bank->context.debounce, bank->base +
- bank->regs->debounce);
-- clk_disable_unprepare(bank->dbck);
-+ clk_disable(bank->dbck);
- bank->dbck_enabled = false;
- }
- }
-@@ -488,9 +490,6 @@
- unsigned long flags;
- unsigned offset = d->hwirq;
-
-- if (!BANK_USED(bank))
-- pm_runtime_get_sync(bank->dev);
--
- if (type & ~IRQ_TYPE_SENSE_MASK)
- return -EINVAL;
-
-@@ -498,20 +497,28 @@
- (type & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH)))
- return -EINVAL;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- retval = omap_set_gpio_triggering(bank, offset, type);
-+ if (retval) {
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-+ goto error;
-+ }
- omap_gpio_init_irq(bank, offset);
- if (!omap_gpio_is_input(bank, offset)) {
-- spin_unlock_irqrestore(&bank->lock, flags);
-- return -EINVAL;
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-+ retval = -EINVAL;
-+ goto error;
- }
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
- __irq_set_handler_locked(d->irq, handle_level_irq);
- else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
- __irq_set_handler_locked(d->irq, handle_edge_irq);
-
-+ return 0;
-+
-+error:
- return retval;
- }
-
-@@ -626,34 +633,30 @@
- return -EINVAL;
- }
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- if (enable)
- bank->context.wake_en |= gpio_bit;
- else
- bank->context.wake_en &= ~gpio_bit;
-
- writel_relaxed(bank->context.wake_en, bank->base + bank->regs->wkup_en);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
-
--static void omap_reset_gpio(struct gpio_bank *bank, unsigned offset)
--{
-- omap_set_gpio_direction(bank, offset, 1);
-- omap_set_gpio_irqenable(bank, offset, 0);
-- omap_clear_gpio_irqstatus(bank, offset);
-- omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
-- omap_clear_gpio_debounce(bank, offset);
--}
--
- /* Use disable_irq_wake() and enable_irq_wake() functions from drivers */
- static int omap_gpio_wake_enable(struct irq_data *d, unsigned int enable)
- {
- struct gpio_bank *bank = omap_irq_data_get_bank(d);
- unsigned offset = d->hwirq;
-+ int ret;
-+
-+ ret = omap_set_gpio_wakeup(bank, offset, enable);
-+ if (!ret)
-+ ret = irq_set_irq_wake(bank->irq, enable);
-
-- return omap_set_gpio_wakeup(bank, offset, enable);
-+ return ret;
- }
-
- static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
-@@ -668,17 +671,10 @@
- if (!BANK_USED(bank))
- pm_runtime_get_sync(bank->dev);
-
-- spin_lock_irqsave(&bank->lock, flags);
-- /* Set trigger to none. You need to enable the desired trigger with
-- * request_irq() or set_irq_type(). Only do this if the IRQ line has
-- * not already been requested.
-- */
-- if (!LINE_USED(bank->irq_usage, offset)) {
-- omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
-- omap_enable_gpio_module(bank, offset);
-- }
-+ raw_spin_lock_irqsave(&bank->lock, flags);
-+ omap_enable_gpio_module(bank, offset);
- bank->mod_usage |= BIT(offset);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
-@@ -688,11 +684,14 @@
- struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
- unsigned long flags;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- bank->mod_usage &= ~(BIT(offset));
-+ if (!LINE_USED(bank->irq_usage, offset)) {
-+ omap_set_gpio_direction(bank, offset, 1);
-+ omap_clear_gpio_debounce(bank, offset);
-+ }
- omap_disable_gpio_module(bank, offset);
-- omap_reset_gpio(bank, offset);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- /*
- * If this is the last gpio to be freed in the bank,
-@@ -711,29 +710,27 @@
- * line's interrupt handler has been run, we may miss some nested
- * interrupts.
- */
--static void omap_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
-+static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank)
- {
- void __iomem *isr_reg = NULL;
- u32 isr;
- unsigned int bit;
-- struct gpio_bank *bank;
-- int unmasked = 0;
-- struct irq_chip *irqchip = irq_desc_get_chip(desc);
-- struct gpio_chip *chip = irq_get_handler_data(irq);
-+ struct gpio_bank *bank = gpiobank;
-+ unsigned long wa_lock_flags;
-+ unsigned long lock_flags;
-
-- chained_irq_enter(irqchip, desc);
--
-- bank = container_of(chip, struct gpio_bank, chip);
- isr_reg = bank->base + bank->regs->irqstatus;
-- pm_runtime_get_sync(bank->dev);
--
- if (WARN_ON(!isr_reg))
- goto exit;
-
-+ pm_runtime_get_sync(bank->dev);
-+
- while (1) {
- u32 isr_saved, level_mask = 0;
- u32 enabled;
-
-+ raw_spin_lock_irqsave(&bank->lock, lock_flags);
-+
- enabled = omap_get_gpio_irqbank_mask(bank);
- isr_saved = isr = readl_relaxed(isr_reg) & enabled;
-
-@@ -747,12 +744,7 @@
- omap_clear_gpio_irqbank(bank, isr_saved & ~level_mask);
- omap_enable_gpio_irqbank(bank, isr_saved & ~level_mask);
-
-- /* if there is only edge sensitive GPIO pin interrupts
-- configured, we could unmask GPIO bank interrupt immediately */
-- if (!level_mask && !unmasked) {
-- unmasked = 1;
-- chained_irq_exit(irqchip, desc);
-- }
-+ raw_spin_unlock_irqrestore(&bank->lock, lock_flags);
-
- if (!isr)
- break;
-@@ -761,6 +753,7 @@
- bit = __ffs(isr);
- isr &= ~(BIT(bit));
-
-+ raw_spin_lock_irqsave(&bank->lock, lock_flags);
- /*
- * Some chips can't respond to both rising and falling
- * at the same time. If this irq was requested with
-@@ -771,18 +764,20 @@
- if (bank->toggle_mask & (BIT(bit)))
- omap_toggle_gpio_edge_triggering(bank, bit);
-
-+ raw_spin_unlock_irqrestore(&bank->lock, lock_flags);
-+
-+ raw_spin_lock_irqsave(&bank->wa_lock, wa_lock_flags);
-+
- generic_handle_irq(irq_find_mapping(bank->chip.irqdomain,
- bit));
-+
-+ raw_spin_unlock_irqrestore(&bank->wa_lock,
-+ wa_lock_flags);
- }
- }
-- /* if bank has any level sensitive GPIO pin interrupt
-- configured, we must unmask the bank interrupt only after
-- handler(s) are executed in order to avoid spurious bank
-- interrupt */
- exit:
-- if (!unmasked)
-- chained_irq_exit(irqchip, desc);
- pm_runtime_put(bank->dev);
-+ return IRQ_HANDLED;
- }
-
- static unsigned int omap_gpio_irq_startup(struct irq_data *d)
-@@ -791,15 +786,22 @@
- unsigned long flags;
- unsigned offset = d->hwirq;
-
-- if (!BANK_USED(bank))
-- pm_runtime_get_sync(bank->dev);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
-
-- spin_lock_irqsave(&bank->lock, flags);
-- omap_gpio_init_irq(bank, offset);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ if (!LINE_USED(bank->mod_usage, offset))
-+ omap_set_gpio_direction(bank, offset, 1);
-+ else if (!omap_gpio_is_input(bank, offset))
-+ goto err;
-+ omap_enable_gpio_module(bank, offset);
-+ bank->irq_usage |= BIT(offset);
-+
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- omap_gpio_unmask_irq(d);
-
- return 0;
-+err:
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-+ return -EINVAL;
- }
-
- static void omap_gpio_irq_shutdown(struct irq_data *d)
-@@ -808,11 +810,28 @@
- unsigned long flags;
- unsigned offset = d->hwirq;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- bank->irq_usage &= ~(BIT(offset));
-+ omap_set_gpio_irqenable(bank, offset, 0);
-+ omap_clear_gpio_irqstatus(bank, offset);
-+ omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
-+ if (!LINE_USED(bank->mod_usage, offset))
-+ omap_clear_gpio_debounce(bank, offset);
- omap_disable_gpio_module(bank, offset);
-- omap_reset_gpio(bank, offset);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-+}
-+
-+static void omap_gpio_irq_bus_lock(struct irq_data *data)
-+{
-+ struct gpio_bank *bank = omap_irq_data_get_bank(data);
-+
-+ if (!BANK_USED(bank))
-+ pm_runtime_get_sync(bank->dev);
-+}
-+
-+static void gpio_irq_bus_sync_unlock(struct irq_data *data)
-+{
-+ struct gpio_bank *bank = omap_irq_data_get_bank(data);
-
- /*
- * If this is the last IRQ to be freed in the bank,
-@@ -836,10 +855,10 @@
- unsigned offset = d->hwirq;
- unsigned long flags;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- omap_set_gpio_irqenable(bank, offset, 0);
- omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- }
-
- static void omap_gpio_unmask_irq(struct irq_data *d)
-@@ -849,7 +868,7 @@
- u32 trigger = irqd_get_trigger_type(d);
- unsigned long flags;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- if (trigger)
- omap_set_gpio_triggering(bank, offset, trigger);
-
-@@ -861,7 +880,7 @@
- }
-
- omap_set_gpio_irqenable(bank, offset, 1);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- }
-
- /*---------------------------------------------------------------------*/
-@@ -874,9 +893,9 @@
- OMAP_MPUIO_GPIO_MASKIT / bank->stride;
- unsigned long flags;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- writel_relaxed(0xffff & ~bank->context.wake_en, mask_reg);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
-@@ -889,9 +908,9 @@
- OMAP_MPUIO_GPIO_MASKIT / bank->stride;
- unsigned long flags;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- writel_relaxed(bank->context.wake_en, mask_reg);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
-@@ -937,9 +956,9 @@
-
- bank = container_of(chip, struct gpio_bank, chip);
- reg = bank->base + bank->regs->direction;
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- dir = !!(readl_relaxed(reg) & BIT(offset));
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- return dir;
- }
-
-@@ -949,9 +968,9 @@
- unsigned long flags;
-
- bank = container_of(chip, struct gpio_bank, chip);
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- omap_set_gpio_direction(bank, offset, 1);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- return 0;
- }
-
-@@ -973,10 +992,10 @@
- unsigned long flags;
-
- bank = container_of(chip, struct gpio_bank, chip);
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- bank->set_dataout(bank, offset, value);
- omap_set_gpio_direction(bank, offset, 0);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- return 0;
- }
-
-@@ -988,9 +1007,9 @@
-
- bank = container_of(chip, struct gpio_bank, chip);
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- omap2_set_gpio_debounce(bank, offset, debounce);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
-@@ -1001,9 +1020,9 @@
- unsigned long flags;
-
- bank = container_of(chip, struct gpio_bank, chip);
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
- bank->set_dataout(bank, offset, value);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- }
-
- /*---------------------------------------------------------------------*/
-@@ -1048,10 +1067,6 @@
- /* Initialize interface clk ungated, module enabled */
- if (bank->regs->ctrl)
- writel_relaxed(0, base + bank->regs->ctrl);
--
-- bank->dbck = clk_get(bank->dev, "dbclk");
-- if (IS_ERR(bank->dbck))
-- dev_err(bank->dev, "Could not get gpio dbck\n");
- }
-
- static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc)
-@@ -1080,7 +1095,6 @@
- } else {
- bank->chip.label = "gpio";
- bank->chip.base = gpio;
-- gpio += bank->width;
- }
- bank->chip.ngpio = bank->width;
-
-@@ -1090,6 +1104,9 @@
- return ret;
- }
-
-+ if (!bank->is_mpuio)
-+ gpio += bank->width;
-+
- #ifdef CONFIG_ARCH_OMAP1
- /*
- * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop
-@@ -1112,7 +1129,7 @@
- }
-
- ret = gpiochip_irqchip_add(&bank->chip, irqc,
-- irq_base, omap_gpio_irq_handler,
-+ irq_base, handle_bad_irq,
- IRQ_TYPE_NONE);
-
- if (ret) {
-@@ -1121,10 +1138,14 @@
- return -ENODEV;
- }
-
-- gpiochip_set_chained_irqchip(&bank->chip, irqc,
-- bank->irq, omap_gpio_irq_handler);
-+ gpiochip_set_chained_irqchip(&bank->chip, irqc, bank->irq, NULL);
-
-- return 0;
-+ ret = devm_request_irq(bank->dev, bank->irq, omap_gpio_irq_handler,
-+ 0, dev_name(bank->dev), bank);
-+ if (ret)
-+ gpiochip_remove(&bank->chip);
-+
-+ return ret;
- }
-
- static const struct of_device_id omap_gpio_match[];
-@@ -1163,17 +1184,23 @@
- irqc->irq_unmask = omap_gpio_unmask_irq,
- irqc->irq_set_type = omap_gpio_irq_type,
- irqc->irq_set_wake = omap_gpio_wake_enable,
-+ irqc->irq_bus_lock = omap_gpio_irq_bus_lock,
-+ irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
- irqc->name = dev_name(&pdev->dev);
-
-- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-- if (unlikely(!res)) {
-- dev_err(dev, "Invalid IRQ resource\n");
-- return -ENODEV;
-+ bank->irq = platform_get_irq(pdev, 0);
-+ if (bank->irq <= 0) {
-+ if (!bank->irq)
-+ bank->irq = -ENXIO;
-+ if (bank->irq != -EPROBE_DEFER)
-+ dev_err(dev,
-+ "can't get irq resource ret=%d\n", bank->irq);
-+ return bank->irq;
- }
-
-- bank->irq = res->start;
- bank->dev = dev;
- bank->chip.dev = dev;
-+ bank->chip.owner = THIS_MODULE;
- bank->dbck_flag = pdata->dbck_flag;
- bank->stride = pdata->bank_stride;
- bank->width = pdata->bank_width;
-@@ -1183,15 +1210,9 @@
- #ifdef CONFIG_OF_GPIO
- bank->chip.of_node = of_node_get(node);
- #endif
-- if (node) {
-- if (!of_property_read_bool(node, "ti,gpio-always-on"))
-- bank->loses_context = true;
-- } else {
-- bank->loses_context = pdata->loses_context;
--
-- if (bank->loses_context)
-- bank->get_context_loss_count =
-- pdata->get_context_loss_count;
-+ if (!node) {
-+ bank->get_context_loss_count =
-+ pdata->get_context_loss_count;
- }
-
- if (bank->regs->set_dataout && bank->regs->clr_dataout)
-@@ -1199,16 +1220,27 @@
- else
- bank->set_dataout = omap_set_gpio_dataout_mask;
-
-- spin_lock_init(&bank->lock);
-+ raw_spin_lock_init(&bank->lock);
-+ raw_spin_lock_init(&bank->wa_lock);
-
- /* Static mapping, never released */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- bank->base = devm_ioremap_resource(dev, res);
- if (IS_ERR(bank->base)) {
-- irq_domain_remove(bank->chip.irqdomain);
- return PTR_ERR(bank->base);
- }
-
-+ if (bank->dbck_flag) {
-+ bank->dbck = devm_clk_get(bank->dev, "dbclk");
-+ if (IS_ERR(bank->dbck)) {
-+ dev_err(bank->dev,
-+ "Could not get gpio dbck. Disable debounce\n");
-+ bank->dbck_flag = false;
-+ } else {
-+ clk_prepare(bank->dbck);
-+ }
-+ }
-+
- platform_set_drvdata(pdev, bank);
-
- pm_runtime_enable(bank->dev);
-@@ -1221,8 +1253,11 @@
- omap_gpio_mod_init(bank);
-
- ret = omap_gpio_chip_init(bank, irqc);
-- if (ret)
-+ if (ret) {
-+ pm_runtime_put_sync(bank->dev);
-+ pm_runtime_disable(bank->dev);
- return ret;
-+ }
-
- omap_gpio_show_rev(bank);
-
-@@ -1233,6 +1268,19 @@
- return 0;
- }
-
-+static int omap_gpio_remove(struct platform_device *pdev)
-+{
-+ struct gpio_bank *bank = platform_get_drvdata(pdev);
-+
-+ list_del(&bank->node);
-+ gpiochip_remove(&bank->chip);
-+ pm_runtime_disable(bank->dev);
-+ if (bank->dbck_flag)
-+ clk_unprepare(bank->dbck);
-+
-+ return 0;
-+}
-+
- #ifdef CONFIG_ARCH_OMAP2PLUS
-
- #if defined(CONFIG_PM)
-@@ -1246,7 +1294,7 @@
- unsigned long flags;
- u32 wake_low, wake_hi;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
-
- /*
- * Only edges can generate a wakeup event to the PRCM.
-@@ -1299,7 +1347,7 @@
- bank->get_context_loss_count(bank->dev);
-
- omap_gpio_dbck_disable(bank);
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
-@@ -1314,14 +1362,14 @@
- unsigned long flags;
- int c;
-
-- spin_lock_irqsave(&bank->lock, flags);
-+ raw_spin_lock_irqsave(&bank->lock, flags);
-
- /*
- * On the first resume during the probe, the context has not
- * been initialised and so initialise it now. Also initialise
- * the context loss count.
- */
-- if (bank->loses_context && !bank->context_valid) {
-+ if (!bank->context_valid) {
- omap_gpio_init_context(bank);
-
- if (bank->get_context_loss_count)
-@@ -1342,22 +1390,20 @@
- writel_relaxed(bank->context.risingdetect,
- bank->base + bank->regs->risingdetect);
-
-- if (bank->loses_context) {
-- if (!bank->get_context_loss_count) {
-+ if (!bank->get_context_loss_count) {
-+ omap_gpio_restore_context(bank);
-+ } else {
-+ c = bank->get_context_loss_count(bank->dev);
-+ if (c != bank->context_loss_count) {
- omap_gpio_restore_context(bank);
- } else {
-- c = bank->get_context_loss_count(bank->dev);
-- if (c != bank->context_loss_count) {
-- omap_gpio_restore_context(bank);
-- } else {
-- spin_unlock_irqrestore(&bank->lock, flags);
-- return 0;
-- }
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-+ return 0;
- }
- }
-
- if (!bank->workaround_enabled) {
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
- return 0;
- }
-
-@@ -1412,18 +1458,19 @@
- }
-
- bank->workaround_enabled = false;
-- spin_unlock_irqrestore(&bank->lock, flags);
-+ raw_spin_unlock_irqrestore(&bank->lock, flags);
-
- return 0;
- }
- #endif /* CONFIG_PM */
-
-+#if IS_BUILTIN(CONFIG_GPIO_OMAP)
- void omap2_gpio_prepare_for_idle(int pwr_mode)
- {
- struct gpio_bank *bank;
-
- list_for_each_entry(bank, &omap_gpio_list, node) {
-- if (!BANK_USED(bank) || !bank->loses_context)
-+ if (!BANK_USED(bank))
- continue;
-
- bank->power_mode = pwr_mode;
-@@ -1437,12 +1484,13 @@
- struct gpio_bank *bank;
-
- list_for_each_entry(bank, &omap_gpio_list, node) {
-- if (!BANK_USED(bank) || !bank->loses_context)
-+ if (!BANK_USED(bank))
- continue;
-
- pm_runtime_get_sync(bank->dev);
- }
- }
-+#endif
-
- #if defined(CONFIG_PM)
- static void omap_gpio_init_context(struct gpio_bank *p)
-@@ -1598,6 +1646,7 @@
-
- static struct platform_driver omap_gpio_driver = {
- .probe = omap_gpio_probe,
-+ .remove = omap_gpio_remove,
- .driver = {
- .name = "omap_gpio",
- .pm = &gpio_pm_ops,
-@@ -1615,3 +1664,13 @@
- return platform_driver_register(&omap_gpio_driver);
- }
- postcore_initcall(omap_gpio_drv_reg);
-+
-+static void __exit omap_gpio_exit(void)
-+{
-+ platform_driver_unregister(&omap_gpio_driver);
-+}
-+module_exit(omap_gpio_exit);
-+
-+MODULE_DESCRIPTION("omap gpio driver");
-+MODULE_ALIAS("platform:gpio-omap");
-+MODULE_LICENSE("GPL v2");
-diff -Nur linux-4.1.39.orig/drivers/gpio/Kconfig linux-4.1.39/drivers/gpio/Kconfig
---- linux-4.1.39.orig/drivers/gpio/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpio/Kconfig 2017-04-18 17:56:30.577395735 +0200
-@@ -309,7 +309,7 @@
- family of SOCs.
-
- config GPIO_OMAP
-- bool "TI OMAP GPIO support" if COMPILE_TEST && !ARCH_OMAP2PLUS
-+ tristate "TI OMAP GPIO support" if ARCH_OMAP2PLUS || COMPILE_TEST
- default y if ARCH_OMAP
- depends on ARM
- select GENERIC_IRQ_CHIP
-diff -Nur linux-4.1.39.orig/drivers/gpu/drm/i915/i915_gem_execbuffer.c linux-4.1.39/drivers/gpu/drm/i915/i915_gem_execbuffer.c
---- linux-4.1.39.orig/drivers/gpu/drm/i915/i915_gem_execbuffer.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpu/drm/i915/i915_gem_execbuffer.c 2017-04-18 17:56:30.577395735 +0200
-@@ -32,6 +32,7 @@
- #include "i915_trace.h"
- #include "intel_drv.h"
- #include <linux/dma_remapping.h>
-+#include <linux/uaccess.h>
-
- #define __EXEC_OBJECT_HAS_PIN (1<<31)
- #define __EXEC_OBJECT_HAS_FENCE (1<<30)
-@@ -465,7 +466,7 @@
- }
-
- /* We can't wait for rendering with pagefaults disabled */
-- if (obj->active && in_atomic())
-+ if (obj->active && pagefault_disabled())
- return -EFAULT;
-
- if (use_cpu_reloc(obj))
-@@ -1338,7 +1339,9 @@
- return ret;
- }
-
-+#ifndef CONFIG_PREEMPT_RT_BASE
- trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
-+#endif
-
- i915_gem_execbuffer_move_to_active(vmas, ring);
- i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
-diff -Nur linux-4.1.39.orig/drivers/gpu/drm/i915/i915_gem_shrinker.c linux-4.1.39/drivers/gpu/drm/i915/i915_gem_shrinker.c
---- linux-4.1.39.orig/drivers/gpu/drm/i915/i915_gem_shrinker.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpu/drm/i915/i915_gem_shrinker.c 2017-04-18 17:56:30.577395735 +0200
-@@ -39,7 +39,7 @@
- if (!mutex_is_locked(mutex))
- return false;
-
--#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
-+#if (defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)) && !defined(CONFIG_PREEMPT_RT_BASE)
- return mutex->owner == task;
- #else
- /* Since UP may be pre-empted, we cannot assume that we own the lock */
-diff -Nur linux-4.1.39.orig/drivers/gpu/drm/i915/i915_irq.c linux-4.1.39/drivers/gpu/drm/i915/i915_irq.c
---- linux-4.1.39.orig/drivers/gpu/drm/i915/i915_irq.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpu/drm/i915/i915_irq.c 2017-04-18 17:56:30.581395889 +0200
-@@ -676,6 +676,7 @@
- spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
-
- /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
-+ preempt_disable_rt();
-
- /* Get optional system timestamp before query. */
- if (stime)
-@@ -727,6 +728,7 @@
- *etime = ktime_get();
-
- /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
-+ preempt_enable_rt();
-
- spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
-
-diff -Nur linux-4.1.39.orig/drivers/gpu/drm/i915/intel_display.c linux-4.1.39/drivers/gpu/drm/i915/intel_display.c
---- linux-4.1.39.orig/drivers/gpu/drm/i915/intel_display.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpu/drm/i915/intel_display.c 2017-04-18 17:56:30.581395889 +0200
-@@ -10084,7 +10084,7 @@
- struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
- struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-- WARN_ON(!in_interrupt());
-+ WARN_ON_NONRT(!in_interrupt());
-
- if (crtc == NULL)
- return;
-diff -Nur linux-4.1.39.orig/drivers/gpu/drm/i915/intel_sprite.c linux-4.1.39/drivers/gpu/drm/i915/intel_sprite.c
---- linux-4.1.39.orig/drivers/gpu/drm/i915/intel_sprite.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpu/drm/i915/intel_sprite.c 2017-04-18 17:56:30.581395889 +0200
-@@ -37,6 +37,7 @@
- #include "intel_drv.h"
- #include <drm/i915_drm.h>
- #include "i915_drv.h"
-+#include <linux/locallock.h>
-
- static bool
- format_is_yuv(uint32_t format)
-@@ -61,6 +62,8 @@
- return DIV_ROUND_UP(usecs * mode->crtc_clock, 1000 * mode->crtc_htotal);
- }
-
-+static DEFINE_LOCAL_IRQ_LOCK(pipe_update_lock);
-+
- /**
- * intel_pipe_update_start() - start update of a set of display registers
- * @crtc: the crtc of which the registers are going to be updated
-@@ -101,7 +104,7 @@
- if (WARN_ON(drm_crtc_vblank_get(&crtc->base)))
- return false;
-
-- local_irq_disable();
-+ local_lock_irq(pipe_update_lock);
-
- trace_i915_pipe_update_start(crtc, min, max);
-
-@@ -123,11 +126,11 @@
- break;
- }
-
-- local_irq_enable();
-+ local_unlock_irq(pipe_update_lock);
-
- timeout = schedule_timeout(timeout);
-
-- local_irq_disable();
-+ local_lock_irq(pipe_update_lock);
- }
-
- finish_wait(wq, &wait);
-@@ -158,7 +161,7 @@
-
- trace_i915_pipe_update_end(crtc, end_vbl_count);
-
-- local_irq_enable();
-+ local_unlock_irq(pipe_update_lock);
-
- if (start_vbl_count != end_vbl_count)
- DRM_ERROR("Atomic update failure on pipe %c (start=%u end=%u)\n",
-diff -Nur linux-4.1.39.orig/drivers/gpu/drm/radeon/radeon_display.c linux-4.1.39/drivers/gpu/drm/radeon/radeon_display.c
---- linux-4.1.39.orig/drivers/gpu/drm/radeon/radeon_display.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/gpu/drm/radeon/radeon_display.c 2017-04-18 17:56:30.581395889 +0200
-@@ -1798,6 +1798,7 @@
- struct radeon_device *rdev = dev->dev_private;
-
- /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
-+ preempt_disable_rt();
-
- /* Get optional system timestamp before query. */
- if (stime)
-@@ -1890,6 +1891,7 @@
- *etime = ktime_get();
-
- /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
-+ preempt_enable_rt();
-
- /* Decode into vertical and horizontal scanout position. */
- *vpos = position & 0x1fff;
-diff -Nur linux-4.1.39.orig/drivers/i2c/busses/i2c-omap.c linux-4.1.39/drivers/i2c/busses/i2c-omap.c
---- linux-4.1.39.orig/drivers/i2c/busses/i2c-omap.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/i2c/busses/i2c-omap.c 2017-04-18 17:56:30.581395889 +0200
-@@ -996,15 +996,12 @@
- u16 mask;
- u16 stat;
-
-- spin_lock(&dev->lock);
-- mask = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
- stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
-+ mask = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
-
- if (stat & mask)
- ret = IRQ_WAKE_THREAD;
-
-- spin_unlock(&dev->lock);
--
- return ret;
- }
-
-diff -Nur linux-4.1.39.orig/drivers/ide/alim15x3.c linux-4.1.39/drivers/ide/alim15x3.c
---- linux-4.1.39.orig/drivers/ide/alim15x3.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/alim15x3.c 2017-04-18 17:56:30.581395889 +0200
-@@ -234,7 +234,7 @@
-
- isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
-
- if (m5229_revision < 0xC2) {
- /*
-@@ -325,7 +325,7 @@
- }
- pci_dev_put(north);
- pci_dev_put(isa_dev);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- return 0;
- }
-
-diff -Nur linux-4.1.39.orig/drivers/ide/hpt366.c linux-4.1.39/drivers/ide/hpt366.c
---- linux-4.1.39.orig/drivers/ide/hpt366.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/hpt366.c 2017-04-18 17:56:30.581395889 +0200
-@@ -1241,7 +1241,7 @@
-
- dma_old = inb(base + 2);
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
-
- dma_new = dma_old;
- pci_read_config_byte(dev, hwif->channel ? 0x4b : 0x43, &masterdma);
-@@ -1252,7 +1252,7 @@
- if (dma_new != dma_old)
- outb(dma_new, base + 2);
-
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n",
- hwif->name, base, base + 7);
-diff -Nur linux-4.1.39.orig/drivers/ide/ide-io.c linux-4.1.39/drivers/ide/ide-io.c
---- linux-4.1.39.orig/drivers/ide/ide-io.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/ide-io.c 2017-04-18 17:56:30.581395889 +0200
-@@ -659,7 +659,7 @@
- /* disable_irq_nosync ?? */
- disable_irq(hwif->irq);
- /* local CPU only, as if we were handling an interrupt */
-- local_irq_disable();
-+ local_irq_disable_nort();
- if (hwif->polling) {
- startstop = handler(drive);
- } else if (drive_is_ready(drive)) {
-diff -Nur linux-4.1.39.orig/drivers/ide/ide-iops.c linux-4.1.39/drivers/ide/ide-iops.c
---- linux-4.1.39.orig/drivers/ide/ide-iops.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/ide-iops.c 2017-04-18 17:56:30.585396045 +0200
-@@ -129,12 +129,12 @@
- if ((stat & ATA_BUSY) == 0)
- break;
-
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- *rstat = stat;
- return -EBUSY;
- }
- }
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- }
- /*
- * Allow status to settle, then read it again.
-diff -Nur linux-4.1.39.orig/drivers/ide/ide-io-std.c linux-4.1.39/drivers/ide/ide-io-std.c
---- linux-4.1.39.orig/drivers/ide/ide-io-std.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/ide-io-std.c 2017-04-18 17:56:30.581395889 +0200
-@@ -175,7 +175,7 @@
- unsigned long uninitialized_var(flags);
-
- if ((io_32bit & 2) && !mmio) {
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- ata_vlb_sync(io_ports->nsect_addr);
- }
-
-@@ -186,7 +186,7 @@
- insl(data_addr, buf, words);
-
- if ((io_32bit & 2) && !mmio)
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- if (((len + 1) & 3) < 2)
- return;
-@@ -219,7 +219,7 @@
- unsigned long uninitialized_var(flags);
-
- if ((io_32bit & 2) && !mmio) {
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- ata_vlb_sync(io_ports->nsect_addr);
- }
-
-@@ -230,7 +230,7 @@
- outsl(data_addr, buf, words);
-
- if ((io_32bit & 2) && !mmio)
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- if (((len + 1) & 3) < 2)
- return;
-diff -Nur linux-4.1.39.orig/drivers/ide/ide-probe.c linux-4.1.39/drivers/ide/ide-probe.c
---- linux-4.1.39.orig/drivers/ide/ide-probe.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/ide-probe.c 2017-04-18 17:56:30.585396045 +0200
-@@ -196,10 +196,10 @@
- int bswap = 1;
-
- /* local CPU only; some systems need this */
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- /* read 512 bytes of id info */
- hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- drive->dev_flags |= IDE_DFLAG_ID_READ;
- #ifdef DEBUG
-diff -Nur linux-4.1.39.orig/drivers/ide/ide-taskfile.c linux-4.1.39/drivers/ide/ide-taskfile.c
---- linux-4.1.39.orig/drivers/ide/ide-taskfile.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/ide/ide-taskfile.c 2017-04-18 17:56:30.585396045 +0200
-@@ -250,7 +250,7 @@
-
- page_is_high = PageHighMem(page);
- if (page_is_high)
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
-
- buf = kmap_atomic(page) + offset;
-
-@@ -271,7 +271,7 @@
- kunmap_atomic(buf);
-
- if (page_is_high)
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- len -= nr_bytes;
- }
-@@ -414,7 +414,7 @@
- }
-
- if ((drive->dev_flags & IDE_DFLAG_UNMASK) == 0)
-- local_irq_disable();
-+ local_irq_disable_nort();
-
- ide_set_handler(drive, &task_pio_intr, WAIT_WORSTCASE);
-
-diff -Nur linux-4.1.39.orig/drivers/infiniband/ulp/ipoib/ipoib_multicast.c linux-4.1.39/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
---- linux-4.1.39.orig/drivers/infiniband/ulp/ipoib/ipoib_multicast.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/infiniband/ulp/ipoib/ipoib_multicast.c 2017-04-18 17:56:30.585396045 +0200
-@@ -824,7 +824,7 @@
-
- ipoib_dbg_mcast(priv, "restarting multicast task\n");
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- netif_addr_lock(dev);
- spin_lock(&priv->lock);
-
-@@ -906,7 +906,7 @@
-
- spin_unlock(&priv->lock);
- netif_addr_unlock(dev);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- /*
- * make sure the in-flight joins have finished before we attempt
-diff -Nur linux-4.1.39.orig/drivers/input/gameport/gameport.c linux-4.1.39/drivers/input/gameport/gameport.c
---- linux-4.1.39.orig/drivers/input/gameport/gameport.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/input/gameport/gameport.c 2017-04-18 17:56:30.585396045 +0200
-@@ -124,12 +124,12 @@
- tx = 1 << 30;
-
- for(i = 0; i < 50; i++) {
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- GET_TIME(t1);
- for (t = 0; t < 50; t++) gameport_read(gameport);
- GET_TIME(t2);
- GET_TIME(t3);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- udelay(i * 10);
- if ((t = DELTA(t2,t1) - DELTA(t3,t2)) < tx) tx = t;
- }
-@@ -148,11 +148,11 @@
- tx = 1 << 30;
-
- for(i = 0; i < 50; i++) {
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- rdtscl(t1);
- for (t = 0; t < 50; t++) gameport_read(gameport);
- rdtscl(t2);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- udelay(i * 10);
- if (t2 - t1 < tx) tx = t2 - t1;
- }
-diff -Nur linux-4.1.39.orig/drivers/leds/trigger/Kconfig linux-4.1.39/drivers/leds/trigger/Kconfig
---- linux-4.1.39.orig/drivers/leds/trigger/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/leds/trigger/Kconfig 2017-04-18 17:56:30.585396045 +0200
-@@ -61,7 +61,7 @@
-
- config LEDS_TRIGGER_CPU
- bool "LED CPU Trigger"
-- depends on LEDS_TRIGGERS
-+ depends on LEDS_TRIGGERS && !PREEMPT_RT_BASE
- help
- This allows LEDs to be controlled by active CPUs. This shows
- the active CPUs across an array of LEDs so you can see which
-diff -Nur linux-4.1.39.orig/drivers/md/bcache/Kconfig linux-4.1.39/drivers/md/bcache/Kconfig
---- linux-4.1.39.orig/drivers/md/bcache/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/md/bcache/Kconfig 2017-04-18 17:56:30.585396045 +0200
-@@ -1,6 +1,7 @@
-
- config BCACHE
- tristate "Block device as cache"
-+ depends on !PREEMPT_RT_FULL
- ---help---
- Allows a block device to be used as cache for other devices; uses
- a btree for indexing and the layout is optimized for SSDs.
-diff -Nur linux-4.1.39.orig/drivers/md/dm.c linux-4.1.39/drivers/md/dm.c
---- linux-4.1.39.orig/drivers/md/dm.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/md/dm.c 2017-04-18 17:56:30.585396045 +0200
-@@ -2141,7 +2141,7 @@
- /* Establish tio->ti before queuing work (map_tio_request) */
- tio->ti = ti;
- queue_kthread_work(&md->kworker, &tio->work);
-- BUG_ON(!irqs_disabled());
-+ BUG_ON_NONRT(!irqs_disabled());
- }
-
- goto out;
-diff -Nur linux-4.1.39.orig/drivers/md/raid5.c linux-4.1.39/drivers/md/raid5.c
---- linux-4.1.39.orig/drivers/md/raid5.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/md/raid5.c 2017-04-18 17:56:30.585396045 +0200
-@@ -1918,8 +1918,9 @@
- struct raid5_percpu *percpu;
- unsigned long cpu;
-
-- cpu = get_cpu();
-+ cpu = get_cpu_light();
- percpu = per_cpu_ptr(conf->percpu, cpu);
-+ spin_lock(&percpu->lock);
- if (test_bit(STRIPE_OP_BIOFILL, &ops_request)) {
- ops_run_biofill(sh);
- overlap_clear++;
-@@ -1975,7 +1976,8 @@
- if (test_and_clear_bit(R5_Overlap, &dev->flags))
- wake_up(&sh->raid_conf->wait_for_overlap);
- }
-- put_cpu();
-+ spin_unlock(&percpu->lock);
-+ put_cpu_light();
- }
-
- static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp)
-@@ -6375,6 +6377,7 @@
- __func__, cpu);
- break;
- }
-+ spin_lock_init(&per_cpu_ptr(conf->percpu, cpu)->lock);
- }
- put_online_cpus();
-
-diff -Nur linux-4.1.39.orig/drivers/md/raid5.h linux-4.1.39/drivers/md/raid5.h
---- linux-4.1.39.orig/drivers/md/raid5.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/md/raid5.h 2017-04-18 17:56:30.585396045 +0200
-@@ -495,6 +495,7 @@
- int recovery_disabled;
- /* per cpu variables */
- struct raid5_percpu {
-+ spinlock_t lock; /* Protection for -RT */
- struct page *spare_page; /* Used when checking P/Q in raid6 */
- struct flex_array *scribble; /* space for constructing buffer
- * lists and performing address
-diff -Nur linux-4.1.39.orig/drivers/misc/hwlat_detector.c linux-4.1.39/drivers/misc/hwlat_detector.c
---- linux-4.1.39.orig/drivers/misc/hwlat_detector.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.39/drivers/misc/hwlat_detector.c 2017-04-18 17:56:30.585396045 +0200
-@@ -0,0 +1,1240 @@
-+/*
-+ * hwlat_detector.c - A simple Hardware Latency detector.
-+ *
-+ * Use this module to detect large system latencies induced by the behavior of
-+ * certain underlying system hardware or firmware, independent of Linux itself.
-+ * The code was developed originally to detect the presence of SMIs on Intel
-+ * and AMD systems, although there is no dependency upon x86 herein.
-+ *
-+ * The classical example usage of this module is in detecting the presence of
-+ * SMIs or System Management Interrupts on Intel and AMD systems. An SMI is a
-+ * somewhat special form of hardware interrupt spawned from earlier CPU debug
-+ * modes in which the (BIOS/EFI/etc.) firmware arranges for the South Bridge
-+ * LPC (or other device) to generate a special interrupt under certain
-+ * circumstances, for example, upon expiration of a special SMI timer device,
-+ * due to certain external thermal readings, on certain I/O address accesses,
-+ * and other situations. An SMI hits a special CPU pin, triggers a special
-+ * SMI mode (complete with special memory map), and the OS is unaware.
-+ *
-+ * Although certain hardware-inducing latencies are necessary (for example,
-+ * a modern system often requires an SMI handler for correct thermal control
-+ * and remote management) they can wreak havoc upon any OS-level performance
-+ * guarantees toward low-latency, especially when the OS is not even made
-+ * aware of the presence of these interrupts. For this reason, we need a
-+ * somewhat brute force mechanism to detect these interrupts. In this case,
-+ * we do it by hogging all of the CPU(s) for configurable timer intervals,
-+ * sampling the built-in CPU timer, looking for discontiguous readings.
-+ *
-+ * WARNING: This implementation necessarily introduces latencies. Therefore,
-+ * you should NEVER use this module in a production environment
-+ * requiring any kind of low-latency performance guarantee(s).
-+ *
-+ * Copyright (C) 2008-2009 Jon Masters, Red Hat, Inc. <jcm@redhat.com>
-+ *
-+ * Includes useful feedback from Clark Williams <clark@redhat.com>
-+ *
-+ * This file is licensed under the terms of the GNU General Public
-+ * License version 2. This program is licensed "as is" without any
-+ * warranty of any kind, whether express or implied.
-+ */
-+
-+#include <linux/module.h>
-+#include <linux/init.h>
-+#include <linux/ring_buffer.h>
-+#include <linux/time.h>
-+#include <linux/hrtimer.h>
-+#include <linux/kthread.h>
-+#include <linux/debugfs.h>
-+#include <linux/seq_file.h>
-+#include <linux/uaccess.h>
-+#include <linux/version.h>
-+#include <linux/delay.h>
-+#include <linux/slab.h>
-+#include <linux/trace_clock.h>
-+
-+#define BUF_SIZE_DEFAULT 262144UL /* 8K*(sizeof(entry)) */
-+#define BUF_FLAGS (RB_FL_OVERWRITE) /* no block on full */
-+#define U64STR_SIZE 22 /* 20 digits max */
-+
-+#define VERSION "1.0.0"
-+#define BANNER "hwlat_detector: "
-+#define DRVNAME "hwlat_detector"
-+#define DEFAULT_SAMPLE_WINDOW 1000000 /* 1s */
-+#define DEFAULT_SAMPLE_WIDTH 500000 /* 0.5s */
-+#define DEFAULT_LAT_THRESHOLD 10 /* 10us */
-+
-+/* Module metadata */
-+
-+MODULE_LICENSE("GPL");
-+MODULE_AUTHOR("Jon Masters <jcm@redhat.com>");
-+MODULE_DESCRIPTION("A simple hardware latency detector");
-+MODULE_VERSION(VERSION);
-+
-+/* Module parameters */
-+
-+static int debug;
-+static int enabled;
-+static int threshold;
-+
-+module_param(debug, int, 0); /* enable debug */
-+module_param(enabled, int, 0); /* enable detector */
-+module_param(threshold, int, 0); /* latency threshold */
-+
-+/* Buffering and sampling */
-+
-+static struct ring_buffer *ring_buffer; /* sample buffer */
-+static DEFINE_MUTEX(ring_buffer_mutex); /* lock changes */
-+static unsigned long buf_size = BUF_SIZE_DEFAULT;
-+static struct task_struct *kthread; /* sampling thread */
-+
-+/* DebugFS filesystem entries */
-+
-+static struct dentry *debug_dir; /* debugfs directory */
-+static struct dentry *debug_max; /* maximum TSC delta */
-+static struct dentry *debug_count; /* total detect count */
-+static struct dentry *debug_sample_width; /* sample width us */
-+static struct dentry *debug_sample_window; /* sample window us */
-+static struct dentry *debug_sample; /* raw samples us */
-+static struct dentry *debug_threshold; /* threshold us */
-+static struct dentry *debug_enable; /* enable/disable */
-+
-+/* Individual samples and global state */
-+
-+struct sample; /* latency sample */
-+struct data; /* Global state */
-+
-+/* Sampling functions */
-+static int __buffer_add_sample(struct sample *sample);
-+static struct sample *buffer_get_sample(struct sample *sample);
-+
-+/* Threading and state */
-+static int kthread_fn(void *unused);
-+static int start_kthread(void);
-+static int stop_kthread(void);
-+static void __reset_stats(void);
-+static int init_stats(void);
-+
-+/* Debugfs interface */
-+static ssize_t simple_data_read(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos, const u64 *entry);
-+static ssize_t simple_data_write(struct file *filp, const char __user *ubuf,
-+ size_t cnt, loff_t *ppos, u64 *entry);
-+static int debug_sample_fopen(struct inode *inode, struct file *filp);
-+static ssize_t debug_sample_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos);
-+static int debug_sample_release(struct inode *inode, struct file *filp);
-+static int debug_enable_fopen(struct inode *inode, struct file *filp);
-+static ssize_t debug_enable_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos);
-+static ssize_t debug_enable_fwrite(struct file *file,
-+ const char __user *user_buffer,
-+ size_t user_size, loff_t *offset);
-+
-+/* Initialization functions */
-+static int init_debugfs(void);
-+static void free_debugfs(void);
-+static int detector_init(void);
-+static void detector_exit(void);
-+
-+/* Individual latency samples are stored here when detected and packed into
-+ * the ring_buffer circular buffer, where they are overwritten when
-+ * more than buf_size/sizeof(sample) samples are received. */
-+struct sample {
-+ u64 seqnum; /* unique sequence */
-+ u64 duration; /* ktime delta */
-+ u64 outer_duration; /* ktime delta (outer loop) */
-+ struct timespec timestamp; /* wall time */
-+ unsigned long lost;
-+};
-+
-+/* keep the global state somewhere. */
-+static struct data {
-+
-+ struct mutex lock; /* protect changes */
-+
-+ u64 count; /* total since reset */
-+ u64 max_sample; /* max hardware latency */
-+ u64 threshold; /* sample threshold level */
-+
-+ u64 sample_window; /* total sampling window (on+off) */
-+ u64 sample_width; /* active sampling portion of window */
-+
-+ atomic_t sample_open; /* whether the sample file is open */
-+
-+ wait_queue_head_t wq; /* waitqeue for new sample values */
-+
-+} data;
-+
-+/**
-+ * __buffer_add_sample - add a new latency sample recording to the ring buffer
-+ * @sample: The new latency sample value
-+ *
-+ * This receives a new latency sample and records it in a global ring buffer.
-+ * No additional locking is used in this case.
-+ */
-+static int __buffer_add_sample(struct sample *sample)
-+{
-+ return ring_buffer_write(ring_buffer,
-+ sizeof(struct sample), sample);
-+}
-+
-+/**
-+ * buffer_get_sample - remove a hardware latency sample from the ring buffer
-+ * @sample: Pre-allocated storage for the sample
-+ *
-+ * This retrieves a hardware latency sample from the global circular buffer
-+ */
-+static struct sample *buffer_get_sample(struct sample *sample)
-+{
-+ struct ring_buffer_event *e = NULL;
-+ struct sample *s = NULL;
-+ unsigned int cpu = 0;
-+
-+ if (!sample)
-+ return NULL;
-+
-+ mutex_lock(&ring_buffer_mutex);
-+ for_each_online_cpu(cpu) {
-+ e = ring_buffer_consume(ring_buffer, cpu, NULL, &sample->lost);
-+ if (e)
-+ break;
-+ }
-+
-+ if (e) {
-+ s = ring_buffer_event_data(e);
-+ memcpy(sample, s, sizeof(struct sample));
-+ } else
-+ sample = NULL;
-+ mutex_unlock(&ring_buffer_mutex);
-+
-+ return sample;
-+}
-+
-+#ifndef CONFIG_TRACING
-+#define time_type ktime_t
-+#define time_get() ktime_get()
-+#define time_to_us(x) ktime_to_us(x)
-+#define time_sub(a, b) ktime_sub(a, b)
-+#define init_time(a, b) (a).tv64 = b
-+#define time_u64(a) ((a).tv64)
-+#else
-+#define time_type u64
-+#define time_get() trace_clock_local()
-+#define time_to_us(x) div_u64(x, 1000)
-+#define time_sub(a, b) ((a) - (b))
-+#define init_time(a, b) (a = b)
-+#define time_u64(a) a
-+#endif
-+/**
-+ * get_sample - sample the CPU TSC and look for likely hardware latencies
-+ *
-+ * Used to repeatedly capture the CPU TSC (or similar), looking for potential
-+ * hardware-induced latency. Called with interrupts disabled and with
-+ * data.lock held.
-+ */
-+static int get_sample(void)
-+{
-+ time_type start, t1, t2, last_t2;
-+ s64 diff, total = 0;
-+ u64 sample = 0;
-+ u64 outer_sample = 0;
-+ int ret = -1;
-+
-+ init_time(last_t2, 0);
-+ start = time_get(); /* start timestamp */
-+
-+ do {
-+
-+ t1 = time_get(); /* we'll look for a discontinuity */
-+ t2 = time_get();
-+
-+ if (time_u64(last_t2)) {
-+ /* Check the delta from outer loop (t2 to next t1) */
-+ diff = time_to_us(time_sub(t1, last_t2));
-+ /* This shouldn't happen */
-+ if (diff < 0) {
-+ pr_err(BANNER "time running backwards\n");
-+ goto out;
-+ }
-+ if (diff > outer_sample)
-+ outer_sample = diff;
-+ }
-+ last_t2 = t2;
-+
-+ total = time_to_us(time_sub(t2, start)); /* sample width */
-+
-+ /* This checks the inner loop (t1 to t2) */
-+ diff = time_to_us(time_sub(t2, t1)); /* current diff */
-+
-+ /* This shouldn't happen */
-+ if (diff < 0) {
-+ pr_err(BANNER "time running backwards\n");
-+ goto out;
-+ }
-+
-+ if (diff > sample)
-+ sample = diff; /* only want highest value */
-+
-+ } while (total <= data.sample_width);
-+
-+ ret = 0;
-+
-+ /* If we exceed the threshold value, we have found a hardware latency */
-+ if (sample > data.threshold || outer_sample > data.threshold) {
-+ struct sample s;
-+
-+ ret = 1;
-+
-+ data.count++;
-+ s.seqnum = data.count;
-+ s.duration = sample;
-+ s.outer_duration = outer_sample;
-+ s.timestamp = CURRENT_TIME;
-+ __buffer_add_sample(&s);
-+
-+ /* Keep a running maximum ever recorded hardware latency */
-+ if (sample > data.max_sample)
-+ data.max_sample = sample;
-+ }
-+
-+out:
-+ return ret;
-+}
-+
-+/*
-+ * kthread_fn - The CPU time sampling/hardware latency detection kernel thread
-+ * @unused: A required part of the kthread API.
-+ *
-+ * Used to periodically sample the CPU TSC via a call to get_sample. We
-+ * disable interrupts, which does (intentionally) introduce latency since we
-+ * need to ensure nothing else might be running (and thus pre-empting).
-+ * Obviously this should never be used in production environments.
-+ *
-+ * Currently this runs on which ever CPU it was scheduled on, but most
-+ * real-worald hardware latency situations occur across several CPUs,
-+ * but we might later generalize this if we find there are any actualy
-+ * systems with alternate SMI delivery or other hardware latencies.
-+ */
-+static int kthread_fn(void *unused)
-+{
-+ int ret;
-+ u64 interval;
-+
-+ while (!kthread_should_stop()) {
-+
-+ mutex_lock(&data.lock);
-+
-+ local_irq_disable();
-+ ret = get_sample();
-+ local_irq_enable();
-+
-+ if (ret > 0)
-+ wake_up(&data.wq); /* wake up reader(s) */
-+
-+ interval = data.sample_window - data.sample_width;
-+ do_div(interval, USEC_PER_MSEC); /* modifies interval value */
-+
-+ mutex_unlock(&data.lock);
-+
-+ if (msleep_interruptible(interval))
-+ break;
-+ }
-+
-+ return 0;
-+}
-+
-+/**
-+ * start_kthread - Kick off the hardware latency sampling/detector kthread
-+ *
-+ * This starts a kernel thread that will sit and sample the CPU timestamp
-+ * counter (TSC or similar) and look for potential hardware latencies.
-+ */
-+static int start_kthread(void)
-+{
-+ kthread = kthread_run(kthread_fn, NULL,
-+ DRVNAME);
-+ if (IS_ERR(kthread)) {
-+ pr_err(BANNER "could not start sampling thread\n");
-+ enabled = 0;
-+ return -ENOMEM;
-+ }
-+
-+ return 0;
-+}
-+
-+/**
-+ * stop_kthread - Inform the hardware latency samping/detector kthread to stop
-+ *
-+ * This kicks the running hardware latency sampling/detector kernel thread and
-+ * tells it to stop sampling now. Use this on unload and at system shutdown.
-+ */
-+static int stop_kthread(void)
-+{
-+ int ret;
-+
-+ ret = kthread_stop(kthread);
-+
-+ return ret;
-+}
-+
-+/**
-+ * __reset_stats - Reset statistics for the hardware latency detector
-+ *
-+ * We use data to store various statistics and global state. We call this
-+ * function in order to reset those when "enable" is toggled on or off, and
-+ * also at initialization. Should be called with data.lock held.
-+ */
-+static void __reset_stats(void)
-+{
-+ data.count = 0;
-+ data.max_sample = 0;
-+ ring_buffer_reset(ring_buffer); /* flush out old sample entries */
-+}
-+
-+/**
-+ * init_stats - Setup global state statistics for the hardware latency detector
-+ *
-+ * We use data to store various statistics and global state. We also use
-+ * a global ring buffer (ring_buffer) to keep raw samples of detected hardware
-+ * induced system latencies. This function initializes these structures and
-+ * allocates the global ring buffer also.
-+ */
-+static int init_stats(void)
-+{
-+ int ret = -ENOMEM;
-+
-+ mutex_init(&data.lock);
-+ init_waitqueue_head(&data.wq);
-+ atomic_set(&data.sample_open, 0);
-+
-+ ring_buffer = ring_buffer_alloc(buf_size, BUF_FLAGS);
-+
-+ if (WARN(!ring_buffer, KERN_ERR BANNER
-+ "failed to allocate ring buffer!\n"))
-+ goto out;
-+
-+ __reset_stats();
-+ data.threshold = threshold ?: DEFAULT_LAT_THRESHOLD; /* threshold us */
-+ data.sample_window = DEFAULT_SAMPLE_WINDOW; /* window us */
-+ data.sample_width = DEFAULT_SAMPLE_WIDTH; /* width us */
-+
-+ ret = 0;
-+
-+out:
-+ return ret;
-+
-+}
-+
-+/*
-+ * simple_data_read - Wrapper read function for global state debugfs entries
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ * @entry: The entry to read from
-+ *
-+ * This function provides a generic read implementation for the global state
-+ * "data" structure debugfs filesystem entries. It would be nice to use
-+ * simple_attr_read directly, but we need to make sure that the data.lock
-+ * is held during the actual read.
-+ */
-+static ssize_t simple_data_read(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos, const u64 *entry)
-+{
-+ char buf[U64STR_SIZE];
-+ u64 val = 0;
-+ int len = 0;
-+
-+ memset(buf, 0, sizeof(buf));
-+
-+ if (!entry)
-+ return -EFAULT;
-+
-+ mutex_lock(&data.lock);
-+ val = *entry;
-+ mutex_unlock(&data.lock);
-+
-+ len = snprintf(buf, sizeof(buf), "%llu\n", (unsigned long long)val);
-+
-+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
-+
-+}
-+
-+/*
-+ * simple_data_write - Wrapper write function for global state debugfs entries
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to write value from
-+ * @cnt: The maximum number of bytes to write
-+ * @ppos: The current "file" position
-+ * @entry: The entry to write to
-+ *
-+ * This function provides a generic write implementation for the global state
-+ * "data" structure debugfs filesystem entries. It would be nice to use
-+ * simple_attr_write directly, but we need to make sure that the data.lock
-+ * is held during the actual write.
-+ */
-+static ssize_t simple_data_write(struct file *filp, const char __user *ubuf,
-+ size_t cnt, loff_t *ppos, u64 *entry)
-+{
-+ char buf[U64STR_SIZE];
-+ int csize = min(cnt, sizeof(buf));
-+ u64 val = 0;
-+ int err = 0;
-+
-+ memset(buf, '\0', sizeof(buf));
-+ if (copy_from_user(buf, ubuf, csize))
-+ return -EFAULT;
-+
-+ buf[U64STR_SIZE-1] = '\0'; /* just in case */
-+ err = kstrtoull(buf, 10, &val);
-+ if (err)
-+ return -EINVAL;
-+
-+ mutex_lock(&data.lock);
-+ *entry = val;
-+ mutex_unlock(&data.lock);
-+
-+ return csize;
-+}
-+
-+/**
-+ * debug_count_fopen - Open function for "count" debugfs entry
-+ * @inode: The in-kernel inode representation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function provides an open implementation for the "count" debugfs
-+ * interface to the hardware latency detector.
-+ */
-+static int debug_count_fopen(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+/**
-+ * debug_count_fread - Read function for "count" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ *
-+ * This function provides a read implementation for the "count" debugfs
-+ * interface to the hardware latency detector. Can be used to read the
-+ * number of latency readings exceeding the configured threshold since
-+ * the detector was last reset (e.g. by writing a zero into "count").
-+ */
-+static ssize_t debug_count_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ return simple_data_read(filp, ubuf, cnt, ppos, &data.count);
-+}
-+
-+/**
-+ * debug_count_fwrite - Write function for "count" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that contains the value to write
-+ * @cnt: The maximum number of bytes to write to "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function provides a write implementation for the "count" debugfs
-+ * interface to the hardware latency detector. Can be used to write a
-+ * desired value, especially to zero the total count.
-+ */
-+static ssize_t debug_count_fwrite(struct file *filp,
-+ const char __user *ubuf,
-+ size_t cnt,
-+ loff_t *ppos)
-+{
-+ return simple_data_write(filp, ubuf, cnt, ppos, &data.count);
-+}
-+
-+/**
-+ * debug_enable_fopen - Dummy open function for "enable" debugfs interface
-+ * @inode: The in-kernel inode representation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function provides an open implementation for the "enable" debugfs
-+ * interface to the hardware latency detector.
-+ */
-+static int debug_enable_fopen(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+/**
-+ * debug_enable_fread - Read function for "enable" debugfs interface
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ *
-+ * This function provides a read implementation for the "enable" debugfs
-+ * interface to the hardware latency detector. Can be used to determine
-+ * whether the detector is currently enabled ("0\n" or "1\n" returned).
-+ */
-+static ssize_t debug_enable_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ char buf[4];
-+
-+ if ((cnt < sizeof(buf)) || (*ppos))
-+ return 0;
-+
-+ buf[0] = enabled ? '1' : '0';
-+ buf[1] = '\n';
-+ buf[2] = '\0';
-+ if (copy_to_user(ubuf, buf, strlen(buf)))
-+ return -EFAULT;
-+ return *ppos = strlen(buf);
-+}
-+
-+/**
-+ * debug_enable_fwrite - Write function for "enable" debugfs interface
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that contains the value to write
-+ * @cnt: The maximum number of bytes to write to "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function provides a write implementation for the "enable" debugfs
-+ * interface to the hardware latency detector. Can be used to enable or
-+ * disable the detector, which will have the side-effect of possibly
-+ * also resetting the global stats and kicking off the measuring
-+ * kthread (on an enable) or the converse (upon a disable).
-+ */
-+static ssize_t debug_enable_fwrite(struct file *filp,
-+ const char __user *ubuf,
-+ size_t cnt,
-+ loff_t *ppos)
-+{
-+ char buf[4];
-+ int csize = min(cnt, sizeof(buf));
-+ long val = 0;
-+ int err = 0;
-+
-+ memset(buf, '\0', sizeof(buf));
-+ if (copy_from_user(buf, ubuf, csize))
-+ return -EFAULT;
-+
-+ buf[sizeof(buf)-1] = '\0'; /* just in case */
-+ err = kstrtoul(buf, 10, &val);
-+ if (0 != err)
-+ return -EINVAL;
-+
-+ if (val) {
-+ if (enabled)
-+ goto unlock;
-+ enabled = 1;
-+ __reset_stats();
-+ if (start_kthread())
-+ return -EFAULT;
-+ } else {
-+ if (!enabled)
-+ goto unlock;
-+ enabled = 0;
-+ err = stop_kthread();
-+ if (err) {
-+ pr_err(BANNER "cannot stop kthread\n");
-+ return -EFAULT;
-+ }
-+ wake_up(&data.wq); /* reader(s) should return */
-+ }
-+unlock:
-+ return csize;
-+}
-+
-+/**
-+ * debug_max_fopen - Open function for "max" debugfs entry
-+ * @inode: The in-kernel inode representation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function provides an open implementation for the "max" debugfs
-+ * interface to the hardware latency detector.
-+ */
-+static int debug_max_fopen(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+/**
-+ * debug_max_fread - Read function for "max" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ *
-+ * This function provides a read implementation for the "max" debugfs
-+ * interface to the hardware latency detector. Can be used to determine
-+ * the maximum latency value observed since it was last reset.
-+ */
-+static ssize_t debug_max_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ return simple_data_read(filp, ubuf, cnt, ppos, &data.max_sample);
-+}
-+
-+/**
-+ * debug_max_fwrite - Write function for "max" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that contains the value to write
-+ * @cnt: The maximum number of bytes to write to "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function provides a write implementation for the "max" debugfs
-+ * interface to the hardware latency detector. Can be used to reset the
-+ * maximum or set it to some other desired value - if, then, subsequent
-+ * measurements exceed this value, the maximum will be updated.
-+ */
-+static ssize_t debug_max_fwrite(struct file *filp,
-+ const char __user *ubuf,
-+ size_t cnt,
-+ loff_t *ppos)
-+{
-+ return simple_data_write(filp, ubuf, cnt, ppos, &data.max_sample);
-+}
-+
-+
-+/**
-+ * debug_sample_fopen - An open function for "sample" debugfs interface
-+ * @inode: The in-kernel inode representation of this debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function handles opening the "sample" file within the hardware
-+ * latency detector debugfs directory interface. This file is used to read
-+ * raw samples from the global ring_buffer and allows the user to see a
-+ * running latency history. Can be opened blocking or non-blocking,
-+ * affecting whether it behaves as a buffer read pipe, or does not.
-+ * Implements simple locking to prevent multiple simultaneous use.
-+ */
-+static int debug_sample_fopen(struct inode *inode, struct file *filp)
-+{
-+ if (!atomic_add_unless(&data.sample_open, 1, 1))
-+ return -EBUSY;
-+ else
-+ return 0;
-+}
-+
-+/**
-+ * debug_sample_fread - A read function for "sample" debugfs interface
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that will contain the samples read
-+ * @cnt: The maximum bytes to read from the debugfs "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function handles reading from the "sample" file within the hardware
-+ * latency detector debugfs directory interface. This file is used to read
-+ * raw samples from the global ring_buffer and allows the user to see a
-+ * running latency history. By default this will block pending a new
-+ * value written into the sample buffer, unless there are already a
-+ * number of value(s) waiting in the buffer, or the sample file was
-+ * previously opened in a non-blocking mode of operation.
-+ */
-+static ssize_t debug_sample_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ int len = 0;
-+ char buf[64];
-+ struct sample *sample = NULL;
-+
-+ if (!enabled)
-+ return 0;
-+
-+ sample = kzalloc(sizeof(struct sample), GFP_KERNEL);
-+ if (!sample)
-+ return -ENOMEM;
-+
-+ while (!buffer_get_sample(sample)) {
-+
-+ DEFINE_WAIT(wait);
-+
-+ if (filp->f_flags & O_NONBLOCK) {
-+ len = -EAGAIN;
-+ goto out;
-+ }
-+
-+ prepare_to_wait(&data.wq, &wait, TASK_INTERRUPTIBLE);
-+ schedule();
-+ finish_wait(&data.wq, &wait);
-+
-+ if (signal_pending(current)) {
-+ len = -EINTR;
-+ goto out;
-+ }
-+
-+ if (!enabled) { /* enable was toggled */
-+ len = 0;
-+ goto out;
-+ }
-+ }
-+
-+ len = snprintf(buf, sizeof(buf), "%010lu.%010lu\t%llu\t%llu\n",
-+ sample->timestamp.tv_sec,
-+ sample->timestamp.tv_nsec,
-+ sample->duration,
-+ sample->outer_duration);
-+
-+
-+ /* handling partial reads is more trouble than it's worth */
-+ if (len > cnt)
-+ goto out;
-+
-+ if (copy_to_user(ubuf, buf, len))
-+ len = -EFAULT;
-+
-+out:
-+ kfree(sample);
-+ return len;
-+}
-+
-+/**
-+ * debug_sample_release - Release function for "sample" debugfs interface
-+ * @inode: The in-kernel inode represenation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function completes the close of the debugfs interface "sample" file.
-+ * Frees the sample_open "lock" so that other users may open the interface.
-+ */
-+static int debug_sample_release(struct inode *inode, struct file *filp)
-+{
-+ atomic_dec(&data.sample_open);
-+
-+ return 0;
-+}
-+
-+/**
-+ * debug_threshold_fopen - Open function for "threshold" debugfs entry
-+ * @inode: The in-kernel inode representation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function provides an open implementation for the "threshold" debugfs
-+ * interface to the hardware latency detector.
-+ */
-+static int debug_threshold_fopen(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+/**
-+ * debug_threshold_fread - Read function for "threshold" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ *
-+ * This function provides a read implementation for the "threshold" debugfs
-+ * interface to the hardware latency detector. It can be used to determine
-+ * the current threshold level at which a latency will be recorded in the
-+ * global ring buffer, typically on the order of 10us.
-+ */
-+static ssize_t debug_threshold_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ return simple_data_read(filp, ubuf, cnt, ppos, &data.threshold);
-+}
-+
-+/**
-+ * debug_threshold_fwrite - Write function for "threshold" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that contains the value to write
-+ * @cnt: The maximum number of bytes to write to "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function provides a write implementation for the "threshold" debugfs
-+ * interface to the hardware latency detector. It can be used to configure
-+ * the threshold level at which any subsequently detected latencies will
-+ * be recorded into the global ring buffer.
-+ */
-+static ssize_t debug_threshold_fwrite(struct file *filp,
-+ const char __user *ubuf,
-+ size_t cnt,
-+ loff_t *ppos)
-+{
-+ int ret;
-+
-+ ret = simple_data_write(filp, ubuf, cnt, ppos, &data.threshold);
-+
-+ if (enabled)
-+ wake_up_process(kthread);
-+
-+ return ret;
-+}
-+
-+/**
-+ * debug_width_fopen - Open function for "width" debugfs entry
-+ * @inode: The in-kernel inode representation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function provides an open implementation for the "width" debugfs
-+ * interface to the hardware latency detector.
-+ */
-+static int debug_width_fopen(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+/**
-+ * debug_width_fread - Read function for "width" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ *
-+ * This function provides a read implementation for the "width" debugfs
-+ * interface to the hardware latency detector. It can be used to determine
-+ * for how many us of the total window us we will actively sample for any
-+ * hardware-induced latecy periods. Obviously, it is not possible to
-+ * sample constantly and have the system respond to a sample reader, or,
-+ * worse, without having the system appear to have gone out to lunch.
-+ */
-+static ssize_t debug_width_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ return simple_data_read(filp, ubuf, cnt, ppos, &data.sample_width);
-+}
-+
-+/**
-+ * debug_width_fwrite - Write function for "width" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that contains the value to write
-+ * @cnt: The maximum number of bytes to write to "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function provides a write implementation for the "width" debugfs
-+ * interface to the hardware latency detector. It can be used to configure
-+ * for how many us of the total window us we will actively sample for any
-+ * hardware-induced latency periods. Obviously, it is not possible to
-+ * sample constantly and have the system respond to a sample reader, or,
-+ * worse, without having the system appear to have gone out to lunch. It
-+ * is enforced that width is less that the total window size.
-+ */
-+static ssize_t debug_width_fwrite(struct file *filp,
-+ const char __user *ubuf,
-+ size_t cnt,
-+ loff_t *ppos)
-+{
-+ char buf[U64STR_SIZE];
-+ int csize = min(cnt, sizeof(buf));
-+ u64 val = 0;
-+ int err = 0;
-+
-+ memset(buf, '\0', sizeof(buf));
-+ if (copy_from_user(buf, ubuf, csize))
-+ return -EFAULT;
-+
-+ buf[U64STR_SIZE-1] = '\0'; /* just in case */
-+ err = kstrtoull(buf, 10, &val);
-+ if (0 != err)
-+ return -EINVAL;
-+
-+ mutex_lock(&data.lock);
-+ if (val < data.sample_window)
-+ data.sample_width = val;
-+ else {
-+ mutex_unlock(&data.lock);
-+ return -EINVAL;
-+ }
-+ mutex_unlock(&data.lock);
-+
-+ if (enabled)
-+ wake_up_process(kthread);
-+
-+ return csize;
-+}
-+
-+/**
-+ * debug_window_fopen - Open function for "window" debugfs entry
-+ * @inode: The in-kernel inode representation of the debugfs "file"
-+ * @filp: The active open file structure for the debugfs "file"
-+ *
-+ * This function provides an open implementation for the "window" debugfs
-+ * interface to the hardware latency detector. The window is the total time
-+ * in us that will be considered one sample period. Conceptually, windows
-+ * occur back-to-back and contain a sample width period during which
-+ * actual sampling occurs.
-+ */
-+static int debug_window_fopen(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+/**
-+ * debug_window_fread - Read function for "window" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The userspace provided buffer to read value into
-+ * @cnt: The maximum number of bytes to read
-+ * @ppos: The current "file" position
-+ *
-+ * This function provides a read implementation for the "window" debugfs
-+ * interface to the hardware latency detector. The window is the total time
-+ * in us that will be considered one sample period. Conceptually, windows
-+ * occur back-to-back and contain a sample width period during which
-+ * actual sampling occurs. Can be used to read the total window size.
-+ */
-+static ssize_t debug_window_fread(struct file *filp, char __user *ubuf,
-+ size_t cnt, loff_t *ppos)
-+{
-+ return simple_data_read(filp, ubuf, cnt, ppos, &data.sample_window);
-+}
-+
-+/**
-+ * debug_window_fwrite - Write function for "window" debugfs entry
-+ * @filp: The active open file structure for the debugfs "file"
-+ * @ubuf: The user buffer that contains the value to write
-+ * @cnt: The maximum number of bytes to write to "file"
-+ * @ppos: The current position in the debugfs "file"
-+ *
-+ * This function provides a write implementation for the "window" debufds
-+ * interface to the hardware latency detetector. The window is the total time
-+ * in us that will be considered one sample period. Conceptually, windows
-+ * occur back-to-back and contain a sample width period during which
-+ * actual sampling occurs. Can be used to write a new total window size. It
-+ * is enfoced that any value written must be greater than the sample width
-+ * size, or an error results.
-+ */
-+static ssize_t debug_window_fwrite(struct file *filp,
-+ const char __user *ubuf,
-+ size_t cnt,
-+ loff_t *ppos)
-+{
-+ char buf[U64STR_SIZE];
-+ int csize = min(cnt, sizeof(buf));
-+ u64 val = 0;
-+ int err = 0;
-+
-+ memset(buf, '\0', sizeof(buf));
-+ if (copy_from_user(buf, ubuf, csize))
-+ return -EFAULT;
-+
-+ buf[U64STR_SIZE-1] = '\0'; /* just in case */
-+ err = kstrtoull(buf, 10, &val);
-+ if (0 != err)
-+ return -EINVAL;
-+
-+ mutex_lock(&data.lock);
-+ if (data.sample_width < val)
-+ data.sample_window = val;
-+ else {
-+ mutex_unlock(&data.lock);
-+ return -EINVAL;
-+ }
-+ mutex_unlock(&data.lock);
-+
-+ return csize;
-+}
-+
-+/*
-+ * Function pointers for the "count" debugfs file operations
-+ */
-+static const struct file_operations count_fops = {
-+ .open = debug_count_fopen,
-+ .read = debug_count_fread,
-+ .write = debug_count_fwrite,
-+ .owner = THIS_MODULE,
-+};
-+
-+/*
-+ * Function pointers for the "enable" debugfs file operations
-+ */
-+static const struct file_operations enable_fops = {
-+ .open = debug_enable_fopen,
-+ .read = debug_enable_fread,
-+ .write = debug_enable_fwrite,
-+ .owner = THIS_MODULE,
-+};
-+
-+/*
-+ * Function pointers for the "max" debugfs file operations
-+ */
-+static const struct file_operations max_fops = {
-+ .open = debug_max_fopen,
-+ .read = debug_max_fread,
-+ .write = debug_max_fwrite,
-+ .owner = THIS_MODULE,
-+};
-+
-+/*
-+ * Function pointers for the "sample" debugfs file operations
-+ */
-+static const struct file_operations sample_fops = {
-+ .open = debug_sample_fopen,
-+ .read = debug_sample_fread,
-+ .release = debug_sample_release,
-+ .owner = THIS_MODULE,
-+};
-+
-+/*
-+ * Function pointers for the "threshold" debugfs file operations
-+ */
-+static const struct file_operations threshold_fops = {
-+ .open = debug_threshold_fopen,
-+ .read = debug_threshold_fread,
-+ .write = debug_threshold_fwrite,
-+ .owner = THIS_MODULE,
-+};
-+
-+/*
-+ * Function pointers for the "width" debugfs file operations
-+ */
-+static const struct file_operations width_fops = {
-+ .open = debug_width_fopen,
-+ .read = debug_width_fread,
-+ .write = debug_width_fwrite,
-+ .owner = THIS_MODULE,
-+};
-+
-+/*
-+ * Function pointers for the "window" debugfs file operations
-+ */
-+static const struct file_operations window_fops = {
-+ .open = debug_window_fopen,
-+ .read = debug_window_fread,
-+ .write = debug_window_fwrite,
-+ .owner = THIS_MODULE,
-+};
-+
-+/**
-+ * init_debugfs - A function to initialize the debugfs interface files
-+ *
-+ * This function creates entries in debugfs for "hwlat_detector", including
-+ * files to read values from the detector, current samples, and the
-+ * maximum sample that has been captured since the hardware latency
-+ * dectector was started.
-+ */
-+static int init_debugfs(void)
-+{
-+ int ret = -ENOMEM;
-+
-+ debug_dir = debugfs_create_dir(DRVNAME, NULL);
-+ if (!debug_dir)
-+ goto err_debug_dir;
-+
-+ debug_sample = debugfs_create_file("sample", 0444,
-+ debug_dir, NULL,
-+ &sample_fops);
-+ if (!debug_sample)
-+ goto err_sample;
-+
-+ debug_count = debugfs_create_file("count", 0444,
-+ debug_dir, NULL,
-+ &count_fops);
-+ if (!debug_count)
-+ goto err_count;
-+
-+ debug_max = debugfs_create_file("max", 0444,
-+ debug_dir, NULL,
-+ &max_fops);
-+ if (!debug_max)
-+ goto err_max;
-+
-+ debug_sample_window = debugfs_create_file("window", 0644,
-+ debug_dir, NULL,
-+ &window_fops);
-+ if (!debug_sample_window)
-+ goto err_window;
-+
-+ debug_sample_width = debugfs_create_file("width", 0644,
-+ debug_dir, NULL,
-+ &width_fops);
-+ if (!debug_sample_width)
-+ goto err_width;
-+
-+ debug_threshold = debugfs_create_file("threshold", 0644,
-+ debug_dir, NULL,
-+ &threshold_fops);
-+ if (!debug_threshold)
-+ goto err_threshold;
-+
-+ debug_enable = debugfs_create_file("enable", 0644,
-+ debug_dir, &enabled,
-+ &enable_fops);
-+ if (!debug_enable)
-+ goto err_enable;
-+
-+ else {
-+ ret = 0;
-+ goto out;
-+ }
-+
-+err_enable:
-+ debugfs_remove(debug_threshold);
-+err_threshold:
-+ debugfs_remove(debug_sample_width);
-+err_width:
-+ debugfs_remove(debug_sample_window);
-+err_window:
-+ debugfs_remove(debug_max);
-+err_max:
-+ debugfs_remove(debug_count);
-+err_count:
-+ debugfs_remove(debug_sample);
-+err_sample:
-+ debugfs_remove(debug_dir);
-+err_debug_dir:
-+out:
-+ return ret;
-+}
-+
-+/**
-+ * free_debugfs - A function to cleanup the debugfs file interface
-+ */
-+static void free_debugfs(void)
-+{
-+ /* could also use a debugfs_remove_recursive */
-+ debugfs_remove(debug_enable);
-+ debugfs_remove(debug_threshold);
-+ debugfs_remove(debug_sample_width);
-+ debugfs_remove(debug_sample_window);
-+ debugfs_remove(debug_max);
-+ debugfs_remove(debug_count);
-+ debugfs_remove(debug_sample);
-+ debugfs_remove(debug_dir);
-+}
-+
-+/**
-+ * detector_init - Standard module initialization code
-+ */
-+static int detector_init(void)
-+{
-+ int ret = -ENOMEM;
-+
-+ pr_info(BANNER "version %s\n", VERSION);
-+
-+ ret = init_stats();
-+ if (0 != ret)
-+ goto out;
-+
-+ ret = init_debugfs();
-+ if (0 != ret)
-+ goto err_stats;
-+
-+ if (enabled)
-+ ret = start_kthread();
-+
-+ goto out;
-+
-+err_stats:
-+ ring_buffer_free(ring_buffer);
-+out:
-+ return ret;
-+
-+}
-+
-+/**
-+ * detector_exit - Standard module cleanup code
-+ */
-+static void detector_exit(void)
-+{
-+ int err;
-+
-+ if (enabled) {
-+ enabled = 0;
-+ err = stop_kthread();
-+ if (err)
-+ pr_err(BANNER "cannot stop kthread\n");
-+ }
-+
-+ free_debugfs();
-+ ring_buffer_free(ring_buffer); /* free up the ring buffer */
-+
-+}
-+
-+module_init(detector_init);
-+module_exit(detector_exit);
-diff -Nur linux-4.1.39.orig/drivers/misc/Kconfig linux-4.1.39/drivers/misc/Kconfig
---- linux-4.1.39.orig/drivers/misc/Kconfig 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/misc/Kconfig 2017-04-18 17:56:30.585396045 +0200
-@@ -54,6 +54,7 @@
- config ATMEL_TCLIB
- bool "Atmel AT32/AT91 Timer/Counter Library"
- depends on (AVR32 || ARCH_AT91)
-+ default y if PREEMPT_RT_FULL
- help
- Select this if you want a library to allocate the Timer/Counter
- blocks found on many Atmel processors. This facilitates using
-@@ -69,8 +70,7 @@
- are combined to make a single 32-bit timer.
-
- When GENERIC_CLOCKEVENTS is defined, the third timer channel
-- may be used as a clock event device supporting oneshot mode
-- (delays of up to two seconds) based on the 32 KiHz clock.
-+ may be used as a clock event device supporting oneshot mode.
-
- config ATMEL_TCB_CLKSRC_BLOCK
- int
-@@ -84,6 +84,15 @@
- TC can be used for other purposes, such as PWM generation and
- interval timing.
-
-+config ATMEL_TCB_CLKSRC_USE_SLOW_CLOCK
-+ bool "TC Block use 32 KiHz clock"
-+ depends on ATMEL_TCB_CLKSRC
-+ default y if !PREEMPT_RT_FULL
-+ help
-+ Select this to use 32 KiHz base clock rate as TC block clock
-+ source for clock events.
-+
-+
- config DUMMY_IRQ
- tristate "Dummy IRQ handler"
- default n
-@@ -113,6 +122,35 @@
- for information on the specific driver level and support statement
- for your IBM server.
-
-+config HWLAT_DETECTOR
-+ tristate "Testing module to detect hardware-induced latencies"
-+ depends on DEBUG_FS
-+ depends on RING_BUFFER
-+ default m
-+ ---help---
-+ A simple hardware latency detector. Use this module to detect
-+ large latencies introduced by the behavior of the underlying
-+ system firmware external to Linux. We do this using periodic
-+ use of stop_machine to grab all available CPUs and measure
-+ for unexplainable gaps in the CPU timestamp counter(s). By
-+ default, the module is not enabled until the "enable" file
-+ within the "hwlat_detector" debugfs directory is toggled.
-+
-+ This module is often used to detect SMI (System Management
-+ Interrupts) on x86 systems, though is not x86 specific. To
-+ this end, we default to using a sample window of 1 second,
-+ during which we will sample for 0.5 seconds. If an SMI or
-+ similar event occurs during that time, it is recorded
-+ into an 8K samples global ring buffer until retreived.
-+
-+ WARNING: This software should never be enabled (it can be built
-+ but should not be turned on after it is loaded) in a production
-+ environment where high latencies are a concern since the
-+ sampling mechanism actually introduces latencies for
-+ regular tasks while the CPU(s) are being held.
-+
-+ If unsure, say N
-+
- config PHANTOM
- tristate "Sensable PHANToM (PCI)"
- depends on PCI
-diff -Nur linux-4.1.39.orig/drivers/misc/Makefile linux-4.1.39/drivers/misc/Makefile
---- linux-4.1.39.orig/drivers/misc/Makefile 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/misc/Makefile 2017-04-18 17:56:30.585396045 +0200
-@@ -38,6 +38,7 @@
- obj-$(CONFIG_HMC6352) += hmc6352.o
- obj-y += eeprom/
- obj-y += cb710/
-+obj-$(CONFIG_HWLAT_DETECTOR) += hwlat_detector.o
- obj-$(CONFIG_SPEAR13XX_PCIE_GADGET) += spear13xx_pcie_gadget.o
- obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
- obj-$(CONFIG_ARM_CHARLCD) += arm-charlcd.o
-diff -Nur linux-4.1.39.orig/drivers/mmc/host/mmci.c linux-4.1.39/drivers/mmc/host/mmci.c
---- linux-4.1.39.orig/drivers/mmc/host/mmci.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/mmc/host/mmci.c 2017-04-18 17:56:30.589396200 +0200
-@@ -1155,15 +1155,12 @@
- struct sg_mapping_iter *sg_miter = &host->sg_miter;
- struct variant_data *variant = host->variant;
- void __iomem *base = host->base;
-- unsigned long flags;
- u32 status;
-
- status = readl(base + MMCISTATUS);
-
- dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status);
-
-- local_irq_save(flags);
--
- do {
- unsigned int remain, len;
- char *buffer;
-@@ -1203,8 +1200,6 @@
-
- sg_miter_stop(sg_miter);
-
-- local_irq_restore(flags);
--
- /*
- * If we have less than the fifo 'half-full' threshold to transfer,
- * trigger a PIO interrupt as soon as any data is available.
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/3com/3c59x.c linux-4.1.39/drivers/net/ethernet/3com/3c59x.c
---- linux-4.1.39.orig/drivers/net/ethernet/3com/3c59x.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/3com/3c59x.c 2017-04-18 17:56:30.589396200 +0200
-@@ -842,9 +842,9 @@
- {
- struct vortex_private *vp = netdev_priv(dev);
- unsigned long flags;
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- (vp->full_bus_master_rx ? boomerang_interrupt:vortex_interrupt)(dev->irq,dev);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- }
- #endif
-
-@@ -1916,12 +1916,12 @@
- * Block interrupts because vortex_interrupt does a bare spin_lock()
- */
- unsigned long flags;
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- if (vp->full_bus_master_tx)
- boomerang_interrupt(dev->irq, dev);
- else
- vortex_interrupt(dev->irq, dev);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- }
- }
-
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/atheros/atl1c/atl1c_main.c linux-4.1.39/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
---- linux-4.1.39.orig/drivers/net/ethernet/atheros/atl1c/atl1c_main.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/atheros/atl1c/atl1c_main.c 2017-04-18 17:56:30.589396200 +0200
-@@ -2212,11 +2212,7 @@
- }
-
- tpd_req = atl1c_cal_tpd_req(skb);
-- if (!spin_trylock_irqsave(&adapter->tx_lock, flags)) {
-- if (netif_msg_pktdata(adapter))
-- dev_info(&adapter->pdev->dev, "tx locked\n");
-- return NETDEV_TX_LOCKED;
-- }
-+ spin_lock_irqsave(&adapter->tx_lock, flags);
-
- if (atl1c_tpd_avail(adapter, type) < tpd_req) {
- /* no enough descriptor, just stop queue */
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/atheros/atl1e/atl1e_main.c linux-4.1.39/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
---- linux-4.1.39.orig/drivers/net/ethernet/atheros/atl1e/atl1e_main.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/atheros/atl1e/atl1e_main.c 2017-04-18 17:56:30.589396200 +0200
-@@ -1880,8 +1880,7 @@
- return NETDEV_TX_OK;
- }
- tpd_req = atl1e_cal_tdp_req(skb);
-- if (!spin_trylock_irqsave(&adapter->tx_lock, flags))
-- return NETDEV_TX_LOCKED;
-+ spin_lock_irqsave(&adapter->tx_lock, flags);
-
- if (atl1e_tpd_avail(adapter) < tpd_req) {
- /* no enough descriptor, just stop queue */
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/chelsio/cxgb/sge.c linux-4.1.39/drivers/net/ethernet/chelsio/cxgb/sge.c
---- linux-4.1.39.orig/drivers/net/ethernet/chelsio/cxgb/sge.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/chelsio/cxgb/sge.c 2017-04-18 17:56:30.589396200 +0200
-@@ -1664,8 +1664,7 @@
- struct cmdQ *q = &sge->cmdQ[qid];
- unsigned int credits, pidx, genbit, count, use_sched_skb = 0;
-
-- if (!spin_trylock(&q->lock))
-- return NETDEV_TX_LOCKED;
-+ spin_lock(&q->lock);
-
- reclaim_completed_tx(sge, q);
-
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/freescale/gianfar.c linux-4.1.39/drivers/net/ethernet/freescale/gianfar.c
---- linux-4.1.39.orig/drivers/net/ethernet/freescale/gianfar.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/freescale/gianfar.c 2017-04-18 17:56:30.589396200 +0200
-@@ -1540,7 +1540,7 @@
-
- if (netif_running(ndev)) {
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- lock_tx_qs(priv);
-
- gfar_halt_nodisable(priv);
-@@ -1556,7 +1556,7 @@
- gfar_write(&regs->maccfg1, tempval);
-
- unlock_tx_qs(priv);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- disable_napi(priv);
-
-@@ -1598,7 +1598,7 @@
- /* Disable Magic Packet mode, in case something
- * else woke us up.
- */
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- lock_tx_qs(priv);
-
- tempval = gfar_read(&regs->maccfg2);
-@@ -1608,7 +1608,7 @@
- gfar_start(priv);
-
- unlock_tx_qs(priv);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- netif_device_attach(ndev);
-
-@@ -3418,14 +3418,14 @@
- dev->stats.tx_dropped++;
- atomic64_inc(&priv->extra_stats.tx_underrun);
-
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- lock_tx_qs(priv);
-
- /* Reactivate the Tx Queues */
- gfar_write(&regs->tstat, gfargrp->tstat);
-
- unlock_tx_qs(priv);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- }
- netif_dbg(priv, tx_err, dev, "Transmit Error\n");
- }
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/neterion/s2io.c linux-4.1.39/drivers/net/ethernet/neterion/s2io.c
---- linux-4.1.39.orig/drivers/net/ethernet/neterion/s2io.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/neterion/s2io.c 2017-04-18 17:56:30.589396200 +0200
-@@ -4084,12 +4084,7 @@
- [skb->priority & (MAX_TX_FIFOS - 1)];
- fifo = &mac_control->fifos[queue];
-
-- if (do_spin_lock)
-- spin_lock_irqsave(&fifo->tx_lock, flags);
-- else {
-- if (unlikely(!spin_trylock_irqsave(&fifo->tx_lock, flags)))
-- return NETDEV_TX_LOCKED;
-- }
-+ spin_lock_irqsave(&fifo->tx_lock, flags);
-
- if (sp->config.multiq) {
- if (__netif_subqueue_stopped(dev, fifo->fifo_no)) {
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c linux-4.1.39/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
---- linux-4.1.39.orig/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c 2017-04-18 17:56:30.589396200 +0200
-@@ -2137,10 +2137,8 @@
- struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
- unsigned long flags;
-
-- if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags)) {
-- /* Collision - tell upper layer to requeue */
-- return NETDEV_TX_LOCKED;
-- }
-+ spin_lock_irqsave(&tx_ring->tx_lock, flags);
-+
- if (unlikely(!PCH_GBE_DESC_UNUSED(tx_ring))) {
- netif_stop_queue(netdev);
- spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/realtek/8139too.c linux-4.1.39/drivers/net/ethernet/realtek/8139too.c
---- linux-4.1.39.orig/drivers/net/ethernet/realtek/8139too.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/realtek/8139too.c 2017-04-18 17:56:30.593396355 +0200
-@@ -2229,7 +2229,7 @@
- struct rtl8139_private *tp = netdev_priv(dev);
- const int irq = tp->pci_dev->irq;
-
-- disable_irq(irq);
-+ disable_irq_nosync(irq);
- rtl8139_interrupt(irq, dev);
- enable_irq(irq);
- }
-diff -Nur linux-4.1.39.orig/drivers/net/ethernet/tehuti/tehuti.c linux-4.1.39/drivers/net/ethernet/tehuti/tehuti.c
---- linux-4.1.39.orig/drivers/net/ethernet/tehuti/tehuti.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/ethernet/tehuti/tehuti.c 2017-04-18 17:56:30.593396355 +0200
-@@ -1629,13 +1629,8 @@
- unsigned long flags;
-
- ENTER;
-- local_irq_save(flags);
-- if (!spin_trylock(&priv->tx_lock)) {
-- local_irq_restore(flags);
-- DBG("%s[%s]: TX locked, returning NETDEV_TX_LOCKED\n",
-- BDX_DRV_NAME, ndev->name);
-- return NETDEV_TX_LOCKED;
-- }
-+
-+ spin_lock_irqsave(&priv->tx_lock, flags);
-
- /* build tx descriptor */
- BDX_ASSERT(f->m.wptr >= f->m.memsz); /* started with valid wptr */
-diff -Nur linux-4.1.39.orig/drivers/net/rionet.c linux-4.1.39/drivers/net/rionet.c
---- linux-4.1.39.orig/drivers/net/rionet.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/rionet.c 2017-04-18 17:56:30.593396355 +0200
-@@ -174,11 +174,7 @@
- unsigned long flags;
- int add_num = 1;
-
-- local_irq_save(flags);
-- if (!spin_trylock(&rnet->tx_lock)) {
-- local_irq_restore(flags);
-- return NETDEV_TX_LOCKED;
-- }
-+ spin_lock_irqsave(&rnet->tx_lock, flags);
-
- if (is_multicast_ether_addr(eth->h_dest))
- add_num = nets[rnet->mport->id].nact;
-diff -Nur linux-4.1.39.orig/drivers/net/wireless/orinoco/orinoco_usb.c linux-4.1.39/drivers/net/wireless/orinoco/orinoco_usb.c
---- linux-4.1.39.orig/drivers/net/wireless/orinoco/orinoco_usb.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/net/wireless/orinoco/orinoco_usb.c 2017-04-18 17:56:30.593396355 +0200
-@@ -697,7 +697,7 @@
- while (!ctx->done.done && msecs--)
- udelay(1000);
- } else {
-- wait_event_interruptible(ctx->done.wait,
-+ swait_event_interruptible(ctx->done.wait,
- ctx->done.done);
- }
- break;
-diff -Nur linux-4.1.39.orig/drivers/pci/access.c linux-4.1.39/drivers/pci/access.c
---- linux-4.1.39.orig/drivers/pci/access.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/pci/access.c 2017-04-18 17:56:30.593396355 +0200
-@@ -561,7 +561,7 @@
- WARN_ON(!dev->block_cfg_access);
-
- dev->block_cfg_access = 0;
-- wake_up_all(&pci_cfg_wait);
-+ wake_up_all_locked(&pci_cfg_wait);
- raw_spin_unlock_irqrestore(&pci_lock, flags);
- }
- EXPORT_SYMBOL_GPL(pci_cfg_access_unlock);
-diff -Nur linux-4.1.39.orig/drivers/pinctrl/qcom/pinctrl-msm.c linux-4.1.39/drivers/pinctrl/qcom/pinctrl-msm.c
---- linux-4.1.39.orig/drivers/pinctrl/qcom/pinctrl-msm.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/pinctrl/qcom/pinctrl-msm.c 2017-04-18 17:56:30.593396355 +0200
-@@ -59,7 +59,7 @@
- struct notifier_block restart_nb;
- int irq;
-
-- spinlock_t lock;
-+ raw_spinlock_t lock;
-
- DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO);
- DECLARE_BITMAP(enabled_irqs, MAX_NR_GPIO);
-@@ -155,14 +155,14 @@
- if (WARN_ON(i == g->nfuncs))
- return -EINVAL;
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->ctl_reg);
- val &= ~(0x7 << g->mux_bit);
- val |= i << g->mux_bit;
- writel(val, pctrl->regs + g->ctl_reg);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
-
- return 0;
- }
-@@ -325,14 +325,14 @@
- break;
- case PIN_CONFIG_OUTPUT:
- /* set output value */
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
- val = readl(pctrl->regs + g->io_reg);
- if (arg)
- val |= BIT(g->out_bit);
- else
- val &= ~BIT(g->out_bit);
- writel(val, pctrl->regs + g->io_reg);
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
-
- /* enable output */
- arg = 1;
-@@ -353,12 +353,12 @@
- return -EINVAL;
- }
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
- val = readl(pctrl->regs + g->ctl_reg);
- val &= ~(mask << bit);
- val |= arg << bit;
- writel(val, pctrl->regs + g->ctl_reg);
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
- }
-
- return 0;
-@@ -386,13 +386,13 @@
-
- g = &pctrl->soc->groups[offset];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->ctl_reg);
- val &= ~BIT(g->oe_bit);
- writel(val, pctrl->regs + g->ctl_reg);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
-
- return 0;
- }
-@@ -406,7 +406,7 @@
-
- g = &pctrl->soc->groups[offset];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->io_reg);
- if (value)
-@@ -419,7 +419,7 @@
- val |= BIT(g->oe_bit);
- writel(val, pctrl->regs + g->ctl_reg);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
-
- return 0;
- }
-@@ -445,7 +445,7 @@
-
- g = &pctrl->soc->groups[offset];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->io_reg);
- if (value)
-@@ -454,7 +454,7 @@
- val &= ~BIT(g->out_bit);
- writel(val, pctrl->regs + g->io_reg);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
- }
-
- static int msm_gpio_request(struct gpio_chip *chip, unsigned offset)
-@@ -585,7 +585,7 @@
-
- g = &pctrl->soc->groups[d->hwirq];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->intr_cfg_reg);
- val &= ~BIT(g->intr_enable_bit);
-@@ -593,7 +593,7 @@
-
- clear_bit(d->hwirq, pctrl->enabled_irqs);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
- }
-
- static void msm_gpio_irq_unmask(struct irq_data *d)
-@@ -606,7 +606,7 @@
-
- g = &pctrl->soc->groups[d->hwirq];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->intr_status_reg);
- val &= ~BIT(g->intr_status_bit);
-@@ -618,7 +618,7 @@
-
- set_bit(d->hwirq, pctrl->enabled_irqs);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
- }
-
- static void msm_gpio_irq_ack(struct irq_data *d)
-@@ -631,7 +631,7 @@
-
- g = &pctrl->soc->groups[d->hwirq];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- val = readl(pctrl->regs + g->intr_status_reg);
- if (g->intr_ack_high)
-@@ -643,7 +643,7 @@
- if (test_bit(d->hwirq, pctrl->dual_edge_irqs))
- msm_gpio_update_dual_edge_pos(pctrl, g, d);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
- }
-
- static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
-@@ -656,7 +656,7 @@
-
- g = &pctrl->soc->groups[d->hwirq];
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- /*
- * For hw without possibility of detecting both edges
-@@ -730,7 +730,7 @@
- if (test_bit(d->hwirq, pctrl->dual_edge_irqs))
- msm_gpio_update_dual_edge_pos(pctrl, g, d);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
-
- if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
- __irq_set_handler_locked(d->irq, handle_level_irq);
-@@ -746,11 +746,11 @@
- struct msm_pinctrl *pctrl = to_msm_pinctrl(gc);
- unsigned long flags;
-
-- spin_lock_irqsave(&pctrl->lock, flags);
-+ raw_spin_lock_irqsave(&pctrl->lock, flags);
-
- irq_set_irq_wake(pctrl->irq, on);
-
-- spin_unlock_irqrestore(&pctrl->lock, flags);
-+ raw_spin_unlock_irqrestore(&pctrl->lock, flags);
-
- return 0;
- }
-@@ -887,7 +887,7 @@
- pctrl->soc = soc_data;
- pctrl->chip = msm_gpio_template;
-
-- spin_lock_init(&pctrl->lock);
-+ raw_spin_lock_init(&pctrl->lock);
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- pctrl->regs = devm_ioremap_resource(&pdev->dev, res);
-diff -Nur linux-4.1.39.orig/drivers/scsi/fcoe/fcoe.c linux-4.1.39/drivers/scsi/fcoe/fcoe.c
---- linux-4.1.39.orig/drivers/scsi/fcoe/fcoe.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/scsi/fcoe/fcoe.c 2017-04-18 17:56:30.593396355 +0200
-@@ -1287,7 +1287,7 @@
- struct sk_buff *skb;
- #ifdef CONFIG_SMP
- struct fcoe_percpu_s *p0;
-- unsigned targ_cpu = get_cpu();
-+ unsigned targ_cpu = get_cpu_light();
- #endif /* CONFIG_SMP */
-
- FCOE_DBG("Destroying receive thread for CPU %d\n", cpu);
-@@ -1343,7 +1343,7 @@
- kfree_skb(skb);
- spin_unlock_bh(&p->fcoe_rx_list.lock);
- }
-- put_cpu();
-+ put_cpu_light();
- #else
- /*
- * This a non-SMP scenario where the singular Rx thread is
-@@ -1567,11 +1567,11 @@
- static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen)
- {
- struct fcoe_percpu_s *fps;
-- int rc;
-+ int rc, cpu = get_cpu_light();
-
-- fps = &get_cpu_var(fcoe_percpu);
-+ fps = &per_cpu(fcoe_percpu, cpu);
- rc = fcoe_get_paged_crc_eof(skb, tlen, fps);
-- put_cpu_var(fcoe_percpu);
-+ put_cpu_light();
-
- return rc;
- }
-@@ -1767,11 +1767,11 @@
- return 0;
- }
-
-- stats = per_cpu_ptr(lport->stats, get_cpu());
-+ stats = per_cpu_ptr(lport->stats, get_cpu_light());
- stats->InvalidCRCCount++;
- if (stats->InvalidCRCCount < 5)
- printk(KERN_WARNING "fcoe: dropping frame with CRC error\n");
-- put_cpu();
-+ put_cpu_light();
- return -EINVAL;
- }
-
-@@ -1815,7 +1815,7 @@
- */
- hp = (struct fcoe_hdr *) skb_network_header(skb);
-
-- stats = per_cpu_ptr(lport->stats, get_cpu());
-+ stats = per_cpu_ptr(lport->stats, get_cpu_light());
- if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {
- if (stats->ErrorFrames < 5)
- printk(KERN_WARNING "fcoe: FCoE version "
-@@ -1847,13 +1847,13 @@
- goto drop;
-
- if (!fcoe_filter_frames(lport, fp)) {
-- put_cpu();
-+ put_cpu_light();
- fc_exch_recv(lport, fp);
- return;
- }
- drop:
- stats->ErrorFrames++;
-- put_cpu();
-+ put_cpu_light();
- kfree_skb(skb);
- }
-
-diff -Nur linux-4.1.39.orig/drivers/scsi/fcoe/fcoe_ctlr.c linux-4.1.39/drivers/scsi/fcoe/fcoe_ctlr.c
---- linux-4.1.39.orig/drivers/scsi/fcoe/fcoe_ctlr.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/scsi/fcoe/fcoe_ctlr.c 2017-04-18 17:56:30.593396355 +0200
-@@ -831,7 +831,7 @@
-
- INIT_LIST_HEAD(&del_list);
-
-- stats = per_cpu_ptr(fip->lp->stats, get_cpu());
-+ stats = per_cpu_ptr(fip->lp->stats, get_cpu_light());
-
- list_for_each_entry_safe(fcf, next, &fip->fcfs, list) {
- deadline = fcf->time + fcf->fka_period + fcf->fka_period / 2;
-@@ -867,7 +867,7 @@
- sel_time = fcf->time;
- }
- }
-- put_cpu();
-+ put_cpu_light();
-
- list_for_each_entry_safe(fcf, next, &del_list, list) {
- /* Removes fcf from current list */
-diff -Nur linux-4.1.39.orig/drivers/scsi/libfc/fc_exch.c linux-4.1.39/drivers/scsi/libfc/fc_exch.c
---- linux-4.1.39.orig/drivers/scsi/libfc/fc_exch.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/scsi/libfc/fc_exch.c 2017-04-18 17:56:30.593396355 +0200
-@@ -814,10 +814,10 @@
- }
- memset(ep, 0, sizeof(*ep));
-
-- cpu = get_cpu();
-+ cpu = get_cpu_light();
- pool = per_cpu_ptr(mp->pool, cpu);
- spin_lock_bh(&pool->lock);
-- put_cpu();
-+ put_cpu_light();
-
- /* peek cache of free slot */
- if (pool->left != FC_XID_UNKNOWN) {
-diff -Nur linux-4.1.39.orig/drivers/scsi/libsas/sas_ata.c linux-4.1.39/drivers/scsi/libsas/sas_ata.c
---- linux-4.1.39.orig/drivers/scsi/libsas/sas_ata.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/scsi/libsas/sas_ata.c 2017-04-18 17:56:30.593396355 +0200
-@@ -190,7 +190,7 @@
- /* TODO: audit callers to ensure they are ready for qc_issue to
- * unconditionally re-enable interrupts
- */
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- spin_unlock(ap->lock);
-
- /* If the device fell off, no sense in issuing commands */
-@@ -255,7 +255,7 @@
-
- out:
- spin_lock(ap->lock);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- return ret;
- }
-
-diff -Nur linux-4.1.39.orig/drivers/scsi/qla2xxx/qla_inline.h linux-4.1.39/drivers/scsi/qla2xxx/qla_inline.h
---- linux-4.1.39.orig/drivers/scsi/qla2xxx/qla_inline.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/scsi/qla2xxx/qla_inline.h 2017-04-18 17:56:30.593396355 +0200
-@@ -59,12 +59,12 @@
- {
- unsigned long flags;
- struct qla_hw_data *ha = rsp->hw;
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- if (IS_P3P_TYPE(ha))
- qla82xx_poll(0, rsp);
- else
- ha->isp_ops->intr_handler(0, rsp);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- }
-
- static inline uint8_t *
-diff -Nur linux-4.1.39.orig/drivers/thermal/x86_pkg_temp_thermal.c linux-4.1.39/drivers/thermal/x86_pkg_temp_thermal.c
---- linux-4.1.39.orig/drivers/thermal/x86_pkg_temp_thermal.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/thermal/x86_pkg_temp_thermal.c 2017-04-18 17:56:30.593396355 +0200
-@@ -29,6 +29,7 @@
- #include <linux/pm.h>
- #include <linux/thermal.h>
- #include <linux/debugfs.h>
-+#include <linux/work-simple.h>
- #include <asm/cpu_device_id.h>
- #include <asm/mce.h>
-
-@@ -352,7 +353,7 @@
- }
- }
-
--static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
-+static void platform_thermal_notify_work(struct swork_event *event)
- {
- unsigned long flags;
- int cpu = smp_processor_id();
-@@ -369,7 +370,7 @@
- pkg_work_scheduled[phy_id]) {
- disable_pkg_thres_interrupt();
- spin_unlock_irqrestore(&pkg_work_lock, flags);
-- return -EINVAL;
-+ return;
- }
- pkg_work_scheduled[phy_id] = 1;
- spin_unlock_irqrestore(&pkg_work_lock, flags);
-@@ -378,9 +379,48 @@
- schedule_delayed_work_on(cpu,
- &per_cpu(pkg_temp_thermal_threshold_work, cpu),
- msecs_to_jiffies(notify_delay_ms));
-+}
-+
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+static struct swork_event notify_work;
-+
-+static int thermal_notify_work_init(void)
-+{
-+ int err;
-+
-+ err = swork_get();
-+ if (err)
-+ return err;
-+
-+ INIT_SWORK(&notify_work, platform_thermal_notify_work);
- return 0;
- }
-
-+static void thermal_notify_work_cleanup(void)
-+{
-+ swork_put();
-+}
-+
-+static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
-+{
-+ swork_queue(&notify_work);
-+ return 0;
-+}
-+
-+#else /* !CONFIG_PREEMPT_RT_FULL */
-+
-+static int thermal_notify_work_init(void) { return 0; }
-+
-+static void thermal_notify_work_cleanup(void) { }
-+
-+static int pkg_temp_thermal_platform_thermal_notify(__u64 msr_val)
-+{
-+ platform_thermal_notify_work(NULL);
-+
-+ return 0;
-+}
-+#endif /* CONFIG_PREEMPT_RT_FULL */
-+
- static int find_siblings_cpu(int cpu)
- {
- int i;
-@@ -584,6 +624,9 @@
- if (!x86_match_cpu(pkg_temp_thermal_ids))
- return -ENODEV;
-
-+ if (!thermal_notify_work_init())
-+ return -ENODEV;
-+
- spin_lock_init(&pkg_work_lock);
- platform_thermal_package_notify =
- pkg_temp_thermal_platform_thermal_notify;
-@@ -608,7 +651,7 @@
- kfree(pkg_work_scheduled);
- platform_thermal_package_notify = NULL;
- platform_thermal_package_rate_control = NULL;
--
-+ thermal_notify_work_cleanup();
- return -ENODEV;
- }
-
-@@ -633,6 +676,7 @@
- mutex_unlock(&phy_dev_list_mutex);
- platform_thermal_package_notify = NULL;
- platform_thermal_package_rate_control = NULL;
-+ thermal_notify_work_cleanup();
- for_each_online_cpu(i)
- cancel_delayed_work_sync(
- &per_cpu(pkg_temp_thermal_threshold_work, i));
-diff -Nur linux-4.1.39.orig/drivers/tty/serial/8250/8250_core.c linux-4.1.39/drivers/tty/serial/8250/8250_core.c
---- linux-4.1.39.orig/drivers/tty/serial/8250/8250_core.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/tty/serial/8250/8250_core.c 2017-04-18 17:56:30.593396355 +0200
-@@ -36,6 +36,7 @@
- #include <linux/nmi.h>
- #include <linux/mutex.h>
- #include <linux/slab.h>
-+#include <linux/kdb.h>
- #include <linux/uaccess.h>
- #include <linux/pm_runtime.h>
- #ifdef CONFIG_SPARC
-@@ -80,7 +81,16 @@
- #define DEBUG_INTR(fmt...) do { } while (0)
- #endif
-
--#define PASS_LIMIT 512
-+/*
-+ * On -rt we can have a more delays, and legitimately
-+ * so - so don't drop work spuriously and spam the
-+ * syslog:
-+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+# define PASS_LIMIT 1000000
-+#else
-+# define PASS_LIMIT 512
-+#endif
-
- #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
-
-@@ -3366,7 +3376,7 @@
-
- if (port->sysrq)
- locked = 0;
-- else if (oops_in_progress)
-+ else if (oops_in_progress || in_kdb_printk())
- locked = spin_trylock_irqsave(&port->lock, flags);
- else
- spin_lock_irqsave(&port->lock, flags);
-diff -Nur linux-4.1.39.orig/drivers/tty/serial/amba-pl011.c linux-4.1.39/drivers/tty/serial/amba-pl011.c
---- linux-4.1.39.orig/drivers/tty/serial/amba-pl011.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/tty/serial/amba-pl011.c 2017-04-18 17:56:30.597396510 +0200
-@@ -2000,13 +2000,19 @@
-
- clk_enable(uap->clk);
-
-- local_irq_save(flags);
-+ /*
-+ * local_irq_save(flags);
-+ *
-+ * This local_irq_save() is nonsense. If we come in via sysrq
-+ * handling then interrupts are already disabled. Aside of
-+ * that the port.sysrq check is racy on SMP regardless.
-+ */
- if (uap->port.sysrq)
- locked = 0;
- else if (oops_in_progress)
-- locked = spin_trylock(&uap->port.lock);
-+ locked = spin_trylock_irqsave(&uap->port.lock, flags);
- else
-- spin_lock(&uap->port.lock);
-+ spin_lock_irqsave(&uap->port.lock, flags);
-
- /*
- * First save the CR then disable the interrupts
-@@ -2028,8 +2034,7 @@
- writew(old_cr, uap->port.membase + UART011_CR);
-
- if (locked)
-- spin_unlock(&uap->port.lock);
-- local_irq_restore(flags);
-+ spin_unlock_irqrestore(&uap->port.lock, flags);
-
- clk_disable(uap->clk);
- }
-diff -Nur linux-4.1.39.orig/drivers/tty/serial/omap-serial.c linux-4.1.39/drivers/tty/serial/omap-serial.c
---- linux-4.1.39.orig/drivers/tty/serial/omap-serial.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/tty/serial/omap-serial.c 2017-04-18 17:56:30.597396510 +0200
-@@ -1282,13 +1282,10 @@
-
- pm_runtime_get_sync(up->dev);
-
-- local_irq_save(flags);
-- if (up->port.sysrq)
-- locked = 0;
-- else if (oops_in_progress)
-- locked = spin_trylock(&up->port.lock);
-+ if (up->port.sysrq || oops_in_progress)
-+ locked = spin_trylock_irqsave(&up->port.lock, flags);
- else
-- spin_lock(&up->port.lock);
-+ spin_lock_irqsave(&up->port.lock, flags);
-
- /*
- * First save the IER then disable the interrupts
-@@ -1317,8 +1314,7 @@
- pm_runtime_mark_last_busy(up->dev);
- pm_runtime_put_autosuspend(up->dev);
- if (locked)
-- spin_unlock(&up->port.lock);
-- local_irq_restore(flags);
-+ spin_unlock_irqrestore(&up->port.lock, flags);
- }
-
- static int __init
-diff -Nur linux-4.1.39.orig/drivers/usb/core/hcd.c linux-4.1.39/drivers/usb/core/hcd.c
---- linux-4.1.39.orig/drivers/usb/core/hcd.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/usb/core/hcd.c 2017-04-18 17:56:30.597396510 +0200
-@@ -1684,9 +1684,9 @@
- * and no one may trigger the above deadlock situation when
- * running complete() in tasklet.
- */
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- urb->complete(urb);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
-
- usb_anchor_resume_wakeups(anchor);
- atomic_dec(&urb->use_count);
-diff -Nur linux-4.1.39.orig/drivers/usb/gadget/function/f_fs.c linux-4.1.39/drivers/usb/gadget/function/f_fs.c
---- linux-4.1.39.orig/drivers/usb/gadget/function/f_fs.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/usb/gadget/function/f_fs.c 2017-04-18 17:56:30.597396510 +0200
-@@ -1404,7 +1404,7 @@
- pr_info("%s(): freeing\n", __func__);
- ffs_data_clear(ffs);
- BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
-- waitqueue_active(&ffs->ep0req_completion.wait));
-+ swaitqueue_active(&ffs->ep0req_completion.wait));
- kfree(ffs->dev_name);
- kfree(ffs);
- }
-diff -Nur linux-4.1.39.orig/drivers/usb/gadget/legacy/inode.c linux-4.1.39/drivers/usb/gadget/legacy/inode.c
---- linux-4.1.39.orig/drivers/usb/gadget/legacy/inode.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/usb/gadget/legacy/inode.c 2017-04-18 17:56:30.597396510 +0200
-@@ -345,7 +345,7 @@
- spin_unlock_irq (&epdata->dev->lock);
-
- if (likely (value == 0)) {
-- value = wait_event_interruptible (done.wait, done.done);
-+ value = swait_event_interruptible (done.wait, done.done);
- if (value != 0) {
- spin_lock_irq (&epdata->dev->lock);
- if (likely (epdata->ep != NULL)) {
-@@ -354,7 +354,7 @@
- usb_ep_dequeue (epdata->ep, epdata->req);
- spin_unlock_irq (&epdata->dev->lock);
-
-- wait_event (done.wait, done.done);
-+ swait_event (done.wait, done.done);
- if (epdata->status == -ECONNRESET)
- epdata->status = -EINTR;
- } else {
-diff -Nur linux-4.1.39.orig/drivers/usb/gadget/udc/atmel_usba_udc.c linux-4.1.39/drivers/usb/gadget/udc/atmel_usba_udc.c
---- linux-4.1.39.orig/drivers/usb/gadget/udc/atmel_usba_udc.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/usb/gadget/udc/atmel_usba_udc.c 2017-04-18 17:56:30.597396510 +0200
-@@ -17,7 +17,9 @@
- #include <linux/device.h>
- #include <linux/dma-mapping.h>
- #include <linux/list.h>
-+#include <linux/mfd/syscon.h>
- #include <linux/platform_device.h>
-+#include <linux/regmap.h>
- #include <linux/usb/ch9.h>
- #include <linux/usb/gadget.h>
- #include <linux/usb/atmel_usba_udc.h>
-@@ -1889,20 +1891,15 @@
- #ifdef CONFIG_OF
- static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on)
- {
-- unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
--
-- if (is_on)
-- at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
-- else
-- at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
-+ regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN,
-+ is_on ? AT91_PMC_BIASEN : 0);
- }
-
- static void at91sam9g45_pulse_bias(struct usba_udc *udc)
- {
-- unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
--
-- at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
-- at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
-+ regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN, 0);
-+ regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN,
-+ AT91_PMC_BIASEN);
- }
-
- static const struct usba_udc_errata at91sam9rl_errata = {
-@@ -1939,6 +1936,9 @@
- return ERR_PTR(-EINVAL);
-
- udc->errata = match->data;
-+ udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
-+ if (udc->errata && IS_ERR(udc->pmc))
-+ return ERR_CAST(udc->pmc);
-
- udc->num_ep = 0;
-
-diff -Nur linux-4.1.39.orig/drivers/usb/gadget/udc/atmel_usba_udc.h linux-4.1.39/drivers/usb/gadget/udc/atmel_usba_udc.h
---- linux-4.1.39.orig/drivers/usb/gadget/udc/atmel_usba_udc.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/drivers/usb/gadget/udc/atmel_usba_udc.h 2017-04-18 17:56:30.597396510 +0200
-@@ -354,6 +354,8 @@
- struct dentry *debugfs_root;
- struct dentry *debugfs_regs;
- #endif
-+
-+ struct regmap *pmc;
- };
-
- static inline struct usba_ep *to_usba_ep(struct usb_ep *ep)
-diff -Nur linux-4.1.39.orig/fs/aio.c linux-4.1.39/fs/aio.c
---- linux-4.1.39.orig/fs/aio.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/aio.c 2017-04-18 17:56:30.597396510 +0200
-@@ -40,6 +40,7 @@
- #include <linux/ramfs.h>
- #include <linux/percpu-refcount.h>
- #include <linux/mount.h>
-+#include <linux/work-simple.h>
-
- #include <asm/kmap_types.h>
- #include <asm/uaccess.h>
-@@ -115,7 +116,7 @@
- struct page **ring_pages;
- long nr_pages;
-
-- struct work_struct free_work;
-+ struct swork_event free_work;
-
- /*
- * signals when all in-flight requests are done
-@@ -253,6 +254,7 @@
- .mount = aio_mount,
- .kill_sb = kill_anon_super,
- };
-+ BUG_ON(swork_get());
- aio_mnt = kern_mount(&aio_fs);
- if (IS_ERR(aio_mnt))
- panic("Failed to create aio fs mount.");
-@@ -559,9 +561,9 @@
- return cancel(&kiocb->common);
- }
-
--static void free_ioctx(struct work_struct *work)
-+static void free_ioctx(struct swork_event *sev)
- {
-- struct kioctx *ctx = container_of(work, struct kioctx, free_work);
-+ struct kioctx *ctx = container_of(sev, struct kioctx, free_work);
-
- pr_debug("freeing %p\n", ctx);
-
-@@ -580,8 +582,8 @@
- if (ctx->rq_wait && atomic_dec_and_test(&ctx->rq_wait->count))
- complete(&ctx->rq_wait->comp);
-
-- INIT_WORK(&ctx->free_work, free_ioctx);
-- schedule_work(&ctx->free_work);
-+ INIT_SWORK(&ctx->free_work, free_ioctx);
-+ swork_queue(&ctx->free_work);
- }
-
- /*
-@@ -589,9 +591,9 @@
- * and ctx->users has dropped to 0, so we know no more kiocbs can be submitted -
- * now it's safe to cancel any that need to be.
- */
--static void free_ioctx_users(struct percpu_ref *ref)
-+static void free_ioctx_users_work(struct swork_event *sev)
- {
-- struct kioctx *ctx = container_of(ref, struct kioctx, users);
-+ struct kioctx *ctx = container_of(sev, struct kioctx, free_work);
- struct aio_kiocb *req;
-
- spin_lock_irq(&ctx->ctx_lock);
-@@ -610,6 +612,14 @@
- percpu_ref_put(&ctx->reqs);
- }
-
-+static void free_ioctx_users(struct percpu_ref *ref)
-+{
-+ struct kioctx *ctx = container_of(ref, struct kioctx, users);
-+
-+ INIT_SWORK(&ctx->free_work, free_ioctx_users_work);
-+ swork_queue(&ctx->free_work);
-+}
-+
- static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
- {
- unsigned i, new_nr;
-diff -Nur linux-4.1.39.orig/fs/autofs4/autofs_i.h linux-4.1.39/fs/autofs4/autofs_i.h
---- linux-4.1.39.orig/fs/autofs4/autofs_i.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/autofs4/autofs_i.h 2017-04-18 17:56:30.597396510 +0200
-@@ -34,6 +34,7 @@
- #include <linux/sched.h>
- #include <linux/mount.h>
- #include <linux/namei.h>
-+#include <linux/delay.h>
- #include <asm/current.h>
- #include <asm/uaccess.h>
-
-diff -Nur linux-4.1.39.orig/fs/autofs4/expire.c linux-4.1.39/fs/autofs4/expire.c
---- linux-4.1.39.orig/fs/autofs4/expire.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/autofs4/expire.c 2017-04-18 17:56:30.597396510 +0200
-@@ -150,7 +150,7 @@
- parent = p->d_parent;
- if (!spin_trylock(&parent->d_lock)) {
- spin_unlock(&p->d_lock);
-- cpu_relax();
-+ cpu_chill();
- goto relock;
- }
- spin_unlock(&p->d_lock);
-diff -Nur linux-4.1.39.orig/fs/buffer.c linux-4.1.39/fs/buffer.c
---- linux-4.1.39.orig/fs/buffer.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/buffer.c 2017-04-18 17:56:30.597396510 +0200
-@@ -301,8 +301,7 @@
- * decide that the page is now completely done.
- */
- first = page_buffers(page);
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
-+ flags = bh_uptodate_lock_irqsave(first);
- clear_buffer_async_read(bh);
- unlock_buffer(bh);
- tmp = bh;
-@@ -315,8 +314,7 @@
- }
- tmp = tmp->b_this_page;
- } while (tmp != bh);
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(first, flags);
-
- /*
- * If none of the buffers had errors and they are all
-@@ -328,9 +326,7 @@
- return;
-
- still_busy:
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-- return;
-+ bh_uptodate_unlock_irqrestore(first, flags);
- }
-
- /*
-@@ -358,8 +354,7 @@
- }
-
- first = page_buffers(page);
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
-+ flags = bh_uptodate_lock_irqsave(first);
-
- clear_buffer_async_write(bh);
- unlock_buffer(bh);
-@@ -371,15 +366,12 @@
- }
- tmp = tmp->b_this_page;
- }
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(first, flags);
- end_page_writeback(page);
- return;
-
- still_busy:
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-- return;
-+ bh_uptodate_unlock_irqrestore(first, flags);
- }
- EXPORT_SYMBOL(end_buffer_async_write);
-
-@@ -3325,6 +3317,7 @@
- struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags);
- if (ret) {
- INIT_LIST_HEAD(&ret->b_assoc_buffers);
-+ buffer_head_init_locks(ret);
- preempt_disable();
- __this_cpu_inc(bh_accounting.nr);
- recalc_bh_state();
-diff -Nur linux-4.1.39.orig/fs/dcache.c linux-4.1.39/fs/dcache.c
---- linux-4.1.39.orig/fs/dcache.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/dcache.c 2017-04-18 17:56:30.597396510 +0200
-@@ -19,6 +19,7 @@
- #include <linux/mm.h>
- #include <linux/fs.h>
- #include <linux/fsnotify.h>
-+#include <linux/delay.h>
- #include <linux/slab.h>
- #include <linux/init.h>
- #include <linux/hash.h>
-@@ -747,6 +748,8 @@
- */
- void dput(struct dentry *dentry)
- {
-+ struct dentry *parent;
-+
- if (unlikely(!dentry))
- return;
-
-@@ -783,9 +786,18 @@
- return;
-
- kill_it:
-- dentry = dentry_kill(dentry);
-- if (dentry) {
-- cond_resched();
-+ parent = dentry_kill(dentry);
-+ if (parent) {
-+ int r;
-+
-+ if (parent == dentry) {
-+ /* the task with the highest priority won't schedule */
-+ r = cond_resched();
-+ if (!r)
-+ cpu_chill();
-+ } else {
-+ dentry = parent;
-+ }
- goto repeat;
- }
- }
-@@ -2394,7 +2406,7 @@
- if (dentry->d_lockref.count == 1) {
- if (!spin_trylock(&inode->i_lock)) {
- spin_unlock(&dentry->d_lock);
-- cpu_relax();
-+ cpu_chill();
- goto again;
- }
- dentry->d_flags &= ~DCACHE_CANT_MOUNT;
-diff -Nur linux-4.1.39.orig/fs/eventpoll.c linux-4.1.39/fs/eventpoll.c
---- linux-4.1.39.orig/fs/eventpoll.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/eventpoll.c 2017-04-18 17:56:30.601396665 +0200
-@@ -505,12 +505,12 @@
- */
- static void ep_poll_safewake(wait_queue_head_t *wq)
- {
-- int this_cpu = get_cpu();
-+ int this_cpu = get_cpu_light();
-
- ep_call_nested(&poll_safewake_ncalls, EP_MAX_NESTS,
- ep_poll_wakeup_proc, NULL, wq, (void *) (long) this_cpu);
-
-- put_cpu();
-+ put_cpu_light();
- }
-
- static void ep_remove_wait_queue(struct eppoll_entry *pwq)
-diff -Nur linux-4.1.39.orig/fs/exec.c linux-4.1.39/fs/exec.c
---- linux-4.1.39.orig/fs/exec.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/exec.c 2017-04-18 17:56:30.601396665 +0200
-@@ -859,12 +859,14 @@
- }
- }
- task_lock(tsk);
-+ preempt_disable_rt();
- active_mm = tsk->active_mm;
- tsk->mm = mm;
- tsk->active_mm = mm;
- activate_mm(active_mm, mm);
- tsk->mm->vmacache_seqnum = 0;
- vmacache_flush(tsk);
-+ preempt_enable_rt();
- task_unlock(tsk);
- if (old_mm) {
- up_read(&old_mm->mmap_sem);
-diff -Nur linux-4.1.39.orig/fs/f2fs/f2fs.h linux-4.1.39/fs/f2fs/f2fs.h
---- linux-4.1.39.orig/fs/f2fs/f2fs.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/f2fs/f2fs.h 2017-04-18 17:56:30.601396665 +0200
-@@ -22,7 +22,6 @@
-
- #ifdef CONFIG_F2FS_CHECK_FS
- #define f2fs_bug_on(sbi, condition) BUG_ON(condition)
--#define f2fs_down_write(x, y) down_write_nest_lock(x, y)
- #else
- #define f2fs_bug_on(sbi, condition) \
- do { \
-@@ -31,7 +30,6 @@
- set_sbi_flag(sbi, SBI_NEED_FSCK); \
- } \
- } while (0)
--#define f2fs_down_write(x, y) down_write(x)
- #endif
-
- /*
-@@ -838,7 +836,7 @@
-
- static inline void f2fs_lock_all(struct f2fs_sb_info *sbi)
- {
-- f2fs_down_write(&sbi->cp_rwsem, &sbi->cp_mutex);
-+ down_write(&sbi->cp_rwsem);
- }
-
- static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi)
-diff -Nur linux-4.1.39.orig/fs/jbd/checkpoint.c linux-4.1.39/fs/jbd/checkpoint.c
---- linux-4.1.39.orig/fs/jbd/checkpoint.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/jbd/checkpoint.c 2017-04-18 17:56:30.601396665 +0200
-@@ -129,6 +129,8 @@
- if (journal->j_flags & JFS_ABORT)
- return;
- spin_unlock(&journal->j_state_lock);
-+ if (current->plug)
-+ io_schedule();
- mutex_lock(&journal->j_checkpoint_mutex);
-
- /*
-diff -Nur linux-4.1.39.orig/fs/jbd2/checkpoint.c linux-4.1.39/fs/jbd2/checkpoint.c
---- linux-4.1.39.orig/fs/jbd2/checkpoint.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/jbd2/checkpoint.c 2017-04-18 17:56:30.601396665 +0200
-@@ -116,6 +116,8 @@
- nblocks = jbd2_space_needed(journal);
- while (jbd2_log_space_left(journal) < nblocks) {
- write_unlock(&journal->j_state_lock);
-+ if (current->plug)
-+ io_schedule();
- mutex_lock(&journal->j_checkpoint_mutex);
-
- /*
-diff -Nur linux-4.1.39.orig/fs/namespace.c linux-4.1.39/fs/namespace.c
---- linux-4.1.39.orig/fs/namespace.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/namespace.c 2017-04-18 17:56:30.601396665 +0200
-@@ -14,6 +14,7 @@
- #include <linux/mnt_namespace.h>
- #include <linux/user_namespace.h>
- #include <linux/namei.h>
-+#include <linux/delay.h>
- #include <linux/security.h>
- #include <linux/idr.h>
- #include <linux/init.h> /* init_rootfs */
-@@ -356,8 +357,11 @@
- * incremented count after it has set MNT_WRITE_HOLD.
- */
- smp_mb();
-- while (ACCESS_ONCE(mnt->mnt.mnt_flags) & MNT_WRITE_HOLD)
-- cpu_relax();
-+ while (ACCESS_ONCE(mnt->mnt.mnt_flags) & MNT_WRITE_HOLD) {
-+ preempt_enable();
-+ cpu_chill();
-+ preempt_disable();
-+ }
- /*
- * After the slowpath clears MNT_WRITE_HOLD, mnt_is_readonly will
- * be set to match its requirements. So we must not load that until
-diff -Nur linux-4.1.39.orig/fs/ntfs/aops.c linux-4.1.39/fs/ntfs/aops.c
---- linux-4.1.39.orig/fs/ntfs/aops.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/ntfs/aops.c 2017-04-18 17:56:30.601396665 +0200
-@@ -107,8 +107,7 @@
- "0x%llx.", (unsigned long long)bh->b_blocknr);
- }
- first = page_buffers(page);
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
-+ flags = bh_uptodate_lock_irqsave(first);
- clear_buffer_async_read(bh);
- unlock_buffer(bh);
- tmp = bh;
-@@ -123,8 +122,7 @@
- }
- tmp = tmp->b_this_page;
- } while (tmp != bh);
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(first, flags);
- /*
- * If none of the buffers had errors then we can set the page uptodate,
- * but we first have to perform the post read mst fixups, if the
-@@ -145,13 +143,13 @@
- recs = PAGE_CACHE_SIZE / rec_size;
- /* Should have been verified before we got here... */
- BUG_ON(!recs);
-- local_irq_save(flags);
-+ local_irq_save_nort(flags);
- kaddr = kmap_atomic(page);
- for (i = 0; i < recs; i++)
- post_read_mst_fixup((NTFS_RECORD*)(kaddr +
- i * rec_size), rec_size);
- kunmap_atomic(kaddr);
-- local_irq_restore(flags);
-+ local_irq_restore_nort(flags);
- flush_dcache_page(page);
- if (likely(page_uptodate && !PageError(page)))
- SetPageUptodate(page);
-@@ -159,9 +157,7 @@
- unlock_page(page);
- return;
- still_busy:
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-- return;
-+ bh_uptodate_unlock_irqrestore(first, flags);
- }
-
- /**
-diff -Nur linux-4.1.39.orig/fs/timerfd.c linux-4.1.39/fs/timerfd.c
---- linux-4.1.39.orig/fs/timerfd.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/timerfd.c 2017-04-18 17:56:30.601396665 +0200
-@@ -450,7 +450,10 @@
- break;
- }
- spin_unlock_irq(&ctx->wqh.lock);
-- cpu_relax();
-+ if (isalarm(ctx))
-+ hrtimer_wait_for_timer(&ctx->t.alarm.timer);
-+ else
-+ hrtimer_wait_for_timer(&ctx->t.tmr);
- }
-
- /*
-diff -Nur linux-4.1.39.orig/fs/xfs/xfs_inode.c linux-4.1.39/fs/xfs/xfs_inode.c
---- linux-4.1.39.orig/fs/xfs/xfs_inode.c 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/xfs/xfs_inode.c 2017-04-18 17:56:30.601396665 +0200
-@@ -164,7 +164,7 @@
- (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL));
- ASSERT((lock_flags & (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)) !=
- (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
-- ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_DEP_MASK)) == 0);
-+ ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_SUBCLASS_MASK)) == 0);
-
- if (lock_flags & XFS_IOLOCK_EXCL)
- mrupdate_nested(&ip->i_iolock, XFS_IOLOCK_DEP(lock_flags));
-@@ -212,7 +212,7 @@
- (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL));
- ASSERT((lock_flags & (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)) !=
- (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
-- ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_DEP_MASK)) == 0);
-+ ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_SUBCLASS_MASK)) == 0);
-
- if (lock_flags & XFS_IOLOCK_EXCL) {
- if (!mrtryupdate(&ip->i_iolock))
-@@ -281,7 +281,7 @@
- (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL));
- ASSERT((lock_flags & (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)) !=
- (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
-- ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_DEP_MASK)) == 0);
-+ ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_SUBCLASS_MASK)) == 0);
- ASSERT(lock_flags != 0);
-
- if (lock_flags & XFS_IOLOCK_EXCL)
-@@ -364,30 +364,38 @@
-
- /*
- * Bump the subclass so xfs_lock_inodes() acquires each lock with a different
-- * value. This shouldn't be called for page fault locking, but we also need to
-- * ensure we don't overrun the number of lockdep subclasses for the iolock or
-- * mmaplock as that is limited to 12 by the mmap lock lockdep annotations.
-+ * value. This can be called for any type of inode lock combination, including
-+ * parent locking. Care must be taken to ensure we don't overrun the subclass
-+ * storage fields in the class mask we build.
- */
- static inline int
- xfs_lock_inumorder(int lock_mode, int subclass)
- {
-+ int class = 0;
-+
-+ ASSERT(!(lock_mode & (XFS_ILOCK_PARENT | XFS_ILOCK_RTBITMAP |
-+ XFS_ILOCK_RTSUM)));
-+
- if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)) {
-- ASSERT(subclass + XFS_LOCK_INUMORDER <
-- (1 << (XFS_MMAPLOCK_SHIFT - XFS_IOLOCK_SHIFT)));
-- lock_mode |= (subclass + XFS_LOCK_INUMORDER) << XFS_IOLOCK_SHIFT;
-+ ASSERT(subclass <= XFS_IOLOCK_MAX_SUBCLASS);
-+ ASSERT(subclass + XFS_IOLOCK_PARENT_VAL <
-+ MAX_LOCKDEP_SUBCLASSES);
-+ class += subclass << XFS_IOLOCK_SHIFT;
-+ if (lock_mode & XFS_IOLOCK_PARENT)
-+ class += XFS_IOLOCK_PARENT_VAL << XFS_IOLOCK_SHIFT;
- }
-
- if (lock_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL)) {
-- ASSERT(subclass + XFS_LOCK_INUMORDER <
-- (1 << (XFS_ILOCK_SHIFT - XFS_MMAPLOCK_SHIFT)));
-- lock_mode |= (subclass + XFS_LOCK_INUMORDER) <<
-- XFS_MMAPLOCK_SHIFT;
-+ ASSERT(subclass <= XFS_MMAPLOCK_MAX_SUBCLASS);
-+ class += subclass << XFS_MMAPLOCK_SHIFT;
- }
-
-- if (lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL))
-- lock_mode |= (subclass + XFS_LOCK_INUMORDER) << XFS_ILOCK_SHIFT;
-+ if (lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)) {
-+ ASSERT(subclass <= XFS_ILOCK_MAX_SUBCLASS);
-+ class += subclass << XFS_ILOCK_SHIFT;
-+ }
-
-- return lock_mode;
-+ return (lock_mode & ~XFS_LOCK_SUBCLASS_MASK) | class;
- }
-
- /*
-@@ -399,6 +407,11 @@
- * transaction (such as truncate). This can result in deadlock since the long
- * running trans might need to wait for the inode we just locked in order to
- * push the tail and free space in the log.
-+ *
-+ * xfs_lock_inodes() can only be used to lock one type of lock at a time -
-+ * the iolock, the mmaplock or the ilock, but not more than one at a time. If we
-+ * lock more than one at a time, lockdep will report false positives saying we
-+ * have violated locking orders.
- */
- void
- xfs_lock_inodes(
-@@ -409,8 +422,29 @@
- int attempts = 0, i, j, try_lock;
- xfs_log_item_t *lp;
-
-- /* currently supports between 2 and 5 inodes */
-+ /*
-+ * Currently supports between 2 and 5 inodes with exclusive locking. We
-+ * support an arbitrary depth of locking here, but absolute limits on
-+ * inodes depend on the the type of locking and the limits placed by
-+ * lockdep annotations in xfs_lock_inumorder. These are all checked by
-+ * the asserts.
-+ */
- ASSERT(ips && inodes >= 2 && inodes <= 5);
-+ ASSERT(lock_mode & (XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL |
-+ XFS_ILOCK_EXCL));
-+ ASSERT(!(lock_mode & (XFS_IOLOCK_SHARED | XFS_MMAPLOCK_SHARED |
-+ XFS_ILOCK_SHARED)));
-+ ASSERT(!(lock_mode & XFS_IOLOCK_EXCL) ||
-+ inodes <= XFS_IOLOCK_MAX_SUBCLASS + 1);
-+ ASSERT(!(lock_mode & XFS_MMAPLOCK_EXCL) ||
-+ inodes <= XFS_MMAPLOCK_MAX_SUBCLASS + 1);
-+ ASSERT(!(lock_mode & XFS_ILOCK_EXCL) ||
-+ inodes <= XFS_ILOCK_MAX_SUBCLASS + 1);
-+
-+ if (lock_mode & XFS_IOLOCK_EXCL) {
-+ ASSERT(!(lock_mode & (XFS_MMAPLOCK_EXCL | XFS_ILOCK_EXCL)));
-+ } else if (lock_mode & XFS_MMAPLOCK_EXCL)
-+ ASSERT(!(lock_mode & XFS_ILOCK_EXCL));
-
- try_lock = 0;
- i = 0;
-diff -Nur linux-4.1.39.orig/fs/xfs/xfs_inode.h linux-4.1.39/fs/xfs/xfs_inode.h
---- linux-4.1.39.orig/fs/xfs/xfs_inode.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/fs/xfs/xfs_inode.h 2017-04-18 17:56:30.601396665 +0200
-@@ -284,9 +284,9 @@
- * Flags for lockdep annotations.
- *
- * XFS_LOCK_PARENT - for directory operations that require locking a
-- * parent directory inode and a child entry inode. The parent gets locked
-- * with this flag so it gets a lockdep subclass of 1 and the child entry
-- * lock will have a lockdep subclass of 0.
-+ * parent directory inode and a child entry inode. IOLOCK requires nesting,
-+ * MMAPLOCK does not support this class, ILOCK requires a single subclass
-+ * to differentiate parent from child.
- *
- * XFS_LOCK_RTBITMAP/XFS_LOCK_RTSUM - the realtime device bitmap and summary
- * inodes do not participate in the normal lock order, and thus have their
-@@ -295,30 +295,63 @@
- * XFS_LOCK_INUMORDER - for locking several inodes at the some time
- * with xfs_lock_inodes(). This flag is used as the starting subclass
- * and each subsequent lock acquired will increment the subclass by one.
-- * So the first lock acquired will have a lockdep subclass of 4, the
-- * second lock will have a lockdep subclass of 5, and so on. It is
-- * the responsibility of the class builder to shift this to the correct
-- * portion of the lock_mode lockdep mask.
-+ * However, MAX_LOCKDEP_SUBCLASSES == 8, which means we are greatly
-+ * limited to the subclasses we can represent via nesting. We need at least
-+ * 5 inodes nest depth for the ILOCK through rename, and we also have to support
-+ * XFS_ILOCK_PARENT, which gives 6 subclasses. Then we have XFS_ILOCK_RTBITMAP
-+ * and XFS_ILOCK_RTSUM, which are another 2 unique subclasses, so that's all
-+ * 8 subclasses supported by lockdep.
-+ *
-+ * This also means we have to number the sub-classes in the lowest bits of
-+ * the mask we keep, and we have to ensure we never exceed 3 bits of lockdep
-+ * mask and we can't use bit-masking to build the subclasses. What a mess.
-+ *
-+ * Bit layout:
-+ *
-+ * Bit Lock Region
-+ * 16-19 XFS_IOLOCK_SHIFT dependencies
-+ * 20-23 XFS_MMAPLOCK_SHIFT dependencies
-+ * 24-31 XFS_ILOCK_SHIFT dependencies
-+ *
-+ * IOLOCK values
-+ *
-+ * 0-3 subclass value
-+ * 4-7 PARENT subclass values
-+ *
-+ * MMAPLOCK values
-+ *
-+ * 0-3 subclass value
-+ * 4-7 unused
-+ *
-+ * ILOCK values
-+ * 0-4 subclass values
-+ * 5 PARENT subclass (not nestable)
-+ * 6 RTBITMAP subclass (not nestable)
-+ * 7 RTSUM subclass (not nestable)
-+ *
- */
--#define XFS_LOCK_PARENT 1
--#define XFS_LOCK_RTBITMAP 2
--#define XFS_LOCK_RTSUM 3
--#define XFS_LOCK_INUMORDER 4
--
--#define XFS_IOLOCK_SHIFT 16
--#define XFS_IOLOCK_PARENT (XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT)
-+#define XFS_IOLOCK_SHIFT 16
-+#define XFS_IOLOCK_PARENT_VAL 4
-+#define XFS_IOLOCK_MAX_SUBCLASS (XFS_IOLOCK_PARENT_VAL - 1)
-+#define XFS_IOLOCK_DEP_MASK 0x000f0000
-+#define XFS_IOLOCK_PARENT (XFS_IOLOCK_PARENT_VAL << XFS_IOLOCK_SHIFT)
-
--#define XFS_MMAPLOCK_SHIFT 20
-+#define XFS_MMAPLOCK_SHIFT 20
-+#define XFS_MMAPLOCK_NUMORDER 0
-+#define XFS_MMAPLOCK_MAX_SUBCLASS 3
-+#define XFS_MMAPLOCK_DEP_MASK 0x00f00000
-
--#define XFS_ILOCK_SHIFT 24
--#define XFS_ILOCK_PARENT (XFS_LOCK_PARENT << XFS_ILOCK_SHIFT)
--#define XFS_ILOCK_RTBITMAP (XFS_LOCK_RTBITMAP << XFS_ILOCK_SHIFT)
--#define XFS_ILOCK_RTSUM (XFS_LOCK_RTSUM << XFS_ILOCK_SHIFT)
-+#define XFS_ILOCK_SHIFT 24
-+#define XFS_ILOCK_PARENT_VAL 5
-+#define XFS_ILOCK_MAX_SUBCLASS (XFS_ILOCK_PARENT_VAL - 1)
-+#define XFS_ILOCK_RTBITMAP_VAL 6
-+#define XFS_ILOCK_RTSUM_VAL 7
-+#define XFS_ILOCK_DEP_MASK 0xff000000
-+#define XFS_ILOCK_PARENT (XFS_ILOCK_PARENT_VAL << XFS_ILOCK_SHIFT)
-+#define XFS_ILOCK_RTBITMAP (XFS_ILOCK_RTBITMAP_VAL << XFS_ILOCK_SHIFT)
-+#define XFS_ILOCK_RTSUM (XFS_ILOCK_RTSUM_VAL << XFS_ILOCK_SHIFT)
-
--#define XFS_IOLOCK_DEP_MASK 0x000f0000
--#define XFS_MMAPLOCK_DEP_MASK 0x00f00000
--#define XFS_ILOCK_DEP_MASK 0xff000000
--#define XFS_LOCK_DEP_MASK (XFS_IOLOCK_DEP_MASK | \
-+#define XFS_LOCK_SUBCLASS_MASK (XFS_IOLOCK_DEP_MASK | \
- XFS_MMAPLOCK_DEP_MASK | \
- XFS_ILOCK_DEP_MASK)
-
-diff -Nur linux-4.1.39.orig/include/acpi/platform/aclinux.h linux-4.1.39/include/acpi/platform/aclinux.h
---- linux-4.1.39.orig/include/acpi/platform/aclinux.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/acpi/platform/aclinux.h 2017-04-18 17:56:30.601396665 +0200
-@@ -123,6 +123,7 @@
-
- #define acpi_cache_t struct kmem_cache
- #define acpi_spinlock spinlock_t *
-+#define acpi_raw_spinlock raw_spinlock_t *
- #define acpi_cpu_flags unsigned long
-
- /* Use native linux version of acpi_os_allocate_zeroed */
-@@ -141,6 +142,20 @@
- #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
- #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
-
-+#define acpi_os_create_raw_lock(__handle) \
-+({ \
-+ raw_spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \
-+ \
-+ if (lock) { \
-+ *(__handle) = lock; \
-+ raw_spin_lock_init(*(__handle)); \
-+ } \
-+ lock ? AE_OK : AE_NO_MEMORY; \
-+ })
-+
-+#define acpi_os_delete_raw_lock(__handle) kfree(__handle)
-+
-+
- /*
- * OSL interfaces used by debugger/disassembler
- */
-diff -Nur linux-4.1.39.orig/include/asm-generic/bug.h linux-4.1.39/include/asm-generic/bug.h
---- linux-4.1.39.orig/include/asm-generic/bug.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/asm-generic/bug.h 2017-04-18 17:56:30.601396665 +0200
-@@ -206,6 +206,20 @@
- # define WARN_ON_SMP(x) ({0;})
- #endif
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+# define BUG_ON_RT(c) BUG_ON(c)
-+# define BUG_ON_NONRT(c) do { } while (0)
-+# define WARN_ON_RT(condition) WARN_ON(condition)
-+# define WARN_ON_NONRT(condition) do { } while (0)
-+# define WARN_ON_ONCE_NONRT(condition) do { } while (0)
-+#else
-+# define BUG_ON_RT(c) do { } while (0)
-+# define BUG_ON_NONRT(c) BUG_ON(c)
-+# define WARN_ON_RT(condition) do { } while (0)
-+# define WARN_ON_NONRT(condition) WARN_ON(condition)
-+# define WARN_ON_ONCE_NONRT(condition) WARN_ON_ONCE(condition)
-+#endif
-+
- #endif /* __ASSEMBLY__ */
-
- #endif
-diff -Nur linux-4.1.39.orig/include/asm-generic/futex.h linux-4.1.39/include/asm-generic/futex.h
---- linux-4.1.39.orig/include/asm-generic/futex.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/asm-generic/futex.h 2017-04-18 17:56:30.601396665 +0200
-@@ -8,8 +8,7 @@
- #ifndef CONFIG_SMP
- /*
- * The following implementation only for uniprocessor machines.
-- * For UP, it's relies on the fact that pagefault_disable() also disables
-- * preemption to ensure mutual exclusion.
-+ * It relies on preempt_disable() ensuring mutual exclusion.
- *
- */
-
-@@ -38,6 +37,7 @@
- if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
- oparg = 1 << oparg;
-
-+ preempt_disable();
- pagefault_disable();
-
- ret = -EFAULT;
-@@ -72,6 +72,7 @@
-
- out_pagefault_enable:
- pagefault_enable();
-+ preempt_enable();
-
- if (ret == 0) {
- switch (cmp) {
-@@ -106,6 +107,7 @@
- {
- u32 val;
-
-+ preempt_disable();
- if (unlikely(get_user(val, uaddr) != 0))
- return -EFAULT;
-
-@@ -113,6 +115,7 @@
- return -EFAULT;
-
- *uval = val;
-+ preempt_enable();
-
- return 0;
- }
-diff -Nur linux-4.1.39.orig/include/asm-generic/preempt.h linux-4.1.39/include/asm-generic/preempt.h
---- linux-4.1.39.orig/include/asm-generic/preempt.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/asm-generic/preempt.h 2017-04-18 17:56:30.601396665 +0200
-@@ -7,10 +7,10 @@
-
- static __always_inline int preempt_count(void)
- {
-- return current_thread_info()->preempt_count;
-+ return READ_ONCE(current_thread_info()->preempt_count);
- }
-
--static __always_inline int *preempt_count_ptr(void)
-+static __always_inline volatile int *preempt_count_ptr(void)
- {
- return &current_thread_info()->preempt_count;
- }
-diff -Nur linux-4.1.39.orig/include/linux/blkdev.h linux-4.1.39/include/linux/blkdev.h
---- linux-4.1.39.orig/include/linux/blkdev.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/blkdev.h 2017-04-18 17:56:30.601396665 +0200
-@@ -101,6 +101,7 @@
- struct list_head queuelist;
- union {
- struct call_single_data csd;
-+ struct work_struct work;
- unsigned long fifo_time;
- };
-
-@@ -482,7 +483,7 @@
- struct throtl_data *td;
- #endif
- struct rcu_head rcu_head;
-- wait_queue_head_t mq_freeze_wq;
-+ struct swait_head mq_freeze_wq;
- struct percpu_ref mq_usage_counter;
- struct list_head all_q_node;
-
-diff -Nur linux-4.1.39.orig/include/linux/blk-mq.h linux-4.1.39/include/linux/blk-mq.h
---- linux-4.1.39.orig/include/linux/blk-mq.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/blk-mq.h 2017-04-18 17:56:30.601396665 +0200
-@@ -202,6 +202,7 @@
-
- struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);
- struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);
-+void __blk_mq_complete_request_remote_work(struct work_struct *work);
-
- int blk_mq_request_started(struct request *rq);
- void blk_mq_start_request(struct request *rq);
-diff -Nur linux-4.1.39.orig/include/linux/bottom_half.h linux-4.1.39/include/linux/bottom_half.h
---- linux-4.1.39.orig/include/linux/bottom_half.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/bottom_half.h 2017-04-18 17:56:30.601396665 +0200
-@@ -4,6 +4,39 @@
- #include <linux/preempt.h>
- #include <linux/preempt_mask.h>
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+
-+extern void __local_bh_disable(void);
-+extern void _local_bh_enable(void);
-+extern void __local_bh_enable(void);
-+
-+static inline void local_bh_disable(void)
-+{
-+ __local_bh_disable();
-+}
-+
-+static inline void __local_bh_disable_ip(unsigned long ip, unsigned int cnt)
-+{
-+ __local_bh_disable();
-+}
-+
-+static inline void local_bh_enable(void)
-+{
-+ __local_bh_enable();
-+}
-+
-+static inline void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
-+{
-+ __local_bh_enable();
-+}
-+
-+static inline void local_bh_enable_ip(unsigned long ip)
-+{
-+ __local_bh_enable();
-+}
-+
-+#else
-+
- #ifdef CONFIG_TRACE_IRQFLAGS
- extern void __local_bh_disable_ip(unsigned long ip, unsigned int cnt);
- #else
-@@ -31,5 +64,6 @@
- {
- __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
- }
-+#endif
-
- #endif /* _LINUX_BH_H */
-diff -Nur linux-4.1.39.orig/include/linux/buffer_head.h linux-4.1.39/include/linux/buffer_head.h
---- linux-4.1.39.orig/include/linux/buffer_head.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/buffer_head.h 2017-04-18 17:56:30.601396665 +0200
-@@ -75,8 +75,52 @@
- struct address_space *b_assoc_map; /* mapping this buffer is
- associated with */
- atomic_t b_count; /* users using this buffer_head */
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ spinlock_t b_uptodate_lock;
-+#if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || \
-+ defined(CONFIG_JBD2) || defined(CONFIG_JBD2_MODULE)
-+ spinlock_t b_state_lock;
-+ spinlock_t b_journal_head_lock;
-+#endif
-+#endif
- };
-
-+static inline unsigned long bh_uptodate_lock_irqsave(struct buffer_head *bh)
-+{
-+ unsigned long flags;
-+
-+#ifndef CONFIG_PREEMPT_RT_BASE
-+ local_irq_save(flags);
-+ bit_spin_lock(BH_Uptodate_Lock, &bh->b_state);
-+#else
-+ spin_lock_irqsave(&bh->b_uptodate_lock, flags);
-+#endif
-+ return flags;
-+}
-+
-+static inline void
-+bh_uptodate_unlock_irqrestore(struct buffer_head *bh, unsigned long flags)
-+{
-+#ifndef CONFIG_PREEMPT_RT_BASE
-+ bit_spin_unlock(BH_Uptodate_Lock, &bh->b_state);
-+ local_irq_restore(flags);
-+#else
-+ spin_unlock_irqrestore(&bh->b_uptodate_lock, flags);
-+#endif
-+}
-+
-+static inline void buffer_head_init_locks(struct buffer_head *bh)
-+{
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ spin_lock_init(&bh->b_uptodate_lock);
-+#if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || \
-+ defined(CONFIG_JBD2) || defined(CONFIG_JBD2_MODULE)
-+ spin_lock_init(&bh->b_state_lock);
-+ spin_lock_init(&bh->b_journal_head_lock);
-+#endif
-+#endif
-+}
-+
- /*
- * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
- * and buffer_foo() functions.
-diff -Nur linux-4.1.39.orig/include/linux/cgroup-defs.h linux-4.1.39/include/linux/cgroup-defs.h
---- linux-4.1.39.orig/include/linux/cgroup-defs.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/cgroup-defs.h 2017-04-18 17:56:30.601396665 +0200
-@@ -124,6 +124,7 @@
- /* percpu_ref killing and RCU release */
- struct rcu_head rcu_head;
- struct work_struct destroy_work;
-+ struct swork_event destroy_swork;
- };
-
- /*
-diff -Nur linux-4.1.39.orig/include/linux/cgroup.h linux-4.1.39/include/linux/cgroup.h
---- linux-4.1.39.orig/include/linux/cgroup.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/cgroup.h 2017-04-18 17:56:30.605396820 +0200
-@@ -17,6 +17,8 @@
- #include <linux/fs.h>
- #include <linux/seq_file.h>
- #include <linux/kernfs.h>
-+#include <linux/wait.h>
-+#include <linux/work-simple.h>
-
- #include <linux/cgroup-defs.h>
-
-diff -Nur linux-4.1.39.orig/include/linux/completion.h linux-4.1.39/include/linux/completion.h
---- linux-4.1.39.orig/include/linux/completion.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/completion.h 2017-04-18 17:56:30.605396820 +0200
-@@ -7,8 +7,7 @@
- * Atomic wait-for-completion handler data structures.
- * See kernel/sched/completion.c for details.
- */
--
--#include <linux/wait.h>
-+#include <linux/wait-simple.h>
-
- /*
- * struct completion - structure used to maintain state for a "completion"
-@@ -24,11 +23,11 @@
- */
- struct completion {
- unsigned int done;
-- wait_queue_head_t wait;
-+ struct swait_head wait;
- };
-
- #define COMPLETION_INITIALIZER(work) \
-- { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
-+ { 0, SWAIT_HEAD_INITIALIZER((work).wait) }
-
- #define COMPLETION_INITIALIZER_ONSTACK(work) \
- ({ init_completion(&work); work; })
-@@ -73,7 +72,7 @@
- static inline void init_completion(struct completion *x)
- {
- x->done = 0;
-- init_waitqueue_head(&x->wait);
-+ init_swait_head(&x->wait);
- }
-
- /**
-diff -Nur linux-4.1.39.orig/include/linux/cpu.h linux-4.1.39/include/linux/cpu.h
---- linux-4.1.39.orig/include/linux/cpu.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/cpu.h 2017-04-18 17:56:30.605396820 +0200
-@@ -231,6 +231,8 @@
- extern void put_online_cpus(void);
- extern void cpu_hotplug_disable(void);
- extern void cpu_hotplug_enable(void);
-+extern void pin_current_cpu(void);
-+extern void unpin_current_cpu(void);
- #define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri)
- #define __hotcpu_notifier(fn, pri) __cpu_notifier(fn, pri)
- #define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
-@@ -249,6 +251,8 @@
- #define put_online_cpus() do { } while (0)
- #define cpu_hotplug_disable() do { } while (0)
- #define cpu_hotplug_enable() do { } while (0)
-+static inline void pin_current_cpu(void) { }
-+static inline void unpin_current_cpu(void) { }
- #define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
- #define __hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
- /* These aren't inline functions due to a GCC bug. */
-diff -Nur linux-4.1.39.orig/include/linux/delay.h linux-4.1.39/include/linux/delay.h
---- linux-4.1.39.orig/include/linux/delay.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/delay.h 2017-04-18 17:56:30.605396820 +0200
-@@ -52,4 +52,10 @@
- msleep(seconds * 1000);
- }
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+extern void cpu_chill(void);
-+#else
-+# define cpu_chill() cpu_relax()
-+#endif
-+
- #endif /* defined(_LINUX_DELAY_H) */
-diff -Nur linux-4.1.39.orig/include/linux/ftrace_event.h linux-4.1.39/include/linux/ftrace_event.h
---- linux-4.1.39.orig/include/linux/ftrace_event.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/ftrace_event.h 2017-04-18 17:56:30.605396820 +0200
-@@ -66,6 +66,9 @@
- unsigned char flags;
- unsigned char preempt_count;
- int pid;
-+ unsigned short migrate_disable;
-+ unsigned short padding;
-+ unsigned char preempt_lazy_count;
- };
-
- #define FTRACE_MAX_EVENT \
-diff -Nur linux-4.1.39.orig/include/linux/ftrace.h linux-4.1.39/include/linux/ftrace.h
---- linux-4.1.39.orig/include/linux/ftrace.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/ftrace.h 2017-04-18 17:56:30.605396820 +0200
-@@ -682,6 +682,18 @@
- #define CALLER_ADDR5 ((unsigned long)ftrace_return_address(5))
- #define CALLER_ADDR6 ((unsigned long)ftrace_return_address(6))
-
-+static inline unsigned long get_lock_parent_ip(void)
-+{
-+ unsigned long addr = CALLER_ADDR0;
-+
-+ if (!in_lock_functions(addr))
-+ return addr;
-+ addr = CALLER_ADDR1;
-+ if (!in_lock_functions(addr))
-+ return addr;
-+ return CALLER_ADDR2;
-+}
-+
- #ifdef CONFIG_IRQSOFF_TRACER
- extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
- extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
-diff -Nur linux-4.1.39.orig/include/linux/highmem.h linux-4.1.39/include/linux/highmem.h
---- linux-4.1.39.orig/include/linux/highmem.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/highmem.h 2017-04-18 17:56:30.605396820 +0200
-@@ -7,6 +7,7 @@
- #include <linux/mm.h>
- #include <linux/uaccess.h>
- #include <linux/hardirq.h>
-+#include <linux/sched.h>
-
- #include <asm/cacheflush.h>
-
-@@ -65,6 +66,7 @@
-
- static inline void *kmap_atomic(struct page *page)
- {
-+ preempt_disable_nort();
- pagefault_disable();
- return page_address(page);
- }
-@@ -73,6 +75,7 @@
- static inline void __kunmap_atomic(void *addr)
- {
- pagefault_enable();
-+ preempt_enable_nort();
- }
-
- #define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
-@@ -85,32 +88,51 @@
-
- #if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32)
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- DECLARE_PER_CPU(int, __kmap_atomic_idx);
-+#endif
-
- static inline int kmap_atomic_idx_push(void)
- {
-+#ifndef CONFIG_PREEMPT_RT_FULL
- int idx = __this_cpu_inc_return(__kmap_atomic_idx) - 1;
-
--#ifdef CONFIG_DEBUG_HIGHMEM
-+# ifdef CONFIG_DEBUG_HIGHMEM
- WARN_ON_ONCE(in_irq() && !irqs_disabled());
- BUG_ON(idx >= KM_TYPE_NR);
--#endif
-+# endif
- return idx;
-+#else
-+ current->kmap_idx++;
-+ BUG_ON(current->kmap_idx > KM_TYPE_NR);
-+ return current->kmap_idx - 1;
-+#endif
- }
-
- static inline int kmap_atomic_idx(void)
- {
-+#ifndef CONFIG_PREEMPT_RT_FULL
- return __this_cpu_read(__kmap_atomic_idx) - 1;
-+#else
-+ return current->kmap_idx - 1;
-+#endif
- }
-
- static inline void kmap_atomic_idx_pop(void)
- {
--#ifdef CONFIG_DEBUG_HIGHMEM
-+#ifndef CONFIG_PREEMPT_RT_FULL
-+# ifdef CONFIG_DEBUG_HIGHMEM
- int idx = __this_cpu_dec_return(__kmap_atomic_idx);
-
- BUG_ON(idx < 0);
--#else
-+# else
- __this_cpu_dec(__kmap_atomic_idx);
-+# endif
-+#else
-+ current->kmap_idx--;
-+# ifdef CONFIG_DEBUG_HIGHMEM
-+ BUG_ON(current->kmap_idx < 0);
-+# endif
- #endif
- }
-
-diff -Nur linux-4.1.39.orig/include/linux/hrtimer.h linux-4.1.39/include/linux/hrtimer.h
---- linux-4.1.39.orig/include/linux/hrtimer.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/hrtimer.h 2017-04-18 17:56:30.605396820 +0200
-@@ -111,6 +111,11 @@
- enum hrtimer_restart (*function)(struct hrtimer *);
- struct hrtimer_clock_base *base;
- unsigned long state;
-+ struct list_head cb_entry;
-+ int irqsafe;
-+#ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST
-+ ktime_t praecox;
-+#endif
- #ifdef CONFIG_TIMER_STATS
- int start_pid;
- void *start_site;
-@@ -147,6 +152,7 @@
- int index;
- clockid_t clockid;
- struct timerqueue_head active;
-+ struct list_head expired;
- ktime_t resolution;
- ktime_t (*get_time)(void);
- ktime_t softirq_time;
-@@ -194,6 +200,9 @@
- unsigned long nr_hangs;
- ktime_t max_hang_time;
- #endif
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ wait_queue_head_t wait;
-+#endif
- struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
- };
-
-@@ -381,6 +390,13 @@
- return hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
- }
-
-+/* Softirq preemption could deadlock timer removal */
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ extern void hrtimer_wait_for_timer(const struct hrtimer *timer);
-+#else
-+# define hrtimer_wait_for_timer(timer) do { cpu_relax(); } while (0)
-+#endif
-+
- /* Query timers: */
- extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer);
- extern int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp);
-diff -Nur linux-4.1.39.orig/include/linux/idr.h linux-4.1.39/include/linux/idr.h
---- linux-4.1.39.orig/include/linux/idr.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/idr.h 2017-04-18 17:56:30.605396820 +0200
-@@ -95,10 +95,14 @@
- * Each idr_preload() should be matched with an invocation of this
- * function. See idr_preload() for details.
- */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+void idr_preload_end(void);
-+#else
- static inline void idr_preload_end(void)
- {
- preempt_enable();
- }
-+#endif
-
- /**
- * idr_find - return pointer for given id
-diff -Nur linux-4.1.39.orig/include/linux/init_task.h linux-4.1.39/include/linux/init_task.h
---- linux-4.1.39.orig/include/linux/init_task.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/init_task.h 2017-04-18 17:56:30.605396820 +0200
-@@ -147,9 +147,16 @@
- # define INIT_PERF_EVENTS(tsk)
- #endif
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+# define INIT_TIMER_LIST .posix_timer_list = NULL,
-+#else
-+# define INIT_TIMER_LIST
-+#endif
-+
- #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
- # define INIT_VTIME(tsk) \
-- .vtime_seqlock = __SEQLOCK_UNLOCKED(tsk.vtime_seqlock), \
-+ .vtime_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.vtime_lock), \
-+ .vtime_seq = SEQCNT_ZERO(tsk.vtime_seq), \
- .vtime_snap = 0, \
- .vtime_snap_whence = VTIME_SYS,
- #else
-@@ -238,6 +245,7 @@
- .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
- .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
- .timer_slack_ns = 50000, /* 50 usec default slack */ \
-+ INIT_TIMER_LIST \
- .pids = { \
- [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
- [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
-diff -Nur linux-4.1.39.orig/include/linux/interrupt.h linux-4.1.39/include/linux/interrupt.h
---- linux-4.1.39.orig/include/linux/interrupt.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/interrupt.h 2017-04-18 17:56:30.605396820 +0200
-@@ -61,6 +61,7 @@
- * interrupt handler after suspending interrupts. For system
- * wakeup devices users need to implement wakeup detection in
- * their interrupt handlers.
-+ * IRQF_NO_SOFTIRQ_CALL - Do not process softirqs in the irq thread context (RT)
- */
- #define IRQF_SHARED 0x00000080
- #define IRQF_PROBE_SHARED 0x00000100
-@@ -74,6 +75,7 @@
- #define IRQF_NO_THREAD 0x00010000
- #define IRQF_EARLY_RESUME 0x00020000
- #define IRQF_COND_SUSPEND 0x00040000
-+#define IRQF_NO_SOFTIRQ_CALL 0x00080000
-
- #define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
-
-@@ -102,6 +104,7 @@
- * @flags: flags (see IRQF_* above)
- * @thread_fn: interrupt handler function for threaded interrupts
- * @thread: thread pointer for threaded interrupts
-+ * @secondary: pointer to secondary irqaction (force threading)
- * @thread_flags: flags related to @thread
- * @thread_mask: bitmask for keeping track of @thread activity
- * @dir: pointer to the proc/irq/NN/name entry
-@@ -113,6 +116,7 @@
- struct irqaction *next;
- irq_handler_t thread_fn;
- struct task_struct *thread;
-+ struct irqaction *secondary;
- unsigned int irq;
- unsigned int flags;
- unsigned long thread_flags;
-@@ -184,7 +188,7 @@
- #ifdef CONFIG_LOCKDEP
- # define local_irq_enable_in_hardirq() do { } while (0)
- #else
--# define local_irq_enable_in_hardirq() local_irq_enable()
-+# define local_irq_enable_in_hardirq() local_irq_enable_nort()
- #endif
-
- extern void disable_irq_nosync(unsigned int irq);
-@@ -215,6 +219,7 @@
- unsigned int irq;
- struct kref kref;
- struct work_struct work;
-+ struct list_head list;
- void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
- void (*release)(struct kref *ref);
- };
-@@ -377,9 +382,13 @@
- bool state);
-
- #ifdef CONFIG_IRQ_FORCED_THREADING
-+# ifndef CONFIG_PREEMPT_RT_BASE
- extern bool force_irqthreads;
-+# else
-+# define force_irqthreads (true)
-+# endif
- #else
--#define force_irqthreads (0)
-+#define force_irqthreads (false)
- #endif
-
- #ifndef __ARCH_SET_SOFTIRQ_PENDING
-@@ -435,9 +444,10 @@
- void (*action)(struct softirq_action *);
- };
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- asmlinkage void do_softirq(void);
- asmlinkage void __do_softirq(void);
--
-+static inline void thread_do_softirq(void) { do_softirq(); }
- #ifdef __ARCH_HAS_DO_SOFTIRQ
- void do_softirq_own_stack(void);
- #else
-@@ -446,13 +456,25 @@
- __do_softirq();
- }
- #endif
-+#else
-+extern void thread_do_softirq(void);
-+#endif
-
- extern void open_softirq(int nr, void (*action)(struct softirq_action *));
- extern void softirq_init(void);
- extern void __raise_softirq_irqoff(unsigned int nr);
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+extern void __raise_softirq_irqoff_ksoft(unsigned int nr);
-+#else
-+static inline void __raise_softirq_irqoff_ksoft(unsigned int nr)
-+{
-+ __raise_softirq_irqoff(nr);
-+}
-+#endif
-
- extern void raise_softirq_irqoff(unsigned int nr);
- extern void raise_softirq(unsigned int nr);
-+extern void softirq_check_pending_idle(void);
-
- DECLARE_PER_CPU(struct task_struct *, ksoftirqd);
-
-@@ -474,8 +496,9 @@
- to be executed on some cpu at least once after this.
- * If the tasklet is already scheduled, but its execution is still not
- started, it will be executed only once.
-- * If this tasklet is already running on another CPU (or schedule is called
-- from tasklet itself), it is rescheduled for later.
-+ * If this tasklet is already running on another CPU, it is rescheduled
-+ for later.
-+ * Schedule must not be called from the tasklet itself (a lockup occurs)
- * Tasklet is strictly serialized wrt itself, but not
- wrt another tasklets. If client needs some intertask synchronization,
- he makes it with spinlocks.
-@@ -500,27 +523,36 @@
- enum
- {
- TASKLET_STATE_SCHED, /* Tasklet is scheduled for execution */
-- TASKLET_STATE_RUN /* Tasklet is running (SMP only) */
-+ TASKLET_STATE_RUN, /* Tasklet is running (SMP only) */
-+ TASKLET_STATE_PENDING /* Tasklet is pending */
- };
-
--#ifdef CONFIG_SMP
-+#define TASKLET_STATEF_SCHED (1 << TASKLET_STATE_SCHED)
-+#define TASKLET_STATEF_RUN (1 << TASKLET_STATE_RUN)
-+#define TASKLET_STATEF_PENDING (1 << TASKLET_STATE_PENDING)
-+
-+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
- static inline int tasklet_trylock(struct tasklet_struct *t)
- {
- return !test_and_set_bit(TASKLET_STATE_RUN, &(t)->state);
- }
-
-+static inline int tasklet_tryunlock(struct tasklet_struct *t)
-+{
-+ return cmpxchg(&t->state, TASKLET_STATEF_RUN, 0) == TASKLET_STATEF_RUN;
-+}
-+
- static inline void tasklet_unlock(struct tasklet_struct *t)
- {
- smp_mb__before_atomic();
- clear_bit(TASKLET_STATE_RUN, &(t)->state);
- }
-
--static inline void tasklet_unlock_wait(struct tasklet_struct *t)
--{
-- while (test_bit(TASKLET_STATE_RUN, &(t)->state)) { barrier(); }
--}
-+extern void tasklet_unlock_wait(struct tasklet_struct *t);
-+
- #else
- #define tasklet_trylock(t) 1
-+#define tasklet_tryunlock(t) 1
- #define tasklet_unlock_wait(t) do { } while (0)
- #define tasklet_unlock(t) do { } while (0)
- #endif
-@@ -569,12 +601,7 @@
- smp_mb();
- }
-
--static inline void tasklet_enable(struct tasklet_struct *t)
--{
-- smp_mb__before_atomic();
-- atomic_dec(&t->count);
--}
--
-+extern void tasklet_enable(struct tasklet_struct *t);
- extern void tasklet_kill(struct tasklet_struct *t);
- extern void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu);
- extern void tasklet_init(struct tasklet_struct *t,
-@@ -605,6 +632,12 @@
- tasklet_kill(&ttimer->tasklet);
- }
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+extern void softirq_early_init(void);
-+#else
-+static inline void softirq_early_init(void) { }
-+#endif
-+
- /*
- * Autoprobing for irqs:
- *
-diff -Nur linux-4.1.39.orig/include/linux/io-mapping.h linux-4.1.39/include/linux/io-mapping.h
---- linux-4.1.39.orig/include/linux/io-mapping.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/io-mapping.h 2017-04-18 17:56:30.605396820 +0200
-@@ -141,6 +141,7 @@
- io_mapping_map_atomic_wc(struct io_mapping *mapping,
- unsigned long offset)
- {
-+ preempt_disable();
- pagefault_disable();
- return ((char __force __iomem *) mapping) + offset;
- }
-@@ -149,6 +150,7 @@
- io_mapping_unmap_atomic(void __iomem *vaddr)
- {
- pagefault_enable();
-+ preempt_enable();
- }
-
- /* Non-atomic map/unmap */
-diff -Nur linux-4.1.39.orig/include/linux/irqdesc.h linux-4.1.39/include/linux/irqdesc.h
---- linux-4.1.39.orig/include/linux/irqdesc.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/irqdesc.h 2017-04-18 17:56:30.605396820 +0200
-@@ -63,6 +63,7 @@
- unsigned int irqs_unhandled;
- atomic_t threads_handled;
- int threads_handled_last;
-+ u64 random_ip;
- raw_spinlock_t lock;
- struct cpumask *percpu_enabled;
- #ifdef CONFIG_SMP
-diff -Nur linux-4.1.39.orig/include/linux/irqflags.h linux-4.1.39/include/linux/irqflags.h
---- linux-4.1.39.orig/include/linux/irqflags.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/irqflags.h 2017-04-18 17:56:30.605396820 +0200
-@@ -25,8 +25,6 @@
- # define trace_softirqs_enabled(p) ((p)->softirqs_enabled)
- # define trace_hardirq_enter() do { current->hardirq_context++; } while (0)
- # define trace_hardirq_exit() do { current->hardirq_context--; } while (0)
--# define lockdep_softirq_enter() do { current->softirq_context++; } while (0)
--# define lockdep_softirq_exit() do { current->softirq_context--; } while (0)
- # define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1,
- #else
- # define trace_hardirqs_on() do { } while (0)
-@@ -39,9 +37,15 @@
- # define trace_softirqs_enabled(p) 0
- # define trace_hardirq_enter() do { } while (0)
- # define trace_hardirq_exit() do { } while (0)
-+# define INIT_TRACE_IRQFLAGS
-+#endif
-+
-+#if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PREEMPT_RT_FULL)
-+# define lockdep_softirq_enter() do { current->softirq_context++; } while (0)
-+# define lockdep_softirq_exit() do { current->softirq_context--; } while (0)
-+#else
- # define lockdep_softirq_enter() do { } while (0)
- # define lockdep_softirq_exit() do { } while (0)
--# define INIT_TRACE_IRQFLAGS
- #endif
-
- #if defined(CONFIG_IRQSOFF_TRACER) || \
-@@ -148,4 +152,23 @@
-
- #define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
-
-+/*
-+ * local_irq* variants depending on RT/!RT
-+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+# define local_irq_disable_nort() do { } while (0)
-+# define local_irq_enable_nort() do { } while (0)
-+# define local_irq_save_nort(flags) local_save_flags(flags)
-+# define local_irq_restore_nort(flags) (void)(flags)
-+# define local_irq_disable_rt() local_irq_disable()
-+# define local_irq_enable_rt() local_irq_enable()
-+#else
-+# define local_irq_disable_nort() local_irq_disable()
-+# define local_irq_enable_nort() local_irq_enable()
-+# define local_irq_save_nort(flags) local_irq_save(flags)
-+# define local_irq_restore_nort(flags) local_irq_restore(flags)
-+# define local_irq_disable_rt() do { } while (0)
-+# define local_irq_enable_rt() do { } while (0)
-+#endif
-+
- #endif
-diff -Nur linux-4.1.39.orig/include/linux/irq.h linux-4.1.39/include/linux/irq.h
---- linux-4.1.39.orig/include/linux/irq.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/irq.h 2017-04-18 17:56:30.605396820 +0200
-@@ -72,6 +72,7 @@
- * IRQ_IS_POLLED - Always polled by another interrupt. Exclude
- * it from the spurious interrupt detection
- * mechanism and from core side polling.
-+ * IRQ_NO_SOFTIRQ_CALL - No softirq processing in the irq thread context (RT)
- */
- enum {
- IRQ_TYPE_NONE = 0x00000000,
-@@ -97,13 +98,14 @@
- IRQ_NOTHREAD = (1 << 16),
- IRQ_PER_CPU_DEVID = (1 << 17),
- IRQ_IS_POLLED = (1 << 18),
-+ IRQ_NO_SOFTIRQ_CALL = (1 << 19),
- };
-
- #define IRQF_MODIFY_MASK \
- (IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \
- IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL | IRQ_NO_BALANCING | \
- IRQ_PER_CPU | IRQ_NESTED_THREAD | IRQ_NOTHREAD | IRQ_PER_CPU_DEVID | \
-- IRQ_IS_POLLED)
-+ IRQ_IS_POLLED | IRQ_NO_SOFTIRQ_CALL)
-
- #define IRQ_NO_BALANCING_MASK (IRQ_PER_CPU | IRQ_NO_BALANCING)
-
-diff -Nur linux-4.1.39.orig/include/linux/irq_work.h linux-4.1.39/include/linux/irq_work.h
---- linux-4.1.39.orig/include/linux/irq_work.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/irq_work.h 2017-04-18 17:56:30.605396820 +0200
-@@ -16,6 +16,7 @@
- #define IRQ_WORK_BUSY 2UL
- #define IRQ_WORK_FLAGS 3UL
- #define IRQ_WORK_LAZY 4UL /* Doesn't want IPI, wait for tick */
-+#define IRQ_WORK_HARD_IRQ 8UL /* Run hard IRQ context, even on RT */
-
- struct irq_work {
- unsigned long flags;
-@@ -51,4 +52,10 @@
- static inline void irq_work_run(void) { }
- #endif
-
-+#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
-+void irq_work_tick_soft(void);
-+#else
-+static inline void irq_work_tick_soft(void) { }
-+#endif
-+
- #endif /* _LINUX_IRQ_WORK_H */
-diff -Nur linux-4.1.39.orig/include/linux/jbd_common.h linux-4.1.39/include/linux/jbd_common.h
---- linux-4.1.39.orig/include/linux/jbd_common.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/jbd_common.h 2017-04-18 17:56:30.605396820 +0200
-@@ -15,32 +15,56 @@
-
- static inline void jbd_lock_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_lock(BH_State, &bh->b_state);
-+#else
-+ spin_lock(&bh->b_state_lock);
-+#endif
- }
-
- static inline int jbd_trylock_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- return bit_spin_trylock(BH_State, &bh->b_state);
-+#else
-+ return spin_trylock(&bh->b_state_lock);
-+#endif
- }
-
- static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- return bit_spin_is_locked(BH_State, &bh->b_state);
-+#else
-+ return spin_is_locked(&bh->b_state_lock);
-+#endif
- }
-
- static inline void jbd_unlock_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_unlock(BH_State, &bh->b_state);
-+#else
-+ spin_unlock(&bh->b_state_lock);
-+#endif
- }
-
- static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_lock(BH_JournalHead, &bh->b_state);
-+#else
-+ spin_lock(&bh->b_journal_head_lock);
-+#endif
- }
-
- static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_unlock(BH_JournalHead, &bh->b_state);
-+#else
-+ spin_unlock(&bh->b_journal_head_lock);
-+#endif
- }
-
- #endif
-diff -Nur linux-4.1.39.orig/include/linux/kdb.h linux-4.1.39/include/linux/kdb.h
---- linux-4.1.39.orig/include/linux/kdb.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/kdb.h 2017-04-18 17:56:30.605396820 +0200
-@@ -167,6 +167,7 @@
- extern __printf(1, 2) int kdb_printf(const char *, ...);
- typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...);
-
-+#define in_kdb_printk() (kdb_trap_printk)
- extern void kdb_init(int level);
-
- /* Access to kdb specific polling devices */
-@@ -201,6 +202,7 @@
- extern int kdb_unregister(char *);
- #else /* ! CONFIG_KGDB_KDB */
- static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
-+#define in_kdb_printk() (0)
- static inline void kdb_init(int level) {}
- static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,
- char *help, short minlen) { return 0; }
-diff -Nur linux-4.1.39.orig/include/linux/kernel.h linux-4.1.39/include/linux/kernel.h
---- linux-4.1.39.orig/include/linux/kernel.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/kernel.h 2017-04-18 17:56:30.605396820 +0200
-@@ -188,6 +188,9 @@
- */
- # define might_sleep() \
- do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
-+
-+# define might_sleep_no_state_check() \
-+ do { ___might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
- # define sched_annotate_sleep() (current->task_state_change = 0)
- #else
- static inline void ___might_sleep(const char *file, int line,
-@@ -195,6 +198,7 @@
- static inline void __might_sleep(const char *file, int line,
- int preempt_offset) { }
- # define might_sleep() do { might_resched(); } while (0)
-+# define might_sleep_no_state_check() do { might_resched(); } while (0)
- # define sched_annotate_sleep() do { } while (0)
- #endif
-
-@@ -244,7 +248,8 @@
-
- #if defined(CONFIG_MMU) && \
- (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP))
--void might_fault(void);
-+#define might_fault() __might_fault(__FILE__, __LINE__)
-+void __might_fault(const char *file, int line);
- #else
- static inline void might_fault(void) { }
- #endif
-@@ -466,6 +471,7 @@
- SYSTEM_HALT,
- SYSTEM_POWER_OFF,
- SYSTEM_RESTART,
-+ SYSTEM_SUSPEND,
- } system_state;
-
- #define TAINT_PROPRIETARY_MODULE 0
-diff -Nur linux-4.1.39.orig/include/linux/kvm_host.h linux-4.1.39/include/linux/kvm_host.h
---- linux-4.1.39.orig/include/linux/kvm_host.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/kvm_host.h 2017-04-18 17:56:30.605396820 +0200
-@@ -230,7 +230,7 @@
-
- int fpu_active;
- int guest_fpu_loaded, guest_xcr0_loaded;
-- wait_queue_head_t wq;
-+ struct swait_head wq;
- struct pid *pid;
- int sigset_active;
- sigset_t sigset;
-@@ -701,7 +701,7 @@
- }
- #endif
-
--static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
-+static inline struct swait_head *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
- {
- #ifdef __KVM_HAVE_ARCH_WQP
- return vcpu->arch.wqp;
-diff -Nur linux-4.1.39.orig/include/linux/lglock.h linux-4.1.39/include/linux/lglock.h
---- linux-4.1.39.orig/include/linux/lglock.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/lglock.h 2017-04-18 17:56:30.605396820 +0200
-@@ -34,22 +34,39 @@
- #endif
-
- struct lglock {
-+#ifndef CONFIG_PREEMPT_RT_FULL
- arch_spinlock_t __percpu *lock;
-+#else
-+ struct rt_mutex __percpu *lock;
-+#endif
- #ifdef CONFIG_DEBUG_LOCK_ALLOC
- struct lock_class_key lock_key;
- struct lockdep_map lock_dep_map;
- #endif
- };
-
--#define DEFINE_LGLOCK(name) \
-+#ifndef CONFIG_PREEMPT_RT_FULL
-+# define DEFINE_LGLOCK(name) \
- static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock) \
- = __ARCH_SPIN_LOCK_UNLOCKED; \
- struct lglock name = { .lock = &name ## _lock }
-
--#define DEFINE_STATIC_LGLOCK(name) \
-+# define DEFINE_STATIC_LGLOCK(name) \
- static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock) \
- = __ARCH_SPIN_LOCK_UNLOCKED; \
- static struct lglock name = { .lock = &name ## _lock }
-+#else
-+
-+# define DEFINE_LGLOCK(name) \
-+ static DEFINE_PER_CPU(struct rt_mutex, name ## _lock) \
-+ = __RT_MUTEX_INITIALIZER( name ## _lock); \
-+ struct lglock name = { .lock = &name ## _lock }
-+
-+# define DEFINE_STATIC_LGLOCK(name) \
-+ static DEFINE_PER_CPU(struct rt_mutex, name ## _lock) \
-+ = __RT_MUTEX_INITIALIZER( name ## _lock); \
-+ static struct lglock name = { .lock = &name ## _lock }
-+#endif
-
- void lg_lock_init(struct lglock *lg, char *name);
- void lg_local_lock(struct lglock *lg);
-@@ -59,6 +76,12 @@
- void lg_global_lock(struct lglock *lg);
- void lg_global_unlock(struct lglock *lg);
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
-+#define lg_global_trylock_relax(name) lg_global_lock(name)
-+#else
-+void lg_global_trylock_relax(struct lglock *lg);
-+#endif
-+
- #else
- /* When !CONFIG_SMP, map lglock to spinlock */
- #define lglock spinlock
-diff -Nur linux-4.1.39.orig/include/linux/list_bl.h linux-4.1.39/include/linux/list_bl.h
---- linux-4.1.39.orig/include/linux/list_bl.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/list_bl.h 2017-04-18 17:56:30.605396820 +0200
-@@ -2,6 +2,7 @@
- #define _LINUX_LIST_BL_H
-
- #include <linux/list.h>
-+#include <linux/spinlock.h>
- #include <linux/bit_spinlock.h>
-
- /*
-@@ -32,13 +33,24 @@
-
- struct hlist_bl_head {
- struct hlist_bl_node *first;
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ raw_spinlock_t lock;
-+#endif
- };
-
- struct hlist_bl_node {
- struct hlist_bl_node *next, **pprev;
- };
--#define INIT_HLIST_BL_HEAD(ptr) \
-- ((ptr)->first = NULL)
-+
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+#define INIT_HLIST_BL_HEAD(h) \
-+do { \
-+ (h)->first = NULL; \
-+ raw_spin_lock_init(&(h)->lock); \
-+} while (0)
-+#else
-+#define INIT_HLIST_BL_HEAD(h) (h)->first = NULL
-+#endif
-
- static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
- {
-@@ -117,12 +129,26 @@
-
- static inline void hlist_bl_lock(struct hlist_bl_head *b)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_lock(0, (unsigned long *)b);
-+#else
-+ raw_spin_lock(&b->lock);
-+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-+ __set_bit(0, (unsigned long *)b);
-+#endif
-+#endif
- }
-
- static inline void hlist_bl_unlock(struct hlist_bl_head *b)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- __bit_spin_unlock(0, (unsigned long *)b);
-+#else
-+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-+ __clear_bit(0, (unsigned long *)b);
-+#endif
-+ raw_spin_unlock(&b->lock);
-+#endif
- }
-
- static inline bool hlist_bl_is_locked(struct hlist_bl_head *b)
-diff -Nur linux-4.1.39.orig/include/linux/locallock.h linux-4.1.39/include/linux/locallock.h
---- linux-4.1.39.orig/include/linux/locallock.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.39/include/linux/locallock.h 2017-04-18 17:56:30.605396820 +0200
-@@ -0,0 +1,276 @@
-+#ifndef _LINUX_LOCALLOCK_H
-+#define _LINUX_LOCALLOCK_H
-+
-+#include <linux/percpu.h>
-+#include <linux/spinlock.h>
-+
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+
-+#ifdef CONFIG_DEBUG_SPINLOCK
-+# define LL_WARN(cond) WARN_ON(cond)
-+#else
-+# define LL_WARN(cond) do { } while (0)
-+#endif
-+
-+/*
-+ * per cpu lock based substitute for local_irq_*()
-+ */
-+struct local_irq_lock {
-+ spinlock_t lock;
-+ struct task_struct *owner;
-+ int nestcnt;
-+ unsigned long flags;
-+};
-+
-+#define DEFINE_LOCAL_IRQ_LOCK(lvar) \
-+ DEFINE_PER_CPU(struct local_irq_lock, lvar) = { \
-+ .lock = __SPIN_LOCK_UNLOCKED((lvar).lock) }
-+
-+#define DECLARE_LOCAL_IRQ_LOCK(lvar) \
-+ DECLARE_PER_CPU(struct local_irq_lock, lvar)
-+
-+#define local_irq_lock_init(lvar) \
-+ do { \
-+ int __cpu; \
-+ for_each_possible_cpu(__cpu) \
-+ spin_lock_init(&per_cpu(lvar, __cpu).lock); \
-+ } while (0)
-+
-+/*
-+ * spin_lock|trylock|unlock_local flavour that does not migrate disable
-+ * used for __local_lock|trylock|unlock where get_local_var/put_local_var
-+ * already takes care of the migrate_disable/enable
-+ * for CONFIG_PREEMPT_BASE map to the normal spin_* calls.
-+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+# define spin_lock_local(lock) rt_spin_lock(lock)
-+# define spin_trylock_local(lock) rt_spin_trylock(lock)
-+# define spin_unlock_local(lock) rt_spin_unlock(lock)
-+#else
-+# define spin_lock_local(lock) spin_lock(lock)
-+# define spin_trylock_local(lock) spin_trylock(lock)
-+# define spin_unlock_local(lock) spin_unlock(lock)
-+#endif
-+
-+static inline void __local_lock(struct local_irq_lock *lv)
-+{
-+ if (lv->owner != current) {
-+ spin_lock_local(&lv->lock);
-+ LL_WARN(lv->owner);
-+ LL_WARN(lv->nestcnt);
-+ lv->owner = current;
-+ }
-+ lv->nestcnt++;
-+}
-+
-+#define local_lock(lvar) \
-+ do { __local_lock(&get_local_var(lvar)); } while (0)
-+
-+#define local_lock_on(lvar, cpu) \
-+ do { __local_lock(&per_cpu(lvar, cpu)); } while (0)
-+
-+static inline int __local_trylock(struct local_irq_lock *lv)
-+{
-+ if (lv->owner != current && spin_trylock_local(&lv->lock)) {
-+ LL_WARN(lv->owner);
-+ LL_WARN(lv->nestcnt);
-+ lv->owner = current;
-+ lv->nestcnt = 1;
-+ return 1;
-+ }
-+ return 0;
-+}
-+
-+#define local_trylock(lvar) \
-+ ({ \
-+ int __locked; \
-+ __locked = __local_trylock(&get_local_var(lvar)); \
-+ if (!__locked) \
-+ put_local_var(lvar); \
-+ __locked; \
-+ })
-+
-+static inline void __local_unlock(struct local_irq_lock *lv)
-+{
-+ LL_WARN(lv->nestcnt == 0);
-+ LL_WARN(lv->owner != current);
-+ if (--lv->nestcnt)
-+ return;
-+
-+ lv->owner = NULL;
-+ spin_unlock_local(&lv->lock);
-+}
-+
-+#define local_unlock(lvar) \
-+ do { \
-+ __local_unlock(this_cpu_ptr(&lvar)); \
-+ put_local_var(lvar); \
-+ } while (0)
-+
-+#define local_unlock_on(lvar, cpu) \
-+ do { __local_unlock(&per_cpu(lvar, cpu)); } while (0)
-+
-+static inline void __local_lock_irq(struct local_irq_lock *lv)
-+{
-+ spin_lock_irqsave(&lv->lock, lv->flags);
-+ LL_WARN(lv->owner);
-+ LL_WARN(lv->nestcnt);
-+ lv->owner = current;
-+ lv->nestcnt = 1;
-+}
-+
-+#define local_lock_irq(lvar) \
-+ do { __local_lock_irq(&get_local_var(lvar)); } while (0)
-+
-+#define local_lock_irq_on(lvar, cpu) \
-+ do { __local_lock_irq(&per_cpu(lvar, cpu)); } while (0)
-+
-+static inline void __local_unlock_irq(struct local_irq_lock *lv)
-+{
-+ LL_WARN(!lv->nestcnt);
-+ LL_WARN(lv->owner != current);
-+ lv->owner = NULL;
-+ lv->nestcnt = 0;
-+ spin_unlock_irq(&lv->lock);
-+}
-+
-+#define local_unlock_irq(lvar) \
-+ do { \
-+ __local_unlock_irq(this_cpu_ptr(&lvar)); \
-+ put_local_var(lvar); \
-+ } while (0)
-+
-+#define local_unlock_irq_on(lvar, cpu) \
-+ do { \
-+ __local_unlock_irq(&per_cpu(lvar, cpu)); \
-+ } while (0)
-+
-+static inline int __local_lock_irqsave(struct local_irq_lock *lv)
-+{
-+ if (lv->owner != current) {
-+ __local_lock_irq(lv);
-+ return 0;
-+ } else {
-+ lv->nestcnt++;
-+ return 1;
-+ }
-+}
-+
-+#define local_lock_irqsave(lvar, _flags) \
-+ do { \
-+ if (__local_lock_irqsave(&get_local_var(lvar))) \
-+ put_local_var(lvar); \
-+ _flags = __this_cpu_read(lvar.flags); \
-+ } while (0)
-+
-+#define local_lock_irqsave_on(lvar, _flags, cpu) \
-+ do { \
-+ __local_lock_irqsave(&per_cpu(lvar, cpu)); \
-+ _flags = per_cpu(lvar, cpu).flags; \
-+ } while (0)
-+
-+static inline int __local_unlock_irqrestore(struct local_irq_lock *lv,
-+ unsigned long flags)
-+{
-+ LL_WARN(!lv->nestcnt);
-+ LL_WARN(lv->owner != current);
-+ if (--lv->nestcnt)
-+ return 0;
-+
-+ lv->owner = NULL;
-+ spin_unlock_irqrestore(&lv->lock, lv->flags);
-+ return 1;
-+}
-+
-+#define local_unlock_irqrestore(lvar, flags) \
-+ do { \
-+ if (__local_unlock_irqrestore(this_cpu_ptr(&lvar), flags)) \
-+ put_local_var(lvar); \
-+ } while (0)
-+
-+#define local_unlock_irqrestore_on(lvar, flags, cpu) \
-+ do { \
-+ __local_unlock_irqrestore(&per_cpu(lvar, cpu), flags); \
-+ } while (0)
-+
-+#define local_spin_trylock_irq(lvar, lock) \
-+ ({ \
-+ int __locked; \
-+ local_lock_irq(lvar); \
-+ __locked = spin_trylock(lock); \
-+ if (!__locked) \
-+ local_unlock_irq(lvar); \
-+ __locked; \
-+ })
-+
-+#define local_spin_lock_irq(lvar, lock) \
-+ do { \
-+ local_lock_irq(lvar); \
-+ spin_lock(lock); \
-+ } while (0)
-+
-+#define local_spin_unlock_irq(lvar, lock) \
-+ do { \
-+ spin_unlock(lock); \
-+ local_unlock_irq(lvar); \
-+ } while (0)
-+
-+#define local_spin_lock_irqsave(lvar, lock, flags) \
-+ do { \
-+ local_lock_irqsave(lvar, flags); \
-+ spin_lock(lock); \
-+ } while (0)
-+
-+#define local_spin_unlock_irqrestore(lvar, lock, flags) \
-+ do { \
-+ spin_unlock(lock); \
-+ local_unlock_irqrestore(lvar, flags); \
-+ } while (0)
-+
-+#define get_locked_var(lvar, var) \
-+ (*({ \
-+ local_lock(lvar); \
-+ this_cpu_ptr(&var); \
-+ }))
-+
-+#define put_locked_var(lvar, var) local_unlock(lvar);
-+
-+#define local_lock_cpu(lvar) \
-+ ({ \
-+ local_lock(lvar); \
-+ smp_processor_id(); \
-+ })
-+
-+#define local_unlock_cpu(lvar) local_unlock(lvar)
-+
-+#else /* PREEMPT_RT_BASE */
-+
-+#define DEFINE_LOCAL_IRQ_LOCK(lvar) __typeof__(const int) lvar
-+#define DECLARE_LOCAL_IRQ_LOCK(lvar) extern __typeof__(const int) lvar
-+
-+static inline void local_irq_lock_init(int lvar) { }
-+
-+#define local_lock(lvar) preempt_disable()
-+#define local_unlock(lvar) preempt_enable()
-+#define local_lock_irq(lvar) local_irq_disable()
-+#define local_unlock_irq(lvar) local_irq_enable()
-+#define local_lock_irqsave(lvar, flags) local_irq_save(flags)
-+#define local_unlock_irqrestore(lvar, flags) local_irq_restore(flags)
-+
-+#define local_spin_trylock_irq(lvar, lock) spin_trylock_irq(lock)
-+#define local_spin_lock_irq(lvar, lock) spin_lock_irq(lock)
-+#define local_spin_unlock_irq(lvar, lock) spin_unlock_irq(lock)
-+#define local_spin_lock_irqsave(lvar, lock, flags) \
-+ spin_lock_irqsave(lock, flags)
-+#define local_spin_unlock_irqrestore(lvar, lock, flags) \
-+ spin_unlock_irqrestore(lock, flags)
-+
-+#define get_locked_var(lvar, var) get_cpu_var(var)
-+#define put_locked_var(lvar, var) put_cpu_var(var)
-+
-+#define local_lock_cpu(lvar) get_cpu()
-+#define local_unlock_cpu(lvar) put_cpu()
-+
-+#endif
-+
-+#endif
-diff -Nur linux-4.1.39.orig/include/linux/mm_types.h linux-4.1.39/include/linux/mm_types.h
---- linux-4.1.39.orig/include/linux/mm_types.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/mm_types.h 2017-04-18 17:56:30.605396820 +0200
-@@ -11,6 +11,7 @@
- #include <linux/completion.h>
- #include <linux/cpumask.h>
- #include <linux/uprobes.h>
-+#include <linux/rcupdate.h>
- #include <linux/page-flags-layout.h>
- #include <asm/page.h>
- #include <asm/mmu.h>
-@@ -453,6 +454,9 @@
- bool tlb_flush_pending;
- #endif
- struct uprobes_state uprobes_state;
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ struct rcu_head delayed_drop;
-+#endif
- #ifdef CONFIG_X86_INTEL_MPX
- /* address of the bounds directory */
- void __user *bd_addr;
-diff -Nur linux-4.1.39.orig/include/linux/module.h linux-4.1.39/include/linux/module.h
---- linux-4.1.39.orig/include/linux/module.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/module.h 2017-04-18 17:56:30.605396820 +0200
-@@ -386,6 +386,7 @@
- struct module *__module_text_address(unsigned long addr);
- struct module *__module_address(unsigned long addr);
- bool is_module_address(unsigned long addr);
-+bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr);
- bool is_module_percpu_address(unsigned long addr);
- bool is_module_text_address(unsigned long addr);
-
-@@ -537,6 +538,11 @@
- {
- return false;
- }
-+
-+static inline bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
-+{
-+ return false;
-+}
-
- static inline bool is_module_text_address(unsigned long addr)
- {
-diff -Nur linux-4.1.39.orig/include/linux/mutex.h linux-4.1.39/include/linux/mutex.h
---- linux-4.1.39.orig/include/linux/mutex.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/mutex.h 2017-04-18 17:56:30.605396820 +0200
-@@ -19,6 +19,17 @@
- #include <asm/processor.h>
- #include <linux/osq_lock.h>
-
-+#ifdef CONFIG_DEBUG_LOCK_ALLOC
-+# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
-+ , .dep_map = { .name = #lockname }
-+#else
-+# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
-+#endif
-+
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+# include <linux/mutex_rt.h>
-+#else
-+
- /*
- * Simple, straightforward mutexes with strict semantics:
- *
-@@ -99,13 +110,6 @@
- static inline void mutex_destroy(struct mutex *lock) {}
- #endif
-
--#ifdef CONFIG_DEBUG_LOCK_ALLOC
--# define __DEP_MAP_MUTEX_INITIALIZER(lockname) \
-- , .dep_map = { .name = #lockname }
--#else
--# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
--#endif
--
- #define __MUTEX_INITIALIZER(lockname) \
- { .count = ATOMIC_INIT(1) \
- , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
-@@ -173,6 +177,8 @@
- extern int mutex_trylock(struct mutex *lock);
- extern void mutex_unlock(struct mutex *lock);
-
-+#endif /* !PREEMPT_RT_FULL */
-+
- extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);
-
- #endif /* __LINUX_MUTEX_H */
-diff -Nur linux-4.1.39.orig/include/linux/mutex_rt.h linux-4.1.39/include/linux/mutex_rt.h
---- linux-4.1.39.orig/include/linux/mutex_rt.h 1970-01-01 01:00:00.000000000 +0100
-+++ linux-4.1.39/include/linux/mutex_rt.h 2017-04-18 17:56:30.605396820 +0200
-@@ -0,0 +1,89 @@
-+#ifndef __LINUX_MUTEX_RT_H
-+#define __LINUX_MUTEX_RT_H
-+
-+#ifndef __LINUX_MUTEX_H
-+#error "Please include mutex.h"
-+#endif
-+
-+#include <linux/rtmutex.h>
-+
-+/* FIXME: Just for __lockfunc */
-+#include <linux/spinlock.h>
-+
-+struct mutex {
-+ struct rt_mutex lock;
-+#ifdef CONFIG_DEBUG_LOCK_ALLOC
-+ struct lockdep_map dep_map;
-+#endif
-+};
-+
-+#define __MUTEX_INITIALIZER(mutexname) \
-+ { \
-+ .lock = __RT_MUTEX_INITIALIZER(mutexname.lock) \
-+ __DEP_MAP_MUTEX_INITIALIZER(mutexname) \
-+ }
-+
-+#define DEFINE_MUTEX(mutexname) \
-+ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
-+
-+extern void __mutex_do_init(struct mutex *lock, const char *name, struct lock_class_key *key);
-+extern void __lockfunc _mutex_lock(struct mutex *lock);
-+extern int __lockfunc _mutex_lock_interruptible(struct mutex *lock);
-+extern int __lockfunc _mutex_lock_killable(struct mutex *lock);
-+extern void __lockfunc _mutex_lock_nested(struct mutex *lock, int subclass);
-+extern void __lockfunc _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *nest_lock);
-+extern int __lockfunc _mutex_lock_interruptible_nested(struct mutex *lock, int subclass);
-+extern int __lockfunc _mutex_lock_killable_nested(struct mutex *lock, int subclass);
-+extern int __lockfunc _mutex_trylock(struct mutex *lock);
-+extern void __lockfunc _mutex_unlock(struct mutex *lock);
-+
-+#define mutex_is_locked(l) rt_mutex_is_locked(&(l)->lock)
-+#define mutex_lock(l) _mutex_lock(l)
-+#define mutex_lock_interruptible(l) _mutex_lock_interruptible(l)
-+#define mutex_lock_killable(l) _mutex_lock_killable(l)
-+#define mutex_trylock(l) _mutex_trylock(l)
-+#define mutex_unlock(l) _mutex_unlock(l)
-+
-+#ifdef CONFIG_DEBUG_MUTEXES
-+#define mutex_destroy(l) rt_mutex_destroy(&(l)->lock)
-+#else
-+static inline void mutex_destroy(struct mutex *lock) {}
-+#endif
-+
-+#ifdef CONFIG_DEBUG_LOCK_ALLOC
-+# define mutex_lock_nested(l, s) _mutex_lock_nested(l, s)
-+# define mutex_lock_interruptible_nested(l, s) \
-+ _mutex_lock_interruptible_nested(l, s)
-+# define mutex_lock_killable_nested(l, s) \
-+ _mutex_lock_killable_nested(l, s)
-+
-+# define mutex_lock_nest_lock(lock, nest_lock) \
-+do { \
-+ typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
-+ _mutex_lock_nest_lock(lock, &(nest_lock)->dep_map); \
-+} while (0)
-+
-+#else
-+# define mutex_lock_nested(l, s) _mutex_lock(l)
-+# define mutex_lock_interruptible_nested(l, s) \
-+ _mutex_lock_interruptible(l)
-+# define mutex_lock_killable_nested(l, s) \
-+ _mutex_lock_killable(l)
-+# define mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock)
-+#endif
-+
-+# define mutex_init(mutex) \
-+do { \
-+ static struct lock_class_key __key; \
-+ \
-+ rt_mutex_init(&(mutex)->lock); \
-+ __mutex_do_init((mutex), #mutex, &__key); \
-+} while (0)
-+
-+# define __mutex_init(mutex, name, key) \
-+do { \
-+ rt_mutex_init(&(mutex)->lock); \
-+ __mutex_do_init((mutex), name, key); \
-+} while (0)
-+
-+#endif
-diff -Nur linux-4.1.39.orig/include/linux/netdevice.h linux-4.1.39/include/linux/netdevice.h
---- linux-4.1.39.orig/include/linux/netdevice.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/netdevice.h 2017-04-18 17:56:30.609396976 +0200
-@@ -390,7 +390,19 @@
- typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
-
- void __napi_schedule(struct napi_struct *n);
-+
-+/*
-+ * When PREEMPT_RT_FULL is defined, all device interrupt handlers
-+ * run as threads, and they can also be preempted (without PREEMPT_RT
-+ * interrupt threads can not be preempted). Which means that calling
-+ * __napi_schedule_irqoff() from an interrupt handler can be preempted
-+ * and can corrupt the napi->poll_list.
-+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+#define __napi_schedule_irqoff(n) __napi_schedule(n)
-+#else
- void __napi_schedule_irqoff(struct napi_struct *n);
-+#endif
-
- static inline bool napi_disable_pending(struct napi_struct *n)
- {
-@@ -2215,11 +2227,20 @@
- void synchronize_net(void);
- int init_dummy_netdev(struct net_device *dev);
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+static inline int dev_recursion_level(void)
-+{
-+ return current->xmit_recursion;
-+}
-+
-+#else
-+
- DECLARE_PER_CPU(int, xmit_recursion);
- static inline int dev_recursion_level(void)
- {
- return this_cpu_read(xmit_recursion);
- }
-+#endif
-
- struct net_device *dev_get_by_index(struct net *net, int ifindex);
- struct net_device *__dev_get_by_index(struct net *net, int ifindex);
-@@ -2510,6 +2531,7 @@
- unsigned int dropped;
- struct sk_buff_head input_pkt_queue;
- struct napi_struct backlog;
-+ struct sk_buff_head tofree_queue;
-
- };
-
-diff -Nur linux-4.1.39.orig/include/linux/netfilter/x_tables.h linux-4.1.39/include/linux/netfilter/x_tables.h
---- linux-4.1.39.orig/include/linux/netfilter/x_tables.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/netfilter/x_tables.h 2017-04-18 17:56:30.609396976 +0200
-@@ -3,6 +3,7 @@
-
-
- #include <linux/netdevice.h>
-+#include <linux/locallock.h>
- #include <uapi/linux/netfilter/x_tables.h>
-
- /**
-@@ -293,6 +294,8 @@
- */
- DECLARE_PER_CPU(seqcount_t, xt_recseq);
-
-+DECLARE_LOCAL_IRQ_LOCK(xt_write_lock);
-+
- /**
- * xt_write_recseq_begin - start of a write section
- *
-@@ -307,6 +310,9 @@
- {
- unsigned int addend;
-
-+ /* RT protection */
-+ local_lock(xt_write_lock);
-+
- /*
- * Low order bit of sequence is set if we already
- * called xt_write_recseq_begin().
-@@ -337,6 +343,7 @@
- /* this is kind of a write_seqcount_end(), but addend is 0 or 1 */
- smp_wmb();
- __this_cpu_add(xt_recseq.sequence, addend);
-+ local_unlock(xt_write_lock);
- }
-
- /*
-diff -Nur linux-4.1.39.orig/include/linux/notifier.h linux-4.1.39/include/linux/notifier.h
---- linux-4.1.39.orig/include/linux/notifier.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/notifier.h 2017-04-18 17:56:30.609396976 +0200
-@@ -6,7 +6,7 @@
- *
- * Alan Cox <Alan.Cox@linux.org>
- */
--
-+
- #ifndef _LINUX_NOTIFIER_H
- #define _LINUX_NOTIFIER_H
- #include <linux/errno.h>
-@@ -42,9 +42,7 @@
- * in srcu_notifier_call_chain(): no cache bounces and no memory barriers.
- * As compensation, srcu_notifier_chain_unregister() is rather expensive.
- * SRCU notifier chains should be used when the chain will be called very
-- * often but notifier_blocks will seldom be removed. Also, SRCU notifier
-- * chains are slightly more difficult to use because they require special
-- * runtime initialization.
-+ * often but notifier_blocks will seldom be removed.
- */
-
- typedef int (*notifier_fn_t)(struct notifier_block *nb,
-@@ -88,7 +86,7 @@
- (name)->head = NULL; \
- } while (0)
-
--/* srcu_notifier_heads must be initialized and cleaned up dynamically */
-+/* srcu_notifier_heads must be cleaned up dynamically */
- extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
- #define srcu_cleanup_notifier_head(name) \
- cleanup_srcu_struct(&(name)->srcu);
-@@ -101,7 +99,13 @@
- .head = NULL }
- #define RAW_NOTIFIER_INIT(name) { \
- .head = NULL }
--/* srcu_notifier_heads cannot be initialized statically */
-+
-+#define SRCU_NOTIFIER_INIT(name, pcpu) \
-+ { \
-+ .mutex = __MUTEX_INITIALIZER(name.mutex), \
-+ .head = NULL, \
-+ .srcu = __SRCU_STRUCT_INIT(name.srcu, pcpu), \
-+ }
-
- #define ATOMIC_NOTIFIER_HEAD(name) \
- struct atomic_notifier_head name = \
-@@ -113,6 +117,18 @@
- struct raw_notifier_head name = \
- RAW_NOTIFIER_INIT(name)
-
-+#define _SRCU_NOTIFIER_HEAD(name, mod) \
-+ static DEFINE_PER_CPU(struct srcu_struct_array, \
-+ name##_head_srcu_array); \
-+ mod struct srcu_notifier_head name = \
-+ SRCU_NOTIFIER_INIT(name, name##_head_srcu_array)
-+
-+#define SRCU_NOTIFIER_HEAD(name) \
-+ _SRCU_NOTIFIER_HEAD(name, )
-+
-+#define SRCU_NOTIFIER_HEAD_STATIC(name) \
-+ _SRCU_NOTIFIER_HEAD(name, static)
-+
- #ifdef __KERNEL__
-
- extern int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
-@@ -182,12 +198,12 @@
-
- /*
- * Declared notifiers so far. I can imagine quite a few more chains
-- * over time (eg laptop power reset chains, reboot chain (to clean
-+ * over time (eg laptop power reset chains, reboot chain (to clean
- * device units up), device [un]mount chain, module load/unload chain,
-- * low memory chain, screenblank chain (for plug in modular screenblankers)
-+ * low memory chain, screenblank chain (for plug in modular screenblankers)
- * VC switch chains (for loadable kernel svgalib VC switch helpers) etc...
- */
--
-+
- /* CPU notfiers are defined in include/linux/cpu.h. */
-
- /* netdevice notifiers are defined in include/linux/netdevice.h */
-diff -Nur linux-4.1.39.orig/include/linux/percpu.h linux-4.1.39/include/linux/percpu.h
---- linux-4.1.39.orig/include/linux/percpu.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/percpu.h 2017-04-18 17:56:30.609396976 +0200
-@@ -24,6 +24,35 @@
- PERCPU_MODULE_RESERVE)
- #endif
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+
-+#define get_local_var(var) (*({ \
-+ migrate_disable(); \
-+ this_cpu_ptr(&var); }))
-+
-+#define put_local_var(var) do { \
-+ (void)&(var); \
-+ migrate_enable(); \
-+} while (0)
-+
-+# define get_local_ptr(var) ({ \
-+ migrate_disable(); \
-+ this_cpu_ptr(var); })
-+
-+# define put_local_ptr(var) do { \
-+ (void)(var); \
-+ migrate_enable(); \
-+} while (0)
-+
-+#else
-+
-+#define get_local_var(var) get_cpu_var(var)
-+#define put_local_var(var) put_cpu_var(var)
-+#define get_local_ptr(var) get_cpu_ptr(var)
-+#define put_local_ptr(var) put_cpu_ptr(var)
-+
-+#endif
-+
- /* minimum unit size, also is the maximum supported allocation size */
- #define PCPU_MIN_UNIT_SIZE PFN_ALIGN(32 << 10)
-
-@@ -116,6 +145,7 @@
- #endif
-
- extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align);
-+extern bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr);
- extern bool is_kernel_percpu_address(unsigned long addr);
-
- #if !defined(CONFIG_SMP) || !defined(CONFIG_HAVE_SETUP_PER_CPU_AREA)
-diff -Nur linux-4.1.39.orig/include/linux/pid.h linux-4.1.39/include/linux/pid.h
---- linux-4.1.39.orig/include/linux/pid.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/pid.h 2017-04-18 17:56:30.609396976 +0200
-@@ -2,6 +2,7 @@
- #define _LINUX_PID_H
-
- #include <linux/rcupdate.h>
-+#include <linux/atomic.h>
-
- enum pid_type
- {
-diff -Nur linux-4.1.39.orig/include/linux/platform_data/gpio-omap.h linux-4.1.39/include/linux/platform_data/gpio-omap.h
---- linux-4.1.39.orig/include/linux/platform_data/gpio-omap.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/platform_data/gpio-omap.h 2017-04-18 17:56:30.609396976 +0200
-@@ -198,7 +198,6 @@
- int bank_width; /* GPIO bank width */
- int bank_stride; /* Only needed for omap1 MPUIO */
- bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
-- bool loses_context; /* whether the bank would ever lose context */
- bool is_mpuio; /* whether the bank is of type MPUIO */
- u32 non_wakeup_gpios;
-
-@@ -208,9 +207,17 @@
- int (*get_context_loss_count)(struct device *dev);
- };
-
-+#if IS_BUILTIN(CONFIG_GPIO_OMAP)
- extern void omap2_gpio_prepare_for_idle(int off_mode);
- extern void omap2_gpio_resume_after_idle(void);
--extern void omap_set_gpio_debounce(int gpio, int enable);
--extern void omap_set_gpio_debounce_time(int gpio, int enable);
-+#else
-+static inline void omap2_gpio_prepare_for_idle(int off_mode)
-+{
-+}
-+
-+static inline void omap2_gpio_resume_after_idle(void)
-+{
-+}
-+#endif
-
- #endif
-diff -Nur linux-4.1.39.orig/include/linux/preempt.h linux-4.1.39/include/linux/preempt.h
---- linux-4.1.39.orig/include/linux/preempt.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/preempt.h 2017-04-18 17:56:30.609396976 +0200
-@@ -34,6 +34,20 @@
- #define preempt_count_inc() preempt_count_add(1)
- #define preempt_count_dec() preempt_count_sub(1)
-
-+#ifdef CONFIG_PREEMPT_LAZY
-+#define add_preempt_lazy_count(val) do { preempt_lazy_count() += (val); } while (0)
-+#define sub_preempt_lazy_count(val) do { preempt_lazy_count() -= (val); } while (0)
-+#define inc_preempt_lazy_count() add_preempt_lazy_count(1)
-+#define dec_preempt_lazy_count() sub_preempt_lazy_count(1)
-+#define preempt_lazy_count() (current_thread_info()->preempt_lazy_count)
-+#else
-+#define add_preempt_lazy_count(val) do { } while (0)
-+#define sub_preempt_lazy_count(val) do { } while (0)
-+#define inc_preempt_lazy_count() do { } while (0)
-+#define dec_preempt_lazy_count() do { } while (0)
-+#define preempt_lazy_count() (0)
-+#endif
-+
- #ifdef CONFIG_PREEMPT_COUNT
-
- #define preempt_disable() \
-@@ -42,13 +56,25 @@
- barrier(); \
- } while (0)
-
-+#define preempt_lazy_disable() \
-+do { \
-+ inc_preempt_lazy_count(); \
-+ barrier(); \
-+} while (0)
-+
- #define sched_preempt_enable_no_resched() \
- do { \
- barrier(); \
- preempt_count_dec(); \
- } while (0)
-
--#define preempt_enable_no_resched() sched_preempt_enable_no_resched()
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+# define preempt_enable_no_resched() sched_preempt_enable_no_resched()
-+# define preempt_check_resched_rt() preempt_check_resched()
-+#else
-+# define preempt_enable_no_resched() preempt_enable()
-+# define preempt_check_resched_rt() barrier();
-+#endif
-
- #ifdef CONFIG_PREEMPT
- #define preempt_enable() \
-@@ -64,6 +90,13 @@
- __preempt_schedule(); \
- } while (0)
-
-+#define preempt_lazy_enable() \
-+do { \
-+ dec_preempt_lazy_count(); \
-+ barrier(); \
-+ preempt_check_resched(); \
-+} while (0)
-+
- #else
- #define preempt_enable() \
- do { \
-@@ -122,6 +155,7 @@
- #define preempt_disable_notrace() barrier()
- #define preempt_enable_no_resched_notrace() barrier()
- #define preempt_enable_notrace() barrier()
-+#define preempt_check_resched_rt() barrier()
-
- #endif /* CONFIG_PREEMPT_COUNT */
-
-@@ -141,10 +175,31 @@
- } while (0)
- #define preempt_fold_need_resched() \
- do { \
-- if (tif_need_resched()) \
-+ if (tif_need_resched_now()) \
- set_preempt_need_resched(); \
- } while (0)
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+# define preempt_disable_rt() preempt_disable()
-+# define preempt_enable_rt() preempt_enable()
-+# define preempt_disable_nort() barrier()
-+# define preempt_enable_nort() barrier()
-+# ifdef CONFIG_SMP
-+ extern void migrate_disable(void);
-+ extern void migrate_enable(void);
-+# else /* CONFIG_SMP */
-+# define migrate_disable() barrier()
-+# define migrate_enable() barrier()
-+# endif /* CONFIG_SMP */
-+#else
-+# define preempt_disable_rt() barrier()
-+# define preempt_enable_rt() barrier()
-+# define preempt_disable_nort() preempt_disable()
-+# define preempt_enable_nort() preempt_enable()
-+# define migrate_disable() preempt_disable()
-+# define migrate_enable() preempt_enable()
-+#endif
-+
- #ifdef CONFIG_PREEMPT_NOTIFIERS
-
- struct preempt_notifier;
-diff -Nur linux-4.1.39.orig/include/linux/preempt_mask.h linux-4.1.39/include/linux/preempt_mask.h
---- linux-4.1.39.orig/include/linux/preempt_mask.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/preempt_mask.h 2017-04-18 17:56:30.609396976 +0200
-@@ -44,16 +44,26 @@
- #define HARDIRQ_OFFSET (1UL << HARDIRQ_SHIFT)
- #define NMI_OFFSET (1UL << NMI_SHIFT)
-
--#define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET)
-+#ifndef CONFIG_PREEMPT_RT_FULL
-+# define SOFTIRQ_DISABLE_OFFSET (2 * SOFTIRQ_OFFSET)
-+#else
-+# define SOFTIRQ_DISABLE_OFFSET (0)
-+#endif
-
- #define PREEMPT_ACTIVE_BITS 1
- #define PREEMPT_ACTIVE_SHIFT (NMI_SHIFT + NMI_BITS)
- #define PREEMPT_ACTIVE (__IRQ_MASK(PREEMPT_ACTIVE_BITS) << PREEMPT_ACTIVE_SHIFT)
-
- #define hardirq_count() (preempt_count() & HARDIRQ_MASK)
--#define softirq_count() (preempt_count() & SOFTIRQ_MASK)
- #define irq_count() (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK \
- | NMI_MASK))
-+#ifndef CONFIG_PREEMPT_RT_FULL
-+# define softirq_count() (preempt_count() & SOFTIRQ_MASK)
-+# define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET)
-+#else
-+# define softirq_count() (0UL)
-+extern int in_serving_softirq(void);
-+#endif
-
- /*
- * Are we doing bottom half or hardware interrupt processing?
-@@ -64,7 +74,6 @@
- #define in_irq() (hardirq_count())
- #define in_softirq() (softirq_count())
- #define in_interrupt() (irq_count())
--#define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET)
-
- /*
- * Are we in NMI context?
-@@ -83,7 +92,11 @@
- /*
- * The preempt_count offset after spin_lock()
- */
-+#if !defined(CONFIG_PREEMPT_RT_FULL)
- #define PREEMPT_LOCK_OFFSET PREEMPT_DISABLE_OFFSET
-+#else
-+#define PREEMPT_LOCK_OFFSET 0
-+#endif
-
- /*
- * The preempt_count offset needed for things like:
-diff -Nur linux-4.1.39.orig/include/linux/printk.h linux-4.1.39/include/linux/printk.h
---- linux-4.1.39.orig/include/linux/printk.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/printk.h 2017-04-18 17:56:30.609396976 +0200
-@@ -115,9 +115,11 @@
- #ifdef CONFIG_EARLY_PRINTK
- extern asmlinkage __printf(1, 2)
- void early_printk(const char *fmt, ...);
-+extern void printk_kill(void);
- #else
- static inline __printf(1, 2) __cold
- void early_printk(const char *s, ...) { }
-+static inline void printk_kill(void) { }
- #endif
-
- typedef int(*printk_func_t)(const char *fmt, va_list args);
-diff -Nur linux-4.1.39.orig/include/linux/radix-tree.h linux-4.1.39/include/linux/radix-tree.h
---- linux-4.1.39.orig/include/linux/radix-tree.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/radix-tree.h 2017-04-18 17:56:30.609396976 +0200
-@@ -279,6 +279,8 @@
- unsigned long first_index, unsigned int max_items);
- int radix_tree_preload(gfp_t gfp_mask);
- int radix_tree_maybe_preload(gfp_t gfp_mask);
-+void radix_tree_preload_end(void);
-+
- void radix_tree_init(void);
- void *radix_tree_tag_set(struct radix_tree_root *root,
- unsigned long index, unsigned int tag);
-@@ -301,11 +303,6 @@
- int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag);
- unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item);
-
--static inline void radix_tree_preload_end(void)
--{
-- preempt_enable();
--}
--
- /**
- * struct radix_tree_iter - radix tree iterator state
- *
-diff -Nur linux-4.1.39.orig/include/linux/random.h linux-4.1.39/include/linux/random.h
---- linux-4.1.39.orig/include/linux/random.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/random.h 2017-04-18 17:56:30.609396976 +0200
-@@ -11,7 +11,7 @@
- extern void add_device_randomness(const void *, unsigned int);
- extern void add_input_randomness(unsigned int type, unsigned int code,
- unsigned int value);
--extern void add_interrupt_randomness(int irq, int irq_flags);
-+extern void add_interrupt_randomness(int irq, int irq_flags, __u64 ip);
-
- extern void get_random_bytes(void *buf, int nbytes);
- extern void get_random_bytes_arch(void *buf, int nbytes);
-diff -Nur linux-4.1.39.orig/include/linux/rcupdate.h linux-4.1.39/include/linux/rcupdate.h
---- linux-4.1.39.orig/include/linux/rcupdate.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/rcupdate.h 2017-04-18 17:56:30.609396976 +0200
-@@ -167,6 +167,9 @@
-
- #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+#define call_rcu_bh call_rcu
-+#else
- /**
- * call_rcu_bh() - Queue an RCU for invocation after a quicker grace period.
- * @head: structure to be used for queueing the RCU updates.
-@@ -190,6 +193,7 @@
- */
- void call_rcu_bh(struct rcu_head *head,
- void (*func)(struct rcu_head *head));
-+#endif
-
- /**
- * call_rcu_sched() - Queue an RCU for invocation after sched grace period.
-@@ -260,6 +264,11 @@
- * types of kernel builds, the rcu_read_lock() nesting depth is unknowable.
- */
- #define rcu_preempt_depth() (current->rcu_read_lock_nesting)
-+#ifndef CONFIG_PREEMPT_RT_FULL
-+#define sched_rcu_preempt_depth() rcu_preempt_depth()
-+#else
-+static inline int sched_rcu_preempt_depth(void) { return 0; }
-+#endif
-
- #else /* #ifdef CONFIG_PREEMPT_RCU */
-
-@@ -283,6 +292,8 @@
- return 0;
- }
-
-+#define sched_rcu_preempt_depth() rcu_preempt_depth()
-+
- #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
-
- /* Internal to kernel */
-@@ -463,7 +474,14 @@
- int debug_lockdep_rcu_enabled(void);
-
- int rcu_read_lock_held(void);
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+static inline int rcu_read_lock_bh_held(void)
-+{
-+ return rcu_read_lock_held();
-+}
-+#else
- int rcu_read_lock_bh_held(void);
-+#endif
-
- /**
- * rcu_read_lock_sched_held() - might we be in RCU-sched read-side critical section?
-@@ -990,10 +1008,14 @@
- static inline void rcu_read_lock_bh(void)
- {
- local_bh_disable();
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ rcu_read_lock();
-+#else
- __acquire(RCU_BH);
- rcu_lock_acquire(&rcu_bh_lock_map);
- rcu_lockdep_assert(rcu_is_watching(),
- "rcu_read_lock_bh() used illegally while idle");
-+#endif
- }
-
- /*
-@@ -1003,10 +1025,14 @@
- */
- static inline void rcu_read_unlock_bh(void)
- {
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ rcu_read_unlock();
-+#else
- rcu_lockdep_assert(rcu_is_watching(),
- "rcu_read_unlock_bh() used illegally while idle");
- rcu_lock_release(&rcu_bh_lock_map);
- __release(RCU_BH);
-+#endif
- local_bh_enable();
- }
-
-diff -Nur linux-4.1.39.orig/include/linux/rcutree.h linux-4.1.39/include/linux/rcutree.h
---- linux-4.1.39.orig/include/linux/rcutree.h 2017-03-13 21:04:36.000000000 +0100
-+++ linux-4.1.39/include/linux/rcutree.h 2017-04-18 17:56:30.609396976 +0200
-@@ -46,7 +46,11 @@
- rcu_note_context_switch();
- }
-
-+#ifdef CONFIG_PREEMPT_RT_F