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

drm/i915: Add helpers for managing rps thresholds

In preparation for exposing via sysfs add helpers for managing rps
thresholds.

v2:
* Force sw and hw re-programming on threshold change.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@kernel.org>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230717164013.826614-3-tvrtko.ursulin@linux.intel.com

+58
+54
drivers/gpu/drm/i915/gt/intel_rps.c
··· 14 14 #include "intel_gt.h" 15 15 #include "intel_gt_clock_utils.h" 16 16 #include "intel_gt_irq.h" 17 + #include "intel_gt_pm.h" 17 18 #include "intel_gt_pm_irq.h" 19 + #include "intel_gt_print.h" 18 20 #include "intel_gt_regs.h" 19 21 #include "intel_mchbar_regs.h" 20 22 #include "intel_pcode.h" ··· 2572 2570 return intel_guc_slpc_set_min_freq(slpc, val); 2573 2571 else 2574 2572 return set_min_freq(rps, val); 2573 + } 2574 + 2575 + u8 intel_rps_get_up_threshold(struct intel_rps *rps) 2576 + { 2577 + return rps->power.up_threshold; 2578 + } 2579 + 2580 + static int rps_set_threshold(struct intel_rps *rps, u8 *threshold, u8 val) 2581 + { 2582 + int ret; 2583 + 2584 + if (val > 100) 2585 + return -EINVAL; 2586 + 2587 + ret = mutex_lock_interruptible(&rps->lock); 2588 + if (ret) 2589 + return ret; 2590 + 2591 + if (*threshold == val) 2592 + goto out_unlock; 2593 + 2594 + *threshold = val; 2595 + 2596 + /* Force reset. */ 2597 + rps->last_freq = -1; 2598 + mutex_lock(&rps->power.mutex); 2599 + rps->power.mode = -1; 2600 + mutex_unlock(&rps->power.mutex); 2601 + 2602 + intel_rps_set(rps, clamp(rps->cur_freq, 2603 + rps->min_freq_softlimit, 2604 + rps->max_freq_softlimit)); 2605 + 2606 + out_unlock: 2607 + mutex_unlock(&rps->lock); 2608 + 2609 + return ret; 2610 + } 2611 + 2612 + int intel_rps_set_up_threshold(struct intel_rps *rps, u8 threshold) 2613 + { 2614 + return rps_set_threshold(rps, &rps->power.up_threshold, threshold); 2615 + } 2616 + 2617 + u8 intel_rps_get_down_threshold(struct intel_rps *rps) 2618 + { 2619 + return rps->power.down_threshold; 2620 + } 2621 + 2622 + int intel_rps_set_down_threshold(struct intel_rps *rps, u8 threshold) 2623 + { 2624 + return rps_set_threshold(rps, &rps->power.down_threshold, threshold); 2575 2625 } 2576 2626 2577 2627 static void intel_rps_set_manual(struct intel_rps *rps, bool enable)
+4
drivers/gpu/drm/i915/gt/intel_rps.h
··· 37 37 38 38 int intel_gpu_freq(struct intel_rps *rps, int val); 39 39 int intel_freq_opcode(struct intel_rps *rps, int val); 40 + u8 intel_rps_get_up_threshold(struct intel_rps *rps); 41 + int intel_rps_set_up_threshold(struct intel_rps *rps, u8 threshold); 42 + u8 intel_rps_get_down_threshold(struct intel_rps *rps); 43 + int intel_rps_set_down_threshold(struct intel_rps *rps, u8 threshold); 40 44 u32 intel_rps_read_actual_frequency(struct intel_rps *rps); 41 45 u32 intel_rps_read_actual_frequency_fw(struct intel_rps *rps); 42 46 u32 intel_rps_get_requested_frequency(struct intel_rps *rps);