Skip to content

Commit b353637

Browse files
benhor01ctmarinas
authored andcommitted
arm_mpam: Consider overflow in bandwidth counter state
Use the overflow status bit to track overflow on each bandwidth counter read and add the counter size to the correction when overflow is detected. This assumes that only a single overflow has occurred since the last read of the counter. Overflow interrupts, on hardware that supports them could be used to remove this limitation. Cc: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 41e8a14 commit b353637

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

drivers/resctrl/mpam_devices.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,18 @@ static void write_msmon_ctl_flt_vals(struct mon_read *m, u32 ctl_val,
985985
}
986986
}
987987

988+
static u64 mpam_msmon_overflow_val(enum mpam_device_features type)
989+
{
990+
/* TODO: scaling, and long counters */
991+
return BIT_ULL(hweight_long(MSMON___VALUE));
992+
}
993+
988994
static void __ris_msmon_read(void *arg)
989995
{
990996
u64 now;
991997
bool nrdy = false;
992998
bool config_mismatch;
999+
bool overflow;
9931000
struct mon_read *m = arg;
9941001
struct mon_cfg *ctx = m->ctx;
9951002
struct mpam_msc_ris *ris = m->ris;
@@ -1011,13 +1018,20 @@ static void __ris_msmon_read(void *arg)
10111018
* This saves waiting for 'nrdy' on subsequent reads.
10121019
*/
10131020
read_msmon_ctl_flt_vals(m, &cur_ctl, &cur_flt);
1021+
overflow = cur_ctl & MSMON_CFG_x_CTL_OFLOW_STATUS;
1022+
10141023
clean_msmon_ctl_val(&cur_ctl);
10151024
gen_msmon_ctl_flt_vals(m, &ctl_val, &flt_val);
10161025
config_mismatch = cur_flt != flt_val ||
10171026
cur_ctl != (ctl_val | MSMON_CFG_x_CTL_EN);
10181027

1019-
if (config_mismatch)
1028+
if (config_mismatch) {
10201029
write_msmon_ctl_flt_vals(m, ctl_val, flt_val);
1030+
overflow = false;
1031+
} else if (overflow) {
1032+
mpam_write_monsel_reg(msc, CFG_MBWU_CTL,
1033+
cur_ctl & ~MSMON_CFG_x_CTL_OFLOW_STATUS);
1034+
}
10211035

10221036
switch (m->type) {
10231037
case mpam_feat_msmon_csu:
@@ -1037,7 +1051,13 @@ static void __ris_msmon_read(void *arg)
10371051

10381052
mbwu_state = &ris->mbwu_state[ctx->mon];
10391053

1040-
/* Include bandwidth consumed before the last hardware reset */
1054+
if (overflow)
1055+
mbwu_state->correction += mpam_msmon_overflow_val(m->type);
1056+
1057+
/*
1058+
* Include bandwidth consumed before the last hardware reset and
1059+
* a counter size increment for each overflow.
1060+
*/
10411061
now += mbwu_state->correction;
10421062
break;
10431063
default:

drivers/resctrl/mpam_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ struct msmon_mbwu_state {
211211
struct mon_cfg cfg;
212212

213213
/*
214-
* The value to add to the new reading to account for power management.
214+
* The value to add to the new reading to account for power management,
215+
* and overflow.
215216
*/
216217
u64 correction;
217218

0 commit comments

Comments
 (0)