drm: add libdrm_amdgpu (v4)
Subsystems (2)
PATCH 3/4 drm: add libdrm_amdgpu (v4)
This is the new ioctl wrapper used by the new admgpu driver. It's primarily used by xf86-video-amdgpu and mesa.
v2: fix amdgpu_drm.h install
v3: Integrate some of the sugestions from Emil:
clean up Makefile.am, configure.ac
capitalize header guards
fix _FILE_OFFSET_BITS with config.h
use drm_mmap/drm_munmap
Remove unused ARRAY_SIZE macro
use shared list implementation
use shared math implementation
use drmGetNodeTypeFromFd helper
v4: remove unused tiling defines
--- Makefile.am | 5 + Makefile.sources | 1 + amdgpu/Makefile.am | 53 ++ amdgpu/amdgpu.h | 1276 ++++++++++++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 626 ++++++++++++++++++++++ amdgpu/amdgpu_cs.c | 981 ++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_device.c | 241 +++++++++ amdgpu/amdgpu_gpu_info.c | 275 ++++++++++ amdgpu/amdgpu_internal.h | 208 ++++++++ amdgpu/amdgpu_vamgr.c | 169 ++++++ amdgpu/libdrm_amdgpu.pc.in | 10 + amdgpu/util_hash.c | 382 +++++++++++++ amdgpu/util_hash.h | 99 ++++ amdgpu/util_hash_table.c | 257 +++++++++ amdgpu/util_hash_table.h | 65 +++ configure.ac | 19 + include/drm/amdgpu_drm.h | 580 ++++++++++++++++++++ 17 files changed, 5247 insertions(+) create mode 100644 amdgpu/Makefile.am create mode 100644 amdgpu/amdgpu.h create mode 100644 amdgpu/amdgpu_bo.c create mode 100644 amdgpu/amdgpu_cs.c create mode 100644 amdgpu/amdgpu_device.c create mode 100644 amdgpu/amdgpu_gpu_info.c create mode 100644 amdgpu/amdgpu_internal.h create mode 100644 amdgpu/amdgpu_vamgr.c create mode 100644 amdgpu/libdrm_amdgpu.pc.in create mode 100644 amdgpu/util_hash.c create mode 100644 amdgpu/util_hash.h create mode 100644 amdgpu/util_hash_table.c create mode 100644 amdgpu/util_hash_table.h create mode 100644 include/drm/amdgpu_drm.h
Makefile.am +5 -0
@@ -57,6 +57,10 @@ if HAVE_RADEON RADEON_SUBDIR = radeon endif +if HAVE_AMDGPU +AMDGPU_SUBDIR = amdgpu +endif + if HAVE_OMAP OMAP_SUBDIR = omap endif
@@ -79,6 +83,7 @@ SUBDIRS = \ $(INTEL_SUBDIR) \ $(NOUVEAU_SUBDIR) \ $(RADEON_SUBDIR) \ + $(AMDGPU_SUBDIR) \ $(OMAP_SUBDIR) \ $(EXYNOS_SUBDIR) \ $(FREEDRENO_SUBDIR) \
Makefile.sources +1 -0
@@ -28,6 +28,7 @@ LIBDRM_INCLUDE_H_FILES := \ include/drm/qxl_drm.h \ include/drm/r128_drm.h \ include/drm/radeon_drm.h \ + include/drm/amdgpu_drm.h \ include/drm/savage_drm.h \ include/drm/sis_drm.h \ include/drm/tegra_drm.h \
amdgpu/Makefile.am new file +53 -0
53 lines not on this page · raw message
amdgpu/amdgpu.h new file +1276 -0
1,276 lines not on this page · raw message
amdgpu/amdgpu_bo.c new file +626 -0
626 lines not on this page · raw message
amdgpu/amdgpu_cs.c new file +981 -0
981 lines not on this page · raw message
amdgpu/amdgpu_device.c new file +241 -0
40 lines not on this page · raw message
amdgpu/amdgpu_gpu_info.c new file +275 -0
275 lines not on this page · raw message
amdgpu/amdgpu_internal.h new file +208 -0
208 lines not on this page · raw message
amdgpu/amdgpu_vamgr.c new file +169 -0
169 lines not on this page · raw message
amdgpu/util_hash.c new file +382 -0
382 lines not on this page · raw message
amdgpu/util_hash.h new file +99 -0
99 lines not on this page · raw message
amdgpu/util_hash_table.c new file +257 -0
257 lines not on this page · raw message
amdgpu/util_hash_table.h new file +65 -0
65 lines not on this page · raw message
include/drm/amdgpu_drm.h new file +580 -0
580 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Part of the diff is not shown here. View the raw message.
Hi Alex,
Quoted 13 lines · Alex Deucher
This is the new ioctl wrapper used by the new admgpu driver. It's primarily used by xf86-video-amdgpu and mesa.
v2: fix
amdgpu_drm.hinstall
v3: Integrate some of the sugestions from Emil:
clean up Makefile.am, configure.ac
capitalize header guards
fix_FILE_OFFSET_BITSwithconfig.h
use drm_mmap/drm_munmap
Remove unusedARRAY_SIZEmacro
use shared list implementation
use shared math implementation
use drmGetNodeTypeFromFd helper
Huge thanks for picking my suggestions. There are a couple which got lost considering the size of the patch. Do let me know if I have missed the plot and some of them are not applicable.
Quoted 40 lines
v4: remove unused tiling defines
Signed-off-by Alex Deucher <[email protected]>--- Makefile.am | 5 + Makefile.sources | 1 + amdgpu/Makefile.am | 53 ++ amdgpu/amdgpu.h | 1276 ++++++++++++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 626 ++++++++++++++++++++++ amdgpu/amdgpu_cs.c | 981 ++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_device.c | 241 +++++++++ amdgpu/amdgpu_gpu_info.c | 275 ++++++++++ amdgpu/amdgpu_internal.h | 208 ++++++++ amdgpu/amdgpu_vamgr.c | 169 ++++++ amdgpu/libdrm_amdgpu.pc.in | 10 + amdgpu/util_hash.c | 382 +++++++++++++ amdgpu/util_hash.h | 99 ++++ amdgpu/util_hash_table.c | 257 +++++++++ amdgpu/util_hash_table.h | 65 +++ configure.ac | 19 + include/drm/amdgpu_drm.h | 580 ++++++++++++++++++++ 17 files changed, 5247 insertions(+) create mode 100644 amdgpu/Makefile.am create mode 100644 amdgpu/amdgpu.h create mode 100644 amdgpu/amdgpu_bo.c create mode 100644 amdgpu/amdgpu_cs.c create mode 100644 amdgpu/amdgpu_device.c create mode 100644 amdgpu/amdgpu_gpu_info.c create mode 100644 amdgpu/amdgpu_internal.h create mode 100644 amdgpu/amdgpu_vamgr.c create mode 100644 amdgpu/libdrm_amdgpu.pc.in create mode 100644 amdgpu/util_hash.c create mode 100644 amdgpu/util_hash.h create mode 100644 amdgpu/util_hash_table.c create mode 100644 amdgpu/util_hash_table.h create mode 100644 include/drm/amdgpu_drm.h
amdgpu/amdgpu_device.c line 46
Quoted 3 lines
amdgpu/amdgpu_device.c new file +2
-0+#define RENDERNODE_MINOR_MASK 0xff7f +
You can drop this if you go for my suggestions below.
amdgpu/amdgpu_device.c line 66
Quoted 7 lines
amdgpu/amdgpu_device.c new file +7
-0+static unsigned fd_hash (void *key) +{ +int fd =PTR_TO_UINT (key); +struct stat stat; +fstat (fd, &stat); + +if (!S_ISCHR (stat.st_mode))
Afaict this cannot/should not happen - might as well drop it ?
amdgpu/amdgpu_device.c line 69
Quoted 3 lines
amdgpu/amdgpu_device.c new file +3
-0+return stat.st_dev ^ stat.st_ino; + else + return stat.st_dev ^ (stat.st_rdev & RENDERNODE_MINOR_MASK);
One cannot get the render/primary node relation by masking/oring the 7th bit.
You can get the primary device name (via drmGetPrimaryDeviceNameFromFd ) and fstat it.
amdgpu/amdgpu_device.c line 80
Quoted 11 lines
amdgpu/amdgpu_device.c new file +11
-0+} + +static int fd_compare (void *key1,void *key2) +{ +int fd1 =PTR_TO_UINT (key1); +int fd2 =PTR_TO_UINT (key2); +struct stat stat1, stat2; +fstat (fd1, &stat1); +fstat (fd2, &stat2); + +if (!S_ISCHR (stat1.st_mode) || !S_ISCHR (stat2.st_mode))
As above.
amdgpu/amdgpu_device.c line 86
Quoted 6 lines
amdgpu/amdgpu_device.c new file +6
-0+return stat1.st_dev != stat2.st_dev || + stat1.st_ino != stat2.st_ino; + else + return major(stat1.st_rdev) != major(stat2.st_rdev) || + (minor (stat1.st_rdev) &RENDERNODE_MINOR_MASK ) != + (minor (stat2.st_rdev) &RENDERNODE_MINOR_MASK );
Similar to above - please compare the primary device name for both fds.
Quoted 16 lines
amdgpu/amdgpu_device.c new file +2
-0+} +include/drm/amdgpu_drm.h new file +6
-0+struct drm_amdgpu_ctx_in { +uint32_t op; +uint32_t flags; +uint32_t ctx_id; +uint32_t pad; +};
include/drm/amdgpu_drm.h line 222
Quoted 10 lines
include/drm/amdgpu_drm.h new file +9
-0+ +/** The same structure is shared for input/output */ +struct drm_amdgpu_gem_metadata { +uint32_t handle;/* GEM Object handle */ +uint32_t op;/** Do we want get or set metadata */ +struct { +uint64_t flags; +uint64_t tiling_info;/* family specific tiling info */ +uint32_t data_size_bytes;
Considering that this is fed directly into the kernel we should pad/align it - similar to drm_amdgpu_ctx_in above.
include/drm/amdgpu_drm.h line 228
Quoted 6 lines
include/drm/amdgpu_drm.h new file +6
-0+uint32_t data[64 ]; + } data; +}; + +struct drm_amdgpu_gem_mmap_in { +uint32_t handle;/** the GEM object handle */
Ditto.
include/drm/amdgpu_drm.h line 261
Quoted 9 lines
include/drm/amdgpu_drm.h new file +8
-0+}; + +struct drm_amdgpu_wait_cs_in { +uint64_t handle; +uint64_t timeout; +uint32_t ip_type; +uint32_t ip_instance; +uint32_t ring;
Ditto.
Quoted 39 lines
include/drm/amdgpu_drm.h new file +38
-0+}; + +/* Input structure for the INFO ioctl */ +struct drm_amdgpu_info { + /* Where the return value will be stored */ + uint64_t return_pointer; + /* The size of the return value. Just like "size" in "snprintf", + * it limits how many bytes the kernel can write. */ + uint32_t return_size; + /* The query request id. */ + uint32_t query; + + union { + struct { + uint32_t id; + } mode_crtc; + + struct { + /** AMDGPU_HW_IP_* */ + uint32_t type; + /** + * Index of the IP if there are more IPs of the same type. + * Ignored by AMDGPU_INFO_HW_IP_COUNT. + */ + uint32_t ip_instance; + } query_hw_ip; + + struct { + uint32_t dword_offset; + uint32_t count; /* number of registers to read */ + uint32_t instance; + uint32_t flags; + } read_mmr_reg; + + struct { + /** AMDGPU_INFO_FW_* */ + uint32_t fw_type; + /** Index of the IP if there are more IPs of the same type. */
include/drm/amdgpu_drm.h line 500
Quoted 10 lines
include/drm/amdgpu_drm.h new file +10
-0+uint32_t ip_instance; +/** +* Index of the engine. Whether this is used depends +* on the firmware type. (e.g. MEC, SDMA) +*/ +uint32_t index; + } query_fw; + }; +}; +
Might need some padding, not sure though.
Quoted 6 lines
include/drm/amdgpu_drm.h new file +6
-0+struct drm_amdgpu_info_gds { +/** GDS GFX partition size */ +uint32_t gds_gfx_partition_size; +/** GDS compute partition size */ +uint32_t compute_partition_size; +/** total GDS memory size */
include/drm/amdgpu_drm.h line 516
Quoted 10 lines
include/drm/amdgpu_drm.h new file +10
-0+uint32_t gds_total_size; +/** GWS size per GFX partition */ +uint32_t gws_per_gfx_partition; +/** GSW size per compute partition */ +uint32_t gws_per_compute_partition; +/** OA size per GFX partition */ +uint32_t oa_per_gfx_partition; +/** OA size per compute partition */ +uint32_t oa_per_compute_partition; +};
Seems unused - neither libdrm_amdgpu nor winsys/amdgpu use it.
Cheers
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel