Remove CentOS/OpenSUSE build support

StarlingX stopped supporting CentOS builds in the after release 7.0.
This update will strip CentOS from our code base.  It will also remove
references to the failed OpenSUSE feature as well.

Story: 2011110
Task: 49955
Change-Id: I927a02d39114862c6a4ebd12c8c88640be18e370
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
Scott Little 2024-04-26 11:41:16 -04:00
parent 1a089999c4
commit 8979864699
137 changed files with 0 additions and 26489 deletions

View File

@ -1 +0,0 @@
distro

View File

@ -1,8 +0,0 @@
mlnx-ofa_kernel-5.5-OFED.5.5.1.0.3.1.src.rpm
mlnx-tools-5.2.0-0.55103.src.rpm
mstflint-4.16.0-1.55103.src.rpm
rdma-core-55mlnx37-1.55103.src.rpm
opae-intel-fpga-driver-2.0.1-10.src.rpm
ice_comms-1.3.35.0.zip
netxtreme-bnxt_en-1.10.2-220.0.13.0.tar.gz
libbnxt_re-220.0.5.0-rhel7u9.src.rpm

View File

@ -1,22 +0,0 @@
# List of packages to be included/installed in guest image
# If these have dependencies, they will be pulled in automatically
#
# kernel
perf
#
# Network Drivers
#
# iavf-kmod
kmod-iavf
# i40e-kmod
kmod-i40e
# ice-kmod
kmod-ice
# qat17
qat17

View File

@ -1,23 +0,0 @@
# List of packages to be included/installed in RT guest image
# If these have dependencies, they will be pulled in automatically
#
#
# Network Drivers
#
# iavf-kmod
kmod-iavf-rt
# i40e-kmod
kmod-i40e-rt
# ice-kmod
kmod-ice-rt
# ixgbevf-kmod
# ixgbe-kmod
# qat17
qat17-rt

View File

@ -1,67 +0,0 @@
# List of packages to be included/installed in the ISO image.
# If these have dependencies, they will be pulled in automatically.
#
# kernel
kernel
kernel-modules-extra
kernel-tools
kernel-tools-libs
kernel-headers
kernel-devel
bpftool
perf
python-perf
# kernel-rt
kernel-rt
kernel-rt-kvm
kernel-rt-modules-extra
kernel-rt-tools
kernel-rt-headers
kernel-rt-devel
# e1000e-kmod
# i40e-kmod
kmod-i40e
kmod-i40e-rt
# iavf-kmod
kmod-iavf
kmod-iavf-rt
# ice-kmod
kmod-ice
kmod-ice-rt
# ixgbevf-kmod
# ixgbe-kmod
# igb_uio-kmod
kmod-igb_uio
kmod-igb_uio-rt
# drbd-kernel
# qat17
qat17
qat17-rt
# opae-intel-fpga-driver
kmod-opae-fpga-driver
kmod-opae-fpga-driver-rt
# mellanox drivers
mlnx-ofa_kernel-modules
mlnx-ofa_kernel-rt-modules
rdma-core
# mellanox firmware tool
mstflint
# Broadcom device driver
kmod-bnxt_en
kmod-bnxt_en-rt
libbnxt_re

View File

@ -1,13 +0,0 @@
kernel-std
kernel-modules/bnxt_en
kernel-modules/intel-iavf
kernel-modules/intel-i40e
kernel-modules/intel-ice
kernel-modules/intel-igb_uio
kernel-modules/qat17
kernel-modules/intel-opae-fpga
kernel-modules/mlnx-ofa_kernel
userspace/broadcom/libbnxt_re
userspace/mellanox/rdma-core
userspace/mellanox/mlnx-tools
userspace/mellanox/mstflint

View File

@ -1,13 +0,0 @@
kernel-rt
kernel-modules/bnxt_en
kernel-modules/mlnx-ofa_kernel
kernel-modules/intel-iavf
kernel-modules/intel-i40e
kernel-modules/intel-ice
kernel-modules/intel-igb_uio
kernel-modules/qat17
kernel-modules/intel-opae-fpga
userspace/broadcom/libbnxt_re
userspace/mellanox/rdma-core
userspace/mellanox/mlnx-tools
userspace/mellanox/mstflint

View File

@ -1,17 +0,0 @@
dpdk-20.05.tar.gz#dpdk-20.05#https://fast.dpdk.org/rel/dpdk-20.05.tar.gz#http##
drbd-8.4.11-1.tar.gz#drbd-8.4.11-1#http://www.linbit.com/downloads/drbd/8.4/drbd-8.4.11-1.tar.gz#http##
e1000e-3.6.0.tar.gz#e1000e-3.6.0#https://sourceforge.net/projects/e1000/files/e1000e%20stable/3.6.0/e1000e-3.6.0.tar.gz#http##
i40e-2.18.9.tar.gz#i40e-2.18.9#https://sourceforge.net/projects/e1000/files/i40e%20stable/2.18.9/i40e-2.18.9.tar.gz/download#https##
iavf-4.4.2.tar.gz#iavf-4.4.2#https://sourceforge.net/projects/e1000/files/iavf%20stable/4.4.2/iavf-4.4.2.tar.gz/download#https##
ice-1.8.3.tar.gz#ice-1.8.3#https://sourceforge.net/projects/e1000/files/ice%20stable/1.8.3/ice-1.8.3.tar.gz/download#https##
ixgbe-5.6.5.tar.gz#ixgbe-5.6.5#https://sourceforge.net/projects/e1000/files/ixgbe%20stable/5.6.5/ixgbe-5.6.5.tar.gz/download#http##
ixgbevf-4.6.3.tar.gz#ixgbevf-4.6.3#https://sourceforge.net/projects/e1000/files/ixgbevf%20stable/4.6.3/ixgbevf-4.6.3.tar.gz/download#http##
!kernel-rt-4.18.0-147.3.1.rt24.96.el8_1.src.rpm#kernel-rt#https://git.centos.org/rpms/kernel-rt#http_script#327ec52423c67051249291f131ec7f6fff44a828#post-dl-script/kernel-rt.sh
!MLNX_OFED_SRC-5.5-1.0.3.2.tgz#MLNX_OFED_SRC-5.5-1.0.3.2#https://content.mellanox.com/ofed/MLNX_OFED-5.5-1.0.3.2/MLNX_OFED_SRC-5.5-1.0.3.2.tgz#http_script##unused
opae-intel-fpga-driver-2.0.1-8.tar.gz#opae-intel-fpga-driver-2.0.1-8#https://github.com/OPAE/opae-sdk/releases/download/1.3.7-4/opae-intel-fpga-driver-2.0.1-8.tar.gz#http##
!qat1.7.l.4.5.0-00034.tar.gz#quickassist#https://01.org/sites/default/files/downloads/qat1.7.l.4.5.0-00034.tar.gz#http_script##post-dl-script/qat1.7.sh
!QAT1.7.L.4.14.0-00031.tar.gz#quickassist#https://downloadmirror.intel.com/30178/eng/QAT1.7.L.4.14.0-00031.tar.gz#http_script##unused
!dpdk-kmods-2a9f0f72a2d926382634cf8f1de10e1acf57542b.tar.gz#dpdk-kmods#git://dpdk.org/dpdk-kmods/#git#2a9f0f72a2d926382634cf8f1de10e1acf57542b##
!OPAE_1.3.7-5_el7.zip#OPAE#https://github.com/OPAE/opae-sdk/releases/download/1.3.7-5/OPAE_1.3.7-5_el7.zip#http_script##unused
!ice_comms-1.3.35.0.zip#unused-field#https://downloadmirror.intel.com/727568/ice_comms-1.3.35.0.zip#http_script##unused
!bcm_220.0.83.0.tar.gz#bcm_220.0.83.0#https://docs.broadcom.com/docs-and-downloads/ethernet-network-adapters/NXE/BRCM_220.0.83.0/bcm_220.0.83.0.tar.gz#http_script#85bdfc30b4bd3e184e3b57a48055c11085e3b97593f7b4a8347fa50a9d571336#unused

View File

@ -1,139 +0,0 @@
%if "%{?_tis_build_type}" == "rt"
%define bt_ext -rt
%else
%undefine bt_ext
%endif
%define kmod_name bnxt_en
%define upstream_release 220.0.13.0
## Condition to check if retpolines are needed.
## Default: retpolines are enabled.
%bcond_without retpoline
# Disable the building of debug package(s).
%define debug_package %{nil}
Name: kmod-%{kmod_name}%{?bt_ext}
Version: 1.10.2
Release: %{upstream_release}%{?_tis_dist}.%{tis_patch_ver}
Group: System Environment/Base
Packager: StarlingX Community
Vendor: Broadcom Inc
URL: https://www.broadcom.com/support/download-search?pg=&pf=&pn=&pa=&po=&dk=bnxt_en&pl=
License: GPLv2
Summary: Broadcom NetXtreme Gigabit Ethernet Driver
Provides: %{kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-make
BuildRequires: findutils
BuildRequires: kernel%{?bt_ext}-devel kernel%{?bt_ext}-devel-keys
BuildRequires: mlnx-ofa_kernel%{?bt_ext}-devel mlnx-ofa_kernel%{?bt_ext}-source
Requires: mlnx-ofa_kernel%{?bt_ext}-modules
Requires(post): /usr/sbin/depmod
Requires(postun): /usr/sbin/depmod
Source0: netxtreme-%{kmod_name}-%{version}-%{upstream_release}.tar.gz
Source1: modprobe.conf
Patch0001: 0001-bnxt_re-Makefile-Adapt-to-mlnx-ofa_kernel-for-Starli.patch
Patch0002: 0002-bnxt_en-bnxt_compat.h-Fix-up-a-build-failure.patch
Patch0003: 0003-bnxt_en-bnxt_re-Use-irq_update_affinity_hint.patch
#define some build variables required
%define bnxt_en_driver bnxt_en
%define bnxt_re_driver bnxt_re
%define kversion %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')
%description
This package provides the %{bnxt_en_driver} and %{bnxt_re_driver} kernel
modules built for the Linux kernel for the %{_target_cpu} family of processors.
%prep
%autosetup -p 1 -n netxtreme-%{kmod_name}-%{version}-%{upstream_release}
cp %{bnxt_re_driver}/README.TXT %{bnxt_re_driver}/%{bnxt_re_driver}_README.TXT
cp %{bnxt_en_driver}/README.TXT %{bnxt_en_driver}/%{bnxt_en_driver}_README.TXT
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
export EXTRA_CFLAGS+='-DVERSION=\"%{version}\"'
%if %{with retpoline}
find . -name *.c -print0 | xargs -0 sed -i '/MODULE_LICENSE(/a MODULE_INFO(retpoline, "Y");'
%endif
# Regenerate MANIFEST HASH
if [ -e bnxt_en/MANIFEST ]; then
pushd bnxt_en >/dev/null
sha512sum $(cat MANIFEST | cut -c 131-) > MANIFEST
popd >/dev/null
fi
%{__make} %{_smp_mflags} -C bnxt_en \
KVER=%{kversion} \
KDIR=%{_usrsrc}/kernels/%{kversion}
OFED_VERSION="$(ls -1vd %{_usrsrc}/ofa_kernel-* | xargs -r -n1 basename | \
sed -e 's@^ofa_kernel-@@' | sort --version-sort | tail -n1)"
if test -z "${OFED_VERSION}"; then
echo "Error: Could not detect the OFED version"
exit 1
fi
%{__make} %{_smp_mflags} -C bnxt_re \
KVER=%{kversion} \
KDIR=%{_usrsrc}/kernels/%{kversion} \
OFED_VERSION="${OFED_VERSION}"
%install
export KVER=%{kversion}
dest_dir_bnxt_en=${RPM_BUILD_ROOT}/lib/modules/${KVER}/extra/%{kmod_name}/
src_dir_bnxt_en=$(find . -name %{bnxt_en_driver}.ko)
dest_dir_bnxt_re=${RPM_BUILD_ROOT}/lib/modules/${KVER}/extra/%{kmod_name}/drivers/infiniband/hw/%{bnxt_re_driver}/
src_dir_bnxt_re=$(find . -name %{bnxt_re_driver}.ko)
mkdir -p ${dest_dir_bnxt_en}
mkdir -p ${dest_dir_bnxt_re}
install -m 744 ${src_dir_bnxt_en} ${dest_dir_bnxt_en}
install -m 744 ${src_dir_bnxt_re} ${dest_dir_bnxt_re}
install -d %{buildroot}%{_sysconfdir}/modprobe.d
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/modprobe.d/bnxt.conf
### Adapted from i40e
# Strip the modules(s).
find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kversion}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do /usr/src/kernels/%{kversion}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%files
%defattr(644,root,root,755)
/lib/modules/%{kversion}/extra/%{kmod_name}/
%{_sysconfdir}/modprobe.d/bnxt.conf
%post
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
%postun
/usr/sbin/depmod -a >/dev/null 2>&1 || true
%clean
rm -rf %{buildroot}
%changelog

View File

@ -1,12 +0,0 @@
COPY_LIST=" \
$PATCHES_BASE/* \
$PKG_BASE/files/modprobe.conf \
$STX_BASE/downloads/netxtreme-bnxt_en-1.10.2-220.0.13.0.tar.gz \
"
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=1378583af6e040bc974f67850cd44e0c62d42f81
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=1378583af6e040bc974f67850cd44e0c62d42f81
PKG_BASE_SRCREV=1378583af6e040bc974f67850cd44e0c62d42f81
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT

View File

@ -1,117 +0,0 @@
From b4de4f0d87331a3df820ca78a7196b41a5ee74d5 Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Fri, 4 Feb 2022 18:27:53 -0500
Subject: [PATCH] bnxt_re/Makefile: Adapt to mlnx-ofa_kernel for StarlingX
This patch adapts the bnxt_re kernel module's Makefile to
mlnx-ofa_kernel for StarlingX.
Here is a summary of the changes:
- $(shell uname -r) is replaced with $(KVER) to ensure that the target
kernel version is selected instead of the build host's kernel version.
- To target Mellanox's OFED distribution instead of compat-rdma, the
references to "/usr/src/compat-rdma" are replaced with
"/usr/src/ofa_kernel".
- Mellanox's OFED distribution has version numbers in the form 5.x, so
the Makefile version match patterns are adjusted.
- "AUTOCONF_H += -include $(LINUXSRC)/include/linux/kconfig.h" line is
added avoid the following kernel module build errors indicating that
IS_ENABLED is unintendedly undefined:
include/asm-generic/bitops/instrumented-non-atomic.h: In function \
'__instrument_read_write_bitop':
include/asm-generic/bitops/instrumented-non-atomic.h:63:6: error: \
implicit declaration of function 'IS_ENABLED' \
[-Werror=implicit-function-declaration]
if (IS_ENABLED(CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC)) {
^~~~~~~~~~
- The line that reads
"KBUILD_EXTRA_SYMBOLS := $(BNXT_PEER_MEM_INC)/Module.symvers"
is guarded to avoid the following build warning, which is encountered
as BNXT_PEER_MEM_INC is not defined by default:
WARNING: Symbol version dump "/Module.symvers" is missing.
- OFA_BUILD_PATH and OFA_KERNEL_PATH are adjusted to refer to the kernel
source code belonging to the target kernel version in
"/usr/src/kernels/", because StarlingX's build environment does not
populate /lib/modules/<kver>/ with symbolic links for kernel source
and build trees.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
bnxt_re-220.0.12.0/Makefile | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/bnxt_re-220.0.12.0/Makefile b/bnxt_re-220.0.12.0/Makefile
index 532fb8025465..d13a61379acb 100644
--- a/bnxt_re-220.0.12.0/Makefile
+++ b/bnxt_re-220.0.12.0/Makefile
@@ -32,7 +32,7 @@ ifeq ($(shell ls /lib/modules/$(KVER)/build > /dev/null 2>&1 && echo build),)
# SuSE source RPMs
_KVER=$(shell echo $(KVER) | cut -d "-" -f1,2)
_KFLA=$(shell echo $(KVER) | cut -d "-" -f3)
- _ARCH=$(shell file -b /lib/modules/$(shell uname -r)/build | cut -d "/" -f5)
+ _ARCH=$(shell file -b /lib/modules/$(KVER)/build | cut -d "/" -f5)
ifeq ($(_ARCH),)
_ARCH=$(__ARCH)
endif
@@ -90,34 +90,40 @@ ifeq ($(OFED_VERSION), )
endif
#find OFED version and compat-includes
-ofed_major=$(filter OFED-3.% OFED-4.%, $(OFED_VERSION))
+ofed_major=$(filter OFED-3.% OFED-4.% 5.%, $(OFED_VERSION))
ifneq ($(ofed_major), )
-exists=$(shell if [ -e /usr/src/compat-rdma$(OFED_VERSION) ];\
+exists=$(shell if [ -e /usr/src/ofa_kernel-$(OFED_VERSION) ];\
then echo y; fi)
ifeq ($(exists), )
-$(shell ln -s /usr/src/compat-rdma\
- /usr/src/compat-rdma$(OFED_VERSION))
+$(shell ln -s /usr/src/ofa_kernel\
+ /usr/src/ofa_kernel-$(OFED_VERSION))
endif
-OFA_BUILD_PATH=/usr/src/compat-rdma$(OFED_VERSION)
-OFA_KERNEL_PATH=/usr/src/compat-rdma$(OFED_VERSION)
+OFA_BUILD_PATH=/usr/src/ofa_kernel/default
+OFA_KERNEL_PATH=/usr/src/ofa_kernel-$(OFED_VERSION)/source
EXTRA_CFLAGS += -DOFED_3_x
-ofed_4_17_x=$(filter OFED-4.17%, $(ofed_major))
+ofed_4_17_x=$(filter OFED-4.17% 5.%, $(ofed_major))
ifneq ($(ofed_4_17_x), )
EXTRA_CFLAGS += -D__OFED_BUILD__
endif
EXTRA_CFLAGS += -include $(OFA_KERNEL_PATH)/include/linux/compat-2.6.h
AUTOCONF_H = -include $(shell /bin/ls -1 $(LINUX)/include/*/autoconf.h 2> /dev/null | head -1)
+AUTOCONF_H += -include $(LINUXSRC)/include/linux/kconfig.h
endif #end non 3.x OFED
+
+ifneq ($(BNXT_PEER_MEM_INC),)
KBUILD_EXTRA_SYMBOLS := $(BNXT_PEER_MEM_INC)/Module.symvers
+else
+KBUILD_EXTRA_SYMBOLS :=
+endif
ifeq (OFED-NATIVE, $(findstring OFED-NATIVE, $(OFED_VERSION)))
ifeq ($(KERNELRELEASE),)
-OFA_BUILD_PATH =/lib/modules/`uname -r`/build/
-OFA_KERNEL_PATH=/lib/modules/`uname -r`/source/
+OFA_BUILD_PATH=/usr/src/kernels/$(KVER)/
+OFA_KERNEL_PATH=/usr/src/kernels/$(KVER)/
else
-OFA_BUILD_PATH =/lib/modules/$(KERNELRELEASE)/build/
-OFA_KERNEL_PATH=/lib/modules/$(KERNELRELEASE)/source/
+OFA_BUILD_PATH=/usr/src/kernels/$(KERNELRELEASE)/
+OFA_KERNEL_PATH=/usr/src/kernels/$(KERNELRELEASE)/
endif
else
# Add OFED symbols only if external OFED is used
--
2.29.2

View File

@ -1,45 +0,0 @@
From c6e38e23c1a2d45efcab73793ebe28f8fcb504e4 Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Fri, 4 Feb 2022 19:44:06 -0500
Subject: [PATCH] bnxt_en/bnxt_compat.h: Fix up a build failure
This commit resolves the following build failure:
In file included from ./include/net/sock.h:59,
from ./include/linux/tcp.h:19,
from ./include/linux/ipv6.h:87,
from ./include/net/dsfield.h:12,
from ./include/net/ip_tunnels.h:13,
from ./include/net/dst_metadata.h:6,
from /builddir/build/BUILD/netxtreme-bnxt_en-1.10.2-219.0.55.0/bnxt_en-1.10.2-219.0.55.0/bnxt.h:30,
from /builddir/build/BUILD/netxtreme-bnxt_en-1.10.2-219.0.55.0/bnxt_en-1.10.2-219.0.55.0/bnxt_hwrm.c:26:
./include/linux/filter.h:980:1: error: useless type name in empty declaration [-Werror]
void bpf_warn_invalid_xdp_action(u32 act);
^~~~
cc1: all warnings being treated as errors
The problem arises from the fact that the function
bpf_warn_invalid_xdp_action is already defined in the kernel. Having a
placeholder macro definition with the same name causes the compilation
warning (which turns into an error due to -Werror).
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
bnxt_en-1.10.2-220.0.13.0/bnxt_compat.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/bnxt_en-1.10.2-220.0.13.0/bnxt_compat.h b/bnxt_en-1.10.2-220.0.13.0/bnxt_compat.h
index 63d27f2e8979..aeb15fc9ab2a 100644
--- a/bnxt_en-1.10.2-220.0.13.0/bnxt_compat.h
+++ b/bnxt_en-1.10.2-220.0.13.0/bnxt_compat.h
@@ -1596,7 +1596,6 @@ enum xdp_action {
#ifndef HAVE_BPF_TRACE
#define trace_xdp_exception(dev, xdp_prog, act)
-#define bpf_warn_invalid_xdp_action(act)
#endif
#ifdef HAVE_XDP_RXQ_INFO
--
2.29.2

View File

@ -1,134 +0,0 @@
From f278ab69adb9e59041d2b8e78b6005587f94d0e3 Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Wed, 2 Mar 2022 14:14:12 -0500
Subject: [PATCH] bnxt_en, bnxt_re: Use irq_update_affinity_hint
This commit updates the bnxt_en and bnxt_re device drivers to use the
irq_update_affinity_hint function instead of the irq_set_affinity_hint
function, so that StarlingX's CPU affinity requirements for interrupts
are met. (Note that the StarlingX kernel has been patched to add the
irq_update_affinity_hint API function, which originally did not exist in
kernel version 5.10.)
irq_set_affinity_hint sets the IRQ affinity hint as well as the actual
IRQ affinity, which causes the IRQ affinity to not align with the value
of the irqaffinity= command line option.
StarlingX's user-space initialization scripts set the IRQ affinities
too, but if a network interface is initialized after the completion of
the initialization scripts, then the network adapter's preferred IRQ
affinity passed to irq_set_affinity_hint takes effect. The latter is
undesirable if the CPU affinity of an interrupt includes CPUs that are
in the set of isolated CPUs configured by StarlingX, as isolated CPUs
should not service unrelated interrupts.
To resolve the aforementioned issues, this patch updates the bnxt_en and
bnxt_re drivers to use irq_update_affinity_hint, which only sets the IRQ
affinity hint, and not the actual IRQ affinity. This allows interrupts
to be affined to the CPUs listed in the irqaffinity= command line
argument by default, and eliminates the need to set the IRQ affinities
after the initialization of network interfaces.
Finally, please note that the changes in bnxt_en were confirmed to not
be compiled with StarlingX's 5.10-based kernel, because of the following
conditional compilation pre-processor directives that are above the
irq_set_affinity_hint/irq_update_affinity_hint call site:
#if (!defined(CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR) || \
KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE) && \
(defined(HAVE_CPUMASK_LOCAL_FIRST) || \
defined(HAVE_CPUMASK_LOCAL_SPREAD))
/* ... */
cpumask_set_cpu(cpumask_local_spread(i, numa_node),
irq->cpu_mask);
/* ... */
rc = irq_update_affinity_hint(irq->vector, irq->cpu_mask);
/* ... */
The IRQ matrix allocator is enabled in StarlingX's kernel, which also
has a version greater than 4.15. 4.15 happens to be the kernel version
with which the IRQ matrix allocator was introduced. In other words, the
call site in question is not compiled at all with the out-of-tree
bnxt_en driver. The in-tree version of bnxt_en does not have conditional
compilation directives around the same code (i.e., the code is always
compiled in).
Our imperfect understanding of the intent is that the out-of-tree
bnxt_en driver's authors decided to rely on the IRQ matrix allocator's
default IRQ vector distribution behaviour (which appears to occur at a
lower level) instead of setting the IRQ affinity hints explicitly.
Thankfully, the lack of a call irq_update_affinity_hint does not prevent
the irqaffinity= command line argument from taking effect for such
interrupts. This was confirmed with a virtual machine and the e1000e
driver, which also manages multiple MSI-X interrupts and which also does
not explicitly set the IRQ affinities nor affinity hints. In our
experiments, the IRQ affinities of the emulated Intel network adapter
correctly matched the CPU list set by the irqaffinity= command line
argument.
Despite what is discussed above, the code changes in bnxt_en are kept
for completeness.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
bnxt_en-1.10.2-220.0.13.0/bnxt.c | 6 +++---
bnxt_re-220.0.12.0/qplib_fp.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/bnxt_en-1.10.2-220.0.13.0/bnxt.c b/bnxt_en-1.10.2-220.0.13.0/bnxt.c
index b0b99338c425..a2f55dfcd0c3 100644
--- a/bnxt_en-1.10.2-220.0.13.0/bnxt.c
+++ b/bnxt_en-1.10.2-220.0.13.0/bnxt.c
@@ -10716,7 +10716,7 @@ static void bnxt_free_irq(struct bnxt *bp)
(defined(HAVE_CPUMASK_LOCAL_FIRST) || \
defined(HAVE_CPUMASK_LOCAL_SPREAD))
if (irq->have_cpumask) {
- irq_set_affinity_hint(irq->vector, NULL);
+ irq_update_affinity_hint(irq->vector, NULL);
free_cpumask_var(irq->cpu_mask);
irq->have_cpumask = 0;
}
@@ -10787,10 +10787,10 @@ static int bnxt_request_irq(struct bnxt *bp)
break;
}
#endif
- rc = irq_set_affinity_hint(irq->vector, irq->cpu_mask);
+ rc = irq_update_affinity_hint(irq->vector, irq->cpu_mask);
if (rc) {
netdev_warn(bp->dev,
- "Set affinity failed, IRQ = %d\n",
+ "Update affinity failed, IRQ = %d\n",
irq->vector);
break;
}
diff --git a/bnxt_re-220.0.12.0/qplib_fp.c b/bnxt_re-220.0.12.0/qplib_fp.c
index ef5f279fcb79..60d2eda3727d 100644
--- a/bnxt_re-220.0.12.0/qplib_fp.c
+++ b/bnxt_re-220.0.12.0/qplib_fp.c
@@ -492,7 +492,7 @@ void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill)
bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, false);
/* Sync with last running IRQ handler */
synchronize_irq(nq->msix_vec);
- irq_set_affinity_hint(nq->msix_vec, NULL);
+ irq_update_affinity_hint(nq->msix_vec, NULL);
free_irq(nq->msix_vec, nq);
/* Cleanup Tasklet */
@@ -546,10 +546,10 @@ int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
cpumask_clear(&nq->mask);
cpumask_set_cpu(nq_indx, &nq->mask);
- rc = irq_set_affinity_hint(nq->msix_vec, &nq->mask);
+ rc = irq_update_affinity_hint(nq->msix_vec, &nq->mask);
if (rc)
dev_warn(&res->pdev->dev,
- "QPLIB: set affinity failed; vector: %d nq_idx: %d\n",
+ "QPLIB: update affinity failed; vector: %d nq_idx: %d\n",
nq->msix_vec, nq_indx);
nq->requested = true;
bnxt_qplib_ring_nq_db(&nq->nq_db.dbinfo, res->cctx, true);
--
2.29.2

View File

@ -1,9 +0,0 @@
COPY_LIST=" \
$PKG_BASE/files/* \
$STX_BASE/downloads/i40e-2.18.9.tar.gz"
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=1378583af6e040bc974f67850cd44e0c62d42f81
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=1378583af6e040bc974f67850cd44e0c62d42f81
PKG_BASE_SRCREV=1927a6d6250856164295aa1aca2ba0e40fa95c18
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT

View File

@ -1,130 +0,0 @@
%if "%{?_tis_build_type}" == "rt"
%define bt_ext -rt
%else
%undefine bt_ext
%endif
# Define the kmod package name here.
%define kmod_name i40e
Name: %{kmod_name}-kmod%{?bt_ext}
Version: 2.18.9
Release: 1%{?_tis_dist}.%{tis_patch_ver}
Group: System Environment/Kernel
License: GPLv2
Summary: %{kmod_name}%{?bt_ext} kernel module(s)
URL: http://www.intel.com/
BuildRequires: kernel%{?bt_ext}-devel, kernel%{?bt_ext}-devel-keys, redhat-rpm-config, openssl
BuildRequires: elfutils-libelf-devel
%if 0%{?rhel} == 7
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-make
%endif
ExclusiveArch: x86_64
# Sources.
Source0: %{kmod_name}-%{version}.tar.gz
Source5: GPL-v2.0.txt
Source11: modules-load.conf
Patch01: i40e-Enable-getting-link-status-from-VF.patch
Patch02: i40e-add-more-debug-info-for-VFs-still-in-reset.patch
Patch03: i40e_main-Use-irq_update_affinity_hint.patch
%define kversion %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')
%package -n kmod-i40e%{?bt_ext}
Summary: i40e kernel module(s)
Group: System Environment/Kernel
%global _use_internal_dependency_generator 0
Provides: kernel-modules >= %{kversion}
Provides: i40e-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires(post): /usr/sbin/depmod
Requires(postun): /usr/sbin/depmod
%description -n kmod-i40e%{?bt_ext}
This package provides the i40e kernel module(s) built
for the Linux kernel using the %{_target_cpu} family of processors.
%post -n kmod-i40e%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
echo "Done."
%preun -n kmod-i40e%{?bt_ext}
rpm -ql kmod-i40e%{?bt_ext}-%{version}-%{release}.x86_64 | grep '\.ko$' > /var/run/rpm-kmod-i40e%{?bt_ext}-modules
%postun -n kmod-i40e%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
rm /var/run/rpm-kmod-i40e%{?bt_ext}-modules
echo "Done."
%files -n kmod-i40e%{?bt_ext}
%defattr(644,root,root,755)
/lib/modules/%{kversion}/
%doc /usr/share/doc/kmod-i40e-%{version}/
%doc /usr/share/man/man7/
%{_sysconfdir}/modules-load.d/i40e.conf
# Disable the building of the debug package(s).
%define debug_package %{nil}
%description
This package provides the %{kmod_name} kernel module(s).
It is built to depend upon the specific ABI provided by a range of releases
of the same variant of the Linux kernel and not on any one specific build.
%prep
%autosetup -p 1 -n %{kmod_name}-%{version}
%{__gzip} %{kmod_name}.7
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
pushd src >/dev/null
%{__make} KSRC=%{_usrsrc}/kernels/%{kversion}
popd >/dev/null
%install
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
%{__install} -d %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} src/%{kmod_name}.ko %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} -d %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} %{SOURCE5} %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} pci.updates %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} README %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} -d %{buildroot}%{_mandir}/man7/
%{__install} %{kmod_name}.7.gz %{buildroot}%{_mandir}/man7/
%{__install} -d %{buildroot}%{_sysconfdir}/modules-load.d
%{__install} -m 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/modules-load.d/i40e.conf
# Strip the modules(s).
find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kversion}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do /usr/src/kernels/%{kversion}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%clean
%{__rm} -rf %{buildroot}
%changelog
* Thu Feb 11 2016 Matthias Saou <matthias@saou.eu> 1.4.25-1
- Initial RPM package, based on elrepo.org's ixgbe one.

View File

@ -1,9 +0,0 @@
COPY_LIST=" \
$PKG_BASE/files/* \
$STX_BASE/downloads/iavf-4.4.2.tar.gz"
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=1378583af6e040bc974f67850cd44e0c62d42f81
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=1378583af6e040bc974f67850cd44e0c62d42f81
PKG_BASE_SRCREV=1927a6d6250856164295aa1aca2ba0e40fa95c18
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT

View File

@ -1,128 +0,0 @@
%if "%{?_tis_build_type}" == "rt"
%define bt_ext -rt
%else
%undefine bt_ext
%endif
# Define the kmod package name here.
%define kmod_name iavf
Name: %{kmod_name}-kmod%{?bt_ext}
Version: 4.4.2
Release: 1%{?_tis_dist}.%{tis_patch_ver}
Group: System Environment/Kernel
License: GPLv2
Summary: %{kmod_name} kernel module(s)
URL: http://www.intel.com/
BuildRequires: kernel%{?bt_ext}-devel, kernel%{?bt_ext}-devel-keys, redhat-rpm-config, openssl
BuildRequires: elfutils-libelf-devel
%if 0%{?rhel} == 7
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-make
%endif
ExclusiveArch: x86_64
# Sources.
Source0: %{kmod_name}-%{version}.tar.gz
Source5: GPL-v2.0.txt
Source11: modules-load.conf
Patch01: iavf_main-Use-irq_update_affinity_hint.patch
%define kversion %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')
%package -n kmod-iavf%{?bt_ext}
Summary: iavf kernel module(s)
Group: System Environment/Kernel
%global _use_internal_dependency_generator 0
Provides: kernel-modules >= %{kversion}
Provides: iavf-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires(post): /usr/sbin/depmod
Requires(postun): /usr/sbin/depmod
%description -n kmod-iavf%{?bt_ext}
This package provides the iavf kernel module(s) built
for the Linux kernel using the %{_target_cpu} family of processors.
%post -n kmod-iavf%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
echo "Done."
%preun -n kmod-iavf%{?bt_ext}
rpm -ql kmod-iavf%{?bt_ext}-%{version}-%{release}.x86_64 | grep '\.ko$' > /var/run/rpm-kmod-iavf%{?bt_ext}-modules
%postun -n kmod-iavf%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
rm /var/run/rpm-kmod-iavf%{?bt_ext}-modules
echo "Done."
%files -n kmod-iavf%{?bt_ext}
%defattr(644,root,root,755)
/lib/modules/%{kversion}/
%doc /usr/share/doc/kmod-iavf-%{version}/
%doc /usr/share/man/man7/
%{_sysconfdir}/modules-load.d/iavf.conf
# Disable the building of the debug package(s).
%define debug_package %{nil}
%description
This package provides the %{kmod_name} kernel module(s).
It is built to depend upon the specific ABI provided by a range of releases
of the same variant of the Linux kernel and not on any one specific build.
%prep
%autosetup -p 1 -n %{kmod_name}-%{version}
%{__gzip} %{kmod_name}.7
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
pushd src >/dev/null
%{__make} KSRC=%{_usrsrc}/kernels/%{kversion}
popd >/dev/null
%install
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
%{__install} -d %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} src/%{kmod_name}.ko %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} -d %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} %{SOURCE5} %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} pci.updates %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} README %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} -d %{buildroot}%{_mandir}/man7/
%{__install} %{kmod_name}.7.gz %{buildroot}%{_mandir}/man7/
%{__install} -d %{buildroot}%{_sysconfdir}/modules-load.d
%{__install} -m 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/modules-load.d/iavf.conf
# Strip the modules(s).
find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kversion}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do /usr/src/kernels/%{kversion}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%clean
%{__rm} -rf %{buildroot}
%changelog
* Thu Feb 11 2016 Matthias Saou <matthias@saou.eu> 1.4.25-1
- Initial RPM package, based on elrepo.org's ixgbe one.

View File

@ -1,10 +0,0 @@
COPY_LIST=" \
$PKG_BASE/files/* \
$STX_BASE/downloads/ice-1.8.3.tar.gz \
$STX_BASE/downloads/ice_comms-1.3.35.0.zip"
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=1378583af6e040bc974f67850cd44e0c62d42f81
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=1378583af6e040bc974f67850cd44e0c62d42f81
PKG_BASE_SRCREV=1927a6d6250856164295aa1aca2ba0e40fa95c18
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT

View File

@ -1,137 +0,0 @@
%if "%{?_tis_build_type}" == "rt"
%define bt_ext -rt
%else
%undefine bt_ext
%endif
%define kmod_name ice
Name: %{kmod_name}-kmod%{?bt_ext}
Version: 1.8.3
Release: 1%{?_tis_dist}.%{tis_patch_ver}
Group: System Environment/Kernel
License: GPL-2.0
Summary: Intel(R) Ethernet Connection E800 Series Linux Driver
URL: http://support.intel.com
BuildRequires: kernel%{?bt_ext}-devel, kernel%{?bt_ext}-devel-keys, redhat-rpm-config, openssl, elfutils-libelf-devel
Requires: kernel%{?bt_ext}-devel, findutils, gawk, bash
%if 0%{?rhel} == 7
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-make
%endif
%define kernel_module_package_buildreqs kernel%{?bt_ext}-devel
Source0: %{kmod_name}-%{version}.tar.gz
Source1: ice_comms-1.3.35.0.zip
Source11: modules-load.conf
Patch1: 0001-ice_main-ice_lib-Use-irq_update_affinity_hint.patch
Patch2: 0002-rename-the-ddp-file-to-avoid-conflict.patch
%define kversion %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')
%define find() %(for f in %*; do if [ -e $f ]; then echo $f; break; fi; done)
%package -n kmod-ice%{?bt_ext}
Summary: Intel(R) Ethernet Connection E800 Series Linux Driver
Group: System Environment/Kernel
%global _use_internal_dependency_generator 0
Provides: kernel-modules >= %{kversion}
Provides: ice-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires(post): /usr/sbin/depmod
Requires(postun): /usr/sbin/depmod
%define debug_package %{nil}
%description -n kmod-ice%{?bt_ext}
This package provides the Intel(R) Ethernet Connection E800 Series Linux Driver,
ice, built for the Linux kernel using the %{_target_cpu} family of processors.
%prep
%autosetup -p 1 -n %{kmod_name}-%{version}
unzip %{SOURCE1} -d ice_comms
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
pushd src >/dev/null
%{__make} KSRC=%{_usrsrc}/kernels/%{kversion}
popd >/dev/null
%install
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
%{__install} -d %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} src/%{kmod_name}.ko %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} -d %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} COPYING %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} pci.updates %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} README %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} -d %{buildroot}%{_mandir}/man7/
%{__install} %{kmod_name}.7 %{buildroot}%{_mandir}/man7/
%{__install} -d %{buildroot}%{_sysconfdir}/modules-load.d
%{__install} -m 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/modules-load.d/ice.conf
# Install both the OS default regular DDP fw and the COMMS version
%{__install} -d %{buildroot}/lib/firmware/updates/intel/ice/ddp/
%{__install} ddp/README %{buildroot}/lib/firmware/updates/intel/ice/ddp/README
%{__install} ddp/LICENSE %{buildroot}/lib/firmware/updates/intel/ice/ddp/LICENSE
%{__install} ddp/ice-*.pkg %{buildroot}/lib/firmware/updates/intel/ice/ddp/
%{__install} -m 644 ice_comms/*.txt %{buildroot}/lib/firmware/updates/intel/ice/ddp/
%{__install} -m 644 ice_comms/ice_comms*.pkg %{buildroot}/lib/firmware/updates/intel/ice/ddp/
# Make the regular DDP fw be the default one to load
mkdir -p %{buildroot}//lib/firmware/intel/ice/ddp/
ln -frs %{buildroot}/lib/firmware/updates/intel/ice/ddp/ice-*.pkg %{buildroot}//lib/firmware/intel/ice/ddp/stx-ice.pkg
# Strip the modules(s).
find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kversion}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do /usr/src/kernels/%{kversion}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%clean
rm -rf %{buildroot}
%files -n kmod-ice%{?bt_ext}
%defattr(644,root,root,755)
/lib/modules/%{kversion}/
/lib/firmware/updates/intel/ice/ddp/*
/lib/firmware/intel/ice/ddp/stx-ice.pkg
%{_sysconfdir}/modules-load.d/ice.conf
%doc /usr/share/doc/kmod-ice-%{version}/
%doc /usr/share/man/man7/
# Disable the building of the debug package(s).
%define debug_package %{nil}
%post -n kmod-ice%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
echo "Done."
%preun -n kmod-ice%{?bt_ext}
rm -rf /usr/local/share/%{name}
%postun -n kmod-ice%{?bt_ext}
uname -r | grep BOOT || /sbin/depmod -a > /dev/null 2>&1 || true
%description
This package provides the ice kernel module(s) built
for the Linux kernel using the %{_target_cpu} family of processors.
This package contains the Intel(R) Ethernet Connection E800 Series Linux Driver.

View File

@ -1,9 +0,0 @@
COPY_LIST=" \
$PKG_BASE/files/* \
$STX_BASE/downloads/dpdk-kmods-2a9f0f72a2d926382634cf8f1de10e1acf57542b.tar.gz"
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=145ff64b9734e5c45cfd8eb837a04e257b4b9581
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=c0fee2da8ef34aa816ddd76690ed425b2ff94c90
PKG_BASE_SRCREV=654d249454a7e5c51c683a6bd453cae2711ade56
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT+1

View File

@ -1,121 +0,0 @@
%if "%{?_tis_build_type}" == "rt"
%define bt_ext -rt
%else
%undefine bt_ext
%endif
# dpdk-devbind.py uses Python 3.
%define __python python3
# Define the kmod package name here.
%define kmod_name igb_uio
Name: %{kmod_name}-kmod%{?bt_ext}
Version: 21.02
Release: 0%{?_tis_dist}.%{tis_patch_ver}
Group: System Environment/Kernel
License: GPLv2
Summary: %{kmod_name} kernel module(s)
URL: http://www.intel.com/
BuildRequires: kernel%{?bt_ext}-devel, kernel%{?bt_ext}-devel-keys, openssl, redhat-rpm-config
%if 0%{?rhel} == 7
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
BuildRequires: devtoolset-8-make
%endif
ExclusiveArch: x86_64 i686 aarch64 ppc64le
# Sources.
Source0: dpdk-kmods-2a9f0f72a2d926382634cf8f1de10e1acf57542b.tar.gz
Source1: dpdk-devbind.py
%define kversion %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')
%package -n kmod-igb_uio%{?bt_ext}
Summary: igb_uio kernel module(s)
Group: System Environment/Kernel
%global _use_internal_dependency_generator 0
Provides: kernel-modules >= %{kversion}
Provides: igb_uio-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
Requires(post): /usr/sbin/depmod
Requires(postun): /usr/sbin/depmod
%description -n kmod-igb_uio%{?bt_ext}
This package provides the igb_uio kernel module(s) built
for the Linux kernel using the %{_target_cpu} family of processors.
%post -n kmod-igb_uio%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
echo "Done."
%preun -n kmod-igb_uio%{?bt_ext}
rpm -ql kmod-igb_uio%{?bt_ext}-%{version}-%{release}.x86_64 | grep '\.ko$' > /var/run/rpm-kmod-igb_uio%{?bt_ext}-modules
%postun -n kmod-igb_uio%{?bt_ext}
echo "Working. This may take some time ..."
if [ -e "/boot/System.map-%{kversion}" ]; then
/usr/sbin/depmod -aeF "/boot/System.map-%{kversion}" "%{kversion}" > /dev/null || :
fi
rm /var/run/rpm-kmod-igb_uio%{?bt_ext}-modules
echo "Done."
%files -n kmod-igb_uio%{?bt_ext}
%defattr(644,root,root,755)
/lib/modules/%{kversion}/
%defattr(755,root,root,755)
%{_datadir}/starlingx/scripts/dpdk-devbind.py
%exclude %{_datadir}/starlingx/scripts/*.py[oc]
# Disable the building of the debug package(s).
%define debug_package %{nil}
%description
This package provides the %{kmod_name} kernel module(s).
It is built to depend upon the specific ABI provided by a range of releases
of the same variant of the Linux kernel and not on any one specific build.
%prep
%autosetup -p 1 -n dpdk-kmods
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
%endif
cd linux/igb_uio
%{__make} KSRC=%{_usrsrc}/kernels/%{kversion}
%install
find . -name *.ko
%{__install} -d %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} linux/igb_uio/%{kmod_name}.ko %{buildroot}/lib/modules/%{kversion}/extra/%{kmod_name}/
%{__install} -d %{buildroot}%{_datadir}/starlingx/scripts
%{__install} -m755 %{SOURCE1} %{buildroot}%{_datadir}/starlingx/scripts/dpdk-devbind.py
# Strip the modules(s).
find %{buildroot} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Always Sign the modules(s).
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey /usr/src/kernels/%{kversion}/signing_key.pem}
%{!?pubkey: %define pubkey /usr/src/kernels/%{kversion}/signing_key.x509}
for module in $(find %{buildroot} -type f -name \*.ko);
do /usr/src/kernels/%{kversion}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%clean
%{__rm} -rf %{buildroot}
%changelog
* Mon Apr 26 2021 Jiping Ma <jiping.ma2@windriver.com> - 21.02
- Up to version 21.02, based on Linux kernel 5.10.
* Wed Jun 03 2020 Steven Webster <steven.webster@windriver.com> - 20.05-1
- Initial RPM package, based on Starlingx iavf-kmod.

View File

@ -1,8 +0,0 @@
COPY_LIST=" \
$PATCHES_BASE/* "
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=b3b85950aecb5fef6902d4dfcf578b402ec6a69d
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=b3b85950aecb5fef6902d4dfcf578b402ec6a69d
PKG_BASE_SRCREV=aab4c0a0882fe82985726f45cffc692d1dfe1998
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT

View File

@ -1,26 +0,0 @@
From 5c639bdbb7e4a652537d743b6303ce2c20eafe2e Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Thu, 25 Aug 2022 23:56:58 -0700
Subject: [PATCH] Add BuildRequires on kernel-devel-keys
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
opae-intel-fpga-driver.spec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/opae-intel-fpga-driver.spec b/opae-intel-fpga-driver.spec
index 193f149..d5d73b7 100755
--- a/SPECS/opae-intel-fpga-driver.spec
+++ b/SPECS/opae-intel-fpga-driver.spec
@@ -23,7 +23,7 @@ Source: %{kmod_name}-%{version}.tar.gz
Exclusiveos: linux
ExclusiveArch: i386 i586 i686 x86_64
Buildroot: %{_builddir}/%{kmod_name}-%{version}
-BuildRequires: kernel%{?bt_ext}-devel, tar, gcc, make
+BuildRequires: kernel%{?bt_ext}-devel, kernel%{?bt_ext}-devel-keys, tar, gcc, make
%if 0%{?rhel} == 7
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
--
2.35.1

View File

@ -1,53 +0,0 @@
From 13a3b91f211ae9f8a965edcf47ae27992a472c23 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Sun, 27 Jun 2021 23:52:04 -0700
Subject: [PATCH] Fix build issues
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
SPECS/opae-intel-fpga-driver.spec | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/SPECS/opae-intel-fpga-driver.spec b/SPECS/opae-intel-fpga-driver.spec
index 6cf186ef8853..193f14950ef3 100755
--- a/SPECS/opae-intel-fpga-driver.spec
+++ b/SPECS/opae-intel-fpga-driver.spec
@@ -42,6 +42,8 @@ BuildRequires: kernel%{?bt_ext}-devel
%endif
Requires: dkms, gcc, kernel%{?bt_ext}-devel, make
%define debug_package ${nil}
+Patch0001: Fix-build-errors.patch
+Patch0002: use-altera.h-from-driver-instead-of-from-kernel.patch
%package -n kmod-opae-fpga-driver%{?bt_ext}
Summary: OPAE modules files
@@ -70,6 +72,8 @@ Source for the OPAE Drivers for common kernels
%prep
%setup -q -n %{kmod_name}-%{version}
+%patch0001 -p1
+%patch0002 -p1
%description
OPAE Driver
@@ -234,13 +238,15 @@ rm -rf $RPM_BUILD_ROOT
%files -n kmod-opae-fpga-driver%{?bt_ext}
%defattr(-,root,root)
-/usr/src/%{kmod_name}-%{version}-%{_release}
+/lib/modules
+/etc/udev
%files -n kmod-opae-fpga-driver%{?bt_ext}-devel
#/usr/include/*
%files -n kmod-opae-fpga-driver%{?bt_ext}-prebuilt
%defattr(-,root,root)
+/usr/src/%{kmod_name}-%{version}-%{_release}
/lib/modules
/etc/udev
--
2.29.2

View File

@ -1,3 +0,0 @@
Support-TiS-system-and-devtoolset-8.patch
Fix-build-issues.patch
Add-BuildRequires-on-kernel-devel-keys.patch

View File

@ -1,285 +0,0 @@
From 81f0f0db2b5444abee5ad58f3079f980db8b3f8d Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Tue, 22 Jun 2021 23:40:36 -0700
Subject: [PATCH] Support-TiS-system and devtoolset-8
Support-TiS-system and build with devtoolset-8, also
change package name from opae-intel-fpga-driver to
kmod-opae-fpga-driver.
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
SPECS/opae-intel-fpga-driver.spec | 151 ++++++++++++++++++------------
1 file changed, 91 insertions(+), 60 deletions(-)
diff --git a/SPECS/opae-intel-fpga-driver.spec b/SPECS/opae-intel-fpga-driver.spec
index c8374d89c3ca..6cf186ef8853 100755
--- a/SPECS/opae-intel-fpga-driver.spec
+++ b/SPECS/opae-intel-fpga-driver.spec
@@ -1,19 +1,35 @@
#
# OPAE Drivers rpm .spec file
#
+%if "%{?_tis_build_type}" == "rt"
+%define bt_ext -rt
+%else
+%undefine bt_ext
+%endif
+
+# Define the kmod package name here.
+%define kmod_name opae-intel-fpga-driver
+
Summary: Create OPAE Driver source and binary rpm packages.
-Name: opae-intel-fpga-driver
+Name: opae-intel-fpga-driver%{?bt_ext}
Version: 2.0.1
-Release: 10
+%define _release 10
+Release: %{_release}%{?_tis_dist}.%{tis_patch_ver}
License: GPL V2
Group: Applications/System
Distribution: CentOS Linux
Vendor: Intel Corporation
-Source: %{name}-%{version}.tar.gz
+Source: %{kmod_name}-%{version}.tar.gz
Exclusiveos: linux
ExclusiveArch: i386 i586 i686 x86_64
-Buildroot: %{_builddir}/%{name}-%{version}
-BuildRequires: kernel-headers, kernel-devel, tar, gcc, make
+Buildroot: %{_builddir}/%{kmod_name}-%{version}
+BuildRequires: kernel%{?bt_ext}-devel, tar, gcc, make
+%if 0%{?rhel} == 7
+BuildRequires: devtoolset-8-build
+BuildRequires: devtoolset-8-binutils
+BuildRequires: devtoolset-8-gcc
+BuildRequires: devtoolset-8-make
+%endif
#BuildRequires: osv-linux4.14-devel
#BuildRequires: osv-linux4.16-devel
#BuildRequires: osv-linux4.19-devel
@@ -21,40 +37,52 @@ BuildRequires: kernel-headers, kernel-devel, tar, gcc, make
BuildRequires: kernel-default-devel
%else
%if %{?_vendor} != "clr"
-BuildRequires: kernel-devel
+BuildRequires: kernel%{?bt_ext}-devel
%endif
%endif
-Requires: dkms, gcc, kernel-devel, make
+Requires: dkms, gcc, kernel%{?bt_ext}-devel, make
%define debug_package ${nil}
-%package devel
+%package -n kmod-opae-fpga-driver%{?bt_ext}
+Summary: OPAE modules files
+Group: Applications/System
+%description -n kmod-opae-fpga-driver%{?bt_ext}
+OPAE Modules files
+
+%package -n kmod-opae-fpga-driver%{?bt_ext}-devel
Summary: OPAE modules devel files
Group: Applications/System
-%description devel
+%description -n kmod-opae-fpga-driver%{?bt_ext}-devel
OPAE Modules Development files
-%package prebuilt
+%package -n kmod-opae-fpga-driver%{?bt_ext}-prebuilt
Summary: Prebuilt OPAE drivers for common kernels
Group: Applications/System
-%description prebuilt
+%description -n kmod-opae-fpga-driver%{?bt_ext}-prebuilt
Prebuilt OPAE Drivers for common kernels
-%package source
+%package -n kmod-opae-fpga-driver%{?bt_ext}-source
Summary: Source for the OPAE drivers for common kernels
Group: Applications/System
Requires: gcc, kernel-devel, make
-%description source
+%description -n kmod-opae-fpga-driver%{?bt_ext}-source
Source for the OPAE Drivers for common kernels
%prep
-%setup -q
+%setup -q -n %{kmod_name}-%{version}
%description
OPAE Driver
%build
+%if 0%{?rhel} == 7
+source scl_source enable devtoolset-8 || :
+%endif
%install
+%if 0%{?rhel} == 7
+source scl_source enable devtoolset-8 || :
+%endif
FILES_TO_COPY=`ls | grep -v '^build-' | grep -v debian | grep -v spec`
@@ -74,12 +102,6 @@ do
if [ -f $kern/Module.symvers ]
then
kernname=`basename $kern`
- if [[ $kernname == *"2.6."* ]]; then
- continue
- fi
- if [[ $kernname == *"4."* ]]; then
- continue
- fi
if ! grep -q "CONFIG_REGMAP=y" $kern/include/config/auto.conf ; then
continue
fi
@@ -95,57 +117,66 @@ done
# Remove the depmod related file we will not be including
rm -f $RPM_BUILD_ROOT/lib/modules/*/modules.*
+# Always Sign the modules(s).
+# If the module signing keys are not defined, define them here.
+%{!?privkey: %define privkey /usr/src/kernels/${kernname}/signing_key.pem}
+%{!?pubkey: %define pubkey /usr/src/kernels/${kernname}/signing_key.x509}
+for module in $(find %{buildroot} -type f -name \*.ko);
+do /usr/src/kernels/${kernname}/scripts/sign-file \
+ sha256 %{privkey} %{pubkey} $module;
+done
+
# Now, install the source for the DKMS package
-install -d $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a drivers $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a include $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a scripts $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a lib-4-12 $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a Makefile $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a 40-intel-fpga.rules $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
-cp -a LICENSE $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
+install -d $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a drivers $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a include $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a scripts $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a lib-4-12 $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a Makefile $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a 40-intel-fpga.rules $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
+cp -a LICENSE $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
# Now, create/install a source tarball of the driver for the -source package
# Make a tarball of the driver source
-tar -C $RPM_BUILD_ROOT/usr/src --group=root --owner=root -czf $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}.tar.gz %{name}-%{version}
+tar -C $RPM_BUILD_ROOT/usr/src --group=root --owner=root -czf $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}.tar.gz %{kmod_name}-%{version}
# Set up a specfile
-sed -e 's/PKGVER/%{version}/' -e 's/PKGREL/%{release}/' build/specs/native-build.spec.in >$RPM_BUILD_ROOT/usr/src/%{name}.spec
+sed -e 's/PKGVER/%{version}/' -e 's/PKGREL/%{_release}/' build/specs/native-build.spec.in >$RPM_BUILD_ROOT/usr/src/%{kmod_name}.spec
# Create a source package tarball that rpmbuild can consume directly
-tar -C $RPM_BUILD_ROOT/usr/src --group=root --owner=root -czf $RPM_BUILD_ROOT/usr/src/%{name}-source-%{version}-%{release}.tar.gz %{name}-%{version}-%{release}.tar.gz %{name}.spec
+tar -C $RPM_BUILD_ROOT/usr/src --group=root --owner=root -czf $RPM_BUILD_ROOT/usr/src/%{kmod_name}-source-%{version}-%{_release}.tar.gz %{kmod_name}-%{version}-%{_release}.tar.gz %{kmod_name}.spec
# Clean up the intemediate files
-rm -rf $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}.tar.gz $RPM_BUILD_ROOT/usr/src/%{name}.spec $RPM_BUILD_ROOT/usr/src/%{name}-%{version}
+rm -rf $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}.tar.gz $RPM_BUILD_ROOT/usr/src/%{kmod_name}.spec $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}
# Prebuilt module udev file
install -d $RPM_BUILD_ROOT/etc/udev/rules.d
cp -a 40-intel-fpga.rules $RPM_BUILD_ROOT/etc/udev/rules.d
# Now, install the source for the DKMS package
-install -d $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a drivers $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a include $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a scripts $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a lib-4-12 $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a Makefile $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a 40-intel-fpga.rules $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a LICENSE $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
+install -d $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a drivers $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a include $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a scripts $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a lib-4-12 $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a Makefile $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a 40-intel-fpga.rules $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a LICENSE $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
# DKMS stuff
-cp -a dkms-postinst.sh $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-cp -a dkms-postrem.sh $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}
-sed -e 's/PKGVER/%{version}-%{release}/' dkms-preinst.sh >$RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}/dkms-preinst.sh
-chmod 0755 $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}/dkms-preinst.sh
-echo "Creating $RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}/dkms.conf"
-sed -e 's/PKGVER/%{version}-%{release}/' dkms.conf >$RPM_BUILD_ROOT/usr/src/%{name}-%{version}-%{release}/dkms.conf
+cp -a dkms-postinst.sh $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+cp -a dkms-postrem.sh $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}
+sed -e 's/PKGVER/%{version}-%{_release}/' dkms-preinst.sh >$RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}/dkms-preinst.sh
+chmod 0755 $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}/dkms-preinst.sh
+echo "Creating $RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}/dkms.conf"
+sed -e 's/PKGVER/%{version}-%{_release}/' dkms.conf >$RPM_BUILD_ROOT/usr/src/%{kmod_name}-%{version}-%{_release}/dkms.conf
%post
-if [ -z "`dkms status -m opae-intel-fpga-driver -v %{version}-%{release}`" ]; then
+if [ -z "`dkms status -m opae-intel-fpga-driver%{?bt_ext} -v %{version}-%{_release}`" ]; then
echo "Add module source to dkms"
- dkms add -m opae-intel-fpga-driver -v %{version}-%{release} --rpm_safe_upgrade
+ dkms add -m opae-intel-fpga-driver%{?bt_ext} -v %{version}-%{_release} --rpm_safe_upgrade
fi
# If we haven't loaded a tarball, then try building it for the current kernel
if [ `uname -r | grep -c "BOOT"` -eq 0 ] && [ -e /lib/modules/`uname -r`/build/include ]; then
- dkms build -m opae-intel-fpga-driver -v %{version}-%{release}
- dkms install -m opae-intel-fpga-driver -v %{version}-%{release} --force
+ dkms build -m opae-intel-fpga-driver%{?bt_ext} -v %{version}-%{_release}
+ dkms install -m opae-intel-fpga-driver%{?bt_ext} -v %{version}-%{_release} --force
elif [ `uname -r | grep -c "BOOT"` -gt 0 ]; then
echo -e ""
@@ -162,8 +193,8 @@ exit 0
%preun
echo -e
-echo -e "Uninstall of opae-intel-fpga-driver module (version %{version}-%{release}) beginning:"
-dkms remove -m opae-intel-fpga-driver -v %{version}-%{release} --all --rpm_safe_upgrade
+echo -e "Uninstall of opae-intel-fpga-driver%{?bt_ext} module (version %{version}-%{_release}) beginning:"
+dkms remove -m opae-intel-fpga-driver%{?bt_ext} -v %{version}-%{_release} --all --rpm_safe_upgrade
if [ "$1" -eq "0" ]
then
find /lib/modules -type f \( -name spi-nor-mod.ko* \
@@ -179,7 +210,7 @@ echo -e "Force regeneration of new initramfs"
dracut --force /boot/initramfs-$(uname -r).img $(uname -r)
exit 0
-%post prebuilt
+%post -n kmod-opae-fpga-driver%{?bt_ext}-prebuilt
depmod=/sbin/depmod
if [ -x /usr/sbin/depmod ]
then
@@ -201,22 +232,22 @@ done
%clean
rm -rf $RPM_BUILD_ROOT
-%files
+%files -n kmod-opae-fpga-driver%{?bt_ext}
%defattr(-,root,root)
-/usr/src/%{name}-%{version}-%{release}
+/usr/src/%{kmod_name}-%{version}-%{_release}
-%files devel
+%files -n kmod-opae-fpga-driver%{?bt_ext}-devel
#/usr/include/*
-%files prebuilt
+%files -n kmod-opae-fpga-driver%{?bt_ext}-prebuilt
%defattr(-,root,root)
/lib/modules
/etc/udev
-%files source
+%files -n kmod-opae-fpga-driver%{?bt_ext}-source
%defattr(-,root,root)
-/usr/src/%{name}-source-%{version}-%{release}.tar.gz
+/usr/src/%{kmod_name}-source-%{version}-%{_release}.tar.gz
%changelog
-* %(date "+%a %b %d %Y") %{version}-%{release}
+* %(date "+%a %b %d %Y") %{version}-%{_release}
-OPAE Intel FPGA Driver Build
--
2.29.2

View File

@ -1,104 +0,0 @@
From 262f8cbac0e4699edfcc5d1027479f85f9c8177f Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Sun, 27 Jun 2021 23:13:51 -0700
Subject: [PATCH 1/2] Fix build errors.
Fix the following issues.
1. readx_poll_timeout redefined
2. change mmap_sem to mmap_lock
because commit da1c55f1b272f4bd54671d459b39ea7b54944ef9
mmap locking API: rename mmap_sem to mmap_lock
3. change i2c_new_device to i2c_new_client_device because
i2c_new_device is deprecated.
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/fpga/intel/dma-region.c | 4 ++--
drivers/fpga/intel/fme-main.c | 1 -
drivers/i2c/busses/i2c-altera.c | 3 +--
drivers/mtd/devices/intel-on-chip-flash.c | 1 -
drivers/mtd/spi-nor/intel-generic-qspi.c | 1 -
5 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/fpga/intel/dma-region.c b/drivers/fpga/intel/dma-region.c
index 87c8f32..d6749b1 100644
--- a/drivers/fpga/intel/dma-region.c
+++ b/drivers/fpga/intel/dma-region.c
@@ -51,7 +51,7 @@ static long afu_dma_adjust_locked_vm(struct device *dev, long npages, bool incr)
if (!current->mm)
return 0;
- down_write(&current->mm->mmap_sem);
+ down_write(&current->mm->mmap_lock);
if (incr) {
locked = current->mm->locked_vm + npages;
@@ -75,7 +75,7 @@ static long afu_dma_adjust_locked_vm(struct device *dev, long npages, bool incr)
rlimit(RLIMIT_MEMLOCK),
ret ? "- execeeded" : "");
- up_write(&current->mm->mmap_sem);
+ up_write(&current->mm->mmap_lock);
return ret;
}
diff --git a/drivers/fpga/intel/fme-main.c b/drivers/fpga/intel/fme-main.c
index 0b68232..29b2cc0 100644
--- a/drivers/fpga/intel/fme-main.c
+++ b/drivers/fpga/intel/fme-main.c
@@ -30,7 +30,6 @@
#include <linux/uaccess.h>
#include <linux/intel-fpga.h>
#include <linux/fpga/fpga-mgr-4-12.h>
-#include <linux/iopoll-4-12.h>
#include <linux/i2c/altera.h>
#include <linux/spi/altera.h>
#include <linux/mtd/altera-asmip2.h>
diff --git a/drivers/i2c/busses/i2c-altera.c b/drivers/i2c/busses/i2c-altera.c
index 381c562..cea3247 100644
--- a/drivers/i2c/busses/i2c-altera.c
+++ b/drivers/i2c/busses/i2c-altera.c
@@ -20,7 +20,6 @@
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/i2c/altera.h>
-#include <linux/iopoll-4-12.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/io.h>
@@ -633,7 +632,7 @@ static int altr_i2c_probe(struct platform_device *pdev)
if (pdata) {
/* add in known devices to the bus */
for (i = 0; i < pdata->num_devices; i++)
- i2c_new_device(&idev->adapter, pdata->devices + i);
+ i2c_new_client_device(&idev->adapter, pdata->devices + i);
}
dev_info(&pdev->dev, "Altera SoftIP I2C Probe Complete\n");
diff --git a/drivers/mtd/devices/intel-on-chip-flash.c b/drivers/mtd/devices/intel-on-chip-flash.c
index 259801d..05e16af 100644
--- a/drivers/mtd/devices/intel-on-chip-flash.c
+++ b/drivers/mtd/devices/intel-on-chip-flash.c
@@ -11,7 +11,6 @@
*/
#include <linux/bitfield-intel-pac.h>
-#include <linux/iopoll-4-12.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/intel-on-chip-flash.h>
diff --git a/drivers/mtd/spi-nor/intel-generic-qspi.c b/drivers/mtd/spi-nor/intel-generic-qspi.c
index 4183125..25d6d84 100644
--- a/drivers/mtd/spi-nor/intel-generic-qspi.c
+++ b/drivers/mtd/spi-nor/intel-generic-qspi.c
@@ -10,7 +10,6 @@
*/
#include <linux/bitfield-intel-pac.h>
-#include <linux/iopoll-4-12.h>
#include <linux/module.h>
#include <linux/mtd/intel-generic-qspi.h>
#include <linux/mtd/mtd.h>
--
2.31.1

View File

@ -1,112 +0,0 @@
From 6371907d1b4809fe6c1cb02a4a9dc8b2a18999fa Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 23 Jun 2021 23:38:47 -0700
Subject: [PATCH] use altera.h from driver instead of from kernel
linux/spi/altera.h in Kernel is very different from
the file in opae-intel-fpga-driver. So we use the
head file in opae-intel-fpga-driver driver.
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
Makefile | 28 ----------------------------
drivers/fpga/intel/fme-main.c | 2 +-
drivers/spi/spi-altera-4-12.c | 2 +-
3 files changed, 2 insertions(+), 30 deletions(-)
diff --git a/Makefile b/Makefile
index bb31b0e..e5518ad 100644
--- a/Makefile
+++ b/Makefile
@@ -10,11 +10,6 @@ ccflags-y += -I$(M)/build/include -I$(M)/build/include/uapi -I$(M)/build/include
ccflags-y += -DCONFIG_AS_AVX512
ccflags-y += -I$(PWD)/scripts/dtc/libfdt-4-12
-ifeq ($(kerval), $(filter $(kerval), 4.18 3.10))
-obj-m += spi-bitbang-mod.o
-obj-m += regmap-mmio-mod.o
-endif
-
obj-m += i2c-altera.o
obj-m += intel-generic-qspi.o
obj-m += intel-on-chip-flash.o
@@ -45,22 +40,11 @@ intel-max10-y += lib-4-12/fdt_sw.o
intel-max10-y += lib-4-12/fdt_strerror.o
intel-max10-y += lib-4-12/fdt_empty_tree.o
-ifeq ($(kerval), 4.18)
-regmap-mmio-mod-y := drivers/base/regmap/regmap-mmio-4-18.o
-else
-regmap-mmio-mod-y := drivers/base/regmap/regmap-mmio-3-10.o
-endif
-
i2c-altera-y := drivers/i2c/busses/i2c-altera.o
intel-generic-qspi-y := drivers/mtd/spi-nor/intel-generic-qspi.o
intel-on-chip-flash-y := drivers/mtd/devices/intel-on-chip-flash.o
-ifeq ($(kerval), 4.18)
-spi-bitbang-mod-y := drivers/spi/spi-bitbang-4-18.o
-else
-spi-bitbang-mod-y := drivers/spi/spi-bitbang-3-10.o
-endif
spi-altera-mod-y := drivers/spi/spi-altera-4-12.o
@@ -108,13 +92,7 @@ load-drv:
if ! egrep -q '^intel_generic_qspi ' /proc/modules; then insmod intel-generic-qspi.ko; fi
if ! egrep -q '^intel_on_chip_flash ' /proc/modules; then insmod intel-on-chip-flash.ko; fi
if ! egrep -q '^altera_asmip2 ' /proc/modules; then insmod altera-asmip2.ko; fi
-ifeq ($(kerval), $(filter $(kerval), 4.18 3.10))
- if ! egrep -q '^regmap_mmio_mod ' /proc/modules; then insmod regmap-mmio-mod.ko; fi
-endif
if ! egrep -q '^i2c_altera ' /proc/modules; then insmod i2c-altera.ko; fi
-ifeq ($(kerval), $(filter $(kerval), 4.18 3.10))
- if ! egrep -q '^spi_bitbang_mod ' /proc/modules; then insmod spi-bitbang-mod.ko; fi
-endif
if ! egrep -q '^spi_altera_mod ' /proc/modules; then insmod spi-altera-mod.ko; fi
if ! egrep -q '^ifpga_sec_mgr ' /proc/modules; then insmod ifpga-sec-mgr.ko; fi
if ! egrep -q '^avmmi_bmc ' /proc/modules; then insmod avmmi-bmc.ko; fi
@@ -142,13 +120,7 @@ unload-drv:
if egrep -q '^avmmi_bmc ' /proc/modules; then rmmod avmmi_bmc; fi
if egrep -q '^ifpga_sec_mgr ' /proc/modules; then rmmod ifpga_sec_mgr; fi
if egrep -q '^spi_altera_mod ' /proc/modules; then rmmod spi_altera_mod; fi
-ifeq ($(kerval), $(filter $(kerval), 4.18 3.10))
- if egrep -q '^spi_bitbang_mod ' /proc/modules; then rmmod spi_bitbang_mod; fi
-endif
if egrep -q '^i2c_altera ' /proc/modules; then rmmod i2c_altera; fi
-ifeq ($(kerval), $(filter $(kerval), 4.18 3.10))
- if egrep -q '^regmap_mmio_mod ' /proc/modules; then rmmod regmap_mmio_mod; fi
-endif
if egrep -q '^altera_asmip2 ' /proc/modules; then rmmod altera_asmip2; fi
if egrep -q '^intel_on_chip_flash ' /proc/modules; then rmmod intel_on_chip_flash; fi
if egrep -q '^intel_generic_qspi ' /proc/modules; then rmmod intel_generic_qspi; fi
diff --git a/drivers/fpga/intel/fme-main.c b/drivers/fpga/intel/fme-main.c
index 29b2cc0..857cf87 100644
--- a/drivers/fpga/intel/fme-main.c
+++ b/drivers/fpga/intel/fme-main.c
@@ -31,7 +31,7 @@
#include <linux/intel-fpga.h>
#include <linux/fpga/fpga-mgr-4-12.h>
#include <linux/i2c/altera.h>
-#include <linux/spi/altera.h>
+#include "../../../include/linux/spi/altera.h"
#include <linux/mtd/altera-asmip2.h>
#include <linux/version.h>
diff --git a/drivers/spi/spi-altera-4-12.c b/drivers/spi/spi-altera-4-12.c
index 9cc2f27..a67b87b 100644
--- a/drivers/spi/spi-altera-4-12.c
+++ b/drivers/spi/spi-altera-4-12.c
@@ -19,7 +19,7 @@
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
-#include <linux/spi/altera.h>
+#include "../../../include/linux/spi/altera.h"
#include <linux/io.h>
#include <linux/of.h>
#include <linux/version.h>
--
2.31.1

View File

@ -1 +0,0 @@
repo:stx/downloads/opae-intel-fpga-driver-2.0.1-10.src.rpm

View File

@ -1,8 +0,0 @@
COPY_LIST="$PKG_BASE/files/modules-load.conf"
OPT_DEP_LIST_FOR_BUILD_TYPE[std]=$GIT_BASE/kernel-std
OPT_DEP_LIST_FOR_BUILD_TYPE[rt]=$GIT_BASE/kernel-rt
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-std]=19ca0df55a7c905dc062008862b7b76b577a2354
BASE_SRCREV_FOR_PATH[$GIT_BASE/kernel-rt]=19ca0df55a7c905dc062008862b7b76b577a2354
PKG_BASE_SRCREV=19ca0df55a7c905dc062008862b7b76b577a2354
TIS_PATCH_VER=PKG_GITREVCOUNT+OTHER_GITREVCOUNT
BUILD_IS_SLOW=3

View File

@ -1,26 +0,0 @@
From 47ce98b70fcbf36998a0eb5995d13b73b1190708 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Thu, 25 Aug 2022 22:10:18 -0700
Subject: [PATCH] Add BuildRequires on kernel-devel-keys
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
mlnx-ofa_kernel.spec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlnx-ofa_kernel.spec b/mlnx-ofa_kernel.spec
index 2a1b956..9d869d5 100644
--- a/SPECS/mlnx-ofa_kernel.spec
+++ b/SPECS/mlnx-ofa_kernel.spec
@@ -33,7 +33,7 @@
# KMP is disabled by default
%{!?KMP: %global KMP 0}
-BuildRequires: kernel%{?bt_ext}-devel, openssl
+BuildRequires: kernel%{?bt_ext}-devel, kernel%{?bt_ext}-devel-keys, openssl
BuildRequires: devtoolset-8-build
BuildRequires: devtoolset-8-binutils
BuildRequires: devtoolset-8-gcc
--
2.35.1

View File

@ -1,33 +0,0 @@
From 0eb52f4a2a5d4d041afae205516515c4393fac2f Mon Sep 17 00:00:00 2001
From: Steven Webster <steven.webster@windriver.com>
Date: Mon, 11 Jul 2022 16:16:13 -0400
Subject: [PATCH] Enable mlx5 onboard udev name
Signed-off-by: Steven Webster <steven.webster@windriver.com>
---
SPECS/mlnx-ofa_kernel.spec | 2 ++
1 file changed, 2 insertions(+)
diff --git a/SPECS/mlnx-ofa_kernel.spec b/SPECS/mlnx-ofa_kernel.spec
index 2a1b956..d83da56 100644
--- a/SPECS/mlnx-ofa_kernel.spec
+++ b/SPECS/mlnx-ofa_kernel.spec
@@ -91,6 +91,7 @@ Group: System Environment/Base
Source: %{_basename}-%{_version}.tgz
Source100: modules-load.conf
Patch01: 0001-mlx5-pci_irq-Use-irq_update_affinity_hint.patch
+Patch02: 0002-Enable-mlx5-onboard-udev-name.patch
BuildRoot: %{?build_root:%{build_root}}%{!?build_root:/var/tmp/OFED}
Vendor: Mellanox Technologies
Obsoletes: kernel-ib
@@ -267,6 +268,7 @@ mv "$@" source/
mkdir obj
%patch01 -p1
+%patch02 -p1
%build
%if 0%{?rhel} == 7
--
2.29.2

View File

@ -1,49 +0,0 @@
From 4d13d151ad85f7b0e47a518f5f8867511b8208f3 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Tue, 22 Mar 2022 00:20:08 -0700
Subject: [PATCH] Ensure that modules are signed
Always sign the modules for StarlingX by enabling WITH_MOD_SIGN.
Also, change the definition of buildsubdir from "%{_name}-%{version}"
to "%{_basename}-%{version}" to fix the rt module build issue after
enabling WITH_MOD_SIGN, because there is no mlnx-ofa_kernel-rt-5.5
directory. It should be mlnx-ofa_kernel-5.5.
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
mlnx-ofa_kernel.spec | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/SPECS/mlnx-ofa_kernel.spec b/SPECS/mlnx-ofa_kernel.spec
index 38ae4a5..2a1b956 100644
--- a/SPECS/mlnx-ofa_kernel.spec
+++ b/SPECS/mlnx-ofa_kernel.spec
@@ -211,13 +211,9 @@ sourecs of driver. Use the -devel package if you want to build other
drivers against it.
#
-# setup module sign scripts if paths to the keys are given
+# Always Sign the modules(s).
#
-%global WITH_MOD_SIGN %(if ( test -f "$MODULE_SIGN_PRIV_KEY" && test -f "$MODULE_SIGN_PUB_KEY" ); \
- then \
- echo -n '1'; \
- else \
- echo -n '0'; fi)
+%global WITH_MOD_SIGN 1
%if "%{WITH_MOD_SIGN}" == "1"
# call module sign script
@@ -226,7 +222,7 @@ drivers against it.
%{nil}
%global __debug_package 1
-%global buildsubdir %{_name}-%{version}
+%global buildsubdir %{_basename}-%{version}
# Disgusting hack alert! We need to ensure we sign modules *after* all
# invocations of strip occur, which is in __debug_install_post if
# find-debuginfo.sh runs, and __os_install_post if not.
--
2.31.1

View File

@ -1,5 +0,0 @@
Support-STX-system-and-introduce-devtoolset-8.patch
mlx5-pci_irq-Use-irq_update_affinity_hint.patch
Ensure-that-modules-are-signed.patch
Enable-mlx5-onboard-udev-name.patch
Add-BuildRequires-on-kernel-devel-keys.patch

View File

@ -1,159 +0,0 @@
From 24a7530968184bd133432e1f8dfccebef772bc7e Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Fri, 28 Jan 2022 23:28:18 -0800
Subject: [PATCH] Support STX system and introduce devtoolset-8
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
mlnx-ofa_kernel.spec | 46 ++++++++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 12 deletions(-)
diff --git a/SPECS/mlnx-ofa_kernel.spec b/SPECS/mlnx-ofa_kernel.spec
index 6a6cde0..3e0d564 100644
--- a/SPECS/mlnx-ofa_kernel.spec
+++ b/SPECS/mlnx-ofa_kernel.spec
@@ -25,10 +25,19 @@
# and/or other materials provided with the distribution.
#
#
+%if "%{_tis_build_type}" == "rt"
+%define bt_ext -rt
+%else
+%undefine bt_ext
+%endif
# KMP is disabled by default
%{!?KMP: %global KMP 0}
-
+BuildRequires: kernel%{?bt_ext}-devel, openssl
+BuildRequires: devtoolset-8-build
+BuildRequires: devtoolset-8-binutils
+BuildRequires: devtoolset-8-gcc
+BuildRequires: devtoolset-8-make
%global WITH_SYSTEMD %(if ( test -d "%{_unitdir}" > /dev/null); then echo -n '1'; else echo -n '0'; fi)
%{!?configure_options: %global configure_options --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-mlx5-mod --with-mlxfw-mod --with-ipoib-mod}
@@ -43,11 +52,11 @@
%global IS_RHEL_VENDOR "%{_vendor}" == "redhat" || ("%{_vendor}" == "bclinux") || ("%{_vendor}" == "openEuler")
-%{!?KVERSION: %global KVERSION %(uname -r)}
+%{!?KVERSION: %global KVERSION %(rpm -q kernel%{?bt_ext}-devel | sort --version-sort | tail -1 | sed 's/kernel%{?bt_ext}-devel-//')}
%global kernel_version %{KVERSION}
%global krelver %(echo -n %{KVERSION} | sed -e 's/-/_/g')
# take path to kernel sources if provided, otherwise look in default location (for non KMP rpms).
-%{!?K_SRC: %global K_SRC /lib/modules/%{KVERSION}/build}
+%{!?K_SRC: %global K_SRC /usr/src/kernels/%{KVERSION}}
# Select packages to build
@@ -62,7 +71,8 @@
%{!?KERNEL_SOURCES: %global KERNEL_SOURCES /lib/modules/%{KVERSION}/source}
-%{!?_name: %global _name mlnx-ofa_kernel}
+%define _basename mlnx-ofa_kernel
+%define _name %{_basename}%{?bt_ext}
%{!?_version: %global _version 5.5}
%{!?_release: %global _release OFED.5.5.1.0.3.1}
%global _kmp_rel %{_release}%{?_kmp_build_num}%{?_dist}
@@ -74,11 +84,12 @@
Summary: Infiniband HCA Driver
Name: %{_name}
Version: %{_version}
-Release: %{_release}%{?_dist}
+Release: %{_release}%{?_dist}%{?_tis_dist}.%{tis_patch_ver}
License: GPLv2
Url: http://www.mellanox.com/
Group: System Environment/Base
-Source: %{_name}-%{_version}.tgz
+Source: %{_basename}-%{_version}.tgz
+Source100: modules-load.conf
BuildRoot: %{?build_root:%{build_root}}%{!?build_root:/var/tmp/OFED}
Vendor: Mellanox Technologies
Obsoletes: kernel-ib
@@ -148,7 +159,7 @@ Obsoletes: mlnx-en-debuginfo
Obsoletes: mlnx-en-sources
Obsoletes: mlnx-rdma-rxe
Version: %{_version}
-Release: %{_release}.kver.%{krelver}
+Release: %{_release}%{?_tis_dist}.%{tis_patch_ver}
Summary: Infiniband Driver and ULPs kernel modules
Group: System Environment/Libraries
%description -n %{non_kmp_pname}
@@ -163,7 +174,7 @@ Version: %{_version}
%if "%{KMP}" == "1"
Release: %{_release}%{?_dist}
%else
-Release: %{_release}.kver.%{krelver}
+Release: %{_release}%{?_tis_dist}.%{tis_patch_ver}
%endif
Obsoletes: kernel-ib-devel
Obsoletes: kernel-ib
@@ -252,13 +263,16 @@ drivers against it.
%{!?install_mod_dir: %global install_mod_dir updates}
%prep
-%setup -n %{_name}-%{_version}
+%setup -n %{_basename}-%{_version}
set -- *
mkdir source
mv "$@" source/
mkdir obj
%build
+%if 0%{?rhel} == 7
+source scl_source enable devtoolset-8 || :
+%endif
export EXTRA_CFLAGS='-DVERSION=\"%version\"'
export INSTALL_MOD_DIR=%{install_mod_dir}
export CONF_OPTIONS="%{configure_options}"
@@ -277,12 +291,17 @@ for flavor in %flavors_to_build; do
done
%install
+%if 0%{?rhel} == 7
+source scl_source enable devtoolset-8 || :
+%endif
export RECORD_PY_FILES=1
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=%{install_mod_dir}
-export NAME=%{name}
+export NAME=%{_basename}
export VERSION=%{version}
export PREFIX=%{_prefix}
+export MODULE_SIGN_PRIV_KEY=/usr/src/kernels/%{KVERSION}/signing_key.pem
+export MODULE_SIGN_PUB_KEY=/usr/src/kernels/%{KVERSION}/signing_key.x509
for flavor in %flavors_to_build; do
export KSRC=%{kernel_source $flavor}
export KVERSION=%{kernel_release $KSRC}
@@ -327,14 +346,16 @@ echo "override ${mod_name} * weak-updates/%{_name}${mod_path}" >> %{buildroot}%{
echo "override ${mod_name} * extra/%{_name}${mod_path}" >> %{buildroot}%{_sysconfdir}/depmod.d/zz01-%{_name}-${mod_name}.conf
done
%endif
+%{__install} -d %{buildroot}%{_sysconfdir}/modules-load.d
+%{__install} -m 644 %{SOURCE100} %{buildroot}%{_sysconfdir}/modules-load.d/mlnx.conf
%endif
# copy sources
mkdir -p %{buildroot}/%{_prefix}/src/ofa_kernel-%{version}
mkdir -p %{buildroot}/%{_prefix}/src/ofa_kernel/%{_arch}
-cp -a %{_builddir}/%{name}-%{version}/source %{buildroot}/%{_prefix}/src/ofa_kernel-%{version}/source
+cp -a %{_builddir}/%{_basename}-%{version}/source %{buildroot}/%{_prefix}/src/ofa_kernel-%{version}/source
ln -s ofa_kernel-%{version}/source %{buildroot}/%{_prefix}/src/mlnx-ofa_kernel-%{version}
-cp -a %{_builddir}/src/%{name}/* %{buildroot}/%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERSION}
+cp -a %{_builddir}/src/%{_basename}/* %{buildroot}/%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERSION}
# Fix path of BACKPORT_INCLUDES
sed -i -e "s@=-I.*backport_includes@=-I/usr/src/ofa_kernel-$VERSION/backport_includes@" %{buildroot}/%{_prefix}/src/ofa_kernel/%{_arch}/%{KVERSION}/configure.mk.kernel || true
rm -rf %{_builddir}/src
@@ -681,6 +702,7 @@ update-alternatives --remove \
%config(noreplace) %{_sysconfdir}/depmod.d/zz01-%{_name}-*.conf
%endif
%endif
+%{_sysconfdir}/modules-load.d/mlnx.conf
%endif
%files -n %{devel_pname}
--
2.31.1

View File

@ -1,37 +0,0 @@
From 839816cfbe2151508e567b1a2244c07a3b592377 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Sun, 20 Feb 2022 23:32:45 -0800
Subject: [PATCH] mlx5: pci_irq: Use irq_update_affinity_hint
(Please see the patch file for a description.)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
mlnx-ofa_kernel.spec | 3 +++
1 file changed, 3 insertions(+)
diff --git a/SPECS/mlnx-ofa_kernel.spec b/SPECS/mlnx-ofa_kernel.spec
index 3e0d564..38ae4a5 100644
--- a/SPECS/mlnx-ofa_kernel.spec
+++ b/SPECS/mlnx-ofa_kernel.spec
@@ -90,6 +90,7 @@ Url: http://www.mellanox.com/
Group: System Environment/Base
Source: %{_basename}-%{_version}.tgz
Source100: modules-load.conf
+Patch01: 0001-mlx5-pci_irq-Use-irq_update_affinity_hint.patch
BuildRoot: %{?build_root:%{build_root}}%{!?build_root:/var/tmp/OFED}
Vendor: Mellanox Technologies
Obsoletes: kernel-ib
@@ -269,6 +270,8 @@ mkdir source
mv "$@" source/
mkdir obj
+%patch01 -p1
+
%build
%if 0%{?rhel} == 7
source scl_source enable devtoolset-8 || :
--
2.31.1

View File

@ -1,91 +0,0 @@
From 88b2e22f1006dd802d44c1cdd901220e36ffd3ee Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 2 Mar 2022 03:44:53 +0000
Subject: [PATCH] mlx5: pci_irq: Use irq_update_affinity_hint
This commit applies a patch that modifies the mlx5 driver so that it
uses the irq_update_affinity_hint function instead of the
irq_set_affinity_hint function. The former only sets the hint, whereas
the latter sets both the hint and the IRQ affinity.
The intent of the patch is to allow the user-specified IRQ affinity (via
the irqaffinity= command line argument) take effect for the IRQs set up
by the mlx5 device driver.
(Please see the description of the applied patch for more information.)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
...pci_irq-Use-irq_update_affinity_hint.patch | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 source/backports/1000-mlx5-pci_irq-Use-irq_update_affinity_hint.patch
diff --git a/source/backports/1000-mlx5-pci_irq-Use-irq_update_affinity_hint.patch b/source/backports/1000-mlx5-pci_irq-Use-irq_update_affinity_hint.patch
new file mode 100644
index 0000000..6b3d7bf
--- /dev/null
+++ b/source/backports/1000-mlx5-pci_irq-Use-irq_update_affinity_hint.patch
@@ -0,0 +1,59 @@
+From 73bb521a587baf042d5e79aa2ff4b5e973c64a7b Mon Sep 17 00:00:00 2001
+From: Jiping Ma <jiping.ma2@windriver.com>
+Date: Tue, 1 Mar 2022 18:42:47 -0800
+Subject: [PATCH] mlx5: pci_irq: Use irq_update_affinity_hint
+
+The StarlingX kernel was patched to deprecate irq_set_affinity_hint
+by cherry-picking the patches at:
+ https://lore.kernel.org/netdev/20210903152430.244937-1-nitesh@redhat.com/t/#u
+
+These patches have been mainlined as of this writing, with the following
+merge commit by Linus Torvalds:
+ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=147cc5838c0f5c76e908b816e924ca378e0d4735
+
+This commit modifies the mlx5 driver so that it uses the
+irq_update_affinity_hint function instead of the irq_set_affinity_hint
+function. The former only sets the hint, whereas the latter sets both
+the hint and the IRQ affinity.
+
+Please note that this is a divergence from the aforementioned patch
+series, which make mlx5 use irq_set_affinity_and_hint, which currently
+behaves in the same way as irq_set_affinity_hint. The intent with
+diverging from mainline is to allow the user-specified IRQ affinity (via
+the irqaffinity= command line argument) take effect for the IRQs
+set up by the mlx5 device driver.
+
+The mlx5 commit in mainline is accessible at:
+ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7451e9ea8e2055af39afe7ff39a5f68d8ec6b98d
+
+Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
+Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
+---
+ drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
+index 06ea6fc..dd97f89 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
+@@ -175,7 +175,7 @@ static void irq_release(struct kref *kref)
+ * before calling it. This is why there is asymmetry with set_rmap
+ * which should be called after alloc_irq but before request_irq.
+ */
+- irq_set_affinity_hint(irq->irqn, NULL);
++ irq_update_affinity_hint(irq->irqn, NULL);
+ free_cpumask_var(irq->mask);
+ free_irq(irq->irqn, &irq->nh);
+ kfree(irq);
+@@ -276,7 +276,7 @@ static struct mlx5_irq *irq_request(struct mlx5_irq_pool *pool, int i,
+ goto err_xa;
+ }
+ affinity_copy(irq, affinity, mlx5_irq_table_get(dev));
+- irq_set_affinity_hint(irq->irqn, irq->mask);
++ irq_update_affinity_hint(irq->irqn, irq->mask);
+ cpu_get(mlx5_irq_table_get(dev), irq->mask);
+ return irq;
+ err_xa:
+--
+2.31.1
+
--
2.29.2

View File

@ -1,57 +0,0 @@
From 74ecb6be9dd81ff6a3c28d2d8f9e557cb76009c3 Mon Sep 17 00:00:00 2001
From: Steven Webster <steven.webster@windriver.com>
Date: Thu, 11 Aug 2022 12:32:48 -0400
Subject: [PATCH] Enable mlx5 onboard udev name
This patch prioritizes the udev renaming rule for mlx5 controlled
devices to take the onboard name over the slot/path name.
This is consistent with the 70-persistent-net.rules file written
by the StarlingX installer.
It is also consistent with the naming order in the 99-default.link
file.
Without this patch, there could be an inconsistency with the
70-persistent-net.rules first re-naming the device to its
slot/path name, and then being overridden by the Mellanox specific
82-net-setup-link.rules.
Signed-off-by: Steven Webster <steven.webster@windriver.com>
---
source/ofed_scripts/vf-net-link-name.sh | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/source/ofed_scripts/vf-net-link-name.sh b/source/ofed_scripts/vf-net-link-name.sh
index 65d8a7b..3bf87cc 100755
--- a/source/ofed_scripts/vf-net-link-name.sh
+++ b/source/ofed_scripts/vf-net-link-name.sh
@@ -68,7 +68,9 @@ if [ "$ID_NET_DRIVER" == "mlx5e_rep" ]; then
fi
if [ "$skip" == "0" ]; then
- if [ -n "$ID_NET_NAME_SLOT" ]; then
+ if [ -n "$ID_NET_NAME_ONBOARD" ]; then
+ NAME="${ID_NET_NAME_ONBOARD%%np[[:digit:]]}"
+ elif [ -n "$ID_NET_NAME_SLOT" ]; then
NAME="${ID_NET_NAME_SLOT%%np[[:digit:]]}"
elif [ -n "$ID_NET_NAME_PATH" ]; then
NAME="${ID_NET_NAME_PATH%%np[[:digit:]]}"
@@ -176,9 +178,12 @@ for cnt in {1..2}; do
continue
fi
- parent_path=`get_pci_name $pci ID_NET_NAME_SLOT`
+ parent_path=`get_pci_name $pci ID_NET_NAME_ONBOARD`
if [ -z "$parent_path" ]; then
- parent_path=`get_pci_name $pci ID_NET_NAME_PATH`
+ parent_path=`get_pci_name $pci ID_NET_NAME_SLOT`
+ if [ -z "$parent_path" ]; then
+ parent_path=`get_pci_name $pci ID_NET_NAME_PATH`
+ fi
fi
echo "NAME=${parent_path}_$PORT"
exit
--
2.29.2

View File

@ -1 +0,0 @@
repo:stx/downloads/mlnx-ofa_kernel-5.5-OFED.5.5.1.0.3.1.src.rpm

View File

@ -1,279 +0,0 @@
#!/bin/bash
# set -x
#
# Copyright (c) 2018-2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
# Refer to build-tools/default_build_srpm and modify for git repo from linux-yocto.
#
source "$SRC_BASE/build-tools/spec-utils"
source "$SRC_BASE/build-tools/srpm-utils"
CUR_DIR=`pwd`
BUILD_DIR="$RPMBUILD_BASE"
if [ "x$DATA" == "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): Environment variable 'DATA' not defined."
exit 1
fi
srpm_source_build_data "$DATA" "$SRC_BUILD_TYPE" "$SRPM_OR_SPEC_PATH"
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): Failed to source build data from $DATA"
exit 1
fi
if [ "x$PBR_VERSION" != "x" ] && [ "x$PBR_VERSION" != "xNA" ]; then
VERSION=$PBR_VERSION
fi
if [ "x$VERSION" == "x" ]; then
for SPEC in `find $SPECS_BASE -name '*.spec' | sort -V`; do
SPEC_PATH="$SPEC"
VERSION_DERIVED=`spec_evaluate '%{version}' "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): '%{version}' not found in '$PKG_BASE/$SPEC_PATH'"
VERSION_DERIVED=""
fi
if [ "x$VERSION_DERIVED" != "x" ]; then
if [ "x$VERSION" == "x" ]; then
VERSION=$VERSION_DERIVED
else
if [ "x$SRC_DIR" != "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): multiple spec files found, can't set VERSION automatically"
exit 1
fi
fi
fi
done
if [ "x$VERSION" == "x" ]; then
if [ -f $SRC_DIR/PKG-INFO ]; then
VERSION=$(grep '^Version:' $SRC_DIR/PKG-INFO | awk -F ': ' '{print $2}' | sed -e 's/^[[:space:]]*//')
fi
fi
if [ "x$VERSION" != "x" ]; then
echo "Derived VERSION=$VERSION"
else
echo "ERROR: kernel build_srpm (${LINENO}): Failed to derive a good VERSION from SPEC file, and none provided."
exit 1
fi
fi
if [ "x$TAR_NAME" == "x" ]; then
for SPEC in `find $SPECS_BASE -name '*.spec' | sort -V`; do
SPEC_PATH="$SPEC"
SERVICE=`spec_find_global service "$SPEC_PATH" 2>> /dev/null`
if [ $? -eq 0 ]; then
if [ "x$TAR_NAME" == "x" ]; then
TAR_NAME=$SERVICE
else
if [ "x$SRC_DIR" != "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): multiple spec files found, can't set TAR_NAME automatically"
exit 1
fi
fi
else
NAME=`spec_find_tag Name "$SPEC_PATH" 2>> /dev/null`
if [ $? -eq 0 ]; then
if [ "x$TAR_NAME" == "x" ]; then
TAR_NAME=$NAME
else
if [ "x$SRC_DIR" != "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): multiple spec files found, can't set TAR_NAME automatically"
exit 1
fi
fi
else
echo "WARNING: kernel build_srpm (${LINENO}): 'Name' not found in '$SPEC_PATH'"
NAME=""
fi
fi
done
if [ "x$TAR_NAME" == "x" ]; then
if [ -f $SRC_DIR/PKG-INFO ]; then
TAR_NAME=$(grep '^Name:' $SRC_DIR/PKG-INFO | awk -F ': ' '{print $2}' | sed -e 's/^[[:space:]]*//')
fi
fi
if [ "x$TAR_NAME" != "x" ]; then
echo "Derived TAR_NAME=$TAR_NAME"
else
echo "ERROR: kernel build_srpm (${LINENO}): Failed to derive a good TAR_NAME from SPEC file, and none provided."
exit 1
fi
fi
if [ "x$TAR" == "x" ]; then
TAR="$TAR_NAME-$VERSION.tar.gz"
fi
SOURCE_PATH="$BUILD_DIR/SOURCES"
TAR_PATH="$SOURCE_PATH/$TAR"
STAGING=""
if [ "x$COPY_LIST_TO_TAR" != "x" ] || [ "x$EXCLUDE_LIST_FROM_TAR" != "x" ]; then
STAGING="$BUILD_DIR/staging"
mkdir -p $STAGING
fi
mkdir -p "$BUILD_DIR/SRPMS"
mkdir -p "$SOURCE_PATH"
if [ "x$SRC_DIR" == "x" -a "x$COPY_LIST" == "x" -a "$ALLOW_EMPTY_RPM" != "true" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): '$PWD/$DATA' failed to provide at least one of 'SRC_DIR' or 'COPY_LIST'"
exit 1
fi
if [ "x$SRC_DIR" != "x" ]; then
if [ ! -d "$SRC_DIR" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): directory not found: '$SRC_DIR'"
exit 1
fi
fi
if [ "x$COPY_LIST" != "x" ]; then
echo "COPY_LIST: $COPY_LIST"
for p in $COPY_LIST; do
# echo "COPY_LIST: $p"
\cp -L -u -r -v $p $SOURCE_PATH
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): COPY_LIST: file not found: '$p'"
exit 1
fi
done
fi
if [ "x$STAGING" != "x" ]; then
\cp -L -u -r -v $SRC_DIR $STAGING
echo "COPY_LIST_TO_TAR: $COPY_LIST_TO_TAR"
for p in $COPY_LIST_TO_TAR; do
# echo "COPY_LIST_TO_TAR: $p"
\cp -L -u -r -v $p $STAGING/$SRC_DIR
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): COPY_LIST_TO_TAR: file not found: '$p'"
exit 1
fi
done
echo "EXCLUDE_LIST_FROM_TAR: $EXCLUDE_LIST_FROM_TAR"
for p in $EXCLUDE_LIST_FROM_TAR; do
# echo "EXCLUDE_LIST_FROM_TAR: $p"
echo "rm -rf $STAGING/$SRC_DIR/$p"
\rm -rf $STAGING/$SRC_DIR/$p
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): EXCLUDE_LIST_FROM_TAR: could not remove file: '$p'"
exit 1
fi
done
fi
TRANSFORM=`echo "$SRC_DIR" | sed 's/^\./\\./' | sed 's:^/::' | sed 's#^.*/\.\./##'`
if [ "x$STAGING" != "x" ]; then
pushd $STAGING
fi
TAR_NEEDED=0
if [ "x$SRC_DIR" != "x" ]; then
echo "SRC_DIR=$SRC_DIR"
if [ -f $TAR_PATH ]; then
n=`find . -cnewer $TAR_PATH -and ! -path './.git*' \
-and ! -path './.pc/*' \
-and ! -path './patches/*' \
-and ! -path "./$DISTRO/*" \
-and ! -path './pbr-*.egg/*' \
| wc -l`
if [ $n -gt 0 ]; then
TAR_NEEDED=1
fi
else
TAR_NEEDED=1
fi
fi
if [ $TAR_NEEDED -gt 0 ]; then
echo "Creating tar file: $TAR_PATH ... $TAR_NAME $VERSION"
#cd $SRC_DIR
#pwd
#git checkout -b linux-rt remotes/origin/v5.10/standard/preempt-rt/intel-x86
#cd -
echo "tar --exclude '.git*' --exclude='.pc' --exclude='patches' --exclude='$SRC_DIR/$DISTRO' --exclude='pbr-*.egg' --transform 's,^$TRANSFORM,$TAR_NAME-$VERSION,' -czf $TAR_PATH $SRC_DIR"
tar --exclude '.git*' --exclude='.pc' --exclude='patches' --exclude="$SRC_DIR/$DISTRO" --exclude='pbr-*.egg' --transform "s,^$TRANSFORM,$TAR_NAME-$VERSION," -czf "$TAR_PATH" "$SRC_DIR"
if [ $? -ne 0 ]; then
if [ "x$STAGING" != "x" ]; then
popd
fi
echo "ERROR: kernel build_srpm (${LINENO}): failed to create tar file, cmd: tar --exclude '.git*' --exclude='.pc' --exclude='patches' --exclude="$SRC_DIR/$DISTRO" --exclude='pbr-*.egg' --transform \"s,^$TRANSFORM,$TAR_NAME-$VERSION,\" -czf '$TAR_PATH' '$SRC_DIR'"
exit 1
fi
echo "Created tar file: $TAR_PATH"
else
echo "Tar file not needed."
fi
if [ "x$STAGING" != "x" ]; then
popd
fi
if [ ! -d $BUILD_DIR/SPECS ]; then
echo "Spec directory '$BUILD_DIR/SPECS' does not exist"
exit 1
fi
if [ $(ls -1 $BUILD_DIR/SPECS/*.spec | wc -l) -eq 0 ]; then
echo "No spec files found in spec directory '$BUILD_DIR/SPECS'"
exit 1
fi
for SPEC in `ls -1 $BUILD_DIR/SPECS`; do
SPEC_PATH="$BUILD_DIR/SPECS/$SPEC"
RELEASE=`spec_find_tag Release "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): 'Release' not found in '$SPEC_PATH'"
fi
NAME=`spec_find_tag Name "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): 'Name' not found in '$SPEC_PATH'"
fi
SRPM="$NAME-$VERSION-$RELEASE.src.rpm"
SRPM_PATH="$BUILD_DIR/SRPMS/$SRPM"
spec_validate_tis_release $SPEC_PATH
if [ $? -ne 0 ]; then
echo "TIS Validation of $SPEC_PATH failed"
exit 1
fi
BUILD_NEEDED=0
if [ -f $SRPM_PATH ]; then
n=`find . -cnewer $SRPM_PATH | wc -l`
if [ $n -gt 0 ]; then
BUILD_NEEDED=1
fi
else
BUILD_NEEDED=1
fi
if [ $BUILD_NEEDED -gt 0 ]; then
echo "SPEC file: $SPEC_PATH"
echo "SRPM build directory: $BUILD_DIR"
echo "TIS_PATCH_VER: $TIS_PATCH_VER"
echo "PBR_VERSION: $PBR_VERSION"
sed -i -e "1 i%define _tis_build_type $BUILD_TYPE" $SPEC_PATH
sed -i -e "1 i%define tis_patch_ver $TIS_PATCH_VER" $SPEC_PATH
sed -i -e "1 i%define pbr_version $PBR_VERSION" $SPEC_PATH
rpmbuild -bs $SPEC_PATH --define="%_topdir $BUILD_DIR" --undefine=dist --define="_tis_dist .tis"
else
echo "SRPM build not needed"
fi
done

View File

@ -1,16 +0,0 @@
SRC_DIR="$STX_BASE/git/linux-yocto-rt"
COPY_LIST=" \
$PKG_BASE/files/* \
$PKG_BASE/centos/patches/*"
BUILD_IS_BIG=21
BUILD_IS_SLOW=16
# The base branch is: v5.10/standard/preempt-rt/base
# commit bd6e7290bc points to a minor fix-up on top of v5.10.112-rt61:
# bd6e7290bc76 (inet/hash: fixup -rt merge, 2022-04-25)
TIS_BASE_SRCREV=bd6e7290bc766ef13e42a1e37f75e6e708b4e317
PKG_BASE_SRCREV=4013790c6ef43fd9f936579b0cac50b8e0c4505a
TIS_PATCH_VER=GITREVCOUNT+PKG_GITREVCOUNT

File diff suppressed because it is too large Load Diff

View File

@ -1,545 +0,0 @@
From 33efb73059c7e1f2facc7bb04f60d706c07f640d Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Thu, 17 Jun 2021 01:28:11 -0700
Subject: [PATCH] Notification of death of arbitrary processes
Note: this commit was copied from Titanium Cloud Rel2
This exposes a new feature which may be called to request
notification when an arbitrary process changes state. The
caller specifies a pid, signal number, and event mask, and
when that pid dies, or is stopped, or anything else that
would normally cause a SIGCHLD, the kernel will send the
specified signal to the caller if the event is in the event
mask originally passed down. The siginfo_t struct will
contain the same information as would be included with SIGCHLD.
This is exposed to userspace via the prctl() call with the
PR_DO_NOTIFY_TASK_STATE option.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
[jm: Adapted the patch for context changes.]
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
include/linux/init_task.h | 9 ++
include/linux/sched.h | 6 +
include/uapi/linux/prctl.h | 16 +++
init/Kconfig | 15 +++
init/init_task.c | 1 +
kernel/Makefile | 1 +
kernel/death_notify.c | 228 +++++++++++++++++++++++++++++++++++++
kernel/death_notify.h | 46 ++++++++
kernel/exit.c | 6 +
kernel/fork.c | 4 +
kernel/signal.c | 11 ++
kernel/sys.c | 8 ++
12 files changed, 351 insertions(+)
create mode 100644 kernel/death_notify.c
create mode 100644 kernel/death_notify.h
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index b2412b4d4c20..7a0828daf59c 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -25,6 +25,15 @@
extern struct files_struct init_files;
extern struct fs_struct init_fs;
extern struct nsproxy init_nsproxy;
+
+#ifdef CONFIG_SIGEXIT
+#define INIT_SIGEXIT(tsk) \
+ .notify = LIST_HEAD_INIT(tsk.notify), \
+ .monitor = LIST_HEAD_INIT(tsk.monitor),
+#else
+#define INIT_SIGEXIT(tsk)
+#endif
+
extern struct group_info init_groups;
extern struct cred init_cred;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e688e9307a21..c4b43b5d439f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1145,6 +1145,12 @@ struct task_struct {
short il_prev;
short pref_node_fork;
#endif
+#ifdef CONFIG_SIGEXIT
+ /* list of processes to notify on death */
+ struct list_head notify;
+ /* list of outstanding monitor requests */
+ struct list_head monitor;
+#endif
#ifdef CONFIG_NUMA_BALANCING
int numa_scan_seq;
unsigned int numa_scan_period;
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index 7f0827705c9a..dbd5a8b6e002 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -63,6 +63,22 @@
# define PR_ENDIAN_LITTLE 1 /* True little endian mode */
# define PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */
+#define PR_DO_NOTIFY_TASK_STATE 17 /* Set/get notification for task
+ state changes */
+
+/* This is the data structure for requestion process death
+ * (and other state change) information. Sig of -1 means
+ * query, sig of 0 means deregistration, positive sig means
+ * that you want to set it. sig and events are value-result
+ * and will be updated with the previous values on every
+ * successful call.
+ */
+struct task_state_notify_info {
+ int pid;
+ int sig;
+ unsigned int events;
+};
+
/* Get/set process seccomp mode */
#define PR_GET_SECCOMP 21
#define PR_SET_SECCOMP 22
diff --git a/init/Kconfig b/init/Kconfig
index 7ba2b602b707..5a5f38706715 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1852,6 +1852,21 @@ config VM_EVENT_COUNTERS
on EXPERT systems. /proc/vmstat will only show page counts
if VM event counters are disabled.
+config SIGEXIT
+ bool "Notification of death of arbitrary processes"
+ default n
+ help
+ When enabled this exposes a new feature which may be called to request
+ notification when an arbitrary process changes state. The caller specifies
+ a pid, signal number, and event mask, and when that pid dies, or is
+ stopped, or anything else that would normally cause a SIGCHLD, the
+ kernel will send the specified signal to the caller if the event is in
+ the event mask originally passed down. The siginfo_t struct will
+ contain the same information as would be included with SIGCHLD.
+
+ This is exposed to userspace via the prctl()
+ call with the PR_DO_NOTIFY_TASK_STATE option
+
config SLUB_DEBUG
default y
bool "Enable SLUB debugging support" if EXPERT
diff --git a/init/init_task.c b/init/init_task.c
index 5fa18ed59d33..e1a245782828 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -128,6 +128,7 @@ struct task_struct init_task
.alloc_lock = __SPIN_LOCK_UNLOCKED(init_task.alloc_lock),
.journal_info = NULL,
INIT_CPU_TIMERS(init_task)
+ INIT_SIGEXIT(init_task)
.pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
.timer_slack_ns = 50000, /* 50 usec default slack */
.thread_pid = &init_struct_pid,
diff --git a/kernel/Makefile b/kernel/Makefile
index e7905bdf6e97..ba9997c7a59c 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -108,6 +108,7 @@ obj-$(CONFIG_BPF) += bpf/
obj-$(CONFIG_KCSAN) += kcsan/
obj-$(CONFIG_SHADOW_CALL_STACK) += scs.o
obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call.o
+obj-$(CONFIG_SIGEXIT) += death_notify.o
obj-$(CONFIG_PERF_EVENTS) += events/
diff --git a/kernel/death_notify.c b/kernel/death_notify.c
new file mode 100644
index 000000000000..5819d35a2564
--- /dev/null
+++ b/kernel/death_notify.c
@@ -0,0 +1,228 @@
+/*
+ * kernel/death_notify.c, Process death notification support
+ *
+ * Copyright (c) 2006-2014 Wind River Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/sched/task.h>
+#include <linux/slab.h>
+#include <linux/prctl.h>
+#include <linux/uaccess.h>
+#include "death_notify.h"
+
+static void unlink_status_notifier(struct signotifier *n)
+{
+ list_del(&n->monitor_list);
+ list_del(&n->notify_list);
+ kfree(n);
+}
+
+static void handle_already_monitoring(struct signotifier *node,
+ struct task_state_notify_info *args,
+ struct task_state_notify_info *oldargs)
+{
+ /* Store the old values */
+ oldargs->sig = node->sig;
+ oldargs->events = node->events;
+
+ /* We know that args->sig is 0 or a valid signal. */
+ if (args->sig > 0) {
+ /* Update the new values */
+ node->sig = args->sig;
+ node->events = args->events;
+ } else if (!args->sig) {
+ /* args->sig of 0 means to deregister */
+ unlink_status_notifier(node);
+ }
+}
+
+static void setup_new_node(struct task_struct *p,
+ struct signotifier *node,
+ struct task_state_notify_info *args)
+{
+ node->notify_tsk = current;
+ node->sig = args->sig;
+ node->events = args->events;
+
+ /* Add this node to the list of notification requests
+ * for the specified process.
+ */
+ list_add_tail(&node->notify_list, &p->notify);
+
+ /* Also add this node to the list of monitor requests
+ * for the current process.
+ */
+ list_add_tail(&node->monitor_list, &current->monitor);
+}
+
+/* Returns 0 if arguments are valid, 1 if they are not. */
+static int invalid_args(struct task_state_notify_info *args)
+{
+ int ret = 1;
+
+ if (args->pid <= 0)
+ goto out;
+
+ /* Sig of -1 implies query, sig of 0 implies deregistration.
+ * Otherwise sig must be positive and within range.
+ */
+ if ((args->sig < -1) || (args->sig > _NSIG))
+ goto out;
+
+ /* If positive sig, must have valid events. */
+ if (args->sig > 0) {
+ if (!args->events || (args->events >= (1 << (NSIGCHLD+1))))
+ goto out;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+/* Notify those registered for process state updates via do_notify_task_state().
+ * If "del" is nonzero, the process is dying and we want to free
+ * the nodes in the list as we go.
+ *
+ * Note: we only notify processes for events in which they have registered
+ * interest.
+ *
+ * Must be called holding a lock on tasklist_lock.
+ */
+void do_notify_others(struct task_struct *tsk, struct kernel_siginfo *info)
+{
+ struct signotifier *node;
+ unsigned int events;
+
+ /* This method of generating the event bit must be
+ * matched in the userspace library.
+ */
+ events = 1 << (info->si_code & 0xFF);
+
+ list_for_each_entry(node, &tsk->notify, notify_list) {
+ if (events & node->events) {
+ info->si_signo = node->sig;
+ group_send_sig_info(node->sig, info, node->notify_tsk, PIDTYPE_TGID);
+ }
+ }
+}
+
+void release_notify_others(struct task_struct *p)
+{
+ struct signotifier *n, *t;
+
+ /* Need to clean up any outstanding requests where we
+ * wanted to be notified when others died.
+ */
+ list_for_each_entry_safe(n, t, &p->monitor, monitor_list) {
+ unlink_status_notifier(n);
+ }
+
+ /* Also need to clean up any outstanding requests where others
+ * wanted to be notified when we died.
+ */
+ list_for_each_entry_safe(n, t, &p->notify, notify_list) {
+ unlink_status_notifier(n);
+ }
+}
+
+/* If the config is defined, then processes can call this routine
+ * to request notification when the specified task's state changes.
+ * On the death (or other state change) of the specified process,
+ * we will send them the specified signal if the event is listed
+ * in their event bitfield.
+ *
+ * A sig of 0 means that we want to deregister.
+ *
+ * The sig/events fields are value/result. On success we update them
+ * to reflect what they were before the call.
+ *
+ * Returns error code on error, on success we return 0.
+ */
+int do_notify_task_state(unsigned long arg)
+{
+ int err;
+ struct task_struct *p;
+ struct signotifier *node, *tmp;
+ struct task_state_notify_info args, oldargs;
+
+ if (copy_from_user(&args, (struct task_state_notify_info __user *)arg,
+ sizeof(args)))
+ return -EFAULT;
+ oldargs.pid = args.pid;
+
+ /* Validate the arguments passed in. */
+ err = -EINVAL;
+ if (invalid_args(&args))
+ goto out;
+
+ /* We must hold a write lock on tasklist_lock to add the notification
+ * later on, and we need some lock on tasklist_lock for
+ * find_task_by_pid(), so may as well take the write lock now.
+ * Must use write_lock_irq().
+ */
+ write_lock_irq(&tasklist_lock);
+
+ err = -ESRCH;
+ p = find_task_by_vpid(args.pid);
+ if (!p)
+ goto unlock_out;
+
+ /* Now we know pid exists, unlikely to fail. */
+ err = 0;
+
+ /* Check if we're already monitoring the specified pid. If so, update
+ * the monitoring parameters and return the old ones.
+ */
+ list_for_each_entry(tmp, &p->notify, notify_list) {
+ if (tmp->notify_tsk == current) {
+ handle_already_monitoring(tmp, &args, &oldargs);
+ goto unlock_out;
+ }
+ }
+
+ /* If we get here, we're not currently monitoring the process. */
+ oldargs.sig = 0;
+ oldargs.events = 0;
+
+ /* If we wanted to set up a new monitor, do it now. If we didn't
+ * manage to allocate memory for the new node, then we return
+ * an appropriate error.
+ */
+ if (args.sig > 0) {
+ node = kmalloc(sizeof(*node), GFP_ATOMIC);
+ if (node)
+ setup_new_node(p, node, &args);
+ else
+ err = -ENOMEM;
+ }
+
+unlock_out:
+ write_unlock_irq(&tasklist_lock);
+
+ /* Copy the old values back to caller. */
+ if (copy_to_user((struct task_state_notify_info __user *)arg,
+ &oldargs, sizeof(oldargs)))
+ err = -EFAULT;
+
+out:
+ return err;
+}
+
diff --git a/kernel/death_notify.h b/kernel/death_notify.h
new file mode 100644
index 000000000000..14a0995b79af
--- /dev/null
+++ b/kernel/death_notify.h
@@ -0,0 +1,46 @@
+/*
+ * kernel/death_notify.h, Process death notification support
+ *
+ * Copyright (c) 2006-2014 Wind River Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _KERNEL_DEATH_NOTIFY_H
+#define _KERNEL_DEATH_NOTIFY_H
+
+#ifdef CONFIG_SIGEXIT
+
+struct signotifier {
+ struct task_struct *notify_tsk;
+ struct list_head notify_list;
+ struct list_head monitor_list;
+ int sig;
+ unsigned int events;
+};
+
+extern int do_notify_task_state(unsigned long arg);
+extern void do_notify_others(struct task_struct *tsk,
+ struct kernel_siginfo *info);
+extern void release_notify_others(struct task_struct *p);
+
+#else /* !CONFIG_SIGEXIT */
+
+static inline void do_notify_others(struct task_struct *tsk,
+ struct kernel_siginfo *info) {}
+static inline void release_notify_others(struct task_struct *p) {}
+
+#endif /* CONFIG_SIGEXIT */
+#endif
+
diff --git a/kernel/exit.c b/kernel/exit.c
index f5933bd07932..3c328a630257 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -68,6 +68,9 @@
#include <linux/uaccess.h>
#include <asm/unistd.h>
#include <asm/mmu_context.h>
+#ifdef CONFIG_SIGEXIT
+#include "death_notify.h"
+#endif
static void __unhash_process(struct task_struct *p, bool group_dead)
{
@@ -194,6 +197,9 @@ void release_task(struct task_struct *p)
cgroup_release(p);
write_lock_irq(&tasklist_lock);
+#ifdef CONFIG_SIGEXIT
+ release_notify_others(p);
+#endif
ptrace_release_task(p);
thread_pid = get_pid(p->thread_pid);
__exit_signal(p);
diff --git a/kernel/fork.c b/kernel/fork.c
index fb3fbfd44b25..94769fcf71ac 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2095,6 +2095,10 @@ static __latent_entropy struct task_struct *copy_process(
p->sequential_io = 0;
p->sequential_io_avg = 0;
#endif
+#ifdef CONFIG_SIGEXIT
+ INIT_LIST_HEAD(&p->notify);
+ INIT_LIST_HEAD(&p->monitor);
+#endif
/* Perform scheduler related setup. Assign this task to a CPU. */
retval = sched_fork(clone_flags, p);
diff --git a/kernel/signal.c b/kernel/signal.c
index 0be3c40c5662..1581b2a76823 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -56,6 +56,9 @@
#include <asm/unistd.h>
#include <asm/siginfo.h>
#include <asm/cacheflush.h>
+#ifdef CONFIG_SIGEXIT
+#include "death_notify.h"
+#endif
/*
* SLAB caches for signal bits.
@@ -2088,6 +2091,10 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
__wake_up_parent(tsk, tsk->parent);
spin_unlock_irqrestore(&psig->siglock, flags);
+#ifdef CONFIG_SIGEXIT
+ do_notify_others(tsk, &info);
+#endif
+
return autoreap;
}
@@ -2160,6 +2167,10 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
*/
__wake_up_parent(tsk, parent);
spin_unlock_irqrestore(&sighand->siglock, flags);
+
+#ifdef CONFIG_SIGEXIT
+ do_notify_others(tsk, &info);
+#endif
}
static inline bool may_ptrace_stop(void)
diff --git a/kernel/sys.c b/kernel/sys.c
index a730c03ee607..0f8decf763f1 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -73,6 +73,9 @@
#include <asm/unistd.h>
#include "uid16.h"
+#ifdef CONFIG_SIGEXIT
+#include "death_notify.h"
+#endif
#ifndef SET_UNALIGN_CTL
# define SET_UNALIGN_CTL(a, b) (-EINVAL)
@@ -2423,6 +2426,11 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
else
error = PR_MCE_KILL_DEFAULT;
break;
+#ifdef CONFIG_SIGEXIT
+ case PR_DO_NOTIFY_TASK_STATE:
+ error = do_notify_task_state(arg2);
+ break;
+#endif
case PR_SET_MM:
error = prctl_set_mm(arg2, arg3, arg4, arg5);
break;
--
2.31.1

View File

@ -1,33 +0,0 @@
From 9317be15490c339cd587292722efac013a2fb880 Mon Sep 17 00:00:00 2001
From: Dahir Osman <dahir.osman@windriver.com>
Date: Wed, 13 Jan 2016 10:01:11 -0500
Subject: [PATCH 02/10] PCI: Add ACS quirk for Intel Fortville NICs
Use quirks to determine isolation for now until a later kernel can
properly read the Fortville ACS capabilities.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/pci/quirks.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b570f297e3ec..910026923549 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4740,6 +4740,10 @@ static const struct pci_dev_acs_enabled {
{ PCI_VENDOR_ID_INTEL, 0x15b7, pci_quirk_mf_endpoint_acs },
{ PCI_VENDOR_ID_INTEL, 0x15b8, pci_quirk_mf_endpoint_acs },
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_rciep_acs },
+ /* I40 */
+ { PCI_VENDOR_ID_INTEL, 0x1572, pci_quirk_mf_endpoint_acs },
+ { PCI_VENDOR_ID_INTEL, 0x1586, pci_quirk_mf_endpoint_acs },
+ { PCI_VENDOR_ID_INTEL, 0x1583, pci_quirk_mf_endpoint_acs },
/* QCOM QDF2xxx root ports */
{ PCI_VENDOR_ID_QCOM, 0x0400, pci_quirk_qcom_rp_acs },
{ PCI_VENDOR_ID_QCOM, 0x0401, pci_quirk_qcom_rp_acs },
--
2.29.2

View File

@ -1,173 +0,0 @@
From 5fba1536bd24bc77ef0d6b2516fefcff69d7cf59 Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Tue, 24 Nov 2015 16:27:28 -0500
Subject: [PATCH] affine compute kernel threads
This is a kernel enhancement to configure the cpu affinity of kernel
threads via kernel boot option kthread_cpus=<cpulist>. The compute
kickstart file and compute-huge.sh scripts will update grub with the
new option.
With kthread_cpus specified, the cpumask is immediately applied upon
thread launch. This does not affect kernel threads that specify cpu
and node.
Note: this is based off of Christoph Lameter's patch at
https://lwn.net/Articles/565932/ with the only difference being
the kernel parameter changed from kthread to kthread_cpus.
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
[VT: The existing "isolcpus"
kernel bootarg, cgroup/cpuset, and taskset might provide the some
way to have cpu isolation. However none of them satisfies the requirements.
Replacing spaces with tabs. Combine two calls of set_cpus_allowed_ptr()
in kernel_init_freeable() in init/main.c into one. Performed tests]
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Vefa Bicakci <vefa.bicakci@windriver.com>
[jm: Adapted the patch for context changes.]
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
.../admin-guide/kernel-parameters.txt | 10 ++++++++
include/linux/cpumask.h | 3 +++
init/main.c | 2 ++
kernel/cpu.c | 23 +++++++++++++++++++
kernel/kthread.c | 4 ++--
kernel/umh.c | 3 +++
6 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index a19a3005b545..6f79c718ae4f 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2223,6 +2223,16 @@
See also Documentation/trace/kprobetrace.rst "Kernel
Boot Parameter" section.
+ kthread_cpus= [KNL, SMP] Only run kernel threads on the specified
+ list of processors. The kernel will start threads
+ on the indicated processors only (unless there
+ are specific reasons to run a thread with
+ different affinities). This can be used to make
+ init start on certain processors and also to
+ control where kmod and other user space threads
+ are being spawned. Allows to keep kernel threads
+ away from certain cores unless absoluteluy necessary.
+
kpti= [ARM64] Control page table isolation of user
and kernel address spaces.
Default: enabled on cores which need mitigation.
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 383684e30f12..8fcc67ea3d8c 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -55,6 +55,7 @@ extern unsigned int nr_cpu_ids;
* cpu_present_mask - has bit 'cpu' set iff cpu is populated
* cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler
* cpu_active_mask - has bit 'cpu' set iff cpu available to migration
+ * cpu_kthread_mask - has bit 'cpu' set iff general kernel threads allowed
*
* If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
*
@@ -91,10 +92,12 @@ extern struct cpumask __cpu_possible_mask;
extern struct cpumask __cpu_online_mask;
extern struct cpumask __cpu_present_mask;
extern struct cpumask __cpu_active_mask;
+extern struct cpumask __cpu_kthread_mask;
#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
#define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask)
#define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask)
#define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask)
+#define cpu_kthread_mask ((const struct cpumask *)&__cpu_kthread_mask)
extern atomic_t __num_online_cpus;
diff --git a/init/main.c b/init/main.c
index db693781a12f..4e7777bdab6e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1536,6 +1536,8 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
+
kunit_run_all_tests();
console_on_rootfs();
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 016f2d0686b6..6783db02e9ae 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2505,6 +2505,29 @@ EXPORT_SYMBOL(__cpu_active_mask);
atomic_t __num_online_cpus __read_mostly;
EXPORT_SYMBOL(__num_online_cpus);
+struct cpumask __cpu_kthread_mask __read_mostly
+ = {CPU_BITS_ALL};
+EXPORT_SYMBOL(__cpu_kthread_mask);
+
+static int __init kthread_setup(char *str)
+{
+ cpumask_var_t tmp_mask;
+ int err;
+
+ alloc_bootmem_cpumask_var(&tmp_mask);
+
+ err = cpulist_parse(str, tmp_mask);
+ if (!err)
+ cpumask_copy(&__cpu_kthread_mask, tmp_mask);
+ else
+ pr_err("Cannot parse 'kthread_cpus=%s'; error %d\n", str, err);
+
+ free_bootmem_cpumask_var(tmp_mask);
+
+ return 1;
+}
+__setup("kthread_cpus=", kthread_setup);
+
void init_cpu_present(const struct cpumask *src)
{
cpumask_copy(&__cpu_present_mask, src);
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 3ce6a31db7b4..683008e94fd4 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -300,7 +300,7 @@ static int kthread(void *_create)
* back to default in case they have been changed.
*/
sched_setscheduler_nocheck(current, SCHED_NORMAL, &param);
- set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_KTHREAD));
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
/* OK, tell user we're spawned, wait for stop or wakeup */
__set_current_state(TASK_UNINTERRUPTIBLE);
@@ -655,7 +655,7 @@ int kthreadd(void *unused)
/* Setup a clean context for our children to inherit. */
set_task_comm(tsk, "kthreadd");
ignore_signals(tsk);
- set_cpus_allowed_ptr(tsk, housekeeping_cpumask(HK_FLAG_KTHREAD));
+ set_cpus_allowed_ptr(tsk, cpu_kthread_mask);
set_mems_allowed(node_states[N_MEMORY]);
current->flags |= PF_NOFREEZE;
diff --git a/kernel/umh.c b/kernel/umh.c
index 3f646613a9d3..e5027cee43f7 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -80,6 +80,9 @@ static int call_usermodehelper_exec_async(void *data)
*/
current->fs->umask = 0022;
+ /* We can run only where init is allowed to run. */
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
+
/*
* Our parent (unbound workqueue) runs with elevated scheduling
* priority. Avoid propagating that into the userspace child.
--
2.29.2

View File

@ -1,72 +0,0 @@
From 36d1eeee008939d77f015d051970bd417ac6fcf1 Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Tue, 24 Nov 2015 16:27:29 -0500
Subject: [PATCH 04/10] Affine irqs and workqueues with kthread_cpus
If the kthread_cpus boot arg is set it means we want to affine
kernel threads to the specified CPU mask as much as possible
in order to avoid doing work on other CPUs.
In this commit we extend the meaning of that boot arg to also
apply to the CPU affinity of unbound and ordered workqueues.
We also use the kthread_cpus value to determine the default irq
affinity. Specifically, as long as the previously-calculated
irq affinity intersects with the kthread_cpus affinity then we'll
use the intersection of the two as the default irq affinity.
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
[VT: replacing spaces with tabs. Performed tests]
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
kernel/irq/manage.c | 7 +++++++
kernel/workqueue.c | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index de00a0599afe..84a120d3abef 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -515,6 +515,13 @@ int irq_setup_affinity(struct irq_desc *desc)
if (cpumask_intersects(&mask, nodemask))
cpumask_and(&mask, &mask, nodemask);
}
+
+ /* This will narrow down the affinity further if we've specified
+ * a reduced cpu_kthread_mask in the boot args.
+ */
+ if (cpumask_intersects(&mask, cpu_kthread_mask))
+ cpumask_and(&mask, &mask, cpu_kthread_mask);
+
ret = irq_do_set_affinity(&desc->irq_data, &mask, false);
raw_spin_unlock(&mask_lock);
return ret;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index c9a0c961d6e0..f69f10a220b6 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5960,6 +5960,8 @@ void __init workqueue_init_early(void)
BUG_ON(!(attrs = alloc_workqueue_attrs()));
attrs->nice = std_nice[i];
+ /* If we've specified a kthread mask apply it here too. */
+ cpumask_copy(attrs->cpumask, cpu_kthread_mask);
unbound_std_wq_attrs[i] = attrs;
/*
@@ -5970,6 +5972,8 @@ void __init workqueue_init_early(void)
BUG_ON(!(attrs = alloc_workqueue_attrs()));
attrs->nice = std_nice[i];
attrs->no_numa = true;
+ /* If we've specified a kthread mask apply it here too. */
+ cpumask_copy(attrs->cpumask, cpu_kthread_mask);
ordered_wq_attrs[i] = attrs;
}
--
2.29.2

View File

@ -1,36 +0,0 @@
From 4a72347e026f8a82c9e8d748daf59b74345c47f1 Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Thu, 12 May 2016 18:00:00 -0400
Subject: [PATCH 05/10] Make kernel start eth devices at offset
In order to avoid naming collisions, we want to make the kernel
start naming its "ethX" devices at eth1000 instead of eth0. This
will let us rename to a range starting at eth0.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
net/core/dev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 623d2622f6be..e85cddf2fc83 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1218,6 +1218,12 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
set_bit(i, inuse);
}
+ /* STX extension, want kernel to start at eth1000 */
+ if (strcmp(name, "eth%d") == 0) {
+ for (i=0; i < 1000; i++)
+ set_bit(i, inuse);
+ }
+
i = find_first_zero_bit(inuse, max_netdevices);
free_page((unsigned long) inuse);
}
--
2.29.2

View File

@ -1,125 +0,0 @@
From c35ee3034b61e72bf9fef888a3c4702049a77bcc Mon Sep 17 00:00:00 2001
From: Matt Peters <matt.peters@windriver.com>
Date: Mon, 30 May 2016 10:51:02 -0400
Subject: [PATCH] intel-iommu: allow ignoring Ethernet device RMRR with IOMMU
passthrough
Some BIOS's are reporting DMAR RMRR entries for Ethernet devices
which is causing problems when PCI passthrough is enabled. These
devices should be able to use the static identity map since the
host should not be enforcing specific address ranges when IOMMU
passthrough is enabled.
Originally-by: Matt Peters <matt.peters@windriver.com>
[PG: Added bootarg wrapper and documentation entries.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Nam Ninh <nam.ninh@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
[lz: Adapted the patch for context changes.]
Signed-off-by: Li Zhou <li.zhou@windriver.com>
[jp: fix warning: this 'else' clause does not guard]
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
.../admin-guide/kernel-parameters.txt | 5 +++++
Documentation/x86/intel-iommu.rst | 18 +++++++++++++++
drivers/iommu/intel/iommu.c | 22 ++++++++++++++++++-
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 78a923d087c1..e7639eaa41b8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1861,6 +1861,11 @@
than 32-bit addressing. The default is to look
for translation below 32-bit and if not available
then look in the higher range.
+ eth_no_rmrr [Default Off]
+ With this option provided, the kernel will ignore
+ any specified RMRR regions specified by the BIOS
+ for PCI ethernet devices. Confirm with your hardware
+ vendor the RMRR regions are indeed invalid first.
strict [Default Off]
With this option on every unmap_single operation will
result in a hardware IOTLB flush operation as opposed
diff --git a/Documentation/x86/intel-iommu.rst b/Documentation/x86/intel-iommu.rst
index 099f13d51d5f..18e6a8d8b1ee 100644
--- a/Documentation/x86/intel-iommu.rst
+++ b/Documentation/x86/intel-iommu.rst
@@ -33,6 +33,24 @@ regions will fail. Hence BIOS uses RMRR to specify these regions along with
devices that need to access these regions. OS is expected to setup
unity mappings for these regions for these devices to access these regions.
+RMRR for other devices?
+-----------------------
+
+There are reports of BIOS out there that indicate RMRR regions for things
+like ethernet devices. As per mainline commit c875d2c1b8083 ("iommu/vt-d:
+Exclude devices using RMRRs from IOMMU API domains") such a device is
+"fundamentally incompatible" with the IOMMU API and "we must prevent such
+devices from being used by the IOMMU API." However, in the event that
+the RMRR indicated by the BIOS is assumed to be just a reporting error,
+there is an additional iommu boot arg that can be used to ignore RMRR
+settings for ethernet, i.e. "intel_iommu=on,eth_no_rmrr iommu=pt".
+Note that iommu=pt is required in order to eth_no_rmrr to have effect.
+
+If you use this setting, you should consult with your hardware vendor to
+confirm that it is just a reporting error, and that it truly is not
+actively using any DMA to/from RMRR, as otherwise system instability
+may result.
+
How is IOVA generated?
----------------------
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index db9bf5ac0722..f30df770243d 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -354,6 +354,7 @@ static int dmar_map_gfx = 1;
static int dmar_forcedac;
static int intel_iommu_strict;
static int intel_iommu_superpage = 1;
+static int intel_iommu_ethrmrr = 1;
static int iommu_identity_mapping;
static int intel_no_bounce;
static int iommu_skip_te_disable;
@@ -448,6 +449,15 @@ static int __init intel_iommu_setup(char *str)
} else if (!strncmp(str, "forcedac", 8)) {
pr_info("Forcing DAC for PCI devices\n");
dmar_forcedac = 1;
+ } else if (!strncmp(str, "eth_no_rmrr", 11)) {
+ if (!iommu_default_passthrough()) {
+ printk(KERN_WARNING
+ "Intel-IOMMU: error - eth_no_rmrr requires iommu=pt\n");
+ } else {
+ printk(KERN_INFO
+ "Intel-IOMMU: ignoring ethernet RMRR values\n");
+ intel_iommu_ethrmrr = 0;
+ }
} else if (!strncmp(str, "strict", 6)) {
pr_info("Disable batched IOTLB flush\n");
intel_iommu_strict = 1;
@@ -2907,8 +2917,18 @@ static bool device_rmrr_is_relaxable(struct device *dev)
pdev = to_pci_dev(dev);
if (IS_USB_DEVICE(pdev) || IS_GFX_DEVICE(pdev))
return true;
- else
+ else {
+ /* As a temporary workaround for issues seen on ProLiant DL380p,
+ * allow the operator to ignore the RMRR settings for ethernet
+ * devices. Ideally the end user should contact their vendor
+ * regarding why there are RMRR, as per mainline c875d2c1b8083
+ * ("iommu/vt-d: Exclude devices using RMRRs from IOMMU API domains")
+ * it seems that these make no sense at all.
+ */
+ if ((pdev->class >> 8) == PCI_CLASS_NETWORK_ETHERNET && !intel_iommu_ethrmrr)
+ return true;
return false;
+ }
}
/*
--
2.29.2

View File

@ -1,27 +0,0 @@
From ecb3070f30a3328bca8844ba2a427e67bf9268ba Mon Sep 17 00:00:00 2001
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Tue, 6 Mar 2018 12:54:40 -0500
Subject: [PATCH 06/10] turn off write same in smartqpi driver
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 5083e5d2b467..cb1280d0ea75 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6575,6 +6575,7 @@ static struct scsi_host_template pqi_driver_template = {
.map_queues = pqi_map_queues,
.sdev_attrs = pqi_sdev_attrs,
.shost_attrs = pqi_shost_attrs,
+ .no_write_same = 1,
};
static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info)
--
2.29.2

View File

@ -1,79 +0,0 @@
From ad3d09f2052d053ebe13220b5acb496a07fcf0da Mon Sep 17 00:00:00 2001
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Wed, 29 Jan 2020 14:19:22 -0500
Subject: [PATCH 07/10] Allow dmar quirks for broken bioses
Problem:
Broken bios creates inaccurate DMAR tables,
reporting some bridges as having endpoint types.
This causes IOMMU initialization to bail
out early with an error code, the result of
which is vfio not working correctly.
This is seen on some Skylake based Wolfpass
server platforms with up-to-date bios installed.
Solution:
Instead of just bailing out of IOMMU
initialization when such a condition is found,
we report it and continue. The IOMMU ends
up successfully initialized anyway. We do this
only on platforms that have the Skylake bridges
where this issue has been seen.
This change is inspired by a similar one posted by
Lu Baolu of Intel Corp to lkml
https://lkml.org/lkml/2019/12/24/15
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/iommu/intel/dmar.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 02e7c10a4224..7d423ac36a44 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -66,6 +66,26 @@ static void free_iommu(struct intel_iommu *iommu);
extern const struct iommu_ops intel_iommu_ops;
+static int scope_mismatch_quirk;
+static void quirk_dmar_scope_mismatch(struct pci_dev *dev)
+{
+ pci_info(dev, "scope mismatch ignored\n");
+ scope_mismatch_quirk = 1;
+}
+
+/*
+ * We expect devices with endpoint scope to have normal PCI
+ * headers, and devices with bridge scope to have bridge PCI
+ * headers. However some PCI devices may be listed in the
+ * DMAR table with bridge scope, even though they have a
+ * normal PCI header and vice versa. We don't declare a
+ * scope mismatch for the special cases below, even though
+ * the bios creates broken tables.
+ */
+/* Sky Lake-E PCI Express Root Port A */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2030,
+ quirk_dmar_scope_mismatch);
+
static void dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
{
/*
@@ -255,7 +275,10 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
info->dev->class >> 16 != PCI_BASE_CLASS_BRIDGE))) {
pr_warn("Device scope type does not match for %s\n",
pci_name(info->dev));
- return -EINVAL;
+ if (!scope_mismatch_quirk)
+ return -EINVAL;
+ else
+ pr_warn("but continuing anyway\n");
}
for_each_dev_scope(devices, devices_cnt, i, tmp)
--
2.29.2

View File

@ -1,100 +0,0 @@
From 7240ac0b8c98c99adc09a46d577c7dd1e8ca46dd Mon Sep 17 00:00:00 2001
From: Nayna Jain <nayna@linux.vnet.ibm.com>
Date: Fri, 10 Nov 2017 17:16:35 -0500
Subject: [PATCH 08/10] tpm: ignore burstcount to improve tpm_tis send()
performance
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The TPM burstcount status indicates the number of bytes that can
be sent to the TPM without causing bus wait states.  Effectively,
it is the number of empty bytes in the command FIFO.
This patch optimizes the tpm_tis_send_data() function by checking
the burstcount only once. And if the burstcount is valid, it writes
all the bytes at once, permitting wait state.
After this change, performance on a TPM 1.2 with an 8 byte
burstcount for 1000 extends improved from ~41sec to ~14sec.
Suggested-by: Ken Goldman <kgold@linux.vnet.ibm.com> in
conjunction with the TPM Device Driver work group.
Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/char/tpm/tpm_tis_core.c | 43 ++++++++++++---------------------
1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index a2e0395cbe61..2c69fde1e4e5 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -330,7 +330,6 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
{
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
int rc, status, burstcnt;
- size_t count = 0;
bool itpm = priv->flags & TPM_TIS_ITPM_WORKAROUND;
status = tpm_tis_status(chip);
@@ -343,36 +342,24 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
goto out_err;
}
}
-
- while (count < len - 1) {
- burstcnt = get_burstcount(chip);
- if (burstcnt < 0) {
- dev_err(&chip->dev, "Unable to read burstcount\n");
- rc = burstcnt;
- goto out_err;
- }
- burstcnt = min_t(int, burstcnt, len - count - 1);
- rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality),
- burstcnt, buf + count);
- if (rc < 0)
- goto out_err;
-
- count += burstcnt;
-
- if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
- status = tpm_tis_status(chip);
- if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
- rc = -EIO;
- goto out_err;
- }
+ /*
+ * Get the initial burstcount to ensure TPM is ready to
+ * accept data, even when waiting for burstcount is disabled.
+ */
+ burstcnt = get_burstcount(chip);
+ if (burstcnt < 0) {
+ dev_err(&chip->dev, "Unable to read burstcount\n");
+ rc = burstcnt;
+ goto out_err;
}
+ rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality),
+ len -1, buf);
+ if (rc < 0)
+ goto out_err;
+
/* write last byte */
- rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[count]);
+ rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[len-1]);
if (rc < 0)
goto out_err;
--
2.29.2

View File

@ -1,46 +0,0 @@
From 496b91a31568c382c50dd2fe7ce190142913eaf5 Mon Sep 17 00:00:00 2001
From: Alex Kozyrev <alex.kozyrev@windriver.com>
Date: Fri, 16 Mar 2018 15:50:57 -0400
Subject: [PATCH 09/10] restrict iSCSI kthreads to CPUs in cpu_kthread_mask
Do not allow them to run on other CPUs to prevent interference with VMs.
Signed-off-by: Alex Kozyrev <alex.kozyrev@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Austin Sun <austin.sun@intel.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/target/iscsi/iscsi_target.c | 4 ++--
include/linux/cpumask.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index a237f1cf9bd6..e00365a0538f 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -3593,8 +3593,8 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn)
* iSCSI connection's RX/TX threads will be scheduled to
* execute upon.
*/
- ord = conn->bitmap_id % cpumask_weight(cpu_online_mask);
- for_each_online_cpu(cpu) {
+ ord = conn->bitmap_id % cpumask_weight(cpu_kthread_mask);
+ for_each_kthread_cpu(cpu) {
if (ord-- == 0) {
cpumask_set_cpu(cpu, conn->conn_cpumask);
return;
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 8fcc67ea3d8c..b24159c028ac 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -820,6 +820,7 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);
#define for_each_possible_cpu(cpu) for_each_cpu((cpu), cpu_possible_mask)
#define for_each_online_cpu(cpu) for_each_cpu((cpu), cpu_online_mask)
#define for_each_present_cpu(cpu) for_each_cpu((cpu), cpu_present_mask)
+#define for_each_kthread_cpu(cpu) for_each_cpu((cpu), cpu_kthread_mask)
/* Wrappers for arch boot code to manipulate normally-constant masks */
void init_cpu_present(const struct cpumask *src);
--
2.29.2

View File

@ -1,41 +0,0 @@
From 2a32d5bc7e385fbf40f22cc413354e17a24d4de9 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Sun, 10 Oct 2021 18:56:26 -0700
Subject: [PATCH] scsi: smartpqi: Enable sas_address sysfs for SATA device
type.
We met the issue DM complains that it can't find the disk specified
in the deployment config file after we updated the Linux kernel to 5.10.
The error is "failed to find disk for path /dev/disk/by-path/
pci-0000:3b:00.0-sas-0x31402ec001d92983-lun-0"
This happens because device type SATA is excluded from being
processed with the function pqi_is_device_with_sas_address.
which causes all SATA type disk drives to appear the same, having
zeroes in the lun name. /dev/disk/by-path/
pci-0000:3b:00.0-sas-0x0000000000000000-lun-0
We can add type SA_DEVICE_TYPE_SATA to class device_with_sas_address,
since it will also get the sas_address from wwid. and works transparently
with the old kernel without gaps.
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index ecb2af3f43ca..df16e0a27a41 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2101,6 +2101,7 @@ static inline void pqi_mask_device(u8 *scsi3addr)
static inline bool pqi_is_device_with_sas_address(struct pqi_scsi_dev *device)
{
switch (device->device_type) {
+ case SA_DEVICE_TYPE_SATA:
case SA_DEVICE_TYPE_SAS:
case SA_DEVICE_TYPE_EXPANDER_SMP:
case SA_DEVICE_TYPE_SES:
--
2.31.1

View File

@ -1,61 +0,0 @@
From 6039b821dbe26c7708537e07276316dca36c1c0f Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Thu, 9 Sep 2021 04:56:46 -0400
Subject: [PATCH] workqueue: Affine rescuer threads and unbound wqs
This commit ensures that workqueue rescuer threads are affined to the
platform CPUs specified by the "kthread_cpus" kernel argument. Prior to
this commit, rescuer threads could be bound to any CPU. Rescuer threads
are described in "kernel/workqueue.c" as follows:
"Regular work processing on a pool may block trying to create a new
worker which uses GFP_KERNEL allocation which has slight chance of
developing into deadlock if some works currently on the same queue
need to be processed to satisfy the GFP_KERNEL allocation. This is
the problem rescuer solves.
When such condition is possible, the pool summons rescuers of all
workqueues which have works queued on the pool and let them process
those works so that forward progress can be guaranteed."
This commit also affines unbound workqueues to the platform CPUs instead
of the housekeeping CPUs, because the latter can be a superset of the
former.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
kernel/workqueue.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1a4151c6faa6..3e3bd8d75f3c 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4242,7 +4242,7 @@ static int init_rescuer(struct workqueue_struct *wq)
}
wq->rescuer = rescuer;
- kthread_bind_mask(rescuer->task, cpu_possible_mask);
+ kthread_bind_mask(rescuer->task, cpu_kthread_mask);
wake_up_process(rescuer->task);
return 0;
@@ -5941,13 +5941,12 @@ static void __init wq_numa_init(void)
void __init workqueue_init_early(void)
{
int std_nice[NR_STD_WORKER_POOLS] = { 0, HIGHPRI_NICE_LEVEL };
- int hk_flags = HK_FLAG_DOMAIN | HK_FLAG_WQ;
int i, cpu;
BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long));
BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL));
- cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(hk_flags));
+ cpumask_copy(wq_unbound_cpumask, cpu_kthread_mask);
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
--
2.29.2

View File

@ -1,167 +0,0 @@
From 42f1ccc21f873a27c125a4e1aa3cb70a2336aa14 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 8 Dec 2021 17:49:56 -0800
Subject: [PATCH] Revert "scsi: sd: Inline sd_probe_part2()"
This reverts commit 82a54da641f3cacfa31db36fc58a5e903f804c22.
Merge conflicts were encountered when reverting this commit, which
inlines sd_probe_part2() into sd_probe(). However, the inlined parts
of sd_probe_part2() have since been modified. To avoid a difference
in behaviour, the updated code was relocated to sd_probe_part2().
The inlined code has been modified as follows since the inlining
happened:
The following code was added
if (sdp->rpm_autosuspend) {
pm_runtime_set_autosuspend_delay(dev,
sdp->host->hostt->rpm_autosuspend_delay);
}
between the following line
blk_pm_runtime_init(sdp->request_queue, dev);
and the following line
device_add_disk(dev, gd, NULL);
In addition, init_opal_dev() is now passed the pointer "sdkp"
instead of "sdp" as the first argument. This commit ensures that
these two changes were accounted for when reverting the inlining
of sd_probe_part2().
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/sd.c | 111 ++++++++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 48 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 56e291708587..d1d27516fc6a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3364,6 +3364,68 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
return 0;
}
+static void sd_probe_part2(struct scsi_disk *sdkp)
+{
+ struct scsi_device *sdp;
+ struct gendisk *gd;
+ u32 index;
+ struct device *dev;
+
+ sdp = sdkp->device;
+ gd = sdkp->disk;
+ index = sdkp->index;
+ dev = &sdp->sdev_gendev;
+
+ gd->major = sd_major((index & 0xf0) >> 4);
+ gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
+
+ gd->fops = &sd_fops;
+ gd->private_data = &sdkp->driver;
+ gd->queue = sdkp->device->request_queue;
+
+ /* defaults, until the device tells us otherwise */
+ sdp->sector_size = 512;
+ sdkp->capacity = 0;
+ sdkp->media_present = 1;
+ sdkp->write_prot = 0;
+ sdkp->cache_override = 0;
+ sdkp->WCE = 0;
+ sdkp->RCD = 0;
+ sdkp->ATO = 0;
+ sdkp->first_scan = 1;
+ sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
+
+ sd_revalidate_disk(gd);
+
+ gd->flags = GENHD_FL_EXT_DEVT;
+ if (sdp->removable) {
+ gd->flags |= GENHD_FL_REMOVABLE;
+ gd->events |= DISK_EVENT_MEDIA_CHANGE;
+ gd->event_flags = DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
+ }
+
+ blk_pm_runtime_init(sdp->request_queue, dev);
+ if (sdp->rpm_autosuspend) {
+ pm_runtime_set_autosuspend_delay(dev,
+ sdp->host->hostt->rpm_autosuspend_delay);
+ }
+ device_add_disk(dev, gd, NULL);
+ if (sdkp->capacity)
+ sd_dif_config_host(sdkp);
+
+ sd_revalidate_disk(gd);
+
+ if (sdkp->security) {
+ sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
+ if (sdkp->opal_dev)
+ sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
+ }
+
+ sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
+ sdp->removable ? "removable " : "");
+ scsi_autopm_put_device(sdp);
+}
+
/**
* sd_probe - called during driver initialization and whenever a
* new scsi device is attached to the system. It is called once
@@ -3455,54 +3517,7 @@ static int sd_probe(struct device *dev)
dev_set_drvdata(dev, sdkp);
- gd->major = sd_major((index & 0xf0) >> 4);
- gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
-
- gd->fops = &sd_fops;
- gd->private_data = &sdkp->driver;
- gd->queue = sdkp->device->request_queue;
-
- /* defaults, until the device tells us otherwise */
- sdp->sector_size = 512;
- sdkp->capacity = 0;
- sdkp->media_present = 1;
- sdkp->write_prot = 0;
- sdkp->cache_override = 0;
- sdkp->WCE = 0;
- sdkp->RCD = 0;
- sdkp->ATO = 0;
- sdkp->first_scan = 1;
- sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
-
- sd_revalidate_disk(gd);
-
- gd->flags = GENHD_FL_EXT_DEVT;
- if (sdp->removable) {
- gd->flags |= GENHD_FL_REMOVABLE;
- gd->events |= DISK_EVENT_MEDIA_CHANGE;
- gd->event_flags = DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
- }
-
- blk_pm_runtime_init(sdp->request_queue, dev);
- if (sdp->rpm_autosuspend) {
- pm_runtime_set_autosuspend_delay(dev,
- sdp->host->hostt->rpm_autosuspend_delay);
- }
- device_add_disk(dev, gd, NULL);
- if (sdkp->capacity)
- sd_dif_config_host(sdkp);
-
- sd_revalidate_disk(gd);
-
- if (sdkp->security) {
- sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
- if (sdkp->opal_dev)
- sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
- }
-
- sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
- sdp->removable ? "removable " : "");
- scsi_autopm_put_device(sdp);
+ sd_probe_part2(sdkp);
return 0;
--
2.31.1

View File

@ -1,135 +0,0 @@
From b5dad6e67f9704968ca7d4daf1715667cddafa3d Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 8 Dec 2021 18:34:59 -0800
Subject: [PATCH 2/2] Revert commit f049cf1a7b
commit f049cf1a7b "scsi: sd: Rely on the driver core for asynchronous
probing"
This reverts commit f049cf1a7b6737c75884247c3f6383ef104d255a,
and it is a clean revert, there is not any conflict.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/scsi.c | 12 +++++++++---
drivers/scsi/scsi_pm.c | 6 +++++-
drivers/scsi/scsi_priv.h | 1 +
drivers/scsi/sd.c | 12 +++++++++---
4 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 24619c3bebd5..3080292a16cd 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -86,10 +86,15 @@ unsigned int scsi_logging_level;
EXPORT_SYMBOL(scsi_logging_level);
#endif
+/* sd, scsi core and power management need to coordinate flushing async actions */
+ASYNC_DOMAIN(scsi_sd_probe_domain);
+EXPORT_SYMBOL(scsi_sd_probe_domain);
+
/*
- * Domain for asynchronous system resume operations. It is marked 'exclusive'
- * to avoid being included in the async_synchronize_full() that is invoked by
- * dpm_resume().
+ * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of
+ * asynchronous system resume operations. It is marked 'exclusive' to avoid
+ * being included in the async_synchronize_full() that is invoked by
+ * dpm_resume()
*/
ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
EXPORT_SYMBOL(scsi_sd_pm_domain);
@@ -799,6 +804,7 @@ static void __exit exit_scsi(void)
scsi_exit_devinfo();
scsi_exit_procfs();
scsi_exit_queue();
+ async_unregister_domain(&scsi_sd_probe_domain);
}
subsys_initcall(init_scsi);
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index 3717eea37ecb..b3d71b516213 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -175,7 +175,11 @@ static int scsi_bus_resume_common(struct device *dev,
static int scsi_bus_prepare(struct device *dev)
{
- if (scsi_is_host_device(dev)) {
+ if (scsi_is_sdev_device(dev)) {
+ /* sd probing uses async_schedule. Wait until it finishes. */
+ async_synchronize_full_domain(&scsi_sd_probe_domain);
+
+ } else if (scsi_is_host_device(dev)) {
/* Wait until async scanning is finished */
scsi_complete_async_scans();
}
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 180636d54982..c43456f0870c 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -172,6 +172,7 @@ static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
#endif /* CONFIG_PM */
extern struct async_domain scsi_sd_pm_domain;
+extern struct async_domain scsi_sd_probe_domain;
/* scsi_dh.c */
#ifdef CONFIG_SCSI_DH
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2e22ee4501e7..e6c70475f084 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -616,7 +616,6 @@ static struct scsi_driver sd_template = {
.name = "sd",
.owner = THIS_MODULE,
.probe = sd_probe,
- .probe_type = PROBE_PREFER_ASYNCHRONOUS,
.remove = sd_remove,
.shutdown = sd_shutdown,
.pm = &sd_pm_ops,
@@ -3364,8 +3363,12 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
return 0;
}
-static void sd_probe_part2(struct scsi_disk *sdkp)
+/*
+ * The asynchronous part of sd_probe
+ */
+static void sd_probe_async(void *data, async_cookie_t cookie)
{
+ struct scsi_disk *sdkp = data;
struct scsi_device *sdp;
struct gendisk *gd;
u32 index;
@@ -3424,6 +3427,7 @@ static void sd_probe_part2(struct scsi_disk *sdkp)
sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
sdp->removable ? "removable " : "");
scsi_autopm_put_device(sdp);
+ put_device(&sdkp->dev);
}
/**
@@ -3517,7 +3521,8 @@ static int sd_probe(struct device *dev)
dev_set_drvdata(dev, sdkp);
- sd_probe_part2(sdkp);
+ get_device(&sdkp->dev); /* prevent release before async_schedule */
+ async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
return 0;
@@ -3554,6 +3559,7 @@ static int sd_remove(struct device *dev)
scsi_autopm_get_device(sdkp->device);
async_synchronize_full_domain(&scsi_sd_pm_domain);
+ async_synchronize_full_domain(&scsi_sd_probe_domain);
device_del(&sdkp->dev);
del_gendisk(sdkp->disk);
sd_shutdown(dev);
--
2.31.1

View File

@ -1,124 +0,0 @@
From f53c29e1392a5f67bc937227417bd786e7594e22 Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 18 May 2021 11:17:26 +0200
Subject: [PATCH] genirq: Export affinity setter for modules
Perf modules abuse irq_set_affinity_hint() to set the affinity of system
PMU interrupts just because irq_set_affinity() was not exported.
The fact that irq_set_affinity_hint() actually sets the affinity is a
non-documented side effect and the name is clearly saying it's a hint.
To clean this up, export the real affinity setter.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20210518093117.968251441@linutronix.de
(cherry picked from commit 4d80d6ca5d77fde9880da8466e5b64f250e5bf82)
[mvb: Adjust context for a function that does not exist in v5.10.]
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
include/linux/interrupt.h | 35 ++---------------------------------
kernel/irq/manage.c | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 7545a2f18560..10319f8da486 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -314,39 +314,8 @@ struct irq_affinity_desc {
extern cpumask_var_t irq_default_affinity;
-/* Internal implementation. Use the helpers below */
-extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
- bool force);
-
-/**
- * irq_set_affinity - Set the irq affinity of a given irq
- * @irq: Interrupt to set affinity
- * @cpumask: cpumask
- *
- * Fails if cpumask does not contain an online CPU
- */
-static inline int
-irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
-{
- return __irq_set_affinity(irq, cpumask, false);
-}
-
-/**
- * irq_force_affinity - Force the irq affinity of a given irq
- * @irq: Interrupt to set affinity
- * @cpumask: cpumask
- *
- * Same as irq_set_affinity, but without checking the mask against
- * online cpus.
- *
- * Solely for low level cpu hotplug code, where we need to make per
- * cpu interrupts affine before the cpu becomes online.
- */
-static inline int
-irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
-{
- return __irq_set_affinity(irq, cpumask, true);
-}
+extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
+extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);
extern int irq_can_set_affinity(unsigned int irq);
extern int irq_select_affinity(unsigned int irq);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 84a120d3abef..d7974de65659 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -371,7 +371,8 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
return ret;
}
-int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
+static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask,
+ bool force)
{
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
@@ -386,6 +387,36 @@ int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
return ret;
}
+/**
+ * irq_set_affinity - Set the irq affinity of a given irq
+ * @irq: Interrupt to set affinity
+ * @cpumask: cpumask
+ *
+ * Fails if cpumask does not contain an online CPU
+ */
+int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+ return __irq_set_affinity(irq, cpumask, false);
+}
+EXPORT_SYMBOL_GPL(irq_set_affinity);
+
+/**
+ * irq_force_affinity - Force the irq affinity of a given irq
+ * @irq: Interrupt to set affinity
+ * @cpumask: cpumask
+ *
+ * Same as irq_set_affinity, but without checking the mask against
+ * online cpus.
+ *
+ * Solely for low level cpu hotplug code, where we need to make per
+ * cpu interrupts affine before the cpu becomes online.
+ */
+int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+ return __irq_set_affinity(irq, cpumask, true);
+}
+EXPORT_SYMBOL_GPL(irq_force_affinity);
+
int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
{
unsigned long flags;
--
2.29.2

View File

@ -1,146 +0,0 @@
From 65d6ca9e8f41d14239e3e7618126f65df9982f92 Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 3 Sep 2021 11:24:17 -0400
Subject: [PATCH] genirq: Provide new interfaces for affinity hints
The discussion about removing the side effect of irq_set_affinity_hint() of
actually applying the cpumask (if not NULL) as affinity to the interrupt,
unearthed a few unpleasantries:
1) The modular perf drivers rely on the current behaviour for the very
wrong reasons.
2) While none of the other drivers prevents user space from changing
the affinity, a cursorily inspection shows that there are at least
expectations in some drivers.
#1 needs to be cleaned up anyway, so that's not a problem
#2 might result in subtle regressions especially when irqbalanced (which
nowadays ignores the affinity hint) is disabled.
Provide new interfaces:
irq_update_affinity_hint() - Only sets the affinity hint pointer
irq_set_affinity_and_hint() - Set the pointer and apply the affinity to
the interrupt
Make irq_set_affinity_hint() a wrapper around irq_apply_affinity_hint() and
document it to be phased out.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com
Link: https://lore.kernel.org/r/20210903152430.244937-2-nitesh@redhat.com
(cherry picked from commit 65c7cdedeb3026fabcc967a7aae2f755ad4d0783)
[mvb: Adapt to v5.10 by resolving a minor merge conflict.]
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
include/linux/interrupt.h | 52 ++++++++++++++++++++++++++++++++++++++-
kernel/irq/manage.c | 8 +++---
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 10319f8da486..c1520fa7e843 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -320,7 +320,45 @@ extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);
extern int irq_can_set_affinity(unsigned int irq);
extern int irq_select_affinity(unsigned int irq);
-extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
+extern int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
+ bool setaffinity);
+
+/**
+ * irq_update_affinity_hint - Update the affinity hint
+ * @irq: Interrupt to update
+ * @m: cpumask pointer (NULL to clear the hint)
+ *
+ * Updates the affinity hint, but does not change the affinity of the interrupt.
+ */
+static inline int
+irq_update_affinity_hint(unsigned int irq, const struct cpumask *m)
+{
+ return __irq_apply_affinity_hint(irq, m, false);
+}
+
+/**
+ * irq_set_affinity_and_hint - Update the affinity hint and apply the provided
+ * cpumask to the interrupt
+ * @irq: Interrupt to update
+ * @m: cpumask pointer (NULL to clear the hint)
+ *
+ * Updates the affinity hint and if @m is not NULL it applies it as the
+ * affinity of that interrupt.
+ */
+static inline int
+irq_set_affinity_and_hint(unsigned int irq, const struct cpumask *m)
+{
+ return __irq_apply_affinity_hint(irq, m, true);
+}
+
+/*
+ * Deprecated. Use irq_update_affinity_hint() or irq_set_affinity_and_hint()
+ * instead.
+ */
+static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
+{
+ return irq_set_affinity_and_hint(irq, m);
+}
extern int
irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
@@ -350,6 +388,18 @@ static inline int irq_can_set_affinity(unsigned int irq)
static inline int irq_select_affinity(unsigned int irq) { return 0; }
+static inline int irq_update_affinity_hint(unsigned int irq,
+ const struct cpumask *m)
+{
+ return -EINVAL;
+}
+
+static inline int irq_set_affinity_and_hint(unsigned int irq,
+ const struct cpumask *m)
+{
+ return -EINVAL;
+}
+
static inline int irq_set_affinity_hint(unsigned int irq,
const struct cpumask *m)
{
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index d7974de65659..836e7111b584 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -417,7 +417,8 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
}
EXPORT_SYMBOL_GPL(irq_force_affinity);
-int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
+int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
+ bool setaffinity)
{
unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
@@ -426,12 +427,11 @@ int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
return -EINVAL;
desc->affinity_hint = m;
irq_put_desc_unlock(desc, flags);
- /* set the initial affinity to prevent every interrupt being on CPU0 */
- if (m)
+ if (m && setaffinity)
__irq_set_affinity(irq, m, false);
return 0;
}
-EXPORT_SYMBOL_GPL(irq_set_affinity_hint);
+EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint);
static void irq_affinity_notify(struct work_struct *work)
{
--
2.29.2

View File

@ -1,64 +0,0 @@
From ec3682a03a0be93ec7e6c8706ab89846cfad4232 Mon Sep 17 00:00:00 2001
From: Nitesh Narayan Lal <nitesh@redhat.com>
Date: Fri, 3 Sep 2021 11:24:25 -0400
Subject: [PATCH] ixgbe: Use irq_update_affinity_hint()
The driver uses irq_set_affinity_hint() to update the affinity_hint mask
that is consumed by the userspace to distribute the interrupts. However,
under the hood irq_set_affinity_hint() also applies the provided cpumask
(if not NULL) as the affinity for the given interrupt which is an
undocumented side effect.
To remove this side effect irq_set_affinity_hint() has been marked
as deprecated and new interfaces have been introduced. Hence, replace the
irq_set_affinity_hint() with the new interface irq_update_affinity_hint()
that only updates the affinity_hint pointer.
Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Link: https://lore.kernel.org/r/20210903152430.244937-10-nitesh@redhat.com
(cherry picked from commit cc493264c01d055742a34cfbaecaffb258dcc58c)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index ffe322136c58..fe10776d8479 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3250,8 +3250,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
/* If Flow Director is enabled, set interrupt affinity */
if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
/* assign the mask for this irq */
- irq_set_affinity_hint(entry->vector,
- &q_vector->affinity_mask);
+ irq_update_affinity_hint(entry->vector,
+ &q_vector->affinity_mask);
}
}
@@ -3267,8 +3267,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
free_queue_irqs:
while (vector) {
vector--;
- irq_set_affinity_hint(adapter->msix_entries[vector].vector,
- NULL);
+ irq_update_affinity_hint(adapter->msix_entries[vector].vector,
+ NULL);
free_irq(adapter->msix_entries[vector].vector,
adapter->q_vector[vector]);
}
@@ -3401,7 +3401,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
continue;
/* clear the affinity_mask in the IRQ descriptor */
- irq_set_affinity_hint(entry->vector, NULL);
+ irq_update_affinity_hint(entry->vector, NULL);
free_irq(entry->vector, q_vector);
}
--
2.29.2

View File

@ -1,743 +0,0 @@
From f7fadaaf14372fcc39555b1e3a1a0efa62472dfd Mon Sep 17 00:00:00 2001
From: Dave Ertman <david.m.ertman@intel.com>
Date: Wed, 2 Dec 2020 16:54:24 -0800
Subject: [PATCH] Add auxiliary bus support
Add support for the Auxiliary Bus, auxiliary_device and auxiliary_driver.
It enables drivers to create an auxiliary_device and bind an
auxiliary_driver to it.
The bus supports probe/remove shutdown and suspend/resume callbacks.
Each auxiliary_device has a unique string based id; driver binds to
an auxiliary_device based on this id through the bus.
Co-developed-by: Kiran Patil <kiran.patil@intel.com>
Co-developed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Co-developed-by: Fred Oh <fred.oh@linux.intel.com>
Co-developed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Martin Habets <mhabets@solarflare.com>
Link: https://lore.kernel.org/r/20201113161859.1775473-2-david.m.ertman@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/160695681289.505290.8978295443574440604.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7de3697e9cbd4bd3d62bafa249d57990e1b8f294)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
Documentation/driver-api/auxiliary_bus.rst | 234 ++++++++++++++++++
Documentation/driver-api/index.rst | 1 +
drivers/base/Kconfig | 3 +
drivers/base/Makefile | 1 +
drivers/base/auxiliary.c | 268 +++++++++++++++++++++
include/linux/auxiliary_bus.h | 78 ++++++
include/linux/mod_devicetable.h | 8 +
scripts/mod/devicetable-offsets.c | 3 +
scripts/mod/file2alias.c | 8 +
9 files changed, 604 insertions(+)
create mode 100644 Documentation/driver-api/auxiliary_bus.rst
create mode 100644 drivers/base/auxiliary.c
create mode 100644 include/linux/auxiliary_bus.h
diff --git a/Documentation/driver-api/auxiliary_bus.rst b/Documentation/driver-api/auxiliary_bus.rst
new file mode 100644
index 000000000000..5dd7804631ef
--- /dev/null
+++ b/Documentation/driver-api/auxiliary_bus.rst
@@ -0,0 +1,234 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+=============
+Auxiliary Bus
+=============
+
+In some subsystems, the functionality of the core device (PCI/ACPI/other) is
+too complex for a single device to be managed by a monolithic driver
+(e.g. Sound Open Firmware), multiple devices might implement a common
+intersection of functionality (e.g. NICs + RDMA), or a driver may want to
+export an interface for another subsystem to drive (e.g. SIOV Physical Function
+export Virtual Function management). A split of the functinoality into child-
+devices representing sub-domains of functionality makes it possible to
+compartmentalize, layer, and distribute domain-specific concerns via a Linux
+device-driver model.
+
+An example for this kind of requirement is the audio subsystem where a single
+IP is handling multiple entities such as HDMI, Soundwire, local devices such as
+mics/speakers etc. The split for the core's functionality can be arbitrary or
+be defined by the DSP firmware topology and include hooks for test/debug. This
+allows for the audio core device to be minimal and focused on hardware-specific
+control and communication.
+
+Each auxiliary_device represents a part of its parent functionality. The
+generic behavior can be extended and specialized as needed by encapsulating an
+auxiliary_device within other domain-specific structures and the use of .ops
+callbacks. Devices on the auxiliary bus do not share any structures and the use
+of a communication channel with the parent is domain-specific.
+
+Note that ops are intended as a way to augment instance behavior within a class
+of auxiliary devices, it is not the mechanism for exporting common
+infrastructure from the parent. Consider EXPORT_SYMBOL_NS() to convey
+infrastructure from the parent module to the auxiliary module(s).
+
+
+When Should the Auxiliary Bus Be Used
+=====================================
+
+The auxiliary bus is to be used when a driver and one or more kernel modules,
+who share a common header file with the driver, need a mechanism to connect and
+provide access to a shared object allocated by the auxiliary_device's
+registering driver. The registering driver for the auxiliary_device(s) and the
+kernel module(s) registering auxiliary_drivers can be from the same subsystem,
+or from multiple subsystems.
+
+The emphasis here is on a common generic interface that keeps subsystem
+customization out of the bus infrastructure.
+
+One example is a PCI network device that is RDMA-capable and exports a child
+device to be driven by an auxiliary_driver in the RDMA subsystem. The PCI
+driver allocates and registers an auxiliary_device for each physical
+function on the NIC. The RDMA driver registers an auxiliary_driver that claims
+each of these auxiliary_devices. This conveys data/ops published by the parent
+PCI device/driver to the RDMA auxiliary_driver.
+
+Another use case is for the PCI device to be split out into multiple sub
+functions. For each sub function an auxiliary_device is created. A PCI sub
+function driver binds to such devices that creates its own one or more class
+devices. A PCI sub function auxiliary device is likely to be contained in a
+struct with additional attributes such as user defined sub function number and
+optional attributes such as resources and a link to the parent device. These
+attributes could be used by systemd/udev; and hence should be initialized
+before a driver binds to an auxiliary_device.
+
+A key requirement for utilizing the auxiliary bus is that there is no
+dependency on a physical bus, device, register accesses or regmap support.
+These individual devices split from the core cannot live on the platform bus as
+they are not physical devices that are controlled by DT/ACPI. The same
+argument applies for not using MFD in this scenario as MFD relies on individual
+function devices being physical devices.
+
+Auxiliary Device
+================
+
+An auxiliary_device represents a part of its parent device's functionality. It
+is given a name that, combined with the registering drivers KBUILD_MODNAME,
+creates a match_name that is used for driver binding, and an id that combined
+with the match_name provide a unique name to register with the bus subsystem.
+
+Registering an auxiliary_device is a two-step process. First call
+auxiliary_device_init(), which checks several aspects of the auxiliary_device
+struct and performs a device_initialize(). After this step completes, any
+error state must have a call to auxiliary_device_uninit() in its resolution path.
+The second step in registering an auxiliary_device is to perform a call to
+auxiliary_device_add(), which sets the name of the device and add the device to
+the bus.
+
+Unregistering an auxiliary_device is also a two-step process to mirror the
+register process. First call auxiliary_device_delete(), then call
+auxiliary_device_uninit().
+
+.. code-block:: c
+
+ struct auxiliary_device {
+ struct device dev;
+ const char *name;
+ u32 id;
+ };
+
+If two auxiliary_devices both with a match_name "mod.foo" are registered onto
+the bus, they must have unique id values (e.g. "x" and "y") so that the
+registered devices names are "mod.foo.x" and "mod.foo.y". If match_name + id
+are not unique, then the device_add fails and generates an error message.
+
+The auxiliary_device.dev.type.release or auxiliary_device.dev.release must be
+populated with a non-NULL pointer to successfully register the auxiliary_device.
+
+The auxiliary_device.dev.parent must also be populated.
+
+Auxiliary Device Memory Model and Lifespan
+------------------------------------------
+
+The registering driver is the entity that allocates memory for the
+auxiliary_device and register it on the auxiliary bus. It is important to note
+that, as opposed to the platform bus, the registering driver is wholly
+responsible for the management for the memory used for the driver object.
+
+A parent object, defined in the shared header file, contains the
+auxiliary_device. It also contains a pointer to the shared object(s), which
+also is defined in the shared header. Both the parent object and the shared
+object(s) are allocated by the registering driver. This layout allows the
+auxiliary_driver's registering module to perform a container_of() call to go
+from the pointer to the auxiliary_device, that is passed during the call to the
+auxiliary_driver's probe function, up to the parent object, and then have
+access to the shared object(s).
+
+The memory for the auxiliary_device is freed only in its release() callback
+flow as defined by its registering driver.
+
+The memory for the shared object(s) must have a lifespan equal to, or greater
+than, the lifespan of the memory for the auxiliary_device. The auxiliary_driver
+should only consider that this shared object is valid as long as the
+auxiliary_device is still registered on the auxiliary bus. It is up to the
+registering driver to manage (e.g. free or keep available) the memory for the
+shared object beyond the life of the auxiliary_device.
+
+The registering driver must unregister all auxiliary devices before its own
+driver.remove() is completed.
+
+Auxiliary Drivers
+=================
+
+Auxiliary drivers follow the standard driver model convention, where
+discovery/enumeration is handled by the core, and drivers
+provide probe() and remove() methods. They support power management
+and shutdown notifications using the standard conventions.
+
+.. code-block:: c
+
+ struct auxiliary_driver {
+ int (*probe)(struct auxiliary_device *,
+ const struct auxiliary_device_id *id);
+ int (*remove)(struct auxiliary_device *);
+ void (*shutdown)(struct auxiliary_device *);
+ int (*suspend)(struct auxiliary_device *, pm_message_t);
+ int (*resume)(struct auxiliary_device *);
+ struct device_driver driver;
+ const struct auxiliary_device_id *id_table;
+ };
+
+Auxiliary drivers register themselves with the bus by calling
+auxiliary_driver_register(). The id_table contains the match_names of auxiliary
+devices that a driver can bind with.
+
+Example Usage
+=============
+
+Auxiliary devices are created and registered by a subsystem-level core device
+that needs to break up its functionality into smaller fragments. One way to
+extend the scope of an auxiliary_device is to encapsulate it within a domain-
+pecific structure defined by the parent device. This structure contains the
+auxiliary_device and any associated shared data/callbacks needed to establish
+the connection with the parent.
+
+An example is:
+
+.. code-block:: c
+
+ struct foo {
+ struct auxiliary_device auxdev;
+ void (*connect)(struct auxiliary_device *auxdev);
+ void (*disconnect)(struct auxiliary_device *auxdev);
+ void *data;
+ };
+
+The parent device then registers the auxiliary_device by calling
+auxiliary_device_init(), and then auxiliary_device_add(), with the pointer to
+the auxdev member of the above structure. The parent provides a name for the
+auxiliary_device that, combined with the parent's KBUILD_MODNAME, creates a
+match_name that is be used for matching and binding with a driver.
+
+Whenever an auxiliary_driver is registered, based on the match_name, the
+auxiliary_driver's probe() is invoked for the matching devices. The
+auxiliary_driver can also be encapsulated inside custom drivers that make the
+core device's functionality extensible by adding additional domain-specific ops
+as follows:
+
+.. code-block:: c
+
+ struct my_ops {
+ void (*send)(struct auxiliary_device *auxdev);
+ void (*receive)(struct auxiliary_device *auxdev);
+ };
+
+
+ struct my_driver {
+ struct auxiliary_driver auxiliary_drv;
+ const struct my_ops ops;
+ };
+
+An example of this type of usage is:
+
+.. code-block:: c
+
+ const struct auxiliary_device_id my_auxiliary_id_table[] = {
+ { .name = "foo_mod.foo_dev" },
+ { },
+ };
+
+ const struct my_ops my_custom_ops = {
+ .send = my_tx,
+ .receive = my_rx,
+ };
+
+ const struct my_driver my_drv = {
+ .auxiliary_drv = {
+ .name = "myauxiliarydrv",
+ .id_table = my_auxiliary_id_table,
+ .probe = my_probe,
+ .remove = my_remove,
+ .shutdown = my_shutdown,
+ },
+ .ops = my_custom_ops,
+ };
diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst
index f357f3eb400c..86759a74b7f1 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -72,6 +72,7 @@ available subsections can be seen below.
thermal/index
fpga/index
acpi/index
+ auxiliary_bus
backlight/lp855x-driver.rst
connector
console
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 8d7001712062..040be48ce046 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
menu "Generic Driver Options"
+config AUXILIARY_BUS
+ bool
+
config UEVENT_HELPER
bool "Support for uevent helper"
help
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 41369fc7004f..5e7bf9669a81 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -7,6 +7,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \
attribute_container.o transport_class.o \
topology.o container.o property.o cacheinfo.o \
swnode.o
+obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o
obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
obj-y += power/
obj-$(CONFIG_ISA_BUS_API) += isa.o
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
new file mode 100644
index 000000000000..ef2af417438b
--- /dev/null
+++ b/drivers/base/auxiliary.c
@@ -0,0 +1,268 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2019-2020 Intel Corporation
+ *
+ * Please see Documentation/driver-api/auxiliary_bus.rst for more information.
+ */
+
+#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
+
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
+#include <linux/string.h>
+#include <linux/auxiliary_bus.h>
+
+static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
+ const struct auxiliary_device *auxdev)
+{
+ for (; id->name[0]; id++) {
+ const char *p = strrchr(dev_name(&auxdev->dev), '.');
+ int match_size;
+
+ if (!p)
+ continue;
+ match_size = p - dev_name(&auxdev->dev);
+
+ /* use dev_name(&auxdev->dev) prefix before last '.' char to match to */
+ if (strlen(id->name) == match_size &&
+ !strncmp(dev_name(&auxdev->dev), id->name, match_size))
+ return id;
+ }
+ return NULL;
+}
+
+static int auxiliary_match(struct device *dev, struct device_driver *drv)
+{
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
+
+ return !!auxiliary_match_id(auxdrv->id_table, auxdev);
+}
+
+static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ const char *name, *p;
+
+ name = dev_name(dev);
+ p = strrchr(name, '.');
+
+ return add_uevent_var(env, "MODALIAS=%s%.*s", AUXILIARY_MODULE_PREFIX, (int)(p - name),
+ name);
+}
+
+static const struct dev_pm_ops auxiliary_dev_pm_ops = {
+ SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, pm_generic_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume)
+};
+
+static int auxiliary_bus_probe(struct device *dev)
+{
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ int ret;
+
+ ret = dev_pm_domain_attach(dev, true);
+ if (ret) {
+ dev_warn(dev, "Failed to attach to PM Domain : %d\n", ret);
+ return ret;
+ }
+
+ ret = auxdrv->probe(auxdev, auxiliary_match_id(auxdrv->id_table, auxdev));
+ if (ret)
+ dev_pm_domain_detach(dev, true);
+
+ return ret;
+}
+
+static int auxiliary_bus_remove(struct device *dev)
+{
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ int ret = 0;
+
+ if (auxdrv->remove)
+ ret = auxdrv->remove(auxdev);
+ dev_pm_domain_detach(dev, true);
+
+ return ret;
+}
+
+static void auxiliary_bus_shutdown(struct device *dev)
+{
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+
+ if (auxdrv->shutdown)
+ auxdrv->shutdown(auxdev);
+}
+
+static struct bus_type auxiliary_bus_type = {
+ .name = "auxiliary",
+ .probe = auxiliary_bus_probe,
+ .remove = auxiliary_bus_remove,
+ .shutdown = auxiliary_bus_shutdown,
+ .match = auxiliary_match,
+ .uevent = auxiliary_uevent,
+ .pm = &auxiliary_dev_pm_ops,
+};
+
+/**
+ * auxiliary_device_init - check auxiliary_device and initialize
+ * @auxdev: auxiliary device struct
+ *
+ * This is the first step in the two-step process to register an auxiliary_device.
+ *
+ * When this function returns an error code, then the device_initialize will *not* have
+ * been performed, and the caller will be responsible to free any memory allocated for the
+ * auxiliary_device in the error path directly.
+ *
+ * It returns 0 on success. On success, the device_initialize has been performed. After this
+ * point any error unwinding will need to include a call to auxiliary_device_uninit().
+ * In this post-initialize error scenario, a call to the device's .release callback will be
+ * triggered, and all memory clean-up is expected to be handled there.
+ */
+int auxiliary_device_init(struct auxiliary_device *auxdev)
+{
+ struct device *dev = &auxdev->dev;
+
+ if (!dev->parent) {
+ pr_err("auxiliary_device has a NULL dev->parent\n");
+ return -EINVAL;
+ }
+
+ if (!auxdev->name) {
+ pr_err("auxiliary_device has a NULL name\n");
+ return -EINVAL;
+ }
+
+ dev->bus = &auxiliary_bus_type;
+ device_initialize(&auxdev->dev);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(auxiliary_device_init);
+
+/**
+ * __auxiliary_device_add - add an auxiliary bus device
+ * @auxdev: auxiliary bus device to add to the bus
+ * @modname: name of the parent device's driver module
+ *
+ * This is the second step in the two-step process to register an auxiliary_device.
+ *
+ * This function must be called after a successful call to auxiliary_device_init(), which
+ * will perform the device_initialize. This means that if this returns an error code, then a
+ * call to auxiliary_device_uninit() must be performed so that the .release callback will
+ * be triggered to free the memory associated with the auxiliary_device.
+ *
+ * The expectation is that users will call the "auxiliary_device_add" macro so that the caller's
+ * KBUILD_MODNAME is automatically inserted for the modname parameter. Only if a user requires
+ * a custom name would this version be called directly.
+ */
+int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname)
+{
+ struct device *dev = &auxdev->dev;
+ int ret;
+
+ if (!modname) {
+ pr_err("auxiliary device modname is NULL\n");
+ return -EINVAL;
+ }
+
+ ret = dev_set_name(dev, "%s.%s.%d", modname, auxdev->name, auxdev->id);
+ if (ret) {
+ pr_err("auxiliary device dev_set_name failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = device_add(dev);
+ if (ret)
+ dev_err(dev, "adding auxiliary device failed!: %d\n", ret);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(__auxiliary_device_add);
+
+/**
+ * auxiliary_find_device - auxiliary device iterator for locating a particular device.
+ * @start: Device to begin with
+ * @data: Data to pass to match function
+ * @match: Callback function to check device
+ *
+ * This function returns a reference to a device that is 'found'
+ * for later use, as determined by the @match callback.
+ *
+ * The callback should return 0 if the device doesn't match and non-zero
+ * if it does. If the callback returns non-zero, this function will
+ * return to the caller and not iterate over any more devices.
+ */
+struct auxiliary_device *
+auxiliary_find_device(struct device *start, const void *data,
+ int (*match)(struct device *dev, const void *data))
+{
+ struct device *dev;
+
+ dev = bus_find_device(&auxiliary_bus_type, start, data, match);
+ if (!dev)
+ return NULL;
+
+ return to_auxiliary_dev(dev);
+}
+EXPORT_SYMBOL_GPL(auxiliary_find_device);
+
+/**
+ * __auxiliary_driver_register - register a driver for auxiliary bus devices
+ * @auxdrv: auxiliary_driver structure
+ * @owner: owning module/driver
+ * @modname: KBUILD_MODNAME for parent driver
+ */
+int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *owner,
+ const char *modname)
+{
+ if (WARN_ON(!auxdrv->probe) || WARN_ON(!auxdrv->id_table))
+ return -EINVAL;
+
+ if (auxdrv->name)
+ auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s.%s", modname, auxdrv->name);
+ else
+ auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s", modname);
+ if (!auxdrv->driver.name)
+ return -ENOMEM;
+
+ auxdrv->driver.owner = owner;
+ auxdrv->driver.bus = &auxiliary_bus_type;
+ auxdrv->driver.mod_name = modname;
+
+ return driver_register(&auxdrv->driver);
+}
+EXPORT_SYMBOL_GPL(__auxiliary_driver_register);
+
+/**
+ * auxiliary_driver_unregister - unregister a driver
+ * @auxdrv: auxiliary_driver structure
+ */
+void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
+{
+ driver_unregister(&auxdrv->driver);
+ kfree(auxdrv->driver.name);
+}
+EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
+
+static int __init auxiliary_bus_init(void)
+{
+ return bus_register(&auxiliary_bus_type);
+}
+
+static void __exit auxiliary_bus_exit(void)
+{
+ bus_unregister(&auxiliary_bus_type);
+}
+
+module_init(auxiliary_bus_init);
+module_exit(auxiliary_bus_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Auxiliary Bus");
+MODULE_AUTHOR("David Ertman <david.m.ertman@intel.com>");
+MODULE_AUTHOR("Kiran Patil <kiran.patil@intel.com>");
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
new file mode 100644
index 000000000000..282fbf7bf9af
--- /dev/null
+++ b/include/linux/auxiliary_bus.h
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2019-2020 Intel Corporation
+ *
+ * Please see Documentation/driver-api/auxiliary_bus.rst for more information.
+ */
+
+#ifndef _AUXILIARY_BUS_H_
+#define _AUXILIARY_BUS_H_
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+#include <linux/slab.h>
+
+struct auxiliary_device {
+ struct device dev;
+ const char *name;
+ u32 id;
+};
+
+struct auxiliary_driver {
+ int (*probe)(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id);
+ int (*remove)(struct auxiliary_device *auxdev);
+ void (*shutdown)(struct auxiliary_device *auxdev);
+ int (*suspend)(struct auxiliary_device *auxdev, pm_message_t state);
+ int (*resume)(struct auxiliary_device *auxdev);
+ const char *name;
+ struct device_driver driver;
+ const struct auxiliary_device_id *id_table;
+};
+
+static inline struct auxiliary_device *to_auxiliary_dev(struct device *dev)
+{
+ return container_of(dev, struct auxiliary_device, dev);
+}
+
+static inline struct auxiliary_driver *to_auxiliary_drv(struct device_driver *drv)
+{
+ return container_of(drv, struct auxiliary_driver, driver);
+}
+
+int auxiliary_device_init(struct auxiliary_device *auxdev);
+int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname);
+#define auxiliary_device_add(auxdev) __auxiliary_device_add(auxdev, KBUILD_MODNAME)
+
+static inline void auxiliary_device_uninit(struct auxiliary_device *auxdev)
+{
+ put_device(&auxdev->dev);
+}
+
+static inline void auxiliary_device_delete(struct auxiliary_device *auxdev)
+{
+ device_del(&auxdev->dev);
+}
+
+int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *owner,
+ const char *modname);
+#define auxiliary_driver_register(auxdrv) \
+ __auxiliary_driver_register(auxdrv, THIS_MODULE, KBUILD_MODNAME)
+
+void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
+
+/**
+ * module_auxiliary_driver() - Helper macro for registering an auxiliary driver
+ * @__auxiliary_driver: auxiliary driver struct
+ *
+ * Helper macro for auxiliary drivers which do not do anything special in
+ * module init/exit. This eliminates a lot of boilerplate. Each module may only
+ * use this macro once, and calling it replaces module_init() and module_exit()
+ */
+#define module_auxiliary_driver(__auxiliary_driver) \
+ module_driver(__auxiliary_driver, auxiliary_driver_register, auxiliary_driver_unregister)
+
+struct auxiliary_device *
+auxiliary_find_device(struct device *start, const void *data,
+ int (*match)(struct device *dev, const void *data));
+
+#endif /* _AUXILIARY_BUS_H_ */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 5b08a473cdba..c425290b21e2 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -838,4 +838,12 @@ struct mhi_device_id {
kernel_ulong_t driver_data;
};
+#define AUXILIARY_NAME_SIZE 32
+#define AUXILIARY_MODULE_PREFIX "auxiliary:"
+
+struct auxiliary_device_id {
+ char name[AUXILIARY_NAME_SIZE];
+ kernel_ulong_t driver_data;
+};
+
#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index 27007c18e754..e377f52dbfa3 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -243,5 +243,8 @@ int main(void)
DEVID(mhi_device_id);
DEVID_FIELD(mhi_device_id, chan);
+ DEVID(auxiliary_device_id);
+ DEVID_FIELD(auxiliary_device_id, name);
+
return 0;
}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 2417dd1dee33..fb4827027536 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1364,6 +1364,13 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias)
{
DEF_FIELD_ADDR(symval, mhi_device_id, chan);
sprintf(alias, MHI_DEVICE_MODALIAS_FMT, *chan);
+ return 1;
+}
+
+static int do_auxiliary_entry(const char *filename, void *symval, char *alias)
+{
+ DEF_FIELD_ADDR(symval, auxiliary_device_id, name);
+ sprintf(alias, AUXILIARY_MODULE_PREFIX "%s", *name);
return 1;
}
@@ -1442,6 +1449,7 @@ static const struct devtable devtable[] = {
{"tee", SIZE_tee_client_device_id, do_tee_entry},
{"wmi", SIZE_wmi_device_id, do_wmi_entry},
{"mhi", SIZE_mhi_device_id, do_mhi_entry},
+ {"auxiliary", SIZE_auxiliary_device_id, do_auxiliary_entry},
};
/* Create MODULE_ALIAS() statements.
--
2.29.2

View File

@ -1,54 +0,0 @@
From e691ecf482fc75f7ed09aac3fa58436b56d5393b Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 4 Dec 2020 12:43:47 +0100
Subject: [PATCH] driver core: auxiliary bus: move slab.h from include file
No need to include slab.h in include/linux/auxiliary_bus.h, as it is not
needed there. Move it to drivers/base/auxiliary.c instead.
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8og8xi3WkoYXet9@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7bbb79ff5f7499e0c5d65987458410e8099207d8)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 1 +
include/linux/auxiliary_bus.h | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index ef2af417438b..eca36d6284d0 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -9,6 +9,7 @@
#include <linux/device.h>
#include <linux/init.h>
+#include <linux/slab.h>
#include <linux/module.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index 282fbf7bf9af..3580743d0e8d 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -10,7 +10,6 @@
#include <linux/device.h>
#include <linux/mod_devicetable.h>
-#include <linux/slab.h>
struct auxiliary_device {
struct device dev;
--
2.29.2

View File

@ -1,79 +0,0 @@
From 3dd9d97b9329c10548b0376307bdda8e23310fa9 Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 4 Dec 2020 12:44:07 +0100
Subject: [PATCH] driver core: auxiliary bus: make remove function return void
There's an effort to move the remove() callback in the driver core to
not return an int, as nothing can be done if this function fails. To
make that effort easier, make the aux bus remove function void to start
with so that no users have to be changed sometime in the future.
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8ohB1ks1NK7kPop@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8142a46c50d2dd8160c42284e1044eed3bec0d18)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
Documentation/driver-api/auxiliary_bus.rst | 2 +-
drivers/base/auxiliary.c | 5 ++---
include/linux/auxiliary_bus.h | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Documentation/driver-api/auxiliary_bus.rst b/Documentation/driver-api/auxiliary_bus.rst
index 5dd7804631ef..2312506b0674 100644
--- a/Documentation/driver-api/auxiliary_bus.rst
+++ b/Documentation/driver-api/auxiliary_bus.rst
@@ -150,7 +150,7 @@ and shutdown notifications using the standard conventions.
struct auxiliary_driver {
int (*probe)(struct auxiliary_device *,
const struct auxiliary_device_id *id);
- int (*remove)(struct auxiliary_device *);
+ void (*remove)(struct auxiliary_device *);
void (*shutdown)(struct auxiliary_device *);
int (*suspend)(struct auxiliary_device *, pm_message_t);
int (*resume)(struct auxiliary_device *);
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index eca36d6284d0..c44e85802b43 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -82,13 +82,12 @@ static int auxiliary_bus_remove(struct device *dev)
{
struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
- int ret = 0;
if (auxdrv->remove)
- ret = auxdrv->remove(auxdev);
+ auxdrv->remove(auxdev);
dev_pm_domain_detach(dev, true);
- return ret;
+ return 0;
}
static void auxiliary_bus_shutdown(struct device *dev)
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index 3580743d0e8d..d67b17606210 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -19,7 +19,7 @@ struct auxiliary_device {
struct auxiliary_driver {
int (*probe)(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id);
- int (*remove)(struct auxiliary_device *auxdev);
+ void (*remove)(struct auxiliary_device *auxdev);
void (*shutdown)(struct auxiliary_device *auxdev);
int (*suspend)(struct auxiliary_device *auxdev, pm_message_t state);
int (*resume)(struct auxiliary_device *auxdev);
--
2.29.2

View File

@ -1,166 +0,0 @@
From 140f2cd50e9a10afcf10e76719d2810c6f8354a2 Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 4 Dec 2020 12:49:28 +0100
Subject: [PATCH] driver core: auxiliary bus: minor coding style tweaks
For some reason, the original aux bus patch had some really long lines
in a few places, probably due to it being a very long-lived patch in
development by many different people. Fix that up so that the two files
all have the same length lines and function formatting styles.
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8oiSFTpYHw1xE/o@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 0d2bf11a6b3e275a526b8d42d8d4a3a6067cf953)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 58 +++++++++++++++++++----------------
include/linux/auxiliary_bus.h | 6 ++--
2 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index c44e85802b43..f303daadf843 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -50,8 +50,8 @@ static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env *env)
name = dev_name(dev);
p = strrchr(name, '.');
- return add_uevent_var(env, "MODALIAS=%s%.*s", AUXILIARY_MODULE_PREFIX, (int)(p - name),
- name);
+ return add_uevent_var(env, "MODALIAS=%s%.*s", AUXILIARY_MODULE_PREFIX,
+ (int)(p - name), name);
}
static const struct dev_pm_ops auxiliary_dev_pm_ops = {
@@ -113,16 +113,18 @@ static struct bus_type auxiliary_bus_type = {
* auxiliary_device_init - check auxiliary_device and initialize
* @auxdev: auxiliary device struct
*
- * This is the first step in the two-step process to register an auxiliary_device.
+ * This is the first step in the two-step process to register an
+ * auxiliary_device.
*
- * When this function returns an error code, then the device_initialize will *not* have
- * been performed, and the caller will be responsible to free any memory allocated for the
- * auxiliary_device in the error path directly.
+ * When this function returns an error code, then the device_initialize will
+ * *not* have been performed, and the caller will be responsible to free any
+ * memory allocated for the auxiliary_device in the error path directly.
*
- * It returns 0 on success. On success, the device_initialize has been performed. After this
- * point any error unwinding will need to include a call to auxiliary_device_uninit().
- * In this post-initialize error scenario, a call to the device's .release callback will be
- * triggered, and all memory clean-up is expected to be handled there.
+ * It returns 0 on success. On success, the device_initialize has been
+ * performed. After this point any error unwinding will need to include a call
+ * to auxiliary_device_uninit(). In this post-initialize error scenario, a call
+ * to the device's .release callback will be triggered, and all memory clean-up
+ * is expected to be handled there.
*/
int auxiliary_device_init(struct auxiliary_device *auxdev)
{
@@ -149,16 +151,19 @@ EXPORT_SYMBOL_GPL(auxiliary_device_init);
* @auxdev: auxiliary bus device to add to the bus
* @modname: name of the parent device's driver module
*
- * This is the second step in the two-step process to register an auxiliary_device.
+ * This is the second step in the two-step process to register an
+ * auxiliary_device.
*
- * This function must be called after a successful call to auxiliary_device_init(), which
- * will perform the device_initialize. This means that if this returns an error code, then a
- * call to auxiliary_device_uninit() must be performed so that the .release callback will
- * be triggered to free the memory associated with the auxiliary_device.
+ * This function must be called after a successful call to
+ * auxiliary_device_init(), which will perform the device_initialize. This
+ * means that if this returns an error code, then a call to
+ * auxiliary_device_uninit() must be performed so that the .release callback
+ * will be triggered to free the memory associated with the auxiliary_device.
*
- * The expectation is that users will call the "auxiliary_device_add" macro so that the caller's
- * KBUILD_MODNAME is automatically inserted for the modname parameter. Only if a user requires
- * a custom name would this version be called directly.
+ * The expectation is that users will call the "auxiliary_device_add" macro so
+ * that the caller's KBUILD_MODNAME is automatically inserted for the modname
+ * parameter. Only if a user requires a custom name would this version be
+ * called directly.
*/
int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname)
{
@@ -166,13 +171,13 @@ int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname)
int ret;
if (!modname) {
- pr_err("auxiliary device modname is NULL\n");
+ dev_err(dev, "auxiliary device modname is NULL\n");
return -EINVAL;
}
ret = dev_set_name(dev, "%s.%s.%d", modname, auxdev->name, auxdev->id);
if (ret) {
- pr_err("auxiliary device dev_set_name failed: %d\n", ret);
+ dev_err(dev, "auxiliary device dev_set_name failed: %d\n", ret);
return ret;
}
@@ -197,9 +202,9 @@ EXPORT_SYMBOL_GPL(__auxiliary_device_add);
* if it does. If the callback returns non-zero, this function will
* return to the caller and not iterate over any more devices.
*/
-struct auxiliary_device *
-auxiliary_find_device(struct device *start, const void *data,
- int (*match)(struct device *dev, const void *data))
+struct auxiliary_device *auxiliary_find_device(struct device *start,
+ const void *data,
+ int (*match)(struct device *dev, const void *data))
{
struct device *dev;
@@ -217,14 +222,15 @@ EXPORT_SYMBOL_GPL(auxiliary_find_device);
* @owner: owning module/driver
* @modname: KBUILD_MODNAME for parent driver
*/
-int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *owner,
- const char *modname)
+int __auxiliary_driver_register(struct auxiliary_driver *auxdrv,
+ struct module *owner, const char *modname)
{
if (WARN_ON(!auxdrv->probe) || WARN_ON(!auxdrv->id_table))
return -EINVAL;
if (auxdrv->name)
- auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s.%s", modname, auxdrv->name);
+ auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s.%s", modname,
+ auxdrv->name);
else
auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s", modname);
if (!auxdrv->driver.name)
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index d67b17606210..fc51d45f106b 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -70,8 +70,8 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
#define module_auxiliary_driver(__auxiliary_driver) \
module_driver(__auxiliary_driver, auxiliary_driver_register, auxiliary_driver_unregister)
-struct auxiliary_device *
-auxiliary_find_device(struct device *start, const void *data,
- int (*match)(struct device *dev, const void *data));
+struct auxiliary_device *auxiliary_find_device(struct device *start,
+ const void *data,
+ int (*match)(struct device *dev, const void *data));
#endif /* _AUXILIARY_BUS_H_ */
--
2.29.2

View File

@ -1,49 +0,0 @@
From fb056562367fc8e65b4b7c7a2e0fabf4543c3533 Mon Sep 17 00:00:00 2001
From: Dave Jiang <dave.jiang@intel.com>
Date: Fri, 4 Dec 2020 09:46:49 -0700
Subject: [PATCH] driver core: auxiliary bus: Fix auxiliary bus shutdown null
auxdrv ptr
If the probe of the auxdrv failed, the device->driver is set to NULL.
During kernel shutdown, the bus shutdown will call auxdrv->shutdown and
cause an invalid ptr dereference. Add check to make sure device->driver is
not NULL before we proceed.
Fixes: 7de3697e9cbd ("Add auxiliary bus support")
Cc: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/160710040926.1889434.8840329810698403478.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 784b2c48ac12dcee27db001fb1a3c58c39380cb6)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index f303daadf843..8336535f1e11 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -92,10 +92,15 @@ static int auxiliary_bus_remove(struct device *dev)
static void auxiliary_bus_shutdown(struct device *dev)
{
- struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
- struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ struct auxiliary_driver *auxdrv = NULL;
+ struct auxiliary_device *auxdev;
+
+ if (dev->driver) {
+ auxdrv = to_auxiliary_drv(dev->driver);
+ auxdev = to_auxiliary_dev(dev);
+ }
- if (auxdrv->shutdown)
+ if (auxdrv && auxdrv->shutdown)
auxdrv->shutdown(auxdev);
}
--
2.29.2

View File

@ -1,146 +0,0 @@
From 4e403070ed6ea6de90ef8e645dec23751018f504 Mon Sep 17 00:00:00 2001
From: Dave Jiang <dave.jiang@intel.com>
Date: Wed, 10 Feb 2021 13:16:11 -0700
Subject: [PATCH] driver core: auxiliary bus: Fix calling stage for auxiliary
bus init
When the auxiliary device code is built into the kernel, it can be executed
before the auxiliary bus is registered. This causes bus->p to be not
allocated and triggers a NULL pointer dereference when the auxiliary bus
device gets added with bus_add_device(). Call the auxiliary_bus_init()
under driver_init() so the bus is initialized before devices.
Below is the kernel splat for the bug:
[ 1.948215] BUG: kernel NULL pointer dereference, address: 0000000000000060
[ 1.950670] #PF: supervisor read access in kernel mode
[ 1.950670] #PF: error_code(0x0000) - not-present page
[ 1.950670] PGD 0
[ 1.950670] Oops: 0000 1 SMP NOPTI
[ 1.950670] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0-intel-nextsvmtest+ #2205
[ 1.950670] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[ 1.950670] RIP: 0010:bus_add_device+0x64/0x140
[ 1.950670] Code: 00 49 8b 75 20 48 89 df e8 59 a1 ff ff 41 89 c4 85 c0 75 7b 48 8b 53 50 48 85 d2 75 03 48 8b 13 49 8b 85 a0 00 00 00 48 89 de <48> 8
78 60 48 83 c7 18 e8 ef d9 a9 ff 41 89 c4 85 c0 75 45 48 8b
[ 1.950670] RSP: 0000:ff46032ac001baf8 EFLAGS: 00010246
[ 1.950670] RAX: 0000000000000000 RBX: ff4597f7414aa680 RCX: 0000000000000000
[ 1.950670] RDX: ff4597f74142bbc0 RSI: ff4597f7414aa680 RDI: ff4597f7414aa680
[ 1.950670] RBP: ff46032ac001bb10 R08: 0000000000000044 R09: 0000000000000228
[ 1.950670] R10: ff4597f741141b30 R11: ff4597f740182a90 R12: 0000000000000000
[ 1.950670] R13: ffffffffa5e936c0 R14: 0000000000000000 R15: 0000000000000000
[ 1.950670] FS: 0000000000000000(0000) GS:ff4597f7bba00000(0000) knlGS:0000000000000000
[ 1.950670] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1.950670] CR2: 0000000000000060 CR3: 000000002140c001 CR4: 0000000000f71ef0
[ 1.950670] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1.950670] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
[ 1.950670] PKRU: 55555554
[ 1.950670] Call Trace:
[ 1.950670] device_add+0x3ee/0x850
[ 1.950670] __auxiliary_device_add+0x47/0x60
[ 1.950670] idxd_pci_probe+0xf77/0x1180
[ 1.950670] local_pci_probe+0x4a/0x90
[ 1.950670] pci_device_probe+0xff/0x1b0
[ 1.950670] really_probe+0x1cf/0x440
[ 1.950670] ? rdinit_setup+0x31/0x31
[ 1.950670] driver_probe_device+0xe8/0x150
[ 1.950670] device_driver_attach+0x58/0x60
[ 1.950670] __driver_attach+0x8f/0x150
[ 1.950670] ? device_driver_attach+0x60/0x60
[ 1.950670] ? device_driver_attach+0x60/0x60
[ 1.950670] bus_for_each_dev+0x79/0xc0
[ 1.950670] ? kmem_cache_alloc_trace+0x323/0x430
[ 1.950670] driver_attach+0x1e/0x20
[ 1.950670] bus_add_driver+0x154/0x1f0
[ 1.950670] driver_register+0x70/0xc0
[ 1.950670] __pci_register_driver+0x54/0x60
[ 1.950670] idxd_init_module+0xe2/0xfc
[ 1.950670] ? idma64_platform_driver_init+0x19/0x19
[ 1.950670] do_one_initcall+0x4a/0x1e0
[ 1.950670] kernel_init_freeable+0x1fc/0x25c
[ 1.950670] ? rest_init+0xba/0xba
[ 1.950670] kernel_init+0xe/0x116
[ 1.950670] ret_from_fork+0x1f/0x30
[ 1.950670] Modules linked in:
[ 1.950670] CR2: 0000000000000060
[ 1.950670] --[ end trace cd7d1b226d3ca901 ]--
Fixes: 7de3697e9cbd ("Add auxiliary bus support")
Reported-by: Jacob Pan <jacob.jun.pan@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20210210201611.1611074-1-dave.jiang@intel.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 471b12c43f376d5203dbff0e91316eea11f6f4df)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 13 +++----------
drivers/base/base.h | 5 +++++
drivers/base/init.c | 1 +
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index 8336535f1e11..d8b314e7d0fd 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -15,6 +15,7 @@
#include <linux/pm_runtime.h>
#include <linux/string.h>
#include <linux/auxiliary_bus.h>
+#include "base.h"
static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
const struct auxiliary_device *auxdev)
@@ -260,19 +261,11 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
}
EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
-static int __init auxiliary_bus_init(void)
+void __init auxiliary_bus_init(void)
{
- return bus_register(&auxiliary_bus_type);
+ WARN_ON(bus_register(&auxiliary_bus_type));
}
-static void __exit auxiliary_bus_exit(void)
-{
- bus_unregister(&auxiliary_bus_type);
-}
-
-module_init(auxiliary_bus_init);
-module_exit(auxiliary_bus_exit);
-
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Auxiliary Bus");
MODULE_AUTHOR("David Ertman <david.m.ertman@intel.com>");
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 91cfb8405abd..7d97447460fa 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -119,6 +119,11 @@ static inline int hypervisor_init(void) { return 0; }
extern int platform_bus_init(void);
extern void cpu_dev_init(void);
extern void container_dev_init(void);
+#ifdef CONFIG_AUXILIARY_BUS
+extern void auxiliary_bus_init(void);
+#else
+static inline void auxiliary_bus_init(void) { }
+#endif
struct kobject *virtual_device_parent(struct device *dev);
diff --git a/drivers/base/init.c b/drivers/base/init.c
index 908e6520e804..a9f57c22fb9e 100644
--- a/drivers/base/init.c
+++ b/drivers/base/init.c
@@ -32,6 +32,7 @@ void __init driver_init(void)
*/
of_core_init();
platform_bus_init();
+ auxiliary_bus_init();
cpu_dev_init();
memory_dev_init();
container_dev_init();
--
2.29.2

View File

@ -1,35 +0,0 @@
From 7739d61db7ae6d01e06f8fbc0feb089cebe84ebe Mon Sep 17 00:00:00 2001
From: Dave Jiang <dave.jiang@intel.com>
Date: Thu, 11 Feb 2021 13:21:29 -0700
Subject: [PATCH] driver core: auxiliary bus: Remove unneeded module bits
Remove module bits in the auxiliary bus code since the auxiliary bus
cannot be built as a module and the relevant code is not needed.
Cc: Dave Ertman <david.m.ertman@intel.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/161307488980.1896017.15627190714413338196.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit bbf44abeeabfe05a124535e6c3a9fd7d682d42bf)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index d8b314e7d0fd..adc199dfba3c 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -265,8 +265,3 @@ void __init auxiliary_bus_init(void)
{
WARN_ON(bus_register(&auxiliary_bus_type));
}
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Auxiliary Bus");
-MODULE_AUTHOR("David Ertman <david.m.ertman@intel.com>");
-MODULE_AUTHOR("Kiran Patil <kiran.patil@intel.com>");
--
2.29.2

View File

@ -1,51 +0,0 @@
From e4a05ae5a0d7fdaf8cfe7080640ce4a6057277c4 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Date: Tue, 13 Jul 2021 12:34:38 +0300
Subject: [PATCH] driver core: auxiliary bus: Fix memory leak when
driver_register() fail
If driver_register() returns with error we need to free the memory
allocated for auxdrv->driver.name before returning from
__auxiliary_driver_register()
Fixes: 7de3697e9cbd4 ("Add auxiliary bus support")
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20210713093438.3173-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 4afa0c22eed33cfe0c590742387f0d16f32412f3)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index adc199dfba3c..6a30264ab2ba 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -231,6 +231,8 @@ EXPORT_SYMBOL_GPL(auxiliary_find_device);
int __auxiliary_driver_register(struct auxiliary_driver *auxdrv,
struct module *owner, const char *modname)
{
+ int ret;
+
if (WARN_ON(!auxdrv->probe) || WARN_ON(!auxdrv->id_table))
return -EINVAL;
@@ -246,7 +248,11 @@ int __auxiliary_driver_register(struct auxiliary_driver *auxdrv,
auxdrv->driver.bus = &auxiliary_bus_type;
auxdrv->driver.mod_name = modname;
- return driver_register(&auxdrv->driver);
+ ret = driver_register(&auxdrv->driver);
+ if (ret)
+ kfree(auxdrv->driver.name);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(__auxiliary_driver_register);
--
2.29.2

View File

@ -1,38 +0,0 @@
From ccf9728c267d16dedb1b5d0ecd4518cac435fd02 Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Thu, 17 Feb 2022 14:17:58 -0500
Subject: [PATCH] driver core: auxiliary bus: Enable by default
This commit enables CONFIG_AUXILIARY_BUS by default. This is necessary,
because StarlingX does not enable any kernel modules that 'select'
CONFIG_AUXILIARY_BUS, which causes the kernel's build system to
automatically disable this option.
However, StarlingX has out-of-tree users of this functionality (such as
the 'ice' and 'mlnx-ofa_kernel' out-of-tree kernel driver packages),
hence the need for this change. Prior to this commit, the aforementioned
out-of-tree kernel drivers would use their embedded/bundled copy of the
same functionality, which would cause kernel symbol conflicts at
run-time when users attempted to load both ice and mlnx-ofa_kernel
drivers.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 040be48ce046..a18ec49b9dac 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -3,6 +3,7 @@ menu "Generic Driver Options"
config AUXILIARY_BUS
bool
+ default y
config UEVENT_HELPER
bool "Support for uevent helper"
--
2.29.2

View File

@ -1,36 +0,0 @@
From e469e34954dc8eb27b0f2fe521e18ac2e03dad61 Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Thu, 3 Feb 2022 21:34:14 -0500
Subject: [PATCH] Enable CONFIG_PAGE_POOL by default
CONFIG_PAGE_POOL is a "hidden" configuration option, which causes it to
be enabled only when another kernel configuration option explicitly
selects it. Specifying CONFIG_PAGE_POOL=y in .config does not have any
effect.
Given that StarlingX disables all in-tree device drivers that explicitly
select CONFIG_PAGE_POOL, and given that at least one out-of-tree kernel
module (mlnx-ofa_kernel) requires the features made available by
CONFIG_PAGE_POOL, this commit enables the configuration option in
question by default.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
net/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/Kconfig b/net/Kconfig
index 05b0f041f039..62443980ba6b 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -437,6 +437,7 @@ config NET_DEVLINK
config PAGE_POOL
bool
+ default y
config FAILOVER
tristate "Generic failover module"
--
2.29.2

View File

@ -1,60 +0,0 @@
From b1d119de793160cd63748316025b68b1b2d50f31 Mon Sep 17 00:00:00 2001
From: Kyung Min Park <kyung.min.park@intel.com>
Date: Mon, 7 Dec 2020 19:34:40 -0800
Subject: [PATCH] x86: Enumerate AVX512 FP16 CPUID feature flag
Enumerate AVX512 Half-precision floating point (FP16) CPUID feature
flag. Compared with using FP32, using FP16 cut the number of bits
required for storage in half, reducing the exponent from 8 bits to 5,
and the mantissa from 23 bits to 10. Using FP16 also enables developers
to train and run inference on deep learning models fast when all
precision or magnitude (FP32) is not needed.
A processor supports AVX512 FP16 if CPUID.(EAX=7,ECX=0):EDX[bit 23]
is present. The AVX512 FP16 requires AVX512BW feature be implemented
since the instructions for manipulating 32bit masks are associated with
AVX512BW.
The only in-kernel usage of this is kvm passthrough. The CPU feature
flag is shown as "avx512_fp16" in /proc/cpuinfo.
Signed-off-by: Kyung Min Park <kyung.min.park@intel.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Message-Id: <20201208033441.28207-2-kyung.min.park@intel.com>
Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit e1b35da5e624f8b09d2e98845c2e4c84b179d9a4)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/kernel/cpu/cpuid-deps.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 3b407f46f1a0..b5252fd26682 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -374,6 +374,7 @@
#define X86_FEATURE_TSXLDTRK (18*32+16) /* TSX Suspend Load Address Tracking */
#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
#define X86_FEATURE_ARCH_LBR (18*32+19) /* Intel ARCH LBR */
+#define X86_FEATURE_AVX512_FP16 (18*32+23) /* AVX512 FP16 */
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
#define X86_FEATURE_FLUSH_L1D (18*32+28) /* Flush L1D cache */
diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index d502241995a3..42af31b64c2c 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -69,6 +69,7 @@ static const struct cpuid_dep cpuid_deps[] = {
{ X86_FEATURE_CQM_MBM_TOTAL, X86_FEATURE_CQM_LLC },
{ X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC },
{ X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL },
+ { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW },
{ X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES },
{ X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA },
{}
--
2.29.2

View File

@ -1,41 +0,0 @@
From 5b18cff344fcd6906469a2849eff4ba71f42c436 Mon Sep 17 00:00:00 2001
From: Cathy Zhang <cathy.zhang@intel.com>
Date: Mon, 7 Dec 2020 19:34:41 -0800
Subject: [PATCH] KVM: x86: Expose AVX512_FP16 for supported CPUID
AVX512_FP16 is supported by Intel processors, like Sapphire Rapids.
It could gain better performance for it's faster compared to FP32
if the precision or magnitude requirements are met. It's availability
is indicated by CPUID.(EAX=7,ECX=0):EDX[bit 23].
Expose it in KVM supported CPUID, then guest could make use of it; no
new registers are used, only new instructions.
Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
Signed-off-by: Kyung Min Park <kyung.min.park@intel.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Message-Id: <20201208033441.28207-3-kyung.min.park@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 2224fc9efb2d6593fbfb57287e39ba4958b188ba)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
arch/x86/kvm/cpuid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 41b0dc37720e..61f10169fc16 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -418,7 +418,7 @@ void kvm_set_cpu_caps(void)
F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP) |
F(MD_CLEAR) | F(AVX512_VP2INTERSECT) | F(FSRM) |
- F(SERIALIZE) | F(TSXLDTRK)
+ F(SERIALIZE) | F(TSXLDTRK) | F(AVX512_FP16)
);
/* TSC_ADJUST and ARCH_CAPABILITIES are emulated in software. */
--
2.29.2

View File

@ -1,51 +0,0 @@
From 766051cc00679d0451710b8837750bb4a6b73f42 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Mon, 21 Dec 2020 09:04:54 -0300
Subject: [PATCH] tools headers cpufeatures: Sync with the kernel sources
To pick the changes in:
69372cf01290b958 ("x86/cpu: Add VM page flush MSR availablility as a CPUID feature")
e1b35da5e624f8b0 ("x86: Enumerate AVX512 FP16 CPUID feature flag")
That causes only these 'perf bench' objects to rebuild:
CC /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
CC /tmp/build/perf/bench/mem-memset-x86-64-asm.o
And addresses these perf build warnings:
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kyung Min Park <kyung.min.park@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
(cherry picked from commit 7f3905f00a2025591a6883ee6880f928029b4d96)
[mvb: Remove X86_FEATURE_VM_PAGE_FLUSH from this commit as that CPU
feature constant is not provided by StarlingX's v5.10 baseline.]
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
tools/arch/x86/include/asm/cpufeatures.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index b58730cc12e8..d7accc927691 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -374,6 +374,7 @@
#define X86_FEATURE_TSXLDTRK (18*32+16) /* TSX Suspend Load Address Tracking */
#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
#define X86_FEATURE_ARCH_LBR (18*32+19) /* Intel ARCH LBR */
+#define X86_FEATURE_AVX512_FP16 (18*32+23) /* AVX512 FP16 */
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
#define X86_FEATURE_FLUSH_L1D (18*32+28) /* Flush L1D cache */
--
2.29.2

View File

@ -1,39 +0,0 @@
From 547921028c785f90e52adb7f54cc2f13103934de Mon Sep 17 00:00:00 2001
Message-Id: <547921028c785f90e52adb7f54cc2f13103934de.1665174246.git.jim.somerville@windriver.com>
From: Zqiang <qiang.zhang1211@gmail.com>
Date: Mon, 15 Nov 2021 13:15:46 +0800
Subject: [PATCH] rcu: Avoid running boost kthreads on isolated CPUs
When the boost kthreads are created on systems with nohz_full CPUs,
the cpus_allowed_ptr is set to housekeeping_cpumask(HK_FLAG_KTHREAD).
However, when the rcu_boost_kthread_setaffinity() is called, the original
affinity will be changed and these kthreads can subsequently run on
nohz_full CPUs. This commit makes rcu_boost_kthread_setaffinity()
restrict these boost kthreads to housekeeping CPUs.
Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
[ commit c2cf0767e98eb4487444e5c7ebba491a866811ce upstream ]
Signed-off-by: Jim Somerville <jim.somerville@windriver.com>
---
kernel/rcu/tree_plugin.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 9db906dcbdac..0a18fa5d27b3 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1185,8 +1185,9 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
if ((mask & leaf_node_cpu_bit(rnp, cpu)) &&
cpu != outgoingcpu)
cpumask_set_cpu(cpu, cm);
+ cpumask_and(cm, cm, housekeeping_cpumask(HK_FLAG_RCU));
if (cpumask_weight(cm) == 0)
- cpumask_setall(cm);
+ cpumask_copy(cm, housekeeping_cpumask(HK_FLAG_RCU));
set_cpus_allowed_ptr(t, cm);
free_cpumask_var(cm);
}
--
2.25.1

View File

@ -1,269 +0,0 @@
From aebe2063884ef5e8a969d73d75e1086ea67d8033 Mon Sep 17 00:00:00 2001
From: Dave Chinner <dchinner@redhat.com>
Date: Sun, 3 Jul 2022 08:04:50 +0300
Subject: [PATCH 1/5] xfs: use current->journal_info for detecting transaction
recursion
commit 756b1c343333a5aefcc26b0409f3fd16f72281bf upstream.
Because the iomap code using PF_MEMALLOC_NOFS to detect transaction
recursion in XFS is just wrong. Remove it from the iomap code and
replace it with XFS specific internal checks using
current->journal_info instead.
[djwong: This change also realigns the lifetime of NOFS flag changes to
match the incore transaction, instead of the inconsistent scheme we have
now.]
Fixes: 9070733b4efa ("xfs: abstract PF_FSTRANS to PF_MEMALLOC_NOFS")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[commit b261cd005ab980c4018634a849f77e036bfd4f80 from
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
linux-5.10.y branch]
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
fs/iomap/buffered-io.c | 7 -------
fs/xfs/libxfs/xfs_btree.c | 12 ++++++++++--
fs/xfs/xfs_aops.c | 17 +++++++++++++++--
fs/xfs/xfs_trans.c | 20 +++++---------------
fs/xfs/xfs_trans.h | 30 ++++++++++++++++++++++++++++++
5 files changed, 60 insertions(+), 26 deletions(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index cd9f7baa5..47279fe00 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1459,13 +1459,6 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
PF_MEMALLOC))
goto redirty;
- /*
- * Given that we do not allow direct reclaim to call us, we should
- * never be called in a recursive filesystem reclaim context.
- */
- if (WARN_ON_ONCE(current->flags & PF_MEMALLOC_NOFS))
- goto redirty;
-
/*
* Is this page beyond the end of the file?
*
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 2d25bab68..fe87ecd76 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -2814,7 +2814,7 @@ xfs_btree_split_worker(
struct xfs_btree_split_args *args = container_of(work,
struct xfs_btree_split_args, work);
unsigned long pflags;
- unsigned long new_pflags = PF_MEMALLOC_NOFS;
+ unsigned long new_pflags = 0;
/*
* we are in a transaction context here, but may also be doing work
@@ -2826,12 +2826,20 @@ xfs_btree_split_worker(
new_pflags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD;
current_set_flags_nested(&pflags, new_pflags);
+ xfs_trans_set_context(args->cur->bc_tp);
args->result = __xfs_btree_split(args->cur, args->level, args->ptrp,
args->key, args->curp, args->stat);
- complete(args->done);
+ xfs_trans_clear_context(args->cur->bc_tp);
current_restore_flags_nested(&pflags, new_pflags);
+
+ /*
+ * Do not access args after complete() has run here. We don't own args
+ * and the owner may run and free args before we return here.
+ */
+ complete(args->done);
+
}
/*
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 4304c6416..b4186d666 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -62,7 +62,7 @@ xfs_setfilesize_trans_alloc(
* We hand off the transaction to the completion thread now, so
* clear the flag here.
*/
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+ xfs_trans_clear_context(tp);
return 0;
}
@@ -125,7 +125,7 @@ xfs_setfilesize_ioend(
* thus we need to mark ourselves as being in a transaction manually.
* Similarly for freeze protection.
*/
- current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+ xfs_trans_set_context(tp);
__sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS);
/* we abort the update if there was an IO error */
@@ -568,6 +568,12 @@ xfs_vm_writepage(
{
struct xfs_writepage_ctx wpc = { };
+ if (WARN_ON_ONCE(current->journal_info)) {
+ redirty_page_for_writepage(wbc, page);
+ unlock_page(page);
+ return 0;
+ }
+
return iomap_writepage(page, wbc, &wpc.ctx, &xfs_writeback_ops);
}
@@ -578,6 +584,13 @@ xfs_vm_writepages(
{
struct xfs_writepage_ctx wpc = { };
+ /*
+ * Writing back data in a transaction context can result in recursive
+ * transactions. This is bad, so issue a warning and get out of here.
+ */
+ if (WARN_ON_ONCE(current->journal_info))
+ return 0;
+
xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED);
return iomap_writepages(mapping, wbc, &wpc.ctx, &xfs_writeback_ops);
}
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index c94e71f74..2d7deacea 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -68,6 +68,7 @@ xfs_trans_free(
xfs_extent_busy_clear(tp->t_mountp, &tp->t_busy, false);
trace_xfs_trans_free(tp, _RET_IP_);
+ xfs_trans_clear_context(tp);
if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT))
sb_end_intwrite(tp->t_mountp->m_super);
xfs_trans_free_dqinfo(tp);
@@ -119,7 +120,8 @@ xfs_trans_dup(
ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used;
tp->t_rtx_res = tp->t_rtx_res_used;
- ntp->t_pflags = tp->t_pflags;
+
+ xfs_trans_switch_context(tp, ntp);
/* move deferred ops over to the new tp */
xfs_defer_move(ntp, tp);
@@ -153,9 +155,6 @@ xfs_trans_reserve(
int error = 0;
bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
- /* Mark this thread as being in a transaction */
- current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
-
/*
* Attempt to reserve the needed disk blocks by decrementing
* the number needed from the number available. This will
@@ -163,10 +162,8 @@ xfs_trans_reserve(
*/
if (blocks > 0) {
error = xfs_mod_fdblocks(mp, -((int64_t)blocks), rsvd);
- if (error != 0) {
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
+ if (error != 0)
return -ENOSPC;
- }
tp->t_blk_res += blocks;
}
@@ -240,9 +237,6 @@ xfs_trans_reserve(
xfs_mod_fdblocks(mp, (int64_t)blocks, rsvd);
tp->t_blk_res = 0;
}
-
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
-
return error;
}
@@ -266,6 +260,7 @@ xfs_trans_alloc(
tp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL);
if (!(flags & XFS_TRANS_NO_WRITECOUNT))
sb_start_intwrite(mp->m_super);
+ xfs_trans_set_context(tp);
/*
* Zero-reservation ("empty") transactions can't modify anything, so
@@ -878,7 +873,6 @@ __xfs_trans_commit(
xfs_log_commit_cil(mp, tp, &commit_lsn, regrant);
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
xfs_trans_free(tp);
/*
@@ -910,7 +904,6 @@ __xfs_trans_commit(
xfs_log_ticket_ungrant(mp->m_log, tp->t_ticket);
tp->t_ticket = NULL;
}
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
xfs_trans_free_items(tp, !!error);
xfs_trans_free(tp);
@@ -970,9 +963,6 @@ xfs_trans_cancel(
tp->t_ticket = NULL;
}
- /* mark this thread as no longer being in a transaction */
- current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS);
-
xfs_trans_free_items(tp, dirty);
xfs_trans_free(tp);
}
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 084658946..075eeade4 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -268,4 +268,34 @@ xfs_trans_item_relog(
return lip->li_ops->iop_relog(lip, tp);
}
+static inline void
+xfs_trans_set_context(
+ struct xfs_trans *tp)
+{
+ ASSERT(current->journal_info == NULL);
+ tp->t_pflags = memalloc_nofs_save();
+ current->journal_info = tp;
+}
+
+static inline void
+xfs_trans_clear_context(
+ struct xfs_trans *tp)
+{
+ if (current->journal_info == tp) {
+ memalloc_nofs_restore(tp->t_pflags);
+ current->journal_info = NULL;
+ }
+}
+
+static inline void
+xfs_trans_switch_context(
+ struct xfs_trans *old_tp,
+ struct xfs_trans *new_tp)
+{
+ ASSERT(current->journal_info == old_tp);
+ new_tp->t_pflags = old_tp->t_pflags;
+ old_tp->t_pflags = 0;
+ current->journal_info = new_tp;
+}
+
#endif /* __XFS_TRANS_H__ */
--
2.34.1

View File

@ -1,138 +0,0 @@
From 8182ec00803085354761bbadf0287cad7eac0e2f Mon Sep 17 00:00:00 2001
From: Brian Foster <bfoster@redhat.com>
Date: Fri, 9 Apr 2021 10:27:43 -0700
Subject: [PATCH 2/5] xfs: drop submit side trans alloc for append ioends
Per-inode ioend completion batching has a log reservation deadlock
vector between preallocated append transactions and transactions
that are acquired at completion time for other purposes (i.e.,
unwritten extent conversion or COW fork remaps). For example, if the
ioend completion workqueue task executes on a batch of ioends that
are sorted such that an append ioend sits at the tail, it's possible
for the outstanding append transaction reservation to block
allocation of transactions required to process preceding ioends in
the list.
Append ioend completion is historically the common path for on-disk
inode size updates. While file extending writes may have completed
sometime earlier, the on-disk inode size is only updated after
successful writeback completion. These transactions are preallocated
serially from writeback context to mitigate concurrency and
associated log reservation pressure across completions processed by
multi-threaded workqueue tasks.
However, now that delalloc blocks unconditionally map to unwritten
extents at physical block allocation time, size updates via append
ioends are relatively rare. This means that inode size updates most
commonly occur as part of the preexisting completion time
transaction to convert unwritten extents. As a result, there is no
longer a strong need to preallocate size update transactions.
Remove the preallocation of inode size update transactions to avoid
the ioend completion processing log reservation deadlock. Instead,
continue to send all potential size extending ioends to workqueue
context for completion and allocate the transaction from that
context. This ensures that no outstanding log reservation is owned
by the ioend completion worker task when it begins to process
ioends.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[commit 7cd3099f4925d7c15887d1940ebd65acd66100f5 upstream
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git]
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
fs/xfs/xfs_aops.c | 45 +++------------------------------------------
1 file changed, 3 insertions(+), 42 deletions(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index b4186d666..60943b28f 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -39,33 +39,6 @@ static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
XFS_I(ioend->io_inode)->i_d.di_size;
}
-STATIC int
-xfs_setfilesize_trans_alloc(
- struct iomap_ioend *ioend)
-{
- struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount;
- struct xfs_trans *tp;
- int error;
-
- error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
- if (error)
- return error;
-
- ioend->io_private = tp;
-
- /*
- * We may pass freeze protection with a transaction. So tell lockdep
- * we released it.
- */
- __sb_writers_release(ioend->io_inode->i_sb, SB_FREEZE_FS);
- /*
- * We hand off the transaction to the completion thread now, so
- * clear the flag here.
- */
- xfs_trans_clear_context(tp);
- return 0;
-}
-
/*
* Update on-disk file size now that data has been written to disk.
*/
@@ -182,12 +155,10 @@ xfs_end_ioend(
error = xfs_reflink_end_cow(ip, offset, size);
else if (ioend->io_type == IOMAP_UNWRITTEN)
error = xfs_iomap_write_unwritten(ip, offset, size, false);
- else
- ASSERT(!xfs_ioend_is_append(ioend) || ioend->io_private);
+ if (!error && xfs_ioend_is_append(ioend))
+ error = xfs_setfilesize(ip, ioend->io_offset, ioend->io_size);
done:
- if (ioend->io_private)
- error = xfs_setfilesize_ioend(ioend, error);
iomap_finish_ioends(ioend, error);
memalloc_nofs_restore(nofs_flag);
}
@@ -237,7 +208,7 @@ xfs_end_io(
static inline bool xfs_ioend_needs_workqueue(struct iomap_ioend *ioend)
{
- return ioend->io_private ||
+ return xfs_ioend_is_append(ioend) ||
ioend->io_type == IOMAP_UNWRITTEN ||
(ioend->io_flags & IOMAP_F_SHARED);
}
@@ -250,8 +221,6 @@ xfs_end_bio(
struct xfs_inode *ip = XFS_I(ioend->io_inode);
unsigned long flags;
- ASSERT(xfs_ioend_needs_workqueue(ioend));
-
spin_lock_irqsave(&ip->i_ioend_lock, flags);
if (list_empty(&ip->i_ioend_list))
WARN_ON_ONCE(!queue_work(ip->i_mount->m_unwritten_workqueue,
@@ -501,14 +470,6 @@ xfs_prepare_ioend(
ioend->io_offset, ioend->io_size);
}
- /* Reserve log space if we might write beyond the on-disk inode size. */
- if (!status &&
- ((ioend->io_flags & IOMAP_F_SHARED) ||
- ioend->io_type != IOMAP_UNWRITTEN) &&
- xfs_ioend_is_append(ioend) &&
- !ioend->io_private)
- status = xfs_setfilesize_trans_alloc(ioend);
-
memalloc_nofs_restore(nofs_flag);
if (xfs_ioend_needs_workqueue(ioend))
--
2.34.1

View File

@ -1,51 +0,0 @@
From edbf1eb9032b84631031d9b43570e262f3461c24 Mon Sep 17 00:00:00 2001
From: Brian Foster <bfoster@redhat.com>
Date: Fri, 9 Apr 2021 10:27:55 -0700
Subject: [PATCH 3/5] xfs: open code ioend needs workqueue helper
Open code xfs_ioend_needs_workqueue() into the only remaining
caller.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[commit 7adb8f14e134d5f885d47c4ccd620836235f0b7f upstream
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git]
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
fs/xfs/xfs_aops.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 60943b28f..a74a9ead5 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -206,13 +206,6 @@ xfs_end_io(
}
}
-static inline bool xfs_ioend_needs_workqueue(struct iomap_ioend *ioend)
-{
- return xfs_ioend_is_append(ioend) ||
- ioend->io_type == IOMAP_UNWRITTEN ||
- (ioend->io_flags & IOMAP_F_SHARED);
-}
-
STATIC void
xfs_end_bio(
struct bio *bio)
@@ -472,7 +465,9 @@ xfs_prepare_ioend(
memalloc_nofs_restore(nofs_flag);
- if (xfs_ioend_needs_workqueue(ioend))
+ /* send ioends that might require a transaction to the completion wq */
+ if (xfs_ioend_is_append(ioend) || ioend->io_type == IOMAP_UNWRITTEN ||
+ (ioend->io_flags & IOMAP_F_SHARED))
ioend->io_bio->bi_end_io = xfs_end_bio;
return status;
}
--
2.34.1

View File

@ -1,94 +0,0 @@
From 170e31793806ce5e5a9647b6340954536244518e Mon Sep 17 00:00:00 2001
From: Brian Foster <bfoster@redhat.com>
Date: Fri, 9 Apr 2021 10:27:55 -0700
Subject: [PATCH 4/5] xfs: drop unused ioend private merge and setfilesize code
XFS no longer attaches anthing to ioend->io_private. Remove the
unnecessary ->io_private merging code. This removes the only remaining
user of xfs_setfilesize_ioend() so remove that function as well.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[commit 044c6449f18f174ba8d86640936add3fc7582e49 upstream
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git]
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
fs/xfs/xfs_aops.c | 46 +---------------------------------------------
1 file changed, 1 insertion(+), 45 deletions(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index a74a9ead5..23a9bd9ff 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -85,31 +85,6 @@ xfs_setfilesize(
return __xfs_setfilesize(ip, tp, offset, size);
}
-STATIC int
-xfs_setfilesize_ioend(
- struct iomap_ioend *ioend,
- int error)
-{
- struct xfs_inode *ip = XFS_I(ioend->io_inode);
- struct xfs_trans *tp = ioend->io_private;
-
- /*
- * The transaction may have been allocated in the I/O submission thread,
- * thus we need to mark ourselves as being in a transaction manually.
- * Similarly for freeze protection.
- */
- xfs_trans_set_context(tp);
- __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS);
-
- /* we abort the update if there was an IO error */
- if (error) {
- xfs_trans_cancel(tp);
- return error;
- }
-
- return __xfs_setfilesize(ip, tp, ioend->io_offset, ioend->io_size);
-}
-
/*
* IO write completion.
*/
@@ -163,25 +138,6 @@ xfs_end_ioend(
memalloc_nofs_restore(nofs_flag);
}
-/*
- * If the to be merged ioend has a preallocated transaction for file
- * size updates we need to ensure the ioend it is merged into also
- * has one. If it already has one we can simply cancel the transaction
- * as it is guaranteed to be clean.
- */
-static void
-xfs_ioend_merge_private(
- struct iomap_ioend *ioend,
- struct iomap_ioend *next)
-{
- if (!ioend->io_private) {
- ioend->io_private = next->io_private;
- next->io_private = NULL;
- } else {
- xfs_setfilesize_ioend(next, -ECANCELED);
- }
-}
-
/* Finish all pending io completions. */
void
xfs_end_io(
@@ -201,7 +157,7 @@ xfs_end_io(
while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
io_list))) {
list_del_init(&ioend->io_list);
- iomap_ioend_try_merge(ioend, &tmp, xfs_ioend_merge_private);
+ iomap_ioend_try_merge(ioend, &tmp, NULL);
xfs_end_ioend(ioend);
}
}
--
2.34.1

View File

@ -1,74 +0,0 @@
From 2fd609b6c90a88630a50fb317473b210759b3873 Mon Sep 17 00:00:00 2001
From: Brian Foster <bfoster@redhat.com>
Date: Fri, 9 Apr 2021 10:27:56 -0700
Subject: [PATCH 5/5] xfs: drop unnecessary setfilesize helper
xfs_setfilesize() is the only remaining caller of the internal
__xfs_setfilesize() helper. Fold them into a single function.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[commit e7a3d7e792a5ad50583a2e6c35e72bd2ca6096f4 upstream
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git]
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
fs/xfs/xfs_aops.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 23a9bd9ff..9e32d4135 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -42,14 +42,20 @@ static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
/*
* Update on-disk file size now that data has been written to disk.
*/
-STATIC int
-__xfs_setfilesize(
+int
+xfs_setfilesize(
struct xfs_inode *ip,
- struct xfs_trans *tp,
xfs_off_t offset,
size_t size)
{
+ struct xfs_mount *mp = ip->i_mount;
+ struct xfs_trans *tp;
xfs_fsize_t isize;
+ int error;
+
+ error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
+ if (error)
+ return error;
xfs_ilock(ip, XFS_ILOCK_EXCL);
isize = xfs_new_eof(ip, offset + size);
@@ -68,23 +74,6 @@ __xfs_setfilesize(
return xfs_trans_commit(tp);
}
-int
-xfs_setfilesize(
- struct xfs_inode *ip,
- xfs_off_t offset,
- size_t size)
-{
- struct xfs_mount *mp = ip->i_mount;
- struct xfs_trans *tp;
- int error;
-
- error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp);
- if (error)
- return error;
-
- return __xfs_setfilesize(ip, tp, offset, size);
-}
-
/*
* IO write completion.
*/
--
2.34.1

View File

@ -1,275 +0,0 @@
#!/bin/bash
# set -x
#
# Copyright (c) 2018-2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
# Refer to build-tools/default_build_srpm and modify for git repo from linux-yocto.
#
source "$SRC_BASE/build-tools/spec-utils"
source "$SRC_BASE/build-tools/srpm-utils"
CUR_DIR=`pwd`
BUILD_DIR="$RPMBUILD_BASE"
if [ "x$DATA" == "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): Environment variable 'DATA' not defined."
exit 1
fi
srpm_source_build_data "$DATA" "$SRC_BUILD_TYPE" "$SRPM_OR_SPEC_PATH"
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): Failed to source build data from $DATA"
exit 1
fi
if [ "x$PBR_VERSION" != "x" ] && [ "x$PBR_VERSION" != "xNA" ]; then
VERSION=$PBR_VERSION
fi
if [ "x$VERSION" == "x" ]; then
for SPEC in `find $SPECS_BASE -name '*.spec' | sort -V`; do
SPEC_PATH="$SPEC"
VERSION_DERIVED=`spec_evaluate '%{version}' "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): '%{version}' not found in '$PKG_BASE/$SPEC_PATH'"
VERSION_DERIVED=""
fi
if [ "x$VERSION_DERIVED" != "x" ]; then
if [ "x$VERSION" == "x" ]; then
VERSION=$VERSION_DERIVED
else
if [ "x$SRC_DIR" != "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): multiple spec files found, can't set VERSION automatically"
exit 1
fi
fi
fi
done
if [ "x$VERSION" == "x" ]; then
if [ -f $SRC_DIR/PKG-INFO ]; then
VERSION=$(grep '^Version:' $SRC_DIR/PKG-INFO | awk -F ': ' '{print $2}' | sed -e 's/^[[:space:]]*//')
fi
fi
if [ "x$VERSION" != "x" ]; then
echo "Derived VERSION=$VERSION"
else
echo "ERROR: kernel build_srpm (${LINENO}): Failed to derive a good VERSION from SPEC file, and none provided."
exit 1
fi
fi
if [ "x$TAR_NAME" == "x" ]; then
for SPEC in `find $SPECS_BASE -name '*.spec' | sort -V`; do
SPEC_PATH="$SPEC"
SERVICE=`spec_find_global service "$SPEC_PATH" 2>> /dev/null`
if [ $? -eq 0 ]; then
if [ "x$TAR_NAME" == "x" ]; then
TAR_NAME=$SERVICE
else
if [ "x$SRC_DIR" != "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): multiple spec files found, can't set TAR_NAME automatically"
exit 1
fi
fi
else
NAME=`spec_find_tag Name "$SPEC_PATH" 2>> /dev/null`
if [ $? -eq 0 ]; then
if [ "x$TAR_NAME" == "x" ]; then
TAR_NAME=$NAME
else
if [ "x$SRC_DIR" != "x" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): multiple spec files found, can't set TAR_NAME automatically"
exit 1
fi
fi
else
echo "WARNING: kernel build_srpm (${LINENO}): 'Name' not found in '$SPEC_PATH'"
NAME=""
fi
fi
done
if [ "x$TAR_NAME" == "x" ]; then
if [ -f $SRC_DIR/PKG-INFO ]; then
TAR_NAME=$(grep '^Name:' $SRC_DIR/PKG-INFO | awk -F ': ' '{print $2}' | sed -e 's/^[[:space:]]*//')
fi
fi
if [ "x$TAR_NAME" != "x" ]; then
echo "Derived TAR_NAME=$TAR_NAME"
else
echo "ERROR: kernel build_srpm (${LINENO}): Failed to derive a good TAR_NAME from SPEC file, and none provided."
exit 1
fi
fi
if [ "x$TAR" == "x" ]; then
TAR="$TAR_NAME-$VERSION.tar.gz"
fi
SOURCE_PATH="$BUILD_DIR/SOURCES"
TAR_PATH="$SOURCE_PATH/$TAR"
STAGING=""
if [ "x$COPY_LIST_TO_TAR" != "x" ] || [ "x$EXCLUDE_LIST_FROM_TAR" != "x" ]; then
STAGING="$BUILD_DIR/staging"
mkdir -p $STAGING
fi
mkdir -p "$BUILD_DIR/SRPMS"
mkdir -p "$SOURCE_PATH"
if [ "x$SRC_DIR" == "x" -a "x$COPY_LIST" == "x" -a "$ALLOW_EMPTY_RPM" != "true" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): '$PWD/$DATA' failed to provide at least one of 'SRC_DIR' or 'COPY_LIST'"
exit 1
fi
if [ "x$SRC_DIR" != "x" ]; then
if [ ! -d "$SRC_DIR" ]; then
echo "ERROR: kernel build_srpm (${LINENO}): directory not found: '$SRC_DIR'"
exit 1
fi
fi
if [ "x$COPY_LIST" != "x" ]; then
echo "COPY_LIST: $COPY_LIST"
for p in $COPY_LIST; do
# echo "COPY_LIST: $p"
\cp -L -u -r -v $p $SOURCE_PATH
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): COPY_LIST: file not found: '$p'"
exit 1
fi
done
fi
if [ "x$STAGING" != "x" ]; then
\cp -L -u -r -v $SRC_DIR $STAGING
echo "COPY_LIST_TO_TAR: $COPY_LIST_TO_TAR"
for p in $COPY_LIST_TO_TAR; do
# echo "COPY_LIST_TO_TAR: $p"
\cp -L -u -r -v $p $STAGING/$SRC_DIR
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): COPY_LIST_TO_TAR: file not found: '$p'"
exit 1
fi
done
echo "EXCLUDE_LIST_FROM_TAR: $EXCLUDE_LIST_FROM_TAR"
for p in $EXCLUDE_LIST_FROM_TAR; do
# echo "EXCLUDE_LIST_FROM_TAR: $p"
echo "rm -rf $STAGING/$SRC_DIR/$p"
\rm -rf $STAGING/$SRC_DIR/$p
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): EXCLUDE_LIST_FROM_TAR: could not remove file: '$p'"
exit 1
fi
done
fi
TRANSFORM=`echo "$SRC_DIR" | sed 's/^\./\\./' | sed 's:^/::' | sed 's#^.*/\.\./##'`
if [ "x$STAGING" != "x" ]; then
pushd $STAGING
fi
TAR_NEEDED=0
if [ "x$SRC_DIR" != "x" ]; then
echo "SRC_DIR=$SRC_DIR"
if [ -f $TAR_PATH ]; then
n=`find . -cnewer $TAR_PATH -and ! -path './.git*' \
-and ! -path './.pc/*' \
-and ! -path './patches/*' \
-and ! -path "./$DISTRO/*" \
-and ! -path './pbr-*.egg/*' \
| wc -l`
if [ $n -gt 0 ]; then
TAR_NEEDED=1
fi
else
TAR_NEEDED=1
fi
fi
if [ $TAR_NEEDED -gt 0 ]; then
echo "Creating tar file: $TAR_PATH ..."
echo "tar --exclude '.git*' --exclude='.pc' --exclude='patches' --exclude='$SRC_DIR/$DISTRO' --exclude='pbr-*.egg' --transform 's,^$TRANSFORM,$TAR_NAME-$VERSION,' -czf $TAR_PATH $SRC_DIR"
tar --exclude '.git*' --exclude='.pc' --exclude='patches' --exclude="$SRC_DIR/$DISTRO" --exclude='pbr-*.egg' --transform "s,^$TRANSFORM,$TAR_NAME-$VERSION," -czf "$TAR_PATH" "$SRC_DIR"
if [ $? -ne 0 ]; then
if [ "x$STAGING" != "x" ]; then
popd
fi
echo "ERROR: kernel build_srpm (${LINENO}): failed to create tar file, cmd: tar --exclude '.git*' --exclude='.pc' --exclude='patches' --exclude="$SRC_DIR/$DISTRO" --exclude='pbr-*.egg' --transform \"s,^$TRANSFORM,$TAR_NAME-$VERSION,\" -czf '$TAR_PATH' '$SRC_DIR'"
exit 1
fi
echo "Created tar file: $TAR_PATH"
else
echo "Tar file not needed."
fi
if [ "x$STAGING" != "x" ]; then
popd
fi
if [ ! -d $BUILD_DIR/SPECS ]; then
echo "Spec directory '$BUILD_DIR/SPECS' does not exist"
exit 1
fi
if [ $(ls -1 $BUILD_DIR/SPECS/*.spec | wc -l) -eq 0 ]; then
echo "No spec files found in spec directory '$BUILD_DIR/SPECS'"
exit 1
fi
for SPEC in `ls -1 $BUILD_DIR/SPECS`; do
SPEC_PATH="$BUILD_DIR/SPECS/$SPEC"
RELEASE=`spec_find_tag Release "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): 'Release' not found in '$SPEC_PATH'"
fi
NAME=`spec_find_tag Name "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: kernel build_srpm (${LINENO}): 'Name' not found in '$SPEC_PATH'"
fi
SRPM="$NAME-$VERSION-$RELEASE.src.rpm"
SRPM_PATH="$BUILD_DIR/SRPMS/$SRPM"
spec_validate_tis_release $SPEC_PATH
if [ $? -ne 0 ]; then
echo "TIS Validation of $SPEC_PATH failed"
exit 1
fi
BUILD_NEEDED=0
if [ -f $SRPM_PATH ]; then
n=`find . -cnewer $SRPM_PATH | wc -l`
if [ $n -gt 0 ]; then
BUILD_NEEDED=1
fi
else
BUILD_NEEDED=1
fi
if [ $BUILD_NEEDED -gt 0 ]; then
echo "SPEC file: $SPEC_PATH"
echo "SRPM build directory: $BUILD_DIR"
echo "TIS_PATCH_VER: $TIS_PATCH_VER"
echo "PBR_VERSION: $PBR_VERSION"
sed -i -e "1 i%define _tis_build_type $BUILD_TYPE" $SPEC_PATH
sed -i -e "1 i%define tis_patch_ver $TIS_PATCH_VER" $SPEC_PATH
sed -i -e "1 i%define pbr_version $PBR_VERSION" $SPEC_PATH
rpmbuild -bs $SPEC_PATH --define="%_topdir $BUILD_DIR" --undefine=dist --define="_tis_dist .tis"
else
echo "SRPM build not needed"
fi
done

View File

@ -1,15 +0,0 @@
SRC_DIR="$STX_BASE/git/linux-yocto-std"
COPY_LIST=" \
$PKG_BASE/files/* \
$PKG_BASE/centos/patches/*"
BUILD_IS_BIG=21
BUILD_IS_SLOW=16
# The base branch is: v5.10/standard/base
# commit 6cf7dea05b points to v5.10.112 in linux-yocto.
TIS_BASE_SRCREV=6cf7dea05bd756513cf58c5ced8c6bf1d1f23c15
PKG_BASE_SRCREV=4013790c6ef43fd9f936579b0cac50b8e0c4505a
TIS_PATCH_VER=GITREVCOUNT+PKG_GITREVCOUNT

File diff suppressed because it is too large Load Diff

View File

@ -1,545 +0,0 @@
From a6d19757680f81e529c789e77bcac01f9b9e2fbd Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Thu, 17 Jun 2021 07:44:04 +0000
Subject: [PATCH] Notification of death of arbitrary processes
Note: this commit was copied from Titanium Cloud Rel2
This exposes a new feature which may be called to request
notification when an arbitrary process changes state. The
caller specifies a pid, signal number, and event mask, and
when that pid dies, or is stopped, or anything else that
would normally cause a SIGCHLD, the kernel will send the
specified signal to the caller if the event is in the event
mask originally passed down. The siginfo_t struct will
contain the same information as would be included with SIGCHLD.
This is exposed to userspace via the prctl() call with the
PR_DO_NOTIFY_TASK_STATE option.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
[jm: Adapted the patch for context changes.]
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
include/linux/init_task.h | 9 ++
include/linux/sched.h | 6 +
include/uapi/linux/prctl.h | 16 +++
init/Kconfig | 15 +++
init/init_task.c | 1 +
kernel/Makefile | 1 +
kernel/death_notify.c | 228 +++++++++++++++++++++++++++++++++++++
kernel/death_notify.h | 46 ++++++++
kernel/exit.c | 6 +
kernel/fork.c | 4 +
kernel/signal.c | 11 ++
kernel/sys.c | 8 ++
12 files changed, 351 insertions(+)
create mode 100644 kernel/death_notify.c
create mode 100644 kernel/death_notify.h
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index b2412b4d4c20..7a0828daf59c 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -25,6 +25,15 @@
extern struct files_struct init_files;
extern struct fs_struct init_fs;
extern struct nsproxy init_nsproxy;
+
+#ifdef CONFIG_SIGEXIT
+#define INIT_SIGEXIT(tsk) \
+ .notify = LIST_HEAD_INIT(tsk.notify), \
+ .monitor = LIST_HEAD_INIT(tsk.monitor),
+#else
+#define INIT_SIGEXIT(tsk)
+#endif
+
extern struct group_info init_groups;
extern struct cred init_cred;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 76cd21fa5501..614cd20935a7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1119,6 +1119,12 @@ struct task_struct {
short il_prev;
short pref_node_fork;
#endif
+#ifdef CONFIG_SIGEXIT
+ /* list of processes to notify on death */
+ struct list_head notify;
+ /* list of outstanding monitor requests */
+ struct list_head monitor;
+#endif
#ifdef CONFIG_NUMA_BALANCING
int numa_scan_seq;
unsigned int numa_scan_period;
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index 7f0827705c9a..dbd5a8b6e002 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -63,6 +63,22 @@
# define PR_ENDIAN_LITTLE 1 /* True little endian mode */
# define PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */
+#define PR_DO_NOTIFY_TASK_STATE 17 /* Set/get notification for task
+ state changes */
+
+/* This is the data structure for requestion process death
+ * (and other state change) information. Sig of -1 means
+ * query, sig of 0 means deregistration, positive sig means
+ * that you want to set it. sig and events are value-result
+ * and will be updated with the previous values on every
+ * successful call.
+ */
+struct task_state_notify_info {
+ int pid;
+ int sig;
+ unsigned int events;
+};
+
/* Get/set process seccomp mode */
#define PR_GET_SECCOMP 21
#define PR_SET_SECCOMP 22
diff --git a/init/Kconfig b/init/Kconfig
index fc4c9f416fad..df9d5284f8d6 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1851,6 +1851,21 @@ config VM_EVENT_COUNTERS
on EXPERT systems. /proc/vmstat will only show page counts
if VM event counters are disabled.
+config SIGEXIT
+ bool "Notification of death of arbitrary processes"
+ default n
+ help
+ When enabled this exposes a new feature which may be called to request
+ notification when an arbitrary process changes state. The caller specifies
+ a pid, signal number, and event mask, and when that pid dies, or is
+ stopped, or anything else that would normally cause a SIGCHLD, the
+ kernel will send the specified signal to the caller if the event is in
+ the event mask originally passed down. The siginfo_t struct will
+ contain the same information as would be included with SIGCHLD.
+
+ This is exposed to userspace via the prctl()
+ call with the PR_DO_NOTIFY_TASK_STATE option
+
config SLUB_DEBUG
default y
bool "Enable SLUB debugging support" if EXPERT
diff --git a/init/init_task.c b/init/init_task.c
index 16d14c2ebb55..eaee56e60985 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -128,6 +128,7 @@ struct task_struct init_task
.alloc_lock = __SPIN_LOCK_UNLOCKED(init_task.alloc_lock),
.journal_info = NULL,
INIT_CPU_TIMERS(init_task)
+ INIT_SIGEXIT(init_task)
.pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
.timer_slack_ns = 50000, /* 50 usec default slack */
.thread_pid = &init_struct_pid,
diff --git a/kernel/Makefile b/kernel/Makefile
index 88b60a6e5dd0..36377f54555a 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -108,6 +108,7 @@ obj-$(CONFIG_BPF) += bpf/
obj-$(CONFIG_KCSAN) += kcsan/
obj-$(CONFIG_SHADOW_CALL_STACK) += scs.o
obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call.o
+obj-$(CONFIG_SIGEXIT) += death_notify.o
obj-$(CONFIG_PERF_EVENTS) += events/
diff --git a/kernel/death_notify.c b/kernel/death_notify.c
new file mode 100644
index 000000000000..5819d35a2564
--- /dev/null
+++ b/kernel/death_notify.c
@@ -0,0 +1,228 @@
+/*
+ * kernel/death_notify.c, Process death notification support
+ *
+ * Copyright (c) 2006-2014 Wind River Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/sched/task.h>
+#include <linux/slab.h>
+#include <linux/prctl.h>
+#include <linux/uaccess.h>
+#include "death_notify.h"
+
+static void unlink_status_notifier(struct signotifier *n)
+{
+ list_del(&n->monitor_list);
+ list_del(&n->notify_list);
+ kfree(n);
+}
+
+static void handle_already_monitoring(struct signotifier *node,
+ struct task_state_notify_info *args,
+ struct task_state_notify_info *oldargs)
+{
+ /* Store the old values */
+ oldargs->sig = node->sig;
+ oldargs->events = node->events;
+
+ /* We know that args->sig is 0 or a valid signal. */
+ if (args->sig > 0) {
+ /* Update the new values */
+ node->sig = args->sig;
+ node->events = args->events;
+ } else if (!args->sig) {
+ /* args->sig of 0 means to deregister */
+ unlink_status_notifier(node);
+ }
+}
+
+static void setup_new_node(struct task_struct *p,
+ struct signotifier *node,
+ struct task_state_notify_info *args)
+{
+ node->notify_tsk = current;
+ node->sig = args->sig;
+ node->events = args->events;
+
+ /* Add this node to the list of notification requests
+ * for the specified process.
+ */
+ list_add_tail(&node->notify_list, &p->notify);
+
+ /* Also add this node to the list of monitor requests
+ * for the current process.
+ */
+ list_add_tail(&node->monitor_list, &current->monitor);
+}
+
+/* Returns 0 if arguments are valid, 1 if they are not. */
+static int invalid_args(struct task_state_notify_info *args)
+{
+ int ret = 1;
+
+ if (args->pid <= 0)
+ goto out;
+
+ /* Sig of -1 implies query, sig of 0 implies deregistration.
+ * Otherwise sig must be positive and within range.
+ */
+ if ((args->sig < -1) || (args->sig > _NSIG))
+ goto out;
+
+ /* If positive sig, must have valid events. */
+ if (args->sig > 0) {
+ if (!args->events || (args->events >= (1 << (NSIGCHLD+1))))
+ goto out;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+/* Notify those registered for process state updates via do_notify_task_state().
+ * If "del" is nonzero, the process is dying and we want to free
+ * the nodes in the list as we go.
+ *
+ * Note: we only notify processes for events in which they have registered
+ * interest.
+ *
+ * Must be called holding a lock on tasklist_lock.
+ */
+void do_notify_others(struct task_struct *tsk, struct kernel_siginfo *info)
+{
+ struct signotifier *node;
+ unsigned int events;
+
+ /* This method of generating the event bit must be
+ * matched in the userspace library.
+ */
+ events = 1 << (info->si_code & 0xFF);
+
+ list_for_each_entry(node, &tsk->notify, notify_list) {
+ if (events & node->events) {
+ info->si_signo = node->sig;
+ group_send_sig_info(node->sig, info, node->notify_tsk, PIDTYPE_TGID);
+ }
+ }
+}
+
+void release_notify_others(struct task_struct *p)
+{
+ struct signotifier *n, *t;
+
+ /* Need to clean up any outstanding requests where we
+ * wanted to be notified when others died.
+ */
+ list_for_each_entry_safe(n, t, &p->monitor, monitor_list) {
+ unlink_status_notifier(n);
+ }
+
+ /* Also need to clean up any outstanding requests where others
+ * wanted to be notified when we died.
+ */
+ list_for_each_entry_safe(n, t, &p->notify, notify_list) {
+ unlink_status_notifier(n);
+ }
+}
+
+/* If the config is defined, then processes can call this routine
+ * to request notification when the specified task's state changes.
+ * On the death (or other state change) of the specified process,
+ * we will send them the specified signal if the event is listed
+ * in their event bitfield.
+ *
+ * A sig of 0 means that we want to deregister.
+ *
+ * The sig/events fields are value/result. On success we update them
+ * to reflect what they were before the call.
+ *
+ * Returns error code on error, on success we return 0.
+ */
+int do_notify_task_state(unsigned long arg)
+{
+ int err;
+ struct task_struct *p;
+ struct signotifier *node, *tmp;
+ struct task_state_notify_info args, oldargs;
+
+ if (copy_from_user(&args, (struct task_state_notify_info __user *)arg,
+ sizeof(args)))
+ return -EFAULT;
+ oldargs.pid = args.pid;
+
+ /* Validate the arguments passed in. */
+ err = -EINVAL;
+ if (invalid_args(&args))
+ goto out;
+
+ /* We must hold a write lock on tasklist_lock to add the notification
+ * later on, and we need some lock on tasklist_lock for
+ * find_task_by_pid(), so may as well take the write lock now.
+ * Must use write_lock_irq().
+ */
+ write_lock_irq(&tasklist_lock);
+
+ err = -ESRCH;
+ p = find_task_by_vpid(args.pid);
+ if (!p)
+ goto unlock_out;
+
+ /* Now we know pid exists, unlikely to fail. */
+ err = 0;
+
+ /* Check if we're already monitoring the specified pid. If so, update
+ * the monitoring parameters and return the old ones.
+ */
+ list_for_each_entry(tmp, &p->notify, notify_list) {
+ if (tmp->notify_tsk == current) {
+ handle_already_monitoring(tmp, &args, &oldargs);
+ goto unlock_out;
+ }
+ }
+
+ /* If we get here, we're not currently monitoring the process. */
+ oldargs.sig = 0;
+ oldargs.events = 0;
+
+ /* If we wanted to set up a new monitor, do it now. If we didn't
+ * manage to allocate memory for the new node, then we return
+ * an appropriate error.
+ */
+ if (args.sig > 0) {
+ node = kmalloc(sizeof(*node), GFP_ATOMIC);
+ if (node)
+ setup_new_node(p, node, &args);
+ else
+ err = -ENOMEM;
+ }
+
+unlock_out:
+ write_unlock_irq(&tasklist_lock);
+
+ /* Copy the old values back to caller. */
+ if (copy_to_user((struct task_state_notify_info __user *)arg,
+ &oldargs, sizeof(oldargs)))
+ err = -EFAULT;
+
+out:
+ return err;
+}
+
diff --git a/kernel/death_notify.h b/kernel/death_notify.h
new file mode 100644
index 000000000000..14a0995b79af
--- /dev/null
+++ b/kernel/death_notify.h
@@ -0,0 +1,46 @@
+/*
+ * kernel/death_notify.h, Process death notification support
+ *
+ * Copyright (c) 2006-2014 Wind River Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _KERNEL_DEATH_NOTIFY_H
+#define _KERNEL_DEATH_NOTIFY_H
+
+#ifdef CONFIG_SIGEXIT
+
+struct signotifier {
+ struct task_struct *notify_tsk;
+ struct list_head notify_list;
+ struct list_head monitor_list;
+ int sig;
+ unsigned int events;
+};
+
+extern int do_notify_task_state(unsigned long arg);
+extern void do_notify_others(struct task_struct *tsk,
+ struct kernel_siginfo *info);
+extern void release_notify_others(struct task_struct *p);
+
+#else /* !CONFIG_SIGEXIT */
+
+static inline void do_notify_others(struct task_struct *tsk,
+ struct kernel_siginfo *info) {}
+static inline void release_notify_others(struct task_struct *p) {}
+
+#endif /* CONFIG_SIGEXIT */
+#endif
+
diff --git a/kernel/exit.c b/kernel/exit.c
index d13d67fc5f4e..0e7adf824a52 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -68,6 +68,9 @@
#include <linux/uaccess.h>
#include <asm/unistd.h>
#include <asm/mmu_context.h>
+#ifdef CONFIG_SIGEXIT
+#include "death_notify.h"
+#endif
static void __unhash_process(struct task_struct *p, bool group_dead)
{
@@ -194,6 +197,9 @@ void release_task(struct task_struct *p)
cgroup_release(p);
write_lock_irq(&tasklist_lock);
+#ifdef CONFIG_SIGEXIT
+ release_notify_others(p);
+#endif
ptrace_release_task(p);
thread_pid = get_pid(p->thread_pid);
__exit_signal(p);
diff --git a/kernel/fork.c b/kernel/fork.c
index 7c044d377926..5333090a7cc5 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2069,6 +2069,10 @@ static __latent_entropy struct task_struct *copy_process(
p->sequential_io = 0;
p->sequential_io_avg = 0;
#endif
+#ifdef CONFIG_SIGEXIT
+ INIT_LIST_HEAD(&p->notify);
+ INIT_LIST_HEAD(&p->monitor);
+#endif
/* Perform scheduler related setup. Assign this task to a CPU. */
retval = sched_fork(clone_flags, p);
diff --git a/kernel/signal.c b/kernel/signal.c
index ef8f2a28d37c..5c41ee2ccf7e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -55,6 +55,9 @@
#include <asm/unistd.h>
#include <asm/siginfo.h>
#include <asm/cacheflush.h>
+#ifdef CONFIG_SIGEXIT
+#include "death_notify.h"
+#endif
/*
* SLAB caches for signal bits.
@@ -1999,6 +2002,10 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
__wake_up_parent(tsk, tsk->parent);
spin_unlock_irqrestore(&psig->siglock, flags);
+#ifdef CONFIG_SIGEXIT
+ do_notify_others(tsk, &info);
+#endif
+
return autoreap;
}
@@ -2071,6 +2078,10 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
*/
__wake_up_parent(tsk, parent);
spin_unlock_irqrestore(&sighand->siglock, flags);
+
+#ifdef CONFIG_SIGEXIT
+ do_notify_others(tsk, &info);
+#endif
}
static inline bool may_ptrace_stop(void)
diff --git a/kernel/sys.c b/kernel/sys.c
index a730c03ee607..0f8decf763f1 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -73,6 +73,9 @@
#include <asm/unistd.h>
#include "uid16.h"
+#ifdef CONFIG_SIGEXIT
+#include "death_notify.h"
+#endif
#ifndef SET_UNALIGN_CTL
# define SET_UNALIGN_CTL(a, b) (-EINVAL)
@@ -2423,6 +2426,11 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
else
error = PR_MCE_KILL_DEFAULT;
break;
+#ifdef CONFIG_SIGEXIT
+ case PR_DO_NOTIFY_TASK_STATE:
+ error = do_notify_task_state(arg2);
+ break;
+#endif
case PR_SET_MM:
error = prctl_set_mm(arg2, arg3, arg4, arg5);
break;
--
2.29.2

View File

@ -1,33 +0,0 @@
From 8d508571597d4e2d8c64621015c375ce0a346748 Mon Sep 17 00:00:00 2001
From: Dahir Osman <dahir.osman@windriver.com>
Date: Wed, 13 Jan 2016 10:01:11 -0500
Subject: [PATCH 02/10] PCI: Add ACS quirk for Intel Fortville NICs
Use quirks to determine isolation for now until a later kernel can
properly read the Fortville ACS capabilities.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/pci/quirks.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b570f297e3ec..910026923549 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4740,6 +4740,10 @@ static const struct pci_dev_acs_enabled {
{ PCI_VENDOR_ID_INTEL, 0x15b7, pci_quirk_mf_endpoint_acs },
{ PCI_VENDOR_ID_INTEL, 0x15b8, pci_quirk_mf_endpoint_acs },
{ PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_rciep_acs },
+ /* I40 */
+ { PCI_VENDOR_ID_INTEL, 0x1572, pci_quirk_mf_endpoint_acs },
+ { PCI_VENDOR_ID_INTEL, 0x1586, pci_quirk_mf_endpoint_acs },
+ { PCI_VENDOR_ID_INTEL, 0x1583, pci_quirk_mf_endpoint_acs },
/* QCOM QDF2xxx root ports */
{ PCI_VENDOR_ID_QCOM, 0x0400, pci_quirk_qcom_rp_acs },
{ PCI_VENDOR_ID_QCOM, 0x0401, pci_quirk_qcom_rp_acs },
--
2.29.2

View File

@ -1,174 +0,0 @@
From d4c6a64967be6e34fec40ddff5714efe001be7c3 Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Tue, 24 Nov 2015 16:27:28 -0500
Subject: [PATCH] affine compute kernel threads
This is a kernel enhancement to configure the cpu affinity of kernel
threads via kernel boot option kthread_cpus=<cpulist>. The compute
kickstart file and compute-huge.sh scripts will update grub with the
new option.
With kthread_cpus specified, the cpumask is immediately applied upon
thread launch. This does not affect kernel threads that specify cpu
and node.
Note: this is based off of Christoph Lameter's patch at
https://lwn.net/Articles/565932/ with the only difference being
the kernel parameter changed from kthread to kthread_cpus.
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
[VT: The existing "isolcpus"
kernel bootarg, cgroup/cpuset, and taskset might provide the some
way to have cpu isolation. However none of them satisfies the requirements.
Replacing spaces with tabs. Combine two calls of set_cpus_allowed_ptr()
in kernel_init_freeable() in init/main.c into one. Performed tests]
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Vefa Bicakci <vefa.bicakci@windriver.com>
[jm: Adapted the patch for context changes.]
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
.../admin-guide/kernel-parameters.txt | 10 ++++++++
include/linux/cpumask.h | 3 +++
init/main.c | 2 ++
kernel/cpu.c | 23 +++++++++++++++++++
kernel/kthread.c | 5 ++--
kernel/umh.c | 3 +++
6 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 19e9e220eaa1..0260789adc94 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2223,6 +2223,16 @@
See also Documentation/trace/kprobetrace.rst "Kernel
Boot Parameter" section.
+ kthread_cpus= [KNL, SMP] Only run kernel threads on the specified
+ list of processors. The kernel will start threads
+ on the indicated processors only (unless there
+ are specific reasons to run a thread with
+ different affinities). This can be used to make
+ init start on certain processors and also to
+ control where kmod and other user space threads
+ are being spawned. Allows to keep kernel threads
+ away from certain cores unless absoluteluy necessary.
+
kpti= [ARM64] Control page table isolation of user
and kernel address spaces.
Default: enabled on cores which need mitigation.
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index f0d895d6ac39..45f338cfdd6f 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -55,6 +55,7 @@ extern unsigned int nr_cpu_ids;
* cpu_present_mask - has bit 'cpu' set iff cpu is populated
* cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler
* cpu_active_mask - has bit 'cpu' set iff cpu available to migration
+ * cpu_kthread_mask - has bit 'cpu' set iff general kernel threads allowed
*
* If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
*
@@ -91,10 +92,12 @@ extern struct cpumask __cpu_possible_mask;
extern struct cpumask __cpu_online_mask;
extern struct cpumask __cpu_present_mask;
extern struct cpumask __cpu_active_mask;
+extern struct cpumask __cpu_kthread_mask;
#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
#define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask)
#define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask)
#define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask)
+#define cpu_kthread_mask ((const struct cpumask *)&__cpu_kthread_mask)
extern atomic_t __num_online_cpus;
diff --git a/init/main.c b/init/main.c
index db693781a12f..4e7777bdab6e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1536,6 +1536,8 @@ static noinline void __init kernel_init_freeable(void)
do_basic_setup();
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
+
kunit_run_all_tests();
console_on_rootfs();
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 67c22941b5f2..67b1a67bd8f0 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2498,6 +2498,29 @@ EXPORT_SYMBOL(__cpu_active_mask);
atomic_t __num_online_cpus __read_mostly;
EXPORT_SYMBOL(__num_online_cpus);
+struct cpumask __cpu_kthread_mask __read_mostly
+ = {CPU_BITS_ALL};
+EXPORT_SYMBOL(__cpu_kthread_mask);
+
+static int __init kthread_setup(char *str)
+{
+ cpumask_var_t tmp_mask;
+ int err;
+
+ alloc_bootmem_cpumask_var(&tmp_mask);
+
+ err = cpulist_parse(str, tmp_mask);
+ if (!err)
+ cpumask_copy(&__cpu_kthread_mask, tmp_mask);
+ else
+ pr_err("Cannot parse 'kthread_cpus=%s'; error %d\n", str, err);
+
+ free_bootmem_cpumask_var(tmp_mask);
+
+ return 1;
+}
+__setup("kthread_cpus=", kthread_setup);
+
void init_cpu_present(const struct cpumask *src)
{
cpumask_copy(&__cpu_present_mask, src);
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 508fe5278285..a7bb87b00cea 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -405,8 +405,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
* The kernel thread should not inherit these properties.
*/
sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
- set_cpus_allowed_ptr(task,
- housekeeping_cpumask(HK_FLAG_KTHREAD));
+ set_cpus_allowed_ptr(task, cpu_kthread_mask);
}
kfree(create);
return task;
@@ -655,7 +654,7 @@ int kthreadd(void *unused)
/* Setup a clean context for our children to inherit. */
set_task_comm(tsk, "kthreadd");
ignore_signals(tsk);
- set_cpus_allowed_ptr(tsk, housekeeping_cpumask(HK_FLAG_KTHREAD));
+ set_cpus_allowed_ptr(tsk, cpu_kthread_mask);
set_mems_allowed(node_states[N_MEMORY]);
current->flags |= PF_NOFREEZE;
diff --git a/kernel/umh.c b/kernel/umh.c
index 3f646613a9d3..e5027cee43f7 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -80,6 +80,9 @@ static int call_usermodehelper_exec_async(void *data)
*/
current->fs->umask = 0022;
+ /* We can run only where init is allowed to run. */
+ set_cpus_allowed_ptr(current, cpu_kthread_mask);
+
/*
* Our parent (unbound workqueue) runs with elevated scheduling
* priority. Avoid propagating that into the userspace child.
--
2.29.2

View File

@ -1,72 +0,0 @@
From 286f3a8af7f620dac84f20de5f7ad6542f447ace Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Tue, 24 Nov 2015 16:27:29 -0500
Subject: [PATCH 04/10] Affine irqs and workqueues with kthread_cpus
If the kthread_cpus boot arg is set it means we want to affine
kernel threads to the specified CPU mask as much as possible
in order to avoid doing work on other CPUs.
In this commit we extend the meaning of that boot arg to also
apply to the CPU affinity of unbound and ordered workqueues.
We also use the kthread_cpus value to determine the default irq
affinity. Specifically, as long as the previously-calculated
irq affinity intersects with the kthread_cpus affinity then we'll
use the intersection of the two as the default irq affinity.
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
[VT: replacing spaces with tabs. Performed tests]
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
kernel/irq/manage.c | 7 +++++++
kernel/workqueue.c | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 79dc02b956dc..420b5ce0bf89 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -515,6 +515,13 @@ int irq_setup_affinity(struct irq_desc *desc)
if (cpumask_intersects(&mask, nodemask))
cpumask_and(&mask, &mask, nodemask);
}
+
+ /* This will narrow down the affinity further if we've specified
+ * a reduced cpu_kthread_mask in the boot args.
+ */
+ if (cpumask_intersects(&mask, cpu_kthread_mask))
+ cpumask_and(&mask, &mask, cpu_kthread_mask);
+
ret = irq_do_set_affinity(&desc->irq_data, &mask, false);
raw_spin_unlock(&mask_lock);
return ret;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1e2ca744dadb..b854874d0518 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5956,6 +5956,8 @@ void __init workqueue_init_early(void)
BUG_ON(!(attrs = alloc_workqueue_attrs()));
attrs->nice = std_nice[i];
+ /* If we've specified a kthread mask apply it here too. */
+ cpumask_copy(attrs->cpumask, cpu_kthread_mask);
unbound_std_wq_attrs[i] = attrs;
/*
@@ -5966,6 +5968,8 @@ void __init workqueue_init_early(void)
BUG_ON(!(attrs = alloc_workqueue_attrs()));
attrs->nice = std_nice[i];
attrs->no_numa = true;
+ /* If we've specified a kthread mask apply it here too. */
+ cpumask_copy(attrs->cpumask, cpu_kthread_mask);
ordered_wq_attrs[i] = attrs;
}
--
2.29.2

View File

@ -1,36 +0,0 @@
From 82e56b6b7c05eebc589b37e96ed3b0a44d6cdef7 Mon Sep 17 00:00:00 2001
From: Chris Friesen <chris.friesen@windriver.com>
Date: Thu, 12 May 2016 18:00:00 -0400
Subject: [PATCH 05/10] Make kernel start eth devices at offset
In order to avoid naming collisions, we want to make the kernel
start naming its "ethX" devices at eth1000 instead of eth0. This
will let us rename to a range starting at eth0.
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
net/core/dev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 62ff7121b22d..e63fe7662c73 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1218,6 +1218,12 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
set_bit(i, inuse);
}
+ /* STX extension, want kernel to start at eth1000 */
+ if (strcmp(name, "eth%d") == 0) {
+ for (i=0; i < 1000; i++)
+ set_bit(i, inuse);
+ }
+
i = find_first_zero_bit(inuse, max_netdevices);
free_page((unsigned long) inuse);
}
--
2.29.2

View File

@ -1,125 +0,0 @@
From c35ee3034b61e72bf9fef888a3c4702049a77bcc Mon Sep 17 00:00:00 2001
From: Matt Peters <matt.peters@windriver.com>
Date: Mon, 30 May 2016 10:51:02 -0400
Subject: [PATCH] intel-iommu: allow ignoring Ethernet device RMRR with IOMMU
passthrough
Some BIOS's are reporting DMAR RMRR entries for Ethernet devices
which is causing problems when PCI passthrough is enabled. These
devices should be able to use the static identity map since the
host should not be enforcing specific address ranges when IOMMU
passthrough is enabled.
Originally-by: Matt Peters <matt.peters@windriver.com>
[PG: Added bootarg wrapper and documentation entries.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Nam Ninh <nam.ninh@windriver.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
[lz: Adapted the patch for context changes.]
Signed-off-by: Li Zhou <li.zhou@windriver.com>
[jp: fix warning: this 'else' clause does not guard]
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
.../admin-guide/kernel-parameters.txt | 5 +++++
Documentation/x86/intel-iommu.rst | 18 +++++++++++++++
drivers/iommu/intel/iommu.c | 22 ++++++++++++++++++-
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 552f1db5b9d7..e862aabe6255 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1861,6 +1861,11 @@
than 32-bit addressing. The default is to look
for translation below 32-bit and if not available
then look in the higher range.
+ eth_no_rmrr [Default Off]
+ With this option provided, the kernel will ignore
+ any specified RMRR regions specified by the BIOS
+ for PCI ethernet devices. Confirm with your hardware
+ vendor the RMRR regions are indeed invalid first.
strict [Default Off]
With this option on every unmap_single operation will
result in a hardware IOTLB flush operation as opposed
diff --git a/Documentation/x86/intel-iommu.rst b/Documentation/x86/intel-iommu.rst
index 099f13d51d5f..18e6a8d8b1ee 100644
--- a/Documentation/x86/intel-iommu.rst
+++ b/Documentation/x86/intel-iommu.rst
@@ -33,6 +33,24 @@ regions will fail. Hence BIOS uses RMRR to specify these regions along with
devices that need to access these regions. OS is expected to setup
unity mappings for these regions for these devices to access these regions.
+RMRR for other devices?
+-----------------------
+
+There are reports of BIOS out there that indicate RMRR regions for things
+like ethernet devices. As per mainline commit c875d2c1b8083 ("iommu/vt-d:
+Exclude devices using RMRRs from IOMMU API domains") such a device is
+"fundamentally incompatible" with the IOMMU API and "we must prevent such
+devices from being used by the IOMMU API." However, in the event that
+the RMRR indicated by the BIOS is assumed to be just a reporting error,
+there is an additional iommu boot arg that can be used to ignore RMRR
+settings for ethernet, i.e. "intel_iommu=on,eth_no_rmrr iommu=pt".
+Note that iommu=pt is required in order to eth_no_rmrr to have effect.
+
+If you use this setting, you should consult with your hardware vendor to
+confirm that it is just a reporting error, and that it truly is not
+actively using any DMA to/from RMRR, as otherwise system instability
+may result.
+
How is IOVA generated?
----------------------
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 7e3db4c0324d..16ebba2723cb 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -354,6 +354,7 @@ static int dmar_map_gfx = 1;
static int dmar_forcedac;
static int intel_iommu_strict;
static int intel_iommu_superpage = 1;
+static int intel_iommu_ethrmrr = 1;
static int iommu_identity_mapping;
static int intel_no_bounce;
static int iommu_skip_te_disable;
@@ -448,6 +449,15 @@ static int __init intel_iommu_setup(char *str)
} else if (!strncmp(str, "forcedac", 8)) {
pr_info("Forcing DAC for PCI devices\n");
dmar_forcedac = 1;
+ } else if (!strncmp(str, "eth_no_rmrr", 11)) {
+ if (!iommu_default_passthrough()) {
+ printk(KERN_WARNING
+ "Intel-IOMMU: error - eth_no_rmrr requires iommu=pt\n");
+ } else {
+ printk(KERN_INFO
+ "Intel-IOMMU: ignoring ethernet RMRR values\n");
+ intel_iommu_ethrmrr = 0;
+ }
} else if (!strncmp(str, "strict", 6)) {
pr_info("Disable batched IOTLB flush\n");
intel_iommu_strict = 1;
@@ -2880,8 +2890,18 @@ static bool device_rmrr_is_relaxable(struct device *dev)
pdev = to_pci_dev(dev);
if (IS_USB_DEVICE(pdev) || IS_GFX_DEVICE(pdev))
return true;
- else
+ else {
+ /* As a temporary workaround for issues seen on ProLiant DL380p,
+ * allow the operator to ignore the RMRR settings for ethernet
+ * devices. Ideally the end user should contact their vendor
+ * regarding why there are RMRR, as per mainline c875d2c1b8083
+ * ("iommu/vt-d: Exclude devices using RMRRs from IOMMU API domains")
+ * it seems that these make no sense at all.
+ */
+ if ((pdev->class >> 8) == PCI_CLASS_NETWORK_ETHERNET && !intel_iommu_ethrmrr)
+ return true;
return false;
+ }
}
/*
--
2.29.2

View File

@ -1,27 +0,0 @@
From 87e7e3bd136b05d9ae105fe87879d1fe6730ee18 Mon Sep 17 00:00:00 2001
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Tue, 6 Mar 2018 12:54:40 -0500
Subject: [PATCH 06/10] turn off write same in smartqpi driver
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Zhang Zhiguo <zhangzhg@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 9d0229656681..af46f3a024da 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6571,6 +6571,7 @@ static struct scsi_host_template pqi_driver_template = {
.map_queues = pqi_map_queues,
.sdev_attrs = pqi_sdev_attrs,
.shost_attrs = pqi_shost_attrs,
+ .no_write_same = 1,
};
static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info)
--
2.29.2

View File

@ -1,79 +0,0 @@
From 4d58a9a618827e4410e3828b4deef5832a8576db Mon Sep 17 00:00:00 2001
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Wed, 29 Jan 2020 14:19:22 -0500
Subject: [PATCH 07/10] Allow dmar quirks for broken bioses
Problem:
Broken bios creates inaccurate DMAR tables,
reporting some bridges as having endpoint types.
This causes IOMMU initialization to bail
out early with an error code, the result of
which is vfio not working correctly.
This is seen on some Skylake based Wolfpass
server platforms with up-to-date bios installed.
Solution:
Instead of just bailing out of IOMMU
initialization when such a condition is found,
we report it and continue. The IOMMU ends
up successfully initialized anyway. We do this
only on platforms that have the Skylake bridges
where this issue has been seen.
This change is inspired by a similar one posted by
Lu Baolu of Intel Corp to lkml
https://lkml.org/lkml/2019/12/24/15
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/iommu/intel/dmar.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index 02e7c10a4224..7d423ac36a44 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -66,6 +66,26 @@ static void free_iommu(struct intel_iommu *iommu);
extern const struct iommu_ops intel_iommu_ops;
+static int scope_mismatch_quirk;
+static void quirk_dmar_scope_mismatch(struct pci_dev *dev)
+{
+ pci_info(dev, "scope mismatch ignored\n");
+ scope_mismatch_quirk = 1;
+}
+
+/*
+ * We expect devices with endpoint scope to have normal PCI
+ * headers, and devices with bridge scope to have bridge PCI
+ * headers. However some PCI devices may be listed in the
+ * DMAR table with bridge scope, even though they have a
+ * normal PCI header and vice versa. We don't declare a
+ * scope mismatch for the special cases below, even though
+ * the bios creates broken tables.
+ */
+/* Sky Lake-E PCI Express Root Port A */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2030,
+ quirk_dmar_scope_mismatch);
+
static void dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
{
/*
@@ -255,7 +275,10 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
info->dev->class >> 16 != PCI_BASE_CLASS_BRIDGE))) {
pr_warn("Device scope type does not match for %s\n",
pci_name(info->dev));
- return -EINVAL;
+ if (!scope_mismatch_quirk)
+ return -EINVAL;
+ else
+ pr_warn("but continuing anyway\n");
}
for_each_dev_scope(devices, devices_cnt, i, tmp)
--
2.29.2

View File

@ -1,100 +0,0 @@
From 451738188482a34603a184e868893f407998bdd4 Mon Sep 17 00:00:00 2001
From: Nayna Jain <nayna@linux.vnet.ibm.com>
Date: Fri, 10 Nov 2017 17:16:35 -0500
Subject: [PATCH 08/10] tpm: ignore burstcount to improve tpm_tis send()
performance
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The TPM burstcount status indicates the number of bytes that can
be sent to the TPM without causing bus wait states.  Effectively,
it is the number of empty bytes in the command FIFO.
This patch optimizes the tpm_tis_send_data() function by checking
the burstcount only once. And if the burstcount is valid, it writes
all the bytes at once, permitting wait state.
After this change, performance on a TPM 1.2 with an 8 byte
burstcount for 1000 extends improved from ~41sec to ~14sec.
Suggested-by: Ken Goldman <kgold@linux.vnet.ibm.com> in
conjunction with the TPM Device Driver work group.
Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Dongqi Chen <chen.dq@neusoft.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/char/tpm/tpm_tis_core.c | 43 ++++++++++++---------------------
1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index a2e0395cbe61..2c69fde1e4e5 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -330,7 +330,6 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
{
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
int rc, status, burstcnt;
- size_t count = 0;
bool itpm = priv->flags & TPM_TIS_ITPM_WORKAROUND;
status = tpm_tis_status(chip);
@@ -343,36 +342,24 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
goto out_err;
}
}
-
- while (count < len - 1) {
- burstcnt = get_burstcount(chip);
- if (burstcnt < 0) {
- dev_err(&chip->dev, "Unable to read burstcount\n");
- rc = burstcnt;
- goto out_err;
- }
- burstcnt = min_t(int, burstcnt, len - count - 1);
- rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality),
- burstcnt, buf + count);
- if (rc < 0)
- goto out_err;
-
- count += burstcnt;
-
- if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
- status = tpm_tis_status(chip);
- if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
- rc = -EIO;
- goto out_err;
- }
+ /*
+ * Get the initial burstcount to ensure TPM is ready to
+ * accept data, even when waiting for burstcount is disabled.
+ */
+ burstcnt = get_burstcount(chip);
+ if (burstcnt < 0) {
+ dev_err(&chip->dev, "Unable to read burstcount\n");
+ rc = burstcnt;
+ goto out_err;
}
+ rc = tpm_tis_write_bytes(priv, TPM_DATA_FIFO(priv->locality),
+ len -1, buf);
+ if (rc < 0)
+ goto out_err;
+
/* write last byte */
- rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[count]);
+ rc = tpm_tis_write8(priv, TPM_DATA_FIFO(priv->locality), buf[len-1]);
if (rc < 0)
goto out_err;
--
2.29.2

View File

@ -1,395 +0,0 @@
From b377b8aed56d93aef67f7dbad01d026bacffedb1 Mon Sep 17 00:00:00 2001
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Tue, 14 Sep 2021 01:07:57 +0200
Subject: [PATCH] bpf, cgroups: Fix cgroup v2 fallback on v1/v2 mixed mode
Fix cgroup v1 interference when non-root cgroup v2 BPF programs are used.
Back in the days, commit bd1060a1d671 ("sock, cgroup: add sock->sk_cgroup")
embedded per-socket cgroup information into sock->sk_cgrp_data and in order
to save 8 bytes in struct sock made both mutually exclusive, that is, when
cgroup v1 socket tagging (e.g. net_cls/net_prio) is used, then cgroup v2
falls back to the root cgroup in sock_cgroup_ptr() (&cgrp_dfl_root.cgrp).
The assumption made was "there is no reason to mix the two and this is in line
with how legacy and v2 compatibility is handled" as stated in bd1060a1d671.
However, with Kubernetes more widely supporting cgroups v2 as well nowadays,
this assumption no longer holds, and the possibility of the v1/v2 mixed mode
with the v2 root fallback being hit becomes a real security issue.
Many of the cgroup v2 BPF programs are also used for policy enforcement, just
to pick _one_ example, that is, to programmatically deny socket related system
calls like connect(2) or bind(2). A v2 root fallback would implicitly cause
a policy bypass for the affected Pods.
In production environments, we have recently seen this case due to various
circumstances: i) a different 3rd party agent and/or ii) a container runtime
such as [0] in the user's environment configuring legacy cgroup v1 net_cls
tags, which triggered implicitly mentioned root fallback. Another case is
Kubernetes projects like kind [1] which create Kubernetes nodes in a container
and also add cgroup namespaces to the mix, meaning programs which are attached
to the cgroup v2 root of the cgroup namespace get attached to a non-root
cgroup v2 path from init namespace point of view. And the latter's root is
out of reach for agents on a kind Kubernetes node to configure. Meaning, any
entity on the node setting cgroup v1 net_cls tag will trigger the bypass
despite cgroup v2 BPF programs attached to the namespace root.
Generally, this mutual exclusiveness does not hold anymore in today's user
environments and makes cgroup v2 usage from BPF side fragile and unreliable.
This fix adds proper struct cgroup pointer for the cgroup v2 case to struct
sock_cgroup_data in order to address these issues; this implicitly also fixes
the tradeoffs being made back then with regards to races and refcount leaks
as stated in bd1060a1d671, and removes the fallback, so that cgroup v2 BPF
programs always operate as expected.
[0] https://github.com/nestybox/sysbox/
[1] https://kind.sigs.k8s.io/
Fixes: bd1060a1d671 ("sock, cgroup: add sock->sk_cgroup")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/bpf/20210913230759.2313-1-daniel@iogearbox.net
(cherry picked from commit 8520e224f547cd070c7c8f97b1fc6d58cff7ccaa)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
include/linux/cgroup-defs.h | 107 +++++++++--------------------------
include/linux/cgroup.h | 22 +------
kernel/cgroup/cgroup.c | 50 ++++------------
net/core/netclassid_cgroup.c | 7 +--
net/core/netprio_cgroup.c | 10 +---
5 files changed, 41 insertions(+), 155 deletions(-)
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index fee0b5547cd0..3e406626168a 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -763,107 +763,54 @@ static inline void cgroup_threadgroup_change_end(struct task_struct *tsk) {}
* sock_cgroup_data is embedded at sock->sk_cgrp_data and contains
* per-socket cgroup information except for memcg association.
*
- * On legacy hierarchies, net_prio and net_cls controllers directly set
- * attributes on each sock which can then be tested by the network layer.
- * On the default hierarchy, each sock is associated with the cgroup it was
- * created in and the networking layer can match the cgroup directly.
- *
- * To avoid carrying all three cgroup related fields separately in sock,
- * sock_cgroup_data overloads (prioidx, classid) and the cgroup pointer.
- * On boot, sock_cgroup_data records the cgroup that the sock was created
- * in so that cgroup2 matches can be made; however, once either net_prio or
- * net_cls starts being used, the area is overriden to carry prioidx and/or
- * classid. The two modes are distinguished by whether the lowest bit is
- * set. Clear bit indicates cgroup pointer while set bit prioidx and
- * classid.
- *
- * While userland may start using net_prio or net_cls at any time, once
- * either is used, cgroup2 matching no longer works. There is no reason to
- * mix the two and this is in line with how legacy and v2 compatibility is
- * handled. On mode switch, cgroup references which are already being
- * pointed to by socks may be leaked. While this can be remedied by adding
- * synchronization around sock_cgroup_data, given that the number of leaked
- * cgroups is bound and highly unlikely to be high, this seems to be the
- * better trade-off.
+ * On legacy hierarchies, net_prio and net_cls controllers directly
+ * set attributes on each sock which can then be tested by the network
+ * layer. On the default hierarchy, each sock is associated with the
+ * cgroup it was created in and the networking layer can match the
+ * cgroup directly.
*/
struct sock_cgroup_data {
- union {
-#ifdef __LITTLE_ENDIAN
- struct {
- u8 is_data : 1;
- u8 no_refcnt : 1;
- u8 unused : 6;
- u8 padding;
- u16 prioidx;
- u32 classid;
- } __packed;
-#else
- struct {
- u32 classid;
- u16 prioidx;
- u8 padding;
- u8 unused : 6;
- u8 no_refcnt : 1;
- u8 is_data : 1;
- } __packed;
+ struct cgroup *cgroup; /* v2 */
+#ifdef CONFIG_CGROUP_NET_CLASSID
+ u32 classid; /* v1 */
+#endif
+#ifdef CONFIG_CGROUP_NET_PRIO
+ u16 prioidx; /* v1 */
#endif
- u64 val;
- };
};
-/*
- * There's a theoretical window where the following accessors race with
- * updaters and return part of the previous pointer as the prioidx or
- * classid. Such races are short-lived and the result isn't critical.
- */
static inline u16 sock_cgroup_prioidx(const struct sock_cgroup_data *skcd)
{
- /* fallback to 1 which is always the ID of the root cgroup */
- return (skcd->is_data & 1) ? skcd->prioidx : 1;
+#ifdef CONFIG_CGROUP_NET_PRIO
+ return READ_ONCE(skcd->prioidx);
+#else
+ return 1;
+#endif
}
static inline u32 sock_cgroup_classid(const struct sock_cgroup_data *skcd)
{
- /* fallback to 0 which is the unconfigured default classid */
- return (skcd->is_data & 1) ? skcd->classid : 0;
+#ifdef CONFIG_CGROUP_NET_CLASSID
+ return READ_ONCE(skcd->classid);
+#else
+ return 0;
+#endif
}
-/*
- * If invoked concurrently, the updaters may clobber each other. The
- * caller is responsible for synchronization.
- */
static inline void sock_cgroup_set_prioidx(struct sock_cgroup_data *skcd,
u16 prioidx)
{
- struct sock_cgroup_data skcd_buf = {{ .val = READ_ONCE(skcd->val) }};
-
- if (sock_cgroup_prioidx(&skcd_buf) == prioidx)
- return;
-
- if (!(skcd_buf.is_data & 1)) {
- skcd_buf.val = 0;
- skcd_buf.is_data = 1;
- }
-
- skcd_buf.prioidx = prioidx;
- WRITE_ONCE(skcd->val, skcd_buf.val); /* see sock_cgroup_ptr() */
+#ifdef CONFIG_CGROUP_NET_PRIO
+ WRITE_ONCE(skcd->prioidx, prioidx);
+#endif
}
static inline void sock_cgroup_set_classid(struct sock_cgroup_data *skcd,
u32 classid)
{
- struct sock_cgroup_data skcd_buf = {{ .val = READ_ONCE(skcd->val) }};
-
- if (sock_cgroup_classid(&skcd_buf) == classid)
- return;
-
- if (!(skcd_buf.is_data & 1)) {
- skcd_buf.val = 0;
- skcd_buf.is_data = 1;
- }
-
- skcd_buf.classid = classid;
- WRITE_ONCE(skcd->val, skcd_buf.val); /* see sock_cgroup_ptr() */
+#ifdef CONFIG_CGROUP_NET_CLASSID
+ WRITE_ONCE(skcd->classid, classid);
+#endif
}
#else /* CONFIG_SOCK_CGROUP_DATA */
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 618838c48313..9c88b7da3245 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -816,33 +816,13 @@ static inline void cgroup_account_cputime_field(struct task_struct *task,
*/
#ifdef CONFIG_SOCK_CGROUP_DATA
-#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
-extern spinlock_t cgroup_sk_update_lock;
-#endif
-
-void cgroup_sk_alloc_disable(void);
void cgroup_sk_alloc(struct sock_cgroup_data *skcd);
void cgroup_sk_clone(struct sock_cgroup_data *skcd);
void cgroup_sk_free(struct sock_cgroup_data *skcd);
static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
{
-#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
- unsigned long v;
-
- /*
- * @skcd->val is 64bit but the following is safe on 32bit too as we
- * just need the lower ulong to be written and read atomically.
- */
- v = READ_ONCE(skcd->val);
-
- if (v & 3)
- return &cgrp_dfl_root.cgrp;
-
- return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp;
-#else
- return (struct cgroup *)(unsigned long)skcd->val;
-#endif
+ return skcd->cgroup;
}
#else /* CONFIG_CGROUP_DATA */
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index c8b811e039cc..e065307f2346 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6419,74 +6419,44 @@ int cgroup_parse_float(const char *input, unsigned dec_shift, s64 *v)
*/
#ifdef CONFIG_SOCK_CGROUP_DATA
-#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
-
-DEFINE_SPINLOCK(cgroup_sk_update_lock);
-static bool cgroup_sk_alloc_disabled __read_mostly;
-
-void cgroup_sk_alloc_disable(void)
-{
- if (cgroup_sk_alloc_disabled)
- return;
- pr_info("cgroup: disabling cgroup2 socket matching due to net_prio or net_cls activation\n");
- cgroup_sk_alloc_disabled = true;
-}
-
-#else
-
-#define cgroup_sk_alloc_disabled false
-
-#endif
-
void cgroup_sk_alloc(struct sock_cgroup_data *skcd)
{
- if (cgroup_sk_alloc_disabled) {
- skcd->no_refcnt = 1;
- return;
- }
-
/* Don't associate the sock with unrelated interrupted task's cgroup. */
if (in_interrupt())
return;
rcu_read_lock();
-
while (true) {
struct css_set *cset;
cset = task_css_set(current);
if (likely(cgroup_tryget(cset->dfl_cgrp))) {
- skcd->val = (unsigned long)cset->dfl_cgrp;
+ skcd->cgroup = cset->dfl_cgrp;
cgroup_bpf_get(cset->dfl_cgrp);
break;
}
cpu_relax();
}
-
rcu_read_unlock();
}
void cgroup_sk_clone(struct sock_cgroup_data *skcd)
{
- if (skcd->val) {
- if (skcd->no_refcnt)
- return;
- /*
- * We might be cloning a socket which is left in an empty
- * cgroup and the cgroup might have already been rmdir'd.
- * Don't use cgroup_get_live().
- */
- cgroup_get(sock_cgroup_ptr(skcd));
- cgroup_bpf_get(sock_cgroup_ptr(skcd));
- }
+ struct cgroup *cgrp = sock_cgroup_ptr(skcd);
+
+ /*
+ * We might be cloning a socket which is left in an empty
+ * cgroup and the cgroup might have already been rmdir'd.
+ * Don't use cgroup_get_live().
+ */
+ cgroup_get(cgrp);
+ cgroup_bpf_get(cgrp);
}
void cgroup_sk_free(struct sock_cgroup_data *skcd)
{
struct cgroup *cgrp = sock_cgroup_ptr(skcd);
- if (skcd->no_refcnt)
- return;
cgroup_bpf_put(cgrp);
cgroup_put(cgrp);
}
diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
index 41b24cd31562..b6de5ee22391 100644
--- a/net/core/netclassid_cgroup.c
+++ b/net/core/netclassid_cgroup.c
@@ -72,11 +72,8 @@ static int update_classid_sock(const void *v, struct file *file, unsigned n)
struct update_classid_context *ctx = (void *)v;
struct socket *sock = sock_from_file(file, &err);
- if (sock) {
- spin_lock(&cgroup_sk_update_lock);
+ if (sock)
sock_cgroup_set_classid(&sock->sk->sk_cgrp_data, ctx->classid);
- spin_unlock(&cgroup_sk_update_lock);
- }
if (--ctx->batch == 0) {
ctx->batch = UPDATE_CLASSID_BATCH;
return n + 1;
@@ -122,8 +119,6 @@ static int write_classid(struct cgroup_subsys_state *css, struct cftype *cft,
struct css_task_iter it;
struct task_struct *p;
- cgroup_sk_alloc_disable();
-
cs->classid = (u32)value;
css_task_iter_start(css, 0, &it);
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 9bd4cab7d510..d4c71e382a13 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -207,8 +207,6 @@ static ssize_t write_priomap(struct kernfs_open_file *of,
if (!dev)
return -ENODEV;
- cgroup_sk_alloc_disable();
-
rtnl_lock();
ret = netprio_set_prio(of_css(of), dev, prio);
@@ -222,12 +220,10 @@ static int update_netprio(const void *v, struct file *file, unsigned n)
{
int err;
struct socket *sock = sock_from_file(file, &err);
- if (sock) {
- spin_lock(&cgroup_sk_update_lock);
+
+ if (sock)
sock_cgroup_set_prioidx(&sock->sk->sk_cgrp_data,
(unsigned long)v);
- spin_unlock(&cgroup_sk_update_lock);
- }
return 0;
}
@@ -236,8 +232,6 @@ static void net_prio_attach(struct cgroup_taskset *tset)
struct task_struct *p;
struct cgroup_subsys_state *css;
- cgroup_sk_alloc_disable();
-
cgroup_taskset_for_each(p, css, tset) {
void *v = (void *)(unsigned long)css->id;
--
2.29.2

View File

@ -1,41 +0,0 @@
From 2a32d5bc7e385fbf40f22cc413354e17a24d4de9 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Sun, 10 Oct 2021 18:56:26 -0700
Subject: [PATCH] scsi: smartpqi: Enable sas_address sysfs for SATA device
type.
We met the issue DM complains that it can't find the disk specified
in the deployment config file after we updated the Linux kernel to 5.10.
The error is "failed to find disk for path /dev/disk/by-path/
pci-0000:3b:00.0-sas-0x31402ec001d92983-lun-0"
This happens because device type SATA is excluded from being
processed with the function pqi_is_device_with_sas_address.
which causes all SATA type disk drives to appear the same, having
zeroes in the lun name. /dev/disk/by-path/
pci-0000:3b:00.0-sas-0x0000000000000000-lun-0
We can add type SA_DEVICE_TYPE_SATA to class device_with_sas_address,
since it will also get the sas_address from wwid. and works transparently
with the old kernel without gaps.
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index ecb2af3f43ca..df16e0a27a41 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2101,6 +2101,7 @@ static inline void pqi_mask_device(u8 *scsi3addr)
static inline bool pqi_is_device_with_sas_address(struct pqi_scsi_dev *device)
{
switch (device->device_type) {
+ case SA_DEVICE_TYPE_SATA:
case SA_DEVICE_TYPE_SAS:
case SA_DEVICE_TYPE_EXPANDER_SMP:
case SA_DEVICE_TYPE_SES:
--
2.31.1

View File

@ -1,61 +0,0 @@
From ee39df8a1626eb35797b0f9943dc881752c36588 Mon Sep 17 00:00:00 2001
From: "M. Vefa Bicakci" <vefa.bicakci@windriver.com>
Date: Thu, 9 Sep 2021 04:56:46 -0400
Subject: [PATCH] workqueue: Affine rescuer threads and unbound wqs
This commit ensures that workqueue rescuer threads are affined to the
platform CPUs specified by the "kthread_cpus" kernel argument. Prior to
this commit, rescuer threads could be bound to any CPU. Rescuer threads
are described in "kernel/workqueue.c" as follows:
"Regular work processing on a pool may block trying to create a new
worker which uses GFP_KERNEL allocation which has slight chance of
developing into deadlock if some works currently on the same queue
need to be processed to satisfy the GFP_KERNEL allocation. This is
the problem rescuer solves.
When such condition is possible, the pool summons rescuers of all
workqueues which have works queued on the pool and let them process
those works so that forward progress can be guaranteed."
This commit also affines unbound workqueues to the platform CPUs instead
of the housekeeping CPUs, because the latter can be a superset of the
former.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
kernel/workqueue.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d6bdf3ad61e9..43f11a383cba 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4242,7 +4242,7 @@ static int init_rescuer(struct workqueue_struct *wq)
}
wq->rescuer = rescuer;
- kthread_bind_mask(rescuer->task, cpu_possible_mask);
+ kthread_bind_mask(rescuer->task, cpu_kthread_mask);
wake_up_process(rescuer->task);
return 0;
@@ -5937,13 +5937,12 @@ static void __init wq_numa_init(void)
void __init workqueue_init_early(void)
{
int std_nice[NR_STD_WORKER_POOLS] = { 0, HIGHPRI_NICE_LEVEL };
- int hk_flags = HK_FLAG_DOMAIN | HK_FLAG_WQ;
int i, cpu;
BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long));
BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL));
- cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(hk_flags));
+ cpumask_copy(wq_unbound_cpumask, cpu_kthread_mask);
pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
--
2.29.2

View File

@ -1,167 +0,0 @@
From 42f1ccc21f873a27c125a4e1aa3cb70a2336aa14 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 8 Dec 2021 17:49:56 -0800
Subject: [PATCH] Revert "scsi: sd: Inline sd_probe_part2()"
This reverts commit 82a54da641f3cacfa31db36fc58a5e903f804c22.
Merge conflicts were encountered when reverting this commit, which
inlines sd_probe_part2() into sd_probe(). However, the inlined parts
of sd_probe_part2() have since been modified. To avoid a difference
in behaviour, the updated code was relocated to sd_probe_part2().
The inlined code has been modified as follows since the inlining
happened:
The following code was added
if (sdp->rpm_autosuspend) {
pm_runtime_set_autosuspend_delay(dev,
sdp->host->hostt->rpm_autosuspend_delay);
}
between the following line
blk_pm_runtime_init(sdp->request_queue, dev);
and the following line
device_add_disk(dev, gd, NULL);
In addition, init_opal_dev() is now passed the pointer "sdkp"
instead of "sdp" as the first argument. This commit ensures that
these two changes were accounted for when reverting the inlining
of sd_probe_part2().
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/sd.c | 111 ++++++++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 48 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 56e291708587..d1d27516fc6a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3364,6 +3364,68 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
return 0;
}
+static void sd_probe_part2(struct scsi_disk *sdkp)
+{
+ struct scsi_device *sdp;
+ struct gendisk *gd;
+ u32 index;
+ struct device *dev;
+
+ sdp = sdkp->device;
+ gd = sdkp->disk;
+ index = sdkp->index;
+ dev = &sdp->sdev_gendev;
+
+ gd->major = sd_major((index & 0xf0) >> 4);
+ gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
+
+ gd->fops = &sd_fops;
+ gd->private_data = &sdkp->driver;
+ gd->queue = sdkp->device->request_queue;
+
+ /* defaults, until the device tells us otherwise */
+ sdp->sector_size = 512;
+ sdkp->capacity = 0;
+ sdkp->media_present = 1;
+ sdkp->write_prot = 0;
+ sdkp->cache_override = 0;
+ sdkp->WCE = 0;
+ sdkp->RCD = 0;
+ sdkp->ATO = 0;
+ sdkp->first_scan = 1;
+ sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
+
+ sd_revalidate_disk(gd);
+
+ gd->flags = GENHD_FL_EXT_DEVT;
+ if (sdp->removable) {
+ gd->flags |= GENHD_FL_REMOVABLE;
+ gd->events |= DISK_EVENT_MEDIA_CHANGE;
+ gd->event_flags = DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
+ }
+
+ blk_pm_runtime_init(sdp->request_queue, dev);
+ if (sdp->rpm_autosuspend) {
+ pm_runtime_set_autosuspend_delay(dev,
+ sdp->host->hostt->rpm_autosuspend_delay);
+ }
+ device_add_disk(dev, gd, NULL);
+ if (sdkp->capacity)
+ sd_dif_config_host(sdkp);
+
+ sd_revalidate_disk(gd);
+
+ if (sdkp->security) {
+ sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
+ if (sdkp->opal_dev)
+ sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
+ }
+
+ sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
+ sdp->removable ? "removable " : "");
+ scsi_autopm_put_device(sdp);
+}
+
/**
* sd_probe - called during driver initialization and whenever a
* new scsi device is attached to the system. It is called once
@@ -3455,54 +3517,7 @@ static int sd_probe(struct device *dev)
dev_set_drvdata(dev, sdkp);
- gd->major = sd_major((index & 0xf0) >> 4);
- gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
-
- gd->fops = &sd_fops;
- gd->private_data = &sdkp->driver;
- gd->queue = sdkp->device->request_queue;
-
- /* defaults, until the device tells us otherwise */
- sdp->sector_size = 512;
- sdkp->capacity = 0;
- sdkp->media_present = 1;
- sdkp->write_prot = 0;
- sdkp->cache_override = 0;
- sdkp->WCE = 0;
- sdkp->RCD = 0;
- sdkp->ATO = 0;
- sdkp->first_scan = 1;
- sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
-
- sd_revalidate_disk(gd);
-
- gd->flags = GENHD_FL_EXT_DEVT;
- if (sdp->removable) {
- gd->flags |= GENHD_FL_REMOVABLE;
- gd->events |= DISK_EVENT_MEDIA_CHANGE;
- gd->event_flags = DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
- }
-
- blk_pm_runtime_init(sdp->request_queue, dev);
- if (sdp->rpm_autosuspend) {
- pm_runtime_set_autosuspend_delay(dev,
- sdp->host->hostt->rpm_autosuspend_delay);
- }
- device_add_disk(dev, gd, NULL);
- if (sdkp->capacity)
- sd_dif_config_host(sdkp);
-
- sd_revalidate_disk(gd);
-
- if (sdkp->security) {
- sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
- if (sdkp->opal_dev)
- sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
- }
-
- sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
- sdp->removable ? "removable " : "");
- scsi_autopm_put_device(sdp);
+ sd_probe_part2(sdkp);
return 0;
--
2.31.1

View File

@ -1,135 +0,0 @@
From b5dad6e67f9704968ca7d4daf1715667cddafa3d Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 8 Dec 2021 18:34:59 -0800
Subject: [PATCH 2/2] Revert commit f049cf1a7b
commit f049cf1a7b "scsi: sd: Rely on the driver core for asynchronous
probing"
This reverts commit f049cf1a7b6737c75884247c3f6383ef104d255a,
and it is a clean revert, there is not any conflict.
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/scsi.c | 12 +++++++++---
drivers/scsi/scsi_pm.c | 6 +++++-
drivers/scsi/scsi_priv.h | 1 +
drivers/scsi/sd.c | 12 +++++++++---
4 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 24619c3bebd5..3080292a16cd 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -86,10 +86,15 @@ unsigned int scsi_logging_level;
EXPORT_SYMBOL(scsi_logging_level);
#endif
+/* sd, scsi core and power management need to coordinate flushing async actions */
+ASYNC_DOMAIN(scsi_sd_probe_domain);
+EXPORT_SYMBOL(scsi_sd_probe_domain);
+
/*
- * Domain for asynchronous system resume operations. It is marked 'exclusive'
- * to avoid being included in the async_synchronize_full() that is invoked by
- * dpm_resume().
+ * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of
+ * asynchronous system resume operations. It is marked 'exclusive' to avoid
+ * being included in the async_synchronize_full() that is invoked by
+ * dpm_resume()
*/
ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
EXPORT_SYMBOL(scsi_sd_pm_domain);
@@ -799,6 +804,7 @@ static void __exit exit_scsi(void)
scsi_exit_devinfo();
scsi_exit_procfs();
scsi_exit_queue();
+ async_unregister_domain(&scsi_sd_probe_domain);
}
subsys_initcall(init_scsi);
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index 3717eea37ecb..b3d71b516213 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -175,7 +175,11 @@ static int scsi_bus_resume_common(struct device *dev,
static int scsi_bus_prepare(struct device *dev)
{
- if (scsi_is_host_device(dev)) {
+ if (scsi_is_sdev_device(dev)) {
+ /* sd probing uses async_schedule. Wait until it finishes. */
+ async_synchronize_full_domain(&scsi_sd_probe_domain);
+
+ } else if (scsi_is_host_device(dev)) {
/* Wait until async scanning is finished */
scsi_complete_async_scans();
}
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 180636d54982..c43456f0870c 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -172,6 +172,7 @@ static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
#endif /* CONFIG_PM */
extern struct async_domain scsi_sd_pm_domain;
+extern struct async_domain scsi_sd_probe_domain;
/* scsi_dh.c */
#ifdef CONFIG_SCSI_DH
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2e22ee4501e7..e6c70475f084 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -616,7 +616,6 @@ static struct scsi_driver sd_template = {
.name = "sd",
.owner = THIS_MODULE,
.probe = sd_probe,
- .probe_type = PROBE_PREFER_ASYNCHRONOUS,
.remove = sd_remove,
.shutdown = sd_shutdown,
.pm = &sd_pm_ops,
@@ -3364,8 +3363,12 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
return 0;
}
-static void sd_probe_part2(struct scsi_disk *sdkp)
+/*
+ * The asynchronous part of sd_probe
+ */
+static void sd_probe_async(void *data, async_cookie_t cookie)
{
+ struct scsi_disk *sdkp = data;
struct scsi_device *sdp;
struct gendisk *gd;
u32 index;
@@ -3424,6 +3427,7 @@ static void sd_probe_part2(struct scsi_disk *sdkp)
sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
sdp->removable ? "removable " : "");
scsi_autopm_put_device(sdp);
+ put_device(&sdkp->dev);
}
/**
@@ -3517,7 +3521,8 @@ static int sd_probe(struct device *dev)
dev_set_drvdata(dev, sdkp);
- sd_probe_part2(sdkp);
+ get_device(&sdkp->dev); /* prevent release before async_schedule */
+ async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
return 0;
@@ -3554,6 +3559,7 @@ static int sd_remove(struct device *dev)
scsi_autopm_get_device(sdkp->device);
async_synchronize_full_domain(&scsi_sd_pm_domain);
+ async_synchronize_full_domain(&scsi_sd_probe_domain);
device_del(&sdkp->dev);
del_gendisk(sdkp->disk);
sd_shutdown(dev);
--
2.31.1

View File

@ -1,124 +0,0 @@
From 7c2dc6277376104f8cfe7f8d07c77f6d7155fb73 Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 18 May 2021 11:17:26 +0200
Subject: [PATCH] genirq: Export affinity setter for modules
Perf modules abuse irq_set_affinity_hint() to set the affinity of system
PMU interrupts just because irq_set_affinity() was not exported.
The fact that irq_set_affinity_hint() actually sets the affinity is a
non-documented side effect and the name is clearly saying it's a hint.
To clean this up, export the real affinity setter.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20210518093117.968251441@linutronix.de
(cherry picked from commit 4d80d6ca5d77fde9880da8466e5b64f250e5bf82)
[mvb: Adjust context for a function that does not exist in v5.10.]
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
include/linux/interrupt.h | 35 ++---------------------------------
kernel/irq/manage.c | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index ee8299eb1f52..087a1cfad35c 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -314,39 +314,8 @@ struct irq_affinity_desc {
extern cpumask_var_t irq_default_affinity;
-/* Internal implementation. Use the helpers below */
-extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
- bool force);
-
-/**
- * irq_set_affinity - Set the irq affinity of a given irq
- * @irq: Interrupt to set affinity
- * @cpumask: cpumask
- *
- * Fails if cpumask does not contain an online CPU
- */
-static inline int
-irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
-{
- return __irq_set_affinity(irq, cpumask, false);
-}
-
-/**
- * irq_force_affinity - Force the irq affinity of a given irq
- * @irq: Interrupt to set affinity
- * @cpumask: cpumask
- *
- * Same as irq_set_affinity, but without checking the mask against
- * online cpus.
- *
- * Solely for low level cpu hotplug code, where we need to make per
- * cpu interrupts affine before the cpu becomes online.
- */
-static inline int
-irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
-{
- return __irq_set_affinity(irq, cpumask, true);
-}
+extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
+extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);
extern int irq_can_set_affinity(unsigned int irq);
extern int irq_select_affinity(unsigned int irq);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 420b5ce0bf89..eeedb6224e2f 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -371,7 +371,8 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
return ret;
}
-int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
+static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask,
+ bool force)
{
struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
@@ -386,6 +387,36 @@ int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
return ret;
}
+/**
+ * irq_set_affinity - Set the irq affinity of a given irq
+ * @irq: Interrupt to set affinity
+ * @cpumask: cpumask
+ *
+ * Fails if cpumask does not contain an online CPU
+ */
+int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+ return __irq_set_affinity(irq, cpumask, false);
+}
+EXPORT_SYMBOL_GPL(irq_set_affinity);
+
+/**
+ * irq_force_affinity - Force the irq affinity of a given irq
+ * @irq: Interrupt to set affinity
+ * @cpumask: cpumask
+ *
+ * Same as irq_set_affinity, but without checking the mask against
+ * online cpus.
+ *
+ * Solely for low level cpu hotplug code, where we need to make per
+ * cpu interrupts affine before the cpu becomes online.
+ */
+int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+ return __irq_set_affinity(irq, cpumask, true);
+}
+EXPORT_SYMBOL_GPL(irq_force_affinity);
+
int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
{
unsigned long flags;
--
2.29.2

View File

@ -1,146 +0,0 @@
From d4b260fea6b5d7f0da84236f97b385312ab2e0ac Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 3 Sep 2021 11:24:17 -0400
Subject: [PATCH] genirq: Provide new interfaces for affinity hints
The discussion about removing the side effect of irq_set_affinity_hint() of
actually applying the cpumask (if not NULL) as affinity to the interrupt,
unearthed a few unpleasantries:
1) The modular perf drivers rely on the current behaviour for the very
wrong reasons.
2) While none of the other drivers prevents user space from changing
the affinity, a cursorily inspection shows that there are at least
expectations in some drivers.
#1 needs to be cleaned up anyway, so that's not a problem
#2 might result in subtle regressions especially when irqbalanced (which
nowadays ignores the affinity hint) is disabled.
Provide new interfaces:
irq_update_affinity_hint() - Only sets the affinity hint pointer
irq_set_affinity_and_hint() - Set the pointer and apply the affinity to
the interrupt
Make irq_set_affinity_hint() a wrapper around irq_apply_affinity_hint() and
document it to be phased out.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com
Link: https://lore.kernel.org/r/20210903152430.244937-2-nitesh@redhat.com
(cherry picked from commit 65c7cdedeb3026fabcc967a7aae2f755ad4d0783)
[mvb: Adapt to v5.10 by resolving a minor merge conflict.]
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
include/linux/interrupt.h | 52 ++++++++++++++++++++++++++++++++++++++-
kernel/irq/manage.c | 8 +++---
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 087a1cfad35c..72350bdee846 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -320,7 +320,45 @@ extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);
extern int irq_can_set_affinity(unsigned int irq);
extern int irq_select_affinity(unsigned int irq);
-extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
+extern int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
+ bool setaffinity);
+
+/**
+ * irq_update_affinity_hint - Update the affinity hint
+ * @irq: Interrupt to update
+ * @m: cpumask pointer (NULL to clear the hint)
+ *
+ * Updates the affinity hint, but does not change the affinity of the interrupt.
+ */
+static inline int
+irq_update_affinity_hint(unsigned int irq, const struct cpumask *m)
+{
+ return __irq_apply_affinity_hint(irq, m, false);
+}
+
+/**
+ * irq_set_affinity_and_hint - Update the affinity hint and apply the provided
+ * cpumask to the interrupt
+ * @irq: Interrupt to update
+ * @m: cpumask pointer (NULL to clear the hint)
+ *
+ * Updates the affinity hint and if @m is not NULL it applies it as the
+ * affinity of that interrupt.
+ */
+static inline int
+irq_set_affinity_and_hint(unsigned int irq, const struct cpumask *m)
+{
+ return __irq_apply_affinity_hint(irq, m, true);
+}
+
+/*
+ * Deprecated. Use irq_update_affinity_hint() or irq_set_affinity_and_hint()
+ * instead.
+ */
+static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
+{
+ return irq_set_affinity_and_hint(irq, m);
+}
extern int
irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
@@ -350,6 +388,18 @@ static inline int irq_can_set_affinity(unsigned int irq)
static inline int irq_select_affinity(unsigned int irq) { return 0; }
+static inline int irq_update_affinity_hint(unsigned int irq,
+ const struct cpumask *m)
+{
+ return -EINVAL;
+}
+
+static inline int irq_set_affinity_and_hint(unsigned int irq,
+ const struct cpumask *m)
+{
+ return -EINVAL;
+}
+
static inline int irq_set_affinity_hint(unsigned int irq,
const struct cpumask *m)
{
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index eeedb6224e2f..63e7de3683d2 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -417,7 +417,8 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
}
EXPORT_SYMBOL_GPL(irq_force_affinity);
-int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
+int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
+ bool setaffinity)
{
unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
@@ -426,12 +427,11 @@ int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
return -EINVAL;
desc->affinity_hint = m;
irq_put_desc_unlock(desc, flags);
- /* set the initial affinity to prevent every interrupt being on CPU0 */
- if (m)
+ if (m && setaffinity)
__irq_set_affinity(irq, m, false);
return 0;
}
-EXPORT_SYMBOL_GPL(irq_set_affinity_hint);
+EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint);
static void irq_affinity_notify(struct work_struct *work)
{
--
2.29.2

View File

@ -1,64 +0,0 @@
From 07298341feaa2c35fdd225735b4ee5299efb112f Mon Sep 17 00:00:00 2001
From: Nitesh Narayan Lal <nitesh@redhat.com>
Date: Fri, 3 Sep 2021 11:24:25 -0400
Subject: [PATCH] ixgbe: Use irq_update_affinity_hint()
The driver uses irq_set_affinity_hint() to update the affinity_hint mask
that is consumed by the userspace to distribute the interrupts. However,
under the hood irq_set_affinity_hint() also applies the provided cpumask
(if not NULL) as the affinity for the given interrupt which is an
undocumented side effect.
To remove this side effect irq_set_affinity_hint() has been marked
as deprecated and new interfaces have been introduced. Hence, replace the
irq_set_affinity_hint() with the new interface irq_update_affinity_hint()
that only updates the affinity_hint pointer.
Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Link: https://lore.kernel.org/r/20210903152430.244937-10-nitesh@redhat.com
(cherry picked from commit cc493264c01d055742a34cfbaecaffb258dcc58c)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index ffe322136c58..fe10776d8479 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3250,8 +3250,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
/* If Flow Director is enabled, set interrupt affinity */
if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
/* assign the mask for this irq */
- irq_set_affinity_hint(entry->vector,
- &q_vector->affinity_mask);
+ irq_update_affinity_hint(entry->vector,
+ &q_vector->affinity_mask);
}
}
@@ -3267,8 +3267,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)
free_queue_irqs:
while (vector) {
vector--;
- irq_set_affinity_hint(adapter->msix_entries[vector].vector,
- NULL);
+ irq_update_affinity_hint(adapter->msix_entries[vector].vector,
+ NULL);
free_irq(adapter->msix_entries[vector].vector,
adapter->q_vector[vector]);
}
@@ -3401,7 +3401,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)
continue;
/* clear the affinity_mask in the IRQ descriptor */
- irq_set_affinity_hint(entry->vector, NULL);
+ irq_update_affinity_hint(entry->vector, NULL);
free_irq(entry->vector, q_vector);
}
--
2.29.2

View File

@ -1,743 +0,0 @@
From a6492f505f12f830372636043098ad9dab3607d6 Mon Sep 17 00:00:00 2001
From: Dave Ertman <david.m.ertman@intel.com>
Date: Wed, 2 Dec 2020 16:54:24 -0800
Subject: [PATCH] Add auxiliary bus support
Add support for the Auxiliary Bus, auxiliary_device and auxiliary_driver.
It enables drivers to create an auxiliary_device and bind an
auxiliary_driver to it.
The bus supports probe/remove shutdown and suspend/resume callbacks.
Each auxiliary_device has a unique string based id; driver binds to
an auxiliary_device based on this id through the bus.
Co-developed-by: Kiran Patil <kiran.patil@intel.com>
Co-developed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Co-developed-by: Fred Oh <fred.oh@linux.intel.com>
Co-developed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Martin Habets <mhabets@solarflare.com>
Link: https://lore.kernel.org/r/20201113161859.1775473-2-david.m.ertman@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/160695681289.505290.8978295443574440604.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7de3697e9cbd4bd3d62bafa249d57990e1b8f294)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
Documentation/driver-api/auxiliary_bus.rst | 234 ++++++++++++++++++
Documentation/driver-api/index.rst | 1 +
drivers/base/Kconfig | 3 +
drivers/base/Makefile | 1 +
drivers/base/auxiliary.c | 268 +++++++++++++++++++++
include/linux/auxiliary_bus.h | 78 ++++++
include/linux/mod_devicetable.h | 8 +
scripts/mod/devicetable-offsets.c | 3 +
scripts/mod/file2alias.c | 8 +
9 files changed, 604 insertions(+)
create mode 100644 Documentation/driver-api/auxiliary_bus.rst
create mode 100644 drivers/base/auxiliary.c
create mode 100644 include/linux/auxiliary_bus.h
diff --git a/Documentation/driver-api/auxiliary_bus.rst b/Documentation/driver-api/auxiliary_bus.rst
new file mode 100644
index 000000000000..5dd7804631ef
--- /dev/null
+++ b/Documentation/driver-api/auxiliary_bus.rst
@@ -0,0 +1,234 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+=============
+Auxiliary Bus
+=============
+
+In some subsystems, the functionality of the core device (PCI/ACPI/other) is
+too complex for a single device to be managed by a monolithic driver
+(e.g. Sound Open Firmware), multiple devices might implement a common
+intersection of functionality (e.g. NICs + RDMA), or a driver may want to
+export an interface for another subsystem to drive (e.g. SIOV Physical Function
+export Virtual Function management). A split of the functinoality into child-
+devices representing sub-domains of functionality makes it possible to
+compartmentalize, layer, and distribute domain-specific concerns via a Linux
+device-driver model.
+
+An example for this kind of requirement is the audio subsystem where a single
+IP is handling multiple entities such as HDMI, Soundwire, local devices such as
+mics/speakers etc. The split for the core's functionality can be arbitrary or
+be defined by the DSP firmware topology and include hooks for test/debug. This
+allows for the audio core device to be minimal and focused on hardware-specific
+control and communication.
+
+Each auxiliary_device represents a part of its parent functionality. The
+generic behavior can be extended and specialized as needed by encapsulating an
+auxiliary_device within other domain-specific structures and the use of .ops
+callbacks. Devices on the auxiliary bus do not share any structures and the use
+of a communication channel with the parent is domain-specific.
+
+Note that ops are intended as a way to augment instance behavior within a class
+of auxiliary devices, it is not the mechanism for exporting common
+infrastructure from the parent. Consider EXPORT_SYMBOL_NS() to convey
+infrastructure from the parent module to the auxiliary module(s).
+
+
+When Should the Auxiliary Bus Be Used
+=====================================
+
+The auxiliary bus is to be used when a driver and one or more kernel modules,
+who share a common header file with the driver, need a mechanism to connect and
+provide access to a shared object allocated by the auxiliary_device's
+registering driver. The registering driver for the auxiliary_device(s) and the
+kernel module(s) registering auxiliary_drivers can be from the same subsystem,
+or from multiple subsystems.
+
+The emphasis here is on a common generic interface that keeps subsystem
+customization out of the bus infrastructure.
+
+One example is a PCI network device that is RDMA-capable and exports a child
+device to be driven by an auxiliary_driver in the RDMA subsystem. The PCI
+driver allocates and registers an auxiliary_device for each physical
+function on the NIC. The RDMA driver registers an auxiliary_driver that claims
+each of these auxiliary_devices. This conveys data/ops published by the parent
+PCI device/driver to the RDMA auxiliary_driver.
+
+Another use case is for the PCI device to be split out into multiple sub
+functions. For each sub function an auxiliary_device is created. A PCI sub
+function driver binds to such devices that creates its own one or more class
+devices. A PCI sub function auxiliary device is likely to be contained in a
+struct with additional attributes such as user defined sub function number and
+optional attributes such as resources and a link to the parent device. These
+attributes could be used by systemd/udev; and hence should be initialized
+before a driver binds to an auxiliary_device.
+
+A key requirement for utilizing the auxiliary bus is that there is no
+dependency on a physical bus, device, register accesses or regmap support.
+These individual devices split from the core cannot live on the platform bus as
+they are not physical devices that are controlled by DT/ACPI. The same
+argument applies for not using MFD in this scenario as MFD relies on individual
+function devices being physical devices.
+
+Auxiliary Device
+================
+
+An auxiliary_device represents a part of its parent device's functionality. It
+is given a name that, combined with the registering drivers KBUILD_MODNAME,
+creates a match_name that is used for driver binding, and an id that combined
+with the match_name provide a unique name to register with the bus subsystem.
+
+Registering an auxiliary_device is a two-step process. First call
+auxiliary_device_init(), which checks several aspects of the auxiliary_device
+struct and performs a device_initialize(). After this step completes, any
+error state must have a call to auxiliary_device_uninit() in its resolution path.
+The second step in registering an auxiliary_device is to perform a call to
+auxiliary_device_add(), which sets the name of the device and add the device to
+the bus.
+
+Unregistering an auxiliary_device is also a two-step process to mirror the
+register process. First call auxiliary_device_delete(), then call
+auxiliary_device_uninit().
+
+.. code-block:: c
+
+ struct auxiliary_device {
+ struct device dev;
+ const char *name;
+ u32 id;
+ };
+
+If two auxiliary_devices both with a match_name "mod.foo" are registered onto
+the bus, they must have unique id values (e.g. "x" and "y") so that the
+registered devices names are "mod.foo.x" and "mod.foo.y". If match_name + id
+are not unique, then the device_add fails and generates an error message.
+
+The auxiliary_device.dev.type.release or auxiliary_device.dev.release must be
+populated with a non-NULL pointer to successfully register the auxiliary_device.
+
+The auxiliary_device.dev.parent must also be populated.
+
+Auxiliary Device Memory Model and Lifespan
+------------------------------------------
+
+The registering driver is the entity that allocates memory for the
+auxiliary_device and register it on the auxiliary bus. It is important to note
+that, as opposed to the platform bus, the registering driver is wholly
+responsible for the management for the memory used for the driver object.
+
+A parent object, defined in the shared header file, contains the
+auxiliary_device. It also contains a pointer to the shared object(s), which
+also is defined in the shared header. Both the parent object and the shared
+object(s) are allocated by the registering driver. This layout allows the
+auxiliary_driver's registering module to perform a container_of() call to go
+from the pointer to the auxiliary_device, that is passed during the call to the
+auxiliary_driver's probe function, up to the parent object, and then have
+access to the shared object(s).
+
+The memory for the auxiliary_device is freed only in its release() callback
+flow as defined by its registering driver.
+
+The memory for the shared object(s) must have a lifespan equal to, or greater
+than, the lifespan of the memory for the auxiliary_device. The auxiliary_driver
+should only consider that this shared object is valid as long as the
+auxiliary_device is still registered on the auxiliary bus. It is up to the
+registering driver to manage (e.g. free or keep available) the memory for the
+shared object beyond the life of the auxiliary_device.
+
+The registering driver must unregister all auxiliary devices before its own
+driver.remove() is completed.
+
+Auxiliary Drivers
+=================
+
+Auxiliary drivers follow the standard driver model convention, where
+discovery/enumeration is handled by the core, and drivers
+provide probe() and remove() methods. They support power management
+and shutdown notifications using the standard conventions.
+
+.. code-block:: c
+
+ struct auxiliary_driver {
+ int (*probe)(struct auxiliary_device *,
+ const struct auxiliary_device_id *id);
+ int (*remove)(struct auxiliary_device *);
+ void (*shutdown)(struct auxiliary_device *);
+ int (*suspend)(struct auxiliary_device *, pm_message_t);
+ int (*resume)(struct auxiliary_device *);
+ struct device_driver driver;
+ const struct auxiliary_device_id *id_table;
+ };
+
+Auxiliary drivers register themselves with the bus by calling
+auxiliary_driver_register(). The id_table contains the match_names of auxiliary
+devices that a driver can bind with.
+
+Example Usage
+=============
+
+Auxiliary devices are created and registered by a subsystem-level core device
+that needs to break up its functionality into smaller fragments. One way to
+extend the scope of an auxiliary_device is to encapsulate it within a domain-
+pecific structure defined by the parent device. This structure contains the
+auxiliary_device and any associated shared data/callbacks needed to establish
+the connection with the parent.
+
+An example is:
+
+.. code-block:: c
+
+ struct foo {
+ struct auxiliary_device auxdev;
+ void (*connect)(struct auxiliary_device *auxdev);
+ void (*disconnect)(struct auxiliary_device *auxdev);
+ void *data;
+ };
+
+The parent device then registers the auxiliary_device by calling
+auxiliary_device_init(), and then auxiliary_device_add(), with the pointer to
+the auxdev member of the above structure. The parent provides a name for the
+auxiliary_device that, combined with the parent's KBUILD_MODNAME, creates a
+match_name that is be used for matching and binding with a driver.
+
+Whenever an auxiliary_driver is registered, based on the match_name, the
+auxiliary_driver's probe() is invoked for the matching devices. The
+auxiliary_driver can also be encapsulated inside custom drivers that make the
+core device's functionality extensible by adding additional domain-specific ops
+as follows:
+
+.. code-block:: c
+
+ struct my_ops {
+ void (*send)(struct auxiliary_device *auxdev);
+ void (*receive)(struct auxiliary_device *auxdev);
+ };
+
+
+ struct my_driver {
+ struct auxiliary_driver auxiliary_drv;
+ const struct my_ops ops;
+ };
+
+An example of this type of usage is:
+
+.. code-block:: c
+
+ const struct auxiliary_device_id my_auxiliary_id_table[] = {
+ { .name = "foo_mod.foo_dev" },
+ { },
+ };
+
+ const struct my_ops my_custom_ops = {
+ .send = my_tx,
+ .receive = my_rx,
+ };
+
+ const struct my_driver my_drv = {
+ .auxiliary_drv = {
+ .name = "myauxiliarydrv",
+ .id_table = my_auxiliary_id_table,
+ .probe = my_probe,
+ .remove = my_remove,
+ .shutdown = my_shutdown,
+ },
+ .ops = my_custom_ops,
+ };
diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst
index f357f3eb400c..86759a74b7f1 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -72,6 +72,7 @@ available subsections can be seen below.
thermal/index
fpga/index
acpi/index
+ auxiliary_bus
backlight/lp855x-driver.rst
connector
console
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 8d7001712062..040be48ce046 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
menu "Generic Driver Options"
+config AUXILIARY_BUS
+ bool
+
config UEVENT_HELPER
bool "Support for uevent helper"
help
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 41369fc7004f..5e7bf9669a81 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -7,6 +7,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \
attribute_container.o transport_class.o \
topology.o container.o property.o cacheinfo.o \
swnode.o
+obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o
obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
obj-y += power/
obj-$(CONFIG_ISA_BUS_API) += isa.o
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
new file mode 100644
index 000000000000..ef2af417438b
--- /dev/null
+++ b/drivers/base/auxiliary.c
@@ -0,0 +1,268 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2019-2020 Intel Corporation
+ *
+ * Please see Documentation/driver-api/auxiliary_bus.rst for more information.
+ */
+
+#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
+
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
+#include <linux/string.h>
+#include <linux/auxiliary_bus.h>
+
+static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
+ const struct auxiliary_device *auxdev)
+{
+ for (; id->name[0]; id++) {
+ const char *p = strrchr(dev_name(&auxdev->dev), '.');
+ int match_size;
+
+ if (!p)
+ continue;
+ match_size = p - dev_name(&auxdev->dev);
+
+ /* use dev_name(&auxdev->dev) prefix before last '.' char to match to */
+ if (strlen(id->name) == match_size &&
+ !strncmp(dev_name(&auxdev->dev), id->name, match_size))
+ return id;
+ }
+ return NULL;
+}
+
+static int auxiliary_match(struct device *dev, struct device_driver *drv)
+{
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(drv);
+
+ return !!auxiliary_match_id(auxdrv->id_table, auxdev);
+}
+
+static int auxiliary_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ const char *name, *p;
+
+ name = dev_name(dev);
+ p = strrchr(name, '.');
+
+ return add_uevent_var(env, "MODALIAS=%s%.*s", AUXILIARY_MODULE_PREFIX, (int)(p - name),
+ name);
+}
+
+static const struct dev_pm_ops auxiliary_dev_pm_ops = {
+ SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, pm_generic_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume)
+};
+
+static int auxiliary_bus_probe(struct device *dev)
+{
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ int ret;
+
+ ret = dev_pm_domain_attach(dev, true);
+ if (ret) {
+ dev_warn(dev, "Failed to attach to PM Domain : %d\n", ret);
+ return ret;
+ }
+
+ ret = auxdrv->probe(auxdev, auxiliary_match_id(auxdrv->id_table, auxdev));
+ if (ret)
+ dev_pm_domain_detach(dev, true);
+
+ return ret;
+}
+
+static int auxiliary_bus_remove(struct device *dev)
+{
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+ int ret = 0;
+
+ if (auxdrv->remove)
+ ret = auxdrv->remove(auxdev);
+ dev_pm_domain_detach(dev, true);
+
+ return ret;
+}
+
+static void auxiliary_bus_shutdown(struct device *dev)
+{
+ struct auxiliary_driver *auxdrv = to_auxiliary_drv(dev->driver);
+ struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
+
+ if (auxdrv->shutdown)
+ auxdrv->shutdown(auxdev);
+}
+
+static struct bus_type auxiliary_bus_type = {
+ .name = "auxiliary",
+ .probe = auxiliary_bus_probe,
+ .remove = auxiliary_bus_remove,
+ .shutdown = auxiliary_bus_shutdown,
+ .match = auxiliary_match,
+ .uevent = auxiliary_uevent,
+ .pm = &auxiliary_dev_pm_ops,
+};
+
+/**
+ * auxiliary_device_init - check auxiliary_device and initialize
+ * @auxdev: auxiliary device struct
+ *
+ * This is the first step in the two-step process to register an auxiliary_device.
+ *
+ * When this function returns an error code, then the device_initialize will *not* have
+ * been performed, and the caller will be responsible to free any memory allocated for the
+ * auxiliary_device in the error path directly.
+ *
+ * It returns 0 on success. On success, the device_initialize has been performed. After this
+ * point any error unwinding will need to include a call to auxiliary_device_uninit().
+ * In this post-initialize error scenario, a call to the device's .release callback will be
+ * triggered, and all memory clean-up is expected to be handled there.
+ */
+int auxiliary_device_init(struct auxiliary_device *auxdev)
+{
+ struct device *dev = &auxdev->dev;
+
+ if (!dev->parent) {
+ pr_err("auxiliary_device has a NULL dev->parent\n");
+ return -EINVAL;
+ }
+
+ if (!auxdev->name) {
+ pr_err("auxiliary_device has a NULL name\n");
+ return -EINVAL;
+ }
+
+ dev->bus = &auxiliary_bus_type;
+ device_initialize(&auxdev->dev);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(auxiliary_device_init);
+
+/**
+ * __auxiliary_device_add - add an auxiliary bus device
+ * @auxdev: auxiliary bus device to add to the bus
+ * @modname: name of the parent device's driver module
+ *
+ * This is the second step in the two-step process to register an auxiliary_device.
+ *
+ * This function must be called after a successful call to auxiliary_device_init(), which
+ * will perform the device_initialize. This means that if this returns an error code, then a
+ * call to auxiliary_device_uninit() must be performed so that the .release callback will
+ * be triggered to free the memory associated with the auxiliary_device.
+ *
+ * The expectation is that users will call the "auxiliary_device_add" macro so that the caller's
+ * KBUILD_MODNAME is automatically inserted for the modname parameter. Only if a user requires
+ * a custom name would this version be called directly.
+ */
+int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname)
+{
+ struct device *dev = &auxdev->dev;
+ int ret;
+
+ if (!modname) {
+ pr_err("auxiliary device modname is NULL\n");
+ return -EINVAL;
+ }
+
+ ret = dev_set_name(dev, "%s.%s.%d", modname, auxdev->name, auxdev->id);
+ if (ret) {
+ pr_err("auxiliary device dev_set_name failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = device_add(dev);
+ if (ret)
+ dev_err(dev, "adding auxiliary device failed!: %d\n", ret);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(__auxiliary_device_add);
+
+/**
+ * auxiliary_find_device - auxiliary device iterator for locating a particular device.
+ * @start: Device to begin with
+ * @data: Data to pass to match function
+ * @match: Callback function to check device
+ *
+ * This function returns a reference to a device that is 'found'
+ * for later use, as determined by the @match callback.
+ *
+ * The callback should return 0 if the device doesn't match and non-zero
+ * if it does. If the callback returns non-zero, this function will
+ * return to the caller and not iterate over any more devices.
+ */
+struct auxiliary_device *
+auxiliary_find_device(struct device *start, const void *data,
+ int (*match)(struct device *dev, const void *data))
+{
+ struct device *dev;
+
+ dev = bus_find_device(&auxiliary_bus_type, start, data, match);
+ if (!dev)
+ return NULL;
+
+ return to_auxiliary_dev(dev);
+}
+EXPORT_SYMBOL_GPL(auxiliary_find_device);
+
+/**
+ * __auxiliary_driver_register - register a driver for auxiliary bus devices
+ * @auxdrv: auxiliary_driver structure
+ * @owner: owning module/driver
+ * @modname: KBUILD_MODNAME for parent driver
+ */
+int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *owner,
+ const char *modname)
+{
+ if (WARN_ON(!auxdrv->probe) || WARN_ON(!auxdrv->id_table))
+ return -EINVAL;
+
+ if (auxdrv->name)
+ auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s.%s", modname, auxdrv->name);
+ else
+ auxdrv->driver.name = kasprintf(GFP_KERNEL, "%s", modname);
+ if (!auxdrv->driver.name)
+ return -ENOMEM;
+
+ auxdrv->driver.owner = owner;
+ auxdrv->driver.bus = &auxiliary_bus_type;
+ auxdrv->driver.mod_name = modname;
+
+ return driver_register(&auxdrv->driver);
+}
+EXPORT_SYMBOL_GPL(__auxiliary_driver_register);
+
+/**
+ * auxiliary_driver_unregister - unregister a driver
+ * @auxdrv: auxiliary_driver structure
+ */
+void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
+{
+ driver_unregister(&auxdrv->driver);
+ kfree(auxdrv->driver.name);
+}
+EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
+
+static int __init auxiliary_bus_init(void)
+{
+ return bus_register(&auxiliary_bus_type);
+}
+
+static void __exit auxiliary_bus_exit(void)
+{
+ bus_unregister(&auxiliary_bus_type);
+}
+
+module_init(auxiliary_bus_init);
+module_exit(auxiliary_bus_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Auxiliary Bus");
+MODULE_AUTHOR("David Ertman <david.m.ertman@intel.com>");
+MODULE_AUTHOR("Kiran Patil <kiran.patil@intel.com>");
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
new file mode 100644
index 000000000000..282fbf7bf9af
--- /dev/null
+++ b/include/linux/auxiliary_bus.h
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2019-2020 Intel Corporation
+ *
+ * Please see Documentation/driver-api/auxiliary_bus.rst for more information.
+ */
+
+#ifndef _AUXILIARY_BUS_H_
+#define _AUXILIARY_BUS_H_
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+#include <linux/slab.h>
+
+struct auxiliary_device {
+ struct device dev;
+ const char *name;
+ u32 id;
+};
+
+struct auxiliary_driver {
+ int (*probe)(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id);
+ int (*remove)(struct auxiliary_device *auxdev);
+ void (*shutdown)(struct auxiliary_device *auxdev);
+ int (*suspend)(struct auxiliary_device *auxdev, pm_message_t state);
+ int (*resume)(struct auxiliary_device *auxdev);
+ const char *name;
+ struct device_driver driver;
+ const struct auxiliary_device_id *id_table;
+};
+
+static inline struct auxiliary_device *to_auxiliary_dev(struct device *dev)
+{
+ return container_of(dev, struct auxiliary_device, dev);
+}
+
+static inline struct auxiliary_driver *to_auxiliary_drv(struct device_driver *drv)
+{
+ return container_of(drv, struct auxiliary_driver, driver);
+}
+
+int auxiliary_device_init(struct auxiliary_device *auxdev);
+int __auxiliary_device_add(struct auxiliary_device *auxdev, const char *modname);
+#define auxiliary_device_add(auxdev) __auxiliary_device_add(auxdev, KBUILD_MODNAME)
+
+static inline void auxiliary_device_uninit(struct auxiliary_device *auxdev)
+{
+ put_device(&auxdev->dev);
+}
+
+static inline void auxiliary_device_delete(struct auxiliary_device *auxdev)
+{
+ device_del(&auxdev->dev);
+}
+
+int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, struct module *owner,
+ const char *modname);
+#define auxiliary_driver_register(auxdrv) \
+ __auxiliary_driver_register(auxdrv, THIS_MODULE, KBUILD_MODNAME)
+
+void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv);
+
+/**
+ * module_auxiliary_driver() - Helper macro for registering an auxiliary driver
+ * @__auxiliary_driver: auxiliary driver struct
+ *
+ * Helper macro for auxiliary drivers which do not do anything special in
+ * module init/exit. This eliminates a lot of boilerplate. Each module may only
+ * use this macro once, and calling it replaces module_init() and module_exit()
+ */
+#define module_auxiliary_driver(__auxiliary_driver) \
+ module_driver(__auxiliary_driver, auxiliary_driver_register, auxiliary_driver_unregister)
+
+struct auxiliary_device *
+auxiliary_find_device(struct device *start, const void *data,
+ int (*match)(struct device *dev, const void *data));
+
+#endif /* _AUXILIARY_BUS_H_ */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 5b08a473cdba..c425290b21e2 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -838,4 +838,12 @@ struct mhi_device_id {
kernel_ulong_t driver_data;
};
+#define AUXILIARY_NAME_SIZE 32
+#define AUXILIARY_MODULE_PREFIX "auxiliary:"
+
+struct auxiliary_device_id {
+ char name[AUXILIARY_NAME_SIZE];
+ kernel_ulong_t driver_data;
+};
+
#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index 27007c18e754..e377f52dbfa3 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -243,5 +243,8 @@ int main(void)
DEVID(mhi_device_id);
DEVID_FIELD(mhi_device_id, chan);
+ DEVID(auxiliary_device_id);
+ DEVID_FIELD(auxiliary_device_id, name);
+
return 0;
}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 2417dd1dee33..fb4827027536 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1364,6 +1364,13 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias)
{
DEF_FIELD_ADDR(symval, mhi_device_id, chan);
sprintf(alias, MHI_DEVICE_MODALIAS_FMT, *chan);
+ return 1;
+}
+
+static int do_auxiliary_entry(const char *filename, void *symval, char *alias)
+{
+ DEF_FIELD_ADDR(symval, auxiliary_device_id, name);
+ sprintf(alias, AUXILIARY_MODULE_PREFIX "%s", *name);
return 1;
}
@@ -1442,6 +1449,7 @@ static const struct devtable devtable[] = {
{"tee", SIZE_tee_client_device_id, do_tee_entry},
{"wmi", SIZE_wmi_device_id, do_wmi_entry},
{"mhi", SIZE_mhi_device_id, do_mhi_entry},
+ {"auxiliary", SIZE_auxiliary_device_id, do_auxiliary_entry},
};
/* Create MODULE_ALIAS() statements.
--
2.29.2

View File

@ -1,54 +0,0 @@
From a64e93a757edfad34955b79f1774d10e9dae955e Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 4 Dec 2020 12:43:47 +0100
Subject: [PATCH] driver core: auxiliary bus: move slab.h from include file
No need to include slab.h in include/linux/auxiliary_bus.h, as it is not
needed there. Move it to drivers/base/auxiliary.c instead.
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8og8xi3WkoYXet9@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7bbb79ff5f7499e0c5d65987458410e8099207d8)
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
---
drivers/base/auxiliary.c | 1 +
include/linux/auxiliary_bus.h | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index ef2af417438b..eca36d6284d0 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -9,6 +9,7 @@
#include <linux/device.h>
#include <linux/init.h>
+#include <linux/slab.h>
#include <linux/module.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>
diff --git a/include/linux/auxiliary_bus.h b/include/linux/auxiliary_bus.h
index 282fbf7bf9af..3580743d0e8d 100644
--- a/include/linux/auxiliary_bus.h
+++ b/include/linux/auxiliary_bus.h
@@ -10,7 +10,6 @@
#include <linux/device.h>
#include <linux/mod_devicetable.h>
-#include <linux/slab.h>
struct auxiliary_device {
struct device dev;
--
2.29.2

Some files were not shown because too many files have changed in this diff Show More