Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Reviewed-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240609181931.1724-3-michal.wajdeczko@intel.com

+19 -20
+19 -20
drivers/gpu/drm/xe/xe_guc_pc.c
··· 19 19 #include "xe_gt_idle.h" 20 20 #include "xe_gt_sysfs.h" 21 21 #include "xe_gt_types.h" 22 + #include "xe_guc.h" 22 23 #include "xe_guc_ct.h" 23 24 #include "xe_map.h" 24 25 #include "xe_mmio.h" ··· 67 66 * 68 67 */ 69 68 70 - static struct xe_guc * 71 - pc_to_guc(struct xe_guc_pc *pc) 69 + static struct xe_guc *pc_to_guc(struct xe_guc_pc *pc) 72 70 { 73 71 return container_of(pc, struct xe_guc, pc); 74 72 } 75 73 76 - static struct xe_device * 77 - pc_to_xe(struct xe_guc_pc *pc) 74 + static struct xe_guc_ct *pc_to_ct(struct xe_guc_pc *pc) 78 75 { 79 - struct xe_guc *guc = pc_to_guc(pc); 80 - struct xe_gt *gt = container_of(guc, struct xe_gt, uc.guc); 81 - 82 - return gt_to_xe(gt); 76 + return &pc_to_guc(pc)->ct; 83 77 } 84 78 85 - static struct xe_gt * 86 - pc_to_gt(struct xe_guc_pc *pc) 79 + static struct xe_gt *pc_to_gt(struct xe_guc_pc *pc) 87 80 { 88 - return container_of(pc, struct xe_gt, uc.guc.pc); 81 + return guc_to_gt(pc_to_guc(pc)); 89 82 } 90 83 91 - static struct iosys_map * 92 - pc_to_maps(struct xe_guc_pc *pc) 84 + static struct xe_device *pc_to_xe(struct xe_guc_pc *pc) 85 + { 86 + return guc_to_xe(pc_to_guc(pc)); 87 + } 88 + 89 + static struct iosys_map *pc_to_maps(struct xe_guc_pc *pc) 93 90 { 94 91 return &pc->bo->vmap; 95 92 } ··· 128 129 129 130 static int pc_action_reset(struct xe_guc_pc *pc) 130 131 { 131 - struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; 132 - int ret; 132 + struct xe_guc_ct *ct = pc_to_ct(pc); 133 133 u32 action[] = { 134 134 GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST, 135 135 SLPC_EVENT(SLPC_EVENT_RESET, 2), 136 136 xe_bo_ggtt_addr(pc->bo), 137 137 0, 138 138 }; 139 + int ret; 139 140 140 141 ret = xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0); 141 142 if (ret) ··· 146 147 147 148 static int pc_action_query_task_state(struct xe_guc_pc *pc) 148 149 { 149 - struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; 150 - int ret; 150 + struct xe_guc_ct *ct = pc_to_ct(pc); 151 151 u32 action[] = { 152 152 GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST, 153 153 SLPC_EVENT(SLPC_EVENT_QUERY_TASK_STATE, 2), 154 154 xe_bo_ggtt_addr(pc->bo), 155 155 0, 156 156 }; 157 + int ret; 157 158 158 159 if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING)) 159 160 return -EAGAIN; ··· 169 170 170 171 static int pc_action_set_param(struct xe_guc_pc *pc, u8 id, u32 value) 171 172 { 172 - struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; 173 - int ret; 173 + struct xe_guc_ct *ct = pc_to_ct(pc); 174 174 u32 action[] = { 175 175 GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST, 176 176 SLPC_EVENT(SLPC_EVENT_PARAMETER_SET, 2), 177 177 id, 178 178 value, 179 179 }; 180 + int ret; 180 181 181 182 if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING)) 182 183 return -EAGAIN; ··· 191 192 192 193 static int pc_action_setup_gucrc(struct xe_guc_pc *pc, u32 mode) 193 194 { 194 - struct xe_guc_ct *ct = &pc_to_guc(pc)->ct; 195 + struct xe_guc_ct *ct = pc_to_ct(pc); 195 196 u32 action[] = { 196 197 GUC_ACTION_HOST2GUC_SETUP_PC_GUCRC, 197 198 mode,