Skip to content

Commit 863a756

Browse files
Umang Jaingregkh
authored andcommitted
staging: vc04_services: vchiq_core: Stop kthreads on vchiq module unload
The various kthreads thread functions (slot_handler_func, sync_func, recycle_func) in vchiq_core and vchiq_keepalive_thread_func in vchiq_arm should be stopped when the module is unloaded. Previous attempt were made to address this but later reverted [1] due to VC04 firmware corruption. The issue around wait_event_interruptible() handling on stopping a kthread has been handled in the previous commit. Hence, it is now safe to stop kthreads on module unload, without any firmware corruption. This also completes the "Fix kernel module support" TODO item, hence drop it from the list. [1] commit ebee9ca ("Revert "staging: vc04_services: vchiq_core: Stop kthreads on shutdown"") Signed-off-by: Umang Jain <[email protected]> Tested-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c22502c commit 863a756

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

drivers/staging/vc04_services/interface/TODO

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ some of the ones we want:
1616
to manage these buffers as dmabufs so that we can zero-copy import
1717
camera images into vc4 for rendering/display.
1818

19-
* Fix kernel module support
20-
21-
Even the VPU firmware doesn't support a VCHI re-connect, the driver
22-
should properly handle a module unload. This also includes that all
23-
resources must be freed (kthreads, debugfs entries, ...) and global
24-
variables avoided.
25-
2619
* Documentation
2720

2821
A short top-down description of this driver's architecture (function of

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ vchiq_keepalive_thread_func(void *v)
13151315
goto shutdown;
13161316
}
13171317

1318-
while (1) {
1318+
while (!kthread_should_stop()) {
13191319
long rc = 0, uc = 0;
13201320

13211321
if (wait_for_completion_interruptible(&arm_state->ka_evt)) {
@@ -1776,12 +1776,20 @@ static int vchiq_probe(struct platform_device *pdev)
17761776
static void vchiq_remove(struct platform_device *pdev)
17771777
{
17781778
struct vchiq_drv_mgmt *mgmt = dev_get_drvdata(&pdev->dev);
1779+
struct vchiq_arm_state *arm_state;
17791780

17801781
vchiq_device_unregister(bcm2835_audio);
17811782
vchiq_device_unregister(bcm2835_camera);
17821783
vchiq_debugfs_deinit();
17831784
vchiq_deregister_chrdev();
17841785

1786+
kthread_stop(mgmt->state.sync_thread);
1787+
kthread_stop(mgmt->state.recycle_thread);
1788+
kthread_stop(mgmt->state.slot_handler_thread);
1789+
1790+
arm_state = vchiq_platform_get_arm_state(&mgmt->state);
1791+
kthread_stop(arm_state->ka_thread);
1792+
17851793
kfree(mgmt);
17861794
}
17871795

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ slot_handler_func(void *v)
19411941

19421942
DEBUG_INITIALISE(local);
19431943

1944-
while (1) {
1944+
while (!kthread_should_stop()) {
19451945
DEBUG_COUNT(SLOT_HANDLER_COUNT);
19461946
DEBUG_TRACE(SLOT_HANDLER_LINE);
19471947
ret = remote_event_wait(&state->trigger_event, &local->trigger);
@@ -1986,7 +1986,7 @@ recycle_func(void *v)
19861986
if (!found)
19871987
return -ENOMEM;
19881988

1989-
while (1) {
1989+
while (!kthread_should_stop()) {
19901990
ret = remote_event_wait(&state->recycle_event, &local->recycle);
19911991
if (ret)
19921992
return ret;
@@ -2008,7 +2008,7 @@ sync_func(void *v)
20082008
int svc_fourcc;
20092009
int ret;
20102010

2011-
while (1) {
2011+
while (!kthread_should_stop()) {
20122012
struct vchiq_service *service;
20132013
int msgid, size;
20142014
int type;

0 commit comments

Comments
 (0)