open failed blocked driver rmmod
hi, xenomai:
I'm a little confused. when you fail to open an rtdm device from dev->ops.open, the rtdm driver cannot be rmmod.
As if cleanup_instance and __rtdm_put_device in __rtdm_dev_open execute atomic_dec(&dev->refcount) twice, dev->refcount becomes a negative value not equal to 0? The wait_event(dev->putwq, atomic_read(&dev->refcount) == 0) condition in rtdm_dev_unregister cannot be satisfied. the task of rmmod is always in TASK_UNINTERRUPTIBLE state.
xenomai:3.2.4 kernel:5.10.199__rtdm_dev_open ->fail_open:cleanup_instance(dev, context);fail_create:filp_close(filp, current->files);fail_fopen:put_unused_fd(ufd);fail_fd:__rtdm_put_device(dev);
[ 1088.581917] INFO: task rmmod:2503 blocked for more than 120 seconds. [ 1088.582231] Tainted: G O 5.10.199-dovetail-xenomai-3.2.4-20240228 #1 [ 1088.582436] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 1088.582642] task:rmmod state:D stack: 0 pid: 2503 ppid: 2502 flags:0x00004004 [ 1088.582850] Call Trace: [ 1088.583059] __schedule+0x2ee/0x780 [ 1088.583264] schedule+0x40/0xe0 [ 1088.583467] rtdm_dev_unregister+0xea/0x170 [ 1088.583664] ? wait_woken+0x80/0x80 [ 1088.583852] UnregisterDevice+0xf/0x20 [mod_test] [ 1088.584038] ? ExitAll+0x64/0x1ff [mod_test] [ 1088.584224] ? ModuleExit+0x5/0xef5 [mod_test] [ 1088.584412] ? __do_sys_delete_module+0x19a/0x240 [ 1088.584598] ? fpregs_assert_state_consistent+0x19/0x40 [ 1088.584790] ? do_syscall_64+0x33/0x50 [ 1088.584982] ? entry_SYSCALL_64_after_hwframe+0x61/0xc6