aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaojie Yuan2017-05-31 15:22:50 -0500
committerMichel Dänzer2017-06-12 20:21:39 -0500
commit7e6bf88cac315a9fa41818cf72a7b5d18a2cb1fc (patch)
treeb9d9c516ea93037df1d9d248939ca8d26a524e3e /amdgpu/amdgpu_device.c
parent87dac00db38fa962c2fd6aa66c8482a9d7464903 (diff)
downloadexternal-libdrm-7e6bf88cac315a9fa41818cf72a7b5d18a2cb1fc.tar.gz
external-libdrm-7e6bf88cac315a9fa41818cf72a7b5d18a2cb1fc.tar.xz
external-libdrm-7e6bf88cac315a9fa41818cf72a7b5d18a2cb1fc.zip
amdgpu: move asic id table to a separate file
v2: fix an off by one error and leading white spaces v3: use thread safe strtok_r(); initialize len before calling getline(); change printf() to drmMsg(); add initial amdgpu.ids v4: integrate some recent internal changes, including format changes v5: fix line number for empty/commented lines; realloc to save memory; indentation changes v6: remove a line error v7: [Michel Dänzer] * Move amdgpu.ids to new data directory * Remove placeholder entries from amdgpu.ids * Set libdrmdatadir variable in configure.ac instead of Makefile.am [Emil Velikov] * Use isblank() instead of open-coding it [Emil Velikov] * Don't leak asic_id_table memory if realloc fails [Emil Velikov] * Check and bump table_max_size at the beginning of the while loop [Emil Velikov] * Initialize table_max_size to the number of entries in data/amdgpu.ids v8: [Michel Dänzer] * Make sure amdgpu_asic_id.c gets rebuilt when amdgpu.ids changes Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Samuel Li <Samuel.Li@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_device.c')
-rw-r--r--amdgpu/amdgpu_device.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index f473d2da..9a238d97 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -44,7 +44,6 @@
44#include "amdgpu_internal.h" 44#include "amdgpu_internal.h"
45#include "util_hash_table.h" 45#include "util_hash_table.h"
46#include "util_math.h" 46#include "util_math.h"
47#include "amdgpu_asic_id.h"
48 47
49#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) 48#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
50#define UINT_TO_PTR(x) ((void *)((intptr_t)(x))) 49#define UINT_TO_PTR(x) ((void *)((intptr_t)(x)))
@@ -131,6 +130,7 @@ static int amdgpu_get_auth(int fd, int *auth)
131 130
132static void amdgpu_device_free_internal(amdgpu_device_handle dev) 131static void amdgpu_device_free_internal(amdgpu_device_handle dev)
133{ 132{
133 const struct amdgpu_asic_id *id;
134 amdgpu_vamgr_deinit(&dev->vamgr_32); 134 amdgpu_vamgr_deinit(&dev->vamgr_32);
135 amdgpu_vamgr_deinit(&dev->vamgr); 135 amdgpu_vamgr_deinit(&dev->vamgr);
136 util_hash_table_destroy(dev->bo_flink_names); 136 util_hash_table_destroy(dev->bo_flink_names);
@@ -140,6 +140,12 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev)
140 close(dev->fd); 140 close(dev->fd);
141 if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd)) 141 if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
142 close(dev->flink_fd); 142 close(dev->flink_fd);
143 if (dev->asic_ids) {
144 for (id = dev->asic_ids; id->did; id++)
145 free(id->marketing_name);
146
147 free(dev->asic_ids);
148 }
143 free(dev); 149 free(dev);
144} 150}
145 151
@@ -267,6 +273,12 @@ int amdgpu_device_initialize(int fd,
267 amdgpu_vamgr_init(&dev->vamgr_32, start, max, 273 amdgpu_vamgr_init(&dev->vamgr_32, start, max,
268 dev->dev_info.virtual_address_alignment); 274 dev->dev_info.virtual_address_alignment);
269 275
276 r = amdgpu_parse_asic_ids(&dev->asic_ids);
277 if (r) {
278 fprintf(stderr, "%s: Cannot parse ASIC IDs, 0x%x.",
279 __func__, r);
280 }
281
270 *major_version = dev->major_version; 282 *major_version = dev->major_version;
271 *minor_version = dev->minor_version; 283 *minor_version = dev->minor_version;
272 *device_handle = dev; 284 *device_handle = dev;
@@ -297,13 +309,15 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
297 309
298const char *amdgpu_get_marketing_name(amdgpu_device_handle dev) 310const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
299{ 311{
300 const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table; 312 const struct amdgpu_asic_id *id;
313
314 if (!dev->asic_ids)
315 return NULL;
301 316
302 while (t->did) { 317 for (id = dev->asic_ids; id->did; id++) {
303 if ((t->did == dev->info.asic_id) && 318 if ((id->did == dev->info.asic_id) &&
304 (t->rid == dev->info.pci_rev_id)) 319 (id->rid == dev->info.pci_rev_id))
305 return t->marketing_name; 320 return id->marketing_name;
306 t++;
307 } 321 }
308 322
309 return NULL; 323 return NULL;