All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/qxl: fix the suspend/resume issue on qxl device
@ 2022-09-07  9:44 ` Zongmin Zhou
  0 siblings, 0 replies; 5+ messages in thread
From: Zongmin Zhou @ 2022-09-07  9:44 UTC (permalink / raw)
  To: airlied, kraxel, airlied, daniel
  Cc: virtualization, spice-devel, dri-devel, linux-kernel,
	zhouzongmin, Ming Xie

[-- Attachment #1: Type: text/plain, Size: 3362 bytes --]


From: Zongmin Zhou <zhouzongmin@kylinos.cn>

Details:
Currently, when trying to suspend and resume with qxl device,
there are some error messages after resuming,
eventually caused to black screen and can't be recovered.

The first error message:
	[   64.668577][    C3] [drm] driver is in bug mode

This error is due to guest qxl driver
will call qxl_reinit_memslots(qdev) during system resume,
but didn't call qxl_io_reset(qdev) before this,
Then will cause the QXL_IO_MEMSLOT_ADD operation to fail on QEMU,
qxl->guest_bug flag will be set,As a result,
the QXL device can't communicate with guest qxl driver through the IO port.

after fix the first error,can success to resume and login to desktop,
but shortly after that will observe the second error message :
	[  353.095343][  T863] qxl 0000:00:02.0: object_init failed for (262144, 0x00000001)
	[  353.096660][  T863] [drm:qxl_gem_object_create [qxl]] *ERROR* Failed to allocate GEM object (260852, 1, 4096, -12)
	[  353.097277][  T863] [drm:qxl_alloc_ioctl [qxl]] *ERROR* qxl_alloc_ioctl: failed to create gem ret=-12
	[  368.197538][  T863] qxl 0000:00:02.0: object_init failed for (3149824, 0x00000001)
	[  368.197541][  T863] [drm:qxl_alloc_bo_reserved [qxl]] *ERROR* failed to allocate VRAM BO

The problem is caused by calling qxl_ring_init_hdr(qdev->release_ring)
in qxl_drm_resume() function.
When do QXL_IO_RESET,QEMU will call init_qxl_ram(),
so params like prod,cons,notify_on_cons and notify_on_prod
will be set to default value.
Ring push/pop actions for release_ring can be performed normally.
But call qxl_ring_init_hdr(qdev->release_ring)
will eventually set notify_on_prod to number of QXL_RELEASE_RING_SIZE,
affect the value of notify in qxl_push_free_res() function always be false,
QEMU will no longer send events of QXL_INTERRUPT_DISPLAY to the
guest qxl driver,so qxl_ring_pop() will never been called anymore,
and can't do dma_fence_signal(),result to ttm_bo_wait_ctx(bo, ctx)
always return EBUSY,fail to call qxl_bo_create().

Test scenario:
1) start virtual machine with qemu command "-device qxl-vga"
2) click suspend botton to enter suspend mode
3) resume and observe the error message in kernel logs,screen will be black

Let's fix this by reset io and remove the qxl_ring_init_hdr calling.

Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
Suggested-by: Ming Xie<xieming@kylinos.cn>
---
 drivers/gpu/drm/qxl/qxl_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 1cb6f0c224bb..3044ca948ce2 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -194,7 +194,6 @@ static int qxl_drm_resume(struct drm_device *dev, bool thaw)
 	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
 	if (!thaw) {
 		qxl_reinit_memslots(qdev);
-		qxl_ring_init_hdr(qdev->release_ring);
 	}
 
 	qxl_create_monitors_object(qdev);
@@ -220,6 +219,7 @@ static int qxl_pm_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
+	struct qxl_device *qdev = to_qxl(drm_dev);
 
 	pci_set_power_state(pdev, PCI_D0);
 	pci_restore_state(pdev);
@@ -227,6 +227,7 @@ static int qxl_pm_resume(struct device *dev)
 		return -EIO;
 	}
 
+	qxl_io_reset(qdev);
 	return qxl_drm_resume(drm_dev, false);
 }
 
-- 
2.25.1


[-- Attachment #2: Type: text/plain, Size: 82 bytes --]

Content-type: Text/plain

No virus found
		Checked by Hillstone Network AntiVirus

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] drm/qxl: fix the suspend/resume issue on qxl device
@ 2022-09-07  9:44 ` Zongmin Zhou
  0 siblings, 0 replies; 5+ messages in thread
From: Zongmin Zhou @ 2022-09-07  9:44 UTC (permalink / raw)
  To: airlied, kraxel, airlied, daniel
  Cc: linux-kernel, dri-devel, virtualization, zhouzongmin, Ming Xie,
	spice-devel

