mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-16 09:07:58 -05:00
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
This commit is contained in:
committed by
Steven Price
parent
94332524b5
commit
c012663b17
@@ -5,40 +5,23 @@
|
||||
#include "panthor_hw.h"
|
||||
#include "panthor_regs.h"
|
||||
|
||||
/**
|
||||
* struct panthor_model - GPU model description
|
||||
*/
|
||||
struct panthor_model {
|
||||
/** @name: Model name. */
|
||||
const char *name;
|
||||
#define GPU_PROD_ID_MAKE(arch_major, prod_major) \
|
||||
(((arch_major) << 24) | (prod_major))
|
||||
|
||||
/** @arch_major: Major version number of architecture. */
|
||||
u8 arch_major;
|
||||
static char *get_gpu_model_name(struct panthor_device *ptdev)
|
||||
{
|
||||
const u32 gpu_id = ptdev->gpu_info.gpu_id;
|
||||
const u32 product_id = GPU_PROD_ID_MAKE(GPU_ARCH_MAJOR(gpu_id),
|
||||
GPU_PROD_MAJOR(gpu_id));
|
||||
|
||||
/** @product_major: Major version number of product. */
|
||||
u8 product_major;
|
||||
};
|
||||
switch (product_id) {
|
||||
case GPU_PROD_ID_MAKE(10, 7):
|
||||
return "Mali-G610";
|
||||
}
|
||||
|
||||
/**
|
||||
* GPU_MODEL() - Define a GPU model. A GPU product can be uniquely identified
|
||||
* by a combination of the major architecture version and the major product
|
||||
* version.
|
||||
* @_name: Name for the GPU model.
|
||||
* @_arch_major: Architecture major.
|
||||
* @_product_major: Product major.
|
||||
*/
|
||||
#define GPU_MODEL(_name, _arch_major, _product_major) \
|
||||
{\
|
||||
.name = __stringify(_name), \
|
||||
.arch_major = _arch_major, \
|
||||
.product_major = _product_major, \
|
||||
return "(Unknown Mali GPU)";
|
||||
}
|
||||
|
||||
static const struct panthor_model gpu_models[] = {
|
||||
GPU_MODEL(g610, 10, 7),
|
||||
{},
|
||||
};
|
||||
|
||||
static void panthor_gpu_info_init(struct panthor_device *ptdev)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -68,27 +51,17 @@ static void panthor_gpu_info_init(struct panthor_device *ptdev)
|
||||
|
||||
static void panthor_hw_info_init(struct panthor_device *ptdev)
|
||||
{
|
||||
const struct panthor_model *model;
|
||||
u32 arch_major, product_major;
|
||||
u32 major, minor, status;
|
||||
|
||||
panthor_gpu_info_init(ptdev);
|
||||
|
||||
arch_major = GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id);
|
||||
product_major = GPU_PROD_MAJOR(ptdev->gpu_info.gpu_id);
|
||||
major = GPU_VER_MAJOR(ptdev->gpu_info.gpu_id);
|
||||
minor = GPU_VER_MINOR(ptdev->gpu_info.gpu_id);
|
||||
status = GPU_VER_STATUS(ptdev->gpu_info.gpu_id);
|
||||
|
||||
for (model = gpu_models; model->name; model++) {
|
||||
if (model->arch_major == arch_major &&
|
||||
model->product_major == product_major)
|
||||
break;
|
||||
}
|
||||
|
||||
drm_info(&ptdev->base,
|
||||
"mali-%s id 0x%x major 0x%x minor 0x%x status 0x%x",
|
||||
model->name ?: "unknown", ptdev->gpu_info.gpu_id >> 16,
|
||||
"%s id 0x%x major 0x%x minor 0x%x status 0x%x",
|
||||
get_gpu_model_name(ptdev), ptdev->gpu_info.gpu_id >> 16,
|
||||
major, minor, status);
|
||||
|
||||
drm_info(&ptdev->base,
|
||||
|
||||
Reference in New Issue
Block a user