Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panthor: Add arch-specific panthor_hw binding

This patch adds the framework for binding to a specific panthor_hw
structure based on the architecture major value parsed from the GPU_ID
register. This is in preparation of enabling architecture-specific
behaviours based on GPU_ID. As such, it also splits the GPU_ID register
read operation into its own helper function.

This framework allows a single panthor_hw structure to be shared across
multiple architectures should there be minimal changes between them via
the arch_min and arch_max field of the panthor_hw_entry structure,
instead of duplicating the structure across multiple architectures.

Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Karunika Choo <karunika.choo@arm.com>
Link: https://patch.msgid.link/20251125125548.3282320-2-karunika.choo@arm.com
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

authored by

Karunika Choo and committed by
Boris Brezillon
b1075ae1 ce04ec03

+74 -1
+4
drivers/gpu/drm/panthor/panthor_device.h
··· 24 24 struct panthor_gpu; 25 25 struct panthor_group_pool; 26 26 struct panthor_heap_pool; 27 + struct panthor_hw; 27 28 struct panthor_job; 28 29 struct panthor_mmu; 29 30 struct panthor_fw; ··· 134 133 135 134 /** @csif_info: Command stream interface information. */ 136 135 struct drm_panthor_csif_info csif_info; 136 + 137 + /** @hw: GPU-specific data. */ 138 + struct panthor_hw *hw; 137 139 138 140 /** @gpu: GPU management data. */ 139 141 struct panthor_gpu *gpu;
+64 -1
drivers/gpu/drm/panthor/panthor_hw.c
··· 10 10 #define GPU_PROD_ID_MAKE(arch_major, prod_major) \ 11 11 (((arch_major) << 24) | (prod_major)) 12 12 13 + /** struct panthor_hw_entry - HW arch major to panthor_hw binding entry */ 14 + struct panthor_hw_entry { 15 + /** @arch_min: Minimum supported architecture major value (inclusive) */ 16 + u8 arch_min; 17 + 18 + /** @arch_max: Maximum supported architecture major value (inclusive) */ 19 + u8 arch_max; 20 + 21 + /** @hwdev: Pointer to panthor_hw structure */ 22 + struct panthor_hw *hwdev; 23 + }; 24 + 25 + static struct panthor_hw panthor_hw_arch_v10 = {}; 26 + 27 + static struct panthor_hw_entry panthor_hw_match[] = { 28 + { 29 + .arch_min = 10, 30 + .arch_max = 13, 31 + .hwdev = &panthor_hw_arch_v10, 32 + }, 33 + }; 34 + 13 35 static char *get_gpu_model_name(struct panthor_device *ptdev) 14 36 { 15 37 const u32 gpu_id = ptdev->gpu_info.gpu_id; ··· 86 64 { 87 65 unsigned int i; 88 66 89 - ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID); 90 67 ptdev->gpu_info.csf_id = gpu_read(ptdev, GPU_CSF_ID); 91 68 ptdev->gpu_info.gpu_rev = gpu_read(ptdev, GPU_REVID); 92 69 ptdev->gpu_info.core_features = gpu_read(ptdev, GPU_CORE_FEATURES); ··· 140 119 ptdev->gpu_info.tiler_present); 141 120 } 142 121 122 + static int panthor_hw_bind_device(struct panthor_device *ptdev) 123 + { 124 + struct panthor_hw *hdev = NULL; 125 + const u32 arch_major = GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id); 126 + int i = 0; 127 + 128 + for (i = 0; i < ARRAY_SIZE(panthor_hw_match); i++) { 129 + struct panthor_hw_entry *entry = &panthor_hw_match[i]; 130 + 131 + if (arch_major >= entry->arch_min && arch_major <= entry->arch_max) { 132 + hdev = entry->hwdev; 133 + break; 134 + } 135 + } 136 + 137 + if (!hdev) 138 + return -EOPNOTSUPP; 139 + 140 + ptdev->hw = hdev; 141 + 142 + return 0; 143 + } 144 + 145 + static int panthor_hw_gpu_id_init(struct panthor_device *ptdev) 146 + { 147 + ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID); 148 + if (!ptdev->gpu_info.gpu_id) 149 + return -ENXIO; 150 + 151 + return 0; 152 + } 153 + 143 154 int panthor_hw_init(struct panthor_device *ptdev) 144 155 { 156 + int ret = 0; 157 + 158 + ret = panthor_hw_gpu_id_init(ptdev); 159 + if (ret) 160 + return ret; 161 + 162 + ret = panthor_hw_bind_device(ptdev); 163 + if (ret) 164 + return ret; 165 + 145 166 panthor_hw_info_init(ptdev); 146 167 147 168 return 0;
+6
drivers/gpu/drm/panthor/panthor_hw.h
··· 6 6 7 7 struct panthor_device; 8 8 9 + /** 10 + * struct panthor_hw - GPU specific register mapping and functions 11 + */ 12 + struct panthor_hw { 13 + }; 14 + 9 15 int panthor_hw_init(struct panthor_device *ptdev); 10 16 11 17 #endif /* __PANTHOR_HW_H__ */