diff mbox

[1/2] drm/qxl: change the way slot is detected

Message ID 1445260909-22541-2-git-send-email-fziglio@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Frediano Ziglio Oct. 19, 2015, 1:21 p.m. UTC
Instead of relaying on surface type use the actual placement.
This allow to have different placement for a single type of
surface.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_cmd.c | 2 +-
 drivers/gpu/drm/qxl/qxl_drv.h | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index fdc1833..3a1b055 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -511,7 +511,7 @@  int qxl_hw_surface_alloc(struct qxl_device *qdev,
 	cmd->u.surface_create.height = surf->surf.height;
 	cmd->u.surface_create.stride = surf->surf.stride;
 	if (new_mem) {
-		int slot_id = surf->type == QXL_GEM_DOMAIN_VRAM ? qdev->main_mem_slot : qdev->surfaces_mem_slot;
+		int slot_id = qxl_bo_get_slot_id(qdev, surf);
 		struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]);
 
 		/* TODO - need to hold one of the locks to read tbo.offset */
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 01a8694..60f0062 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -365,11 +365,18 @@  qxl_fb_virtual_address(struct qxl_device *qdev, unsigned long physical)
 	return 0;
 }
 
+static inline int
+qxl_bo_get_slot_id(struct qxl_device *qdev, struct qxl_bo *bo)
+{
+	return ((bo->tbo.cur_placement & TTM_PL_MASK_MEM) == TTM_PL_FLAG_VRAM) ?
+		qdev->main_mem_slot : qdev->surfaces_mem_slot;
+}
+
 static inline uint64_t
 qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo,
 			unsigned long offset)
 {
-	int slot_id = bo->type == QXL_GEM_DOMAIN_VRAM ? qdev->main_mem_slot : qdev->surfaces_mem_slot;
+	int slot_id = qxl_bo_get_slot_id(qdev, bo);
 	struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]);
 
 	/* TODO - need to hold one of the locks to read tbo.offset */