Skip to contentSkip to conversation

amdgpu: add the function to get the marketing name (v2)

PATCH In review Alex Deucher 5 participants 14 messages Sep 12, 2016 – Nov 8, 2016 7 messages not in the archive DRM drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 amdgpu: add the function to get the marketing name (v2)

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.

---
 amdgpu/amdgpu.h         |  10 +++
 amdgpu/amdgpu_asic_id.h | 170 ++++++++++++++++++++++++++++++++++++++++++++++++
 amdgpu/amdgpu_device.c  |  15 +++++
 3 files changed, 195 insertions(+)
 create mode 100644 amdgpu/amdgpu_asic_id.h
amdgpu/amdgpu.h +10 -0
index 5d5a2c6..7b26a04 100644
@@ -1245,4 +1245,14 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 */
 int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
 
+/**
+ *  Get the ASIC marketing name
+ *
+ * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
+ *
+ * \return  the constant string of the marketing name
+ *          "NULL" means the ASIC is not found
+*/
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev);
+
 #endif /* #ifdef _AMDGPU_H_ */
amdgpu/amdgpu_asic_id.h new file +170 -0

170 lines not on this page · raw message

amdgpu/amdgpu_device.c +15 -0
index e5a923e..c584ef4 100644
@@ -44,6 +44,7 @@
 #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)))
@@ -303,3 +304,17 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
+{
+	const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table;
+
+	while (t->did) {
+		if ((t->did == dev->info.asic_id) &&
+				(t->rid == dev->info.pci_rev_id))
+			return t->marketing_name;
+		t++;
+	}
+
+	return NULL;
+}
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1473693254-3199-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/4 amdgpu: add the interface of waiting multiple fences

From: Junwei Zhang <[email protected]>

---
 amdgpu/amdgpu.h          | 22 +++++++++++++++
 amdgpu/amdgpu_cs.c       | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/amdgpu_drm.h | 27 ++++++++++++++++++
 3 files changed, 121 insertions(+)
amdgpu/amdgpu.h +22 -0
index 7b26a04..e80cb12 100644
@@ -907,6 +907,28 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
 				 uint64_t flags,
 				 uint32_t *expired);
 
+/**
+ *  Wait for multiple fences
+ *
+ * \param   fences      - \c [in] The fence array to wait
+ * \param   fence_count - \c [in] The fence count
+ * \param   wait_all    - \c [in] If true, wait all fences to be signaled,
+ *                                otherwise, wait at least one fence
+ * \param   timeout_ns  - \c [in] The timeout to wait, in nanoseconds
+ * \param   status      - \c [out] '1' for signaled, '0' for timeout
+ *
+ * \return  0 on success
+ *          <0 - Negative POSIX Error code
+ *
+ * \note    Currently it supports only one amdgpu_device. All fences come from
+ *          the same amdgpu_device with the same fd.
+*/
+int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
+			  uint32_t fence_count,
+			  bool wait_all,
+			  uint64_t timeout_ns,
+			  uint32_t *status);
+
 /*
  * Query / Info API
  *
amdgpu/amdgpu_cs.c +72 -0

78 lines not on this page · raw message

include/drm/amdgpu_drm.h +27 -0
index d8f2497..f6f995a 100644
@@ -50,6 +50,7 @@ extern "C" {
 #define DRM_AMDGPU_WAIT_CS		0x09
 #define DRM_AMDGPU_GEM_OP		0x10
 #define DRM_AMDGPU_GEM_USERPTR		0x11
+#define DRM_AMDGPU_WAIT_FENCES		0x12
 
 #define DRM_IOCTL_AMDGPU_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
 #define DRM_IOCTL_AMDGPU_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -63,6 +64,7 @@ extern "C" {
 #define DRM_IOCTL_AMDGPU_WAIT_CS	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)
 #define DRM_IOCTL_AMDGPU_GEM_OP		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)
 #define DRM_IOCTL_AMDGPU_GEM_USERPTR	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
+#define DRM_IOCTL_AMDGPU_WAIT_FENCES	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
 
 #define AMDGPU_GEM_DOMAIN_CPU		0x1
 #define AMDGPU_GEM_DOMAIN_GTT		0x2
@@ -303,6 +305,31 @@ union drm_amdgpu_wait_cs {
 	struct drm_amdgpu_wait_cs_out out;
 };
 
+struct drm_amdgpu_fence {
+	uint32_t ctx_id;
+	uint32_t ip_type;
+	uint32_t ip_instance;
+	uint32_t ring;
+	uint64_t seq_no;
+};
+
+struct drm_amdgpu_wait_fences_in {
+	/** This points to uint64_t * which points to fences */
+	uint64_t fences;
+	uint32_t fence_count;
+	uint32_t wait_all;
+	uint64_t timeout_ns;
+};
+
+struct drm_amdgpu_wait_fences_out {
+	uint64_t status;
+};
+
+union drm_amdgpu_wait_fences {
+	struct drm_amdgpu_wait_fences_in in;
+	struct drm_amdgpu_wait_fences_out out;
+};
+
 #define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO	0
 #define AMDGPU_GEM_OP_SET_PLACEMENT		1
 
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/4 amdgpu/tests: add multi-fence test in base test

In reply to a message not in the archive

From: Junwei Zhang <[email protected]>

---
 tests/amdgpu/basic_tests.c | 100 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
tests/amdgpu/basic_tests.c +100 -0
index 11f6a63..5144e03 100644
@@ -46,6 +46,7 @@ static void amdgpu_memory_alloc(void);
 static void amdgpu_command_submission_gfx(void);
 static void amdgpu_command_submission_compute(void);
 static void amdgpu_command_submission_sdma(void);
+static void amdgpu_command_submission_multi_fence(void);
 static void amdgpu_userptr_test(void);
 static void amdgpu_semaphore_test(void);
 
@@ -60,6 +61,7 @@ CU_TestInfo basic_tests[] = {
 	{ "Command submission Test (GFX)",  amdgpu_command_submission_gfx },
 	{ "Command submission Test (Compute)", amdgpu_command_submission_compute },
 	{ "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
+	{ "Command submission Test (Multi-fence)", amdgpu_command_submission_multi_fence },
 	{ "SW semaphore Test",  amdgpu_semaphore_test },
 	CU_TEST_INFO_NULL,
 };
@@ -1123,6 +1125,104 @@ static void amdgpu_command_submission_sdma(void)
 	amdgpu_command_submission_sdma_copy_linear();
 }
 
