drm/qxl: ttm fixes, cleanups, allocation tweaks, multihead, fbdev
Subsystems (4)
Gerd Hoffmann
maintainerPATCH v3 1/23 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
@@ -460,8 +460,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;
@@ -487,16 +486,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 v3 1/23 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
@@ -460,8 +460,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;
@@ -487,16 +486,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 v3 2/23 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 v3 2/23 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 v3 3/23 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 v3 3/23 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 v3 4/23 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 v3 5/23 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 v3 5/23 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 v3 6/23 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 · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v3 6/23 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 v3 7/23 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 v3 7/23 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 v3 8/23 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 v3 8/23 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 v3 9/23 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 v3 9/23 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 v3 10/23 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 v3 10/23 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 v3 11/23 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
@@ -377,8 +377,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;
@@ -389,9 +388,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 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 11/23 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
@@ -377,8 +377,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;
@@ -389,9 +388,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 v3 12/23 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
@@ -374,13 +374,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;
@@ -399,7 +402,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 · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 12/23 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
@@ -374,13 +374,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;
@@ -399,7 +402,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 v3 13/23 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().
qxl_io_create/destroy_primary: primary_bo tracking [fixup]
--- drivers/gpu/drm/qxl/qxl_cmd.c | 10 +++++----- drivers/gpu/drm/qxl/qxl_display.c | 33 +++++++++++---------------------- 2 files changed, 16 insertions(+), 27 deletions(-)
drivers/gpu/drm/qxl/qxl_cmd.c +5 -5
@@ -374,6 +374,8 @@ 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; +drm_gem_object_put_unlocked (&qdev->primary_bo->gem_base); qdev->primary_bo =NULL ; }
@@ -390,11 +392,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);
@@ -403,6 +401,8 @@ 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; +drm_gem_object_get (&qdev->primary_bo->gem_base); }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 · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v3 13/23 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().
qxl_io_create/destroy_primary: primary_bo tracking [fixup]
--- drivers/gpu/drm/qxl/qxl_cmd.c | 10 +++++----- drivers/gpu/drm/qxl/qxl_display.c | 33 +++++++++++---------------------- 2 files changed, 16 insertions(+), 27 deletions(-)
drivers/gpu/drm/qxl/qxl_cmd.c +5 -5
@@ -374,6 +374,8 @@ 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; +drm_gem_object_put_unlocked (&qdev->primary_bo->gem_base); qdev->primary_bo =NULL ; }
@@ -390,11 +392,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);
@@ -403,6 +401,8 @@ 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; +drm_gem_object_get (&qdev->primary_bo->gem_base); }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 v3 14/23 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 | 119 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 9 ++- 3 files changed, 104 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 +93 -26
173 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 v3 14/23 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 | 119 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 9 ++- 3 files changed, 104 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 +93 -26
173 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 v3 15/23 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); }
@@ -1146,9 +1145,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,
@@ -1170,9 +1168,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 · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v3 15/23 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); }
@@ -1146,9 +1145,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,
@@ -1170,9 +1168,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 v3 16/23 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 v3 16/23 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 v3 17/23 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
@@ -1221,18 +1221,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 v3 17/23 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
@@ -1221,18 +1221,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 v3 18/23 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 v3 18/23 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
maintainerPATCH v3 19/23 drm/qxl: implement qxl_gem_prime_(un)pin
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_prime.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_prime.c +7 -3
@@ -22,6 +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
@@ -29,13 +30,16 @@int qxl_gem_prime_pin (struct drm_gem_object *obj) { -WARN_ONCE (1 ,"not implemented" ); -return -ENOSYS ; +struct qxl_bo *bo =gem_to_qxl_bo (obj); + +return qxl_bo_pin (bo); }void qxl_gem_prime_unpin (struct drm_gem_object *obj) { -WARN_ONCE (1 ,"not implemented" ); +struct qxl_bo *bo =gem_to_qxl_bo (obj); + +qxl_bo_unpin (bo); }struct sg_table *qxl_gem_prime_get_sg_table (struct drm_gem_object *obj)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Gerd Hoffmann
maintainerPATCH v3 19/23 drm/qxl: implement qxl_gem_prime_(un)pin
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_prime.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_prime.c +7 -3
@@ -22,6 +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
@@ -29,13 +30,16 @@int qxl_gem_prime_pin (struct drm_gem_object *obj) { -WARN_ONCE (1 ,"not implemented" ); -return -ENOSYS ; +struct qxl_bo *bo =gem_to_qxl_bo (obj); + +return qxl_bo_pin (bo); }void qxl_gem_prime_unpin (struct drm_gem_object *obj) { -WARN_ONCE (1 ,"not implemented" ); +struct qxl_bo *bo =gem_to_qxl_bo (obj); + +qxl_bo_unpin (bo); }struct sg_table *qxl_gem_prime_get_sg_table (struct drm_gem_object *obj)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 20/23 drm/qxl: add mode/framebuffer check functions
In reply to Gerd HoffmannAdd a helper functions to check video modes. Also add a helper to check framebuffer buffer objects, using the former for consistency. That way we should not fail in qxl_primary_atomic_check() because video modes which are too big will not be added to the mode list in the first place.
--- drivers/gpu/drm/qxl/qxl_display.c | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +26 -18
@@ -190,6 +190,28 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) } } +static int qxl_check_mode (struct qxl_device *qdev, +unsigned int width, +unsigned int height) +{ +unsigned int stride; +unsigned int size; + +if (check_mul_overflow (width,4u , &stride)) +return -EINVAL ; +if (check_mul_overflow (stride, height, &size)) +return -EINVAL ; +if (size > qdev->vram_size) +return -ENOMEM ; +return 0 ; +} + +static int qxl_check_framebuffer (struct qxl_device *qdev, +struct qxl_bo *bo) +{ +return qxl_check_mode (qdev, bo->surf.width, bo->surf.height); +} +static int qxl_add_monitors_config_modes (struct drm_connector *connector,unsigned *pwidth,unsigned *pheight)
@@ -469,12 +491,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane, bo =gem_to_qxl_bo (state->fb->obj[0 ]); -if (bo->surf.stride * bo->surf.height > qdev->vram_size) { -DRM_ERROR ("Mode doesn't fit in vram size (vgamem)" ); -return -EINVAL ; - } - -return 0 ; +return qxl_check_framebuffer (qdev, bo); }static int qxl_primary_apply_cursor (struct drm_plane *plane)
@@ -990,20 +1007,11 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector, {struct drm_device *ddev = connector->dev;struct qxl_device *qdev = ddev->dev_private; -int i; -/* TODO: is this called for user defined modes? (xrandr --add-mode) -* TODO: check that the mode fits in the framebuffer */ +if (qxl_check_mode (qdev, mode->hdisplay, mode->vdisplay) !=0 ) +return MODE_BAD ; -if (qdev->monitors_config_width == mode->hdisplay && - qdev->monitors_config_height == mode->vdisplay) -return MODE_OK ; - -for (i =0 ; i <ARRAY_SIZE (common_modes); i++) { -if (common_modes[i].w == mode->hdisplay && common_modes[i].h == mode->vdisplay) -return MODE_OK ; - } -return MODE_BAD ; +return MODE_OK ; }static struct drm_encoder *qxl_best_encoder (struct drm_connector *connector)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 20/23 drm/qxl: add mode/framebuffer check functions
In reply to Gerd HoffmannAdd a helper functions to check video modes. Also add a helper to check framebuffer buffer objects, using the former for consistency. That way we should not fail in qxl_primary_atomic_check() because video modes which are too big will not be added to the mode list in the first place.
--- drivers/gpu/drm/qxl/qxl_display.c | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +26 -18
@@ -190,6 +190,28 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) } } +static int qxl_check_mode (struct qxl_device *qdev, +unsigned int width, +unsigned int height) +{ +unsigned int stride; +unsigned int size; + +if (check_mul_overflow (width,4u , &stride)) +return -EINVAL ; +if (check_mul_overflow (stride, height, &size)) +return -EINVAL ; +if (size > qdev->vram_size) +return -ENOMEM ; +return 0 ; +} + +static int qxl_check_framebuffer (struct qxl_device *qdev, +struct qxl_bo *bo) +{ +return qxl_check_mode (qdev, bo->surf.width, bo->surf.height); +} +static int qxl_add_monitors_config_modes (struct drm_connector *connector,unsigned *pwidth,unsigned *pheight)
@@ -469,12 +491,7 @@ static int qxl_primary_atomic_check(struct drm_plane *plane, bo =gem_to_qxl_bo (state->fb->obj[0 ]); -if (bo->surf.stride * bo->surf.height > qdev->vram_size) { -DRM_ERROR ("Mode doesn't fit in vram size (vgamem)" ); -return -EINVAL ; - } - -return 0 ; +return qxl_check_framebuffer (qdev, bo); }static int qxl_primary_apply_cursor (struct drm_plane *plane)
@@ -990,20 +1007,11 @@ static enum drm_mode_status qxl_conn_mode_valid(struct drm_connector *connector, {struct drm_device *ddev = connector->dev;struct qxl_device *qdev = ddev->dev_private; -int i; -/* TODO: is this called for user defined modes? (xrandr --add-mode) -* TODO: check that the mode fits in the framebuffer */ +if (qxl_check_mode (qdev, mode->hdisplay, mode->vdisplay) !=0 ) +return MODE_BAD ; -if (qdev->monitors_config_width == mode->hdisplay && - qdev->monitors_config_height == mode->vdisplay) -return MODE_OK ; - -for (i =0 ; i <ARRAY_SIZE (common_modes); i++) { -if (common_modes[i].w == mode->hdisplay && common_modes[i].h == mode->vdisplay) -return MODE_OK ; - } -return MODE_BAD ; +return MODE_OK ; }static struct drm_encoder *qxl_best_encoder (struct drm_connector *connector)
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 21/23 drm/qxl: add qxl_add_mode helper function
In reply to Gerd HoffmannAdd a helper function to add custom video modes to a connector.
--- drivers/gpu/drm/qxl/qxl_display.c | 84 +++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 35 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +49 -35
@@ -212,15 +212,36 @@ static int qxl_check_framebuffer(struct qxl_device *qdev,return qxl_check_mode (qdev, bo->surf.width, bo->surf.height); } -static int qxl_add_monitors_config_modes (struct drm_connector *connector, -unsigned *pwidth, -unsigned *pheight) +static int qxl_add_mode (struct drm_connector *connector, +unsigned int width, +unsigned int height, +bool preferred) +{ +struct drm_device *dev = connector->dev; +struct qxl_device *qdev = dev->dev_private; +struct drm_display_mode *mode =NULL ; +int rc; + + rc =qxl_check_mode (qdev, width, height); +if (rc !=0 ) +return 0 ; + + mode =drm_cvt_mode (dev, width, height,60 , false, false, false); +if (preferred) + mode->type |=DRM_MODE_TYPE_PREFERRED ; + mode->hdisplay = width; + mode->vdisplay = height; +drm_mode_set_name (mode); +drm_mode_probed_add (connector, mode); +return 1 ; +} + +static int qxl_add_monitors_config_modes (struct drm_connector *connector) {struct drm_device *dev = connector->dev;struct qxl_device *qdev = dev->dev_private;struct qxl_output *output =drm_connector_to_qxl_output (connector);int h = output->index; -struct drm_display_mode *mode =NULL ;struct qxl_head *head;if (!qdev->monitors_config)
@@ -235,19 +256,7 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector, head = &qdev->client_monitors_config->heads[h];DRM_DEBUG_KMS ("head %d is %dx%d\n" , h, head->width, head->height); - mode =drm_cvt_mode (dev, head->width, head->height,60 , false, false, - false); - mode->type |=DRM_MODE_TYPE_PREFERRED ; - mode->hdisplay = head->width; - mode->vdisplay = head->height; -drm_mode_set_name (mode); - *pwidth = head->width; - *pheight = head->height; -drm_mode_probed_add (connector, mode); -/* remember the last custom size for mode validation */ - qdev->monitors_config_width = mode->hdisplay; - qdev->monitors_config_height = mode->vdisplay; -return 1 ; +return qxl_add_mode (connector, head->width, head->height, true); } static struct mode_size {
@@ -273,22 +282,16 @@ static struct mode_size { {1920, 1200} }; -static int qxl_add_common_modes (struct drm_connector *connector, -unsigned int pwidth, -unsigned int pheight) +static int qxl_add_common_modes (struct drm_connector *connector) { -struct drm_device *dev = connector->dev; -struct drm_display_mode *mode =NULL ; -int i; +int i, ret =0 ; -for (i =0 ; i <ARRAY_SIZE (common_modes); i++) { - mode =drm_cvt_mode (dev, common_modes[i].w, common_modes[i].h, -60 , false, false, false); -if (common_modes[i].w == pwidth && common_modes[i].h == pheight) - mode->type |=DRM_MODE_TYPE_PREFERRED ; -drm_mode_probed_add (connector, mode); - } -return i -1 ; +for (i =0 ; i <ARRAY_SIZE (common_modes); i++) + ret +=qxl_add_mode (connector, + common_modes[i].w, + common_modes[i].h, + false); +return ret; }static void qxl_send_monitors_config (struct qxl_device *qdev)
@@ -991,14 +994,25 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)static int qxl_conn_get_modes (struct drm_connector *connector) { +struct drm_device *dev = connector->dev; +struct qxl_device *qdev = dev->dev_private; +struct qxl_output *output =drm_connector_to_qxl_output (connector);unsigned int pwidth =1024 ;unsigned int pheight =768 ;int ret =0 ; - ret =qxl_add_monitors_config_modes (connector, &pwidth, &pheight); -if (ret <0 ) -return ret; - ret +=qxl_add_common_modes (connector, pwidth, pheight); +if (qdev->client_monitors_config) { +struct qxl_head *head; + head = &qdev->client_monitors_config->heads[output->index]; +if (head->width) + pwidth = head->width; +if (head->height) + pheight = head->height; + } + + ret +=qxl_add_common_modes (connector); + ret +=qxl_add_monitors_config_modes (connector); +drm_set_preferred_mode (connector, pwidth, pheight);return ret; }
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Gerd Hoffmann
maintainerPATCH v3 21/23 drm/qxl: add qxl_add_mode helper function
In reply to Gerd HoffmannAdd a helper function to add custom video modes to a connector.
--- drivers/gpu/drm/qxl/qxl_display.c | 84 +++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 35 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +49 -35
@@ -212,15 +212,36 @@ static int qxl_check_framebuffer(struct qxl_device *qdev,return qxl_check_mode (qdev, bo->surf.width, bo->surf.height); } -static int qxl_add_monitors_config_modes (struct drm_connector *connector, -unsigned *pwidth, -unsigned *pheight) +static int qxl_add_mode (struct drm_connector *connector, +unsigned int width, +unsigned int height, +bool preferred) +{ +struct drm_device *dev = connector->dev; +struct qxl_device *qdev = dev->dev_private; +struct drm_display_mode *mode =NULL ; +int rc; + + rc =qxl_check_mode (qdev, width, height); +if (rc !=0 ) +return 0 ; + + mode =drm_cvt_mode (dev, width, height,60 , false, false, false); +if (preferred) + mode->type |=DRM_MODE_TYPE_PREFERRED ; + mode->hdisplay = width; + mode->vdisplay = height; +drm_mode_set_name (mode); +drm_mode_probed_add (connector, mode); +return 1 ; +} + +static int qxl_add_monitors_config_modes (struct drm_connector *connector) {struct drm_device *dev = connector->dev;struct qxl_device *qdev = dev->dev_private;struct qxl_output *output =drm_connector_to_qxl_output (connector);int h = output->index; -struct drm_display_mode *mode =NULL ;struct qxl_head *head;if (!qdev->monitors_config)
@@ -235,19 +256,7 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector, head = &qdev->client_monitors_config->heads[h];DRM_DEBUG_KMS ("head %d is %dx%d\n" , h, head->width, head->height); - mode =drm_cvt_mode (dev, head->width, head->height,60 , false, false, - false); - mode->type |=DRM_MODE_TYPE_PREFERRED ; - mode->hdisplay = head->width; - mode->vdisplay = head->height; -drm_mode_set_name (mode); - *pwidth = head->width; - *pheight = head->height; -drm_mode_probed_add (connector, mode); -/* remember the last custom size for mode validation */ - qdev->monitors_config_width = mode->hdisplay; - qdev->monitors_config_height = mode->vdisplay; -return 1 ; +return qxl_add_mode (connector, head->width, head->height, true); } static struct mode_size {
@@ -273,22 +282,16 @@ static struct mode_size { {1920, 1200} }; -static int qxl_add_common_modes (struct drm_connector *connector, -unsigned int pwidth, -unsigned int pheight) +static int qxl_add_common_modes (struct drm_connector *connector) { -struct drm_device *dev = connector->dev; -struct drm_display_mode *mode =NULL ; -int i; +int i, ret =0 ; -for (i =0 ; i <ARRAY_SIZE (common_modes); i++) { - mode =drm_cvt_mode (dev, common_modes[i].w, common_modes[i].h, -60 , false, false, false); -if (common_modes[i].w == pwidth && common_modes[i].h == pheight) - mode->type |=DRM_MODE_TYPE_PREFERRED ; -drm_mode_probed_add (connector, mode); - } -return i -1 ; +for (i =0 ; i <ARRAY_SIZE (common_modes); i++) + ret +=qxl_add_mode (connector, + common_modes[i].w, + common_modes[i].h, + false); +return ret; }static void qxl_send_monitors_config (struct qxl_device *qdev)
@@ -991,14 +994,25 @@ static int qdev_crtc_init(struct drm_device *dev, int crtc_id)static int qxl_conn_get_modes (struct drm_connector *connector) { +struct drm_device *dev = connector->dev; +struct qxl_device *qdev = dev->dev_private; +struct qxl_output *output =drm_connector_to_qxl_output (connector);unsigned int pwidth =1024 ;unsigned int pheight =768 ;int ret =0 ; - ret =qxl_add_monitors_config_modes (connector, &pwidth, &pheight); -if (ret <0 ) -return ret; - ret +=qxl_add_common_modes (connector, pwidth, pheight); +if (qdev->client_monitors_config) { +struct qxl_head *head; + head = &qdev->client_monitors_config->heads[output->index]; +if (head->width) + pwidth = head->width; +if (head->height) + pheight = head->height; + } + + ret +=qxl_add_common_modes (connector); + ret +=qxl_add_monitors_config_modes (connector); +drm_set_preferred_mode (connector, pwidth, pheight);return ret; }
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 22/23 drm/qxl: use kernel mode db
In reply to Gerd HoffmannAdd all standard modes from the kernel's video mode data base. Keep a few non-standard modes in the qxl mode list.
--- drivers/gpu/drm/qxl/qxl_display.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +7 -20
@@ -262,34 +262,20 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector)static struct mode_size {int w;int h; -} common_modes[] = { - {640 ,480 }, +} extra_modes[] = { {720 ,480 }, - {800 ,600 }, - {848 ,480 }, - {1024 ,768 }, {1152 ,768 }, - {1280 ,720 }, - {1280 ,800 }, {1280 ,854 }, - {1280 ,960 }, - {1280 ,1024 }, - {1440 ,900 }, - {1400 ,1050 }, - {1680 ,1050 }, - {1600 ,1200 }, - {1920 ,1080 }, - {1920 ,1200 } }; -static int qxl_add_common_modes (struct drm_connector *connector) +static int qxl_add_extra_modes (struct drm_connector *connector) {int i, ret =0 ; -for (i =0 ; i <ARRAY_SIZE (common_modes); i++) +for (i =0 ; i <ARRAY_SIZE (extra_modes); i++) ret +=qxl_add_mode (connector, - common_modes[i].w, - common_modes[i].h, + extra_modes[i].w, + extra_modes[i].h, false);return ret; }
@@ -1010,7 +996,8 @@ static int qxl_conn_get_modes(struct drm_connector *connector) pheight = head->height; } - ret +=qxl_add_common_modes (connector); + ret +=drm_add_modes_noedid (connector,8192 ,8192 ); + ret +=qxl_add_extra_modes (connector); ret +=qxl_add_monitors_config_modes (connector);drm_set_preferred_mode (connector, pwidth, pheight);return ret;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 22/23 drm/qxl: use kernel mode db
In reply to Gerd HoffmannAdd all standard modes from the kernel's video mode data base. Keep a few non-standard modes in the qxl mode list.
--- drivers/gpu/drm/qxl/qxl_display.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +7 -20
@@ -262,34 +262,20 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector)static struct mode_size {int w;int h; -} common_modes[] = { - {640 ,480 }, +} extra_modes[] = { {720 ,480 }, - {800 ,600 }, - {848 ,480 }, - {1024 ,768 }, {1152 ,768 }, - {1280 ,720 }, - {1280 ,800 }, {1280 ,854 }, - {1280 ,960 }, - {1280 ,1024 }, - {1440 ,900 }, - {1400 ,1050 }, - {1680 ,1050 }, - {1600 ,1200 }, - {1920 ,1080 }, - {1920 ,1200 } }; -static int qxl_add_common_modes (struct drm_connector *connector) +static int qxl_add_extra_modes (struct drm_connector *connector) {int i, ret =0 ; -for (i =0 ; i <ARRAY_SIZE (common_modes); i++) +for (i =0 ; i <ARRAY_SIZE (extra_modes); i++) ret +=qxl_add_mode (connector, - common_modes[i].w, - common_modes[i].h, + extra_modes[i].w, + extra_modes[i].h, false);return ret; }
@@ -1010,7 +996,8 @@ static int qxl_conn_get_modes(struct drm_connector *connector) pheight = head->height; } - ret +=qxl_add_common_modes (connector); + ret +=drm_add_modes_noedid (connector,8192 ,8192 ); + ret +=qxl_add_extra_modes (connector); ret +=qxl_add_monitors_config_modes (connector);drm_set_preferred_mode (connector, pwidth, pheight);return ret;
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 23/23 drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_dumb.c +6 -4
@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );switch (args->bpp) {case 16 :
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerPATCH v3 23/23 drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Gerd Hoffmann--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/qxl/qxl_dumb.c +6 -4
@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );switch (args->bpp) {case 16 :
Signature · 1 line
2.9.3
Gerd Hoffmann
maintainerv3 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.
v3 changes:
- rebased.
- added mode list patches, qxl uses kernel mode database now.
cheers,
Gerd
Frediano Ziglio (1):
drm/qxl: change the way slot is detected
Gerd Hoffmann (22):
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
drm/qxl: implement qxl_gem_prime_(un)pin
drm/qxl: add mode/framebuffer check functions
drm/qxl: add qxl_add_mode helper function
drm/qxl: use kernel mode db
drm/qxl: add overflow checks to qxl_mode_dumb_create()
drivers/gpu/drm/qxl/qxl_drv.h | 64 +++----- drivers/gpu/drm/qxl/qxl_cmd.c | 34 ++-- drivers/gpu/drm/qxl/qxl_display.c | 325 ++++++++++++++++++++++---------------- drivers/gpu/drm/qxl/qxl_draw.c | 241 +--------------------------- drivers/gpu/drm/qxl/qxl_drv.c | 2 + drivers/gpu/drm/qxl/qxl_dumb.c | 12 +- 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 | 25 ++- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +- drivers/gpu/drm/qxl/Makefile | 2 +- 12 files changed, 306 insertions(+), 802 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
Re: [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Gerd HoffmannQuoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>
We already do all reasonable overflow checks in drm_mode_create_dumb(). If you don't trust them I think would be better time spent typing an igt to test this than adding redundant check in all drivers.
You're also missing one check for bpp underflows :-) -Daniel
Quoted 29 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/qxl/qxl_dumb.c +6
-4@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );switch (args->bpp) {case 16 :Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Gerd HoffmannQuoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>
We already do all reasonable overflow checks in drm_mode_create_dumb(). If you don't trust them I think would be better time spent typing an igt to test this than adding redundant check in all drivers.
You're also missing one check for bpp underflows :-) -Daniel
Quoted 29 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/qxl/qxl_dumb.c +6
-4@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );switch (args->bpp) {case 16 :Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Daniel VetterQuoted 8 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>We already do all reasonable overflow checks in
drm_mode_create_dumb(). If you don't trust them I think would be better time spent typing an igt to test this than adding redundant check in all drivers.You're also missing one check for bpp underflows :-)
BTW I just noticed that we don't seem to validating create_dumb->flags at all. Someone should probably add some checks for that, or mark it as deprecated in case we already lost the battle with userspace stack garbage.
Quoted 40 lines
-Daniel
Quoted 29 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/qxl/qxl_dumb.c +6
-4@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );switch (args->bpp) {case 16 :Signature · 1 line
2.9.3Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Daniel VetterQuoted 8 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>We already do all reasonable overflow checks in
drm_mode_create_dumb(). If you don't trust them I think would be better time spent typing an igt to test this than adding redundant check in all drivers.You're also missing one check for bpp underflows :-)
BTW I just noticed that we don't seem to validating create_dumb->flags at all. Someone should probably add some checks for that, or mark it as deprecated in case we already lost the battle with userspace stack garbage.
Quoted 40 lines
-Daniel
Quoted 29 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/qxl/qxl_dumb.c +6
-4@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );switch (args->bpp) {case 16 :Signature · 1 line
2.9.3Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä Intel
Re: [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Ville SyrjäläQuoted 9 lines · Ville Syrjälä
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>We already do all reasonable overflow checks in
drm_mode_create_dumb(). If you don't trust them I think would be better time spent typing an igt to test this than adding redundant check in all drivers.
Quoted 6 lines
Quoted 1 line
You're also missing one check for bpp underflows :-)
BTW I just noticed that we don't seem to validating
create_dumb->flagsat all. Someone should probably add some checks for that, or mark it as deprecated in case we already lost the battle with userspace stack garbage.
Given that every kms client/compositor under the sun uses this (or well, all the generic ones at least) I think we can safely assume to have lost that battle :-/
-Daniel
Quoted 49 lines
Quoted 27 lines
-Daniel
Quoted 24 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/qxl/qxl_dumb.c +6
-4@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );Quoted 14 lines
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_dumb.c +0
-1switch (args->bpp) {case 16 : --2.9.3
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create()
In reply to Ville SyrjäläQuoted 9 lines · Ville Syrjälä
Quoted 7 lines · Daniel Vetter
Quoted 1 line · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>We already do all reasonable overflow checks in
drm_mode_create_dumb(). If you don't trust them I think would be better time spent typing an igt to test this than adding redundant check in all drivers.
Quoted 6 lines
Quoted 1 line
You're also missing one check for bpp underflows :-)
BTW I just noticed that we don't seem to validating
create_dumb->flagsat all. Someone should probably add some checks for that, or mark it as deprecated in case we already lost the battle with userspace stack garbage.
Given that every kms client/compositor under the sun uses this (or well, all the generic ones at least) I think we can safely assume to have lost that battle :-/
-Daniel
Quoted 49 lines
Quoted 27 lines
-Daniel
Quoted 24 lines
--- drivers/gpu/drm/qxl/qxl_dumb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/qxl/qxl_dumb.c +6
-4@@ -37,11 +37,13 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,uint32_t handle;int r;struct qxl_surface surf; -uint32_t pitch, format; +uint32_t pitch, size, format; - pitch = args->width * ((args->bpp +1 ) /8 ); - args->size = pitch * args->height; - args->size =ALIGN (args->size,PAGE_SIZE ); +if (check_mul_overflow (args->width, ((args->bpp +1 ) /8 ), &pitch)) +return -EINVAL ; +if (check_mul_overflow (pitch, args->height, &size)) +return -EINVAL ; + args->size =ALIGN (size,PAGE_SIZE );Quoted 14 lines
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_dumb.c +0
-1switch (args->bpp) {case 16 : --2.9.3
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 01/23] drm/qxl: drop ttm_mem_reg arg from qxl_hw_surface_alloc()
In reply to Gerd HoffmannDen 18.01.2019 13.19, skrev Gerd Hoffmann:
Quoted 4 lines
Not used, is always NULL.
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 01/23] drm/qxl: drop ttm_mem_reg arg from qxl_hw_surface_alloc()
In reply to Gerd HoffmannDen 18.01.2019 13.19, skrev Gerd Hoffmann:
Quoted 4 lines
Not used, is always NULL.
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 02/23] drm/qxl: drop unused qxl_fb_virtual_address
In reply to Gerd HoffmannDen 18.01.2019 13.19, skrev Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 02/23] drm/qxl: drop unused qxl_fb_virtual_address
In reply to Gerd HoffmannDen 18.01.2019 13.19, skrev Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 03/23] drm/qxl: simplify slot management
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
Drop pointless indirection, remove the
mem_slotsarray and index variables, drop dynamic allocation. Store memslots inqxl_deviceinstead.Signed-off-by Gerd Hoffmann <[email protected]>---
Looks sane:
Re: [PATCH v3 03/23] drm/qxl: simplify slot management
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
Drop pointless indirection, remove the
mem_slotsarray and index variables, drop dynamic allocation. Store memslots inqxl_deviceinstead.Signed-off-by Gerd Hoffmann <[email protected]>---
Looks sane:
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 04/23] drm/qxl: change the way slot is detected
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
From: 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.
Quoted 6 lines
Signed-off-by Frediano Ziglio <[email protected]>[ kraxel: rebased, adapted to upstream changes ]
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 04/23] drm/qxl: change the way slot is detected
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
From: 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.
Quoted 6 lines
Signed-off-by Frediano Ziglio <[email protected]>[ kraxel: rebased, adapted to upstream changes ]
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 05/23] drm/qxl: drop unused fields from struct qxl_device
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 5 lines
slot_id_bitsandslot_gen_bitscan be read directly from qxlrom instead.va_slot_maskis never used anywhere.Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 05/23] drm/qxl: drop unused fields from struct qxl_device
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 5 lines
slot_id_bitsandslot_gen_bitscan be read directly from qxlrom instead.va_slot_maskis never used anywhere.Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 06/23] drm/qxl: use separate offset spaces for the two slots / ttm memory types.
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 8 lines
Without 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.
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 06/23] drm/qxl: use separate offset spaces for the two slots / ttm memory types.
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 8 lines
Without 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.
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 07/23] drm/qxl: allow both PRIV and VRAM placement for QXL_GEM_DOMAIN_SURFACE
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
qxl 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.
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 07/23] drm/qxl: allow both PRIV and VRAM placement for QXL_GEM_DOMAIN_SURFACE
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
qxl 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.
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 08/23] drm/qxl: use QXL_GEM_DOMAIN_SURFACE for shadow bo.
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
The 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.Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 08/23] drm/qxl: use QXL_GEM_DOMAIN_SURFACE for shadow bo.
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
The 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.Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 09/23] drm/qxl: use QXL_GEM_DOMAIN_SURFACE for dumb gem objects
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
dumb 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.Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 09/23] drm/qxl: use QXL_GEM_DOMAIN_SURFACE for dumb gem objects
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 6 lines
dumb 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.Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 31 lines
The cursor must be set again after creating the primary surface. Also drop the error message.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_display.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/gpu/drm/qxl/qxl_display.c +0
-6@@ -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" ); }
drivers/gpu/drm/qxl/qxl_display.c static void qxl_primary_atomic_update(struct drm_plane *plane, · line 565
Quoted 10 lines
drivers/gpu/drm/qxl/qxl_display.c +3
-1if (!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; }
I don't see how the commit message matches what you're doing. It gives the impression that it must be applied under yet another condition, but the condition for applying the cursor is changed from bo_old->is_primary to !bo->is_primary.
It probably makes sense to someone that knows the driver.
Re: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 31 lines
The cursor must be set again after creating the primary surface. Also drop the error message.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_display.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/gpu/drm/qxl/qxl_display.c +0
-6@@ -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" ); }
drivers/gpu/drm/qxl/qxl_display.c static void qxl_primary_atomic_update(struct drm_plane *plane, · line 565
Quoted 10 lines
drivers/gpu/drm/qxl/qxl_display.c +3
-1if (!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; }
I don't see how the commit message matches what you're doing. It gives the impression that it must be applied under yet another condition, but the condition for applying the cursor is changed from bo_old->is_primary to !bo->is_primary.
It probably makes sense to someone that knows the driver.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 11/23] drm/qxl: drop unused offset parameter from qxl_io_create_primary()
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 11/23] drm/qxl: drop unused offset parameter from qxl_io_create_primary()
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 12/23] drm/qxl: track primary bo
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 9 lines
Track which bo is used as primary surface. With that in place we don't need the
primary_createdflag 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().Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 12/23] drm/qxl: track primary bo
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 9 lines
Track which bo is used as primary surface. With that in place we don't need the
primary_createdflag 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().Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 13/23] drm/qxl: use shadow bo directly
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 5 lines
Pass the shadow bo to
qxl_io_create_primary()instead of expectingqxl_io_create_primaryto checkbo->shadow. Setis_primaryflag on the shadow bo. Move theis_primarytracking intoqxl_io_create_primary()andqxl_io_destroy_primary()functions.
Quoted 7 lines
That simplifies primary surface tracking and the workflow in
qxl_primary_atomic_update().Signed-off-by Gerd Hoffmann <[email protected]>qxl_io_create/destroy_primary:
primary_botracking [fixup]
---
I'm unable to follow the logic, but I didn't spot anything suspicious looking.
Re: [PATCH v3 13/23] drm/qxl: use shadow bo directly
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 5 lines
Pass the shadow bo to
qxl_io_create_primary()instead of expectingqxl_io_create_primaryto checkbo->shadow. Setis_primaryflag on the shadow bo. Move theis_primarytracking intoqxl_io_create_primary()andqxl_io_destroy_primary()functions.
Quoted 7 lines
That simplifies primary surface tracking and the workflow in
qxl_primary_atomic_update().Signed-off-by Gerd Hoffmann <[email protected]>qxl_io_create/destroy_primary:
primary_botracking [fixup]
---
I'm unable to follow the logic, but I didn't spot anything suspicious looking.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 14/23] drm/qxl: cover all crtcs in shadow bo.
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 231 lines
The 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.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.h | 5 +- drivers/gpu/drm/qxl/qxl_display.c | 119 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 9 ++- 3 files changed, 104 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 +91
-26@@ -323,6 +323,8 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc, head.y = crtc->y;if (qdev->monitors_config->count < i +1 ) qdev->monitors_config->count = i +1 ; +if (qdev->primary_bo == qdev->dumb_shadow_bo) + head.x += qdev->dumb_heads[i].x; }else if (i >0 ) { head.width =0 ; head.height =0 ;@@ -426,7 +428,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb, }qxl_draw_dirty_fb (qdev, fb, qobj, flags, color, - clips, num_clips, inc); + clips, num_clips, inc,0 );drm_modeset_unlock_all (fb->dev);@@ -535,6 +537,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, .x2 = plane->state->fb->width, .y2 = plane->state->fb->height }; +uint32_t dumb_shadow_offset =0 ;if (old_state->fb) { bo_old =gem_to_qxl_bo (old_state->fb->obj[0 ]);@@ -551,7 +554,12 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,qxl_primary_apply_cursor (plane); } -qxl_draw_dirty_fb (qdev, plane->state->fb, bo,0 ,0 , &norect,1 ,1 ); +if (bo->is_dumb) + dumb_shadow_offset = + qdev->dumb_heads[plane->state->crtc->index].x; + +qxl_draw_dirty_fb (qdev, plane->state->fb, bo,0 ,0 , &norect,1 ,1 , + dumb_shadow_offset); } static void qxl_primary_atomic_disable(struct drm_plane *plane,@@ -707,12 +715,68 @@ static void qxl_cursor_atomic_disable(struct drm_plane *plane,qxl_release_fence_buffer_objects (release); } +static void qxl_update_dumb_head (struct qxl_device *qdev, +int index,struct qxl_bo *bo) +{ +uint32_t width, height; + +if (index >= qdev->monitors_config->max_allowed) +return ; + +if (bo && bo->is_dumb) { + width = bo->surf.width; + height = bo->surf.height; + }else { + width =0 ; + height =0 ; + } + +if (qdev->dumb_heads[index].width == width && + qdev->dumb_heads[index].height == height) +return ; + +DRM_DEBUG ("#%d: %dx%d -> %dx%d\n" , index, + qdev->dumb_heads[index].width, + qdev->dumb_heads[index].height, + width, height); + qdev->dumb_heads[index].width = width; + qdev->dumb_heads[index].height = height; +} + +static void qxl_calc_dumb_shadow (struct qxl_device *qdev, +struct qxl_surface *surf) +{ +struct qxl_head *head; +int i; + +memset (surf,0 ,sizeof (*surf)); +for (i =0 ; i < qdev->monitors_config->max_allowed; i++) { + head = qdev->dumb_heads + i; + head->x = surf->width; + surf->width += head->width; +if (surf->height < head->height) + surf->height = head->height; + } +if (surf->width <64 ) + surf->width =64 ; +if (surf->height <64 ) + surf->height =64 ; + surf->format = SPICE_SURFACE_FMT_32_xRGB; + surf->stride = surf->width *4 ; + +if (!qdev->dumb_shadow_bo || + qdev->dumb_shadow_bo->surf.width != surf->width || + qdev->dumb_shadow_bo->surf.height != surf->height) +DRM_DEBUG ("%dx%d\n" , surf->width, surf->height); +} +static int qxl_plane_prepare_fb (struct drm_plane *plane,struct drm_plane_state *new_state) {struct qxl_device *qdev = plane->dev->dev_private;struct drm_gem_object *obj; -struct qxl_bo *user_bo, *old_bo =NULL ; +struct qxl_bo *user_bo; +struct qxl_surface surf;int ret;if (!new_state->fb)@@ -722,29 +786,30 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane, user_bo =gem_to_qxl_bo (obj);if (plane->type ==DRM_PLANE_TYPE_PRIMARY && - user_bo->is_dumb && !user_bo->shadow) { -if (plane->state->fb) { - obj = plane->state->fb->obj[0 ]; - old_bo =gem_to_qxl_bo (obj); + user_bo->is_dumb) { +qxl_update_dumb_head (qdev, new_state->crtc->index, + user_bo); +qxl_calc_dumb_shadow (qdev, &surf); +if (!qdev->dumb_shadow_bo || + qdev->dumb_shadow_bo->surf.width != surf.width || + qdev->dumb_shadow_bo->surf.height != surf.height) { +if (qdev->dumb_shadow_bo) { +drm_gem_object_put_unlocked + (&qdev->dumb_shadow_bo->gem_base); + qdev->dumb_shadow_bo =NULL ; + } +qxl_bo_create (qdev, surf.height * surf.stride, + true, true,QXL_GEM_DOMAIN_SURFACE , &surf, + &qdev->dumb_shadow_bo); } -if (old_bo && old_bo->shadow && - user_bo->gem_base.size == old_bo->gem_base.size && - plane->state->crtc == new_state->crtc && - plane->state->crtc_w == new_state->crtc_w && - plane->state->crtc_h == new_state->crtc_h && - plane->state->src_x == new_state->src_x && - plane->state->src_y == new_state->src_y && - plane->state->src_w == new_state->src_w && - plane->state->src_h == new_state->src_h && - plane->state->rotation == new_state->rotation && - plane->state->zpos == new_state->zpos) { -drm_gem_object_get (&old_bo->shadow->gem_base); - user_bo->shadow = old_bo->shadow; - }else { -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; +if (user_bo->shadow != qdev->dumb_shadow_bo) { +if (user_bo->shadow) { +drm_gem_object_put_unlocked + (&user_bo->shadow->gem_base); + user_bo->shadow =NULL ; + } +drm_gem_object_get (&qdev->dumb_shadow_bo->gem_base); + user_bo->shadow = qdev->dumb_shadow_bo; } }@@ -773,7 +838,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->shadow->is_primary) { +if (old_state->fb != plane->state->fb && user_bo->shadow) {drm_gem_object_put_unlocked (&user_bo->shadow->gem_base); user_bo->shadow =NULL ; }
drivers/gpu/drm/qxl/qxl_display.c int qxl_create_monitors_object(struct qxl_device *qdev) · line 1175
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_display.c +2
-0@@ -1106,6 +1171,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev)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 );
Needs an allocation failure check. With that:
Quoted 29 lines
drivers/gpu/drm/qxl/qxl_display.c +0
-0return 0 ; }drivers/gpu/drm/qxl/qxl_draw.c +5
-1@@ -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;
drivers/gpu/drm/qxl/qxl_draw.c void qxl_draw_dirty_fb(struct qxl_device *qdev, · line 353
Quoted 9 lines
drivers/gpu/drm/qxl/qxl_draw.c +2
-1@@ -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;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 14/23] drm/qxl: cover all crtcs in shadow bo.
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 231 lines
The 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.
Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/qxl/qxl_drv.h | 5 +- drivers/gpu/drm/qxl/qxl_display.c | 119 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/qxl/qxl_draw.c | 9 ++- 3 files changed, 104 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 +91
-26@@ -323,6 +323,8 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc, head.y = crtc->y;if (qdev->monitors_config->count < i +1 ) qdev->monitors_config->count = i +1 ; +if (qdev->primary_bo == qdev->dumb_shadow_bo) + head.x += qdev->dumb_heads[i].x; }else if (i >0 ) { head.width =0 ; head.height =0 ;@@ -426,7 +428,7 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb, }qxl_draw_dirty_fb (qdev, fb, qobj, flags, color, - clips, num_clips, inc); + clips, num_clips, inc,0 );drm_modeset_unlock_all (fb->dev);@@ -535,6 +537,7 @@ static void qxl_primary_atomic_update(struct drm_plane *plane, .x2 = plane->state->fb->width, .y2 = plane->state->fb->height }; +uint32_t dumb_shadow_offset =0 ;if (old_state->fb) { bo_old =gem_to_qxl_bo (old_state->fb->obj[0 ]);@@ -551,7 +554,12 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,qxl_primary_apply_cursor (plane); } -qxl_draw_dirty_fb (qdev, plane->state->fb, bo,0 ,0 , &norect,1 ,1 ); +if (bo->is_dumb) + dumb_shadow_offset = + qdev->dumb_heads[plane->state->crtc->index].x; + +qxl_draw_dirty_fb (qdev, plane->state->fb, bo,0 ,0 , &norect,1 ,1 , + dumb_shadow_offset); } static void qxl_primary_atomic_disable(struct drm_plane *plane,@@ -707,12 +715,68 @@ static void qxl_cursor_atomic_disable(struct drm_plane *plane,qxl_release_fence_buffer_objects (release); } +static void qxl_update_dumb_head (struct qxl_device *qdev, +int index,struct qxl_bo *bo) +{ +uint32_t width, height; + +if (index >= qdev->monitors_config->max_allowed) +return ; + +if (bo && bo->is_dumb) { + width = bo->surf.width; + height = bo->surf.height; + }else { + width =0 ; + height =0 ; + } + +if (qdev->dumb_heads[index].width == width && + qdev->dumb_heads[index].height == height) +return ; + +DRM_DEBUG ("#%d: %dx%d -> %dx%d\n" , index, + qdev->dumb_heads[index].width, + qdev->dumb_heads[index].height, + width, height); + qdev->dumb_heads[index].width = width; + qdev->dumb_heads[index].height = height; +} + +static void qxl_calc_dumb_shadow (struct qxl_device *qdev, +struct qxl_surface *surf) +{ +struct qxl_head *head; +int i; + +memset (surf,0 ,sizeof (*surf)); +for (i =0 ; i < qdev->monitors_config->max_allowed; i++) { + head = qdev->dumb_heads + i; + head->x = surf->width; + surf->width += head->width; +if (surf->height < head->height) + surf->height = head->height; + } +if (surf->width <64 ) + surf->width =64 ; +if (surf->height <64 ) + surf->height =64 ; + surf->format = SPICE_SURFACE_FMT_32_xRGB; + surf->stride = surf->width *4 ; + +if (!qdev->dumb_shadow_bo || + qdev->dumb_shadow_bo->surf.width != surf->width || + qdev->dumb_shadow_bo->surf.height != surf->height) +DRM_DEBUG ("%dx%d\n" , surf->width, surf->height); +} +static int qxl_plane_prepare_fb (struct drm_plane *plane,struct drm_plane_state *new_state) {struct qxl_device *qdev = plane->dev->dev_private;struct drm_gem_object *obj; -struct qxl_bo *user_bo, *old_bo =NULL ; +struct qxl_bo *user_bo; +struct qxl_surface surf;int ret;if (!new_state->fb)@@ -722,29 +786,30 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane, user_bo =gem_to_qxl_bo (obj);if (plane->type ==DRM_PLANE_TYPE_PRIMARY && - user_bo->is_dumb && !user_bo->shadow) { -if (plane->state->fb) { - obj = plane->state->fb->obj[0 ]; - old_bo =gem_to_qxl_bo (obj); + user_bo->is_dumb) { +qxl_update_dumb_head (qdev, new_state->crtc->index, + user_bo); +qxl_calc_dumb_shadow (qdev, &surf); +if (!qdev->dumb_shadow_bo || + qdev->dumb_shadow_bo->surf.width != surf.width || + qdev->dumb_shadow_bo->surf.height != surf.height) { +if (qdev->dumb_shadow_bo) { +drm_gem_object_put_unlocked + (&qdev->dumb_shadow_bo->gem_base); + qdev->dumb_shadow_bo =NULL ; + } +qxl_bo_create (qdev, surf.height * surf.stride, + true, true,QXL_GEM_DOMAIN_SURFACE , &surf, + &qdev->dumb_shadow_bo); } -if (old_bo && old_bo->shadow && - user_bo->gem_base.size == old_bo->gem_base.size && - plane->state->crtc == new_state->crtc && - plane->state->crtc_w == new_state->crtc_w && - plane->state->crtc_h == new_state->crtc_h && - plane->state->src_x == new_state->src_x && - plane->state->src_y == new_state->src_y && - plane->state->src_w == new_state->src_w && - plane->state->src_h == new_state->src_h && - plane->state->rotation == new_state->rotation && - plane->state->zpos == new_state->zpos) { -drm_gem_object_get (&old_bo->shadow->gem_base); - user_bo->shadow = old_bo->shadow; - }else { -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; +if (user_bo->shadow != qdev->dumb_shadow_bo) { +if (user_bo->shadow) { +drm_gem_object_put_unlocked + (&user_bo->shadow->gem_base); + user_bo->shadow =NULL ; + } +drm_gem_object_get (&qdev->dumb_shadow_bo->gem_base); + user_bo->shadow = qdev->dumb_shadow_bo; } }@@ -773,7 +838,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->shadow->is_primary) { +if (old_state->fb != plane->state->fb && user_bo->shadow) {drm_gem_object_put_unlocked (&user_bo->shadow->gem_base); user_bo->shadow =NULL ; }
drivers/gpu/drm/qxl/qxl_display.c int qxl_create_monitors_object(struct qxl_device *qdev) · line 1175
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_display.c +2
-0@@ -1106,6 +1171,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev)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 );
Needs an allocation failure check. With that:
Quoted 29 lines
drivers/gpu/drm/qxl/qxl_display.c +0
-0return 0 ; }drivers/gpu/drm/qxl/qxl_draw.c +5
-1@@ -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;
drivers/gpu/drm/qxl/qxl_draw.c void qxl_draw_dirty_fb(struct qxl_device *qdev, · line 353
Quoted 9 lines
drivers/gpu/drm/qxl/qxl_draw.c +2
-1@@ -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;
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 15/23] drm/qxl: use qxl_num_crtc directly
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 9 lines
qdev->monitors_config->max_allowedis effectively set by the qxl.num_heads module parameter, stored in theqxl_num_crtcvariable. Lets get rid of the indirection and use the variableqxl_num_crtcdirectly. 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 whyqdev->monitors_config->max_allowedis set.Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 15/23] drm/qxl: use qxl_num_crtc directly
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 9 lines
qdev->monitors_config->max_allowedis effectively set by the qxl.num_heads module parameter, stored in theqxl_num_crtcvariable. Lets get rid of the indirection and use the variableqxl_num_crtcdirectly. 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 whyqdev->monitors_config->max_allowedis set.Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 16/23] drm/qxl: implement prime kmap/kunmap
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
Generic 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.
Signed-off-by Gerd Hoffmann <[email protected]>---
Just a note: You catch the one-to-many kmap type of unbalance, but not the one-too-many kunmap situation.
Quoted 95 lines
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,
Re: [PATCH v3 16/23] drm/qxl: implement prime kmap/kunmap
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
Generic 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.
Signed-off-by Gerd Hoffmann <[email protected]>---
Just a note: You catch the one-to-many kmap type of unbalance, but not the one-too-many kunmap situation.
Quoted 85 lines
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 +10
-3@@ -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; }
drivers/gpu/drm/qxl/qxl_prime.c struct drm_gem_object *qxl_gem_prime_import_sg_table( · line 75
Quoted 10 lines
drivers/gpu/drm/qxl/qxl_prime.c +3
-1void 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,
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 17/23] drm/qxl: use generic fbdev emulation
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 36 lines
Switch qxl over to the new generic fbdev emulation.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -1221,18 +1221,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 +0
-0
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 96
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-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" );
I couldn't find that this was part of old fbdev code, so it would be nice to mention it in the commit message.
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 100
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0+drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ; modeset_cleanup:
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 17/23] drm/qxl: use generic fbdev emulation
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 36 lines
Switch qxl over to the new generic fbdev emulation.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -1221,18 +1221,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 +0
-0
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 96
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-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" );
I couldn't find that this was part of old fbdev code, so it would be nice to mention it in the commit message.
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 100
Quoted 5 lines
drivers/gpu/drm/qxl/qxl_drv.c +1
-0+drm_fbdev_generic_setup (&qdev->ddev,32 );return 0 ; modeset_cleanup:
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
Lovely 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 -----------------------------------------------------
Quoted 9 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- 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
Nice!
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
Lovely 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 -----------------------------------------------------
Quoted 9 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- 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
Nice!
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 19/23] drm/qxl: implement qxl_gem_prime_(un)pin
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 19/23] drm/qxl: implement qxl_gem_prime_(un)pin
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 2 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 20/23] drm/qxl: add mode/framebuffer check functions
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
Add a helper functions to check video modes. Also add a helper to check framebuffer buffer objects, using the former for consistency. That way we should not fail in
qxl_primary_atomic_check()because video modes which are too big will not be added to the mode list in the first place.Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 20/23] drm/qxl: add mode/framebuffer check functions
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 7 lines
Add a helper functions to check video modes. Also add a helper to check framebuffer buffer objects, using the former for consistency. That way we should not fail in
qxl_primary_atomic_check()because video modes which are too big will not be added to the mode list in the first place.Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 21/23] drm/qxl: add qxl_add_mode helper function
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 4 lines
Add a helper function to add custom video modes to a connector.
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 21/23] drm/qxl: add qxl_add_mode helper function
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 4 lines
Add a helper function to add custom video modes to a connector.
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 22/23] drm/qxl: use kernel mode db
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 5 lines
Add all standard modes from the kernel's video mode data base. Keep a few non-standard modes in the qxl mode list.
Signed-off-by Gerd Hoffmann <[email protected]>---
Re: [PATCH v3 22/23] drm/qxl: use kernel mode db
In reply to Gerd HoffmannDen 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 5 lines
Add all standard modes from the kernel's video mode data base. Keep a few non-standard modes in the qxl mode list.
Signed-off-by Gerd Hoffmann <[email protected]>---
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code
In reply to Noralf TrønnesHi Noralf.
Quoted 17 lines
Quoted 7 lines
Lovely 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 -----------------------------------------------------Quoted 9 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- 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
Quoted 3 lines
Nice!
Acked-by Noralf Trønnes <[email protected]>
It must be a very satisfying experience to see such benefits of the many hours of works you have put into the genric fbdev emulation code.
Well done, and indeed a nice patch from Gerd.
Sam
_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code
In reply to Noralf TrønnesHi Noralf.
Quoted 17 lines
Quoted 7 lines
Lovely 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 -----------------------------------------------------Quoted 9 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- 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
Quoted 3 lines
Nice!
Acked-by Noralf Trønnes <[email protected]>
It must be a very satisfying experience to see such benefits of the many hours of works you have put into the genric fbdev emulation code.
Well done, and indeed a nice patch from Gerd.
Sam
Re: [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code
In reply to Sam RavnborgDen 25.01.2019 19.10, skrev Sam Ravnborg:
Quoted 19 lines
Hi Noralf.
Quoted 17 lines
Quoted 16 lines
Lovely 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 -----------------------------------------------------Signed-off-by Gerd Hoffmann <[email protected]>--- 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
Quoted 6 lines
Quoted 3 lines
Nice!
Acked-by Noralf Trønnes <[email protected]>It must be a very satisfying experience to see such benefits of the many hours of works you have put into the genric fbdev emulation code.
Indeed and having more users of the code increases the chance of detecting any bugs lurking underneath the surface.
Quoted 4 lines
Well done, and indeed a nice patch from Gerd.
Sam
Re: [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code
In reply to Sam RavnborgDen 25.01.2019 19.10, skrev Sam Ravnborg:
Quoted 19 lines
Hi Noralf.
Quoted 17 lines
Quoted 16 lines
Lovely 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 -----------------------------------------------------Signed-off-by Gerd Hoffmann <[email protected]>--- 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
Quoted 6 lines
Quoted 3 lines
Nice!
Acked-by Noralf Trønnes <[email protected]>It must be a very satisfying experience to see such benefits of the many hours of works you have put into the genric fbdev emulation code.
Indeed and having more users of the code increases the chance of detecting any bugs lurking underneath the surface.
Quoted 4 lines
Well done, and indeed a nice patch from Gerd.
Sam
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Gerd Hoffmann
maintainerRe: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Noralf TrønnesQuoted 18 lines
drivers/gpu/drm/qxl/qxl_display.c static void qxl_primary_atomic_update(struct drm_plane *plane, · line 564
Quoted 13 lines
The cursor must be set again after creating the primary surface. Also drop the error message.
drivers/gpu/drm/qxl/qxl_display.c +3
-1if (!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; }I don't see how the commit message matches what you're doing. It gives the impression that it must be applied under yet another condition, but the condition for applying the cursor is changed from
bo_old->is_primaryto !bo->is_primary.
The qxl device ties the cursor to the primary surface. Therefore calling qxl_io_destroy_primary() and qxl_io_create_primary() to switch the framebuffer causes the cursor information being lost and the driver must re-apply it.
The correct call order to do that is qxl_io_destroy_primary() + qxl_io_create_primary() + qxl_primary_apply_cursor().
The old code did qxl_io_destroy_primary() + qxl_primary_apply_cursor() + qxl_io_create_primary(). Due to qxl_primary_apply_cursor request being queued in a ringbuffer and qxl_io_create_primary() trapping to the hypervisor instantly there is a high chance that qxl_io_create_primary() is processed first even with the wrong call order. But it's racy and thus not reliable.
Quoted 1 line
It probably makes sense to someone that knows the driver.
If the above explains things better to you I should probably replace the commit message with that.
Quoted 1 line
Acked-by Noralf Trønnes <[email protected]>
thanks,
Gerd
Gerd Hoffmann
maintainerRe: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Noralf TrønnesQuoted 18 lines
drivers/gpu/drm/qxl/qxl_display.c static void qxl_primary_atomic_update(struct drm_plane *plane, · line 564
Quoted 13 lines
The cursor must be set again after creating the primary surface. Also drop the error message.
drivers/gpu/drm/qxl/qxl_display.c +3
-1if (!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; }I don't see how the commit message matches what you're doing. It gives the impression that it must be applied under yet another condition, but the condition for applying the cursor is changed from
bo_old->is_primaryto !bo->is_primary.
The qxl device ties the cursor to the primary surface. Therefore calling qxl_io_destroy_primary() and qxl_io_create_primary() to switch the framebuffer causes the cursor information being lost and the driver must re-apply it.
The correct call order to do that is qxl_io_destroy_primary() + qxl_io_create_primary() + qxl_primary_apply_cursor().
The old code did qxl_io_destroy_primary() + qxl_primary_apply_cursor() + qxl_io_create_primary(). Due to qxl_primary_apply_cursor request being queued in a ringbuffer and qxl_io_create_primary() trapping to the hypervisor instantly there is a high chance that qxl_io_create_primary() is processed first even with the wrong call order. But it's racy and thus not reliable.
Quoted 1 line
It probably makes sense to someone that knows the driver.
If the above explains things better to you I should probably replace the commit message with that.
Quoted 1 line
Acked-by Noralf Trønnes <[email protected]>
thanks,
Gerd
Gerd Hoffmann
maintainerRe: [PATCH v3 17/23] drm/qxl: use generic fbdev emulation
In reply to Noralf TrønnesQuoted 42 lines · Noralf Trønnes
Den 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 39 lines
Switch qxl over to the new generic fbdev emulation.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -1221,18 +1221,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 +0
-0@@ -93,6 +93,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto modeset_cleanup;
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 96
Quoted 1 line
drivers/gpu/drm/qxl/qxl_drv.c +1
-0+drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" );I couldn't find that this was part of old fbdev code, so it would be nice to mention it in the commit message.
It actually is, but a bit hidden because it doesn't use a helper you can easily grep for. Instead sets fb_info->apertures->ranges[0] in qxlfb_create(), which has the same effect.
cheers,
Gerd
Gerd Hoffmann
maintainerRe: [PATCH v3 17/23] drm/qxl: use generic fbdev emulation
In reply to Noralf TrønnesQuoted 42 lines · Noralf Trønnes
Den 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 39 lines
Switch qxl over to the new generic fbdev emulation.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -1221,18 +1221,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 +0
-0@@ -93,6 +93,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto modeset_cleanup;
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 96
Quoted 1 line
drivers/gpu/drm/qxl/qxl_drv.c +1
-0+drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" );I couldn't find that this was part of old fbdev code, so it would be nice to mention it in the commit message.
It actually is, but a bit hidden because it doesn't use a helper you can easily grep for. Instead sets fb_info->apertures->ranges[0] in qxlfb_create(), which has the same effect.
cheers,
Gerd
Re: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Gerd HoffmannDen 28.01.2019 09.10, skrev Gerd Hoffmann:
Quoted 34 lines
Quoted 18 lines
drivers/gpu/drm/qxl/qxl_display.c static void qxl_primary_atomic_update(struct drm_plane *plane, · line 564
Quoted 13 lines
The cursor must be set again after creating the primary surface. Also drop the error message.
drivers/gpu/drm/qxl/qxl_display.c +3
-1if (!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; }I don't see how the commit message matches what you're doing. It gives the impression that it must be applied under yet another condition, but the condition for applying the cursor is changed from
bo_old->is_primaryto !bo->is_primary.The qxl device ties the cursor to the primary surface. Therefore calling
qxl_io_destroy_primary()andqxl_io_create_primary()to switch the framebuffer causes the cursor information being lost and the driver must re-apply it.The correct call order to do that is
qxl_io_destroy_primary()+qxl_io_create_primary()+qxl_primary_apply_cursor().The old code did
qxl_io_destroy_primary()+qxl_primary_apply_cursor()+qxl_io_create_primary(). Due toqxl_primary_apply_cursorrequest being queued in a ringbuffer andqxl_io_create_primary()trapping to the hypervisor instantly there is a high chance thatqxl_io_create_primary()is processed first even with the wrong call order. But it's racy and thus not reliable.
Quoted 5 lines
Quoted 1 line
It probably makes sense to someone that knows the driver.
If the above explains things better to you I should probably replace the commit message with that.
This is actually my first review of a driver that I'm not familiar with. I'm not quite sure how much in depth understanding that is required to put my ack on it. Going further into the patchset I realised that there's no way that I can verify the logic without being intimate with the driver. So I have tried to verify things from a kms point of view.
I liked your expanded explanation better.
Noralf.
Quoted 5 lines
Quoted 1 line
Acked-by Noralf Trønnes <[email protected]>thanks,
Gerd
_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Gerd HoffmannDen 28.01.2019 09.10, skrev Gerd Hoffmann:
Quoted 34 lines
Quoted 18 lines
drivers/gpu/drm/qxl/qxl_display.c static void qxl_primary_atomic_update(struct drm_plane *plane, · line 564
Quoted 13 lines
The cursor must be set again after creating the primary surface. Also drop the error message.
drivers/gpu/drm/qxl/qxl_display.c +3
-1if (!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; }I don't see how the commit message matches what you're doing. It gives the impression that it must be applied under yet another condition, but the condition for applying the cursor is changed from
bo_old->is_primaryto !bo->is_primary.The qxl device ties the cursor to the primary surface. Therefore calling
qxl_io_destroy_primary()andqxl_io_create_primary()to switch the framebuffer causes the cursor information being lost and the driver must re-apply it.The correct call order to do that is
qxl_io_destroy_primary()+qxl_io_create_primary()+qxl_primary_apply_cursor().The old code did
qxl_io_destroy_primary()+qxl_primary_apply_cursor()+qxl_io_create_primary(). Due toqxl_primary_apply_cursorrequest being queued in a ringbuffer andqxl_io_create_primary()trapping to the hypervisor instantly there is a high chance thatqxl_io_create_primary()is processed first even with the wrong call order. But it's racy and thus not reliable.
Quoted 5 lines
Quoted 1 line
It probably makes sense to someone that knows the driver.
If the above explains things better to you I should probably replace the commit message with that.
This is actually my first review of a driver that I'm not familiar with. I'm not quite sure how much in depth understanding that is required to put my ack on it. Going further into the patchset I realised that there's no way that I can verify the logic without being intimate with the driver. So I have tried to verify things from a kms point of view.
I liked your expanded explanation better.
Noralf.
Quoted 5 lines
Quoted 1 line
Acked-by Noralf Trønnes <[email protected]>thanks,
Gerd
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Noralf Trønnes
Acked-byRe: [PATCH v3 17/23] drm/qxl: use generic fbdev emulation
In reply to Gerd HoffmannDen 28.01.2019 09.59, skrev Gerd Hoffmann:
Quoted 43 lines · Noralf Trønnes
Quoted 42 lines
Den 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 39 lines
Switch qxl over to the new generic fbdev emulation.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -1221,18 +1221,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 +0
-0@@ -93,6 +93,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto modeset_cleanup;
Quoted 9 lines
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 96
Quoted 1 line
drivers/gpu/drm/qxl/qxl_drv.c +1
-0+drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" );I couldn't find that this was part of old fbdev code, so it would be nice to mention it in the commit message.
It actually is, but a bit hidden because it doesn't use a helper you can easily grep for. Instead sets fb_info->apertures->ranges[0] in
qxlfb_create(), which has the same effect.
Indeed,
Noralf Trønnes
Acked-byRe: [PATCH v3 17/23] drm/qxl: use generic fbdev emulation
In reply to Gerd HoffmannDen 28.01.2019 09.59, skrev Gerd Hoffmann:
Quoted 43 lines · Noralf Trønnes
Quoted 42 lines
Den 18.01.2019 13.20, skrev Gerd Hoffmann:
Quoted 39 lines
Switch qxl over to the new generic fbdev emulation.
Signed-off-by Gerd Hoffmann <[email protected]>--- 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@@ -1221,18 +1221,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 +0
-0@@ -93,6 +93,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret) goto modeset_cleanup;
Quoted 9 lines
Quoted 4 lines
drivers/gpu/drm/qxl/qxl_drv.c qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 96
Quoted 1 line
drivers/gpu/drm/qxl/qxl_drv.c +1
-0+drm_fb_helper_remove_conflicting_pci_framebuffers (pdev,0 ,"qxl" );I couldn't find that this was part of old fbdev code, so it would be nice to mention it in the commit message.
It actually is, but a bit hidden because it doesn't use a helper you can easily grep for. Instead sets fb_info->apertures->ranges[0] in
qxlfb_create(), which has the same effect.
Indeed,
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Gerd Hoffmann
maintainerRe: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Noralf TrønnesHi,
Quoted 6 lines
Quoted 2 lines
If the above explains things better to you I should probably replace the commit message with that.
This is actually my first review of a driver that I'm not familiar with. I'm not quite sure how much in depth understanding that is required to put my ack on it.
Usually I try to show that by picking either Reviewed-by (I'm confident the changes are fine) or Acked-by (Changes look sane, but I don't know the code base and/or hardware good enough to be sure).
Quoted 3 lines
Going further into the patchset I realised that
there's no way that I can verify the logic without being intimate with the driver.
Yep. Same for me when looking at patches for other drivers. I think this is one reason why it isn't that easy to get patches for drivers reviewed where effectively only a single maintainer/developer is working on.
Quoted 1 line
I liked your expanded explanation better.
Updated the commit message.
cheers,
Gerd
Gerd Hoffmann
maintainerRe: [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place
In reply to Noralf TrønnesHi,
Quoted 6 lines
Quoted 2 lines
If the above explains things better to you I should probably replace the commit message with that.
This is actually my first review of a driver that I'm not familiar with. I'm not quite sure how much in depth understanding that is required to put my ack on it.
Usually I try to show that by picking either Reviewed-by (I'm confident the changes are fine) or Acked-by (Changes look sane, but I don't know the code base and/or hardware good enough to be sure).
Quoted 3 lines
Going further into the patchset I realised that
there's no way that I can verify the logic without being intimate with the driver.
Yep. Same for me when looking at patches for other drivers. I think this is one reason why it isn't that easy to get patches for drivers reviewed where effectively only a single maintainer/developer is working on.
Quoted 1 line
I liked your expanded explanation better.
Updated the commit message.
cheers,
Gerd