]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/panthor: Add panthor_hw and move gpu_info initialization into it
authorKarunika Choo <karunika.choo@arm.com>
Thu, 7 Aug 2025 16:26:27 +0000 (17:26 +0100)
committerSteven Price <steven.price@arm.com>
Fri, 15 Aug 2025 09:50:43 +0000 (10:50 +0100)
This patch introduces panthor_hw and moves the initialization of the
gpu_info struct into panthor_hw.c in preparation of handling future GPU
register and naming changes.

Future GPU support can be added by extending panthor_gpu_info_init()
with the necessary register reads behind GPU architecture version guards
if the change is minor. For more complex changes, the function can be
forked and the appropriate function will need to be called based on the
GPU architecture version.

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-2-karunika.choo@arm.com
drivers/gpu/drm/panthor/Makefile
drivers/gpu/drm/panthor/panthor_device.c
drivers/gpu/drm/panthor/panthor_gpu.c
drivers/gpu/drm/panthor/panthor_hw.c [new file with mode: 0644]
drivers/gpu/drm/panthor/panthor_hw.h [new file with mode: 0644]

index 15294719b09cbe8fd801cdbcf0e6a5c8515b6a6d..02db21748c125688d2ef20ed254b5ebd7ff642e4 100644 (file)
@@ -8,6 +8,7 @@ panthor-y := \
        panthor_gem.o \
        panthor_gpu.o \
        panthor_heap.o \
+       panthor_hw.o \
        panthor_mmu.o \
        panthor_sched.o
 
index f0b2da5b2b9676631b6db4952d6b599724fa5f5c..81df49880bd87ca669dafef04c60da718b6f6b8e 100644 (file)
@@ -18,6 +18,7 @@
 #include "panthor_device.h"
 #include "panthor_fw.h"
 #include "panthor_gpu.h"
+#include "panthor_hw.h"
 #include "panthor_mmu.h"
 #include "panthor_regs.h"
 #include "panthor_sched.h"
@@ -244,6 +245,10 @@ int panthor_device_init(struct panthor_device *ptdev)
                        return ret;
        }
 
+       ret = panthor_hw_init(ptdev);
+       if (ret)
+               goto err_rpm_put;
+
        ret = panthor_gpu_init(ptdev);
        if (ret)
                goto err_rpm_put;
index cb7a335e07d7c3b6457150c8a3225a9c49286677..5e2c3173ae27f13d31fb4b5c101e3585dfe8a038 100644 (file)
@@ -37,40 +37,6 @@ struct panthor_gpu {
        wait_queue_head_t reqs_acked;
 };
 
