drm/msm/a6xx: Use rev to identify SKU
authorAkhil P Oommen <akhilpo@codeaurora.org>
Thu, 29 Jul 2021 19:51:24 +0000 (01:21 +0530)
committerRob Clark <robdclark@chromium.org>
Sat, 31 Jul 2021 15:35:23 +0000 (08:35 -0700)
Use rev instead of revn to identify the SKU. This is in
preparation to the introduction of 7c3 gpu which won't have a
revn.

Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Link: https://lore.kernel.org/r/20210730011945.v4.2.I286ef007fcadd9e6ee3b2c0ad948f990735f9610@changeid
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/adreno/adreno_device.c
drivers/gpu/drm/msm/adreno/adreno_gpu.h

index 2d03f807e256d893b9452b8a1f2674f6ea73479c..a16d2cdfad88879706db516035a78ddc69fd3aa3 100644 (file)
@@ -1675,11 +1675,11 @@ static u32 a618_get_speed_bin(u32 fuse)
        return UINT_MAX;
 }
 
-static u32 fuse_to_supp_hw(struct device *dev, u32 revn, u32 fuse)
+static u32 fuse_to_supp_hw(struct device *dev, struct adreno_rev rev, u32 fuse)
 {
        u32 val = UINT_MAX;
 
-       if (revn == 618)
+       if (adreno_cmp_rev(ADRENO_REV(6, 1, 8, ANY_ID), rev))
                val = a618_get_speed_bin(fuse);
 
        if (val == UINT_MAX) {
@@ -1692,8 +1692,7 @@ static u32 fuse_to_supp_hw(struct device *dev, u32 revn, u32 fuse)
        return (1 << val);
 }
 
-static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
-               u32 revn)
+static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev)
 {
        u32 supp_hw = UINT_MAX;
        u16 speedbin;
@@ -1714,7 +1713,7 @@ static int a6xx_set_supported_hw(struct device *dev, struct a6xx_gpu *a6xx_gpu,
        }
        speedbin = le16_to_cpu(speedbin);
 
-       supp_hw = fuse_to_supp_hw(dev, revn, speedbin);
+       supp_hw = fuse_to_supp_hw(dev, rev, speedbin);
 
 done:
        ret = devm_pm_opp_set_supported_hw(dev, &supp_hw, 1);
@@ -1785,7 +1784,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
 
        a6xx_llc_slices_init(pdev, a6xx_gpu);
 
-       ret = a6xx_set_supported_hw(&pdev->dev, a6xx_gpu, info->revn);
+       ret = a6xx_set_supported_hw(&pdev->dev, config->rev);
        if (ret) {
                a6xx_destroy(&(a6xx_gpu->base.base));
                return ERR_PTR(ret);
index 6dad8015c9a16fac3dc61adc03d69e719c53aeb9..7e6fafe3e99c237d531dbf9cfa66890b58fa0249 100644 (file)
@@ -8,8 +8,6 @@
 
 #include "adreno_gpu.h"
 
-#define ANY_ID 0xff
-
 bool hang_debug = false;
 MODULE_PARM_DESC(hang_debug, "Dump registers when hang is detected (can be slow!)");
 module_param_named(hang_debug, hang_debug, bool, 0600);
@@ -325,6 +323,15 @@ static inline bool _rev_match(uint8_t entry, uint8_t id)
        return (entry == ANY_ID) || (entry == id);
 }
 
+bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2)
+{
+
+       return _rev_match(rev1.core, rev2.core) &&
+               _rev_match(rev1.major, rev2.major) &&
+               _rev_match(rev1.minor, rev2.minor) &&
+               _rev_match(rev1.patchid, rev2.patchid);
+}
+
 const struct adreno_info *adreno_info(struct adreno_rev rev)
 {
        int i;
@@ -332,10 +339,7 @@ const struct adreno_info *adreno_info(struct adreno_rev rev)
        /* identify gpu: */
        for (i = 0; i < ARRAY_SIZE(gpulist); i++) {
                const struct adreno_info *info = &gpulist[i];
-               if (_rev_match(info->rev.core, rev.core) &&
-                               _rev_match(info->rev.major, rev.major) &&
-                               _rev_match(info->rev.minor, rev.minor) &&
-                               _rev_match(info->rev.patchid, rev.patchid))
+               if (adreno_cmp_rev(info->rev, rev))
                        return info;
        }
 
index 8dbe0d1575209e65732c05a445731a6641946eb0..a368a166e5a123a89b387b6bddd4bc51d78dc788 100644 (file)
@@ -42,6 +42,8 @@ struct adreno_rev {
        uint8_t  patchid;
 };
 
+#define ANY_ID 0xff
+
 #define ADRENO_REV(core, major, minor, patchid) \
        ((struct adreno_rev){ core, major, minor, patchid })
 
@@ -141,6 +143,8 @@ struct adreno_platform_config {
        __ret;                                             \
 })
 
+bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2);
+
 static inline bool adreno_is_a2xx(struct adreno_gpu *gpu)
 {
        return (gpu->revn < 300);