Skip to contentSkip to conversation

util: move some files to an ASIC neutral directory.

PATCH In review Samuel Li 2 participants 2 messages Jun 30, 2017 – Jul 5, 2017 1 message not in the archive Kbuild

lore
Share & tools
lore

Samuel Li

author
#0 lore raw

PATCH 1/2 util: move some files to an ASIC neutral directory.

Change-Id Iac1c4870253e8b8860a61b7cf175e7a25cc95921
---
 Makefile.sources         |  10 +-
 amdgpu/Makefile.am       |   3 +-
 amdgpu/Makefile.sources  |   7 +-
 amdgpu/amdgpu_asic_id.c  | 219 ---------------------------
 amdgpu/amdgpu_device.c   |   7 +-
 amdgpu/amdgpu_internal.h |  11 +-
 amdgpu/util_hash.c       | 387 -----------------------------------------------
 amdgpu/util_hash.h       | 107 -------------
 amdgpu/util_hash_table.c | 262 --------------------------------
 amdgpu/util_hash_table.h |  73 ---------
 util/util_asic_id.c      | 217 ++++++++++++++++++++++++++
 util/util_asic_id.h      |  39 +++++
 util/util_hash.c         | 387 +++++++++++++++++++++++++++++++++++++++++++++++
 util/util_hash.h         | 107 +++++++++++++
 util/util_hash_table.c   | 262 ++++++++++++++++++++++++++++++++
 util/util_hash_table.h   |  73 +++++++++
 16 files changed, 1102 insertions(+), 1069 deletions(-)
 delete mode 100644 amdgpu/amdgpu_asic_id.c
 delete mode 100644 amdgpu/util_hash.c
 delete mode 100644 amdgpu/util_hash.h
 delete mode 100644 amdgpu/util_hash_table.c
 delete mode 100644 amdgpu/util_hash_table.h
 create mode 100644 util/util_asic_id.c
 create mode 100644 util/util_asic_id.h
 create mode 100644 util/util_hash.c
 create mode 100644 util/util_hash.h
 create mode 100644 util/util_hash_table.c
 create mode 100644 util/util_hash_table.h
Makefile.sources +8 -2
index 10aa1d0..f2b0ec6 100644
@@ -10,12 +10,18 @@ LIBDRM_FILES := \
 	libdrm_macros.h \
 	libdrm_lists.h \
 	util_double_list.h \
-	util_math.h
+	util_math.h \
+	util/util_asic_id.c \
+	util/util_hash.c \
+	util/util_hash_table.c
 
 LIBDRM_H_FILES := \
 	libsync.h \
 	xf86drm.h \
-	xf86drmMode.h
+	xf86drmMode.h \
+	util/util_asic_id.h \
+	util/util_hash.h \
+	util/util_hash_table.h
 
 LIBDRM_INCLUDE_H_FILES := \
 	include/drm/drm.h \
amdgpu/Makefile.am +2 -1
index 66f6f67..c3e83d6 100644
@@ -28,7 +28,8 @@ AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
 	$(PTHREADSTUBS_CFLAGS) \
