Commit e928d5c
soundwire: bus: serialize BPT/BRA transfers per bus
On Intel ACE2+ platforms, each SoundWire link uses a single pair of
PDIs (PDI0 for TX, PDI1 for RX) and associated DMA resources for
Bulk Port Transfers. When two codecs on the same link initiate BRA
transfers concurrently (e.g. during firmware download), the second
sdw_bpt_send_async() call races with the first:
- intel_ace2x_bpt_open_stream() has a TOCTOU on the bpt_stream
pointer: both callers see it as NULL and proceed
- The second open overwrites the first's stream allocation, leaking
the original sdw_stream_runtime
- PCMSyCM mappings for the first transfer get overwritten, causing
chain DMA to operate with wrong PDI assignments
- IOC timeouts, use-after-free, and double-free follow on close
Add a per-bus bpt_lock mutex held across the send_async/wait span to
serialize BPT transfers. The lock is acquired in sdw_bpt_send_async()
before calling the master ops and released in sdw_bpt_wait() after the
transfer completes. On send_async failure, the lock is released
immediately.
Cross-link transfers (different sdw_bus instances) remain concurrent
since each bus has its own lock.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>1 parent f6602b8 commit e928d5c
2 files changed
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
2094 | 2096 | | |
2095 | 2097 | | |
2096 | 2098 | | |
| 2099 | + | |
2097 | 2100 | | |
2098 | 2101 | | |
2099 | 2102 | | |
| |||
2118 | 2121 | | |
2119 | 2122 | | |
2120 | 2123 | | |
2121 | | - | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
2122 | 2133 | | |
2123 | 2134 | | |
2124 | 2135 | | |
2125 | 2136 | | |
2126 | 2137 | | |
2127 | | - | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
2128 | 2144 | | |
2129 | 2145 | | |
2130 | 2146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
| 1047 | + | |
1047 | 1048 | | |
1048 | 1049 | | |
1049 | 1050 | | |
| |||
0 commit comments