staging: vchiq_arm: Improve initial VCHIQ connect
authorStefan Wahren <wahrenst@gmx.net>
Sun, 9 Mar 2025 12:50:14 +0000 (13:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2025 14:11:21 +0000 (07:11 -0700)
The code to start the keep-alive thread on initial VCHIQ connect
within vchiq_platform_conn_state_changed is unnecessary complex.
Move the keep-alive thread wake-up into a separate function and call it
during VCHIQ connect.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20250309125014.37166-6-wahrenst@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h

index cdf5687ad4f057c9ae2b7ed8c6d1c4d9e1ee081b..5dbf8d53db09f1d1c23588f72e7679b9df7f4b7e 100644 (file)
@@ -97,13 +97,6 @@ struct vchiq_arm_state {
         * tracked separately with the state.
         */
        int peer_use_count;
-
-       /*
-        * Flag to indicate that the first vchiq connect has made it through.
-        * This means that both sides should be fully ready, and we should
-        * be able to suspend after this point.
-        */
-       int first_connect;
 };
 
 static int
@@ -1336,26 +1329,19 @@ out:
        return ret;
 }
 
+void vchiq_platform_connected(struct vchiq_state *state)
+{
+       struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
+
+       wake_up_process(arm_state->ka_thread);
+}
+
 void vchiq_platform_conn_state_changed(struct vchiq_state *state,
                                       enum vchiq_connstate oldstate,
                                       enum vchiq_connstate newstate)
 {
-       struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
-
        dev_dbg(state->dev, "suspend: %d: %s->%s\n",
                state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate));
-       if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED)
-               return;
-
-       write_lock_bh(&arm_state->susp_res_lock);
-       if (arm_state->first_connect) {
-               write_unlock_bh(&arm_state->susp_res_lock);
-               return;
-       }
-
-       arm_state->first_connect = 1;
-       write_unlock_bh(&arm_state->susp_res_lock);
-       wake_up_process(arm_state->ka_thread);
 }
 
 static const struct of_device_id vchiq_of_match[] = {
index e2cac0898b8faa3c255de6b8562c7096a9683c49..e7b0c800a205ddac55e5a1dc37eb3ef57f25f7bb 100644 (file)
@@ -3343,6 +3343,7 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc
                        return -EAGAIN;
 
                vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED);
+               vchiq_platform_connected(state);
                complete(&state->connect);
        }
 
index 9b4e766990a493d6e9d4e0604f2c84f4e7b77804..3b5c0618e5672f07e2701f6b833ca0e05c045317 100644 (file)
@@ -575,6 +575,8 @@ int vchiq_send_remote_use(struct vchiq_state *state);
 
 int vchiq_send_remote_use_active(struct vchiq_state *state);
 
+void vchiq_platform_connected(struct vchiq_state *state);
+
 void vchiq_platform_conn_state_changed(struct vchiq_state *state,
                                       enum vchiq_connstate oldstate,
                                  enum vchiq_connstate newstate);