1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 # T2 SDE: architecture/powerpc64/package/*/0666-ps3fb-vram.patch
5 # Copyright (C) 2021 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
18 Free system memory, bandwidth and simply the code by drawing into the
19 RSX DDR frame-buffer directly. Read-back is very slow, so just don't
20 do that, and use RSX accelerated X anyway ;-)
22 Signed-off-by: Ren<C3><A9> Rebe <rene@exactcode.de>
24 --- linux-5.8/drivers/video/fbdev/ps3fb.c.vanilla 2020-11-07 23:22:58.116092178 +0100
25 +++ linux-5.8/drivers/video/fbdev/ps3fb.c 2020-11-08 11:21:34.232138765 +0100
27 #include <linux/interrupt.h>
28 #include <linux/console.h>
29 #include <linux/ioctl.h>
30 -#include <linux/kthread.h>
31 #include <linux/freezer.h>
32 #include <linux/uaccess.h>
35 atomic_t ext_flip; /* on/off flip with vsync */
36 atomic_t f_count; /* fb_open count */
39 - struct task_struct *task;
41 static struct ps3fb_priv ps3fb;
42 static int ps3fb_gpu_major;
47 -static void ps3fb_sync_image(struct device *dev, u64 frame_offset,
48 - u64 dst_offset, u64 src_offset, u32 width,
49 - u32 height, u32 dst_line_length,
50 - u32 src_line_length)
51 +static void ps3fb_sync_image(struct device *dev, u64 frame_offset)
55 - src_offset += GPU_FB_START;
57 - mutex_lock(&ps3_gpu_mutex);
58 - status = ps3fb_fb_blit(&ps3fb.fifo,
60 - GPU_IOIF + src_offset,
62 - dst_line_length, src_line_length,
63 - L1GPU_FB_BLIT_WAIT_FOR_COMPLETION);
64 - mutex_unlock(&ps3_gpu_mutex);
67 - dev_err(dev, "%s: ps3fb_fb_blit failed: %d\n", __func__,
70 status = lv1_gpu_display_flip(ps3fb.context_handle, 0, frame_offset);
74 u64 ddr_base, xdr_base;
78 if (frame > par->num_frames - 1) {
79 dev_dbg(info->device, "%s: invalid frame number (%u)\n",
85 - xdr_base = frame * par->xdr_frame_size;
86 ddr_base = frame * par->ddr_frame_size;
88 - ps3fb_sync_image(info->device, ddr_base + par->full_offset,
89 - ddr_base + par->fb_offset, xdr_base + par->pan_offset,
90 - par->width, par->height, par->ddr_line_length,
91 - info->fix.line_length);
92 + ps3fb_sync_image(info->device, ddr_base + par->full_offset);
97 par->mode_id = par->new_mode_id;
100 - /* Clear XDR frame buffer memory */
101 memset((void __force *)info->screen_base, 0, info->fix.smem_len);
103 - /* Clear DDR frame buffer memory */
104 - lines = vmode->yres * par->num_frames;
105 - if (par->full_offset)
107 - maxlines = info->fix.smem_len / ddr_line_length;
108 - for (dst = 0; lines; dst += maxlines * ddr_line_length) {
109 - unsigned int l = min(lines, maxlines);
110 - ps3fb_sync_image(info->device, 0, dst, 0, vmode->xres, l,
111 - ddr_line_length, ddr_line_length);
114 + ps3fb_sync_image(info->device, 0);
118 @@ -1275,25 +1242,6 @@
122 -static int ps3fbd(void *arg)
124 - struct fb_info *info = arg;
127 - while (!kthread_should_stop()) {
129 - set_current_state(TASK_INTERRUPTIBLE);
130 - if (ps3fb.is_kicked) {
131 - ps3fb.is_kicked = 0;
133 - ps3fb_sync(info, 0); /* single buffer */
141 static void ps3fb_print_graph_exception_info(struct device *dev,
142 struct gpu_graph_exception_info *info)
144 @@ -1344,11 +1292,6 @@
145 if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) {
147 ps3fb.vblank_count = head->vblank_count;
148 - if (ps3fb.task && !ps3fb.is_blanked &&
149 - !atomic_read(&ps3fb.ext_flip)) {
150 - ps3fb.is_kicked = 1;
151 - wake_up_process(ps3fb.task);
153 wake_up_interruptible(&ps3fb.wait_vsync);
156 @@ -1470,7 +1413,6 @@
157 struct gpu_driver_info *dinfo;
160 - struct task_struct *task;
161 unsigned long max_ps3fb_size;
163 if (ps3fb_videomemory.size < GPU_CMD_BUF_SIZE) {
164 @@ -1659,13 +1601,13 @@
165 * frame buffer at offset GPU_FB_START and save some precious XDR
168 - fb_start = ps3fb_videomemory.address + GPU_FB_START;
169 + fb_start = ioremap_wc(ps3fb.vram_lpar, 16*1024*1024); //ps3fb_videomemory.address + GPU_FB_START;
170 info->screen_base = (char __force __iomem *)fb_start;
171 - info->fix.smem_start = __pa(fb_start);
172 - info->fix.smem_len = ps3fb_videomemory.size - GPU_FB_START;
173 + info->fix.smem_start = ps3fb.vram_lpar; //__pa(fb_start);
174 + info->fix.smem_len = 16*1024*1024; // ps3fb_videomemory.size - GPU_FB_START;
176 info->pseudo_palette = par->pseudo_palette;
177 - info->flags = FBINFO_DEFAULT | FBINFO_READS_FAST |
178 + info->flags = FBINFO_DEFAULT | // FBINFO_READS_FAST |
179 FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN;
181 retval = fb_alloc_cmap(&info->cmap, 256, 0);
182 @@ -1692,14 +1634,6 @@
183 dev_driver_string(info->dev), dev_name(info->dev),
184 info->fix.smem_len >> 10);
186 - task = kthread_run(ps3fbd, info, DEVICE_NAME);
187 - if (IS_ERR(task)) {
188 - retval = PTR_ERR(task);
189 - goto err_unregister_framebuffer;
195 status = register_chrdev(ps3fb_gpu_major, DEVICE_NAME, &ps3fb_gpu_fops);
197 @@ -1756,11 +1690,6 @@
198 atomic_inc(&ps3fb.ext_flip); /* flip off */
199 ps3fb.dinfo->irq.mask = 0;
202 - struct task_struct *task = ps3fb.task;
204 - kthread_stop(task);
207 free_irq(ps3fb.irq_no, &dev->core);
208 ps3_irq_plug_destroy(ps3fb.irq_no);