]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf/arm_cspmu: nvidia: Add revision id matching
authorBesar Wicaksono <bwicaksono@nvidia.com>
Tue, 30 Sep 2025 00:26:03 +0000 (00:26 +0000)
committerWill Deacon <will@kernel.org>
Mon, 3 Nov 2025 13:35:07 +0000 (13:35 +0000)
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>
drivers/perf/arm_cspmu/nvidia_cspmu.c

index b6cec351a1422856c829bcfa54d168f09ab271f6..ac91dc46501d17617e10f8cf6c98d5d284519e44 100644 (file)
@@ -23,7 +23,7 @@
 
 #define NV_GENERIC_FILTER_ID_MASK    GENMASK_ULL(31, 0)
 
-#define NV_PRODID_MASK               GENMASK(31, 0)
+#define NV_PRODID_MASK (PMIIDR_PRODUCTID | PMIIDR_VARIANT | PMIIDR_REVISION)
 
 #define NV_FORMAT_NAME_GENERIC 0
 
@@ -220,7 +220,7 @@ struct nv_cspmu_match {
 
 static const struct nv_cspmu_match nv_cspmu_match[] = {
        {
-         .prodid = 0x103,
+         .prodid = 0x10300000,
          .prodid_mask = NV_PRODID_MASK,
          .filter_mask = NV_PCIE_FILTER_ID_MASK,
          .filter_default_val = NV_PCIE_FILTER_ID_MASK,
@@ -230,7 +230,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
          .format_attr = pcie_pmu_format_attrs
        },
        {
-         .prodid = 0x104,
+         .prodid = 0x10400000,
          .prodid_mask = NV_PRODID_MASK,
          .filter_mask = NV_NVL_C2C_FILTER_ID_MASK,
          .filter_default_val = NV_NVL_C2C_FILTER_ID_MASK,
@@ -240,7 +240,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
          .format_attr = nvlink_c2c_pmu_format_attrs
        },
        {
-         .prodid = 0x105,
+         .prodid = 0x10500000,
          .prodid_mask = NV_PRODID_MASK,
          .filter_mask = NV_NVL_C2C_FILTER_ID_MASK,
          .filter_default_val = NV_NVL_C2C_FILTER_ID_MASK,
@@ -250,7 +250,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
          .format_attr = nvlink_c2c_pmu_format_attrs
        },
        {
-         .prodid = 0x106,
+         .prodid = 0x10600000,
          .prodid_mask = NV_PRODID_MASK,
          .filter_mask = NV_CNVL_FILTER_ID_MASK,
          .filter_default_val = NV_CNVL_FILTER_ID_MASK,
@@ -260,7 +260,7 @@ static const struct nv_cspmu_match nv_cspmu_match[] = {
          .format_attr = cnvlink_pmu_format_attrs
        },
        {
-         .prodid = 0x2CF,
+         .prodid = 0x2CF00000,
          .prodid_mask = NV_PRODID_MASK,
          .filter_mask = 0x0,
          .filter_default_val = 0x0,
@@ -312,7 +312,6 @@ static char *nv_cspmu_format_name(const struct arm_cspmu *cspmu,
 
 static int nv_cspmu_init_ops(struct arm_cspmu *cspmu)
 {
-       u32 prodid;
        struct nv_cspmu_ctx *ctx;
        struct device *dev = cspmu->dev;
        struct arm_cspmu_impl_ops *impl_ops = &cspmu->impl.ops;
@@ -322,13 +321,12 @@ static int nv_cspmu_init_ops(struct arm_cspmu *cspmu)
        if (!ctx)
                return -ENOMEM;
 
-       prodid = FIELD_GET(PMIIDR_PRODUCTID, cspmu->impl.pmiidr);
-
        /* Find matching PMU. */
        for (; match->prodid; match++) {
                const u32 prodid_mask = match->prodid_mask;
 
-               if ((match->prodid & prodid_mask) == (prodid & prodid_mask))
+               if ((match->prodid & prodid_mask) ==
+                   (cspmu->impl.pmiidr & prodid_mask))
                        break;
        }