Skip to content

Commit dc48eb1

Browse files
shankerd04James Morse
authored andcommitted
arm_mpam: Add workaround for T241-MPAM-6
The registers MSMON_MBWU_L and MSMON_MBWU return the number of requests rather than the number of bytes transferred. Bandwidth resource monitoring is performed at the last level cache, where each request arrive in 64Byte granularity. The current implementation returns the number of transactions received at the last level cache but does not provide the value in bytes. Scaling by 64 gives an accurate byte count to match the MPAM specification for the MSMON_MBWU and MSMON_MBWU_L registers. This patch fixes the issue by reporting the actual number of bytes instead of the number of transactions from __ris_msmon_read(). Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Jesse Chick <jessechick@os.amperecomputing.com> Reviewed-by: Zeng Heng <zengheng4@huawei.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent a7efe23 commit dc48eb1

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

Documentation/arch/arm64/silicon-errata.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ stable kernels.
251251
+----------------+-----------------+-----------------+-----------------------------+
252252
| NVIDIA | T241 MPAM | T241-MPAM-4 | N/A |
253253
+----------------+-----------------+-----------------+-----------------------------+
254+
| NVIDIA | T241 MPAM | T241-MPAM-6 | N/A |
255+
+----------------+-----------------+-----------------+-----------------------------+
254256
+----------------+-----------------+-----------------+-----------------------------+
255257
| Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 |
256258
+----------------+-----------------+-----------------+-----------------------------+

drivers/resctrl/mpam_devices.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ static const struct mpam_quirk mpam_quirks[] = {
685685
.iidr_mask = MPAM_IIDR_MATCH_ONE,
686686
.workaround = T241_FORCE_MBW_MIN_TO_ONE,
687687
},
688+
{
689+
/* NVIDIA t241 erratum T241-MPAM-6 */
690+
.iidr = MPAM_IIDR_NVIDIA_T241,
691+
.iidr_mask = MPAM_IIDR_MATCH_ONE,
692+
.workaround = T241_MBW_COUNTER_SCALE_64,
693+
},
688694
{ NULL } /* Sentinel */
689695
};
690696

@@ -1146,7 +1152,7 @@ static void write_msmon_ctl_flt_vals(struct mon_read *m, u32 ctl_val,
11461152
}
11471153
}
11481154

1149-
static u64 mpam_msmon_overflow_val(enum mpam_device_features type)
1155+
static u64 __mpam_msmon_overflow_val(enum mpam_device_features type)
11501156
{
11511157
/* TODO: implement scaling counters */
11521158
switch (type) {
@@ -1161,6 +1167,18 @@ static u64 mpam_msmon_overflow_val(enum mpam_device_features type)
11611167
}
11621168
}
11631169

1170+
static u64 mpam_msmon_overflow_val(enum mpam_device_features type,
1171+
struct mpam_msc *msc)
1172+
{
1173+
u64 overflow_val = __mpam_msmon_overflow_val(type);
1174+
1175+
if (mpam_has_quirk(T241_MBW_COUNTER_SCALE_64, msc) &&
1176+
type != mpam_feat_msmon_mbwu_63counter)
1177+
overflow_val *= 64;
1178+
1179+
return overflow_val;
1180+
}
1181+
11641182
static void __ris_msmon_read(void *arg)
11651183
{
11661184
u64 now;
@@ -1251,13 +1269,17 @@ static void __ris_msmon_read(void *arg)
12511269
now = FIELD_GET(MSMON___VALUE, now);
12521270
}
12531271

1272+
if (mpam_has_quirk(T241_MBW_COUNTER_SCALE_64, msc) &&
1273+
m->type != mpam_feat_msmon_mbwu_63counter)
1274+
now *= 64;
1275+
12541276
if (nrdy)
12551277
break;
12561278

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

12591281
if (overflow)
1260-
mbwu_state->correction += mpam_msmon_overflow_val(m->type);
1282+
mbwu_state->correction += mpam_msmon_overflow_val(m->type, msc);
12611283

12621284
/*
12631285
* Include bandwidth consumed before the last hardware reset and

drivers/resctrl/mpam_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ struct mpam_props {
225225
enum mpam_device_quirks {
226226
T241_SCRUB_SHADOW_REGS,
227227
T241_FORCE_MBW_MIN_TO_ONE,
228+
T241_MBW_COUNTER_SCALE_64,
228229
MPAM_QUIRK_LAST
229230
};
230231

0 commit comments

Comments
 (0)