Commit 1e941c98 authored by Rodrigo Vivi's avatar Rodrigo Vivi

drm/xe: Remove mem_access from guc_pc calls

We are now protected by init, sysfs, or removal and don't
need these mem_access protections around GuC_PC anymore.
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240222163937.138342-6-rodrigo.vivi@intel.com
parent 3f0e1465
...@@ -381,8 +381,6 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc) ...@@ -381,8 +381,6 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc)
struct xe_device *xe = gt_to_xe(gt); struct xe_device *xe = gt_to_xe(gt);
u32 freq; u32 freq;
xe_device_mem_access_get(gt_to_xe(gt));
/* When in RC6, actual frequency reported will be 0. */ /* When in RC6, actual frequency reported will be 0. */
if (GRAPHICS_VERx100(xe) >= 1270) { if (GRAPHICS_VERx100(xe) >= 1270) {
freq = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1); freq = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1);
...@@ -394,8 +392,6 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc) ...@@ -394,8 +392,6 @@ u32 xe_guc_pc_get_act_freq(struct xe_guc_pc *pc)
freq = decode_freq(freq); freq = decode_freq(freq);
xe_device_mem_access_put(gt_to_xe(gt));
return freq; return freq;
} }
...@@ -412,14 +408,13 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq) ...@@ -412,14 +408,13 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq)
struct xe_gt *gt = pc_to_gt(pc); struct xe_gt *gt = pc_to_gt(pc);
int ret; int ret;
xe_device_mem_access_get(gt_to_xe(gt));
/* /*
* GuC SLPC plays with cur freq request when GuCRC is enabled * GuC SLPC plays with cur freq request when GuCRC is enabled
* Block RC6 for a more reliable read. * Block RC6 for a more reliable read.
*/ */
ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
if (ret) if (ret)
goto out; return ret;
*freq = xe_mmio_read32(gt, RPNSWREQ); *freq = xe_mmio_read32(gt, RPNSWREQ);
...@@ -427,9 +422,7 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq) ...@@ -427,9 +422,7 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq)
*freq = decode_freq(*freq); *freq = decode_freq(*freq);
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
out: return 0;
xe_device_mem_access_put(gt_to_xe(gt));
return ret;
} }
/** /**
...@@ -451,12 +444,7 @@ u32 xe_guc_pc_get_rp0_freq(struct xe_guc_pc *pc) ...@@ -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) 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); pc_update_rp_values(pc);
xe_device_mem_access_put(xe);
return pc->rpe_freq; return pc->rpe_freq;
} }
...@@ -485,7 +473,6 @@ int xe_guc_pc_get_min_freq(struct xe_guc_pc *pc, u32 *freq) ...@@ -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); struct xe_gt *gt = pc_to_gt(pc);
int ret; int ret;
xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock); mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) { if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */ /* Might be in the middle of a gt reset */
...@@ -511,7 +498,6 @@ int xe_guc_pc_get_min_freq(struct xe_guc_pc *pc, u32 *freq) ...@@ -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)); XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
out: out:
mutex_unlock(&pc->freq_lock); mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret; return ret;
} }
...@@ -528,7 +514,6 @@ int xe_guc_pc_set_min_freq(struct xe_guc_pc *pc, u32 freq) ...@@ -528,7 +514,6 @@ int xe_guc_pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
{ {
int ret; int ret;
xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock); mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) { if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */ /* Might be in the middle of a gt reset */
...@@ -544,8 +529,6 @@ int xe_guc_pc_set_min_freq(struct xe_guc_pc *pc, u32 freq) ...@@ -544,8 +529,6 @@ int xe_guc_pc_set_min_freq(struct xe_guc_pc *pc, u32 freq)
out: out:
mutex_unlock(&pc->freq_lock); mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret; return ret;
} }
...@@ -561,7 +544,6 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq) ...@@ -561,7 +544,6 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq)
{ {
int ret; int ret;
xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock); mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) { if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */ /* Might be in the middle of a gt reset */
...@@ -577,7 +559,6 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq) ...@@ -577,7 +559,6 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq)
out: out:
mutex_unlock(&pc->freq_lock); mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret; return ret;
} }
...@@ -594,7 +575,6 @@ int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq) ...@@ -594,7 +575,6 @@ int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
{ {
int ret; int ret;
xe_device_mem_access_get(pc_to_xe(pc));
mutex_lock(&pc->freq_lock); mutex_lock(&pc->freq_lock);
if (!pc->freq_ready) { if (!pc->freq_ready) {
/* Might be in the middle of a gt reset */ /* Might be in the middle of a gt reset */
...@@ -610,7 +590,6 @@ int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq) ...@@ -610,7 +590,6 @@ int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq)
out: out:
mutex_unlock(&pc->freq_lock); mutex_unlock(&pc->freq_lock);
xe_device_mem_access_put(pc_to_xe(pc));
return ret; return ret;
} }
...@@ -623,8 +602,6 @@ enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc) ...@@ -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); struct xe_gt *gt = pc_to_gt(pc);
u32 reg, gt_c_state; u32 reg, gt_c_state;
xe_device_mem_access_get(gt_to_xe(gt));
if (GRAPHICS_VERx100(gt_to_xe(gt)) >= 1270) { if (GRAPHICS_VERx100(gt_to_xe(gt)) >= 1270) {
reg = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1); reg = xe_mmio_read32(gt, MTL_MIRROR_TARGET_WP1);
gt_c_state = REG_FIELD_GET(MTL_CC_MASK, reg); gt_c_state = REG_FIELD_GET(MTL_CC_MASK, reg);
...@@ -633,8 +610,6 @@ enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc) ...@@ -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); gt_c_state = REG_FIELD_GET(RCN_MASK, reg);
} }
xe_device_mem_access_put(gt_to_xe(gt));
switch (gt_c_state) { switch (gt_c_state) {
case GT_C6: case GT_C6:
return GT_IDLE_C6; return GT_IDLE_C6;
...@@ -654,9 +629,7 @@ u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc) ...@@ -654,9 +629,7 @@ u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc)
struct xe_gt *gt = pc_to_gt(pc); struct xe_gt *gt = pc_to_gt(pc);
u32 reg; u32 reg;
xe_device_mem_access_get(gt_to_xe(gt));
reg = xe_mmio_read32(gt, GT_GFX_RC6); reg = xe_mmio_read32(gt, GT_GFX_RC6);
xe_device_mem_access_put(gt_to_xe(gt));
return reg; return reg;
} }
...@@ -670,9 +643,7 @@ u64 xe_guc_pc_mc6_residency(struct xe_guc_pc *pc) ...@@ -670,9 +643,7 @@ u64 xe_guc_pc_mc6_residency(struct xe_guc_pc *pc)
struct xe_gt *gt = pc_to_gt(pc); struct xe_gt *gt = pc_to_gt(pc);
u64 reg; u64 reg;
xe_device_mem_access_get(gt_to_xe(gt));
reg = xe_mmio_read32(gt, MTL_MEDIA_MC6); reg = xe_mmio_read32(gt, MTL_MEDIA_MC6);
xe_device_mem_access_put(gt_to_xe(gt));
return reg; return reg;
} }
...@@ -801,23 +772,19 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc) ...@@ -801,23 +772,19 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc)
if (xe->info.skip_guc_pc) if (xe->info.skip_guc_pc)
return 0; return 0;
xe_device_mem_access_get(pc_to_xe(pc));
ret = pc_action_setup_gucrc(pc, XE_GUCRC_HOST_CONTROL); ret = pc_action_setup_gucrc(pc, XE_GUCRC_HOST_CONTROL);
if (ret) if (ret)
goto out; return ret;
ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL); ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
if (ret) if (ret)
goto out; return ret;
xe_gt_idle_disable_c6(gt); xe_gt_idle_disable_c6(gt);
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
out: return 0;
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
} }
static void pc_init_pcode_freq(struct xe_guc_pc *pc) static void pc_init_pcode_freq(struct xe_guc_pc *pc)
...@@ -870,11 +837,9 @@ int xe_guc_pc_start(struct xe_guc_pc *pc) ...@@ -870,11 +837,9 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
xe_gt_assert(gt, xe_device_uc_enabled(xe)); 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); ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
if (ret) if (ret)
goto out_fail_force_wake; return ret;
if (xe->info.skip_guc_pc) { if (xe->info.skip_guc_pc) {
if (xe->info.platform != XE_PVC) if (xe->info.platform != XE_PVC)
...@@ -914,8 +879,6 @@ int xe_guc_pc_start(struct xe_guc_pc *pc) ...@@ -914,8 +879,6 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
out: out:
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL)); 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; return ret;
} }
...@@ -928,12 +891,9 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc) ...@@ -928,12 +891,9 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc)
struct xe_device *xe = pc_to_xe(pc); struct xe_device *xe = pc_to_xe(pc);
int ret; int ret;
xe_device_mem_access_get(pc_to_xe(pc));
if (xe->info.skip_guc_pc) { if (xe->info.skip_guc_pc) {
xe_gt_idle_disable_c6(pc_to_gt(pc)); xe_gt_idle_disable_c6(pc_to_gt(pc));
ret = 0; return 0;
goto out;
} }
mutex_lock(&pc->freq_lock); mutex_lock(&pc->freq_lock);
...@@ -942,16 +902,14 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc) ...@@ -942,16 +902,14 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc)
ret = pc_action_shutdown(pc); ret = pc_action_shutdown(pc);
if (ret) if (ret)
goto out; return ret;
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_NOT_RUNNING)) { if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_NOT_RUNNING)) {
drm_err(&pc_to_xe(pc)->drm, "GuC PC Shutdown failed\n"); drm_err(&pc_to_xe(pc)->drm, "GuC PC Shutdown failed\n");
ret = -EIO; return -EIO;
} }
out: return 0;
xe_device_mem_access_put(pc_to_xe(pc));
return ret;
} }
/** /**
...@@ -965,9 +923,7 @@ static void xe_guc_pc_fini(struct drm_device *drm, void *arg) ...@@ -965,9 +923,7 @@ static void xe_guc_pc_fini(struct drm_device *drm, void *arg)
struct xe_device *xe = pc_to_xe(pc); struct xe_device *xe = pc_to_xe(pc);
if (xe->info.skip_guc_pc) { if (xe->info.skip_guc_pc) {
xe_device_mem_access_get(xe);
xe_gt_idle_disable_c6(pc_to_gt(pc)); xe_gt_idle_disable_c6(pc_to_gt(pc));
xe_device_mem_access_put(xe);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment