diff mbox series

[04/11] drm/ast: Reserve space for double-buffered cursor image

Message ID 20190918142307.27127-5-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/vram: Add VRAM buffers for HW cursors | expand

Commit Message

Thomas Zimmermann Sept. 18, 2019, 2:23 p.m. UTC
With the patch, we reserve 2x 16 KiB at the high end of video memory,
with each frame aligned to an 8-byte boundary. The remaining memory is
available for GEM VRAM buffer objects.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/ast/ast_ttm.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index fad34106083a..8e6a1d8917d0 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -35,13 +35,20 @@ 
 
 int ast_mm_init(struct ast_private *ast)
 {
+	unsigned long cursor_size;
 	struct drm_vram_mm *vmm;
 	int ret;
 	struct drm_device *dev = ast->dev;
 
-	vmm = drm_vram_helper_alloc_mm(
-		dev, pci_resource_start(dev->pdev, 0),
-		ast->vram_size);
+	/* At the high end of video memory, we reserve space for
+	 * two cursor images. The cursor plane uses this memory to
+	 * store a double-buffered image of the current cursor.
+	 */
+	cursor_size = roundup((AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE),
+			      PAGE_SIZE) * AST_DEFAULT_HWC_NUM;
+
+	vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
+				       ast->vram_size - cursor_size);
 	if (IS_ERR(vmm)) {
 		ret = PTR_ERR(vmm);
 		DRM_ERROR("Error initializing VRAM MM; %d\n", ret);