Skip to content

Commit 43efd3b

Browse files
vsbelgaumrodrigovivi
authored andcommitted
drm/xe: Raise GT frequency before GuC/HuC load
Starting GT freq is usually RPn. Raising freq to RP0 will help speed up GuC load times. As an example, this data was collected on DG2- GuC Load time @rpn ~ 41 ms GuC Load time @rp0 ~ 11 ms v2: Raise GT freq before hwconfig init. This will speed up both HuC and GuC loads. Address review comments (Rodrigo). Also add a small usleep after requesting frequency which gives pcode some time to react. v3: Address checkpatch issue Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 08987a8 commit 43efd3b

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

drivers/gpu/drm/xe/regs/xe_gt_regs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@
263263

264264
#define RPNSWREQ XE_REG(0xa008)
265265
#define REQ_RATIO_MASK REG_GENMASK(31, 23)
266+
267+
#define RP_CONTROL XE_REG(0xa024)
268+
#define RPSWCTL_MASK REG_GENMASK(10, 9)
269+
#define RPSWCTL_ENABLE REG_FIELD_PREP(RPSWCTL_MASK, 2)
270+
#define RPSWCTL_DISABLE REG_FIELD_PREP(RPSWCTL_MASK, 0)
266271
#define RC_CONTROL XE_REG(0xa090)
267272
#define RC_STATE XE_REG(0xa094)
268273

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "xe_gt_tlb_invalidation.h"
3131
#include "xe_gt_topology.h"
3232
#include "xe_guc_exec_queue_types.h"
33+
#include "xe_guc_pc.h"
3334
#include "xe_hw_fence.h"
3435
#include "xe_hw_engine_class_sysfs.h"
3536
#include "xe_irq.h"
@@ -349,6 +350,9 @@ static int gt_fw_domain_init(struct xe_gt *gt)
349350
if (err)
350351
goto err_force_wake;
351352

353+
/* Raise GT freq to speed up HuC/GuC load */
354+
xe_guc_pc_init_early(&gt->uc.guc.pc);
355+
352356
err = xe_uc_init_hwconfig(&gt->uc);
353357
if (err)
354358
goto err_force_wake;

drivers/gpu/drm/xe/xe_guc_pc.c

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ static u32 decode_freq(u32 raw)
247247
GEN9_FREQ_SCALER);
248248
}
249249

250+
static u32 encode_freq(u32 freq)
251+
{
252+
return DIV_ROUND_CLOSEST(freq * GEN9_FREQ_SCALER,
253+
GT_FREQUENCY_MULTIPLIER);
254+
}
255+
250256
static u32 pc_get_min_freq(struct xe_guc_pc *pc)
251257
{
252258
u32 freq;
@@ -257,6 +263,32 @@ static u32 pc_get_min_freq(struct xe_guc_pc *pc)
257263
return decode_freq(freq);
258264
}
259265

266+
static void pc_set_manual_rp_ctrl(struct xe_guc_pc *pc, bool enable)
267+
{
268+
struct xe_gt *gt = pc_to_gt(pc);
269+
u32 state = enable ? RPSWCTL_ENABLE : RPSWCTL_DISABLE;
270+
271+
/* Allow/Disallow punit to process software freq requests */
272+
xe_mmio_write32(gt, RP_CONTROL, state);
273+
}
274+
275+
static void pc_set_cur_freq(struct xe_guc_pc *pc, u32 freq)
276+
{
277+
struct xe_gt *gt = pc_to_gt(pc);
278+
u32 rpnswreq;
279+
280+
pc_set_manual_rp_ctrl(pc, true);
281+
282+
/* Req freq is in units of 16.66 Mhz */
283+
rpnswreq = REG_FIELD_PREP(REQ_RATIO_MASK, encode_freq(freq));
284+
xe_mmio_write32(gt, RPNSWREQ, rpnswreq);
285+
286+
/* Sleep for a small time to allow pcode to respond */
287+
usleep_range(100, 300);
288+
289+
pc_set_manual_rp_ctrl(pc, false);
290+
}
291+
260292
static int pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
261293
{
262294
/*
@@ -685,6 +717,21 @@ static void pc_init_fused_rp_values(struct xe_guc_pc *pc)
685717
else
686718
tgl_init_fused_rp_values(pc);
687719
}
720+
721+
/**
722+
* xe_guc_pc_init_early - Initialize RPx values and request a higher GT
723+
* frequency to allow faster GuC load times
724+
* @pc: Xe_GuC_PC instance
725+
*/
726+
void xe_guc_pc_init_early(struct xe_guc_pc *pc)
727+
{
728+
struct xe_gt *gt = pc_to_gt(pc);
729+
730+
xe_force_wake_assert_held(gt_to_fw(gt), XE_FW_GT);
731+
pc_init_fused_rp_values(pc);
732+
pc_set_cur_freq(pc, pc->rp0_freq);
733+
}
734+
688735
static int pc_adjust_freq_bounds(struct xe_guc_pc *pc)
689736
{
690737
int ret;
@@ -918,8 +965,6 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
918965

919966
pc->bo = bo;
920967

921-
pc_init_fused_rp_values(pc);
922-
923968
err = sysfs_create_files(gt->sysfs, pc_attrs);
924969
if (err)
925970
return err;

drivers/gpu/drm/xe/xe_guc_pc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc);
1717
enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc);
1818
u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc);
1919
u64 xe_guc_pc_mc6_residency(struct xe_guc_pc *pc);
20+
void xe_guc_pc_init_early(struct xe_guc_pc *pc);
2021
#endif /* _XE_GUC_PC_H_ */

0 commit comments

Comments
 (0)