Skip to content
Snippets Groups Projects
Commit f19dd946 authored by Rocky Automation's avatar Rocky Automation :tv:
Browse files

import imports/r8/kmod-idpf-irdma-0.0.129.20_0.0.647-9.el8_10.cloud

parents
No related branches found
No related tags found
No related merge requests found
SOURCES/ethernet-linux-irdma-and-idpf-*.tar.gz
*~
/,host-*/
/,out*/
7075227826b49d4d7742653c7e6a1efe2dfb09775ac42d8a111a5281475868c8 SOURCES/ethernet-linux-irdma-and-idpf-2.2.tar.gz
From 7d3bc01afe13c81dbc13aab79194177a01ef18fd Mon Sep 17 00:00:00 2001
From: Jacob Moroni <jmoroni@google.com>
Date: Wed, 20 Nov 2024 04:30:59 +0000
Subject: [PATCH] irdma: register netdev notifiers after IB device is
registered
Previously, the netdev notifiers were being registered before
the IB device was fully initialized. This introduces a race
condition that can lead to a segfault.
Registering netdevice notifiers causes artificial events
to be synchronously generated for all the netdevs in the
system, and if the netdev associated with the IB device
is UP, this can cause ib_dispatch_event to be called
for an IB device that hasn't had its ops populated yet.
This becomes a race since ib_dispatch_event results in an
ib_cache_event call executing asynchronously via a
workqueue, which ultimately results in a call to query_port
that can potentially fault.
This is most easily reproducible when loading irdma some
time after idpf is already loaded and the netdev is UP.
Moving the notifier registration to the end of the init
sequence resolves the issue.
Signed-off-by: Jacob Moroni <jmoroni@google.com>
---
rdma-driver/src/irdma/main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/rdma-driver/src/irdma/main.c b/rdma-driver/src/irdma/main.c
index 9a25240..9033c43 100644
--- a/rdma-driver/src/irdma/main.c
+++ b/rdma-driver/src/irdma/main.c
@@ -963,9 +963,6 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
if (err)
goto err_rt_init;
- err = irdma_register_notifiers(iwdev);
- if (err)
- goto err_notifier_reg;
irdma_add_handler(hdl);
#ifdef CONFIG_DEBUG_FS
irdma_dbg_pf_init(hdl);
@@ -996,6 +993,14 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
cdev_info->ops->register_notifier(cdev_info, &idc_notifiers);
+ /* Register notifiers after device is fully created. */
+ err = irdma_register_notifiers(iwdev);
+ if (err) {
+ ibdev_err(&iwdev->ibdev, "INIT: Failed to register notifiers\n");
+ irdma_remove(aux_dev);
+ return err;
+ }
+
return 0;
err_ibreg:
@@ -1004,7 +1009,6 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
#endif
irdma_del_handler(iwdev->hdl);
irdma_unregister_notifiers(iwdev);
-err_notifier_reg:
irdma_rt_deinit_hw(iwdev);
err_rt_init:
irdma_ctrl_deinit_hw(rf);
[protected_kmods]
kmod_names = kmod-idpf-irdma
This diff is collapsed.
From 92c60f51f2b31dd92b37b51bbb945504b18f78ca Mon Sep 17 00:00:00 2001
From: Jacob Moroni <jmoroni@google.com>
Date: Tue, 5 Nov 2024 23:07:03 +0000
Subject: [PATCH] irdma: prevent more than one flush
The change at:
03ccacb: irdma: enable SW based completion generation for flushed QPs
leaves open the possibility of multiple flushes, so this
change explicitly prevents that scenario.
Signed-off-by: Jacob Moroni <jmoroni@google.com>
---
rdma-driver/src/irdma/cm.c | 10 +++++++---
rdma-driver/src/irdma/verbs.c | 16 +++++++---------
rdma-driver/src/irdma/verbs.h | 1 +
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/rdma-driver/src/irdma/cm.c b/rdma-driver/src/irdma/cm.c
index 6aaf0c6..5fede1b 100644
--- a/rdma-driver/src/irdma/cm.c
+++ b/rdma-driver/src/irdma/cm.c
@@ -3522,7 +3522,7 @@ static void irdma_cm_disconn_true(struct irdma_qp *iwqp)
if (rdma_protocol_roce(&iwdev->ibdev, 1)) {
struct ib_qp_attr attr;
- if (atomic_read(&iwqp->flush_issued) ||
+ if (iwqp->flush_oneshot ||
iwqp->sc_qp.qp_uk.destroy_pending) {
spin_unlock_irqrestore(&iwqp->lock, flags);
return;
@@ -3546,8 +3546,10 @@ static void irdma_cm_disconn_true(struct irdma_qp *iwqp)
issue_close = 1;
iwqp->cm_id = NULL;
irdma_terminate_del_timer(qp);
- if (!atomic_read(&iwqp->flush_issued))
+ if (!iwqp->flush_oneshot) {
+ iwqp->flush_oneshot = true;
issue_flush = 1;
+ }
} else if ((original_hw_tcp_state == IRDMA_TCP_STATE_CLOSE_WAIT) ||
((original_ibqp_state == IB_QPS_RTS) &&
(last_ae == IRDMA_AE_LLP_CONNECTION_RESET))) {
@@ -3564,8 +3566,10 @@ static void irdma_cm_disconn_true(struct irdma_qp *iwqp)
issue_close = 1;
iwqp->cm_id = NULL;
qp->term_flags = 0;
- if (!atomic_read(&iwqp->flush_issued))
+ if (!iwqp->flush_oneshot) {
+ iwqp->flush_oneshot = true;
issue_flush = 1;
+ }
}
spin_unlock_irqrestore(&iwqp->lock, flags);
diff --git a/rdma-driver/src/irdma/verbs.c b/rdma-driver/src/irdma/verbs.c
index 731e9ac..f26cde4 100644
--- a/rdma-driver/src/irdma/verbs.c
+++ b/rdma-driver/src/irdma/verbs.c
@@ -1315,6 +1315,7 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
if (attr_mask & IB_QP_STATE) {
if (issue_modify_qp) {
+ bool do_flush = false;
ctx_info->rem_endpoint_idx = udp_info->arp_idx;
if (irdma_hw_modify_qp(iwdev, iwqp, &info, true))
return -EINVAL;
@@ -1329,18 +1330,15 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr,
iwqp->ibqp_state = attr->qp_state;
iwqp->sc_qp.qp_state = iwqp->iwarp_state;
}
- if (iwqp->ibqp_state > IB_QPS_RTS &&
- !atomic_read(&iwqp->flush_issued)) {
- spin_unlock_irqrestore(&iwqp->lock, flags);
- /* TODO(jmoroni): Is there a race here? Can another modify QP
- * occur and kick off another flush since flush_issued
- * doesn't get set until the end of irdma_flush_wqes?
- */
+ if (iwqp->ibqp_state > IB_QPS_RTS && !iwqp->flush_oneshot) {
+ iwqp->flush_oneshot = true;
+ do_flush = true;
+ }
+ spin_unlock_irqrestore(&iwqp->lock, flags);
+ if (do_flush) {
irdma_flush_wqes(iwqp, IRDMA_FLUSH_SQ |
IRDMA_FLUSH_RQ |
IRDMA_FLUSH_WAIT);
- } else {
- spin_unlock_irqrestore(&iwqp->lock, flags);
}
} else {
iwqp->ibqp_state = attr->qp_state;
diff --git a/rdma-driver/src/irdma/verbs.h b/rdma-driver/src/irdma/verbs.h
index e6d9dcc..ff173dd 100644
--- a/rdma-driver/src/irdma/verbs.h
+++ b/rdma-driver/src/irdma/verbs.h
@@ -268,6 +268,7 @@ struct irdma_qp {
dma_addr_t pbl_pbase;
struct page *page;
u8 iwarp_state;
+ bool flush_oneshot;
atomic_t flush_issued;
u16 term_sq_flush_code;
u16 term_rq_flush_code;
# Define the kmod package name here.
%define kmod_name idpf-irdma
# This is the name of the project in GitHub.
%define upstream_name ethernet-linux-irdma-and-idpf
%define upstream_version 2.2
# Version of each module:
%define IRDMA_VER 0.0.129.20
%define IDPF_VER 0.0.647
# If kmod_kernel_version isn't defined on the rpmbuild line, define it here.
%{!?kmod_kernel_version: %define kmod_kernel_version 4.18.0-553.16.1.el8_10.cloud.0.1}
# Information in description for secure-boot signed builds
%if 0%{?pe_signing_certkeyslot:1}
%define sb_summary "Signed for secure boot"
%else
%define sb_summary %{nil}
%endif
# Figure out EL kernel release number (ex: 4.18.0-513.5.1 == "4.18.0" , "513").
# We need to grab the correct kernel-devel package to build against.
%define kmod_kernel_base %(echo "%{kmod_kernel_version}" | grep -Eo '^.*-' | tr -d '-')
%define kmod_kernel_release %(echo "%{kmod_kernel_version}" | grep -Eo '\\-[[:digit:]]+\\.' | tr -d '.' | tr -d '-')
Name: kmod-%{kmod_name}
Version: %{IRDMA_VER}_%{IDPF_VER}
Release: 9%{?dist}
Summary: Kernel modules for IRDMA + IDPF
Group: System Environment/Kernel
License: GPLv2
URL: https://github.com/intel/%{upstream_name}
Source0: https://github.com/intel/%{upstream_name}/archive/v%{version}/%{upstream_name}-%{upstream_version}.tar.gz
Source1: kmod-%{kmod_name}.conf
# Source code patches go here:
Patch1: main...jakemoroni-ethernet-linux-irdma-and-idpf-main.patch
Patch2: single-flush.patch
Patch3: irdma-netdev-notifiers.patch
%define __spec_install_post /usr/lib/rpm/check-buildroot \
/usr/lib/rpm/redhat/brp-ldconfig \
/usr/lib/rpm/brp-compress \
/usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump \
/usr/lib/rpm/brp-strip-static-archive /usr/bin/strip \
/usr/lib/rpm/brp-python-bytecompile "" 1 \
/usr/lib/rpm/brp-python-hardlink \
PYTHON3="/usr/libexec/platform-python" /usr/lib/rpm/redhat/brp-mangle-shebangs
%define findpat %( echo "%""P" )
%define __find_requires /usr/lib/rpm/redhat/find-requires.ksyms
%define __find_provides /usr/lib/rpm/redhat/find-provides.ksyms %{kmod_name} %{?epoch:%{epoch}:}%{version}-%{release}
%define dup_state_dir %{_localstatedir}/lib/rpm-state/kmod-dups
%define kver_state_dir %{dup_state_dir}/kver
%define kver_state_file %{kver_state_dir}/%{kmod_kernel_version}.%{_arch}
%define dup_module_list %{dup_state_dir}/rpm-kmod-%{kmod_name}-modules
%define debug_package %{nil}
%global _use_internal_dependency_generator 0
%global kernel_source() %{_usrsrc}/kernels/%{kmod_kernel_version}.%{_arch}
BuildRequires: elfutils-libelf-devel
BuildRequires: kernel-devel = %{kmod_kernel_version}
BuildRequires: kernel-abi-stablelists
BuildRequires: kernel-rpm-macros
BuildRequires: redhat-rpm-config
# Not automatically pulled in by mock
BuildRequires: kmod
Provides: kernel-modules >= %{kmod_kernel_version}.%{_arch}
Provides: kmod-%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release}
Provides: kmod-irdma = %{IRDMA_VER}
Provides: kmod-idpf = %{IDPF_VER}
Requires(post): %{_sbindir}/weak-modules
Requires(postun): %{_sbindir}/weak-modules
Requires: kernel >= %{kmod_kernel_base}-%{kmod_kernel_release}, kernel < %{kmod_kernel_base}-%(let release=%{kmod_kernel_release}+1; echo ${release})
Recommends: dnf-plugin-protected-kmods
%description
This package provides the IRDMA and IDPF kernel modules:
IRDMA version: %{IRDMA_VER}
IDPF version: %{IDPF_VER}
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.
This was built specifically for kernel series:
%{kmod_kernel_base}-%{kmod_kernel_release}
%prep
%autosetup -n %{upstream_name}-%{upstream_version} -p1
echo "override idpf * weak-updates/idpf" > kmod-%{kmod_name}.conf
echo "override irdma * weak-updates/irdma" >> kmod-%{kmod_name}.conf
%build
pushd idpf-driver
%{__make} BUILD_KERNEL=%{kmod_kernel_version}.%{_arch}
popd
pushd rdma-driver
BUILD_KERNEL=%{kmod_kernel_version}.%{_arch} bash ./build.sh noinstall
popd
whitelist="/lib/modules/kabi-current/kabi_whitelist_%{_target_cpu}"
for modules in $( find . -name "*.ko" -type f -printf "%{findpat}\n" | sed 's|\.ko$||' | sort -u ) ; do
# update greylist
nm -u ./$modules.ko | sed 's/.*U //' | sed 's/^\.//' | sort -u | while read -r symbol; do
grep -q "^\s*$symbol\$" $whitelist || echo "$symbol" >> ./greylist
done
done
sort -u greylist | uniq > greylist.txt
%install
%{__install} -d %{buildroot}/lib/modules/%{kmod_kernel_version}.%{_arch}/extra/idpf/
%{__install} -d %{buildroot}/lib/modules/%{kmod_kernel_version}.%{_arch}/extra/irdma/
%{__install} idpf-driver/idpf/src/idpf.ko %{buildroot}/lib/modules/%{kmod_kernel_version}.%{_arch}/extra/idpf/
%{__install} rdma-driver/src/irdma/irdma.ko %{buildroot}/lib/modules/%{kmod_kernel_version}.%{_arch}/extra/irdma/
%{__install} -d %{buildroot}%{_sysconfdir}/depmod.d/
%{__install} -m 0644 kmod-%{kmod_name}.conf %{buildroot}%{_sysconfdir}/depmod.d/
%{__install} -d %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
%{__install} -m 0644 greylist.txt %{buildroot}%{_defaultdocdir}/kmod-%{kmod_name}-%{version}/
# strip the modules(s)
find %{buildroot} -name \*.ko -type f | xargs --no-run-if-empty %{__strip} --strip-debug
# SecureBoot official signing:
# Define signing macros if we are signing with a YubiHSM:
%if 0%{?pe_signing_certkeyslot:1}
%define _with_modsign 1
%define __certkeyslot %{?pe_signing_certkeyslot:%{pe_signing_certkeyslot}}
%define __opensslcnf %{?pe_signing_opensslcnf:%{pe_signing_opensslcnf}}
export OPENSSL_CONF=%{__opensslcnf}
# sign-file requires special environment variable - it is set up to mask output so we don't expose it to logs
{ export KBUILD_SIGN_PIN=$HSMPIN; } &> /dev/null
%define privkey "pkcs11:token=YubiHSM;id=%{__certkeyslot}"
%define pubkey %{SOURCE1000}
# Need yubihsm connector config file
# Also - /etc/pkcs11/modules/yubihsm.modules *MUST* exist and be configured for the yubihsm_pkcs11.so file
echo -e "connector = http://127.0.0.1:12345\ndebug" > yubihsm_pkcs11.conf
%endif
# Sign the modules(s)
%if %{?_with_modsign:1}%{!?_with_modsign:0}
# If the module signing keys are not defined, define them here.
%{!?privkey: %define privkey %{_sysconfdir}/pki/SECURE-BOOT-KEY.priv}
%{!?pubkey: %define pubkey %{_sysconfdir}/pki/SECURE-BOOT-KEY.der}
for module in $(find %{buildroot} -type f -name \*.ko);
do %{_usrsrc}/kernels/%{kmod_kernel_version}.%{_arch}/scripts/sign-file \
sha256 %{privkey} %{pubkey} $module;
done
%endif
%{__install} -d %{buildroot}%{_sysconfdir}/dnf/plugins/protected-kmods.d/
%{__install} -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/dnf/plugins/protected-kmods.d/kmod-idpf-irdma.conf
%clean
%{__rm} -rf %{buildroot}
%post
modules=( $(find /lib/modules/%{kmod_kernel_version}.%{_arch}/extra/idpf /lib/modules/%{kmod_kernel_version}.%{_arch}/extra/irdma | grep '\.ko$') )
printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --add-modules --no-initramfs
mkdir -p "%{kver_state_dir}"
touch "%{kver_state_file}"
exit 0
%posttrans
# We have to re-implement part of weak-modules here because it doesn't allow
# calling initramfs regeneration separately
if [ -f "%{kver_state_file}" ]; then
rm -f "%{kver_state_file}"
rmdir "%{kver_state_dir}" 2> /dev/null
fi
rmdir "%{dup_state_dir}" 2> /dev/null
# Update initramfs for all kABI compatible kernels
if [ -x /usr/bin/dracut ]; then
# get installed kernels
for KERNEL in $(rpm -q --qf '%{v}-%{r}.%{arch}\n' kernel); do
VMLINUZ="/boot/vmlinuz-"$KERNEL
# Check kABI compatibility
for KABI in $(find /lib/modules -name nvidia.ko | cut -d / -f 4); do
if [[ "$KERNEL" == "$KABI" && -e "$VMLINUZ" ]]; then
/usr/bin/dracut --add-drivers nvidia -f /boot/initramfs-$KERNEL.img $KERNEL
fi
done
done
fi
exit 0
%preun
if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then
mkdir -p "%{kver_state_dir}"
touch "%{kver_state_file}"
fi
mkdir -p "%{dup_state_dir}"
rpm -ql %{name}-%{version}-%{release}.%{_arch} | grep '\.ko$' > "%{dup_module_list}"
%postun
if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then
initramfs_opt="--no-initramfs"
else
initramfs_opt=""
fi
modules=( $(cat "%{dup_module_list}") )
rm -f "%{dup_module_list}"
printf '%s\n' "${modules[@]}" | %{_sbindir}/weak-modules --remove-modules $initramfs_opt
rmdir "%{dup_state_dir}" 2> /dev/null
exit 0
%files
%defattr(644,root,root,755)
/lib/modules/%{kmod_kernel_version}.%{_arch}/
%config %{_sysconfdir}/depmod.d/kmod-%{kmod_name}.conf
%config %{_sysconfdir}/dnf/plugins/protected-kmods.d/kmod-idpf-irdma.conf
%doc %{_docdir}/kmod-%{kmod_name}-%{version}/
%changelog
* Fri Dec 13 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-9
- Clean up spec file for SIG/Cloud
* Tue Dec 03 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-8
- Add weak dependency on dnf-plugin-protected-kmods
* Tue Nov 26 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-7
- Handle rename of dnf plugin to dnf-plugin-protected-kmods
* Mon Nov 25 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-6
- Add patch from Google to eliminate race condition
* Wed Nov 20 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-5
- Add protected kmod file for use with dnf-plugin-kmod-kernel
- Bump to kernel version that's compatible with current kernel
* Tue Nov 19 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-3
- Fix dependency issues
* Mon Nov 11 2024 Jonathan Dieter <jdieter@ciq.com> - 0.0.129.20_0.0.647-2
- Add patch to prevent more than one flush
* Thu Nov 07 2024 Jeff Uphoff <juphoff@ciq.com> - 0.0.129.20_0.0.647-1
- Remove .el8 %{dist} definition
* Tue Nov 05 2024 Jeff Uphoff <juphoff@ciq.com> - 0.0.129.20_0.0.647-0.el8
- Refactor for new upstream repository and versioning
* Tue Nov 05 2024 Jeff Uphoff <juphoff@ciq.com> - 2.1-3.el8
- Correct depmod config for weak-updates
* Tue Nov 05 2024 Jeff Uphoff <juphoff@ciq.com> - 2.1-2.el8
- Refactor and clean up weak-updates handling
* Wed Oct 16 2024 Jeff Uphoff <juphoff@ciq.com> - 2.1-1.el8
- Rebuilt using SIG/Cloud kernel
* Thu Sep 05 2024 Jeff Uphoff <juphoff@ciq.com> - 2.1-0.el8
- Adapted for upstream v2.1 branch, idfp 0.0.644
Upstream idpf repos were completely refactored, necessitating dropping
most local Makefile structure & customizations in order to consume
upstream "cleanly."
* Fri Jan 19 2024 Skip Grube <sgrube@ciq.com>
- Initial package for test builds, loosely based on ELRepo kmod format
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment