aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-07-20 07:40:59 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-07-25 12:23:51 -0400
commit3bb73aba1ed5198a2c1dfaac4f3c95459930d84a (patch)
treecda853891463b2df4e440775a7faf415a143395c
parent540a8950047579a368a9b8fdcc15ab7fdb9921d3 (diff)
drm/i915: Allow late allocation of request for i915_add_request()
Request preallocation was added to i915_add_request() in order to support the overlay. However, not all users care and can quite happily ignore the failure to allocate the request as they will simply repeat the request in the future. By pushing the allocation down into i915_add_request(), we can then remove some rather ugly error handling in the callers. v2: Nullify request->file_priv otherwise we chase a garbage pointer when retiring requests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h6
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c44
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c7
3 files changed, 21 insertions, 36 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2c0d8403c5ed..1f5f5ff6f897 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1358,9 +1358,9 @@ void i915_gem_init_ppgtt(struct drm_device *dev);
1358void i915_gem_cleanup_ringbuffer(struct drm_device *dev); 1358void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
1359int __must_check i915_gpu_idle(struct drm_device *dev); 1359int __must_check i915_gpu_idle(struct drm_device *dev);
1360int __must_check i915_gem_idle(struct drm_device *dev); 1360int __must_check i915_gem_idle(struct drm_device *dev);
1361int __must_check i915_add_request(struct intel_ring_buffer *ring, 1361int i915_add_request(struct intel_ring_buffer *ring,
1362 struct drm_file *file, 1362 struct drm_file *file,
1363 struct drm_i915_gem_request *request); 1363 struct drm_i915_gem_request *request);
1364int __must_check i915_wait_seqno(struct intel_ring_buffer *ring, 1364int __must_check i915_wait_seqno(struct intel_ring_buffer *ring,
1365 uint32_t seqno); 1365 uint32_t seqno);
1366int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 1366int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4be096068b35..771b8ba36e44 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1597,7 +1597,12 @@ i915_add_request(struct intel_ring_buffer *ring,
1597 ring->gpu_caches_dirty = false; 1597 ring->gpu_caches_dirty = false;
1598 } 1598 }
1599 1599
1600 BUG_ON(request == NULL); 1600 if (request == NULL) {
1601 request = kmalloc(sizeof(*request), GFP_KERNEL);
1602 if (request == NULL)
1603 return -ENOMEM;
1604 }
1605
1601 seqno = i915_gem_next_request_seqno(ring); 1606 seqno = i915_gem_next_request_seqno(ring);
1602 1607
1603 /* Record the position of the start of the request so that 1608 /* Record the position of the start of the request so that
@@ -1608,8 +1613,10 @@ i915_add_request(struct intel_ring_buffer *ring,
1608 request_ring_position = intel_ring_get_tail(ring); 1613 request_ring_position = intel_ring_get_tail(ring);
1609 1614
1610 ret = ring->add_request(ring, &seqno); 1615 ret = ring->add_request(ring, &seqno);
1611 if (ret) 1616 if (ret) {
1612 return ret; 1617 kfree(request);
1618 return ret;
1619 }
1613 1620
1614 trace_i915_gem_request_add(ring, seqno); 1621 trace_i915_gem_request_add(ring, seqno);
1615 1622
@@ -1619,6 +1626,7 @@ i915_add_request(struct intel_ring_buffer *ring,
1619 request->emitted_jiffies = jiffies; 1626 request->emitted_jiffies = jiffies;
1620 was_empty = list_empty(&ring->request_list); 1627 was_empty = list_empty(&ring->request_list);
1621 list_add_tail(&request->list, &ring->request_list); 1628 list_add_tail(&request->list, &ring->request_list);
1629 request->file_priv = NULL;
1622 1630
1623 if (file) { 1631 if (file) {
1624 struct drm_i915_file_private *file_priv = file->driver_priv; 1632 struct drm_i915_file_private *file_priv = file->driver_priv;
@@ -1859,14 +1867,8 @@ i915_gem_retire_work_handler(struct work_struct *work)
1859 */ 1867 */
1860 idle = true; 1868 idle = true;
1861 for_each_ring(ring, dev_priv, i) { 1869 for_each_ring(ring, dev_priv, i) {
1862 if (ring->gpu_caches_dirty) { 1870 if (ring->gpu_caches_dirty)
1863 struct drm_i915_gem_request *request; 1871 i915_add_request(ring, NULL, NULL);
1864
1865 request = kzalloc(sizeof(*request), GFP_KERNEL);
1866 if (request == NULL ||
1867 i915_add_request(ring, NULL, request))
1868 kfree(request);
1869 }
1870 1872
1871 idle &= list_empty(&ring->request_list); 1873 idle &= list_empty(&ring->request_list);
1872 } 1874 }
@@ -1913,25 +1915,13 @@ i915_gem_check_wedge(struct drm_i915_private *dev_priv,
1913static int 1915static int
1914i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno) 1916i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno)
1915{ 1917{
1916 int ret = 0; 1918 int ret;
1917 1919
1918 BUG_ON(!mutex_is_locked(&ring->dev->struct_mutex)); 1920 BUG_ON(!mutex_is_locked(&ring->dev->struct_mutex));
1919 1921
1920 if (seqno == ring->outstanding_lazy_request) { 1922 ret = 0;
1921 struct drm_i915_gem_request *request; 1923 if (seqno == ring->outstanding_lazy_request)
1922 1924 ret = i915_add_request(ring, NULL, NULL);
1923 request = kzalloc(sizeof(*request), GFP_KERNEL);
1924 if (request == NULL)
1925 return -ENOMEM;
1926
1927 ret = i915_add_request(ring, NULL, request);
1928 if (ret) {
1929 kfree(request);
1930 return ret;
1931 }
1932
1933 BUG_ON(seqno != request->seqno);
1934 }
1935 1925
1936 return ret; 1926 return ret;
1937} 1927}
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 5af631e788c8..f94ec574db2b 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -972,16 +972,11 @@ i915_gem_execbuffer_retire_commands(struct drm_device *dev,
972 struct drm_file *file, 972 struct drm_file *file,
973 struct intel_ring_buffer *ring) 973 struct intel_ring_buffer *ring)
974{ 974{
975 struct drm_i915_gem_request *request;
976
977 /* Unconditionally force add_request to emit a full flush. */ 975 /* Unconditionally force add_request to emit a full flush. */
978 ring->gpu_caches_dirty = true; 976 ring->gpu_caches_dirty = true;
979 977
980 /* Add a breadcrumb for the completion of the batch buffer */ 978 /* Add a breadcrumb for the completion of the batch buffer */
981 request = kzalloc(sizeof(*request), GFP_KERNEL); 979 (void)i915_add_request(ring, file, NULL);
982 if (request == NULL || i915_add_request(ring, file, request)) {
983 kfree(request);
984 }
985} 980}
986 981
987static int 982static int