Maarten Lankhorst
2018-Nov-12 15:01 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
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 <maarten.lankhorst at linux.intel.com> Cc: Harry Wentland <harry.wentland at amd.com> Cc: Leo Li <sunpeng.li at amd.com> Cc: Alex Deucher <alexander.deucher at amd.com> Cc: "Christian König" <christian.koenig at amd.com> Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> Cc: David Airlie <airlied at linux.ie> Cc: Liviu Dudau <liviu.dudau at arm.com> Cc: Brian Starkey <brian.starkey at arm.com> Cc: Mali DP Maintainers <malidp at foss.arm.com> Cc: Boris Brezillon <boris.brezillon at bootlin.com> Cc: Nicolas Ferre <nicolas.ferre at microchip.com> Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> Cc: Ludovic Desroches <ludovic.desroches at microchip.com> Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> Cc: Maxime Ripard <maxime.ripard at bootlin.com> Cc: Sean Paul <sean at poorly.run> Cc: Jani Nikula <jani.nikula at linux.intel.com> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> Cc: Philipp Zabel <p.zabel at pengutronix.de> Cc: CK Hu <ck.hu at mediatek.com> Cc: Matthias Brugger <matthias.bgg at gmail.com> Cc: Rob Clark <robdclark at gmail.com> Cc: Ben Skeggs <bskeggs at redhat.com> Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> Cc: Sandy Huang <hjc at rock-chips.com> Cc: "Heiko Stübner" <heiko at sntech.de> Cc: Thierry Reding <thierry.reding at gmail.com> Cc: Jonathan Hunter <jonathanh at nvidia.com> Cc: Eric Anholt <eric at anholt.net> Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> Cc: Sinclair Yeh <syeh at vmware.com> Cc: Thomas Hellstrom <thellstrom at vmware.com> Cc: Tony Cheng <Tony.Cheng at amd.com> Cc: Shirish S <shirish.s at amd.com> Cc: Mikita Lipski <mikita.lipski at amd.com> Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> Cc: David Francis <David.Francis at amd.com> Cc: Anthony Koo <Anthony.Koo at amd.com> Cc: Jeykumar Sankaran <jsanka at codeaurora.org> Cc: Jordan Crouse <jcrouse at codeaurora.org> Cc: Bruce Wang <bzwang at chromium.org> Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> Cc: Archit Taneja <architt at codeaurora.org> Cc: Steve Kowalik <steven at wedontsleep.org> Cc: Carsten Behling <carsten.behling at googlemail.com> Cc: Haneen Mohammed <hamohammed.sa at gmail.com> Cc: Daniel Vetter <daniel.vetter at ffwll.ch> Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> Cc: Mahesh Kumar <mahesh1.kumar at intel.com> Cc: amd-gfx at lists.freedesktop.org Cc: dri-devel at lists.freedesktop.org Cc: linux-kernel at vger.kernel.org Cc: linux-arm-kernel at lists.infradead.org Cc: intel-gfx at lists.freedesktop.org Cc: linux-mediatek at lists.infradead.org Cc: linux-arm-msm at vger.kernel.org Cc: freedreno at lists.freedesktop.org Cc: nouveau at lists.freedesktop.org Cc: linux-renesas-soc at vger.kernel.org Cc: linux-rockchip at lists.infradead.org Cc: linux-tegra at vger.kernel.org --- .../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); -- 2.19.1
Boris Brezillon
2018-Nov-12 15:11 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, 12 Nov 2018 16:01:14 +0100 Maarten Lankhorst <maarten.lankhorst at linux.intel.com> wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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 +--For the atmel-hlcdc driver Acked-by: Boris Brezillon <boris.brezillon at bootlin.com>
Li, Sun peng (Leo)
2018-Nov-12 15:23 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On 2018-11-12 10:01 AM, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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^ Do you mean drm_crtc->state? For amdgpu_dm, Acked-by: Leo Li <sunpeng.li at amd.com> Leo> + * 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); >
Heiko Stuebner
2018-Nov-12 15:36 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
Am Montag, 12. November 2018, 16:01:14 CET schrieb Maarten Lankhorst:> 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 <maarten.lankhorst at linux.intel.com>> 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)for the Rockchip-part Acked-by: Heiko Stuebner <heiko at sntech.de>
Thierry Reding
2018-Nov-12 15:36 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, Nov 12, 2018 at 04:01:14PM +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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(-)Looks good to me: Acked-by: Thierry Reding <treding at nvidia.com> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20181112/a3825d06/attachment.sig>
Wentland, Harry
2018-Nov-12 16:02 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On 2018-11-12 10:01 a.m., Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.orgFor amdgpu_dm and core changes Reviewed-by: Harry Wentland <harry.wentland at amd.com> Harry> --- > .../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); >
Sean Paul
2018-Nov-12 16:11 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, Nov 12, 2018 at 04:01:14PM +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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))Can you give this the same treatment as the other allocation checks?> 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; > - }You're changing behavior slightly here. If the allocation fails in the old code, you just continue on (and presumably use-after-free on the next crtc->state access). Whereas now you're going to just deref NULL. Neither one are really desireable :) So you probably want to continue checking the allocation and clear crtc->state if it fails. After that you can call helper_crtc_reset with &state->base.> + __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); > -- > 2.19.1 >-- Sean Paul, Software Engineer, Google / Chromium OS
Maarten Lankhorst
2018-Nov-12 17:33 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
Op 12-11-18 om 17:11 schreef Sean Paul:> On Mon, Nov 12, 2018 at 04:01:14PM +0100, Maarten Lankhorst wrote: >> 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 <maarten.lankhorst at linux.intel.com> >> Cc: Harry Wentland <harry.wentland at amd.com> >> Cc: Leo Li <sunpeng.li at amd.com> >> Cc: Alex Deucher <alexander.deucher at amd.com> >> Cc: "Christian König" <christian.koenig at amd.com> >> Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> >> Cc: David Airlie <airlied at linux.ie> >> Cc: Liviu Dudau <liviu.dudau at arm.com> >> Cc: Brian Starkey <brian.starkey at arm.com> >> Cc: Mali DP Maintainers <malidp at foss.arm.com> >> Cc: Boris Brezillon <boris.brezillon at bootlin.com> >> Cc: Nicolas Ferre <nicolas.ferre at microchip.com> >> Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> >> Cc: Ludovic Desroches <ludovic.desroches at microchip.com> >> Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> >> Cc: Maxime Ripard <maxime.ripard at bootlin.com> >> Cc: Sean Paul <sean at poorly.run> >> Cc: Jani Nikula <jani.nikula at linux.intel.com> >> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> >> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> >> Cc: Philipp Zabel <p.zabel at pengutronix.de> >> Cc: CK Hu <ck.hu at mediatek.com> >> Cc: Matthias Brugger <matthias.bgg at gmail.com> >> Cc: Rob Clark <robdclark at gmail.com> >> Cc: Ben Skeggs <bskeggs at redhat.com> >> Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> >> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> >> Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> >> Cc: Sandy Huang <hjc at rock-chips.com> >> Cc: "Heiko Stübner" <heiko at sntech.de> >> Cc: Thierry Reding <thierry.reding at gmail.com> >> Cc: Jonathan Hunter <jonathanh at nvidia.com> >> Cc: Eric Anholt <eric at anholt.net> >> Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> >> Cc: Sinclair Yeh <syeh at vmware.com> >> Cc: Thomas Hellstrom <thellstrom at vmware.com> >> Cc: Tony Cheng <Tony.Cheng at amd.com> >> Cc: Shirish S <shirish.s at amd.com> >> Cc: Mikita Lipski <mikita.lipski at amd.com> >> Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> >> Cc: David Francis <David.Francis at amd.com> >> Cc: Anthony Koo <Anthony.Koo at amd.com> >> Cc: Jeykumar Sankaran <jsanka at codeaurora.org> >> Cc: Jordan Crouse <jcrouse at codeaurora.org> >> Cc: Bruce Wang <bzwang at chromium.org> >> Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> >> Cc: Archit Taneja <architt at codeaurora.org> >> Cc: Steve Kowalik <steven at wedontsleep.org> >> Cc: Carsten Behling <carsten.behling at googlemail.com> >> Cc: Haneen Mohammed <hamohammed.sa at gmail.com> >> Cc: Daniel Vetter <daniel.vetter at ffwll.ch> >> Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> >> Cc: Mahesh Kumar <mahesh1.kumar at intel.com> >> Cc: amd-gfx at lists.freedesktop.org >> Cc: dri-devel at lists.freedesktop.org >> Cc: linux-kernel at vger.kernel.org >> Cc: linux-arm-kernel at lists.infradead.org >> Cc: intel-gfx at lists.freedesktop.org >> Cc: linux-mediatek at lists.infradead.org >> Cc: linux-arm-msm at vger.kernel.org >> Cc: freedreno at lists.freedesktop.org >> Cc: nouveau at lists.freedesktop.org >> Cc: linux-renesas-soc at vger.kernel.org >> Cc: linux-rockchip at lists.infradead.org >> Cc: linux-tegra at vger.kernel.org >> --- >> .../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)) > Can you give this the same treatment as the other allocation checks?Yeah sure, the reason I didn't was because all of the amdgpu reset functions worked like that. I'll send a preparation patch to fix that up. ~Maarten
Ville Syrjälä
2018-Nov-12 18:21 UTC
[Nouveau] [Intel-gfx] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, Nov 12, 2018 at 04:01:14PM +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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(-) ><snip>> 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;So apparently crtc and connector reset expect a NULL state, but plane reset does not. That seems a bit inconsistent. Migth be nice to get them all to agree on what is the correct behaviour.> + > + 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);intel_crtc_init() could use the same treatment. And intel_create_plane_state() could use the plane reset. In fact it looks like we aren't intializing plane constant alpha at all. So it'll start out as zero which probably isn't what most people would expect. I also wonder if this patch shouldn't be split up more. Just in case there's some unforseen regression somewhere I'd hate to see the entire thing get reverted. -- Ville Syrjälä Intel
Liviu Dudau
2018-Nov-12 20:01 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, Nov 12, 2018 at 04:01:14PM +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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,For the malidp changes: Acked-by: Liviu Dudau <liviu.dudau at arm.com> Best regards, Liviu> 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); > -- > 2.19.1 > > _______________________________________________ > dri-devel mailing list > dri-devel at lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel-- ===================| I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
Rodrigo Siqueira
2018-Nov-18 13:31 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On 11/12, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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); > }I tested the changes with IGT, and everything looks fine for VKMS. Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com>> 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); > -- > 2.19.1 >-- Rodrigo Siqueira https://siqueira.tech Graduate Student Department of Computer Science University of São Paulo
CK Hu
2018-Nov-20 07:08 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, 2018-11-12 at 16:01 +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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); > }For the mediatek drm driver, Reviewed-by: CK Hu <ck.hu at mediatek.com>> > 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);
Philipp Zabel
2018-Nov-20 09:30 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On Mon, 2018-11-12 at 16:01 +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com>[...]> 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)For the imx-drm and mediatek drivers, Acked-by: Philipp Zabel <p.zabel at pengutronix.de> regards Philipp
Lyude Paul
2018-Nov-21 18:41 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
For the nouveau and drm core changes Reviewed-by: Lyude Paul <lyude at redhat.com> On Mon, 2018-11-12 at 16:01 +0100, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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);-- Cheers, Lyude Paul
Kieran Bingham
2018-Nov-21 21:06 UTC
[Nouveau] [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
On 12/11/2018 15:01, Maarten Lankhorst wrote:> 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 <maarten.lankhorst at linux.intel.com> > Cc: Harry Wentland <harry.wentland at amd.com> > Cc: Leo Li <sunpeng.li at amd.com> > Cc: Alex Deucher <alexander.deucher at amd.com> > Cc: "Christian König" <christian.koenig at amd.com> > Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com> > Cc: David Airlie <airlied at linux.ie> > Cc: Liviu Dudau <liviu.dudau at arm.com> > Cc: Brian Starkey <brian.starkey at arm.com> > Cc: Mali DP Maintainers <malidp at foss.arm.com> > Cc: Boris Brezillon <boris.brezillon at bootlin.com> > Cc: Nicolas Ferre <nicolas.ferre at microchip.com> > Cc: Alexandre Belloni <alexandre.belloni at bootlin.com> > Cc: Ludovic Desroches <ludovic.desroches at microchip.com> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com> > Cc: Maxime Ripard <maxime.ripard at bootlin.com> > Cc: Sean Paul <sean at poorly.run> > Cc: Jani Nikula <jani.nikula at linux.intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com> > Cc: Philipp Zabel <p.zabel at pengutronix.de> > Cc: CK Hu <ck.hu at mediatek.com> > Cc: Matthias Brugger <matthias.bgg at gmail.com> > Cc: Rob Clark <robdclark at gmail.com> > Cc: Ben Skeggs <bskeggs at redhat.com> > Cc: Tomi Valkeinen <tomi.valkeinen at ti.com> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com> > Cc: Sandy Huang <hjc at rock-chips.com> > Cc: "Heiko Stübner" <heiko at sntech.de> > Cc: Thierry Reding <thierry.reding at gmail.com> > Cc: Jonathan Hunter <jonathanh at nvidia.com> > Cc: Eric Anholt <eric at anholt.net> > Cc: VMware Graphics <linux-graphics-maintainer at vmware.com> > Cc: Sinclair Yeh <syeh at vmware.com> > Cc: Thomas Hellstrom <thellstrom at vmware.com> > Cc: Tony Cheng <Tony.Cheng at amd.com> > Cc: Shirish S <shirish.s at amd.com> > Cc: Mikita Lipski <mikita.lipski at amd.com> > Cc: Bhawanpreet Lakha <Bhawanpreet.Lakha at amd.com> > Cc: David Francis <David.Francis at amd.com> > Cc: Anthony Koo <Anthony.Koo at amd.com> > Cc: Jeykumar Sankaran <jsanka at codeaurora.org> > Cc: Jordan Crouse <jcrouse at codeaurora.org> > Cc: Bruce Wang <bzwang at chromium.org> > Cc: Sravanthi Kollukuduru <skolluku at codeaurora.org> > Cc: Archit Taneja <architt at codeaurora.org> > Cc: Steve Kowalik <steven at wedontsleep.org> > Cc: Carsten Behling <carsten.behling at googlemail.com> > Cc: Haneen Mohammed <hamohammed.sa at gmail.com> > Cc: Daniel Vetter <daniel.vetter at ffwll.ch> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo at gmail.com> > Cc: Mahesh Kumar <mahesh1.kumar at intel.com> > Cc: amd-gfx at lists.freedesktop.org > Cc: dri-devel at lists.freedesktop.org > Cc: linux-kernel at vger.kernel.org > Cc: linux-arm-kernel at lists.infradead.org > Cc: intel-gfx at lists.freedesktop.org > Cc: linux-mediatek at lists.infradead.org > Cc: linux-arm-msm at vger.kernel.org > Cc: freedreno at lists.freedesktop.org > Cc: nouveau at lists.freedesktop.org > Cc: linux-renesas-soc at vger.kernel.org > Cc: linux-rockchip at lists.infradead.org > Cc: linux-tegra at vger.kernel.org > --- > .../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; > }For rcar-du: Acked-by: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com>> 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); >
Reasonably Related Threads
- [PATCH 2/2] drm/atomic: Create and use __drm_atomic_helper_crtc_reset() everywhere
- [v3 PATCH 0/3] Allow ASYNC flip with atomic helpers.
- [PATCH v5 0/3] Allow ASYNC flip with atomic helpers.
- [PATCH v4 0/3] Allow ASYNC flip with atomic helpers.
- [PATCH 0/4] Allow ASYNC flip with atomic helpers.