]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: add dc interface for query QoS information
authorWenjing Liu <wenjing.liu@amd.com>
Mon, 10 Nov 2025 19:37:26 +0000 (14:37 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 8 Dec 2025 18:56:40 +0000 (13:56 -0500)
[why]
Add support for retrieving Quality of Service (QoS) metrics from dc
to enable performance analysis and bottleneck identification. This provides
benchmark tools with real-time bandwidth and latency measurements from hardware
performance counters, helping diagnose display system performance issues.

[how]
- Add dc_get_qos_info() function to DC layer for unified QoS data retrieval
- Implement hardware sequencer interface with function pointers for QoS
measurements
- Integrate QoS metrics: peak/average bandwidth (Mbps) and max/average
latency (ns)

Reviewed-by: Aric Cyr <aric.cyr@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Roman Li <roman.li@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h

index 8be9cbd43e180e2142799e25f34179a3505af972..1e7c61b975e3f9b0813870387ba816bda1cd59e4 100644 (file)
@@ -7091,3 +7091,27 @@ void dc_log_preos_dmcub_info(const struct dc *dc)
 {
        dc_dmub_srv_log_preos_dmcub_info(dc->ctx->dmub_srv);
 }
+
+bool dc_get_qos_info(struct dc *dc, struct dc_qos_info *info)
+{
+       const struct dc_clocks *clk = &dc->current_state->bw_ctx.bw.dcn.clk;
+
+       memset(info, 0, sizeof(*info));
+
+       // Check if all measurement functions are available
+       if (!dc->hwss.measure_peak_bw_mbps ||
+           !dc->hwss.measure_avg_bw_mbps ||
+           !dc->hwss.measure_max_latency_ns ||
+           !dc->hwss.measure_avg_latency_ns) {
+               return false;
+       }
+
+       // Call measurement functions to get actual values
+       info->actual_peak_bw_in_mbps = dc->hwss.measure_peak_bw_mbps(dc);
+       info->actual_avg_bw_in_mbps = dc->hwss.measure_avg_bw_mbps(dc);
+       info->actual_max_latency_in_ns = dc->hwss.measure_max_latency_ns(dc);
+       info->actual_avg_latency_in_ns = dc->hwss.measure_avg_latency_ns(dc);
+       info->dcn_bandwidth_ub_in_mbps = (uint32_t)(clk->fclk_khz / 1000 * 64);
+
+       return true;
+}
index a5f7b2561b005bf391a38ead5ff42ad7842fbf7a..27b202f66541e8e3aee2a96cca648399266361af 100644 (file)
@@ -951,6 +951,18 @@ struct dc_bounding_box_overrides {
        int min_dcfclk_mhz;
 };
 
+struct dc_qos_info {
+       uint32_t actual_peak_bw_in_mbps;
+       uint32_t qos_bandwidth_lb_in_mbps;
+       uint32_t actual_avg_bw_in_mbps;
+       uint32_t calculated_avg_bw_in_mbps;
+       uint32_t actual_max_latency_in_ns;
+       uint32_t qos_max_latency_ub_in_ns;
+       uint32_t actual_avg_latency_in_ns;
+       uint32_t qos_avg_latency_ub_in_ns;
+       uint32_t dcn_bandwidth_ub_in_mbps;
+};
+
 struct dc_state;
 struct resource_pool;
 struct dce_hwseq;
@@ -3322,4 +3334,28 @@ struct dc_register_software_state {
  */
 bool dc_capture_register_software_state(struct dc *dc, struct dc_register_software_state *state);
 
+/**
+ * dc_get_qos_info() - Retrieve Quality of Service (QoS) information from display core
+ * @dc: DC context containing current display configuration
+ * @info: Pointer to dc_qos_info structure to populate with QoS metrics
+ *
+ * This function retrieves QoS metrics from the display core that can be used by
+ * benchmark tools to analyze display system performance. The function may take
+ * several milliseconds to execute due to hardware measurement requirements.
+ *
+ * QoS information includes:
+ * - Bandwidth bounds (lower limits in Mbps)
+ * - Latency bounds (upper limits in nanoseconds)
+ * - Hardware-measured bandwidth metrics (peak/average in Mbps)
+ * - Hardware-measured latency metrics (maximum/average in nanoseconds)
+ *
+ * The function will populate the provided dc_qos_info structure with current
+ * QoS measurements. If hardware measurement functions are not available for
+ * the current DCN version, the function returns false with zero'd info structure.
+ *
+ * Return: true if QoS information was successfully retrieved, false if measurement
+ *         functions are unavailable or hardware measurements cannot be performed
+ */
+bool dc_get_qos_info(struct dc *dc, struct dc_qos_info *info);
+
 #endif /* DC_INTERFACE_H_ */
index 8ed9eea40c56462fdae83a2d4f516f681d724e45..490a6fccebffc68acf17833fa771aa505143d72b 100644 (file)
@@ -1287,6 +1287,43 @@ struct hw_sequencer_funcs {
        void (*get_underflow_debug_data)(const struct dc *dc,
                        struct timing_generator *tg,
                        struct dc_underflow_debug_data *out_data);
+
+       /**
+        * measure_peak_bw_mbps - Measure actual peak bandwidth in Mbps
+        * @dc: DC structure
+        *
+        * Returns the measured peak bandwidth value in Mbps from hardware
+        * performance counters or registers.
+        */
+       uint32_t (*measure_peak_bw_mbps)(struct dc *dc);
+
+       /**
+        * measure_avg_bw_mbps - Measure actual average bandwidth in Mbps
+        * @dc: DC structure
+        *
+        * Returns the measured average bandwidth value in Mbps from hardware
+        * performance counters or registers.
+        */
+       uint32_t (*measure_avg_bw_mbps)(struct dc *dc);
+
+       /**
+        * measure_max_latency_ns - Measure actual maximum latency in nanoseconds
+        * @dc: DC structure
+        *
+        * Returns the measured maximum latency value in nanoseconds from hardware
+        * performance counters or registers.
+        */
+       uint32_t (*measure_max_latency_ns)(struct dc *dc);
+
+       /**
+        * measure_avg_latency_ns - Measure actual average latency in nanoseconds
+        * @dc: DC structure
+        *
+        * Returns the measured average latency value in nanoseconds from hardware
+        * performance counters or registers.
+        */
+       uint32_t (*measure_avg_latency_ns)(struct dc *dc);
+
 };
 
 void color_space_to_black_color(