+static void amdgpu_command_submission_multi_fence_wait_all(bool wait_all)
+{
+	amdgpu_context_handle context_handle;
+	amdgpu_bo_handle ib_result_handle, ib_result_ce_handle;
+	void *ib_result_cpu, *ib_result_ce_cpu;
+	uint64_t ib_result_mc_address, ib_result_ce_mc_address;
+	struct amdgpu_cs_request ibs_request[2] = {0};
+	struct amdgpu_cs_ib_info ib_info[2];
+	struct amdgpu_cs_fence fence_status[2] = {0};
+	uint32_t *ptr;
+	uint32_t expired;
+	amdgpu_bo_list_handle bo_list;
+	amdgpu_va_handle va_handle, va_handle_ce;
+	int r;
+	int i, ib_cs_num = 2;
+
+	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096,
+				    AMDGPU_GEM_DOMAIN_GTT, 0,
+				    &ib_result_handle, &ib_result_cpu,
+				    &ib_result_mc_address, &va_handle);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_bo_alloc_and_map(device_handle, 4096, 4096,
+				    AMDGPU_GEM_DOMAIN_GTT, 0,
+				    &ib_result_ce_handle, &ib_result_ce_cpu,
+				    &ib_result_ce_mc_address, &va_handle_ce);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_get_bo_list(device_handle, ib_result_handle,
+			       ib_result_ce_handle, &bo_list);
+	CU_ASSERT_EQUAL(r, 0);
+
+	memset(ib_info, 0, 2 * sizeof(struct amdgpu_cs_ib_info));
+
+	/* IT_SET_CE_DE_COUNTERS */
+	ptr = ib_result_ce_cpu;
+	ptr[0] = 0xc0008900;
+	ptr[1] = 0;
+	ptr[2] = 0xc0008400;
+	ptr[3] = 1;
+	ib_info[0].ib_mc_address = ib_result_ce_mc_address;
+	ib_info[0].size = 4;
+	ib_info[0].flags = AMDGPU_IB_FLAG_CE;
+
+	/* IT_WAIT_ON_CE_COUNTER */
+	ptr = ib_result_cpu;
+	ptr[0] = 0xc0008600;
+	ptr[1] = 0x00000001;
+	ib_info[1].ib_mc_address = ib_result_mc_address;
+	ib_info[1].size = 2;
+
+	for (i = 0; i < ib_cs_num; i++) {
+		ibs_request[i].ip_type = AMDGPU_HW_IP_GFX;
+		ibs_request[i].number_of_ibs = 2;
+		ibs_request[i].ibs = ib_info;
+		ibs_request[i].resources = bo_list;
+		ibs_request[i].fence_info.handle = NULL;
+	}
+
+	r = amdgpu_cs_submit(context_handle, 0,ibs_request, ib_cs_num);
+
+	CU_ASSERT_EQUAL(r, 0);
+
+	for (i = 0; i < ib_cs_num; i++) {
+		fence_status[i].context = context_handle;
+		fence_status[i].ip_type = AMDGPU_HW_IP_GFX;
+		fence_status[i].fence = ibs_request[i].seq_no;
+	}
+
+	r = amdgpu_cs_wait_fences(fence_status, ib_cs_num, wait_all,
+				AMDGPU_TIMEOUT_INFINITE,
+				&expired);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
+				     ib_result_mc_address, 4096);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_bo_unmap_and_free(ib_result_ce_handle, va_handle_ce,
+				     ib_result_ce_mc_address, 4096);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_bo_list_destroy(bo_list);
+	CU_ASSERT_EQUAL(r, 0);
+
+	r = amdgpu_cs_ctx_free(context_handle);
+	CU_ASSERT_EQUAL(r, 0);
+}
+
+static void amdgpu_command_submission_multi_fence(void)
+{
+	amdgpu_command_submission_multi_fence_wait_all(true);
+	amdgpu_command_submission_multi_fence_wait_all(false);
+}
+
 static void amdgpu_userptr_test(void)
 {
 	int i, r, j;
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 4/4 amdgpu: cs_wait_fences now can return the first signaled fence index

In reply to a message not in the archive

From: "monk.liu" <[email protected]>

Change-Id Idf3d3bf0f2d2396a77341f97174d0a173fdd8932
---
 amdgpu/amdgpu.h            |  3 ++-
 amdgpu/amdgpu_cs.c         | 12 +++++++++---
 include/drm/amdgpu_drm.h   |  3 ++-
 tests/amdgpu/basic_tests.c |  2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
amdgpu/amdgpu.h +2 -1
index e80cb12..631bcf8 100644
@@ -916,6 +916,7 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
  *                                otherwise, wait at least one fence
  * \param   timeout_ns  - \c [in] The timeout to wait, in nanoseconds
  * \param   status      - \c [out] '1' for signaled, '0' for timeout
+ * \param   first       - \c [out] the index of the first signaled fence from @fences
  *
  * \return  0 on success
  *          <0 - Negative POSIX Error code
@@ -927,7 +928,7 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
 			  uint32_t fence_count,
 			  bool wait_all,
 			  uint64_t timeout_ns,
-			  uint32_t *status);
+			  uint32_t *status, uint32_t *first);
 
 /*
  * Query / Info API
amdgpu/amdgpu_cs.c +9 -3
index 0c9bcc4..b29e8c9 100644
@@ -447,7 +447,8 @@ static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,
 				    uint32_t fence_count,
 				    bool wait_all,
 				    uint64_t timeout_ns,
-				    uint32_t *status)
+				    uint32_t *status,
+				    uint32_t *first)
 {
 	struct drm_amdgpu_fence *drm_fences;
 	amdgpu_device_handle dev = fences[0].context->dev;
@@ -475,6 +476,10 @@ static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,
 		return -errno;
 
 	*status = args.out.status;
+
+	if (first)
+		*first = args.out.first_signaled;
+
 	return 0;
 }
 
@@ -482,7 +487,8 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
 			  uint32_t fence_count,
 			  bool wait_all,
 			  uint64_t timeout_ns,
-			  uint32_t *status)
+			  uint32_t *status,
+			  uint32_t *first)
 {
 	uint32_t ioctl_status = 0;
 	uint32_t i;
@@ -507,7 +513,7 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
 	*status = 0;
 
 	r = amdgpu_ioctl_wait_fences(fences, fence_count, wait_all, timeout_ns,
-					&ioctl_status);
+					&ioctl_status, first);
 
 	if (!r)
 		*status = ioctl_status;
include/drm/amdgpu_drm.h +2 -1
index f6f995a..3e7397f 100644
@@ -322,7 +322,8 @@ struct drm_amdgpu_wait_fences_in {
 };
 
 struct drm_amdgpu_wait_fences_out {
-	uint64_t status;
+	uint32_t status;
+	uint32_t first_signaled;
 };
 
 union drm_amdgpu_wait_fences {
tests/amdgpu/basic_tests.c +1 -1
index 5144e03..877a789 100644
@@ -1199,7 +1199,7 @@ static void amdgpu_command_submission_multi_fence_wait_all(bool wait_all)
 
 	r = amdgpu_cs_wait_fences(fence_status, ib_cs_num, wait_all,
 				AMDGPU_TIMEOUT_INFINITE,
-				&expired);
+				&expired, NULL);
 	CU_ASSERT_EQUAL(r, 0);
 
 	r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#5 lore raw
In reply to a message not in the archive
Quoted 6 lines · Alex Deucher

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.

As is, this breaks make check:

Quoted 1 line

+struct amdgpu_asic_id_table_t {

Make this static, so the amdgpu_asic_id_table_t symbol doesn't get exported from libdrm_amdgpu.

BTW, is there any particular reason for putting this table in a separate header file?

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 308

Quoted 6 lines
amdgpu/amdgpu_device.c +2 -0
@@ -303,3 +304,17 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)

amdgpu_get_marketing_name needs to be added to amdgpu-symbols-check.

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 314

Quoted 2 lines
amdgpu/amdgpu_device.c +2 -0
+		if ((t->did == dev->info.asic_id) &&
+				(t->rid == dev->info.pci_rev_id))

Wrong indentation of the second line.

With these issues fixed,

Would be nice to land this in master soon, as we're going to use it in
xf86-video-amdgpu: https://patchwork.freedesktop.org/patch/119501/

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

A message that is not in the archive (sent off-list or not yet received): 7d554227-df5a-5f5b-65f0-0497a45430c0-otUistvHUpPR7s880joybQ@public.gmane.org

#7 lore raw
Quoted 36 lines · Michel Dänzer
Quoted 6 lines · Alex Deucher

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.

As is, this breaks make check:

Quoted 1 line

+struct amdgpu_asic_id_table_t {

Make this static, so the amdgpu_asic_id_table_t symbol doesn't get exported from libdrm_amdgpu.

BTW, is there any particular reason for putting this table in a separate header file?

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 308

Quoted 6 lines
amdgpu/amdgpu_device.c +2 -0
@@ -303,3 +304,17 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)

amdgpu_get_marketing_name needs to be added to amdgpu-symbols-check.

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 314

Quoted 2 lines
amdgpu/amdgpu_device.c +2 -0
+		if ((t->did == dev->info.asic_id) &&
+				(t->rid == dev->info.pci_rev_id))

Wrong indentation of the second line.

Quoted 6 lines

With these issues fixed,

Would be nice to land this in master soon, as we're going to use it in
xf86-video-amdgpu: https://patchwork.freedesktop.org/patch/119501/

Junwei, if it's okay with you, I can amend the patch and push it to master.

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

A message that is not in the archive (sent off-list or not yet received): d7c69d78-eac0-7a85-83c6-348e4a60095f-otUistvHUpPR7s880joybQ@public.gmane.org

#9 lore raw
Quoted 48 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Tuesday, November 01, 2016 11:51 PM
To: Alex Deucher
Cc: Zhang, Jerry; [email protected]
Subject: Re: [1/4] amdgpu: add the function to get the marketing name (v2)

Quoted 13 lines · Michel Dänzer
Quoted 6 lines · Alex Deucher

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.

As is, this breaks make check:

Quoted 1 line

+struct amdgpu_asic_id_table_t {

Quoted 8 lines

Make this static, so the amdgpu_asic_id_table_t symbol doesn't get exported from libdrm_amdgpu.

BTW, is there any particular reason for putting this table in a separate header file?

Review int

Quoted 1 line
(quoted diff) +0 -0
@@ -303,3 +304,17 @@ int

amdgpu_device_deinitialize(amdgpu_device_handle dev)

Quoted 5 lines

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev)

Quoted 5 lines
amdgpu/amdgpu_device.c +2 -0
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle

dev)

Quoted 2 lines

amdgpu_get_marketing_name needs to be added to amdgpu-symbols-

check.

Quoted 8 lines

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 314

Quoted 4 lines
amdgpu/amdgpu_device.c +2 -0
+		if ((t->did == dev->info.asic_id) &&
+				(t->rid == dev->info.pci_rev_id))

Wrong indentation of the second line.

Quoted 8 lines
Quoted 6 lines

With these issues fixed,

Would be nice to land this in master soon, as we're going to use it in
xf86-video-amdgpu: https://patchwork.freedesktop.org/patch/119501/

Junwei, if it's okay with you, I can amend the patch and push it to master.

You might double check the internal git tree and pick up any additional marketing names that were added since I pulled those patches.

Alex

Quoted 9 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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MWHPR12MB169438F64A198BAF8CA22E94F7A00-Gy0DoCVfaSW4WA4dJ5YXGAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#11 lore raw
Quoted 50 lines · Alexander
Quoted 50 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Tuesday, November 01, 2016 11:51 PM
To: Alex Deucher
Cc: Zhang, Jerry; [email protected]
Subject: Re: [1/4] amdgpu: add the function to get the marketing name (v2)

Quoted 13 lines · Michel Dänzer
Quoted 6 lines · Alex Deucher

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.

As is, this breaks make check:

Quoted 1 line

+struct amdgpu_asic_id_table_t {

Quoted 8 lines

Make this static, so the amdgpu_asic_id_table_t symbol doesn't get exported from libdrm_amdgpu.

BTW, is there any particular reason for putting this table in a separate header file?

Review int

Quoted 1 line
(quoted diff) +0 -0
@@ -303,3 +304,17 @@ int

amdgpu_device_deinitialize(amdgpu_device_handle dev)

Quoted 5 lines

Review int · line 308

Quoted 5 lines
(quoted diff) +2 -0
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle

dev)

Quoted 2 lines

amdgpu_get_marketing_name needs to be added to amdgpu-symbols-

check.

Quoted 10 lines

Review int · line 310

Quoted 4 lines
(quoted diff) +2 -0
+		if ((t->did == dev->info.asic_id) &&
+				(t->rid == dev->info.pci_rev_id))

Wrong indentation of the second line.

With these issues fixed,

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Would be nice to land this in master soon, as we're going to use it in
xf86-video-amdgpu: https://patchwork.freedesktop.org/patch/119501/

Junwei, if it's okay with you, I can amend the patch and push it to master.

You might double check the internal git tree and pick up any additional marketing names that were added since I pulled those patches.

Done (no new entries have been added, but a few redundant ones have been removed), thanks. v3 patch submitted for review.

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
#12 lore raw

PATCH 1/1 amdgpu: add the function to get the marketing name (v3)

In reply to a message not in the archive

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.
v3: [Michel Dänzer]
* Make amdgpu_asic_id_table static, so it's not exported from libdrm_amdgpu.so.1
* Add amdgpu_get_marketing_name to amdgpu-symbols-check
* Fix indentation of second line of if statement
* Squash in another change removing redundant entries
* Change spelling of "RADEON" -> "Radeon"
* Remove "(TM)" from a minority of entries

---

This will be used by https://patchwork.freedesktop.org/patch/119501/ .

 amdgpu/amdgpu-symbol-check |   1 +
 amdgpu/amdgpu.h            |  10 +++
 amdgpu/amdgpu_asic_id.h    | 165 +++++++++++++++++++++++++++++++++++++++++++++
 amdgpu/amdgpu_device.c     |  15 +++++
 4 files changed, 191 insertions(+)
 create mode 100644 amdgpu/amdgpu_asic_id.h
amdgpu/amdgpu-symbol-check +1 -0
index 648db9b..87f4fd2 100755
@@ -35,6 +35,7 @@ amdgpu_cs_submit
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
+amdgpu_get_marketing_name
 amdgpu_query_buffer_size_alignment
 amdgpu_query_crtc_from_id
 amdgpu_query_firmware_version
amdgpu/amdgpu.h +10 -0
index 5d5a2c6..7b26a04 100644
@@ -1245,4 +1245,14 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 */
 int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
 
