ath79: add support for COMFAST CF-E130N v2
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-4.19 / 950-0298-staging-vc-sm-cma-Use-a-void-pointer-as-the-handle-w.patch
1 From df84621e5bd5cc206d1039ce0880ccd0b325525b 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] staging: vc-sm-cma: Use a void* pointer as the handle
5 within the kernel
6
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
10 in an unsigned int.
11
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
15 of that.
16
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
18 ---
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(-)
24
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
28 }
29
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)
33 {
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);
38
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)
42 {
43 struct dma_buf *dma_buf = (struct dma_buf *)handle;
44
45 @@ -772,7 +772,7 @@ int vc_sm_cma_free(int handle)
46 return -EPERM;
47 }
48
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);
51
52 dma_buf_put(dma_buf);
53
54 @@ -781,7 +781,7 @@ int vc_sm_cma_free(int handle)
55 EXPORT_SYMBOL_GPL(vc_sm_cma_free);
56
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)
60 {
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;
65
66 /* Assign valid handle at this time.*/
67 - *handle = (int)new_dma_buf;
68 + *handle = new_dma_buf;
69 } else {
70 /*
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
74 @@ -17,12 +17,12 @@
75 #endif
76
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);
80
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);
84
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);
88
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;
94
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 */
99
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) {
105 int ret;
106
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__,
109 buf->vcsm_handle);
110 ret = vc_sm_cma_free(buf->vcsm_handle);
111 if (ret)