]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Add dc interface to log pre os firmware information
authorMeenakshikumar Somasundaram <meenakshikumar.somasundaram@amd.com>
Wed, 15 Oct 2025 18:45:43 +0000 (14:45 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Oct 2025 13:58:11 +0000 (09:58 -0400)
[Why]
Pre os firmware information is useful to debug pre os to post os fw
transition issues.

[How]
Add dc interface dc_log_preos_dmcub_info() to log pre os firmware
information.

Reviewed-by: Cruise Hung <cruise.hung@amd.com>
Signed-off-by: Meenakshikumar Somasundaram <meenakshikumar.somasundaram@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@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/dc_dmub_srv.c
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
drivers/gpu/drm/amd/display/dmub/dmub_srv.h
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn35.c
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn35.h
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c

index 2eb02345daddc7862bedd54ba1a6fa4e4bf3fab8..6ef9dd9ab7a3e41caa34dcc4aac78b43a8f75834 100644 (file)
@@ -6401,3 +6401,8 @@ void dc_get_underflow_debug_data_for_otg(struct dc *dc, int primary_otg_inst,
        if (dc->hwss.get_underflow_debug_data)
                dc->hwss.get_underflow_debug_data(dc, tg, out_data);
 }
+
+void dc_log_preos_dmcub_info(const struct dc *dc)
+{
+       dc_dmub_srv_log_preos_dmcub_info(dc->ctx->dmub_srv);
+}
index 0fcecf1c5debe363583d14e58a115bf62c373b7b..4a5aa0bd3bc4d3bd64519aaf0de313f303fff150 100644 (file)
@@ -2727,6 +2727,8 @@ unsigned int dc_get_det_buffer_size_from_state(const struct dc_state *context);
 
 bool dc_get_host_router_index(const struct dc_link *link, unsigned int *host_router_index);
 
+void dc_log_preos_dmcub_info(const struct dc *dc);
+
 /* DSC Interfaces */
 #include "dc_dsc.h"
 
index 4b20c01bf64611870016a21519bfb3ecd8300cb5..fffbf1983143df2f96d1e9f41d591807532fd352 100644 (file)
@@ -2344,3 +2344,24 @@ void dc_dmub_srv_release_hw(const struct dc *dc)
 
        dm_execute_dmub_cmd(dc->ctx, &cmd,  DM_DMUB_WAIT_TYPE_WAIT);
 }
+
+void dc_dmub_srv_log_preos_dmcub_info(struct dc_dmub_srv *dc_dmub_srv)
+{
+       struct dmub_srv *dmub;
+
+       if (!dc_dmub_srv || !dc_dmub_srv->dmub)
+               return;
+
+       dmub = dc_dmub_srv->dmub;
+
+       if (dmub_srv_get_preos_info(dmub)) {
+               DC_LOG_DEBUG("%s: PreOS DMCUB Info", __func__);
+               DC_LOG_DEBUG("fw_version                                : 0x%08x", dmub->preos_info.fw_version);
+               DC_LOG_DEBUG("boot_options                              : 0x%08x", dmub->preos_info.boot_options);
+               DC_LOG_DEBUG("boot_status                               : 0x%08x", dmub->preos_info.boot_status);
+               DC_LOG_DEBUG("trace_buffer_phy_addr             : 0x%016llx", dmub->preos_info.trace_buffer_phy_addr);
+               DC_LOG_DEBUG("trace_buffer_size_bytes   : 0x%08x", dmub->preos_info.trace_buffer_size);
+               DC_LOG_DEBUG("fb_base                                   : 0x%016llx", dmub->preos_info.fb_base);
+               DC_LOG_DEBUG("fb_offset                                 : 0x%016llx", dmub->preos_info.fb_offset);
+       }
+}
index 9bb00d48fd5e16e65ec298c63bce34af1a9797e2..72e0a41f39f04729a7ec56fed0d736b69435a525 100644 (file)
@@ -367,4 +367,11 @@ bool dc_dmub_srv_is_cursor_offload_enabled(const struct dc *dc);
  * @dc - pointer to DC object
  */
 void dc_dmub_srv_release_hw(const struct dc *dc);
+
+/**
+ * dc_dmub_srv_log_preos_dmcub_info() - Logs preos dmcub fw info.
+ *
+ * @dc - pointer to DC object
+ */
+void dc_dmub_srv_log_preos_dmcub_info(struct dc_dmub_srv *dc_dmub_srv);
 #endif /* _DMUB_DC_SRV_H_ */
index f25c2fc2f98fd787e654b31aaac743142bf2793b..9d0168986fe7a5ac9863a3c20faa5a2ac84bd62d 100644 (file)
@@ -363,6 +363,19 @@ struct dmub_diagnostic_data {
        uint8_t is_pwait : 1;
 };
 