+/**
+ *  Get the ASIC marketing name
+ *
+ * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
+ *
+ * \return  the constant string of the marketing name
+ *          "NULL" means the ASIC is not found
+*/
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev);
+
 #endif /* #ifdef _AMDGPU_H_ */
amdgpu/amdgpu_asic_id.h new file +165 -0

165 lines not on this page · raw message

amdgpu/amdgpu_device.c +15 -0
index e5a923e..f4ede03 100644
@@ -44,6 +44,7 @@
 #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)))
@@ -303,3 +304,17 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
+{
+	const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table;
+
+	while (t->did) {
+		if ((t->did == dev->info.asic_id) &&
+		    (t->rid == dev->info.pci_rev_id))
+			return t->marketing_name;
+		t++;
+	}
+
+	return NULL;
+}
Signature · 6 lines
2.10.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20161107090913.2464-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#14 lore raw

Re: [PATCH libdrm] amdgpu: add the function to get the marketing name (v3)

Am 07.11.2016 um 10:09 schrieb Michel Dänzer:

Quoted 15 lines

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.
v3: [Michel Dänzer]
* Make amdgpu_asic_id_table static, so it's not exported from libdrm_amdgpu.so.1
* Add amdgpu_get_marketing_name to amdgpu-symbols-check
* Fix indentation of second line of if statement
* Squash in another change removing redundant entries
* Change spelling of "RADEON" -> "Radeon"
* Remove "(TM)" from a minority of entries

