1 From 0c9e8983c1ab986a833e8b5fbe180f06957529ad 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 491/725] Revert "video: bcm2708_fb: Try allocating on the ARM
7 This reverts commit ca36c709fce57e8023d2b8b354376bf161601a49.
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.
13 Revert until we either totally give up on gpu_mem and increase
14 CMA always, or find a way to try an allocation.
16 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
18 drivers/video/fbdev/bcm2708_fb.c | 102 +++------------------
19 include/soc/bcm2835/raspberrypi-firmware.h | 1 -
20 2 files changed, 12 insertions(+), 91 deletions(-)
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;
29 - bool disable_arm_alloc;
30 - unsigned int image_size;
31 - dma_addr_t dma_addr;
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 */
45 + .tag6 = { RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH, 4, 0 },
48 - int ret, image_size;
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);
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;
61 - if (!fb->disable_arm_alloc &&
62 - (image_size != fb->image_size || !fb->dma_addr)) {
64 - dma_free_coherent(info->device, fb->image_size,
65 - fb->cpuaddr, fb->dma_addr);
71 - fb->cpuaddr = dma_alloc_coherent(info->device, image_size,
72 - &fb->dma_addr, GFP_KERNEL);
76 - fb->disable_arm_alloc = true;
78 - fb->image_size = image_size;
83 - fbinfo.base = fb->dma_addr;
84 - fbinfo.screen_size = image_size;
85 - fbinfo.pitch = (info->var.xres * info->var.bits_per_pixel) >> 3;
87 - ret = rpi_firmware_property_list(fb->fw, &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
93 - * Destroy the allocation, and don't try again.
95 - dma_free_coherent(info->device, fb->image_size,
96 - fb->cpuaddr, fb->dma_addr);
100 - fb->disable_arm_alloc = true;
103 - /* Our allocation failed - drop into the old scheme of
104 - * allocation by the VPU.
109 + ret = rpi_firmware_property_list(fb->fw, &fbinfo, sizeof(fbinfo));
112 - * - FRAMEBUFFER_ALLOCATE passes 0 for base and screen_size.
113 - * - GET_PITCH instead of SET_PITCH.
116 - fbinfo.screen_size = 0;
117 - fbinfo.tag6.tag = RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH;
120 - ret = rpi_firmware_property_list(fb->fw, &fbinfo,
123 - dev_err(info->device,
124 - "Failed to allocate GPU framebuffer (%d)\n",
128 + dev_err(info->device,
129 + "Failed to allocate GPU framebuffer (%d)\n", ret);
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;
139 - if (!fb->dma_addr) {
140 - if (fb->fb.screen_base)
141 - iounmap(fb->fb.screen_base);
143 - fb->fb.screen_base = ioremap_wc(fbinfo.base,
144 - fb->fb.screen_size);
146 - fb->fb.screen_base = fb->cpuaddr;
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 */
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,