Skip to content

Commit d1d7732

Browse files
committed
Merge tag 'drm-xe-fixes-2025-03-13' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
- Release guc ids before cancelling work (Tejas) - Fix new warnings around userptr (Thomas) - Temporaritly disable D3Cold on BMG (Rodrigo) - Retry and wait longer for GuC PC to start (Rodrigo) - Remove redundant check in xe_vm_create_ioctl (Xin) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/Z9MJWeIlZPuvXZ_G@intel.com
2 parents c8a7495 + f5d4e81 commit d1d7732

File tree

5 files changed

+58
-19
lines changed

5 files changed

+58
-19
lines changed

drivers/gpu/drm/xe/xe_guc_pc.c

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "xe_guc_pc.h"
77

88
#include <linux/delay.h>
9+
#include <linux/ktime.h>
910

1011
#include <drm/drm_managed.h>
1112
#include <generated/xe_wa_oob.h>
@@ -19,6 +20,7 @@
1920
#include "xe_gt.h"
2021
#include "xe_gt_idle.h"
2122
#include "xe_gt_printk.h"
23+
#include "xe_gt_throttle.h"
2224
#include "xe_gt_types.h"
2325
#include "xe_guc.h"
2426
#include "xe_guc_ct.h"
@@ -49,6 +51,9 @@
4951
#define LNL_MERT_FREQ_CAP 800
5052
#define BMG_MERT_FREQ_CAP 2133
5153

54+
#define SLPC_RESET_TIMEOUT_MS 5 /* roughly 5ms, but no need for precision */
55+
#define SLPC_RESET_EXTENDED_TIMEOUT_MS 1000 /* To be used only at pc_start */
56+
5257
/**
5358
* DOC: GuC Power Conservation (PC)
5459
*
@@ -113,9 +118,10 @@ static struct iosys_map *pc_to_maps(struct xe_guc_pc *pc)
113118
FIELD_PREP(HOST2GUC_PC_SLPC_REQUEST_MSG_1_EVENT_ARGC, count))
114119

115120
static int wait_for_pc_state(struct xe_guc_pc *pc,
116-
enum slpc_global_state state)
121+
enum slpc_global_state state,
122+
int timeout_ms)
117123
{
118-
int timeout_us = 5000; /* rought 5ms, but no need for precision */
124+
int timeout_us = 1000 * timeout_ms;
119125
int slept, wait = 10;
120126

121127
xe_device_assert_mem_access(pc_to_xe(pc));
@@ -164,7 +170,8 @@ static int pc_action_query_task_state(struct xe_guc_pc *pc)
164170
};
165171
int ret;
166172

167-
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING))
173+
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
174+
SLPC_RESET_TIMEOUT_MS))
168175
return -EAGAIN;
169176

170177
/* Blocking here to ensure the results are ready before reading them */
@@ -187,7 +194,8 @@ static int pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value)
187194
};
188195
int ret;
189196

190-
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING))
197+
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
198+
SLPC_RESET_TIMEOUT_MS))
191199
return -EAGAIN;
192200

193201
ret = xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0);
@@ -208,7 +216,8 @@ static int pc_action_unset_param(struct xe_guc_pc *pc, u8 id)
208216
struct xe_guc_ct *ct = &pc_to_guc(pc)->ct;
209217
int ret;
210218

211-
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING))
219+
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
220+
SLPC_RESET_TIMEOUT_MS))
212221
return -EAGAIN;
213222

214223
ret = xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0);
@@ -440,6 +449,15 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc)
440449
return freq;
441450
}
442451

