Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "staging: vc04_services: vchiq_core: Stop kthreads on shutdown"

This reverts commit d9c60badccc183eb971e0941bb86f9475d4b9551.

It has been reported that stopping kthreads corrupts the VC04 firmware
and creates issues at boot time [1].

A fix-up version of this patch
bac670144384 ("staging: vc04_services: Stop kthreads on .remove") [2]
was also attempted but it also doesn't properly fix the TODO
(i.e. clean module unload) and similar errors were observed when
stopping these khthreads on RaspberryPi 3.

Hence, revert the entire patch for now since it is not very clear why
stopping the kthreads breaks the firmware.

[1]: https://lore.kernel.org/linux-staging/CAPY8ntBaz_RGr2sboQqbuUv+xZNfRct6-sckDLYPTig_HWyXEw@mail.gmail.com/t/#me90b9a9bc91599f18cd65ceb7eedd40e5fee0cdd

[2]: https://lore.kernel.org/linux-staging/171161507013.3072637.12125782507523919379@ping.linuxembedded.co.uk/T/#m1d3de7d2fa73b2447274858353bbd4a0c3a8ba14

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20240403052100.2794-1-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Umang Jain and committed by
Greg Kroah-Hartman
ebee9ca2 883295e9

+12 -13
+7
drivers/staging/vc04_services/interface/TODO
··· 16 16 to manage these buffers as dmabufs so that we can zero-copy import 17 17 camera images into vc4 for rendering/display. 18 18 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 + 19 26 * Documentation 20 27 21 28 A short top-down description of this driver's architecture (function of
+2 -6
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
··· 726 726 727 727 int vchiq_shutdown(struct vchiq_instance *instance) 728 728 { 729 - struct vchiq_state *state = instance->state; 730 - struct vchiq_arm_state *arm_state; 731 729 int status = 0; 730 + struct vchiq_state *state = instance->state; 732 731 733 732 if (mutex_lock_killable(&state->mutex)) 734 733 return -EAGAIN; ··· 738 739 mutex_unlock(&state->mutex); 739 740 740 741 dev_dbg(state->dev, "core: (%p): returning %d\n", instance, status); 741 - 742 - arm_state = vchiq_platform_get_arm_state(state); 743 - kthread_stop(arm_state->ka_thread); 744 742 745 743 free_bulk_waiter(instance); 746 744 kfree(instance); ··· 1310 1314 goto shutdown; 1311 1315 } 1312 1316 1313 - while (!kthread_should_stop()) { 1317 + while (1) { 1314 1318 long rc = 0, uc = 0; 1315 1319 1316 1320 if (wait_for_completion_interruptible(&arm_state->ka_evt)) {
+3 -7
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
··· 1936 1936 1937 1937 DEBUG_INITIALISE(local); 1938 1938 1939 - while (!kthread_should_stop()) { 1939 + while (1) { 1940 1940 DEBUG_COUNT(SLOT_HANDLER_COUNT); 1941 1941 DEBUG_TRACE(SLOT_HANDLER_LINE); 1942 1942 remote_event_wait(&state->trigger_event, &local->trigger); ··· 1978 1978 if (!found) 1979 1979 return -ENOMEM; 1980 1980 1981 - while (!kthread_should_stop()) { 1981 + while (1) { 1982 1982 remote_event_wait(&state->recycle_event, &local->recycle); 1983 1983 1984 1984 process_free_queue(state, found, length); ··· 1997 1997 state->remote->slot_sync); 1998 1998 int svc_fourcc; 1999 1999 2000 - while (!kthread_should_stop()) { 2000 + while (1) { 2001 2001 struct vchiq_service *service; 2002 2002 int msgid, size; 2003 2003 int type; ··· 2844 2844 (void)vchiq_remove_service(instance, service->handle); 2845 2845 vchiq_service_put(service); 2846 2846 } 2847 - 2848 - kthread_stop(state->sync_thread); 2849 - kthread_stop(state->recycle_thread); 2850 - kthread_stop(state->slot_handler_thread); 2851 2847 } 2852 2848 2853 2849 int