Quoted 3 lines
Quoted 233 lines

---

This will be used by https://patchwork.freedesktop.org/patch/119501/ .

  amdgpu/amdgpu-symbol-check |   1 +
  amdgpu/amdgpu.h            |  10 +++
  amdgpu/amdgpu_asic_id.h    | 165 +++++++++++++++++++++++++++++++++++++++++++++
  amdgpu/amdgpu_device.c     |  15 +++++
  4 files changed, 191 insertions(+)

create mode 100644 amdgpu/amdgpu_asic_id.h

amdgpu/amdgpu-symbol-check +1 -0
index 648db9b..87f4fd2 100755
@@ -35,6 +35,7 @@ amdgpu_cs_submit
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
+amdgpu_get_marketing_name
  amdgpu_query_buffer_size_alignment
  amdgpu_query_crtc_from_id
  amdgpu_query_firmware_version
amdgpu/amdgpu.h +10 -0
index 5d5a2c6..7b26a04 100644
@@ -1245,4 +1245,14 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
  */
  int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
 
+/**
+ *  Get the ASIC marketing name
+ *
+ * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
+ *
+ * \return  the constant string of the marketing name
+ *          "NULL" means the ASIC is not found
+*/
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev);
+
  #endif /* #ifdef _AMDGPU_H_ */
