@@ -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+ */
174189struct 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+ */
289321struct 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+ */
303339struct 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