Skip to content

Commit 38e8c41

Browse files
rtauro1895rodrigovivi
authored andcommitted
drm/xe: Enable Coarse Power Gating
Enable power gating for all units and sub-pipes that are disabled by default. v2: change the init function name use symmetric calls for enable/disable pg re-pharase commit message (Rodrigo) modify the sub-pipe power gating condition v3: set hysteresis value for render and media when GuC PC is disabled skip CPG for PVC (Vinay) v4: rebase Signed-off-by: Riana Tauro <riana.tauro@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> #v2 Reviewed-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240524070916.143022-3-riana.tauro@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 9276bcc commit 38e8c41

File tree

4 files changed

+68
-9
lines changed

4 files changed

+68
-9
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@
309309
#define RC_CTL_RC6_ENABLE REG_BIT(18)
310310
#define RC_STATE XE_REG(0xa094)
311311
#define RC_IDLE_HYSTERSIS XE_REG(0xa0ac)
312+
#define MEDIA_POWERGATE_IDLE_HYSTERESIS XE_REG(0xa0c4)
313+
#define RENDER_POWERGATE_IDLE_HYSTERESIS XE_REG(0xa0c8)
312314

313315
#define PMINTRMSK XE_REG(0xa168)
314316
#define PMINTR_DISABLE_REDIRECT_TO_GUC REG_BIT(31)
@@ -317,6 +319,8 @@
317319
#define FORCEWAKE_GT XE_REG(0xa188)
318320

319321
#define POWERGATE_ENABLE XE_REG(0xa210)
322+
#define RENDER_POWERGATE_ENABLE REG_BIT(0)
323+
#define MEDIA_POWERGATE_ENABLE REG_BIT(1)
320324
#define VDN_HCP_POWERGATE_ENABLE(n) REG_BIT(3 + 2 * (n))
321325
#define VDN_MFXVDENC_POWERGATE_ENABLE(n) REG_BIT(4 + 2 * (n))
322326

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ static int gt_fw_domain_init(struct xe_gt *gt)
366366
xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt);
367367
}
368368

369-
err = xe_gt_idle_sysfs_init(&gt->gtidle);
370-
if (err)
371-
goto err_force_wake;
372-
373369
/* Enable per hw engine IRQs */
374370
xe_irq_enable_hwe(gt);
375371

@@ -554,6 +550,10 @@ int xe_gt_init(struct xe_gt *gt)
554550
if (err)
555551
return err;
556552

553+
err = xe_gt_idle_init(&gt->gtidle);
554+
if (err)
555+
return err;
556+
557557
err = xe_gt_freq_init(gt);
558558
if (err)
559559
return err;
@@ -760,6 +760,8 @@ int xe_gt_suspend(struct xe_gt *gt)
760760
if (err)
761761
goto err_force_wake;
762762

763+
xe_gt_idle_disable_pg(gt);
764+
763765
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
764766
xe_gt_dbg(gt, "suspended\n");
765767

@@ -786,6 +788,8 @@ int xe_gt_resume(struct xe_gt *gt)
786788
if (err)
787789
goto err_force_wake;
788790

791+
xe_gt_idle_enable_pg(gt);
792+
789793
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
790794
xe_gt_dbg(gt, "resumed\n");
791795

drivers/gpu/drm/xe/xe_gt_idle.c

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "xe_gt_sysfs.h"
1313
#include "xe_guc_pc.h"
1414
#include "regs/xe_gt_regs.h"
15+
#include "xe_macros.h"
1516
#include "xe_mmio.h"
1617
#include "xe_pm.h"
1718

@@ -93,6 +94,50 @@ static u64 get_residency_ms(struct xe_gt_idle *gtidle, u64 cur_residency)
9394
return cur_residency;
9495
}
9596

