|
36 | 36 | #include "vchiq_arm.h"
|
37 | 37 | #include "vchiq_bus.h"
|
38 | 38 | #include "vchiq_debugfs.h"
|
39 |
| -#include "vchiq_connected.h" |
40 | 39 | #include "vchiq_pagelist.h"
|
41 | 40 |
|
42 | 41 | #define DEVICE_NAME "vchiq"
|
@@ -189,6 +188,56 @@ is_adjacent_block(u32 *addrs, u32 addr, unsigned int k)
|
189 | 188 | return tmp == (addr & PAGE_MASK);
|
190 | 189 | }
|
191 | 190 |
|
| 191 | +/* |
| 192 | + * This function is called by the vchiq stack once it has been connected to |
| 193 | + * the videocore and clients can start to use the stack. |
| 194 | + */ |
| 195 | +static void vchiq_call_connected_callbacks(struct vchiq_drv_mgmt *drv_mgmt) |
| 196 | +{ |
| 197 | + int i; |
| 198 | + |
| 199 | + if (mutex_lock_killable(&drv_mgmt->connected_mutex)) |
| 200 | + return; |
| 201 | + |
| 202 | + for (i = 0; i < drv_mgmt->num_deferred_callbacks; i++) |
| 203 | + drv_mgmt->deferred_callback[i](); |
| 204 | + |
| 205 | + drv_mgmt->num_deferred_callbacks = 0; |
| 206 | + drv_mgmt->connected = true; |
| 207 | + mutex_unlock(&drv_mgmt->connected_mutex); |
| 208 | +} |
| 209 | + |
| 210 | +/* |
| 211 | + * This function is used to defer initialization until the vchiq stack is |
| 212 | + * initialized. If the stack is already initialized, then the callback will |
| 213 | + * be made immediately, otherwise it will be deferred until |
| 214 | + * vchiq_call_connected_callbacks is called. |
| 215 | + */ |
| 216 | +void vchiq_add_connected_callback(struct vchiq_device *device, void (*callback)(void)) |
| 217 | +{ |
| 218 | + struct vchiq_drv_mgmt *drv_mgmt = device->drv_mgmt; |
| 219 | + |
| 220 | + if (mutex_lock_killable(&drv_mgmt->connected_mutex)) |
| 221 | + return; |
| 222 | + |
| 223 | + if (drv_mgmt->connected) { |
| 224 | + /* We're already connected. Call the callback immediately. */ |
| 225 | + callback(); |
| 226 | + } else { |
| 227 | + if (drv_mgmt->num_deferred_callbacks >= VCHIQ_DRV_MAX_CALLBACKS) { |
| 228 | + dev_err(&device->dev, |
| 229 | + "core: deferred callbacks(%d) exceeded the maximum limit(%d)\n", |
| 230 | + drv_mgmt->num_deferred_callbacks, VCHIQ_DRV_MAX_CALLBACKS); |
| 231 | + } else { |
| 232 | + drv_mgmt->deferred_callback[drv_mgmt->num_deferred_callbacks] = |
| 233 | + callback; |
| 234 | + drv_mgmt->num_deferred_callbacks++; |
| 235 | + } |
| 236 | + } |
| 237 | + mutex_unlock(&drv_mgmt->connected_mutex); |
| 238 | +} |
| 239 | +EXPORT_SYMBOL(vchiq_add_connected_callback); |
| 240 | + |
192 | 241 | /* There is a potential problem with partial cache lines (pages?)
|
193 | 242 | * at the ends of the block when reading. If the CPU accessed anything in
|
194 | 243 | * the same line (page?) then it may have pulled old data into the cache,
|
|
0 commit comments