Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) SoundWire Locking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) This document explains locking mechanism of the SoundWire Bus. Bus uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) following locks in order to avoid race conditions in Bus operations on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) shared resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)   - Bus lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)   - Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) Bus lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) SoundWire Bus lock is a mutex and is part of Bus data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) (sdw_bus) which is used for every Bus instance. This lock is used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) serialize each of the following operations(s) within SoundWire Bus instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)   - Addition and removal of Slave(s), changing Slave status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)   - Prepare, Enable, Disable and De-prepare stream operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)   - Access of Stream data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) SoundWire message transfer lock. This mutex is part of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) Bus data structure (sdw_bus). This lock is used to serialize the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) transfers (read/write) within a SoundWire Bus instance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) Below examples show how locks are acquired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) Example 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) ---------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) Message transfer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)   1. For every message transfer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)      a. Acquire Message lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)      b. Transfer message (Read/Write) to Slave1 or broadcast message on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)         Bus in case of bank switch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)      c. Release Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)      ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	+----------+                    +---------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	|          |                    |         |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	|   Bus    |                    | Master  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	|          |                    | Driver  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	|          |                    |         |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	+----+-----+                    +----+----+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	     |     bus->ops->xfer_msg()      |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	     <-------------------------------+   a. Acquire Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	     |                               |   b. Transfer message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	     +------------------------------->   c. Release Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	     |    return success/error       |   d. Return success/error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	     +                               +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) Example 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) ---------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) Prepare operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)   1. Acquire lock for Bus instance associated with Master 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)   2. For every message transfer in Prepare operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)      a. Acquire Message lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)      b. Transfer message (Read/Write) to Slave1 or broadcast message on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)         Bus in case of bank switch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)      c. Release Message lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)   3. Release lock for Bus instance associated with Master 1 ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	+----------+                    +---------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	|          |                    |         |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	|   Bus    |                    | Master  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	|          |                    | Driver  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	|          |                    |         |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	+----+-----+                    +----+----+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	     |    sdw_prepare_stream()       |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	     <-------------------------------+   1. Acquire bus lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	     |                               |   2. Perform stream prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	     |     bus->ops->xfer_msg()      |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	     <-------------------------------+   a. Acquire Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	     |                               |   b. Transfer message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	     +------------------------------->   c. Release Message lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	     |    return success/error       |   d. Return success/error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	     |    return success/error       |   3. Release bus lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	     +------------------------------->   4. Return success/error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	     |                               |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	     +                               +