OpenCloudOS-Kernel/drivers/gpu/drm/msm
Maxime Ripard 351f950db4
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.

In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.

virtual report

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@

 disable_outputs(struct drm_device *dev, struct drm_atomic_state *state)
 {
 	<...
-	FUNCS->atomic_disable(crtc, crtc_state);
+	FUNCS->atomic_disable(crtc, state);
 	...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier dev, state;
identifier crtc, crtc_state;
@@

 drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, struct drm_atomic_state *state)
 {
 	<...
-	FUNCS->atomic_enable(crtc, crtc_state);
+	FUNCS->atomic_enable(crtc, state);
 	...>
 }

@@
identifier crtc, old_state;
@@

 struct drm_crtc_helper_funcs {
	...
-	void (*atomic_enable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+	void (*atomic_enable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
	...
-	void (*atomic_disable)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+	void (*atomic_disable)(struct drm_crtc *crtc, struct drm_atomic_state *state);
	...
}

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

(
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_enable = func,
	...,
};
|
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_disable = func,
	...,
};
)

@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc,
		struct drm_crtc_state *old_state)
{
	... when != old_state
}

@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+	struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
	...
}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@

void func(...)
{
	...
-	T state = E;
+	T crtc_state = E;
	<+...
-	state
+	crtc_state
	...+>

}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@

void func(...)
{
	...
-	T state;
+	T crtc_state;
	<+...
-	state
+	crtc_state
	...+>

}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@

void func(struct drm_crtc *crtc,
-	       struct drm_crtc_state *old_state
+	       struct drm_atomic_state *state
	       )
		{ ... }

@ include depends on adds_old_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_old_state @
@@

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

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-09 09:55:59 +02:00
..
adreno Merge tag 'drm-msm-fixes-2020-09-04' of https://gitlab.freedesktop.org/drm/msm into drm-fixes 2020-09-08 14:51:16 +10:00
disp drm/atomic: Pass the full state to CRTC atomic enable/disable 2020-10-09 09:55:59 +02:00
dsi Merge drm/drm-next into drm-misc-next 2020-08-12 20:42:08 +02:00
edp drm/msm: sync generated headers 2020-07-31 06:46:16 -07:00
hdmi drm/msm: sync generated headers 2020-07-31 06:46:16 -07:00
Kconfig drm/msm/gpu: add ocmem init/cleanup functions 2019-10-07 08:17:39 -07:00
Makefile drm/msm/dpu: add support for color processing blocks in dpu driver 2020-05-18 09:26:32 -07:00
NOTES
msm_atomic.c drm/msm: enable vblank during atomic commits 2020-08-21 22:30:17 -07:00
msm_atomic_trace.h
msm_atomic_tracepoints.c
msm_debugfs.c drm: convert .debugfs_init() hook to return void. 2020-03-18 17:53:28 +01:00
msm_debugfs.h drm: convert .debugfs_init() hook to return void. 2020-03-18 17:53:28 +01:00
msm_drv.c drm/msm: Introduce GEM object funcs 2020-09-25 09:21:03 +02:00
msm_drv.h drm/msm: Introduce GEM object funcs 2020-09-25 09:21:03 +02:00
msm_fb.c drm/msm: remove _unlocked suffix in drm_gem_object_put_unlocked 2020-05-19 22:31:33 +01:00
msm_fbdev.c drm: Remove drm_fb_helper add, add all and remove connector calls 2020-03-06 14:19:58 +01:00
msm_fence.c
msm_fence.h
msm_gem.c drm/msm: Introduce GEM object funcs 2020-09-25 09:21:03 +02:00
msm_gem.h drm/msm: add internal MSM_BO_MAP_PRIV flag 2020-05-18 09:26:33 -07:00
msm_gem_prime.c drm: allow limiting the scatter list size. 2020-09-09 07:58:56 +02:00
msm_gem_shrinker.c
msm_gem_submit.c drm-misc-next for v5.9: 2020-06-24 15:45:51 +10:00
msm_gem_vma.c drm/msm: Refactor address space initialization 2020-05-23 13:38:16 -07:00
msm_gpu.c drm/msm: Enable expanded apriv support for a650 2020-09-04 12:14:07 -07:00
msm_gpu.h drm/msm: Enable expanded apriv support for a650 2020-09-04 12:14:07 -07:00
msm_gpu_trace.h
msm_gpu_tracepoints.c
msm_gpummu.c drm/msm: Update the MMU helper function APIs 2020-05-23 13:38:16 -07:00
msm_iommu.c drm/msm: Update the MMU helper function APIs 2020-05-23 13:38:16 -07:00
msm_kms.h
msm_mmu.h drm/msm: Update the MMU helper function APIs 2020-05-23 13:38:16 -07:00
msm_perf.c
msm_rd.c drm/msm: Fix undefined "rd_full" link error 2020-05-18 09:26:32 -07:00
msm_ringbuffer.c drm/msm: Enable expanded apriv support for a650 2020-09-04 12:14:07 -07:00
msm_ringbuffer.h
msm_submitqueue.c drm/msm: fix potential memleak in error branch 2020-06-11 20:06:12 -07:00