Instead of relaying on surface type use the actual placement.
This allow to have different placement for a single type of
surface.
---
 qxl/qxl_cmd.c | 2 +-
 qxl/qxl_drv.h | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/qxl/qxl_cmd.c b/qxl/qxl_cmd.c
index fdc1833..3a1b055 100644
--- a/qxl/qxl_cmd.c
+++ b/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/qxl/qxl_drv.h b/qxl/qxl_drv.h
index 01a8694..60f0062 100644
--- a/qxl/qxl_drv.h
+++ b/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 */
-- 
2.4.3

Reply via email to