97+
void xe_gt_idle_enable_pg(struct xe_gt *gt)
98+
{
99+
struct xe_device *xe = gt_to_xe(gt);
100+
u32 pg_enable;
101+
int i, j;
102+
103+
/* Disable CPG for PVC */
104+
if (xe->info.platform == XE_PVC)
105+
return;
106+
107+
xe_device_assert_mem_access(gt_to_xe(gt));
108+
109+
pg_enable = RENDER_POWERGATE_ENABLE | MEDIA_POWERGATE_ENABLE;
110+
111+
for (i = XE_HW_ENGINE_VCS0, j = 0; i <= XE_HW_ENGINE_VCS7; ++i, ++j) {
112+
if ((gt->info.engine_mask & BIT(i)))
113+
pg_enable |= (VDN_HCP_POWERGATE_ENABLE(j) |
114+
VDN_MFXVDENC_POWERGATE_ENABLE(j));
115+
}
116+
117+
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FW_GT));
118+
if (xe->info.skip_guc_pc) {
119+
/*
120+
* GuC sets the hysteresis value when GuC PC is enabled
121+
* else set it to 25 (25 * 1.28us)
122+
*/
123+
xe_mmio_write32(gt, MEDIA_POWERGATE_IDLE_HYSTERESIS, 25);
124+
xe_mmio_write32(gt, RENDER_POWERGATE_IDLE_HYSTERESIS, 25);
125+
}
126+
127+
xe_mmio_write32(gt, POWERGATE_ENABLE, pg_enable);
128+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FW_GT));
129+
}
130+
131+
void xe_gt_idle_disable_pg(struct xe_gt *gt)
132+
{
133+
xe_device_assert_mem_access(gt_to_xe(gt));
134+
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FW_GT));
135+
136+
xe_mmio_write32(gt, POWERGATE_ENABLE, 0);
137+
138+
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FW_GT));
139+
}
140+
96141
static ssize_t name_show(struct device *dev,
97142
struct device_attribute *attr, char *buff)
98143
{
@@ -145,15 +190,18 @@ static const struct attribute *gt_idle_attrs[] = {
145190
NULL,
146191
};
147192

148-
static void gt_idle_sysfs_fini(void *arg)
193+
static void gt_idle_fini(void *arg)
149194
{
150195
struct kobject *kobj = arg;
196+
struct xe_gt *gt = kobj_to_gt(kobj->parent);
197+
198+
xe_gt_idle_disable_pg(gt);
151199

152200
sysfs_remove_files(kobj, gt_idle_attrs);
153201
kobject_put(kobj);
154202
}
155203

156-
int xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle)
204+
int xe_gt_idle_init(struct xe_gt_idle *gtidle)
157205
{
158206
struct xe_gt *gt = gtidle_to_gt(gtidle);
159207
struct xe_device *xe = gt_to_xe(gt);
@@ -182,7 +230,9 @@ int xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle)
182230
return err;
183231
}
184232

185-
return devm_add_action_or_reset(xe->drm.dev, gt_idle_sysfs_fini, kobj);
233+
xe_gt_idle_enable_pg(gt);
234+
235+
return devm_add_action_or_reset(xe->drm.dev, gt_idle_fini, kobj);
186236
}
187237

188238
void xe_gt_idle_enable_c6(struct xe_gt *gt)
@@ -202,7 +252,6 @@ void xe_gt_idle_disable_c6(struct xe_gt *gt)
202252
xe_device_assert_mem_access(gt_to_xe(gt));
203253
xe_force_wake_assert_held(gt_to_fw(gt), XE_FORCEWAKE_ALL);
204254

205-
xe_mmio_write32(gt, POWERGATE_ENABLE, 0);
206255
xe_mmio_write32(gt, RC_CONTROL, 0);
207256
xe_mmio_write32(gt, RC_STATE, 0);
208257
}

drivers/gpu/drm/xe/xe_gt_idle.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
struct xe_gt;
1212

13-
int xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle);
13+
int xe_gt_idle_init(struct xe_gt_idle *gtidle);
1414
void xe_gt_idle_enable_c6(struct xe_gt *gt);
1515
void xe_gt_idle_disable_c6(struct xe_gt *gt);
16+
void xe_gt_idle_enable_pg(struct xe_gt *gt);
17+
void xe_gt_idle_disable_pg(struct xe_gt *gt);
1618

1719
#endif /* _XE_GT_IDLE_H_ */

0 commit comments

Comments
 (0)