1 From 6d7ababea249987cb3014e62b54d8ee577179107 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Tue, 29 Jan 2019 16:29:00 +0000
4 Subject: [PATCH 343/725] staging: vc-sm-cma: Use a void* pointer as the handle
7 The driver was using an unsigned int as the handle to the outside world,
8 and doing a nasty cast to the struct dmabuf when handed it back.
9 This breaks badly with a 64 bit kernel where the pointer doesn't fit
12 Switch to using a void* within the kernel. Reality is that it is
13 a struct dma_buf*, but advertising it as such to other drivers seems
14 to encourage the use of it as such, and I'm not sure on the implications
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
19 drivers/staging/vc04_services/vc-sm-cma/vc_sm.c | 10 +++++-----
20 drivers/staging/vc04_services/vc-sm-cma/vc_sm_knl.h | 6 +++---
21 drivers/staging/vc04_services/vchiq-mmal/mmal-common.h | 2 +-
22 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +-
23 4 files changed, 10 insertions(+), 10 deletions(-)
25 --- a/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
26 +++ b/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
27 @@ -745,7 +745,7 @@ static int bcm2835_vc_sm_cma_remove(stru
30 /* Get an internal resource handle mapped from the external one. */
31 -int vc_sm_cma_int_handle(int handle)
32 +int vc_sm_cma_int_handle(void *handle)
34 struct dma_buf *dma_buf = (struct dma_buf *)handle;
35 struct vc_sm_buffer *res;
36 @@ -762,7 +762,7 @@ int vc_sm_cma_int_handle(int handle)
37 EXPORT_SYMBOL_GPL(vc_sm_cma_int_handle);
39 /* Free a previously allocated shared memory handle and block. */
40 -int vc_sm_cma_free(int handle)
41 +int vc_sm_cma_free(void *handle)
43 struct dma_buf *dma_buf = (struct dma_buf *)handle;
45 @@ -772,7 +772,7 @@ int vc_sm_cma_free(int handle)
49 - pr_debug("%s: handle %08x/dmabuf %p\n", __func__, handle, dma_buf);
50 + pr_debug("%s: handle %p/dmabuf %p\n", __func__, handle, dma_buf);
54 @@ -781,7 +781,7 @@ int vc_sm_cma_free(int handle)
55 EXPORT_SYMBOL_GPL(vc_sm_cma_free);
57 /* Import a dmabuf to be shared with VC. */
58 -int vc_sm_cma_import_dmabuf(struct dma_buf *src_dmabuf, int *handle)
59 +int vc_sm_cma_import_dmabuf(struct dma_buf *src_dmabuf, void **handle)
61 struct dma_buf *new_dma_buf;
62 struct vc_sm_buffer *res;
63 @@ -801,7 +801,7 @@ int vc_sm_cma_import_dmabuf(struct dma_b
64 res = (struct vc_sm_buffer *)new_dma_buf->priv;
66 /* Assign valid handle at this time.*/
67 - *handle = (int)new_dma_buf;
68 + *handle = new_dma_buf;
71 * succeeded in importing the dma_buf, but then
72 --- a/drivers/staging/vc04_services/vc-sm-cma/vc_sm_knl.h
73 +++ b/drivers/staging/vc04_services/vc-sm-cma/vc_sm_knl.h
77 /* Free a previously allocated or imported shared memory handle and block. */
78 -int vc_sm_cma_free(int handle);
79 +int vc_sm_cma_free(void *handle);
81 /* Get an internal resource handle mapped from the external one. */
82 -int vc_sm_cma_int_handle(int handle);
83 +int vc_sm_cma_int_handle(void *handle);
85 /* Import a block of memory into the GPU space. */
86 -int vc_sm_cma_import_dmabuf(struct dma_buf *dmabuf, int *handle);
87 +int vc_sm_cma_import_dmabuf(struct dma_buf *dmabuf, void **handle);
89 #endif /* __VC_SM_KNL_H__INCLUDED__ */
90 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
91 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
92 @@ -52,7 +52,7 @@ struct mmal_buffer {
93 struct mmal_msg_context *msg_context;
95 struct dma_buf *dma_buf;/* Exported dmabuf fd from videobuf2 */
96 - int vcsm_handle; /* VCSM handle having imported the dmabuf */
97 + void *vcsm_handle; /* VCSM handle having imported the dmabuf */
98 u32 vc_handle; /* VC handle to that dmabuf */
100 u32 cmd; /* MMAL command. 0=data. */
101 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
102 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
103 @@ -1794,7 +1794,7 @@ int mmal_vchi_buffer_cleanup(struct mmal
104 if (buf->vcsm_handle) {
107 - pr_debug("%s: vc_sm_cma_free on handle %08X\n", __func__,
108 + pr_debug("%s: vc_sm_cma_free on handle %p\n", __func__,
110 ret = vc_sm_cma_free(buf->vcsm_handle);