Skip to contentSkip to conversation

drm/msm/dpu: add current resource allocation to dumped state

PATCH In review Dmitry Baryshkov 2 participants 3 messages Feb 22, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 drm/msm/dpu: add current resource allocation to dumped state

Provide atomic_print_state callback to the DPU's private object. This way the debugfs/dri/0/state will also include RM's internal state.

Example output (RB5 board, HDMI and writeback encoder enabled)

resource mapping:

	pingpong=31 36 # # # # - - - - -
	mixer=31 36 # # # # -
	ctl=# # 31 36 # #
	dspp=# # # #
	dsc=# # # # - -
	cdm=#

---
Changes in v5:
- Extracted the common helper for printing RM state
- Changed the code to print '#' for unused/unmapped blocks (Abhinav)
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Split the patch from the virual wide planes series
- Reworked the output format
- Added the CDM block into the dump

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 12 +++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h |  2 ++
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 56 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  |  8 +++++
 4 files changed, 78 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +12 -0
index 723cc1d82143..9f3697e1eacb 100644
@@ -353,9 +353,18 @@ static void dpu_kms_global_destroy_state(struct drm_private_obj *obj,
 	kfree(dpu_state);
 }
 
+static void dpu_kms_global_print_state(struct drm_printer *p,
+				       const struct drm_private_state *state)
+{
+	const struct dpu_global_state *global_state = to_dpu_global_state(state);
+
+	dpu_rm_print_state(p, global_state);
+}
+
 static const struct drm_private_state_funcs dpu_kms_global_state_funcs = {
 	.atomic_duplicate_state = dpu_kms_global_duplicate_state,
 	.atomic_destroy_state = dpu_kms_global_destroy_state,
+	.atomic_print_state = dpu_kms_global_print_state,
 };
 
 static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
@@ -371,6 +380,9 @@ static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
 	drm_atomic_private_obj_init(dpu_kms->dev, &dpu_kms->global_state,
 				    &state->base,
 				    &dpu_kms_global_state_funcs);
