diff options
author | Jerome Glisse <jglisse@redhat.com> | 2012-01-05 22:11:05 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-01-06 04:15:42 -0500 |
commit | 721604a15b934f0a8d1909acb8017f029128be2f (patch) | |
tree | ac1dc0f837d70616b36c9b57d22eb9678c5e68fc /include/drm/radeon_drm.h | |
parent | 09b4ea47d1041612b101c369969db123ac2c1511 (diff) |
drm/radeon: GPU virtual memory support v22
Virtual address space are per drm client (opener of /dev/drm).
Client are in charge of virtual address space, they need to
map bo into it by calling DRM_RADEON_GEM_VA ioctl.
First 16M of virtual address space is reserved by the kernel.
Once using 2 level page table we should be able to have a small
vram memory footprint for each pt (there would be one pt for all
gart, one for all vram and then one first level for each virtual
address space).
Plan include using the sub allocator for a common vm page table
area and using memcpy to copy vm page table in & out. Or use
a gart object and copy things in & out using dma.
v2: agd5f fixes:
- Add vram base offset for vram pages. The GPU physical address of a
vram page is FB_OFFSET + page offset. FB_OFFSET is 0 on discrete
cards and the physical bus address of the stolen memory on
integrated chips.
- VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR covers all vmid's >= 1
v3: agd5f:
- integrate with the semaphore/multi-ring stuff
v4:
- rebase on top ttm dma & multi-ring stuff
- userspace is now in charge of the address space
- no more specific cs vm ioctl, instead cs ioctl has a new
chunk
v5:
- properly handle mem == NULL case from move_notify callback
- fix the vm cleanup path
v6:
- fix update of page table to only happen on valid mem placement
v7:
- add tlb flush for each vm context
- add flags to define mapping property (readable, writeable, snooped)
- make ring id implicit from ib->fence->ring, up to each asic callback
to then do ring specific scheduling if vm ib scheduling function
v8:
- add query for ib limit and kernel reserved virtual space
- rename vm->size to max_pfn (maximum number of page)
- update gem_va ioctl to also allow unmap operation
- bump kernel version to allow userspace to query for vm support
v9:
- rebuild page table only when bind and incrementaly depending
on bo referenced by cs and that have been moved
- allow virtual address space to grow
- use sa allocator for vram page table
- return invalid when querying vm limit on non cayman GPU
- dump vm fault register on lockup
v10: agd5f:
- Move the vm schedule_ib callback to a standalone function, remove
the callback and use the existing ib_execute callback for VM IBs.
v11:
- rebase on top of lastest Linus
v12: agd5f:
- remove spurious backslash
- set IB vm_id to 0 in radeon_ib_get()
v13: agd5f:
- fix handling of RADEON_CHUNK_ID_FLAGS
v14:
- fix va destruction
- fix suspend resume
- forbid bo to have several different va in same vm
v15:
- rebase
v16:
- cleanup left over of vm init/fini
v17: agd5f:
- cs checker
v18: agd5f:
- reworks the CS ioctl to better support multiple rings and
VM. Rather than adding a new chunk id for VM, just re-use the
IB chunk id and add a new flags for VM mode. Also define additional
dwords for the flags chunk id to define the what ring we want to use
(gfx, compute, uvd, etc.) and the priority.
v19:
- fix cs fini in weird case of no ib
- semi working flush fix for ni
- rebase on top of sa allocator changes
v20: agd5f:
- further CS ioctl cleanups from Christian's comments
v21: agd5f:
- integrate CS checker improvements
v22: agd5f:
- final cleanups for release, only allow VM CS on cayman
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/radeon_drm.h')
-rw-r--r-- | include/drm/radeon_drm.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h index be94be6d6f17..d7079f42624b 100644 --- a/include/drm/radeon_drm.h +++ b/include/drm/radeon_drm.h | |||
@@ -509,6 +509,7 @@ typedef struct { | |||
509 | #define DRM_RADEON_GEM_SET_TILING 0x28 | 509 | #define DRM_RADEON_GEM_SET_TILING 0x28 |
510 | #define DRM_RADEON_GEM_GET_TILING 0x29 | 510 | #define DRM_RADEON_GEM_GET_TILING 0x29 |
511 | #define DRM_RADEON_GEM_BUSY 0x2a | 511 | #define DRM_RADEON_GEM_BUSY 0x2a |
512 | #define DRM_RADEON_GEM_VA 0x2b | ||
512 | 513 | ||
513 | #define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t) | 514 | #define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t) |
514 | #define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START) | 515 | #define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START) |
@@ -550,6 +551,7 @@ typedef struct { | |||
550 | #define DRM_IOCTL_RADEON_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling) | 551 | #define DRM_IOCTL_RADEON_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling) |
551 | #define DRM_IOCTL_RADEON_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling) | 552 | #define DRM_IOCTL_RADEON_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling) |
552 | #define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy) | 553 | #define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy) |
554 | #define DRM_IOCTL_RADEON_GEM_VA DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_VA, struct drm_radeon_gem_va) | ||
553 | 555 | ||
554 | typedef struct drm_radeon_init { | 556 | typedef struct drm_radeon_init { |
555 | enum { | 557 | enum { |
@@ -872,12 +874,42 @@ struct drm_radeon_gem_pwrite { | |||
872 | uint64_t data_ptr; | 874 | uint64_t data_ptr; |
873 | }; | 875 | }; |
874 | 876 | ||
877 | #define RADEON_VA_MAP 1 | ||
878 | #define RADEON_VA_UNMAP 2 | ||
879 | |||
880 | #define RADEON_VA_RESULT_OK 0 | ||
881 | #define RADEON_VA_RESULT_ERROR 1 | ||
882 | #define RADEON_VA_RESULT_VA_EXIST 2 | ||
883 | |||
884 | #define RADEON_VM_PAGE_VALID (1 << 0) | ||
885 | #define RADEON_VM_PAGE_READABLE (1 << 1) | ||
886 | #define RADEON_VM_PAGE_WRITEABLE (1 << 2) | ||
887 | #define RADEON_VM_PAGE_SYSTEM (1 << 3) | ||
888 | #define RADEON_VM_PAGE_SNOOPED (1 << 4) | ||
889 | |||
890 | struct drm_radeon_gem_va { | ||
891 | uint32_t handle; | ||
892 | uint32_t operation; | ||
893 | uint32_t vm_id; | ||
894 | uint32_t flags; | ||
895 | uint64_t offset; | ||
896 | }; | ||
897 | |||
875 | #define RADEON_CHUNK_ID_RELOCS 0x01 | 898 | #define RADEON_CHUNK_ID_RELOCS 0x01 |
876 | #define RADEON_CHUNK_ID_IB 0x02 | 899 | #define RADEON_CHUNK_ID_IB 0x02 |
877 | #define RADEON_CHUNK_ID_FLAGS 0x03 | 900 | #define RADEON_CHUNK_ID_FLAGS 0x03 |
878 | 901 | ||
879 | /* The first dword of RADEON_CHUNK_ID_FLAGS is a uint32 of these flags: */ | 902 | /* The first dword of RADEON_CHUNK_ID_FLAGS is a uint32 of these flags: */ |
880 | #define RADEON_CS_KEEP_TILING_FLAGS 0x01 | 903 | #define RADEON_CS_KEEP_TILING_FLAGS 0x01 |
904 | #define RADEON_CS_USE_VM 0x02 | ||
905 | /* The second dword of RADEON_CHUNK_ID_FLAGS is a uint32 that sets the ring type */ | ||
906 | #define RADEON_CS_RING_GFX 0 | ||
907 | #define RADEON_CS_RING_COMPUTE 1 | ||
908 | /* The third dword of RADEON_CHUNK_ID_FLAGS is a sint32 that sets the priority */ | ||
909 | /* 0 = normal, + = higher priority, - = lower priority */ | ||
910 | struct drm_radeon_cs_ring_priority { | ||
911 | int32_t priority; | ||
912 | }; | ||
881 | 913 | ||
882 | struct drm_radeon_cs_chunk { | 914 | struct drm_radeon_cs_chunk { |
883 | uint32_t chunk_id; | 915 | uint32_t chunk_id; |
@@ -916,6 +948,10 @@ struct drm_radeon_cs { | |||
916 | #define RADEON_INFO_NUM_TILE_PIPES 0x0b /* tile pipes for r600+ */ | 948 | #define RADEON_INFO_NUM_TILE_PIPES 0x0b /* tile pipes for r600+ */ |
917 | #define RADEON_INFO_FUSION_GART_WORKING 0x0c /* fusion writes to GTT were broken before this */ | 949 | #define RADEON_INFO_FUSION_GART_WORKING 0x0c /* fusion writes to GTT were broken before this */ |
918 | #define RADEON_INFO_BACKEND_MAP 0x0d /* pipe to backend map, needed by mesa */ | 950 | #define RADEON_INFO_BACKEND_MAP 0x0d /* pipe to backend map, needed by mesa */ |
951 | /* virtual address start, va < start are reserved by the kernel */ | ||
952 | #define RADEON_INFO_VA_START 0x0e | ||
953 | /* maximum size of ib using the virtual memory cs */ | ||
954 | #define RADEON_INFO_IB_VM_MAX_SIZE 0x0f | ||
919 | 955 | ||
920 | struct drm_radeon_info { | 956 | struct drm_radeon_info { |
921 | uint32_t request; | 957 | uint32_t request; |