Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/nouveau: allow cursor image and position to survive suspend

- This isn't triggered yet on a normal kernel, because it still does a VT
switch, but it seemed like a good idea to fix this now.

Tested-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

authored by

Maarten Maathuis and committed by
Ben Skeggs
b334f2b3 893887ed

+33
+2
drivers/gpu/drm/nouveau/nouveau_crtc.h
··· 40 40 int sharpness; 41 41 int last_dpms; 42 42 43 + int cursor_saved_x, cursor_saved_y; 44 + 43 45 struct { 44 46 int cpp; 45 47 bool blanked;
+29
drivers/gpu/drm/nouveau/nouveau_drv.c
··· 175 175 nouveau_bo_unpin(nouveau_fb->nvbo); 176 176 } 177 177 178 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 179 + struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 180 + 181 + nouveau_bo_unmap(nv_crtc->cursor.nvbo); 182 + nouveau_bo_unpin(nv_crtc->cursor.nvbo); 183 + } 184 + 178 185 NV_INFO(dev, "Evicting buffers...\n"); 179 186 ttm_bo_evict_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM); 180 187 ··· 321 314 nouveau_bo_pin(nouveau_fb->nvbo, TTM_PL_FLAG_VRAM); 322 315 } 323 316 317 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 318 + struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 319 + int ret; 320 + 321 + ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM); 322 + if (!ret) 323 + ret = nouveau_bo_map(nv_crtc->cursor.nvbo); 324 + if (ret) 325 + NV_ERROR(dev, "Could not pin/map cursor.\n"); 326 + } 327 + 324 328 if (dev_priv->card_type < NV_50) { 325 329 nv04_display_restore(dev); 326 330 NVLockVgaCrtcs(dev, false); 327 331 } else 328 332 nv50_display_init(dev); 333 + 334 + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 335 + struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 336 + 337 + nv_crtc->cursor.set_offset(nv_crtc, 338 + nv_crtc->cursor.nvbo->bo.offset - 339 + dev_priv->vm_vram_base); 340 + 341 + nv_crtc->cursor.set_pos(nv_crtc, nv_crtc->cursor_saved_x, 342 + nv_crtc->cursor_saved_y); 343 + } 329 344 330 345 /* Force CLUT to get re-loaded during modeset */ 331 346 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+1
drivers/gpu/drm/nouveau/nv04_cursor.c
··· 20 20 static void 21 21 nv04_cursor_set_pos(struct nouveau_crtc *nv_crtc, int x, int y) 22 22 { 23 + nv_crtc->cursor_saved_x = x; nv_crtc->cursor_saved_y = y; 23 24 NVWriteRAMDAC(nv_crtc->base.dev, nv_crtc->index, 24 25 NV_PRAMDAC_CU_START_POS, 25 26 XLATE(y, 0, NV_PRAMDAC_CU_START_POS_Y) |
+1
drivers/gpu/drm/nouveau/nv50_cursor.c
··· 107 107 { 108 108 struct drm_device *dev = nv_crtc->base.dev; 109 109 110 + nv_crtc->cursor_saved_x = x; nv_crtc->cursor_saved_y = y; 110 111 nv_wr32(dev, NV50_PDISPLAY_CURSOR_USER_POS(nv_crtc->index), 111 112 ((y & 0xFFFF) << 16) | (x & 0xFFFF)); 112 113 /* Needed to make the cursor move. */