Blame SPECS/kmod-redhat-rtw89.spec

56e3f4
%define kmod_name		rtw89
56e3f4
%define kmod_vendor		redhat
56e3f4
%define kmod_rpm_name		kmod-redhat-rtw89
56e3f4
%define kmod_driver_version	4.18.0_363_dup8.5
56e3f4
%define kmod_driver_epoch	%{nil}
56e3f4
%define kmod_rpm_release	1
56e3f4
%define kmod_kernel_version	4.18.0-348.el8
56e3f4
%define kmod_kernel_version_min	%{nil}
56e3f4
%define kmod_kernel_version_dep	%{nil}
56e3f4
%define kmod_kbuild_dir		drivers/net/wireless/realtek/rtw89
56e3f4
%define kmod_dependencies       %{nil}
56e3f4
%define kmod_dist_build_deps	%{nil}
56e3f4
%define kmod_build_dependencies	%{nil}
56e3f4
%define kmod_provides           %{nil}
56e3f4
%define kmod_devel_package	1
56e3f4
%define kmod_devel_src_paths	%{nil}
56e3f4
%define kmod_install_path	extra/kmod-redhat-rtw89
56e3f4
%define kmod_files_package	0
56e3f4
%define kmod_files_noarch	1
56e3f4
%define kernel_pkg		kernel
56e3f4
%define kernel_devel_pkg	kernel-devel
56e3f4
%define kernel_modules_pkg	kernel-modules
56e3f4
56e3f4
%{!?dist: %define dist .el8_5}
56e3f4
%{!?make_build: %define make_build make}
56e3f4
56e3f4
%if "%{kmod_kernel_version_dep}" == ""
56e3f4
%define kmod_kernel_version_dep %{kmod_kernel_version}
56e3f4
%endif
56e3f4
56e3f4
%if "%{kmod_dist_build_deps}" == ""
56e3f4
%if (0%{?rhel} > 7) || (0%{?centos} > 7)
56e3f4
%define kmod_dist_build_deps redhat-rpm-config kernel-abi-whitelists elfutils-libelf-devel kernel-rpm-macros kmod
56e3f4
%else
56e3f4
%define kmod_dist_build_deps redhat-rpm-config kernel-abi-whitelists
56e3f4
%endif
56e3f4
%endif
56e3f4
56e3f4
Source0:	%{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}.tar.bz2
56e3f4
# Source code patches
56e3f4
Patch0:	0001-rtw89-add-Realtek-802.11ax-driver.patch
56e3f4
Patch1:	0002-rtw89-Fix-two-spelling-mistakes-in-debug-messages.patch
56e3f4
Patch2:	0003-rtw89-Remove-redundant-check-of-ret-after-call-to-rt.patch
56e3f4
Patch3:	0004-rtw89-fix-return-value-check-in-rtw89_cam_send_sec_k.patch
56e3f4
Patch4:	0005-rtw89-remove-unneeded-semicolon.patch
56e3f4
Patch5:	0006-rtw89-fix-error-function-parameter.patch
56e3f4
Patch6:	0007-rtw89-remove-duplicate-register-definitions.patch
56e3f4
Patch7:	0008-rtw89-fix-return-value-in-hfc_pub_cfg_chk.patch
56e3f4
Patch8:	0009-rtw89-Fix-variable-dereferenced-before-check-sta.patch
56e3f4
Patch9:	0010-rtw89-update-partition-size-of-firmware-header-on-sk.patch
56e3f4
Patch10:	0011-rtw89-fill-regd-field-of-limit-limit_ru-tables-by-en.patch
56e3f4
Patch11:	0012-rtw89-update-rtw89-regulation-definition-to-R58-R31.patch
56e3f4
Patch12:	0013-rtw89-update-tx-power-limit-limit_ru-tables-to-R54.patch
56e3f4
Patch13:	0014-rtw89-update-rtw89_regulatory-map-to-R58-R31.patch
56e3f4
Patch14:	0015-rtw89-remove-unnecessary-conditional-operators.patch
56e3f4
Patch15:	0016-rtw89-remove-unneeded-variable.patch
56e3f4
Patch16:	0017-rtw89-fix-potentially-access-out-of-range-of-RF-regi.patch
56e3f4
Patch17:	0018-rtw89-add-AXIDMA-and-TX-FIFO-dump-in-mac_mem_dump.patch
56e3f4
Patch18:	0019-rtw89-add-const-in-the-cast-of-le32_get_bits.patch
56e3f4
Patch19:	0020-rtw89-use-inline-function-instead-macro-to-set-H2C-a.patch
56e3f4
Patch20:	0021-rtw89-update-scan_mac_addr-during-scanning-period.patch
56e3f4
Patch21:	0022-rtw89-fix-incorrect-channel-info-during-scan.patch
56e3f4
Patch22:	0023-rtw89-fix-sending-wrong-rtwsta-mac_id-to-firmware-to.patch
56e3f4
Patch23:	0024-rtw89-remove-cch_by_bw-which-is-not-used.patch
56e3f4
Patch24:	0025-rtw89-don-t-kick-off-TX-DMA-if-failed-to-write-skb.patch
56e3f4
Patch25:	0026-rtw89-coex-correct-C2H-header-length.patch
56e3f4
Patch26:	0027-rtw89-coex-Not-to-send-H2C-when-WL-not-ready-and-cou.patch
56e3f4
Patch27:	0028-rtw89-coex-Add-MAC-API-to-get-BT-polluted-counter.patch
56e3f4
Patch28:	0029-rtw89-coex-Define-LPS-state-for-BTC-using.patch
56e3f4
Patch29:	0030-rtw89-coex-Update-BT-counters-while-receiving-report.patch
56e3f4
Patch30:	0031-rtw89-coex-Cancel-PS-leaving-while-C2H-comes.patch
56e3f4
Patch31:	0032-rtw89-coex-Update-COEX-to-5.5.8.patch
56e3f4
Patch32:	0033-rtw89-8852a-correct-bit-definition-of-dfs_en.patch
56e3f4
Patch33:	0034-rtw89-fix-maybe-uninitialized-error-RHEL-only.patch
56e3f4
Patch34:	0035-rtw89-enable-driver-and-device-RTL8852AE.patch
56e3f4
Patch35:	0036-rtw89-fix-maybe-uninitialized-error.patch
56e3f4
Patch36:	9000-force-enable-rtw89.patch
56e3f4
Patch37:	9001-add-driver-version.patch
56e3f4
Patch38:	9002-change-firmware-path.patch
56e3f4
56e3f4
%define findpat %( echo "%""P" )
56e3f4
%define __find_requires /usr/lib/rpm/redhat/find-requires.ksyms
56e3f4
%define __find_provides /usr/lib/rpm/redhat/find-provides.ksyms %{kmod_name} %{?epoch:%{epoch}:}%{version}-%{release}
56e3f4
%define sbindir %( if [ -d "/sbin" -a \! -h "/sbin" ]; then echo "/sbin"; else echo %{_sbindir}; fi )
56e3f4
%define dup_state_dir %{_localstatedir}/lib/rpm-state/kmod-dups
56e3f4
%define kver_state_dir %{dup_state_dir}/kver
56e3f4
%define kver_state_file %{kver_state_dir}/%{kmod_kernel_version}.%(arch)
56e3f4
%define dup_module_list %{dup_state_dir}/rpm-kmod-%{kmod_name}-modules
56e3f4
56e3f4
Name:		kmod-redhat-rtw89
56e3f4
Version:	%{kmod_driver_version}
56e3f4
Release:	%{kmod_rpm_release}%{?dist}
56e3f4
%if "%{kmod_driver_epoch}" != ""
56e3f4
Epoch:		%{kmod_driver_epoch}
56e3f4
%endif
56e3f4
Summary:	rtw89 kernel module for Driver Update Program
56e3f4
Group:		System/Kernel
56e3f4
License:	GPLv2
56e3f4
URL:		https://www.kernel.org/
56e3f4
BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
56e3f4
BuildRequires:	%kernel_devel_pkg = %kmod_kernel_version
56e3f4
%if "%{kmod_dist_build_deps}" != ""
56e3f4
BuildRequires:	%{kmod_dist_build_deps}
56e3f4
%endif
56e3f4
ExclusiveArch:	x86_64
56e3f4
%global kernel_source() /usr/src/kernels/%{kmod_kernel_version}.$(arch)
56e3f4
56e3f4
%global _use_internal_dependency_generator 0
56e3f4
%if "%{?kmod_kernel_version_min}" != ""
56e3f4
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
56e3f4
%else
56e3f4
Provides:	%kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu}
56e3f4
%endif
56e3f4
Provides:	kmod-%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release}
56e3f4
Requires(post):	%{sbindir}/weak-modules
56e3f4
Requires(postun):	%{sbindir}/weak-modules
56e3f4
Requires:	kernel >= 4.18.0-348.el8
56e3f4
56e3f4
Requires:	kernel < 4.18.0-349.el8
56e3f4
%if 1
56e3f4
Requires: firmware(%{kmod_name}) = 20211119_105.gitf5d51956_dup8.5
56e3f4
%endif
56e3f4
%if "%{kmod_build_dependencies}" != ""
56e3f4
BuildRequires:  %{kmod_build_dependencies}
56e3f4
%endif
56e3f4
%if "%{kmod_dependencies}" != ""
56e3f4
Requires:       %{kmod_dependencies}
56e3f4
%endif
56e3f4
%if "%{kmod_provides}" != ""
56e3f4
Provides:       %{kmod_provides}
56e3f4
%endif
56e3f4
# if there are multiple kmods for the same driver from different vendors,
56e3f4
# they should conflict with each other.
56e3f4
Conflicts:	kmod-%{kmod_name}
56e3f4
56e3f4
%description
56e3f4
rtw89 kernel module for Driver Update Program
56e3f4
56e3f4
%if 1
56e3f4
56e3f4
%package -n kmod-redhat-rtw89-firmware
56e3f4
Version:	20211119_105.gitf5d51956_dup8.5
56e3f4
Summary:	rtw89 firmware for Driver Update Program
56e3f4
Provides:	firmware(%{kmod_name}) = 20211119_105.gitf5d51956_dup8.5
56e3f4
%if "%{kmod_kernel_version_min}" != ""
56e3f4
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
56e3f4
%else
56e3f4
Provides:	%kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu}
56e3f4
%endif
56e3f4
%description -n  kmod-redhat-rtw89-firmware
56e3f4
rtw89 firmware for Driver Update Program
56e3f4
56e3f4
56e3f4
%files -n kmod-redhat-rtw89-firmware
56e3f4
%defattr(644,root,root,755)
56e3f4
/lib/firmware/rtw89/rtw8852a_fw_dup85.bin
56e3f4
56e3f4
56e3f4
%endif
56e3f4
56e3f4
# Development package
56e3f4
%if 0%{kmod_devel_package}
56e3f4
%package -n kmod-redhat-rtw89-devel
56e3f4
Version:	%{kmod_driver_version}
56e3f4
Requires:	kernel >= 4.18.0-348.el8
56e3f4
56e3f4
Requires:	kernel < 4.18.0-349.el8
56e3f4
Summary:	rtw89 development files for Driver Update Program
56e3f4
56e3f4
%description -n  kmod-redhat-rtw89-devel
56e3f4
rtw89 development files for Driver Update Program
56e3f4
56e3f4
56e3f4
%files -n kmod-redhat-rtw89-devel
56e3f4
%defattr(644,root,root,755)
56e3f4
/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/
56e3f4
%endif
56e3f4
56e3f4
# Extra files package
56e3f4
%if 0%{kmod_files_package}
56e3f4
%package -n kmod-redhat-rtw89-files
56e3f4
Version:	%{kmod_driver_version}
56e3f4
Summary:	rtw89 additional files for Driver Update Program
56e3f4
%if 0%{kmod_files_noarch}
56e3f4
BuildArch:	noarch
56e3f4
%endif
56e3f4
%if "%{?kmod_kernel_version_min}" != ""
56e3f4
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
56e3f4
%else
56e3f4
Provides:	%kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu}
56e3f4
%endif
56e3f4
56e3f4
%description -n  kmod-redhat-rtw89-files
56e3f4
rtw89 additional files for Driver Update Program
56e3f4
56e3f4
56e3f4
%files -n kmod-redhat-rtw89-files
56e3f4
%defattr(644,root,root,755)
56e3f4
/etc/dracut.conf.d/kmod-redhat-rtw89_dup85.conf
56e3f4
%endif
56e3f4
56e3f4
%post
56e3f4
modules=( $(find /lib/modules/%{kmod_kernel_version}.%(arch)/%{kmod_install_path} | grep '\.ko$') )
56e3f4
printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --add-modules --no-initramfs
56e3f4
56e3f4
mkdir -p "%{kver_state_dir}"
56e3f4
touch "%{kver_state_file}"
56e3f4
56e3f4
exit 0
56e3f4
56e3f4
%posttrans
56e3f4
# We have to re-implement part of weak-modules here because it doesn't allow
56e3f4
# calling initramfs regeneration separately
56e3f4
if [ -f "%{kver_state_file}" ]; then
56e3f4
	kver_base="%{kmod_kernel_version_dep}"
