drm/msm/dp: cleanup debugfs handling
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 19 Oct 2023 10:44:19 +0000 (13:44 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sun, 3 Dec 2023 00:12:49 +0000 (03:12 +0300)
Currently there are two subdirs for DP debugfs files, e.g. DP-1, created
by the drm core for the connector, and the msm_dp-DP-1, created by the
DP driver itself. Merge those two, so that there are no extraneous
connector-related subdirs.

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/563523/
Link: https://lore.kernel.org/r/20231019104419.1032329-1-dmitry.baryshkov@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
drivers/gpu/drm/msm/dp/dp_debug.c
drivers/gpu/drm/msm/dp/dp_debug.h
drivers/gpu/drm/msm/dp/dp_display.c
drivers/gpu/drm/msm/dp/dp_display.h
drivers/gpu/drm/msm/dp/dp_drm.c
drivers/gpu/drm/msm/msm_drv.h

index fe7267b3bff536fb80d5197249b3d55c1b55d73e..babec724c76a5909591f3baa2c8386332858caaa 100644 (file)
@@ -274,9 +274,6 @@ static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
        struct dpu_kms *dpu_kms = to_dpu_kms(kms);
        void *p = dpu_hw_util_get_log_mask_ptr();
        struct dentry *entry;
-       struct drm_device *dev;
-       struct msm_drm_private *priv;
-       int i;
 
        if (!p)
                return -EINVAL;
@@ -285,9 +282,6 @@ static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
        if (minor->type != DRM_MINOR_PRIMARY)
                return 0;
 
-       dev = dpu_kms->dev;
-       priv = dev->dev_private;
-
        entry = debugfs_create_dir("debug", minor->debugfs_root);
 
        debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, entry, p);
@@ -297,11 +291,6 @@ static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
        dpu_debugfs_core_irq_init(dpu_kms, entry);
        dpu_debugfs_sspp_init(dpu_kms, entry);
 
-       for (i = 0; i < ARRAY_SIZE(priv->dp); i++) {
-               if (priv->dp[i])
-                       msm_dp_debugfs_init(priv->dp[i], minor);
-       }
-
        return dpu_core_perf_debugfs_init(dpu_kms, entry);
 }
 #endif
index 3bba901afe3354e65ad8fe4f035f15d93a762eda..6c281dc095b9a0000e6234409b73a95aa0759189 100644 (file)
 #define DEBUG_NAME "msm_dp"
 
 struct dp_debug_private {
-       struct dentry *root;
-
        struct dp_link *link;
        struct dp_panel *panel;
        struct drm_connector *connector;
-       struct device *dev;
-       struct drm_device *drm_dev;
 
        struct dp_debug dp_debug;
 };
@@ -204,35 +200,33 @@ static const struct file_operations test_active_fops = {
        .write = dp_test_active_write
 };
 
-static void dp_debug_init(struct dp_debug *dp_debug, struct drm_minor *minor)
+static void dp_debug_init(struct dp_debug *dp_debug, struct dentry *root, bool is_edp)
 {
-       char path[64];
        struct dp_debug_private *debug = container_of(dp_debug,
                        struct dp_debug_private, dp_debug);
 
-       snprintf(path, sizeof(path), "msm_dp-%s", debug->connector->name);
-
-       debug->root = debugfs_create_dir(path, minor->debugfs_root);
-
-       debugfs_create_file("dp_debug", 0444, debug->root,
+       debugfs_create_file("dp_debug", 0444, root,
                        debug, &dp_debug_fops);
 
-       debugfs_create_file("msm_dp_test_active", 0444,
-                       debug->root,
-                       debug, &test_active_fops);
+       if (!is_edp) {
+               debugfs_create_file("msm_dp_test_active", 0444,
+                                   root,
+                                   debug, &test_active_fops);
 
-       debugfs_create_file("msm_dp_test_data", 0444,
-                       debug->root,
-                       debug, &dp_test_data_fops);
+               debugfs_create_file("msm_dp_test_data", 0444,
+                                   root,
+                                   debug, &dp_test_data_fops);
 
-       debugfs_create_file("msm_dp_test_type", 0444,
-                       debug->root,
-                       debug, &dp_test_type_fops);
+               debugfs_create_file("msm_dp_test_type", 0444,
+                                   root,
+                                   debug, &dp_test_type_fops);
+       }
 }
 
 struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel,
                struct dp_link *link,
-               struct drm_connector *connector, struct drm_minor *minor)
+               struct drm_connector *connector,
+               struct dentry *root, bool is_edp)
 {
        struct dp_debug_private *debug;
        struct dp_debug *dp_debug;
@@ -253,46 +247,15 @@ struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel,
        debug->dp_debug.debug_en = false;
        debug->link = link;
        debug->panel = panel;
-       debug->dev = dev;
-       debug->drm_dev = minor->dev;
-       debug->connector = connector;
 
        dp_debug = &debug->dp_debug;
        dp_debug->vdisplay = 0;
        dp_debug->hdisplay = 0;
        dp_debug->vrefresh = 0;
 
-       dp_debug_init(dp_debug, minor);
+       dp_debug_init(dp_debug, root, is_edp);
 
        return dp_debug;
  error:
        return ERR_PTR(rc);
 }
