diff options
author | Christian König <christian.koenig@amd.com> | 2014-08-07 03:36:00 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2014-08-11 11:04:23 -0400 |
commit | f72a113a71ab08c4df8a5f80ab2f8a140feb81f6 (patch) | |
tree | 6d1453a5ffef6dfab8fdf1bc2e85b9abc531ed9a /include/uapi/drm | |
parent | 7963e9db1b1f842fdc53309baa8714d38e9f5681 (diff) |
drm/radeon: add userptr support v8
This patch adds an IOCTL for turning a pointer supplied by
userspace into a buffer object.
It imposes several restrictions upon the memory being mapped:
1. It must be page aligned (both start/end addresses, i.e ptr and size).
2. It must be normal system memory, not a pointer into another map of IO
space (e.g. it must not be a GTT mmapping of another object).
3. The BO is mapped into GTT, so the maximum amount of memory mapped at
all times is still the GTT limit.
4. The BO is only mapped readonly for now, so no write support.
5. List of backing pages is only acquired once, so they represent a
snapshot of the first use.
Exporting and sharing as well as mapping of buffer objects created by
this function is forbidden and results in an -EPERM.
v2: squash all previous changes into first public version
v3: fix tabs, map readonly, don't use MM callback any more
v4: set TTM_PAGE_FLAG_SG so that TTM never messes with the pages,
pin/unpin pages on bind/unbind instead of populate/unpopulate
v5: rebased on 3.17-wip, IOCTL renamed to userptr, reject any unknown
flags, better handle READONLY flag, improve permission check
v6: fix ptr cast warning, use set_page_dirty/mark_page_accessed on unpin
v7: add warning about it's availability in the API definition
v8: drop access_ok check, fix VM mapping bits
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v4)
Reviewed-by: Jérôme Glisse <jglisse@redhat.com> (v4)
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'include/uapi/drm')
-rw-r--r-- | include/uapi/drm/radeon_drm.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/uapi/drm/radeon_drm.h b/include/uapi/drm/radeon_drm.h index 509b2d7a41b7..3a9f20930372 100644 --- a/include/uapi/drm/radeon_drm.h +++ b/include/uapi/drm/radeon_drm.h | |||
@@ -511,6 +511,7 @@ typedef struct { | |||
511 | #define DRM_RADEON_GEM_BUSY 0x2a | 511 | #define DRM_RADEON_GEM_BUSY 0x2a |
512 | #define DRM_RADEON_GEM_VA 0x2b | 512 | #define DRM_RADEON_GEM_VA 0x2b |
513 | #define DRM_RADEON_GEM_OP 0x2c | 513 | #define DRM_RADEON_GEM_OP 0x2c |
514 | #define DRM_RADEON_GEM_USERPTR 0x2d | ||
514 | 515 | ||
515 | #define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t) | 516 | #define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t) |
516 | #define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START) | 517 | #define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START) |
@@ -554,6 +555,7 @@ typedef struct { | |||
554 | #define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy) | 555 | #define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy) |
555 | #define DRM_IOCTL_RADEON_GEM_VA DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_VA, struct drm_radeon_gem_va) | 556 | #define DRM_IOCTL_RADEON_GEM_VA DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_VA, struct drm_radeon_gem_va) |
556 | #define DRM_IOCTL_RADEON_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_OP, struct drm_radeon_gem_op) | 557 | #define DRM_IOCTL_RADEON_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_OP, struct drm_radeon_gem_op) |
558 | #define DRM_IOCTL_RADEON_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_USERPTR, struct drm_radeon_gem_userptr) | ||
557 | 559 | ||
558 | typedef struct drm_radeon_init { | 560 | typedef struct drm_radeon_init { |
559 | enum { | 561 | enum { |
@@ -808,6 +810,20 @@ struct drm_radeon_gem_create { | |||
808 | uint32_t flags; | 810 | uint32_t flags; |
809 | }; | 811 | }; |
810 | 812 | ||
813 | /* | ||
814 | * This is not a reliable API and you should expect it to fail for any | ||
815 | * number of reasons and have fallback path that do not use userptr to | ||
816 | * perform any operation. | ||
817 | */ | ||
818 | #define RADEON_GEM_USERPTR_READONLY (1 << 0) | ||
819 | |||
820 | struct drm_radeon_gem_userptr { | ||
821 | uint64_t addr; | ||
822 | uint64_t size; | ||
823 | uint32_t flags; | ||
824 | uint32_t handle; | ||
825 | }; | ||
826 | |||
811 | #define RADEON_TILING_MACRO 0x1 | 827 | #define RADEON_TILING_MACRO 0x1 |
812 | #define RADEON_TILING_MICRO 0x2 | 828 | #define RADEON_TILING_MICRO 0x2 |
813 | #define RADEON_TILING_SWAP_16BIT 0x4 | 829 | #define RADEON_TILING_SWAP_16BIT 0x4 |