-	-I$(top_srcdir)/include/drm
+	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/util
 
 libdrmdatadir = @libdrmdatadir@
 ASIC_ID_TABLE_NUM_ENTRIES := $(shell egrep -ci '^[0-9a-f]{4},.*[0-9a-f]+,' \
amdgpu/Makefile.sources +1 -6
index bc3abaa..23e9e69 100644
@@ -1,15 +1,10 @@
 LIBDRM_AMDGPU_FILES := \
-	amdgpu_asic_id.c \
 	amdgpu_bo.c \
 	amdgpu_cs.c \
 	amdgpu_device.c \
 	amdgpu_gpu_info.c \
 	amdgpu_internal.h \
-	amdgpu_vamgr.c \
-	util_hash.c \
-	util_hash.h \
-	util_hash_table.c \
-	util_hash_table.h
+	amdgpu_vamgr.c
 
 LIBDRM_AMDGPU_H_FILES := \
 	amdgpu.h
amdgpu/amdgpu_asic_id.c deleted +0 -219

219 lines not on this page · raw message

amdgpu/amdgpu_device.c +4 -3
index 9a238d9..2653ada 100644
@@ -130,7 +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;
+	const struct util_asic_id *id;
 	amdgpu_vamgr_deinit(&dev->vamgr_32);
 	amdgpu_vamgr_deinit(&dev->vamgr);
 	util_hash_table_destroy(dev->bo_flink_names);
@@ -273,7 +273,8 @@ 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);
+	r = util_parse_asic_ids(&dev->asic_ids, AMDGPU_ASIC_ID_TABLE,
+				  AMDGPU_ASIC_ID_TABLE_NUM_ENTRIES);
 	if (r) {
 		fprintf(stderr, "%s: Cannot parse ASIC IDs, 0x%x.",
 			__func__, r);
@@ -309,7 +310,7 @@ int amdgpu_device_deinitialize(amdgpu_device_handle dev)
 
 const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
 {
-	const struct amdgpu_asic_id *id;
+	const struct util_asic_id *id;
 
 	if (!dev->asic_ids)
 		return NULL;
amdgpu/amdgpu_internal.h +2 -9
index e68246b..07ebda9 100644
@@ -36,6 +36,7 @@
 #include "xf86atomic.h"
 #include "amdgpu.h"
 #include "util_double_list.h"
+#include "util/util_asic_id.h"
 
 #define AMDGPU_CS_MAX_RINGS 8
 /* do not use below macro if b is not power of 2 aligned value */
@@ -69,12 +70,6 @@ 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;
@@ -83,7 +78,7 @@ struct amdgpu_device {
 	unsigned minor_version;
 
 	/** Lookup table of asic device id, revision id and marketing name */
-	struct amdgpu_asic_id *asic_ids;
+	struct util_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. */
@@ -157,8 +152,6 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
 drm_private void
 amdgpu_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);
amdgpu/util_hash.c deleted +0 -387

387 lines not on this page · raw message

amdgpu/util_hash.h deleted +0 -107

107 lines not on this page · raw message

amdgpu/util_hash_table.c deleted +0 -262

262 lines not on this page · raw message

amdgpu/util_hash_table.h deleted +0 -73

73 lines not on this page · raw message

util/util_asic_id.c new file +217 -0

217 lines not on this page · raw message

util/util_asic_id.h new file +39 -0
new file mode 100644
index 0000000..949bcda
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2017 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 _UTIL_ASIC_H_
+#define _UTIL_ASIC_H_
+
+#include "libdrm_macros.h"
+
+struct util_asic_id {
+	uint32_t did;
+	uint32_t rid;
+	char *marketing_name;
+};
+
+int util_parse_asic_ids(struct util_asic_id **p_asic_id_table, const char *filename, size_t table_max_size);
+
+
+#endif
util/util_hash.c new file +387 -0

387 lines not on this page · raw message

util/util_hash.h new file +107 -0

107 lines not on this page · raw message

util/util_hash_table.c new file +262 -0

262 lines not on this page · raw message

util/util_hash_table.h new file +73 -0

73 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
#2 lore raw
In reply to a message not in the archive

On 30 June 2017 at 20:24, Samuel Li <[email protected]> wrote:

Commit message should explain why we want this - aka "Will be reused in radeon with a later commit"

Quoted 23 lines
Change-Id Iac1c4870253e8b8860a61b7cf175e7a25cc95921
---
 Makefile.sources         |  10 +-
 amdgpu/Makefile.am       |   3 +-
 amdgpu/Makefile.sources  |   7 +-
 amdgpu/amdgpu_asic_id.c  | 219 ---------------------------
 amdgpu/amdgpu_device.c   |   7 +-
 amdgpu/amdgpu_internal.h |  11 +-
 amdgpu/util_hash.c       | 387 -----------------------------------------------
 amdgpu/util_hash.h       | 107 -------------
 amdgpu/util_hash_table.c | 262 --------------------------------
 amdgpu/util_hash_table.h |  73 ---------
 util/util_asic_id.c      | 217 ++++++++++++++++++++++++++
 util/util_asic_id.h      |  39 +++++
 util/util_hash.c         | 387 +++++++++++++++++++++++++++++++++++++++++++++++
 util/util_hash.h         | 107 +++++++++++++
 util/util_hash_table.c   | 262 ++++++++++++++++++++++++++++++++
 util/util_hash_table.h   |  73 +++++++++
 16 files changed, 1102 insertions(+), 1069 deletions(-)
 delete mode 100644 amdgpu/amdgpu_asic_id.c
 delete mode 100644 amdgpu/util_hash.c
 delete mode 100644 amdgpu/util_hash.h
Quoted 9 lines
 delete mode 100644 amdgpu/util_hash_table.c
 delete mode 100644 amdgpu/util_hash_table.h
 create mode 100644 util/util_asic_id.c
 create mode 100644 util/util_asic_id.h
 create mode 100644 util/util_hash.c
 create mode 100644 util/util_hash.h
 create mode 100644 util/util_hash_table.c
 create mode 100644 util/util_hash_table.h

Please generate patches which move files around with git format-patch -M.

Quoted 13 lines
Makefile.sources +4 -1
index 10aa1d0..f2b0ec6 100644
@@ -10,12 +10,18 @@ LIBDRM_FILES := \
        libdrm_macros.h \
        libdrm_lists.h \
        util_double_list.h \
-       util_math.h
+       util_math.h \
+       util/util_asic_id.c \
+       util/util_hash.c \
+       util/util_hash_table.c

Makefile.sources LIBDRM_FILES := \ · line 25

Quoted 10 lines
Makefile.sources +4 -1
 
 LIBDRM_H_FILES := \
        libsync.h \
        xf86drm.h \
-       xf86drmMode.h
+       xf86drmMode.h \
+       util/util_asic_id.h \
+       util/util_hash.h \
+       util/util_hash_table.h
 

The "H_FILES" are installed, which we don't want to do here. Please move them to LIBDRM_FILES above.

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