From patchwork Tue Sep 18 17:44:35 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: 10604667 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 16E571508 for ; Tue, 18 Sep 2018 17:45:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 063DC289DA for ; Tue, 18 Sep 2018 17:45:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE9A82B2FF; Tue, 18 Sep 2018 17:45:24 +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 954C8289DA for ; Tue, 18 Sep 2018 17:45:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D0426E1D4; Tue, 18 Sep 2018 17:45:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 015056E446 for ; Tue, 18 Sep 2018 17:44:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B5DD3084036; Tue, 18 Sep 2018 17:44:54 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39B521001F5B; Tue, 18 Sep 2018 17:44:53 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman Subject: [PATCH 09/12] staging: vboxvideo: Move pin / unpin of fb out of vbox_crtc_set_base_and_mode Date: Tue, 18 Sep 2018 19:44:35 +0200 Message-Id: <20180918174438.19780-10-hdegoede@redhat.com> In-Reply-To: <20180918174438.19780-1-hdegoede@redhat.com> References: <20180918174438.19780-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 18 Sep 2018 17:44:54 +0000 (UTC) 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 Move pin / unpin of fb out of vbox_crtc_set_base_and_mode() so that it can be used to implement the atomic_update drm_plane_helper_func for the primary plane. Signed-off-by: Hans de Goede --- drivers/staging/vboxvideo/vbox_drv.h | 5 +++ drivers/staging/vboxvideo/vbox_mode.c | 52 ++++++++++++++------------- drivers/staging/vboxvideo/vbox_ttm.c | 5 --- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index 5034c6bd5445..6a4d3b382e79 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -220,6 +220,11 @@ static inline struct vbox_bo *vbox_bo(struct ttm_buffer_object *bo) #define to_vbox_obj(x) container_of(x, struct vbox_gem_object, base) +static inline u64 vbox_bo_gpu_offset(struct vbox_bo *bo) +{ + return bo->bo.offset; +} + int vbox_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args); diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 6d7a89524fbf..1a2416a59fe0 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -255,28 +255,18 @@ static void vbox_fb_unpin(struct drm_framebuffer *fb) vbox_bo_unreserve(bo); } -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) +static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, + struct drm_framebuffer *fb, + struct drm_display_mode *mode, + int x, int y) { + struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj); struct vbox_private *vbox = crtc->dev->dev_private; struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc); - u64 gpu_addr; - int ret; - - /* Prepare: pin the new framebuffer bo */ - ret = vbox_fb_pin(new_fb, TTM_PL_FLAG_VRAM, &gpu_addr); - if (ret) { - DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret); - return ret; - } - /* Commit: Update hardware to use the new fb */ mutex_lock(&vbox->hw_mutex); - vbox_crtc->fb_offset = gpu_addr; + vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo); /* vbox_do_modeset() checks vbox->single_framebuffer so update it now */ if (mode && vbox_set_up_input_mapping(vbox)) { @@ -299,11 +289,6 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, 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, @@ -311,8 +296,19 @@ 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) { - return vbox_crtc_set_base_and_mode(crtc, old_fb, CRTC_FB(crtc), - mode, x, y); + int ret; + + ret = vbox_fb_pin(CRTC_FB(crtc), TTM_PL_FLAG_VRAM, NULL); + if (ret) { + DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret); + return ret; + } + + vbox_crtc_set_base_and_mode(crtc, CRTC_FB(crtc), mode, x, y); + + vbox_fb_unpin(old_fb); + + return 0; } static int vbox_crtc_page_flip(struct drm_crtc *crtc, @@ -324,9 +320,15 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc, unsigned long flags; int rc; - rc = vbox_crtc_set_base_and_mode(crtc, CRTC_FB(crtc), fb, NULL, 0, 0); - if (rc) + rc = vbox_fb_pin(fb, TTM_PL_FLAG_VRAM, NULL); + if (rc) { + DRM_WARN("Error %d pinning new fb, out of video mem?\n", rc); return rc; + } + + vbox_crtc_set_base_and_mode(crtc, fb, NULL, 0, 0); + + vbox_fb_unpin(CRTC_FB(crtc)); spin_lock_irqsave(&crtc->dev->event_lock, flags); diff --git a/drivers/staging/vboxvideo/vbox_ttm.c b/drivers/staging/vboxvideo/vbox_ttm.c index 7b8eac30faca..0e14556dcd6b 100644 --- a/drivers/staging/vboxvideo/vbox_ttm.c +++ b/drivers/staging/vboxvideo/vbox_ttm.c @@ -343,11 +343,6 @@ int vbox_bo_create(struct vbox_private *vbox, int size, int align, return ret; } -static inline u64 vbox_bo_gpu_offset(struct vbox_bo *bo) -{ - return bo->bo.offset; -} - int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr) { struct ttm_operation_ctx ctx = { false, false };