56e3f4
	kvers=$(ls -d "/lib/modules/${kver_base%%.*}"*)
56e3f4
56e3f4
	for k_dir in $kvers; do
56e3f4
		k="${k_dir#/lib/modules/}"
56e3f4
56e3f4
		tmp_initramfs="/boot/initramfs-$k.tmp"
56e3f4
		dst_initramfs="/boot/initramfs-$k.img"
56e3f4
56e3f4
		# The same check as in weak-modules: we assume that the kernel present
56e3f4
		# if the symvers file exists.
56e3f4
		if [ -e "/boot/symvers-$k.gz" ] || [ -e "$k_dir/symvers.gz" ]; then
56e3f4
			/usr/bin/dracut -f "$tmp_initramfs" "$k" || exit 1
56e3f4
			cmp -s "$tmp_initramfs" "$dst_initramfs"
56e3f4
			if [ "$?" = 1 ]; then
56e3f4
				mv "$tmp_initramfs" "$dst_initramfs"
56e3f4
			else
56e3f4
				rm -f "$tmp_initramfs"
56e3f4
			fi
56e3f4
		fi
56e3f4
	done
56e3f4
56e3f4
	rm -f "%{kver_state_file}"
56e3f4
	rmdir "%{kver_state_dir}" 2> /dev/null