-
-static int dp_debug_deinit(struct dp_debug *dp_debug)
-{
-       struct dp_debug_private *debug;
-
-       if (!dp_debug)
-               return -EINVAL;
-
-       debug = container_of(dp_debug, struct dp_debug_private, dp_debug);
-
-       debugfs_remove_recursive(debug->root);
-
-       return 0;
-}
-
-void dp_debug_put(struct dp_debug *dp_debug)
-{
-       struct dp_debug_private *debug;
-
-       if (!dp_debug)
-               return;
-
-       debug = container_of(dp_debug, struct dp_debug_private, dp_debug);
-
-       dp_debug_deinit(dp_debug);
-
-       devm_kfree(debug->dev, debug);
-}
index 124227873d58cb929e08ae5b13eca60fbda34726..9b3b2e702f65504cc374da6c1ee606aa70c71477 100644 (file)
@@ -34,7 +34,8 @@ struct dp_debug {
  * @panel: instance of panel module
  * @link: instance of link module
  * @connector: double pointer to display connector
- * @minor: pointer to drm minor number after device registration
+ * @root: connector's debugfs root
+ * @is_edp: set for eDP connectors / panels
  * return: pointer to allocated debug module data
  *
  * This function sets up the debug module and provides a way
@@ -43,31 +44,21 @@ struct dp_debug {
 struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel,
                struct dp_link *link,
                struct drm_connector *connector,
-               struct drm_minor *minor);
-
-/**
- * dp_debug_put()
- *
- * Cleans up dp_debug instance
- *
- * @dp_debug: instance of dp_debug
- */
-void dp_debug_put(struct dp_debug *dp_debug);
+               struct dentry *root,
+               bool is_edp);
 
 #else
 
 static inline
 struct dp_debug *dp_debug_get(struct device *dev, struct dp_panel *panel,
                struct dp_link *link,
-               struct drm_connector *connector, struct drm_minor *minor)
+               struct drm_connector *connector,
+               struct dentry *root,
+               bool is_edp)
 {
        return ERR_PTR(-EINVAL);
 }
 
-static inline void dp_debug_put(struct dp_debug *dp_debug)
-{
-}
-
 #endif /* defined(CONFIG_DEBUG_FS) */
 
 #endif /* _DP_DEBUG_H_ */
index e329e03e068d527339fb31ca3cc8dbcd4e2bd83a..2ac9d61501c7511b54d7fc7ccf343e308283417a 100644 (file)
@@ -715,7 +715,6 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
 
 static void dp_display_deinit_sub_modules(struct dp_display_private *dp)
 {
-       dp_debug_put(dp->debug);
        dp_audio_put(dp->audio);
        dp_panel_put(dp->panel);
        dp_aux_put(dp->aux);
@@ -1451,7 +1450,7 @@ bool msm_dp_wide_bus_available(const struct msm_dp *dp_display)
        return dp->wide_bus_en;
 }
 
