linux/drivers/gpu/drm/virtio
Maxime Ripard 253f28b623
drm: Use state helper instead of CRTC state pointer
Many drivers reference the crtc->pointer in order to get the current CRTC
state in their atomic_begin or atomic_flush hooks, which would be the new
CRTC state in the global atomic state since _swap_state happened when those
hooks are run.

Use the drm_atomic_get_new_crtc_state helper to get that state to make it
more obvious.

This was made using the coccinelle script below:

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

(
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_begin = func,
	...,
};
|
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_flush = func,
	...,
};
)

@@
identifier crtc_atomic_func.func;
identifier crtc, state;
symbol crtc_state;
expression e;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  ...
- struct tegra_dc_state *crtc_state = e;
+ struct tegra_dc_state *dc_state = e;
  <+...
-       crtc_state
+	dc_state
  ...+>
  }

@@
identifier crtc_atomic_func.func;
identifier crtc, state;
symbol crtc_state;
expression e;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  ...
- struct mtk_crtc_state *crtc_state = e;
+ struct mtk_crtc_state *mtk_crtc_state = e;
  <+...
-       crtc_state
+	mtk_crtc_state
  ...+>
  }

@ replaces_new_state @
identifier crtc_atomic_func.func;
identifier crtc, state, crtc_state;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  ...
- struct drm_crtc_state *crtc_state = crtc->state;
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
 }

@@
identifier crtc_atomic_func.func;
identifier crtc, state, crtc_state;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
- crtc->state
+ crtc_state
  ...
 }

@ adds_new_state @
identifier crtc_atomic_func.func;
identifier crtc, state;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
- crtc->state
+ crtc_state
  ...
 }

@ include depends on adds_new_state || replaces_new_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && (adds_new_state || replaces_new_state) @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: "James (Qian) Wang" <james.qian.wang@arm.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mihail Atanassov <mihail.atanassov@arm.com>
Cc: Brian Starkey <brian.starkey@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201105164518.392891-1-maxime@cerno.tech
2020-11-10 12:41:06 +01:00
..
Kconfig drm: virtio: fix kconfig dependency warning 2020-08-31 08:55:02 +02:00
Makefile drm/virtio: implement blob resources: implement vram object 2020-09-29 11:23:33 +02:00
virtgpu_debugfs.c drm/virtio: implement blob resources: implement vram object 2020-09-29 11:23:33 +02:00
virtgpu_display.c drm: Use state helper instead of CRTC state pointer 2020-11-10 12:41:06 +01:00
virtgpu_drv.c drm/<drivers>: Constify struct drm_driver 2020-11-06 10:31:26 +01:00
virtgpu_drv.h drm/virtio: implement blob resources: resource create blob ioctl 2020-09-29 11:23:51 +02:00
virtgpu_fence.c drm/virtio: move to_virtio_fence inside virtgpu_fence 2019-12-19 07:13:46 +01:00
virtgpu_gem.c drm/virtio: Use struct_size() helper in kmalloc() 2020-08-17 13:08:43 +02:00
virtgpu_ioctl.c drm/virtio: advertise features to userspace 2020-09-29 11:23:57 +02:00
virtgpu_kms.c drm/virtio: implement blob resources: implement vram object 2020-09-29 11:23:33 +02:00
virtgpu_object.c drm/virtio: use kvmalloc for large allocations 2020-11-05 12:33:26 +01:00
virtgpu_plane.c drm/virtio: implement blob resources: blob display integration 2020-09-29 11:23:42 +02:00
virtgpu_prime.c drm/virtio: implement blob resources: refactor UUID code somewhat 2020-09-29 11:23:45 +02:00
virtgpu_trace_points.c drm/virtio: add trace events for commands 2019-05-06 10:52:58 +02:00
virtgpu_trace.h drm/virtio: add trace events for commands 2019-05-06 10:52:58 +02:00
virtgpu_vq.c drm/virtio: Fix a double free in virtio_gpu_cmd_map() 2020-11-06 08:50:30 +01:00
virtgpu_vram.c drm/virtio: implement blob resources: resource create blob ioctl 2020-09-29 11:23:51 +02:00