1
0
Fork 0

모듈 포함하도록 수정

This commit is contained in:
Sangbum Kim 2016-12-07 02:07:23 +09:00
parent 5510415b51
commit e952eeece7
9 changed files with 6079 additions and 796 deletions

622
PKGBUILD
View File

@ -7,7 +7,7 @@ pkgname=$pkgbase
# comment the following line to build a single package containing the kernel and the headers
(( 1 )) && pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
pkgdesc="The Linux Kernel and modules from Linus' git tree"
depends=('coreutils' 'linux-firmware' 'mkinitcpio')
depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio')
pkgver=4.9.rc7
pkgrel=1
@ -32,9 +32,9 @@ _gitrev="v4.8.12"
# This PKGBUILD searches for config files in the current directory
# and will use the first one it finds from the following
# list as base configuration:
# config.local
# config.saved.$CARCH
# config.$CARCH
# config.local
# config.saved.$CARCH
# config.$CARCH
#
####################################################################
@ -61,7 +61,15 @@ _gitrev="v4.8.12"
#
# Uncomment desired options
#############################
#_make_modules=0
_make_modules=1
#######
# Skip the merge of Linus's kernel tree
#
# _skip_merge=1
MAKEFLAGS="-j $(expr $(cat /proc/cpuinfo |grep processor |wc -l) \* 2)"
#######
@ -87,12 +95,29 @@ _config_cmd="${_config_cmd:-menuconfig}"
# _configure_only=1
#######
# The directory where the kernel should be built
#
# Can be useful, for example, if you want to compile on a
# tmpfs mount, which can speed up the compilation process
#
#_build_dir="${_build_dir:-$srcdir}"
#######
# Append the date to the localversion
#
# e.g. -ARCH -> -ARCH-20090422
# e.g. -ARCH -> -ARCH-20090422
#
# _date_localversion=1
_date_localversion=0
#######
# Set the pkgver to the kernel version
# rather than the build date
#
# _kernel_pkgver=1
#######
@ -105,7 +130,7 @@ _save_config=1
#######
# Do not compress kernel modules
#
# _no_modules_compression=1
_no_modules_compression=0
#######
@ -117,245 +142,250 @@ _save_config=1
# internal variables
(( 1 )) && _kernel_src="$pkgname"
#(( 1 )) && _kernel_src="$BUILDDIR/$(find . -maxdepth 1 -type d -name "linux-*" -printf "%f\n" | head -1)"
#(( 1 )) && _kernel_src="$_build_dir/$pkgname_$"
#######
# define required functions
pkgver() {
cd "$_kernel_src"
git describe --always | sed 's/^v//;s/-/./g'
cd "$_kernel_src"
git describe --always | sed 's/^v//;s/-/./g'
}
# single package
package() {
eval package_$pkgbase-headers
eval package_$pkgbase
eval package_$pkgbase-headers
eval package_$pkgbase
}
# split package functions
eval "package_$pkgbase() { _generic_package_linux; }"
eval "package_$pkgbase-headers() { _generic_package_linux-headers; }"
eval "package_$pkgbase-docs() { _generic_package_linux-docs; }"
eval "package_$pkgbase() { _generic_package_kernel; }"
eval "package_$pkgbase-headers() { _generic_package_kernel-headers; }"
eval "package_$pkgbase-docs() { _generic_package_kernel-docs; }"
##############################
# where the magic happens...
##############################
build() {
cd "$_kernel_src"
msg "Sanitizing source tree.."
[[ -n $_gitrev ]] && git reset --hard "$_gitrev"
# cleaning source trees
git clean -f
cd "$_kernel_src"
msg "Sanitizing source tree.."
[[ -n $_gitrev ]] && git reset --hard "$_gitrev"
# cleaning source trees
git clean -f
#################
# Apply patches
#################
msg "Applying patches..."
local i patches
for i in "${source[@]}"; do
i=${i##*/}
[[ $i =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/$i")
[[ ${i%.*} =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/${i%.*}")
done
#################
# Apply patches
#################
msg "Applying patches..."
local i patches
for i in "${source[@]}"; do
i=${i##*/}
[[ $i =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/$i")
[[ ${i%.*} =~ .*\.patch$ ]] && patches=("${patches[@]}" "$srcdir/${i%.*}")
done
shopt -s nullglob
for i in "${patches[@]}" "$startdir/patches/"*; do
msg2 "Applying ${i##*/}..."
patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
done
shopt -u nullglob
shopt -s nullglob
for i in "${patches[@]}" "$startdir/patches/"*; do
msg2 "Applying ${i##*/}..."
patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
done
shopt -u nullglob
#################
# CONFIGURATION
#################
#################
# CONFIGURATION
#################
#########################
# Loading configuration
#########################
msg "Loading configuration..."
for i in local "saved.$CARCH" "$CARCH"; do
if [[ -e $startdir/config.$i ]]; then
msg2 "Using kernel config file config.$i..."
cp -f "$startdir/config.$i" .config
break
fi
done
#########################
# Loading configuration
#########################
msg "Loading configuration..."
for i in local "saved.$CARCH" "$CARCH"; do
if [[ -e $startdir/config.$i ]]; then
msg2 "Using kernel config file config.$i..."
cp -f "$startdir/config.$i" .config
break
fi
done
[[ ! -e .config ]] &&
warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."
[[ ! -e .config ]] &&
warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."
###########################
# Start the configuration
###########################
msg "Updating configuration..."
yes "" | make config > /dev/null
###########################
# Start the configuration
###########################
msg "Updating configuration..."
yes "" | make config > /dev/null
if [[ -f "$startdir/config.saved.$CARCH" ]]; then
msg2 "migrating previous config..."
cp "$startdir/config.saved.$CARCH" .config
make oldconfig
else
msg2 "migrating default config..."
cp "$startdir/config.$CARCH" .config
make oldconfig
fi
if [[ -n ${_config_cmd// /} ]]; then
msg2 "Running make $_config_cmd..."
make $_config_cmd
else
warning "Unknown config command: $_config_cmd"
fi
if [[ -f "$startdir/config.saved.$CARCH" ]]; then
msg2 "migrating previous config..."
cp "$startdir/config.saved.$CARCH" .config
make oldconfig
else
msg2 "migrating default config..."
cp "$startdir/config.$CARCH" .config
make oldconfig
fi
if [[ -n ${_config_cmd// /} ]]; then
msg2 "Running make $_config_cmd..."
make $_config_cmd
else
warning "Unknown config command: $_config_cmd"
fi
##############################################
# Save the config file the package directory
##############################################
if [[ -n $_save_config || -n $_configure_only ]]; then
msg "Saving configuration..."
msg2 "Saving $_kernel_src/.config as $startdir/config.saved.$CARCH"
cp .config "$startdir/config.saved.$CARCH"
fi
##############################################
# Save the config file the package directory
##############################################
if [[ -n $_save_config || -n $_configure_only ]]; then
msg "Saving configuration..."
msg2 "Saving $_kernel_src/.config as $startdir/config.saved.$CARCH"
cp .config "$startdir/config.saved.$CARCH"
fi
#######################################
# Stop after configuration if desired
#######################################
if [[ -n $_configure_only ]]; then
rm -rf "$srcdir" "$pkgdir"
return 1
fi
#######################################
# Stop after configuration if desired
#######################################
if [[ -n $_configure_only ]]; then
rm -rf "$_kernel_src" "$srcdir" "$pkgdir"
return 1
fi
###############################
# Append date to localversion
###############################
if [[ -n $_date_localversion ]]; then
local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)"
[[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion"
###############################
# Append date to localversion
###############################
if [[ -n $_date_localversion ]]; then
local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)"
[[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion"
# since this is a git package, the $pkgver is equal to $(date +%Y%m%d)
msg2 "Appending $pkgver to CONFIG_LOCALVERSION..."
sed -ri "s/^(CONFIG_LOCALVERSION=).*$/\1\"$_localversion-$pkgver\"/" .config
fi
# since this is a git package, the $pkgver is equal to $(date +%Y%m%d)
msg2 "Appending $pkgver to CONFIG_LOCALVERSION..."
sed -ri "s/^(CONFIG_LOCALVERSION=).*$/\1\"$_localversion-$pkgver\"/" .config
fi
####################################
# Append pkgrel to kernel version
####################################
sed -ri "s/^(EXTRAVERSION =).*$/\1 -$pkgrel/" Makefile
#################
# BUILD PROCESS
#################
####################################
# don't run depmod on 'make install'
####################################
sed -i '2iexit 0' scripts/depmod.sh
git update-index --assume-unchanged scripts/depmod.sh
################################
# Build the kernel and modules
################################
msg "Building kernel and modules..."
if [[ -n $_make_modules ]]; then
make $MAKEFLAGS V="$_verbose" bzImage modules
else
make $MAKEFLAGS V="$_verbose" bzImage
fi
############
# CLEANUP
############
#################
# BUILD PROCESS
#################
################################
# Build the kernel and modules
################################
msg "Building kernel and modules..."
if [[ -n $_make_modules ]]; then
make $MAKEFLAGS V="$_verbose" bzImage modules
else
make $MAKEFLAGS V="$_verbose" bzImage
fi
###################################
# Copy files from build directory
####################################
# if (( ! CLEANUP )) && [[ $_build_dir != $srcdir ]]; then
# msg "Saving $_kernel_src to $srcdir/${_kernel_src##*/}..."
# mv "$_kernel_src" "$srcdir"
# rm -rf "$_kernel_src"
# fi
}
_generic_package_initialization() {
cd "$srcdir/${_kernel_src##*/}"
cd "$_kernel_src"
_karch="x86"
_karch="x86"
######################
# Get kernel version
######################
_kernver=$(make kernelrelease)
_basekernel=${_kernver%%-*}
############################################################
# Use kernel version instead of the current date as pkgver
############################################################
if [[ -n $_kernel_pkgver ]]; then
pkgver=${_kernver//-/_}
msg "Setting pkgver to kernel version: $pkgver"
fi
######################
# Get kernel version
######################
_kernver=$(make kernelrelease)
_basekernver=${_kernver%%-*}
}
_generic_package_linux() {
pkgdesc="The Linux Kernel and modules from Linus' git tree"
backup=(etc/mkinitcpio.d/$pkgname.preset)
install=$pkgname.install
changelog=$pkgname.changelog
_generic_package_kernel() {
pkgdesc="The Linux Kernel and modules from Linus' git tree"
depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio')
backup=(etc/mkinitcpio.d/$pkgname.preset)
install=$pkgname.install
changelog=$pkgname.changelog
# set required variables
_generic_package_initialization
# set required variables
_generic_package_initialization
#############################################################
# Provide linux
# (probably someone wants to use this kernel exclusively?)
#############################################################
provides=("${provides[@]}" "linux=${_kernver//-/_}")
#############################################################
# Provide linux
# (probably someone wants to use this kernel exclusively?)
#############################################################
provides=("${provides[@]}" "linux=${_kernver//-/_}")
################
# INSTALLATION
################
################
# INSTALLATION
################
#####################
# Install the image
#####################
msg "Installing kernel image..."
install -Dm644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz-$pkgname"
#####################
# Install the image
#####################
msg "Installing kernel image..."
install -Dm644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz-$pkgname"
##########################
# Install kernel modules
##########################
msg "Installing kernel modules..."
if [[ -n $_make_modules ]]; then
# force -j1 to work around make 3.82 bug
make -j1 INSTALL_MOD_PATH="$pkgdir/usr" modules_install
[[ -z $_no_modules_compression ]] && find "$pkgdir" -name "*.ko" -exec gzip -9 {} +
#########################################################
# Set up extramodules directory (for external modules)
#########################################################
local extramodules="$pkgdir/usr/lib/modules/extramodules-$(cut -d. -f1,2 <<<$_basekernver)"
local modversion=$(grep '^CONFIG_LOCALVERSION=' .config | cut -d'"' -f2)
[[ -n $modversion ]] && extramodules+=$modversion
install -dm755 "${extramodules}${_pkgext}"
echo $_kernver > "${extramodules}${_pkgext}/version"
ln -s "../${extramodules##*/}${_pkgext}" "$pkgdir/usr/lib/modules/$_kernver/extramodules"
##########################
# Install kernel modules
##########################
msg "Installing kernel modules..."
if [[ -n $_make_modules ]]; then
make INSTALL_MOD_PATH="$pkgdir" modules_install
fi
[[ -z $_no_modules_compression ]] && find "$pkgdir" -name "*.ko" -exec gzip -9 {} +
##################################
# Create important symlinks
##################################
msg "Creating important symlinks..."
##################################
# Create important symlinks
##################################
msg "Creating important symlinks..."
# Create generic modules symlink
if [[ $_kernver != ${_basekernver}${_pkgext} ]]; then
cd "$pkgdir/usr/lib/modules"
ln -s "$_kernver" "${_basekernver}${_pkgext}"
cd "$OLDPWD"
fi
# Create generic modules symlink
# remove header symlinks
cd "$pkgdir/usr/lib/modules/$_kernver"
rm -rf source build
cd "$OLDPWD"
fi
if [[ $_kernver != ${_basekernel}${_pkgext} ]]; then
cd "$pkgdir/lib/modules"
ln -s "$_kernver" "${_basekernel}${_pkgext}"
cd "$OLDPWD"
fi
############################
# Install mkinitcpio files
############################
install -d "$pkgdir/etc/mkinitcpio.d"
# remove header symlinks
cd "$pkgdir/lib/modules/$_kernver"
rm -rf source build
cd "$OLDPWD"
############################
# Install mkinitcpio files
############################
install -d "$pkgdir/etc/mkinitcpio.d"
msg "Generating $pkgname.preset..."
cat > "$pkgdir/etc/mkinitcpio.d/$pkgname.preset" <<EOF
# mkinitcpio preset file for $pkgname
msg "Generating $pkgname.preset..."
cat > "$pkgdir/etc/mkinitcpio.d/$pkgname.preset" <<EOF
# mkinitcpio preset file for the '$pkgname' package
ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-$pkgname"
@ -368,149 +398,155 @@ COMPRESSION="lz4" # since kernel 2.6.34
EOF
#######################
# Update install file
#######################
msg "Updating install file..."
sed -ri "s/^(pkgname=).*$/\1$pkgname/" "$startdir/$pkgname.install"
sed -ri "s/^(kernver=).*$/\1$_kernver/" "$startdir/$pkgname.install"
msg "Generating $pkgname.kver..."
echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
> "$pkgdir/etc/mkinitcpio.d/$pkgname.kver"
#######################
# Remove the firmware
#######################
rm -rf "$pkgdir/usr/lib/firmware"
#######################
# Update install file
#######################
msg "Updating install file..."
sed -ri "s/^(pkgname=).*$/\1$pkgname/" "$startdir/$pkgname.install"
sed -ri "s/^(kernver=).*$/\1$_kernver/" "$startdir/$pkgname.install"
#######################
# Run depmod
#######################
if [[ -n $_make_modules ]]; then
depmod -a "$pkgdir/usr"
depmod -b "$pkgdir/usr" -F System.map "$_kernver"
fi
#######################
# Remove the firmware
#######################
# remove the firmware
rm -rf "${pkgdir}/lib/firmware"
# Now we call depmod...
depmod -b "${pkgdir}" -F System.map "${_kernver}"
# move module tree /lib -> /usr/lib
mkdir -p "${pkgdir}/usr"
mv "${pkgdir}/lib" "${pkgdir}/usr/"
}
_generic_package_kernel-headers() {
pkgdesc="Header files and scripts for building modules for $pkgbase"
depends=("$pkgbase")
_generic_package_linux-headers() {
pkgdesc="Header files and scripts for building modules for $pkgbase"
depends=("$pkgbase")
# set required variables
_generic_package_initialization
# set required variables
_generic_package_initialization
#############################################################
# Provide linux-headers
# (probably someone wants to use this kernel exclusively?)
#############################################################
provides=("${provides[@]}" "linux-headers=${_kernver//-/_}")
#############################################################
# Provide linux-headers
# (probably someone wants to use this kernel exclusively?)
#############################################################
provides=("${provides[@]}" "linux-headers=${_kernver//-/_}")
##############################
# Install fake kernel source
##############################
install -Dm644 Module.symvers "$pkgdir/usr/src/linux-$_kernver/Module.symvers"
install -Dm644 Makefile "$pkgdir/usr/src/linux-$_kernver/Makefile"
install -Dm644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile"
install -Dm644 .config "$pkgdir/usr/src/linux-$_kernver/.config"
install -Dm644 .config "$pkgdir/usr/lib/modules/$_kernver/.config"
##############################
# Install fake kernel source
##############################
install -Dm644 Module.symvers "$pkgdir/usr/src/linux-$_kernver/Module.symvers"
install -Dm644 Makefile "$pkgdir/usr/src/linux-$_kernver/Makefile"
install -Dm644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile"
install -Dm644 .config "$pkgdir/usr/lib/modules/$_kernver/.config"
#######################################################
# Install scripts directory and fix permissions on it
#######################################################
cp -a scripts "$pkgdir/usr/src/linux-$_kernver"
#######################################################
# Install scripts directory and fix permissions on it
#######################################################
cp -a scripts "$pkgdir/usr/src/linux-$_kernver"
##########################
# Install header files
##########################
msg "Installing header files..."
##########################
# Install header files
##########################
msg "Installing header files..."
for i in net/ipv4/netfilter/ipt_CLUSTERIP.c \
$(find include/ net/mac80211/ drivers/md -iname "*.h") \
$(find include/config/ -type f) \
$(find . -name "Kconfig*")
do
mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}"
cp -af "$i" "$pkgdir/usr/src/linux-$_kernver/$i"
done
for i in net/ipv4/netfilter/ipt_CLUSTERIP.c \
$(find include/ net/mac80211/ drivers/{md,media/video/} -iname "*.h") \
$(find include/config/ -type f) \
$(find . -name "Kconfig*")
do
mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}"
cp -af "$i" "$pkgdir/usr/src/linux-$_kernver/$i"
done
# required by virtualbox and probably others
ln -s "../generated/autoconf.h" "$pkgdir/usr/src/linux-$_kernver/include/linux/"
# required by virtualbox and probably others
ln -s "../generated/autoconf.h" "$pkgdir/usr/src/linux-$_kernver/include/linux/"
########################################
# Install architecture dependent files
########################################
msg "Installing architecture files..."
mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel"
cp -a arch/$_karch/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel/"
########################################
# Install architecture dependent files
########################################
msg "Installing architecture files..."
mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel"
cp -a arch/$_karch/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel/"
cp -a arch/$_karch/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
cp -a arch/$_karch/configs "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
cp -a arch/$_karch/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
cp -a arch/$_karch/configs "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
# copy arch includes for external modules and fix the nVidia issue
mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"
cp -a "arch/$_karch/include" "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
# copy arch includes for external modules and fix the nVidia issue
mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"
cp -a "arch/$_karch/include" "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/"
# create a necessary symlink to the arch folder
cd "$pkgdir/usr/src/linux-$_kernver/arch"
# create a necessary symlink to the arch folder
cd "$pkgdir/usr/src/linux-$_kernver/arch"
if [[ $CARCH = "x86_64" ]]; then
ln -s $_karch x86_64
else
ln -s $_karch i386
fi
if [[ $CARCH = "x86_64" ]]; then
ln -s $_karch x86_64
else
ln -s $_karch i386
fi
cd "$OLDPWD"
cd "$OLDPWD"
################################
# Remove unneeded architecures
################################
msg "Removing unneeded architectures..."
for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
[[ ${i##*/} =~ ($_karch|Kconfig) ]] || rm -rf "$i"
done
################################
# Remove unneeded architecures
################################
msg "Removing unneeded architectures..."
for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
[[ ${i##*/} =~ ($_karch|Kconfig) ]] || rm -rf "$i"
done
############################
# Remove .gitignore files
############################
msg "Removing .gitignore files from kernel source..."
find "$pkgdir/usr/src/linux-$_kernver/" -name ".gitignore" -delete
############################
# Remove .gitignore files
############################
msg "Removing .gitignore files from kernel source..."
find "$pkgdir/usr/src/linux-$_kernver/" -name ".gitignore" -delete
##################################
# Create important symlinks
##################################
msg "Creating important symlinks..."
##################################
# Create important symlinks
##################################
msg "Creating important symlinks..."
# the build symlink needs to be relative
cd "$pkgdir/usr/lib/modules/$_kernver"
rm -rf source build
ln -s "/usr/src/linux-$_kernver" build
cd "$OLDPWD"
# the build symlink needs to be relative
cd "$pkgdir/usr/lib/modules/$_kernver"
rm -rf source build
ln -s "/usr/src/linux-$_kernver" build
cd "$OLDPWD"
if [[ $_kernver != ${_basekernver}${_pkgext} ]]; then
cd "$pkgdir/usr/src"
ln -s "linux-$_kernver" "linux-${_basekernver}${_pkgext}"
cd "$OLDPWD"
fi
if [[ $_kernver != ${_basekernver}${_pkgext} ]]; then
cd "$pkgdir/usr/src"
ln -s "linux-$_kernver" "linux-${_basekernel}${_pkgext}"
cd "$OLDPWD"
fi
}
_generic_package_linux-docs() {
pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
depends=("$pkgbase")
_generic_package_kernel-docs() {
pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
depends=("$pkgbase")
# set required variables
_generic_package_initialization
# set required variables
_generic_package_initialization
mkdir -p "$pkgdir/usr/src/linux-$_kernver"
cp -aL Documentation "$pkgdir/usr/src/linux-$_kernver/"
mkdir -p "$pkgdir/usr/src/linux-$_kernver"
cp -a Documentation "$pkgdir/usr/src/linux-$_kernver/"
}
# vim: set fenc=utf-8 ts=2 sw=2 noet:

File diff suppressed because it is too large Load Diff

4483
config.saved.x86_64_static Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
pkgname=linux-spica
kernver=4.8.12-1spica-dirty
kernver=4.8.12spica-4.9.rc7-dirty
#bootdevice="BOOT_IMAGE=/boot/vmlinuz-$pkgname root=UUID=d670564f-2cb3-4981-9d51-6ed9c1327d47"
#option="rw quiet clocksource=hpet initrd=EFI/spi-ca/initrd intel_iommu=on pci-stub.ids=1002:683f,1002:aab0 vfio_iommu_type1.allow_unsafe_interrupts=1,kvm.ignore_msrs=1"
#option="rw quiet clocksource=hpet initrd=EFI/spi-ca/initrd quiet intremap=no_x2apic_optout zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"

31
patches/apple-gmux.patch Normal file
View File

@ -0,0 +1,31 @@
--- a/drivers/platform/x86/apple-gmux.c
+++ a/drivers/platform/x86/apple-gmux.c
@@ -419,6 +419,7 @@ static int gmux_resume(struct device *dev)
static struct pci_dev *gmux_get_io_pdev(void)
{
+ struct pci_dev *igp = NULL, *dgp = NULL;
struct pci_dev *pdev = NULL;
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev))) {
@@ -428,10 +429,18 @@ static struct pci_dev *gmux_get_io_pdev(void)
if (!(cmd & PCI_COMMAND_IO))
continue;
- return pdev;
+ if (pdev->bus && pdev->bus->number > 0 && !dgp)
+ dgp = pci_dev_get(pdev);
+ else if (pdev->bus && pdev->bus->number == 0 && !igp)
+ igp = pci_dev_get(pdev);
}
- return NULL;
+ if (dgp && !igp)
+ pr_warn("Found only discrete GPU %s, integrated GPU is hidden,"
+ " unable to protect backlight behind VGA IO",
+ pci_name(dgp));
+ pci_dev_put(dgp);
+ return igp;
}
static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)

View File

@ -0,0 +1,11 @@
--- linux-3.16/include/linux/printk.h.old 2014-08-04 18:48:30.686043266 +0200
+++ linux-3.16/include/linux/printk.h 2014-08-04 18:48:47.706218528 +0200
@@ -37,7 +37,7 @@
#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
-#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
+#define CONSOLE_LOGLEVEL_DEFAULT 4 /* anything MORE serious than KERN_DEBUG */
#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */

View File

@ -0,0 +1,148 @@
--- linux-4.8/drivers/cpufreq/intel_pstate.c.orig 2016-10-02 19:24:33.000000000 -0400
+++ linux-4.8/drivers/cpufreq/intel_pstate.c 2016-10-09 19:32:01.073141319 -0400
@@ -181,6 +181,8 @@
* @cpu: CPU number for this instance data
* @update_util: CPUFreq utility callback information
* @update_util_set: CPUFreq utility callback is set
+ * @iowait_boost: iowait-related boost fraction
+ * @last_update: Time of the last update.
* @pstate: Stores P state limits for this CPU
* @vid: Stores VID limits for this CPU
* @pid: Stores PID parameters for this CPU
@@ -206,6 +208,7 @@
struct vid_data vid;
struct _pid pid;
+ u64 last_update;
u64 last_sample_time;
u64 prev_aperf;
u64 prev_mperf;
@@ -216,6 +219,7 @@
struct acpi_processor_performance acpi_perf_data;
bool valid_pss_table;
#endif
+ unsigned int iowait_boost;
};
static struct cpudata **all_cpu_data;
@@ -229,6 +233,7 @@
* @p_gain_pct: PID proportional gain
* @i_gain_pct: PID integral gain
* @d_gain_pct: PID derivative gain
+ * @boost_iowait: Whether or not to use iowait boosting.
*
* Stores per CPU model static PID configuration data.
*/
@@ -240,6 +245,7 @@
int p_gain_pct;
int d_gain_pct;
int i_gain_pct;
+ bool boost_iowait;
};
/**
@@ -1029,7 +1035,7 @@
},
};
-static struct cpu_defaults silvermont_params = {
+static const struct cpu_defaults silvermont_params = {
.pid_policy = {
.sample_rate_ms = 10,
.deadband = 0,
@@ -1037,6 +1043,7 @@
.p_gain_pct = 14,
.d_gain_pct = 0,
.i_gain_pct = 4,
+ .boost_iowait = true,
},
.funcs = {
.get_max = atom_get_max_pstate,
@@ -1050,7 +1057,7 @@
},
};
-static struct cpu_defaults airmont_params = {
+static const struct cpu_defaults airmont_params = {
.pid_policy = {
.sample_rate_ms = 10,
.deadband = 0,
@@ -1058,6 +1065,7 @@
.p_gain_pct = 14,
.d_gain_pct = 0,
.i_gain_pct = 4,
+ .boost_iowait = true,
},
.funcs = {
.get_max = atom_get_max_pstate,
@@ -1071,7 +1079,7 @@
},
};
-static struct cpu_defaults knl_params = {
+static const struct cpu_defaults knl_params = {
.pid_policy = {
.sample_rate_ms = 10,
.deadband = 0,
@@ -1091,7 +1099,7 @@
},
};
-static struct cpu_defaults bxt_params = {
+static const struct cpu_defaults bxt_params = {
.pid_policy = {
.sample_rate_ms = 10,
.deadband = 0,
@@ -1099,6 +1107,7 @@
.p_gain_pct = 14,
.d_gain_pct = 0,
.i_gain_pct = 4,
+ .boost_iowait = true,
},
.funcs = {
.get_max = core_get_max_pstate,
@@ -1222,36 +1231,18 @@
static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu)
{
struct sample *sample = &cpu->sample;
- u64 cummulative_iowait, delta_iowait_us;
- u64 delta_iowait_mperf;
- u64 mperf, now;
- int32_t cpu_load;
+ int32_t busy_frac, boost;
- cummulative_iowait = get_cpu_iowait_time_us(cpu->cpu, &now);
+ busy_frac = div_fp(sample->mperf, sample->tsc);
- /*
- * Convert iowait time into number of IO cycles spent at max_freq.
- * IO is considered as busy only for the cpu_load algorithm. For
- * performance this is not needed since we always try to reach the
- * maximum P-State, so we are already boosting the IOs.
- */
- delta_iowait_us = cummulative_iowait - cpu->prev_cummulative_iowait;
- delta_iowait_mperf = div64_u64(delta_iowait_us * cpu->pstate.scaling *
- cpu->pstate.max_pstate, MSEC_PER_SEC);
-
- mperf = cpu->sample.mperf + delta_iowait_mperf;
- cpu->prev_cummulative_iowait = cummulative_iowait;
+ boost = cpu->iowait_boost;
+ cpu->iowait_boost >>= 1;
- /*
- * The load can be estimated as the ratio of the mperf counter
- * running at a constant frequency during active periods
- * (C0) and the time stamp counter running at the same frequency
- * also during C-states.
- */
- cpu_load = div64_u64(int_tofp(100) * mperf, sample->tsc);
- cpu->sample.busy_scaled = cpu_load;
+ if (busy_frac < boost)
+ busy_frac = boost;
- return get_avg_pstate(cpu) - pid_calc(&cpu->pid, cpu_load);
+ sample->busy_scaled = busy_frac * 100;
+ return get_avg_pstate(cpu) - pid_calc(&cpu->pid, sample->busy_scaled);
}
static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu)

View File

@ -0,0 +1,123 @@
--- linux_for_test.orig/scripts/mod/modpost.c 2016-04-21 17:01:42.917757676 +0800
+++ linux_for_test.orig/scripts/mod/modpost.c 2016-05-29 13:32:41.266916072 +0800
@@ -877,6 +877,7 @@
#define ALL_PCI_INIT_SECTIONS \
".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
+ ".pci_fixup_assign", \
".pci_fixup_enable", ".pci_fixup_resume", \
".pci_fixup_resume_early", ".pci_fixup_suspend"
--- linux_for_test.orig/include/asm-generic/vmlinux.lds.h 2016-05-18 13:14:13.970951863 +0800
+++ linux_for_test.orig/include/asm-generic/vmlinux.lds.h 2016-05-29 13:32:24.870916334 +0800
@@ -283,6 +283,9 @@
VMLINUX_SYMBOL(__start_pci_fixups_final) = .; \
*(.pci_fixup_final) \
VMLINUX_SYMBOL(__end_pci_fixups_final) = .; \
+ VMLINUX_SYMBOL(__start_pci_fixups_assign) = .; \
+ *(.pci_fixup_assign) \
+ VMLINUX_SYMBOL(__end_pci_fixups_assign) = .; \
VMLINUX_SYMBOL(__start_pci_fixups_enable) = .; \
*(.pci_fixup_enable) \
VMLINUX_SYMBOL(__end_pci_fixups_enable) = .; \
--- linux_for_test.orig/include/linux/pci.h 2016-05-29 12:51:02.000000000 +0800
+++ linux_for_test.orig/include/linux/pci.h 2016-05-29 13:39:20.926909684 +0800
@@ -1584,6 +1584,7 @@
pci_fixup_early, /* Before probing BARs */
pci_fixup_header, /* After reading configuration header */
pci_fixup_final, /* Final phase of device fixups */
+ pci_fixup_assign, /* Before resource assignment */
pci_fixup_enable, /* pci_enable_device() time */
pci_fixup_resume, /* pci_device_resume() */
pci_fixup_suspend, /* pci_device_suspend() */
@@ -1644,6 +1645,9 @@
#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
hook, vendor, device, PCI_ANY_ID, 0, hook)
+#define DECLARE_PCI_FIXUP_ASSIGN(vendor, device, hook) \
+ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_assign, \
+ hook, vendor, device, PCI_ANY_ID, 0, hook)
#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
hook, vendor, device, PCI_ANY_ID, 0, hook)
--- linux_for_test.orig/drivers/pci/quirks.c 2016-05-27 13:20:01.114516646 +0800
+++ linux_for_test.orig/drivers/pci/quirks.c 2016-05-29 16:07:58.230767144 +0800
@@ -3370,6 +3370,8 @@
extern struct pci_fixup __end_pci_fixups_header[];
extern struct pci_fixup __start_pci_fixups_final[];
extern struct pci_fixup __end_pci_fixups_final[];
+extern struct pci_fixup __start_pci_fixups_assign[];
+extern struct pci_fixup __end_pci_fixups_assign[];
extern struct pci_fixup __start_pci_fixups_enable[];
extern struct pci_fixup __end_pci_fixups_enable[];
extern struct pci_fixup __start_pci_fixups_resume[];
@@ -3405,6 +3407,11 @@
end = __end_pci_fixups_final;
break;
+ case pci_fixup_assign:
+ start = __start_pci_fixups_assign;
+ end = __end_pci_fixups_assign;
+ break;
+
case pci_fixup_enable:
start = __start_pci_fixups_enable;
end = __end_pci_fixups_enable;
@@ -4419,3 +4426,30 @@
}
}
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap);
+
+static int disable_mode;
+/* On Mac Pro 11, mem allocation broke ACPI Sleep Type register region. */
+static void quirk_disable_mmio_bar(struct pci_dev *dev)
+{
+ struct resource *b_res;
+
+ dev_info(&dev->dev, "[Quirk] Disable mmio regions for Mac Pro 11\n");
+ if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
+ return;
+
+ b_res = &dev->resource[PCI_BRIDGE_RESOURCES];
+ b_res[1].flags = 0;
+
+ if (disable_mode & 1) {
+ b_res[2].flags = 0;
+ }
+
+}
+DECLARE_PCI_FIXUP_ASSIGN(PCI_VENDOR_ID_INTEL, 0x8c10, quirk_disable_mmio_bar);
+
+static int __init parse_disable_mode(char *str)
+{
+ get_option(&str, &disable_mode);
+ return 0;
+}
+early_param("disable_mode", parse_disable_mode);
--- linux_for_test.orig/drivers/pci/setup-bus.c 2016-05-29 12:26:08.000000000 +0800
+++ linux_for_test.orig/drivers/pci/setup-bus.c 2016-05-29 13:58:36.086891219 +0800
@@ -1256,6 +1256,8 @@
additional_io_size = pci_hotplug_io_size;
additional_mem_size = pci_hotplug_mem_size;
}
+
+ pci_fixup_device(pci_fixup_assign, bus->self);
/* Fall through */
default:
pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2775,6 +2775,13 @@ static void quirk_hotplug_bridge(struct pci_dev *dev)
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge);
+static void quirk_hotplug_bridge_skip(struct pci_dev *dev)
+{
+ dev->is_hotplug_bridge = 0;
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x8c10, quirk_hotplug_bridge_skip);
+
/*
* This is a quirk for the Ricoh MMC controller found as a part of
* some mulifunction chips.

View File

@ -0,0 +1,32 @@
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 37ff015..47b303a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2776,6 +2776,27 @@ static void quirk_hotplug_bridge(struct pci_dev *dev)
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge);
/*
+ * Apple: Avoid programming the memory/io aperture of 00:1c.0
+ *
+ * BIOS does not declare any resource for 00:1c.0, but with
+ * hotplug flag set, thus OS allocate:
+ * [mem 0x7fa00000 - 0x7fbfffff]
+ * [mem 0x7fc00000-0x7fdfffff 64bit pref]
+ * which is conflict with an unreported device, which
+ * causes unpredictable result such as accessing io port.
+ * So clear the hotplug flag to work around it.
+ */
+static void quirk_apple_mbp_poweroff(struct pci_dev *dev)
+{
+ if (dmi_match(DMI_BOARD_VENDOR, "Apple Inc.") &&
+ dmi_match(DMI_PRODUCT_NAME, "MacBookPro11,4") ||
+ dmi_match(DMI_PRODUCT_NAME, "MacBookPro11,5"))
+ dev->is_hotplug_bridge = 0;
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x8c10, quirk_apple_mbp_poweroff);
+
+/*
* This is a quirk for the Ricoh MMC controller found as a part of
* some mulifunction chips.