From a70bf82036b17ea3f12074306f853e92492dad2f Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Mon, 28 Jul 2025 15:09:56 +0800 Subject: [PATCH] soc/mediatek/common: Measure eDP initialization time Meaure the execution time for following eDP functions. - dptx_check_sinkcap - dptx_get_edid - dptx_set_trainingstart - mtk_edp_init These dptx_* functions are the primary contributors to the execution time of mtk_edp_init, which is only called in dev/recovery mode. This insight can be used for future boot time optimization by breaking down the eDP initialization process. TEST=Boot with DEV mode using the boot image without serial console support. TEST=cbmem -c|grep "done after" [INFO ] dptx_check_sinkcap done after 38 msecs [INFO ] dptx_get_edid done after 294 msecs [INFO ] dptx_set_trainingstart done after 100 msecs [INFO ] mtk_edp_init done after 438 msecs Change-Id: I7aabf3a33b9628f20fe16980033b00de9afc44e6 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/88584 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu Reviewed-by: Paul Menzel --- src/soc/mediatek/common/dp/dptx_common.c | 15 +++++++++++++++ src/soc/mediatek/common/dp/dptx_v1.c | 5 +++++ src/soc/mediatek/common/dp/dptx_v2.c | 6 +++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/soc/mediatek/common/dp/dptx_common.c b/src/soc/mediatek/common/dp/dptx_common.c index 5326fb55e7..9c6cdcba4d 100644 --- a/src/soc/mediatek/common/dp/dptx_common.c +++ b/src/soc/mediatek/common/dp/dptx_common.c @@ -11,6 +11,7 @@ #include #include #include +#include static bool dptx_auxwrite_bytes(struct mtk_dp *mtk_dp, u8 cmd, u32 dpcd_addr, size_t length, u8 *data) @@ -77,7 +78,9 @@ static int dptx_get_edid(struct mtk_dp *mtk_dp, struct edid *out) u8 tmp = 0; u8 extblock = 0; size_t total_size; + struct stopwatch sw; + stopwatch_init(&sw); dptx_auxwrite_dpcd(mtk_dp, DP_AUX_I2C_WRITE, 0x50, 0x1, &tmp); /* Read 1st block */ @@ -111,6 +114,9 @@ static int dptx_get_edid(struct mtk_dp *mtk_dp, struct edid *out) } mtk_dp->edid = out; + printk(BIOS_INFO, "%s done after %lld msecs\n", __func__, + stopwatch_duration_msecs(&sw)); + return 0; } @@ -404,7 +410,9 @@ static void dptx_set_dptxout(struct mtk_dp *mtk_dp) static void dptx_check_sinkcap(struct mtk_dp *mtk_dp) { u8 buffer[16]; + struct stopwatch sw; + stopwatch_init(&sw); memset(buffer, 0x0, sizeof(buffer)); buffer[0] = 0x1; @@ -473,6 +481,8 @@ static void dptx_check_sinkcap(struct mtk_dp *mtk_dp) dptx_auxread_dpcd(mtk_dp, DP_AUX_NATIVE_READ, DPCD_00200, 0x2, buffer); + printk(BIOS_INFO, "%s done after %lld msecs\n", __func__, + stopwatch_duration_msecs(&sw)); } void dptx_video_enable(struct mtk_dp *mtk_dp, bool enable) @@ -532,6 +542,9 @@ __weak void dptx_power_on(void) { /* do nothing */ }; int mtk_edp_init(struct mtk_dp *mtk_dp, struct edid *edid) { + struct stopwatch sw; + + stopwatch_init(&sw); dptx_power_on(); dptx_init_variable(mtk_dp); dptx_init_port(mtk_dp); @@ -555,6 +568,8 @@ int mtk_edp_init(struct mtk_dp *mtk_dp, struct edid *edid) dp_intf_config(edid); dptx_video_config(mtk_dp); + printk(BIOS_INFO, "%s done after %lld msecs\n", __func__, + stopwatch_duration_msecs(&sw)); return 0; } diff --git a/src/soc/mediatek/common/dp/dptx_v1.c b/src/soc/mediatek/common/dp/dptx_v1.c index bf95eff967..76a324a9bb 100644 --- a/src/soc/mediatek/common/dp/dptx_v1.c +++ b/src/soc/mediatek/common/dp/dptx_v1.c @@ -12,6 +12,7 @@ #include #include #include +#include static void dptx_training_checkswingpre(struct mtk_dp *mtk_dp, u8 target_lane_count, @@ -364,7 +365,9 @@ int dptx_set_trainingstart(struct mtk_dp *mtk_dp) u8 buffer; u8 limit; u8 max_linkrate; + struct stopwatch sw; + stopwatch_init(&sw); buffer = 0x1; dptx_auxwrite_dpcd(mtk_dp, DP_AUX_NATIVE_WRITE, DPCD_00600, 0x1, &buffer); @@ -447,6 +450,8 @@ int dptx_set_trainingstart(struct mtk_dp *mtk_dp) else return DPTX_TRANING_FAIL; } else { + printk(BIOS_INFO, "%s done after %lld msecs\n", __func__, + stopwatch_duration_msecs(&sw)); return DPTX_PASS; } } while (--limit > 0); diff --git a/src/soc/mediatek/common/dp/dptx_v2.c b/src/soc/mediatek/common/dp/dptx_v2.c index adea70d140..5b917a501a 100644 --- a/src/soc/mediatek/common/dp/dptx_v2.c +++ b/src/soc/mediatek/common/dp/dptx_v2.c @@ -11,6 +11,7 @@ #include #include #include +#include static void mtk_edp_pattern(struct mtk_dp *mtk_dp, u8 lane_count, u8 pattern) { @@ -255,7 +256,9 @@ int dptx_set_trainingstart(struct mtk_dp *mtk_dp) u8 train_limit; u8 max_linkrate; int ret; + struct stopwatch sw; + stopwatch_init(&sw); buffer = 0x1; dptx_auxwrite_dpcd(mtk_dp, DP_AUX_NATIVE_WRITE, DPCD_00600, 0x1, &buffer); @@ -349,7 +352,8 @@ int dptx_set_trainingstart(struct mtk_dp *mtk_dp) dptx_hal_setscramble(mtk_dp, true); dptx_hal_set_ef_mode(mtk_dp, ENABLE_DPTX_EF_MODE); - printk(BIOS_INFO, "%s: done\n", __func__); + printk(BIOS_INFO, "%s done after %lld msecs\n", __func__, + stopwatch_duration_msecs(&sw)); return DPTX_PASS; }