|
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,6 +2574,58 @@ int intel_rps_set_min_frequency(struct intel_rps *rps, u32 val)
|
2572 | 2574 | return set_min_freq(rps, val);
|
2573 | 2575 | }
|
2574 | 2576 |
|
| 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 | + |
2575 | 2629 | static void intel_rps_set_manual(struct intel_rps *rps, bool enable)
|
2576 | 2630 | {
|
2577 | 2631 | struct intel_uncore *uncore = rps_to_uncore(rps);
|
|
0 commit comments