aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_ringbuffer.c
diff options
context:
space:
mode:
authorOscar Mateo <oscar.mateo@intel.com>2014-05-22 09:13:34 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-05-22 17:02:16 -0400
commit8ee149756e4fbaf4462cf3f7377456ec5fff8b63 (patch)
tree13eedaf2b463f0cf21d76cfa559e087ac2fb3647 /drivers/gpu/drm/i915/intel_ringbuffer.c
parenta4872ba6d01454dfeb251d96f623ab5d1b0666a4 (diff)
drm/i915: Split the ringbuffers from the rings (1/3)
As advanced by the previous patch, the ringbuffers and the engine command streamers belong in different structs. This is so because, while they used to be tightly coupled together, the new Logical Ring Contexts (LRC for short) have a ringbuffer each. In legacy code, we will use the buffer* pointer inside each ring to get to the pertaining ringbuffer (the actual switch will be done in the next patch). In the new Execlists code, this pointer will be NULL and we will use instead the one inside the context instead. Signed-off-by: Oscar Mateo <oscar.mateo@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.c')
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 748041aa84df..9b406e424a6f 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1422,8 +1422,16 @@ err_unref:
1422static int intel_init_ring_buffer(struct drm_device *dev, 1422static int intel_init_ring_buffer(struct drm_device *dev,
1423 struct intel_engine_cs *ring) 1423 struct intel_engine_cs *ring)
1424{ 1424{
1425 struct intel_ringbuffer *ringbuf = ring->buffer;
1425 int ret; 1426 int ret;
1426 1427
1428 if (ringbuf == NULL) {
1429 ringbuf = kzalloc(sizeof(*ringbuf), GFP_KERNEL);
1430 if (!ringbuf)
1431 return -ENOMEM;
1432 ring->buffer = ringbuf;
1433 }
1434
1427 ring->dev = dev; 1435 ring->dev = dev;
1428 INIT_LIST_HEAD(&ring->active_list); 1436 INIT_LIST_HEAD(&ring->active_list);
1429 INIT_LIST_HEAD(&ring->request_list); 1437 INIT_LIST_HEAD(&ring->request_list);
@@ -1435,18 +1443,18 @@ static int intel_init_ring_buffer(struct drm_device *dev,
1435 if (I915_NEED_GFX_HWS(dev)) { 1443 if (I915_NEED_GFX_HWS(dev)) {
1436 ret = init_status_page(ring); 1444 ret = init_status_page(ring);
1437 if (ret) 1445 if (ret)
1438 return ret; 1446 goto error;
1439 } else { 1447 } else {
1440 BUG_ON(ring->id != RCS); 1448 BUG_ON(ring->id != RCS);
1441 ret = init_phys_status_page(ring); 1449 ret = init_phys_status_page(ring);
1442 if (ret) 1450 if (ret)
1443 return ret; 1451 goto error;
1444 } 1452 }
1445 1453
1446 ret = allocate_ring_buffer(ring); 1454 ret = allocate_ring_buffer(ring);
1447 if (ret) { 1455 if (ret) {
1448 DRM_ERROR("Failed to allocate ringbuffer %s: %d\n", ring->name, ret); 1456 DRM_ERROR("Failed to allocate ringbuffer %s: %d\n", ring->name, ret);
1449 return ret; 1457 goto error;
1450 } 1458 }
1451 1459
1452 /* Workaround an erratum on the i830 which causes a hang if 1460 /* Workaround an erratum on the i830 which causes a hang if
@@ -1459,9 +1467,18 @@ static int intel_init_ring_buffer(struct drm_device *dev,
1459 1467
1460 ret = i915_cmd_parser_init_ring(ring); 1468 ret = i915_cmd_parser_init_ring(ring);
1461 if (ret) 1469 if (ret)
1462 return ret; 1470 goto error;
1471
1472 ret = ring->init(ring);
1473 if (ret)
1474 goto error;
1475
1476 return 0;
1463 1477
1464 return ring->init(ring); 1478error:
1479 kfree(ringbuf);
1480 ring->buffer = NULL;
1481 return ret;
1465} 1482}
1466 1483
1467void intel_cleanup_ring_buffer(struct intel_engine_cs *ring) 1484void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)
@@ -1488,6 +1505,9 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)
1488 cleanup_status_page(ring); 1505 cleanup_status_page(ring);
1489 1506
1490 i915_cmd_parser_fini_ring(ring); 1507 i915_cmd_parser_fini_ring(ring);
1508
1509 kfree(ring->buffer);
1510 ring->buffer = NULL;
1491} 1511}
1492 1512
1493static int intel_ring_wait_request(struct intel_engine_cs *ring, int n) 1513static int intel_ring_wait_request(struct intel_engine_cs *ring, int n)
@@ -2022,15 +2042,24 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
2022{ 2042{
2023 struct drm_i915_private *dev_priv = dev->dev_private; 2043 struct drm_i915_private *dev_priv = dev->dev_private;
2024 struct intel_engine_cs *ring = &dev_priv->ring[RCS]; 2044 struct intel_engine_cs *ring = &dev_priv->ring[RCS];
2045 struct intel_ringbuffer *ringbuf = ring->buffer;
2025 int ret; 2046 int ret;
2026 2047
2048 if (ringbuf == NULL) {
2049 ringbuf = kzalloc(sizeof(*ringbuf), GFP_KERNEL);
2050 if (!ringbuf)
2051 return -ENOMEM;
2052 ring->buffer = ringbuf;
2053 }
2054
2027 ring->name = "render ring"; 2055 ring->name = "render ring";
2028 ring->id = RCS; 2056 ring->id = RCS;
2029 ring->mmio_base = RENDER_RING_BASE; 2057 ring->mmio_base = RENDER_RING_BASE;
2030 2058
2031 if (INTEL_INFO(dev)->gen >= 6) { 2059 if (INTEL_INFO(dev)->gen >= 6) {
2032 /* non-kms not supported on gen6+ */ 2060 /* non-kms not supported on gen6+ */
2033 return -ENODEV; 2061 ret = -ENODEV;
2062 goto err_ringbuf;
2034 } 2063 }
2035 2064
2036 /* Note: gem is not supported on gen5/ilk without kms (the corresponding 2065 /* Note: gem is not supported on gen5/ilk without kms (the corresponding
@@ -2074,16 +2103,24 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
2074 if (ring->virtual_start == NULL) { 2103 if (ring->virtual_start == NULL) {
2075 DRM_ERROR("can not ioremap virtual address for" 2104 DRM_ERROR("can not ioremap virtual address for"
2076 " ring buffer\n"); 2105 " ring buffer\n");
2077 return -ENOMEM; 2106 ret = -ENOMEM;
2107 goto err_ringbuf;
2078 } 2108 }
2079 2109
2080 if (!I915_NEED_GFX_HWS(dev)) { 2110 if (!I915_NEED_GFX_HWS(dev)) {
2081 ret = init_phys_status_page(ring); 2111 ret = init_phys_status_page(ring);
2082 if (ret) 2112 if (ret)
2083 return ret; 2113 goto err_vstart;
2084 } 2114 }
2085 2115
2086 return 0; 2116 return 0;
2117
2118err_vstart:
2119 iounmap(ring->virtual_start);
2120err_ringbuf:
2121 kfree(ringbuf);
2122 ring->buffer = NULL;
2123 return ret;
2087} 2124}
2088 2125
2089int intel_init_bsd_ring_buffer(struct drm_device *dev) 2126int intel_init_bsd_ring_buffer(struct drm_device *dev)