Skip to content

Commit afab9d9

Browse files
Akhil P Oommenrobclark
authored andcommitted
drm/msm/adreno: Expose speedbin to userspace
Expose speedbin through MSM_PARAM_CHIP_ID parameter to help userspace identify the sku. Signed-off-by: Akhil P Oommen <quic_akhilpo@quicinc.com> Link: https://lore.kernel.org/r/20220226005021.v2.4.I86c32730e08cba9e5c83f02ec17885124d45fa56@changeid Signed-off-by: Rob Clark <robdclark@chromium.org>
1 parent c43de1a commit afab9d9

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

drivers/gpu/drm/msm/adreno/a6xx_gpu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <linux/bitfield.h>
1212
#include <linux/devfreq.h>
13-
#include <linux/nvmem-consumer.h>
1413
#include <linux/soc/qcom/llcc-qcom.h>
1514

1615
#define GPU_PAS_ID 13
@@ -1774,7 +1773,7 @@ static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev)
17741773
u32 speedbin;
17751774
int ret;
17761775

1777-
ret = nvmem_cell_read_variable_le_u32(dev, "speed_bin", &speedbin);
1776+
ret = adreno_read_speedbin(dev, &speedbin);
17781777
/*
17791778
* -ENOENT means that the platform doesn't support speedbin which is
17801779
* fine

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/pm_opp.h>
1515
#include <linux/slab.h>
1616
#include <linux/soc/qcom/mdt_loader.h>
17+
#include <linux/nvmem-consumer.h>
1718
#include <soc/qcom/ocmem.h>
1819
#include "adreno_gpu.h"
1920
#include "a6xx_gpu.h"
@@ -243,10 +244,12 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
243244
*value = !adreno_is_a650_family(adreno_gpu) ? 0x100000 : 0;
244245
return 0;
245246
case MSM_PARAM_CHIP_ID:
246-
*value = adreno_gpu->rev.patchid |
247-
(adreno_gpu->rev.minor << 8) |
248-
(adreno_gpu->rev.major << 16) |
249-
(adreno_gpu->rev.core << 24);
247+
*value = (uint64_t) adreno_gpu->rev.patchid |
248+
(uint64_t) (adreno_gpu->rev.minor << 8) |
249+
(uint64_t) (adreno_gpu->rev.major << 16) |
250+
(uint64_t) (adreno_gpu->rev.core << 24);
251+
if (!adreno_gpu->info->revn)
252+
*value |= ((uint64_t) adreno_gpu->speedbin) << 32;
250253
return 0;
251254
case MSM_PARAM_MAX_FREQ:
252255
*value = adreno_gpu->base.fast_rate;
@@ -922,6 +925,11 @@ void adreno_gpu_ocmem_cleanup(struct adreno_ocmem *adreno_ocmem)
922925
adreno_ocmem->hdl);
923926
}
924927

928+
int adreno_read_speedbin(struct device *dev, u32 *speedbin)
929+
{
930+
return nvmem_cell_read_variable_le_u32(dev, "speed_bin", speedbin);
931+
}
932+
925933
int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
926934
struct adreno_gpu *adreno_gpu,
927935
const struct adreno_gpu_funcs *funcs, int nr_rings)
@@ -932,13 +940,18 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
932940
struct msm_gpu *gpu = &adreno_gpu->base;
933941
struct adreno_rev *rev = &config->rev;
934942
const char *gpu_name;
943+
u32 speedbin;
935944

936945
adreno_gpu->funcs = funcs;
937946
adreno_gpu->info = adreno_info(config->rev);
938947
adreno_gpu->gmem = adreno_gpu->info->gmem;
939948
adreno_gpu->revn = adreno_gpu->info->revn;
940949
adreno_gpu->rev = *rev;
941950

951+
if (adreno_read_speedbin(dev, &speedbin) || !speedbin)
952+
speedbin = 0xffff;
953+
adreno_gpu->speedbin = (uint16_t) (0xffff & speedbin);
954+
942955
gpu_name = adreno_gpu->info->name;
943956
if (!gpu_name) {
944957
gpu_name = devm_kasprintf(dev, GFP_KERNEL, "%d.%d.%d.%d",

drivers/gpu/drm/msm/adreno/adreno_gpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct adreno_gpu {
8080
const struct adreno_info *info;
8181
uint32_t gmem; /* actual gmem size */
8282
uint32_t revn; /* numeric revision name */
83+
uint16_t speedbin;
8384
const struct adreno_gpu_funcs *funcs;
8485

8586
/* interesting register offsets to dump: */
@@ -325,6 +326,8 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu,
325326

326327
void adreno_set_llc_attributes(struct iommu_domain *iommu);
327328

329+
int adreno_read_speedbin(struct device *dev, u32 *speedbin);
330+
328331
/*
329332
* For a5xx and a6xx targets load the zap shader that is used to pull the GPU
330333
* out of secure mode

0 commit comments

Comments
 (0)