[-- Attachment #1: Type: text/plain, Size: 3362 bytes --]


From: Zongmin Zhou <zhouzongmin@kylinos.cn>

Details:
Currently, when trying to suspend and resume with qxl device,
there are some error messages after resuming,
eventually caused to black screen and can't be recovered.

The first error message:
	[   64.668577][    C3] [drm] driver is in bug mode

This error is due to guest qxl driver
will call qxl_reinit_memslots(qdev) during system resume,
but didn't call qxl_io_reset(qdev) before this,
Then will cause the QXL_IO_MEMSLOT_ADD operation to fail on QEMU,
qxl->guest_bug flag will be set,As a result,
the QXL device can't communicate with guest qxl driver through the IO port.

after fix the first error,can success to resume and login to desktop,
but shortly after that will observe the second error message :
	[  353.095343][  T863] qxl 0000:00:02.0: object_init failed for (262144, 0x00000001)
	[  353.096660][  T863] [drm:qxl_gem_object_create [qxl]] *ERROR* Failed to allocate GEM object (260852, 1, 4096, -12)
	[  353.097277][  T863] [drm:qxl_alloc_ioctl [qxl]] *ERROR* qxl_alloc_ioctl: failed to create gem ret=-12
	[  368.197538][  T863] qxl 0000:00:02.0: object_init failed for (3149824, 0x00000001)
	[  368.197541][  T863] [drm:qxl_alloc_bo_reserved [qxl]] *ERROR* failed to allocate VRAM BO

The problem is caused by calling qxl_ring_init_hdr(qdev->release_ring)
in qxl_drm_resume() function.
When do QXL_IO_RESET,QEMU will call init_qxl_ram(),
so params like prod,cons,notify_on_cons and notify_on_prod
will be set to default value.
Ring push/pop actions for release_ring can be performed normally.
But call qxl_ring_init_hdr(qdev->release_ring)
will eventually set notify_on_prod to number of QXL_RELEASE_RING_SIZE,
affect the value of notify in qxl_push_free_res() function always be false,
QEMU will no longer send events of QXL_INTERRUPT_DISPLAY to the
guest qxl driver,so qxl_ring_pop() will never been called anymore,
and can't do dma_fence_signal(),result to ttm_bo_wait_ctx(bo, ctx)
always return EBUSY,fail to call qxl_bo_create().

Test scenario:
1) start virtual machine with qemu command "-device qxl-vga"
2) click suspend botton to enter suspend mode
3) resume and observe the error message in kernel logs,screen will be black

Let's fix this by reset io and remove the qxl_ring_init_hdr calling.

Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn>
Suggested-by: Ming Xie<xieming@kylinos.cn>
---
 drivers/gpu/drm/qxl/qxl_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 1cb6f0c224bb..3044ca948ce2 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -194,7 +194,6 @@ static int qxl_drm_resume(struct drm_device *dev, bool thaw)
 	qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
 	if (!thaw) {
 		qxl_reinit_memslots(qdev);
-		qxl_ring_init_hdr(qdev->release_ring);
 	}
 
 	qxl_create_monitors_object(qdev);
@@ -220,6 +219,7 @@ static int qxl_pm_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
+	struct qxl_device *qdev = to_qxl(drm_dev);
 
 	pci_set_power_state(pdev, PCI_D0);
 	pci_restore_state(pdev);
@@ -227,6 +227,7 @@ static int qxl_pm_resume(struct device *dev)
 		return -EIO;
 	}
 
+	qxl_io_reset(qdev);
 	return qxl_drm_resume(drm_dev, false);
 }
 
-- 
2.25.1


[-- Attachment #2: Type: text/plain, Size: 82 bytes --]

Content-type: Text/plain

No virus found
		Checked by Hillstone Network AntiVirus

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/qxl: fix the suspend/resume issue on qxl device
  2022-09-07  9:44 ` Zongmin Zhou
  (?)
@ 2022-09-07 10:17   ` Gerd Hoffmann
  -1 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2022-09-07 10:17 UTC (permalink / raw)
  To: Zongmin Zhou
  Cc: airlied, linux-kernel, dri-devel, virtualization, zhouzongmin,
	Ming Xie, daniel, spice-devel, airlied

On Wed, Sep 07, 2022 at 05:44:23PM +0800, Zongmin Zhou wrote:
> 
> From: Zongmin Zhou <zhouzongmin@kylinos.cn>
> 
> Details:
> Currently, when trying to suspend and resume with qxl device,
> there are some error messages after resuming,
> eventually caused to black screen and can't be recovered.

[ analysis snipped ]

> Let's fix this by reset io and remove the qxl_ring_init_hdr calling.

Pushed to drm-misc-next

thanks,
  Gerd

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/qxl: fix the suspend/resume issue on qxl device
@ 2022-09-07 10:17   ` Gerd Hoffmann
  0 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2022-09-07 10:17 UTC (permalink / raw)
  To: Zongmin Zhou
  Cc: airlied, linux-kernel, dri-devel, virtualization, zhouzongmin,
	Ming Xie, spice-devel, airlied

On Wed, Sep 07, 2022 at 05:44:23PM +0800, Zongmin Zhou wrote:
> 
> From: Zongmin Zhou <zhouzongmin@kylinos.cn>
> 
> Details:
> Currently, when trying to suspend and resume with qxl device,
> there are some error messages after resuming,
> eventually caused to black screen and can't be recovered.

[ analysis snipped ]

> Let's fix this by reset io and remove the qxl_ring_init_hdr calling.

Pushed to drm-misc-next

thanks,
  Gerd


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/qxl: fix the suspend/resume issue on qxl device
@ 2022-09-07 10:17   ` Gerd Hoffmann
  0 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2022-09-07 10:17 UTC (permalink / raw)
  To: Zongmin Zhou
  Cc: airlied, airlied, daniel, virtualization, spice-devel, dri-devel,
	linux-kernel, zhouzongmin, Ming Xie

On Wed, Sep 07, 2022 at 05:44:23PM +0800, Zongmin Zhou wrote:
> 
> From: Zongmin Zhou <zhouzongmin@kylinos.cn>
> 
> Details:
> Currently, when trying to suspend and resume with qxl device,
> there are some error messages after resuming,
> eventually caused to black screen and can't be recovered.

[ analysis snipped ]

> Let's fix this by reset io and remove the qxl_ring_init_hdr calling.

Pushed to drm-misc-next

thanks,
  Gerd


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-07 14:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07  9:44 [PATCH] drm/qxl: fix the suspend/resume issue on qxl device Zongmin Zhou
2022-09-07  9:44 ` Zongmin Zhou
2022-09-07 10:17 ` Gerd Hoffmann
2022-09-07 10:17   ` Gerd Hoffmann
2022-09-07 10:17   ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.