Now that the API is stabilised we can do a bit of a cleanup, and ensure only the symbols part of it are exported - 62 -> 34.
This also gives us some ~10% is size reduction of the final binary.
Android support would be nice, but it's not a show stopper :)
Please review, Emil
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- Makefile.am | 1 + 1 file changed, 1 insertion(+)
diff --git a/Makefile.am b/Makefile.am index cb808ff..55e39a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,6 +27,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-libkms \ --enable-intel \ --enable-radeon \ + --enable-amdgpu \ --enable-nouveau \ --enable-vmwgfx \ --enable-omap-experimental-api \
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/util_hash.c | 29 +++++++++++++++-------------- amdgpu/util_hash.h | 34 +++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/amdgpu/util_hash.c b/amdgpu/util_hash.c index b1e12c4..7e59041 100644 --- a/amdgpu/util_hash.c +++ b/amdgpu/util_hash.c @@ -214,8 +214,8 @@ static struct util_node **util_hash_find_node(struct util_hash *hash, unsigned a return node; }
-struct util_hash_iter util_hash_insert(struct util_hash *hash, - unsigned key, void *data) +drm_private struct util_hash_iter +util_hash_insert(struct util_hash *hash, unsigned key, void *data) { util_data_might_grow(hash->data.d);
@@ -234,7 +234,7 @@ struct util_hash_iter util_hash_insert(struct util_hash *hash, } }
-struct util_hash * util_hash_create(void) +drm_private struct util_hash *util_hash_create(void) { struct util_hash *hash = malloc(sizeof(struct util_hash)); if (!hash) @@ -257,7 +257,7 @@ struct util_hash * util_hash_create(void) return hash; }
-void util_hash_delete(struct util_hash *hash) +drm_private void util_hash_delete(struct util_hash *hash) { struct util_node *e_for_x = (struct util_node *)(hash->data.d); struct util_node **bucket = (struct util_node **)(hash->data.d->buckets); @@ -275,22 +275,22 @@ void util_hash_delete(struct util_hash *hash) free(hash); }
-struct util_hash_iter util_hash_find(struct util_hash *hash, - unsigned key) +drm_private struct util_hash_iter +util_hash_find(struct util_hash *hash, unsigned key) { struct util_node **nextNode = util_hash_find_node(hash, key); struct util_hash_iter iter = {hash, *nextNode}; return iter; }
-unsigned util_hash_iter_key(struct util_hash_iter iter) +drm_private unsigned util_hash_iter_key(struct util_hash_iter iter) { if (!iter.node || iter.hash->data.e == iter.node) return 0; return iter.node->key; }
-void * util_hash_iter_data(struct util_hash_iter iter) +drm_private void *util_hash_iter_data(struct util_hash_iter iter) { if (!iter.node || iter.hash->data.e == iter.node) return 0; @@ -327,21 +327,21 @@ static struct util_node *util_hash_data_next(struct util_node *node) return a.e; }
-struct util_hash_iter util_hash_iter_next(struct util_hash_iter iter) +drm_private struct util_hash_iter +util_hash_iter_next(struct util_hash_iter iter) { struct util_hash_iter next = {iter.hash, util_hash_data_next(iter.node)}; return next; }
-int util_hash_iter_is_null(struct util_hash_iter iter) +drm_private int util_hash_iter_is_null(struct util_hash_iter iter) { if (!iter.node || iter.node == iter.hash->data.e) return 1; return 0; }
-void * util_hash_take(struct util_hash *hash, - unsigned akey) +drm_private void *util_hash_take(struct util_hash *hash, unsigned akey) { struct util_node **node = util_hash_find_node(hash, akey); if (*node != hash->data.e) { @@ -356,13 +356,14 @@ void * util_hash_take(struct util_hash *hash, return 0; }
-struct util_hash_iter util_hash_first_node(struct util_hash *hash) +drm_private struct util_hash_iter util_hash_first_node(struct util_hash *hash) { struct util_hash_iter iter = {hash, util_data_first_node(hash->data.d)}; return iter; }
-struct util_hash_iter util_hash_erase(struct util_hash *hash, struct util_hash_iter iter) +drm_private struct util_hash_iter +util_hash_erase(struct util_hash *hash, struct util_hash_iter iter) { struct util_hash_iter ret = iter; struct util_node *node = iter.node; diff --git a/amdgpu/util_hash.h b/amdgpu/util_hash.h index 8e0f9a2..01a4779 100644 --- a/amdgpu/util_hash.h +++ b/amdgpu/util_hash.h @@ -44,8 +44,14 @@ #ifndef UTIL_HASH_H #define UTIL_HASH_H
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdbool.h>
+#include "libdrm_macros.h" + struct util_hash; struct util_node;
@@ -55,8 +61,8 @@ struct util_hash_iter { };
-struct util_hash *util_hash_create(void); -void util_hash_delete(struct util_hash *hash); +drm_private struct util_hash *util_hash_create(void); +drm_private void util_hash_delete(struct util_hash *hash);
/** @@ -65,8 +71,8 @@ void util_hash_delete(struct util_hash *hash); * in the collision list. * Function returns iterator pointing to the inserted item in the hash. */ -struct util_hash_iter util_hash_insert(struct util_hash *hash, unsigned key, - void *data); +drm_private struct util_hash_iter +util_hash_insert(struct util_hash *hash, unsigned key, void *data);
/** * Removes the item pointed to by the current iterator from the hash. @@ -75,25 +81,27 @@ struct util_hash_iter util_hash_insert(struct util_hash *hash, unsigned key, * Function returns iterator pointing to the item after the removed one in * the hash. */ -struct util_hash_iter util_hash_erase(struct util_hash *hash, - struct util_hash_iter iter); +drm_private struct util_hash_iter +util_hash_erase(struct util_hash *hash, struct util_hash_iter iter);
-void *util_hash_take(struct util_hash *hash, unsigned key); +drm_private void *util_hash_take(struct util_hash *hash, unsigned key);
-struct util_hash_iter util_hash_first_node(struct util_hash *hash); +drm_private struct util_hash_iter util_hash_first_node(struct util_hash *hash);
/** * Return an iterator pointing to the first entry in the collision list. */ -struct util_hash_iter util_hash_find(struct util_hash *hash, unsigned key); +drm_private struct util_hash_iter +util_hash_find(struct util_hash *hash, unsigned key);
-int util_hash_iter_is_null(struct util_hash_iter iter); -unsigned util_hash_iter_key(struct util_hash_iter iter); -void *util_hash_iter_data(struct util_hash_iter iter); +drm_private int util_hash_iter_is_null(struct util_hash_iter iter); +drm_private unsigned util_hash_iter_key(struct util_hash_iter iter); +drm_private void *util_hash_iter_data(struct util_hash_iter iter);
-struct util_hash_iter util_hash_iter_next(struct util_hash_iter iter); +drm_private struct util_hash_iter +util_hash_iter_next(struct util_hash_iter iter);
#endif
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/util_hash_table.c | 18 ++++++++++-------- amdgpu/util_hash_table.h | 24 ++++++++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/amdgpu/util_hash_table.c b/amdgpu/util_hash_table.c index cb7213c..ce6f1d5 100644 --- a/amdgpu/util_hash_table.c +++ b/amdgpu/util_hash_table.c @@ -69,8 +69,9 @@ util_hash_table_item(struct util_hash_iter iter) return (struct util_hash_table_item *)util_hash_iter_data(iter); }
-struct util_hash_table *util_hash_table_create(unsigned (*hash)(void *key), - int (*compare)(void *key1, void *key2)) +drm_private struct util_hash_table * +util_hash_table_create(unsigned (*hash)(void *key), + int (*compare)(void *key1, void *key2)) { struct util_hash_table *ht;
@@ -126,7 +127,8 @@ util_hash_table_find_item(struct util_hash_table *ht, return NULL; }
-void util_hash_table_set(struct util_hash_table *ht, void *key, void *value) +drm_private void +util_hash_table_set(struct util_hash_table *ht, void *key, void *value) { unsigned key_hash; struct util_hash_table_item *item; @@ -159,7 +161,7 @@ void util_hash_table_set(struct util_hash_table *ht, void *key, void *value) } }
-void *util_hash_table_get(struct util_hash_table *ht, void *key) +drm_private void *util_hash_table_get(struct util_hash_table *ht, void *key) { unsigned key_hash; struct util_hash_table_item *item; @@ -177,7 +179,7 @@ void *util_hash_table_get(struct util_hash_table *ht, void *key) return item->value; }
-void util_hash_table_remove(struct util_hash_table *ht, void *key) +drm_private void util_hash_table_remove(struct util_hash_table *ht, void *key) { unsigned key_hash; struct util_hash_iter iter; @@ -200,7 +202,7 @@ void util_hash_table_remove(struct util_hash_table *ht, void *key) util_hash_erase(ht->head, iter); }
-void util_hash_table_clear(struct util_hash_table *ht) +drm_private void util_hash_table_clear(struct util_hash_table *ht) { struct util_hash_iter iter; struct util_hash_table_item *item; @@ -217,7 +219,7 @@ void util_hash_table_clear(struct util_hash_table *ht) } }
-void util_hash_table_foreach(struct util_hash_table *ht, +drm_private void util_hash_table_foreach(struct util_hash_table *ht, void (*callback)(void *key, void *value, void *data), void *data) { @@ -236,7 +238,7 @@ void util_hash_table_foreach(struct util_hash_table *ht, } }
-void util_hash_table_destroy(struct util_hash_table *ht) +drm_private void util_hash_table_destroy(struct util_hash_table *ht) { struct util_hash_iter iter; struct util_hash_table_item *item; diff --git a/amdgpu/util_hash_table.h b/amdgpu/util_hash_table.h index 04fe704..e000128 100644 --- a/amdgpu/util_hash_table.h +++ b/amdgpu/util_hash_table.h @@ -34,6 +34,12 @@ #ifndef U_HASH_TABLE_H_ #define U_HASH_TABLE_H_
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "libdrm_macros.h" + /** * Generic purpose hash table. */ @@ -45,21 +51,23 @@ struct util_hash_table; * @param hash hash function * @param compare should return 0 for two equal keys. */ -struct util_hash_table *util_hash_table_create(unsigned (*hash)(void *key), - int (*compare)(void *key1, void *key2)); +drm_private struct util_hash_table * +util_hash_table_create(unsigned (*hash)(void *key), + int (*compare)(void *key1, void *key2));
-void util_hash_table_set(struct util_hash_table *ht, void *key, void *value); +drm_private void +util_hash_table_set(struct util_hash_table *ht, void *key, void *value);
-void *util_hash_table_get(struct util_hash_table *ht, void *key); +drm_private void *util_hash_table_get(struct util_hash_table *ht, void *key);
-void util_hash_table_remove(struct util_hash_table *ht, void *key); +drm_private void util_hash_table_remove(struct util_hash_table *ht, void *key);
-void util_hash_table_clear(struct util_hash_table *ht); +drm_private void util_hash_table_clear(struct util_hash_table *ht);
-void util_hash_table_foreach(struct util_hash_table *ht, +drm_private void util_hash_table_foreach(struct util_hash_table *ht, void (*callback)(void *key, void *value, void *data), void *data);
-void util_hash_table_destroy(struct util_hash_table *ht); +drm_private void util_hash_table_destroy(struct util_hash_table *ht);
#endif /* U_HASH_TABLE_H_ */
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/amdgpu_cs.c | 5 +++++ amdgpu/amdgpu_device.c | 4 ++++ amdgpu/amdgpu_gpu_info.c | 4 ++++ amdgpu/amdgpu_vamgr.c | 4 ++++ amdgpu/util_hash.c | 4 ++++ amdgpu/util_hash_table.c | 3 +++ 6 files changed, 24 insertions(+)
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 4ec1941..6caf7ff 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -20,6 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. * */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index 5f21b32..c21bb74 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -29,6 +29,10 @@ * */
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <sys/stat.h> #include <errno.h> #include <string.h> diff --git a/amdgpu/amdgpu_gpu_info.c b/amdgpu/amdgpu_gpu_info.c index 16a463e..5994e75 100644 --- a/amdgpu/amdgpu_gpu_info.c +++ b/amdgpu/amdgpu_gpu_info.c @@ -21,6 +21,10 @@ * OTHER DEALINGS IN THE SOFTWARE. */
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <errno.h> #include <string.h>
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index ced4f4f..dd0b420 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -21,6 +21,10 @@ * */
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdlib.h> #include <string.h> #include <errno.h> diff --git a/amdgpu/util_hash.c b/amdgpu/util_hash.c index 7e59041..87cb671 100644 --- a/amdgpu/util_hash.c +++ b/amdgpu/util_hash.c @@ -30,6 +30,10 @@ * Zack Rusin zackr@vmware.com */
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "util_hash.h"
#include <stdlib.h> diff --git a/amdgpu/util_hash_table.c b/amdgpu/util_hash_table.c index ce6f1d5..fa7f6ea 100644 --- a/amdgpu/util_hash_table.c +++ b/amdgpu/util_hash_table.c @@ -38,6 +38,9 @@ */
+#ifdef HAVE_CONFIG_H +#include "config.h" +#endif
#include "util_hash_table.h" #include "util_hash.h"
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/amdgpu.h | 2 +- amdgpu/amdgpu_bo.c | 1 + amdgpu/amdgpu_cs.c | 2 +- amdgpu/amdgpu_device.c | 3 +-- amdgpu/amdgpu_gpu_info.c | 1 + amdgpu/amdgpu_internal.h | 1 + amdgpu/amdgpu_vamgr.c | 2 +- 7 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index a90c1ac..b0c22d4 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -19,7 +19,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * -*/ + */
/** * \file amdgpu.h diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index a17bd0f..aacb42c 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -19,6 +19,7 @@ * 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. + * */
#ifdef HAVE_CONFIG_H diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 6caf7ff..fd28bd9 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -19,7 +19,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * -*/ + */
#ifdef HAVE_CONFIG_H #include "config.h" diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index c21bb74..bf941c1 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -19,14 +19,13 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * -*/ + */
/** * \file amdgpu_device.c * * Implementation of functions for AMD GPU device * - * */
#ifdef HAVE_CONFIG_H diff --git a/amdgpu/amdgpu_gpu_info.c b/amdgpu/amdgpu_gpu_info.c index 5994e75..0970769 100644 --- a/amdgpu/amdgpu_gpu_info.c +++ b/amdgpu/amdgpu_gpu_info.c @@ -19,6 +19,7 @@ * 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. + * */
#ifdef HAVE_CONFIG_H diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 526a93f..ab01bb5 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -19,6 +19,7 @@ * 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_INTERNAL_H_ diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index dd0b420..e2a4c87 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -19,7 +19,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * -*/ + */
#ifdef HAVE_CONFIG_H #include "config.h"
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/amdgpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index b0c22d4..a3eea84 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -709,7 +709,7 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); /** * Wait until a buffer is not used by the device. * - * \param dev - \c [in] Device handle. See #amdgpu_lib_initialize() + * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() * \param buf_handle - \c [in] Buffer handle. * \param timeout_ns - Timeout in nanoseconds. * \param buffer_busy - 0 if buffer is idle, all GPU access was completed
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/amdgpu_internal.h | 18 ++++++++++++------ amdgpu/amdgpu_vamgr.c | 17 ++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index ab01bb5..7f86da9 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -31,6 +31,8 @@
#include <assert.h> #include <pthread.h> + +#include "libdrm_macros.h" #include "xf86atomic.h" #include "amdgpu.h" #include "util_double_list.h" @@ -121,15 +123,19 @@ void amdgpu_device_free_internal(amdgpu_device_handle dev);
void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
-struct amdgpu_bo_va_mgr* amdgpu_vamgr_get_global(struct amdgpu_device *dev); +drm_private struct amdgpu_bo_va_mgr* +amdgpu_vamgr_get_global(struct amdgpu_device *dev);
-void amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst, struct amdgpu_bo_va_mgr *src); +drm_private void +amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst, + struct amdgpu_bo_va_mgr *src);
-uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, - uint64_t alignment, uint64_t base_required); +drm_private uint64_t +amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, + uint64_t alignment, uint64_t base_required);
-void amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, - uint64_t size); +drm_private void +amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size);
int amdgpu_query_gpu_info_init(amdgpu_device_handle dev);
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c index e2a4c87..b5d330f 100644 --- a/amdgpu/amdgpu_vamgr.c +++ b/amdgpu/amdgpu_vamgr.c @@ -66,7 +66,8 @@ static void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr) pthread_mutex_destroy(&mgr->bo_va_mutex); }
-struct amdgpu_bo_va_mgr * amdgpu_vamgr_get_global(struct amdgpu_device *dev) +drm_private struct amdgpu_bo_va_mgr * +amdgpu_vamgr_get_global(struct amdgpu_device *dev) { int ref; ref = atomic_inc_return(&vamgr.refcount); @@ -76,16 +77,18 @@ struct amdgpu_bo_va_mgr * amdgpu_vamgr_get_global(struct amdgpu_device *dev) return &vamgr; }
-void amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst, - struct amdgpu_bo_va_mgr *src) +drm_private void +amdgpu_vamgr_reference(struct amdgpu_bo_va_mgr **dst, + struct amdgpu_bo_va_mgr *src) { if (update_references(&(*dst)->refcount, NULL)) amdgpu_vamgr_deinit(*dst); *dst = src; }
-uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, - uint64_t alignment, uint64_t base_required) +drm_private uint64_t +amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, + uint64_t alignment, uint64_t base_required) { struct amdgpu_bo_va_hole *hole, *n; uint64_t offset = 0, waste = 0; @@ -170,8 +173,8 @@ uint64_t amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size, return offset; }
-void amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, - uint64_t va, uint64_t size) +drm_private void +amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size) { struct amdgpu_bo_va_hole *hole;
Thus the only symbols that we export are the ones officially provided by the API.
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/amdgpu_bo.c | 2 +- amdgpu/amdgpu_cs.c | 2 +- amdgpu/amdgpu_device.c | 58 ++++++++++++++++++++++++++++++------------------ amdgpu/amdgpu_gpu_info.c | 2 +- amdgpu/amdgpu_internal.h | 24 +++----------------- 5 files changed, 42 insertions(+), 46 deletions(-)
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index aacb42c..7607f2c 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -53,7 +53,7 @@ static void amdgpu_close_kms_handle(amdgpu_device_handle dev, drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args); }
-void amdgpu_bo_free_internal(amdgpu_bo_handle bo) +drm_private void amdgpu_bo_free_internal(amdgpu_bo_handle bo) { /* Remove the buffer from the hash tables. */ pthread_mutex_lock(&bo->dev->bo_table_mutex); diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index fd28bd9..ea35326 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -290,7 +290,7 @@ int amdgpu_cs_submit(amdgpu_context_handle context, * * \return absolute timeout in nanoseconds */ -uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout) +drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout) { int r;
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index bf941c1..c6bbae8 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -47,7 +47,7 @@ #define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) #define UINT_TO_PTR(x) ((void *)((intptr_t)(x)))
-pthread_mutex_t fd_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t fd_mutex = PTHREAD_MUTEX_INITIALIZER; static struct util_hash_table *fd_tab;
static unsigned handle_hash(void *key) @@ -127,6 +127,41 @@ static int amdgpu_get_auth(int fd, int *auth) return r; }
+static void amdgpu_device_free_internal(amdgpu_device_handle dev) +{ + amdgpu_vamgr_reference(&dev->vamgr, NULL); + util_hash_table_destroy(dev->bo_flink_names); + util_hash_table_destroy(dev->bo_handles); + pthread_mutex_destroy(&dev->bo_table_mutex); + util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd)); + close(dev->fd); + if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd)) + close(dev->flink_fd); + free(dev); +} + +/** + * Assignment between two amdgpu_device pointers with reference counting. + * + * Usage: + * struct amdgpu_device *dst = ... , *src = ...; + * + * dst = src; + * // No reference counting. Only use this when you need to move + * // a reference from one pointer to another. + * + * amdgpu_device_reference(&dst, src); + * // Reference counters are updated. dst is decremented and src is + * // incremented. dst is freed if its reference counter is 0. + */ +static void amdgpu_device_reference(struct amdgpu_device **dst, + struct amdgpu_device *src) +{ + if (update_references(&(*dst)->refcount, &src->refcount)) + amdgpu_device_free_internal(*dst); + *dst = src; +} + int amdgpu_device_initialize(int fd, uint32_t *major_version, uint32_t *minor_version, @@ -232,29 +267,8 @@ cleanup: return r; }
-void amdgpu_device_free_internal(amdgpu_device_handle dev) -{ - amdgpu_vamgr_reference(&dev->vamgr, NULL); - util_hash_table_destroy(dev->bo_flink_names); - util_hash_table_destroy(dev->bo_handles); - pthread_mutex_destroy(&dev->bo_table_mutex); - util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd)); - close(dev->fd); - if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd)) - close(dev->flink_fd); - free(dev); -} - int amdgpu_device_deinitialize(amdgpu_device_handle dev) { amdgpu_device_reference(&dev, NULL); return 0; } - -void amdgpu_device_reference(struct amdgpu_device **dst, - struct amdgpu_device *src) -{ - if (update_references(&(*dst)->refcount, &src->refcount)) - amdgpu_device_free_internal(*dst); - *dst = src; -} diff --git a/amdgpu/amdgpu_gpu_info.c b/amdgpu/amdgpu_gpu_info.c index 0970769..0cc17f1 100644 --- a/amdgpu/amdgpu_gpu_info.c +++ b/amdgpu/amdgpu_gpu_info.c @@ -140,7 +140,7 @@ int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type, return 0; }
-int amdgpu_query_gpu_info_init(amdgpu_device_handle dev) +drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev) { int r, i;
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h index 7f86da9..4b07aff 100644 --- a/amdgpu/amdgpu_internal.h +++ b/amdgpu/amdgpu_internal.h @@ -119,9 +119,7 @@ struct amdgpu_context { * Functions. */
-void amdgpu_device_free_internal(amdgpu_device_handle dev); - -void amdgpu_bo_free_internal(amdgpu_bo_handle bo); +drm_private void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
drm_private struct amdgpu_bo_va_mgr* amdgpu_vamgr_get_global(struct amdgpu_device *dev); @@ -137,9 +135,9 @@ 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);
-int amdgpu_query_gpu_info_init(amdgpu_device_handle dev); +drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev);
-uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout); +drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout);
/** * Inline functions. @@ -189,20 +187,4 @@ static inline void amdgpu_bo_reference(struct amdgpu_bo **dst, *dst = src; }
-/** - * Assignment between two amdgpu_device pointers with reference counting. - * - * Usage: - * struct amdgpu_device *dst = ... , *src = ...; - * - * dst = src; - * // No reference counting. Only use this when you need to move - * // a reference from one pointer to another. - * - * amdgpu_device_reference(&dst, src); - * // Reference counters are updated. dst is decremented and src is - * // incremented. dst is freed if its reference counter is 0. - */ -void amdgpu_device_reference(struct amdgpu_device **dst, - struct amdgpu_device *src); #endif
Signed-off-by: Emil Velikov emil.l.velikov@gmail.com --- amdgpu/Makefile.am | 3 +++ amdgpu/amdgpu-symbol-check | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 amdgpu/amdgpu-symbol-check
diff --git a/amdgpu/Makefile.am b/amdgpu/Makefile.am index 82e78c7..ed97803 100644 --- a/amdgpu/Makefile.am +++ b/amdgpu/Makefile.am @@ -52,3 +52,6 @@ libdrm_amdgpuinclude_HEADERS = \
pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_amdgpu.pc + +TESTS = amdgpu-symbol-check +EXTRA_DIST = $(TESTS) diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbol-check new file mode 100755 index 0000000..9a0b36c --- /dev/null +++ b/amdgpu/amdgpu-symbol-check @@ -0,0 +1,51 @@ +#!/bin/bash + +# The following symbols (past the first five) are taken from the public headers. +# A list of the latter should be available Makefile.am/libdrm_amdgpuinclude_HEADERS + +FUNCS=$(nm -D --format=bsd --defined-only ${1-.libs/libdrm_amdgpu.so} | awk '{print $3}' | while read func; do +( grep -q "^$func$" || echo $func ) <<EOF +__bss_start +_edata +_end +_fini +_init +amdgpu_bo_alloc +amdgpu_bo_cpu_map +amdgpu_bo_cpu_unmap +amdgpu_bo_export +amdgpu_bo_free +amdgpu_bo_import +amdgpu_bo_list_create +amdgpu_bo_list_destroy +amdgpu_bo_list_update +amdgpu_bo_query_info +amdgpu_bo_set_metadata +amdgpu_bo_va_op +amdgpu_bo_wait_for_idle +amdgpu_create_bo_from_user_mem +amdgpu_cs_ctx_create +amdgpu_cs_ctx_free +amdgpu_cs_query_fence_status +amdgpu_cs_query_reset_state +amdgpu_cs_submit +amdgpu_device_deinitialize +amdgpu_device_initialize +amdgpu_query_buffer_size_alignment +amdgpu_query_crtc_from_id +amdgpu_query_firmware_version +amdgpu_query_gds_info +amdgpu_query_gpu_info +amdgpu_query_heap_info +amdgpu_query_hw_ip_count +amdgpu_query_hw_ip_info +amdgpu_query_info +amdgpu_read_mm_registers +amdgpu_va_range_alloc +amdgpu_va_range_free +amdgpu_va_range_query +EOF +done) + +test ! -n "$FUNCS" || echo $FUNCS +test ! -n "$FUNCS"
For this series Reviewed-by: Christian König christian.koenig@amd.com
Thanks for taking care of this, Christian.
On 07.08.2015 18:44, Emil Velikov wrote:
Now that the API is stabilised we can do a bit of a cleanup, and ensure only the symbols part of it are exported - 62 -> 34.
This also gives us some ~10% is size reduction of the final binary.
Android support would be nice, but it's not a show stopper :)
Please review, Emil
dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
On Fri, Aug 7, 2015 at 1:32 PM, Christian König deathsimple@vodafone.de wrote:
For this series Reviewed-by: Christian König christian.koenig@amd.com
Thanks for taking care of this, Christian.
Yes, thanks! For the series: Reviewed-by: Alex Deucher alexander.deucher@amd.com
On 07.08.2015 18:44, Emil Velikov wrote:
Now that the API is stabilised we can do a bit of a cleanup, and ensure only the symbols part of it are exported - 62 -> 34.
This also gives us some ~10% is size reduction of the final binary.
Android support would be nice, but it's not a show stopper :)
Please review, Emil
dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
The series are Reviewed-by: Jammy Zhou Jammy.Zhou@amd.com
And I will rebase my pending patches on top of this series. Thanks.
Regards, Jammy
-----Original Message----- From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of Emil Velikov Sent: Saturday, August 08, 2015 12:45 AM To: dri-devel@lists.freedesktop.org Cc: Deucher, Alexander Subject: [PATCH libdrm 0/9] amdgpu: cleanup the exported symbols
Now that the API is stabilised we can do a bit of a cleanup, and ensure only the symbols part of it are exported - 62 -> 34.
This also gives us some ~10% is size reduction of the final binary.
Android support would be nice, but it's not a show stopper :)
Please review, Emil
_______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
On 7 August 2015 at 17:44, Emil Velikov emil.l.velikov@gmail.com wrote:
Now that the API is stabilised we can do a bit of a cleanup, and ensure only the symbols part of it are exported - 62 -> 34.
This also gives us some ~10% is size reduction of the final binary.
Android support would be nice, but it's not a show stopper :)
Thanks for the review guys.
I gave it a final quick test and pushed to master.
-Emil
dri-devel@lists.freedesktop.org