452+
static u32 get_cur_freq(struct xe_gt *gt)
453+
{
454+
u32 freq;
455+
456+
freq = xe_mmio_read32(&gt->mmio, RPNSWREQ);
457+
freq = REG_FIELD_GET(REQ_RATIO_MASK, freq);
458+
return decode_freq(freq);
459+
}
460+
443461
/**
444462
* xe_guc_pc_get_cur_freq - Get Current requested frequency
445463
* @pc: The GuC PC
@@ -463,10 +481,7 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq)
463481
return -ETIMEDOUT;
464482
}
465483

466-
*freq = xe_mmio_read32(&gt->mmio, RPNSWREQ);
467-
468-
*freq = REG_FIELD_GET(REQ_RATIO_MASK, *freq);
469-
*freq = decode_freq(*freq);
484+
*freq = get_cur_freq(gt);
470485

471486
xe_force_wake_put(gt_to_fw(gt), fw_ref);
472487
return 0;
@@ -1002,6 +1017,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
10021017
struct xe_gt *gt = pc_to_gt(pc);
10031018
u32 size = PAGE_ALIGN(sizeof(struct slpc_shared_data));
10041019
unsigned int fw_ref;
1020+
ktime_t earlier;
10051021
int ret;
10061022

10071023
xe_gt_assert(gt, xe_device_uc_enabled(xe));
@@ -1026,14 +1042,25 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
10261042
memset(pc->bo->vmap.vaddr, 0, size);
10271043
slpc_shared_data_write(pc, header.size, size);
10281044

1045+
earlier = ktime_get();
10291046
ret = pc_action_reset(pc);
10301047
if (ret)
10311048
goto out;
10321049

1033-
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING)) {
1034-
xe_gt_err(gt, "GuC PC Start failed\n");
1035-
ret = -EIO;
1036-
goto out;
1050+
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
1051+
SLPC_RESET_TIMEOUT_MS)) {
1052+
xe_gt_warn(gt, "GuC PC start taking longer than normal [freq = %dMHz (req = %dMHz), perf_limit_reasons = 0x%08X]\n",
1053+
xe_guc_pc_get_act_freq(pc), get_cur_freq(gt),
1054+
xe_gt_throttle_get_limit_reasons(gt));
1055+
1056+
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
1057+
SLPC_RESET_EXTENDED_TIMEOUT_MS)) {
1058+
xe_gt_err(gt, "GuC PC Start failed: Dynamic GT frequency control and GT sleep states are now disabled.\n");
1059+
goto out;
1060+
}
1061+
1062+
xe_gt_warn(gt, "GuC PC excessive start time: %lldms",
1063+
ktime_ms_delta(ktime_get(), earlier));
10371064
}
10381065

10391066
ret = pc_init_freqs(pc);

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,11 +1246,11 @@ static void __guc_exec_queue_fini_async(struct work_struct *w)
12461246
xe_pm_runtime_get(guc_to_xe(guc));
12471247
trace_xe_exec_queue_destroy(q);
12481248

1249+
release_guc_id(guc, q);
12491250
if (xe_exec_queue_is_lr(q))
12501251
cancel_work_sync(&ge->lr_tdr);
12511252
/* Confirm no work left behind accessing device structures */
12521253
cancel_delayed_work_sync(&ge->sched.base.work_tdr);
1253-
release_guc_id(guc, q);
12541254
xe_sched_entity_fini(&ge->entity);
12551255
xe_sched_fini(&ge->sched);
12561256

drivers/gpu/drm/xe/xe_hmm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,17 @@ static int xe_build_sg(struct xe_device *xe, struct hmm_range *range,
138138
i += size;
139139

140140
if (unlikely(j == st->nents - 1)) {
141+
xe_assert(xe, i >= npages);
141142
if (i > npages)
142143
size -= (i - npages);
144+
143145
sg_mark_end(sgl);
146+
} else {
147+
xe_assert(xe, i < npages);
144148
}
149+
145150
sg_set_page(sgl, page, size << PAGE_SHIFT, 0);
146151
}
147-
xe_assert(xe, i == npages);
148152

149153
return dma_map_sgtable(dev, st, write ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE,
150154
DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_NO_KERNEL_MAPPING);

drivers/gpu/drm/xe/xe_pm.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ int xe_pm_init_early(struct xe_device *xe)
267267
}
268268
ALLOW_ERROR_INJECTION(xe_pm_init_early, ERRNO); /* See xe_pci_probe() */
269269

270+
static u32 vram_threshold_value(struct xe_device *xe)
271+
{
272+
/* FIXME: D3Cold temporarily disabled by default on BMG */
273+
if (xe->info.platform == XE_BATTLEMAGE)
274+
return 0;
275+
276+
return DEFAULT_VRAM_THRESHOLD;
277+
}
278+
270279
/**
271280
* xe_pm_init - Initialize Xe Power Management
272281
* @xe: xe device instance
@@ -277,6 +286,7 @@ ALLOW_ERROR_INJECTION(xe_pm_init_early, ERRNO); /* See xe_pci_probe() */
277286
*/
278287
int xe_pm_init(struct xe_device *xe)
279288
{
289+
u32 vram_threshold;
280290
int err;
281291

282292
/* For now suspend/resume is only allowed with GuC */
@@ -290,7 +300,8 @@ int xe_pm_init(struct xe_device *xe)
290300
if (err)
291301
return err;
292302

293-
err = xe_pm_set_vram_threshold(xe, DEFAULT_VRAM_THRESHOLD);
303+
vram_threshold = vram_threshold_value(xe);
304+
err = xe_pm_set_vram_threshold(xe, vram_threshold);
294305
if (err)
295306
return err;
296307
}

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,6 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
18091809
args->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE))
18101810
return -EINVAL;
18111811

1812-
if (XE_IOCTL_DBG(xe, args->extensions))
1813-
return -EINVAL;
1814-
18151812
if (args->flags & DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE)
18161813
flags |= XE_VM_FLAG_SCRATCH_PAGE;
18171814
if (args->flags & DRM_XE_VM_CREATE_FLAG_LR_MODE)

0 commit comments

Comments
 (0)