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.lankho...@linux.intel.com>
> Cc: Harry Wentland <harry.wentl...@amd.com>
> Cc: Leo Li <sunpeng...@amd.com>
> Cc: Alex Deucher <alexander.deuc...@amd.com>
> Cc: "Christian König" <christian.koe...@amd.com>
> Cc: "David (ChunMing) Zhou" <david1.z...@amd.com>
> Cc: David Airlie <airl...@linux.ie>
> Cc: Liviu Dudau <liviu.du...@arm.com>
> Cc: Brian Starkey <brian.star...@arm.com>
> Cc: Mali DP Maintainers <mal...@foss.arm.com>
> Cc: Boris Brezillon <boris.brezil...@bootlin.com>
> Cc: Nicolas Ferre <nicolas.fe...@microchip.com>
> Cc: Alexandre Belloni <alexandre.bell...@bootlin.com>
> Cc: Ludovic Desroches <ludovic.desroc...@microchip.com>
> Cc: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
> Cc: Maxime Ripard <maxime.rip...@bootlin.com>
> Cc: Sean Paul <s...@poorly.run>
> Cc: Jani Nikula <jani.nik...@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahti...@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.v...@intel.com>
> Cc: Philipp Zabel <p.za...@pengutronix.de>
> Cc: CK Hu <ck...@mediatek.com>
> Cc: Matthias Brugger <matthias....@gmail.com>
> Cc: Rob Clark <robdcl...@gmail.com>
> Cc: Ben Skeggs <bske...@redhat.com>
> Cc: Tomi Valkeinen <tomi.valkei...@ti.com>
> Cc: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Cc: Kieran Bingham <kieran.bingham+rene...@ideasonboard.com>
> Cc: Sandy Huang <h...@rock-chips.com>
> Cc: "Heiko Stübner" <he...@sntech.de>
> Cc: Thierry Reding <thierry.red...@gmail.com>
> Cc: Jonathan Hunter <jonath...@nvidia.com>
> Cc: Eric Anholt <e...@anholt.net>
> Cc: VMware Graphics <linux-graphics-maintai...@vmware.com>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Cc: Tony Cheng <tony.ch...@amd.com>
> Cc: Shirish S <shiris...@amd.com>
> Cc: Mikita Lipski <mikita.lip...@amd.com>
> Cc: Bhawanpreet Lakha <bhawanpreet.la...@amd.com>
> Cc: David Francis <david.fran...@amd.com>
> Cc: Anthony Koo <anthony....@amd.com>
> Cc: Jeykumar Sankaran <jsa...@codeaurora.org>
> Cc: Jordan Crouse <jcro...@codeaurora.org>
> Cc: Bruce Wang <bzw...@chromium.org>
> Cc: Sravanthi Kollukuduru <skoll...@codeaurora.org>
> Cc: Archit Taneja <arch...@codeaurora.org>
> Cc: Steve Kowalik <ste...@wedontsleep.org>
> Cc: Carsten Behling <carsten.behl...@googlemail.com>
> Cc: Haneen Mohammed <hamohammed...@gmail.com>
> Cc: Daniel Vetter <daniel.vet...@ffwll.ch>
> Cc: Rodrigo Siqueira <rodrigosiqueiram...@gmail.com>
> Cc: Mahesh Kumar <mahesh1.ku...@intel.com>
> Cc: amd-...@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-ker...@vger.kernel.org
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: intel-...@lists.freedesktop.org
> Cc: linux-media...@lists.infradead.org
> Cc: linux-arm-...@vger.kernel.org
> Cc: freedr...@lists.freedesktop.org
> Cc: nouv...@lists.freedesktop.org
> Cc: linux-renesas-...@vger.kernel.org
> Cc: linux-rockc...@lists.infradead.org
> Cc: linux-te...@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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to