Skip to content

Commit fa77452

Browse files
shankerd04James Morse
authored andcommitted
arm_mpam: Add quirk framework
The MPAM specification includes the MPAMF_IIDR, which serves to uniquely identify the MSC implementation through a combination of implementer details, product ID, variant, and revision. Certain hardware issues/errata can be resolved using software workarounds. Introduce a quirk framework to allow workarounds to be enabled based on the MPAMF_IIDR value. Tested-by: Gavin Shan <gshan@redhat.com> Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Zeng Heng <zengheng4@huawei.com> Tested-by: Punit Agrawal <punit.agrawal@oss.qualcomm.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: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com> Co-developed-by: Ben Horgan <ben.horgan@arm.com> Signed-off-by: Ben Horgan <ben.horgan@arm.com> Co-developed-by: James Morse <james.morse@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
1 parent fb481ec commit fa77452

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

drivers/resctrl/mpam_devices.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,30 @@ static struct mpam_msc_ris *mpam_get_or_create_ris(struct mpam_msc *msc,
630630
return ERR_PTR(-ENOENT);
631631
}
632632

633+
static const struct mpam_quirk mpam_quirks[] = {
634+
{ NULL } /* Sentinel */
635+
};
636+
637+
static void mpam_enable_quirks(struct mpam_msc *msc)
638+
{
639+
const struct mpam_quirk *quirk;
640+
641+
for (quirk = &mpam_quirks[0]; quirk->iidr_mask; quirk++) {
642+
int err = 0;
643+
644+
if (quirk->iidr != (msc->iidr & quirk->iidr_mask))
645+
continue;
646+
647+
if (quirk->init)
648+
err = quirk->init(msc, quirk);
649+
650+
if (err)
651+
continue;
652+
653+
mpam_set_quirk(quirk->workaround, msc);
654+
}
655+
}
656+
633657
/*
634658
* IHI009A.a has this nugget: "If a monitor does not support automatic behaviour
635659
* of NRDY, software can use this bit for any purpose" - so hardware might not
@@ -864,8 +888,11 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
864888
/* Grab an IDR value to find out how many RIS there are */
865889
mutex_lock(&msc->part_sel_lock);
866890
idr = mpam_msc_read_idr(msc);
891+
msc->iidr = mpam_read_partsel_reg(msc, IIDR);
867892
mutex_unlock(&msc->part_sel_lock);
868893

894+
mpam_enable_quirks(msc);
895+
869896
msc->ris_max = FIELD_GET(MPAMF_IDR_RIS_MAX, idr);
870897

871898
/* Use these values so partid/pmg always starts with a valid value */
@@ -1972,6 +1999,7 @@ static bool mpam_has_cmax_wd_feature(struct mpam_props *props)
19721999
* resulting safe value must be compatible with both. When merging values in
19732000
* the tree, all the aliasing resources must be handled first.
19742001
* On mismatch, parent is modified.
2002+
* Quirks on an MSC will apply to all MSC in that class.
19752003
*/
19762004
static void __props_mismatch(struct mpam_props *parent,
19772005
struct mpam_props *child, bool alias)
@@ -2091,6 +2119,7 @@ static void __props_mismatch(struct mpam_props *parent,
20912119
* nobble the class feature, as we can't configure all the resources.
20922120
* e.g. The L3 cache is composed of two resources with 13 and 17 portion
20932121
* bitmaps respectively.
2122+
* Quirks on an MSC will apply to all MSC in that class.
20942123
*/
20952124
static void
20962125
__class_props_mismatch(struct mpam_class *class, struct mpam_vmsc *vmsc)
@@ -2104,6 +2133,9 @@ __class_props_mismatch(struct mpam_class *class, struct mpam_vmsc *vmsc)
21042133
dev_dbg(dev, "Merging features for class:0x%lx &= vmsc:0x%lx\n",
21052134
(long)cprops->features, (long)vprops->features);
21062135

2136+
/* Merge quirks */
2137+
class->quirks |= vmsc->msc->quirks;
2138+
21072139
/* Take the safe value for any common features */
21082140
__props_mismatch(cprops, vprops, false);
21092141
}

drivers/resctrl/mpam_internal.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct mpam_msc {
8585
u8 pmg_max;
8686
unsigned long ris_idxs;
8787
u32 ris_max;
88+
u32 iidr;
89+
u16 quirks;
8890

8991
/*
9092
* error_irq_lock is taken when registering/unregistering the error
@@ -216,6 +218,28 @@ struct mpam_props {
216218
#define mpam_set_feature(_feat, x) __set_bit(_feat, (x)->features)
217219
#define mpam_clear_feature(_feat, x) __clear_bit(_feat, (x)->features)
218220

221+
/* Workaround bits for msc->quirks */
222+
enum mpam_device_quirks {
223+
MPAM_QUIRK_LAST
224+
};
225+
226+
#define mpam_has_quirk(_quirk, x) ((1 << (_quirk) & (x)->quirks))
227+
#define mpam_set_quirk(_quirk, x) ((x)->quirks |= (1 << (_quirk)))
228+
229+
struct mpam_quirk {
230+
int (*init)(struct mpam_msc *msc, const struct mpam_quirk *quirk);
231+
232+
u32 iidr;
233+
u32 iidr_mask;
234+
235+
enum mpam_device_quirks workaround;
236+
};
237+
238+
#define MPAM_IIDR_MATCH_ONE (FIELD_PREP_CONST(MPAMF_IIDR_PRODUCTID, 0xfff) | \
239+
FIELD_PREP_CONST(MPAMF_IIDR_VARIANT, 0xf) | \
240+
FIELD_PREP_CONST(MPAMF_IIDR_REVISION, 0xf) | \
241+
FIELD_PREP_CONST(MPAMF_IIDR_IMPLEMENTER, 0xfff))
242+
219243
/* The values for MSMON_CFG_MBWU_FLT.RWBW */
220244
enum mon_filter_options {
221245
COUNT_BOTH = 0,
@@ -259,6 +283,7 @@ struct mpam_class {
259283

260284
struct mpam_props props;
261285
u32 nrdy_usec;
286+
u16 quirks;
262287
u8 level;
263288
enum mpam_class_types type;
264289

0 commit comments

Comments
 (0)