+
+	state->rm = &dpu_kms->rm;
+
 	return 0;
 }
 
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +2 -0
index d1207f4ec3ae..2512c9bd08df 100644
@@ -131,6 +131,8 @@ struct vsync_info {
 struct dpu_global_state {
 	struct drm_private_state base;
 
+	struct dpu_rm *rm;
+
 	uint32_t pingpong_to_enc_id[PINGPONG_MAX - PINGPONG_0];
 	uint32_t mixer_to_enc_id[LM_MAX - LM_0];
 	uint32_t ctl_to_enc_id[CTL_MAX - CTL_0];
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +56 -0

59 lines not on this page · raw message

drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +8 -0
index e3f83ebc656b..e63db8ace6b9 100644
@@ -89,6 +89,14 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,
 	struct dpu_global_state *global_state, uint32_t enc_id,
 	enum dpu_hw_blk_type type, struct dpu_hw_blk **blks, int blks_size);
 
+/**
+ * dpu_rm_print_state - output the RM private state
+ * @p: DRM printer
+ * @global_state: global state
+ */
+void dpu_rm_print_state(struct drm_printer *p,
+			const struct dpu_global_state *global_state);
+
 /**
  * dpu_rm_get_intf - Return a struct dpu_hw_intf instance given it's index.
  * @rm: DPU Resource Manager handle

---
base-commit: 41c177cf354126a22443b5c80cec9fdd313e67e1
change-id: 20240219-fd-rm-state-bd1218954b78

Best regards,

Signature · 1 line
Dmitry Baryshkov <[email protected]>
Reviewed-by on v5 1/1
#1 lore raw
Quoted 5 lines · Dmitry Baryshkov

Provide atomic_print_state callback to the DPU's private object. This way the debugfs/dri/0/state will also include RM's internal state.

Example output (RB5 board, HDMI and writeback encoder enabled)

Quoted 8 lines

resource mapping:

	pingpong=31 36 # # # # - - - - -
	mixer=31 36 # # # # -
	ctl=# # 31 36 # #
	dspp=# # # #
	dsc=# # # # - -
	cdm=#

Thanks, this LGTM now, one nit below.

Quoted 69 lines

---
Changes in v5:
- Extracted the common helper for printing RM state
- Changed the code to print '#' for unused/unmapped blocks (Abhinav)
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Split the patch from the virual wide planes series
- Reworked the output format
- Added the CDM block into the dump

---
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 12 +++++++
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h |  2 ++
  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 56 +++++++++++++++++++++++++++++++++
  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  |  8 +++++
  4 files changed, 78 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +12 -0
index 723cc1d82143..9f3697e1eacb 100644
@@ -353,9 +353,18 @@ static void dpu_kms_global_destroy_state(struct drm_private_obj *obj,
  	kfree(dpu_state);
  }
 
+static void dpu_kms_global_print_state(struct drm_printer *p,
+				       const struct drm_private_state *state)
+{
+	const struct dpu_global_state *global_state = to_dpu_global_state(state);
+
+	dpu_rm_print_state(p, global_state);
+}
+
  static const struct drm_private_state_funcs dpu_kms_global_state_funcs = {
  	.atomic_duplicate_state = dpu_kms_global_duplicate_state,
  	.atomic_destroy_state = dpu_kms_global_destroy_state,
+	.atomic_print_state = dpu_kms_global_print_state,
  };
 
  static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
@@ -371,6 +380,9 @@ static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
  	drm_atomic_private_obj_init(dpu_kms->dev, &dpu_kms->global_state,
  				    &state->base,
  				    &dpu_kms_global_state_funcs);
+
+	state->rm = &dpu_kms->rm;
+
  	return 0;
  }
 
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +2 -0
index d1207f4ec3ae..2512c9bd08df 100644
@@ -131,6 +131,8 @@ struct vsync_info {
  struct dpu_global_state {
  	struct drm_private_state base;
 
+	struct dpu_rm *rm;
+
  	uint32_t pingpong_to_enc_id[PINGPONG_MAX - PINGPONG_0];
  	uint32_t mixer_to_enc_id[LM_MAX - LM_0];
  	uint32_t ctl_to_enc_id[CTL_MAX - CTL_0];
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +0 -0
index 724537ab776d..1a56ddca536d 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c int dpu_rm_get_assigned_resources(struct dpu_rm *rm, · line 640

Quoted 7 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +4 -0
@@ -634,3 +634,59 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,
 
  	return num_blks;
  }
+
+static void dpu_rm_print_state_helper(struct drm_printer *p,
+					    struct dpu_hw_blk *blk,
+					    uint32_t mapping)

Not sure if its the mail client, but is this aligned with the opening brace?

Please double check once. Rest LGTM.

#2 lore raw
Quoted 90 lines · Abhinav Kumar
Quoted 5 lines · Dmitry Baryshkov

Provide atomic_print_state callback to the DPU's private object. This way the debugfs/dri/0/state will also include RM's internal state.

Example output (RB5 board, HDMI and writeback encoder enabled)

Quoted 8 lines

resource mapping:

      pingpong=31 36 # # # # - - - - -
      mixer=31 36 # # # # -
      ctl=# # 31 36 # #
      dspp=# # # #
      dsc=# # # # - -
      cdm=#

Thanks, this LGTM now, one nit below.

Quoted 70 lines

---
Changes in v5:
- Extracted the common helper for printing RM state
- Changed the code to print '#' for unused/unmapped blocks (Abhinav)
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Split the patch from the virual wide planes series
- Reworked the output format
- Added the CDM block into the dump

---
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 12 +++++++
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h |  2 ++
  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 56 +++++++++++++++++++++++++++++++++
  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  |  8 +++++
  4 files changed, 78 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +12 -0
index 723cc1d82143..9f3697e1eacb 100644
@@ -353,9 +353,18 @@ static void dpu_kms_global_destroy_state(struct drm_private_obj *obj,
      kfree(dpu_state);
  }
 
+static void dpu_kms_global_print_state(struct drm_printer *p,
+                                    const struct drm_private_state *state)
+{
+     const struct dpu_global_state *global_state = to_dpu_global_state(state);
+
+     dpu_rm_print_state(p, global_state);
+}
+
  static const struct drm_private_state_funcs dpu_kms_global_state_funcs = {
      .atomic_duplicate_state = dpu_kms_global_duplicate_state,
      .atomic_destroy_state = dpu_kms_global_destroy_state,
+     .atomic_print_state = dpu_kms_global_print_state,
  };
 
  static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
@@ -371,6 +380,9 @@ static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
      drm_atomic_private_obj_init(dpu_kms->dev, &dpu_kms->global_state,
                                  &state->base,
                                  &dpu_kms_global_state_funcs);
+
+     state->rm = &dpu_kms->rm;
+
      return 0;
  }
 
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +2 -0
index d1207f4ec3ae..2512c9bd08df 100644
@@ -131,6 +131,8 @@ struct vsync_info {
  struct dpu_global_state {
      struct drm_private_state base;
 
+     struct dpu_rm *rm;
+
      uint32_t pingpong_to_enc_id[PINGPONG_MAX - PINGPONG_0];
      uint32_t mixer_to_enc_id[LM_MAX - LM_0];
      uint32_t ctl_to_enc_id[CTL_MAX - CTL_0];
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +0 -0
index 724537ab776d..1a56ddca536d 100644
@@ -634,3 +634,59 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,
 
Quoted 8 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c int dpu_rm_get_assigned_resources(struct dpu_rm *rm, · line 640

Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +4 -0
      return num_blks;
  }
+
+static void dpu_rm_print_state_helper(struct drm_printer *p,
+                                         struct dpu_hw_blk *blk,
+                                         uint32_t mapping)

Not sure if its the mail client, but is this aligned with the opening brace?

No, it is shifted to the right. Will fix while applying.

Quoted 4 lines

Please double check once. Rest LGTM.

Signature · 2 lines
With best wishes
Dmitry