-void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor)
+void dp_display_debugfs_init(struct msm_dp *dp_display, struct dentry *root, bool is_edp)
 {
        struct dp_display_private *dp;
        struct device *dev;
@@ -1462,7 +1461,7 @@ void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor)
 
        dp->debug = dp_debug_get(dev, dp->panel,
                                        dp->link, dp->dp_display.connector,
-                                       minor);
+                                       root, is_edp);
        if (IS_ERR(dp->debug)) {
                rc = PTR_ERR(dp->debug);
                DRM_ERROR("failed to initialize debug, rc = %d\n", rc);
index f66cdbc357856ba36afa323ade225ce4ee354846..5e2fbd8318e93f5c49f6e88046b5110b2ffa04c5 100644 (file)
@@ -42,5 +42,6 @@ int dp_display_get_test_bpp(struct msm_dp *dp_display);
 void dp_display_signal_audio_start(struct msm_dp *dp_display);
 void dp_display_signal_audio_complete(struct msm_dp *dp_display);
 void dp_display_set_psr(struct msm_dp *dp, bool enter);
+void dp_display_debugfs_init(struct msm_dp *dp_display, struct dentry *dentry, bool is_edp);
 
 #endif /* _DP_DISPLAY_H_ */
index 40e7344180e3e0e8d4f99804835d5ab51a12a842..21850a384b10bdcd60ba22425b85262912c06584 100644 (file)
@@ -90,6 +90,13 @@ static int dp_bridge_get_modes(struct drm_bridge *bridge, struct drm_connector *
        return rc;
 }
 
+static void dp_bridge_debugfs_init(struct drm_bridge *bridge, struct dentry *root)
+{
+       struct msm_dp *dp = to_dp_bridge(bridge)->dp_display;
+
+       dp_display_debugfs_init(dp, root, false);
+}
+
 static const struct drm_bridge_funcs dp_bridge_ops = {
        .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
        .atomic_destroy_state   = drm_atomic_helper_bridge_destroy_state,
@@ -105,6 +112,7 @@ static const struct drm_bridge_funcs dp_bridge_ops = {
        .hpd_enable   = dp_bridge_hpd_enable,
        .hpd_disable  = dp_bridge_hpd_disable,
        .hpd_notify   = dp_bridge_hpd_notify,
+       .debugfs_init = dp_bridge_debugfs_init,
 };
 
 static int edp_bridge_atomic_check(struct drm_bridge *drm_bridge,
@@ -260,6 +268,13 @@ static enum drm_mode_status edp_bridge_mode_valid(struct drm_bridge *bridge,
        return MODE_OK;
 }
 
+static void edp_bridge_debugfs_init(struct drm_bridge *bridge, struct dentry *root)
+{
+       struct msm_dp *dp = to_dp_bridge(bridge)->dp_display;
+
+       dp_display_debugfs_init(dp, root, true);
+}
+
 static const struct drm_bridge_funcs edp_bridge_ops = {
        .atomic_enable = edp_bridge_atomic_enable,
        .atomic_disable = edp_bridge_atomic_disable,
@@ -270,6 +285,7 @@ static const struct drm_bridge_funcs edp_bridge_ops = {
        .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
        .atomic_check = edp_bridge_atomic_check,
+       .debugfs_init = edp_bridge_debugfs_init,
 };
 
 int dp_bridge_init(struct msm_dp *dp_display, struct drm_device *dev,
index cd5bf658df669ee697f9efbd732f77bba8d18a38..628ef3e663ea49b68a7a38cc911427f52c2c0e2d 100644 (file)
@@ -389,7 +389,6 @@ int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev,
 void msm_dp_irq_postinstall(struct msm_dp *dp_display);
 void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp_display);
 
-void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor);
 bool msm_dp_wide_bus_available(const struct msm_dp *dp_display);
 
 #else
@@ -415,11 +414,6 @@ static inline void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm
 {
 }
 
-static inline void msm_dp_debugfs_init(struct msm_dp *dp_display,
-               struct drm_minor *minor)
-{
-}
-
 static inline bool msm_dp_wide_bus_available(const struct msm_dp *dp_display)
 {
        return false;