Skip to content

Commit 55ea73a

Browse files
mbrost05rodrigovivi
authored andcommitted
drm/xe: Build PM into GuC CT layer
Take PM ref when any G2H are outstanding, drop when none are outstanding. To safely ensure we have PM ref when in the GuC CT layer, a PM ref needs to be held when scheduler messages are pending too. v2: - Add outer PM protections to xe_file_close (CI) v3: - Only take PM ref 0->1 and drop on 1->0 (Matthew Auld) v4: - Add assert to G2H increment function v5: - Rebase v6: - Declare xe as local variable in xe_file_close (CI) Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: Matthew Auld <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Nirmoy Das <[email protected]> Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit d930c19) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 64da63c commit 55ea73a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

drivers/gpu/drm/xe/xe_device.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,14 @@ void xe_file_put(struct xe_file *xef)
138138

139139
static void xe_file_close(struct drm_device *dev, struct drm_file *file)
140140
{
141+
struct xe_device *xe = to_xe_device(dev);
141142
struct xe_file *xef = file->driver_priv;
142143
struct xe_vm *vm;
143144
struct xe_exec_queue *q;
144145
unsigned long idx;
145146

147+
xe_pm_runtime_get(xe);
148+
146149
/*
147150
* No need for exec_queue.lock here as there is no contention for it
148151
* when FD is closing as IOCTLs presumably can't be modifying the
@@ -159,6 +162,8 @@ static void xe_file_close(struct drm_device *dev, struct drm_file *file)
159162
mutex_unlock(&xef->vm.lock);
160163

161164
xe_file_put(xef);
165+
166+
xe_pm_runtime_put(xe);
162167
}
163168

164169
static const struct drm_ioctl_desc xe_ioctls[] = {

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ static void xe_guc_ct_set_state(struct xe_guc_ct *ct,
327327
xe_gt_assert(ct_to_gt(ct), ct->g2h_outstanding == 0 ||
328328
state == XE_GUC_CT_STATE_STOPPED);
329329

330+
if (ct->g2h_outstanding)
331+
xe_pm_runtime_put(ct_to_xe(ct));
330332
ct->g2h_outstanding = 0;
331333
ct->state = state;
332334

@@ -495,10 +497,15 @@ static void h2g_reserve_space(struct xe_guc_ct *ct, u32 cmd_len)
495497
static void __g2h_reserve_space(struct xe_guc_ct *ct, u32 g2h_len, u32 num_g2h)
496498
{
497499
xe_gt_assert(ct_to_gt(ct), g2h_len <= ct->ctbs.g2h.info.space);
500+
xe_gt_assert(ct_to_gt(ct), (!g2h_len && !num_g2h) ||
501+
(g2h_len && num_g2h));
498502

499503
if (g2h_len) {
500504
lockdep_assert_held(&ct->fast_lock);
501505

506+
if (!ct->g2h_outstanding)
507+
xe_pm_runtime_get_noresume(ct_to_xe(ct));
508+
502509
ct->ctbs.g2h.info.space -= g2h_len;
503510
ct->g2h_outstanding += num_g2h;
504511
}
@@ -511,7 +518,8 @@ static void __g2h_release_space(struct xe_guc_ct *ct, u32 g2h_len)
511518
ct->ctbs.g2h.info.size - ct->ctbs.g2h.info.resv_space);
512519

513520
ct->ctbs.g2h.info.space += g2h_len;
514-
--ct->g2h_outstanding;
521+
if (!--ct->g2h_outstanding)
522+
xe_pm_runtime_put(ct_to_xe(ct));
515523
}
516524

517525
static void g2h_release_space(struct xe_guc_ct *ct, u32 g2h_len)

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,8 @@ static void guc_exec_queue_process_msg(struct xe_sched_msg *msg)
13931393
default:
13941394
XE_WARN_ON("Unknown message type");
13951395
}
1396+
1397+
xe_pm_runtime_put(guc_to_xe(exec_queue_to_guc(msg->private_data)));
13961398
}
13971399

13981400
static const struct drm_sched_backend_ops drm_sched_ops = {
@@ -1482,6 +1484,8 @@ static void guc_exec_queue_kill(struct xe_exec_queue *q)
14821484
static void guc_exec_queue_add_msg(struct xe_exec_queue *q, struct xe_sched_msg *msg,
14831485
u32 opcode)
14841486
{
1487+
xe_pm_runtime_get_noresume(guc_to_xe(exec_queue_to_guc(q)));
1488+
14851489
INIT_LIST_HEAD(&msg->link);
14861490
msg->opcode = opcode;
14871491
msg->private_data = q;

0 commit comments

Comments
 (0)