Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions drivers/resctrl/mpam_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,7 @@ static void __ris_msmon_read(void *arg)
{
bool nrdy = false;
bool config_mismatch;
bool overflow;
struct mon_read *m = arg;
u64 now, overflow_val = 0;
struct mon_cfg *ctx = m->ctx;
Expand Down Expand Up @@ -1431,13 +1432,20 @@ static void __ris_msmon_read(void *arg)
* This saves waiting for 'nrdy' on subsequent reads.
*/
read_msmon_ctl_flt_vals(m, &cur_ctl, &cur_flt);
overflow = cur_ctl & MSMON_CFG_x_CTL_OFLOW_STATUS;

clean_msmon_ctl_val(&cur_ctl);
gen_msmon_ctl_flt_vals(m, &ctl_val, &flt_val);
config_mismatch = cur_flt != flt_val ||
cur_ctl != (ctl_val | MSMON_CFG_x_CTL_EN);

if (config_mismatch || reset_on_next_read)
if (config_mismatch || reset_on_next_read) {
write_msmon_ctl_flt_vals(m, ctl_val, flt_val);
overflow = false;
} else if (overflow) {
mpam_write_monsel_reg(msc, CFG_MBWU_CTL,
cur_ctl & ~MSMON_CFG_x_CTL_OFLOW_STATUS);
}

switch (m->type) {
case mpam_feat_msmon_csu:
Expand Down Expand Up @@ -1477,18 +1485,13 @@ static void __ris_msmon_read(void *arg)

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

/* Add any pre-overflow value to the mbwu_state->val */
if (mbwu_state->prev_val > now) {
overflow_val = mpam_msmon_overflow_val(m->type);
if (mpam_has_quirk(T241_MBW_COUNTER_SCALE_64, msc))
overflow_val *= 64;
overflow_val -= mbwu_state->prev_val;
}

mbwu_state->prev_val = now;
mbwu_state->correction += overflow_val;
if (overflow)
mbwu_state->correction += mpam_msmon_overflow_val(m->type);

/* Include bandwidth consumed before the last hardware reset */
/*
* Include bandwidth consumed before the last hardware reset and
* a counter size increment for each overflow.
*/
now += mbwu_state->correction;
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion drivers/resctrl/mpam_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ struct msmon_mbwu_state {

/*
* The value to add to the new reading to account for power management,
* and shifts to trigger the overflow interrupt.
* and overflow.
*/
u64 correction;

Expand Down
Loading