Skip to content

Commit 228af5a

Browse files
lategoodbyegregkh
authored andcommitted
Revert "staging: vchiq_arm: Create keep-alive thread during probe"
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 <[email protected]> Closes: https://lore.kernel.org/linux-staging/[email protected]/ Cc: [email protected] Signed-off-by: Stefan Wahren <[email protected]> Reviewed-by: Maíra Canal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ebe0b2e commit 228af5a

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
@@ -280,6 +280,29 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
280280
return 0;
281281
}
282282

283+
int
284+
vchiq_platform_init_state(struct vchiq_state *state)
285+
{
286+
struct vchiq_arm_state *platform_state;
287+
288+
platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
289+
if (!platform_state)
290+
return -ENOMEM;
291+
292+
rwlock_init(&platform_state->susp_res_lock);
293+
294+
init_completion(&platform_state->ka_evt);
295+
atomic_set(&platform_state->ka_use_count, 0);
296+
atomic_set(&platform_state->ka_use_ack_count, 0);
297+
atomic_set(&platform_state->ka_release_count, 0);
298+
299+
platform_state->state = state;
300+
301+
state->platform_state = (struct opaque_platform_state *)platform_state;
302+
303+
return 0;
304+
}
305+
283306
static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
284307
{
285308
return (struct vchiq_arm_state *)state->platform_state;
@@ -988,39 +1011,6 @@ vchiq_keepalive_thread_func(void *v)
9881011
return 0;
9891012
}
9901013

991-
int
992-
vchiq_platform_init_state(struct vchiq_state *state)
993-
{
994-
struct vchiq_arm_state *platform_state;
995-
char threadname[16];
996-
997-
platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
998-
if (!platform_state)
999-
return -ENOMEM;
1000-
1001-
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
1002-
state->id);
1003-
platform_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
1004-
(void *)state, threadname);
1005-
if (IS_ERR(platform_state->ka_thread)) {
1006-
dev_err(state->dev, "couldn't create thread %s\n", threadname);
1007-
return PTR_ERR(platform_state->ka_thread);
1008-
}
1009-
1010-
rwlock_init(&platform_state->susp_res_lock);
1011-
1012-
init_completion(&platform_state->ka_evt);
1013-
atomic_set(&platform_state->ka_use_count, 0);
1014-
atomic_set(&platform_state->ka_use_ack_count, 0);
1015-
atomic_set(&platform_state->ka_release_count, 0);
1016-
1017-
platform_state->state = state;
1018-
1019-
state->platform_state = (struct opaque_platform_state *)platform_state;
1020-
1021-
return 0;
1022-
}
1023-
10241014
int
10251015
vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
10261016
enum USE_TYPE_E use_type)
@@ -1341,6 +1331,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
13411331
enum vchiq_connstate newstate)
13421332
{
13431333
struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
1334+
char threadname[16];
13441335

13451336
dev_dbg(state->dev, "suspend: %d: %s->%s\n",
13461337
state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate));
@@ -1355,7 +1346,17 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
13551346

13561347
arm_state->first_connect = 1;
13571348
write_unlock_bh(&arm_state->susp_res_lock);
1358-
wake_up_process(arm_state->ka_thread);
1349+
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
1350+
state->id);
1351+
arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
1352+
(void *)state,
1353+
threadname);
1354+
if (IS_ERR(arm_state->ka_thread)) {
1355+
dev_err(state->dev, "suspend: Couldn't create thread %s\n",
1356+
threadname);
1357+
} else {
1358+
wake_up_process(arm_state->ka_thread);
1359+
}
13591360
}
13601361

13611362
static const struct of_device_id vchiq_of_match[] = {

0 commit comments

Comments
 (0)