diff options
| author | Dave Airlie <airlied@redhat.com> | 2014-08-25 19:05:14 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2014-08-25 19:05:14 -0400 |
| commit | 484048db6b4890bc433aac7f5e32fdcf1b2b4786 (patch) | |
| tree | c6be2f9cbe71d6732975c987e1c814c0298b0b65 | |
| parent | d5a0f2e7be20d29c5a23fdbc65c1f8307690413c (diff) | |
| parent | bd645e4314b95b21146aa6ff893d783de20c4e60 (diff) | |
Merge branch 'drm-next-3.18' of git://people.freedesktop.org/~agd5f/linux into drm-next
radeon userptr support.
* 'drm-next-3.18' of git://people.freedesktop.org/~agd5f/linux:
drm/radeon: allow userptr write access under certain conditions
drm/radeon: add userptr flag to register MMU notifier v3
drm/radeon: add userptr flag to directly validate the BO to GTT
drm/radeon: add userptr flag to limit it to anonymous memory v2
drm/radeon: add userptr support v8
Conflicts:
drivers/gpu/drm/radeon/radeon_prime.c
| -rw-r--r-- | drivers/gpu/drm/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/Makefile | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 18 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_cs.c | 25 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_device.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_drv.c | 5 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_gem.c | 97 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_kms.c | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_mn.c | 272 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_prime.c | 10 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 155 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_vm.c | 3 | ||||
| -rw-r--r-- | include/uapi/drm/radeon_drm.h | 19 |
14 files changed, 610 insertions, 4 deletions
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index e251ecce4ed2..e3500f9584ec 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig | |||
| @@ -116,6 +116,7 @@ config DRM_RADEON | |||
| 116 | select HWMON | 116 | select HWMON |
| 117 | select BACKLIGHT_CLASS_DEVICE | 117 | select BACKLIGHT_CLASS_DEVICE |
| 118 | select INTERVAL_TREE | 118 | select INTERVAL_TREE |
| 119 | select MMU_NOTIFIER | ||
| 119 | help | 120 | help |
| 120 | Choose this option if you have an ATI Radeon graphics card. There | 121 | Choose this option if you have an ATI Radeon graphics card. There |
| 121 | are both PCI and AGP versions. You don't need to choose this to | 122 | are both PCI and AGP versions. You don't need to choose this to |
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile index f77b7135ee4c..357f09afd222 100644 --- a/drivers/gpu/drm/radeon/Makefile +++ b/drivers/gpu/drm/radeon/Makefile | |||
| @@ -80,7 +80,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \ | |||
| 80 | r600_dpm.o rs780_dpm.o rv6xx_dpm.o rv770_dpm.o rv730_dpm.o rv740_dpm.o \ | 80 | r600_dpm.o rs780_dpm.o rv6xx_dpm.o rv770_dpm.o rv730_dpm.o rv740_dpm.o \ |
| 81 | rv770_smc.o cypress_dpm.o btc_dpm.o sumo_dpm.o sumo_smc.o trinity_dpm.o \ | 81 | rv770_smc.o cypress_dpm.o btc_dpm.o sumo_dpm.o sumo_smc.o trinity_dpm.o \ |
| 82 | trinity_smc.o ni_dpm.o si_smc.o si_dpm.o kv_smc.o kv_dpm.o ci_smc.o \ | 82 | trinity_smc.o ni_dpm.o si_smc.o si_dpm.o kv_smc.o kv_dpm.o ci_smc.o \ |
| 83 | ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o | 83 | ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o radeon_mn.o |
| 84 | 84 | ||
| 85 | # add async DMA block | 85 | # add async DMA block |
| 86 | radeon-y += \ | 86 | radeon-y += \ |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index b281886f6f51..b321ad4dcafd 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
| @@ -65,6 +65,7 @@ | |||
| 65 | #include <linux/list.h> | 65 | #include <linux/list.h> |
| 66 | #include <linux/kref.h> | 66 | #include <linux/kref.h> |
| 67 | #include <linux/interval_tree.h> | 67 | #include <linux/interval_tree.h> |
| 68 | #include <linux/hashtable.h> | ||
| 68 | 69 | ||
| 69 | #include <ttm/ttm_bo_api.h> | 70 | #include <ttm/ttm_bo_api.h> |
| 70 | #include <ttm/ttm_bo_driver.h> | 71 | #include <ttm/ttm_bo_driver.h> |
| @@ -488,6 +489,9 @@ struct radeon_bo { | |||
| 488 | 489 | ||
| 489 | struct ttm_bo_kmap_obj dma_buf_vmap; | 490 | struct ttm_bo_kmap_obj dma_buf_vmap; |
| 490 | pid_t pid; | 491 | pid_t pid; |
| 492 | |||
| 493 | struct radeon_mn *mn; | ||
| 494 | struct interval_tree_node mn_it; | ||
| 491 | }; | 495 | }; |
| 492 | #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base) | 496 | #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base) |
| 493 | 497 | ||
| @@ -1728,6 +1732,11 @@ void radeon_test_ring_sync(struct radeon_device *rdev, | |||
| 1728 | struct radeon_ring *cpB); | 1732 | struct radeon_ring *cpB); |
| 1729 | void radeon_test_syncing(struct radeon_device *rdev); | 1733 | void radeon_test_syncing(struct radeon_device *rdev); |
| 1730 | 1734 | ||
| 1735 | /* | ||
| 1736 | * MMU Notifier | ||
| 1737 | */ | ||
| 1738 | int radeon_mn_register(struct radeon_bo *bo, unsigned long addr); | ||
| 1739 | void radeon_mn_unregister(struct radeon_bo *bo); | ||
| 1731 | 1740 | ||
| 1732 | /* | 1741 | /* |
| 1733 | * Debugfs | 1742 | * Debugfs |
| @@ -2141,6 +2150,8 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data, | |||
| 2141 | struct drm_file *filp); | 2150 | struct drm_file *filp); |
| 2142 | int radeon_gem_create_ioctl(struct drm_device *dev, void *data, | 2151 | int radeon_gem_create_ioctl(struct drm_device *dev, void *data, |
| 2143 | struct drm_file *filp); | 2152 | struct drm_file *filp); |
| 2153 | int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data, | ||
| 2154 | struct drm_file *filp); | ||
| 2144 | int radeon_gem_pin_ioctl(struct drm_device *dev, void *data, | 2155 | int radeon_gem_pin_ioctl(struct drm_device *dev, void *data, |
| 2145 | struct drm_file *file_priv); | 2156 | struct drm_file *file_priv); |
| 2146 | int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data, | 2157 | int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data, |
| @@ -2373,6 +2384,9 @@ struct radeon_device { | |||
| 2373 | /* tracking pinned memory */ | 2384 | /* tracking pinned memory */ |
| 2374 | u64 vram_pin_size; | 2385 | u64 vram_pin_size; |
| 2375 | u64 gart_pin_size; | 2386 | u64 gart_pin_size; |
| 2387 | |||
| 2388 | struct mutex mn_lock; | ||
| 2389 | DECLARE_HASHTABLE(mn_hash, 7); | ||
| 2376 | }; | 2390 | }; |
| 2377 | 2391 | ||
| 2378 | bool radeon_is_px(struct drm_device *dev); | 2392 | bool radeon_is_px(struct drm_device *dev); |
| @@ -2874,6 +2888,10 @@ extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enabl | |||
| 2874 | extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable); | 2888 | extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable); |
| 2875 | extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain); | 2889 | extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain); |
| 2876 | extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo); | 2890 | extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo); |
| 2891 | extern int radeon_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr, | ||
| 2892 | uint32_t flags); | ||
| 2893 | extern bool radeon_ttm_tt_has_userptr(struct ttm_tt *ttm); | ||
| 2894 | extern bool radeon_ttm_tt_is_readonly(struct ttm_tt *ttm); | ||
| 2877 | extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base); | 2895 | extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base); |
| 2878 | extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); | 2896 | extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
| 2879 | extern int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon); | 2897 | extern int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon); |
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 83f382e8e40e..0669399efcea 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
| @@ -78,7 +78,8 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) | |||
| 78 | struct radeon_cs_chunk *chunk; | 78 | struct radeon_cs_chunk *chunk; |
| 79 | struct radeon_cs_buckets buckets; | 79 | struct radeon_cs_buckets buckets; |
| 80 | unsigned i, j; | 80 | unsigned i, j; |
| 81 | bool duplicate; | 81 | bool duplicate, need_mmap_lock = false; |
| 82 | int r; | ||
| 82 | 83 | ||
| 83 | if (p->chunk_relocs_idx == -1) { | 84 | if (p->chunk_relocs_idx == -1) { |
| 84 | return 0; | 85 | return 0; |
| @@ -165,6 +166,19 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) | |||
| 165 | p->relocs[i].allowed_domains = domain; | 166 | p->relocs[i].allowed_domains = domain; |
| 166 | } | 167 | } |
| 167 | 168 | ||
| 169 | if (radeon_ttm_tt_has_userptr(p->relocs[i].robj->tbo.ttm)) { | ||
| 170 | uint32_t domain = p->relocs[i].prefered_domains; | ||
| 171 | if (!(domain & RADEON_GEM_DOMAIN_GTT)) { | ||
| 172 | DRM_ERROR("Only RADEON_GEM_DOMAIN_GTT is " | ||
| 173 | "allowed for userptr BOs\n"); | ||
| 174 | return -EINVAL; | ||
| 175 | } | ||
| 176 | need_mmap_lock = true; | ||
| 177 | domain = RADEON_GEM_DOMAIN_GTT; | ||
| 178 | p->relocs[i].prefered_domains = domain; | ||
| 179 | p->relocs[i].allowed_domains = domain; | ||
| 180 | } | ||
| 181 | |||
| 168 | p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; | 182 | p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; |
| 169 | p->relocs[i].handle = r->handle; | 183 | p->relocs[i].handle = r->handle; |
| 170 | 184 | ||
| @@ -177,8 +191,15 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) | |||
| 177 | if (p->cs_flags & RADEON_CS_USE_VM) | 191 | if (p->cs_flags & RADEON_CS_USE_VM) |
| 178 | p->vm_bos = radeon_vm_get_bos(p->rdev, p->ib.vm, | 192 | p->vm_bos = radeon_vm_get_bos(p->rdev, p->ib.vm, |
| 179 | &p->validated); | 193 | &p->validated); |
| 194 | if (need_mmap_lock) | ||
| 195 | down_read(¤t->mm->mmap_sem); | ||
| 196 | |||
| 197 | r = radeon_bo_list_validate(p->rdev, &p->ticket, &p->validated, p->ring); | ||
| 180 | 198 | ||
| 181 | return radeon_bo_list_validate(p->rdev, &p->ticket, &p->validated, p->ring); | 199 | if (need_mmap_lock) |
| 200 | up_read(¤t->mm->mmap_sem); | ||
| 201 | |||
| 202 | return r; | ||
| 182 | } | 203 | } |
| 183 | 204 | ||
| 184 | static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority) | 205 | static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority) |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 6a219bcee66d..a5d202a7c0a4 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