-/**
- * struct panthor_model - GPU model description
- */
-struct panthor_model {
-       /** @name: Model name. */
-       const char *name;
-
-       /** @arch_major: Major version number of architecture. */
-       u8 arch_major;
-
-       /** @product_major: Major version number of product. */
-       u8 product_major;
-};
-
-/**
- * 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,                        \
-}
-
-static const struct panthor_model gpu_models[] = {
-       GPU_MODEL(g610, 10, 7),
-       {},
-};
-
 #define GPU_INTERRUPTS_MASK    \
        (GPU_IRQ_FAULT | \
         GPU_IRQ_PROTM_FAULT | \
@@ -83,66 +49,6 @@ static void panthor_gpu_coherency_set(struct panthor_device *ptdev)
                ptdev->coherent ? GPU_COHERENCY_PROT_BIT(ACE_LITE) : GPU_COHERENCY_NONE);
 }
 
-static void panthor_gpu_init_info(struct panthor_device *ptdev)
-{
-       const struct panthor_model *model;
-       u32 arch_major, product_major;
-       u32 major, minor, status;
-       unsigned int i;
-
-       ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID);
-       ptdev->gpu_info.csf_id = gpu_read(ptdev, GPU_CSF_ID);
-       ptdev->gpu_info.gpu_rev = gpu_read(ptdev, GPU_REVID);
-       ptdev->gpu_info.core_features = gpu_read(ptdev, GPU_CORE_FEATURES);
-       ptdev->gpu_info.l2_features = gpu_read(ptdev, GPU_L2_FEATURES);
-       ptdev->gpu_info.tiler_features = gpu_read(ptdev, GPU_TILER_FEATURES);
-       ptdev->gpu_info.mem_features = gpu_read(ptdev, GPU_MEM_FEATURES);
-       ptdev->gpu_info.mmu_features = gpu_read(ptdev, GPU_MMU_FEATURES);
-       ptdev->gpu_info.thread_features = gpu_read(ptdev, GPU_THREAD_FEATURES);
-       ptdev->gpu_info.max_threads = gpu_read(ptdev, GPU_THREAD_MAX_THREADS);
-       ptdev->gpu_info.thread_max_workgroup_size = gpu_read(ptdev, GPU_THREAD_MAX_WORKGROUP_SIZE);
-       ptdev->gpu_info.thread_max_barrier_size = gpu_read(ptdev, GPU_THREAD_MAX_BARRIER_SIZE);
-       ptdev->gpu_info.coherency_features = gpu_read(ptdev, GPU_COHERENCY_FEATURES);
-       for (i = 0; i < 4; i++)
-               ptdev->gpu_info.texture_features[i] = gpu_read(ptdev, GPU_TEXTURE_FEATURES(i));
-
-       ptdev->gpu_info.as_present = gpu_read(ptdev, GPU_AS_PRESENT);
-
-       ptdev->gpu_info.shader_present = gpu_read64(ptdev, GPU_SHADER_PRESENT);
-       ptdev->gpu_info.tiler_present = gpu_read64(ptdev, GPU_TILER_PRESENT);
-       ptdev->gpu_info.l2_present = gpu_read64(ptdev, GPU_L2_PRESENT);
-
-       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,
-                major, minor, status);
-
-       drm_info(&ptdev->base,
-                "Features: L2:%#x Tiler:%#x Mem:%#x MMU:%#x AS:%#x",
-                ptdev->gpu_info.l2_features,
-                ptdev->gpu_info.tiler_features,
-                ptdev->gpu_info.mem_features,
-                ptdev->gpu_info.mmu_features,
-                ptdev->gpu_info.as_present);
-
-       drm_info(&ptdev->base,
-                "shader_present=0x%0llx l2_present=0x%0llx tiler_present=0x%0llx",
-                ptdev->gpu_info.shader_present, ptdev->gpu_info.l2_present,
-                ptdev->gpu_info.tiler_present);
-}
-
 static void panthor_gpu_irq_handler(struct panthor_device *ptdev, u32 status)
 {
        gpu_write(ptdev, GPU_INT_CLEAR, status);
@@ -205,7 +111,6 @@ int panthor_gpu_init(struct panthor_device *ptdev)
        spin_lock_init(&gpu->reqs_lock);
        init_waitqueue_head(&gpu->reqs_acked);
        ptdev->gpu = gpu;
-       panthor_gpu_init_info(ptdev);
 
        dma_set_max_seg_size(ptdev->base.dev, UINT_MAX);
        pa_bits = GPU_MMU_FEATURES_PA_BITS(ptdev->gpu_info.mmu_features);
diff --git a/drivers/gpu/drm/panthor/panthor_hw.c b/drivers/gpu/drm/panthor/panthor_hw.c
new file mode 100644 (file)
index 0000000..94f170a
--- /dev/null
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/* Copyright 2025 ARM Limited. All rights reserved. */
+
+#include "panthor_device.h"
+#include "panthor_hw.h"
+#include "panthor_regs.h"
+
+/**
+ * struct panthor_model - GPU model description
+ */
+struct panthor_model {
+       /** @name: Model name. */
+       const char *name;
+
+       /** @arch_major: Major version number of architecture. */
+       u8 arch_major;
+
+       /** @product_major: Major version number of product. */
+       u8 product_major;
+};
+
+/**
+ * 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,                        \
+}
+
+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;
+
+       ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID);
+       ptdev->gpu_info.csf_id = gpu_read(ptdev, GPU_CSF_ID);
+       ptdev->gpu_info.gpu_rev = gpu_read(ptdev, GPU_REVID);
+       ptdev->gpu_info.core_features = gpu_read(ptdev, GPU_CORE_FEATURES);
+       ptdev->gpu_info.l2_features = gpu_read(ptdev, GPU_L2_FEATURES);
+       ptdev->gpu_info.tiler_features = gpu_read(ptdev, GPU_TILER_FEATURES);
+       ptdev->gpu_info.mem_features = gpu_read(ptdev, GPU_MEM_FEATURES);
+       ptdev->gpu_info.mmu_features = gpu_read(ptdev, GPU_MMU_FEATURES);
+       ptdev->gpu_info.thread_features = gpu_read(ptdev, GPU_THREAD_FEATURES);
+       ptdev->gpu_info.max_threads = gpu_read(ptdev, GPU_THREAD_MAX_THREADS);
+       ptdev->gpu_info.thread_max_workgroup_size = gpu_read(ptdev, GPU_THREAD_MAX_WORKGROUP_SIZE);
+       ptdev->gpu_info.thread_max_barrier_size = gpu_read(ptdev, GPU_THREAD_MAX_BARRIER_SIZE);
+       ptdev->gpu_info.coherency_features = gpu_read(ptdev, GPU_COHERENCY_FEATURES);
+       for (i = 0; i < 4; i++)
+               ptdev->gpu_info.texture_features[i] = gpu_read(ptdev, GPU_TEXTURE_FEATURES(i));
+
+       ptdev->gpu_info.as_present = gpu_read(ptdev, GPU_AS_PRESENT);
+
+       ptdev->gpu_info.shader_present = gpu_read64(ptdev, GPU_SHADER_PRESENT);
+       ptdev->gpu_info.tiler_present = gpu_read64(ptdev, GPU_TILER_PRESENT);
+       ptdev->gpu_info.l2_present = gpu_read64(ptdev, GPU_L2_PRESENT);
+}
+
+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,
+                major, minor, status);
+
+       drm_info(&ptdev->base,
+                "Features: L2:%#x Tiler:%#x Mem:%#x MMU:%#x AS:%#x",
+                ptdev->gpu_info.l2_features,
+                ptdev->gpu_info.tiler_features,
+                ptdev->gpu_info.mem_features,
+                ptdev->gpu_info.mmu_features,
+                ptdev->gpu_info.as_present);
+
+       drm_info(&ptdev->base,
+                "shader_present=0x%0llx l2_present=0x%0llx tiler_present=0x%0llx",
+                ptdev->gpu_info.shader_present, ptdev->gpu_info.l2_present,
+                ptdev->gpu_info.tiler_present);
+}
+
+int panthor_hw_init(struct panthor_device *ptdev)
+{
+       panthor_hw_info_init(ptdev);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/panthor/panthor_hw.h b/drivers/gpu/drm/panthor/panthor_hw.h
new file mode 100644 (file)
index 0000000..0af6acc
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+/* Copyright 2025 ARM Limited. All rights reserved. */
+
+#ifndef __PANTHOR_HW_H__
+#define __PANTHOR_HW_H__
+
+struct panthor_device;
+
+int panthor_hw_init(struct panthor_device *ptdev);
+
+#endif /* __PANTHOR_HW_H__ */