@@ -174,7 +174,21 @@ struct vchiq_slot_info {
174
174
short release_count ;
175
175
};
176
176
177
- /* TODO: Please explain the meaning of "service" in the context of VCHIQ */
177
+ /*
178
+ * VCHIQ is a reliable connection-oriented datagram protocol.
179
+ *
180
+ * A VCHIQ service is equivalent to a TCP connection, except:
181
+ * + FOURCCs are used for the rendezvous, and port numbers are assigned at the
182
+ * time the connection is established.
183
+ * + There is less of a distinction between server and client sockets, the only
184
+ * difference being which end makes the first move.
185
+ * + For a multi-client server, the server creates new "listening" services as
186
+ * the existing one becomes connected - there is no need to specify the
187
+ * maximum number of clients up front.
188
+ * + Data transfer is reliable but packetised (messages have defined ends).
189
+ * + Messages can be either short (capable of fitting in a slot) and in-band,
190
+ * or copied between external buffers (bulk transfers).
191
+ */
178
192
struct vchiq_service {
179
193
struct vchiq_service_base base ;
180
194
unsigned int handle ;
@@ -291,8 +305,21 @@ struct vchiq_shared_state {
291
305
};
292
306
293
307
/*
294
- * TODO: Mark all structs which are shared with the VideoCore and must not
295
- * be modified (ABI)
308
+ * vchiq_slot_zero describes the memory shared between the ARM host and the
309
+ * VideoCore VPU. The "master" and "slave" states are owned by the respective
310
+ * sides but visible to the other; the slots are shared, and the remaining
311
+ * fields are read-only.
312
+ *
313
+ * In the configuration used by this implementation, the memory is allocated
314
+ * by the host, the VPU is the master (the side which controls the DMA for bulk
315
+ * transfers), and the host is the slave.
316
+ *
317
+ * The owmership of slots changes with use:
318
+ * + When empty they are owned by the sender.
319
+ * + When partially filled they are shared with the receiver.
320
+ * + When completely full they are owned by the receiver.
321
+ * + When the receiver has finished processing the contents, they are recycled
322
+ * back to the sender.
296
323
*/
297
324
struct vchiq_slot_zero {
298
325
int magic ;
@@ -308,6 +335,10 @@ struct vchiq_slot_zero {
308
335
struct vchiq_slot_info slots [VCHIQ_MAX_SLOTS ];
309
336
};
310
337
338
+ /*
339
+ * This is the private runtime state used by each side. The same structure was
340
+ * originally used by both sides, but implementations have since diverged.
341
+ */
311
342
struct vchiq_state {
312
343
struct device * dev ;
313
344
int id ;
@@ -329,18 +360,27 @@ struct vchiq_state {
329
360
struct mutex mutex ;
330
361
struct vchiq_instance * * instance ;
331
362
332
- /* Processes incoming messages */
333
- /* TODO: This is the only thread which handles incoming messages
334
- * or just asynchronous messages ?
335
- */
363
+ /* This thread processes all incoming messages which aren't synchronous */
336
364
struct task_struct * slot_handler_thread ;
337
365
338
- /* Processes recycled slots */
339
- /* TODO: Please elaborate more ... (purpose) */
366
+ /*
367
+ * Slots which have been fully processed and released by the (peer)
368
+ * receiver are added to the receiver queue, which is asynchronously
369
+ * processed by the recycle thread.
370
+ */
340
371
struct task_struct * recycle_thread ;
341
372
342
- /* Processes synchronous messages */
343
- /* TODO: Please elaborate more ... (direction, purpose) */
373
+ /*
374
+ * Processes incoming synchronous messagses
375
+ *
376
+ * The synchronous message channel is shared between all synchronous
377
+ * services, and provides a way for urgent messages to bypass potentially
378
+ * long queues of asynchronous messages in the normal slots.
379
+ *
380
+ * There can be only one outstanding synchronous message in each direction,
381
+ * and as a precious shared resource synchronous services should be used
382
+ * sparingly.
383
+ */
344
384
struct task_struct * sync_thread ;
345
385
346
386
/* Local implementation of the trigger remote event */
0 commit comments