amdgpu: move asic id table to a separate file
Subsystems (2)
PATCH v4 1/1 amdgpu: move asic id table to a separate file
From: Xiaojie Yuan <[email protected]>
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
--- Makefile.am | 3 + amdgpu/Makefile.am | 2 + amdgpu/Makefile.sources | 2 +- amdgpu/amdgpu_asic_id.c | 206 +++++++++++++++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_asic_id.h | 165 ------------------------------------- amdgpu/amdgpu_device.c | 28 +++++-- amdgpu/amdgpu_internal.h | 10 +++ include/drm/amdgpu.ids | 170 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 413 insertions(+), 173 deletions(-) create mode 100644 amdgpu/amdgpu_asic_id.c delete mode 100644 amdgpu/amdgpu_asic_id.h create mode 100644 include/drm/amdgpu.ids
Makefile.am +3 -0
@@ -45,6 +45,9 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm.pc +libdrmdatadir = $(datadir)/libdrm +dist_libdrmdata_DATA = include/drm/amdgpu.ids +export libdrmdatadir if HAVE_LIBKMS LIBKMS_SUBDIR = libkms
amdgpu/Makefile.am +2 -0
@@ -30,6 +30,8 @@ AM_CFLAGS = \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm +AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\" + libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la libdrm_amdgpu_ladir = $(libdir) libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
amdgpu/Makefile.sources +1 -1
@@ -1,5 +1,5 @@ LIBDRM_AMDGPU_FILES := \ - amdgpu_asic_id.h \ + amdgpu_asic_id.c \ amdgpu_bo.c \ amdgpu_cs.c \ amdgpu_device.c \
amdgpu/amdgpu_asic_id.c new file +206 -0
206 lines not on this page · raw message
amdgpu/amdgpu_asic_id.h deleted +0 -165
165 lines not on this page · raw message
amdgpu/amdgpu_device.c +21 -7
@@ -44,7 +44,6 @@#include "amdgpu_internal.h" #include "util_hash_table.h" #include "util_math.h" -#include "amdgpu_asic_id.h" #define PTR_TO_UINT (x) ((unsigned)((intptr_t)(x)))#define UINT_TO_PTR (x) ((void *)((intptr_t)(x)))
@@ -131,6 +130,7 @@ static int amdgpu_get_auth(int fd, int *auth)static void amdgpu_device_free_internal (amdgpu_device_handle dev) { +const struct amdgpu_asic_id *id;amdgpu_vamgr_deinit (&dev->vamgr_32);amdgpu_vamgr_deinit (&dev->vamgr);util_hash_table_destroy (dev->bo_flink_names);
@@ -140,6 +140,13 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev)close (dev->fd);if ((dev->flink_fd >=0 ) && (dev->fd != dev->flink_fd))close (dev->flink_fd); +if (dev->asic_ids) { +for (id = dev->asic_ids; id->did; id++) { +if (id->marketing_name !=NULL ) +free (id->marketing_name); + } +free (dev->asic_ids); + }free (dev); }
@@ -267,6 +274,11 @@ int amdgpu_device_initialize(int fd,amdgpu_vamgr_init (&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + r =amdgpu_parse_asic_ids (&dev->asic_ids); +if (r) +fprintf (stderr,"%s: Can not parse asic ids, 0x%x." , + __func__, r); + *major_version = dev->major_version; *minor_version = dev->minor_version; *device_handle = dev;
@@ -297,13 +309,15 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)const char *amdgpu_get_marketing_name (amdgpu_device_handle dev) { -const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table; +const struct amdgpu_asic_id *id; + +if (!dev->asic_ids) +return NULL ; -while (t->did) { -if ((t->did == dev->info.asic_id) && - (t->rid == dev->info.pci_rev_id)) -return t->marketing_name; - t++; +for (id = dev->asic_ids; id->did; id++) { +if ((id->did == dev->info.asic_id) && + (id->rid == dev->info.pci_rev_id)) +return id->marketing_name; }return NULL ;
amdgpu/amdgpu_internal.h +10 -0
@@ -69,6 +69,12 @@ struct amdgpu_va {struct amdgpu_bo_va_mgr *vamgr; }; +struct amdgpu_asic_id { +uint32_t did; +uint32_t rid; +char *marketing_name; +}; +struct amdgpu_device {atomic_t refcount;int fd;
@@ -76,6 +82,8 @@ struct amdgpu_device {unsigned major_version;unsigned minor_version; +/** Lookup table of asic device id, revision id and marketing name */ +struct amdgpu_asic_id *asic_ids;/** List of buffer handles. Protected by bo_table_mutex. */ struct util_hash_table *bo_handles;/** List of buffer GEM flink names. Protected by bo_table_mutex. */
@@ -149,6 +157,8 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, drm_private voidamdgpu_vamgr_free_va (struct amdgpu_bo_va_mgr *mgr,uint64_t va,uint64_t size); +drm_private int amdgpu_parse_asic_ids(struct amdgpu_asic_id **asic_ids); + drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev); drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout);
include/drm/amdgpu.ids new file +170 -0
170 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 1 line · Samuel Li
From: Xiaojie Yuan <[email protected]>
I took a closer look and noticed some details (and some non-details about the amdgpu.ids file at the end).
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +0
-0
[...]
amdgpu/amdgpu_asic_id.c line 37
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h"
Should be
#include <xf86drm.h>
#include <amdgpu_drm.h>
since these header files are not located in the same directory as amdgpu_asic_id.c.
amdgpu/amdgpu_asic_id.c line 47
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +8
-0+static int parse_one_line (const char *line,struct amdgpu_asic_id *id) +{ +char *buf, *saveptr; +char *s_did; +char *s_rid; +char *s_name; +char *endptr; +int r =0 ;
This function could be simplified slightly by initializing r = -EINVAL here and only setting it to 0 just before the out label.
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+int amdgpu_parse_asic_ids (struct amdgpu_asic_id **p_asic_id_table) +{
[...]
amdgpu/amdgpu_asic_id.c line 141
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +5
-0+/* 1st valid line is file version */ +while ((n =getline (&line, &len, fp)) !=-1 ) { +/* trim trailing newline */ +if (line[n -1 ] =='\n' ) + line[n -1 ] ='\0' ;
Should probably increment line_num here, otherwise the line number in the error message below might be confusing.
amdgpu/amdgpu_asic_id.c line 165
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+fprintf (stderr,"Invalid format: %s: line %d: %s\n" , +AMDGPU_ASIC_ID_TABLE , line_num, line);
The second line should be indented to align with the opening parenthesis.
amdgpu/amdgpu_asic_id.c line 176
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +5
-0+if (table_size >= table_max_size) { +/* double table size */ + table_max_size *=2 ; + asic_id_table =realloc (asic_id_table, table_max_size * +sizeof (struct amdgpu_asic_id ));
Ditto.
amdgpu/amdgpu_asic_id.c line 186
Quoted 3 lines
amdgpu/amdgpu_asic_id.c new file +3
-0+/* end of table */ + id = asic_id_table + table_size; +memset (id,0 ,sizeof (struct amdgpu_asic_id ));
Might also want to realloc asic_id_table according to the final table size, to avoid wasting memory.
amdgpu/amdgpu_asic_id.c line 195
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +5
-0+if (r && asic_id_table) { +while (table_size--) { + id = asic_id_table + table_size; +if (id->marketing_name !=NULL ) +free (id->marketing_name);
free(NULL) works fine (and parse_one_line returns an error for id->marketing_name == NULL anyway), so this can be simplified to
free(id->marketing_name);
amdgpu/amdgpu_asic_id.c static void amdgpu_device_free_internal(amdgpu_device_handle dev) · line 147
Quoted 9 lines
amdgpu/amdgpu_asic_id.c new file +5
-0@@ -140,6 +140,13 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev)close (dev->fd);if ((dev->flink_fd >=0 ) && (dev->fd != dev->flink_fd))close (dev->flink_fd); +if (dev->asic_ids) { +for (id = dev->asic_ids; id->did; id++) { +if (id->marketing_name !=NULL ) +free (id->marketing_name); + }
Ditto, this can be simplified to
for (id = dev->asic_ids; id->did; id++) free(id->marketing_name);
amdgpu/amdgpu_asic_id.c int amdgpu_device_initialize(int fd, · line 280
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +4
-0@@ -267,6 +274,11 @@ int amdgpu_device_initialize(int fd,amdgpu_vamgr_init (&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + r =amdgpu_parse_asic_ids (&dev->asic_ids); +if (r) +fprintf (stderr,"%s: Can not parse asic ids, 0x%x." , + __func__, r);
"Cannot parse ASIC IDs"
Also, there should be curly braces around a multi-line statement.
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +3
-1@@ -297,13 +309,15 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)const char *amdgpu_get_marketing_name (amdgpu_device_handle dev) { -const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table; +const struct amdgpu_asic_id *id; + +if (!dev->asic_ids)
amdgpu/amdgpu_asic_id.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 319
Quoted 10 lines
amdgpu/amdgpu_asic_id.c new file +4
-5+return NULL ; -while (t->did) { -if ((t->did == dev->info.asic_id) && - (t->rid == dev->info.pci_rev_id)) -return t->marketing_name; - t++; +for (id = dev->asic_ids; id->did; id++) { +if ((id->did == dev->info.asic_id) && + (id->rid == dev->info.pci_rev_id))
The last line is indented incorrectly, should be 2 tabs and 4 spaces.
include/drm/amdgpu.ids
Quoted 5 lines
include/drm/amdgpu.ids new file +0
-0
I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than include/drm/amdgpu.ids.
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID's
This should say "IDs" instead of "ID's".
include/drm/amdgpu.ids line 99
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EF
There should be no such dummy entries in the file. If it's useful, amdgpu_get_marketing_name can return a dummy string based on the PCI ID and revision when there's no matching entry in the file.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Please see comments inline.
-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Monday, May 29, 2017 9:26 PM
To: Li, Samuel <[email protected]>
Cc: [email protected]; Yuan, Xiaojie <[email protected]>
Subject: Re: [PATCH libdrm v4 1/1] amdgpu: move asic id table to a separate file
Quoted 1 line · Samuel Li
From: Xiaojie Yuan <[email protected]>
I took a closer look and noticed some details (and some non-details about the amdgpu.ids file at the end).
Quoted 4 lines
amdgpu/amdgpu_asic_id.c new renamed from amdgpu/amdgpu_asic_id.c +0
-0file mode 100644 index 0000000..a43ca33
amdgpu/amdgpu_asic_id.c new file +0
-0
[...]
amdgpu/amdgpu_asic_id.c line 37
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h"
Should be
#include <xf86drm.h>
#include <amdgpu_drm.h>
since these header files are not located in the same directory as amdgpu_asic_id.c.
[Sam] Actually, "" is used to include programmer-defined header files, and <> is used for files pre-designated by the compiler/IDE.
amdgpu/amdgpu_asic_id.c line 47
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +8
-0+static int parse_one_line (const char *line,struct amdgpu_asic_id *id) +{ +char *buf, *saveptr; +char *s_did; +char *s_rid; +char *s_name; +char *endptr; +int r =0 ;
This function could be simplified slightly by initializing r = -EINVAL here and only setting it to 0 just before the out label.
[Sam]This is likely a personal preference. I am fine with current implementation which is clear.
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+int amdgpu_parse_asic_ids (struct amdgpu_asic_id **p_asic_id_table) +{
[...]
amdgpu/amdgpu_asic_id.c line 141
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +5
-0+/* 1st valid line is file version */ +while ((n =getline (&line, &len, fp)) !=-1 ) { +/* trim trailing newline */ +if (line[n -1 ] =='\n' ) + line[n -1 ] ='\0' ;
Should probably increment line_num here, otherwise the line number in the error message below might be confusing.
[Sam]That is a good catch.
amdgpu/amdgpu_asic_id.c line 165
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+fprintf (stderr,"Invalid format: %s: line %d: %s\n" , +AMDGPU_ASIC_ID_TABLE , line_num, line);
The second line should be indented to align with the opening parenthesis.
[Sam] Can be done.
amdgpu/amdgpu_asic_id.c line 176
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +5
-0+if (table_size >= table_max_size) { +/* double table size */ + table_max_size *=2 ; + asic_id_table =realloc (asic_id_table, table_max_size * +sizeof (struct amdgpu_asic_id ));
Ditto.
[Sam] Can be done.
amdgpu/amdgpu_asic_id.c line 186
Quoted 3 lines
amdgpu/amdgpu_asic_id.c new file +3
-0+/* end of table */ + id = asic_id_table + table_size; +memset (id,0 ,sizeof (struct amdgpu_asic_id ));
Might also want to realloc asic_id_table according to the final table size, to avoid wasting memory.
[Sam] Good one.
amdgpu/amdgpu_asic_id.c line 195
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new file +5
-0+if (r && asic_id_table) { +while (table_size--) { + id = asic_id_table + table_size; +if (id->marketing_name !=NULL ) +free (id->marketing_name);
free(NULL) works fine (and parse_one_line returns an error for id->marketing_name == NULL anyway), so this can be simplified to
free(id->marketing_name);
[Sam] Can be done.
amdgpu/amdgpu_asic_id.c static void amdgpu_device_free_internal(amdgpu_device_handle dev) · line 147
Quoted 9 lines
amdgpu/amdgpu_asic_id.c new file +5
-0@@ -140,6 +140,13 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev)close (dev->fd);if ((dev->flink_fd >=0 ) && (dev->fd != dev->flink_fd))close (dev->flink_fd); +if (dev->asic_ids) { +for (id = dev->asic_ids; id->did; id++) { +if (id->marketing_name !=NULL ) +free (id->marketing_name); + }
Ditto, this can be simplified to
[Sam] Can be done.
for (id = dev->asic_ids; id->did; id++) free(id->marketing_name);
amdgpu/amdgpu_asic_id.c int amdgpu_device_initialize(int fd, · line 280
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +4
-0@@ -267,6 +274,11 @@ int amdgpu_device_initialize(int fd,amdgpu_vamgr_init (&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + r =amdgpu_parse_asic_ids (&dev->asic_ids); +if (r) +fprintf (stderr,"%s: Can not parse asic ids, 0x%x." , + __func__, r);
"Cannot parse ASIC IDs"
Also, there should be curly braces around a multi-line statement.
[Sam] Can be done. However, it is still a single statement. Does it matter?
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +3
-1@@ -297,13 +309,15 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)const char *amdgpu_get_marketing_name (amdgpu_device_handle dev) { -const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table; +const struct amdgpu_asic_id *id; + +if (!dev->asic_ids)
amdgpu/amdgpu_asic_id.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 319
Quoted 10 lines
amdgpu/amdgpu_asic_id.c new file +4
-5+return NULL ; -while (t->did) { -if ((t->did == dev->info.asic_id) && - (t->rid == dev->info.pci_rev_id)) -return t->marketing_name; - t++; +for (id = dev->asic_ids; id->did; id++) { +if ((id->did == dev->info.asic_id) && + (id->rid == dev->info.pci_rev_id))
The last line is indented incorrectly, should be 2 tabs and 4 spaces.
[Sam] Can be done
include/drm/amdgpu.ids
Quoted 5 lines
include/drm/amdgpu.ids new file +0
-0
I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than include/drm/amdgpu.ids.
[Sam] The file is going to be shared with radeon.
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID's
This should say "IDs" instead of "ID's".
include/drm/amdgpu.ids line 99
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EF
There should be no such dummy entries in the file. If it's useful, amdgpu_get_marketing_name can return a dummy string based on the PCI ID and revision when there's no matching entry in the file.
[Sam] I forwarded another thread to you.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 15 lines · Samuel
From: Michel Dänzer [mailto:[email protected]]
Quoted 14 lines · Samuel Li
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new renamed from amdgpu/amdgpu_asic_id.c +0
-0file mode 100644 index 0000000..a43ca33
amdgpu/amdgpu_asic_id.c new file +0
-0[...]
amdgpu/amdgpu_asic_id.c line 37
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h" Should be
Quoted 8 lines
Quoted 5 lines
#include <
xf86drm.h>
#include <amdgpu_drm.h>since these header files are not located in the same directory as
amdgpu_asic_id.c.[Sam] Actually, "" is used to include programmer-defined header files,
and <> is used for files pre-designated by the compiler/IDE.
The only difference between the two is that #include "" first looks for the header file in the same directory where the file containing the #include directive (not necessarily the same as the original *.c file passed to the compiler/preprocessor) is located, after that it looks in the same paths in the same order as <>. So "" only really makes sense when the header file is in the same directory as the file including it.
Quoted 11 lines
Quoted 11 lines
amdgpu/amdgpu_asic_id.c int amdgpu_device_initialize(int fd, · line 280
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +4
-0@@ -267,6 +274,11 @@ int amdgpu_device_initialize(int fd,amdgpu_vamgr_init (&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + r =amdgpu_parse_asic_ids (&dev->asic_ids); +if (r) +fprintf (stderr,"%s: Can not parse asic ids, 0x%x." , + __func__, r);"Cannot parse ASIC IDs"
Quoted 3 lines
Quoted 1 line
Also, there should be curly braces around a multi-line statement.
[Sam] Can be done. However, it is still a single statement. Does it matter?
It might not be strictly required, but I think it does make the code clearer in this case.
Quoted 10 lines
Quoted 8 lines
include/drm/amdgpu.ids
Quoted 5 lines
include/drm/amdgpu.ids new file +0
-0I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than
include/drm/amdgpu.ids.[Sam] The file is going to be shared with radeon.
We can cross that bridge when we get there. Meanwhile, it's not a header file and not installed under $prefix/include/, so it doesn't belong in include/.
Quoted 6 lines
Quoted 6 lines
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID'sThis should say "IDs" instead of "ID's".
Quoted 8 lines
Quoted 6 lines
include/drm/amdgpu.ids line 99
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EFThere should be no such dummy entries in the file. If it's useful,
amdgpu_get_marketing_namecan return a dummy string based on the PCI ID and revision when there's no matching entry in the file.[Sam] I forwarded another thread to you.
Please make your argument explicitly, for the benefit of non-AMD readers of the amd-gfx list.
Anyway, I don't think that invalidates what I wrote, and Alex seems to agree. "67FF:CF" isn't a marketing name, so there should be no such entries in this file. It's not necessary anyway; assuming it's useful for amdgpu_get_marketing_name to return such "names", it can generate them on the fly when there is no matching entry in the file.
Ideally the issues above should be fixed in the original file we get from marketing (?), but meanwhile / failing that we should fix them up (and can easily with Git).
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 92 lines · Michel Dänzer
Quoted 15 lines · Samuel
From: Michel Dänzer [mailto:[email protected]]
Quoted 14 lines · Samuel Li
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new renamed from amdgpu/amdgpu_asic_id.c +0
-0file mode 100644 index 0000000..a43ca33
amdgpu/amdgpu_asic_id.c new file +0
-0[...]
amdgpu/amdgpu_asic_id.c
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h" Should be
Quoted 8 lines
Quoted 5 lines
#include <
xf86drm.h>
#include <amdgpu_drm.h>since these header files are not located in the same directory as
amdgpu_asic_id.c.[Sam] Actually, "" is used to include programmer-defined header files,
and <> is used for files pre-designated by the compiler/IDE.The only difference between the two is that #include "" first looks for the header file in the same directory where the file containing the #include directive (not necessarily the same as the original *.c file passed to the compiler/preprocessor) is located, after that it looks in the same paths in the same order as <>. So "" only really makes sense when the header file is in the same directory as the file including it.
Quoted 11 lines
Quoted 11 lines
amdgpu/amdgpu_asic_id.c int amdgpu_device_initialize(int fd, · line 280
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +4
-0@@ -267,6 +274,11 @@ int amdgpu_device_initialize(int fd,amdgpu_vamgr_init (&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + r =amdgpu_parse_asic_ids (&dev->asic_ids); +if (r) +fprintf (stderr,"%s: Can not parse asic ids, 0x%x." , + __func__, r);"Cannot parse ASIC IDs"
Quoted 3 lines
Quoted 1 line
Also, there should be curly braces around a multi-line statement.
[Sam] Can be done. However, it is still a single statement. Does it matter?
It might not be strictly required, but I think it does make the code clearer in this case.
Quoted 10 lines
Quoted 8 lines
include/drm/amdgpu.ids
Quoted 5 lines
include/drm/amdgpu.ids new file +0
-0I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than
include/drm/amdgpu.ids.[Sam] The file is going to be shared with radeon.
We can cross that bridge when we get there. Meanwhile, it's not a header file and not installed under $prefix/include/, so it doesn't belong in
include/.Quoted 6 lines
Quoted 6 lines
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID'sThis should say "IDs" instead of "ID's".
Quoted 8 lines
Quoted 6 lines
include/drm/amdgpu.ids line 3
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EFThere should be no such dummy entries in the file. If it's useful,
amdgpu_get_marketing_namecan return a dummy string based on the PCI ID and revision when there's no matching entry in the file.[Sam] I forwarded another thread to you.
Please make your argument explicitly, for the benefit of non-AMD readers of the amd-gfx list.
Anyway, I don't think that invalidates what I wrote, and Alex seems to agree. "67FF:CF" isn't a marketing name, so there should be no such entries in this file. It's not necessary anyway; assuming it's useful for
amdgpu_get_marketing_nameto return such "names", it can generate them on the fly when there is no matching entry in the file.
Quoted 3 lines
Ideally the issues above should be fixed in the original file we get from marketing (?), but meanwhile / failing that we should fix them up (and can easily with Git).
Thinking about this more, it probably doesn't matter that much. By the time any of these cards with no marketing names get onto shelves, the names will be filled in. That said, it does seem strange to have these dummy entries.
Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Please see comments incline,
-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Wednesday, May 31, 2017 1:15 AM
To: Li, Samuel <[email protected]>
Cc: [email protected]; Yuan, Xiaojie <[email protected]>
Subject: Re: [PATCH libdrm v4 1/1] amdgpu: move asic id table to a separate file
Quoted 15 lines · Samuel
From: Michel Dänzer [mailto:[email protected]]
Quoted 14 lines · Samuel Li
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new renamed from amdgpu/amdgpu_asic_id.c +0
-0file mode 100644 index 0000000..a43ca33
amdgpu/amdgpu_asic_id.c new file +0
-0[...]
amdgpu/amdgpu_asic_id.c
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h" Should be
Quoted 8 lines
Quoted 5 lines
#include <
xf86drm.h>
#include <amdgpu_drm.h>since these header files are not located in the same directory as
amdgpu_asic_id.c.[Sam] Actually, "" is used to include programmer-defined header
files, and <> is used for files pre-designated by the compiler/IDE.
The only difference between the two is that #include "" first looks for the header file in the same directory where the file containing the #include directive (not necessarily the same as the original *.c file passed to the compiler/preprocessor) is located, after that it looks in the same paths in the same order as <>. So "" only really makes sense when the header file is in the same directory as the file including it.
[Sam] Please see here
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
Quoted 11 lines
Quoted 11 lines
amdgpu/amdgpu_asic_id.c int amdgpu_device_initialize(int fd, · line 280
Quoted 8 lines
amdgpu/amdgpu_asic_id.c new file +4
-0@@ -267,6 +274,11 @@ int amdgpu_device_initialize(int fd,amdgpu_vamgr_init (&dev->vamgr_32, start, max, dev->dev_info.virtual_address_alignment); + r =amdgpu_parse_asic_ids (&dev->asic_ids); +if (r) +fprintf (stderr,"%s: Can not parse asic ids, 0x%x." , + __func__, r);"Cannot parse ASIC IDs"
Quoted 3 lines
Quoted 1 line
Also, there should be curly braces around a multi-line statement.
[Sam] Can be done. However, it is still a single statement. Does it matter?
It might not be strictly required, but I think it does make the code clearer in this case.
[Sam] OK.
Quoted 9 lines
Quoted 7 lines
include/drm/amdgpu.ids
Quoted 4 lines
include/drm/amdgpu.ids new renamed from include/drm/amdgpu.ids +0
-0file mode 100644 index 0000000..6d6b944
include/drm/amdgpu.ids new file +0
-0I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than
include/drm/amdgpu.ids.[Sam] The file is going to be shared with radeon.
We can cross that bridge when we get there. Meanwhile, it's not a header file and not installed under $prefix/include/, so it doesn't belong in include/. [Sam] I am planning to do it right after this. README is also located in this directory.
Quoted 6 lines
Quoted 6 lines
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID'sThis should say "IDs" instead of "ID's".
Quoted 8 lines
Quoted 6 lines
include/drm/amdgpu.ids line 3
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EFThere should be no such dummy entries in the file. If it's useful,
amdgpu_get_marketing_namecan return a dummy string based on the PCI ID and revision when there's no matching entry in the file.[Sam] I forwarded another thread to you.
Please make your argument explicitly, for the benefit of non-AMD readers of the amd-gfx list.
Anyway, I don't think that invalidates what I wrote, and Alex seems to agree. "67FF:CF" isn't a marketing name, so there should be no such entries in this file. It's not necessary anyway; assuming it's useful for amdgpu_get_marketing_name to return such "names", it can generate them on the fly when there is no matching entry in the file. Ideally the issues above should be fixed in the original file we get from marketing (?), but meanwhile / failing that we should fix them up (and can easily with Git).
[Sam] Essentially marketing names are defined by Marketing. They are complicated as I can imagine. If you have questions regarding the names, the thread I forwarded has the contact you can use. IIRC, the hex format in marketing names has been used for very long time. My preference is to pass the names only, not to audit from a coder's view ... that can make discussions much much more difficult.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 23 lines · Alex Deucher
Quoted 22 lines · Michel Dänzer
Quoted 11 lines · Samuel
From: Michel Dänzer [mailto:[email protected]]
Quoted 8 lines · Samuel Li
Quoted 3 lines
+67FF, CF, 67FF:CF +67FF, EF, 67FF:EFThere should be no such dummy entries in the file. If it's useful,
amdgpu_get_marketing_namecan return a dummy string based on the PCI ID and revision when there's no matching entry in the file.[Sam] I forwarded another thread to you.
Please make your argument explicitly, for the benefit of non-AMD readers of the amd-gfx list.
Anyway, I don't think that invalidates what I wrote, and Alex seems to agree. "67FF:CF" isn't a marketing name, so there should be no such entries in this file. It's not necessary anyway; assuming it's useful for
amdgpu_get_marketing_nameto return such "names", it can generate them on the fly when there is no matching entry in the file.
Quoted 8 lines
Quoted 3 lines
Ideally the issues above should be fixed in the original file we get from marketing (?), but meanwhile / failing that we should fix them up (and can easily with Git).
Thinking about this more, it probably doesn't matter that much. By the time any of these cards with no marketing names get onto shelves, the names will be filled in. That said, it does seem strange to have these dummy entries.
Right, by the time a product is released, we should have the final marketing name and can just add that directly. I really don't see the point of adding such dummy entries before that in the libdrm repository.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 23 lines · Samuel
Quoted 23 lines
From: Michel Dänzer [mailto:[email protected]]
Quoted 21 lines · Samuel
From: Michel Dänzer [mailto:[email protected]]
Quoted 19 lines · Samuel Li
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new renamed from amdgpu/amdgpu_asic_id.c +0
-0file mode 100644 index 0000000..a43ca33
amdgpu/amdgpu_asic_id.c new file +0
-0[...]
amdgpu/amdgpu_asic_id.c
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h" Should be
#include <
xf86drm.h>
#include <amdgpu_drm.h>since these header files are not located in the same directory as
amdgpu_asic_id.c.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
[Sam] Actually, "" is used to include programmer-defined header
files, and <> is used for files pre-designated by the compiler/IDE.The only difference between the two is that #include "" first looks for the header file in the same directory where the file containing the #include directive (not necessarily the same as the original *.c file passed to the compiler/preprocessor) is located, after that it looks in the same paths in the same order as <>. So "" only really makes sense when the header file is in the same directory as the file including it.
[Sam] Please see here
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
Thanks, I didn't know different search paths can apply with "" vs <>. One learns something new every day. :) You can ignore the above then.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
include/drm/amdgpu.ids
Quoted 4 lines
include/drm/amdgpu.ids new renamed from include/drm/amdgpu.ids +0
-0file mode 100644 index 0000000..6d6b944
include/drm/amdgpu.ids new file +0
-0I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than
include/drm/amdgpu.ids.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
[Sam] The file is going to be shared with radeon.
We can cross that bridge when we get there. Meanwhile, it's not a header file and not installed under $prefix/include/, so it doesn't belong in
include/.[Sam] I am planning to do it right after this.
If amdgpu.ids living in the amdgpu directory prevents it from being used by libdrm_radeon (why?), let's put it in a new toplevel directory, e.g. "data".
Quoted 1 line
README is also located in this directory.
Not the same thing. It documents things about the header files, and doesn't get installed anywhere.
Quoted 19 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID'sThis should say "IDs" instead of "ID's".
include/drm/amdgpu.ids line 3
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EFThere should be no such dummy entries in the file. If it's useful,
amdgpu_get_marketing_namecan return a dummy string based on the PCI ID and revision when there's no matching entry in the file.Quoted 5 lines
Quoted 1 line
[Sam] I forwarded another thread to you.
Please make your argument explicitly, for the benefit of non-AMD readers of the amd-gfx list.
Anyway, I don't think that invalidates what I wrote, and Alex seems to agree. "67FF:CF" isn't a marketing name, so there should be no such entries in this file. It's not necessary anyway; assuming it's useful foramdgpu_get_marketing_nameto return such "names", it can generate them on the fly when there is no matching entry in the file. Ideally the issues above should be fixed in the original file we get from marketing (?), but meanwhile / failing that we should fix them up (and can easily with Git).
Quoted 5 lines
[Sam] Essentially marketing names are defined by Marketing. They are complicated as I can imagine. If you have questions regarding the names, the thread I forwarded has the contact you can use. IIRC, the hex format in marketing names has been used for very long time.
It's obviously not a "marketing name" but some kind of placeholder. We don't need those in libdrm.
Quoted 2 lines
My preference is to pass the names only, not to audit from a coder's view ...
That's not how we do things.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
If amdgpu.ids living in the amdgpu directory prevents it from being used by
libdrm_radeon(why?), let's put it in a new toplevel directory, e.g. "data".Quoted 1 line
README is also located in this directory.
Not the same thing. It documents things about the header files, and doesn't get installed anywhere.
I think that is a personal preference.
Quoted 3 lines
Quoted 2 lines
My preference is to pass the names only, not to audit from a coder's view ...
That's not how we do things.
It is a data file, not really a part of code. It shall be your preference to decide how much time you would like to spend in auditing the names :)
Sam
-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Thursday, June 01, 2017 2:09 AM
To: Li, Samuel <[email protected]>
Cc: [email protected]; Yuan, Xiaojie <[email protected]>
Subject: Re: [PATCH libdrm v4 1/1] amdgpu: move asic id table to a separate file
Quoted 23 lines · Samuel
Quoted 23 lines
From: Michel Dänzer [mailto:[email protected]] On 31/05/17 07:31 AM,
Quoted 21 lines · Samuel
From: Michel Dänzer [mailto:[email protected]]
Quoted 19 lines · Samuel Li
Quoted 5 lines
amdgpu/amdgpu_asic_id.c new renamed from amdgpu/amdgpu_asic_id.c +0
-0file mode 100644 index 0000000..a43ca33
amdgpu/amdgpu_asic_id.c new file +0
-0[...]
amdgpu/amdgpu_asic_id.c
Quoted 2 lines
amdgpu/amdgpu_asic_id.c new file +2
-0+#include "xf86drm.h" +#include "amdgpu_drm.h" Should be
#include <
xf86drm.h>
#include <amdgpu_drm.h>since these header files are not located in the same directory as
amdgpu_asic_id.c.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
[Sam] Actually, "" is used to include programmer-defined header
files, and <> is used for files pre-designated by the compiler/IDE.The only difference between the two is that #include "" first looks for the header file in the same directory where the file containing the #include directive (not necessarily the same as the original *.c file passed to the compiler/preprocessor) is located, after that it looks in the same paths in the same order as <>. So "" only really makes sense when the header file is in the same directory as the file including it.
[Sam] Please see here
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
Thanks, I didn't know different search paths can apply with "" vs <>. One learns something new every day. :) You can ignore the above then.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
include/drm/amdgpu.ids
Quoted 4 lines
include/drm/amdgpu.ids new renamed from include/drm/amdgpu.ids +0
-0file mode 100644 index 0000000..6d6b944
include/drm/amdgpu.ids new file +0
-0I think the path of this file in the repository should be amdgpu/amdgpu.ids rather than
include/drm/amdgpu.ids.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
[Sam] The file is going to be shared with radeon.
We can cross that bridge when we get there. Meanwhile, it's not a header file and not installed under $prefix/include/, so it doesn't belong in
include/.[Sam] I am planning to do it right after this.
If amdgpu.ids living in the amdgpu directory prevents it from being used by libdrm_radeon (why?), let's put it in a new toplevel directory, e.g. "data".
Quoted 1 line
README is also located in this directory.
Not the same thing. It documents things about the header files, and doesn't get installed anywhere.
Quoted 19 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
include/drm/amdgpu.ids line 1
Quoted 2 lines
include/drm/amdgpu.ids new file +1
-0@@ -0,0 +1,170 @@ +# List of AMDGPU ID'sThis should say "IDs" instead of "ID's".
include/drm/amdgpu.ids line 3
Quoted 2 lines
include/drm/amdgpu.ids new file +2
-0+67FF, CF, 67FF:CF +67FF, EF, 67FF:EFThere should be no such dummy entries in the file. If it's useful,
amdgpu_get_marketing_namecan return a dummy string based on the PCI ID and revision when there's no matching entry in the file.Quoted 5 lines
Quoted 1 line
[Sam] I forwarded another thread to you.
Please make your argument explicitly, for the benefit of non-AMD readers of the amd-gfx list.
Anyway, I don't think that invalidates what I wrote, and Alex seems to agree. "67FF:CF" isn't a marketing name, so there should be no such entries in this file. It's not necessary anyway; assuming it's useful foramdgpu_get_marketing_nameto return such "names", it can generate them on the fly when there is no matching entry in the file. Ideally the issues above should be fixed in the original file we get from marketing (?), but meanwhile / failing that we should fix them up (and can easily with Git).
Quoted 5 lines
[Sam] Essentially marketing names are defined by Marketing. They are complicated as I can imagine. If you have questions regarding the names, the thread I forwarded has the contact you can use. IIRC, the hex format in marketing names has been used for very long time.
It's obviously not a "marketing name" but some kind of placeholder. We don't need those in libdrm.
Quoted 2 lines
My preference is to pass the names only, not to audit from a coder's view ...
That's not how we do things.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 5 lines · Samuel
Quoted 4 lines
If amdgpu.ids living in the amdgpu directory prevents it from being used by
libdrm_radeon(why?), let's put it in a new toplevel directory, e.g. "data".Quoted 1 line
README is also located in this directory.
Not the same thing. It documents things about the header files, and doesn't get installed anywhere.
I think that is a personal preference.
If you're referring to naming the new directory "data", that's just a suggestion. Another possibility is to simply put it in the toplevel directory.
What I wrote about include/drm/README is easily verifiable fact.
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
My preference is to pass the names only, not to audit from a coder's view ...
That's not how we do things.
It is a data file, not really a part of code.
There is nothing magic about it. It's subject to the review process just like any other file in the repository.
BTW, if you put the file outside of the amdgpu directory, you should send the patch to the dri-devel mailing list for review as well.
Quoted 2 lines
It shall be your preference to decide how much time you would like to spend in auditing the names :)
It shouldn't take as much time as we've spent talking about it in this thread. :}
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 1 line
Another possibility is to simply put it in the toplevel directory.
I considered that too, but I prefer not to pollute the toplevel.
Quoted 1 line
It shouldn't take as much time as we've spent talking about it in this thread. :}
Right, I meant you can go ahead if you would like to verify the names.
Sam
-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Thursday, June 01, 2017 11:06 PM
To: Li, Samuel <[email protected]>
Cc: [email protected]; Yuan, Xiaojie <[email protected]>
Subject: Re: [PATCH libdrm v4 1/1] amdgpu: move asic id table to a separate file
Quoted 5 lines · Samuel
Quoted 4 lines
If amdgpu.ids living in the amdgpu directory prevents it from being used by
libdrm_radeon(why?), let's put it in a new toplevel directory, e.g. "data".Quoted 1 line
README is also located in this directory.
Not the same thing. It documents things about the header files, and doesn't get installed anywhere.
I think that is a personal preference.
If you're referring to naming the new directory "data", that's just a suggestion. Another possibility is to simply put it in the toplevel directory.
What I wrote about include/drm/README is easily verifiable fact.
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
My preference is to pass the names only, not to audit from a coder's view ...
That's not how we do things.
It is a data file, not really a part of code.
There is nothing magic about it. It's subject to the review process just like any other file in the repository.
BTW, if you put the file outside of the amdgpu directory, you should send the patch to the dri-devel mailing list for review as well.
Quoted 2 lines
It shall be your preference to decide how much time you would like to spend in auditing the names :)
It shouldn't take as much time as we've spent talking about it in this thread. :}
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx