Skip to content

Commit c40b50c

Browse files
Nicolas Frattarolibbrezillon
authored andcommitted
drm/panthor: Implement reading shader_present from nvmem
On some platforms, notably MediaTek MT8196, the shader_present bitmask in the Mali GPU register for it has cores enabled that may be faulty. The true shader_present bitmask is found in an efuse instead. Implement reading shader_present from an nvmem cell if one is present, falling back to the Mali register if it's absent. The error codes are trickled up through to the probe function so that probe deferral works. Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Reviewed-by: Steven Price <steven.price@arm.com> Link: https://patch.msgid.link/20251220-mt8196-shader-present-v2-3-45b1ff1dfab0@collabora.com Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
1 parent 2568b8b commit c40b50c

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

drivers/gpu/drm/panthor/panthor_hw.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0 or MIT
22
/* Copyright 2025 ARM Limited. All rights reserved. */
33

4+
#include <linux/nvmem-consumer.h>
45
#include <drm/drm_print.h>
56

67
#include "panthor_device.h"
@@ -109,7 +110,25 @@ static char *get_gpu_model_name(struct panthor_device *ptdev)
109110
return "(Unknown Mali GPU)";
110111
}
111112

112-
static void panthor_gpu_info_init(struct panthor_device *ptdev)
113+
static int overload_shader_present(struct panthor_device *ptdev)
114+
{
115+
u64 contents;
116+
int ret;
117+
118+
ret = nvmem_cell_read_variable_le_u64(ptdev->base.dev, "shader-present",
119+
&contents);
120+
if (!ret)
121+
ptdev->gpu_info.shader_present = contents;
122+
else if (ret == -ENOENT)
123+
return 0;
124+
else
125+
return dev_err_probe(ptdev->base.dev, ret,
126+
"Failed to read shader-present nvmem cell\n");
127+
128+
return 0;
129+
}
130+
131+
static int panthor_gpu_info_init(struct panthor_device *ptdev)
113132
{
114133
unsigned int i;
115134

@@ -143,13 +162,18 @@ static void panthor_gpu_info_init(struct panthor_device *ptdev)
143162
ptdev->gpu_info.tiler_present = gpu_read64(ptdev, GPU_TILER_PRESENT);
144163
ptdev->gpu_info.l2_present = gpu_read64(ptdev, GPU_L2_PRESENT);
145164
}
165+
166+
return overload_shader_present(ptdev);
146167
}
147168

148-
static void panthor_hw_info_init(struct panthor_device *ptdev)
169+
static int panthor_hw_info_init(struct panthor_device *ptdev)
149170
{
150171
u32 major, minor, status;
172+
int ret;
151173

152-
panthor_gpu_info_init(ptdev);
174+
ret = panthor_gpu_info_init(ptdev);
175+
if (ret)
176+
return ret;
153177

154178
major = GPU_VER_MAJOR(ptdev->gpu_info.gpu_id);
155179
minor = GPU_VER_MINOR(ptdev->gpu_info.gpu_id);
@@ -172,6 +196,8 @@ static void panthor_hw_info_init(struct panthor_device *ptdev)
172196
"shader_present=0x%0llx l2_present=0x%0llx tiler_present=0x%0llx",
173197
ptdev->gpu_info.shader_present, ptdev->gpu_info.l2_present,
174198
ptdev->gpu_info.tiler_present);
199+
200+
return 0;
175201
}
176202

177203
static int panthor_hw_bind_device(struct panthor_device *ptdev)
@@ -218,7 +244,5 @@ int panthor_hw_init(struct panthor_device *ptdev)
218244
if (ret)
219245
return ret;
220246

221-
panthor_hw_info_init(ptdev);
222-
223-
return 0;
247+
return panthor_hw_info_init(ptdev);
224248
}

0 commit comments

Comments
 (0)