amdgpu/amdgpu_asic_id.h new file +165 -0
new file mode 100644
index 0000000..f477875
@@ -0,0 +1,165 @@
+/*
+ * Copyright © 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __AMDGPU_ASIC_ID_H__
+#define __AMDGPU_ASIC_ID_H__
+
+static struct amdgpu_asic_id_table_t {
+	uint32_t did;
+	uint32_t rid;
+	char marketing_name[64];
+} const amdgpu_asic_id_table [] = {
+	{0x6600,	0x0,	"AMD Radeon HD 8600/8700M"},
+	{0x6600,	0x81,	"AMD Radeon R7 M370"},
+	{0x6601,	0x0,	"AMD Radeon HD 8500M/8700M"},
+	{0x6604,	0x0,	"AMD Radeon R7 M265 Series"},
+	{0x6604,	0x81,	"AMD Radeon R7 M350"},
+	{0x6605,	0x0,	"AMD Radeon R7 M260 Series"},
+	{0x6605,	0x81,	"AMD Radeon R7 M340"},
+	{0x6606,	0x0,	"AMD Radeon HD 8790M"},
+	{0x6607,	0x0,	"AMD Radeon HD8530M"},
+	{0x6608,	0x0,	"AMD FirePro W2100"},
+	{0x6610,	0x0,	"AMD Radeon HD 8600 Series"},
+	{0x6610,	0x81,	"AMD Radeon R7 350"},
+	{0x6610,	0x83,	"AMD Radeon R5 340"},
+	{0x6611,	0x0,	"AMD Radeon HD 8500 Series"},
+	{0x6613,	0x0,	"AMD Radeon HD 8500 series"},
+	{0x6617,	0xC7,	"AMD Radeon R7 240 Series"},
+	{0x6640,	0x0,	"AMD Radeon HD 8950"},
+	{0x6640,	0x80,	"AMD Radeon R9 M380"},
+	{0x6646,	0x0,	"AMD Radeon R9 M280X"},
+	{0x6646,	0x80,	"AMD Radeon R9 M470X"},
+	{0x6647,	0x0,	"AMD Radeon R9 M270X"},
+	{0x6647,	0x80,	"AMD Radeon R9 M380"},
+	{0x6649,	0x0,	"AMD FirePro W5100"},
+	{0x6658,	0x0,	"AMD Radeon R7 200 Series"},
+	{0x665C,	0x0,	"AMD Radeon HD 7700 Series"},
+	{0x665D,	0x0,	"AMD Radeon R7 200 Series"},
+	{0x665F,	0x81,	"AMD Radeon R7 300 Series"},
+	{0x6660,	0x0,	"AMD Radeon HD 8600M Series"},
+	{0x6660,	0x81,	"AMD Radeon R5 M335"},
+	{0x6660,	0x83,	"AMD Radeon R5 M330"},
+	{0x6663,	0x0,	"AMD Radeon HD 8500M Series"},
+	{0x6663,	0x83,	"AMD Radeon R5 M320"},
+	{0x6664,	0x0,	"AMD Radeon R5 M200 Series"},
+	{0x6665,	0x0,	"AMD Radeon R5 M200 Series"},
+	{0x6665,	0x83,	"AMD Radeon R5 M320"},
+	{0x6667,	0x0,	"AMD Radeon R5 M200 Series"},
+	{0x666F,	0x0,	"AMD Radeon HD 8500M"},
+	{0x6780,	0x0,	"ATI FirePro V (FireGL V) Graphics Adapter"},
+	{0x678A,	0x0,	"ATI FirePro V (FireGL V) Graphics Adapter"},
+	{0x6798,	0x0,	"AMD Radeon HD 7900 Series"},
+	{0x679A,	0x0,	"AMD Radeon HD 7900 Series"},
+	{0x679B,	0x0,	"AMD Radeon HD 7900 Series"},
+	{0x679E,	0x0,	"AMD Radeon HD 7800 Series"},
+	{0x67A0,	0x0,	"HAWAII XTGL (67A0)"},
+	{0x67A1,	0x0,	"HAWAII GL40 (67A1)"},
+	{0x67B0,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x67B0,	0x80,	"AMD Radeon R9 390 Series"},
+	{0x67B1,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x67B1,	0x80,	"AMD Radeon R9 390 Series"},
+	{0x67B9,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x67DF,	0xC4,	"AMD Radeon RX 480 Graphics"},
+	{0x67DF,	0xC5,	"AMD Radeon RX 470 Graphics"},
+	{0x67DF,	0xC7,	"AMD Radeon RX 480 Graphics"},
+	{0x67DF,	0xCF,	"AMD Radeon RX 470 Graphics"},
+	{0x67C4,	0x00,	"AMD Radeon Pro WX 7100 Graphics"},
+	{0x67C7,	0x00,	"AMD Radeon Pro WX 5100 Graphics"},
+	{0x67C0,	0x00,	"AMD Radeon Pro WX 7100 Graphics"},
+	{0x67E0,	0x00,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67E3,	0x00,	"AMD Radeon Pro WX 4100 Graphics"},
+	{0x67E8,	0x00,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67E8,	0x01,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67E8,	0x80,	"AMD Radeon E9260 Graphics"},
+	{0x67EB,	0x00,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67EF,	0xC0,	"AMD Radeon RX Graphics"},
+	{0x67EF,	0xC1,	"AMD Radeon RX 460 Graphics"},
+	{0x67EF,	0xC5,	"AMD Radeon RX 460 Graphics"},
+	{0x67EF,	0xC7,	"AMD Radeon RX Graphics"},
+	{0x67EF,	0xCF,	"AMD Radeon RX 460 Graphics"},
+	{0x67EF,	0xEF,	"AMD Radeon RX Graphics"},
+	{0x67FF,	0xC0,	"AMD Radeon RX Graphics"},
+	{0x67FF,	0xC1,	"AMD Radeon RX Graphics"},
+	{0x6800,	0x0,	"AMD Radeon HD 7970M"},
+	{0x6801,	0x0,	"AMD Radeon(TM) HD8970M"},
+	{0x6808,	0x0,	"ATI FirePro V(FireGL V) Graphics Adapter"},
+	{0x6809,	0x0,	"ATI FirePro V(FireGL V) Graphics Adapter"},
+	{0x6810,	0x0,	"AMD Radeon(TM) HD 8800 Series"},
+	{0x6810,	0x81,	"AMD Radeon R7 370 Series"},
+	{0x6811,	0x0,	"AMD Radeon(TM) HD8800 Series"},
+	{0x6811,	0x81,	"AMD Radeon R7 300 Series"},
+	{0x6818,	0x0,	"AMD Radeon HD 7800 Series"},
+	{0x6819,	0x0,	"AMD Radeon HD 7800 Series"},
+	{0x6820,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x6820,	0x81,	"AMD Radeon R9 M375"},
+	{0x6820,	0x83,	"AMD Radeon R9 M375X"},
+	{0x6821,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x6821,	0x87,	"AMD Radeon R7 M380"},
+	{0x6821,	0x83,	"AMD Radeon R9 M370X"},
+	{0x6822,	0x0,	"AMD Radeon E8860"},
+	{0x6823,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x6825,	0x0,	"AMD Radeon HD 7800M Series"},
+	{0x6827,	0x0,	"AMD Radeon HD 7800M Series"},
+	{0x6828,	0x0,	"ATI FirePro V(FireGL V) Graphics Adapter"},
+	{0x682B,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x682B,	0x87,	"AMD Radeon R9 M360"},
+	{0x682C,	0x0,	"AMD FirePro W4100"},
+	{0x682D,	0x0,	"AMD Radeon HD 7700M Series"},
+	{0x682F,	0x0,	"AMD Radeon HD 7700M Series"},
+	{0x6835,	0x0,	"AMD Radeon R7 Series / HD 9000 Series"},
+	{0x6837,	0x0,	"AMD Radeon HD7700 Series"},
+	{0x683D,	0x0,	"AMD Radeon HD 7700 Series"},
+	{0x683F,	0x0,	"AMD Radeon HD 7700 Series"},
+	{0x6900,	0x0,	"AMD Radeon R7 M260"},
+	{0x6900,	0x81,	"AMD Radeon R7 M360"},
+	{0x6900,	0x83,	"AMD Radeon R7 M340"},
+	{0x6901,	0x0,	"AMD Radeon R5 M255"},
+	{0x6907,	0x0,	"AMD Radeon R5 M255"},
+	{0x6907,	0x87,	"AMD Radeon R5 M315"},
+	{0x6920,	0x0,	"AMD Radeon R9 M395X"},
+	{0x6920,	0x1,	"AMD Radeon R9 M390X"},
+	{0x6921,	0x0,	"AMD Radeon R9 M295X"},
+	{0x6929,	0x0,	"AMD FirePro S7150"},
+	{0x692B,	0x0,	"AMD FirePro W7100"},
+	{0x6938,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x6938,	0xF0,	"AMD Radeon R9 200 Series"},
+	{0x6938,	0xF1,	"AMD Radeon R9 380 Series"},
+	{0x6939,	0xF0,	"AMD Radeon R9 200 Series"},
+	{0x6939,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x6939,	0xF1,	"AMD Radeon R9 380 Series"},
+	{0x7300,	0xC8,	"AMD Radeon R9 Fury Series"},
+	{0x7300,	0xCB,	"AMD Radeon R9 Fury Series"},
+	{0x7300,	0xCA,	"AMD Radeon R9 Fury Series"},
+	{0x9874,	0xC4,	"AMD Radeon R7 Graphics"},
+	{0x9874,	0xC5,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0xC6,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0xC7,	"AMD Radeon R5 Graphics"},
+	{0x9874,	0x81,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0x87,	"AMD Radeon R5 Graphics"},
+	{0x9874,	0x85,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0x84,	"AMD Radeon R7 Graphics"},
+
+	{0x0000,	0x0,	"\0"},
+};
+#endif
amdgpu/amdgpu_device.c +5 -0
index e5a923e..f4ede03 100644
@@ -44,6 +44,7 @@
  #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)))
@@ -303,3 +304,17 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
  	amdgpu_device_reference(&dev, NULL);
  	return 0;
  }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
+{
+	const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table;

amdgpu/amdgpu_device.c int amdgpu_device_deinitialize(amdgpu_device_handle dev) · line 320

Quoted 10 lines
amdgpu/amdgpu_device.c +10 -0
+
+	while (t->did) {
+		if ((t->did == dev->info.asic_id) &&
+		    (t->rid == dev->info.pci_rev_id))
+			return t->marketing_name;
+		t++;
+	}
+
+	return NULL;
+}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#15 lore raw

Re: [PATCH libdrm] amdgpu: add the function to get the marketing name (v3)

In reply to a message not in the archive

amdgpu/amdgpu_asic_id.h line 31

Quoted 4 lines · Michel Dänzer
amdgpu/amdgpu_asic_id.h new file +4 -0
+static struct amdgpu_asic_id_table_t {
+       uint32_t did;
+       uint32_t rid;
+       char marketing_name[64];

Using a char * here might be a better. From a quick look [64] is quite wasteful.

-Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CACvgo53qtudiZhM2gDq9dXp1NfE6FZmKPaqEHyqPgdoDy6Y3Rg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#17 lore raw

Re: [PATCH libdrm] amdgpu: add the function to get the marketing name (v3)

Quoted 8 lines · Emil Velikov

amdgpu/amdgpu_asic_id.h line 31

Quoted 4 lines · Michel Dänzer
amdgpu/amdgpu_asic_id.h new file +4 -0
+static struct amdgpu_asic_id_table_t {
+       uint32_t did;
+       uint32_t rid;
+       char marketing_name[64];

Using a char * here might be a better. From a quick look [64] is quite wasteful.

By "quite wasteful" I meant ~doubling the binary .text size. Some sample numbers which I should have mentioned earlier :-\

text data bss dec hex filename

 10587     552       8   11147    2b8b ./a.out.fixed-size
  5227     552       8    5787    169b ./a.out.char-star

Regards,
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CACvgo53Ld6R3qw-fsgPy=gVP8bfDVZqvOrmUzfAvyy2mbZK_gQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#19 lore raw

Re: [PATCH libdrm] amdgpu: add the function to get the marketing name (v3)

Quoted 7 lines · Emil Velikov
Quoted 6 lines · Emil Velikov
Quoted 4 lines · Michel Dänzer
amdgpu/amdgpu_asic_id.h new file +4 -0
+static struct amdgpu_asic_id_table_t {
+       uint32_t did;
+       uint32_t rid;
+       char marketing_name[64];
Quoted 8 lines
Quoted 2 lines

Using a char * here might be a better. From a quick look [64] is quite wasteful.

By "quite wasteful" I meant ~doubling the binary .text size. Some sample numbers which I should have mentioned earlier :-\

text data bss dec hex filename

 10587     552       8   11147    2b8b ./a.out.fixed-size
  5227     552       8    5787    169b ./a.out.char-star

Good catch, pushed v4 with this changed to const char *, thanks!

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
Reviewed-by Alex Deucher
#20 lore raw

RE: [PATCH libdrm] amdgpu: add the function to get the marketing name (v3)

In reply to a message not in the archive
Quoted 24 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Michel Dänzer
Sent: Monday, November 07, 2016 4:09 AM
To: [email protected]
Cc: Zhang, Jerry
Subject: [PATCH libdrm] amdgpu: add the function to get the marketing name (v3)

From: Junwei Zhang <[email protected]>

This function is used to look up the marking name
for a specific board.

v2: agd: Squash in subsequent updates to the table.
v3: [Michel Dänzer]
* Make amdgpu_asic_id_table static, so it's not exported from libdrm_amdgpu.so.1
* Add amdgpu_get_marketing_name to amdgpu-symbols-check
* Fix indentation of second line of if statement
* Squash in another change removing redundant entries
* Change spelling of "RADEON" -> "Radeon"
* Remove "(TM)" from a minority of entries

Quoted 3 lines
Quoted 257 lines

---

This will be used by https://patchwork.freedesktop.org/patch/119501/ .

 amdgpu/amdgpu-symbol-check |   1 +
 amdgpu/amdgpu.h            |  10 +++
 amdgpu/amdgpu_asic_id.h    | 165
+++++++++++++++++++++++++++++++++++++++++++++
 amdgpu/amdgpu_device.c     |  15 +++++
 4 files changed, 191 insertions(+)
 create mode 100644 amdgpu/amdgpu_asic_id.h
amdgpu/amdgpu-symbol- renamed from amdgpu/amdgpu-symbol-check +0 -0

check
index 648db9b..87f4fd2 100755

amdgpu/amdgpu-symbol-check +1 -0
@@ -35,6 +35,7 @@ amdgpu_cs_submit
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
+amdgpu_get_marketing_name
 amdgpu_query_buffer_size_alignment
 amdgpu_query_crtc_from_id
 amdgpu_query_firmware_version
amdgpu/amdgpu.h +10 -0
index 5d5a2c6..7b26a04 100644
@@ -1245,4 +1245,14 @@ int
 amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 */
 int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
 
