package/dkml: supports auto unload drivers

This commit is contained in:
Liangbin Lian 2024-02-29 14:06:31 +08:00
parent b928a6985c
commit b2edd50d0c
3 changed files with 67 additions and 2 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=dkml
PKG_VERSION:=1.0.1
PKG_RELEASE:=2
PKG_VERSION:=1.0.2
PKG_RELEASE:=1
PKG_FLAGS:=hold essential nonshared
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
@ -32,6 +32,7 @@ endef
define Package/dkml/install
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) ./files/kmods.init $(1)/etc/init.d/kmods
$(INSTALL_BIN) ./files/kmods-unload.init $(1)/etc/init.d/kmods-unload
$(INSTALL_DATA) ./files/kmods.config $(1)/etc/config/kmods
endef

View File

@ -0,0 +1,36 @@
#!/bin/sh /etc/rc.common
START=25
check_driver_bond() {
local kmod="$1"
ls /sys/module/$kmod/drivers/*/ | grep -Fq :
}
auto_unload() {
local function support keep kmod
config_get function "$1" function
config_get support "$1" support
keep=0
if [ -n "$function" ]; then
for kmod in $function; do
if check_driver_bond $kmod; then
keep=1
else
echo "auto rmmod $kmod" >>/dev/kmsg
rmmod $kmod
fi
done
fi
if [ "$keep" = "0" -a -n "$support" ]; then
for kmod in $support; do
rmmod $kmod 2>/dev/null
done
fi
}
boot() {
config_load kmods
config_foreach auto_unload auto_unload
}

View File

@ -1,3 +1,31 @@
config global 'kmods'
# list enable 'r8125'
# list enable 'r8168'
# config auto_unload 'amdgpu'
# option function 'amdgpu'
# option support ''
# config auto_unload 'i915'
# option function 'i915'
# option support ''
# config auto_unload 'radeon'
# option function 'radeon'
# option support ''
# config auto_unload 'rtw89'
# option function 'rtw_8851be rtw_8852ae rtw_8852be rtw_8852ce'
# option support 'rtw_8852c rtw_8852b rtw_8852a rtw_8851b rtw89pci rtw89core'
# config auto_unload 'mwifiex'
# option function 'mwifiex_pcie'
# option support 'mwifiex'
# config auto_unload 'ath10k'
# option function 'ath10k_pci'
# option support 'ath10k_core'
# config auto_unload 'x86_others'
# option function 'bnx2x mlx5_core i40e mpt3sas ixgbe'
# option support ''