56e3f4
fi
56e3f4
56e3f4
rmdir "%{dup_state_dir}" 2> /dev/null
56e3f4
56e3f4
exit 0
56e3f4
56e3f4
%preun
56e3f4
if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then
56e3f4
	mkdir -p "%{kver_state_dir}"
56e3f4
	touch "%{kver_state_file}"
56e3f4
fi
56e3f4
56e3f4
mkdir -p "%{dup_state_dir}"
56e3f4
rpm -ql kmod-redhat-rtw89-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.$(arch) | \
56e3f4
	grep '\.ko$' > "%{dup_module_list}"
56e3f4
56e3f4
%postun
56e3f4
if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then
56e3f4
	initramfs_opt="--no-initramfs"
56e3f4
else
56e3f4
	initramfs_opt=""
56e3f4
fi
56e3f4
56e3f4
modules=( $(cat "%{dup_module_list}") )
56e3f4
rm -f "%{dup_module_list}"
56e3f4
printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --remove-modules $initramfs_opt
56e3f4
56e3f4
rmdir "%{dup_state_dir}" 2> /dev/null
56e3f4
56e3f4
exit 0
56e3f4
56e3f4
%files
56e3f4
%defattr(644,root,root,755)
56e3f4
/lib/modules/%{kmod_kernel_version}.%(arch)
56e3f4
/etc/depmod.d/%{kmod_name}.conf
56e3f4
%doc /usr/share/doc/%{kmod_rpm_name}/greylist.txt
56e3f4
%if !0%{kmod_files_package}
56e3f4
/etc/dracut.conf.d/kmod-redhat-rtw89_dup85.conf
56e3f4
%endif
56e3f4
56e3f4
%prep
56e3f4
%setup -n %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}
56e3f4
56e3f4
%patch0 -p1
56e3f4
%patch1 -p1
56e3f4
%patch2 -p1
56e3f4
%patch3 -p1
56e3f4
%patch4 -p1
56e3f4
%patch5 -p1
56e3f4
%patch6 -p1
56e3f4
%patch7 -p1
56e3f4
%patch8 -p1
56e3f4
%patch9 -p1
56e3f4
%patch10 -p1
56e3f4
%patch11 -p1
56e3f4
%patch12 -p1
56e3f4
%patch13 -p1
56e3f4
%patch14 -p1
56e3f4
%patch15 -p1
56e3f4
%patch16 -p1
56e3f4
%patch17 -p1
56e3f4
%patch18 -p1
56e3f4
%patch19 -p1
56e3f4
%patch20 -p1
56e3f4
%patch21 -p1
56e3f4
%patch22 -p1
56e3f4
%patch23 -p1
56e3f4
%patch24 -p1
56e3f4
%patch25 -p1
56e3f4
%patch26 -p1
56e3f4
%patch27 -p1
56e3f4
%patch28 -p1
56e3f4
%patch29 -p1
56e3f4
%patch30 -p1
56e3f4
%patch31 -p1
56e3f4
%patch32 -p1
56e3f4
%patch33 -p1
56e3f4
%patch34 -p1
56e3f4
%patch35 -p1
56e3f4
%patch36 -p1
56e3f4
%patch37 -p1
56e3f4
%patch38 -p1
56e3f4
set -- *
56e3f4
mkdir source
56e3f4
mv "$@" source/
56e3f4
mkdir obj
56e3f4
56e3f4
%build
56e3f4
rm -rf obj
56e3f4
cp -r source obj
56e3f4
56e3f4
PWD_PATH="$PWD"
56e3f4
%if "%{workaround_no_pwd_rel_path}" != "1"
56e3f4
PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD")
56e3f4
%endif
56e3f4
%{make_build} -C %{kernel_source} V=1 M="$PWD_PATH/obj/%{kmod_kbuild_dir}" \
56e3f4
	NOSTDINC_FLAGS="-I$PWD_PATH/obj/include -I$PWD_PATH/obj/include/uapi %{nil}" \
