Lines Matching refs:xcp_mgr

30 static int __amdgpu_xcp_run(struct amdgpu_xcp_mgr *xcp_mgr,  in __amdgpu_xcp_run()  argument
57 ret = run_func(xcp_mgr->adev, xcp_ip->inst_mask); in __amdgpu_xcp_run()
62 static int amdgpu_xcp_run_transition(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id, in amdgpu_xcp_run_transition() argument
69 if (xcp_id >= MAX_XCP || !xcp_mgr->xcp[xcp_id].valid) in amdgpu_xcp_run_transition()
72 xcp = &xcp_mgr->xcp[xcp_id]; in amdgpu_xcp_run_transition()
75 ret = __amdgpu_xcp_run(xcp_mgr, xcp_ip, state); in amdgpu_xcp_run_transition()
83 int amdgpu_xcp_prepare_suspend(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id) in amdgpu_xcp_prepare_suspend() argument
85 return amdgpu_xcp_run_transition(xcp_mgr, xcp_id, in amdgpu_xcp_prepare_suspend()
89 int amdgpu_xcp_suspend(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id) in amdgpu_xcp_suspend() argument
91 return amdgpu_xcp_run_transition(xcp_mgr, xcp_id, AMDGPU_XCP_SUSPEND); in amdgpu_xcp_suspend()
94 int amdgpu_xcp_prepare_resume(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id) in amdgpu_xcp_prepare_resume() argument
96 return amdgpu_xcp_run_transition(xcp_mgr, xcp_id, in amdgpu_xcp_prepare_resume()
100 int amdgpu_xcp_resume(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id) in amdgpu_xcp_resume() argument
102 return amdgpu_xcp_run_transition(xcp_mgr, xcp_id, AMDGPU_XCP_RESUME); in amdgpu_xcp_resume()
105 static void __amdgpu_xcp_add_block(struct amdgpu_xcp_mgr *xcp_mgr, int xcp_id, in __amdgpu_xcp_add_block() argument
113 xcp = &xcp_mgr->xcp[xcp_id]; in __amdgpu_xcp_add_block()
120 int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode) in amdgpu_xcp_init() argument
122 struct amdgpu_device *adev = xcp_mgr->adev; in amdgpu_xcp_init()
130 xcp_mgr->mode = mode; in amdgpu_xcp_init()
133 xcp_mgr->xcp[i].valid = false; in amdgpu_xcp_init()
136 xcp_mgr->num_xcp_per_mem_partition = num_xcps / xcp_mgr->adev->gmc.num_mem_partitions; in amdgpu_xcp_init()
140 ret = xcp_mgr->funcs->get_ip_details(xcp_mgr, i, j, in amdgpu_xcp_init()
145 __amdgpu_xcp_add_block(xcp_mgr, i, &ip); in amdgpu_xcp_init()
148 xcp_mgr->xcp[i].id = i; in amdgpu_xcp_init()
150 if (xcp_mgr->funcs->get_xcp_mem_id) { in amdgpu_xcp_init()
151 ret = xcp_mgr->funcs->get_xcp_mem_id( in amdgpu_xcp_init()
152 xcp_mgr, &xcp_mgr->xcp[i], &mem_id); in amdgpu_xcp_init()
156 xcp_mgr->xcp[i].mem_id = mem_id; in amdgpu_xcp_init()
160 xcp_mgr->num_xcps = num_xcps; in amdgpu_xcp_init()
166 static int __amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, in __amdgpu_xcp_switch_partition_mode() argument
171 if (!xcp_mgr->funcs || !xcp_mgr->funcs->switch_partition_mode) in __amdgpu_xcp_switch_partition_mode()
174 mutex_lock(&xcp_mgr->xcp_lock); in __amdgpu_xcp_switch_partition_mode()
176 curr_mode = xcp_mgr->mode; in __amdgpu_xcp_switch_partition_mode()
178 xcp_mgr->mode = AMDGPU_XCP_MODE_TRANS; in __amdgpu_xcp_switch_partition_mode()
180 ret = xcp_mgr->funcs->switch_partition_mode(xcp_mgr, mode, &num_xcps); in __amdgpu_xcp_switch_partition_mode()
184 if (xcp_mgr->funcs->query_partition_mode) in __amdgpu_xcp_switch_partition_mode()
185 xcp_mgr->mode = amdgpu_xcp_query_partition_mode( in __amdgpu_xcp_switch_partition_mode()
186 xcp_mgr, AMDGPU_XCP_FL_LOCKED); in __amdgpu_xcp_switch_partition_mode()
188 xcp_mgr->mode = curr_mode; in __amdgpu_xcp_switch_partition_mode()
194 mutex_unlock(&xcp_mgr->xcp_lock); in __amdgpu_xcp_switch_partition_mode()
199 int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode) in amdgpu_xcp_switch_partition_mode() argument
201 if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE) in amdgpu_xcp_switch_partition_mode()
204 if (xcp_mgr->mode == mode) in amdgpu_xcp_switch_partition_mode()
207 return __amdgpu_xcp_switch_partition_mode(xcp_mgr, mode); in amdgpu_xcp_switch_partition_mode()
210 int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr) in amdgpu_xcp_restore_partition_mode() argument
212 if (!xcp_mgr || xcp_mgr->mode == AMDGPU_XCP_MODE_NONE) in amdgpu_xcp_restore_partition_mode()
215 return __amdgpu_xcp_switch_partition_mode(xcp_mgr, xcp_mgr->mode); in amdgpu_xcp_restore_partition_mode()
218 int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags) in amdgpu_xcp_query_partition_mode() argument
222 if (!amdgpu_sriov_vf(xcp_mgr->adev) && in amdgpu_xcp_query_partition_mode()
223 xcp_mgr->mode == AMDGPU_XCP_MODE_NONE) in amdgpu_xcp_query_partition_mode()
224 return xcp_mgr->mode; in amdgpu_xcp_query_partition_mode()
226 if (!xcp_mgr->funcs || !xcp_mgr->funcs->query_partition_mode) in amdgpu_xcp_query_partition_mode()
227 return xcp_mgr->mode; in amdgpu_xcp_query_partition_mode()
230 mutex_lock(&xcp_mgr->xcp_lock); in amdgpu_xcp_query_partition_mode()
231 mode = xcp_mgr->funcs->query_partition_mode(xcp_mgr); in amdgpu_xcp_query_partition_mode()
234 if (amdgpu_sriov_vf(xcp_mgr->adev) && in amdgpu_xcp_query_partition_mode()
235 xcp_mgr->mode == AMDGPU_XCP_MODE_NONE) in amdgpu_xcp_query_partition_mode()
236 xcp_mgr->mode = mode; in amdgpu_xcp_query_partition_mode()
238 if (xcp_mgr->mode != AMDGPU_XCP_MODE_TRANS && mode != xcp_mgr->mode) in amdgpu_xcp_query_partition_mode()
240 xcp_mgr->adev->dev, in amdgpu_xcp_query_partition_mode()
242 xcp_mgr->mode, mode); in amdgpu_xcp_query_partition_mode()
245 mutex_unlock(&xcp_mgr->xcp_lock); in amdgpu_xcp_query_partition_mode()
259 adev->xcp_mgr->xcp->ddev = ddev; in amdgpu_xcp_dev_alloc()
272 adev->xcp_mgr->xcp[i].rdev = p_ddev->render->dev; in amdgpu_xcp_dev_alloc()
273 adev->xcp_mgr->xcp[i].pdev = p_ddev->primary->dev; in amdgpu_xcp_dev_alloc()
274 adev->xcp_mgr->xcp[i].driver = (struct drm_driver *)p_ddev->driver; in amdgpu_xcp_dev_alloc()
275 adev->xcp_mgr->xcp[i].vma_offset_manager = p_ddev->vma_offset_manager; in amdgpu_xcp_dev_alloc()
280 adev->xcp_mgr->xcp[i].ddev = p_ddev; in amdgpu_xcp_dev_alloc()
290 struct amdgpu_xcp_mgr *xcp_mgr; in amdgpu_xcp_mgr_init() local
295 xcp_mgr = kzalloc(sizeof(*xcp_mgr), GFP_KERNEL); in amdgpu_xcp_mgr_init()
297 if (!xcp_mgr) in amdgpu_xcp_mgr_init()
300 xcp_mgr->adev = adev; in amdgpu_xcp_mgr_init()
301 xcp_mgr->funcs = xcp_funcs; in amdgpu_xcp_mgr_init()
302 xcp_mgr->mode = init_mode; in amdgpu_xcp_mgr_init()
303 mutex_init(&xcp_mgr->xcp_lock); in amdgpu_xcp_mgr_init()
306 amdgpu_xcp_init(xcp_mgr, init_num_xcps, init_mode); in amdgpu_xcp_mgr_init()
308 adev->xcp_mgr = xcp_mgr; in amdgpu_xcp_mgr_init()
313 int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr, in amdgpu_xcp_get_partition() argument
322 for (i = 0; i < xcp_mgr->num_xcps; ++i) { in amdgpu_xcp_get_partition()
323 xcp = &xcp_mgr->xcp[i]; in amdgpu_xcp_get_partition()
352 if (!adev->xcp_mgr) in amdgpu_xcp_dev_register()
356 if (!adev->xcp_mgr->xcp[i].ddev) in amdgpu_xcp_dev_register()
359 ret = drm_dev_register(adev->xcp_mgr->xcp[i].ddev, ent->driver_data); in amdgpu_xcp_dev_register()
372 if (!adev->xcp_mgr) in amdgpu_xcp_dev_unplug()
376 if (!adev->xcp_mgr->xcp[i].ddev) in amdgpu_xcp_dev_unplug()
379 p_ddev = adev->xcp_mgr->xcp[i].ddev; in amdgpu_xcp_dev_unplug()
381 p_ddev->render->dev = adev->xcp_mgr->xcp[i].rdev; in amdgpu_xcp_dev_unplug()
382 p_ddev->primary->dev = adev->xcp_mgr->xcp[i].pdev; in amdgpu_xcp_dev_unplug()
383 p_ddev->driver = adev->xcp_mgr->xcp[i].driver; in amdgpu_xcp_dev_unplug()
384 p_ddev->vma_offset_manager = adev->xcp_mgr->xcp[i].vma_offset_manager; in amdgpu_xcp_dev_unplug()
394 if (!adev->xcp_mgr) in amdgpu_xcp_open_device()
399 if (!adev->xcp_mgr->xcp[i].ddev) in amdgpu_xcp_open_device()
402 if (file_priv->minor == adev->xcp_mgr->xcp[i].ddev->render) { in amdgpu_xcp_open_device()
403 if (adev->xcp_mgr->xcp[i].valid == FALSE) { in amdgpu_xcp_open_device()
416 adev->xcp_mgr->xcp[fpriv->xcp_id].mem_id; in amdgpu_xcp_open_device()
426 if (!adev->xcp_mgr) in amdgpu_xcp_release_sched()
432 atomic_dec(&adev->xcp_mgr->xcp[ring->xcp_id].ref_cnt); in amdgpu_xcp_release_sched()
521 static int amdgpu_xcp_get_res_info(struct amdgpu_xcp_mgr *xcp_mgr, in amdgpu_xcp_get_res_info() argument
525 if (xcp_mgr->funcs && xcp_mgr->funcs->get_xcp_res_info) in amdgpu_xcp_get_res_info()
526 return xcp_mgr->funcs->get_xcp_res_info(xcp_mgr, mode, xcp_cfg); in amdgpu_xcp_get_res_info()
536 struct amdgpu_xcp_mgr *xcp_mgr = xcp_cfg->xcp_mgr; in supported_xcp_configs_show() local
540 if (!xcp_mgr || !xcp_mgr->supp_xcp_modes) in supported_xcp_configs_show()
543 for_each_inst(mode, xcp_mgr->supp_xcp_modes) { in supported_xcp_configs_show()
602 r = amdgpu_xcp_get_res_info(xcp_cfg->xcp_mgr, mode, xcp_cfg); in xcp_config_store()
644 if (!adev->xcp_mgr) in amdgpu_xcp_cfg_sysfs_init()
650 xcp_cfg->xcp_mgr = adev->xcp_mgr; in amdgpu_xcp_cfg_sysfs_init()
669 mode = (xcp_cfg->xcp_mgr->mode == in amdgpu_xcp_cfg_sysfs_init()
672 xcp_cfg->xcp_mgr->mode; in amdgpu_xcp_cfg_sysfs_init()
673 r = amdgpu_xcp_get_res_info(xcp_cfg->xcp_mgr, mode, xcp_cfg); in amdgpu_xcp_cfg_sysfs_init()
692 adev->xcp_mgr->xcp_cfg = xcp_cfg; in amdgpu_xcp_cfg_sysfs_init()
712 if (!adev->xcp_mgr) in amdgpu_xcp_cfg_sysfs_fini()
715 xcp_cfg = adev->xcp_mgr->xcp_cfg; in amdgpu_xcp_cfg_sysfs_fini()