Linux kernel staging patches
 help / color / mirror / Atom feed
From: Umang Jain <umang.jain@ideasonboard.com>
To: linux-staging@lists.linux.dev
Cc: Dan Carpenter <error27@gmail.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Phil Elwell <phil@raspberrypi.com>, Greg KH <greg@kroah.com>,
	Stefan Wahren <wahrenst@gmx.net>, Mark Brown <broonie@kernel.org>,
	Umang Jain <umang.jain@ideasonboard.com>
Subject: [PATCH] Revert "staging: vc04_services: vchiq_core: Stop kthreads on shutdown"
Date: Sat, 30 Mar 2024 21:34:40 +0530	[thread overview]
Message-ID: <20240330160440.49179-1-umang.jain@ideasonboard.com> (raw)

This reverts commit d9c60badccc183eb971e0941bb86f9475d4b9551.

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

A fix-up version of this patch [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>
---
Please ignore the previous email patch, so the staging-list email ID had
a typo.
---
 drivers/staging/vc04_services/interface/TODO           |  7 +++++++
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c      |  8 ++------
 .../vc04_services/interface/vchiq_arm/vchiq_core.c     | 10 +++-------
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging/vc04_services/interface/TODO
index 57a2d6761f9b..05eb5140d096 100644
--- a/drivers/staging/vc04_services/interface/TODO
+++ b/drivers/staging/vc04_services/interface/TODO
@@ -16,6 +16,13 @@ some of the ones we want:
   to manage these buffers as dmabufs so that we can zero-copy import
   camera images into vc4 for rendering/display.
 
+* Fix kernel module support
+
+Even the VPU firmware doesn't support a VCHI re-connect, the driver
+should properly handle a module unload. This also includes that all
+resources must be freed (kthreads, debugfs entries, ...) and global
+variables avoided.
+
 * Documentation
 
 A short top-down description of this driver's architecture (function of
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 1d21f9cfbfe5..ad506016fc93 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -726,9 +726,8 @@ void free_bulk_waiter(struct vchiq_instance *instance)
 
 int vchiq_shutdown(struct vchiq_instance *instance)
 {
-	struct vchiq_state *state = instance->state;
-	struct vchiq_arm_state *arm_state;
 	int status = 0;
+	struct vchiq_state *state = instance->state;
 
 	if (mutex_lock_killable(&state->mutex))
 		return -EAGAIN;
@@ -740,9 +739,6 @@ int vchiq_shutdown(struct vchiq_instance *instance)
 
 	dev_dbg(state->dev, "core: (%p): returning %d\n", instance, status);
 
-	arm_state = vchiq_platform_get_arm_state(state);
-	kthread_stop(arm_state->ka_thread);
-
 	free_bulk_waiter(instance);
 	kfree(instance);
 
@@ -1314,7 +1310,7 @@ vchiq_keepalive_thread_func(void *v)
 		goto shutdown;
 	}
 
-	while (!kthread_should_stop()) {
+	while (1) {
 		long rc = 0, uc = 0;
 
 		if (wait_for_completion_interruptible(&arm_state->ka_evt)) {
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 953ccd87f425..76c27778154a 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1936,7 +1936,7 @@ slot_handler_func(void *v)
 
 	DEBUG_INITIALISE(local);
 
-	while (!kthread_should_stop()) {
+	while (1) {
 		DEBUG_COUNT(SLOT_HANDLER_COUNT);
 		DEBUG_TRACE(SLOT_HANDLER_LINE);
 		remote_event_wait(&state->trigger_event, &local->trigger);
@@ -1978,7 +1978,7 @@ recycle_func(void *v)
 	if (!found)
 		return -ENOMEM;
 
-	while (!kthread_should_stop()) {
+	while (1) {
 		remote_event_wait(&state->recycle_event, &local->recycle);
 
 		process_free_queue(state, found, length);
@@ -1997,7 +1997,7 @@ sync_func(void *v)
 			state->remote->slot_sync);
 	int svc_fourcc;
 
-	while (!kthread_should_stop()) {
+	while (1) {
 		struct vchiq_service *service;
 		int msgid, size;
 		int type;
@@ -2844,10 +2844,6 @@ vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instan
 		(void)vchiq_remove_service(instance, service->handle);
 		vchiq_service_put(service);
 	}
-
-	kthread_stop(state->sync_thread);
-	kthread_stop(state->recycle_thread);
-	kthread_stop(state->slot_handler_thread);
 }
 
 int
-- 
2.43.0


             reply	other threads:[~2024-03-30 16:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-30 16:04 Umang Jain [this message]
2024-04-02 20:08 ` [PATCH] Revert "staging: vc04_services: vchiq_core: Stop kthreads on shutdown" Stefan Wahren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240330160440.49179-1-umang.jain@ideasonboard.com \
    --to=umang.jain@ideasonboard.com \
    --cc=broonie@kernel.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=error27@gmail.com \
    --cc=greg@kroah.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-staging@lists.linux.dev \
    --cc=phil@raspberrypi.com \
    --cc=wahrenst@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).