Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Maíra Canal" <maira.canal@usp.br>
To: Stefan Wahren <wahrenst@gmx.net>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Umang Jain <umang.jain@ideasonboard.com>,
	Ojaswin Mujoo <ojaswin98@gmail.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	bcm-kernel-feedback-list@broadcom.com,
	kernel-list@raspberrypi.com, linux-staging@lists.linux.dev
Subject: Re: [PATCH 4/5] staging: vchiq_arm: Create keep-alive thread during probe
Date: Thu, 26 Jun 2025 15:22:17 -0300	[thread overview]
Message-ID: <ba35b960-a981-4671-9f7f-060da10feaa1@usp.br> (raw)
In-Reply-To: <20250309125014.37166-5-wahrenst@gmx.net>

Hi Stefan,

On 09/03/25 09:50, Stefan Wahren wrote:
> Creating the keep-alive thread in vchiq_platform_init_state have
> the following advantages:
> - abort driver probe if kthread_create fails (more consistent behavior)
> - make resource release process easier
> 
> Since vchiq_keepalive_thread_func is defined below
> vchiq_platform_init_state, the latter must be moved.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>   .../interface/vchiq_arm/vchiq_arm.c           | 69 +++++++++----------
>   1 file changed, 34 insertions(+), 35 deletions(-)
> 

After this patch landed on 6.12 stable, I started to observe the
following warning in Mesa CI [1]:

20:07:07.830: [  242.653532] INFO: task vchiq-keep/0:85 blocked for more 
than 120 seconds.
20:07:07.835: [  242.660404]       Not tainted 6.12.34-v8-+ #13
20:07:07.843: [  242.666173] "echo 0 > 
/proc/sys/kernel/hung_task_timeout_secs" disables this message.
20:07:07.852: [  242.677126] task:vchiq-keep/0    state:D stack:0 
pid:85    tgid:85    ppid:2      flags:0x00000008
20:07:07.854: [  242.690734] Call trace:
20:07:07.857: [  242.693191]  __switch_to+0x188/0x230
20:07:07.858: [  242.697010]  __schedule+0xa54/0xb28
20:07:07.859: [  242.704889]  schedule+0x80/0x120
20:07:07.859: [  242.712581]  schedule_preempt_disabled+0x30/0x50
20:07:07.860: [  242.721437]  kthread+0xd4/0x1a0
20:07:07.861: [  242.724606]  ret_from_fork+0x10/0x20

If I revert this patch, I no longer get those warnings. From that, I was
wondering: is it possible that in some scenarios, we might never
actually get to the connected state and therefore, we wouldn't wake up
the kthread that we created when we initialized the state?

[1] https://gitlab.freedesktop.org/mairacanal/mesa/-/jobs/78940369

Best Regards,
- Maíra

> 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 0c7ea2d0ee85..64f9536f1232 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -280,29 +280,6 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
>   	return 0;
>   }
> 
> -int
> -vchiq_platform_init_state(struct vchiq_state *state)
> -{
> -	struct vchiq_arm_state *platform_state;
> -
> -	platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
> -	if (!platform_state)
> -		return -ENOMEM;
> -
> -	rwlock_init(&platform_state->susp_res_lock);
> -
> -	init_completion(&platform_state->ka_evt);
> -	atomic_set(&platform_state->ka_use_count, 0);
> -	atomic_set(&platform_state->ka_use_ack_count, 0);
> -	atomic_set(&platform_state->ka_release_count, 0);
> -
> -	platform_state->state = state;
> -
> -	state->platform_state = (struct opaque_platform_state *)platform_state;
> -
> -	return 0;
> -}
> -
>   static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
>   {
>   	return (struct vchiq_arm_state *)state->platform_state;
> @@ -1011,6 +988,39 @@ vchiq_keepalive_thread_func(void *v)
>   	return 0;
>   }
> 
> +int
> +vchiq_platform_init_state(struct vchiq_state *state)
> +{
> +	struct vchiq_arm_state *platform_state;
> +	char threadname[16];
> +
> +	platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
> +	if (!platform_state)
> +		return -ENOMEM;
> +
> +	snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
> +		 state->id);
> +	platform_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
> +						   (void *)state, threadname);
> +	if (IS_ERR(platform_state->ka_thread)) {
> +		dev_err(state->dev, "couldn't create thread %s\n", threadname);
> +		return PTR_ERR(platform_state->ka_thread);
> +	}
> +
> +	rwlock_init(&platform_state->susp_res_lock);
> +
> +	init_completion(&platform_state->ka_evt);
> +	atomic_set(&platform_state->ka_use_count, 0);
> +	atomic_set(&platform_state->ka_use_ack_count, 0);
> +	atomic_set(&platform_state->ka_release_count, 0);
> +
> +	platform_state->state = state;
> +
> +	state->platform_state = (struct opaque_platform_state *)platform_state;
> +
> +	return 0;
> +}
> +
>   int
>   vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
>   		   enum USE_TYPE_E use_type)
> @@ -1331,7 +1341,6 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
>   				       enum vchiq_connstate newstate)
>   {
>   	struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
> -	char threadname[16];
> 
>   	dev_dbg(state->dev, "suspend: %d: %s->%s\n",
>   		state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate));
> @@ -1346,17 +1355,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
> 
>   	arm_state->first_connect = 1;
>   	write_unlock_bh(&arm_state->susp_res_lock);
> -	snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
> -		 state->id);
> -	arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
> -					      (void *)state,
> -					      threadname);
> -	if (IS_ERR(arm_state->ka_thread)) {
> -		dev_err(state->dev, "suspend: Couldn't create thread %s\n",
> -			threadname);
> -	} else {
> -		wake_up_process(arm_state->ka_thread);
> -	}
> +	wake_up_process(arm_state->ka_thread);
>   }
> 
>   static const struct of_device_id vchiq_of_match[] = {
> --
> 2.34.1
> 
> 



  reply	other threads:[~2025-06-26 18:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-09 12:50 [PATCH 0/5] staging: vchiq_arm: Fix & improve resource handling Stefan Wahren
2025-03-09 12:50 ` [PATCH 1/5] staging: vchiq_arm: Register debugfs after cdev Stefan Wahren
2025-03-09 12:50 ` [PATCH 2/5] staging: vchiq_arm: Fix possible NPR of keep-alive thread Stefan Wahren
2025-03-09 12:50 ` [PATCH 3/5] staging: vchiq_arm: Stop kthreads if vchiq cdev register fails Stefan Wahren
2025-03-09 12:50 ` [PATCH 4/5] staging: vchiq_arm: Create keep-alive thread during probe Stefan Wahren
2025-06-26 18:22   ` Maíra Canal [this message]
2025-06-26 20:14     ` Stefan Wahren
2025-06-26 20:30       ` Maíra Canal
2025-06-27 15:18         ` Stefan Wahren
2025-06-27 22:28           ` Maíra Canal
2025-06-28 22:34             ` Stefan Wahren
2025-08-24 18:37               ` MichaIng
2025-08-24 19:58                 ` Stefan Wahren
2025-08-24 20:14                   ` MichaIng
2025-03-09 12:50 ` [PATCH 5/5] staging: vchiq_arm: Improve initial VCHIQ connect 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=ba35b960-a981-4671-9f7f-060da10feaa1@usp.br \
    --to=maira.canal@usp.br \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dan.carpenter@linaro.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-list@raspberrypi.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=ojaswin98@gmail.com \
    --cc=umang.jain@ideasonboard.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