summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>2023-01-12 17:31:53 +0100
committerMarge Bot <emma+marge@anholt.net>2023-01-25 08:09:13 +0000
commitf2ef663d08b88489cc0484737a5c9bbbf31b35ec (patch)
treed7d41f191c49309f548d705aaeba2d83cf278496 /src/gallium/winsys
parent3ed75027b74614fa929fe6d03577d53799a136ac (diff)
winsys/amdgpu: use DMA_BUF_SET_NAME_B if available
Give a name to dma-buf. This name appears in /sys/kernel/debug/dma_buf/bufinfo and could be useful to debug dma-buf: Dma-buf Objects: size flags mode count exp_name ino name 00606208 00000002 00080007 00000003 drm 00192014 2321705-glxgears The name is only added to non-shared buffer, to avoid overwriting an existing name when exporting an imported buffer (otherwise all dma-buf will pretend to be created by XWayland). Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20728>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 1b53bcc61b0..d39ef610ed6 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -25,13 +25,17 @@
* of the Software.
*/
+#include <sys/ioctl.h>
+
#include "amdgpu_cs.h"
#include "util/hash_table.h"
#include "util/os_time.h"
#include "util/u_hash_table.h"
+#include "util/u_process.h"
#include "frontend/drm_driver.h"
#include "drm-uapi/amdgpu_drm.h"
+#include "drm-uapi/dma-buf.h"
#include <xf86drm.h>
#include <stdio.h>
#include <inttypes.h>
@@ -1636,6 +1640,15 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
if (r)
return false;
+#if defined(DMA_BUF_SET_NAME_B)
+ if (whandle->type == WINSYS_HANDLE_TYPE_FD &&
+ !bo->u.real.is_shared) {
+ char dmabufname[32];
+ snprintf(dmabufname, 32, "%d-%s", getpid(), util_get_process_name());
+ r = ioctl(whandle->handle, DMA_BUF_SET_NAME_B, (uint64_t)(uintptr_t)dmabufname);
+ }
+#endif
+
if (whandle->type == WINSYS_HANDLE_TYPE_KMS) {
int dma_fd = whandle->handle;