From patchwork Fri Jul 13 15:50:35 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: 10523655 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 F41366032C for ; Fri, 13 Jul 2018 15:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A7329DA1 for ; Fri, 13 Jul 2018 15:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D86BD29D39; Fri, 13 Jul 2018 15:50:54 +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 9452929D39 for ; Fri, 13 Jul 2018 15:50:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 986176F2D6; Fri, 13 Jul 2018 15:50:49 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id E230E6F2D6; Fri, 13 Jul 2018 15:50:47 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 08:50:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,348,1526367600"; d="scan'208";a="64481774" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by FMSMGA003.fm.intel.com with SMTP; 13 Jul 2018 08:50:45 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 13 Jul 2018 18:50:44 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Date: Fri, 13 Jul 2018 18:50:35 +0300 Message-Id: <20180713155035.3866-4-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180713155035.3866-1-ville.syrjala@linux.intel.com> References: <20180713155035.3866-1-ville.syrjala@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 4/4] drm: Simplify the setplane/pageflip old_fb handling further 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ä Instead of doing the things in a convoluted way with the failure and success paths mixed up let's just clear old_fb when we encounter an error and bail out immediately. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_plane.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index e3f2ddf7deae..406f11281d61 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -655,12 +655,13 @@ static int __setplane_internal(struct drm_plane *plane, if (!fb) { plane->old_fb = plane->fb; ret = plane->funcs->disable_plane(plane, ctx); - if (!ret) { - plane->crtc = NULL; - plane->fb = NULL; - } else { + if (ret) { plane->old_fb = NULL; + return ret; } + + plane->crtc = NULL; + plane->fb = NULL; goto out; } @@ -668,20 +669,22 @@ static int __setplane_internal(struct drm_plane *plane, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h); if (ret) - goto out; + return ret; plane->old_fb = plane->fb; + ret = plane->funcs->update_plane(plane, crtc, fb, crtc_x, crtc_y, crtc_w, crtc_h, src_x, src_y, src_w, src_h, ctx); - if (!ret) { - plane->crtc = crtc; - plane->fb = fb; - drm_framebuffer_get(plane->fb); - } else { + if (ret) { plane->old_fb = NULL; + return ret; } + plane->crtc = crtc; + plane->fb = fb; + drm_framebuffer_get(plane->fb); + out: if (plane->old_fb) drm_framebuffer_put(plane->old_fb); @@ -1049,15 +1052,14 @@ static int page_flip_internal(struct drm_crtc *crtc, target_vblank, ctx); else ret = crtc->funcs->page_flip(crtc, fb, e, flags, ctx); - if (ret) { - /* Keep the old fb, don't unref it. */ plane->old_fb = NULL; - } else { - plane->fb = fb; - drm_framebuffer_get(plane->fb); + return ret; } + plane->fb = fb; + drm_framebuffer_get(plane->fb); + if (plane->old_fb) drm_framebuffer_put(plane->old_fb); plane->old_fb = NULL;