Skip to content

Commit b933c72

Browse files
committed
Merge tag 'staging-6.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver fixes from Greg KH: "Here are some small driver fixes for the vchiq_arm staging driver: - reverts of previous changes that turned out to caused problems. - change to prevent a resource leak All of these have been in linux-next this week with no reported problems" * tag 'staging-6.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: staging: vchiq_arm: Make vchiq_shutdown never fail Revert "staging: vchiq_arm: Create keep-alive thread during probe" Revert "staging: vchiq_arm: Improve initial VCHIQ connect"
2 parents ecf11d3 + f2b8ebf commit b933c72

File tree

3 files changed

+56
-45
lines changed

3 files changed

+56
-45
lines changed

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

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ struct vchiq_arm_state {
9797
* tracked separately with the state.
9898
*/
9999
int peer_use_count;
100+
101+
/*
102+
* Flag to indicate that the first vchiq connect has made it through.
103+
* This means that both sides should be fully ready, and we should
104+
* be able to suspend after this point.
105+
*/
106+
int first_connect;
100107
};
101108

102109
static int
@@ -273,6 +280,29 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
273280
return 0;
274281
}
275282

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+
276306
static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
277307
{
278308
return (struct vchiq_arm_state *)state->platform_state;
@@ -363,8 +393,7 @@ int vchiq_shutdown(struct vchiq_instance *instance)
363393
struct vchiq_state *state = instance->state;
364394
int ret = 0;
365395

366-
if (mutex_lock_killable(&state->mutex))
367-
return -EAGAIN;
396+
mutex_lock(&state->mutex);
368397

369398
/* Remove all services */
370399
vchiq_shutdown_internal(state, instance);
@@ -981,39 +1010,6 @@ vchiq_keepalive_thread_func(void *v)
9811010
return 0;
9821011
}
9831012

984-
int
985-
vchiq_platform_init_state(struct vchiq_state *state)
986-
{
987-
struct vchiq_arm_state *platform_state;
988-
char threadname[16];
989-
990-
platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
991-
if (!platform_state)
992-
return -ENOMEM;
993-
994-
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
995-
state->id);
996-
platform_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
997-
(void *)state, threadname);
998-
if (IS_ERR(platform_state->ka_thread)) {
999-
dev_err(state->dev, "couldn't create thread %s\n", threadname);
1000-
return PTR_ERR(platform_state->ka_thread);
1001-
}
1002-
1003-
rwlock_init(&platform_state->susp_res_lock);
1004-
1005-
init_completion(&platform_state->ka_evt);
1006-
atomic_set(&platform_state->ka_use_count, 0);
1007-
atomic_set(&platform_state->ka_use_ack_count, 0);
1008-
atomic_set(&platform_state->ka_release_count, 0);
1009-
1010-
platform_state->state = state;
1011-
1012-
state->platform_state = (struct opaque_platform_state *)platform_state;
1013-
1014-
return 0;
1015-
}
1016-
10171013
int
10181014
vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
10191015
enum USE_TYPE_E use_type)
@@ -1329,19 +1325,37 @@ vchiq_check_service(struct vchiq_service *service)
13291325
return ret;
13301326
}
13311327

1332-
void vchiq_platform_connected(struct vchiq_state *state)
1333-
{
1334-
struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
1335-
1336-
wake_up_process(arm_state->ka_thread);
1337-
}
1338-
13391328
void vchiq_platform_conn_state_changed(struct vchiq_state *state,
13401329
enum vchiq_connstate oldstate,
13411330
enum vchiq_connstate newstate)
13421331
{
1332+
struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
1333+
char threadname[16];
1334+
13431335
dev_dbg(state->dev, "suspend: %d: %s->%s\n",
13441336
state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate));
1337+
if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED)
1338+
return;
1339+
1340+
write_lock_bh(&arm_state->susp_res_lock);
1341+
if (arm_state->first_connect) {
1342+
write_unlock_bh(&arm_state->susp_res_lock);
1343+
return;
1344+
}
1345+
1346+
arm_state->first_connect = 1;
1347+
write_unlock_bh(&arm_state->susp_res_lock);
1348+
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
1349+
state->id);
1350+
arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
1351+
(void *)state,
1352+
threadname);
1353+
if (IS_ERR(arm_state->ka_thread)) {
1354+
dev_err(state->dev, "suspend: Couldn't create thread %s\n",
1355+
threadname);
1356+
} else {
1357+
wake_up_process(arm_state->ka_thread);
1358+
}
13451359
}
13461360

13471361
static const struct of_device_id vchiq_of_match[] = {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,6 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc
33433343
return -EAGAIN;
33443344

33453345
vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED);
3346-
vchiq_platform_connected(state);
33473346
complete(&state->connect);
33483347
}
33493348

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,6 @@ int vchiq_send_remote_use(struct vchiq_state *state);
575575

576576
int vchiq_send_remote_use_active(struct vchiq_state *state);
577577

578-
void vchiq_platform_connected(struct vchiq_state *state);
579-
580578
void vchiq_platform_conn_state_changed(struct vchiq_state *state,
581579
enum vchiq_connstate oldstate,
582580
enum vchiq_connstate newstate);

0 commit comments

Comments
 (0)