[Intel-xe] [PATCH v6 2/2] drm/i915: xe dpt integration
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Thu Nov 9 11:18:38 UTC 2023
On 2023-11-07 21:30, Juha-Pekka Heikkila wrote:
> From: Jani Nikula <jani.nikula at intel.com>
>
> Abstract i915 and Xe dpt related differences. Create
> intel_dpt_common.c where common dpt code go into.
>
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> drivers/gpu/drm/i915/Makefile | 1 +
> .../gpu/drm/i915/display/intel_atomic_plane.c | 12 ++++-
> drivers/gpu/drm/i915/display/intel_display.c | 1 +
> .../drm/i915/display/intel_display_types.h | 1 +
> drivers/gpu/drm/i915/display/intel_dpt.c | 26 -----------
> drivers/gpu/drm/i915/display/intel_dpt.h | 2 -
> .../gpu/drm/i915/display/intel_dpt_common.c | 45 +++++++++++++++++++
> .../gpu/drm/i915/display/intel_dpt_common.h | 13 ++++++
> drivers/gpu/drm/i915/display/intel_fb.c | 34 +++++++++++---
> .../drm/i915/display/skl_universal_plane.c | 6 ++-
> drivers/gpu/drm/xe/Makefile | 2 +-
> 11 files changed, 105 insertions(+), 38 deletions(-)
> create mode 100644 drivers/gpu/drm/i915/display/intel_dpt_common.c
> create mode 100644 drivers/gpu/drm/i915/display/intel_dpt_common.h
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 3c26e9ae3722..3b745ee8b3c5 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -260,6 +260,7 @@ i915-y += \
> display/intel_dpll.o \
> display/intel_dpll_mgr.o \
> display/intel_dpt.o \
> + display/intel_dpt_common.o \
> display/intel_drrs.o \
> display/intel_dsb.o \
> display/intel_fb.o \
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> index 7adf9e0059c5..eabb6c6dde3f 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> @@ -119,6 +119,15 @@ intel_plane_duplicate_state(struct drm_plane *plane)
> return &intel_state->uapi;
> }
>
> +static void check_intel_plane_state_vmas(struct drm_device *dev,
> + struct intel_plane_state *intel_state)
> +{
> + drm_WARN_ON(dev, intel_state->ggtt_vma);
> +#ifdef I915
> + drm_WARN_ON(dev, intel_state->dpt_vma);
> +#endif
> +}
> +
> /**
> * intel_plane_destroy_state - destroy plane state
> * @plane: drm plane
> @@ -133,8 +142,7 @@ intel_plane_destroy_state(struct drm_plane *plane,
> {
> struct intel_plane_state *plane_state = to_intel_plane_state(state);
>
> - drm_WARN_ON(plane->dev, plane_state->ggtt_vma);
> - drm_WARN_ON(plane->dev, plane_state->dpt_vma);
> + check_intel_plane_state_vmas(plane->dev, plane_state);
>
> __drm_atomic_helper_plane_destroy_state(&plane_state->uapi);
> if (plane_state->hw.fb)
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 9874025cb77e..b1bedccfeae8 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -78,6 +78,7 @@
> #include "intel_dpll.h"
> #include "intel_dpll_mgr.h"
> #include "intel_dpt.h"
> +#include "intel_dpt_common.h"
> #include "intel_drrs.h"
> #include "intel_dsb.h"
> #include "intel_dsi.h"
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 8ae36bb8b937..ec708d84ec7f 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -699,6 +699,7 @@ struct intel_plane_state {
>
> struct i915_vma *ggtt_vma;
> struct i915_vma *dpt_vma;
> + struct i915_vma embed_vma;
> unsigned long flags;
> #define PLANE_HAS_FENCE BIT(0)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c b/drivers/gpu/drm/i915/display/intel_dpt.c
> index 2b067cb952f0..b29bceff73f2 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpt.c
> +++ b/drivers/gpu/drm/i915/display/intel_dpt.c
> @@ -9,8 +9,6 @@
> #include "gt/gen8_ppgtt.h"
>
> #include "i915_drv.h"
> -#include "i915_reg.h"
> -#include "intel_de.h"
> #include "intel_display_types.h"
> #include "intel_dpt.h"
> #include "intel_fb.h"
> @@ -318,27 +316,3 @@ void intel_dpt_destroy(struct i915_address_space *vm)
> i915_vm_put(&dpt->vm);
> }
>
> -void intel_dpt_configure(struct intel_crtc *crtc)
> -{
> - struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> -
> - if (DISPLAY_VER(i915) == 14) {
> - enum pipe pipe = crtc->pipe;
> - enum plane_id plane_id;
> -
> - for_each_plane_id_on_crtc(crtc, plane_id) {
> - if (plane_id == PLANE_CURSOR)
> - continue;
> -
> - intel_de_rmw(i915, PLANE_CHICKEN(pipe, plane_id),
> - PLANE_CHICKEN_DISABLE_DPT,
> - i915->display.params.enable_dpt ? 0 :
> - PLANE_CHICKEN_DISABLE_DPT);
> - }
> - } else if (DISPLAY_VER(i915) == 13) {
> - intel_de_rmw(i915, CHICKEN_MISC_2,
> - CHICKEN_MISC_DISABLE_DPT,
> - i915->display.params.enable_dpt ? 0 :
> - CHICKEN_MISC_DISABLE_DPT);
> - }
> -}
> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.h b/drivers/gpu/drm/i915/display/intel_dpt.h
> index d9a166550185..e18a9f767b11 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpt.h
> +++ b/drivers/gpu/drm/i915/display/intel_dpt.h
> @@ -10,7 +10,6 @@ struct drm_i915_private;
>
> struct i915_address_space;
> struct i915_vma;
> -struct intel_crtc;
> struct intel_framebuffer;
>
> void intel_dpt_destroy(struct i915_address_space *vm);
> @@ -20,6 +19,5 @@ void intel_dpt_suspend(struct drm_i915_private *i915);
> void intel_dpt_resume(struct drm_i915_private *i915);
> struct i915_address_space *
> intel_dpt_create(struct intel_framebuffer *fb);
> -void intel_dpt_configure(struct intel_crtc *crtc);
>
> #endif /* __INTEL_DPT_H__ */
> diff --git a/drivers/gpu/drm/i915/display/intel_dpt_common.c b/drivers/gpu/drm/i915/display/intel_dpt_common.c
> new file mode 100644
> index 000000000000..47586ec7f1a2
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_dpt_common.c
> @@ -0,0 +1,45 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#include "i915_reg.h"
> +#include "intel_de.h"
> +#include "intel_display_types.h"
> +#include "intel_dpt_common.h"
> +
> +/*
> + * For Xe introduce dummy intel_dpt_create which return NULL and will be
> + * optimized out by compiler.
> + */
> +#ifndef I915
> +struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
> +{
> + return NULL;
> +}
> +#endif
> +
> +void intel_dpt_configure(struct intel_crtc *crtc)
> +{
> + struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> +
> + if (DISPLAY_VER(i915) == 14) {
> + enum pipe pipe = crtc->pipe;
> + enum plane_id plane_id;
> +
> + for_each_plane_id_on_crtc(crtc, plane_id) {
> + if (plane_id == PLANE_CURSOR)
> + continue;
> +
> + intel_de_rmw(i915, PLANE_CHICKEN(pipe, plane_id),
> + PLANE_CHICKEN_DISABLE_DPT,
> + i915->display.params.enable_dpt ? 0 :
> + PLANE_CHICKEN_DISABLE_DPT);
> + }
> + } else if (DISPLAY_VER(i915) == 13) {
> + intel_de_rmw(i915, CHICKEN_MISC_2,
> + CHICKEN_MISC_DISABLE_DPT,
> + i915->display.params.enable_dpt ? 0 :
> + CHICKEN_MISC_DISABLE_DPT);
> + }
> +}
> diff --git a/drivers/gpu/drm/i915/display/intel_dpt_common.h b/drivers/gpu/drm/i915/display/intel_dpt_common.h
> new file mode 100644
> index 000000000000..6d7de405126a
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_dpt_common.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#ifndef __INTEL_DPT_COMMON_H__
> +#define __INTEL_DPT_COMMON_H__
> +
> +struct intel_crtc;
> +
> +void intel_dpt_configure(struct intel_crtc *crtc);
> +
> +#endif /* __INTEL_DPT_COMMON_H__ */
> diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
> index 3862e55e8980..035f51a310d4 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb.c
> @@ -1885,17 +1885,36 @@ int intel_plane_compute_gtt(struct intel_plane_state *plane_state)
> return intel_plane_check_stride(plane_state);
> }
>
> -static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
> +static void intel_user_framebuffer_destroy_vm(struct drm_framebuffer *fb)
> {
> +#ifdef I915
> struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
>
> - drm_framebuffer_cleanup(fb);
> -
> if (intel_fb_uses_dpt(fb))
> intel_dpt_destroy(intel_fb->dpt_vm);
> +#else
> + if (intel_fb_obj(fb)->flags & XE_BO_CREATE_PINNED_BIT) {
> + struct xe_bo *bo = intel_fb_obj(fb);
> +
> + /* Unpin our kernel fb first */
> + xe_bo_lock(bo, false);
> + xe_bo_unpin(bo);
> + xe_bo_unlock(bo);
> + }
> + xe_bo_put(intel_fb_obj(fb));
> +#endif
> +}
This chunk should not be part of the xe_dpt integration patch? I think
it should be part of the fbdev changes.\
Might have been addressed by my changes to split up the big remaining patch.
Cheers,
~Maarten
> +static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb)
> +{
> + struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
> +
> + drm_framebuffer_cleanup(fb);
>
> intel_frontbuffer_put(intel_fb->frontbuffer);
>
> + intel_user_framebuffer_destroy_vm(fb);
> +
> kfree(intel_fb);
> }
>
> @@ -2137,7 +2156,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
> }
> }
>
> - fb->obj[i] = &obj->base;
> + fb->obj[i] = intel_bo_to_drm_bo(obj);
> }
>
> ret = intel_fill_fb_info(dev_priv, intel_fb);
> @@ -2156,6 +2175,10 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
>
> intel_fb->dpt_vm = vm;
> }
> +#ifndef I915
> + /* Hold a reference to object while fb is alive */
> + xe_bo_get(obj);
> +#endif
>
> ret = drm_framebuffer_init(&dev_priv->drm, fb, &intel_fb_funcs);
> if (ret) {
> @@ -2166,8 +2189,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
> return 0;
>
> err_free_dpt:
> - if (intel_fb_uses_dpt(fb))
> - intel_dpt_destroy(intel_fb->dpt_vm);
> + intel_user_framebuffer_destroy_vm(fb);
> err:
> intel_frontbuffer_put(intel_fb->frontbuffer);
> return ret;
> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> index 4553dd6bfbbd..68eabe089aaf 100644
> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> @@ -1010,9 +1010,13 @@ static u32 skl_surf_address(const struct intel_plane_state *plane_state,
> * The DPT object contains only one vma, so the VMA's offset
> * within the DPT is always 0.
> */
> - drm_WARN_ON(&i915->drm, plane_state->dpt_vma->node.start);
> drm_WARN_ON(&i915->drm, offset & 0x1fffff);
> +#ifdef I915
> + drm_WARN_ON(&i915->drm, plane_state->dpt_vma->node.start);
> return offset >> 9;
> +#else
> + return 0;
> +#endif
> } else {
> drm_WARN_ON(&i915->drm, offset & 0xfff);
> return offset;
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index a1a8847e2ba3..b82641dcca70 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -201,7 +201,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
> i915-display/intel_dp_mst.o \
> i915-display/intel_dpll.o \
> i915-display/intel_dpll_mgr.o \
> - i915-display/intel_dpt.o \
> + i915-display/intel_dpt_common.o \
> i915-display/intel_drrs.o \
> i915-display/intel_dsb.o \
> i915-display/intel_dsi.o \
More information about the Intel-xe
mailing list