qxl: Various fixes
Subsystems (3)
v4 cover qxl: Various fixes
Hey,
Here is what should hopefully be the final version of this series, only change since v3 is that I made sure to keep "PATCH" in the subject line, and I added missing Acked-by/Signed-of-by annotations to the logs.
Christophe
_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel
PATCH v4 1/7 qxl: Mark some internal functions as static
They are not used outside of their respective source file
--- drivers/gpu/drm/qxl/qxl_cmd.c | 2 +- drivers/gpu/drm/qxl/qxl_display.c | 4 ++-- drivers/gpu/drm/qxl/qxl_drv.h | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/qxl/qxl_cmd.c +1 -1
@@ -578,7 +578,7 @@ int qxl_hw_surface_dealloc(struct qxl_device *qdev,return 0 ; } -int qxl_update_surface (struct qxl_device *qdev,struct qxl_bo *surf) +static int qxl_update_surface (struct qxl_device *qdev,struct qxl_bo *surf) {struct qxl_rect rect;int ret;
drivers/gpu/drm/qxl/qxl_display.c +2 -2
@@ -36,7 +36,7 @@ static bool qxl_head_enabled(struct qxl_head *head)return head->width && head->height; } -void qxl_alloc_client_monitors_config (struct qxl_device *qdev,unsigned count) +static void qxl_alloc_client_monitors_config (struct qxl_device *qdev,unsigned count) {if (qdev->client_monitors_config && count > qdev->client_monitors_config->count) {
@@ -559,7 +559,7 @@ static bool qxl_crtc_mode_fixup(struct drm_crtc *crtc,return true; } -void +static void qxl_send_monitors_config (struct qxl_device *qdev) {int i;
drivers/gpu/drm/qxl/qxl_drv.h +0 -3
@@ -394,13 +394,11 @@ qxl_framebuffer_init(struct drm_device *dev,struct drm_gem_object *obj, const struct drm_framebuffer_funcs *funcs);void qxl_display_read_client_monitors_config (struct qxl_device *qdev); -void qxl_send_monitors_config (struct qxl_device *qdev);int qxl_create_monitors_object (struct qxl_device *qdev);int qxl_destroy_monitors_object (struct qxl_device *qdev);/* used by qxl_debugfs only */ void qxl_crtc_set_from_monitors_config (struct qxl_device *qdev); -void qxl_alloc_client_monitors_config (struct qxl_device *qdev,unsigned count);/* qxl_gem.c */ int qxl_gem_init (struct qxl_device *qdev);
@@ -573,6 +571,5 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo);struct qxl_drv_surface *qxl_surface_lookup (struct drm_device *dev,int surface_id);void qxl_surface_evict (struct qxl_device *qdev,struct qxl_bo *surf,bool freeing); -int qxl_update_surface (struct qxl_device *qdev,struct qxl_bo *surf);#endif
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 2/7 qxl: Remove unused prototype
In reply to Christophe Fergeauqxl_crtc_set_from_monitors_config() is defined in qxl_drv.h but never implemented.
--- drivers/gpu/drm/qxl/qxl_drv.h | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +0 -3
@@ -397,9 +397,6 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev);int qxl_create_monitors_object (struct qxl_device *qdev);int qxl_destroy_monitors_object (struct qxl_device *qdev); -/* used by qxl_debugfs only */ -void qxl_crtc_set_from_monitors_config (struct qxl_device *qdev); -/* qxl_gem.c */ int qxl_gem_init (struct qxl_device *qdev);void qxl_gem_fini (struct qxl_device *qdev);
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 3/7 qxl: Add missing '\n' to qxl_io_log() call
In reply to Christophe FergeauThe message has to be terminated by a newline as it's not going to get added automatically.
--- drivers/gpu/drm/qxl/qxl_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_fb.c +1 -1
@@ -198,7 +198,7 @@ static int qxlfb_framebuffer_dirty(struct drm_framebuffer *fb,/* * we are using a shadow draw buffer, at qdev->surface0_shadow */ -qxl_io_log (qdev,"dirty x[%d, %d], y[%d, %d]" , clips->x1, clips->x2, +qxl_io_log (qdev,"dirty x[%d, %d], y[%d, %d]\n" , clips->x1, clips->x2, clips->y1, clips->y2); image->dx = clips->x1; image->dy = clips->y1;
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 4/7 qxl: Call qxl_gem_{init, fini}
In reply to Christophe Fergeauqdev->gem.objects was initialized directly in qxl_device_init() rather than going through qxl_gem_init(), and qxl_gem_fini() was never called.
--- drivers/gpu/drm/qxl/qxl_kms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/qxl_kms.c +2 -1
@@ -131,7 +131,7 @@ static int qxl_device_init(struct qxl_device *qdev,mutex_init (&qdev->update_area_mutex);mutex_init (&qdev->release_mutex);mutex_init (&qdev->surf_evict_mutex); -INIT_LIST_HEAD (&qdev->gem.objects); +qxl_gem_init (qdev); qdev->rom_base =pci_resource_start (pdev,2 ); qdev->rom_size =pci_resource_len (pdev,2 );
@@ -273,6 +273,7 @@ static void qxl_device_fini(struct qxl_device *qdev)qxl_ring_free (qdev->command_ring);qxl_ring_free (qdev->cursor_ring);qxl_ring_free (qdev->release_ring); +qxl_gem_fini (qdev);qxl_bo_fini (qdev);io_mapping_free (qdev->surface_mapping);io_mapping_free (qdev->vram_mapping);
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
PATCH v4 5/7 qxl: Remove qxl_bo_init() return value
In reply to Christophe FergeauIt's always returning 0, and it's always ignored.
--- drivers/gpu/drm/qxl/qxl_drv.h | 2 +- drivers/gpu/drm/qxl/qxl_gem.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/qxl/qxl_drv.h +1 -1
@@ -398,7 +398,7 @@ int qxl_create_monitors_object(struct qxl_device *qdev);int qxl_destroy_monitors_object (struct qxl_device *qdev);/* qxl_gem.c */ -int qxl_gem_init (struct qxl_device *qdev); +void qxl_gem_init (struct qxl_device *qdev);void qxl_gem_fini (struct qxl_device *qdev); int qxl_gem_object_create(struct qxl_device *qdev, int size, int alignment, int initial_domain,
drivers/gpu/drm/qxl/qxl_gem.c +1 -2
@@ -111,10 +111,9 @@ void qxl_gem_object_close(struct drm_gem_object *obj, { } -int qxl_gem_init (struct qxl_device *qdev) +void qxl_gem_init (struct qxl_device *qdev) {INIT_LIST_HEAD (&qdev->gem.objects); -return 0 ; }void qxl_gem_fini (struct qxl_device *qdev)
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 6/7 qxl: Don't notify userspace when monitors config is unchanged
In reply to Christophe FergeauWhen the QXL driver receives a QXL_INTERRUPT_CLIENT_MONITORS_CONFIG interrupt, we currently always notify userspace that there was some hotplug event.
However, gnome-shell/mutter is reacting to this event by attempting a resolution change, which it does by issueing drmModeRmFB, drmModeAddFB, and then drmModeSetCrtc. This has the side-effect of causing qxl_crtc_mode_set() to tell the QXL virtual hardware that a primary surface was destroyed and created. After going through QEMU and then the remote SPICE client, a new identical monitors config message will be sent, resulting in a QXL_INTERRUPT_CLIENT_MONITORS_CONFIG interrupt to be emitted, and the same scenario occurring again.
As destroying/creating the primary surface causes a visible screen flicker, this makes the guest hard to use (
https://bugzilla.redhat.com/show_bug.cgi?id=1266484 ).
This commit checks if the screen configuration we received is the same one as the current one, and does not notify userspace about it if that's the case.
--- drivers/gpu/drm/qxl/qxl_display.c | 62 ++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +52 -10
@@ -57,11 +57,18 @@ static void qxl_alloc_client_monitors_config(struct qxl_device *qdev, unsigned c qdev->client_monitors_config->count = count; } +enum { +MONITORS_CONFIG_MODIFIED , +MONITORS_CONFIG_UNCHANGED , +MONITORS_CONFIG_BAD_CRC , +}; +static int qxl_display_copy_rom_client_monitors_config (struct qxl_device *qdev) {int i;int num_monitors;uint32_t crc; +int status =MONITORS_CONFIG_UNCHANGED ; num_monitors = qdev->rom->client_monitors_config.count; crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config,
@@ -70,7 +77,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)qxl_io_log (qdev,"crc mismatch: have %X (%zd) != %X\n" , crc,sizeof (qdev->rom->client_monitors_config), qdev->rom->client_monitors_config_crc); -return 1 ; +return MONITORS_CONFIG_BAD_CRC ; }if (num_monitors > qdev->monitors_config->max_allowed) { DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n",
@@ -79,6 +86,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) }else { num_monitors = qdev->rom->client_monitors_config.count; } +if (qdev->client_monitors_config + && (num_monitors != qdev->client_monitors_config->count)) { + status =MONITORS_CONFIG_MODIFIED ; + }qxl_alloc_client_monitors_config (qdev, num_monitors);/* we copy max from the client but it isn't used */ qdev->client_monitors_config->max_allowed =
@@ -88,17 +99,39 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) &qdev->rom->client_monitors_config.heads[i];struct qxl_head *client_head = &qdev->client_monitors_config->heads[i]; - client_head->x = c_rect->left; - client_head->y = c_rect->top; - client_head->width = c_rect->right - c_rect->left; - client_head->height = c_rect->bottom - c_rect->top; - client_head->surface_id =0 ; - client_head->id = i; - client_head->flags =0 ; +if (client_head->x != c_rect->left) { + client_head->x = c_rect->left; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->y != c_rect->top) { + client_head->y = c_rect->top; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->width != c_rect->right - c_rect->left) { + client_head->width = c_rect->right - c_rect->left; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->height != c_rect->bottom - c_rect->top) { + client_head->height = c_rect->bottom - c_rect->top; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->surface_id !=0 ) { + client_head->surface_id =0 ; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->id != i) { + client_head->id = i; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->flags !=0 ) { + client_head->flags =0 ; + status =MONITORS_CONFIG_MODIFIED ; + }DRM_DEBUG_KMS ("read %dx%d+%d+%d\n" , client_head->width, client_head->height, client_head->x, client_head->y); } -return 0 ; + +return status; }static void qxl_update_offset_props (struct qxl_device *qdev)
@@ -124,9 +157,18 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) {struct drm_device *dev = qdev->ddev; -while (qxl_display_copy_rom_client_monitors_config (qdev)) { +int status; + + status =qxl_display_copy_rom_client_monitors_config (qdev); +while (status ==MONITORS_CONFIG_BAD_CRC ) {qxl_io_log (qdev,"failed crc check for client_monitors_config," " retrying\n" ); + status =qxl_display_copy_rom_client_monitors_config (qdev); + } +if (status ==MONITORS_CONFIG_UNCHANGED ) { +qxl_io_log (qdev,"config unchanged\n" ); +DRM_DEBUG ("ignoring unchanged client monitors config" ); +return ; }drm_modeset_lock_all (dev);
Signature · 6 lines
2.9.3 _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
PATCH v4 7/7 qxl: Allow resolution which are not multiple of 8
In reply to Christophe FergeauThe use of drm_cvt_mode() in qxl_add_monitors_config_modes() means that the resolutions we are going to present to user-space are going to be rounded down to a multiple of 8. In the QXL arbitrary resolution case, this is not useful.
This commit forces the actual width/height that was requested by the client in the drm_display_mode structure rather than keeping the rounded version.
--- drivers/gpu/drm/qxl/qxl_display.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/qxl/qxl_display.c +3 -0
@@ -199,6 +199,9 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector, 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);
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH drm/qxl v4 6/7] qxl: Don't notify userspace when monitors config is unchanged
In reply to Christophe FergeauQuoted 146 lines
When the QXL driver receives a
QXL_INTERRUPT_CLIENT_MONITORS_CONFIGinterrupt,
we currently always notify userspace that there was some hotplug event.However, gnome-shell/mutter is reacting to this event by attempting a resolution change, which it does by issueing drmModeRmFB, drmModeAddFB, and then drmModeSetCrtc. This has the side-effect of causing
qxl_crtc_mode_set()to tell the QXL virtual hardware that a primary surface was destroyed and created. After going through QEMU and then the remote SPICE client, a new identical monitors config message will be sent, resulting in aQXL_INTERRUPT_CLIENT_MONITORS_CONFIGinterrupt to be emitted, and the same scenario occurring again.As destroying/creating the primary surface causes a visible screen flicker, this makes the guest hard to use (
https://bugzilla.redhat.com/show_bug.cgi?id=1266484 ).This commit checks if the screen configuration we received is the same one as the current one, and does not notify userspace about it if that's the case.
Signed-off-by Christophe Fergeau <[email protected]>--- drivers/gpu/drm/qxl/qxl_display.c | 62 ++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-)drivers/gpu/drm/qxl/qxl_display.c +0
-0@@ -57,11 +57,18 @@ static void qxl_alloc_client_monitors_config(struct
qxl_device*qdev, unsigned cdrivers/gpu/drm/qxl/qxl_display.c +8
-1qdev->client_monitors_config->count = count; } +enum { +MONITORS_CONFIG_MODIFIED , +MONITORS_CONFIG_UNCHANGED , +MONITORS_CONFIG_BAD_CRC , +}; +static int qxl_display_copy_rom_client_monitors_config (struct qxl_device *qdev) {int i;int num_monitors;uint32_t crc; +int status =MONITORS_CONFIG_UNCHANGED ; num_monitors = qdev->rom->client_monitors_config.count; crc = crc32(0, (const uint8_t *)&qdev->rom->client_monitors_config,@@ -70,7 +77,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) qxl_io_log(qdev, "crc mismatch: have %X (%zd) != %X\n", crc,sizeof (qdev->rom->client_monitors_config), qdev->rom->client_monitors_config_crc); -return 1 ; +return MONITORS_CONFIG_BAD_CRC ; }if (num_monitors > qdev->monitors_config->max_allowed) {drivers/gpu/drm/qxl/qxl_display.c +4
-0DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n",@@ -79,6 +86,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) }else { num_monitors = qdev->rom->client_monitors_config.count; } +if (qdev->client_monitors_config + && (num_monitors != qdev->client_monitors_config->count)) { + status =MONITORS_CONFIG_MODIFIED ; + }qxl_alloc_client_monitors_config (qdev, num_monitors);/* we copy max from the client but it isn't used */ drivers/gpu/drm/qxl/qxl_display.c +30
-8qdev->client_monitors_config->max_allowed =@@ -88,17 +99,39 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) &qdev->rom->client_monitors_config.heads[i];struct qxl_head *client_head = &qdev->client_monitors_config->heads[i]; - client_head->x = c_rect->left; - client_head->y = c_rect->top; - client_head->width = c_rect->right - c_rect->left; - client_head->height = c_rect->bottom - c_rect->top; - client_head->surface_id =0 ; - client_head->id = i; - client_head->flags =0 ; +if (client_head->x != c_rect->left) { + client_head->x = c_rect->left; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->y != c_rect->top) { + client_head->y = c_rect->top; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->width != c_rect->right - c_rect->left) { + client_head->width = c_rect->right - c_rect->left; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->height != c_rect->bottom - c_rect->top) { + client_head->height = c_rect->bottom - c_rect->top; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->surface_id !=0 ) { + client_head->surface_id =0 ; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->id != i) { + client_head->id = i; + status =MONITORS_CONFIG_MODIFIED ; + } +if (client_head->flags !=0 ) { + client_head->flags =0 ; + status =MONITORS_CONFIG_MODIFIED ; + }DRM_DEBUG_KMS ("read %dx%d+%d+%d\n" , client_head->width, client_head->height, client_head->x, client_head->y); } -return 0 ; + +return status; }static void
qxl_update_offset_props(struct qxl_device *qdev)drivers/gpu/drm/qxl/qxl_display.c +10
-1@@ -124,9 +157,18 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) {struct drm_device *dev = qdev->ddev; -while (qxl_display_copy_rom_client_monitors_config (qdev)) { +int status; + + status =qxl_display_copy_rom_client_monitors_config (qdev); +while (status ==MONITORS_CONFIG_BAD_CRC ) {qxl_io_log (qdev,"failed crc check for client_monitors_config," " retrying\n" ); + status =qxl_display_copy_rom_client_monitors_config (qdev); + } +if (status ==MONITORS_CONFIG_UNCHANGED ) { +qxl_io_log (qdev,"config unchanged\n" ); +DRM_DEBUG ("ignoring unchanged client monitors config" ); +return ; }
Quoted 1 line
drm_modeset_lock_all(dev);
Frediano
_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel