Skip to content

Commit 1c40d40

Browse files
vsbelgaumjohnharr-intel
authored andcommitted
drm/i915/guc: Request RP0 before loading firmware
By default, GT (and GuC) run at RPn. Requesting for RP0 before firmware load can speed up DMA and HuC auth as well. In addition to writing to 0xA008, we also need to enable swreq in 0xA024 so that Punit will pay heed to our request. SLPC will restore the frequency back to RPn after initialization, but we need to manually do that for the non-SLPC path. We don't need a manual override in the SLPC disabled case, just use the intel_rps_set function to ensure consistent RPS state. Signed-off-by: Vinay Belgaumkar <[email protected]> Reviewed-by: Sujaritha Sundaresan <[email protected]> Signed-off-by: John Harrison <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent d8be135 commit 1c40d40

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,6 +2226,65 @@ u32 intel_rps_read_state_cap(struct intel_rps *rps)
22262226
return intel_uncore_read(uncore, GEN6_RP_STATE_CAP);
22272227
}
22282228

2229+
static void intel_rps_set_manual(struct intel_rps *rps, bool enable)
2230+
{
2231+
struct intel_uncore *uncore = rps_to_uncore(rps);
2232+
u32 state = enable ? GEN9_RPSWCTL_ENABLE : GEN9_RPSWCTL_DISABLE;
2233+
2234+
/* Allow punit to process software requests */
2235+
intel_uncore_write(uncore, GEN6_RP_CONTROL, state);
2236+
}
2237+
2238+
void intel_rps_raise_unslice(struct intel_rps *rps)
2239+
{
2240+
struct intel_uncore *uncore = rps_to_uncore(rps);
2241+
u32 rp0_unslice_req;
2242+
2243+
mutex_lock(&rps->lock);
2244+
2245+
if (rps_uses_slpc(rps)) {
2246+
/* RP limits have not been initialized yet for SLPC path */
2247+
rp0_unslice_req = ((intel_rps_read_state_cap(rps) >> 0)
2248+
& 0xff) * GEN9_FREQ_SCALER;
2249+
2250+
intel_rps_set_manual(rps, true);
2251+
intel_uncore_write(uncore, GEN6_RPNSWREQ,
2252+
((rp0_unslice_req <<
2253+
GEN9_SW_REQ_UNSLICE_RATIO_SHIFT) |
2254+
GEN9_IGNORE_SLICE_RATIO));
2255+
intel_rps_set_manual(rps, false);
2256+
} else {
2257+
intel_rps_set(rps, rps->rp0_freq);
2258+
}
2259+
2260+
mutex_unlock(&rps->lock);
2261+
}
2262+
2263+
void intel_rps_lower_unslice(struct intel_rps *rps)
2264+
{
2265+
struct intel_uncore *uncore = rps_to_uncore(rps);
2266+
u32 rpn_unslice_req;
2267+
2268+
mutex_lock(&rps->lock);
2269+
2270+
if (rps_uses_slpc(rps)) {
2271+
/* RP limits have not been initialized yet for SLPC path */
2272+
rpn_unslice_req = ((intel_rps_read_state_cap(rps) >> 16)
2273+
& 0xff) * GEN9_FREQ_SCALER;
2274+
2275+
intel_rps_set_manual(rps, true);
2276+
intel_uncore_write(uncore, GEN6_RPNSWREQ,
2277+
((rpn_unslice_req <<
2278+
GEN9_SW_REQ_UNSLICE_RATIO_SHIFT) |
2279+
GEN9_IGNORE_SLICE_RATIO));
2280+
intel_rps_set_manual(rps, false);
2281+
} else {
2282+
intel_rps_set(rps, rps->min_freq);
2283+
}
2284+
2285+
mutex_unlock(&rps->lock);
2286+
}
2287+
22292288
/* External interface for intel_ips.ko */
22302289

22312290
static struct drm_i915_private __rcu *ips_mchdev;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ u32 intel_rps_get_rpn_frequency(struct intel_rps *rps);
4545
u32 intel_rps_read_punit_req(struct intel_rps *rps);
4646
u32 intel_rps_read_punit_req_frequency(struct intel_rps *rps);
4747
u32 intel_rps_read_state_cap(struct intel_rps *rps);
48+
void intel_rps_raise_unslice(struct intel_rps *rps);
49+
void intel_rps_lower_unslice(struct intel_rps *rps);
4850

4951
void gen5_rps_irq_handler(struct intel_rps *rps);
5052
void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);

drivers/gpu/drm/i915/gt/uc/intel_uc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "intel_guc.h"
99
#include "intel_guc_ads.h"
1010
#include "intel_guc_submission.h"
11+
#include "gt/intel_rps.h"
1112
#include "intel_uc.h"
1213

1314
#include "i915_drv.h"
@@ -462,6 +463,8 @@ static int __uc_init_hw(struct intel_uc *uc)
462463
else
463464
attempts = 1;
464465

466+
intel_rps_raise_unslice(&uc_to_gt(uc)->rps);
467+
465468
while (attempts--) {
466469
/*
467470
* Always reset the GuC just before (re)loading, so
@@ -499,6 +502,9 @@ static int __uc_init_hw(struct intel_uc *uc)
499502
ret = intel_guc_slpc_enable(&guc->slpc);
500503
if (ret)
501504
goto err_submission;
505+
} else {
506+
/* Restore GT back to RPn for non-SLPC path */
507+
intel_rps_lower_unslice(&uc_to_gt(uc)->rps);
502508
}
503509

504510
drm_info(&i915->drm, "%s firmware %s version %u.%u %s:%s\n",
@@ -529,6 +535,9 @@ static int __uc_init_hw(struct intel_uc *uc)
529535
err_log_capture:
530536
__uc_capture_load_err_log(uc);
531537
err_out:
538+
/* Return GT back to RPn */
539+
intel_rps_lower_unslice(&uc_to_gt(uc)->rps);
540+
532541
__uc_sanitize(uc);
533542

534543
if (!ret) {

drivers/gpu/drm/i915/i915_reg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9399,6 +9399,7 @@ enum {
93999399
#define GEN6_OFFSET(x) ((x) << 19)
94009400
#define GEN6_AGGRESSIVE_TURBO (0 << 15)
94019401
#define GEN9_SW_REQ_UNSLICE_RATIO_SHIFT 23
9402+
#define GEN9_IGNORE_SLICE_RATIO (0 << 0)
94029403

94039404
#define GEN6_RC_VIDEO_FREQ _MMIO(0xA00C)
94049405
#define GEN6_RC_CONTROL _MMIO(0xA090)
@@ -9434,6 +9435,9 @@ enum {
94349435
#define GEN6_RP_UP_BUSY_CONT (0x4 << 3)
94359436
#define GEN6_RP_DOWN_IDLE_AVG (0x2 << 0)
94369437
#define GEN6_RP_DOWN_IDLE_CONT (0x1 << 0)
9438+
#define GEN6_RPSWCTL_SHIFT 9
9439+
#define GEN9_RPSWCTL_ENABLE (0x2 << GEN6_RPSWCTL_SHIFT)
9440+
#define GEN9_RPSWCTL_DISABLE (0x0 << GEN6_RPSWCTL_SHIFT)
94379441
#define GEN6_RP_UP_THRESHOLD _MMIO(0xA02C)
94389442
#define GEN6_RP_DOWN_THRESHOLD _MMIO(0xA030)
94399443
#define GEN6_RP_CUR_UP_EI _MMIO(0xA050)

0 commit comments

Comments
 (0)