admin管理员组

文章数量:1642330

最近项目上SOC 厂商发过来一个驱动xxx.ko 文件,需要先把原来的驱动rmmod 掉然后再加载insmod xxx.ko, 发现怎么都手动卸载不了,LOG 如下:
1|uid=0 gid=0@😕 # cat /proc/modules

11129660 4 usb222,usb333,iap2, Live 0x00000000
configfs 22081 6 ncm,iap2,libcomposite, Live 0x00000000
udc 36173 0 - Live 0x00000000
udc_core 8233 4 libcomposite,udc, Live 0x00000000
xxxx13912 0 [permanent], Live 0x00000000 (PO)
yyyyy 16795 0 [permanent], Live 0x00000000 (O)
zzzzz34088 2 gerda_pcm,[permanent], Live 0x00000000 (PO)

uid=0 gid=0@😕 #
uid=0 gid=0@😕 #
uid=0 gid=0@😕 # rmmod vpu
rmmod: delete_module ‘vpu’ failed (errno 16)

后发现凡是带[permanent] 属性的驱动都rmmod 不了,试了很长时间都无法解决,
最后再友商的提示下,发现根本问题再下面:
truct modele” may be difrrent in your enviroment and our enviroment.

“struct module” is defined in “/include/linux/module.h”

In our enviroment:

sizeof(struct module) = 376

offsetof(struct module, init) = xxx

offsetof(struct module, exit) = yyyy

Coudl you check them in your enviroment?

There are “#ifdef CONFIG_ “ in the definition of “struct module”

In our enviroment.

#ifdef CONFIG_KALLSYMS → true

#ifdef CONFIG_SMP → true

#ifdef CONFIG_KMC_MODULE_DEBUG → false

#ifdef CONFIG_TRACEPOINTS → true

#ifdef CONFIG_JUMP_LABEL → true

#ifdef CONFIG_TRACING → false

#ifdef CONFIG_EVENT_TRACING → false

#ifdef CONFIG_FTRACE_MCOUNT_RECORD → false

#ifdef CONFIG_MODULE_UNLOAD → true

然后去看代码:
struct module {
enum module_state state;
。。。。
。。。。
#ifdef CONFIG_TRACEPOINTS
unsigned int num_tracepoints;
struct tracepoint * const *tracepoints_ptrs;
#endif
#ifdef HAVE_JUMP_LABEL
struct jump_entry *jump_entries;
unsigned int num_jump_entries;
#endif
#ifdef CONFIG_TRACING
。。。。。。
}
上面意思也就是说由于上面配置不同导致最后生成的ko 驱动的size 和offset 成员环境不一样,所以就有了permanent 属性,从而rmmod 不掉驱动,
后经验证:
在我们环境中把ONFIG_TRACEPOINTS → false ,permanent 就没有了,就可以rmmod 相应驱动了,
binggo

本文标签: rmmod