1. 26 Feb, 2021 3 commits
  2. 25 Feb, 2021 25 commits
  3. 24 Feb, 2021 10 commits
    • Maxime Ripard's avatar
      drm: Rename plane->state variables in atomic update and disable · 41016fe1
      Maxime Ripard authored
      Some drivers are storing the plane->state pointer in atomic_update and
      atomic_disable in a variable simply called state, while the state passed
      as an argument is called old_state.
      
      In order to ease subsequent reworks and to avoid confusing or
      inconsistent names, let's rename those variables to new_state.
      
      This was done using the following coccinelle script, plus some manual
      changes for mtk and tegra.
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
      (
       static const struct drm_plane_helper_funcs helpers = {
       	...,
       	.atomic_disable = func,
      	...,
       };
      |
       static const struct drm_plane_helper_funcs helpers = {
       	...,
       	.atomic_update = func,
      	...,
       };
      )
      
      @ moves_new_state_old_state @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol old_state;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_state)
       {
       	...
      -	struct drm_plane_state *state = plane->state;
      +	struct drm_plane_state *new_state = plane->state;
      	...
       }
      
      @ depends on moves_new_state_old_state @
      identifier plane_atomic_func.func;
      identifier plane;
      identifier old_state;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_state)
       {
       	<...
      -	state
      +	new_state
      	...>
       }
      
      @ moves_new_state_oldstate @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol oldstate;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *oldstate)
       {
       	...
      -	struct drm_plane_state *state = plane->state;
      +	struct drm_plane_state *newstate = plane->state;
      	...
       }
      
      @ depends on moves_new_state_oldstate @
      identifier plane_atomic_func.func;
      identifier plane;
      identifier old_state;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_state)
       {
       	<...
      -	state
      +	newstate
      	...>
       }
      
      @ moves_new_state_old_pstate @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol old_pstate;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
       {
       	...
      -	struct drm_plane_state *state = plane->state;
      +	struct drm_plane_state *new_pstate = plane->state;
      	...
       }
      
      @ depends on moves_new_state_old_pstate @
      identifier plane_atomic_func.func;
      identifier plane;
      identifier old_pstate;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_pstate)
       {
       	<...
      -	state
      +	new_pstate
      	...>
       }
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-8-maxime@cerno.tech
      41016fe1
    • Maxime Ripard's avatar
      drm: Store new plane state in a variable for atomic_update and disable · e05162c0
      Maxime Ripard authored
      In order to store the new plane state in a subsequent helper, let's move
      the plane->state dereferences into a variable.
      
      This was done using the following coccinelle script, plus some hand
      changes for vmwgfx:
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
      (
       static const struct drm_plane_helper_funcs helpers = {
       	...,
       	.atomic_disable = func,
      	...,
       };
      |
       static const struct drm_plane_helper_funcs helpers = {
       	...,
       	.atomic_update = func,
      	...,
       };
      )
      
      @ has_new_state_old_state @
      identifier plane_atomic_func.func;
      identifier plane;
      identifier new_state;
      symbol old_state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_state)
       {
       	...
       	struct drm_plane_state *new_state = plane->state;
      	...
       }
      
      @ depends on !has_new_state_old_state @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol old_state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_state)
       {
      +	struct drm_plane_state *new_state = plane->state;
       	<+...
      -	plane->state
      +	new_state
      	...+>
       }
      
      @ has_new_state_state @
      identifier plane_atomic_func.func;
      identifier plane;
      identifier new_state;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *state)
       {
       	...
       	struct drm_plane_state *new_state = plane->state;
      	...
       }
      
      @ depends on !has_new_state_state @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *state)
       {
      +	struct drm_plane_state *new_plane_state = plane->state;
       	<+...
      -	plane->state
      +	new_plane_state
      	...+>
       }
      
      @ has_new_state_old_s @
      identifier plane_atomic_func.func;
      identifier plane;
      identifier new_state;
      symbol old_s;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_s)
       {
       	...
       	struct drm_plane_state *new_state = plane->state;
      	...
       }
      
      @ depends on !has_new_state_old_s @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol old_s;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *old_s)
       {
      +	struct drm_plane_state *new_s = plane->state;
       	<+...
      -	plane->state
      +	new_s
      	...+>
       }
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
      e05162c0
    • Maxime Ripard's avatar
      drm: Use state helper instead of plane state pointer in atomic_check · 0b6aaf9d
      Maxime Ripard authored
      Many drivers reference the plane->state pointer in order to get the
      current plane state in their atomic_check hook, which would be the old
      plane state in the global atomic state since _swap_state hasn't happened
      when atomic_check is run.
      
      Use the drm_atomic_get_old_plane_state helper to get that state to make
      it more obvious.
      
      This was made using the coccinelle script below:
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
      static struct drm_plane_helper_funcs helpers = {
      	...,
      	.atomic_check = func,
      	...,
      };
      
      @ replaces_old_state @
      identifier plane_atomic_func.func;
      identifier plane, state, plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_atomic_state *state) {
       	...
      -	struct drm_plane_state *plane_state = plane->state;
      +	struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
       	...
       }
      
      @@
      identifier plane_atomic_func.func;
      identifier plane, state, plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_atomic_state *state) {
       	struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
       	<...
      -	plane->state
      +	plane_state
       	...>
       }
      
      @ adds_old_state @
      identifier plane_atomic_func.func;
      identifier plane, state;
      @@
      
       func(struct drm_plane *plane, struct drm_atomic_state *state) {
      +	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
       	<...
      -	plane->state
      +	old_plane_state
       	...>
       }
      
      @ include depends on adds_old_state || replaces_old_state @
      @@
      
       #include <drm/drm_atomic.h>
      
      @ no_include depends on !include && (adds_old_state || replaces_old_state) @
      @@
      
      + #include <drm/drm_atomic.h>
        #include <drm/...>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-6-maxime@cerno.tech
      0b6aaf9d
    • Maxime Ripard's avatar
      drm: Use the state pointer directly in planes atomic_check · dec92020
      Maxime Ripard authored
      Now that atomic_check takes the global atomic state as a parameter, we
      don't need to go through the pointer in the plane state.
      
      This was done using the following coccinelle script:
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
      static struct drm_plane_helper_funcs helpers = {
      	...,
      	.atomic_check = func,
      	...,
      };
      
      @@
      identifier plane_atomic_func.func;
      identifier plane, state;
      identifier plane_state;
      @@
      
        func(struct drm_plane *plane, struct drm_atomic_state *state) {
        ...
      - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
        <... when != plane_state
      - plane_state->state
      + state
        ...>
       }
      
      @@
      identifier plane_atomic_func.func;
      identifier plane, state;
      identifier plane_state;
      @@
      
        func(struct drm_plane *plane, struct drm_atomic_state *state) {
        ...
        struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
        <...
      - plane_state->state
      + state
        ...>
       }
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-5-maxime@cerno.tech
      dec92020
    • Maxime Ripard's avatar
      drm/atomic: Pass the full state to planes atomic_check · 7c11b99a
      Maxime Ripard authored
      The current atomic helpers have either their object state being passed as
      an argument or the full atomic state.
      
      The former is the pattern that was done at first, before switching to the
      latter for new hooks or when it was needed.
      
      Let's convert all the remaining helpers to provide a consistent
      interface, starting with the planes atomic_check.
      
      The conversion was done using the coccinelle script below plus some
      manual changes for vmwgfx, built tested on all the drivers.
      
      @@
      identifier plane, plane_state;
      symbol state;
      @@
      
       struct drm_plane_helper_funcs {
       	...
      	int (*atomic_check)(struct drm_plane *plane,
      -			    struct drm_plane_state *plane_state);
      +			    struct drm_atomic_state *state);
      	...
      }
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
      static const struct drm_plane_helper_funcs helpers = {
      	...,
       	.atomic_check = func,
      	...,
      };
      
      @@
      struct drm_plane_helper_funcs *FUNCS;
      identifier f;
      identifier dev;
      identifier plane, plane_state, state;
      @@
      
       f(struct drm_device *dev, struct drm_atomic_state *state)
       {
       	<+...
      -	FUNCS->atomic_check(plane, plane_state)
      +	FUNCS->atomic_check(plane, state)
       	...+>
       }
      
      @ ignores_new_state @
      identifier plane_atomic_func.func;
      identifier plane, new_plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
       {
      	... when != new_plane_state
       }
      
      @ adds_new_state depends on plane_atomic_func && !ignores_new_state @
      identifier plane_atomic_func.func;
      identifier plane, new_plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
       {
      +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
       	...
       }
      
      @ depends on plane_atomic_func @
      identifier plane_atomic_func.func;
      identifier plane, new_plane_state;
      @@
      
       func(struct drm_plane *plane,
      -     struct drm_plane_state *new_plane_state
      +     struct drm_atomic_state *state
           )
       { ... }
      
      @ include depends on adds_new_state @
      @@
      
       #include <drm/drm_atomic.h>
      
      @ no_include depends on !include && adds_new_state @
      @@
      
      + #include <drm/drm_atomic.h>
        #include <drm/...>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-4-maxime@cerno.tech
      7c11b99a
    • Maxime Ripard's avatar
      drm/atmel-hlcdc: Rename custom plane state variable · 6af70eb3
      Maxime Ripard authored
      Subsequent reworks will pass the global atomic state in the function
      prototype, and atomic_check and atomic_update already have such a
      variable already. Let's change them to ease the rework.
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-3-maxime@cerno.tech
      6af70eb3
    • Maxime Ripard's avatar
      drm: Rename plane atomic_check state names · ba5c1649
      Maxime Ripard authored
      Most drivers call the argument to the plane atomic_check hook simply
      state, which is going to conflict with the global atomic state in a
      later rework. Let's rename it to new_plane_state (or new_state depending
      on the convention used in the driver).
      
      This was done using the coccinelle script below, and built tested:
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
       static const struct drm_plane_helper_funcs helpers = {
       	.atomic_check = func,
       };
      
      @ has_old_state @
      identifier plane_atomic_func.func;
      identifier plane;
      expression e;
      symbol old_state;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *state)
       {
       	...
       	struct drm_plane_state *old_state = e;
       	...
       }
      
      @ depends on has_old_state @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol old_state;
      @@
      
       func(struct drm_plane *plane,
      -	struct drm_plane_state *state
      +	struct drm_plane_state *new_state
           )
       {
       	<+...
      -	state
      +	new_state
      	...+>
       }
      
      @ has_state @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *state)
       {
       	...
       }
      
      @ depends on has_state @
      identifier plane_atomic_func.func;
      identifier plane;
      symbol old_state;
      @@
      
       func(struct drm_plane *plane,
      -	struct drm_plane_state *state
      +	struct drm_plane_state *new_plane_state
           )
       {
       	<+...
      -	state
      +	new_plane_state
      	...+>
       }
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-2-maxime@cerno.tech
      ba5c1649
    • Maxime Ripard's avatar
      drm/atomic: Pass the full state to planes async atomic check and update · 5ddb0bd4
      Maxime Ripard authored
      The current atomic helpers have either their object state being passed as
      an argument or the full atomic state.
      
      The former is the pattern that was done at first, before switching to the
      latter for new hooks or when it was needed.
      
      Let's start convert all the remaining helpers to provide a consistent
      interface, starting with the planes atomic_async_check and
      atomic_async_update.
      
      The conversion was done using the coccinelle script below, built tested on
      all the drivers.
      
      @@
      identifier plane, plane_state;
      symbol state;
      @@
      
       struct drm_plane_helper_funcs {
       	...
      	int (*atomic_async_check)(struct drm_plane *plane,
      -				  struct drm_plane_state *plane_state);
      +				  struct drm_atomic_state *state);
      	...
       }
      
      @@
      identifier plane, plane_state;
      symbol state;
      @@
       struct drm_plane_helper_funcs {
       	...
      	void (*atomic_async_update)(struct drm_plane *plane,
      -				    struct drm_plane_state *plane_state);
      +				    struct drm_atomic_state *state);
      	...
       }
      
      @ plane_atomic_func @
      identifier helpers;
      identifier func;
      @@
      
      (
       static const struct drm_plane_helper_funcs helpers = {
      	...,
       	.atomic_async_check = func,
      	...,
       };
      |
       static const struct drm_plane_helper_funcs helpers = {
       	...,
       	.atomic_async_update = func,
       	...,
       };
      )
      
      @@
      struct drm_plane_helper_funcs *FUNCS;
      identifier f;
      identifier dev;
      identifier plane, plane_state, state;
      @@
      
       f(struct drm_device *dev, struct drm_atomic_state *state)
       {
       	<+...
      -	FUNCS->atomic_async_check(plane, plane_state)
      +	FUNCS->atomic_async_check(plane, state)
       	...+>
       }
      
      @@
      struct drm_plane_helper_funcs *FUNCS;
      identifier f;
      identifier dev;
      identifier plane, plane_state, state;
      @@
      
       f(struct drm_device *dev, struct drm_atomic_state *state)
       {
       	<+...
      -	FUNCS->atomic_async_update(plane, plane_state)
      +	FUNCS->atomic_async_update(plane, state)
       	...+>
       }
      
      @@
      identifier mtk_plane_atomic_async_update;
      identifier plane;
      symbol new_state, state;
      expression e;
      @@
      
        void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
      {
        ...
      - struct mtk_plane_state *state = e;
      + struct mtk_plane_state *new_plane_state = e;
        <+...
      -       state
      +       new_plane_state
        ...+>
        }
      
      @@
      identifier plane_atomic_func.func;
      identifier plane;
      symbol state;
      @@
      
       func(struct drm_plane *plane,
      -    struct drm_plane_state *state)
      +    struct drm_plane_state *new_plane_state)
       {
      	<...
      -	state
      +	new_plane_state
      	...>
       }
      
      @ ignores_new_state @
      identifier plane_atomic_func.func;
      identifier plane, new_plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
       {
      	... when != new_plane_state
       }
      
      @ adds_new_state depends on plane_atomic_func && !ignores_new_state @
      identifier plane_atomic_func.func;
      identifier plane, new_plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
       {
      +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
       	...
       }
      
      @ depends on plane_atomic_func @
      identifier plane_atomic_func.func;
      identifier plane, plane_state;
      @@
      
       func(struct drm_plane *plane,
      -     struct drm_plane_state *plane_state
      +     struct drm_atomic_state *state
           )
       { ... }
      
      @ include depends on adds_new_state @
      @@
      
       #include <drm/drm_atomic.h>
      
      @ no_include depends on !include && adds_new_state @
      @@
      
      + #include <drm/drm_atomic.h>
        #include <drm/...>
      
      @@
      identifier plane_atomic_func.func;
      identifier plane, state;
      identifier plane_state;
      @@
      
       func(struct drm_plane *plane, struct drm_atomic_state *state) {
              ...
              struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
              <+...
      -       plane_state->state
      +       state
              ...+>
       }
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-1-maxime@cerno.tech
      5ddb0bd4
    • Wayne Lin's avatar
      drm/dp_mst: Set CLEAR_PAYLOAD_ID_TABLE as broadcast · d919d3d6
      Wayne Lin authored
      [Why & How]
      According to DP spec, CLEAR_PAYLOAD_ID_TABLE is a path broadcast request
      message and current implementation is incorrect. Fix it.
      Signed-off-by: default avatarWayne Lin <Wayne.Lin@amd.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210224101521.6713-3-Wayne.Lin@amd.com
      d919d3d6
    • Wayne Lin's avatar
      drm/dp_mst: Revise broadcast msg lct & lcr · 419e91ea
      Wayne Lin authored
      [Why & How]
      According to DP spec, broadcast message LCT equals to 1 and LCR equals
      to 6. Current implementation is incorrect. Fix it.
      In addition, revise a bit the hdr->rad handling to include broadcast
      case.
      Signed-off-by: default avatarWayne Lin <Wayne.Lin@amd.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210224101521.6713-2-Wayne.Lin@amd.com
      419e91ea
  4. 23 Feb, 2021 2 commits