Skip to content

Commit f875976

Browse files
Umang Jaingregkh
authored andcommitted
staging: vc04_services: Drop vchiq_connected.[ch] files
The vchiq_connected.[ch] just implements two function: - vchiq_add_connected_callback() - vchiq_call_connected_callbacks() for the deferred vchiq callbacks. Those can easily live in vchiq_arm.[ch], hence move them. This allows making the vchiq_call_connected_callbacks() function static. The move doesn't copy over MAX_CALLBACKS because it is the same as VCHIQ_DRV_MAX_CALLBACKS. Hence, it now being used in vchiq_add_connected_callback(). No functional changes intended in this patch. Suggested-by: Laurent Pinchart <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Umang Jain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e1c0af4 commit f875976

File tree

5 files changed

+55
-76
lines changed

5 files changed

+55
-76
lines changed

drivers/staging/vc04_services/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ vchiq-objs := \
66
interface/vchiq_arm/vchiq_arm.o \
77
interface/vchiq_arm/vchiq_bus.o \
88
interface/vchiq_arm/vchiq_debugfs.o \
9-
interface/vchiq_arm/vchiq_connected.o \
109

1110
ifdef CONFIG_VCHIQ_CDEV
1211
vchiq-objs += interface/vchiq_arm/vchiq_dev.o

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "vchiq_arm.h"
3737
#include "vchiq_bus.h"
3838
#include "vchiq_debugfs.h"
39-
#include "vchiq_connected.h"
4039
#include "vchiq_pagelist.h"
4140

4241
#define DEVICE_NAME "vchiq"
@@ -189,6 +188,56 @@ is_adjacent_block(u32 *addrs, u32 addr, unsigned int k)
189188
return tmp == (addr & PAGE_MASK);
190189
}
191190

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+
192241
/* There is a potential problem with partial cache lines (pages?)
193242
* at the ends of the block when reading. If the CPU accessed anything in
194243
* the same line (page?) then it may have pulled old data into the cache,

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define VCHIQ_DRV_MAX_CALLBACKS 10
2424

2525
struct rpi_firmware;
26+
struct vchiq_device;
2627

2728
enum USE_TYPE_E {
2829
USE_TYPE_SERVICE,
@@ -132,6 +133,10 @@ vchiq_instance_get_trace(struct vchiq_instance *instance);
132133
extern void
133134
vchiq_instance_set_trace(struct vchiq_instance *instance, int trace);
134135

136+
extern void
137+
vchiq_add_connected_callback(struct vchiq_device *device,
138+
void (*callback)(void));
139+
135140
#if IS_ENABLED(CONFIG_VCHIQ_CDEV)
136141

137142
extern void

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c

Lines changed: 0 additions & 60 deletions
This file was deleted.

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)