+/**
+ *  Get the ASIC marketing name
+ *
+ * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
+ *
+ * \return  the constant string of the marketing name
+ *          "NULL" means the ASIC is not found
+*/
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev);
+

#endif /* #ifdef _AMDGPU_H_ */

amdgpu/amdgpu_asic_id.h new file +6 -0
new file mode 100644
index 0000000..f477875
@@ -0,0 +1,165 @@
+/*
+ * Copyright © 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the

"Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */

amdgpu/amdgpu_asic_id.h new file +142 -0
+
+#ifndef __AMDGPU_ASIC_ID_H__
+#define __AMDGPU_ASIC_ID_H__
+
+static struct amdgpu_asic_id_table_t {
+	uint32_t did;
+	uint32_t rid;
+	char marketing_name[64];
+} const amdgpu_asic_id_table [] = {
+	{0x6600,	0x0,	"AMD Radeon HD 8600/8700M"},
+	{0x6600,	0x81,	"AMD Radeon R7 M370"},
+	{0x6601,	0x0,	"AMD Radeon HD 8500M/8700M"},
+	{0x6604,	0x0,	"AMD Radeon R7 M265 Series"},
+	{0x6604,	0x81,	"AMD Radeon R7 M350"},
+	{0x6605,	0x0,	"AMD Radeon R7 M260 Series"},
+	{0x6605,	0x81,	"AMD Radeon R7 M340"},
+	{0x6606,	0x0,	"AMD Radeon HD 8790M"},
+	{0x6607,	0x0,	"AMD Radeon HD8530M"},
+	{0x6608,	0x0,	"AMD FirePro W2100"},
+	{0x6610,	0x0,	"AMD Radeon HD 8600 Series"},
+	{0x6610,	0x81,	"AMD Radeon R7 350"},
+	{0x6610,	0x83,	"AMD Radeon R5 340"},
+	{0x6611,	0x0,	"AMD Radeon HD 8500 Series"},
+	{0x6613,	0x0,	"AMD Radeon HD 8500 series"},
+	{0x6617,	0xC7,	"AMD Radeon R7 240 Series"},
+	{0x6640,	0x0,	"AMD Radeon HD 8950"},
+	{0x6640,	0x80,	"AMD Radeon R9 M380"},
+	{0x6646,	0x0,	"AMD Radeon R9 M280X"},
+	{0x6646,	0x80,	"AMD Radeon R9 M470X"},
+	{0x6647,	0x0,	"AMD Radeon R9 M270X"},
+	{0x6647,	0x80,	"AMD Radeon R9 M380"},
+	{0x6649,	0x0,	"AMD FirePro W5100"},
+	{0x6658,	0x0,	"AMD Radeon R7 200 Series"},
+	{0x665C,	0x0,	"AMD Radeon HD 7700 Series"},
+	{0x665D,	0x0,	"AMD Radeon R7 200 Series"},
+	{0x665F,	0x81,	"AMD Radeon R7 300 Series"},
+	{0x6660,	0x0,	"AMD Radeon HD 8600M Series"},
+	{0x6660,	0x81,	"AMD Radeon R5 M335"},
+	{0x6660,	0x83,	"AMD Radeon R5 M330"},
+	{0x6663,	0x0,	"AMD Radeon HD 8500M Series"},
+	{0x6663,	0x83,	"AMD Radeon R5 M320"},
+	{0x6664,	0x0,	"AMD Radeon R5 M200 Series"},
+	{0x6665,	0x0,	"AMD Radeon R5 M200 Series"},
+	{0x6665,	0x83,	"AMD Radeon R5 M320"},
+	{0x6667,	0x0,	"AMD Radeon R5 M200 Series"},
+	{0x666F,	0x0,	"AMD Radeon HD 8500M"},
+	{0x6780,	0x0,	"ATI FirePro V (FireGL V) Graphics Adapter"},
+	{0x678A,	0x0,	"ATI FirePro V (FireGL V) Graphics Adapter"},
+	{0x6798,	0x0,	"AMD Radeon HD 7900 Series"},
+	{0x679A,	0x0,	"AMD Radeon HD 7900 Series"},
+	{0x679B,	0x0,	"AMD Radeon HD 7900 Series"},
+	{0x679E,	0x0,	"AMD Radeon HD 7800 Series"},
+	{0x67A0,	0x0,	"HAWAII XTGL (67A0)"},
+	{0x67A1,	0x0,	"HAWAII GL40 (67A1)"},
+	{0x67B0,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x67B0,	0x80,	"AMD Radeon R9 390 Series"},
+	{0x67B1,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x67B1,	0x80,	"AMD Radeon R9 390 Series"},
+	{0x67B9,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x67DF,	0xC4,	"AMD Radeon RX 480 Graphics"},
+	{0x67DF,	0xC5,	"AMD Radeon RX 470 Graphics"},
+	{0x67DF,	0xC7,	"AMD Radeon RX 480 Graphics"},
+	{0x67DF,	0xCF,	"AMD Radeon RX 470 Graphics"},
+	{0x67C4,	0x00,	"AMD Radeon Pro WX 7100 Graphics"},
+	{0x67C7,	0x00,	"AMD Radeon Pro WX 5100 Graphics"},
+	{0x67C0,	0x00,	"AMD Radeon Pro WX 7100 Graphics"},
+	{0x67E0,	0x00,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67E3,	0x00,	"AMD Radeon Pro WX 4100 Graphics"},
+	{0x67E8,	0x00,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67E8,	0x01,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67E8,	0x80,	"AMD Radeon E9260 Graphics"},
+	{0x67EB,	0x00,	"AMD Radeon Pro WX Series Graphics"},
+	{0x67EF,	0xC0,	"AMD Radeon RX Graphics"},
+	{0x67EF,	0xC1,	"AMD Radeon RX 460 Graphics"},
+	{0x67EF,	0xC5,	"AMD Radeon RX 460 Graphics"},
+	{0x67EF,	0xC7,	"AMD Radeon RX Graphics"},
+	{0x67EF,	0xCF,	"AMD Radeon RX 460 Graphics"},
+	{0x67EF,	0xEF,	"AMD Radeon RX Graphics"},
+	{0x67FF,	0xC0,	"AMD Radeon RX Graphics"},
+	{0x67FF,	0xC1,	"AMD Radeon RX Graphics"},
+	{0x6800,	0x0,	"AMD Radeon HD 7970M"},
+	{0x6801,	0x0,	"AMD Radeon(TM) HD8970M"},
+	{0x6808,	0x0,	"ATI FirePro V(FireGL V) Graphics Adapter"},
+	{0x6809,	0x0,	"ATI FirePro V(FireGL V) Graphics Adapter"},
+	{0x6810,	0x0,	"AMD Radeon(TM) HD 8800 Series"},
+	{0x6810,	0x81,	"AMD Radeon R7 370 Series"},
+	{0x6811,	0x0,	"AMD Radeon(TM) HD8800 Series"},
+	{0x6811,	0x81,	"AMD Radeon R7 300 Series"},
+	{0x6818,	0x0,	"AMD Radeon HD 7800 Series"},
+	{0x6819,	0x0,	"AMD Radeon HD 7800 Series"},
+	{0x6820,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x6820,	0x81,	"AMD Radeon R9 M375"},
+	{0x6820,	0x83,	"AMD Radeon R9 M375X"},
+	{0x6821,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x6821,	0x87,	"AMD Radeon R7 M380"},
+	{0x6821,	0x83,	"AMD Radeon R9 M370X"},
+	{0x6822,	0x0,	"AMD Radeon E8860"},
+	{0x6823,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x6825,	0x0,	"AMD Radeon HD 7800M Series"},
+	{0x6827,	0x0,	"AMD Radeon HD 7800M Series"},
+	{0x6828,	0x0,	"ATI FirePro V(FireGL V) Graphics Adapter"},
+	{0x682B,	0x0,	"AMD Radeon HD 8800M Series"},
+	{0x682B,	0x87,	"AMD Radeon R9 M360"},
+	{0x682C,	0x0,	"AMD FirePro W4100"},
+	{0x682D,	0x0,	"AMD Radeon HD 7700M Series"},
+	{0x682F,	0x0,	"AMD Radeon HD 7700M Series"},
+	{0x6835,	0x0,	"AMD Radeon R7 Series / HD 9000 Series"},
+	{0x6837,	0x0,	"AMD Radeon HD7700 Series"},
+	{0x683D,	0x0,	"AMD Radeon HD 7700 Series"},
+	{0x683F,	0x0,	"AMD Radeon HD 7700 Series"},
+	{0x6900,	0x0,	"AMD Radeon R7 M260"},
+	{0x6900,	0x81,	"AMD Radeon R7 M360"},
+	{0x6900,	0x83,	"AMD Radeon R7 M340"},
+	{0x6901,	0x0,	"AMD Radeon R5 M255"},
+	{0x6907,	0x0,	"AMD Radeon R5 M255"},
+	{0x6907,	0x87,	"AMD Radeon R5 M315"},
+	{0x6920,	0x0,	"AMD Radeon R9 M395X"},
+	{0x6920,	0x1,	"AMD Radeon R9 M390X"},
+	{0x6921,	0x0,	"AMD Radeon R9 M295X"},
+	{0x6929,	0x0,	"AMD FirePro S7150"},
+	{0x692B,	0x0,	"AMD FirePro W7100"},
+	{0x6938,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x6938,	0xF0,	"AMD Radeon R9 200 Series"},
+	{0x6938,	0xF1,	"AMD Radeon R9 380 Series"},
+	{0x6939,	0xF0,	"AMD Radeon R9 200 Series"},
+	{0x6939,	0x0,	"AMD Radeon R9 200 Series"},
+	{0x6939,	0xF1,	"AMD Radeon R9 380 Series"},
+	{0x7300,	0xC8,	"AMD Radeon R9 Fury Series"},
+	{0x7300,	0xCB,	"AMD Radeon R9 Fury Series"},
+	{0x7300,	0xCA,	"AMD Radeon R9 Fury Series"},
+	{0x9874,	0xC4,	"AMD Radeon R7 Graphics"},
+	{0x9874,	0xC5,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0xC6,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0xC7,	"AMD Radeon R5 Graphics"},
+	{0x9874,	0x81,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0x87,	"AMD Radeon R5 Graphics"},
+	{0x9874,	0x85,	"AMD Radeon R6 Graphics"},
+	{0x9874,	0x84,	"AMD Radeon R7 Graphics"},
+
+	{0x0000,	0x0,	"\0"},
+};
+#endif
amdgpu/amdgpu_device.c +15 -1
index e5a923e..f4ede03 100644
@@ -44,6 +44,7 @@
 #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)))
@@ -303,3 +304,17 @@ int
 amdgpu_device_deinitialize(amdgpu_device_handle dev)
 	amdgpu_device_reference(&dev, NULL);
 	return 0;
 }
+
+const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
+{
+	const struct amdgpu_asic_id_table_t *t = amdgpu_asic_id_table;
+
+	while (t->did) {
+		if ((t->did == dev->info.asic_id) &&
+		    (t->rid == dev->info.pci_rev_id))
+			return t->marketing_name;
+		t++;
+	}
+
+	return NULL;
+}
--

2.10.2

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx