drm/qxl: ttm fixes, cleanups, allocation tweaks, multihead, fbdev
Subsystems (4)
Gerd Hoffmann
maintainerPATCH v2 1/18 drm/qxl: drop ttm_mem_reg arg from qxl_hw_surface_alloc()
In reply to Gerd HoffmannNot used, is always NULL.
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 +-- drivers/gpu/drm/qxl/qxl_cmd.c | 14 ++------------ drivers/gpu/drm/qxl/qxl_object.c | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -2
@@ -497,8 +497,7 @@ int qxl_surface_id_alloc(struct qxl_device *qdev,void qxl_surface_id_dealloc (struct qxl_device *qdev,uint32_t surface_id);int qxl_hw_surface_alloc (struct qxl_device *qdev, -struct qxl_bo *surf, -struct ttm_mem_reg *mem); +struct qxl_bo *surf);int qxl_hw_surface_dealloc (struct qxl_device *qdev,struct qxl_bo *surf);
drivers/gpu/drm/qxl/qxl_cmd.c +2 -12
@@ -458,8 +458,7 @@ void qxl_surface_id_dealloc(struct qxl_device *qdev, }int qxl_hw_surface_alloc (struct qxl_device *qdev, -struct qxl_bo *surf, -struct ttm_mem_reg *new_mem) +struct qxl_bo *surf) {struct qxl_surface_cmd *cmd;struct qxl_release *release;
@@ -485,16 +484,7 @@ int qxl_hw_surface_alloc(struct qxl_device *qdev, cmd->u.surface_create.width = surf->surf.width; 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; -struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]); - -/* TODO - need to hold one of the locks to read tbo.offset */ - cmd->u.surface_create.data = slot->high_bits; - - cmd->u.surface_create.data |= (new_mem->start <<PAGE_SHIFT ) + surf->tbo.bdev->man[new_mem->mem_type].gpu_offset; - }else - cmd->u.surface_create.data =qxl_bo_physical_address (qdev, surf,0 ); + cmd->u.surface_create.data =qxl_bo_physical_address (qdev, surf,0 ); cmd->surface_id = surf->surface_id;qxl_release_unmap (qdev, release, &cmd->release_info);
drivers/gpu/drm/qxl/qxl_object.c +1 -1
@@ -332,7 +332,7 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo)if (ret)return ret; - ret =qxl_hw_surface_alloc (qdev, bo,NULL ); + ret =qxl_hw_surface_alloc (qdev, bo);if (ret)return ret; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 1/18 drm/qxl: drop ttm_mem_reg arg from qxl_hw_surface_alloc()
In reply to Gerd HoffmannNot used, is always NULL.
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 +-- drivers/gpu/drm/qxl/qxl_cmd.c | 14 ++------------ drivers/gpu/drm/qxl/qxl_object.c | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -2
@@ -497,8 +497,7 @@ int qxl_surface_id_alloc(struct qxl_device *qdev,void qxl_surface_id_dealloc (struct qxl_device *qdev,uint32_t surface_id);int qxl_hw_surface_alloc (struct qxl_device *qdev, -struct qxl_bo *surf, -struct ttm_mem_reg *mem); +struct qxl_bo *surf);int qxl_hw_surface_dealloc (struct qxl_device *qdev,struct qxl_bo *surf);
drivers/gpu/drm/qxl/qxl_cmd.c +2 -12
@@ -458,8 +458,7 @@ void qxl_surface_id_dealloc(struct qxl_device *qdev, }int qxl_hw_surface_alloc (struct qxl_device *qdev, -struct qxl_bo *surf, -struct ttm_mem_reg *new_mem) +struct qxl_bo *surf) {struct qxl_surface_cmd *cmd;struct qxl_release *release;
@@ -485,16 +484,7 @@ int qxl_hw_surface_alloc(struct qxl_device *qdev, cmd->u.surface_create.width = surf->surf.width; 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; -struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]); - -/* TODO - need to hold one of the locks to read tbo.offset */ - cmd->u.surface_create.data = slot->high_bits; - - cmd->u.surface_create.data |= (new_mem->start <<PAGE_SHIFT ) + surf->tbo.bdev->man[new_mem->mem_type].gpu_offset; - }else - cmd->u.surface_create.data =qxl_bo_physical_address (qdev, surf,0 ); + cmd->u.surface_create.data =qxl_bo_physical_address (qdev, surf,0 ); cmd->surface_id = surf->surface_id;qxl_release_unmap (qdev, release, &cmd->release_info);
drivers/gpu/drm/qxl/qxl_object.c +1 -1
@@ -332,7 +332,7 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo)if (ret)return ret; - ret =qxl_hw_surface_alloc (qdev, bo,NULL ); + ret =qxl_hw_surface_alloc (qdev, bo);if (ret)return ret; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 2/18 drm/qxl: drop unused qxl_fb_virtual_address
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_drv.h | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -7
@@ -308,13 +308,6 @@ void qxl_ring_free(struct qxl_ring *ring);void qxl_ring_init_hdr (struct qxl_ring *ring);int qxl_check_idle (struct qxl_ring *ring); -static inline void * -qxl_fb_virtual_address (struct qxl_device *qdev,unsigned long physical) -{ -DRM_DEBUG_DRIVER ("not implemented (%lu)\n" , physical); -return 0 ; -} -static inline uint64_t qxl_bo_physical_address (struct qxl_device *qdev,struct qxl_bo *bo,unsigned long offset)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 2/18 drm/qxl: drop unused qxl_fb_virtual_address
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_drv.h | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -7
@@ -308,13 +308,6 @@ void qxl_ring_free(struct qxl_ring *ring);void qxl_ring_init_hdr (struct qxl_ring *ring);int qxl_check_idle (struct qxl_ring *ring); -static inline void * -qxl_fb_virtual_address (struct qxl_device *qdev,unsigned long physical) -{ -DRM_DEBUG_DRIVER ("not implemented (%lu)\n" , physical); -return 0 ; -} -static inline uint64_t qxl_bo_physical_address (struct qxl_device *qdev,struct qxl_bo *bo,unsigned long offset)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 3/18 drm/qxl: simplify slot management
In reply to Gerd HoffmannDrop pointless indirection, remove the mem_slots array and index variables, drop dynamic allocation. Store memslots in qxl_device instead.
--- drivers/gpu/drm/qxl/qxl_drv.h | 15 +++++---- drivers/gpu/drm/qxl/qxl_kms.c | 72 +++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 51 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +7 -8
@@ -130,9 +130,11 @@ struct qxl_mman { };struct qxl_memslot { +int index; +const char *name;uint8_t generation;uint64_t start_phys_addr; -uint64_t end_phys_addr; +uint64_t size;uint64_t high_bits; };
@@ -228,11 +230,8 @@ struct qxl_device { unsigned int primary_created:1; -struct qxl_memslot *mem_slots; -uint8_t n_mem_slots; - -uint8_t main_mem_slot; -uint8_t surfaces_mem_slot; +struct qxl_memslot main_slot; +struct qxl_memslot surfaces_slot;uint8_t slot_id_bits;uint8_t slot_gen_bits;uint64_t va_slot_mask;
@@ -312,8 +311,8 @@ 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; -struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]); + struct qxl_memslot *slot = bo->type == QXL_GEM_DOMAIN_VRAM + ? &qdev->main_slot : &qdev->surfaces_slot;/* TODO - need to hold one of the locks to read tbo.offset */ return slot->high_bits | (bo->tbo.offset + offset);
drivers/gpu/drm/qxl/qxl_kms.c +29 -43
124 lines not on this page · raw message
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 3/18 drm/qxl: simplify slot management
In reply to Gerd HoffmannDrop pointless indirection, remove the mem_slots array and index variables, drop dynamic allocation. Store memslots in qxl_device instead.
--- drivers/gpu/drm/qxl/qxl_drv.h | 15 +++++---- drivers/gpu/drm/qxl/qxl_kms.c | 72 +++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 51 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +7 -8
@@ -130,9 +130,11 @@ struct qxl_mman { };struct qxl_memslot { +int index; +const char *name;uint8_t generation;uint64_t start_phys_addr; -uint64_t end_phys_addr; +uint64_t size;uint64_t high_bits; };
@@ -228,11 +230,8 @@ struct qxl_device { unsigned int primary_created:1; -struct qxl_memslot *mem_slots; -uint8_t n_mem_slots; - -uint8_t main_mem_slot; -uint8_t surfaces_mem_slot; +struct qxl_memslot main_slot; +struct qxl_memslot surfaces_slot;uint8_t slot_id_bits;uint8_t slot_gen_bits;uint64_t va_slot_mask;
@@ -312,8 +311,8 @@ 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; -struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]); + struct qxl_memslot *slot = bo->type == QXL_GEM_DOMAIN_VRAM + ? &qdev->main_slot : &qdev->surfaces_slot;/* TODO - need to hold one of the locks to read tbo.offset */ return slot->high_bits | (bo->tbo.offset + offset);
drivers/gpu/drm/qxl/qxl_kms.c +29 -43
124 lines not on this page · raw message
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 4/18 drm/qxl: change the way slot is detected
In reply to Gerd HoffmannFrom: Frediano Ziglio <[email protected]>
Instead of relaying on surface type use the actual placement. This allow to have different placement for a single type of surface.
[ kraxel: rebased, adapted to upstream changes ]
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_drv.h +2 -1
@@ -311,7 +311,8 @@ static inline uint64_t qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo, unsigned long offset) { - struct qxl_memslot *slot = bo->type == QXL_GEM_DOMAIN_VRAM + struct qxl_memslot *slot = + (bo->tbo.mem.mem_type ==TTM_PL_VRAM ) ? &qdev->main_slot : &qdev->surfaces_slot;/* TODO - need to hold one of the locks to read tbo.offset */
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 4/18 drm/qxl: change the way slot is detected
In reply to Gerd HoffmannFrom: Frediano Ziglio <[email protected]>
Instead of relaying on surface type use the actual placement. This allow to have different placement for a single type of surface.
[ kraxel: rebased, adapted to upstream changes ]
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_drv.h +2 -1
@@ -311,7 +311,8 @@ static inline uint64_t qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo, unsigned long offset) { - struct qxl_memslot *slot = bo->type == QXL_GEM_DOMAIN_VRAM + struct qxl_memslot *slot = + (bo->tbo.mem.mem_type ==TTM_PL_VRAM ) ? &qdev->main_slot : &qdev->surfaces_slot;/* TODO - need to hold one of the locks to read tbo.offset */
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 5/18 drm/qxl: drop unused fields from struct qxl_device
In reply to Gerd Hoffmannslot_id_bits and slot_gen_bits can be read directly from qxlrom instead. va_slot_mask is never used anywhere.
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 --- drivers/gpu/drm/qxl/qxl_kms.c | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -3
@@ -232,9 +232,6 @@ struct qxl_device {struct qxl_memslot main_slot;struct qxl_memslot surfaces_slot; -uint8_t slot_id_bits; -uint8_t slot_gen_bits; -uint64_t va_slot_mask;spinlock_t release_lock;struct idr release_idr;
drivers/gpu/drm/qxl/qxl_kms.c +2 -8
@@ -78,9 +78,9 @@ static void setup_slot(struct qxl_device *qdev, slot->generation = qdev->rom->slot_generation; high_bits = (qdev->rom->slots_start + slot->index) - << qdev->slot_gen_bits; + << qdev->rom->slot_gen_bits; high_bits |= slot->generation; - high_bits <<= (64 - (qdev->slot_gen_bits + qdev->slot_id_bits)); + high_bits <<= (64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits)); slot->high_bits = high_bits; DRM_INFO("slot %d (%s): base 0x%08lx, size 0x%08lx\n",
@@ -235,12 +235,6 @@ int qxl_device_init(struct qxl_device *qdev, r = -ENOMEM ; goto cursor_ring_free; } -/* TODO - slot initialization should happen on reset. where is our -* reset handler? */ - qdev->slot_gen_bits = qdev->rom->slot_gen_bits; - qdev->slot_id_bits = qdev->rom->slot_id_bits; - qdev->va_slot_mask = - (~(uint64_t )0 ) >> (qdev->slot_id_bits + qdev->slot_gen_bits);idr_init (&qdev->release_idr);spin_lock_init (&qdev->release_idr_lock);
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v2 5/18 drm/qxl: drop unused fields from struct qxl_device
In reply to Gerd Hoffmannslot_id_bits and slot_gen_bits can be read directly from qxlrom instead. va_slot_mask is never used anywhere.
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 --- drivers/gpu/drm/qxl/qxl_kms.c | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -3
@@ -232,9 +232,6 @@ struct qxl_device {struct qxl_memslot main_slot;struct qxl_memslot surfaces_slot; -uint8_t slot_id_bits; -uint8_t slot_gen_bits; -uint64_t va_slot_mask;spinlock_t release_lock;struct idr release_idr;
drivers/gpu/drm/qxl/qxl_kms.c +2 -8
@@ -78,9 +78,9 @@ static void setup_slot(struct qxl_device *qdev, slot->generation = qdev->rom->slot_generation; high_bits = (qdev->rom->slots_start + slot->index) - << qdev->slot_gen_bits; + << qdev->rom->slot_gen_bits; high_bits |= slot->generation; - high_bits <<= (64 - (qdev->slot_gen_bits + qdev->slot_id_bits)); + high_bits <<= (64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits)); slot->high_bits = high_bits; DRM_INFO("slot %d (%s): base 0x%08lx, size 0x%08lx\n",
@@ -235,12 +235,6 @@ int qxl_device_init(struct qxl_device *qdev, r = -ENOMEM ; goto cursor_ring_free; } -/* TODO - slot initialization should happen on reset. where is our -* reset handler? */ - qdev->slot_gen_bits = qdev->rom->slot_gen_bits; - qdev->slot_id_bits = qdev->rom->slot_id_bits; - qdev->va_slot_mask = - (~(uint64_t )0 ) >> (qdev->slot_id_bits + qdev->slot_gen_bits);idr_init (&qdev->release_idr);spin_lock_init (&qdev->release_idr_lock);
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 6/18 drm/qxl: use separate offset spaces for the two slots / ttm memory types.
In reply to Gerd HoffmannWithout that ttm offsets are not unique, they can refer to objects in both VRAM and PRIV memory (aka main and surfaces slot).
One of those "why things didn't blow up without this" moments. Probably offset conflicts are rare enough by pure luck.
--- drivers/gpu/drm/qxl/qxl_drv.h | 5 ++++- drivers/gpu/drm/qxl/qxl_kms.c | 5 +++-- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +++++++++- 3 files changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +4 -1
@@ -136,6 +136,7 @@ struct qxl_memslot {uint64_t start_phys_addr;uint64_t size;uint64_t high_bits; +uint64_t gpu_offset; };enum {
@@ -312,8 +313,10 @@ qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo, (bo->tbo.mem.mem_type ==TTM_PL_VRAM ) ? &qdev->main_slot : &qdev->surfaces_slot; +WARN_ON_ONCE ((bo->tbo.offset & slot->gpu_offset) != slot->gpu_offset); +/* TODO - need to hold one of the locks to read tbo.offset */ -return slot->high_bits | (bo->tbo.offset + offset); +return slot->high_bits | (bo->tbo.offset - slot->gpu_offset + offset); }/* qxl_fb.c */
drivers/gpu/drm/qxl/qxl_kms.c +3 -2
@@ -83,10 +83,11 @@ static void setup_slot(struct qxl_device *qdev, high_bits <<= (64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits)); slot->high_bits = high_bits; -DRM_INFO ("slot %d (%s): base 0x%08lx, size 0x%08lx\n" , +DRM_INFO ("slot %d (%s): base 0x%08lx, size 0x%08lx, gpu_offset 0x%lx\n" , slot->index, slot->name, (unsigned long )slot->start_phys_addr, - (unsigned long )slot->size); + (unsigned long )slot->size, + (unsigned long )slot->gpu_offset); }void qxl_reinit_memslots (struct qxl_device *qdev)
drivers/gpu/drm/qxl/qxl_ttm.c +9 -1
@@ -100,6 +100,11 @@ static int qxl_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)static int qxl_init_mem_type (struct ttm_bo_device *bdev,uint32_t type,struct ttm_mem_type_manager *man) { +struct qxl_device *qdev =qxl_get_qdev (bdev); +unsigned int gpu_offset_shift = +64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits +8 ); +struct qxl_memslot *slot; +switch (type) {case TTM_PL_SYSTEM :/* System memory */
@@ -110,8 +115,11 @@ static int qxl_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :case TTM_PL_PRIV :/* "On-card" video ram */ + slot = (type ==TTM_PL_VRAM ) ? + &qdev->main_slot : &qdev->surfaces_slot; + slot->gpu_offset = (uint64_t )type << gpu_offset_shift; man->func = &ttm_bo_manager_func; - man->gpu_offset =0 ; + man->gpu_offset = slot->gpu_offset; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_MASK_CACHING ;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 6/18 drm/qxl: use separate offset spaces for the two slots / ttm memory types.
In reply to Gerd HoffmannWithout that ttm offsets are not unique, they can refer to objects in both VRAM and PRIV memory (aka main and surfaces slot).
One of those "why things didn't blow up without this" moments. Probably offset conflicts are rare enough by pure luck.
--- drivers/gpu/drm/qxl/qxl_drv.h | 5 ++++- drivers/gpu/drm/qxl/qxl_kms.c | 5 +++-- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +++++++++- 3 files changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +4 -1
@@ -136,6 +136,7 @@ struct qxl_memslot {uint64_t start_phys_addr;uint64_t size;uint64_t high_bits; +uint64_t gpu_offset; };enum {
@@ -312,8 +313,10 @@ qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo, (bo->tbo.mem.mem_type ==TTM_PL_VRAM ) ? &qdev->main_slot : &qdev->surfaces_slot; +WARN_ON_ONCE ((bo->tbo.offset & slot->gpu_offset) != slot->gpu_offset); +/* TODO - need to hold one of the locks to read tbo.offset */ -return slot->high_bits | (bo->tbo.offset + offset); +return slot->high_bits | (bo->tbo.offset - slot->gpu_offset + offset); }/* qxl_fb.c */
drivers/gpu/drm/qxl/qxl_kms.c +3 -2
@@ -83,10 +83,11 @@ static void setup_slot(struct qxl_device *qdev, high_bits <<= (64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits)); slot->high_bits = high_bits; -DRM_INFO ("slot %d (%s): base 0x%08lx, size 0x%08lx\n" , +DRM_INFO ("slot %d (%s): base 0x%08lx, size 0x%08lx, gpu_offset 0x%lx\n" , slot->index, slot->name, (unsigned long )slot->start_phys_addr, - (unsigned long )slot->size); + (unsigned long )slot->size, + (unsigned long )slot->gpu_offset); }void qxl_reinit_memslots (struct qxl_device *qdev)
drivers/gpu/drm/qxl/qxl_ttm.c +9 -1
@@ -100,6 +100,11 @@ static int qxl_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)static int qxl_init_mem_type (struct ttm_bo_device *bdev,uint32_t type,struct ttm_mem_type_manager *man) { +struct qxl_device *qdev =qxl_get_qdev (bdev); +unsigned int gpu_offset_shift = +64 - (qdev->rom->slot_gen_bits + qdev->rom->slot_id_bits +8 ); +struct qxl_memslot *slot; +switch (type) {case TTM_PL_SYSTEM :/* System memory */
@@ -110,8 +115,11 @@ static int qxl_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :case TTM_PL_PRIV :/* "On-card" video ram */ + slot = (type ==TTM_PL_VRAM ) ? + &qdev->main_slot : &qdev->surfaces_slot; + slot->gpu_offset = (uint64_t )type << gpu_offset_shift; man->func = &ttm_bo_manager_func; - man->gpu_offset =0 ; + man->gpu_offset = slot->gpu_offset; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_MASK_CACHING ;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 7/18 drm/qxl: allow both PRIV and VRAM placement for QXL_GEM_DOMAIN_SURFACE
In reply to Gerd Hoffmannqxl surfaces (used for framebuffers and gem objects) can live in both VRAM and PRIV ttm domains. Update placement setup to include both. Put PRIV first in the list so it is preferred, so VRAM will have more room for objects which must be allocated there.
--- drivers/gpu/drm/qxl/qxl_object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_object.c +3 -1
@@ -60,8 +60,10 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned) qbo->placement.busy_placement = qbo->placements;if (domain ==QXL_GEM_DOMAIN_VRAM ) qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; -if (domain ==QXL_GEM_DOMAIN_SURFACE ) +if (domain ==QXL_GEM_DOMAIN_SURFACE ) { qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_PRIV | pflag; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; + }if (domain ==QXL_GEM_DOMAIN_CPU ) qbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM | pflag;if (!c)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v2 7/18 drm/qxl: allow both PRIV and VRAM placement for QXL_GEM_DOMAIN_SURFACE
In reply to Gerd Hoffmannqxl surfaces (used for framebuffers and gem objects) can live in both VRAM and PRIV ttm domains. Update placement setup to include both. Put PRIV first in the list so it is preferred, so VRAM will have more room for objects which must be allocated there.
--- drivers/gpu/drm/qxl/qxl_object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_object.c +3 -1
@@ -60,8 +60,10 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned) qbo->placement.busy_placement = qbo->placements;if (domain ==QXL_GEM_DOMAIN_VRAM ) qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; -if (domain ==QXL_GEM_DOMAIN_SURFACE ) +if (domain ==QXL_GEM_DOMAIN_SURFACE ) { qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_PRIV | pflag; + qbo->placements[c++].flags =TTM_PL_FLAG_CACHED |TTM_PL_FLAG_VRAM | pflag; + }if (domain ==QXL_GEM_DOMAIN_CPU ) qbo->placements[c++].flags =TTM_PL_MASK_CACHING |TTM_PL_FLAG_SYSTEM | pflag;if (!c)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 8/18 drm/qxl: use QXL_GEM_DOMAIN_SURFACE for shadow bo.
In reply to Gerd HoffmannThe shadow bo is used as qxl surface, so allocate it as QXL_GEM_DOMAIN_SURFACE. Should usually be allocated in PRIV ttm domain then, so this reduces VRAM memory pressure.
--- drivers/gpu/drm/qxl/qxl_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_display.c +1 -1
@@ -758,7 +758,7 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane, user_bo->shadow = old_bo->shadow; }else {qxl_bo_create (qdev, user_bo->gem_base.size, - true, true,QXL_GEM_DOMAIN_VRAM ,NULL , + true, true,QXL_GEM_DOMAIN_SURFACE ,NULL , &user_bo->shadow); } }
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v2 8/18 drm/qxl: use QXL_GEM_DOMAIN_SURFACE for shadow bo.
In reply to Gerd HoffmannThe shadow bo is used as qxl surface, so allocate it as QXL_GEM_DOMAIN_SURFACE. Should usually be allocated in PRIV ttm domain then, so this reduces VRAM memory pressure.
--- drivers/gpu/drm/qxl/qxl_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_display.c +1 -1
@@ -758,7 +758,7 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane, user_bo->shadow = old_bo->shadow; }else {qxl_bo_create (qdev, user_bo->gem_base.size, - true, true,QXL_GEM_DOMAIN_VRAM ,NULL , + true, true,QXL_GEM_DOMAIN_SURFACE ,NULL , &user_bo->shadow); } }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 9/18 drm/qxl: use QXL_GEM_DOMAIN_SURFACE for dumb gem objects
In reply to Gerd Hoffmanndumb buffers are used as qxl surfaces, so allocate them as QXL_GEM_DOMAIN_SURFACE. Should usually be allocated in PRIV ttm domain then, so this reduces VRAM memory pressure.
--- drivers/gpu/drm/qxl/qxl_dumb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_dumb.c +1 -1
@@ -59,7 +59,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv, surf.stride = pitch; surf.format = format; r =qxl_gem_object_create_with_handle (qdev, file_priv, -QXL_GEM_DOMAIN_VRAM , +QXL_GEM_DOMAIN_SURFACE , args->size, &surf, &qobj, &handle);if (r)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v2 9/18 drm/qxl: use QXL_GEM_DOMAIN_SURFACE for dumb gem objects
In reply to Gerd Hoffmanndumb buffers are used as qxl surfaces, so allocate them as QXL_GEM_DOMAIN_SURFACE. Should usually be allocated in PRIV ttm domain then, so this reduces VRAM memory pressure.
--- drivers/gpu/drm/qxl/qxl_dumb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_dumb.c +1 -1
@@ -59,7 +59,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv, surf.stride = pitch; surf.format = format; r =qxl_gem_object_create_with_handle (qdev, file_priv, -QXL_GEM_DOMAIN_VRAM , +QXL_GEM_DOMAIN_SURFACE , args->size, &surf, &qobj, &handle);if (r)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 10/18 drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Gerd HoffmannThe cursor must be set again after creating the primary surface. Also drop the error message.
--- drivers/gpu/drm/qxl/qxl_display.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +3 -7
@@ -533,7 +533,6 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, .x2 = plane->state->fb->width, .y2 = plane->state->fb->height }; -int ret;bool same_shadow = false;if (old_state->fb) {
@@ -554,16 +553,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,if (!same_shadow)qxl_io_destroy_primary (qdev); bo_old->is_primary = false; - - ret =qxl_primary_apply_cursor (plane); -if (ret) -DRM_ERROR ( -"could not set cursor after creating primary" ); }if (!bo->is_primary) { -if (!same_shadow) +if (!same_shadow) {qxl_io_create_primary (qdev,0 , bo); +qxl_primary_apply_cursor (plane); + } bo->is_primary = true; }
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v2 10/18 drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Gerd HoffmannThe cursor must be set again after creating the primary surface. Also drop the error message.
--- drivers/gpu/drm/qxl/qxl_display.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +3 -7
@@ -533,7 +533,6 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, .x2 = plane->state->fb->width, .y2 = plane->state->fb->height }; -int ret;bool same_shadow = false;if (old_state->fb) {
@@ -554,16 +553,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,if (!same_shadow)qxl_io_destroy_primary (qdev); bo_old->is_primary = false; - - ret =qxl_primary_apply_cursor (plane); -if (ret) -DRM_ERROR ( -"could not set cursor after creating primary" ); }if (!bo->is_primary) { -if (!same_shadow) +if (!same_shadow) {qxl_io_create_primary (qdev,0 , bo); +qxl_primary_apply_cursor (plane); + } bo->is_primary = true; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 11/18 drm/qxl: drop unused offset parameter from qxl_io_create_primary()
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_drv.h | 1 - drivers/gpu/drm/qxl/qxl_cmd.c | 7 +++---- drivers/gpu/drm/qxl/qxl_display.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -1
@@ -385,7 +385,6 @@ void qxl_update_screen(struct qxl_device *qxl);/* qxl io operations (qxl_cmd.c) */ void qxl_io_create_primary (struct qxl_device *qdev, -unsigned int offset,struct qxl_bo *bo);void qxl_io_destroy_primary (struct qxl_device *qdev);void qxl_io_memslot_add (struct qxl_device *qdev,uint8_t id);
drivers/gpu/drm/qxl/qxl_cmd.c +3 -4
@@ -375,8 +375,7 @@ void qxl_io_destroy_primary(struct qxl_device *qdev) qdev->primary_created = false; } -void qxl_io_create_primary (struct qxl_device *qdev, -unsigned int offset,struct qxl_bo *bo) +void qxl_io_create_primary (struct qxl_device *qdev,struct qxl_bo *bo) {struct qxl_surface_create *create;
@@ -387,9 +386,9 @@ void qxl_io_create_primary(struct qxl_device *qdev, create->height = bo->surf.height; create->stride = bo->surf.stride;if (bo->shadow) { - create->mem =qxl_bo_physical_address (qdev, bo->shadow, offset); + create->mem =qxl_bo_physical_address (qdev, bo->shadow,0 ); }else { - create->mem =qxl_bo_physical_address (qdev, bo, offset); + create->mem =qxl_bo_physical_address (qdev, bo,0 ); }DRM_DEBUG_DRIVER ("mem = %llx, from %p\n" , create->mem, bo->kptr);
drivers/gpu/drm/qxl/qxl_display.c +1 -1
@@ -557,7 +557,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,if (!bo->is_primary) {if (!same_shadow) { -qxl_io_create_primary (qdev,0 , bo); +qxl_io_create_primary (qdev, bo);qxl_primary_apply_cursor (plane); } bo->is_primary = true;
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v2 11/18 drm/qxl: drop unused offset parameter from qxl_io_create_primary()
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_drv.h | 1 - drivers/gpu/drm/qxl/qxl_cmd.c | 7 +++---- drivers/gpu/drm/qxl/qxl_display.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -1
@@ -385,7 +385,6 @@ void qxl_update_screen(struct qxl_device *qxl);/* qxl io operations (qxl_cmd.c) */ void qxl_io_create_primary (struct qxl_device *qdev, -unsigned int offset,struct qxl_bo *bo);void qxl_io_destroy_primary (struct qxl_device *qdev);void qxl_io_memslot_add (struct qxl_device *qdev,uint8_t id);
drivers/gpu/drm/qxl/qxl_cmd.c +3 -4
@@ -375,8 +375,7 @@ void qxl_io_destroy_primary(struct qxl_device *qdev) qdev->primary_created = false; } -void qxl_io_create_primary (struct qxl_device *qdev, -unsigned int offset,struct qxl_bo *bo) +void qxl_io_create_primary (struct qxl_device *qdev,struct qxl_bo *bo) {struct qxl_surface_create *create;
@@ -387,9 +386,9 @@ void qxl_io_create_primary(struct qxl_device *qdev, create->height = bo->surf.height; create->stride = bo->surf.stride;if (bo->shadow) { - create->mem =qxl_bo_physical_address (qdev, bo->shadow, offset); + create->mem =qxl_bo_physical_address (qdev, bo->shadow,0 ); }else { - create->mem =qxl_bo_physical_address (qdev, bo, offset); + create->mem =qxl_bo_physical_address (qdev, bo,0 ); }DRM_DEBUG_DRIVER ("mem = %llx, from %p\n" , create->mem, bo->kptr);
drivers/gpu/drm/qxl/qxl_display.c +1 -1
@@ -557,7 +557,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,if (!bo->is_primary) {if (!same_shadow) { -qxl_io_create_primary (qdev,0 , bo); +qxl_io_create_primary (qdev, bo);qxl_primary_apply_cursor (plane); } bo->is_primary = true;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 12/18 drm/qxl: track primary bo
In reply to Gerd HoffmannTrack which bo is used as primary surface. With that in place we don't need the primary_created flag any more, we can just check the primary bo pointer instead.
Also verify we don't already have a primary surface in qxl_io_create_primary().
--- drivers/gpu/drm/qxl/qxl_drv.h | 2 +- drivers/gpu/drm/qxl/qxl_cmd.c | 7 +++++-- drivers/gpu/drm/qxl/qxl_display.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -1
@@ -229,7 +229,7 @@ struct qxl_device {struct qxl_ram_header *ram_header; - unsigned int primary_created:1; +struct qxl_bo *primary_bo;struct qxl_memslot main_slot;struct qxl_memslot surfaces_slot;
drivers/gpu/drm/qxl/qxl_cmd.c +5 -2
@@ -372,13 +372,16 @@ void qxl_io_flush_surfaces(struct qxl_device *qdev)void qxl_io_destroy_primary (struct qxl_device *qdev) {wait_for_io_cmd (qdev,0 ,QXL_IO_DESTROY_PRIMARY_ASYNC ); - qdev->primary_created = false; + qdev->primary_bo =NULL ; }void qxl_io_create_primary (struct qxl_device *qdev,struct qxl_bo *bo) {struct qxl_surface_create *create; +if (WARN_ON (qdev->primary_bo)) +return ; +DRM_DEBUG_DRIVER ("qdev %p, ram_header %p\n" , qdev, qdev->ram_header); create = &qdev->ram_header->create_surface; create->format = bo->surf.format;
@@ -397,7 +400,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo) create->type =QXL_SURF_TYPE_PRIMARY ;wait_for_io_cmd (qdev,0 ,QXL_IO_CREATE_PRIMARY_ASYNC ); - qdev->primary_created = true; + qdev->primary_bo = bo; }void qxl_io_memslot_add (struct qxl_device *qdev,uint8_t id)
drivers/gpu/drm/qxl/qxl_display.c +1 -1
@@ -302,7 +302,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,struct qxl_head head;int oldcount, i = qcrtc->index; -if (!qdev->primary_created) { +if (!qdev->primary_bo) {DRM_DEBUG_KMS ("no primary surface, skip (%s)\n" , reason);return ; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 12/18 drm/qxl: track primary bo
In reply to Gerd HoffmannTrack which bo is used as primary surface. With that in place we don't need the primary_created flag any more, we can just check the primary bo pointer instead.
Also verify we don't already have a primary surface in qxl_io_create_primary().
--- drivers/gpu/drm/qxl/qxl_drv.h | 2 +- drivers/gpu/drm/qxl/qxl_cmd.c | 7 +++++-- drivers/gpu/drm/qxl/qxl_display.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -1
@@ -229,7 +229,7 @@ struct qxl_device {struct qxl_ram_header *ram_header; - unsigned int primary_created:1; +struct qxl_bo *primary_bo;struct qxl_memslot main_slot;struct qxl_memslot surfaces_slot;
drivers/gpu/drm/qxl/qxl_cmd.c +5 -2
@@ -372,13 +372,16 @@ void qxl_io_flush_surfaces(struct qxl_device *qdev)void qxl_io_destroy_primary (struct qxl_device *qdev) {wait_for_io_cmd (qdev,0 ,QXL_IO_DESTROY_PRIMARY_ASYNC ); - qdev->primary_created = false; + qdev->primary_bo =NULL ; }void qxl_io_create_primary (struct qxl_device *qdev,struct qxl_bo *bo) {struct qxl_surface_create *create; +if (WARN_ON (qdev->primary_bo)) +return ; +DRM_DEBUG_DRIVER ("qdev %p, ram_header %p\n" , qdev, qdev->ram_header); create = &qdev->ram_header->create_surface; create->format = bo->surf.format;
@@ -397,7 +400,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo) create->type =QXL_SURF_TYPE_PRIMARY ;wait_for_io_cmd (qdev,0 ,QXL_IO_CREATE_PRIMARY_ASYNC ); - qdev->primary_created = true; + qdev->primary_bo = bo; }void qxl_io_memslot_add (struct qxl_device *qdev,uint8_t id)
drivers/gpu/drm/qxl/qxl_display.c +1 -1
@@ -302,7 +302,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,struct qxl_head head;int oldcount, i = qcrtc->index; -if (!qdev->primary_created) { +if (!qdev->primary_bo) {DRM_DEBUG_KMS ("no primary surface, skip (%s)\n" , reason);return ; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 13/18 drm/qxl: use shadow bo directly
In reply to Gerd HoffmannPass the shadow bo to qxl_io_create_primary() instead of expecting qxl_io_create_primary to check bo->shadow. Set is_primary flag on the shadow bo. Move the is_primary tracking into qxl_io_create_primary() and qxl_io_destroy_primary() functions.
That simplifies primary surface tracking and the workflow in qxl_primary_atomic_update().
--- drivers/gpu/drm/qxl/qxl_cmd.c | 8 +++----- drivers/gpu/drm/qxl/qxl_display.c | 33 +++++++++++---------------------- 2 files changed, 14 insertions(+), 27 deletions(-)
drivers/gpu/drm/qxl/qxl_cmd.c +3 -5
@@ -372,6 +372,7 @@ void qxl_io_flush_surfaces(struct qxl_device *qdev)void qxl_io_destroy_primary (struct qxl_device *qdev) {wait_for_io_cmd (qdev,0 ,QXL_IO_DESTROY_PRIMARY_ASYNC ); + qdev->primary_bo->is_primary = false; qdev->primary_bo =NULL ; }
@@ -388,11 +389,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo) create->width = bo->surf.width; create->height = bo->surf.height; create->stride = bo->surf.stride; -if (bo->shadow) { - create->mem =qxl_bo_physical_address (qdev, bo->shadow,0 ); - }else { - create->mem =qxl_bo_physical_address (qdev, bo,0 ); - } + create->mem =qxl_bo_physical_address (qdev, bo,0 );DRM_DEBUG_DRIVER ("mem = %llx, from %p\n" , create->mem, bo->kptr);
@@ -401,6 +398,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo)wait_for_io_cmd (qdev,0 ,QXL_IO_CREATE_PRIMARY_ASYNC ); qdev->primary_bo = bo; + qdev->primary_bo->is_primary = true; }void qxl_io_memslot_add (struct qxl_device *qdev,uint8_t id)
drivers/gpu/drm/qxl/qxl_display.c +11 -22
@@ -401,13 +401,15 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,struct qxl_device *qdev = fb->dev->dev_private;struct drm_clip_rect norect;struct qxl_bo *qobj; +bool is_primary;int inc =1 ;drm_modeset_lock_all (fb->dev); qobj =gem_to_qxl_bo (fb->obj[0 ]);/* if we aren't primary surface ignore this */ -if (!qobj->is_primary) { + is_primary = qobj->shadow ? qobj->shadow->is_primary : qobj->is_primary; +if (!is_primary) {drm_modeset_unlock_all (fb->dev);return 0 ; }
@@ -526,14 +528,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, {struct qxl_device *qdev = plane->dev->dev_private;struct qxl_bo *bo =gem_to_qxl_bo (plane->state->fb->obj[0 ]); -struct qxl_bo *bo_old; +struct qxl_bo *bo_old, *primary;struct drm_clip_rect norect = { .x1 =0 , .y1 =0 , .x2 = plane->state->fb->width, .y2 = plane->state->fb->height }; -bool same_shadow = false;if (old_state->fb) { bo_old =gem_to_qxl_bo (old_state->fb->obj[0 ]);
@@ -541,26 +542,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, bo_old =NULL ; } -if (bo == bo_old) -return ; + primary = bo->shadow ? bo->shadow : bo; -if (bo_old && bo_old->shadow && bo->shadow && - bo_old->shadow == bo->shadow) { - same_shadow = true; - } - -if (bo_old && bo_old->is_primary) { -if (!same_shadow) +if (!primary->is_primary) { +if (qdev->primary_bo)qxl_io_destroy_primary (qdev); - bo_old->is_primary = false; - } - -if (!bo->is_primary) { -if (!same_shadow) { -qxl_io_create_primary (qdev, bo); -qxl_primary_apply_cursor (plane); - } - bo->is_primary = true; +qxl_io_create_primary (qdev, primary); +qxl_primary_apply_cursor (plane); }qxl_draw_dirty_fb (qdev, plane->state->fb, bo,0 ,0 , &norect,1 ,1 );
@@ -756,6 +744,7 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane,qxl_bo_create (qdev, user_bo->gem_base.size, true, true,QXL_GEM_DOMAIN_SURFACE ,NULL , &user_bo->shadow); + user_bo->shadow->surf = user_bo->surf; } }
@@ -784,7 +773,7 @@ static void qxl_plane_cleanup_fb(struct drm_plane *plane, user_bo =gem_to_qxl_bo (obj);qxl_bo_unpin (user_bo); -if (user_bo->shadow && !user_bo->is_primary) { +if (user_bo->shadow && !user_bo->shadow->is_primary) {drm_gem_object_put_unlocked (&user_bo->shadow->gem_base); user_bo->shadow =NULL ; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 13/18 drm/qxl: use shadow bo directly
In reply to Gerd HoffmannPass the shadow bo to qxl_io_create_primary() instead of expecting qxl_io_create_primary to check bo->shadow. Set is_primary flag on the shadow bo. Move the is_primary tracking into qxl_io_create_primary() and qxl_io_destroy_primary() functions.
That simplifies primary surface tracking and the workflow in qxl_primary_atomic_update().
--- drivers/gpu/drm/qxl/qxl_cmd.c | 8 +++----- drivers/gpu/drm/qxl/qxl_display.c | 33 +++++++++++---------------------- 2 files changed, 14 insertions(+), 27 deletions(-)
drivers/gpu/drm/qxl/qxl_cmd.c +3 -5
@@ -372,6 +372,7 @@ void qxl_io_flush_surfaces(struct qxl_device *qdev)void qxl_io_destroy_primary (struct qxl_device *qdev) {wait_for_io_cmd (qdev,0 ,QXL_IO_DESTROY_PRIMARY_ASYNC ); + qdev->primary_bo->is_primary = false; qdev->primary_bo =NULL ; }
@@ -388,11 +389,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo) create->width = bo->surf.width; create->height = bo->surf.height; create->stride = bo->surf.stride; -if (bo->shadow) { - create->mem =qxl_bo_physical_address (qdev, bo->shadow,0 ); - }else { - create->mem =qxl_bo_physical_address (qdev, bo,0 ); - } + create->mem =qxl_bo_physical_address (qdev, bo,0 );DRM_DEBUG_DRIVER ("mem = %llx, from %p\n" , create->mem, bo->kptr);
@@ -401,6 +398,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo)wait_for_io_cmd (qdev,0 ,QXL_IO_CREATE_PRIMARY_ASYNC ); qdev->primary_bo = bo; + qdev->primary_bo->is_primary = true; }void qxl_io_memslot_add (struct qxl_device *qdev,uint8_t id)
drivers/gpu/drm/qxl/qxl_display.c +11 -22
@@ -401,13 +401,15 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,struct qxl_device *qdev = fb->dev->dev_private;struct drm_clip_rect norect;struct qxl_bo *qobj; +bool is_primary;int inc =1 ;drm_modeset_lock_all (fb->dev); qobj =gem_to_qxl_bo (fb->obj[0 ]);/* if we aren't primary surface ignore this */ -if (!qobj->is_primary) { + is_primary = qobj->shadow ? qobj->shadow->is_primary : qobj->is_primary; +if (!is_primary) {drm_modeset_unlock_all (fb->dev);return 0 ; }
@@ -526,14 +528,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, {struct qxl_device *qdev = plane->dev->dev_private;struct qxl_bo *bo =gem_to_qxl_bo (plane->state->fb->obj[0 ]); -struct qxl_bo *bo_old; +struct qxl_bo *bo_old, *primary;struct drm_clip_rect norect = { .x1 =0 , .y1 =0 , .x2 = plane->state->fb->width, .y2 = plane->state->fb->height }; -bool same_shadow = false;if (old_state->fb) { bo_old =gem_to_qxl_bo (old_state->fb->obj[0 ]);
@@ -541,26 +542,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, bo_old =NULL ; } -if (bo == bo_old) -return ; + primary = bo->shadow ? bo->shadow : bo; -if (bo_old && bo_old->shadow && bo->shadow && - bo_old->shadow == bo->shadow) { - same_shadow = true; - } - -if (bo_old && bo_old->is_primary) { -if (!same_shadow) +if (!primary->is_primary) { +if (qdev->primary_bo)qxl_io_destroy_primary (qdev); - bo_old->is_primary = false; - } - -if (!bo->is_primary) { -if (!same_shadow) { -qxl_io_create_primary (qdev, bo); -qxl_primary_apply_cursor (plane); - } - bo->is_primary = true; +qxl_io_create_primary (qdev, primary); +qxl_primary_apply_cursor (plane); }qxl_draw_dirty_fb (qdev, plane->state->fb, bo,0 ,0 , &norect,1 ,1 );
@@ -756,6 +744,7 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane,qxl_bo_create (qdev, user_bo->gem_base.size, true, true,QXL_GEM_DOMAIN_SURFACE ,NULL , &user_bo->shadow); + user_bo->shadow->surf = user_bo->surf; } }
@@ -784,7 +773,7 @@ static void qxl_plane_cleanup_fb(struct drm_plane *plane, user_bo =gem_to_qxl_bo (obj);qxl_bo_unpin (user_bo); -if (user_bo->shadow && !user_bo->is_primary) { +if (user_bo->shadow && !user_bo->shadow->is_primary) {drm_gem_object_put_unlocked (&user_bo->shadow->gem_base); user_bo->shadow =NULL ; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 14/18 drm/qxl: cover all crtcs in shadow bo.
In reply to Gerd HoffmannThe qxl device supports only a single active framebuffer ("primary surface" in spice terminology). In multihead configurations are handled by defining rectangles within the primary surface for each head/crtc.
Userspace which uses the qxl ioctl interface (xorg qxl driver) is aware of this limitation and will setup framebuffers and crtcs accordingly.
Userspace which uses dumb framebuffers (xorg modesetting driver, wayland) is not aware of this limitation and tries to use two framebuffers (one for each crtc) instead.
The qxl kms driver already has the dumb bo separated from the primary surface, by using a (shared) shadow bo as primary surface. This is needed to support pageflips without having to re-create the primary surface. The qxl driver will blit from the dumb bo to the shadow bo instead.
So we can extend the shadow logic: Maintain a global shadow bo (aka primary surface), make it big enough that dumb bo's for all crtcs fit in side-by-side. Adjust the pageflip blits to place the heads next to each other in the shadow.
With this patch in place multihead qxl works with wayland.
--- drivers/gpu/drm/qxl/qxl_drv.h | 5 +- drivers/gpu/drm/qxl/qxl_display.c | 120 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 9 ++- 3 files changed, 105 insertions(+), 29 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +4 -1
@@ -230,6 +230,8 @@ struct qxl_device {struct qxl_ram_header *ram_header;struct qxl_bo *primary_bo; +struct qxl_bo *dumb_shadow_bo; +struct qxl_head *dumb_heads;struct qxl_memslot main_slot;struct qxl_memslot surfaces_slot;
@@ -437,7 +439,8 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,struct qxl_bo *bo, unsigned int flags, unsigned int color, struct drm_clip_rect *clips, - unsigned int num_clips, int inc); + unsigned int num_clips, int inc, + uint32_t dumb_shadow_offset);void qxl_draw_fill (struct qxl_draw_fill *qxl_draw_fill_rec);
drivers/gpu/drm/qxl/qxl_display.c +94 -26
174 lines not on this page · raw message
drivers/gpu/drm/qxl/qxl_draw.c +7 -2
@@ -267,7 +267,8 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,struct qxl_bo *bo, unsigned int flags, unsigned int color, struct drm_clip_rect *clips, - unsigned int num_clips, int inc) + unsigned int num_clips, int inc, + uint32_t dumb_shadow_offset) {/* * TODO: if flags & DRM_MODE_FB_DIRTY_ANNOTATE_FILL then we should
@@ -295,6 +296,9 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,if (ret)return ; + clips->x1 += dumb_shadow_offset; + clips->x2 += dumb_shadow_offset; + left = clips->x1; right = clips->x2; top = clips->y1;
@@ -342,7 +346,8 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev, goto out_release_backoff; ret =qxl_image_init (qdev, release, dimage, surface_base, - left, top, width, height, depth, stride); + left - dumb_shadow_offset, + top, width, height, depth, stride);qxl_bo_kunmap (bo);if (ret) goto out_release_backoff;
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v2 14/18 drm/qxl: cover all crtcs in shadow bo.
In reply to Gerd HoffmannThe qxl device supports only a single active framebuffer ("primary surface" in spice terminology). In multihead configurations are handled by defining rectangles within the primary surface for each head/crtc.
Userspace which uses the qxl ioctl interface (xorg qxl driver) is aware of this limitation and will setup framebuffers and crtcs accordingly.
Userspace which uses dumb framebuffers (xorg modesetting driver, wayland) is not aware of this limitation and tries to use two framebuffers (one for each crtc) instead.
The qxl kms driver already has the dumb bo separated from the primary surface, by using a (shared) shadow bo as primary surface. This is needed to support pageflips without having to re-create the primary surface. The qxl driver will blit from the dumb bo to the shadow bo instead.
So we can extend the shadow logic: Maintain a global shadow bo (aka primary surface), make it big enough that dumb bo's for all crtcs fit in side-by-side. Adjust the pageflip blits to place the heads next to each other in the shadow.
With this patch in place multihead qxl works with wayland.
--- drivers/gpu/drm/qxl/qxl_drv.h | 5 +- drivers/gpu/drm/qxl/qxl_display.c | 120 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 9 ++- 3 files changed, 105 insertions(+), 29 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +4 -1
@@ -230,6 +230,8 @@ struct qxl_device {struct qxl_ram_header *ram_header;struct qxl_bo *primary_bo; +struct qxl_bo *dumb_shadow_bo; +struct qxl_head *dumb_heads;struct qxl_memslot main_slot;struct qxl_memslot surfaces_slot;
@@ -437,7 +439,8 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,struct qxl_bo *bo, unsigned int flags, unsigned int color, struct drm_clip_rect *clips, - unsigned int num_clips, int inc); + unsigned int num_clips, int inc, + uint32_t dumb_shadow_offset);void qxl_draw_fill (struct qxl_draw_fill *qxl_draw_fill_rec);
drivers/gpu/drm/qxl/qxl_display.c +94 -26
174 lines not on this page · raw message
drivers/gpu/drm/qxl/qxl_draw.c +7 -2
@@ -267,7 +267,8 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,struct qxl_bo *bo, unsigned int flags, unsigned int color, struct drm_clip_rect *clips, - unsigned int num_clips, int inc) + unsigned int num_clips, int inc, + uint32_t dumb_shadow_offset) {/* * TODO: if flags & DRM_MODE_FB_DIRTY_ANNOTATE_FILL then we should
@@ -295,6 +296,9 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,if (ret)return ; + clips->x1 += dumb_shadow_offset; + clips->x2 += dumb_shadow_offset; + left = clips->x1; right = clips->x2; top = clips->y1;
@@ -342,7 +346,8 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev, goto out_release_backoff; ret =qxl_image_init (qdev, release, dimage, surface_base, - left, top, width, height, depth, stride); + left - dumb_shadow_offset, + top, width, height, depth, stride);qxl_bo_kunmap (bo);if (ret) goto out_release_backoff;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 15/18 drm/qxl: use qxl_num_crtc directly
In reply to Gerd Hoffmannqdev->monitors_config->max_allowed is effectively set by the qxl.num_heads module parameter, stored in the qxl_num_crtc variable. Lets get rid of the indirection and use the variable qxl_num_crtc directly. The kernel doesn't need to dereference pointers each time it needs the value, and when reading the code you don't have to trace where and why qdev->monitors_config->max_allowed is set.
--- drivers/gpu/drm/qxl/qxl_display.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +11 -14
@@ -80,10 +80,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)DRM_DEBUG_KMS ("no client monitors configured\n" );return status; } -if (num_monitors > qdev->monitors_config->max_allowed) { +if (num_monitors > qxl_num_crtc) {DRM_DEBUG_KMS ("client monitors list will be truncated: %d < %d\n" , - qdev->monitors_config->max_allowed, num_monitors); - num_monitors = qdev->monitors_config->max_allowed; + qxl_num_crtc, num_monitors); + num_monitors = qxl_num_crtc; }else { num_monitors = qdev->rom->client_monitors_config.count; }
@@ -96,8 +96,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)return status; }/* we copy max from the client but it isn't used */ - qdev->client_monitors_config->max_allowed = - qdev->monitors_config->max_allowed; + qdev->client_monitors_config->max_allowed = qxl_num_crtc;for (i =0 ; i < qdev->client_monitors_config->count ; ++i) {struct qxl_urect *c_rect = &qdev->rom->client_monitors_config.heads[i];
@@ -204,7 +203,7 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,if (!qdev->monitors_config)return 0 ; -if (h >= qdev->monitors_config->max_allowed) +if (h >= qxl_num_crtc)return 0 ;if (!qdev->client_monitors_config)return 0 ;
@@ -307,8 +306,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,return ; } -if (!qdev->monitors_config || - qdev->monitors_config->max_allowed <= i) +if (!qdev->monitors_config || qxl_num_crtc <= i)return ; head.id = i;
@@ -350,9 +348,10 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,if (oldcount != qdev->monitors_config->count)DRM_DEBUG_KMS ("active heads %d -> %d (%d total)\n" , oldcount, qdev->monitors_config->count, - qdev->monitors_config->max_allowed); + qxl_num_crtc); qdev->monitors_config->heads[i] = head; + qdev->monitors_config->max_allowed = qxl_num_crtc;qxl_send_monitors_config (qdev); }
@@ -1148,9 +1147,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev) {int ret;struct drm_gem_object *gobj; -int max_allowed = qxl_num_crtc;int monitors_config_size =sizeof (struct qxl_monitors_config ) + - max_allowed *sizeof (struct qxl_head ); + qxl_num_crtc *sizeof (struct qxl_head ); ret = qxl_gem_object_create(qdev, monitors_config_size, 0, QXL_GEM_DOMAIN_VRAM,
@@ -1172,9 +1170,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev)qxl_bo_physical_address (qdev, qdev->monitors_config_bo,0 );memset (qdev->monitors_config,0 , monitors_config_size); - qdev->monitors_config->max_allowed = max_allowed; - - qdev->dumb_heads =kcalloc (max_allowed,sizeof (qdev->dumb_heads[0 ]),GFP_KERNEL ); + qdev->dumb_heads =kcalloc (qxl_num_crtc,sizeof (qdev->dumb_heads[0 ]), +GFP_KERNEL );return 0 ; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 15/18 drm/qxl: use qxl_num_crtc directly
In reply to Gerd Hoffmannqdev->monitors_config->max_allowed is effectively set by the qxl.num_heads module parameter, stored in the qxl_num_crtc variable. Lets get rid of the indirection and use the variable qxl_num_crtc directly. The kernel doesn't need to dereference pointers each time it needs the value, and when reading the code you don't have to trace where and why qdev->monitors_config->max_allowed is set.
--- drivers/gpu/drm/qxl/qxl_display.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +11 -14
@@ -80,10 +80,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)DRM_DEBUG_KMS ("no client monitors configured\n" );return status; } -if (num_monitors > qdev->monitors_config->max_allowed) { +if (num_monitors > qxl_num_crtc) {DRM_DEBUG_KMS ("client monitors list will be truncated: %d < %d\n" , - qdev->monitors_config->max_allowed, num_monitors); - num_monitors = qdev->monitors_config->max_allowed; + qxl_num_crtc, num_monitors); + num_monitors = qxl_num_crtc; }else { num_monitors = qdev->rom->client_monitors_config.count; }
@@ -96,8 +96,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)return status; }/* we copy max from the client but it isn't used */ - qdev->client_monitors_config->max_allowed = - qdev->monitors_config->max_allowed; + qdev->client_monitors_config->max_allowed = qxl_num_crtc;for (i =0 ; i < qdev->client_monitors_config->count ; ++i) {struct qxl_urect *c_rect = &qdev->rom->client_monitors_config.heads[i];
@@ -204,7 +203,7 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,if (!qdev->monitors_config)return 0 ; -if (h >= qdev->monitors_config->max_allowed) +if (h >= qxl_num_crtc)return 0 ;if (!qdev->client_monitors_config)return 0 ;
@@ -307,8 +306,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,return ; } -if (!qdev->monitors_config || - qdev->monitors_config->max_allowed <= i) +if (!qdev->monitors_config || qxl_num_crtc <= i)return ; head.id = i;
@@ -350,9 +348,10 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,if (oldcount != qdev->monitors_config->count)DRM_DEBUG_KMS ("active heads %d -> %d (%d total)\n" , oldcount, qdev->monitors_config->count, - qdev->monitors_config->max_allowed); + qxl_num_crtc); qdev->monitors_config->heads[i] = head; + qdev->monitors_config->max_allowed = qxl_num_crtc;qxl_send_monitors_config (qdev); }
@@ -1148,9 +1147,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev) {int ret;struct drm_gem_object *gobj; -int max_allowed = qxl_num_crtc;int monitors_config_size =sizeof (struct qxl_monitors_config ) + - max_allowed *sizeof (struct qxl_head ); + qxl_num_crtc *sizeof (struct qxl_head ); ret = qxl_gem_object_create(qdev, monitors_config_size, 0, QXL_GEM_DOMAIN_VRAM,
@@ -1172,9 +1170,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev)qxl_bo_physical_address (qdev, qdev->monitors_config_bo,0 );memset (qdev->monitors_config,0 , monitors_config_size); - qdev->monitors_config->max_allowed = max_allowed; - - qdev->dumb_heads =kcalloc (max_allowed,sizeof (qdev->dumb_heads[0 ]),GFP_KERNEL ); + qdev->dumb_heads =kcalloc (qxl_num_crtc,sizeof (qdev->dumb_heads[0 ]), +GFP_KERNEL );return 0 ; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 16/18 drm/qxl: implement prime kmap/kunmap
In reply to Gerd HoffmannGeneric fbdev emulation needs this. Also: We must keep track of the number of mappings now, so we don't unmap early in case two users want a kmap of the same bo. Add a sanity check to destroy callback to make sure kmap/kunmap is balanced.
--- drivers/gpu/drm/qxl/qxl_drv.h | 1 + drivers/gpu/drm/qxl/qxl_object.c | 6 ++++++ drivers/gpu/drm/qxl/qxl_prime.c | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -0
@@ -84,6 +84,7 @@ struct qxl_bo {struct ttm_bo_kmap_obj kmap;unsigned int pin_count;void *kptr; +unsigned int map_count;int type;/* Constant after initialization */
drivers/gpu/drm/qxl/qxl_object.c +6 -0
@@ -36,6 +36,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo) qdev = (struct qxl_device *)bo->gem_base.dev->dev_private;qxl_surface_evict (qdev, bo, false); +WARN_ON_ONCE (bo->map_count >0 );mutex_lock (&qdev->gem.mutex);list_del_init (&bo->list);mutex_unlock (&qdev->gem.mutex);
@@ -131,6 +132,7 @@ int qxl_bo_kmap(struct qxl_bo *bo, void **ptr)if (bo->kptr) {if (ptr) *ptr = bo->kptr; + bo->map_count++;return 0 ; } r =ttm_bo_kmap (&bo->tbo,0 , bo->tbo.num_pages, &bo->kmap);
@@ -139,6 +141,7 @@ int qxl_bo_kmap(struct qxl_bo *bo, void **ptr) bo->kptr =ttm_kmap_obj_virtual (&bo->kmap, &is_iomem);if (ptr) *ptr = bo->kptr; + bo->map_count =1 ;return 0 ; }
@@ -180,6 +183,9 @@ void qxl_bo_kunmap(struct qxl_bo *bo) {if (bo->kptr ==NULL )return ; + bo->map_count--; +if (bo->map_count >0 ) +return ; bo->kptr =NULL ;ttm_bo_kunmap (&bo->kmap); }
drivers/gpu/drm/qxl/qxl_prime.c +13 -4
@@ -22,7 +22,7 @@* Authors: Andreas Pokorny */ -#include "qxl_drv.h" +#include "qxl_object.h" /* Empty Implementations as there should not be any other driver for a virtual * device that might share buffers with qxl */
@@ -54,13 +54,22 @@ struct drm_gem_object *qxl_gem_prime_import_sg_table(void *qxl_gem_prime_vmap (struct drm_gem_object *obj) { -WARN_ONCE (1 ,"not implemented" ); -return ERR_PTR (-ENOSYS ); +struct qxl_bo *bo =gem_to_qxl_bo (obj); +void *ptr; +int ret; + + ret =qxl_bo_kmap (bo, &ptr); +if (ret <0 ) +return ERR_PTR (ret); + +return ptr; }void qxl_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr) { -WARN_ONCE (1 ,"not implemented" ); +struct qxl_bo *bo =gem_to_qxl_bo (obj); + +qxl_bo_kunmap (bo); } int qxl_gem_prime_mmap(struct drm_gem_object *obj,
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v2 16/18 drm/qxl: implement prime kmap/kunmap
In reply to Gerd HoffmannGeneric fbdev emulation needs this. Also: We must keep track of the number of mappings now, so we don't unmap early in case two users want a kmap of the same bo. Add a sanity check to destroy callback to make sure kmap/kunmap is balanced.
--- drivers/gpu/drm/qxl/qxl_drv.h | 1 + drivers/gpu/drm/qxl/qxl_object.c | 6 ++++++ drivers/gpu/drm/qxl/qxl_prime.c | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -0
@@ -84,6 +84,7 @@ struct qxl_bo {struct ttm_bo_kmap_obj kmap;unsigned int pin_count;void *kptr; +unsigned int map_count;int type;/* Constant after initialization */
drivers/gpu/drm/qxl/qxl_object.c +6 -0
@@ -36,6 +36,7 @@ static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo) qdev = (struct qxl_device *)bo->gem_base.dev->dev_private;qxl_surface_evict (qdev, bo, false); +WARN_ON_ONCE (bo->map_count >0 );mutex_lock (&qdev->gem.mutex);list_del_init (&bo->list);mutex_unlock (&qdev->gem.mutex);
@@ -131,6 +132,7 @@ int qxl_bo_kmap(struct qxl_bo *bo, void **ptr)if (bo->kptr) {if (ptr) *ptr = bo->kptr; + bo->map_count++;return 0 ; } r =ttm_bo_kmap (&bo->tbo,0 , bo->tbo.num_pages, &bo->kmap);
@@ -139,6 +141,7 @@ int qxl_bo_kmap(struct qxl_bo *bo, void **ptr) bo->kptr =ttm_kmap_obj_virtual (&bo->kmap, &is_iomem);if (ptr) *ptr = bo->kptr; + bo->map_count =1 ;return 0 ; }
@@ -180,6 +183,9 @@ void qxl_bo_kunmap(struct qxl_bo *bo) {if (bo->kptr ==NULL )return ; + bo->map_count--; +if (bo->map_count >0 ) +return ; bo->kptr =NULL ;ttm_bo_kunmap (&bo->kmap); }
drivers/gpu/drm/qxl/qxl_prime.c +13 -4
@@ -22,7 +22,7 @@* Authors: Andreas Pokorny */ -#include "qxl_drv.h" +#include "qxl_object.h" /* Empty Implementations as there should not be any other driver for a virtual * device that might share buffers with qxl */
@@ -54,13 +54,22 @@ struct drm_gem_object *qxl_gem_prime_import_sg_table(void *qxl_gem_prime_vmap (struct drm_gem_object *obj) { -WARN_ONCE (1 ,"not implemented" ); -return ERR_PTR (-ENOSYS ); +struct qxl_bo *bo =gem_to_qxl_bo (obj); +void *ptr; +int ret; + + ret =qxl_bo_kmap (bo, &ptr); +if (ret <0 ) +return ERR_PTR (ret); + +return ptr; }void qxl_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr) { -WARN_ONCE (1 ,"not implemented" ); +struct qxl_bo *bo =gem_to_qxl_bo (obj); + +qxl_bo_kunmap (bo); } int qxl_gem_prime_mmap(struct drm_gem_object *obj,
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 17/18 drm/qxl: use generic fbdev emulation
In reply to Gerd HoffmannSwitch qxl over to the new generic fbdev emulation.
--- drivers/gpu/drm/qxl/qxl_display.c | 7 ------- drivers/gpu/drm/qxl/qxl_drv.c | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +0 -7
@@ -1223,18 +1223,11 @@ int qxl_modeset_init(struct qxl_device *qdev)qxl_display_read_client_monitors_config (qdev);drm_mode_config_reset (&qdev->ddev); - -/* primary surface must be created by this point, to allow -* issuing command queue commands and having them read by -* spice server. */ -qxl_fbdev_init (qdev);return 0 ; }void qxl_modeset_fini (struct qxl_device *qdev) { -qxl_fbdev_fini (qdev); -qxl_destroy_monitors_object (qdev);drm_mode_config_cleanup (&qdev->ddev); }
drivers/gpu/drm/qxl/qxl_drv.c +2 -0
@@ -93,6 +93,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto modeset_cleanup; +drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ; modeset_cleanup:
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 17/18 drm/qxl: use generic fbdev emulation
In reply to Gerd HoffmannSwitch qxl over to the new generic fbdev emulation.
--- drivers/gpu/drm/qxl/qxl_display.c | 7 ------- drivers/gpu/drm/qxl/qxl_drv.c | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +0 -7
@@ -1223,18 +1223,11 @@ int qxl_modeset_init(struct qxl_device *qdev)qxl_display_read_client_monitors_config (qdev);drm_mode_config_reset (&qdev->ddev); - -/* primary surface must be created by this point, to allow -* issuing command queue commands and having them read by -* spice server. */ -qxl_fbdev_init (qdev);return 0 ; }void qxl_modeset_fini (struct qxl_device *qdev) { -qxl_fbdev_fini (qdev); -qxl_destroy_monitors_object (qdev);drm_mode_config_cleanup (&qdev->ddev); }
drivers/gpu/drm/qxl/qxl_drv.c +2 -0
@@ -93,6 +93,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto modeset_cleanup; +drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" ); +drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ; modeset_cleanup:
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v2 18/18 drm/qxl: remove dead qxl fbdev emulation code
In reply to Gerd HoffmannLovely diffstat, thanks to the new generic fbdev emulation.
drm/qxl/Makefile | 2 drm/qxl/qxl_draw.c | 232 ---------------------------------------- drm/qxl/qxl_drv.h | 21 --- drm/qxl/qxl_fb.c | 300 -----------------------------------------------------
--- drivers/gpu/drm/qxl/qxl_drv.h | 21 --- drivers/gpu/drm/qxl/qxl_draw.c | 232 ------------------------------- drivers/gpu/drm/qxl/qxl_fb.c | 300 ----------------------------------------- drivers/gpu/drm/qxl/Makefile | 2 +- 4 files changed, 1 insertion(+), 554 deletions(-) delete mode 100644 drivers/gpu/drm/qxl/qxl_fb.c
drivers/gpu/drm/qxl/qxl_drv.h +0 -21
@@ -220,8 +220,6 @@ struct qxl_device {struct qxl_mman mman;struct qxl_gem gem; -struct drm_fb_helper fb_helper; -void *ram_physical;struct qxl_ring *release_ring;
@@ -322,12 +320,6 @@ qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo,return slot->high_bits | (bo->tbo.offset - slot->gpu_offset + offset); } -/* qxl_fb.c */ -#define QXLFB_CONN_LIMIT 1 - -int qxl_fbdev_init (struct qxl_device *qdev); -void qxl_fbdev_fini (struct qxl_device *qdev); -/* qxl_display.c */ void qxl_display_read_client_monitors_config (struct qxl_device *qdev);int qxl_create_monitors_object (struct qxl_device *qdev);
@@ -432,9 +424,6 @@ int qxl_alloc_bo_reserved(struct qxl_device *qdev, struct qxl_bo **_bo);/* qxl drawing commands */ -void qxl_draw_opaque_fb (const struct qxl_fb_image *qxl_fb_image, -int stride/* filled in if 0 */ ); - void qxl_draw_dirty_fb(struct qxl_device *qdev, struct drm_framebuffer *fb, struct qxl_bo *bo,
@@ -443,13 +432,6 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev, unsigned int num_clips, int inc, uint32_t dumb_shadow_offset); -void qxl_draw_fill (struct qxl_draw_fill *qxl_draw_fill_rec); - -void qxl_draw_copyarea (struct qxl_device *qdev, -u32 width,u32 height, -u32 sx,u32 sy, -u32 dx,u32 dy); -void qxl_release_free (struct qxl_device *qdev,struct qxl_release *release);
@@ -481,9 +463,6 @@ int qxl_gem_prime_mmap(struct drm_gem_object *obj,int qxl_irq_init (struct qxl_device *qdev);irqreturn_t qxl_irq_handler (int irq,void *arg); -/* qxl_fb.c */ -bool qxl_fbdev_qobj_is_fb (struct qxl_device *qdev,struct qxl_bo *qobj); -int qxl_debugfs_add_files (struct qxl_device *qdev,struct drm_info_list *files,unsigned int nfiles);
drivers/gpu/drm/qxl/qxl_draw.c +0 -232
241 lines not on this page · raw message
drivers/gpu/drm/qxl/qxl_fb.c deleted +0 -300
300 lines not on this page · raw message
drivers/gpu/drm/qxl/Makefile +1 -1
@@ -2,6 +2,6 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. -qxl-y := qxl_drv.o qxl_kms.o qxl_display.o qxl_ttm.o qxl_fb.o qxl_object.o qxl_gem.o qxl_cmd.o qxl_image.o qxl_draw.o qxl_debugfs.o qxl_irq.o qxl_dumb.o qxl_ioctl.o qxl_release.o qxl_prime.o +qxl-y := qxl_drv.o qxl_kms.o qxl_display.o qxl_ttm.o qxl_object.o qxl_gem.o qxl_cmd.o qxl_image.o qxl_draw.o qxl_debugfs.o qxl_irq.o qxl_dumb.o qxl_ioctl.o qxl_release.o qxl_prime.o obj-$(CONFIG_DRM_QXL)+= qxl.o
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v2 18/18 drm/qxl: remove dead qxl fbdev emulation code
In reply to Gerd HoffmannLovely diffstat, thanks to the new generic fbdev emulation.
drm/qxl/Makefile | 2 drm/qxl/qxl_draw.c | 232 ---------------------------------------- drm/qxl/qxl_drv.h | 21 --- drm/qxl/qxl_fb.c | 300 -----------------------------------------------------
--- drivers/gpu/drm/qxl/qxl_drv.h | 21 --- drivers/gpu/drm/qxl/qxl_draw.c | 232 ------------------------------- drivers/gpu/drm/qxl/qxl_fb.c | 300 ----------------------------------------- drivers/gpu/drm/qxl/Makefile | 2 +- 4 files changed, 1 insertion(+), 554 deletions(-) delete mode 100644 drivers/gpu/drm/qxl/qxl_fb.c
drivers/gpu/drm/qxl/qxl_drv.h +0 -21
@@ -220,8 +220,6 @@ struct qxl_device {struct qxl_mman mman;struct qxl_gem gem; -struct drm_fb_helper fb_helper; -void *ram_physical;struct qxl_ring *release_ring;
@@ -322,12 +320,6 @@ qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo,return slot->high_bits | (bo->tbo.offset - slot->gpu_offset + offset); } -/* qxl_fb.c */ -#define QXLFB_CONN_LIMIT 1 - -int qxl_fbdev_init (struct qxl_device *qdev); -void qxl_fbdev_fini (struct qxl_device *qdev); -/* qxl_display.c */ void qxl_display_read_client_monitors_config (struct qxl_device *qdev);int qxl_create_monitors_object (struct qxl_device *qdev);
@@ -432,9 +424,6 @@ int qxl_alloc_bo_reserved(struct qxl_device *qdev, struct qxl_bo **_bo);/* qxl drawing commands */ -void qxl_draw_opaque_fb (const struct qxl_fb_image *qxl_fb_image, -int stride/* filled in if 0 */ ); - void qxl_draw_dirty_fb(struct qxl_device *qdev, struct drm_framebuffer *fb, struct qxl_bo *bo,
@@ -443,13 +432,6 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev, unsigned int num_clips, int inc, uint32_t dumb_shadow_offset); -void qxl_draw_fill (struct qxl_draw_fill *qxl_draw_fill_rec); - -void qxl_draw_copyarea (struct qxl_device *qdev, -u32 width,u32 height, -u32 sx,u32 sy, -u32 dx,u32 dy); -void qxl_release_free (struct qxl_device *qdev,struct qxl_release *release);
@@ -481,9 +463,6 @@ int qxl_gem_prime_mmap(struct drm_gem_object *obj,int qxl_irq_init (struct qxl_device *qdev);irqreturn_t qxl_irq_handler (int irq,void *arg); -/* qxl_fb.c */ -bool qxl_fbdev_qobj_is_fb (struct qxl_device *qdev,struct qxl_bo *qobj); -int qxl_debugfs_add_files (struct qxl_device *qdev,struct drm_info_list *files,unsigned int nfiles);
drivers/gpu/drm/qxl/qxl_draw.c +0 -232
241 lines not on this page · raw message
drivers/gpu/drm/qxl/qxl_fb.c deleted +0 -300
300 lines not on this page · raw message
drivers/gpu/drm/qxl/Makefile +1 -1
@@ -2,6 +2,6 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. -qxl-y := qxl_drv.o qxl_kms.o qxl_display.o qxl_ttm.o qxl_fb.o qxl_object.o qxl_gem.o qxl_cmd.o qxl_image.o qxl_draw.o qxl_debugfs.o qxl_irq.o qxl_dumb.o qxl_ioctl.o qxl_release.o qxl_prime.o +qxl-y := qxl_drv.o qxl_kms.o qxl_display.o qxl_ttm.o qxl_object.o qxl_gem.o qxl_cmd.o qxl_image.o qxl_draw.o qxl_debugfs.o qxl_irq.o qxl_dumb.o qxl_ioctl.o qxl_release.o qxl_prime.o obj-$(CONFIG_DRM_QXL)+= qxl.o
Signature · 6 lines
2.9.3 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Gerd Hoffmann
maintainerv2 cover drm/qxl: ttm fixes, cleanups, allocation tweaks, multihead, fbdev
So, here is the all-in-one package of all my qxl changes. Some of these changes have been on the list before, some not. Summary:
(1) A collection of misc ttm bugfixes and cleanups.
(2) Move some allocations from VRAM to PRIV domain, to reduce VRAM memory pressure. Should help especially with wayland, which uses dumb gem buffers.
(3) Extend the shadow bo logic to handle multihead setups with dumb buffers. Helps wayland too.
(4) Switch qxl over to the generic fbdev emulation.
cheers,
Gerd
Frediano Ziglio (1):
drm/qxl: change the way slot is detected
Gerd Hoffmann (17):
drm/qxl: drop ttm_mem_reg arg from qxl_hw_surface_alloc() drm/qxl: drop unused qxl_fb_virtual_address
drm/qxl: simplify slot management
drm/qxl: drop unused fields from struct qxl_device drm/qxl: use separate offset spaces for the two slots / ttm memory
types.
drm/qxl: allow both PRIV and VRAM placement for QXL_GEM_DOMAIN_SURFACE drm/qxl: use QXL_GEM_DOMAIN_SURFACE for shadow bo. drm/qxl: use QXL_GEM_DOMAIN_SURFACE for dumb gem objects drm/qxl: move qxl_primary_apply_cursor to correct place drm/qxl: drop unused offset parameter from qxl_io_create_primary() drm/qxl: track primary bo
drm/qxl: use shadow bo directly
drm/qxl: cover all crtcs in shadow bo.
drm/qxl: use qxl_num_crtc directly
drm/qxl: implement prime kmap/kunmap
drm/qxl: use generic fbdev emulation
drm/qxl: remove dead qxl fbdev emulation code
drivers/gpu/drm/qxl/qxl_drv.h | 64 +++----- drivers/gpu/drm/qxl/qxl_cmd.c | 32 ++-- drivers/gpu/drm/qxl/qxl_display.c | 181 ++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 241 +----------------------------- drivers/gpu/drm/qxl/qxl_drv.c | 2 + drivers/gpu/drm/qxl/qxl_dumb.c | 2 +- drivers/gpu/drm/qxl/qxl_fb.c | 300 -------------------------------------- drivers/gpu/drm/qxl/qxl_kms.c | 81 ++++------ drivers/gpu/drm/qxl/qxl_object.c | 12 +- drivers/gpu/drm/qxl/qxl_prime.c | 17 ++- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +- drivers/gpu/drm/qxl/Makefile | 2 +- 12 files changed, 216 insertions(+), 728 deletions(-) delete mode 100644 drivers/gpu/drm/qxl/qxl_fb.c
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel