Skip to content

Commit

Permalink
drm/xe: Remove mem_access from guc_pc calls
Browse files Browse the repository at this point in the history
[ Upstream commit 1e941c9 ]

We are now protected by init, sysfs, or removal and don't
need these mem_access protections around GuC_PC anymore.

Reviewed-by: Matthew Auld <[email protected]>
Signed-off-by: Rodrigo Vivi <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Stable-dep-of: 2470b14 ("drm/xe: move disable_c6 call")
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
rodrigovivi authored and gregkh committed Jun 21, 2024
1 parent 794556b commit 6503743
Showing 1 changed file with 10 additions and 54 deletions.
64 changes: 10 additions & 54 deletions drivers/gpu/drm/xe/xe_guc_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,6 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc)
struct xe_device *xe = gt_to_xe(gt);
u32 freq;

xe_device_mem_access_get(gt_to_xe(gt));

/* When in RC6, actual frequency reported will be 0. */
if (GRAPHICS_VERx100(xe) >= 1270) {
freq = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1);
Expand All @@ -394,8 +392,6 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc)

freq = decode_freq(freq);

xe_device_mem_access_put(gt_to_xe(gt));

return freq;
}

Expand All @@ -412,24 +408,21 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq)
struct xe_gt *gt = pc_to_gt(pc);
int ret;

xe_device_mem_access_get(gt_to_xe(gt));
/*
* GuC SLPC plays with cur freq request when GuCRC is enabled
* Block RC6 for a more reliable read.
*/
ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
if (ret)
goto out;
return ret;

*freq = xe_mmio_read32(gt, RPNSWREQ);

*freq = REG_FIELD_GET(REQ_RATIO_MASK, *freq);
*freq = decode_freq(*freq);

XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
out:
xe_device_mem_access_put(gt_to_xe(gt));
return ret;
return 0;
}

/**
Expand All @@ -451,12 +444,7 @@ u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc)
*/
u32 xe_guc_pc_get_rpe_freq(struct xe_guc_pc *pc)
{
struct xe_gt *gt = pc_to_gt(pc);
struct xe_device *xe = gt_to_xe(gt);

xe_device_mem_access_get(xe);
pc_update_rp_values(pc);
xe_device_mem_access_put(xe);

return pc->rpe_freq;
}
Expand Down Expand Up @@ -485,7 +473,6 @@ int xe_guc_pc_get_min_freq(struct xe_guc_pc *pc, u32 *freq)
struct xe_gt *gt = pc_to_gt(pc);
int ret;

xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */
Expand All @@ -511,7 +498,6 @@ int xe_guc_pc_get_min_freq(struct xe_guc_pc *pc, u32 *freq)
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
out:
mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
}

Expand All @@ -528,7 +514,6 @@ int xe_guc_pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
{
int ret;

xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */
Expand All @@ -544,8 +529,6 @@ int xe_guc_pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)

out:
mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));

return ret;
}

Expand All @@ -561,7 +544,6 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq)
{
int ret;

xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */
Expand All @@ -577,7 +559,6 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq)

out:
mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
}

Expand All @@ -594,7 +575,6 @@ int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
{
int ret;

xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */
Expand All @@ -610,7 +590,6 @@ int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)

out:
mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
}

Expand All @@ -623,8 +602,6 @@ enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc)
struct xe_gt *gt = pc_to_gt(pc);
u32 reg, gt_c_state;

xe_device_mem_access_get(gt_to_xe(gt));

if (GRAPHICS_VERx100(gt_to_xe(gt)) >= 1270) {
reg = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1);
gt_c_state = REG_FIELD_GET(MTL_CC_MASK, reg);
Expand All @@ -633,8 +610,6 @@ enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc)
gt_c_state = REG_FIELD_GET(RCN_MASK, reg);
}

xe_device_mem_access_put(gt_to_xe(gt));

switch (gt_c_state) {
case GT_C6:
return GT_IDLE_C6;
Expand All @@ -654,9 +629,7 @@ u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc)
struct xe_gt *gt = pc_to_gt(pc);
u32 reg;

xe_device_mem_access_get(gt_to_xe(gt));
reg = xe_mmio_read32(gt, GT_GFX_RC6);
xe_device_mem_access_put(gt_to_xe(gt));

return reg;
}
Expand All @@ -670,9 +643,7 @@ u64 xe_guc_pc_mc6_residency(struct xe_guc_pc *pc)
struct xe_gt *gt = pc_to_gt(pc);
u64 reg;

xe_device_mem_access_get(gt_to_xe(gt));
reg = xe_mmio_read32(gt, MTL_MEDIA_MC6);
xe_device_mem_access_put(gt_to_xe(gt));

return reg;
}
Expand Down Expand Up @@ -801,23 +772,19 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc)
if (xe->info.skip_guc_pc)
return 0;

xe_device_mem_access_get(pc_to_xe(pc));

ret = pc_action_setup_gucrc(pc, XE_GUCRC_HOST_CONTROL);
if (ret)
goto out;
return ret;

ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
if (ret)
goto out;
return ret;

xe_gt_idle_disable_c6(gt);

XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));

out:
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
return 0;
}

static void pc_init_pcode_freq(struct xe_guc_pc *pc)
Expand Down Expand Up @@ -870,11 +837,9 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)

xe_gt_assert(gt, xe_device_uc_enabled(xe));

xe_device_mem_access_get(pc_to_xe(pc));

ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
if (ret)
goto out_fail_force_wake;
return ret;

if (xe->info.skip_guc_pc) {
if (xe->info.platform != XE_PVC)
Expand Down Expand Up @@ -914,8 +879,6 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)

out:
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
out_fail_force_wake:
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
}

Expand All @@ -928,12 +891,9 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc)
struct xe_device *xe = pc_to_xe(pc);
int ret;

xe_device_mem_access_get(pc_to_xe(pc));

if (xe->info.skip_guc_pc) {
xe_gt_idle_disable_c6(pc_to_gt(pc));
ret = 0;
goto out;
return 0;
}

mutex_lock(&pc->freq_lock);
Expand All @@ -942,16 +902,14 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc)

ret = pc_action_shutdown(pc);
if (ret)
goto out;
return ret;

if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_NOT_RUNNING)) {
drm_err(&pc_to_xe(pc)->drm, "GuC PC Shutdown failed\n");
ret = -EIO;
return -EIO;
}

out:
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
return 0;
}

/**
Expand All @@ -965,9 +923,7 @@ static void xe_guc_pc_fini(struct drm_device *drm, void *arg)
struct xe_device *xe = pc_to_xe(pc);

if (xe->info.skip_guc_pc) {
xe_device_mem_access_get(xe);
xe_gt_idle_disable_c6(pc_to_gt(pc));
xe_device_mem_access_put(xe);
return;
}

Expand Down

0 comments on commit 6503743

Please sign in to comment.