Commit 7eea2580 authored by Michal Wajdeczko's avatar Michal Wajdeczko

drm/xe/guc: Add pc_to_ct() helper

We are converting xe_guc_pc to xe_guc_ct few times already.
Add simple helper function to avoid code duplication.
While at it, simplify other helper functions and fix order
of local variables to match the guideline.
Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Reviewed-by: default avatarVinay Belgaumkar <vinay.belgaumkar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240609181931.1724-3-michal.wajdeczko@intel.com
parent 3a3fc10c
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "xe_gt_idle.h" #include "xe_gt_idle.h"
#include "xe_gt_sysfs.h" #include "xe_gt_sysfs.h"
#include "xe_gt_types.h" #include "xe_gt_types.h"
#include "xe_guc.h"
#include "xe_guc_ct.h" #include "xe_guc_ct.h"
#include "xe_map.h" #include "xe_map.h"
#include "xe_mmio.h" #include "xe_mmio.h"
...@@ -66,29 +67,27 @@ ...@@ -66,29 +67,27 @@
* *
*/ */
static struct xe_guc * static struct xe_guc *pc_to_guc(struct xe_guc_pc *pc)
pc_to_guc(struct xe_guc_pc *pc)
{ {
return container_of(pc, struct xe_guc, pc); return container_of(pc, struct xe_guc, pc);
} }
static struct xe_device * static struct xe_guc_ct *pc_to_ct(struct xe_guc_pc *pc)
pc_to_xe(struct xe_guc_pc *pc)
{ {
struct xe_guc *guc = pc_to_guc(pc); return &pc_to_guc(pc)->ct;
struct xe_gt *gt = container_of(guc, struct xe_gt, uc.guc); }
return gt_to_xe(gt); static struct xe_gt *pc_to_gt(struct xe_guc_pc *pc)
{
return guc_to_gt(pc_to_guc(pc));
} }
static struct xe_gt * static struct xe_device *pc_to_xe(struct xe_guc_pc *pc)
pc_to_gt(struct xe_guc_pc *pc)
{ {
return container_of(pc, struct xe_gt, uc.guc.pc); return guc_to_xe(pc_to_guc(pc));
} }
static struct iosys_map * static struct iosys_map *pc_to_maps(struct xe_guc_pc *pc)
pc_to_maps(struct xe_guc_pc *pc)
{ {
return &pc->bo->vmap; return &pc->bo->vmap;
} }
...@@ -129,14 +128,14 @@ static int wait_for_pc_state(struct xe_guc_pc *pc, ...@@ -129,14 +128,14 @@ static int wait_for_pc_state(struct xe_guc_pc *pc,
static int pc_action_reset(struct xe_guc_pc *pc) static int pc_action_reset(struct xe_guc_pc *pc)
{ {
struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; struct xe_guc_ct *ct = pc_to_ct(pc);
int ret;
u32 action[] = { u32 action[] = {
GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST, GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST,
SLPC_EVENT(SLPC_EVENT_RESET, 2), SLPC_EVENT(SLPC_EVENT_RESET, 2),
xe_bo_ggtt_addr(pc->bo), xe_bo_ggtt_addr(pc->bo),
0, 0,
}; };
int ret;
ret = xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0); ret = xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0);
if (ret) if (ret)
...@@ -147,14 +146,14 @@ static int pc_action_reset(struct xe_guc_pc *pc) ...@@ -147,14 +146,14 @@ static int pc_action_reset(struct xe_guc_pc *pc)
static int pc_action_query_task_state(struct xe_guc_pc *pc) static int pc_action_query_task_state(struct xe_guc_pc *pc)
{ {
struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; struct xe_guc_ct *ct = pc_to_ct(pc);
int ret;
u32 action[] = { u32 action[] = {
GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST, GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST,
SLPC_EVENT(SLPC_EVENT_QUERY_TASK_STATE, 2), SLPC_EVENT(SLPC_EVENT_QUERY_TASK_STATE, 2),
xe_bo_ggtt_addr(pc->bo), xe_bo_ggtt_addr(pc->bo),
0, 0,
}; };
int ret;
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING)) if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING))
return -EAGAIN; return -EAGAIN;
...@@ -170,14 +169,14 @@ static int pc_action_query_task_state(struct xe_guc_pc *pc) ...@@ -170,14 +169,14 @@ static int pc_action_query_task_state(struct xe_guc_pc *pc)
static int pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value) static int pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value)
{ {
struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; struct xe_guc_ct *ct = pc_to_ct(pc);
int ret;
u32 action[] = { u32 action[] = {
GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST, GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST,
SLPC_EVENT(SLPC_EVENT_PARAMETER_SET, 2), SLPC_EVENT(SLPC_EVENT_PARAMETER_SET, 2),
id, id,
value, value,
}; };
int ret;
if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING)) if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING))
return -EAGAIN; return -EAGAIN;
...@@ -192,7 +191,7 @@ static int pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value) ...@@ -192,7 +191,7 @@ static int pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value)
static int pc_action_setup_gucrc(struct xe_guc_pc *pc, u32 mode) static int pc_action_setup_gucrc(struct xe_guc_pc *pc, u32 mode)
{ {
struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; struct xe_guc_ct *ct = pc_to_ct(pc);
u32 action[] = { u32 action[] = {
GUC_ACTION_HOST2GUC_SETUP_PC_GUCRC, GUC_ACTION_HOST2GUC_SETUP_PC_GUCRC,
mode, mode,
......
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