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

drm/panthor: Add architecture-specific function operations

Introduce architecture-specific function pointers to support
architecture-dependent behaviours. This patch adds the following
function pointers and updates their usage accordingly:

- soft_reset
- l2_power_on
- l2_power_off

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

authored by

Karunika Choo and committed by
Boris Brezillon
7d334f5c b1075ae1

+57 -9
+2 -2
drivers/gpu/drm/panthor/panthor_device.c
··· 152 152 panthor_sched_pre_reset(ptdev); 153 153 panthor_fw_pre_reset(ptdev, true); 154 154 panthor_mmu_pre_reset(ptdev); 155 - panthor_gpu_soft_reset(ptdev); 156 - panthor_gpu_l2_power_on(ptdev); 155 + panthor_hw_soft_reset(ptdev); 156 + panthor_hw_l2_power_on(ptdev); 157 157 panthor_mmu_post_reset(ptdev); 158 158 ret = panthor_fw_post_reset(ptdev); 159 159 atomic_set(&ptdev->reset.pending, 0);
+3 -2
drivers/gpu/drm/panthor/panthor_fw.c
··· 22 22 #include "panthor_fw.h" 23 23 #include "panthor_gem.h" 24 24 #include "panthor_gpu.h" 25 + #include "panthor_hw.h" 25 26 #include "panthor_mmu.h" 26 27 #include "panthor_regs.h" 27 28 #include "panthor_sched.h" ··· 1187 1186 ptdev->fw->vm = NULL; 1188 1187 1189 1188 if (!IS_ENABLED(CONFIG_PM) || pm_runtime_active(ptdev->base.dev)) 1190 - panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000); 1189 + panthor_hw_l2_power_off(ptdev); 1191 1190 } 1192 1191 1193 1192 /** ··· 1366 1365 return ret; 1367 1366 } 1368 1367 1369 - ret = panthor_gpu_l2_power_on(ptdev); 1368 + ret = panthor_hw_l2_power_on(ptdev); 1370 1369 if (ret) 1371 1370 return ret; 1372 1371
+9 -3
drivers/gpu/drm/panthor/panthor_gpu.c
··· 19 19 20 20 #include "panthor_device.h" 21 21 #include "panthor_gpu.h" 22 + #include "panthor_hw.h" 22 23 #include "panthor_regs.h" 23 24 24 25 /** ··· 242 241 return 0; 243 242 } 244 243 244 + void panthor_gpu_l2_power_off(struct panthor_device *ptdev) 245 + { 246 + panthor_gpu_power_off(ptdev, L2, ptdev->gpu_info.l2_present, 20000); 247 + } 248 + 245 249 /** 246 250 * panthor_gpu_l2_power_on() - Power-on the L2-cache 247 251 * @ptdev: Device. ··· 374 368 { 375 369 /* On a fast reset, simply power down the L2. */ 376 370 if (!ptdev->reset.fast) 377 - panthor_gpu_soft_reset(ptdev); 371 + panthor_hw_soft_reset(ptdev); 378 372 else 379 - panthor_gpu_power_off(ptdev, L2, 1, 20000); 373 + panthor_hw_l2_power_off(ptdev); 380 374 381 375 panthor_gpu_irq_suspend(&ptdev->gpu->irq); 382 376 } ··· 391 385 void panthor_gpu_resume(struct panthor_device *ptdev) 392 386 { 393 387 panthor_gpu_irq_resume(&ptdev->gpu->irq, GPU_INTERRUPTS_MASK); 394 - panthor_gpu_l2_power_on(ptdev); 388 + panthor_hw_l2_power_on(ptdev); 395 389 } 396 390
+1
drivers/gpu/drm/panthor/panthor_gpu.h
··· 46 46 type ## _PWRTRANS, \ 47 47 mask, timeout_us) 48 48 49 + void panthor_gpu_l2_power_off(struct panthor_device *ptdev); 49 50 int panthor_gpu_l2_power_on(struct panthor_device *ptdev); 50 51 int panthor_gpu_flush_caches(struct panthor_device *ptdev, 51 52 u32 l2, u32 lsc, u32 other);
+8 -1
drivers/gpu/drm/panthor/panthor_hw.c
··· 4 4 #include <drm/drm_print.h> 5 5 6 6 #include "panthor_device.h" 7 + #include "panthor_gpu.h" 7 8 #include "panthor_hw.h" 8 9 #include "panthor_regs.h" 9 10 ··· 23 22 struct panthor_hw *hwdev; 24 23 }; 25 24 26 - static struct panthor_hw panthor_hw_arch_v10 = {}; 25 + static struct panthor_hw panthor_hw_arch_v10 = { 26 + .ops = { 27 + .soft_reset = panthor_gpu_soft_reset, 28 + .l2_power_off = panthor_gpu_l2_power_off, 29 + .l2_power_on = panthor_gpu_l2_power_on, 30 + }, 31 + }; 27 32 28 33 static struct panthor_hw_entry panthor_hw_match[] = { 29 34 {
+34 -1
drivers/gpu/drm/panthor/panthor_hw.h
··· 4 4 #ifndef __PANTHOR_HW_H__ 5 5 #define __PANTHOR_HW_H__ 6 6 7 - struct panthor_device; 7 + #include "panthor_device.h" 8 + 9 + /** 10 + * struct panthor_hw_ops - HW operations that are specific to a GPU 11 + */ 12 + struct panthor_hw_ops { 13 + /** @soft_reset: Soft reset function pointer */ 14 + int (*soft_reset)(struct panthor_device *ptdev); 15 + 16 + /** @l2_power_off: L2 power off function pointer */ 17 + void (*l2_power_off)(struct panthor_device *ptdev); 18 + 19 + /** @l2_power_on: L2 power on function pointer */ 20 + int (*l2_power_on)(struct panthor_device *ptdev); 21 + }; 8 22 9 23 /** 10 24 * struct panthor_hw - GPU specific register mapping and functions 11 25 */ 12 26 struct panthor_hw { 27 + /** @features: Bitmap containing panthor_hw_feature */ 28 + 29 + /** @ops: Panthor HW specific operations */ 30 + struct panthor_hw_ops ops; 13 31 }; 14 32 15 33 int panthor_hw_init(struct panthor_device *ptdev); 34 + 35 + static inline int panthor_hw_soft_reset(struct panthor_device *ptdev) 36 + { 37 + return ptdev->hw->ops.soft_reset(ptdev); 38 + } 39 + 40 + static inline int panthor_hw_l2_power_on(struct panthor_device *ptdev) 41 + { 42 + return ptdev->hw->ops.l2_power_on(ptdev); 43 + } 44 + 45 + static inline void panthor_hw_l2_power_off(struct panthor_device *ptdev) 46 + { 47 + ptdev->hw->ops.l2_power_off(ptdev); 48 + } 16 49 17 50 #endif /* __PANTHOR_HW_H__ */