From: Konrad Dybcio <konrad.dybcio@linaro.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>
Cc: Marijn Suijten <marijn.suijten@somainline.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] soc: qcom: icc-bwmon: Set default thresholds dynamically
Date: Sat, 10 Jun 2023 19:32:39 +0200 [thread overview]
Message-ID: <af9364df-df56-f267-0369-83395d620c0f@linaro.org> (raw)
In-Reply-To: <22aa4744-7167-11fe-b21e-0b0af07f51c3@linaro.org>
On 10.06.2023 14:02, Konrad Dybcio wrote:
>
>
> On 10.06.2023 14:01, Konrad Dybcio wrote:
>> Currently we use predefined threshold values. This works, but does not
>> really scale well, as they may differ between SoCs due to LPDDR generation
>> and/or DDR controller setup. All of the data we need for that is already
>> provided in the device tree, anyway.
>>
>> Change that to:
>> * 0 for low (as we've been doing up until now)
>> * BW_MIN/4 for mid
>> * BW_MIN for high
>>
>> The mid value is chosen for a "low enough" bw to nudge bwmon into
>> slowing down if the bw starts too high from the bootloader.
>>
>> The high value corresponds to the upper barrier which - when crossed -
>> raises an interrupt in the third zone, signaling a need for upping
>> the bw.
>>
>> This only changes the values programmed at probe time, as high and med
>> thresholds are updated at interrupt, based on the OPP table from DT.
>>
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
> I think I hit a b4 bug and it didn't send this notice..:
>
> Depends on: https://lore.kernel.org/linux-arm-msm/d403e841-7a86-1f07-c634-1990902826f1@linaro.org/
>
> Konrad
>> drivers/soc/qcom/icc-bwmon.c | 28 +++++++---------------------
>> 1 file changed, 7 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/soc/qcom/icc-bwmon.c b/drivers/soc/qcom/icc-bwmon.c
>> index 40068a285913..99cbdb3cf531 100644
>> --- a/drivers/soc/qcom/icc-bwmon.c
>> +++ b/drivers/soc/qcom/icc-bwmon.c
>> @@ -165,9 +165,6 @@ enum bwmon_fields {
>> struct icc_bwmon_data {
>> unsigned int sample_ms;
>> unsigned int count_unit_kb; /* kbytes */
>> - unsigned int default_highbw_kbps;
>> - unsigned int default_medbw_kbps;
>> - unsigned int default_lowbw_kbps;
>> u8 zone1_thres_count;
>> u8 zone3_thres_count;
>> unsigned int quirks;
>> @@ -564,20 +561,21 @@ static void bwmon_set_threshold(struct icc_bwmon *bwmon,
>> static void bwmon_start(struct icc_bwmon *bwmon)
>> {
>> const struct icc_bwmon_data *data = bwmon->data;
>> + u32 bw_low = 0;
>> int window;
>>
>> + /* No need to check for errors, as this must have succeeded before. */
>> + dev_pm_opp_find_bw_ceil(bwmon->dev, &bw_low, 0);
>> +
>> bwmon_clear_counters(bwmon, true);
>>
>> window = mult_frac(bwmon->data->sample_ms, HW_TIMER_HZ, MSEC_PER_SEC);
>> /* Maximum sampling window: 0xffffff for v4 and 0xfffff for v5 */
>> regmap_field_write(bwmon->regs[F_SAMPLE_WINDOW], window);
>>
>> - bwmon_set_threshold(bwmon, bwmon->regs[F_THRESHOLD_HIGH],
>> - data->default_highbw_kbps);
>> - bwmon_set_threshold(bwmon, bwmon->regs[F_THRESHOLD_MED],
>> - data->default_medbw_kbps);
>> - bwmon_set_threshold(bwmon, bwmon->regs[F_THRESHOLD_LOW],
>> - data->default_lowbw_kbps);
>> + bwmon_set_threshold(bwmon, bwmon->regs[F_THRESHOLD_HIGH], bw_low);
>> + bwmon_set_threshold(bwmon, bwmon->regs[F_THRESHOLD_MED], div_u64(bw_low, 4));
Giving it a spin on more platforms, div4 seems to be.. too harsh for some?
MSM8998 boots fine if I divide it by 2, but crashes when I divide by 4..
Note sure what to make out of it..
Konrad
>> + bwmon_set_threshold(bwmon, bwmon->regs[F_THRESHOLD_LOW], 0);
>>
>> regmap_field_write(bwmon->regs[F_THRESHOLD_COUNT_ZONE0],
>> BWMON_THRESHOLD_COUNT_ZONE0_DEFAULT);
>> @@ -807,9 +805,6 @@ static int bwmon_remove(struct platform_device *pdev)
>> static const struct icc_bwmon_data msm8998_bwmon_data = {
>> .sample_ms = 4,
>> .count_unit_kb = 1024,
>> - .default_highbw_kbps = 4800 * 1024, /* 4.8 GBps */
>> - .default_medbw_kbps = 512 * 1024, /* 512 MBps */
>> - .default_lowbw_kbps = 0,
>> .zone1_thres_count = 16,
>> .zone3_thres_count = 1,
>> .quirks = BWMON_HAS_GLOBAL_IRQ,
>> @@ -822,9 +817,6 @@ static const struct icc_bwmon_data msm8998_bwmon_data = {
>> static const struct icc_bwmon_data sdm845_cpu_bwmon_data = {
>> .sample_ms = 4,
>> .count_unit_kb = 64,
>> - .default_highbw_kbps = 4800 * 1024, /* 4.8 GBps */
>> - .default_medbw_kbps = 512 * 1024, /* 512 MBps */
>> - .default_lowbw_kbps = 0,
>> .zone1_thres_count = 16,
>> .zone3_thres_count = 1,
>> .quirks = BWMON_HAS_GLOBAL_IRQ,
>> @@ -835,9 +827,6 @@ static const struct icc_bwmon_data sdm845_cpu_bwmon_data = {
>> static const struct icc_bwmon_data sdm845_llcc_bwmon_data = {
>> .sample_ms = 4,
>> .count_unit_kb = 1024,
>> - .default_highbw_kbps = 800 * 1024, /* 800 MBps */
>> - .default_medbw_kbps = 256 * 1024, /* 256 MBps */
>> - .default_lowbw_kbps = 0,
>> .zone1_thres_count = 16,
>> .zone3_thres_count = 1,
>> .regmap_fields = sdm845_llcc_bwmon_reg_fields,
>> @@ -847,9 +836,6 @@ static const struct icc_bwmon_data sdm845_llcc_bwmon_data = {
>> static const struct icc_bwmon_data sc7280_llcc_bwmon_data = {
>> .sample_ms = 4,
>> .count_unit_kb = 64,
>> - .default_highbw_kbps = 800 * 1024, /* 800 MBps */
>> - .default_medbw_kbps = 256 * 1024, /* 256 MBps */
>> - .default_lowbw_kbps = 0,
>> .zone1_thres_count = 16,
>> .zone3_thres_count = 1,
>> .quirks = BWMON_NEEDS_FORCE_CLEAR,
>>
>> ---
>> base-commit: 49dd846128d56199db2e3bcfca42d87fbc82b212
>> change-id: 20230610-topic-bwmon_opp-f995bbdd18bd
>>
>> Best regards,
next prev parent reply other threads:[~2023-06-10 17:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-10 12:01 Konrad Dybcio
2023-06-10 12:02 ` Konrad Dybcio
2023-06-10 17:32 ` Konrad Dybcio [this message]
2023-06-11 1:45 ` Bjorn Andersson
2023-06-12 9:55 ` Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af9364df-df56-f267-0369-83395d620c0f@linaro.org \
--to=konrad.dybcio@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marijn.suijten@somainline.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®