From patchwork Fri Aug 7 16:45:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6971591 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C8D04C05AD for ; Fri, 7 Aug 2015 16:41:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF4562061B for ; Fri, 7 Aug 2015 16:41:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7B37C2041D for ; Fri, 7 Aug 2015 16:41:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5098C7A1AE; Fri, 7 Aug 2015 09:41:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F47D7A1AA for ; Fri, 7 Aug 2015 09:41:10 -0700 (PDT) Received: by wijp15 with SMTP id p15so66578936wij.0 for ; Fri, 07 Aug 2015 09:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u/fa6cAeJgXvvIaWWmqQmxfhvX4bSAHGqhoY5tV+1C8=; b=ltN/7cU1v+JW8/zoVVpKBzBF6kJxHAYA9nUhKxpIvlYIrSQy7jeWDdC6T2yaw7XuLi 7odLr1JNtylmja5nNEWu5220OeeFowJeE1NqRPQnqL4SGa4R2rtGN5JLzCwMMDsX8lwM V8wFe9HVMKgIrq0KS17++pJfH+71GAHOhumDvALP/sh26sN17dNgDSa89C17bBuQ01n7 fDP44/0BVAV5VEhkE7U48ZqaFtkpc5Oh4L/g3Ot/Ddwg7pZIPkkDjpUzAbB02sHVN3x6 ft3WGxLpmwxMnnFffmc9vgXT7Qns/AMoE9OEj1iS7lazjf4eX1fSmzKj4LCg8l1+OCzi l5gQ== X-Received: by 10.180.205.230 with SMTP id lj6mr8400818wic.82.1438965669033; Fri, 07 Aug 2015 09:41:09 -0700 (PDT) Received: from arch-x220.localdomain (genkt-049-238.t-mobile.co.uk. [149.254.49.238]) by smtp.gmail.com with ESMTPSA id lg8sm4528960wic.12.2015.08.07.09.41.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Aug 2015 09:41:08 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 8/9] amdgpu: hide the final internal functions from global namespace Date: Fri, 7 Aug 2015 17:45:02 +0100 Message-Id: <1438965903-6342-9-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438965903-6342-1-git-send-email-emil.l.velikov@gmail.com> References: <1438965903-6342-1-git-send-email-emil.l.velikov@gmail.com> Cc: Alex Deucher , Emil Velikov X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Thus the only symbols that we export are the ones officially provided by the API. Signed-off-by: Emil Velikov --- 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