+/**
+ * struct dmub_preos_info - preos fw info before loading post os fw.
+ */
+struct dmub_preos_info {
+       uint64_t fb_base;
+       uint64_t fb_offset;
+       uint64_t trace_buffer_phy_addr;
+       uint32_t trace_buffer_size;
+       uint32_t fw_version;
+       uint32_t boot_status;
+       uint32_t boot_options;
+};
+
 struct dmub_srv_inbox {
        /* generic status */
        uint64_t num_submitted;
@@ -488,6 +501,7 @@ struct dmub_srv_hw_funcs {
        uint32_t (*get_current_time)(struct dmub_srv *dmub);
 
        void (*get_diagnostic_data)(struct dmub_srv *dmub);
+       bool (*get_preos_fw_info)(struct dmub_srv *dmub);
 
        bool (*should_detect)(struct dmub_srv *dmub);
        void (*init_reg_offsets)(struct dmub_srv *dmub, struct dc_context *ctx);
@@ -588,6 +602,7 @@ struct dmub_srv {
        enum dmub_srv_power_state_type power_state;
        struct dmub_diagnostic_data debug;
        struct dmub_fb lsdma_rb_fb;
+       struct dmub_preos_info preos_info;
 };
 
 /**
@@ -1073,4 +1088,14 @@ enum dmub_status dmub_srv_wait_for_inbox_free(struct dmub_srv *dmub,
  */
 enum dmub_status dmub_srv_update_inbox_status(struct dmub_srv *dmub);
 
+/**
+ * dmub_srv_get_preos_info() - retrieves preos fw info
+ * @dmub: the dmub service
+ *
+ * Return:
+ *   true - preos fw info retrieved successfully
+ *   false - preos fw info not retrieved successfully
+ */
+bool dmub_srv_get_preos_info(struct dmub_srv *dmub);
+
 #endif /* _DMUB_SRV_H_ */
index b40482dbd6ad641850f3b9ecc392fdd91d4b3981..e13557ed97be532bf75108c6701f9de407c4154c 100644 (file)
@@ -521,6 +521,45 @@ void dmub_dcn35_get_diagnostic_data(struct dmub_srv *dmub)
 
        dmub->debug.gpint_datain0 = REG_READ(DMCUB_GPINT_DATAIN0);
 }
+
+bool dmub_dcn35_get_preos_fw_info(struct dmub_srv *dmub)
+{
+       uint64_t region3_cw5_offset;
+       uint32_t top_addr, top_addr_enable, offset_low;
+       uint32_t offset_high, base_addr, fw_version;
+       bool is_vbios_fw = false;
+
+       memset(&dmub->preos_info, 0, sizeof(dmub->preos_info));
+
+       fw_version = REG_READ(DMCUB_SCRATCH1);
+       is_vbios_fw = ((fw_version >> 6) & 0x01) ? true : false;
+       if (!is_vbios_fw)
+               return false;
+
+       dmub->preos_info.boot_status = REG_READ(DMCUB_SCRATCH0);
+       dmub->preos_info.fw_version = REG_READ(DMCUB_SCRATCH1);
+       dmub->preos_info.boot_options = REG_READ(DMCUB_SCRATCH14);
+       REG_GET(DMCUB_REGION3_CW5_TOP_ADDRESS,
+               DMCUB_REGION3_CW5_ENABLE, &top_addr_enable);
+       if (top_addr_enable) {
+               dmub_dcn35_get_fb_base_offset(dmub,
+                       &dmub->preos_info.fb_base, &dmub->preos_info.fb_offset);
+               offset_low = REG_READ(DMCUB_REGION3_CW5_OFFSET);
+               offset_high = REG_READ(DMCUB_REGION3_CW5_OFFSET_HIGH);
+               region3_cw5_offset = ((uint64_t)offset_high << 32) | offset_low;
+               dmub->preos_info.trace_buffer_phy_addr = region3_cw5_offset
+                       - dmub->preos_info.fb_base + dmub->preos_info.fb_offset;
+
+               REG_GET(DMCUB_REGION3_CW5_TOP_ADDRESS,
+                       DMCUB_REGION3_CW5_TOP_ADDRESS, &top_addr);
+               base_addr = REG_READ(DMCUB_REGION3_CW5_BASE_ADDRESS) & 0x1FFFFFFF;
+               dmub->preos_info.trace_buffer_size =
+                       (top_addr > base_addr) ? (top_addr - base_addr + 1) : 0;
+       }
+
+       return true;
+}
+
 void dmub_dcn35_configure_dmub_in_system_memory(struct dmub_srv *dmub)
 {
        /* DMCUB_REGION3_TMR_AXI_SPACE values:
index 39fcb7275da515abdce3751887b76416f1112ee5..92e6695a2c9bad86cf0fb74e185ceab2f9b66d69 100644 (file)
@@ -285,4 +285,6 @@ bool dmub_dcn35_is_hw_powered_up(struct dmub_srv *dmub);
 
 void dmub_srv_dcn35_regs_init(struct dmub_srv *dmub, struct dc_context *ctx);
 
+bool dmub_dcn35_get_preos_fw_info(struct dmub_srv *dmub);
+
 #endif /* _DMUB_DCN35_H_ */
index 0244c9b44eccf3c8e67b35c30d68f7738bb4c953..a657efda89ce3a255b655d60ea7017ca950b1201 100644 (file)
@@ -359,6 +359,7 @@ static bool dmub_srv_hw_setup(struct dmub_srv *dmub, enum dmub_asic asic)
 
                        funcs->get_current_time = dmub_dcn35_get_current_time;
                        funcs->get_diagnostic_data = dmub_dcn35_get_diagnostic_data;
+                       funcs->get_preos_fw_info = dmub_dcn35_get_preos_fw_info;
 
                        funcs->init_reg_offsets = dmub_srv_dcn35_regs_init;
                        if (asic == DMUB_ASIC_DCN351)
@@ -1372,3 +1373,11 @@ enum dmub_status dmub_srv_update_inbox_status(struct dmub_srv *dmub)
 
        return DMUB_STATUS_OK;
 }
+
+bool dmub_srv_get_preos_info(struct dmub_srv *dmub)
+{
+       if (!dmub || !dmub->hw_funcs.get_preos_fw_info)
+               return false;
+
+       return dmub->hw_funcs.get_preos_fw_info(dmub);
+}