Skip to content

Commit ff62859

Browse files
lategoodbyegregkh
authored andcommitted
Revert "staging: vchiq_arm: Create keep-alive thread during probe"
commit 228af5a upstream. The commit 86bc882 ("staging: vchiq_arm: Create keep-alive thread during probe") introduced a regression for certain configurations, which doesn't have a VCHIQ user. This results in a unused and hanging keep-alive thread: INFO: task vchiq-keep/0:85 blocked for more than 120 seconds. Not tainted 6.12.34-v8-+ #13 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:vchiq-keep/0 state:D stack:0 pid:85 tgid:85 ppid:2 Call trace: __switch_to+0x188/0x230 __schedule+0xa54/0xb28 schedule+0x80/0x120 schedule_preempt_disabled+0x30/0x50 kthread+0xd4/0x1a0 ret_from_fork+0x10/0x20 Fixes: 86bc882 ("staging: vchiq_arm: Create keep-alive thread during probe") Reported-by: Maíra Canal <mcanal@igalia.com> Closes: https://lore.kernel.org/linux-staging/ba35b960-a981-4671-9f7f-060da10feaa1@usp.br/ Cc: stable@kernel.org Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Reviewed-by: Maíra Canal <mcanal@igalia.com> Link: https://lore.kernel.org/r/20250715161108.3411-3-wahrenst@gmx.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 970635e commit ff62859

File tree

1 file changed

+35
-34
lines changed
  • drivers/staging/vc04_services/interface/vchiq_arm

1 file changed

+35
-34
lines changed

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

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,29 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
588588
return 0;
589589
}
590590

591+
int
592+
vchiq_platform_init_state(struct vchiq_state *state)
593+
{
594+
struct vchiq_arm_state *platform_state;
595+
596+
platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
597+
if (!platform_state)
598+
return -ENOMEM;
599+
600+
rwlock_init(&platform_state->susp_res_lock);
601+
602+
init_completion(&platform_state->ka_evt);
603+
atomic_set(&platform_state->ka_use_count, 0);
604+
atomic_set(&platform_state->ka_use_ack_count, 0);
605+
atomic_set(&platform_state->ka_release_count, 0);
606+
607+
platform_state->state = state;
608+
609+
state->platform_state = (struct opaque_platform_state *)platform_state;
610+
611+
return 0;
612+
}
613+
591614
static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
592615
{
593616
return (struct vchiq_arm_state *)state->platform_state;
@@ -1335,39 +1358,6 @@ vchiq_keepalive_thread_func(void *v)
13351358
return 0;
13361359
}
13371360

1338-
int
1339-
vchiq_platform_init_state(struct vchiq_state *state)
1340-
{
1341-
struct vchiq_arm_state *platform_state;
1342-
char threadname[16];
1343-
1344-
platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
1345-
if (!platform_state)
1346-
return -ENOMEM;
1347-
1348-
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
1349-
state->id);
1350-
platform_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
1351-
(void *)state, threadname);
1352-
if (IS_ERR(platform_state->ka_thread)) {
1353-
dev_err(state->dev, "couldn't create thread %s\n", threadname);
1354-
return PTR_ERR(platform_state->ka_thread);
1355-
}
1356-
1357-
rwlock_init(&platform_state->susp_res_lock);
1358-
1359-
init_completion(&platform_state->ka_evt);
1360-
atomic_set(&platform_state->ka_use_count, 0);
1361-
atomic_set(&platform_state->ka_use_ack_count, 0);
1362-
atomic_set(&platform_state->ka_release_count, 0);
1363-
1364-
platform_state->state = state;
1365-
1366-
state->platform_state = (struct opaque_platform_state *)platform_state;
1367-
1368-
return 0;
1369-
}
1370-
13711361
int
13721362
vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
13731363
enum USE_TYPE_E use_type)
@@ -1688,6 +1678,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
16881678
enum vchiq_connstate newstate)
16891679
{
16901680
struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
1681+
char threadname[16];
16911682

16921683
dev_dbg(state->dev, "suspend: %d: %s->%s\n",
16931684
state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate));
@@ -1702,7 +1693,17 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
17021693

17031694
arm_state->first_connect = 1;
17041695
write_unlock_bh(&arm_state->susp_res_lock);
1705-
wake_up_process(arm_state->ka_thread);
1696+
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
1697+
state->id);
1698+
arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
1699+
(void *)state,
1700+
threadname);
1701+
if (IS_ERR(arm_state->ka_thread)) {
1702+
dev_err(state->dev, "suspend: Couldn't create thread %s\n",
1703+
threadname);
1704+
} else {
1705+
wake_up_process(arm_state->ka_thread);
1706+
}
17061707
}
17071708

17081709
static const struct of_device_id vchiq_of_match[] = {

0 commit comments

Comments
 (0)