Skip to content

Commit c1be616

Browse files
committed
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 <[email protected]> Cc: Rodrigo Vivi <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c188622 commit c1be616

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

drivers/gpu/drm/i915/gt/intel_rps.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#include "intel_gt.h"
1515
#include "intel_gt_clock_utils.h"
1616
#include "intel_gt_irq.h"
17+
#include "intel_gt_pm.h"
1718
#include "intel_gt_pm_irq.h"
19+
#include "intel_gt_print.h"
1820
#include "intel_gt_regs.h"
1921
#include "intel_mchbar_regs.h"
2022
#include "intel_pcode.h"
@@ -2572,6 +2574,58 @@ int intel_rps_set_min_frequency(struct intel_rps *rps, u32 val)
25722574
return set_min_freq(rps, val);
25732575
}
25742576

2577+
u8 intel_rps_get_up_threshold(struct intel_rps *rps)
2578+
{
2579+
return rps->power.up_threshold;
2580+
}
2581+
2582+
static int rps_set_threshold(struct intel_rps *rps, u8 *threshold, u8 val)
2583+
{
2584+
int ret;
2585+
2586+
if (val > 100)
2587+
return -EINVAL;
2588+
2589+
ret = mutex_lock_interruptible(&rps->lock);
2590+
if (ret)
2591+
return ret;
2592+
2593+
if (*threshold == val)
2594+
goto out_unlock;
2595+
2596+
*threshold = val;
2597+
2598+
/* Force reset. */
2599+
rps->last_freq = -1;
2600+
mutex_lock(&rps->power.mutex);
2601+
rps->power.mode = -1;
2602+
mutex_unlock(&rps->power.mutex);
2603+
2604+
intel_rps_set(rps, clamp(rps->cur_freq,
2605+
rps->min_freq_softlimit,
2606+
rps->max_freq_softlimit));
2607+
2608+
out_unlock:
2609+
mutex_unlock(&rps->lock);
2610+
2611+
return ret;
2612+
}
2613+
2614+
int intel_rps_set_up_threshold(struct intel_rps *rps, u8 threshold)
2615+
{
2616+
return rps_set_threshold(rps, &rps->power.up_threshold, threshold);
2617+
}
2618+
2619+
u8 intel_rps_get_down_threshold(struct intel_rps *rps)
2620+
{
2621+
return rps->power.down_threshold;
2622+
}
2623+
2624+
int intel_rps_set_down_threshold(struct intel_rps *rps, u8 threshold)
2625+
{
2626+
return rps_set_threshold(rps, &rps->power.down_threshold, threshold);
2627+
}
2628+
25752629
static void intel_rps_set_manual(struct intel_rps *rps, bool enable)
25762630
{
25772631
struct intel_uncore *uncore = rps_to_uncore(rps);

drivers/gpu/drm/i915/gt/intel_rps.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive);
3737

3838
int intel_gpu_freq(struct intel_rps *rps, int val);
3939
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);
4044
u32 intel_rps_read_actual_frequency(struct intel_rps *rps);
4145
u32 intel_rps_read_actual_frequency_fw(struct intel_rps *rps);
4246
u32 intel_rps_get_requested_frequency(struct intel_rps *rps);

0 commit comments

Comments
 (0)