drm/i915/crc: move pipe_crc from drm_i915_private to intel_crtc
authorJani Nikula <jani.nikula@intel.com>
Thu, 27 Feb 2020 16:12:53 +0000 (18:12 +0200)
committerJani Nikula <jani.nikula@intel.com>
Mon, 2 Mar 2020 10:58:26 +0000 (12:58 +0200)
Having an array pipe_crc[I915_MAX_PIPES] in struct drm_i915_private
should be an obvious clue this should be located in struct intel_crtc
instead. Make it so.

As a side-effect, fix some errors in indexing pipe_crc with both pipe
and crtc index. And, of course, reduce the size of i915_drv.h.

Cc: Anshuman Gupta <anshuman.gupta@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200227161253.15741-1-jani.nikula@intel.com
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_display_types.h
drivers/gpu/drm/i915/display/intel_pipe_crc.c
drivers/gpu/drm/i915/display/intel_pipe_crc.h
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_irq.c

index 97fa1709b00d26150b9291cf95f341357359eb4a..2a812123377f91c8d244c44d757078de4fea89ba 100644 (file)
@@ -16707,6 +16707,8 @@ static int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
 
        intel_color_init(crtc);
 
+       intel_crtc_crc_init(crtc);
+
        drm_WARN_ON(&dev_priv->drm, drm_crtc_index(&crtc->base) != crtc->pipe);
 
        return 0;
index 0a06043d4d4cb83f46b309e86a57e18af2dff954..ac5d066e23a0a8d25264b80a8193139e386aef0a 100644 (file)
@@ -1045,6 +1045,32 @@ struct intel_crtc_state {
        enum transcoder mst_master_transcoder;
 };
 
