2ad3299595b5f2479ded96dcb94cce35835a4603
[openwrt/staging/jogo.git] /
1 From 71a27bf49d7a64959b7e60d780a1f899ead34f5f Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Mon, 13 May 2019 17:34:29 +0100
4 Subject: [PATCH] Revert "video: bcm2708_fb: Try allocating on the ARM
5 and passing to VPU"
6
7 This reverts commit ca36c709fce57e8023d2b8b354376bf161601a49.
8
9 The driver tries a cma_alloc to avoid using gpu_mem, but should
10 that fail the core code is logging an error with no easy way to
11 test whether it will succeed or fail first.
12
13 Revert until we either totally give up on gpu_mem and increase
14 CMA always, or find a way to try an allocation.
15
16 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
17 ---
18 drivers/video/fbdev/bcm2708_fb.c | 102 +++------------------
19 include/soc/bcm2835/raspberrypi-firmware.h | 1 -
20 2 files changed, 12 insertions(+), 91 deletions(-)
21
22 --- a/drivers/video/fbdev/bcm2708_fb.c
23 +++ b/drivers/video/fbdev/bcm2708_fb.c
24 @@ -98,11 +98,6 @@ struct bcm2708_fb {
25 struct bcm2708_fb_stats stats;
26 unsigned long fb_bus_address;
27 struct { u32 base, length; } gpu;
28 -
29 - bool disable_arm_alloc;
30 - unsigned int image_size;
31 - dma_addr_t dma_addr;
32 - void *cpuaddr;
33 };
34
35 #define to_bcm2708(info) container_of(info, struct bcm2708_fb, fb)
36 @@ -288,88 +283,23 @@ static int bcm2708_fb_set_par(struct fb_
37 .xoffset = info->var.xoffset,
38 .yoffset = info->var.yoffset,
39 .tag5 = { RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE, 8, 0 },
40 - /* base and screen_size will be initialised later */
41 - .tag6 = { RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH, 4, 0 },
42 - /* pitch will be initialised later */
43 + .base = 0,
44 + .screen_size = 0,
45 + .tag6 = { RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH, 4, 0 },
46 + .pitch = 0,
47 };
48 - int ret, image_size;
49 -
50 + int ret;
51
52 print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n", __func__, info,
53 info->var.xres, info->var.yres, info->var.xres_virtual,
54 info->var.yres_virtual, (int)info->screen_size,
55 info->var.bits_per_pixel);
56
57 - /* Try allocating our own buffer. We can specify all the parameters */
58 - image_size = ((info->var.xres * info->var.yres) *
59 - info->var.bits_per_pixel) >> 3;
60 -
61 - if (!fb->disable_arm_alloc &&
62 - (image_size != fb->image_size || !fb->dma_addr)) {
63 - if (fb->dma_addr) {
64 - dma_free_coherent(info->device, fb->image_size,
65 - fb->cpuaddr, fb->dma_addr);
66 - fb->image_size = 0;
67 - fb->cpuaddr = NULL;
68 - fb->dma_addr = 0;
69 - }
70 -
71 - fb->cpuaddr = dma_alloc_coherent(info->device, image_size,
72 - &fb->dma_addr, GFP_KERNEL);
73 -
74 - if (!fb->cpuaddr) {
75 - fb->dma_addr = 0;
76 - fb->disable_arm_alloc = true;
77 - } else {
78 - fb->image_size = image_size;
79 - }
80 - }
81 -
82 - if (fb->cpuaddr) {
83 - fbinfo.base = fb->dma_addr;
84 - fbinfo.screen_size = image_size;
85 - fbinfo.pitch = (info->var.xres * info->var.bits_per_pixel) >> 3;
86 -
87 - ret = rpi_firmware_property_list(fb->fw, &fbinfo,
88 - sizeof(fbinfo));
89 - if (ret || fbinfo.base != fb->dma_addr) {
90 - /* Firmware either failed, or assigned a different base
91 - * address (ie it doesn't support being passed an FB
92 - * allocation).
93 - * Destroy the allocation, and don't try again.
94 - */
95 - dma_free_coherent(info->device, fb->image_size,
96 - fb->cpuaddr, fb->dma_addr);
97 - fb->image_size = 0;
98 - fb->cpuaddr = NULL;
99 - fb->dma_addr = 0;
100 - fb->disable_arm_alloc = true;
101 - }
102 - } else {
103 - /* Our allocation failed - drop into the old scheme of
104 - * allocation by the VPU.
105 - */
106 - ret = -ENOMEM;
107 - }
108 -
109 + ret = rpi_firmware_property_list(fb->fw, &fbinfo, sizeof(fbinfo));
110 if (ret) {
111 - /* Old scheme:
112 - * - FRAMEBUFFER_ALLOCATE passes 0 for base and screen_size.
113 - * - GET_PITCH instead of SET_PITCH.
114 - */
115 - fbinfo.base = 0;
116 - fbinfo.screen_size = 0;
117 - fbinfo.tag6.tag = RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH;
118 - fbinfo.pitch = 0;
119 -
120 - ret = rpi_firmware_property_list(fb->fw, &fbinfo,
121 - sizeof(fbinfo));
122 - if (ret) {
123 - dev_err(info->device,
124 - "Failed to allocate GPU framebuffer (%d)\n",
125 - ret);
126 - return ret;
127 - }
128 + dev_err(info->device,
129 + "Failed to allocate GPU framebuffer (%d)\n", ret);
130 + return ret;
131 }
132
133 if (info->var.bits_per_pixel <= 8)
134 @@ -384,17 +314,9 @@ static int bcm2708_fb_set_par(struct fb_
135 fb->fb.fix.smem_start = fbinfo.base;
136 fb->fb.fix.smem_len = fbinfo.pitch * fbinfo.yres_virtual;
137 fb->fb.screen_size = fbinfo.screen_size;
138 -
139 - if (!fb->dma_addr) {
140 - if (fb->fb.screen_base)
141 - iounmap(fb->fb.screen_base);
142 -
143 - fb->fb.screen_base = ioremap_wc(fbinfo.base,
144 - fb->fb.screen_size);
145 - } else {
146 - fb->fb.screen_base = fb->cpuaddr;
147 - }
148 -
149 + if (fb->fb.screen_base)
150 + iounmap(fb->fb.screen_base);
151 + fb->fb.screen_base = ioremap_wc(fbinfo.base, fb->fb.screen_size);
152 if (!fb->fb.screen_base) {
153 /* the console may currently be locked */
154 console_trylock();
155 --- a/include/soc/bcm2835/raspberrypi-firmware.h
156 +++ b/include/soc/bcm2835/raspberrypi-firmware.h
157 @@ -128,7 +128,6 @@ enum rpi_firmware_property_tag {
158 RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH = 0x00048005,
159 RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER = 0x00048006,
160 RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE = 0x00048007,
161 - RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH = 0x00048008,
162 RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET = 0x00048009,
163 RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN = 0x0004800a,
164 RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE = 0x0004800b,