56e3f4
	EXTRA_CFLAGS="%{nil}" \
56e3f4
	%{nil}
56e3f4
# mark modules executable so that strip-to-file can strip them
56e3f4
find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -exec chmod u+x '{}' +
56e3f4
56e3f4
whitelist="/lib/modules/kabi-current/kabi_whitelist_%{_target_cpu}"
56e3f4
for modules in $( find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -printf "%{findpat}\n" | sed 's|\.ko$||' | sort -u ) ; do
56e3f4
	# update depmod.conf
56e3f4
	module_weak_path=$(echo "$modules" | sed 's/[\/]*[^\/]*$//')
56e3f4
	if [ -z "$module_weak_path" ]; then
56e3f4
		module_weak_path=%{name}
56e3f4
	else
56e3f4
		module_weak_path=%{name}/$module_weak_path
56e3f4
	fi
56e3f4
	echo "override $(echo $modules | sed 's/.*\///')" \
56e3f4
	     "$(echo "%{kmod_kernel_version_dep}" |
56e3f4
	        sed 's/\.[^\.]*$//;
56e3f4
		     s/\([.+?^$\/\\|()\[]\|\]\)/\\\0/g').*" \
56e3f4
		     "weak-updates/$module_weak_path" >> source/depmod.conf
56e3f4
56e3f4
	# update greylist
