Skip to content

Commit 3d2115e

Browse files
pelwellgregkh
authored andcommitted
staging: vchiq_arm: Improve inline documentation
Add more comments to the VCHIQ driver, which provides some high-level descriptions how things work. Link: raspberrypi/linux#6801 Signed-off-by: Phil Elwell <phil@raspberrypi.com> [wahrenst@gmx.net: Rewrite commit log] Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com> Link: https://patch.msgid.link/20251029-vchiq-destage-v3-3-da8d6c83c2c5@ideasonboard.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e31d4d6 commit 3d2115e

2 files changed

Lines changed: 60 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ static const struct vchiq_platform_info bcm2836_info = {
7272
};
7373

7474
struct vchiq_arm_state {
75-
/* Keepalive-related data */
75+
/*
76+
* Keepalive-related data
77+
*
78+
* The keepalive mechanism was retro-fitted to VCHIQ to allow active
79+
* services to prevent the system from suspending.
80+
* This feature is not used on Raspberry Pi devices.
81+
*/
7682
struct task_struct *ka_thread;
7783
struct completion ka_evt;
7884
atomic_t ka_use_count;

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

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@ struct vchiq_slot_info {
171171
short release_count;
172172
};
173173

174+
/*
175+
* VCHIQ is a reliable connection-oriented datagram protocol.
176+
*
177+
* A VCHIQ service is equivalent to a TCP connection, except:
178+
* + FOURCCs are used for the rendezvous, and port numbers are assigned at the
179+
* time the connection is established.
180+
* + There is less of a distinction between server and client sockets, the only
181+
* difference being which end makes the first move.
182+
* + For a multi-client server, the server creates new "listening" services as
183+
* the existing one becomes connected - there is no need to specify the
184+
* maximum number of clients up front.
185+
* + Data transfer is reliable but packetized (messages have defined ends).
186+
* + Messages can be either short (capable of fitting in a slot) and in-band,
187+
* or copied between external buffers (bulk transfers).
188+
*/
174189
struct vchiq_service {
175190
struct vchiq_service_base base;
176191
unsigned int handle;
@@ -286,6 +301,23 @@ struct vchiq_shared_state {
286301
int debug[DEBUG_MAX];
287302
};
288303

304+
/*
305+
* vchiq_slot_zero describes the memory shared between the ARM host and the
306+
* VideoCore VPU. The "master" and "slave" states are owned by the respective
307+
* sides but visible to the other; the slots are shared, and the remaining
308+
* fields are read-only.
309+
*
310+
* In the configuration used by this implementation, the memory is allocated
311+
* by the host, the VPU is the master (the side which controls the DMA for bulk
312+
* transfers), and the host is the slave.
313+
*
314+
* The ownership of slots changes with use:
315+
* + When empty they are owned by the sender.
316+
* + When partially filled they are shared with the receiver.
317+
* + When completely full they are owned by the receiver.
318+
* + When the receiver has finished processing the contents, they are recycled
319+
* back to the sender.
320+
*/
289321
struct vchiq_slot_zero {
290322
int magic;
291323
short version;
@@ -300,6 +332,10 @@ struct vchiq_slot_zero {
300332
struct vchiq_slot_info slots[VCHIQ_MAX_SLOTS];
301333
};
302334

335+
/*
336+
* This is the private runtime state used by each side. The same structure was
337+
* originally used by both sides, but implementations have since diverged.
338+
*/
303339
struct vchiq_state {
304340
struct device *dev;
305341
int id;
@@ -321,13 +357,27 @@ struct vchiq_state {
321357
struct mutex mutex;
322358
struct vchiq_instance **instance;
323359

324-
/* Processes incoming messages */
360+
/* Processes all incoming messages which aren't synchronous */
325361
struct task_struct *slot_handler_thread;
326362

327-
/* Processes recycled slots */
363+
/*
364+
* Slots which have been fully processed and released by the (peer)
365+
* receiver are added to the receiver queue, which is asynchronously
366+
* processed by the recycle thread.
367+
*/
328368
struct task_struct *recycle_thread;
329369

330-
/* Processes synchronous messages */
370+
/*
371+
* Processes incoming synchronous messages
372+
*
373+
* The synchronous message channel is shared between all synchronous
374+
* services, and provides a way for urgent messages to bypass
375+
* potentially long queues of asynchronous messages in the normal slots.
376+
*
377+
* There can be only one outstanding synchronous message in
378+
* each direction, and as a precious shared resource synchronous
379+
* services should be used sparingly.
380+
*/
331381
struct task_struct *sync_thread;
332382

333383
/* Local implementation of the trigger remote event */

0 commit comments

Comments
 (0)