0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef __AMDGPU_XGMI_H__
0023 #define __AMDGPU_XGMI_H__
0024
0025 #include <drm/task_barrier.h>
0026 #include "amdgpu_psp.h"
0027 #include "amdgpu_ras.h"
0028
0029 struct amdgpu_hive_info {
0030 struct kobject kobj;
0031 uint64_t hive_id;
0032 struct list_head device_list;
0033 struct list_head node;
0034 atomic_t number_devices;
0035 struct mutex hive_lock;
0036 int hi_req_count;
0037 struct amdgpu_device *hi_req_gpu;
0038 struct task_barrier tb;
0039 enum {
0040 AMDGPU_XGMI_PSTATE_MIN,
0041 AMDGPU_XGMI_PSTATE_MAX_VEGA20,
0042 AMDGPU_XGMI_PSTATE_UNKNOWN
0043 } pstate;
0044
0045 struct amdgpu_reset_domain *reset_domain;
0046 };
0047
0048 struct amdgpu_pcs_ras_field {
0049 const char *err_name;
0050 uint32_t pcs_err_mask;
0051 uint32_t pcs_err_shift;
0052 };
0053
0054 extern struct amdgpu_xgmi_ras xgmi_ras;
0055 struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev);
0056 void amdgpu_put_xgmi_hive(struct amdgpu_hive_info *hive);
0057 int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_device *adev);
0058 int amdgpu_xgmi_add_device(struct amdgpu_device *adev);
0059 int amdgpu_xgmi_remove_device(struct amdgpu_device *adev);
0060 int amdgpu_xgmi_set_pstate(struct amdgpu_device *adev, int pstate);
0061 int amdgpu_xgmi_get_hops_count(struct amdgpu_device *adev,
0062 struct amdgpu_device *peer_adev);
0063 int amdgpu_xgmi_get_num_links(struct amdgpu_device *adev,
0064 struct amdgpu_device *peer_adev);
0065 uint64_t amdgpu_xgmi_get_relative_phy_addr(struct amdgpu_device *adev,
0066 uint64_t addr);
0067 static inline bool amdgpu_xgmi_same_hive(struct amdgpu_device *adev,
0068 struct amdgpu_device *bo_adev)
0069 {
0070 return (amdgpu_use_xgmi_p2p &&
0071 adev != bo_adev &&
0072 adev->gmc.xgmi.hive_id &&
0073 adev->gmc.xgmi.hive_id == bo_adev->gmc.xgmi.hive_id);
0074 }
0075
0076 #endif