From patchwork Tue Sep 11 07:15:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10595157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5D8B6CB for ; Tue, 11 Sep 2018 07:15:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC65E28D97 for ; Tue, 11 Sep 2018 07:15:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CE9A290E7; Tue, 11 Sep 2018 07:15:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25A8E28D97 for ; Tue, 11 Sep 2018 07:15:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F148F6E329; Tue, 11 Sep 2018 07:15:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3D3E6E329 for ; Tue, 11 Sep 2018 07:15:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D8D880825A9; Tue, 11 Sep 2018 07:15:47 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34B5410EE79B; Tue, 11 Sep 2018 07:15:45 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman Subject: [PATCH 1/4] staging: vboxvideo: Fix modeset / page_flip error handling Date: Tue, 11 Sep 2018 09:15:41 +0200 Message-Id: <20180911071544.17190-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 11 Sep 2018 07:15:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 11 Sep 2018 07:15:47 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Hans de Goede , Michael Thayer , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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, From patchwork Tue Sep 11 07:15:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10595163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5DD46CB for ; Tue, 11 Sep 2018 07:15:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0FF228D97 for ; Tue, 11 Sep 2018 07:15:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C51ED290E7; Tue, 11 Sep 2018 07:15:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7EC6628D97 for ; Tue, 11 Sep 2018 07:15:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7D9C6E332; Tue, 11 Sep 2018 07:15:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 128326E32C for ; Tue, 11 Sep 2018 07:15:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35A12401EF36; Tue, 11 Sep 2018 07:15:48 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55346104947B; Tue, 11 Sep 2018 07:15:47 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman Subject: [PATCH 2/4] staging: vboxvideo: Skip currrent crtc when updating crtcs Date: Tue, 11 Sep 2018 09:15:42 +0200 Message-Id: <20180911071544.17190-2-hdegoede@redhat.com> In-Reply-To: <20180911071544.17190-1-hdegoede@redhat.com> References: <20180911071544.17190-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 11 Sep 2018 07:15:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 11 Sep 2018 07:15:48 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Hans de Goede , Michael Thayer , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); } } From patchwork Tue Sep 11 07:15:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10595159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2B7B14E0 for ; Tue, 11 Sep 2018 07:15:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DBE628D97 for ; Tue, 11 Sep 2018 07:15:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 921FA290E7; Tue, 11 Sep 2018 07:15:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 548C428D97 for ; Tue, 11 Sep 2018 07:15:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A4D56E32E; Tue, 11 Sep 2018 07:15:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2686C6E32E for ; Tue, 11 Sep 2018 07:15:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ECC1401EF3C; Tue, 11 Sep 2018 07:15:49 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D5021134CCC; Tue, 11 Sep 2018 07:15:48 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman Subject: [PATCH 3/4] staging: vboxvideo: Remove vboxfb_create_object() wrapper Date: Tue, 11 Sep 2018 09:15:43 +0200 Message-Id: <20180911071544.17190-3-hdegoede@redhat.com> In-Reply-To: <20180911071544.17190-1-hdegoede@redhat.com> References: <20180911071544.17190-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 11 Sep 2018 07:15:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 11 Sep 2018 07:15:49 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Hans de Goede , Michael Thayer , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; From patchwork Tue Sep 11 07:15:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10595161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F44D14E0 for ; Tue, 11 Sep 2018 07:15:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE0D628D97 for ; Tue, 11 Sep 2018 07:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2689290E7; Tue, 11 Sep 2018 07:15:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ACAFD28D97 for ; Tue, 11 Sep 2018 07:15:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 536FD6E330; Tue, 11 Sep 2018 07:15:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2FBCB6E32F for ; Tue, 11 Sep 2018 07:15:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69A954B75B; Tue, 11 Sep 2018 07:15:50 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-90.ams2.redhat.com [10.36.117.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85E531102E1F; Tue, 11 Sep 2018 07:15:49 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman Subject: [PATCH 4/4] staging: vboxvideo: Drop vbox_bo_unref() helper Date: Tue, 11 Sep 2018 09:15:44 +0200 Message-Id: <20180911071544.17190-4-hdegoede@redhat.com> In-Reply-To: <20180911071544.17190-1-hdegoede@redhat.com> References: <20180911071544.17190-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 11 Sep 2018 07:15:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 11 Sep 2018 07:15:50 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Hans de Goede , Michael Thayer , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Drop the unnecessary vbox_bo_unref() helper and directly call ttm_bo_put() at the single call site. Signed-off-by: Hans de Goede --- 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)