Lines Matching refs:hive

215 	struct amdgpu_hive_info *hive = container_of(  in amdgpu_xgmi_show_attrs()  local
219 return snprintf(buf, PAGE_SIZE, "%llu\n", hive->hive_id); in amdgpu_xgmi_show_attrs()
226 struct amdgpu_hive_info *hive = container_of( in amdgpu_xgmi_hive_release() local
229 mutex_destroy(&hive->hive_lock); in amdgpu_xgmi_hive_release()
230 kfree(hive); in amdgpu_xgmi_hive_release()
287 struct amdgpu_hive_info *hive) in amdgpu_xgmi_sysfs_add_dev_info() argument
306 if (hive->kobj.parent != (&adev->dev->kobj)) { in amdgpu_xgmi_sysfs_add_dev_info()
307 ret = sysfs_create_link(&adev->dev->kobj, &hive->kobj, in amdgpu_xgmi_sysfs_add_dev_info()
315 sprintf(node, "node%d", atomic_read(&hive->number_devices)); in amdgpu_xgmi_sysfs_add_dev_info()
317 ret = sysfs_create_link(&hive->kobj, &adev->dev->kobj, node); in amdgpu_xgmi_sysfs_add_dev_info()
337 struct amdgpu_hive_info *hive) in amdgpu_xgmi_sysfs_rem_dev_info() argument
345 if (hive->kobj.parent != (&adev->dev->kobj)) in amdgpu_xgmi_sysfs_rem_dev_info()
348 sprintf(node, "node%d", atomic_read(&hive->number_devices)); in amdgpu_xgmi_sysfs_rem_dev_info()
349 sysfs_remove_link(&hive->kobj, node); in amdgpu_xgmi_sysfs_rem_dev_info()
357 struct amdgpu_hive_info *hive = NULL; in amdgpu_get_xgmi_hive() local
363 if (adev->hive) { in amdgpu_get_xgmi_hive()
364 kobject_get(&adev->hive->kobj); in amdgpu_get_xgmi_hive()
365 return adev->hive; in amdgpu_get_xgmi_hive()
370 list_for_each_entry(hive, &xgmi_hive_list, node) { in amdgpu_get_xgmi_hive()
371 if (hive->hive_id == adev->gmc.xgmi.hive_id) in amdgpu_get_xgmi_hive()
375 hive = kzalloc(sizeof(*hive), GFP_KERNEL); in amdgpu_get_xgmi_hive()
376 if (!hive) { in amdgpu_get_xgmi_hive()
378 hive = NULL; in amdgpu_get_xgmi_hive()
383 ret = kobject_init_and_add(&hive->kobj, in amdgpu_get_xgmi_hive()
389 kobject_put(&hive->kobj); in amdgpu_get_xgmi_hive()
390 kfree(hive); in amdgpu_get_xgmi_hive()
391 hive = NULL; in amdgpu_get_xgmi_hive()
395 hive->hive_id = adev->gmc.xgmi.hive_id; in amdgpu_get_xgmi_hive()
396 INIT_LIST_HEAD(&hive->device_list); in amdgpu_get_xgmi_hive()
397 INIT_LIST_HEAD(&hive->node); in amdgpu_get_xgmi_hive()
398 mutex_init(&hive->hive_lock); in amdgpu_get_xgmi_hive()
399 atomic_set(&hive->in_reset, 0); in amdgpu_get_xgmi_hive()
400 atomic_set(&hive->number_devices, 0); in amdgpu_get_xgmi_hive()
401 task_barrier_init(&hive->tb); in amdgpu_get_xgmi_hive()
402 hive->pstate = AMDGPU_XGMI_PSTATE_UNKNOWN; in amdgpu_get_xgmi_hive()
403 hive->hi_req_gpu = NULL; in amdgpu_get_xgmi_hive()
408 hive->hi_req_count = AMDGPU_MAX_XGMI_DEVICE_PER_HIVE; in amdgpu_get_xgmi_hive()
409 list_add_tail(&hive->node, &xgmi_hive_list); in amdgpu_get_xgmi_hive()
412 if (hive) in amdgpu_get_xgmi_hive()
413 kobject_get(&hive->kobj); in amdgpu_get_xgmi_hive()
415 return hive; in amdgpu_get_xgmi_hive()
418 void amdgpu_put_xgmi_hive(struct amdgpu_hive_info *hive) in amdgpu_put_xgmi_hive() argument
420 if (hive) in amdgpu_put_xgmi_hive()
421 kobject_put(&hive->kobj); in amdgpu_put_xgmi_hive()
427 struct amdgpu_hive_info *hive; in amdgpu_xgmi_set_pstate() local
432 hive = amdgpu_get_xgmi_hive(adev); in amdgpu_xgmi_set_pstate()
433 if (!hive) in amdgpu_xgmi_set_pstate()
436 request_adev = hive->hi_req_gpu ? hive->hi_req_gpu : adev; in amdgpu_xgmi_set_pstate()
437 init_low = hive->pstate == AMDGPU_XGMI_PSTATE_UNKNOWN; in amdgpu_xgmi_set_pstate()
438 amdgpu_put_xgmi_hive(hive); in amdgpu_xgmi_set_pstate()
442 if (!hive || adev->asic_type != CHIP_VEGA20) in amdgpu_xgmi_set_pstate()
445 mutex_lock(&hive->hive_lock); in amdgpu_xgmi_set_pstate()
448 hive->hi_req_count++; in amdgpu_xgmi_set_pstate()
450 hive->hi_req_count--; in amdgpu_xgmi_set_pstate()
456 if (hive->pstate == pstate || in amdgpu_xgmi_set_pstate()
457 (!is_hi_req && hive->hi_req_count && !init_low)) in amdgpu_xgmi_set_pstate()
472 hive->pstate = hive->hi_req_count ? in amdgpu_xgmi_set_pstate()
473 hive->pstate : AMDGPU_XGMI_PSTATE_MIN; in amdgpu_xgmi_set_pstate()
475 hive->pstate = pstate; in amdgpu_xgmi_set_pstate()
476 hive->hi_req_gpu = pstate != AMDGPU_XGMI_PSTATE_MIN ? in amdgpu_xgmi_set_pstate()
480 mutex_unlock(&hive->hive_lock); in amdgpu_xgmi_set_pstate()
484 int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_device *adev) in amdgpu_xgmi_update_topology() argument
490 atomic_read(&hive->number_devices), in amdgpu_xgmi_update_topology()
539 static int amdgpu_xgmi_initialize_hive_get_data_partition(struct amdgpu_hive_info *hive, in amdgpu_xgmi_initialize_hive_get_data_partition() argument
545 list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { in amdgpu_xgmi_initialize_hive_get_data_partition()
562 struct amdgpu_hive_info *hive; in amdgpu_xgmi_add_device() local
598 hive = amdgpu_get_xgmi_hive(adev); in amdgpu_xgmi_add_device()
599 if (!hive) { in amdgpu_xgmi_add_device()
606 mutex_lock(&hive->hive_lock); in amdgpu_xgmi_add_device()
610 list_add_tail(&adev->gmc.xgmi.head, &hive->device_list); in amdgpu_xgmi_add_device()
611 list_for_each_entry(entry, &hive->device_list, head) in amdgpu_xgmi_add_device()
614 atomic_set(&hive->number_devices, count); in amdgpu_xgmi_add_device()
616 task_barrier_add_task(&hive->tb); in amdgpu_xgmi_add_device()
620 list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { in amdgpu_xgmi_add_device()
628 ret = amdgpu_xgmi_update_topology(hive, tmp_adev); in amdgpu_xgmi_add_device()
634 list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { in amdgpu_xgmi_add_device()
651 ret = amdgpu_xgmi_initialize_hive_get_data_partition(hive, true); in amdgpu_xgmi_add_device()
656 list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) { in amdgpu_xgmi_add_device()
669 ret = amdgpu_xgmi_initialize_hive_get_data_partition(hive, false); in amdgpu_xgmi_add_device()
677 ret = amdgpu_xgmi_sysfs_add_dev_info(adev, hive); in amdgpu_xgmi_add_device()
680 mutex_unlock(&hive->hive_lock); in amdgpu_xgmi_add_device()
683 adev->hive = hive; in amdgpu_xgmi_add_device()
687 amdgpu_put_xgmi_hive(hive); in amdgpu_xgmi_add_device()
698 struct amdgpu_hive_info *hive = adev->hive; in amdgpu_xgmi_remove_device() local
703 if (!hive) in amdgpu_xgmi_remove_device()
706 mutex_lock(&hive->hive_lock); in amdgpu_xgmi_remove_device()
707 task_barrier_rem_task(&hive->tb); in amdgpu_xgmi_remove_device()
708 amdgpu_xgmi_sysfs_rem_dev_info(adev, hive); in amdgpu_xgmi_remove_device()
709 if (hive->hi_req_gpu == adev) in amdgpu_xgmi_remove_device()
710 hive->hi_req_gpu = NULL; in amdgpu_xgmi_remove_device()
712 mutex_unlock(&hive->hive_lock); in amdgpu_xgmi_remove_device()
714 amdgpu_put_xgmi_hive(hive); in amdgpu_xgmi_remove_device()
715 adev->hive = NULL; in amdgpu_xgmi_remove_device()
717 if (atomic_dec_return(&hive->number_devices) == 0) { in amdgpu_xgmi_remove_device()
720 list_del(&hive->node); in amdgpu_xgmi_remove_device()
723 amdgpu_put_xgmi_hive(hive); in amdgpu_xgmi_remove_device()