brcm2708-gpu-fw: update to latest firmware
[openwrt/staging/dedeckeh.git] / target / linux / brcm2708 / patches-4.19 / 950-0276-char-vc_mem-Fix-up-compat-ioctls-for-64bit-kernel.patch
1 From 966ff2b4c758eb8c8c04f26422cd183e6aa8eda5 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 23 Jan 2019 18:25:50 +0000
4 Subject: [PATCH] char: vc_mem: Fix up compat ioctls for 64bit kernel
5
6 compat_ioctl wasn't defined, so 32bit user/64bit kernel
7 always failed.
8 VC_MEM_IOC_MEM_PHYS_ADDR was defined with parameter size
9 unsigned long, so the ioctl cmd changes between sizes.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 ---
13 drivers/char/broadcom/vc_mem.c | 40 +++++++++++++++++++++++++++++----
14 include/linux/broadcom/vc_mem.h | 4 ++++
15 2 files changed, 40 insertions(+), 4 deletions(-)
16
17 --- a/drivers/char/broadcom/vc_mem.c
18 +++ b/drivers/char/broadcom/vc_mem.c
19 @@ -148,7 +148,7 @@ vc_mem_ioctl(struct file *file, unsigned
20 (void) cmd;
21 (void) arg;
22
23 - pr_debug("%s: called file = 0x%p\n", __func__, file);
24 + pr_debug("%s: called file = 0x%p, cmd %08x\n", __func__, file, cmd);
25
26 switch (cmd) {
27 case VC_MEM_IOC_MEM_PHYS_ADDR:
28 @@ -167,7 +167,7 @@ vc_mem_ioctl(struct file *file, unsigned
29 // Get the videocore memory size first
30 vc_mem_get_size();
31
32 - pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%u\n", __func__,
33 + pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%x\n", __func__,
34 mm_vc_mem_size);
35
36 if (copy_to_user((void *) arg, &mm_vc_mem_size,
37 @@ -181,7 +181,7 @@ vc_mem_ioctl(struct file *file, unsigned
38 // Get the videocore memory base
39 vc_mem_get_base();
40
41 - pr_debug("%s: VC_MEM_IOC_MEM_BASE=%u\n", __func__,
42 + pr_debug("%s: VC_MEM_IOC_MEM_BASE=%x\n", __func__,
43 mm_vc_mem_base);
44
45 if (copy_to_user((void *) arg, &mm_vc_mem_base,
46 @@ -195,7 +195,7 @@ vc_mem_ioctl(struct file *file, unsigned
47 // Get the videocore memory base
48 vc_mem_get_base();
49
50 - pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%u\n", __func__,
51 + pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%x\n", __func__,
52 mm_vc_mem_base);
53
54 if (copy_to_user((void *) arg, &mm_vc_mem_base,
55 @@ -214,6 +214,35 @@ vc_mem_ioctl(struct file *file, unsigned
56 return rc;
57 }
58
59 +#ifdef CONFIG_COMPAT
60 +static long
61 +vc_mem_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
62 +{
63 + int rc = 0;
64 +
65 + switch (cmd) {
66 + case VC_MEM_IOC_MEM_PHYS_ADDR32:
67 + pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR32=0x%p\n",
68 + __func__, (void *)mm_vc_mem_phys_addr);
69 +
70 + /* This isn't correct, but will cover us for now as
71 + * VideoCore is 32bit only.
72 + */
73 + if (copy_to_user((void *)arg, &mm_vc_mem_phys_addr,
74 + sizeof(compat_ulong_t)))
75 + rc = -EFAULT;
76 +
77 + break;
78 +
79 + default:
80 + rc = vc_mem_ioctl(file, cmd, arg);
81 + break;
82 + }
83 +
84 + return rc;
85 +}
86 +#endif
87 +
88 /****************************************************************************
89 *
90 * vc_mem_mmap
91 @@ -259,6 +288,9 @@ static const struct file_operations vc_m
92 .open = vc_mem_open,
93 .release = vc_mem_release,
94 .unlocked_ioctl = vc_mem_ioctl,
95 +#ifdef CONFIG_COMPAT
96 + .compat_ioctl = vc_mem_compat_ioctl,
97 +#endif
98 .mmap = vc_mem_mmap,
99 };
100
101 --- a/include/linux/broadcom/vc_mem.h
102 +++ b/include/linux/broadcom/vc_mem.h
103 @@ -32,4 +32,8 @@ extern unsigned int mm_vc_mem_size;
104 extern int vc_mem_get_current_size( void );
105 #endif
106
107 +#ifdef CONFIG_COMPAT
108 +#define VC_MEM_IOC_MEM_PHYS_ADDR32 _IOR(VC_MEM_IOC_MAGIC, 0, compat_ulong_t)
109 +#endif
110 +
111 #endif /* _VC_MEM_H */