All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling
@ 2018-09-11  7:15 Hans de Goede
  2018-09-11  7:15 ` [PATCH 2/4] staging: vboxvideo: Skip currrent crtc when updating crtcs Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Hans de Goede @ 2018-09-11  7:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, Hans de Goede, Michael Thayer, dri-devel

The default settings for Linux vms created in VirtualBox allocate only
16M of videomem. When running fullscreen on a 1920x1080 (or bigger) monitor
this is not a lot.

When using GNOME3 on Wayland we have already been seeing out of video
memory errors for a while now. After commit 2408898e3b6c ("staging:
vboxvideo: Add page-flip support") this has become much worse as now
multiple buffers are used.

There is nothing we can do about there not being enough video-mem, but
we should handle running out of video-mem properly, currently there are
2 problems with this:

1) vbox_crtc_mode_set() does not check if vbox_crtc_mode_set_base() fails
at all and does not properly propagate the oom error.

2) vbox_crtc_do_set_base() unpins the old fb too soon:

2.1) It unpins it before pinning the new fb, so if the pinning of the new
fb fails (which it will when we run out of video-mem), then we also cannot
fall back to the old-fb as it has been already unpinned. We could try to
re-pin it but there is no guarantee that will succeed.

2.2) It unpins it before reprogramming the hardware to scan out from the
new-fb, which could lead to some ugliness where the hw is scanning out the
oldfb while it is being replaced with something else.

Fixing this requires to do things in this order:
1) Pin the new fb
2) Program the hw
3) Unpin the oldfb

This needs to be done for both a mode_set and for a page_flip so this
commit re-writes vbox_crtc_do_set_base() into vbox_crtc_set_base_and_mode()
which does this in the correct order, putting the hardware programming
which was duplicated between the mode_set and page_flip code inside the
new function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/vboxvideo/vbox_mode.c | 121 +++++++++++++-------------
 1 file changed, 62 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index 79836c8fb909..47de1364ec4d 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -221,53 +221,68 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)
 	return old_single_framebuffer != vbox->single_framebuffer;
 }
 
-static int vbox_crtc_do_set_base(struct drm_crtc *crtc,
-				 struct drm_framebuffer *old_fb,
-				 struct drm_framebuffer *new_fb,
-				 int x, int y)
+static int vbox_fb_pin(struct drm_framebuffer *fb, u64 *addr)
+{
+	struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
+	int ret;
+
+	ret = vbox_bo_reserve(bo, false);
+	if (ret)
+		return ret;
+
+	ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, addr);
+	vbox_bo_unreserve(bo);
+	return ret;
+}
+
+static void vbox_fb_unpin(struct drm_framebuffer *fb)
 {
-	struct vbox_private *vbox = crtc->dev->dev_private;
-	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
-	struct drm_gem_object *obj;
-	struct vbox_framebuffer *vbox_fb;
 	struct vbox_bo *bo;
 	int ret;
-	u64 gpu_addr;
 
-	/* Unpin the previous fb. */
-	if (old_fb) {
-		vbox_fb = to_vbox_framebuffer(old_fb);
-		obj = vbox_fb->obj;
-		bo = gem_to_vbox_bo(obj);
-		ret = vbox_bo_reserve(bo, false);
-		if (ret)
-			return ret;
+	if (!fb)
+		return;
 
-		vbox_bo_unpin(bo);
-		vbox_bo_unreserve(bo);
+	bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj);
+
+	ret = vbox_bo_reserve(bo, false);
+	if (ret) {
+		DRM_ERROR("Error %d reserving fb bo, leaving it pinned\n", ret);
+		return;
 	}
 
-	vbox_fb = to_vbox_framebuffer(new_fb);
-	obj = vbox_fb->obj;
-	bo = gem_to_vbox_bo(obj);
+	vbox_bo_unpin(bo);
+	vbox_bo_unreserve(bo);
+}
 
-	ret = vbox_bo_reserve(bo, false);
-	if (ret)
-		return ret;
+static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
+				       struct drm_framebuffer *old_fb,
+				       struct drm_framebuffer *new_fb,
+				       struct drm_display_mode *mode,
+				       int x, int y)
+{
+	struct vbox_private *vbox = crtc->dev->dev_private;
+	struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
+	u64 gpu_addr;
+	int ret;
 
-	ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
+	/* Prepare: pin the new framebuffer bo */
+	ret = vbox_fb_pin(new_fb, &gpu_addr);
 	if (ret) {
-		vbox_bo_unreserve(bo);
+		DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
 		return ret;
 	}
 
-	if (&vbox->fbdev->afb == vbox_fb)
+	/* Commit: Update hardware to use the new fb */
+	mutex_lock(&vbox->hw_mutex);
+
+	if (&vbox->fbdev->afb == to_vbox_framebuffer(new_fb))
 		vbox_fbdev_set_base(vbox, gpu_addr);
-	vbox_bo_unreserve(bo);
 
-	/* vbox_set_start_address_crt1(crtc, (u32)gpu_addr); */
 	vbox_crtc->fb_offset = gpu_addr;
-	if (vbox_set_up_input_mapping(vbox)) {
+
+	/* vbox_do_modeset() checks vbox->single_framebuffer so update it now */
+	if (mode && vbox_set_up_input_mapping(vbox)) {
 		struct drm_crtc *crtci;
 
 		list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list,
@@ -277,13 +292,20 @@ static int vbox_crtc_do_set_base(struct drm_crtc *crtc,
 		}
 	}
 
-	return 0;
-}
+	vbox_set_view(crtc);
+	vbox_do_modeset(crtc, mode ? mode : &crtc->mode);
 
-static int vbox_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-				   struct drm_framebuffer *old_fb)
-{
-	return vbox_crtc_do_set_base(crtc, old_fb, CRTC_FB(crtc), x, y);
+	if (mode)
+		hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
+					   vbox->input_mapping_width,
+					   vbox->input_mapping_height);
+
+	mutex_unlock(&vbox->hw_mutex);
+
+	/* Cleanup: unpin the old fb */
+	vbox_fb_unpin(old_fb);
+
+	return 0;
 }
 
 static int vbox_crtc_mode_set(struct drm_crtc *crtc,
@@ -291,21 +313,8 @@ static int vbox_crtc_mode_set(struct drm_crtc *crtc,
 			      struct drm_display_mode *adjusted_mode,
 			      int x, int y, struct drm_framebuffer *old_fb)
 {
-	struct vbox_private *vbox = crtc->dev->dev_private;
-	int ret;
-
-	vbox_crtc_mode_set_base(crtc, x, y, old_fb);
-
-	mutex_lock(&vbox->hw_mutex);
-	ret = vbox_set_view(crtc);
-	if (!ret)
-		vbox_do_modeset(crtc, mode);
-	hgsmi_update_input_mapping(vbox->guest_pool, 0, 0,
-				   vbox->input_mapping_width,
-				   vbox->input_mapping_height);
-	mutex_unlock(&vbox->hw_mutex);
-
-	return ret;
+	return vbox_crtc_set_base_and_mode(crtc, old_fb, CRTC_FB(crtc),
+					   mode, x, y);
 }
 
 static int vbox_crtc_page_flip(struct drm_crtc *crtc,
@@ -319,15 +328,10 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc,
 	unsigned long flags;
 	int rc;
 
-	rc = vbox_crtc_do_set_base(crtc, CRTC_FB(crtc), fb, 0, 0);
+	rc = vbox_crtc_set_base_and_mode(crtc, CRTC_FB(crtc), fb, NULL, 0, 0);
 	if (rc)
 		return rc;
 
-	mutex_lock(&vbox->hw_mutex);
-	vbox_set_view(crtc);
-	vbox_do_modeset(crtc, &crtc->mode);
-	mutex_unlock(&vbox->hw_mutex);
-
 	spin_lock_irqsave(&drm->event_lock, flags);
 
 	if (event)
@@ -354,7 +358,6 @@ static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
 	.dpms = vbox_crtc_dpms,
 	.mode_fixup = vbox_crtc_mode_fixup,
 	.mode_set = vbox_crtc_mode_set,
-	/* .mode_set_base = vbox_crtc_mode_set_base, */
 	.disable = vbox_crtc_disable,
 	.prepare = vbox_crtc_prepare,
 	.commit = vbox_crtc_commit,
-- 
2.19.0.rc0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 2/4] staging: vboxvideo: Skip currrent crtc when updating crtcs
  2018-09-11  7:15 [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Hans de Goede
@ 2018-09-11  7:15 ` Hans de Goede
  2018-09-11  7:15 ` [PATCH 3/4] staging: vboxvideo: Remove vboxfb_create_object() wrapper Hans de Goede
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2018-09-11  7:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, Hans de Goede, Michael Thayer, dri-devel

In vbox_crtc_set_base_and_mode() we update all the crtcs when the
single_framebuffer setting changes, including the one on which
vbox_crtc_set_base_and_mode() was called, so we end up doing
vbox_do_modeset() on it twice. This commit skips the crtc on which
we are updating in the loop to update the other crtcs.

This commit also removes the vbox_set_view() call from the loop,
vbox_set_view() does not depend on the single_framebuffer setting and it
was being called on the passed in crtc parameter and not on the crtci
local iterator value (typo), so it was a no-op already.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/vboxvideo/vbox_mode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index 47de1364ec4d..e7d70ced5bfd 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -287,7 +287,8 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
 
 		list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list,
 				    head) {
-			vbox_set_view(crtc);
+			if (crtci == crtc)
+				continue;
 			vbox_do_modeset(crtci, &crtci->mode);
 		}
 	}
-- 
2.19.0.rc0

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

* [PATCH 3/4] staging: vboxvideo: Remove vboxfb_create_object() wrapper
  2018-09-11  7:15 [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Hans de Goede
  2018-09-11  7:15 ` [PATCH 2/4] staging: vboxvideo: Skip currrent crtc when updating crtcs Hans de Goede
