Commit 437298b8 authored by Xiaojie Yuan's avatar Xiaojie Yuan Committed by Alex Deucher

drm/amdgpu/discovery: refactor ip list traversal

for each ip, check whether it is needed by amdgpu driver,
if yes, record its base addresses

v2: change some DRM_INFO to DRM_DEBUG
v3: remove unused variable (Alex)
Signed-off-by: default avatarXiaojie Yuan <xiaojie.yuan@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent a190d1c7
...@@ -266,7 +266,6 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) ...@@ -266,7 +266,6 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
uint16_t num_ips; uint16_t num_ips;
uint8_t num_base_address; uint8_t num_base_address;
int hw_ip; int hw_ip;
int hw_id;
int i, j, k; int i, j, k;
if (!adev->discovery) { if (!adev->discovery) {
...@@ -279,8 +278,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) ...@@ -279,8 +278,7 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset)); le16_to_cpu(bhdr->table_list[IP_DISCOVERY].offset));
num_dies = le16_to_cpu(ihdr->num_dies); num_dies = le16_to_cpu(ihdr->num_dies);
for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) { DRM_DEBUG("number of dies: %d\n", num_dies);
hw_id = hw_id_map[hw_ip];
for (i = 0; i < num_dies; i++) { for (i = 0; i < num_dies; i++) {
die_offset = le16_to_cpu(ihdr->die_info[i].die_offset); die_offset = le16_to_cpu(ihdr->die_info[i].die_offset);
...@@ -288,13 +286,23 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) ...@@ -288,13 +286,23 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
num_ips = le16_to_cpu(dhdr->num_ips); num_ips = le16_to_cpu(dhdr->num_ips);
ip_offset = die_offset + sizeof(*dhdr); ip_offset = die_offset + sizeof(*dhdr);
if (le16_to_cpu(dhdr->die_id) != i) {
DRM_ERROR("invalid die id %d, expected %d\n",
le16_to_cpu(dhdr->die_id), i);
return -EINVAL;
}
DRM_DEBUG("number of hardware IPs on die%d: %d\n",
le16_to_cpu(dhdr->die_id), num_ips);
for (j = 0; j < num_ips; j++) { for (j = 0; j < num_ips; j++) {
ip = (struct ip *)(adev->discovery + ip_offset); ip = (struct ip *)(adev->discovery + ip_offset);
num_base_address = ip->num_base_address; num_base_address = ip->num_base_address;
if (le16_to_cpu(ip->hw_id) == hw_id) { DRM_DEBUG("%s(%d) #%d v%d.%d.%d:\n",
DRM_DEBUG("%s(%d) v%d.%d.%d:\n", hw_id_names[le16_to_cpu(ip->hw_id)],
hw_id_names[hw_id], hw_id, le16_to_cpu(ip->hw_id),
ip->number_instance,
ip->major, ip->minor, ip->major, ip->minor,
ip->revision); ip->revision);
...@@ -307,12 +315,17 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev) ...@@ -307,12 +315,17 @@ int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
DRM_DEBUG("\t0x%08x\n", ip->base_address[k]); DRM_DEBUG("\t0x%08x\n", ip->base_address[k]);
} }
for (hw_ip = 0; hw_ip < MAX_HWIP; hw_ip++) {
if (hw_id_map[hw_ip] == le16_to_cpu(ip->hw_id)) {
DRM_INFO("set register base offset for %s\n",
hw_id_names[le16_to_cpu(ip->hw_id)]);
adev->reg_offset[hw_ip][ip->number_instance] = adev->reg_offset[hw_ip][ip->number_instance] =
ip->base_address; ip->base_address;
} }
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1);
} }
ip_offset += sizeof(*ip) + 4 * (ip->num_base_address - 1);
} }
} }
......
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