aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-09-01 09:13:53 -0400
committerAlex Deucher <alexander.deucher@amd.com>2015-10-21 11:35:12 -0400
commit0c418f10104d4aa1d6b83698790898dc9ef1c12d (patch)
tree0fe6d3a53c2a9c8d66636124c29b0085b1c00be1 /drivers/gpu
parentb7e4dad3e1fc5d3909737fb72e57aedeb0072c7f (diff)
drm/amdgpu: remove the exclusive lock
Finally getting rid of it. Signed-off-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_display.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c21
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c7
6 files changed, 8 insertions, 42 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 911d67032d57..39d96088f7b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1955,7 +1955,6 @@ struct amdgpu_device {
1955 struct device *dev; 1955 struct device *dev;
1956 struct drm_device *ddev; 1956 struct drm_device *ddev;
1957 struct pci_dev *pdev; 1957 struct pci_dev *pdev;
1958 struct rw_semaphore exclusive_lock;
1959 1958
1960 /* ASIC */ 1959 /* ASIC */
1961 enum amd_asic_type asic_type; 1960 enum amd_asic_type asic_type;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 25012c790f8f..5fdc0394561e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -831,11 +831,8 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
831 bool reserved_buffers = false; 831 bool reserved_buffers = false;
832 int i, r; 832 int i, r;
833 833
834 down_read(&adev->exclusive_lock); 834 if (!adev->accel_working)
835 if (!adev->accel_working) {
836 up_read(&adev->exclusive_lock);
837 return -EBUSY; 835 return -EBUSY;
838 }
839 836
840 parser = amdgpu_cs_parser_create(adev, filp, NULL, NULL, 0); 837 parser = amdgpu_cs_parser_create(adev, filp, NULL, NULL, 0);
841 if (!parser) 838 if (!parser)
@@ -843,8 +840,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
843 r = amdgpu_cs_parser_init(parser, data); 840 r = amdgpu_cs_parser_init(parser, data);
844 if (r) { 841 if (r) {
845 DRM_ERROR("Failed to initialize parser !\n"); 842 DRM_ERROR("Failed to initialize parser !\n");
846 kfree(parser); 843 amdgpu_cs_parser_fini(parser, r, false);
847 up_read(&adev->exclusive_lock);
848 r = amdgpu_cs_handle_lockup(adev, r); 844 r = amdgpu_cs_handle_lockup(adev, r);
849 return r; 845 return r;
850 } 846 }
@@ -915,14 +911,12 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
915 911
916 mutex_unlock(&job->job_lock); 912 mutex_unlock(&job->job_lock);
917 amdgpu_cs_parser_fini_late(parser); 913 amdgpu_cs_parser_fini_late(parser);
918 up_read(&adev->exclusive_lock);
919 return 0; 914 return 0;
920 } 915 }
921 916
922 cs->out.handle = parser->ibs[parser->num_ibs - 1].sequence; 917 cs->out.handle = parser->ibs[parser->num_ibs - 1].sequence;
923out: 918out:
924 amdgpu_cs_parser_fini(parser, r, reserved_buffers); 919 amdgpu_cs_parser_fini(parser, r, reserved_buffers);
925 up_read(&adev->exclusive_lock);
926 r = amdgpu_cs_handle_lockup(adev, r); 920 r = amdgpu_cs_handle_lockup(adev, r);
927 return r; 921 return r;
928} 922}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 28c9ee334dd7..19e185ec3707 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1418,7 +1418,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
1418 mutex_init(&adev->gfx.gpu_clock_mutex); 1418 mutex_init(&adev->gfx.gpu_clock_mutex);
1419 mutex_init(&adev->srbm_mutex); 1419 mutex_init(&adev->srbm_mutex);
1420 mutex_init(&adev->grbm_idx_mutex); 1420 mutex_init(&adev->grbm_idx_mutex);
1421 init_rwsem(&adev->exclusive_lock);
1422 mutex_init(&adev->mn_lock); 1421 mutex_init(&adev->mn_lock);
1423 hash_init(adev->mn_hash); 1422 hash_init(adev->mn_hash);
1424 1423
@@ -1814,8 +1813,6 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
1814 int i, r; 1813 int i, r;
1815 int resched; 1814 int resched;
1816 1815
1817 down_write(&adev->exclusive_lock);
1818
1819 atomic_inc(&adev->gpu_reset_counter); 1816 atomic_inc(&adev->gpu_reset_counter);
1820 1817
1821 /* block TTM */ 1818 /* block TTM */
@@ -1879,7 +1876,6 @@ retry:
1879 dev_info(adev->dev, "GPU reset failed\n"); 1876 dev_info(adev->dev, "GPU reset failed\n");
1880 } 1877 }
1881 1878
1882 up_write(&adev->exclusive_lock);
1883 return r; 1879 return r;
1884} 1880}
1885 1881
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 9b34a3410c32..fdf7525cf120 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -47,11 +47,8 @@ static void amdgpu_flip_wait_fence(struct amdgpu_device *adev,
47 fence = to_amdgpu_fence(*f); 47 fence = to_amdgpu_fence(*f);
48 if (fence) { 48 if (fence) {
49 r = fence_wait(&fence->base, false); 49 r = fence_wait(&fence->base, false);
50 if (r == -EDEADLK) { 50 if (r == -EDEADLK)
51 up_read(&adev->exclusive_lock);
52 r = amdgpu_gpu_reset(adev); 51 r = amdgpu_gpu_reset(adev);
53 down_read(&adev->exclusive_lock);
54 }
55 } else 52 } else
56 r = fence_wait(*f, false); 53 r = fence_wait(*f, false);
57 54
@@ -77,7 +74,6 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
77 unsigned long flags; 74 unsigned long flags;
78 unsigned i; 75 unsigned i;
79 76
80 down_read(&adev->exclusive_lock);
81 amdgpu_flip_wait_fence(adev, &work->excl); 77 amdgpu_flip_wait_fence(adev, &work->excl);
82 for (i = 0; i < work->shared_count; ++i) 78 for (i = 0; i < work->shared_count; ++i)
83 amdgpu_flip_wait_fence(adev, &work->shared[i]); 79 amdgpu_flip_wait_fence(adev, &work->shared[i]);
@@ -93,7 +89,6 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
93 amdgpuCrtc->pflip_status = AMDGPU_FLIP_SUBMITTED; 89 amdgpuCrtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
94 90
95 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); 91 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
96 up_read(&adev->exclusive_lock);
97} 92}
98 93
99/* 94/*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 4010aa6b4e53..1fadc15e64ae 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -260,16 +260,8 @@ static void amdgpu_fence_check_lockup(struct work_struct *work)
260 lockup_work.work); 260 lockup_work.work);
261 ring = fence_drv->ring; 261 ring = fence_drv->ring;
262 262
263 if (!down_read_trylock(&ring->adev->exclusive_lock)) { 263 if (amdgpu_fence_activity(ring))
264 /* just reschedule the check if a reset is going on */
265 amdgpu_fence_schedule_check(ring);
266 return;
267 }
268
269 if (amdgpu_fence_activity(ring)) {
270 wake_up_all(&ring->fence_drv.fence_queue); 264 wake_up_all(&ring->fence_drv.fence_queue);
271 }
272 up_read(&ring->adev->exclusive_lock);
273} 265}
274 266
275/** 267/**
@@ -317,18 +309,15 @@ static bool amdgpu_fence_is_signaled(struct fence *f)
317{ 309{
318 struct amdgpu_fence *fence = to_amdgpu_fence(f); 310 struct amdgpu_fence *fence = to_amdgpu_fence(f);
319 struct amdgpu_ring *ring = fence->ring; 311 struct amdgpu_ring *ring = fence->ring;
320 struct amdgpu_device *adev = ring->adev;
321 312
322 if (atomic64_read(&ring->fence_drv.last_seq) >= fence->seq) 313 if (atomic64_read(&ring->fence_drv.last_seq) >= fence->seq)
323 return true; 314 return true;
324 315
325 if (down_read_trylock(&adev->exclusive_lock)) { 316 amdgpu_fence_process(ring);
326 amdgpu_fence_process(ring); 317
327 up_read(&adev->exclusive_lock); 318 if (atomic64_read(&ring->fence_drv.last_seq) >= fence->seq)
319 return true;
328 320
329 if (atomic64_read(&ring->fence_drv.last_seq) >= fence->seq)
330 return true;
331 }
332 return false; 321 return false;
333} 322}
334 323
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 7297ca3a0ba7..d81ab785368a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -181,7 +181,6 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
181 bool kernel = false; 181 bool kernel = false;
182 int r; 182 int r;
183 183
184 down_read(&adev->exclusive_lock);
185 /* create a gem object to contain this object in */ 184 /* create a gem object to contain this object in */
186 if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS | 185 if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |
187 AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) { 186 AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {
@@ -214,11 +213,9 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
214 213
215 memset(args, 0, sizeof(*args)); 214 memset(args, 0, sizeof(*args));
216 args->out.handle = handle; 215 args->out.handle = handle;
217 up_read(&adev->exclusive_lock);
218 return 0; 216 return 0;
219 217
220error_unlock: 218error_unlock:
221 up_read(&adev->exclusive_lock);
222 r = amdgpu_gem_handle_lockup(adev, r); 219 r = amdgpu_gem_handle_lockup(adev, r);
223 return r; 220 return r;
224} 221}
@@ -250,8 +247,6 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
250 return -EACCES; 247 return -EACCES;
251 } 248 }
252 249
253 down_read(&adev->exclusive_lock);
254
255 /* create a gem object to contain this object in */ 250 /* create a gem object to contain this object in */
256 r = amdgpu_gem_object_create(adev, args->size, 0, 251 r = amdgpu_gem_object_create(adev, args->size, 0,
257 AMDGPU_GEM_DOMAIN_CPU, 0, 252 AMDGPU_GEM_DOMAIN_CPU, 0,
@@ -293,14 +288,12 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
293 goto handle_lockup; 288 goto handle_lockup;
294 289
295 args->handle = handle; 290 args->handle = handle;
296 up_read(&adev->exclusive_lock);
297 return 0; 291 return 0;
298 292
299release_object: 293release_object:
300 drm_gem_object_unreference_unlocked(gobj); 294 drm_gem_object_unreference_unlocked(gobj);
301 295
302handle_lockup: 296handle_lockup:
303 up_read(&adev->exclusive_lock);
304 r = amdgpu_gem_handle_lockup(adev, r); 297 r = amdgpu_gem_handle_lockup(adev, r);
305 298
306 return r; 299 return r;