dpu_encoder_needs_periph_flush() switches on the interface type to call
msm_dp_needs_periph_flush() on the DP sub-block directly, hardcoding that
only DP interfaces ever need a peripheral flush.

Add a mandatory needs_periph_flush() callback to struct msm_display_funcs.
DP implements it (keeping its internal msm_dp_needs_periph_flush() helper,
now declared privately); DSI and HDMI, which never need a peripheral
flush, return false. The DPU encoder now looks up the sub-block and calls
the one callback.

No functional change intended.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Dmitry Baryshkov <[email protected]>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 49 +++++++++++++++--------------
 drivers/gpu/drm/msm/dp/dp_display.c         | 13 ++++++--
 drivers/gpu/drm/msm/dsi/dsi.c               |  7 +++++
 drivers/gpu/drm/msm/hdmi/hdmi.c             |  7 +++++
 drivers/gpu/drm/msm/msm_drv.h               | 11 ++-----
 5 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index ce358c1c9757..09bf959b2ca7 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -245,29 +245,6 @@ u32 dpu_encoder_get_drm_fmt(struct dpu_encoder_phys 
*phys_enc)
        return DRM_FORMAT_RGB888;
 }
 
-/**
- * dpu_encoder_needs_periph_flush - return true if physical encoder requires
- *     peripheral flush
- * @phys_enc: Pointer to physical encoder structure
- */
-bool dpu_encoder_needs_periph_flush(struct dpu_encoder_phys *phys_enc)
-{
-       struct drm_encoder *drm_enc;
-       struct dpu_encoder_virt *dpu_enc;
-       struct msm_display_info *disp_info;
-       struct msm_drm_private *priv;
-       struct drm_display_mode *mode;
-
-       drm_enc = phys_enc->parent;
-       dpu_enc = to_dpu_encoder_virt(drm_enc);
-       disp_info = &dpu_enc->disp_info;
-       priv = drm_enc->dev->dev_private;
-       mode = &phys_enc->cached_mode;
-
-       return phys_enc->hw_intf->cap->type == INTF_DP &&
-              
msm_dp_needs_periph_flush(priv->kms->dp[disp_info->h_tile_instance[0]], mode);
-}
-
 /**
  * dpu_encoder_get_display - find the display sub-block driving an interface
  * @dev:        the DRM device
@@ -294,6 +271,32 @@ static struct msm_display *dpu_encoder_get_display(struct 
drm_device *dev,
        }
 }
 
+/**
+ * dpu_encoder_needs_periph_flush - return true if physical encoder requires
+ *     peripheral flush
+ * @phys_enc: Pointer to physical encoder structure
+ */
+bool dpu_encoder_needs_periph_flush(struct dpu_encoder_phys *phys_enc)
+{
+       struct drm_encoder *drm_enc;
+       struct dpu_encoder_virt *dpu_enc;
+       struct msm_display_info *disp_info;
+       struct drm_display_mode *mode;
+       struct msm_display *display;
+
+       drm_enc = phys_enc->parent;
+       dpu_enc = to_dpu_encoder_virt(drm_enc);
+       disp_info = &dpu_enc->disp_info;
+       mode = &phys_enc->cached_mode;
+
+       display = dpu_encoder_get_display(drm_enc->dev, disp_info);
+
+       if (display)
+               return display->funcs->needs_periph_flush(display, mode);
+
+       return false;
+}
+
 /**
  * dpu_encoder_is_widebus_enabled - return bool value if widebus is enabled
  * @drm_enc:    Pointer to previously created drm encoder structure
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c 
b/drivers/gpu/drm/msm/dp/dp_display.c
index 04d291a93d20..773dee9d0be4 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -1290,8 +1290,8 @@ void __exit msm_dp_unregister(void)
        platform_driver_unregister(&msm_dp_display_driver);
 }
 
-bool msm_dp_needs_periph_flush(const struct msm_dp *msm_dp_display,
-                              const struct drm_display_mode *mode)
+static bool msm_dp_needs_periph_flush(const struct msm_dp *msm_dp_display,
+                                     const struct drm_display_mode *mode)
 {
        return drm_mode_is_420_only(&msm_dp_display->connector->display_info, 
mode);
 }
@@ -1361,10 +1361,19 @@ static bool msm_dp_display_wide_bus_enabled(struct 
msm_display *display)
        return msm_dp_wide_bus_available(dp);
 }
 
+static bool msm_dp_display_needs_periph_flush(struct msm_display *display,
+                                             const struct drm_display_mode 
*mode)
+{
+       struct msm_dp *dp = container_of(display, struct msm_dp, display);
+
+       return msm_dp_needs_periph_flush(dp, mode);
+}
+
 static const struct msm_display_funcs msm_dp_display_funcs = {
        .modeset_init = msm_dp_modeset_init,
        .snapshot = msm_dp_snapshot,
        .wide_bus_enabled = msm_dp_display_wide_bus_enabled,
+       .needs_periph_flush = msm_dp_display_needs_periph_flush,
 };
 
 struct msm_display *msm_dp_get_display(struct msm_dp *msm_dp_display)
diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index ce3b261123ea..085e202bf7e6 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -24,6 +24,12 @@ static bool msm_dsi_wide_bus_enabled(struct msm_display 
*display)
        return msm_dsi_host_is_wide_bus_enabled(msm_dsi->host);
 }
 
+static bool msm_dsi_needs_periph_flush(struct msm_display *display,
+                                      const struct drm_display_mode *mode)
+{
+       return false;
+}
+
 static int dsi_get_phy(struct msm_dsi *msm_dsi)
 {
        struct platform_device *pdev = msm_dsi->pdev;
@@ -282,6 +288,7 @@ static const struct msm_display_funcs msm_dsi_display_funcs 
= {
        .modeset_init = msm_dsi_modeset_init,
        .snapshot = msm_dsi_snapshot,
        .wide_bus_enabled = msm_dsi_wide_bus_enabled,
+       .needs_periph_flush = msm_dsi_needs_periph_flush,
 };
 
 struct msm_display *msm_dsi_get_display(struct msm_dsi *msm_dsi)
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
index 5f24f778c7ef..72f7403265f9 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
@@ -233,10 +233,17 @@ static bool msm_hdmi_wide_bus_enabled(struct msm_display 
*display)
        return false;
 }
 
+static bool msm_hdmi_needs_periph_flush(struct msm_display *display,
+                                       const struct drm_display_mode *mode)
+{
+       return false;
+}
+
 static const struct msm_display_funcs msm_hdmi_display_funcs = {
        .modeset_init = msm_hdmi_modeset_init,
        .snapshot = msm_hdmi_snapshot,
        .wide_bus_enabled = msm_hdmi_wide_bus_enabled,
+       .needs_periph_flush = msm_hdmi_needs_periph_flush,
 };
 
 struct msm_display *msm_hdmi_get_display(struct hdmi *hdmi)
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 519571170207..806d72ed393b 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -285,6 +285,7 @@ struct msm_disp_state;
  *                mandatory.
  * @wide_bus_enabled: whether the sub-block drives a wide (2 pixel/clock) bus;
  *                    mandatory.
+ * @needs_periph_flush: whether @mode requires a peripheral flush; mandatory.
  */
 struct msm_display_funcs {
        int (*modeset_init)(struct msm_display *display, struct drm_device *dev,
@@ -292,6 +293,8 @@ struct msm_display_funcs {
        void (*snapshot)(struct msm_display *display,
                         struct msm_disp_state *disp_state);
        bool (*wide_bus_enabled)(struct msm_display *display);
+       bool (*needs_periph_flush)(struct msm_display *display,
+                                  const struct drm_display_mode *mode);
 };
 
 /**
@@ -372,8 +375,6 @@ struct msm_dp;
 int __init msm_dp_register(void);
 void __exit msm_dp_unregister(void);
 struct msm_display *msm_dp_get_display(struct msm_dp *dp_display);
-bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display,
-                              const struct drm_display_mode *mode);
 
 #else
 static inline int __init msm_dp_register(void)
@@ -388,12 +389,6 @@ static inline struct msm_display 
*msm_dp_get_display(struct msm_dp *dp_display)
        return NULL;
 }
 
-static inline bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display,
-                                            const struct drm_display_mode 
*mode)
-{
-       return false;
-}
-
 #endif
 
 #ifdef CONFIG_DRM_MSM_MDP4

-- 
2.47.3

Reply via email to