Skip to content

Commit c012663

Browse files
Karunika Choostevenprice-arm
authored andcommitted
drm/panthor: Simplify getting the GPU model name
This patch replaces the panthor_model structure with a simple switch case based on the product_id which is in the format of: ((arch_major << 24) | product_major) This simplifies comparison and allows extending of the function to accommodate naming differences based on supported GPU features. Reviewed-by: Steven Price <steven.price@arm.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Signed-off-by: Karunika Choo <karunika.choo@arm.com> Signed-off-by: Steven Price <steven.price@arm.com> Link: https://lore.kernel.org/r/20250807162633.3666310-3-karunika.choo@arm.com
1 parent 9433252 commit c012663

1 file changed

Lines changed: 17 additions & 44 deletions

File tree

drivers/gpu/drm/panthor/panthor_hw.c

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,22 @@
55
#include "panthor_hw.h"
66
#include "panthor_regs.h"
77

8-
/**
9-
* struct panthor_model - GPU model description
10-
*/
11-
struct panthor_model {
12-
/** @name: Model name. */
13-
const char *name;
14-
15-
/** @arch_major: Major version number of architecture. */
16-
u8 arch_major;
17-
18-
/** @product_major: Major version number of product. */
19-
u8 product_major;
20-
};
21-
22-
/**
23-
* GPU_MODEL() - Define a GPU model. A GPU product can be uniquely identified
24-
* by a combination of the major architecture version and the major product
25-
* version.
26-
* @_name: Name for the GPU model.
27-
* @_arch_major: Architecture major.
28-
* @_product_major: Product major.
29-
*/
30-
#define GPU_MODEL(_name, _arch_major, _product_major) \
31-
{\
32-
.name = __stringify(_name), \
33-
.arch_major = _arch_major, \
34-
.product_major = _product_major, \
35-
}
8+
#define GPU_PROD_ID_MAKE(arch_major, prod_major) \
9+
(((arch_major) << 24) | (prod_major))
10+
11+
static char *get_gpu_model_name(struct panthor_device *ptdev)
12+
{
13+
const u32 gpu_id = ptdev->gpu_info.gpu_id;
14+
const u32 product_id = GPU_PROD_ID_MAKE(GPU_ARCH_MAJOR(gpu_id),
15+
GPU_PROD_MAJOR(gpu_id));
16+
17+
switch (product_id) {
18+
case GPU_PROD_ID_MAKE(10, 7):
19+
return "Mali-G610";
20+
}
3621

37-
static const struct panthor_model gpu_models[] = {
38-
GPU_MODEL(g610, 10, 7),
39-
{},
40-
};
22+
return "(Unknown Mali GPU)";
23+
}
4124

4225
static void panthor_gpu_info_init(struct panthor_device *ptdev)
4326
{
@@ -68,27 +51,17 @@ static void panthor_gpu_info_init(struct panthor_device *ptdev)
6851

6952
static void panthor_hw_info_init(struct panthor_device *ptdev)
7053
{
71-
const struct panthor_model *model;
72-
u32 arch_major, product_major;
7354
u32 major, minor, status;
7455

7556
panthor_gpu_info_init(ptdev);
7657

77-
arch_major = GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id);
78-
product_major = GPU_PROD_MAJOR(ptdev->gpu_info.gpu_id);
7958
major = GPU_VER_MAJOR(ptdev->gpu_info.gpu_id);
8059
minor = GPU_VER_MINOR(ptdev->gpu_info.gpu_id);
8160
status = GPU_VER_STATUS(ptdev->gpu_info.gpu_id);
8261

83-
for (model = gpu_models; model->name; model++) {
84-
if (model->arch_major == arch_major &&
85-
model->product_major == product_major)
86-
break;
87-
}
88-
8962
drm_info(&ptdev->base,
90-
"mali-%s id 0x%x major 0x%x minor 0x%x status 0x%x",
91-
model->name ?: "unknown", ptdev->gpu_info.gpu_id >> 16,
63+
"%s id 0x%x major 0x%x minor 0x%x status 0x%x",
64+
get_gpu_model_name(ptdev), ptdev->gpu_info.gpu_id >> 16,
9265
major, minor, status);
9366

9467
drm_info(&ptdev->base,

0 commit comments

Comments
 (0)