@ 2018-09-11  7:15 ` Hans de Goede
  2018-09-11  7:15 ` [PATCH 4/4] staging: vboxvideo: Drop vbox_bo_unref() helper Hans de Goede
  2018-09-11 18:46 ` [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Greg Kroah-Hartman
  3 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2018-09-11  7:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, Hans de Goede, Michael Thayer, dri-devel

The vboxfb_create_object() wrapper really does nothing more then just
call vbox_gem_create(), so this commit drops it, replacing it with
a direct call to vbox_gem_create().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/vboxvideo/vbox_fb.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c
index 43c39eca4ae1..79814117e063 100644
--- a/drivers/staging/vboxvideo/vbox_fb.c
+++ b/drivers/staging/vboxvideo/vbox_fb.c
@@ -66,26 +66,6 @@ static struct fb_ops vboxfb_ops = {
 	.fb_debug_leave = drm_fb_helper_debug_leave,
 };
 
-static int vboxfb_create_object(struct vbox_fbdev *fbdev,
-				struct DRM_MODE_FB_CMD *mode_cmd,
-				struct drm_gem_object **gobj_p)
-{
-	struct drm_device *dev = fbdev->helper.dev;
-	u32 size;
-	struct drm_gem_object *gobj;
-	u32 pitch = mode_cmd->pitches[0];
-	int ret;
-
-	size = pitch * mode_cmd->height;
-	ret = vbox_gem_create(dev, size, true, &gobj);
-	if (ret)
-		return ret;
-
-	*gobj_p = gobj;
-
-	return 0;
-}
-
 static int vboxfb_create(struct drm_fb_helper *helper,
 			 struct drm_fb_helper_surface_size *sizes)
 {
@@ -109,7 +89,7 @@ static int vboxfb_create(struct drm_fb_helper *helper,
 
 	size = pitch * mode_cmd.height;
 
-	ret = vboxfb_create_object(fbdev, &mode_cmd, &gobj);
+	ret = vbox_gem_create(fbdev->helper.dev, size, true, &gobj);
 	if (ret) {
 		DRM_ERROR("failed to create fbcon backing object %d\n", ret);
 		return ret;
-- 
2.19.0.rc0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH 4/4] staging: vboxvideo: Drop vbox_bo_unref() helper
  2018-09-11  7:15 [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Hans de Goede
  2018-09-11  7:15 ` [PATCH 2/4] staging: vboxvideo: Skip currrent crtc when updating crtcs Hans de Goede
  2018-09-11  7:15 ` [PATCH 3/4] staging: vboxvideo: Remove vboxfb_create_object() wrapper Hans de Goede
@ 2018-09-11  7:15 ` Hans de Goede
  2018-09-11 18:46 ` [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Greg Kroah-Hartman
  3 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2018-09-11  7:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, Hans de Goede, Michael Thayer, dri-devel

Drop the unnecessary vbox_bo_unref() helper and directly call ttm_bo_put()
at the single call site.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/staging/vboxvideo/vbox_main.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c
index b6cff31903b3..783a68c0de3b 100644
--- a/drivers/staging/vboxvideo/vbox_main.c
+++ b/drivers/staging/vboxvideo/vbox_main.c
@@ -482,23 +482,11 @@ int vbox_dumb_create(struct drm_file *file,
 	return 0;
 }
 
-static void vbox_bo_unref(struct vbox_bo **bo)
-{
-	struct ttm_buffer_object *tbo;
-
-	if ((*bo) == NULL)
-		return;
-
-	tbo = &((*bo)->bo);
-	ttm_bo_put(tbo);
-	*bo = NULL;
-}
-
 void vbox_gem_free_object(struct drm_gem_object *obj)
 {
 	struct vbox_bo *vbox_bo = gem_to_vbox_bo(obj);
 
-	vbox_bo_unref(&vbox_bo);
+	ttm_bo_put(&vbox_bo->bo);
 }
 
 static inline u64 vbox_bo_mmap_offset(struct vbox_bo *bo)
-- 
2.19.0.rc0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling
  2018-09-11  7:15 [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Hans de Goede
                   ` (2 preceding siblings ...)
  2018-09-11  7:15 ` [PATCH 4/4] staging: vboxvideo: Drop vbox_bo_unref() helper Hans de Goede
@ 2018-09-11 18:46 ` Greg Kroah-Hartman
  2018-09-12  7:54   ` Hans de Goede
  3 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-09-11 18:46 UTC (permalink / raw)
  To: Hans de Goede; +Cc: devel, Michael Thayer, dri-devel

On Tue, Sep 11, 2018 at 09:15:41AM +0200, Hans de Goede wrote:
> The default settings for Linux vms created in VirtualBox allocate only
> 16M of videomem. When running fullscreen on a 1920x1080 (or bigger) monitor
> this is not a lot.
> 
> When using GNOME3 on Wayland we have already been seeing out of video
> memory errors for a while now. After commit 2408898e3b6c ("staging:
> vboxvideo: Add page-flip support") this has become much worse as now
> multiple buffers are used.
> 
> There is nothing we can do about there not being enough video-mem, but
> we should handle running out of video-mem properly, currently there are
> 2 problems with this:
> 
> 1) vbox_crtc_mode_set() does not check if vbox_crtc_mode_set_base() fails
> at all and does not properly propagate the oom error.
> 
> 2) vbox_crtc_do_set_base() unpins the old fb too soon:
> 
> 2.1) It unpins it before pinning the new fb, so if the pinning of the new
> fb fails (which it will when we run out of video-mem), then we also cannot
> fall back to the old-fb as it has been already unpinned. We could try to
> re-pin it but there is no guarantee that will succeed.
> 
> 2.2) It unpins it before reprogramming the hardware to scan out from the
> new-fb, which could lead to some ugliness where the hw is scanning out the
> oldfb while it is being replaced with something else.
> 
> Fixing this requires to do things in this order:
> 1) Pin the new fb
> 2) Program the hw
> 3) Unpin the oldfb
> 
> This needs to be done for both a mode_set and for a page_flip so this
> commit re-writes vbox_crtc_do_set_base() into vbox_crtc_set_base_and_mode()
> which does this in the correct order, putting the hardware programming
> which was duplicated between the mode_set and page_flip code inside the
> new function.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/staging/vboxvideo/vbox_mode.c | 121 +++++++++++++-------------
>  1 file changed, 62 insertions(+), 59 deletions(-)

This doesn't apply to my tree.  Does it need to go on top of the
previous patches you sent for 4.19-final?

thanks,

greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling
  2018-09-11 18:46 ` [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Greg Kroah-Hartman
@ 2018-09-12  7:54   ` Hans de Goede
  2018-09-12  8:20     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2018-09-12  7:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, Michael Thayer, dri-devel

Hi,

On 11-09-18 20:46, Greg Kroah-Hartman wrote:
> On Tue, Sep 11, 2018 at 09:15:41AM +0200, Hans de Goede wrote:
>> The default settings for Linux vms created in VirtualBox allocate only
>> 16M of videomem. When running fullscreen on a 1920x1080 (or bigger) monitor
>> this is not a lot.
>>
>> When using GNOME3 on Wayland we have already been seeing out of video
>> memory errors for a while now. After commit 2408898e3b6c ("staging:
>> vboxvideo: Add page-flip support") this has become much worse as now
>> multiple buffers are used.
>>
>> There is nothing we can do about there not being enough video-mem, but
>> we should handle running out of video-mem properly, currently there are
>> 2 problems with this:
>>
>> 1) vbox_crtc_mode_set() does not check if vbox_crtc_mode_set_base() fails
>> at all and does not properly propagate the oom error.
>>
>> 2) vbox_crtc_do_set_base() unpins the old fb too soon:
>>
>> 2.1) It unpins it before pinning the new fb, so if the pinning of the new
>> fb fails (which it will when we run out of video-mem), then we also cannot
>> fall back to the old-fb as it has been already unpinned. We could try to
>> re-pin it but there is no guarantee that will succeed.
>>
>> 2.2) It unpins it before reprogramming the hardware to scan out from the
>> new-fb, which could lead to some ugliness where the hw is scanning out the
>> oldfb while it is being replaced with something else.
>>
>> Fixing this requires to do things in this order:
>> 1) Pin the new fb
>> 2) Program the hw
>> 3) Unpin the oldfb
>>
>> This needs to be done for both a mode_set and for a page_flip so this
>> commit re-writes vbox_crtc_do_set_base() into vbox_crtc_set_base_and_mode()
>> which does this in the correct order, putting the hardware programming
>> which was duplicated between the mode_set and page_flip code inside the
>> new function.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/staging/vboxvideo/vbox_mode.c | 121 +++++++++++++-------------
>>   1 file changed, 62 insertions(+), 59 deletions(-)
> 
> This doesn't apply to my tree.  Does it need to go on top of the
> previous patches you sent for 4.19-final?

Yes this goes on top of the fixes for 4.19-final.

Regards,

Hans

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling
  2018-09-12  7:54   ` Hans de Goede
@ 2018-09-12  8:20     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-09-12  8:20 UTC (permalink / raw)
  To: Hans de Goede; +Cc: devel, Michael Thayer, dri-devel

On Wed, Sep 12, 2018 at 09:54:51AM +0200, Hans de Goede wrote:
> Hi,
> 
> On 11-09-18 20:46, Greg Kroah-Hartman wrote:
> > On Tue, Sep 11, 2018 at 09:15:41AM +0200, Hans de Goede wrote:
> > > The default settings for Linux vms created in VirtualBox allocate only
> > > 16M of videomem. When running fullscreen on a 1920x1080 (or bigger) monitor
> > > this is not a lot.
> > > 
> > > When using GNOME3 on Wayland we have already been seeing out of video
> > > memory errors for a while now. After commit 2408898e3b6c ("staging:
> > > vboxvideo: Add page-flip support") this has become much worse as now
> > > multiple buffers are used.
> > > 
> > > There is nothing we can do about there not being enough video-mem, but
> > > we should handle running out of video-mem properly, currently there are
> > > 2 problems with this:
> > > 
> > > 1) vbox_crtc_mode_set() does not check if vbox_crtc_mode_set_base() fails
> > > at all and does not properly propagate the oom error.
> > > 
> > > 2) vbox_crtc_do_set_base() unpins the old fb too soon:
> > > 
> > > 2.1) It unpins it before pinning the new fb, so if the pinning of the new
> > > fb fails (which it will when we run out of video-mem), then we also cannot
> > > fall back to the old-fb as it has been already unpinned. We could try to
> > > re-pin it but there is no guarantee that will succeed.
> > > 
> > > 2.2) It unpins it before reprogramming the hardware to scan out from the
> > > new-fb, which could lead to some ugliness where the hw is scanning out the
> > > oldfb while it is being replaced with something else.
> > > 
> > > Fixing this requires to do things in this order:
> > > 1) Pin the new fb
> > > 2) Program the hw
> > > 3) Unpin the oldfb
> > > 
> > > This needs to be done for both a mode_set and for a page_flip so this
> > > commit re-writes vbox_crtc_do_set_base() into vbox_crtc_set_base_and_mode()
> > > which does this in the correct order, putting the hardware programming
> > > which was duplicated between the mode_set and page_flip code inside the
> > > new function.
> > > 
> > > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > > ---
> > >   drivers/staging/vboxvideo/vbox_mode.c | 121 +++++++++++++-------------
> > >   1 file changed, 62 insertions(+), 59 deletions(-)
> > 
> > This doesn't apply to my tree.  Does it need to go on top of the
> > previous patches you sent for 4.19-final?
> 
> Yes this goes on top of the fixes for 4.19-final.

Ok, thanks for confirming.

greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2018-09-12  8:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11  7:15 [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Hans de Goede
2018-09-11  7:15 ` [PATCH 2/4] staging: vboxvideo: Skip currrent crtc when updating crtcs Hans de Goede
2018-09-11  7:15 ` [PATCH 3/4] staging: vboxvideo: Remove vboxfb_create_object() wrapper Hans de Goede
2018-09-11  7:15 ` [PATCH 4/4] staging: vboxvideo: Drop vbox_bo_unref() helper Hans de Goede
2018-09-11 18:46 ` [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Greg Kroah-Hartman
2018-09-12  7:54   ` Hans de Goede
2018-09-12  8:20     ` Greg Kroah-Hartman

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.