aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/mgag200/mgag200_cursor.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2019-09-27 11:13:00 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2019-10-04 10:01:05 +0200
commit2c51a6601693ffbcef2eb3e47f6c2b8cb3949b86 (patch)
tree71e4b1a2678e0c72a9587a515ab47b69add372f5 /drivers/gpu/drm/mgag200/mgag200_cursor.c
parentdrm/mgag200: Move cursor BO swapping into mgag200_show_cursor() (diff)
downloadlinux-dev-2c51a6601693ffbcef2eb3e47f6c2b8cb3949b86.tar.xz
linux-dev-2c51a6601693ffbcef2eb3e47f6c2b8cb3949b86.zip
drm/mgag200: Reserve video memory for cursor plane
The double-buffered cursor image is currently stored in video memory by creating two BOs and pinning them to VRAM. The exact location is chosen by VRAM helpers. The pinned cursor BOs can conflict with framebuffer BOs and prevent the primary plane from displaying its framebuffer. As a first step to solving this problem, we reserve dedicated space at the high end of the video memory for the cursor images. As the amount of video memory now differs from the amount of available framebuffer memory, size tests are adapted accordingly. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190927091301.10574-7-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/mgag200/mgag200_cursor.c')
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_cursor.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/gpu/drm/mgag200/mgag200_cursor.c b/drivers/gpu/drm/mgag200/mgag200_cursor.c
index ed69b396ac02..318e434f2d40 100644
--- a/drivers/gpu/drm/mgag200/mgag200_cursor.c
+++ b/drivers/gpu/drm/mgag200/mgag200_cursor.c
@@ -215,17 +215,20 @@ static void mgag200_move_cursor(struct mga_device *mdev, int x, int y)
int mgag200_cursor_init(struct mga_device *mdev)
{
struct drm_device *dev = mdev->dev;
+ size_t size;
+
+ size = roundup(64 * 48, PAGE_SIZE);
+ if (size * 2 > mdev->vram_fb_available)
+ return -ENOMEM;
/*
* Make small buffers to store a hardware cursor (double
* buffered icon updates)
*/
mdev->cursor.pixels_1 = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
- roundup(48*64, PAGE_SIZE),
- 0, 0);
+ size, 0, 0);
mdev->cursor.pixels_2 = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
- roundup(48*64, PAGE_SIZE),
- 0, 0);
+ size, 0, 0);
if (IS_ERR(mdev->cursor.pixels_2) || IS_ERR(mdev->cursor.pixels_1)) {
mdev->cursor.pixels_1 = NULL;
mdev->cursor.pixels_2 = NULL;
@@ -234,6 +237,14 @@ int mgag200_cursor_init(struct mga_device *mdev)
}
mdev->cursor.pixels_current = NULL;
+ /*
+ * At the high end of video memory, we reserve space for
+ * buffer objects. The cursor plane uses this memory to store
+ * a double-buffered image of the current cursor. Hence, it's
+ * not available for framebuffers.
+ */
+ mdev->vram_fb_available -= 2 * size;
+
return 0;
}