gk7205v500: let the kernel unload modules - #2528
Conversation
With CONFIG_MODULE_UNLOAD off, a module that is in cannot come out again, so nothing on this family can be swapped or reloaded without a reboot. That includes the media stack itself while a fault in it is being chased. The setting was left off with the vendor's tiny defconfig, but it is not part of the ABI the closed V500 objects depend on. They carry no struct module of their own: modpost generates __this_module with this kernel's layout, and they already export cleanup_module. The vendor's own xm72050500_full_defconfig ships with MODULE_UNLOAD=y. The layout hazard is CONFIG_PM, which moves struct device's fields, and it stays off. gk7201v200 has its own kernel config and is not touched.
PR Summary by QodoEnable module unloading for GK7205V500 kernels
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
Once the kernel can unload, -r, -a and the sensor-detection pass reach remove_ko() and remove_detect() for the first time, and neither removed anything. The from-source build installs xm_<m>.ko, but each module registers as open_<m>, so every `rmmod xm_<m>` failed with "No such file or directory". `modprobe -r xm_<m>` is no better: it exits 0 and leaves the module loaded. The sysconfig line also named a module that does not exist, xm_sys_config. So detection left sysconfig loaded with sensors=unknown, and the modprobe that should have reloaded it with the detected sensor found it already in and did nothing. unload() tries open_<m> first, then the name as given. Both lists now run in dependency order: venc before rc, and sysconfig before osal.
Problem
The gk7205v500 family kernel (gk7205v500_lite / gk7205v500_ultimate, and the gk7205v510 / gk7205v530 aliases) is built without
CONFIG_MODULE_UNLOAD. A loaded module can never be removed, so the media stack cannot be reloaded, or swapped for a test build, without rebooting the camera. That makes the open GK7205V510 video bring-up much slower to debug.The setting was off because the vendor's tiny defconfig has it off, not because the closed V500 objects need it off:
struct moduleof their own. modpost generates__this_modulewith this kernel's layout, and the objects already exportcleanup_module.xm72050500_full_defconfigships withCONFIG_MODULE_UNLOAD=y.CONFIG_PM, which movesstruct device's fields. It stays off.gk7201v200.generic.configis separate and not touched.Once the kernel can unload,
load_goke's-r,-aand sensor-detection paths reachremove_ko()andremove_detect()for the first time, and neither removed anything. The from-source build installsxm_<m>.ko, but each module registers asopen_<m>, so everyrmmod xm_<m>failed.modprobe -rexits 0 and leaves the module loaded, andxm_sys_confignamed no module at all. As a result, detection leftsysconfigloaded withsensors=unknown. The second commit addsunload(), which triesopen_<m>first, and puts both lists in dependency order.Changing the setting changes vermagic (
mod_unload), so the kernel and every module in an image must come from the same build. A normal image build already does that.Hardware tested on
GK7205V510, Zenointel SD-2N-4G (MIS2008, 128 MB SPI-NAND),
gk7205v500_ultimateNAND image.The image was built from 9bde58d's content (#2526) plus this commit, and flashed with
sysupgrade --archivewith the overlay kept. Since then master has added only #2527 (wifibroadcast), which does not touch this family.Evidence
Before: stock vermagic, and
rmmodrefuses every media module.After: every module in the image carries
mod_unload. All 26open_*modules come out;load_goke -iputs them back; majestic restarts; dmesg shows no oops.load_gokeon the same kernel, shipped script vs this PR's:Image sizes from this build:
uImage: [1910KB/2048KB],fitImage: [1911KB/4096KB],rootfs.ubi: [15104KB/16384KB].Scope
general/package/all-patches/linux/(those go to OpenIPC/linux)general/overlay/or in a sharedload_<vendor>script hardcodes a value specific to my boardLD_PRELOAD, and no binaries that cannot be rebuilt from source