1 From 50df0b1532cf88e2ec152caa2cf89af0d0646b4a Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Tue, 22 Jan 2019 12:04:09 +0000
4 Subject: [PATCH] staging: mmal-vchiq: Fix client_component for 64 bit
7 The MMAL client_component field is used with the event
8 mechanism to allow the client to identify the component for
9 which the event is generated.
10 The field is only 32bits in size, therefore we can't use a
11 pointer to the component in a 64 bit kernel.
13 Component handles are already held in an array per VCHI
14 instance, so use the array index as the client_component handle
15 to avoid having to create a new IDR for this purpose.
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
19 .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 +++++++++---
20 .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 1 +
21 2 files changed, 10 insertions(+), 3 deletions(-)
23 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
24 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
25 @@ -472,9 +472,9 @@ buffer_from_host(struct vchiq_mmal_insta
26 static void event_to_host_cb(struct vchiq_mmal_instance *instance,
27 struct mmal_msg *msg, u32 msg_len)
29 - /* FIXME: Not going to work on 64 bit */
30 + int comp_idx = msg->u.event_to_host.client_component;
31 struct vchiq_mmal_component *component =
32 - (struct vchiq_mmal_component *)msg->u.event_to_host.client_component;
33 + &instance->component[comp_idx];
34 struct vchiq_mmal_port *port = NULL;
35 struct mmal_msg_context *msg_context;
36 u32 port_num = msg->u.event_to_host.port_num;
37 @@ -1073,7 +1073,7 @@ static int create_component(struct vchiq
39 /* build component create message */
40 m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
41 - m.u.component_create.client_component = (u32)(unsigned long)component;
42 + m.u.component_create.client_component = component->client_component;
43 strncpy(m.u.component_create.name, name,
44 sizeof(m.u.component_create.name));
46 @@ -1868,6 +1868,12 @@ int vchiq_mmal_component_init(struct vch
50 + /* We need a handle to reference back to our component structure.
51 + * Use the array index in instance->component rather than rolling
54 + component->client_component = idx;
56 ret = create_component(instance, component, name);
58 pr_err("%s: failed to create component %d (Not enough GPU mem?)\n",
59 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
60 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
61 @@ -97,6 +97,7 @@ struct vchiq_mmal_component {
62 struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
63 struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
64 struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
65 + u32 client_component; /* Used to ref back to client struct */
68 int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);