From patchwork Mon Nov 12 15:01:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 10678781 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 387DB13BF for ; Mon, 12 Nov 2018 15:01:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 265A429DFB for ; Mon, 12 Nov 2018 15:01:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19C7829DD2; Mon, 12 Nov 2018 15:01:44 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08FE829D6C for ; Mon, 12 Nov 2018 15:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FnXkP6V01iqUXB3slPrYjSJgP5NAu5B2UjCCJRXdwhw=; b=RpXzoQH8EztSdB cKBEqJ26X2Irfb+slLfsoDaQNJtGzCKUo5I46e5STI042fXJka36M2qbqN3d6plugdDj+D91MfCwL TgLBZy85Gix7BuHnyJYeWnSaa+TY5ps0MkALO26NgcC4yi5bUe4RA8YvuAykrZrabT5EAJixUVs0v +cIJcv8qRI+4OfWh1Fdo1Z0XFErBDwQR834FA0lj2/CzC5gRett09U1mFetBhAYDV5F0VGT1RbL1n fsz00LIHI0QHJa3qzyfw8mehczfvaDfij3fgki209oR69NbWgxdSLa+SrUB6Cj2zJ9xwGz8y55vVL x719bKKVaJfSqb6ptNAQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMDif-0000Wg-KJ; Mon, 12 Nov 2018 15:01:41 +0000 Received: from mblankhorst.nl ([2a02:2308::216:3eff:fe92:dfa3]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMDiX-0000Uf-77; Mon, 12 Nov 2018 15:01:39 +0000 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere Date: Mon, 12 Nov 2018 16:01:14 +0100 Message-Id: <20181112150114.18395-2-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181112150114.18395-1-maarten.lankhorst@linux.intel.com> References: <20181112150114.18395-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181112_070133_536439_7A265388 X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haneen Mohammed , Alexandre Belloni , =?utf-8?q?Heiko_St=C3=83?= =?utf-8?q?=C2=BCbner?= , David Airlie , Daniel Vetter , Joonas Lahtinen , Liviu Dudau , Sandy Huang , Bhawanpreet Lakha , Eric Anholt , Thierry Reding , Laurent Pinchart , Shirish S , Anthony Koo , "David \(ChunMing\) Zhou" , Thomas Hellstrom , Sinclair Yeh , Tony Cheng , David Francis , amd-gfx@lists.freedesktop.org, Jonathan Hunter , Maxime Ripard , Ludovic Desroches , Tomi Valkeinen , Mali DP Maintainers , Ben Skeggs , linux-arm-msm@vger.kernel.org, CK Hu , VMware Graphics , Harry Wentland , Mahesh Kumar , linux-tegra@vger.kernel.org, Steve Kowalik , Leo Li , linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Maarten Lankhorst , Archit Taneja , Jani Nikula , Bruce Wang , Boris Brezillon , Jordan Crouse , linux-mediatek@lists.infradead.org, Rodrigo Vivi , Matthias Brugger , Jeykumar Sankaran , Mikita Lipski , Sean Paul , linux-arm-kernel@lists.infradead.org, Carsten Behling , Rodrigo Siqueira , nouveau@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Nicolas Ferre , =?utf-8?b?Q2hyaXN0aWFuIEvDg8K2?= =?utf-8?b?bmln?= , linux-renesas-soc@vger.kernel.org, Rob Clark , Kieran Bingham , Philipp Zabel , Alex Deucher , freedreno@lists.freedesktop.org, Brian Starkey , Sravanthi Kollukuduru Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We already have __drm_atomic_helper_connector_reset() and __drm_atomic_helper_plane_reset(), extend this to crtc as well. Most drivers already have a gpu reset hook, correct it. Nouveau already implemented its own __drm_atomic_helper_crtc_reset(), convert it to the common one. Signed-off-by: Maarten Lankhorst Cc: Harry Wentland Cc: Leo Li Cc: Alex Deucher Cc: "Christian König" Cc: "David (ChunMing) Zhou" Cc: David Airlie Cc: Liviu Dudau Cc: Brian Starkey Cc: Mali DP Maintainers Cc: Boris Brezillon Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Philipp Zabel Cc: CK Hu Cc: Matthias Brugger Cc: Rob Clark Cc: Ben Skeggs Cc: Tomi Valkeinen Cc: Laurent Pinchart Cc: Kieran Bingham Cc: Sandy Huang Cc: "Heiko Stübner" Cc: Thierry Reding Cc: Jonathan Hunter Cc: Eric Anholt Cc: VMware Graphics Cc: Sinclair Yeh Cc: Thomas Hellstrom Cc: Tony Cheng Cc: Shirish S Cc: Mikita Lipski Cc: Bhawanpreet Lakha Cc: David Francis Cc: Anthony Koo Cc: Jeykumar Sankaran Cc: Jordan Crouse Cc: Bruce Wang Cc: Sravanthi Kollukuduru Cc: Archit Taneja Cc: Steve Kowalik Cc: Carsten Behling Cc: Haneen Mohammed Cc: Daniel Vetter Cc: Rodrigo Siqueira Cc: Mahesh Kumar Cc: amd-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: intel-gfx@lists.freedesktop.org Cc: linux-mediatek@lists.infradead.org Cc: linux-arm-msm@vger.kernel.org Cc: freedreno@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Cc: linux-tegra@vger.kernel.org Acked-by: Boris Brezillon Acked-by: Leo Li Acked-by: Heiko Stuebner Acked-by: Thierry Reding Reviewed-by: Harry Wentland Acked-by: Liviu Dudau Reviewed-by: Rodrigo Siqueira Reviewed-by: CK Hu Acked-by: Philipp Zabel Reviewed-by: Lyude Paul Acked-by: Kieran Bingham --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 +-- drivers/gpu/drm/arm/malidp_crtc.c | 5 +-- .../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 5 +-- drivers/gpu/drm/drm_atomic_state_helper.c | 31 ++++++++++++++++--- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/imx/ipuv3-crtc.c | 5 +-- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 12 ++----- drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 6 +--- drivers/gpu/drm/nouveau/dispnv50/head.c | 13 ++------ drivers/gpu/drm/omapdrm/omap_crtc.c | 7 ++--- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 4 +-- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 7 +++-- drivers/gpu/drm/tegra/dc.c | 5 +-- drivers/gpu/drm/vc4/vc4_crtc.c | 8 ++--- drivers/gpu/drm/vkms/vkms_crtc.c | 7 +---- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 9 +----- include/drm/drm_atomic_state_helper.h | 2 ++ 18 files changed, 56 insertions(+), 81 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 5064768642f3..770a71726cd1 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2802,9 +2802,7 @@ static void dm_crtc_reset_state(struct drm_crtc *crtc) if (WARN_ON(!state)) return; - crtc->state = &state->base; - crtc->state->crtc = crtc; - + __drm_atomic_helper_crtc_reset(crtc, &state->base); } static struct drm_crtc_state * diff --git a/drivers/gpu/drm/arm/malidp_crtc.c b/drivers/gpu/drm/arm/malidp_crtc.c index e1b72782848c..9a924ff27148 100644 --- a/drivers/gpu/drm/arm/malidp_crtc.c +++ b/drivers/gpu/drm/arm/malidp_crtc.c @@ -474,10 +474,7 @@ static void malidp_crtc_reset(struct drm_crtc *crtc) kfree(state); state = kzalloc(sizeof(*state), GFP_KERNEL); - if (state) { - crtc->state = &state->base; - crtc->state->crtc = crtc; - } + __drm_atomic_helper_crtc_reset(crtc, &state->base); } static void malidp_crtc_destroy_state(struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index 96f4082671fe..8084d549c7d1 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c @@ -412,10 +412,7 @@ static void atmel_hlcdc_crtc_reset(struct drm_crtc *crtc) } state = kzalloc(sizeof(*state), GFP_KERNEL); - if (state) { - crtc->state = &state->base; - crtc->state->crtc = crtc; - } + __drm_atomic_helper_crtc_reset(crtc, &state->base); } static struct drm_crtc_state * diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 3ba996069d69..3eee1ca33fc5 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -55,6 +55,29 @@ * for these functions. */ +/** + * __drm_atomic_helper_crtc_reset - reset state on CRTC + * @crtc: drm CRTC + * @crtc_state: CRTC state to assign + * + * Initializes the newly allocated @crtc_state and assigns it to + * the &drm_conector->state pointer of @crtc, usually required when + * initializing the drivers or when called from the &drm_crtc_funcs.reset + * hook. + * + * This is useful for drivers that subclass the CRTC state. + */ +void +__drm_atomic_helper_crtc_reset(struct drm_crtc *crtc, + struct drm_crtc_state *crtc_state) +{ + if (crtc_state) + crtc_state->crtc = crtc; + + crtc->state = crtc_state; +} +EXPORT_SYMBOL(__drm_atomic_helper_crtc_reset); + /** * drm_atomic_helper_crtc_reset - default &drm_crtc_funcs.reset hook for CRTCs * @crtc: drm CRTC @@ -64,14 +87,14 @@ */ void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc) { + struct drm_crtc_state *crtc_state = + kzalloc(sizeof(*crtc->state), GFP_KERNEL); + if (crtc->state) __drm_atomic_helper_crtc_destroy_state(crtc->state); kfree(crtc->state); - crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL); - - if (crtc->state) - crtc->state->crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, crtc_state); } EXPORT_SYMBOL(drm_atomic_helper_crtc_reset); diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f383417571ec..907ffeb64781 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -15457,7 +15457,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) __drm_atomic_helper_crtc_destroy_state(&crtc_state->base); memset(crtc_state, 0, sizeof(*crtc_state)); - crtc_state->base.crtc = &crtc->base; + __drm_atomic_helper_crtc_reset(&crtc->base, &crtc_state->base); crtc_state->base.active = crtc_state->base.enable = dev_priv->display.get_pipe_config(crtc, crtc_state); diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c index 7d4b710b837a..8bc36f0d2b6b 100644 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c @@ -120,12 +120,9 @@ static void imx_drm_crtc_reset(struct drm_crtc *crtc) memset(state, 0, sizeof(*state)); } else { state = kzalloc(sizeof(*state), GFP_KERNEL); - if (!state) - return; - crtc->state = &state->base; } - state->base.crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, &state->base); } static struct drm_crtc_state *imx_drm_crtc_duplicate_state(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 92ecb9bf982c..a743e5ed1177 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -119,12 +119,9 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc) memset(state, 0, sizeof(*state)); } else { state = kzalloc(sizeof(*state), GFP_KERNEL); - if (!state) - return; - crtc->state = &state->base; } - state->base.crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, &state->base); } static struct drm_crtc_state *mtk_drm_crtc_duplicate_state(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index d4530d60767b..c86e603f486a 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -894,20 +894,12 @@ static void dpu_crtc_reset(struct drm_crtc *crtc) _dpu_crtc_set_suspend(crtc, false); /* remove previous state, if present */ - if (crtc->state) { + if (crtc->state) dpu_crtc_destroy_state(crtc, crtc->state); - crtc->state = 0; - } dpu_crtc = to_dpu_crtc(crtc); cstate = kzalloc(sizeof(*cstate), GFP_KERNEL); - if (!cstate) { - DPU_ERROR("failed to allocate state\n"); - return; - } - - cstate->base.crtc = crtc; - crtc->state = &cstate->base; + __drm_atomic_helper_crtc_reset(crtc, &cstate->base); } static void dpu_crtc_handle_power_event(u32 event_type, void *arg) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c index b1da9ce54379..138da66b1530 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c @@ -1019,11 +1019,7 @@ static void mdp5_crtc_reset(struct drm_crtc *crtc) } mdp5_cstate = kzalloc(sizeof(*mdp5_cstate), GFP_KERNEL); - - if (mdp5_cstate) { - mdp5_cstate->base.crtc = crtc; - crtc->state = &mdp5_cstate->base; - } + __drm_atomic_helper_crtc_reset(crtc, &mdp5_cstate->base); } static struct drm_crtc_state * diff --git a/drivers/gpu/drm/nouveau/dispnv50/head.c b/drivers/gpu/drm/nouveau/dispnv50/head.c index 4f57e5379796..341600406589 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/head.c +++ b/drivers/gpu/drm/nouveau/dispnv50/head.c @@ -418,16 +418,6 @@ nv50_head_atomic_duplicate_state(struct drm_crtc *crtc) return &asyh->state; } -static void -__drm_atomic_helper_crtc_reset(struct drm_crtc *crtc, - struct drm_crtc_state *state) -{ - if (crtc->state) - crtc->funcs->atomic_destroy_state(crtc, crtc->state); - crtc->state = state; - crtc->state->crtc = crtc; -} - static void nv50_head_reset(struct drm_crtc *crtc) { @@ -436,6 +426,9 @@ nv50_head_reset(struct drm_crtc *crtc) if (WARN_ON(!(asyh = kzalloc(sizeof(*asyh), GFP_KERNEL)))) return; + if (crtc->state) + crtc->funcs->atomic_destroy_state(crtc, crtc->state); + __drm_atomic_helper_crtc_reset(crtc, &asyh->state); } diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index caffc547ef97..9c5f8109913c 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -554,14 +554,13 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, static void omap_crtc_reset(struct drm_crtc *crtc) { + struct omap_crtc_state *crtc_state = + kzalloc(sizeof(*crtc_state), GFP_KERNEL); if (crtc->state) __drm_atomic_helper_crtc_destroy_state(crtc->state); kfree(crtc->state); - crtc->state = kzalloc(sizeof(struct omap_crtc_state), GFP_KERNEL); - - if (crtc->state) - crtc->state->crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base); } static struct drm_crtc_state * diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 17741843cf51..7beab22b4674 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -857,14 +857,12 @@ static void rcar_du_crtc_reset(struct drm_crtc *crtc) } state = kzalloc(sizeof(*state), GFP_KERNEL); + __drm_atomic_helper_crtc_reset(crtc, &state->state); if (state == NULL) return; state->crc.source = VSP1_DU_CRC_NONE; state->crc.index = 0; - - crtc->state = &state->state; - crtc->state->crtc = crtc; } static int rcar_du_crtc_enable_vblank(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index fb70fb486fbf..d2d5aa676084 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1071,13 +1071,14 @@ static void vop_crtc_destroy(struct drm_crtc *crtc) static void vop_crtc_reset(struct drm_crtc *crtc) { + struct rockchip_crtc_state *crtc_state = + kzalloc(sizeof(*crtc_state), GFP_KERNEL); + if (crtc->state) __drm_atomic_helper_crtc_destroy_state(crtc->state); kfree(crtc->state); - crtc->state = kzalloc(sizeof(struct rockchip_crtc_state), GFP_KERNEL); - if (crtc->state) - crtc->state->crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base); } static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index f80e82e16475..140d6191d8d2 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -1164,10 +1164,7 @@ static void tegra_crtc_reset(struct drm_crtc *crtc) crtc->state = NULL; state = kzalloc(sizeof(*state), GFP_KERNEL); - if (state) { - crtc->state = &state->base; - crtc->state->crtc = crtc; - } + __drm_atomic_helper_crtc_reset(crtc, &state->base); drm_crtc_vblank_reset(crtc); } diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c index cd226e63d557..76beeda157fc 100644 --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c @@ -998,12 +998,12 @@ static void vc4_crtc_destroy_state(struct drm_crtc *crtc, static void vc4_crtc_reset(struct drm_crtc *crtc) { - if (crtc->state) - vc4_crtc_destroy_state(crtc->state); + struct vc4_crtc_state *crtc_state = + kzalloc(sizeof(*crtc_state), GFP_KERNEL); - crtc->state = kzalloc(sizeof(struct vc4_crtc_state), GFP_KERNEL); if (crtc->state) - crtc->state->crtc = crtc; + vc4_crtc_destroy_state(crtc, crtc->state); + __drm_atomic_helper_crtc_reset(crtc, &crtc_state->base); } static const struct drm_crtc_funcs vc4_crtc_funcs = { diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 177bbcb38306..7b018f6ee971 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -98,15 +98,10 @@ static void vkms_atomic_crtc_reset(struct drm_crtc *crtc) vkms_state = to_vkms_crtc_state(crtc->state); __drm_atomic_helper_crtc_destroy_state(crtc->state); kfree(vkms_state); - crtc->state = NULL; } vkms_state = kzalloc(sizeof(*vkms_state), GFP_KERNEL); - if (!vkms_state) - return; - - crtc->state = &vkms_state->base; - crtc->state->crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, &vkms_state->base); } static struct drm_crtc_state * diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index e6b11f6ae2e4..2878bc0a4718 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -633,14 +633,7 @@ void vmw_du_crtc_reset(struct drm_crtc *crtc) } vcs = kzalloc(sizeof(*vcs), GFP_KERNEL); - - if (!vcs) { - DRM_ERROR("Cannot allocate vmw_crtc_state\n"); - return; - } - - crtc->state = &vcs->base; - crtc->state->crtc = crtc; + __drm_atomic_helper_crtc_reset(crtc, &vcs->base); } diff --git a/include/drm/drm_atomic_state_helper.h b/include/drm/drm_atomic_state_helper.h index 5b82ccfdb502..ab2b5a49948c 100644 --- a/include/drm/drm_atomic_state_helper.h +++ b/include/drm/drm_atomic_state_helper.h @@ -37,6 +37,8 @@ struct drm_private_state; struct drm_modeset_acquire_ctx; struct drm_device; +void __drm_atomic_helper_crtc_reset(struct drm_crtc *crtc, + struct drm_crtc_state *state); void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc); void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc, struct drm_crtc_state *state);