56e3f4
	nm -u obj/%{kmod_kbuild_dir}/$modules.ko | sed 's/.*U //' |  sed 's/^\.//' | sort -u | while read -r symbol; do
56e3f4
		grep -q "^\s*$symbol\$" $whitelist || echo "$symbol" >> source/greylist
56e3f4
	done
56e3f4
done
56e3f4
sort -u source/greylist | uniq > source/greylist.txt
56e3f4
56e3f4
%install
56e3f4
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
56e3f4
export INSTALL_MOD_DIR=%{kmod_install_path}
56e3f4
PWD_PATH="$PWD"
56e3f4
%if "%{workaround_no_pwd_rel_path}" != "1"
56e3f4
PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD")
56e3f4
%endif
56e3f4
make -C %{kernel_source} modules_install \
56e3f4
	M=$PWD_PATH/obj/%{kmod_kbuild_dir}
56e3f4
# Cleanup unnecessary kernel-generated module dependency files.
56e3f4
find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \;
56e3f4
56e3f4
install -m 644 -D source/depmod.conf $RPM_BUILD_ROOT/etc/depmod.d/%{kmod_name}.conf
56e3f4
install -m 644 -D source/greylist.txt $RPM_BUILD_ROOT/usr/share/doc/%{kmod_rpm_name}/greylist.txt
56e3f4
%if 1
56e3f4
install -m 644 -D source/firmware/rtw89/rtw8852a_fw_dup85.bin $RPM_BUILD_ROOT/lib/firmware/rtw89/rtw8852a_fw_dup85.bin
56e3f4
56e3f4
%endif
56e3f4
%if 0%{kmod_devel_package}
56e3f4
install -m 644 -D $PWD/obj/%{kmod_kbuild_dir}/Module.symvers $RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/Module.symvers
56e3f4
56e3f4
if [ -n "%{kmod_devel_src_paths}" ]; then
56e3f4
	for i in %{kmod_devel_src_paths}; do
56e3f4
		mkdir -p "$RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/$(dirname "$i")"
56e3f4
		cp -rv "$PWD/source/$i" \
56e3f4
			"$RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/$i"
56e3f4
	done
56e3f4
fi
56e3f4
%endif
56e3f4
install -m 664 -D source/extra//etc/dracut.conf.d/kmod-redhat-rtw89_dup85.conf $RPM_BUILD_ROOT//etc/dracut.conf.d/kmod-redhat-rtw89_dup85.conf
56e3f4
56e3f4
56e3f4
%clean
56e3f4
rm -rf $RPM_BUILD_ROOT
56e3f4
56e3f4
%changelog
56e3f4
* Wed Feb 09 2022 Eugene Syromiatnikov <esyr@redhat.com> 4.18.0_363_dup8.5-1
56e3f4
- 9dc660bf1362f5a22a908e61004498cf7ec063a8
56e3f4
- rtw89 kernel module for Driver Update Program
56e3f4
- Resolves: #bz2051886