From patchwork Fri Jul 13 15:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 10523643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90E3D6028E for ; Fri, 13 Jul 2018 15:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80D0629D72 for ; Fri, 13 Jul 2018 15:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F66529D87; Fri, 13 Jul 2018 15:50:41 +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 2FEA129D72 for ; Fri, 13 Jul 2018 15:50:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AAD16E2E6; Fri, 13 Jul 2018 15:50:40 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5718E6E0EE; Fri, 13 Jul 2018 15:50:39 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 08:50:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,348,1526367600"; d="scan'208";a="66732611" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga002.fm.intel.com with SMTP; 13 Jul 2018 08:50:36 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 13 Jul 2018 18:50:35 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Date: Fri, 13 Jul 2018 18:50:32 +0300 Message-Id: <20180713155035.3866-1-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/4] drm: Move page_flip fb lookup earlier X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Ville Syrjälä No reason that I can see to delay the fb lookup this late. Moving it earlier allows us to keep it outside of the lock retry loop. This makes error handling and whatnot simpler. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_plane.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 6153cbda239f..924830071307 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1009,7 +1009,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, struct drm_mode_crtc_page_flip_target *page_flip = data; struct drm_crtc *crtc; struct drm_plane *plane; - struct drm_framebuffer *fb = NULL, *old_fb; + struct drm_framebuffer *fb, *old_fb; struct drm_pending_vblank_event *e = NULL; u32 target_vblank = page_flip->sequence; struct drm_modeset_acquire_ctx ctx; @@ -1055,16 +1055,16 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, DRM_DEBUG("Invalid absolute flip target %u, " "must be <= %u\n", target_vblank, current_vblank + 1); - drm_crtc_vblank_put(crtc); - return -EINVAL; + ret = -EINVAL; + goto put_vblank; } break; case DRM_MODE_PAGE_FLIP_TARGET_RELATIVE: if (target_vblank != 0 && target_vblank != 1) { DRM_DEBUG("Invalid relative flip target %u, " "must be 0 or 1\n", target_vblank); - drm_crtc_vblank_put(crtc); - return -EINVAL; + ret = -EINVAL; + goto put_vblank; } target_vblank += current_vblank; break; @@ -1075,7 +1075,14 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, } } else if (crtc->funcs->page_flip == NULL || (page_flip->flags & DRM_MODE_PAGE_FLIP_TARGET)) { - return -EINVAL; + ret = -EINVAL; + goto put_vblank; + } + + fb = drm_framebuffer_lookup(dev, file_priv, page_flip->fb_id); + if (!fb) { + ret = -ENOENT; + goto put_vblank; } drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); @@ -1101,12 +1108,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, goto out; } - fb = drm_framebuffer_lookup(dev, file_priv, page_flip->fb_id); - if (!fb) { - ret = -ENOENT; - goto out; - } - if (plane->state) { const struct drm_plane_state *state = plane->state; @@ -1170,8 +1171,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, } out: - if (fb) - drm_framebuffer_put(fb); if (plane->old_fb) drm_framebuffer_put(plane->old_fb); plane->old_fb = NULL; @@ -1185,6 +1184,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); + drm_framebuffer_put(fb); +put_vblank: if (ret && crtc->funcs->page_flip_target) drm_crtc_vblank_put(crtc);