brcm63xx: rename target to bcm63xx
[openwrt/staging/stintel.git] / target / linux / brcm2708 / patches-4.19 / 950-0593-video-bcm2708_fb-Revert-cma-allocation-attempt.patch
1 From b3fe618a47d770f6c9808ade14360fd81a599789 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 19 Jun 2019 03:55:50 +0100
4 Subject: [PATCH] video/bcm2708_fb: Revert cma allocation attempt
5
6 "4600e91 Pulled in the multi frame buffer support from the Pi3 repo"
7 pulled back in the code for allocating the framebuffer from the CMA
8 heap.
9 Revert it again.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
12 ---
13 drivers/video/fbdev/bcm2708_fb.c | 101 +++------------------
14 include/soc/bcm2835/raspberrypi-firmware.h | 1 -
15 2 files changed, 13 insertions(+), 89 deletions(-)
16
17 --- a/drivers/video/fbdev/bcm2708_fb.c
18 +++ b/drivers/video/fbdev/bcm2708_fb.c
19 @@ -112,9 +112,6 @@ struct bcm2708_fb {
20 struct vc4_display_settings_t display_settings;
21 struct debugfs_regset32 screeninfo_regset;
22 struct bcm2708_fb_dev *fbdev;
23 - unsigned int image_size;
24 - dma_addr_t dma_addr;
25 - void *cpuaddr;
26 };
27
28 #define MAX_FRAMEBUFFERS 3
29 @@ -377,12 +374,12 @@ static int bcm2708_fb_set_par(struct fb_
30 .xoffset = info->var.xoffset,
31 .yoffset = info->var.yoffset,
32 .tag5 = { RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE, 8, 0 },
33 - /* base and screen_size will be initialised later */
34 - .tag6 = { RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH, 4, 0 },
35 - /* pitch will be initialised later */
36 + .base = 0,
37 + .screen_size = 0,
38 + .tag6 = { RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH, 4, 0 },
39 + .pitch = 0,
40 };
41 - int ret, image_size;
42 -
43 + int ret;
44
45 print_debug("%s(%p) %dx%d (%dx%d), %d, %d (display %d)\n", __func__,
46 info,
47 @@ -397,76 +394,12 @@ static int bcm2708_fb_set_par(struct fb_
48 */
49 set_display_num(fb);
50
51 - /* Try allocating our own buffer. We can specify all the parameters */
52 - image_size = ((info->var.xres * info->var.yres) *
53 - info->var.bits_per_pixel) >> 3;
54 -
55 - if (!fb->fbdev->disable_arm_alloc &&
56 - (image_size != fb->image_size || !fb->dma_addr)) {
57 - if (fb->dma_addr) {
58 - dma_free_coherent(info->device, fb->image_size,
59 - fb->cpuaddr, fb->dma_addr);
60 - fb->image_size = 0;
61 - fb->cpuaddr = NULL;
62 - fb->dma_addr = 0;
63 - }
64 -
65 - fb->cpuaddr = dma_alloc_coherent(info->device, image_size,
66 - &fb->dma_addr, GFP_KERNEL);
67 -
68 - if (!fb->cpuaddr) {
69 - fb->dma_addr = 0;
70 - fb->fbdev->disable_arm_alloc = true;
71 - } else {
72 - fb->image_size = image_size;
73 - }
74 - }
75 -
76 - if (fb->cpuaddr) {
77 - fbinfo.base = fb->dma_addr;
78 - fbinfo.screen_size = image_size;
79 - fbinfo.pitch = (info->var.xres * info->var.bits_per_pixel) >> 3;
80 -
81 - ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
82 - sizeof(fbinfo));
83 - if (ret || fbinfo.base != fb->dma_addr) {
84 - /* Firmware either failed, or assigned a different base
85 - * address (ie it doesn't support being passed an FB
86 - * allocation).
87 - * Destroy the allocation, and don't try again.
88 - */
89 - dma_free_coherent(info->device, fb->image_size,
90 - fb->cpuaddr, fb->dma_addr);
91 - fb->image_size = 0;
92 - fb->cpuaddr = NULL;
93 - fb->dma_addr = 0;
94 - fb->fbdev->disable_arm_alloc = true;
95 - }
96 - } else {
97 - /* Our allocation failed - drop into the old scheme of
98 - * allocation by the VPU.
99 - */
100 - ret = -ENOMEM;
101 - }
102 -
103 + ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
104 + sizeof(fbinfo));
105 if (ret) {
106 - /* Old scheme:
107 - * - FRAMEBUFFER_ALLOCATE passes 0 for base and screen_size.
108 - * - GET_PITCH instead of SET_PITCH.
109 - */
110 - fbinfo.base = 0;
111 - fbinfo.screen_size = 0;
112 - fbinfo.tag6.tag = RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH;
113 - fbinfo.pitch = 0;
114 -
115 - ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
116 - sizeof(fbinfo));
117 - if (ret) {
118 - dev_err(info->device,
119 - "Failed to allocate GPU framebuffer (%d)\n",
120 - ret);
121 - return ret;
122 - }
123 + dev_err(info->device,
124 + "Failed to allocate GPU framebuffer (%d)\n", ret);
125 + return ret;
126 }
127
128 if (info->var.bits_per_pixel <= 8)
129 @@ -481,17 +414,9 @@ static int bcm2708_fb_set_par(struct fb_
130 fb->fb.fix.smem_start = fbinfo.base;
131 fb->fb.fix.smem_len = fbinfo.pitch * fbinfo.yres_virtual;
132 fb->fb.screen_size = fbinfo.screen_size;
133 -
134 - if (!fb->dma_addr) {
135 - if (fb->fb.screen_base)
136 - iounmap(fb->fb.screen_base);
137 -
138 - fb->fb.screen_base = ioremap_wc(fbinfo.base,
139 - fb->fb.screen_size);
140 - } else {
141 - fb->fb.screen_base = fb->cpuaddr;
142 - }
143 -
144 + if (fb->fb.screen_base)
145 + iounmap(fb->fb.screen_base);
146 + fb->fb.screen_base = ioremap_wc(fbinfo.base, fb->fb.screen_size);
147 if (!fb->fb.screen_base) {
148 /* the console may currently be locked */
149 console_trylock();
150 --- a/include/soc/bcm2835/raspberrypi-firmware.h
151 +++ b/include/soc/bcm2835/raspberrypi-firmware.h
152 @@ -138,7 +138,6 @@ enum rpi_firmware_property_tag {
153 RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH = 0x00048005,
154 RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER = 0x00048006,
155 RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE = 0x00048007,
156 - RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH = 0x00048008,
157 RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET = 0x00048009,
158 RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN = 0x0004800a,
159 RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE = 0x0004800b,