From 330c0722c7f459ea70745b6d5b498e2d00cb5f2b Mon Sep 17 00:00:00 2001 From: "qinglin.li" Date: Wed, 1 Feb 2023 19:52:57 +0800 Subject: [PATCH] ddr_bandwidth: ddr theoretic max bandwidth value error [1/1] PD#SWPL-109664 Problem: ddr theoretic max bandwidth value error Solution: some soc dmc bus bandwidth is 16 Verify: s5 Change-Id: I233c6ba840f4a758bd0b7335fde5cca436ae41a6 Signed-off-by: qinglin.li --- drivers/memory_debug/ddr_tool/ddr_band_op_t7.c | 6 +----- drivers/memory_debug/ddr_tool/ddr_bandwidth.c | 9 ++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/memory_debug/ddr_tool/ddr_band_op_t7.c b/drivers/memory_debug/ddr_tool/ddr_band_op_t7.c index 0c6395d67..c7cf646b2 100644 --- a/drivers/memory_debug/ddr_tool/ddr_band_op_t7.c +++ b/drivers/memory_debug/ddr_tool/ddr_band_op_t7.c @@ -203,11 +203,7 @@ static unsigned long t7_get_dmc_freq_quick(struct ddr_bandwidth *db) od1 = (((val >> 19) & 0x1)) == 1 ? 2 : 1; freq = DEFAULT_XTAL_FREQ / 1000; /* avoid overflow */ if (n) { - if (db->cpu_type == DMC_TYPE_P1) - freq = ((((freq * m) / n) >> od1) / od_div) * 1000 / 2; - else - - freq = ((((freq * m) / n) >> od1) / od_div) * 1000; + freq = ((((freq * m) / n) >> od1) / od_div) * 1000; } return freq; diff --git a/drivers/memory_debug/ddr_tool/ddr_bandwidth.c b/drivers/memory_debug/ddr_tool/ddr_bandwidth.c index 3efe15a29..b79544e89 100644 --- a/drivers/memory_debug/ddr_tool/ddr_bandwidth.c +++ b/drivers/memory_debug/ddr_tool/ddr_bandwidth.c @@ -181,7 +181,14 @@ static void cal_ddr_usage(struct ddr_bandwidth *db, struct ddr_grant *dg) } } else { - mbw = (u64)freq * db->bytes_per_cycle * db->dmc_number; + /* ddr data bus width = dmc bus width * dmc number. + * After s4 soc, not register to distinguish ddr data bus width, + * default ereryone dmc bus width is 32, but p1 and s5 is 16. + */ + if (db->cpu_type == DMC_TYPE_P1 || db->cpu_type == DMC_TYPE_S5) + mbw = (u64)freq * db->bytes_per_cycle * db->dmc_number / 2; + else + mbw = (u64)freq * db->bytes_per_cycle * db->dmc_number; } if (!mbw) { pr_emerg("warning: theoretic max bandwidth is zer0\n");