Skip to content

Commit 82dfd72

Browse files
bwicaksononvwilldeacon
authored andcommitted
perf/arm_cspmu: nvidia: Add revision id matching
Distinguish NVIDIA devices by revision and variant bits in PMIIDR register in addition to product id. Reviewed-by: Ilkka Koskinen <ilkka@os.amperecomputing.com> Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 04330be commit 82dfd72

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

drivers/perf/arm_cspmu/nvidia_cspmu.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define NV_GENERIC_FILTER_ID_MASK GENMASK_ULL(31, 0)
2525

26-
#define NV_PRODID_MASK GENMASK(31, 0)
26+
#define NV_PRODID_MASK (PMIIDR_PRODUCTID | PMIIDR_VARIANT | PMIIDR_REVISION)
2727

2828
#define NV_FORMAT_NAME_GENERIC 0
2929

@@ -220,7 +220,7 @@ struct nv_cspmu_match {
220220

221221
static const struct nv_cspmu_match nv_cspmu_match[] = {
222222
{
223-
.prodid = 0x103,
223+
.prodid = 0x10300000,
224224
.prodid_mask = NV_PRODID_MASK,
225225
.filter_mask = NV_PCIE_FILTER_ID_MASK,
226226
.filter_default_val = NV_PCIE_FILTER_ID_MASK,
@@ -230,7 +230,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
230230
.format_attr = pcie_pmu_format_attrs
231231
},
232232
{
233-
.prodid = 0x104,
233+
.prodid = 0x10400000,
234234
.prodid_mask = NV_PRODID_MASK,
235235
.filter_mask = NV_NVL_C2C_FILTER_ID_MASK,
236236
.filter_default_val = NV_NVL_C2C_FILTER_ID_MASK,
@@ -240,7 +240,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
240240
.format_attr = nvlink_c2c_pmu_format_attrs
241241
},
242242
{
243-
.prodid = 0x105,
243+
.prodid = 0x10500000,
244244
.prodid_mask = NV_PRODID_MASK,
245245
.filter_mask = NV_NVL_C2C_FILTER_ID_MASK,
246246
.filter_default_val = NV_NVL_C2C_FILTER_ID_MASK,
@@ -250,7 +250,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
250250
.format_attr = nvlink_c2c_pmu_format_attrs
251251
},
252252
{
253-
.prodid = 0x106,
253+
.prodid = 0x10600000,
254254
.prodid_mask = NV_PRODID_MASK,
255255
.filter_mask = NV_CNVL_FILTER_ID_MASK,
256256
.filter_default_val = NV_CNVL_FILTER_ID_MASK,
@@ -260,7 +260,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
260260
.format_attr = cnvlink_pmu_format_attrs
261261
},
262262
{
263-
.prodid = 0x2CF,
263+
.prodid = 0x2CF00000,
264264
.prodid_mask = NV_PRODID_MASK,
265265
.filter_mask = 0x0,
266266
.filter_default_val = 0x0,
@@ -312,7 +312,6 @@ static char *nv_cspmu_format_name(const struct arm_cspmu *cspmu,
312312

313313
static int nv_cspmu_init_ops(struct arm_cspmu *cspmu)
314314
{
315-
u32 prodid;
316315
struct nv_cspmu_ctx *ctx;
317316
struct device *dev = cspmu->dev;
318317
struct arm_cspmu_impl_ops *impl_ops = &cspmu->impl.ops;
@@ -322,13 +321,12 @@ static int nv_cspmu_init_ops(struct arm_cspmu *cspmu)
322321
if (!ctx)
323322
return -ENOMEM;
324323

325-
prodid = FIELD_GET(PMIIDR_PRODUCTID, cspmu->impl.pmiidr);
326-
327324
/* Find matching PMU. */
328325
for (; match->prodid; match++) {
329326
const u32 prodid_mask = match->prodid_mask;
330327

331-
if ((match->prodid & prodid_mask) == (prodid & prodid_mask))
328+
if ((match->prodid & prodid_mask) ==
329+
(cspmu->impl.pmiidr & prodid_mask))
332330
break;
333331
}
334332

0 commit comments

Comments
 (0)