diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2018-11-01 08:23:22 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2018-11-01 08:23:22 +0000 |
commit | 151b82d100e6380d41996fb56cafcab4728d5149 (patch) | |
tree | 19af1b08d3b8f2d16fb28d5350bea0f0a7435027 | |
parent | e33f6733f6eb02ee1097e1f4ef19735adea243a1 (diff) |
Import libdrm 2.4.96
106 files changed, 2243 insertions, 695 deletions
diff --git a/lib/libdrm/amdgpu/amdgpu-symbol-check b/lib/libdrm/amdgpu/amdgpu-symbol-check index 90b7a1d63..6f5e0f95b 100755 --- a/lib/libdrm/amdgpu/amdgpu-symbol-check +++ b/lib/libdrm/amdgpu/amdgpu-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # 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 @@ -16,6 +18,7 @@ amdgpu_bo_cpu_unmap amdgpu_bo_export amdgpu_bo_free amdgpu_bo_import +amdgpu_bo_inc_ref amdgpu_bo_list_create amdgpu_bo_list_destroy amdgpu_bo_list_update @@ -53,6 +56,7 @@ amdgpu_cs_wait_fences amdgpu_cs_wait_semaphore amdgpu_device_deinitialize amdgpu_device_initialize +amdgpu_find_bo_by_cpu_mapping amdgpu_get_marketing_name amdgpu_query_buffer_size_alignment amdgpu_query_crtc_from_id diff --git a/lib/libdrm/amdgpu/amdgpu.h b/lib/libdrm/amdgpu/amdgpu.h index a8c353c6c..dc51659ae 100644 --- a/lib/libdrm/amdgpu/amdgpu.h +++ b/lib/libdrm/amdgpu/amdgpu.h @@ -721,7 +721,17 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, int amdgpu_bo_free(amdgpu_bo_handle buf_handle); /** - * Request CPU access to GPU accessible memory + * Increase the reference count of a buffer object + * + * \param bo - \c [in] Buffer object handle to increase the reference count + * + * \sa amdgpu_bo_alloc(), amdgpu_bo_free() + * +*/ +void amdgpu_bo_inc_ref(amdgpu_bo_handle bo); + +/** + * Request CPU access to GPU accessable memory * * \param buf_handle - \c [in] Buffer handle * \param cpu - \c [out] CPU address to be used for access diff --git a/lib/libdrm/amdgpu/amdgpu_cs.c b/lib/libdrm/amdgpu/amdgpu_cs.c index 3c9be6c2e..3b8231aa1 100644 --- a/lib/libdrm/amdgpu/amdgpu_cs.c +++ b/lib/libdrm/amdgpu/amdgpu_cs.c @@ -48,8 +48,9 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem); * * \return 0 on success otherwise POSIX Error code */ -int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, uint32_t priority, - amdgpu_context_handle *context) +drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, + uint32_t priority, + amdgpu_context_handle *context) { struct amdgpu_context *gpu_context; union drm_amdgpu_ctx args; @@ -93,8 +94,8 @@ error: return r; } -int amdgpu_cs_ctx_create(amdgpu_device_handle dev, - amdgpu_context_handle *context) +drm_public int amdgpu_cs_ctx_create(amdgpu_device_handle dev, + amdgpu_context_handle *context) { return amdgpu_cs_ctx_create2(dev, AMDGPU_CTX_PRIORITY_NORMAL, context); } @@ -107,7 +108,7 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev, * * \return 0 on success otherwise POSIX Error code */ -int amdgpu_cs_ctx_free(amdgpu_context_handle context) +drm_public int amdgpu_cs_ctx_free(amdgpu_context_handle context) { union drm_amdgpu_ctx args; int i, j, k; @@ -141,8 +142,8 @@ int amdgpu_cs_ctx_free(amdgpu_context_handle context) return r; } -int amdgpu_cs_query_reset_state(amdgpu_context_handle context, - uint32_t *state, uint32_t *hangs) +drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context, + uint32_t *state, uint32_t *hangs) { union drm_amdgpu_ctx args; int r; @@ -323,10 +324,10 @@ error_unlock: return r; } -int amdgpu_cs_submit(amdgpu_context_handle context, - uint64_t flags, - struct amdgpu_cs_request *ibs_request, - uint32_t number_of_requests) +drm_public int amdgpu_cs_submit(amdgpu_context_handle context, + uint64_t flags, + struct amdgpu_cs_request *ibs_request, + uint32_t number_of_requests) { uint32_t i; int r; @@ -407,10 +408,10 @@ static int amdgpu_ioctl_wait_cs(amdgpu_context_handle context, return 0; } -int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, - uint64_t timeout_ns, - uint64_t flags, - uint32_t *expired) +drm_public int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, + uint64_t timeout_ns, + uint64_t flags, + uint32_t *expired) { bool busy = true; int r; @@ -478,12 +479,12 @@ static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences, return 0; } -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 *first) +drm_public 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 *first) { uint32_t i; @@ -506,7 +507,7 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences, timeout_ns, status, first); } -int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem) +drm_public int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem) { struct amdgpu_semaphore *gpu_semaphore; @@ -523,8 +524,8 @@ int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem) return 0; } -int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx, - uint32_t ip_type, +drm_public int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx, + uint32_t ip_type, uint32_t ip_instance, uint32_t ring, amdgpu_semaphore_handle sem) @@ -549,8 +550,8 @@ int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx, return 0; } -int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, - uint32_t ip_type, +drm_public int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, + uint32_t ip_type, uint32_t ip_instance, uint32_t ring, amdgpu_semaphore_handle sem) @@ -595,14 +596,14 @@ static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem) return 0; } -int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem) +drm_public int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem) { return amdgpu_cs_unreference_sem(sem); } -int amdgpu_cs_create_syncobj2(amdgpu_device_handle dev, - uint32_t flags, - uint32_t *handle) +drm_public int amdgpu_cs_create_syncobj2(amdgpu_device_handle dev, + uint32_t flags, + uint32_t *handle) { if (NULL == dev) return -EINVAL; @@ -610,8 +611,8 @@ int amdgpu_cs_create_syncobj2(amdgpu_device_handle dev, return drmSyncobjCreate(dev->fd, flags, handle); } -int amdgpu_cs_create_syncobj(amdgpu_device_handle dev, - uint32_t *handle) +drm_public int amdgpu_cs_create_syncobj(amdgpu_device_handle dev, + uint32_t *handle) { if (NULL == dev) return -EINVAL; @@ -619,8 +620,8 @@ int amdgpu_cs_create_syncobj(amdgpu_device_handle dev, return drmSyncobjCreate(dev->fd, 0, handle); } -int amdgpu_cs_destroy_syncobj(amdgpu_device_handle dev, - uint32_t handle) +drm_public int amdgpu_cs_destroy_syncobj(amdgpu_device_handle dev, + uint32_t handle) { if (NULL == dev) return -EINVAL; @@ -628,8 +629,9 @@ int amdgpu_cs_destroy_syncobj(amdgpu_device_handle dev, return drmSyncobjDestroy(dev->fd, handle); } -int amdgpu_cs_syncobj_reset(amdgpu_device_handle dev, - const uint32_t *syncobjs, uint32_t syncobj_count) +drm_public int amdgpu_cs_syncobj_reset(amdgpu_device_handle dev, + const uint32_t *syncobjs, + uint32_t syncobj_count) { if (NULL == dev) return -EINVAL; @@ -637,8 +639,9 @@ int amdgpu_cs_syncobj_reset(amdgpu_device_handle dev, return drmSyncobjReset(dev->fd, syncobjs, syncobj_count); } -int amdgpu_cs_syncobj_signal(amdgpu_device_handle dev, - const uint32_t *syncobjs, uint32_t syncobj_count) +drm_public int amdgpu_cs_syncobj_signal(amdgpu_device_handle dev, + const uint32_t *syncobjs, + uint32_t syncobj_count) { if (NULL == dev) return -EINVAL; @@ -646,10 +649,10 @@ int amdgpu_cs_syncobj_signal(amdgpu_device_handle dev, return drmSyncobjSignal(dev->fd, syncobjs, syncobj_count); } -int amdgpu_cs_syncobj_wait(amdgpu_device_handle dev, - uint32_t *handles, unsigned num_handles, - int64_t timeout_nsec, unsigned flags, - uint32_t *first_signaled) +drm_public int amdgpu_cs_syncobj_wait(amdgpu_device_handle dev, + uint32_t *handles, unsigned num_handles, + int64_t timeout_nsec, unsigned flags, + uint32_t *first_signaled) { if (NULL == dev) return -EINVAL; @@ -658,9 +661,9 @@ int amdgpu_cs_syncobj_wait(amdgpu_device_handle dev, flags, first_signaled); } -int amdgpu_cs_export_syncobj(amdgpu_device_handle dev, - uint32_t handle, - int *shared_fd) +drm_public int amdgpu_cs_export_syncobj(amdgpu_device_handle dev, + uint32_t handle, + int *shared_fd) { if (NULL == dev) return -EINVAL; @@ -668,9 +671,9 @@ int amdgpu_cs_export_syncobj(amdgpu_device_handle dev, return drmSyncobjHandleToFD(dev->fd, handle, shared_fd); } -int amdgpu_cs_import_syncobj(amdgpu_device_handle dev, - int shared_fd, - uint32_t *handle) +drm_public int amdgpu_cs_import_syncobj(amdgpu_device_handle dev, + int shared_fd, + uint32_t *handle) { if (NULL == dev) return -EINVAL; @@ -678,9 +681,9 @@ int amdgpu_cs_import_syncobj(amdgpu_device_handle dev, return drmSyncobjFDToHandle(dev->fd, shared_fd, handle); } -int amdgpu_cs_syncobj_export_sync_file(amdgpu_device_handle dev, - uint32_t syncobj, - int *sync_file_fd) +drm_public int amdgpu_cs_syncobj_export_sync_file(amdgpu_device_handle dev, + uint32_t syncobj, + int *sync_file_fd) { if (NULL == dev) return -EINVAL; @@ -688,9 +691,9 @@ int amdgpu_cs_syncobj_export_sync_file(amdgpu_device_handle dev, return drmSyncobjExportSyncFile(dev->fd, syncobj, sync_file_fd); } -int amdgpu_cs_syncobj_import_sync_file(amdgpu_device_handle dev, - uint32_t syncobj, - int sync_file_fd) +drm_public int amdgpu_cs_syncobj_import_sync_file(amdgpu_device_handle dev, + uint32_t syncobj, + int sync_file_fd) { if (NULL == dev) return -EINVAL; @@ -698,12 +701,12 @@ int amdgpu_cs_syncobj_import_sync_file(amdgpu_device_handle dev, return drmSyncobjImportSyncFile(dev->fd, syncobj, sync_file_fd); } -int amdgpu_cs_submit_raw(amdgpu_device_handle dev, - amdgpu_context_handle context, - amdgpu_bo_list_handle bo_list_handle, - int num_chunks, - struct drm_amdgpu_cs_chunk *chunks, - uint64_t *seq_no) +drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev, + amdgpu_context_handle context, + amdgpu_bo_list_handle bo_list_handle, + int num_chunks, + struct drm_amdgpu_cs_chunk *chunks, + uint64_t *seq_no) { union drm_amdgpu_cs cs = {0}; uint64_t *chunk_array; @@ -728,15 +731,15 @@ int amdgpu_cs_submit_raw(amdgpu_device_handle dev, return 0; } -void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info, +drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info, struct drm_amdgpu_cs_chunk_data *data) { data->fence_data.handle = fence_info->handle->handle; data->fence_data.offset = fence_info->offset * sizeof(uint64_t); } -void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence, - struct drm_amdgpu_cs_chunk_dep *dep) +drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence, + struct drm_amdgpu_cs_chunk_dep *dep) { dep->ip_type = fence->ip_type; dep->ip_instance = fence->ip_instance; @@ -745,10 +748,10 @@ void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence, dep->handle = fence->fence; } -int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev, - struct amdgpu_cs_fence *fence, - uint32_t what, - uint32_t *out_handle) +drm_public int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev, + struct amdgpu_cs_fence *fence, + uint32_t what, + uint32_t *out_handle) { union drm_amdgpu_fence_to_handle fth = {0}; int r; diff --git a/lib/libdrm/amdgpu/amdgpu_device.c b/lib/libdrm/amdgpu/amdgpu_device.c index 73eeeed6f..362494b16 100644 --- a/lib/libdrm/amdgpu/amdgpu_device.c +++ b/lib/libdrm/amdgpu/amdgpu_device.c @@ -133,17 +133,17 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev) * // incremented. dst is freed if its reference counter is 0. */ static void amdgpu_device_reference(struct amdgpu_device **dst, - struct amdgpu_device *src) + 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, - amdgpu_device_handle *device_handle) +drm_public int amdgpu_device_initialize(int fd, + uint32_t *major_version, + uint32_t *minor_version, + amdgpu_device_handle *device_handle) { struct amdgpu_device *dev; drmVersionPtr version; @@ -279,19 +279,20 @@ cleanup: return r; } -int amdgpu_device_deinitialize(amdgpu_device_handle dev) +drm_public 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) +drm_public const char *amdgpu_get_marketing_name(amdgpu_device_handle dev) { return dev->marketing_name; } -int amdgpu_query_sw_info(amdgpu_device_handle dev, enum amdgpu_sw_info info, - void *value) +drm_public int amdgpu_query_sw_info(amdgpu_device_handle dev, + enum amdgpu_sw_info info, + void *value) { uint32_t *val32 = (uint32_t*)value; diff --git a/lib/libdrm/amdgpu/amdgpu_gpu_info.c b/lib/libdrm/amdgpu/amdgpu_gpu_info.c index b68e1c4fe..777087f27 100644 --- a/lib/libdrm/amdgpu/amdgpu_gpu_info.c +++ b/lib/libdrm/amdgpu/amdgpu_gpu_info.c @@ -30,8 +30,8 @@ #include "amdgpu_internal.h" #include "xf86drm.h" -int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, - unsigned size, void *value) +drm_public int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, + unsigned size, void *value) { struct drm_amdgpu_info request; @@ -44,8 +44,8 @@ int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, sizeof(struct drm_amdgpu_info)); } -int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id, - int32_t *result) +drm_public int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id, + int32_t *result) { struct drm_amdgpu_info request; @@ -59,9 +59,9 @@ int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id, sizeof(struct drm_amdgpu_info)); } -int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset, - unsigned count, uint32_t instance, uint32_t flags, - uint32_t *values) +drm_public int amdgpu_read_mm_registers(amdgpu_device_handle dev, + unsigned dword_offset, unsigned count, uint32_t instance, + uint32_t flags, uint32_t *values) { struct drm_amdgpu_info request; @@ -78,8 +78,9 @@ int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset, sizeof(struct drm_amdgpu_info)); } -int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type, - uint32_t *count) +drm_public int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, + unsigned type, + uint32_t *count) { struct drm_amdgpu_info request; @@ -93,9 +94,9 @@ int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type, sizeof(struct drm_amdgpu_info)); } -int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type, - unsigned ip_instance, - struct drm_amdgpu_info_hw_ip *info) +drm_public int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type, + unsigned ip_instance, + struct drm_amdgpu_info_hw_ip *info) { struct drm_amdgpu_info request; @@ -110,9 +111,9 @@ int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type, sizeof(struct drm_amdgpu_info)); } -int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type, - unsigned ip_instance, unsigned index, - uint32_t *version, uint32_t *feature) +drm_public int amdgpu_query_firmware_version(amdgpu_device_handle dev, + unsigned fw_type, unsigned ip_instance, unsigned index, + uint32_t *version, uint32_t *feature) { struct drm_amdgpu_info request; struct drm_amdgpu_info_firmware firmware = {}; @@ -227,8 +228,8 @@ drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev) return 0; } -int amdgpu_query_gpu_info(amdgpu_device_handle dev, - struct amdgpu_gpu_info *info) +drm_public int amdgpu_query_gpu_info(amdgpu_device_handle dev, + struct amdgpu_gpu_info *info) { if (!dev || !info) return -EINVAL; @@ -239,10 +240,10 @@ int amdgpu_query_gpu_info(amdgpu_device_handle dev, return 0; } -int amdgpu_query_heap_info(amdgpu_device_handle dev, - uint32_t heap, - uint32_t flags, - struct amdgpu_heap_info *info) +drm_public int amdgpu_query_heap_info(amdgpu_device_handle dev, + uint32_t heap, + uint32_t flags, + struct amdgpu_heap_info *info) { struct drm_amdgpu_info_vram_gtt vram_gtt_info = {}; int r; @@ -291,8 +292,8 @@ int amdgpu_query_heap_info(amdgpu_device_handle dev, return 0; } -int amdgpu_query_gds_info(amdgpu_device_handle dev, - struct amdgpu_gds_resource_info *gds_info) +drm_public int amdgpu_query_gds_info(amdgpu_device_handle dev, + struct amdgpu_gds_resource_info *gds_info) { struct drm_amdgpu_info_gds gds_config = {}; int r; @@ -316,8 +317,8 @@ int amdgpu_query_gds_info(amdgpu_device_handle dev, return 0; } -int amdgpu_query_sensor_info(amdgpu_device_handle dev, unsigned sensor_type, - unsigned size, void *value) +drm_public int amdgpu_query_sensor_info(amdgpu_device_handle dev, unsigned sensor_type, + unsigned size, void *value) { struct drm_amdgpu_info request; diff --git a/lib/libdrm/amdgpu/amdgpu_vamgr.c b/lib/libdrm/amdgpu/amdgpu_vamgr.c index 1de9f952f..d25d4216f 100644 --- a/lib/libdrm/amdgpu/amdgpu_vamgr.c +++ b/lib/libdrm/amdgpu/amdgpu_vamgr.c @@ -29,9 +29,9 @@ #include "amdgpu_internal.h" #include "util_math.h" -int amdgpu_va_range_query(amdgpu_device_handle dev, - enum amdgpu_gpu_va_range type, - uint64_t *start, uint64_t *end) +drm_public int amdgpu_va_range_query(amdgpu_device_handle dev, + enum amdgpu_gpu_va_range type, + uint64_t *start, uint64_t *end) { if (type != amdgpu_gpu_va_range_general) return -EINVAL; @@ -186,14 +186,14 @@ out: pthread_mutex_unlock(&mgr->bo_va_mutex); } -int amdgpu_va_range_alloc(amdgpu_device_handle dev, - enum amdgpu_gpu_va_range va_range_type, - uint64_t size, - uint64_t va_base_alignment, - uint64_t va_base_required, - uint64_t *va_base_allocated, - amdgpu_va_handle *va_range_handle, - uint64_t flags) +drm_public int amdgpu_va_range_alloc(amdgpu_device_handle dev, + enum amdgpu_gpu_va_range va_range_type, + uint64_t size, + uint64_t va_base_alignment, + uint64_t va_base_required, + uint64_t *va_base_allocated, + amdgpu_va_handle *va_range_handle, + uint64_t flags) { struct amdgpu_bo_va_mgr *vamgr; @@ -250,7 +250,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev, return 0; } -int amdgpu_va_range_free(amdgpu_va_handle va_range_handle) +drm_public int amdgpu_va_range_free(amdgpu_va_handle va_range_handle) { if(!va_range_handle || !va_range_handle->address) return 0; diff --git a/lib/libdrm/amdgpu/amdgpu_vm.c b/lib/libdrm/amdgpu/amdgpu_vm.c index da9d07f81..7e6e28f01 100644 --- a/lib/libdrm/amdgpu/amdgpu_vm.c +++ b/lib/libdrm/amdgpu/amdgpu_vm.c @@ -26,7 +26,7 @@ #include "xf86drm.h" #include "amdgpu_internal.h" -int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags) +drm_public int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags) { union drm_amdgpu_vm vm; @@ -37,7 +37,8 @@ int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags) &vm, sizeof(vm)); } -int amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, uint32_t flags) +drm_public int amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, + uint32_t flags) { union drm_amdgpu_vm vm; diff --git a/lib/libdrm/amdgpu/meson.build b/lib/libdrm/amdgpu/meson.build index d9d7de2d4..7c8ccc7e4 100644 --- a/lib/libdrm/amdgpu/meson.build +++ b/lib/libdrm/amdgpu/meson.build @@ -31,7 +31,7 @@ libdrm_amdgpu = shared_library( config_file, ], c_args : [ - warn_c_args, + libdrm_c_args, '-DAMDGPU_ASIC_ID_TABLE="@0@"'.format(join_paths(datadir_amdgpu, 'amdgpu.ids')), ], include_directories : [inc_root, inc_drm], diff --git a/lib/libdrm/build-aux/compile b/lib/libdrm/build-aux/compile index a85b723c7..de0005d4f 100755 --- a/lib/libdrm/build-aux/compile +++ b/lib/libdrm/build-aux/compile @@ -1,9 +1,9 @@ -#! /bin/sh +#!/bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -255,7 +255,8 @@ EOF echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -342,6 +343,6 @@ exit $ret # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/lib/libdrm/build-aux/test-driver b/lib/libdrm/build-aux/test-driver index 8e575b017..de1e61da1 100755 --- a/lib/libdrm/build-aux/test-driver +++ b/lib/libdrm/build-aux/test-driver @@ -1,9 +1,9 @@ -#! /bin/sh +#!/bin/sh # test-driver - basic testsuite driver script. -scriptversion=2013-07-13.22; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-2017 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -143,6 +143,6 @@ echo ":copy-in-global-log: $gcopy" >> $trs_file # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/lib/libdrm/etnaviv/Makefile.am b/lib/libdrm/etnaviv/Makefile.am index be96ba868..648e3c5b3 100644 --- a/lib/libdrm/etnaviv/Makefile.am +++ b/lib/libdrm/etnaviv/Makefile.am @@ -2,6 +2,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm @@ -22,5 +23,6 @@ libdrm_etnavivinclude_HEADERS = $(LIBDRM_ETNAVIV_H_FILES) pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_etnaviv.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = etnaviv-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/etnaviv/etnaviv-symbol-check b/lib/libdrm/etnaviv/etnaviv-symbol-check index bc5096159..189106889 100755 --- a/lib/libdrm/etnaviv/etnaviv-symbol-check +++ b/lib/libdrm/etnaviv/etnaviv-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.sources/LIBDRM_ETNAVIV_H_FILES diff --git a/lib/libdrm/etnaviv/etnaviv_bo.c b/lib/libdrm/etnaviv/etnaviv_bo.c index 32f7b3487..43ce6b4e3 100644 --- a/lib/libdrm/etnaviv/etnaviv_bo.c +++ b/lib/libdrm/etnaviv/etnaviv_bo.c @@ -104,7 +104,7 @@ static struct etna_bo *bo_from_handle(struct etna_device *dev, } /* allocate a new (un-tiled) buffer object */ -struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size, +drm_public struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size, uint32_t flags) { struct etna_bo *bo; @@ -131,7 +131,7 @@ struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size, return bo; } -struct etna_bo *etna_bo_ref(struct etna_bo *bo) +drm_public struct etna_bo *etna_bo_ref(struct etna_bo *bo) { atomic_inc(&bo->refcnt); @@ -159,7 +159,8 @@ static int get_buffer_info(struct etna_bo *bo) } /* import a buffer object from DRI2 name */ -struct etna_bo *etna_bo_from_name(struct etna_device *dev, uint32_t name) +drm_public struct etna_bo *etna_bo_from_name(struct etna_device *dev, + uint32_t name) { struct etna_bo *bo; struct drm_gem_open req = { @@ -196,7 +197,7 @@ out_unlock: * fd so caller should close() the fd when it is otherwise done * with it (even if it is still using the 'struct etna_bo *') */ -struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd) +drm_public struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd) { struct etna_bo *bo; int ret, size; @@ -231,7 +232,7 @@ out_unlock: } /* destroy a buffer object */ -void etna_bo_del(struct etna_bo *bo) +drm_public void etna_bo_del(struct etna_bo *bo) { struct etna_device *dev = bo->dev; @@ -253,7 +254,7 @@ out: } /* get the global flink/DRI2 buffer name */ -int etna_bo_get_name(struct etna_bo *bo, uint32_t *name) +drm_public int etna_bo_get_name(struct etna_bo *bo, uint32_t *name) { if (!bo->name) { struct drm_gem_flink req = { @@ -277,7 +278,7 @@ int etna_bo_get_name(struct etna_bo *bo, uint32_t *name) return 0; } -uint32_t etna_bo_handle(struct etna_bo *bo) +drm_public uint32_t etna_bo_handle(struct etna_bo *bo) { return bo->handle; } @@ -285,7 +286,7 @@ uint32_t etna_bo_handle(struct etna_bo *bo) /* caller owns the dmabuf fd that is returned and is responsible * to close() it when done */ -int etna_bo_dmabuf(struct etna_bo *bo) +drm_public int etna_bo_dmabuf(struct etna_bo *bo) { int ret, prime_fd; @@ -301,12 +302,12 @@ int etna_bo_dmabuf(struct etna_bo *bo) return prime_fd; } -uint32_t etna_bo_size(struct etna_bo *bo) +drm_public uint32_t etna_bo_size(struct etna_bo *bo) { return bo->size; } -void *etna_bo_map(struct etna_bo *bo) +drm_public void *etna_bo_map(struct etna_bo *bo) { if (!bo->map) { if (!bo->offset) { @@ -324,7 +325,7 @@ void *etna_bo_map(struct etna_bo *bo) return bo->map; } -int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op) +drm_public int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op) { struct drm_etnaviv_gem_cpu_prep req = { .handle = bo->handle, @@ -337,7 +338,7 @@ int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op) &req, sizeof(req)); } -void etna_bo_cpu_fini(struct etna_bo *bo) +drm_public void etna_bo_cpu_fini(struct etna_bo *bo) { struct drm_etnaviv_gem_cpu_fini req = { .handle = bo->handle, diff --git a/lib/libdrm/etnaviv/etnaviv_cmd_stream.c b/lib/libdrm/etnaviv/etnaviv_cmd_stream.c index 137301681..7139c3245 100644 --- a/lib/libdrm/etnaviv/etnaviv_cmd_stream.c +++ b/lib/libdrm/etnaviv/etnaviv_cmd_stream.c @@ -55,7 +55,8 @@ etna_cmd_stream_priv(struct etna_cmd_stream *stream) return (struct etna_cmd_stream_priv *)stream; } -struct etna_cmd_stream *etna_cmd_stream_new(struct etna_pipe *pipe, uint32_t size, +drm_public struct etna_cmd_stream *etna_cmd_stream_new(struct etna_pipe *pipe, + uint32_t size, void (*reset_notify)(struct etna_cmd_stream *stream, void *priv), void *priv) { @@ -95,7 +96,7 @@ fail: return NULL; } -void etna_cmd_stream_del(struct etna_cmd_stream *stream) +drm_public void etna_cmd_stream_del(struct etna_cmd_stream *stream) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); @@ -119,7 +120,7 @@ static void reset_buffer(struct etna_cmd_stream *stream) priv->reset_notify(stream, priv->reset_notify_priv); } -uint32_t etna_cmd_stream_timestamp(struct etna_cmd_stream *stream) +drm_public uint32_t etna_cmd_stream_timestamp(struct etna_cmd_stream *stream) { return etna_cmd_stream_priv(stream)->last_timestamp; } @@ -222,20 +223,21 @@ static void flush(struct etna_cmd_stream *stream, int in_fence_fd, *out_fence_fd = req.fence_fd; } -void etna_cmd_stream_flush(struct etna_cmd_stream *stream) +drm_public void etna_cmd_stream_flush(struct etna_cmd_stream *stream) { flush(stream, -1, NULL); reset_buffer(stream); } -void etna_cmd_stream_flush2(struct etna_cmd_stream *stream, int in_fence_fd, - int *out_fence_fd) +drm_public void etna_cmd_stream_flush2(struct etna_cmd_stream *stream, + int in_fence_fd, + int *out_fence_fd) { flush(stream, in_fence_fd, out_fence_fd); reset_buffer(stream); } -void etna_cmd_stream_finish(struct etna_cmd_stream *stream) +drm_public void etna_cmd_stream_finish(struct etna_cmd_stream *stream) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); @@ -244,7 +246,8 @@ void etna_cmd_stream_finish(struct etna_cmd_stream *stream) reset_buffer(stream); } -void etna_cmd_stream_reloc(struct etna_cmd_stream *stream, const struct etna_reloc *r) +drm_public void etna_cmd_stream_reloc(struct etna_cmd_stream *stream, + const struct etna_reloc *r) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); struct drm_etnaviv_gem_submit_reloc *reloc; @@ -261,7 +264,7 @@ void etna_cmd_stream_reloc(struct etna_cmd_stream *stream, const struct etna_rel etna_cmd_stream_emit(stream, addr); } -void etna_cmd_stream_perf(struct etna_cmd_stream *stream, const struct etna_perf *p) +drm_public void etna_cmd_stream_perf(struct etna_cmd_stream *stream, const struct etna_perf *p) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); struct drm_etnaviv_gem_submit_pmr *pmr; diff --git a/lib/libdrm/etnaviv/etnaviv_device.c b/lib/libdrm/etnaviv/etnaviv_device.c index d83e8d3e6..699df256f 100644 --- a/lib/libdrm/etnaviv/etnaviv_device.c +++ b/lib/libdrm/etnaviv/etnaviv_device.c @@ -41,7 +41,7 @@ static pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER; -struct etna_device *etna_device_new(int fd) +drm_public struct etna_device *etna_device_new(int fd) { struct etna_device *dev = calloc(sizeof(*dev), 1); @@ -59,7 +59,7 @@ struct etna_device *etna_device_new(int fd) /* like etna_device_new() but creates it's own private dup() of the fd * which is close()d when the device is finalized. */ -struct etna_device *etna_device_new_dup(int fd) +drm_public struct etna_device *etna_device_new_dup(int fd) { int dup_fd = dup(fd); struct etna_device *dev = etna_device_new(dup_fd); @@ -72,7 +72,7 @@ struct etna_device *etna_device_new_dup(int fd) return dev; } -struct etna_device *etna_device_ref(struct etna_device *dev) +drm_public struct etna_device *etna_device_ref(struct etna_device *dev) { atomic_inc(&dev->refcnt); @@ -99,7 +99,7 @@ drm_private void etna_device_del_locked(struct etna_device *dev) etna_device_del_impl(dev); } -void etna_device_del(struct etna_device *dev) +drm_public void etna_device_del(struct etna_device *dev) { if (!atomic_dec_and_test(&dev->refcnt)) return; @@ -109,7 +109,7 @@ void etna_device_del(struct etna_device *dev) pthread_mutex_unlock(&table_lock); } -int etna_device_fd(struct etna_device *dev) +drm_public int etna_device_fd(struct etna_device *dev) { return dev->fd; } diff --git a/lib/libdrm/etnaviv/etnaviv_gpu.c b/lib/libdrm/etnaviv/etnaviv_gpu.c index f7efa0289..dc4c126d1 100644 --- a/lib/libdrm/etnaviv/etnaviv_gpu.c +++ b/lib/libdrm/etnaviv/etnaviv_gpu.c @@ -44,7 +44,7 @@ static uint64_t get_param(struct etna_device *dev, uint32_t core, uint32_t param return req.value; } -struct etna_gpu *etna_gpu_new(struct etna_device *dev, unsigned int core) +drm_public struct etna_gpu *etna_gpu_new(struct etna_device *dev, unsigned int core) { struct etna_gpu *gpu; @@ -73,12 +73,12 @@ fail: return NULL; } -void etna_gpu_del(struct etna_gpu *gpu) +drm_public void etna_gpu_del(struct etna_gpu *gpu) { free(gpu); } -int etna_gpu_get_param(struct etna_gpu *gpu, enum etna_param_id param, +drm_public int etna_gpu_get_param(struct etna_gpu *gpu, enum etna_param_id param, uint64_t *value) { struct etna_device *dev = gpu->dev; diff --git a/lib/libdrm/etnaviv/etnaviv_perfmon.c b/lib/libdrm/etnaviv/etnaviv_perfmon.c index 5f408a7bc..f6576b8aa 100644 --- a/lib/libdrm/etnaviv/etnaviv_perfmon.c +++ b/lib/libdrm/etnaviv/etnaviv_perfmon.c @@ -121,7 +121,7 @@ static void etna_perfmon_free_domains(struct etna_perfmon *pm) } } -struct etna_perfmon *etna_perfmon_create(struct etna_pipe *pipe) +drm_public struct etna_perfmon *etna_perfmon_create(struct etna_pipe *pipe) { struct etna_perfmon *pm; int ret; @@ -147,7 +147,7 @@ fail: return NULL; } -void etna_perfmon_del(struct etna_perfmon *pm) +drm_public void etna_perfmon_del(struct etna_perfmon *pm) { if (!pm) return; @@ -156,7 +156,7 @@ void etna_perfmon_del(struct etna_perfmon *pm) free(pm); } -struct etna_perfmon_domain *etna_perfmon_get_dom_by_name(struct etna_perfmon *pm, const char *name) +drm_public struct etna_perfmon_domain *etna_perfmon_get_dom_by_name(struct etna_perfmon *pm, const char *name) { struct etna_perfmon_domain *dom; @@ -170,7 +170,7 @@ struct etna_perfmon_domain *etna_perfmon_get_dom_by_name(struct etna_perfmon *pm return NULL; } -struct etna_perfmon_signal *etna_perfmon_get_sig_by_name(struct etna_perfmon_domain *dom, const char *name) +drm_public struct etna_perfmon_signal *etna_perfmon_get_sig_by_name(struct etna_perfmon_domain *dom, const char *name) { struct etna_perfmon_signal *signal; diff --git a/lib/libdrm/etnaviv/etnaviv_pipe.c b/lib/libdrm/etnaviv/etnaviv_pipe.c index 53954aa32..4120a36fe 100644 --- a/lib/libdrm/etnaviv/etnaviv_pipe.c +++ b/lib/libdrm/etnaviv/etnaviv_pipe.c @@ -26,12 +26,12 @@ #include "etnaviv_priv.h" -int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms) +drm_public int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms) { return etna_pipe_wait_ns(pipe, timestamp, ms * 1000000); } -int etna_pipe_wait_ns(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns) +drm_public int etna_pipe_wait_ns(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns) { struct etna_device *dev = pipe->gpu->dev; int ret; @@ -55,12 +55,12 @@ int etna_pipe_wait_ns(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns) return 0; } -void etna_pipe_del(struct etna_pipe *pipe) +drm_public void etna_pipe_del(struct etna_pipe *pipe) { free(pipe); } -struct etna_pipe *etna_pipe_new(struct etna_gpu *gpu, enum etna_pipe_id id) +drm_public struct etna_pipe *etna_pipe_new(struct etna_gpu *gpu, enum etna_pipe_id id) { struct etna_pipe *pipe; diff --git a/lib/libdrm/etnaviv/meson.build b/lib/libdrm/etnaviv/meson.build index ca2aa544c..515a4ed07 100644 --- a/lib/libdrm/etnaviv/meson.build +++ b/lib/libdrm/etnaviv/meson.build @@ -30,7 +30,7 @@ libdrm_etnaviv = shared_library( ], include_directories : [inc_root, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, dependencies : [dep_pthread_stubs, dep_rt, dep_atomic_ops], version : '1.0.0', install : true, diff --git a/lib/libdrm/exynos/Makefile.am b/lib/libdrm/exynos/Makefile.am index f99f8981f..76b185d30 100644 --- a/lib/libdrm/exynos/Makefile.am +++ b/lib/libdrm/exynos/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm @@ -23,5 +24,6 @@ libdrm_exynosinclude_HEADERS = exynos_drmif.h pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_exynos.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = exynos-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/exynos/exynos-symbol-check b/lib/libdrm/exynos/exynos-symbol-check index e9f1b04d5..49d611e6b 100755 --- a/lib/libdrm/exynos/exynos-symbol-check +++ b/lib/libdrm/exynos/exynos-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.am/libdrm_exynos*_HEADERS diff --git a/lib/libdrm/exynos/exynos_drm.c b/lib/libdrm/exynos/exynos_drm.c index e1afef650..078bf2c59 100644 --- a/lib/libdrm/exynos/exynos_drm.c +++ b/lib/libdrm/exynos/exynos_drm.c @@ -48,7 +48,7 @@ * * if true, return the device object else NULL. */ -struct exynos_device * exynos_device_create(int fd) +drm_public struct exynos_device * exynos_device_create(int fd) { struct exynos_device *dev; @@ -69,7 +69,7 @@ struct exynos_device * exynos_device_create(int fd) * * @dev: exynos drm device object. */ -void exynos_device_destroy(struct exynos_device *dev) +drm_public void exynos_device_destroy(struct exynos_device *dev) { free(dev); } @@ -87,8 +87,8 @@ void exynos_device_destroy(struct exynos_device *dev) * * if true, return a exynos buffer object else NULL. */ -struct exynos_bo * exynos_bo_create(struct exynos_device *dev, - size_t size, uint32_t flags) +drm_public struct exynos_bo * exynos_bo_create(struct exynos_device *dev, + size_t size, uint32_t flags) { struct exynos_bo *bo; struct drm_exynos_gem_create req = { @@ -141,8 +141,8 @@ fail: * * if true, return 0 else negative. */ -int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle, - size_t *size, uint32_t *flags) +drm_public int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle, + size_t *size, uint32_t *flags) { int ret; struct drm_exynos_gem_info req = { @@ -167,7 +167,7 @@ int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle, * * @bo: a exynos buffer object to be destroyed. */ -void exynos_bo_destroy(struct exynos_bo *bo) +drm_public void exynos_bo_destroy(struct exynos_bo *bo) { if (!bo) return; @@ -199,7 +199,7 @@ void exynos_bo_destroy(struct exynos_bo *bo) * if true, return a exynos buffer object else NULL. * */ -struct exynos_bo * +drm_public struct exynos_bo * exynos_bo_from_name(struct exynos_device *dev, uint32_t name) { struct exynos_bo *bo; @@ -242,7 +242,7 @@ err_free_bo: * * if true, return 0 else negative. */ -int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name) +drm_public int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name) { if (!bo->name) { struct drm_gem_flink req = { @@ -265,7 +265,7 @@ int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name) return 0; } -uint32_t exynos_bo_handle(struct exynos_bo *bo) +drm_public uint32_t exynos_bo_handle(struct exynos_bo *bo) { return bo->handle; } @@ -278,7 +278,7 @@ uint32_t exynos_bo_handle(struct exynos_bo *bo) * * if true, user pointer mmaped else NULL. */ -void *exynos_bo_map(struct exynos_bo *bo) +drm_public void *exynos_bo_map(struct exynos_bo *bo) { if (!bo->vaddr) { struct exynos_device *dev = bo->dev; @@ -315,7 +315,7 @@ void *exynos_bo_map(struct exynos_bo *bo) * * @return: 0 on success, -1 on error, and errno will be set */ -int +drm_public int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle, int *fd) { return drmPrimeHandleToFD(dev->fd, handle, 0, fd); @@ -330,7 +330,7 @@ exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle, int *fd) * * @return: 0 on success, -1 on error, and errno will be set */ -int +drm_public int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, uint32_t *handle) { return drmPrimeFDToHandle(dev->fd, fd, handle); @@ -353,7 +353,7 @@ exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, uint32_t *handle) * * if true, return 0 else negative. */ -int +drm_public int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, uint32_t ext, void *edid) { @@ -394,7 +394,7 @@ exynos_handle_vendor(int fd, struct drm_event *e, void *ctx) } } -int +drm_public int exynos_handle_event(struct exynos_device *dev, struct exynos_event_context *ctx) { char buffer[1024]; diff --git a/lib/libdrm/exynos/exynos_fimg2d.c b/lib/libdrm/exynos/exynos_fimg2d.c index bca884b9e..ac6fa6872 100644 --- a/lib/libdrm/exynos/exynos_fimg2d.c +++ b/lib/libdrm/exynos/exynos_fimg2d.c @@ -356,7 +356,7 @@ static int g2d_flush(struct g2d_context *ctx) * * fd: a file descriptor to an opened drm device. */ -struct g2d_context *g2d_init(int fd) +drm_public struct g2d_context *g2d_init(int fd) { struct drm_exynos_g2d_get_ver ver; struct g2d_context *ctx; @@ -384,7 +384,7 @@ struct g2d_context *g2d_init(int fd) return ctx; } -void g2d_fini(struct g2d_context *ctx) +drm_public void g2d_fini(struct g2d_context *ctx) { free(ctx); } @@ -400,7 +400,7 @@ void g2d_fini(struct g2d_context *ctx) * @ctx: a pointer to g2d_context structure. * @userdata: a pointer to the user data */ -void g2d_config_event(struct g2d_context *ctx, void *userdata) +drm_public void g2d_config_event(struct g2d_context *ctx, void *userdata) { ctx->event_userdata = userdata; } @@ -410,7 +410,7 @@ void g2d_config_event(struct g2d_context *ctx, void *userdata) * * @ctx: a pointer to g2d_context structure. */ -int g2d_exec(struct g2d_context *ctx) +drm_public int g2d_exec(struct g2d_context *ctx) { struct drm_exynos_g2d_exec exec; int ret; @@ -442,7 +442,7 @@ int g2d_exec(struct g2d_context *ctx) * @w: width value to buffer filled with given color data. * @h: height value to buffer filled with given color data. */ -int +drm_public int g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img, unsigned int x, unsigned int y, unsigned int w, unsigned int h) @@ -495,7 +495,7 @@ g2d_solid_fill(struct g2d_context *ctx, struct g2d_image *img, * @w: width value to source and destination buffers. * @h: height value to source and destination buffers. */ -int +drm_public int g2d_copy(struct g2d_context *ctx, struct g2d_image *src, struct g2d_image *dst, unsigned int src_x, unsigned int src_y, unsigned int dst_x, unsigned dst_y, unsigned int w, @@ -578,7 +578,7 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src, * @w: width of rectangle to move. * @h: height of rectangle to move. */ -int +drm_public int g2d_move(struct g2d_context *ctx, struct g2d_image *img, unsigned int src_x, unsigned int src_y, unsigned int dst_x, unsigned dst_y, unsigned int w, @@ -676,7 +676,7 @@ g2d_move(struct g2d_context *ctx, struct g2d_image *img, * @negative: indicate that it uses color negative to source and * destination buffers. */ -int +drm_public int g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, struct g2d_image *dst, unsigned int src_x, unsigned int src_y, unsigned int src_w, @@ -785,7 +785,7 @@ g2d_copy_with_scale(struct g2d_context *ctx, struct g2d_image *src, * @h: height value to source and destination buffer. * @op: blend operation type. */ -int +drm_public int g2d_blend(struct g2d_context *ctx, struct g2d_image *src, struct g2d_image *dst, unsigned int src_x, unsigned int src_y, unsigned int dst_x, unsigned int dst_y, @@ -902,7 +902,7 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src, * @dst_h: height value to destination buffer. * @op: blend operation type. */ -int +drm_public int g2d_scale_and_blend(struct g2d_context *ctx, struct g2d_image *src, struct g2d_image *dst, unsigned int src_x, unsigned int src_y, unsigned int src_w, unsigned int src_h, unsigned int dst_x, diff --git a/lib/libdrm/exynos/meson.build b/lib/libdrm/exynos/meson.build index 30d36405d..bdfc3fc6d 100644 --- a/lib/libdrm/exynos/meson.build +++ b/lib/libdrm/exynos/meson.build @@ -21,7 +21,7 @@ libdrm_exynos = shared_library( 'drm_exynos', [files('exynos_drm.c', 'exynos_fimg2d.c'), config_file], - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_pthread_stubs], diff --git a/lib/libdrm/freedreno/Makefile.am b/lib/libdrm/freedreno/Makefile.am index cbb0d0318..378450354 100644 --- a/lib/libdrm/freedreno/Makefile.am +++ b/lib/libdrm/freedreno/Makefile.am @@ -3,6 +3,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ $(VALGRIND_CFLAGS) \ @@ -27,5 +28,6 @@ libdrm_freedrenocommoninclude_HEADERS = $(LIBDRM_FREEDRENO_H_FILES) pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_freedreno.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = freedreno-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/freedreno/freedreno-symbol-check b/lib/libdrm/freedreno/freedreno-symbol-check index e732c9951..978026c09 100755 --- a/lib/libdrm/freedreno/freedreno-symbol-check +++ b/lib/libdrm/freedreno/freedreno-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.sources/LIBDRM_FREEDRENO_H_FILES @@ -46,19 +48,16 @@ fd_ringbuffer_emit_reloc_ring_full fd_ringbuffer_flush fd_ringbuffer_grow fd_ringbuffer_new +fd_ringbuffer_new_flags fd_ringbuffer_new_object +fd_ringbuffer_ref fd_ringbuffer_reloc fd_ringbuffer_reloc2 fd_ringbuffer_reset fd_ringbuffer_set_parent fd_ringbuffer_size fd_ringbuffer_timestamp -fd_ringmarker_del -fd_ringmarker_dwords -fd_ringmarker_flush fd_ringbuffer_flush2 -fd_ringmarker_mark -fd_ringmarker_new EOF done) diff --git a/lib/libdrm/freedreno/freedreno_bo.c b/lib/libdrm/freedreno/freedreno_bo.c index 34c285fbd..efc5b71f1 100644 --- a/lib/libdrm/freedreno/freedreno_bo.c +++ b/lib/libdrm/freedreno/freedreno_bo.c @@ -78,14 +78,15 @@ static struct fd_bo * bo_from_handle(struct fd_device *dev, return bo; } -struct fd_bo * -fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags) +static struct fd_bo * +bo_new(struct fd_device *dev, uint32_t size, uint32_t flags, + struct fd_bo_cache *cache) { struct fd_bo *bo = NULL; uint32_t handle; int ret; - bo = fd_bo_cache_alloc(&dev->bo_cache, &size, flags); + bo = fd_bo_cache_alloc(cache, &size, flags); if (bo) return bo; @@ -95,7 +96,6 @@ fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags) pthread_mutex_lock(&table_lock); bo = bo_from_handle(dev, size, handle); - bo->bo_reuse = TRUE; pthread_mutex_unlock(&table_lock); VG_BO_ALLOC(bo); @@ -103,7 +103,30 @@ fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags) return bo; } -struct fd_bo * +drm_public struct fd_bo * +fd_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags) +{ + struct fd_bo *bo = bo_new(dev, size, flags, &dev->bo_cache); + if (bo) + bo->bo_reuse = BO_CACHE; + return bo; +} + +/* internal function to allocate bo's that use the ringbuffer cache + * instead of the normal bo_cache. The purpose is, because cmdstream + * bo's get vmap'd on the kernel side, and that is expensive, we want + * to re-use cmdstream bo's for cmdstream and not unrelated purposes. + */ +drm_private struct fd_bo * +fd_bo_new_ring(struct fd_device *dev, uint32_t size, uint32_t flags) +{ + struct fd_bo *bo = bo_new(dev, size, flags, &dev->ring_cache); + if (bo) + bo->bo_reuse = RING_CACHE; + return bo; +} + +drm_public struct fd_bo * fd_bo_from_handle(struct fd_device *dev, uint32_t handle, uint32_t size) { struct fd_bo *bo = NULL; @@ -124,7 +147,7 @@ out_unlock: return bo; } -struct fd_bo * +drm_public struct fd_bo * fd_bo_from_dmabuf(struct fd_device *dev, int fd) { int ret, size; @@ -156,7 +179,7 @@ out_unlock: return bo; } -struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name) +drm_public struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name) { struct drm_gem_open req = { .name = name, @@ -191,23 +214,23 @@ out_unlock: return bo; } -uint64_t fd_bo_get_iova(struct fd_bo *bo) +drm_public uint64_t fd_bo_get_iova(struct fd_bo *bo) { return bo->funcs->iova(bo); } -void fd_bo_put_iova(struct fd_bo *bo) +drm_public void fd_bo_put_iova(struct fd_bo *bo) { /* currently a no-op */ } -struct fd_bo * fd_bo_ref(struct fd_bo *bo) +drm_public struct fd_bo * fd_bo_ref(struct fd_bo *bo) { atomic_inc(&bo->refcnt); return bo; } -void fd_bo_del(struct fd_bo *bo) +drm_public void fd_bo_del(struct fd_bo *bo) { struct fd_device *dev = bo->dev; @@ -216,7 +239,9 @@ void fd_bo_del(struct fd_bo *bo) pthread_mutex_lock(&table_lock); - if (bo->bo_reuse && (fd_bo_cache_free(&dev->bo_cache, bo) == 0)) + if ((bo->bo_reuse == BO_CACHE) && (fd_bo_cache_free(&dev->bo_cache, bo) == 0)) + goto out; + if ((bo->bo_reuse == RING_CACHE) && (fd_bo_cache_free(&dev->ring_cache, bo) == 0)) goto out; bo_del(bo); @@ -250,7 +275,7 @@ drm_private void bo_del(struct fd_bo *bo) bo->funcs->destroy(bo); } -int fd_bo_get_name(struct fd_bo *bo, uint32_t *name) +drm_public int fd_bo_get_name(struct fd_bo *bo, uint32_t *name) { if (!bo->name) { struct drm_gem_flink req = { @@ -266,7 +291,7 @@ int fd_bo_get_name(struct fd_bo *bo, uint32_t *name) pthread_mutex_lock(&table_lock); set_name(bo, req.name); pthread_mutex_unlock(&table_lock); - bo->bo_reuse = FALSE; + bo->bo_reuse = NO_CACHE; } *name = bo->name; @@ -274,12 +299,12 @@ int fd_bo_get_name(struct fd_bo *bo, uint32_t *name) return 0; } -uint32_t fd_bo_handle(struct fd_bo *bo) +drm_public uint32_t fd_bo_handle(struct fd_bo *bo) { return bo->handle; } -int fd_bo_dmabuf(struct fd_bo *bo) +drm_public int fd_bo_dmabuf(struct fd_bo *bo) { int ret, prime_fd; @@ -290,17 +315,17 @@ int fd_bo_dmabuf(struct fd_bo *bo) return ret; } - bo->bo_reuse = FALSE; + bo->bo_reuse = NO_CACHE; return prime_fd; } -uint32_t fd_bo_size(struct fd_bo *bo) +drm_public uint32_t fd_bo_size(struct fd_bo *bo) { return bo->size; } -void * fd_bo_map(struct fd_bo *bo) +drm_public void * fd_bo_map(struct fd_bo *bo) { if (!bo->map) { uint64_t offset; @@ -322,18 +347,18 @@ void * fd_bo_map(struct fd_bo *bo) } /* a bit odd to take the pipe as an arg, but it's a, umm, quirk of kgsl.. */ -int fd_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op) +drm_public int fd_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op) { return bo->funcs->cpu_prep(bo, pipe, op); } -void fd_bo_cpu_fini(struct fd_bo *bo) +drm_public void fd_bo_cpu_fini(struct fd_bo *bo) { bo->funcs->cpu_fini(bo); } #if !HAVE_FREEDRENO_KGSL -struct fd_bo * fd_bo_from_fbdev(struct fd_pipe *pipe, int fbfd, uint32_t size) +drm_public struct fd_bo * fd_bo_from_fbdev(struct fd_pipe *pipe, int fbfd, uint32_t size) { return NULL; } diff --git a/lib/libdrm/freedreno/freedreno_bo_cache.c b/lib/libdrm/freedreno/freedreno_bo_cache.c index 3b737159c..bb0605abd 100644 --- a/lib/libdrm/freedreno/freedreno_bo_cache.c +++ b/lib/libdrm/freedreno/freedreno_bo_cache.c @@ -49,7 +49,7 @@ add_bucket(struct fd_bo_cache *cache, int size) * fill in for a bit smoother size curve.. */ drm_private void -fd_bo_cache_init(struct fd_bo_cache *cache, int course) +fd_bo_cache_init(struct fd_bo_cache *cache, int coarse) { unsigned long size, cache_max_size = 64 * 1024 * 1024; @@ -63,13 +63,13 @@ fd_bo_cache_init(struct fd_bo_cache *cache, int course) */ add_bucket(cache, 4096); add_bucket(cache, 4096 * 2); - if (!course) + if (!coarse) add_bucket(cache, 4096 * 3); /* Initialize the linked lists for BO reuse cache. */ for (size = 4 * 4096; size <= cache_max_size; size *= 2) { add_bucket(cache, size); - if (!course) { + if (!coarse) { add_bucket(cache, size + size * 1 / 4); add_bucket(cache, size + size * 2 / 4); add_bucket(cache, size + size * 3 / 4); diff --git a/lib/libdrm/freedreno/freedreno_device.c b/lib/libdrm/freedreno/freedreno_device.c index 0b42561a4..ac2343044 100644 --- a/lib/libdrm/freedreno/freedreno_device.c +++ b/lib/libdrm/freedreno/freedreno_device.c @@ -38,7 +38,7 @@ static pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER; struct fd_device * kgsl_device_new(int fd); struct fd_device * msm_device_new(int fd); -struct fd_device * fd_device_new(int fd) +drm_public struct fd_device * fd_device_new(int fd) { struct fd_device *dev; drmVersionPtr version; @@ -82,6 +82,7 @@ out: dev->handle_table = drmHashCreate(); dev->name_table = drmHashCreate(); fd_bo_cache_init(&dev->bo_cache, FALSE); + fd_bo_cache_init(&dev->ring_cache, TRUE); return dev; } @@ -89,7 +90,7 @@ out: /* like fd_device_new() but creates it's own private dup() of the fd * which is close()d when the device is finalized. */ -struct fd_device * fd_device_new_dup(int fd) +drm_public struct fd_device * fd_device_new_dup(int fd) { int dup_fd = dup(fd); struct fd_device *dev = fd_device_new(dup_fd); @@ -100,7 +101,7 @@ struct fd_device * fd_device_new_dup(int fd) return dev; } -struct fd_device * fd_device_ref(struct fd_device *dev) +drm_public struct fd_device * fd_device_ref(struct fd_device *dev) { atomic_inc(&dev->refcnt); return dev; @@ -124,7 +125,7 @@ drm_private void fd_device_del_locked(struct fd_device *dev) fd_device_del_impl(dev); } -void fd_device_del(struct fd_device *dev) +drm_public void fd_device_del(struct fd_device *dev) { if (!atomic_dec_and_test(&dev->refcnt)) return; @@ -133,12 +134,12 @@ void fd_device_del(struct fd_device *dev) pthread_mutex_unlock(&table_lock); } -int fd_device_fd(struct fd_device *dev) +drm_public int fd_device_fd(struct fd_device *dev) { return dev->fd; } -enum fd_version fd_device_version(struct fd_device *dev) +drm_public enum fd_version fd_device_version(struct fd_device *dev) { return dev->version; } diff --git a/lib/libdrm/freedreno/freedreno_pipe.c b/lib/libdrm/freedreno/freedreno_pipe.c index 30d231c7d..e82e64486 100644 --- a/lib/libdrm/freedreno/freedreno_pipe.c +++ b/lib/libdrm/freedreno/freedreno_pipe.c @@ -33,7 +33,7 @@ * priority of zero is highest priority, and higher numeric values are * lower priorities */ -struct fd_pipe * +drm_public struct fd_pipe * fd_pipe_new2(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio) { struct fd_pipe *pipe; @@ -65,37 +65,37 @@ fd_pipe_new2(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio) return pipe; } -struct fd_pipe * +drm_public struct fd_pipe * fd_pipe_new(struct fd_device *dev, enum fd_pipe_id id) { return fd_pipe_new2(dev, id, 1); } -struct fd_pipe * fd_pipe_ref(struct fd_pipe *pipe) +drm_public struct fd_pipe * fd_pipe_ref(struct fd_pipe *pipe) { atomic_inc(&pipe->refcnt); return pipe; } -void fd_pipe_del(struct fd_pipe *pipe) +drm_public void fd_pipe_del(struct fd_pipe *pipe) { if (!atomic_dec_and_test(&pipe->refcnt)) return; pipe->funcs->destroy(pipe); } -int fd_pipe_get_param(struct fd_pipe *pipe, +drm_public int fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value) { return pipe->funcs->get_param(pipe, param, value); } -int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp) +drm_public int fd_pipe_wait(struct fd_pipe *pipe, uint32_t timestamp) { return fd_pipe_wait_timeout(pipe, timestamp, ~0); } -int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp, +drm_public int fd_pipe_wait_timeout(struct fd_pipe *pipe, uint32_t timestamp, uint64_t timeout) { return pipe->funcs->wait(pipe, timestamp, timeout); diff --git a/lib/libdrm/freedreno/freedreno_priv.h b/lib/libdrm/freedreno/freedreno_priv.h index 9d51c368b..b8eac4b26 100644 --- a/lib/libdrm/freedreno/freedreno_priv.h +++ b/lib/libdrm/freedreno/freedreno_priv.h @@ -98,6 +98,7 @@ struct fd_device { const struct fd_device_funcs *funcs; struct fd_bo_cache bo_cache; + struct fd_bo_cache ring_cache; int closefd; /* call close(fd) upon destruction */ @@ -114,10 +115,6 @@ drm_private int fd_bo_cache_free(struct fd_bo_cache *cache, struct fd_bo *bo); /* for where @table_lock is already held: */ drm_private void fd_device_del_locked(struct fd_device *dev); -enum fd_ringbuffer_flags { - FD_RINGBUFFER_OBJECT = 0x1, -}; - struct fd_pipe_funcs { struct fd_ringbuffer * (*ringbuffer_new)(struct fd_pipe *pipe, uint32_t size, enum fd_ringbuffer_flags flags); @@ -134,11 +131,6 @@ struct fd_pipe { const struct fd_pipe_funcs *funcs; }; -struct fd_ringmarker { - struct fd_ringbuffer *ring; - uint32_t *cur; -}; - struct fd_ringbuffer_funcs { void * (*hostptr)(struct fd_ringbuffer *ring); int (*flush)(struct fd_ringbuffer *ring, uint32_t *last_start, @@ -148,8 +140,7 @@ struct fd_ringbuffer_funcs { void (*emit_reloc)(struct fd_ringbuffer *ring, const struct fd_reloc *reloc); uint32_t (*emit_reloc_ring)(struct fd_ringbuffer *ring, - struct fd_ringbuffer *target, uint32_t cmd_idx, - uint32_t submit_offset, uint32_t size); + struct fd_ringbuffer *target, uint32_t cmd_idx); uint32_t (*cmd_count)(struct fd_ringbuffer *ring); void (*destroy)(struct fd_ringbuffer *ring); }; @@ -172,11 +163,19 @@ struct fd_bo { atomic_t refcnt; const struct fd_bo_funcs *funcs; - int bo_reuse; + enum { + NO_CACHE = 0, + BO_CACHE = 1, + RING_CACHE = 2, + } bo_reuse; + struct list_head list; /* bucket-list entry */ time_t free_time; /* time when added to bucket-list */ }; +drm_private struct fd_bo *fd_bo_new_ring(struct fd_device *dev, + uint32_t size, uint32_t flags); + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define enable_debug 0 /* TODO make dynamic */ diff --git a/lib/libdrm/freedreno/freedreno_ringbuffer.c b/lib/libdrm/freedreno/freedreno_ringbuffer.c index eb6cd0ca1..8f0093ae6 100644 --- a/lib/libdrm/freedreno/freedreno_ringbuffer.c +++ b/lib/libdrm/freedreno/freedreno_ringbuffer.c @@ -32,12 +32,19 @@ #include "freedreno_priv.h" #include "freedreno_ringbuffer.h" -static struct fd_ringbuffer * -ringbuffer_new(struct fd_pipe *pipe, uint32_t size, +drm_public struct fd_ringbuffer * +fd_ringbuffer_new_flags(struct fd_pipe *pipe, uint32_t size, enum fd_ringbuffer_flags flags) { struct fd_ringbuffer *ring; + /* we can't really support "growable" rb's in general for + * stateobj's since we need a single gpu addr (ie. can't + * do the trick of a chain of IB packets): + */ + if (flags & FD_RINGBUFFER_OBJECT) + assert(size); + ring = pipe->funcs->ringbuffer_new(pipe, size, flags); if (!ring) return NULL; @@ -52,35 +59,40 @@ ringbuffer_new(struct fd_pipe *pipe, uint32_t size, return ring; } -struct fd_ringbuffer * +drm_public struct fd_ringbuffer * fd_ringbuffer_new(struct fd_pipe *pipe, uint32_t size) { - return ringbuffer_new(pipe, size, 0); + return fd_ringbuffer_new_flags(pipe, size, 0); } -struct fd_ringbuffer * +drm_public struct fd_ringbuffer * fd_ringbuffer_new_object(struct fd_pipe *pipe, uint32_t size) { - /* we can't really support "growable" rb's in general for - * stateobj's since we need a single gpu addr (ie. can't - * do the trick of a chain of IB packets): - */ - assert(size); - return ringbuffer_new(pipe, size, FD_RINGBUFFER_OBJECT); + return fd_ringbuffer_new_flags(pipe, size, FD_RINGBUFFER_OBJECT); } -void fd_ringbuffer_del(struct fd_ringbuffer *ring) +drm_public void fd_ringbuffer_del(struct fd_ringbuffer *ring) { - if (!(ring->flags & FD_RINGBUFFER_OBJECT)) - fd_ringbuffer_reset(ring); + if (!atomic_dec_and_test(&ring->refcnt)) + return; + + fd_ringbuffer_reset(ring); ring->funcs->destroy(ring); } +drm_public struct fd_ringbuffer * +fd_ringbuffer_ref(struct fd_ringbuffer *ring) +{ + STATIC_ASSERT(sizeof(ring->refcnt) <= sizeof(ring->__pad)); + atomic_inc(&ring->refcnt); + return ring; +} + /* ringbuffers which are IB targets should set the toplevel rb (ie. * the IB source) as it's parent before emitting reloc's, to ensure * the bookkeeping works out properly. */ -void fd_ringbuffer_set_parent(struct fd_ringbuffer *ring, +drm_public void fd_ringbuffer_set_parent(struct fd_ringbuffer *ring, struct fd_ringbuffer *parent) { /* state objects should not be parented! */ @@ -88,7 +100,7 @@ void fd_ringbuffer_set_parent(struct fd_ringbuffer *ring, ring->parent = parent; } -void fd_ringbuffer_reset(struct fd_ringbuffer *ring) +drm_public void fd_ringbuffer_reset(struct fd_ringbuffer *ring) { uint32_t *start = ring->start; if (ring->pipe->id == FD_PIPE_2D) @@ -98,18 +110,18 @@ void fd_ringbuffer_reset(struct fd_ringbuffer *ring) ring->funcs->reset(ring); } -int fd_ringbuffer_flush(struct fd_ringbuffer *ring) +drm_public int fd_ringbuffer_flush(struct fd_ringbuffer *ring) { return ring->funcs->flush(ring, ring->last_start, -1, NULL); } -int fd_ringbuffer_flush2(struct fd_ringbuffer *ring, int in_fence_fd, +drm_public int fd_ringbuffer_flush2(struct fd_ringbuffer *ring, int in_fence_fd, int *out_fence_fd) { return ring->funcs->flush(ring, ring->last_start, in_fence_fd, out_fence_fd); } -void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords) +drm_public void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords) { assert(ring->funcs->grow); /* unsupported on kgsl */ @@ -125,55 +137,39 @@ void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords) ring->cur = ring->last_start = ring->start; } -uint32_t fd_ringbuffer_timestamp(struct fd_ringbuffer *ring) +drm_public uint32_t fd_ringbuffer_timestamp(struct fd_ringbuffer *ring) { return ring->last_timestamp; } -void fd_ringbuffer_reloc(struct fd_ringbuffer *ring, +drm_public void fd_ringbuffer_reloc(struct fd_ringbuffer *ring, const struct fd_reloc *reloc) { assert(ring->pipe->gpu_id < 500); ring->funcs->emit_reloc(ring, reloc); } -void fd_ringbuffer_reloc2(struct fd_ringbuffer *ring, +drm_public void fd_ringbuffer_reloc2(struct fd_ringbuffer *ring, const struct fd_reloc *reloc) { ring->funcs->emit_reloc(ring, reloc); } -void fd_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, - struct fd_ringmarker *target, struct fd_ringmarker *end) -{ - uint32_t submit_offset, size; - - /* This function is deprecated and not supported on 64b devices: */ - assert(ring->pipe->gpu_id < 500); - assert(target->ring == end->ring); - - submit_offset = offset_bytes(target->cur, target->ring->start); - size = offset_bytes(end->cur, target->cur); - - ring->funcs->emit_reloc_ring(ring, target->ring, 0, submit_offset, size); -} - -uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring) +drm_public uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring) { if (!ring->funcs->cmd_count) return 1; return ring->funcs->cmd_count(ring); } -uint32_t +drm_public uint32_t fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring, struct fd_ringbuffer *target, uint32_t cmd_idx) { - uint32_t size = offset_bytes(target->cur, target->start); - return ring->funcs->emit_reloc_ring(ring, target, cmd_idx, 0, size); + return ring->funcs->emit_reloc_ring(ring, target, cmd_idx); } -uint32_t +drm_public uint32_t fd_ringbuffer_size(struct fd_ringbuffer *ring) { /* only really needed for stateobj ringbuffers, and won't really @@ -184,45 +180,3 @@ fd_ringbuffer_size(struct fd_ringbuffer *ring) return offset_bytes(ring->cur, ring->start); } -/* - * Deprecated ringmarker API: - */ - -struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring) -{ - struct fd_ringmarker *marker = NULL; - - marker = calloc(1, sizeof(*marker)); - if (!marker) { - ERROR_MSG("allocation failed"); - return NULL; - } - - marker->ring = ring; - - marker->cur = marker->ring->cur; - - return marker; -} - -void fd_ringmarker_del(struct fd_ringmarker *marker) -{ - free(marker); -} - -void fd_ringmarker_mark(struct fd_ringmarker *marker) -{ - marker->cur = marker->ring->cur; -} - -uint32_t fd_ringmarker_dwords(struct fd_ringmarker *start, - struct fd_ringmarker *end) -{ - return end->cur - start->cur; -} - -int fd_ringmarker_flush(struct fd_ringmarker *marker) -{ - struct fd_ringbuffer *ring = marker->ring; - return ring->funcs->flush(ring, marker->cur, -1, NULL); -} diff --git a/lib/libdrm/freedreno/freedreno_ringbuffer.h b/lib/libdrm/freedreno/freedreno_ringbuffer.h index 69e7ed997..bc41a31cd 100644 --- a/lib/libdrm/freedreno/freedreno_ringbuffer.h +++ b/lib/libdrm/freedreno/freedreno_ringbuffer.h @@ -37,7 +37,29 @@ */ struct fd_ringbuffer_funcs; -struct fd_ringmarker; + +enum fd_ringbuffer_flags { + + /* Ringbuffer is a "state object", which is potentially reused + * many times, rather than being used in one-shot mode linked + * to a parent ringbuffer. + */ + FD_RINGBUFFER_OBJECT = 0x1, + + /* Hint that the stateobj will be used for streaming state + * that is used once or a few times and then discarded. + * + * For sub-allocation, non streaming stateobj's should be + * sub-allocated from a page size buffer, so one long lived + * state obj doesn't prevent other pages from being freed. + * (Ie. it would be no worse than allocating a page sized + * bo for each small non-streaming stateobj). + * + * But streaming stateobj's could be sub-allocated from a + * larger buffer to reduce the alloc/del overhead. + */ + FD_RINGBUFFER_STREAMING = 0x2, +}; struct fd_ringbuffer { int size; @@ -52,17 +74,35 @@ struct fd_ringbuffer { */ void *user; - uint32_t flags; + enum fd_ringbuffer_flags flags; + + /* This is a bit gross, but we can't use atomic_t in exported + * headers. OTOH, we don't need the refcnt to be publicly + * visible. The only reason that this struct is exported is + * because fd_ringbuffer_emit needs to be something that can + * be inlined for performance reasons. + */ + union { +#ifdef HAS_ATOMIC_OPS + atomic_t refcnt; +#endif + uint64_t __pad; + }; }; struct fd_ringbuffer * fd_ringbuffer_new(struct fd_pipe *pipe, uint32_t size); +will_be_deprecated struct fd_ringbuffer * fd_ringbuffer_new_object(struct fd_pipe *pipe, uint32_t size); +struct fd_ringbuffer * fd_ringbuffer_new_flags(struct fd_pipe *pipe, + uint32_t size, enum fd_ringbuffer_flags flags); +struct fd_ringbuffer *fd_ringbuffer_ref(struct fd_ringbuffer *ring); void fd_ringbuffer_del(struct fd_ringbuffer *ring); void fd_ringbuffer_set_parent(struct fd_ringbuffer *ring, struct fd_ringbuffer *parent); +will_be_deprecated void fd_ringbuffer_reset(struct fd_ringbuffer *ring); int fd_ringbuffer_flush(struct fd_ringbuffer *ring); /* in_fence_fd: -1 for no in-fence, else fence fd @@ -94,18 +134,9 @@ struct fd_reloc { void fd_ringbuffer_reloc2(struct fd_ringbuffer *ring, const struct fd_reloc *reloc); will_be_deprecated void fd_ringbuffer_reloc(struct fd_ringbuffer *ring, const struct fd_reloc *reloc); -will_be_deprecated void fd_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, - struct fd_ringmarker *target, struct fd_ringmarker *end); uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring); uint32_t fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring, struct fd_ringbuffer *target, uint32_t cmd_idx); uint32_t fd_ringbuffer_size(struct fd_ringbuffer *ring); -will_be_deprecated struct fd_ringmarker * fd_ringmarker_new(struct fd_ringbuffer *ring); -will_be_deprecated void fd_ringmarker_del(struct fd_ringmarker *marker); -will_be_deprecated void fd_ringmarker_mark(struct fd_ringmarker *marker); -will_be_deprecated uint32_t fd_ringmarker_dwords(struct fd_ringmarker *start, - struct fd_ringmarker *end); -will_be_deprecated int fd_ringmarker_flush(struct fd_ringmarker *marker); - #endif /* FREEDRENO_RINGBUFFER_H_ */ diff --git a/lib/libdrm/freedreno/kgsl/kgsl_bo.c b/lib/libdrm/freedreno/kgsl/kgsl_bo.c index c6d2d4999..7a6af2f08 100644 --- a/lib/libdrm/freedreno/kgsl/kgsl_bo.c +++ b/lib/libdrm/freedreno/kgsl/kgsl_bo.c @@ -177,7 +177,7 @@ drm_private struct fd_bo * kgsl_bo_from_handle(struct fd_device *dev, return bo; } -struct fd_bo * +drm_public struct fd_bo * fd_bo_from_fbdev(struct fd_pipe *pipe, int fbfd, uint32_t size) { struct fd_bo *bo; diff --git a/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c b/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c index e4fdf342b..9abf0adff 100644 --- a/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c +++ b/lib/libdrm/freedreno/kgsl/kgsl_ringbuffer.c @@ -28,6 +28,7 @@ #include <assert.h> +#include "xf86atomic.h" #include "freedreno_ringbuffer.h" #include "kgsl_priv.h" @@ -174,13 +175,12 @@ static void kgsl_ringbuffer_emit_reloc(struct fd_ringbuffer *ring, } static uint32_t kgsl_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, - struct fd_ringbuffer *target, uint32_t cmd_idx, - uint32_t submit_offset, uint32_t size) + struct fd_ringbuffer *target, uint32_t cmd_idx) { struct kgsl_ringbuffer *target_ring = to_kgsl_ringbuffer(target); assert(cmd_idx == 0); - (*ring->cur++) = target_ring->bo->gpuaddr + submit_offset; - return size; + (*ring->cur++) = target_ring->bo->gpuaddr; + return offset_bytes(target->cur, target->start); } static void kgsl_ringbuffer_destroy(struct fd_ringbuffer *ring) @@ -216,6 +216,8 @@ drm_private struct fd_ringbuffer * kgsl_ringbuffer_new(struct fd_pipe *pipe, } ring = &kgsl_ring->base; + atomic_set(&ring->refcnt, 1); + ring->funcs = &funcs; ring->size = size; diff --git a/lib/libdrm/freedreno/meson.build b/lib/libdrm/freedreno/meson.build index 015b7fb1c..c9aba060a 100644 --- a/lib/libdrm/freedreno/meson.build +++ b/lib/libdrm/freedreno/meson.build @@ -42,7 +42,7 @@ endif libdrm_freedreno = shared_library( 'drm_freedreno', [files_freedreno, config_file], - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm], dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt, dep_atomic_ops], link_with : libdrm, diff --git a/lib/libdrm/freedreno/msm/msm_device.c b/lib/libdrm/freedreno/msm/msm_device.c index 7bb576774..58b0746d9 100644 --- a/lib/libdrm/freedreno/msm/msm_device.c +++ b/lib/libdrm/freedreno/msm/msm_device.c @@ -35,7 +35,6 @@ static void msm_device_destroy(struct fd_device *dev) { struct msm_device *msm_dev = to_msm_device(dev); - fd_bo_cache_cleanup(&msm_dev->ring_cache, 0); free(msm_dev); } @@ -58,8 +57,6 @@ drm_private struct fd_device * msm_device_new(int fd) dev = &msm_dev->base; dev->funcs = &funcs; - fd_bo_cache_init(&msm_dev->ring_cache, TRUE); - dev->bo_size = sizeof(struct msm_bo); return dev; diff --git a/lib/libdrm/freedreno/msm/msm_pipe.c b/lib/libdrm/freedreno/msm/msm_pipe.c index f28778ef9..e070b3170 100644 --- a/lib/libdrm/freedreno/msm/msm_pipe.c +++ b/lib/libdrm/freedreno/msm/msm_pipe.c @@ -138,6 +138,12 @@ static void msm_pipe_destroy(struct fd_pipe *pipe) { struct msm_pipe *msm_pipe = to_msm_pipe(pipe); close_submitqueue(pipe, msm_pipe->queue_id); + + if (msm_pipe->suballoc_ring) { + fd_ringbuffer_del(msm_pipe->suballoc_ring); + msm_pipe->suballoc_ring = NULL; + } + free(msm_pipe); } diff --git a/lib/libdrm/freedreno/msm/msm_priv.h b/lib/libdrm/freedreno/msm/msm_priv.h index ee0eecb83..cc951fba2 100644 --- a/lib/libdrm/freedreno/msm/msm_priv.h +++ b/lib/libdrm/freedreno/msm/msm_priv.h @@ -57,6 +57,17 @@ struct msm_pipe { uint32_t gmem; uint32_t chip_id; uint32_t queue_id; + + /* Allow for sub-allocation of stateobj ring buffers (ie. sharing + * the same underlying bo).. + * + * This takes advantage of each context having it's own fd_pipe, + * so we don't have to worry about access from multiple threads. + * + * We also rely on previous stateobj having been fully constructed + * so we can reclaim extra space at it's end. + */ + struct fd_ringbuffer *suballoc_ring; }; static inline struct msm_pipe * to_msm_pipe(struct fd_pipe *x) diff --git a/lib/libdrm/freedreno/msm/msm_ringbuffer.c b/lib/libdrm/freedreno/msm/msm_ringbuffer.c index 35a7a7d44..475c65d78 100644 --- a/lib/libdrm/freedreno/msm/msm_ringbuffer.c +++ b/lib/libdrm/freedreno/msm/msm_ringbuffer.c @@ -29,6 +29,7 @@ #include <assert.h> #include <inttypes.h> +#include "xf86atomic.h" #include "freedreno_ringbuffer.h" #include "msm_priv.h" @@ -45,13 +46,14 @@ struct msm_cmd { DECLARE_ARRAY(struct drm_msm_gem_submit_reloc, relocs); uint32_t size; + + /* has cmd already been added to parent rb's submit.cmds table? */ + int is_appended_to_submit; }; struct msm_ringbuffer { struct fd_ringbuffer base; - atomic_t refcnt; - /* submit ioctl related tables: * Note that bos and cmds are tracked by the parent ringbuffer, since * that is global to the submit ioctl call. The reloc's table is tracked @@ -86,10 +88,24 @@ struct msm_ringbuffer { int is_growable; unsigned cmd_count; + unsigned offset; /* for sub-allocated stateobj rb's */ + unsigned seqno; /* maps fd_bo to idx: */ void *bo_table; + + /* maps msm_cmd to drm_msm_gem_submit_cmd in parent rb. Each rb has a + * list of msm_cmd's which correspond to each chunk of cmdstream in + * a 'growable' rb. For each of those we need to create one + * drm_msm_gem_submit_cmd in the parent rb which collects the state + * for the submit ioctl. Because we can have multiple IB's to the same + * target rb (for example, or same stateobj emit multiple times), and + * because in theory we can have multiple different rb's that have a + * reference to a given target, we need a hashtable to track this per + * rb. + */ + void *cmd_table; }; static inline struct msm_ringbuffer * to_msm_ringbuffer(struct fd_ringbuffer *x) @@ -97,59 +113,28 @@ static inline struct msm_ringbuffer * to_msm_ringbuffer(struct fd_ringbuffer *x) return (struct msm_ringbuffer *)x; } -static void msm_ringbuffer_unref(struct fd_ringbuffer *ring); -static void msm_ringbuffer_ref(struct fd_ringbuffer *ring); - #define INIT_SIZE 0x1000 static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER; -drm_private extern pthread_mutex_t table_lock; - -static void ring_bo_del(struct fd_device *dev, struct fd_bo *bo) -{ - int ret; - - assert(atomic_read(&bo->refcnt) == 1); - - pthread_mutex_lock(&table_lock); - ret = fd_bo_cache_free(&to_msm_device(dev)->ring_cache, bo); - pthread_mutex_unlock(&table_lock); - - if (ret == 0) - return; - fd_bo_del(bo); -} - -static struct fd_bo * ring_bo_new(struct fd_device *dev, uint32_t size) +static struct msm_cmd *current_cmd(struct fd_ringbuffer *ring) { - struct fd_bo *bo; - - bo = fd_bo_cache_alloc(&to_msm_device(dev)->ring_cache, &size, 0); - if (bo) - return bo; - - bo = fd_bo_new(dev, size, 0); - if (!bo) - return NULL; - - /* keep ringbuffer bo's out of the normal bo cache: */ - bo->bo_reuse = FALSE; - - return bo; + struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); + assert(!LIST_IS_EMPTY(&msm_ring->cmd_list)); + return LIST_LAST_ENTRY(&msm_ring->cmd_list, struct msm_cmd, list); } static void ring_cmd_del(struct msm_cmd *cmd) { - if (cmd->ring_bo) - ring_bo_del(cmd->ring->pipe->dev, cmd->ring_bo); + fd_bo_del(cmd->ring_bo); list_del(&cmd->list); to_msm_ringbuffer(cmd->ring)->cmd_count--; free(cmd->relocs); free(cmd); } -static struct msm_cmd * ring_cmd_new(struct fd_ringbuffer *ring, uint32_t size) +static struct msm_cmd * ring_cmd_new(struct fd_ringbuffer *ring, uint32_t size, + enum fd_ringbuffer_flags flags) { struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); struct msm_cmd *cmd = calloc(1, sizeof(*cmd)); @@ -158,7 +143,48 @@ static struct msm_cmd * ring_cmd_new(struct fd_ringbuffer *ring, uint32_t size) return NULL; cmd->ring = ring; - cmd->ring_bo = ring_bo_new(ring->pipe->dev, size); + + /* TODO separate suballoc buffer for small non-streaming state, using + * smaller page-sized backing bo's. + */ + if (flags & FD_RINGBUFFER_STREAMING) { + struct msm_pipe *msm_pipe = to_msm_pipe(ring->pipe); + unsigned suballoc_offset = 0; + struct fd_bo *suballoc_bo = NULL; + + if (msm_pipe->suballoc_ring) { + struct msm_ringbuffer *suballoc_ring = to_msm_ringbuffer(msm_pipe->suballoc_ring); + + assert(msm_pipe->suballoc_ring->flags & FD_RINGBUFFER_OBJECT); + assert(suballoc_ring->cmd_count == 1); + + suballoc_bo = current_cmd(msm_pipe->suballoc_ring)->ring_bo; + + suballoc_offset = fd_ringbuffer_size(msm_pipe->suballoc_ring) + + suballoc_ring->offset; + + suballoc_offset = ALIGN(suballoc_offset, 0x10); + + if ((size + suballoc_offset) > suballoc_bo->size) { + suballoc_bo = NULL; + } + } + + if (!suballoc_bo) { + cmd->ring_bo = fd_bo_new_ring(ring->pipe->dev, 0x8000, 0); + msm_ring->offset = 0; + } else { + cmd->ring_bo = fd_bo_ref(suballoc_bo); + msm_ring->offset = suballoc_offset; + } + + if (msm_pipe->suballoc_ring) + fd_ringbuffer_del(msm_pipe->suballoc_ring); + + msm_pipe->suballoc_ring = fd_ringbuffer_ref(ring); + } else { + cmd->ring_bo = fd_bo_new_ring(ring->pipe->dev, size, 0); + } if (!cmd->ring_bo) goto fail; @@ -172,13 +198,6 @@ fail: return NULL; } -static struct msm_cmd *current_cmd(struct fd_ringbuffer *ring) -{ - struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); - assert(!LIST_IS_EMPTY(&msm_ring->cmd_list)); - return LIST_LAST_ENTRY(&msm_ring->cmd_list, struct msm_cmd, list); -} - static uint32_t append_bo(struct fd_ringbuffer *ring, struct fd_bo *bo) { struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); @@ -230,13 +249,6 @@ static uint32_t bo2idx(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t fl return idx; } -static int check_cmd_bo(struct fd_ringbuffer *ring, - struct drm_msm_gem_submit_cmd *cmd, struct fd_bo *bo) -{ - struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); - return msm_ring->submit.bos[cmd->submit_idx].handle == bo->handle; -} - /* Ensure that submit has corresponding entry in cmds table for the * target cmdstream buffer: * @@ -249,15 +261,31 @@ static int get_cmd(struct fd_ringbuffer *ring, struct msm_cmd *target_cmd, struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); struct drm_msm_gem_submit_cmd *cmd; uint32_t i; + void *val; - /* figure out if we already have a cmd buf: */ - for (i = 0; i < msm_ring->submit.nr_cmds; i++) { + if (!msm_ring->cmd_table) + msm_ring->cmd_table = drmHashCreate(); + + /* figure out if we already have a cmd buf.. short-circuit hash + * lookup if: + * - target cmd has never been added to submit.cmds + * - target cmd is not a streaming stateobj (which unlike longer + * lived CSO stateobj, is not expected to be reused with multiple + * submits) + */ + if (target_cmd->is_appended_to_submit && + !(target_cmd->ring->flags & FD_RINGBUFFER_STREAMING) && + !drmHashLookup(msm_ring->cmd_table, (unsigned long)target_cmd, &val)) { + i = VOID2U64(val); cmd = &msm_ring->submit.cmds[i]; - if ((cmd->submit_offset == submit_offset) && - (cmd->size == size) && - (cmd->type == type) && - check_cmd_bo(ring, cmd, target_cmd->ring_bo)) - return FALSE; + + assert(cmd->submit_offset == submit_offset); + assert(cmd->size == size); + assert(cmd->type == type); + assert(msm_ring->submit.bos[cmd->submit_idx].handle == + target_cmd->ring_bo->handle); + + return FALSE; } /* create cmd buf if not: */ @@ -271,6 +299,13 @@ static int get_cmd(struct fd_ringbuffer *ring, struct msm_cmd *target_cmd, cmd->size = size; cmd->pad = 0; + target_cmd->is_appended_to_submit = TRUE; + + if (!(target_cmd->ring->flags & FD_RINGBUFFER_STREAMING)) { + drmHashInsert(msm_ring->cmd_table, (unsigned long)target_cmd, + U642VOID(i)); + } + target_cmd->size = size; return TRUE; @@ -278,22 +313,9 @@ static int get_cmd(struct fd_ringbuffer *ring, struct msm_cmd *target_cmd, static void * msm_ringbuffer_hostptr(struct fd_ringbuffer *ring) { - return fd_bo_map(current_cmd(ring)->ring_bo); -} - -static uint32_t find_next_reloc_idx(struct msm_cmd *msm_cmd, - uint32_t start, uint32_t offset) -{ - uint32_t i; - - /* a binary search would be more clever.. */ - for (i = start; i < msm_cmd->nr_relocs; i++) { - struct drm_msm_gem_submit_reloc *reloc = &msm_cmd->relocs[i]; - if (reloc->submit_offset >= offset) - return i; - } - - return i; + struct msm_cmd *cmd = current_cmd(ring); + uint8_t *base = fd_bo_map(cmd->ring_bo); + return base + to_msm_ringbuffer(ring)->offset; } static void delete_cmds(struct msm_ringbuffer *msm_ring) @@ -318,12 +340,14 @@ static void flush_reset(struct fd_ringbuffer *ring) fd_bo_del(&msm_bo->base); } - /* for each of the cmd buffers, clear their reloc's: */ - for (i = 0; i < msm_ring->submit.nr_cmds; i++) { - struct msm_cmd *target_cmd = msm_ring->cmds[i]; - if (!target_cmd) + for (i = 0; i < msm_ring->nr_cmds; i++) { + struct msm_cmd *msm_cmd = msm_ring->cmds[i]; + + if (msm_cmd->ring == ring) continue; - target_cmd->nr_relocs = 0; + + if (msm_cmd->ring->flags & FD_RINGBUFFER_OBJECT) + fd_ringbuffer_del(msm_cmd->ring); } msm_ring->submit.nr_cmds = 0; @@ -336,6 +360,11 @@ static void flush_reset(struct fd_ringbuffer *ring) msm_ring->bo_table = NULL; } + if (msm_ring->cmd_table) { + drmHashDestroy(msm_ring->cmd_table); + msm_ring->cmd_table = NULL; + } + if (msm_ring->is_growable) { delete_cmds(msm_ring); } else { @@ -407,6 +436,24 @@ handle_stateobj_relocs(struct fd_ringbuffer *parent, struct fd_ringbuffer *state relocs[i].reloc_idx = bo2idx(parent, bo, flags); } + /* stateobj rb's could have reloc's to other stateobj rb's which didn't + * get propagated to the parent rb at _emit_reloc_ring() time (because + * the parent wasn't known then), so fix that up now: + */ + for (i = 0; i < msm_ring->nr_cmds; i++) { + struct msm_cmd *msm_cmd = msm_ring->cmds[i]; + struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i]; + + if (msm_ring->cmds[i]->ring == stateobj) + continue; + + assert(msm_cmd->ring->flags & FD_RINGBUFFER_OBJECT); + + if (get_cmd(parent, msm_cmd, cmd->submit_offset, cmd->size, cmd->type)) { + fd_ringbuffer_ref(msm_cmd->ring); + } + } + return relocs; } @@ -414,9 +461,10 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start int in_fence_fd, int *out_fence_fd) { struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); + struct msm_pipe *msm_pipe = to_msm_pipe(ring->pipe); struct drm_msm_gem_submit req = { - .flags = to_msm_pipe(ring->pipe)->pipe, - .queueid = to_msm_pipe(ring->pipe)->queue_id, + .flags = msm_pipe->pipe, + .queueid = msm_pipe->queue_id, }; uint32_t i; int ret; @@ -436,12 +484,10 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start /* for each of the cmd's fix up their reloc's: */ for (i = 0; i < msm_ring->submit.nr_cmds; i++) { - struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i]; struct msm_cmd *msm_cmd = msm_ring->cmds[i]; - uint32_t a = find_next_reloc_idx(msm_cmd, 0, cmd->submit_offset); - uint32_t b = find_next_reloc_idx(msm_cmd, a, cmd->submit_offset + cmd->size); - struct drm_msm_gem_submit_reloc *relocs = &msm_cmd->relocs[a]; - unsigned nr_relocs = (b > a) ? b - a : 0; + struct drm_msm_gem_submit_reloc *relocs = msm_cmd->relocs; + struct drm_msm_gem_submit_cmd *cmd; + unsigned nr_relocs = msm_cmd->nr_relocs; /* for reusable stateobjs, the reloc table has reloc_idx that * points into it's own private bos table, rather than the global @@ -454,6 +500,7 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start relocs, nr_relocs); } + cmd = &msm_ring->submit.cmds[i]; cmd->relocs = VOID2U64(relocs); cmd->nr_relocs = nr_relocs; } @@ -488,17 +535,6 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start struct drm_msm_gem_submit_cmd *cmd = &msm_ring->submit.cmds[i]; struct msm_cmd *msm_cmd = msm_ring->cmds[i]; if (msm_cmd->ring->flags & FD_RINGBUFFER_OBJECT) { - /* we could have dropped last reference: */ - msm_ring->cmds[i] = NULL; - - /* need to drop ring_bo ref prior to unref'ing the ring, - * because ring_bo_del assumes it is dropping the *last* - * reference: - */ - fd_bo_del(msm_ring->bos[cmd->submit_idx]); - msm_ring->bos[cmd->submit_idx] = NULL; - - msm_ringbuffer_unref(msm_cmd->ring); free(U642VOID(cmd->relocs)); } } @@ -512,7 +548,7 @@ static void msm_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t size) { assert(to_msm_ringbuffer(ring)->is_growable); finalize_current_cmd(ring, ring->last_start); - ring_cmd_new(ring, size); + ring_cmd_new(ring, size, 0); } static void msm_ringbuffer_reset(struct fd_ringbuffer *ring) @@ -536,7 +572,8 @@ static void msm_ringbuffer_emit_reloc(struct fd_ringbuffer *ring, reloc->reloc_offset = r->offset; reloc->or = r->or; reloc->shift = r->shift; - reloc->submit_offset = offset_bytes(ring->cur, ring->start); + reloc->submit_offset = offset_bytes(ring->cur, ring->start) + + to_msm_ringbuffer(ring)->offset; addr = msm_bo->presumed; if (reloc->shift < 0) @@ -561,7 +598,8 @@ static void msm_ringbuffer_emit_reloc(struct fd_ringbuffer *ring, reloc_hi->reloc_offset = r->offset; reloc_hi->or = r->orhi; reloc_hi->shift = r->shift - 32; - reloc_hi->submit_offset = offset_bytes(ring->cur, ring->start); + reloc_hi->submit_offset = offset_bytes(ring->cur, ring->start) + + to_msm_ringbuffer(ring)->offset; addr = msm_bo->presumed >> 32; if (reloc_hi->shift < 0) @@ -573,14 +611,16 @@ static void msm_ringbuffer_emit_reloc(struct fd_ringbuffer *ring, } static uint32_t msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, - struct fd_ringbuffer *target, uint32_t cmd_idx, - uint32_t submit_offset, uint32_t size) + struct fd_ringbuffer *target, uint32_t cmd_idx) { struct msm_cmd *cmd = NULL; + struct msm_ringbuffer *msm_target = to_msm_ringbuffer(target); uint32_t idx = 0; int added_cmd = FALSE; + uint32_t size; + uint32_t submit_offset = msm_target->offset; - LIST_FOR_EACH_ENTRY(cmd, &to_msm_ringbuffer(target)->cmd_list, list) { + LIST_FOR_EACH_ENTRY(cmd, &msm_target->cmd_list, list) { if (idx == cmd_idx) break; idx++; @@ -588,7 +628,7 @@ static uint32_t msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, assert(cmd && (idx == cmd_idx)); - if (idx < (to_msm_ringbuffer(target)->cmd_count - 1)) { + if (idx < (msm_target->cmd_count - 1)) { /* All but the last cmd buffer is fully "baked" (ie. already has * done get_cmd() to add it to the cmds table). But in this case, * the size we get is invalid (since it is calculated from the @@ -597,6 +637,7 @@ static uint32_t msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, size = cmd->size; } else { struct fd_ringbuffer *parent = ring->parent ? ring->parent : ring; + size = offset_bytes(target->cur, target->start); added_cmd = get_cmd(parent, cmd, submit_offset, size, MSM_SUBMIT_CMD_IB_TARGET_BUF); } @@ -612,7 +653,7 @@ static uint32_t msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring, * destroyed after emitted but before flush, so we must hold a ref: */ if (added_cmd && (target->flags & FD_RINGBUFFER_OBJECT)) { - msm_ringbuffer_ref(target); + fd_ringbuffer_ref(target); } return size; @@ -623,13 +664,10 @@ static uint32_t msm_ringbuffer_cmd_count(struct fd_ringbuffer *ring) return to_msm_ringbuffer(ring)->cmd_count; } -static void msm_ringbuffer_unref(struct fd_ringbuffer *ring) +static void msm_ringbuffer_destroy(struct fd_ringbuffer *ring) { struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); - if (!atomic_dec_and_test(&msm_ring->refcnt)) - return; - flush_reset(ring); delete_cmds(msm_ring); @@ -640,12 +678,6 @@ static void msm_ringbuffer_unref(struct fd_ringbuffer *ring) free(msm_ring); } -static void msm_ringbuffer_ref(struct fd_ringbuffer *ring) -{ - struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); - atomic_inc(&msm_ring->refcnt); -} - static const struct fd_ringbuffer_funcs funcs = { .hostptr = msm_ringbuffer_hostptr, .flush = msm_ringbuffer_flush, @@ -654,7 +686,7 @@ static const struct fd_ringbuffer_funcs funcs = { .emit_reloc = msm_ringbuffer_emit_reloc, .emit_reloc_ring = msm_ringbuffer_emit_reloc_ring, .cmd_count = msm_ringbuffer_cmd_count, - .destroy = msm_ringbuffer_unref, + .destroy = msm_ringbuffer_destroy, }; drm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe, @@ -677,14 +709,15 @@ drm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe, list_inithead(&msm_ring->cmd_list); msm_ring->seqno = ++to_msm_device(pipe->dev)->ring_cnt; - atomic_set(&msm_ring->refcnt, 1); ring = &msm_ring->base; + atomic_set(&ring->refcnt, 1); + ring->funcs = &funcs; ring->size = size; ring->pipe = pipe; /* needed in ring_cmd_new() */ - ring_cmd_new(ring, size); + ring_cmd_new(ring, size, flags); return ring; } diff --git a/lib/libdrm/include/drm/README b/lib/libdrm/include/drm/README index 521630db8..ea2320cc9 100644 --- a/lib/libdrm/include/drm/README +++ b/lib/libdrm/include/drm/README @@ -71,7 +71,7 @@ Note: One should not do _any_ changes to the files apart from the steps below. In order to update the files do the following: - Switch to a Linux kernel tree/branch which is not rebased. -For example: airlied/drm-next + For example: drm-next (https://cgit.freedesktop.org/drm/drm) - Install the headers via `make headers_install' to a separate location. - Copy the drm header[s] + git add + git commit. - Note: Your commit message must include: diff --git a/lib/libdrm/include/drm/amdgpu_drm.h b/lib/libdrm/include/drm/amdgpu_drm.h index c363b67f2..1ceec56de 100644 --- a/lib/libdrm/include/drm/amdgpu_drm.h +++ b/lib/libdrm/include/drm/amdgpu_drm.h @@ -72,12 +72,41 @@ extern "C" { #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle) #define DRM_IOCTL_AMDGPU_SCHED DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched) +/** + * DOC: memory domains + * + * %AMDGPU_GEM_DOMAIN_CPU System memory that is not GPU accessible. + * Memory in this pool could be swapped out to disk if there is pressure. + * + * %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the + * GPU's virtual address space via gart. Gart memory linearizes non-contiguous + * pages of system memory, allows GPU access system memory in a linezrized + * fashion. + * + * %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory + * carved out by the BIOS. + * + * %AMDGPU_GEM_DOMAIN_GDS Global on-chip data storage used to share data + * across shader threads. + * + * %AMDGPU_GEM_DOMAIN_GWS Global wave sync, used to synchronize the + * execution of all the waves on a device. + * + * %AMDGPU_GEM_DOMAIN_OA Ordered append, used by 3D or Compute engines + * for appending data. + */ #define AMDGPU_GEM_DOMAIN_CPU 0x1 #define AMDGPU_GEM_DOMAIN_GTT 0x2 #define AMDGPU_GEM_DOMAIN_VRAM 0x4 #define AMDGPU_GEM_DOMAIN_GDS 0x8 #define AMDGPU_GEM_DOMAIN_GWS 0x10 #define AMDGPU_GEM_DOMAIN_OA 0x20 +#define AMDGPU_GEM_DOMAIN_MASK (AMDGPU_GEM_DOMAIN_CPU | \ + AMDGPU_GEM_DOMAIN_GTT | \ + AMDGPU_GEM_DOMAIN_VRAM | \ + AMDGPU_GEM_DOMAIN_GDS | \ + AMDGPU_GEM_DOMAIN_GWS | \ + AMDGPU_GEM_DOMAIN_OA) /* Flag that CPU access will be required for the case of VRAM domain */ #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED (1 << 0) @@ -95,6 +124,10 @@ extern "C" { #define AMDGPU_GEM_CREATE_VM_ALWAYS_VALID (1 << 6) /* Flag that BO sharing will be explicitly synchronized */ #define AMDGPU_GEM_CREATE_EXPLICIT_SYNC (1 << 7) +/* Flag that indicates allocating MQD gart on GFX9, where the mtype + * for the second page onward should be set to NC. + */ +#define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8) struct drm_amdgpu_gem_create_in { /** the requested memory size */ @@ -473,7 +506,8 @@ struct drm_amdgpu_gem_va { #define AMDGPU_HW_IP_UVD_ENC 5 #define AMDGPU_HW_IP_VCN_DEC 6 #define AMDGPU_HW_IP_VCN_ENC 7 -#define AMDGPU_HW_IP_NUM 8 +#define AMDGPU_HW_IP_VCN_JPEG 8 +#define AMDGPU_HW_IP_NUM 9 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1 @@ -482,6 +516,7 @@ struct drm_amdgpu_gem_va { #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 struct drm_amdgpu_cs_chunk { __u32 chunk_id; @@ -520,6 +555,10 @@ union drm_amdgpu_cs { /* Preempt flag, IB should set Pre_enb bit if PREEMPT flag detected */ #define AMDGPU_IB_FLAG_PREEMPT (1<<2) +/* The IB fence should do the L2 writeback but not invalidate any shader + * caches (L2/vL1/sL1/I$). */ +#define AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE (1 << 3) + struct drm_amdgpu_cs_chunk_ib { __u32 _pad; /** AMDGPU_IB_FLAG_* */ @@ -620,6 +659,12 @@ struct drm_amdgpu_cs_chunk_data { #define AMDGPU_INFO_FW_ASD 0x0d /* Subquery id: Query VCN firmware version */ #define AMDGPU_INFO_FW_VCN 0x0e + /* Subquery id: Query GFX RLC SRLC firmware version */ + #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_CNTL 0x0f + /* Subquery id: Query GFX RLC SRLG firmware version */ + #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_GPM_MEM 0x10 + /* Subquery id: Query GFX RLC SRLS firmware version */ + #define AMDGPU_INFO_FW_GFX_RLC_RESTORE_LIST_SRM_MEM 0x11 /* number of bytes moved for TTM migration */ #define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f /* the used VRAM size */ diff --git a/lib/libdrm/include/drm/drm_fourcc.h b/lib/libdrm/include/drm/drm_fourcc.h index e04613d30..139632b87 100644 --- a/lib/libdrm/include/drm/drm_fourcc.h +++ b/lib/libdrm/include/drm/drm_fourcc.h @@ -30,11 +30,50 @@ extern "C" { #endif +/** + * DOC: overview + * + * In the DRM subsystem, framebuffer pixel formats are described using the + * fourcc codes defined in `include/uapi/drm/drm_fourcc.h`. In addition to the + * fourcc code, a Format Modifier may optionally be provided, in order to + * further describe the buffer's format - for example tiling or compression. + * + * Format Modifiers + * ---------------- + * + * Format modifiers are used in conjunction with a fourcc code, forming a + * unique fourcc:modifier pair. This format:modifier pair must fully define the + * format and data layout of the buffer, and should be the only way to describe + * that particular buffer. + * + * Having multiple fourcc:modifier pairs which describe the same layout should + * be avoided, as such aliases run the risk of different drivers exposing + * different names for the same data format, forcing userspace to understand + * that they are aliases. + * + * Format modifiers may change any property of the buffer, including the number + * of planes and/or the required allocation size. Format modifiers are + * vendor-namespaced, and as such the relationship between a fourcc code and a + * modifier is specific to the modifer being used. For example, some modifiers + * may preserve meaning - such as number of planes - from the fourcc code, + * whereas others may not. + * + * Vendors should document their modifier usage in as much detail as + * possible, to ensure maximum compatibility across devices, drivers and + * applications. + * + * The authoritative list of format modifier codes is found in + * `include/uapi/drm/drm_fourcc.h` + */ + #define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ ((__u32)(c) << 16) | ((__u32)(d) << 24)) #define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */ +/* Reserve 0 for the invalid format specifier */ +#define DRM_FORMAT_INVALID 0 + /* color index */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ @@ -183,6 +222,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 #define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 +#define DRM_FORMAT_MOD_VENDOR_ARM 0x08 /* add more to the end as needed */ #define DRM_FORMAT_RESERVED ((1ULL << 56) - 1) @@ -298,6 +338,19 @@ extern "C" { */ #define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) +/* + * Qualcomm Compressed Format + * + * Refers to a compressed variant of the base format that is compressed. + * Implementation may be platform and base-format specific. + * + * Each macrotile consists of m x n (mostly 4 x 4) tiles. + * Pixel data pitch/stride is aligned with macrotile width. + * Pixel data height is aligned with macrotile height. + * Entire pixel data buffer is aligned with 4k(bytes). + */ +#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) + /* Vivante framebuffer modifiers */ /* @@ -385,6 +438,23 @@ extern "C" { fourcc_mod_code(NVIDIA, 0x15) /* + * Some Broadcom modifiers take parameters, for example the number of + * vertical lines in the image. Reserve the lower 32 bits for modifier + * type, and the next 24 bits for parameters. Top 8 bits are the + * vendor code. + */ +#define __fourcc_mod_broadcom_param_shift 8 +#define __fourcc_mod_broadcom_param_bits 48 +#define fourcc_mod_broadcom_code(val, params) \ + fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val)) +#define fourcc_mod_broadcom_param(m) \ + ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \ + ((1ULL << __fourcc_mod_broadcom_param_bits) - 1))) +#define fourcc_mod_broadcom_mod(m) \ + ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \ + __fourcc_mod_broadcom_param_shift)) + +/* * Broadcom VC4 "T" format * * This is the primary layout that the V3D GPU can texture from (it @@ -405,6 +475,151 @@ extern "C" { */ #define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) +/* + * Broadcom SAND format + * + * This is the native format that the H.264 codec block uses. For VC4 + * HVS, it is only valid for H.264 (NV12/21) and RGBA modes. + * + * The image can be considered to be split into columns, and the + * columns are placed consecutively into memory. The width of those + * columns can be either 32, 64, 128, or 256 pixels, but in practice + * only 128 pixel columns are used. + * + * The pitch between the start of each column is set to optimally + * switch between SDRAM banks. This is passed as the number of lines + * of column width in the modifier (we can't use the stride value due + * to various core checks that look at it , so you should set the + * stride to width*cpp). + * + * Note that the column height for this format modifier is the same + * for all of the planes, assuming that each column contains both Y + * and UV. Some SAND-using hardware stores UV in a separate tiled + * image from Y to reduce the column height, which is not supported + * with these modifiers. + */ + +#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \ + fourcc_mod_broadcom_code(2, v) +#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \ + fourcc_mod_broadcom_code(3, v) +#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \ + fourcc_mod_broadcom_code(4, v) +#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \ + fourcc_mod_broadcom_code(5, v) + +#define DRM_FORMAT_MOD_BROADCOM_SAND32 \ + DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0) +#define DRM_FORMAT_MOD_BROADCOM_SAND64 \ + DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0) +#define DRM_FORMAT_MOD_BROADCOM_SAND128 \ + DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0) +#define DRM_FORMAT_MOD_BROADCOM_SAND256 \ + DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0) + +/* Broadcom UIF format + * + * This is the common format for the current Broadcom multimedia + * blocks, including V3D 3.x and newer, newer video codecs, and + * displays. + * + * The image consists of utiles (64b blocks), UIF blocks (2x2 utiles), + * and macroblocks (4x4 UIF blocks). Those 4x4 UIF block groups are + * stored in columns, with padding between the columns to ensure that + * moving from one column to the next doesn't hit the same SDRAM page + * bank. + * + * To calculate the padding, it is assumed that each hardware block + * and the software driving it knows the platform's SDRAM page size, + * number of banks, and XOR address, and that it's identical between + * all blocks using the format. This tiling modifier will use XOR as + * necessary to reduce the padding. If a hardware block can't do XOR, + * the assumption is that a no-XOR tiling modifier will be created. + */ +#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6) + +/* + * Arm Framebuffer Compression (AFBC) modifiers + * + * AFBC is a proprietary lossless image compression protocol and format. + * It provides fine-grained random access and minimizes the amount of data + * transferred between IP blocks. + * + * AFBC has several features which may be supported and/or used, which are + * represented using bits in the modifier. Not all combinations are valid, + * and different devices or use-cases may support different combinations. + */ +#define DRM_FORMAT_MOD_ARM_AFBC(__afbc_mode) fourcc_mod_code(ARM, __afbc_mode) + +/* + * AFBC superblock size + * + * Indicates the superblock size(s) used for the AFBC buffer. The buffer + * size (in pixels) must be aligned to a multiple of the superblock size. + * Four lowest significant bits(LSBs) are reserved for block size. + */ +#define AFBC_FORMAT_MOD_BLOCK_SIZE_MASK 0xf +#define AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 (1ULL) +#define AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 (2ULL) + +/* + * AFBC lossless colorspace transform + * + * Indicates that the buffer makes use of the AFBC lossless colorspace + * transform. + */ +#define AFBC_FORMAT_MOD_YTR (1ULL << 4) + +/* + * AFBC block-split + * + * Indicates that the payload of each superblock is split. The second + * half of the payload is positioned at a predefined offset from the start + * of the superblock payload. + */ +#define AFBC_FORMAT_MOD_SPLIT (1ULL << 5) + +/* + * AFBC sparse layout + * + * This flag indicates that the payload of each superblock must be stored at a + * predefined position relative to the other superblocks in the same AFBC + * buffer. This order is the same order used by the header buffer. In this mode + * each superblock is given the same amount of space as an uncompressed + * superblock of the particular format would require, rounding up to the next + * multiple of 128 bytes in size. + */ +#define AFBC_FORMAT_MOD_SPARSE (1ULL << 6) + +/* + * AFBC copy-block restrict + * + * Buffers with this flag must obey the copy-block restriction. The restriction + * is such that there are no copy-blocks referring across the border of 8x8 + * blocks. For the subsampled data the 8x8 limitation is also subsampled. + */ +#define AFBC_FORMAT_MOD_CBR (1ULL << 7) + +/* + * AFBC tiled layout + * + * The tiled layout groups superblocks in 8x8 or 4x4 tiles, where all + * superblocks inside a tile are stored together in memory. 8x8 tiles are used + * for pixel formats up to and including 32 bpp while 4x4 tiles are used for + * larger bpp formats. The order between the tiles is scan line. + * When the tiled layout is used, the buffer size (in pixels) must be aligned + * to the tile size. + */ +#define AFBC_FORMAT_MOD_TILED (1ULL << 8) + +/* + * AFBC solid color blocks + * + * Indicates that the buffer makes use of solid-color blocks, whereby bandwidth + * can be reduced if a whole superblock is a single color. + */ +#define AFBC_FORMAT_MOD_SC (1ULL << 9) + #if defined(__cplusplus) } #endif diff --git a/lib/libdrm/include/drm/drm_mode.h b/lib/libdrm/include/drm/drm_mode.h index 5f9fadbd1..d3e0fe31e 100644 --- a/lib/libdrm/include/drm/drm_mode.h +++ b/lib/libdrm/include/drm/drm_mode.h @@ -46,6 +46,10 @@ extern "C" { #define DRM_MODE_TYPE_USERDEF (1<<5) #define DRM_MODE_TYPE_DRIVER (1<<6) +#define DRM_MODE_TYPE_ALL (DRM_MODE_TYPE_PREFERRED | \ + DRM_MODE_TYPE_USERDEF | \ + DRM_MODE_TYPE_DRIVER) + /* Video mode flags */ /* bit compatible with the xrandr RR_ definitions (bits 0-13) * @@ -89,6 +93,15 @@ extern "C" { #define DRM_MODE_PICTURE_ASPECT_NONE 0 #define DRM_MODE_PICTURE_ASPECT_4_3 1 #define DRM_MODE_PICTURE_ASPECT_16_9 2 +#define DRM_MODE_PICTURE_ASPECT_64_27 3 +#define DRM_MODE_PICTURE_ASPECT_256_135 4 + +/* Content type options */ +#define DRM_MODE_CONTENT_TYPE_NO_DATA 0 +#define DRM_MODE_CONTENT_TYPE_GRAPHICS 1 +#define DRM_MODE_CONTENT_TYPE_PHOTO 2 +#define DRM_MODE_CONTENT_TYPE_CINEMA 3 +#define DRM_MODE_CONTENT_TYPE_GAME 4 /* Aspect ratio flag bitmask (4 bits 22:19) */ #define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19) @@ -98,6 +111,24 @@ extern "C" { (DRM_MODE_PICTURE_ASPECT_4_3<<19) #define DRM_MODE_FLAG_PIC_AR_16_9 \ (DRM_MODE_PICTURE_ASPECT_16_9<<19) +#define DRM_MODE_FLAG_PIC_AR_64_27 \ + (DRM_MODE_PICTURE_ASPECT_64_27<<19) +#define DRM_MODE_FLAG_PIC_AR_256_135 \ + (DRM_MODE_PICTURE_ASPECT_256_135<<19) + +#define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | \ + DRM_MODE_FLAG_NHSYNC | \ + DRM_MODE_FLAG_PVSYNC | \ + DRM_MODE_FLAG_NVSYNC | \ + DRM_MODE_FLAG_INTERLACE | \ + DRM_MODE_FLAG_DBLSCAN | \ + DRM_MODE_FLAG_CSYNC | \ + DRM_MODE_FLAG_PCSYNC | \ + DRM_MODE_FLAG_NCSYNC | \ + DRM_MODE_FLAG_HSKEW | \ + DRM_MODE_FLAG_DBLCLK | \ + DRM_MODE_FLAG_CLKDIV2 | \ + DRM_MODE_FLAG_3D_MASK) /* DPMS flags */ /* bit compatible with the xorg definitions. */ @@ -155,8 +186,9 @@ extern "C" { /* * DRM_MODE_REFLECT_<axis> * - * Signals that the contents of a drm plane is reflected in the <axis> axis, + * Signals that the contents of a drm plane is reflected along the <axis> axis, * in the same way as mirroring. + * See kerneldoc chapter "Plane Composition Properties" for more details. * * This define is provided as a convenience, looking up the property id * using the name->prop id lookup is the preferred method. @@ -320,6 +352,7 @@ enum drm_mode_subconnector { #define DRM_MODE_CONNECTOR_VIRTUAL 15 #define DRM_MODE_CONNECTOR_DSI 16 #define DRM_MODE_CONNECTOR_DPI 17 +#define DRM_MODE_CONNECTOR_WRITEBACK 18 struct drm_mode_get_connector { diff --git a/lib/libdrm/include/drm/qxl_drm.h b/lib/libdrm/include/drm/qxl_drm.h index 38a0dbdfd..880999d2d 100644 --- a/lib/libdrm/include/drm/qxl_drm.h +++ b/lib/libdrm/include/drm/qxl_drm.h @@ -24,7 +24,6 @@ #ifndef QXL_DRM_H #define QXL_DRM_H -#include <stddef.h> #include "drm.h" #if defined(__cplusplus) @@ -89,7 +88,6 @@ struct drm_qxl_command { __u32 pad; }; -/* XXX: call it drm_qxl_commands? */ struct drm_qxl_execbuffer { __u32 flags; /* for future use */ __u32 commands_num; diff --git a/lib/libdrm/include/drm/tegra_drm.h b/lib/libdrm/include/drm/tegra_drm.h index 12f9bf848..6c07919c0 100644 --- a/lib/libdrm/include/drm/tegra_drm.h +++ b/lib/libdrm/include/drm/tegra_drm.h @@ -32,143 +32,615 @@ extern "C" { #define DRM_TEGRA_GEM_CREATE_TILED (1 << 0) #define DRM_TEGRA_GEM_CREATE_BOTTOM_UP (1 << 1) +/** + * struct drm_tegra_gem_create - parameters for the GEM object creation IOCTL + */ struct drm_tegra_gem_create { + /** + * @size: + * + * The size, in bytes, of the buffer object to be created. + */ __u64 size; + + /** + * @flags: + * + * A bitmask of flags that influence the creation of GEM objects: + * + * DRM_TEGRA_GEM_CREATE_TILED + * Use the 16x16 tiling format for this buffer. + * + * DRM_TEGRA_GEM_CREATE_BOTTOM_UP + * The buffer has a bottom-up layout. + */ __u32 flags; + + /** + * @handle: + * + * The handle of the created GEM object. Set by the kernel upon + * successful completion of the IOCTL. + */ __u32 handle; }; +/** + * struct drm_tegra_gem_mmap - parameters for the GEM mmap IOCTL + */ struct drm_tegra_gem_mmap { + /** + * @handle: + * + * Handle of the GEM object to obtain an mmap offset for. + */ __u32 handle; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; + + /** + * @offset: + * + * The mmap offset for the given GEM object. Set by the kernel upon + * successful completion of the IOCTL. + */ __u64 offset; }; +/** + * struct drm_tegra_syncpt_read - parameters for the read syncpoint IOCTL + */ struct drm_tegra_syncpt_read { + /** + * @id: + * + * ID of the syncpoint to read the current value from. + */ __u32 id; + + /** + * @value: + * + * The current syncpoint value. Set by the kernel upon successful + * completion of the IOCTL. + */ __u32 value; }; +/** + * struct drm_tegra_syncpt_incr - parameters for the increment syncpoint IOCTL + */ struct drm_tegra_syncpt_incr { + /** + * @id: + * + * ID of the syncpoint to increment. + */ __u32 id; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; }; +/** + * struct drm_tegra_syncpt_wait - parameters for the wait syncpoint IOCTL + */ struct drm_tegra_syncpt_wait { + /** + * @id: + * + * ID of the syncpoint to wait on. + */ __u32 id; + + /** + * @thresh: + * + * Threshold value for which to wait. + */ __u32 thresh; + + /** + * @timeout: + * + * Timeout, in milliseconds, to wait. + */ __u32 timeout; + + /** + * @value: + * + * The new syncpoint value after the wait. Set by the kernel upon + * successful completion of the IOCTL. + */ __u32 value; }; #define DRM_TEGRA_NO_TIMEOUT (0xffffffff) +/** + * struct drm_tegra_open_channel - parameters for the open channel IOCTL + */ struct drm_tegra_open_channel { + /** + * @client: + * + * The client ID for this channel. + */ __u32 client; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; + + /** + * @context: + * + * The application context of this channel. Set by the kernel upon + * successful completion of the IOCTL. This context needs to be passed + * to the DRM_TEGRA_CHANNEL_CLOSE or the DRM_TEGRA_SUBMIT IOCTLs. + */ __u64 context; }; +/** + * struct drm_tegra_close_channel - parameters for the close channel IOCTL + */ struct drm_tegra_close_channel { + /** + * @context: + * + * The application context of this channel. This is obtained from the + * DRM_TEGRA_OPEN_CHANNEL IOCTL. + */ __u64 context; }; +/** + * struct drm_tegra_get_syncpt - parameters for the get syncpoint IOCTL + */ struct drm_tegra_get_syncpt { + /** + * @context: + * + * The application context identifying the channel for which to obtain + * the syncpoint ID. + */ __u64 context; + + /** + * @index: + * + * Index of the client syncpoint for which to obtain the ID. + */ __u32 index; + + /** + * @id: + * + * The ID of the given syncpoint. Set by the kernel upon successful + * completion of the IOCTL. + */ __u32 id; }; +/** + * struct drm_tegra_get_syncpt_base - parameters for the get wait base IOCTL + */ struct drm_tegra_get_syncpt_base { + /** + * @context: + * + * The application context identifying for which channel to obtain the + * wait base. + */ __u64 context; + + /** + * @syncpt: + * + * ID of the syncpoint for which to obtain the wait base. + */ __u32 syncpt; + + /** + * @id: + * + * The ID of the wait base corresponding to the client syncpoint. Set + * by the kernel upon successful completion of the IOCTL. + */ __u32 id; }; +/** + * struct drm_tegra_syncpt - syncpoint increment operation + */ struct drm_tegra_syncpt { + /** + * @id: + * + * ID of the syncpoint to operate on. + */ __u32 id; + + /** + * @incrs: + * + * Number of increments to perform for the syncpoint. + */ __u32 incrs; }; +/** + * struct drm_tegra_cmdbuf - structure describing a command buffer + */ struct drm_tegra_cmdbuf { + /** + * @handle: + * + * Handle to a GEM object containing the command buffer. + */ __u32 handle; + + /** + * @offset: + * + * Offset, in bytes, into the GEM object identified by @handle at + * which the command buffer starts. + */ __u32 offset; + + /** + * @words: + * + * Number of 32-bit words in this command buffer. + */ __u32 words; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; }; +/** + * struct drm_tegra_reloc - GEM object relocation structure + */ struct drm_tegra_reloc { struct { + /** + * @cmdbuf.handle: + * + * Handle to the GEM object containing the command buffer for + * which to perform this GEM object relocation. + */ __u32 handle; + + /** + * @cmdbuf.offset: + * + * Offset, in bytes, into the command buffer at which to + * insert the relocated address. + */ __u32 offset; } cmdbuf; struct { + /** + * @target.handle: + * + * Handle to the GEM object to be relocated. + */ __u32 handle; + + /** + * @target.offset: + * + * Offset, in bytes, into the target GEM object at which the + * relocated data starts. + */ __u32 offset; } target; + + /** + * @shift: + * + * The number of bits by which to shift relocated addresses. + */ __u32 shift; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; }; +/** + * struct drm_tegra_waitchk - wait check structure + */ struct drm_tegra_waitchk { + /** + * @handle: + * + * Handle to the GEM object containing a command stream on which to + * perform the wait check. + */ __u32 handle; + + /** + * @offset: + * + * Offset, in bytes, of the location in the command stream to perform + * the wait check on. + */ __u32 offset; + + /** + * @syncpt: + * + * ID of the syncpoint to wait check. + */ __u32 syncpt; + + /** + * @thresh: + * + * Threshold value for which to check. + */ __u32 thresh; }; +/** + * struct drm_tegra_submit - job submission structure + */ struct drm_tegra_submit { + /** + * @context: + * + * The application context identifying the channel to use for the + * execution of this job. + */ __u64 context; + + /** + * @num_syncpts: + * + * The number of syncpoints operated on by this job. This defines the + * length of the array pointed to by @syncpts. + */ __u32 num_syncpts; + + /** + * @num_cmdbufs: + * + * The number of command buffers to execute as part of this job. This + * defines the length of the array pointed to by @cmdbufs. + */ __u32 num_cmdbufs; + + /** + * @num_relocs: + * + * The number of relocations to perform before executing this job. + * This defines the length of the array pointed to by @relocs. + */ __u32 num_relocs; + + /** + * @num_waitchks: + * + * The number of wait checks to perform as part of this job. This + * defines the length of the array pointed to by @waitchks. + */ __u32 num_waitchks; + + /** + * @waitchk_mask: + * + * Bitmask of valid wait checks. + */ __u32 waitchk_mask; + + /** + * @timeout: + * + * Timeout, in milliseconds, before this job is cancelled. + */ __u32 timeout; + + /** + * @syncpts: + * + * A pointer to an array of &struct drm_tegra_syncpt structures that + * specify the syncpoint operations performed as part of this job. + * The number of elements in the array must be equal to the value + * given by @num_syncpts. + */ __u64 syncpts; + + /** + * @cmdbufs: + * + * A pointer to an array of &struct drm_tegra_cmdbuf structures that + * define the command buffers to execute as part of this job. The + * number of elements in the array must be equal to the value given + * by @num_syncpts. + */ __u64 cmdbufs; + + /** + * @relocs: + * + * A pointer to an array of &struct drm_tegra_reloc structures that + * specify the relocations that need to be performed before executing + * this job. The number of elements in the array must be equal to the + * value given by @num_relocs. + */ __u64 relocs; + + /** + * @waitchks: + * + * A pointer to an array of &struct drm_tegra_waitchk structures that + * specify the wait checks to be performed while executing this job. + * The number of elements in the array must be equal to the value + * given by @num_waitchks. + */ __u64 waitchks; - __u32 fence; /* Return value */ - __u32 reserved[5]; /* future expansion */ + /** + * @fence: + * + * The threshold of the syncpoint associated with this job after it + * has been completed. Set by the kernel upon successful completion of + * the IOCTL. This can be used with the DRM_TEGRA_SYNCPT_WAIT IOCTL to + * wait for this job to be finished. + */ + __u32 fence; + + /** + * @reserved: + * + * This field is reserved for future use. Must be 0. + */ + __u32 reserved[5]; }; #define DRM_TEGRA_GEM_TILING_MODE_PITCH 0 #define DRM_TEGRA_GEM_TILING_MODE_TILED 1 #define DRM_TEGRA_GEM_TILING_MODE_BLOCK 2 +/** + * struct drm_tegra_gem_set_tiling - parameters for the set tiling IOCTL + */ struct drm_tegra_gem_set_tiling { - /* input */ + /** + * @handle: + * + * Handle to the GEM object for which to set the tiling parameters. + */ __u32 handle; + + /** + * @mode: + * + * The tiling mode to set. Must be one of: + * + * DRM_TEGRA_GEM_TILING_MODE_PITCH + * pitch linear format + * + * DRM_TEGRA_GEM_TILING_MODE_TILED + * 16x16 tiling format + * + * DRM_TEGRA_GEM_TILING_MODE_BLOCK + * 16Bx2 tiling format + */ __u32 mode; + + /** + * @value: + * + * The value to set for the tiling mode parameter. + */ __u32 value; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; }; +/** + * struct drm_tegra_gem_get_tiling - parameters for the get tiling IOCTL + */ struct drm_tegra_gem_get_tiling { - /* input */ + /** + * @handle: + * + * Handle to the GEM object for which to query the tiling parameters. + */ __u32 handle; - /* output */ + + /** + * @mode: + * + * The tiling mode currently associated with the GEM object. Set by + * the kernel upon successful completion of the IOCTL. + */ __u32 mode; + + /** + * @value: + * + * The tiling mode parameter currently associated with the GEM object. + * Set by the kernel upon successful completion of the IOCTL. + */ __u32 value; + + /** + * @pad: + * + * Structure padding that may be used in the future. Must be 0. + */ __u32 pad; }; #define DRM_TEGRA_GEM_BOTTOM_UP (1 << 0) #define DRM_TEGRA_GEM_FLAGS (DRM_TEGRA_GEM_BOTTOM_UP) +/** + * struct drm_tegra_gem_set_flags - parameters for the set flags IOCTL + */ struct drm_tegra_gem_set_flags { - /* input */ + /** + * @handle: + * + * Handle to the GEM object for which to set the flags. + */ __u32 handle; - /* output */ + + /** + * @flags: + * + * The flags to set for the GEM object. + */ __u32 flags; }; +/** + * struct drm_tegra_gem_get_flags - parameters for the get flags IOCTL + */ struct drm_tegra_gem_get_flags { - /* input */ + /** + * @handle: + * + * Handle to the GEM object for which to query the flags. + */ __u32 handle; - /* output */ + + /** + * @flags: + * + * The flags currently associated with the GEM object. Set by the + * kernel upon successful completion of the IOCTL. + */ __u32 flags; }; @@ -193,7 +665,7 @@ struct drm_tegra_gem_get_flags { #define DRM_IOCTL_TEGRA_SYNCPT_INCR DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_INCR, struct drm_tegra_syncpt_incr) #define DRM_IOCTL_TEGRA_SYNCPT_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_WAIT, struct drm_tegra_syncpt_wait) #define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel) -#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_open_channel) +#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_close_channel) #define DRM_IOCTL_TEGRA_GET_SYNCPT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT, struct drm_tegra_get_syncpt) #define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit) #define DRM_IOCTL_TEGRA_GET_SYNCPT_BASE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT_BASE, struct drm_tegra_get_syncpt_base) diff --git a/lib/libdrm/include/drm/vc4_drm.h b/lib/libdrm/include/drm/vc4_drm.h index 4117117b4..31f50de39 100644 --- a/lib/libdrm/include/drm/vc4_drm.h +++ b/lib/libdrm/include/drm/vc4_drm.h @@ -183,10 +183,17 @@ struct drm_vc4_submit_cl { /* ID of the perfmon to attach to this job. 0 means no perfmon. */ __u32 perfmonid; - /* Unused field to align this struct on 64 bits. Must be set to 0. - * If one ever needs to add an u32 field to this struct, this field - * can be used. + /* Syncobj handle to wait on. If set, processing of this render job + * will not start until the syncobj is signaled. 0 means ignore. */ + __u32 in_sync; + + /* Syncobj handle to export fence to. If set, the fence in the syncobj + * will be replaced with a fence that signals upon completion of this + * render job. 0 means ignore. + */ + __u32 out_sync; + __u32 pad2; }; diff --git a/lib/libdrm/intel/Makefile.sources b/lib/libdrm/intel/Makefile.sources index 6947ab742..aa27e2737 100644 --- a/lib/libdrm/intel/Makefile.sources +++ b/lib/libdrm/intel/Makefile.sources @@ -1,10 +1,12 @@ LIBDRM_INTEL_FILES := \ + i915_pciids.h \ intel_bufmgr.c \ intel_bufmgr_priv.h \ intel_bufmgr_fake.c \ intel_bufmgr_gem.c \ intel_decode.c \ intel_chipset.h \ + intel_chipset.c \ mm.c \ mm.h \ uthash.h diff --git a/lib/libdrm/intel/i915_pciids.h b/lib/libdrm/intel/i915_pciids.h new file mode 100644 index 000000000..fd965ffbb --- /dev/null +++ b/lib/libdrm/intel/i915_pciids.h @@ -0,0 +1,461 @@ +/* + * Copyright 2013 Intel Corporation + * 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, sub license, 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 (including the + * next paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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 _I915_PCIIDS_H +#define _I915_PCIIDS_H + +/* + * A pci_device_id struct { + * __u32 vendor, device; + * __u32 subvendor, subdevice; + * __u32 class, class_mask; + * kernel_ulong_t driver_data; + * }; + * Don't use C99 here because "class" is reserved and we want to + * give userspace flexibility. + */ +#define INTEL_VGA_DEVICE(id, info) { \ + 0x8086, id, \ + ~0, ~0, \ + 0x030000, 0xff0000, \ + (unsigned long) info } + +#define INTEL_QUANTA_VGA_DEVICE(info) { \ + 0x8086, 0x16a, \ + 0x152d, 0x8990, \ + 0x030000, 0xff0000, \ + (unsigned long) info } + +#define INTEL_I810_IDS(info) \ + INTEL_VGA_DEVICE(0x7121, info), /* I810 */ \ + INTEL_VGA_DEVICE(0x7123, info), /* I810_DC100 */ \ + INTEL_VGA_DEVICE(0x7125, info) /* I810_E */ + +#define INTEL_I815_IDS(info) \ + INTEL_VGA_DEVICE(0x1132, info) /* I815*/ + +#define INTEL_I830_IDS(info) \ + INTEL_VGA_DEVICE(0x3577, info) + +#define INTEL_I845G_IDS(info) \ + INTEL_VGA_DEVICE(0x2562, info) + +#define INTEL_I85X_IDS(info) \ + INTEL_VGA_DEVICE(0x3582, info), /* I855_GM */ \ + INTEL_VGA_DEVICE(0x358e, info) + +#define INTEL_I865G_IDS(info) \ + INTEL_VGA_DEVICE(0x2572, info) /* I865_G */ + +#define INTEL_I915G_IDS(info) \ + INTEL_VGA_DEVICE(0x2582, info), /* I915_G */ \ + INTEL_VGA_DEVICE(0x258a, info) /* E7221_G */ + +#define INTEL_I915GM_IDS(info) \ + INTEL_VGA_DEVICE(0x2592, info) /* I915_GM */ + +#define INTEL_I945G_IDS(info) \ + INTEL_VGA_DEVICE(0x2772, info) /* I945_G */ + +#define INTEL_I945GM_IDS(info) \ + INTEL_VGA_DEVICE(0x27a2, info), /* I945_GM */ \ + INTEL_VGA_DEVICE(0x27ae, info) /* I945_GME */ + +#define INTEL_I965G_IDS(info) \ + INTEL_VGA_DEVICE(0x2972, info), /* I946_GZ */ \ + INTEL_VGA_DEVICE(0x2982, info), /* G35_G */ \ + INTEL_VGA_DEVICE(0x2992, info), /* I965_Q */ \ + INTEL_VGA_DEVICE(0x29a2, info) /* I965_G */ + +#define INTEL_G33_IDS(info) \ + INTEL_VGA_DEVICE(0x29b2, info), /* Q35_G */ \ + INTEL_VGA_DEVICE(0x29c2, info), /* G33_G */ \ + INTEL_VGA_DEVICE(0x29d2, info) /* Q33_G */ + +#define INTEL_I965GM_IDS(info) \ + INTEL_VGA_DEVICE(0x2a02, info), /* I965_GM */ \ + INTEL_VGA_DEVICE(0x2a12, info) /* I965_GME */ + +#define INTEL_GM45_IDS(info) \ + INTEL_VGA_DEVICE(0x2a42, info) /* GM45_G */ + +#define INTEL_G45_IDS(info) \ + INTEL_VGA_DEVICE(0x2e02, info), /* IGD_E_G */ \ + INTEL_VGA_DEVICE(0x2e12, info), /* Q45_G */ \ + INTEL_VGA_DEVICE(0x2e22, info), /* G45_G */ \ + INTEL_VGA_DEVICE(0x2e32, info), /* G41_G */ \ + INTEL_VGA_DEVICE(0x2e42, info), /* B43_G */ \ + INTEL_VGA_DEVICE(0x2e92, info) /* B43_G.1 */ + +#define INTEL_PINEVIEW_IDS(info) \ + INTEL_VGA_DEVICE(0xa001, info), \ + INTEL_VGA_DEVICE(0xa011, info) + +#define INTEL_IRONLAKE_D_IDS(info) \ + INTEL_VGA_DEVICE(0x0042, info) + +#define INTEL_IRONLAKE_M_IDS(info) \ + INTEL_VGA_DEVICE(0x0046, info) + +#define INTEL_SNB_D_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x0102, info), \ + INTEL_VGA_DEVICE(0x010A, info) + +#define INTEL_SNB_D_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x0112, info), \ + INTEL_VGA_DEVICE(0x0122, info) + +#define INTEL_SNB_D_IDS(info) \ + INTEL_SNB_D_GT1_IDS(info), \ + INTEL_SNB_D_GT2_IDS(info) + +#define INTEL_SNB_M_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x0106, info) + +#define INTEL_SNB_M_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x0116, info), \ + INTEL_VGA_DEVICE(0x0126, info) + +#define INTEL_SNB_M_IDS(info) \ + INTEL_SNB_M_GT1_IDS(info), \ + INTEL_SNB_M_GT2_IDS(info) + +#define INTEL_IVB_M_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x0156, info) /* GT1 mobile */ + +#define INTEL_IVB_M_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x0166, info) /* GT2 mobile */ + +#define INTEL_IVB_M_IDS(info) \ + INTEL_IVB_M_GT1_IDS(info), \ + INTEL_IVB_M_GT2_IDS(info) + +#define INTEL_IVB_D_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x0152, info), /* GT1 desktop */ \ + INTEL_VGA_DEVICE(0x015a, info) /* GT1 server */ + +#define INTEL_IVB_D_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x0162, info), /* GT2 desktop */ \ + INTEL_VGA_DEVICE(0x016a, info) /* GT2 server */ + +#define INTEL_IVB_D_IDS(info) \ + INTEL_IVB_D_GT1_IDS(info), \ + INTEL_IVB_D_GT2_IDS(info) + +#define INTEL_IVB_Q_IDS(info) \ + INTEL_QUANTA_VGA_DEVICE(info) /* Quanta transcode */ + +#define INTEL_HSW_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x0402, info), /* GT1 desktop */ \ + INTEL_VGA_DEVICE(0x040a, info), /* GT1 server */ \ + INTEL_VGA_DEVICE(0x040B, info), /* GT1 reserved */ \ + INTEL_VGA_DEVICE(0x040E, info), /* GT1 reserved */ \ + INTEL_VGA_DEVICE(0x0C02, info), /* SDV GT1 desktop */ \ + INTEL_VGA_DEVICE(0x0C0A, info), /* SDV GT1 server */ \ + INTEL_VGA_DEVICE(0x0C0B, info), /* SDV GT1 reserved */ \ + INTEL_VGA_DEVICE(0x0C0E, info), /* SDV GT1 reserved */ \ + INTEL_VGA_DEVICE(0x0A02, info), /* ULT GT1 desktop */ \ + INTEL_VGA_DEVICE(0x0A0A, info), /* ULT GT1 server */ \ + INTEL_VGA_DEVICE(0x0A0B, info), /* ULT GT1 reserved */ \ + INTEL_VGA_DEVICE(0x0D02, info), /* CRW GT1 desktop */ \ + INTEL_VGA_DEVICE(0x0D0A, info), /* CRW GT1 server */ \ + INTEL_VGA_DEVICE(0x0D0B, info), /* CRW GT1 reserved */ \ + INTEL_VGA_DEVICE(0x0D0E, info), /* CRW GT1 reserved */ \ + INTEL_VGA_DEVICE(0x0406, info), /* GT1 mobile */ \ + INTEL_VGA_DEVICE(0x0C06, info), /* SDV GT1 mobile */ \ + INTEL_VGA_DEVICE(0x0A06, info), /* ULT GT1 mobile */ \ + INTEL_VGA_DEVICE(0x0A0E, info), /* ULX GT1 mobile */ \ + INTEL_VGA_DEVICE(0x0D06, info) /* CRW GT1 mobile */ + +#define INTEL_HSW_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x0412, info), /* GT2 desktop */ \ + INTEL_VGA_DEVICE(0x041a, info), /* GT2 server */ \ + INTEL_VGA_DEVICE(0x041B, info), /* GT2 reserved */ \ + INTEL_VGA_DEVICE(0x041E, info), /* GT2 reserved */ \ + INTEL_VGA_DEVICE(0x0C12, info), /* SDV GT2 desktop */ \ + INTEL_VGA_DEVICE(0x0C1A, info), /* SDV GT2 server */ \ + INTEL_VGA_DEVICE(0x0C1B, info), /* SDV GT2 reserved */ \ + INTEL_VGA_DEVICE(0x0C1E, info), /* SDV GT2 reserved */ \ + INTEL_VGA_DEVICE(0x0A12, info), /* ULT GT2 desktop */ \ + INTEL_VGA_DEVICE(0x0A1A, info), /* ULT GT2 server */ \ + INTEL_VGA_DEVICE(0x0A1B, info), /* ULT GT2 reserved */ \ + INTEL_VGA_DEVICE(0x0D12, info), /* CRW GT2 desktop */ \ + INTEL_VGA_DEVICE(0x0D1A, info), /* CRW GT2 server */ \ + INTEL_VGA_DEVICE(0x0D1B, info), /* CRW GT2 reserved */ \ + INTEL_VGA_DEVICE(0x0D1E, info), /* CRW GT2 reserved */ \ + INTEL_VGA_DEVICE(0x0416, info), /* GT2 mobile */ \ + INTEL_VGA_DEVICE(0x0426, info), /* GT2 mobile */ \ + INTEL_VGA_DEVICE(0x0C16, info), /* SDV GT2 mobile */ \ + INTEL_VGA_DEVICE(0x0A16, info), /* ULT GT2 mobile */ \ + INTEL_VGA_DEVICE(0x0A1E, info), /* ULX GT2 mobile */ \ + INTEL_VGA_DEVICE(0x0D16, info) /* CRW GT2 mobile */ + +#define INTEL_HSW_GT3_IDS(info) \ + INTEL_VGA_DEVICE(0x0422, info), /* GT3 desktop */ \ + INTEL_VGA_DEVICE(0x042a, info), /* GT3 server */ \ + INTEL_VGA_DEVICE(0x042B, info), /* GT3 reserved */ \ + INTEL_VGA_DEVICE(0x042E, info), /* GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0C22, info), /* SDV GT3 desktop */ \ + INTEL_VGA_DEVICE(0x0C2A, info), /* SDV GT3 server */ \ + INTEL_VGA_DEVICE(0x0C2B, info), /* SDV GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0C2E, info), /* SDV GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0A22, info), /* ULT GT3 desktop */ \ + INTEL_VGA_DEVICE(0x0A2A, info), /* ULT GT3 server */ \ + INTEL_VGA_DEVICE(0x0A2B, info), /* ULT GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0D22, info), /* CRW GT3 desktop */ \ + INTEL_VGA_DEVICE(0x0D2A, info), /* CRW GT3 server */ \ + INTEL_VGA_DEVICE(0x0D2B, info), /* CRW GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0D2E, info), /* CRW GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0C26, info), /* SDV GT3 mobile */ \ + INTEL_VGA_DEVICE(0x0A26, info), /* ULT GT3 mobile */ \ + INTEL_VGA_DEVICE(0x0A2E, info), /* ULT GT3 reserved */ \ + INTEL_VGA_DEVICE(0x0D26, info) /* CRW GT3 mobile */ + +#define INTEL_HSW_IDS(info) \ + INTEL_HSW_GT1_IDS(info), \ + INTEL_HSW_GT2_IDS(info), \ + INTEL_HSW_GT3_IDS(info) + +#define INTEL_VLV_IDS(info) \ + INTEL_VGA_DEVICE(0x0f30, info), \ + INTEL_VGA_DEVICE(0x0f31, info), \ + INTEL_VGA_DEVICE(0x0f32, info), \ + INTEL_VGA_DEVICE(0x0f33, info), \ + INTEL_VGA_DEVICE(0x0157, info), \ + INTEL_VGA_DEVICE(0x0155, info) + +#define INTEL_BDW_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x1602, info), /* GT1 ULT */ \ + INTEL_VGA_DEVICE(0x1606, info), /* GT1 ULT */ \ + INTEL_VGA_DEVICE(0x160B, info), /* GT1 Iris */ \ + INTEL_VGA_DEVICE(0x160E, info), /* GT1 ULX */ \ + INTEL_VGA_DEVICE(0x160A, info), /* GT1 Server */ \ + INTEL_VGA_DEVICE(0x160D, info) /* GT1 Workstation */ + +#define INTEL_BDW_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x1612, info), /* GT2 Halo */ \ + INTEL_VGA_DEVICE(0x1616, info), /* GT2 ULT */ \ + INTEL_VGA_DEVICE(0x161B, info), /* GT2 ULT */ \ + INTEL_VGA_DEVICE(0x161E, info), /* GT2 ULX */ \ + INTEL_VGA_DEVICE(0x161A, info), /* GT2 Server */ \ + INTEL_VGA_DEVICE(0x161D, info) /* GT2 Workstation */ + +#define INTEL_BDW_GT3_IDS(info) \ + INTEL_VGA_DEVICE(0x1622, info), /* ULT */ \ + INTEL_VGA_DEVICE(0x1626, info), /* ULT */ \ + INTEL_VGA_DEVICE(0x162B, info), /* Iris */ \ + INTEL_VGA_DEVICE(0x162E, info), /* ULX */\ + INTEL_VGA_DEVICE(0x162A, info), /* Server */ \ + INTEL_VGA_DEVICE(0x162D, info) /* Workstation */ + +#define INTEL_BDW_RSVD_IDS(info) \ + INTEL_VGA_DEVICE(0x1632, info), /* ULT */ \ + INTEL_VGA_DEVICE(0x1636, info), /* ULT */ \ + INTEL_VGA_DEVICE(0x163B, info), /* Iris */ \ + INTEL_VGA_DEVICE(0x163E, info), /* ULX */ \ + INTEL_VGA_DEVICE(0x163A, info), /* Server */ \ + INTEL_VGA_DEVICE(0x163D, info) /* Workstation */ + +#define INTEL_BDW_IDS(info) \ + INTEL_BDW_GT1_IDS(info), \ + INTEL_BDW_GT2_IDS(info), \ + INTEL_BDW_GT3_IDS(info), \ + INTEL_BDW_RSVD_IDS(info) + +#define INTEL_CHV_IDS(info) \ + INTEL_VGA_DEVICE(0x22b0, info), \ + INTEL_VGA_DEVICE(0x22b1, info), \ + INTEL_VGA_DEVICE(0x22b2, info), \ + INTEL_VGA_DEVICE(0x22b3, info) + +#define INTEL_SKL_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x1906, info), /* ULT GT1 */ \ + INTEL_VGA_DEVICE(0x190E, info), /* ULX GT1 */ \ + INTEL_VGA_DEVICE(0x1902, info), /* DT GT1 */ \ + INTEL_VGA_DEVICE(0x190B, info), /* Halo GT1 */ \ + INTEL_VGA_DEVICE(0x190A, info) /* SRV GT1 */ + +#define INTEL_SKL_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x1916, info), /* ULT GT2 */ \ + INTEL_VGA_DEVICE(0x1921, info), /* ULT GT2F */ \ + INTEL_VGA_DEVICE(0x191E, info), /* ULX GT2 */ \ + INTEL_VGA_DEVICE(0x1912, info), /* DT GT2 */ \ + INTEL_VGA_DEVICE(0x191B, info), /* Halo GT2 */ \ + INTEL_VGA_DEVICE(0x191A, info), /* SRV GT2 */ \ + INTEL_VGA_DEVICE(0x191D, info) /* WKS GT2 */ + +#define INTEL_SKL_GT3_IDS(info) \ + INTEL_VGA_DEVICE(0x1923, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x1926, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x1927, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x192B, info), /* Halo GT3 */ \ + INTEL_VGA_DEVICE(0x192D, info) /* SRV GT3 */ + +#define INTEL_SKL_GT4_IDS(info) \ + INTEL_VGA_DEVICE(0x1932, info), /* DT GT4 */ \ + INTEL_VGA_DEVICE(0x193B, info), /* Halo GT4 */ \ + INTEL_VGA_DEVICE(0x193D, info), /* WKS GT4 */ \ + INTEL_VGA_DEVICE(0x192A, info), /* SRV GT4 */ \ + INTEL_VGA_DEVICE(0x193A, info) /* SRV GT4e */ + +#define INTEL_SKL_IDS(info) \ + INTEL_SKL_GT1_IDS(info), \ + INTEL_SKL_GT2_IDS(info), \ + INTEL_SKL_GT3_IDS(info), \ + INTEL_SKL_GT4_IDS(info) + +#define INTEL_BXT_IDS(info) \ + INTEL_VGA_DEVICE(0x0A84, info), \ + INTEL_VGA_DEVICE(0x1A84, info), \ + INTEL_VGA_DEVICE(0x1A85, info), \ + INTEL_VGA_DEVICE(0x5A84, info), /* APL HD Graphics 505 */ \ + INTEL_VGA_DEVICE(0x5A85, info) /* APL HD Graphics 500 */ + +#define INTEL_GLK_IDS(info) \ + INTEL_VGA_DEVICE(0x3184, info), \ + INTEL_VGA_DEVICE(0x3185, info) + +#define INTEL_KBL_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x5913, info), /* ULT GT1.5 */ \ + INTEL_VGA_DEVICE(0x5915, info), /* ULX GT1.5 */ \ + INTEL_VGA_DEVICE(0x5906, info), /* ULT GT1 */ \ + INTEL_VGA_DEVICE(0x590E, info), /* ULX GT1 */ \ + INTEL_VGA_DEVICE(0x5902, info), /* DT GT1 */ \ + INTEL_VGA_DEVICE(0x5908, info), /* Halo GT1 */ \ + INTEL_VGA_DEVICE(0x590B, info), /* Halo GT1 */ \ + INTEL_VGA_DEVICE(0x590A, info) /* SRV GT1 */ + +#define INTEL_KBL_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x5916, info), /* ULT GT2 */ \ + INTEL_VGA_DEVICE(0x5917, info), /* Mobile GT2 */ \ + INTEL_VGA_DEVICE(0x5921, info), /* ULT GT2F */ \ + INTEL_VGA_DEVICE(0x591E, info), /* ULX GT2 */ \ + INTEL_VGA_DEVICE(0x5912, info), /* DT GT2 */ \ + INTEL_VGA_DEVICE(0x591B, info), /* Halo GT2 */ \ + INTEL_VGA_DEVICE(0x591A, info), /* SRV GT2 */ \ + INTEL_VGA_DEVICE(0x591D, info) /* WKS GT2 */ + +#define INTEL_KBL_GT3_IDS(info) \ + INTEL_VGA_DEVICE(0x5923, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x5926, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x5927, info) /* ULT GT3 */ + +#define INTEL_KBL_GT4_IDS(info) \ + INTEL_VGA_DEVICE(0x593B, info) /* Halo GT4 */ + +/* AML/KBL Y GT2 */ +#define INTEL_AML_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x591C, info), /* ULX GT2 */ \ + INTEL_VGA_DEVICE(0x87C0, info) /* ULX GT2 */ + +#define INTEL_KBL_IDS(info) \ + INTEL_KBL_GT1_IDS(info), \ + INTEL_KBL_GT2_IDS(info), \ + INTEL_KBL_GT3_IDS(info), \ + INTEL_KBL_GT4_IDS(info), \ + INTEL_AML_GT2_IDS(info) + +/* CFL S */ +#define INTEL_CFL_S_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x3E90, info), /* SRV GT1 */ \ + INTEL_VGA_DEVICE(0x3E93, info), /* SRV GT1 */ \ + INTEL_VGA_DEVICE(0x3E99, info) /* SRV GT1 */ + +#define INTEL_CFL_S_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x3E91, info), /* SRV GT2 */ \ + INTEL_VGA_DEVICE(0x3E92, info), /* SRV GT2 */ \ + INTEL_VGA_DEVICE(0x3E96, info), /* SRV GT2 */ \ + INTEL_VGA_DEVICE(0x3E98, info), /* SRV GT2 */ \ + INTEL_VGA_DEVICE(0x3E9A, info) /* SRV GT2 */ + +/* CFL H */ +#define INTEL_CFL_H_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x3E9B, info), /* Halo GT2 */ \ + INTEL_VGA_DEVICE(0x3E94, info) /* Halo GT2 */ + +/* CFL U GT2 */ +#define INTEL_CFL_U_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x3EA9, info) + +/* CFL U GT3 */ +#define INTEL_CFL_U_GT3_IDS(info) \ + INTEL_VGA_DEVICE(0x3EA5, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x3EA6, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x3EA7, info), /* ULT GT3 */ \ + INTEL_VGA_DEVICE(0x3EA8, info) /* ULT GT3 */ + +/* WHL/CFL U GT1 */ +#define INTEL_WHL_U_GT1_IDS(info) \ + INTEL_VGA_DEVICE(0x3EA1, info) + +/* WHL/CFL U GT2 */ +#define INTEL_WHL_U_GT2_IDS(info) \ + INTEL_VGA_DEVICE(0x3EA0, info) + +/* WHL/CFL U GT3 */ +#define INTEL_WHL_U_GT3_IDS(info) \ + INTEL_VGA_DEVICE(0x3EA2, info), \ + INTEL_VGA_DEVICE(0x3EA3, info), \ + INTEL_VGA_DEVICE(0x3EA4, info) + +#define INTEL_CFL_IDS(info) \ + INTEL_CFL_S_GT1_IDS(info), \ + INTEL_CFL_S_GT2_IDS(info), \ + INTEL_CFL_H_GT2_IDS(info), \ + INTEL_CFL_U_GT2_IDS(info), \ + INTEL_CFL_U_GT3_IDS(info), \ + INTEL_WHL_U_GT1_IDS(info), \ + INTEL_WHL_U_GT2_IDS(info), \ + INTEL_WHL_U_GT3_IDS(info) + +/* CNL */ +#define INTEL_CNL_IDS(info) \ + INTEL_VGA_DEVICE(0x5A51, info), \ + INTEL_VGA_DEVICE(0x5A59, info), \ + INTEL_VGA_DEVICE(0x5A41, info), \ + INTEL_VGA_DEVICE(0x5A49, info), \ + INTEL_VGA_DEVICE(0x5A52, info), \ + INTEL_VGA_DEVICE(0x5A5A, info), \ + INTEL_VGA_DEVICE(0x5A42, info), \ + INTEL_VGA_DEVICE(0x5A4A, info), \ + INTEL_VGA_DEVICE(0x5A50, info), \ + INTEL_VGA_DEVICE(0x5A40, info), \ + INTEL_VGA_DEVICE(0x5A54, info), \ + INTEL_VGA_DEVICE(0x5A5C, info), \ + INTEL_VGA_DEVICE(0x5A44, info), \ + INTEL_VGA_DEVICE(0x5A4C, info) + +/* ICL */ +#define INTEL_ICL_11_IDS(info) \ + INTEL_VGA_DEVICE(0x8A50, info), \ + INTEL_VGA_DEVICE(0x8A51, info), \ + INTEL_VGA_DEVICE(0x8A5C, info), \ + INTEL_VGA_DEVICE(0x8A5D, info), \ + INTEL_VGA_DEVICE(0x8A52, info), \ + INTEL_VGA_DEVICE(0x8A5A, info), \ + INTEL_VGA_DEVICE(0x8A5B, info), \ + INTEL_VGA_DEVICE(0x8A71, info), \ + INTEL_VGA_DEVICE(0x8A70, info) + +#endif /* _I915_PCIIDS_H */ diff --git a/lib/libdrm/intel/intel-symbol-check b/lib/libdrm/intel/intel-symbol-check index 4d30a4b15..de377bef1 100755 --- a/lib/libdrm/intel/intel-symbol-check +++ b/lib/libdrm/intel/intel-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.sources/LIBDRM_INTEL_H_FILES diff --git a/lib/libdrm/intel/intel_chipset.c b/lib/libdrm/intel/intel_chipset.c new file mode 100644 index 000000000..5aa4a2f25 --- /dev/null +++ b/lib/libdrm/intel/intel_chipset.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * 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 (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + */ +#include "intel_chipset.h" + +#include <inttypes.h> +#include <stdbool.h> + +#include "i915_pciids.h" + +#undef INTEL_VGA_DEVICE +#define INTEL_VGA_DEVICE(id, gen) { id, gen } + +static const struct pci_device { + uint16_t device; + uint16_t gen; +} pciids[] = { + /* Keep ids sorted by gen; latest gen first */ + INTEL_ICL_11_IDS(11), + INTEL_CNL_IDS(10), + INTEL_CFL_IDS(9), + INTEL_GLK_IDS(9), + INTEL_KBL_IDS(9), + INTEL_BXT_IDS(9), + INTEL_SKL_IDS(9), +}; + +drm_private bool intel_is_genx(unsigned int devid, int gen) +{ + const struct pci_device *p, + *pend = pciids + sizeof(pciids) / sizeof(pciids[0]); + + for (p = pciids; p < pend; p++) { + /* PCI IDs are sorted */ + if (p->gen < gen) + break; + + if (p->device != devid) + continue; + + if (gen == p->gen) + return true; + + break; + } + + return false; +} + +drm_private bool intel_get_genx(unsigned int devid, int *gen) +{ + const struct pci_device *p, + *pend = pciids + sizeof(pciids) / sizeof(pciids[0]); + + for (p = pciids; p < pend; p++) { + if (p->device != devid) + continue; + + if (gen) + *gen = p->gen; + + return true; + } + + return false; +} diff --git a/lib/libdrm/intel/meson.build b/lib/libdrm/intel/meson.build index 53c7fce4e..3d6bbac62 100644 --- a/lib/libdrm/intel/meson.build +++ b/lib/libdrm/intel/meson.build @@ -23,14 +23,14 @@ libdrm_intel = shared_library( [ files( 'intel_bufmgr.c', 'intel_bufmgr_fake.c', 'intel_bufmgr_gem.c', - 'intel_decode.c', 'mm.c', + 'intel_decode.c', 'mm.c', 'intel_chipset.c', ), config_file, ], include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind, dep_atomic_ops], - c_args : warn_c_args, + c_args : libdrm_c_args, version : '1.0.0', install : true, ) @@ -59,7 +59,7 @@ test_decode = executable( files('test_decode.c'), include_directories : [inc_root, inc_drm], link_with : [libdrm, libdrm_intel], - c_args : warn_c_args, + c_args : libdrm_c_args, ) test( diff --git a/lib/libdrm/libkms/Makefile.am b/lib/libdrm/libkms/Makefile.am index 461fc35b6..ff4c1b2a5 100644 --- a/lib/libdrm/libkms/Makefile.am +++ b/lib/libdrm/libkms/Makefile.am @@ -2,6 +2,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir) @@ -39,5 +40,6 @@ libkmsinclude_HEADERS = $(LIBKMS_H_FILES) pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libkms.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = kms-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/libkms/kms-symbol-check b/lib/libdrm/libkms/kms-symbol-check index a5c2120d5..30f444f7b 100755 --- a/lib/libdrm/libkms/kms-symbol-check +++ b/lib/libdrm/libkms/kms-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.sources/LIBKMS_H_FILES diff --git a/lib/libdrm/libkms/meson.build b/lib/libdrm/libkms/meson.build index 86d1a4ee6..dc9316086 100644 --- a/lib/libdrm/libkms/meson.build +++ b/lib/libdrm/libkms/meson.build @@ -44,7 +44,7 @@ endif libkms = shared_library( 'kms', [files_libkms, config_file], - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : libkms_include, link_with : libdrm, version : '1.0.0', diff --git a/lib/libdrm/meson.build b/lib/libdrm/meson.build index 75c7bdff6..1d7b78633 100644 --- a/lib/libdrm/meson.build +++ b/lib/libdrm/meson.build @@ -21,7 +21,7 @@ project( 'libdrm', ['c'], - version : '2.4.94', + version : '2.4.96', license : 'MIT', meson_version : '>= 0.43', default_options : ['buildtype=debugoptimized', 'c_std=gnu99'], @@ -211,6 +211,9 @@ foreach a : ['unused-parameter', 'attributes', 'long-long', endif endforeach +# all c args: +libdrm_c_args = warn_c_args + ['-fvisibility=hidden'] + dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : with_intel) dep_cunit = dependency('cunit', version : '>= 2.1', required : false) @@ -286,7 +289,7 @@ libdrm = shared_library( ), config_file, ], - c_args : warn_c_args, + c_args : libdrm_c_args, dependencies : [dep_valgrind, dep_rt, dep_m], include_directories : inc_drm, version : '2.4.0', diff --git a/lib/libdrm/nouveau/Makefile.am b/lib/libdrm/nouveau/Makefile.am index 344a84454..5574fd8f3 100644 --- a/lib/libdrm/nouveau/Makefile.am +++ b/lib/libdrm/nouveau/Makefile.am @@ -2,6 +2,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm \ @@ -29,5 +30,6 @@ libdrm_nouveaunvifinclude_HEADERS = nvif/class.h \ pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_nouveau.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = nouveau-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/nouveau/bufctx.c b/lib/libdrm/nouveau/bufctx.c index 67b7570ef..00924b3cc 100644 --- a/lib/libdrm/nouveau/bufctx.c +++ b/lib/libdrm/nouveau/bufctx.c @@ -58,7 +58,7 @@ nouveau_bufctx(struct nouveau_bufctx *bctx) return (struct nouveau_bufctx_priv *)bctx; } -int +drm_public int nouveau_bufctx_new(struct nouveau_client *client, int bins, struct nouveau_bufctx **pbctx) { @@ -78,7 +78,7 @@ nouveau_bufctx_new(struct nouveau_client *client, int bins, return -ENOMEM; } -void +drm_public void nouveau_bufctx_del(struct nouveau_bufctx **pbctx) { struct nouveau_bufctx_priv *pctx = nouveau_bufctx(*pbctx); @@ -95,7 +95,7 @@ nouveau_bufctx_del(struct nouveau_bufctx **pbctx) } } -void +drm_public void nouveau_bufctx_reset(struct nouveau_bufctx *bctx, int bin) { struct nouveau_bufctx_priv *pctx = nouveau_bufctx(bctx); @@ -113,7 +113,7 @@ nouveau_bufctx_reset(struct nouveau_bufctx *bctx, int bin) pbin->relocs = 0; } -struct nouveau_bufref * +drm_public struct nouveau_bufref * nouveau_bufctx_refn(struct nouveau_bufctx *bctx, int bin, struct nouveau_bo *bo, uint32_t flags) { @@ -140,7 +140,7 @@ nouveau_bufctx_refn(struct nouveau_bufctx *bctx, int bin, return &pref->base; } -struct nouveau_bufref * +drm_public struct nouveau_bufref * nouveau_bufctx_mthd(struct nouveau_bufctx *bctx, int bin, uint32_t packet, struct nouveau_bo *bo, uint64_t data, uint32_t flags, uint32_t vor, uint32_t tor) diff --git a/lib/libdrm/nouveau/meson.build b/lib/libdrm/nouveau/meson.build index 51c9a7123..0c1498d7e 100644 --- a/lib/libdrm/nouveau/meson.build +++ b/lib/libdrm/nouveau/meson.build @@ -22,7 +22,7 @@ libdrm_nouveau = shared_library( 'drm_nouveau', [files( 'nouveau.c', 'pushbuf.c', 'bufctx.c', 'abi16.c'), config_file], - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_threads, dep_atomic_ops], diff --git a/lib/libdrm/nouveau/nouveau-symbol-check b/lib/libdrm/nouveau/nouveau-symbol-check index b3a24101e..6296244c1 100755 --- a/lib/libdrm/nouveau/nouveau-symbol-check +++ b/lib/libdrm/nouveau/nouveau-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.sources/LIBDRM_NOUVEAU_H_FILES diff --git a/lib/libdrm/nouveau/nouveau.c b/lib/libdrm/nouveau/nouveau.c index 555935173..f18d1426b 100644 --- a/lib/libdrm/nouveau/nouveau.c +++ b/lib/libdrm/nouveau/nouveau.c @@ -88,7 +88,7 @@ nouveau_object_ioctl(struct nouveau_object *obj, void *data, uint32_t size) return drmCommandWriteRead(drm->fd, DRM_NOUVEAU_NVIF, args, argc); } -int +drm_public int nouveau_object_mthd(struct nouveau_object *obj, uint32_t mthd, void *data, uint32_t size) { @@ -123,14 +123,14 @@ nouveau_object_mthd(struct nouveau_object *obj, return ret; } -void +drm_public void nouveau_object_sclass_put(struct nouveau_sclass **psclass) { free(*psclass); *psclass = NULL; } -int +drm_public int nouveau_object_sclass_get(struct nouveau_object *obj, struct nouveau_sclass **psclass) { @@ -180,7 +180,7 @@ nouveau_object_sclass_get(struct nouveau_object *obj, return ret; } -int +drm_public int nouveau_object_mclass(struct nouveau_object *obj, const struct nouveau_mclass *mclass) { @@ -282,7 +282,7 @@ nouveau_object_init(struct nouveau_object *parent, uint32_t handle, return 0; } -int +drm_public int nouveau_object_new(struct nouveau_object *parent, uint64_t handle, uint32_t oclass, void *data, uint32_t length, struct nouveau_object **pobj) @@ -303,7 +303,7 @@ nouveau_object_new(struct nouveau_object *parent, uint64_t handle, return 0; } -void +drm_public void nouveau_object_del(struct nouveau_object **pobj) { struct nouveau_object *obj = *pobj; @@ -314,14 +314,14 @@ nouveau_object_del(struct nouveau_object **pobj) } } -void +drm_public void nouveau_drm_del(struct nouveau_drm **pdrm) { free(*pdrm); *pdrm = NULL; } -int +drm_public int nouveau_drm_new(int fd, struct nouveau_drm **pdrm) { struct nouveau_drm *drm; @@ -353,14 +353,14 @@ nouveau_drm_new(int fd, struct nouveau_drm **pdrm) * is kept here to prevent AIGLX from crashing if the DDX is linked against * the new libdrm, but the DRI driver against the old */ -int +drm_public int nouveau_device_open_existing(struct nouveau_device **pdev, int close, int fd, drm_context_t ctx) { return -EACCES; } -int +drm_public int nouveau_device_new(struct nouveau_object *parent, int32_t oclass, void *data, uint32_t size, struct nouveau_device **pdev) { @@ -454,7 +454,7 @@ done: return ret; } -int +drm_public int nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev) { struct nouveau_drm *drm; @@ -482,7 +482,7 @@ nouveau_device_wrap(int fd, int close, struct nouveau_device **pdev) return 0; } -int +drm_public int nouveau_device_open(const char *busid, struct nouveau_device **pdev) { int ret = -ENODEV, fd = drmOpen("nouveau", busid); @@ -494,7 +494,7 @@ nouveau_device_open(const char *busid, struct nouveau_device **pdev) return ret; } -void +drm_public void nouveau_device_del(struct nouveau_device **pdev) { struct nouveau_device_priv *nvdev = nouveau_device(*pdev); @@ -513,7 +513,7 @@ nouveau_device_del(struct nouveau_device **pdev) } } -int +drm_public int nouveau_getparam(struct nouveau_device *dev, uint64_t param, uint64_t *value) { struct nouveau_drm *drm = nouveau_drm(&dev->object); @@ -524,7 +524,7 @@ nouveau_getparam(struct nouveau_device *dev, uint64_t param, uint64_t *value) return ret; } -int +drm_public int nouveau_setparam(struct nouveau_device *dev, uint64_t param, uint64_t value) { struct nouveau_drm *drm = nouveau_drm(&dev->object); @@ -532,7 +532,7 @@ nouveau_setparam(struct nouveau_device *dev, uint64_t param, uint64_t value) return drmCommandWrite(drm->fd, DRM_NOUVEAU_SETPARAM, &r, sizeof(r)); } -int +drm_public int nouveau_client_new(struct nouveau_device *dev, struct nouveau_client **pclient) { struct nouveau_device_priv *nvdev = nouveau_device(dev); @@ -571,7 +571,7 @@ unlock: return ret; } -void +drm_public void nouveau_client_del(struct nouveau_client **pclient) { struct nouveau_client_priv *pcli = nouveau_client(*pclient); @@ -618,7 +618,7 @@ nouveau_bo_del(struct nouveau_bo *bo) free(nvbo); } -int +drm_public int nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, uint32_t align, uint64_t size, union nouveau_bo_config *config, struct nouveau_bo **pbo) @@ -709,7 +709,7 @@ nouveau_bo_make_global(struct nouveau_bo_priv *nvbo) } } -int +drm_public int nouveau_bo_wrap(struct nouveau_device *dev, uint32_t handle, struct nouveau_bo **pbo) { @@ -721,7 +721,7 @@ nouveau_bo_wrap(struct nouveau_device *dev, uint32_t handle, return ret; } -int +drm_public int nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name, struct nouveau_bo **pbo) { @@ -750,7 +750,7 @@ nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name, return ret; } -int +drm_public int nouveau_bo_name_get(struct nouveau_bo *bo, uint32_t *name) { struct drm_gem_flink req = { .handle = bo->handle }; @@ -772,7 +772,7 @@ nouveau_bo_name_get(struct nouveau_bo *bo, uint32_t *name) return 0; } -void +drm_public void nouveau_bo_ref(struct nouveau_bo *bo, struct nouveau_bo **pref) { struct nouveau_bo *ref = *pref; @@ -786,7 +786,7 @@ nouveau_bo_ref(struct nouveau_bo *bo, struct nouveau_bo **pref) *pref = bo; } -int +drm_public int nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd, struct nouveau_bo **bo) { @@ -806,7 +806,7 @@ nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd, return ret; } -int +drm_public int nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd) { struct nouveau_drm *drm = nouveau_drm(&bo->device->object); @@ -821,7 +821,7 @@ nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd) return 0; } -int +drm_public int nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client) { @@ -856,7 +856,7 @@ nouveau_bo_wait(struct nouveau_bo *bo, uint32_t access, return ret; } -int +drm_public int nouveau_bo_map(struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client) { diff --git a/lib/libdrm/nouveau/pushbuf.c b/lib/libdrm/nouveau/pushbuf.c index 445c966e4..e5f73f0d7 100644 --- a/lib/libdrm/nouveau/pushbuf.c +++ b/lib/libdrm/nouveau/pushbuf.c @@ -528,7 +528,7 @@ pushbuf_validate(struct nouveau_pushbuf *push, bool retry) return ret; } -int +drm_public int nouveau_pushbuf_new(struct nouveau_client *client, struct nouveau_object *chan, int nr, uint32_t size, bool immediate, struct nouveau_pushbuf **ppush) @@ -599,7 +599,7 @@ nouveau_pushbuf_new(struct nouveau_client *client, struct nouveau_object *chan, return 0; } -void +drm_public void nouveau_pushbuf_del(struct nouveau_pushbuf **ppush) { struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(*ppush); @@ -625,7 +625,7 @@ nouveau_pushbuf_del(struct nouveau_pushbuf **ppush) *ppush = NULL; } -struct nouveau_bufctx * +drm_public struct nouveau_bufctx * nouveau_pushbuf_bufctx(struct nouveau_pushbuf *push, struct nouveau_bufctx *ctx) { struct nouveau_bufctx *prev = push->bufctx; @@ -633,7 +633,7 @@ nouveau_pushbuf_bufctx(struct nouveau_pushbuf *push, struct nouveau_bufctx *ctx) return prev; } -int +drm_public int nouveau_pushbuf_space(struct nouveau_pushbuf *push, uint32_t dwords, uint32_t relocs, uint32_t pushes) { @@ -697,7 +697,7 @@ nouveau_pushbuf_space(struct nouveau_pushbuf *push, return flushed ? pushbuf_validate(push, false) : 0; } -void +drm_public void nouveau_pushbuf_data(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint64_t offset, uint64_t length) { @@ -728,14 +728,14 @@ nouveau_pushbuf_data(struct nouveau_pushbuf *push, struct nouveau_bo *bo, } } -int +drm_public int nouveau_pushbuf_refn(struct nouveau_pushbuf *push, struct nouveau_pushbuf_refn *refs, int nr) { return pushbuf_refn(push, true, refs, nr); } -void +drm_public void nouveau_pushbuf_reloc(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t data, uint32_t flags, uint32_t vor, uint32_t tor) { @@ -743,13 +743,13 @@ nouveau_pushbuf_reloc(struct nouveau_pushbuf *push, struct nouveau_bo *bo, push->cur++; } -int +drm_public int nouveau_pushbuf_validate(struct nouveau_pushbuf *push) { return pushbuf_validate(push, true); } -uint32_t +drm_public uint32_t nouveau_pushbuf_refd(struct nouveau_pushbuf *push, struct nouveau_bo *bo) { struct drm_nouveau_gem_pushbuf_bo *kref; @@ -767,7 +767,7 @@ nouveau_pushbuf_refd(struct nouveau_pushbuf *push, struct nouveau_bo *bo) return flags; } -int +drm_public int nouveau_pushbuf_kick(struct nouveau_pushbuf *push, struct nouveau_object *chan) { if (!push->channel) diff --git a/lib/libdrm/omap/Makefile.am b/lib/libdrm/omap/Makefile.am index 599bb9ded..38a1007b1 100644 --- a/lib/libdrm/omap/Makefile.am +++ b/lib/libdrm/omap/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm @@ -20,5 +21,6 @@ libdrm_omapinclude_HEADERS = omap_drmif.h pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_omap.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = omap-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/omap/meson.build b/lib/libdrm/omap/meson.build index e57b8f5da..54698c6a8 100644 --- a/lib/libdrm/omap/meson.build +++ b/lib/libdrm/omap/meson.build @@ -22,7 +22,7 @@ libdrm_omap = shared_library( 'drm_omap', [files('omap_drm.c'), config_file], include_directories : [inc_root, inc_drm], - c_args : warn_c_args, + c_args : libdrm_c_args, link_with : libdrm, dependencies : [dep_pthread_stubs, dep_atomic_ops], version : '1.0.0', diff --git a/lib/libdrm/omap/omap-symbol-check b/lib/libdrm/omap/omap-symbol-check index 0fb4a0f26..16da3c406 100755 --- a/lib/libdrm/omap/omap-symbol-check +++ b/lib/libdrm/omap/omap-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.am/libdrm_omap*HEADERS diff --git a/lib/libdrm/omap/omap_drm.c b/lib/libdrm/omap/omap_drm.c index 417d522c3..3aed4e0a2 100644 --- a/lib/libdrm/omap/omap_drm.c +++ b/lib/libdrm/omap/omap_drm.c @@ -88,7 +88,7 @@ static struct omap_device * omap_device_new_impl(int fd) return dev; } -struct omap_device * omap_device_new(int fd) +drm_public struct omap_device * omap_device_new(int fd) { struct omap_device *dev = NULL; @@ -111,13 +111,13 @@ struct omap_device * omap_device_new(int fd) return dev; } -struct omap_device * omap_device_ref(struct omap_device *dev) +drm_public struct omap_device * omap_device_ref(struct omap_device *dev) { atomic_inc(&dev->refcnt); return dev; } -void omap_device_del(struct omap_device *dev) +drm_public void omap_device_del(struct omap_device *dev) { if (!atomic_dec_and_test(&dev->refcnt)) return; @@ -128,7 +128,7 @@ void omap_device_del(struct omap_device *dev) free(dev); } -int +drm_public int omap_get_param(struct omap_device *dev, uint64_t param, uint64_t *value) { struct drm_omap_param req = { @@ -146,7 +146,7 @@ omap_get_param(struct omap_device *dev, uint64_t param, uint64_t *value) return 0; } -int +drm_public int omap_set_param(struct omap_device *dev, uint64_t param, uint64_t value) { struct drm_omap_param req = { @@ -226,7 +226,7 @@ fail: /* allocate a new (un-tiled) buffer object */ -struct omap_bo * +drm_public struct omap_bo * omap_bo_new(struct omap_device *dev, uint32_t size, uint32_t flags) { union omap_gem_size gsize = { @@ -239,7 +239,7 @@ omap_bo_new(struct omap_device *dev, uint32_t size, uint32_t flags) } /* allocate a new buffer object */ -struct omap_bo * +drm_public struct omap_bo * omap_bo_new_tiled(struct omap_device *dev, uint32_t width, uint32_t height, uint32_t flags) { @@ -255,7 +255,7 @@ omap_bo_new_tiled(struct omap_device *dev, uint32_t width, return omap_bo_new_impl(dev, gsize, flags); } -struct omap_bo *omap_bo_ref(struct omap_bo *bo) +drm_public struct omap_bo *omap_bo_ref(struct omap_bo *bo) { atomic_inc(&bo->refcnt); return bo; @@ -281,7 +281,7 @@ static int get_buffer_info(struct omap_bo *bo) } /* import a buffer object from DRI2 name */ -struct omap_bo * +drm_public struct omap_bo * omap_bo_from_name(struct omap_device *dev, uint32_t name) { struct omap_bo *bo = NULL; @@ -315,7 +315,7 @@ fail: * fd so caller should close() the fd when it is otherwise done * with it (even if it is still using the 'struct omap_bo *') */ -struct omap_bo * +drm_public struct omap_bo * omap_bo_from_dmabuf(struct omap_device *dev, int fd) { struct omap_bo *bo = NULL; @@ -347,7 +347,7 @@ fail: } /* destroy a buffer object */ -void omap_bo_del(struct omap_bo *bo) +drm_public void omap_bo_del(struct omap_bo *bo) { if (!bo) { return; @@ -380,7 +380,7 @@ void omap_bo_del(struct omap_bo *bo) } /* get the global flink/DRI2 buffer name */ -int omap_bo_get_name(struct omap_bo *bo, uint32_t *name) +drm_public int omap_bo_get_name(struct omap_bo *bo, uint32_t *name) { if (!bo->name) { struct drm_gem_flink req = { @@ -401,7 +401,7 @@ int omap_bo_get_name(struct omap_bo *bo, uint32_t *name) return 0; } -uint32_t omap_bo_handle(struct omap_bo *bo) +drm_public uint32_t omap_bo_handle(struct omap_bo *bo) { return bo->handle; } @@ -409,7 +409,7 @@ uint32_t omap_bo_handle(struct omap_bo *bo) /* caller owns the dmabuf fd that is returned and is responsible * to close() it when done */ -int omap_bo_dmabuf(struct omap_bo *bo) +drm_public int omap_bo_dmabuf(struct omap_bo *bo) { if (bo->fd < 0) { struct drm_prime_handle req = { @@ -428,7 +428,7 @@ int omap_bo_dmabuf(struct omap_bo *bo) return dup(bo->fd); } -uint32_t omap_bo_size(struct omap_bo *bo) +drm_public uint32_t omap_bo_size(struct omap_bo *bo) { if (!bo->size) { get_buffer_info(bo); @@ -436,7 +436,7 @@ uint32_t omap_bo_size(struct omap_bo *bo) return bo->size; } -void *omap_bo_map(struct omap_bo *bo) +drm_public void *omap_bo_map(struct omap_bo *bo) { if (!bo->map) { if (!bo->offset) { @@ -452,7 +452,7 @@ void *omap_bo_map(struct omap_bo *bo) return bo->map; } -int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op) +drm_public int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op) { struct drm_omap_gem_cpu_prep req = { .handle = bo->handle, @@ -462,7 +462,7 @@ int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op) DRM_OMAP_GEM_CPU_PREP, &req, sizeof(req)); } -int omap_bo_cpu_fini(struct omap_bo *bo, enum omap_gem_op op) +drm_public int omap_bo_cpu_fini(struct omap_bo *bo, enum omap_gem_op op) { struct drm_omap_gem_cpu_fini req = { .handle = bo->handle, diff --git a/lib/libdrm/radeon/Makefile.am b/lib/libdrm/radeon/Makefile.am index e24153148..e712a4ac4 100644 --- a/lib/libdrm/radeon/Makefile.am +++ b/lib/libdrm/radeon/Makefile.am @@ -26,6 +26,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ -I$(top_srcdir)/include/drm @@ -43,5 +44,6 @@ libdrm_radeoninclude_HEADERS = $(LIBDRM_RADEON_H_FILES) pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_radeon.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = radeon-symbol-check EXTRA_DIST = $(LIBDRM_RADEON_BOF_FILES) $(TESTS) diff --git a/lib/libdrm/radeon/meson.build b/lib/libdrm/radeon/meson.build index b08c74421..1fc5282cf 100644 --- a/lib/libdrm/radeon/meson.build +++ b/lib/libdrm/radeon/meson.build @@ -28,7 +28,7 @@ libdrm_radeon = shared_library( ), config_file, ], - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_pthread_stubs, dep_atomic_ops], diff --git a/lib/libdrm/radeon/radeon-symbol-check b/lib/libdrm/radeon/radeon-symbol-check index 7d79d9012..da605bb88 100755 --- a/lib/libdrm/radeon/radeon-symbol-check +++ b/lib/libdrm/radeon/radeon-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first five) are taken from the public headers. # A list of the latter should be available Makefile.sources/LIBDRM_RADEON_H_FILES diff --git a/lib/libdrm/tegra/Makefile.am b/lib/libdrm/tegra/Makefile.am index fb40be55a..531199707 100644 --- a/lib/libdrm/tegra/Makefile.am +++ b/lib/libdrm/tegra/Makefile.am @@ -4,7 +4,8 @@ AM_CPPFLAGS = \ AM_CFLAGS = \ @PTHREADSTUBS_CFLAGS@ \ - $(WARN_CFLAGS) + $(WARN_CFLAGS) \ + -fvisibility=hidden libdrm_tegra_ladir = $(libdir) libdrm_tegra_la_LTLIBRARIES = libdrm_tegra.la @@ -21,5 +22,6 @@ libdrm_tegrainclude_HEADERS = tegra.h pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libdrm_tegra.pc +AM_TESTS_ENVIRONMENT = NM='$(NM)' TESTS = tegra-symbol-check EXTRA_DIST = $(TESTS) diff --git a/lib/libdrm/tegra/meson.build b/lib/libdrm/tegra/meson.build index 1f5c74b38..4bc454b6e 100644 --- a/lib/libdrm/tegra/meson.build +++ b/lib/libdrm/tegra/meson.build @@ -24,7 +24,7 @@ libdrm_tegra = shared_library( include_directories : [inc_root, inc_drm], link_with : libdrm, dependencies : [dep_pthread_stubs, dep_atomic_ops], - c_args : warn_c_args, + c_args : libdrm_c_args, version : '0.0.0', install : true, ) diff --git a/lib/libdrm/tegra/tegra-symbol-check b/lib/libdrm/tegra/tegra-symbol-check index 509b678c3..8539b95be 100755 --- a/lib/libdrm/tegra/tegra-symbol-check +++ b/lib/libdrm/tegra/tegra-symbol-check @@ -1,5 +1,7 @@ #!/bin/bash +set -u + # The following symbols (past the first nine) are taken from tegra.h. FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_tegra.so} | awk '{print $3}'| while read func; do diff --git a/lib/libdrm/tegra/tegra.c b/lib/libdrm/tegra/tegra.c index 1d7268e5c..cf00a3cac 100644 --- a/lib/libdrm/tegra/tegra.c +++ b/lib/libdrm/tegra/tegra.c @@ -70,7 +70,7 @@ static int drm_tegra_wrap(struct drm_tegra **drmp, int fd, bool close) return 0; } -int drm_tegra_new(struct drm_tegra **drmp, int fd) +drm_public int drm_tegra_new(struct drm_tegra **drmp, int fd) { bool supported = false; drmVersionPtr version; @@ -90,7 +90,7 @@ int drm_tegra_new(struct drm_tegra **drmp, int fd) return drm_tegra_wrap(drmp, fd, false); } -void drm_tegra_close(struct drm_tegra *drm) +drm_public void drm_tegra_close(struct drm_tegra *drm) { if (!drm) return; @@ -101,7 +101,7 @@ void drm_tegra_close(struct drm_tegra *drm) free(drm); } -int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm, +drm_public int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm, uint32_t flags, uint32_t size) { struct drm_tegra_gem_create args; @@ -139,7 +139,7 @@ int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm, return 0; } -int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm, +drm_public int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm, uint32_t handle, uint32_t flags, uint32_t size) { struct drm_tegra_bo *bo; @@ -162,7 +162,7 @@ int drm_tegra_bo_wrap(struct drm_tegra_bo **bop, struct drm_tegra *drm, return 0; } -struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo) +drm_public struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo) { if (bo) atomic_inc(&bo->ref); @@ -170,13 +170,13 @@ struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo) return bo; } -void drm_tegra_bo_unref(struct drm_tegra_bo *bo) +drm_public void drm_tegra_bo_unref(struct drm_tegra_bo *bo) { if (bo && atomic_dec_and_test(&bo->ref)) drm_tegra_bo_free(bo); } -int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle) +drm_public int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle) { if (!bo || !handle) return -EINVAL; @@ -186,7 +186,7 @@ int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle) return 0; } -int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr) +drm_public int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr) { struct drm_tegra *drm = bo->drm; @@ -218,7 +218,7 @@ int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr) return 0; } -int drm_tegra_bo_unmap(struct drm_tegra_bo *bo) +drm_public int drm_tegra_bo_unmap(struct drm_tegra_bo *bo) { if (!bo) return -EINVAL; @@ -234,7 +234,7 @@ int drm_tegra_bo_unmap(struct drm_tegra_bo *bo) return 0; } -int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags) +drm_public int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags) { struct drm_tegra_gem_get_flags args; struct drm_tegra *drm = bo->drm; @@ -257,7 +257,7 @@ int drm_tegra_bo_get_flags(struct drm_tegra_bo *bo, uint32_t *flags) return 0; } -int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags) +drm_public int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags) { struct drm_tegra_gem_get_flags args; struct drm_tegra *drm = bo->drm; @@ -278,7 +278,7 @@ int drm_tegra_bo_set_flags(struct drm_tegra_bo *bo, uint32_t flags) return 0; } -int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo, +drm_public int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo, struct drm_tegra_bo_tiling *tiling) { struct drm_tegra_gem_get_tiling args; @@ -304,7 +304,7 @@ int drm_tegra_bo_get_tiling(struct drm_tegra_bo *bo, return 0; } -int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo, +drm_public int drm_tegra_bo_set_tiling(struct drm_tegra_bo *bo, const struct drm_tegra_bo_tiling *tiling) { struct drm_tegra_gem_set_tiling args; diff --git a/lib/libdrm/tests/Makefile.am b/lib/libdrm/tests/Makefile.am index b72c24f9e..d274a3e90 100644 --- a/lib/libdrm/tests/Makefile.am +++ b/lib/libdrm/tests/Makefile.am @@ -32,6 +32,7 @@ endif AM_CFLAGS = \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir) diff --git a/lib/libdrm/tests/amdgpu/Makefile.am b/lib/libdrm/tests/amdgpu/Makefile.am index e79c1bd3f..447ff217d 100644 --- a/lib/libdrm/tests/amdgpu/Makefile.am +++ b/lib/libdrm/tests/amdgpu/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = \ + -fvisibility=hidden \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir)/amdgpu \ -I $(top_srcdir) \ diff --git a/lib/libdrm/tests/amdgpu/amdgpu_test.h b/lib/libdrm/tests/amdgpu/amdgpu_test.h index f2ece3c30..af81eea8a 100644 --- a/lib/libdrm/tests/amdgpu/amdgpu_test.h +++ b/lib/libdrm/tests/amdgpu/amdgpu_test.h @@ -207,11 +207,9 @@ static inline amdgpu_bo_handle gpu_mem_alloc( amdgpu_va_handle *va_handle) { struct amdgpu_bo_alloc_request req = {0}; - amdgpu_bo_handle buf_handle; + amdgpu_bo_handle buf_handle = NULL; int r; - CU_ASSERT_NOT_EQUAL(vmc_addr, NULL); - req.alloc_size = size; req.phys_alignment = alignment; req.preferred_heap = type; @@ -219,17 +217,36 @@ static inline amdgpu_bo_handle gpu_mem_alloc( r = amdgpu_bo_alloc(device_handle, &req, &buf_handle); CU_ASSERT_EQUAL(r, 0); + if (r) + return NULL; + + if (vmc_addr && va_handle) { + r = amdgpu_va_range_alloc(device_handle, + amdgpu_gpu_va_range_general, + size, alignment, 0, vmc_addr, + va_handle, 0); + CU_ASSERT_EQUAL(r, 0); + if (r) + goto error_free_bo; + + r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, + AMDGPU_VA_OP_MAP); + CU_ASSERT_EQUAL(r, 0); + if (r) + goto error_free_va; + } + + return buf_handle; - r = amdgpu_va_range_alloc(device_handle, - amdgpu_gpu_va_range_general, - size, alignment, 0, vmc_addr, - va_handle, 0); +error_free_va: + r = amdgpu_va_range_free(*va_handle); CU_ASSERT_EQUAL(r, 0); - r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP); +error_free_bo: + r = amdgpu_bo_free(buf_handle); CU_ASSERT_EQUAL(r, 0); - return buf_handle; + return NULL; } static inline int gpu_mem_free(amdgpu_bo_handle bo, @@ -239,16 +256,26 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo, { int r; - r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP); - CU_ASSERT_EQUAL(r, 0); + if (!bo) + return 0; - r = amdgpu_va_range_free(va_handle); - CU_ASSERT_EQUAL(r, 0); + if (va_handle) { + r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, + AMDGPU_VA_OP_UNMAP); + CU_ASSERT_EQUAL(r, 0); + if (r) + return r; + + r = amdgpu_va_range_free(va_handle); + CU_ASSERT_EQUAL(r, 0); + if (r) + return r; + } r = amdgpu_bo_free(bo); CU_ASSERT_EQUAL(r, 0); - return 0; + return r; } static inline int @@ -274,57 +301,20 @@ amdgpu_bo_alloc_wrap(amdgpu_device_handle dev, unsigned size, return 0; } +int amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size, + unsigned alignment, unsigned heap, uint64_t alloc_flags, + uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu, + uint64_t *mc_address, + amdgpu_va_handle *va_handle); + static inline int amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size, - unsigned alignment, unsigned heap, uint64_t flags, + unsigned alignment, unsigned heap, uint64_t alloc_flags, amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address, amdgpu_va_handle *va_handle) { - struct amdgpu_bo_alloc_request request = {}; - amdgpu_bo_handle buf_handle; - amdgpu_va_handle handle; - uint64_t vmc_addr; - int r; - - request.alloc_size = size; - request.phys_alignment = alignment; - request.preferred_heap = heap; - request.flags = flags; - - r = amdgpu_bo_alloc(dev, &request, &buf_handle); - if (r) - return r; - - r = amdgpu_va_range_alloc(dev, - amdgpu_gpu_va_range_general, - size, alignment, 0, &vmc_addr, - &handle, 0); - if (r) - goto error_va_alloc; - - r = amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_MAP); - if (r) - goto error_va_map; - - r = amdgpu_bo_cpu_map(buf_handle, cpu); - if (r) - goto error_cpu_map; - - *bo = buf_handle; - *mc_address = vmc_addr; - *va_handle = handle; - - return 0; - -error_cpu_map: - amdgpu_bo_cpu_unmap(buf_handle); - -error_va_map: - amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP); - -error_va_alloc: - amdgpu_bo_free(buf_handle); - return r; + return amdgpu_bo_alloc_and_map_raw(dev, size, alignment, heap, + alloc_flags, 0, bo, cpu, mc_address, va_handle); } static inline int diff --git a/lib/libdrm/tests/amdgpu/basic_tests.c b/lib/libdrm/tests/amdgpu/basic_tests.c index 1adbddd9d..dbae4d533 100644 --- a/lib/libdrm/tests/amdgpu/basic_tests.c +++ b/lib/libdrm/tests/amdgpu/basic_tests.c @@ -33,6 +33,7 @@ #include "amdgpu_test.h" #include "amdgpu_drm.h" +#include "util_math.h" static amdgpu_device_handle device_handle; static uint32_t major_version; @@ -286,6 +287,66 @@ static uint32_t shader_bin[] = { #define DATA_OFFSET 1024 +int amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size, + unsigned alignment, unsigned heap, uint64_t alloc_flags, + uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu, + uint64_t *mc_address, + amdgpu_va_handle *va_handle) +{ + struct amdgpu_bo_alloc_request request = {}; + amdgpu_bo_handle buf_handle; + amdgpu_va_handle handle; + uint64_t vmc_addr; + int r; + + request.alloc_size = size; + request.phys_alignment = alignment; + request.preferred_heap = heap; + request.flags = alloc_flags; + + r = amdgpu_bo_alloc(dev, &request, &buf_handle); + if (r) + return r; + + r = amdgpu_va_range_alloc(dev, + amdgpu_gpu_va_range_general, + size, alignment, 0, &vmc_addr, + &handle, 0); + if (r) + goto error_va_alloc; + + r = amdgpu_bo_va_op_raw(dev, buf_handle, 0, ALIGN(size, getpagesize()), vmc_addr, + AMDGPU_VM_PAGE_READABLE | + AMDGPU_VM_PAGE_WRITEABLE | + AMDGPU_VM_PAGE_EXECUTABLE | + mapping_flags, + AMDGPU_VA_OP_MAP); + if (r) + goto error_va_map; + + r = amdgpu_bo_cpu_map(buf_handle, cpu); + if (r) + goto error_cpu_map; + + *bo = buf_handle; + *mc_address = vmc_addr; + *va_handle = handle; + + return 0; + + error_cpu_map: + amdgpu_bo_cpu_unmap(buf_handle); + + error_va_map: + amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP); + + error_va_alloc: + amdgpu_bo_free(buf_handle); + return r; +} + + + int suite_basic_tests_init(void) { struct amdgpu_gpu_info gpu_info = {0}; diff --git a/lib/libdrm/tests/amdgpu/bo_tests.c b/lib/libdrm/tests/amdgpu/bo_tests.c index dc2de9b70..7cff4cf73 100644 --- a/lib/libdrm/tests/amdgpu/bo_tests.c +++ b/lib/libdrm/tests/amdgpu/bo_tests.c @@ -242,6 +242,27 @@ static void amdgpu_memory_alloc(void) r = gpu_mem_free(bo, va_handle, bo_mc, 4096); CU_ASSERT_EQUAL(r, 0); + + /* Test GDS */ + bo = gpu_mem_alloc(device_handle, 1024, 0, + AMDGPU_GEM_DOMAIN_GDS, 0, + NULL, NULL); + r = gpu_mem_free(bo, NULL, 0, 4096); + CU_ASSERT_EQUAL(r, 0); + + /* Test GWS */ + bo = gpu_mem_alloc(device_handle, 1, 0, + AMDGPU_GEM_DOMAIN_GWS, 0, + NULL, NULL); + r = gpu_mem_free(bo, NULL, 0, 4096); + CU_ASSERT_EQUAL(r, 0); + + /* Test OA */ + bo = gpu_mem_alloc(device_handle, 1, 0, + AMDGPU_GEM_DOMAIN_OA, 0, + NULL, NULL); + r = gpu_mem_free(bo, NULL, 0, 4096); + CU_ASSERT_EQUAL(r, 0); } static void amdgpu_mem_fail_alloc(void) diff --git a/lib/libdrm/tests/amdgpu/deadlock_tests.c b/lib/libdrm/tests/amdgpu/deadlock_tests.c index 304482d71..292ec4eb9 100644 --- a/lib/libdrm/tests/amdgpu/deadlock_tests.c +++ b/lib/libdrm/tests/amdgpu/deadlock_tests.c @@ -80,6 +80,8 @@ static uint32_t minor_version; static pthread_t stress_thread; static uint32_t *ptr; +int use_uc_mtype = 0; + static void amdgpu_deadlock_helper(unsigned ip_type); static void amdgpu_deadlock_gfx(void); static void amdgpu_deadlock_compute(void); @@ -92,13 +94,14 @@ CU_BOOL suite_deadlock_tests_enable(void) &minor_version, &device_handle)) return CU_FALSE; - if (device_handle->info.family_id == AMDGPU_FAMILY_AI || - device_handle->info.family_id == AMDGPU_FAMILY_SI || - device_handle->info.family_id == AMDGPU_FAMILY_RV) { + if (device_handle->info.family_id == AMDGPU_FAMILY_SI) { printf("\n\nCurrently hangs the CP on this ASIC, deadlock suite disabled\n"); enable = CU_FALSE; } + if (device_handle->info.family_id >= AMDGPU_FAMILY_AI) + use_uc_mtype = 1; + if (amdgpu_device_deinitialize(device_handle)) return CU_FALSE; @@ -183,8 +186,8 @@ static void amdgpu_deadlock_helper(unsigned ip_type) 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, + r = amdgpu_bo_alloc_and_map_raw(device_handle, 4096, 4096, + AMDGPU_GEM_DOMAIN_GTT, 0, use_uc_mtype ? AMDGPU_VM_MTYPE_UC : 0, &ib_result_handle, &ib_result_cpu, &ib_result_mc_address, &va_handle); CU_ASSERT_EQUAL(r, 0); diff --git a/lib/libdrm/tests/amdgpu/vm_tests.c b/lib/libdrm/tests/amdgpu/vm_tests.c index 7b6dc5d6a..fada2987c 100644 --- a/lib/libdrm/tests/amdgpu/vm_tests.c +++ b/lib/libdrm/tests/amdgpu/vm_tests.c @@ -31,8 +31,8 @@ static amdgpu_device_handle device_handle; static uint32_t major_version; static uint32_t minor_version; - static void amdgpu_vmid_reserve_test(void); +static void amdgpu_vm_unaligned_map(void); CU_BOOL suite_vm_tests_enable(void) { @@ -84,6 +84,7 @@ int suite_vm_tests_clean(void) CU_TestInfo vm_tests[] = { { "resere vmid test", amdgpu_vmid_reserve_test }, + { "unaligned map", amdgpu_vm_unaligned_map }, CU_TEST_INFO_NULL, }; @@ -167,3 +168,45 @@ static void amdgpu_vmid_reserve_test(void) r = amdgpu_cs_ctx_free(context_handle); CU_ASSERT_EQUAL(r, 0); } + +static void amdgpu_vm_unaligned_map(void) +{ + const uint64_t map_size = (4ULL << 30) - (2 << 12); + struct amdgpu_bo_alloc_request request = {}; + amdgpu_bo_handle buf_handle; + amdgpu_va_handle handle; + uint64_t vmc_addr; + int r; + + request.alloc_size = 4ULL << 30; + request.phys_alignment = 4096; + request.preferred_heap = AMDGPU_GEM_DOMAIN_VRAM; + request.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS; + + r = amdgpu_bo_alloc(device_handle, &request, &buf_handle); + /* Don't let the test fail if the device doesn't have enough VRAM */ + if (r) + return; + + r = amdgpu_va_range_alloc(device_handle, amdgpu_gpu_va_range_general, + 4ULL << 30, 1ULL << 30, 0, &vmc_addr, + &handle, 0); + CU_ASSERT_EQUAL(r, 0); + if (r) + goto error_va_alloc; + + vmc_addr += 1 << 12; + + r = amdgpu_bo_va_op(buf_handle, 0, map_size, vmc_addr, 0, + AMDGPU_VA_OP_MAP); + CU_ASSERT_EQUAL(r, 0); + if (r) + goto error_va_alloc; + + amdgpu_bo_va_op(buf_handle, 0, map_size, vmc_addr, 0, + AMDGPU_VA_OP_UNMAP); + +error_va_alloc: + amdgpu_bo_free(buf_handle); + +} diff --git a/lib/libdrm/tests/etnaviv/Makefile.am b/lib/libdrm/tests/etnaviv/Makefile.am index 226baee28..3e0c6120c 100644 --- a/lib/libdrm/tests/etnaviv/Makefile.am +++ b/lib/libdrm/tests/etnaviv/Makefile.am @@ -1,4 +1,5 @@ AM_CFLAGS = \ + -fvisibility=hidden \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir)/etnaviv \ -I $(top_srcdir) diff --git a/lib/libdrm/tests/exynos/Makefile.am b/lib/libdrm/tests/exynos/Makefile.am index b6361727b..9658fb427 100644 --- a/lib/libdrm/tests/exynos/Makefile.am +++ b/lib/libdrm/tests/exynos/Makefile.am @@ -1,6 +1,7 @@ AM_CFLAGS = \ -pthread \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir)/libkms/ \ -I $(top_srcdir)/exynos \ diff --git a/lib/libdrm/tests/exynos/meson.build b/lib/libdrm/tests/exynos/meson.build index 940c3ce44..3a048e8ae 100644 --- a/lib/libdrm/tests/exynos/meson.build +++ b/lib/libdrm/tests/exynos/meson.build @@ -24,7 +24,7 @@ if with_libkms exynos_fimg2d_test = executable( 'exynos_fimg2d_test', files('exynos_fimg2d_test.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm, inc_exynos, include_directories('../../libkms')], link_with : [libdrm, libkms, libdrm_exynos], @@ -36,7 +36,7 @@ endif exynos_fimg2d_perf = executable( 'exynos_fimg2d_perf', files('exynos_fimg2d_perf.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm, inc_exynos], link_with : [libdrm, libdrm_exynos], dependencies : dep_threads, @@ -46,7 +46,7 @@ exynos_fimg2d_perf = executable( exynos_fimg2d_event = executable( 'exynos_fimg2d_event', files('exynos_fimg2d_event.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_drm, inc_exynos], link_with : [libdrm, libdrm_exynos], dependencies : dep_threads, diff --git a/lib/libdrm/tests/kms/Makefile.am b/lib/libdrm/tests/kms/Makefile.am index 6645af7ac..422420063 100644 --- a/lib/libdrm/tests/kms/Makefile.am +++ b/lib/libdrm/tests/kms/Makefile.am @@ -4,7 +4,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir) AM_CFLAGS = \ - $(WARN_CFLAGS) + $(WARN_CFLAGS) \ + -fvisibility=hidden noinst_LTLIBRARIES = libkms-test.la diff --git a/lib/libdrm/tests/kms/meson.build b/lib/libdrm/tests/kms/meson.build index 1f7f724d1..91371aa0c 100644 --- a/lib/libdrm/tests/kms/meson.build +++ b/lib/libdrm/tests/kms/meson.build @@ -27,7 +27,7 @@ libkms_test = static_library( ), include_directories : [inc_root, inc_tests, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, ) kms_steal_crtc = executable( diff --git a/lib/libdrm/tests/kmstest/Makefile.am b/lib/libdrm/tests/kmstest/Makefile.am index ced541b74..4c993b04e 100644 --- a/lib/libdrm/tests/kmstest/Makefile.am +++ b/lib/libdrm/tests/kmstest/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/libkms/ \ -I$(top_srcdir)/tests/ \ diff --git a/lib/libdrm/tests/kmstest/meson.build b/lib/libdrm/tests/kmstest/meson.build index a47d49519..4fb870f9f 100644 --- a/lib/libdrm/tests/kmstest/meson.build +++ b/lib/libdrm/tests/kmstest/meson.build @@ -21,7 +21,7 @@ kmstest = executable( 'kmstest', files('main.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [ inc_root, inc_tests, include_directories('../../libkms'), inc_drm, ], diff --git a/lib/libdrm/tests/meson.build b/lib/libdrm/tests/meson.build index fdf950b78..6c8ddd9c2 100644 --- a/lib/libdrm/tests/meson.build +++ b/lib/libdrm/tests/meson.build @@ -53,7 +53,7 @@ drmsl = executable( files('drmsl.c'), include_directories : [inc_root, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, ) hash = executable( @@ -61,7 +61,7 @@ hash = executable( files('hash.c'), include_directories : [inc_root, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, ) random = executable( @@ -69,7 +69,7 @@ random = executable( files('random.c'), include_directories : [inc_root, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, ) drmdevice = executable( @@ -77,7 +77,7 @@ drmdevice = executable( files('drmdevice.c'), include_directories : [inc_root, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, ) test('random', random, timeout : 240) diff --git a/lib/libdrm/tests/modeprint/Makefile.am b/lib/libdrm/tests/modeprint/Makefile.am index 601dbc964..568185f08 100644 --- a/lib/libdrm/tests/modeprint/Makefile.am +++ b/lib/libdrm/tests/modeprint/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/tests \ -I$(top_srcdir) @@ -15,4 +16,5 @@ endif modeprint_SOURCES = \ modeprint.c modeprint_LDADD = \ + $(top_builddir)/tests/util/libutil.la \ $(top_builddir)/libdrm.la diff --git a/lib/libdrm/tests/modeprint/meson.build b/lib/libdrm/tests/modeprint/meson.build index 5f0eb24b7..0801808a9 100644 --- a/lib/libdrm/tests/modeprint/meson.build +++ b/lib/libdrm/tests/modeprint/meson.build @@ -21,9 +21,9 @@ modeprint = executable( 'modeprint', files('modeprint.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_tests, inc_drm], - link_with : libdrm, + link_with : [libdrm, libutil], dependencies : dep_threads, install : with_install_tests, ) diff --git a/lib/libdrm/tests/modeprint/modeprint.c b/lib/libdrm/tests/modeprint/modeprint.c index c81dd91db..ad727e12d 100644 --- a/lib/libdrm/tests/modeprint/modeprint.c +++ b/lib/libdrm/tests/modeprint/modeprint.c @@ -42,6 +42,7 @@ #include "xf86drmMode.h" #include "util/common.h" +#include "util/kms.h" int current; int connectors; @@ -54,20 +55,6 @@ int crtcs; int fbs; char *module_name; -static const char* getConnectionText(drmModeConnection conn) -{ - switch (conn) { - case DRM_MODE_CONNECTED: - return "connected"; - case DRM_MODE_DISCONNECTED: - return "disconnected"; - case DRM_MODE_UNKNOWNCONNECTION: - default: - return "unknown"; - } - -} - static int printMode(struct drm_mode_modeinfo *mode) { if (full_modes) { @@ -141,40 +128,24 @@ static int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, ui return 0; } -static const char * const output_names[] = { "None", - "VGA", - "DVI-I", - "DVI-D", - "DVI-A", - "Composite", - "SVIDEO", - "LVDS", - "Component", - "DIN", - "DP", - "HDMI-A", - "HDMI-B", - "TV", - "eDP", - "Virtual", - "DSI", -}; - static int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id) { int i = 0; struct drm_mode_modeinfo *mode = NULL; drmModePropertyPtr props; + const char *connector_type_name = NULL; + + connector_type_name = util_lookup_connector_type_name(connector->connector_type); - if (connector->connector_type < ARRAY_SIZE(output_names)) - printf("Connector: %s-%d\n", output_names[connector->connector_type], + if (connector_type_name) + printf("Connector: %s-%d\n", connector_type_name, connector->connector_type_id); else printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); printf("\tid : %i\n", id); printf("\tencoder id : %i\n", connector->encoder_id); - printf("\tconn : %s\n", getConnectionText(connector->connection)); + printf("\tconn : %s\n", util_lookup_connector_status_name(connector->connection)); printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); printf("\tcount_modes : %i\n", connector->count_modes); printf("\tcount_props : %i\n", connector->count_props); @@ -215,7 +186,13 @@ static int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connect static int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t id) { - printf("Encoder\n"); + const char *encoder_name; + + encoder_name = util_lookup_encoder_type_name(encoder->encoder_type); + if (encoder_name) + printf("Encoder: %s\n", encoder_name); + else + printf("Encoder\n"); printf("\tid :%i\n", id); printf("\tcrtc_id :%d\n", encoder->crtc_id); printf("\ttype :%d\n", encoder->encoder_type); diff --git a/lib/libdrm/tests/modetest/Makefile.am b/lib/libdrm/tests/modetest/Makefile.am index 4b296c837..5eebd9601 100644 --- a/lib/libdrm/tests/modetest/Makefile.am +++ b/lib/libdrm/tests/modetest/Makefile.am @@ -3,6 +3,7 @@ include Makefile.sources AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS)) AM_CFLAGS += \ + -fvisibility=hidden \ -pthread \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/tests \ diff --git a/lib/libdrm/tests/modetest/meson.build b/lib/libdrm/tests/modetest/meson.build index 2a081845c..23d84a1d2 100644 --- a/lib/libdrm/tests/modetest/meson.build +++ b/lib/libdrm/tests/modetest/meson.build @@ -21,7 +21,7 @@ modetest = executable( 'modetest', files('buffers.c', 'cursor.c', 'modetest.c'), - c_args : [warn_c_args, '-Wno-pointer-arith'], + c_args : [libdrm_c_args, '-Wno-pointer-arith'], include_directories : [inc_root, inc_tests, inc_drm], dependencies : [dep_threads, dep_cairo], link_with : [libdrm, libutil], diff --git a/lib/libdrm/tests/nouveau/Makefile.am b/lib/libdrm/tests/nouveau/Makefile.am index 3c799a81d..554f43ec0 100644 --- a/lib/libdrm/tests/nouveau/Makefile.am +++ b/lib/libdrm/tests/nouveau/Makefile.am @@ -1,6 +1,7 @@ AM_CFLAGS = \ -pthread \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/nouveau \ -I$(top_srcdir) diff --git a/lib/libdrm/tests/nouveau/meson.build b/lib/libdrm/tests/nouveau/meson.build index f5d73c1e0..ca4d44f07 100644 --- a/lib/libdrm/tests/nouveau/meson.build +++ b/lib/libdrm/tests/nouveau/meson.build @@ -24,7 +24,7 @@ threaded = executable( dependencies : [dep_dl, dep_threads], include_directories : [inc_root, inc_drm, include_directories('../../nouveau')], link_with : [libdrm, libdrm_nouveau], - c_args : warn_c_args, + c_args : libdrm_c_args, ) test('threaded', threaded) diff --git a/lib/libdrm/tests/proptest/Makefile.am b/lib/libdrm/tests/proptest/Makefile.am index 3fde46bec..33b8705bc 100644 --- a/lib/libdrm/tests/proptest/Makefile.am +++ b/lib/libdrm/tests/proptest/Makefile.am @@ -2,6 +2,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/tests \ -I$(top_srcdir) diff --git a/lib/libdrm/tests/proptest/meson.build b/lib/libdrm/tests/proptest/meson.build index 22d7473e3..9c87965a2 100644 --- a/lib/libdrm/tests/proptest/meson.build +++ b/lib/libdrm/tests/proptest/meson.build @@ -21,7 +21,7 @@ proptest = executable( 'proptest', files('proptest.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_tests, inc_drm], link_with : [libdrm, libutil], install : with_install_tests, diff --git a/lib/libdrm/tests/radeon/Makefile.am b/lib/libdrm/tests/radeon/Makefile.am index 9da762596..3d173e31a 100644 --- a/lib/libdrm/tests/radeon/Makefile.am +++ b/lib/libdrm/tests/radeon/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I $(top_srcdir)/include/drm \ -I $(top_srcdir) diff --git a/lib/libdrm/tests/radeon/meson.build b/lib/libdrm/tests/radeon/meson.build index 9e4f916ea..bb345b733 100644 --- a/lib/libdrm/tests/radeon/meson.build +++ b/lib/libdrm/tests/radeon/meson.build @@ -23,5 +23,5 @@ radeon_ttm = executable( files('rbo.c', 'radeon_ttm.c'), include_directories : [inc_root, inc_drm], link_with : libdrm, - c_args : warn_c_args, + c_args : libdrm_c_args, ) diff --git a/lib/libdrm/tests/tegra/Makefile.am b/lib/libdrm/tests/tegra/Makefile.am index 8e625c8fe..b462a30c7 100644 --- a/lib/libdrm/tests/tegra/Makefile.am +++ b/lib/libdrm/tests/tegra/Makefile.am @@ -3,7 +3,9 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/tegra \ -I$(top_srcdir) -AM_CFLAGS = $(WARN_CFLAGS) +AM_CFLAGS = \ + $(WARN_CFLAGS) \ + -fvisibility=hidden LDADD = \ ../../tegra/libdrm_tegra.la \ diff --git a/lib/libdrm/tests/tegra/meson.build b/lib/libdrm/tests/tegra/meson.build index 9c74ac4ac..4f8c54f41 100644 --- a/lib/libdrm/tests/tegra/meson.build +++ b/lib/libdrm/tests/tegra/meson.build @@ -22,6 +22,6 @@ openclose = executable( 'openclose', files('openclose.c'), include_directories : [inc_root, inc_drm, include_directories('../../tegra')], - c_args : warn_c_args, + c_args : libdrm_c_args, link_with : [libdrm, libdrm_tegra], ) diff --git a/lib/libdrm/tests/util/kms.c b/lib/libdrm/tests/util/kms.c index a2d1d7ba2..5af8bf20a 100644 --- a/lib/libdrm/tests/util/kms.c +++ b/lib/libdrm/tests/util/kms.c @@ -145,6 +145,7 @@ static const char * const modules[] = { "meson", "pl111", "stm", + "sun4i-drm", }; int util_open(const char *device, const char *module) diff --git a/lib/libdrm/tests/vbltest/Makefile.am b/lib/libdrm/tests/vbltest/Makefile.am index 276afad55..b6cd7a4d7 100644 --- a/lib/libdrm/tests/vbltest/Makefile.am +++ b/lib/libdrm/tests/vbltest/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ $(WARN_CFLAGS)\ + -fvisibility=hidden \ -I$(top_srcdir)/include/drm \ -I$(top_srcdir)/tests \ -I$(top_srcdir) diff --git a/lib/libdrm/tests/vbltest/meson.build b/lib/libdrm/tests/vbltest/meson.build index ae52ab885..6339febae 100644 --- a/lib/libdrm/tests/vbltest/meson.build +++ b/lib/libdrm/tests/vbltest/meson.build @@ -21,7 +21,7 @@ vbltest = executable( 'vbltest', files('vbltest.c'), - c_args : warn_c_args, + c_args : libdrm_c_args, include_directories : [inc_root, inc_tests, inc_drm], link_with : [libdrm, libutil], install : with_install_tests, diff --git a/lib/libdrm/util_math.h b/lib/libdrm/util_math.h index 02b15a8e5..35bf45129 100644 --- a/lib/libdrm/util_math.h +++ b/lib/libdrm/util_math.h @@ -29,6 +29,6 @@ #define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) #define __align_mask(value, mask) (((value) + (mask)) & ~(mask)) -#define ALIGN(value, alignment) __align_mask(value, (typeof(value))((alignment) - 1)) +#define ALIGN(value, alignment) __align_mask(value, (__typeof__(value))((alignment) - 1)) #endif /*_UTIL_MATH_H_*/ diff --git a/lib/libdrm/vc4/Makefile.am b/lib/libdrm/vc4/Makefile.am index 7e486b4d8..5f82d04eb 100644 --- a/lib/libdrm/vc4/Makefile.am +++ b/lib/libdrm/vc4/Makefile.am @@ -23,6 +23,7 @@ include Makefile.sources AM_CFLAGS = \ $(WARN_CFLAGS) \ + -fvisibility=hidden \ -I$(top_srcdir) \ $(PTHREADSTUBS_CFLAGS) \ $(VALGRIND_CFLAGS) \ |