+enum intel_pipe_crc_source {
+       INTEL_PIPE_CRC_SOURCE_NONE,
+       INTEL_PIPE_CRC_SOURCE_PLANE1,
+       INTEL_PIPE_CRC_SOURCE_PLANE2,
+       INTEL_PIPE_CRC_SOURCE_PLANE3,
+       INTEL_PIPE_CRC_SOURCE_PLANE4,
+       INTEL_PIPE_CRC_SOURCE_PLANE5,
+       INTEL_PIPE_CRC_SOURCE_PLANE6,
+       INTEL_PIPE_CRC_SOURCE_PLANE7,
+       INTEL_PIPE_CRC_SOURCE_PIPE,
+       /* TV/DP on pre-gen5/vlv can't use the pipe source. */
+       INTEL_PIPE_CRC_SOURCE_TV,
+       INTEL_PIPE_CRC_SOURCE_DP_B,
+       INTEL_PIPE_CRC_SOURCE_DP_C,
+       INTEL_PIPE_CRC_SOURCE_DP_D,
+       INTEL_PIPE_CRC_SOURCE_AUTO,
+       INTEL_PIPE_CRC_SOURCE_MAX,
+};
+
+#define INTEL_PIPE_CRC_ENTRIES_NR      128
+struct intel_pipe_crc {
+       spinlock_t lock;
+       int skipped;
+       enum intel_pipe_crc_source source;
+};
+
 struct intel_crtc {
        struct drm_crtc base;
        enum pipe pipe;
@@ -1088,6 +1114,10 @@ struct intel_crtc {
 
        /* per pipe DSB related info */
        struct intel_dsb dsb;
+
+#ifdef CONFIG_DEBUG_FS
+       struct intel_pipe_crc pipe_crc;
+#endif
 };
 
 struct intel_plane {
index 59d7e3cb344585e4c49d056b219c4f831f090863..a9a5df2fee4dc8ac6dbd28087bbf8606277982a8 100644 (file)
@@ -441,15 +441,11 @@ display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
        return 0;
 }
 
-void intel_display_crc_init(struct drm_i915_private *dev_priv)
+void intel_crtc_crc_init(struct intel_crtc *crtc)
 {
-       enum pipe pipe;
+       struct intel_pipe_crc *pipe_crc = &crtc->pipe_crc;
 
-       for_each_pipe(dev_priv, pipe) {
-               struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
-
-               spin_lock_init(&pipe_crc->lock);
-       }
+       spin_lock_init(&pipe_crc->lock);
 }
 
 static int i8xx_crc_source_valid(struct drm_i915_private *dev_priv,
@@ -587,7 +583,8 @@ int intel_crtc_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name)
 {
        struct drm_i915_private *dev_priv = to_i915(crtc->dev);
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       struct intel_pipe_crc *pipe_crc = &intel_crtc->pipe_crc;
        enum intel_display_power_domain power_domain;
        enum intel_pipe_crc_source source;
        intel_wakeref_t wakeref;
@@ -640,7 +637,7 @@ void intel_crtc_enable_pipe_crc(struct intel_crtc *intel_crtc)
 {
        struct drm_crtc *crtc = &intel_crtc->base;
        struct drm_i915_private *dev_priv = to_i915(crtc->dev);
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
+       struct intel_pipe_crc *pipe_crc = &intel_crtc->pipe_crc;
        u32 val = 0;
 
        if (!crtc->crc.opened)
@@ -660,7 +657,7 @@ void intel_crtc_disable_pipe_crc(struct intel_crtc *intel_crtc)
 {
        struct drm_crtc *crtc = &intel_crtc->base;
        struct drm_i915_private *dev_priv = to_i915(crtc->dev);
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
+       struct intel_pipe_crc *pipe_crc = &intel_crtc->pipe_crc;
 
        /* Swallow crc's until we stop generating them. */
        spin_lock_irq(&pipe_crc->lock);
index db258a756fc6af841ad3a13e30ad26edca2ff208..43012b1894157808c54451bf0fa144886bacdc74 100644 (file)
@@ -13,7 +13,7 @@ struct drm_i915_private;
 struct intel_crtc;
 
 #ifdef CONFIG_DEBUG_FS
-void intel_display_crc_init(struct drm_i915_private *dev_priv);
+void intel_crtc_crc_init(struct intel_crtc *crtc);
 int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name);
 int intel_crtc_verify_crc_source(struct drm_crtc *crtc,
                                 const char *source_name, size_t *values_cnt);
@@ -22,7 +22,7 @@ const char *const *intel_crtc_get_crc_sources(struct drm_crtc *crtc,
 void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc);
 void intel_crtc_enable_pipe_crc(struct intel_crtc *crtc);
 #else
-static inline void intel_display_crc_init(struct drm_i915_private *dev_priv) {}
+static inline void intel_crtc_crc_init(struct intel_crtc *crtc) {}
 #define intel_crtc_set_crc_source NULL
 #define intel_crtc_verify_crc_source NULL
 #define intel_crtc_get_crc_sources NULL
index f26021f26ef580d168925a0034f7b3f4890441e6..77a2cec4ec5d5c1eb1db1d873d5ad634d9acfbbd 100644 (file)
@@ -466,7 +466,6 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
        intel_init_display_hooks(dev_priv);
        intel_init_clock_gating_hooks(dev_priv);
        intel_init_audio_hooks(dev_priv);
-       intel_display_crc_init(dev_priv);
 
        intel_detect_preproduction_hw(dev_priv);
 
index b621df933212a05970c81563fca1fa1f1c97f779..c038295230aff37b87790d4f835ebea50601c241 100644 (file)
@@ -822,32 +822,6 @@ struct skl_wm_params {
        u32 dbuf_block_size;
 };
 
-enum intel_pipe_crc_source {
-       INTEL_PIPE_CRC_SOURCE_NONE,
-       INTEL_PIPE_CRC_SOURCE_PLANE1,
-       INTEL_PIPE_CRC_SOURCE_PLANE2,
-       INTEL_PIPE_CRC_SOURCE_PLANE3,
-       INTEL_PIPE_CRC_SOURCE_PLANE4,
-       INTEL_PIPE_CRC_SOURCE_PLANE5,
-       INTEL_PIPE_CRC_SOURCE_PLANE6,
-       INTEL_PIPE_CRC_SOURCE_PLANE7,
-       INTEL_PIPE_CRC_SOURCE_PIPE,
-       /* TV/DP on pre-gen5/vlv can't use the pipe source. */
-       INTEL_PIPE_CRC_SOURCE_TV,
-       INTEL_PIPE_CRC_SOURCE_DP_B,
-       INTEL_PIPE_CRC_SOURCE_DP_C,
-       INTEL_PIPE_CRC_SOURCE_DP_D,
-       INTEL_PIPE_CRC_SOURCE_AUTO,
-       INTEL_PIPE_CRC_SOURCE_MAX,
-};
-
-#define INTEL_PIPE_CRC_ENTRIES_NR      128
-struct intel_pipe_crc {
-       spinlock_t lock;
-       int skipped;
-       enum intel_pipe_crc_source source;
-};
-
 struct i915_frontbuffer_tracking {
        spinlock_t lock;
 
@@ -1043,10 +1017,6 @@ struct drm_i915_private {
        struct intel_crtc *plane_to_crtc_mapping[I915_MAX_PIPES];
        struct intel_crtc *pipe_to_crtc_mapping[I915_MAX_PIPES];
 
-#ifdef CONFIG_DEBUG_FS
-       struct intel_pipe_crc pipe_crc[I915_MAX_PIPES];
-#endif
-
        /* dpll and cdclk state is protected by connection_mutex */
        int num_shared_dpll;
        struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
index ad44d481d7b32efa442617cf4c01170e608395f6..ecf07b0faad2a712b96cbf5943a74f33ea955323 100644 (file)
@@ -1207,8 +1207,8 @@ static void display_pipe_crc_irq_handler(struct drm_i915_private *dev_priv,
                                         u32 crc2, u32 crc3,
                                         u32 crc4)
 {
-       struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
        struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
+       struct intel_pipe_crc *pipe_crc = &crtc->pipe_crc;
        u32 crcs[5] = { crc0, crc1, crc2, crc3, crc4 };
 
        trace_intel_pipe_crc(crtc, crcs);