aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-01-15 11:51:46 -0500
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2016-01-21 06:00:35 -0500
commit426960bed3217f72a1b7bb94f084d79cc616ec0f (patch)
treef26fb2afc54529609c28397c43fdc1207fb33907 /drivers/gpu/drm
parentde1add360522c876c25ef2bbbbab1c94bdb509ab (diff)
drm/i915: Seal busy-ioctl uABI and prevent leaking of internal ids
Tvrtko was looking through the execbuffer-ioctl and noticed that the uABI was tightly coupled to our internal engine identifiers. Close inspection also revealed that we leak those internal engine identifiers through the busy-ioctl, and those internal identifiers already do not match the user identifiers. Fortuitiously, there is only one user of the set of busy rings from the busy-ioctl, and they only wish to choose between the RENDER and the BLT engines. Let's fix the userspace ABI while we still can. v2: Update the uAPI documentation to explain the identifiers. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Testcase: igt/gem_busy Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1452876706-21620-1-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c18
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c5
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c5
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h1
4 files changed, 25 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 0ed731ed6976..371bbb28c471 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4358,10 +4358,20 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
4358 if (ret) 4358 if (ret)
4359 goto unref; 4359 goto unref;
4360 4360
4361 BUILD_BUG_ON(I915_NUM_RINGS > 16); 4361 args->busy = 0;
4362 args->busy = obj->active << 16; 4362 if (obj->active) {
4363 if (obj->last_write_req) 4363 int i;
4364 args->busy |= obj->last_write_req->ring->id; 4364
4365 for (i = 0; i < I915_NUM_RINGS; i++) {
4366 struct drm_i915_gem_request *req;
4367
4368 req = obj->last_read_req[i];
4369 if (req)
4370 args->busy |= 1 << (16 + req->ring->exec_id);
4371 }
4372 if (obj->last_write_req)
4373 args->busy |= obj->last_write_req->ring->exec_id;
4374 }
4365 4375
4366unref: 4376unref:
4367 drm_gem_object_unreference(&obj->base); 4377 drm_gem_object_unreference(&obj->base);
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 7f47948d5c40..73d4347429df 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2085,6 +2085,7 @@ static int logical_render_ring_init(struct drm_device *dev)
2085 2085
2086 ring->name = "render ring"; 2086 ring->name = "render ring";
2087 ring->id = RCS; 2087 ring->id = RCS;
2088 ring->exec_id = I915_EXEC_RENDER;
2088 ring->mmio_base = RENDER_RING_BASE; 2089 ring->mmio_base = RENDER_RING_BASE;
2089 2090
2090 logical_ring_default_irqs(ring, GEN8_RCS_IRQ_SHIFT); 2091 logical_ring_default_irqs(ring, GEN8_RCS_IRQ_SHIFT);
@@ -2135,6 +2136,7 @@ static int logical_bsd_ring_init(struct drm_device *dev)
2135 2136
2136 ring->name = "bsd ring"; 2137 ring->name = "bsd ring";
2137 ring->id = VCS; 2138 ring->id = VCS;
2139 ring->exec_id = I915_EXEC_BSD;
2138 ring->mmio_base = GEN6_BSD_RING_BASE; 2140 ring->mmio_base = GEN6_BSD_RING_BASE;
2139 2141
2140 logical_ring_default_irqs(ring, GEN8_VCS1_IRQ_SHIFT); 2142 logical_ring_default_irqs(ring, GEN8_VCS1_IRQ_SHIFT);
@@ -2150,6 +2152,7 @@ static int logical_bsd2_ring_init(struct drm_device *dev)
2150 2152
2151 ring->name = "bsd2 ring"; 2153 ring->name = "bsd2 ring";
2152 ring->id = VCS2; 2154 ring->id = VCS2;
2155 ring->exec_id = I915_EXEC_BSD;
2153 ring->mmio_base = GEN8_BSD2_RING_BASE; 2156 ring->mmio_base = GEN8_BSD2_RING_BASE;
2154 2157
2155 logical_ring_default_irqs(ring, GEN8_VCS2_IRQ_SHIFT); 2158 logical_ring_default_irqs(ring, GEN8_VCS2_IRQ_SHIFT);
@@ -2165,6 +2168,7 @@ static int logical_blt_ring_init(struct drm_device *dev)
2165 2168
2166 ring->name = "blitter ring"; 2169 ring->name = "blitter ring";
2167 ring->id = BCS; 2170 ring->id = BCS;
2171 ring->exec_id = I915_EXEC_BLT;
2168 ring->mmio_base = BLT_RING_BASE; 2172 ring->mmio_base = BLT_RING_BASE;
2169 2173
2170 logical_ring_default_irqs(ring, GEN8_BCS_IRQ_SHIFT); 2174 logical_ring_default_irqs(ring, GEN8_BCS_IRQ_SHIFT);
@@ -2180,6 +2184,7 @@ static int logical_vebox_ring_init(struct drm_device *dev)
2180 2184
2181 ring->name = "video enhancement ring"; 2185 ring->name = "video enhancement ring";
2182 ring->id = VECS; 2186 ring->id = VECS;
2187 ring->exec_id = I915_EXEC_VEBOX;
2183 ring->mmio_base = VEBOX_RING_BASE; 2188 ring->mmio_base = VEBOX_RING_BASE;
2184 2189
2185 logical_ring_default_irqs(ring, GEN8_VECS_IRQ_SHIFT); 2190 logical_ring_default_irqs(ring, GEN8_VECS_IRQ_SHIFT);
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index d4e33ac02efa..9030e2bca0c0 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2683,6 +2683,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
2683 2683
2684 ring->name = "render ring"; 2684 ring->name = "render ring";
2685 ring->id = RCS; 2685 ring->id = RCS;
2686 ring->exec_id = I915_EXEC_RENDER;
2686 ring->mmio_base = RENDER_RING_BASE; 2687 ring->mmio_base = RENDER_RING_BASE;
2687 2688
2688 if (INTEL_INFO(dev)->gen >= 8) { 2689 if (INTEL_INFO(dev)->gen >= 8) {
@@ -2831,6 +2832,7 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
2831 2832
2832 ring->name = "bsd ring"; 2833 ring->name = "bsd ring";
2833 ring->id = VCS; 2834 ring->id = VCS;
2835 ring->exec_id = I915_EXEC_BSD;
2834 2836
2835 ring->write_tail = ring_write_tail; 2837 ring->write_tail = ring_write_tail;
2836 if (INTEL_INFO(dev)->gen >= 6) { 2838 if (INTEL_INFO(dev)->gen >= 6) {
@@ -2907,6 +2909,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
2907 2909
2908 ring->name = "bsd2 ring"; 2910 ring->name = "bsd2 ring";
2909 ring->id = VCS2; 2911 ring->id = VCS2;
2912 ring->exec_id = I915_EXEC_BSD;
2910 2913
2911 ring->write_tail = ring_write_tail; 2914 ring->write_tail = ring_write_tail;
2912 ring->mmio_base = GEN8_BSD2_RING_BASE; 2915 ring->mmio_base = GEN8_BSD2_RING_BASE;
@@ -2937,6 +2940,7 @@ int intel_init_blt_ring_buffer(struct drm_device *dev)
2937 2940
2938 ring->name = "blitter ring"; 2941 ring->name = "blitter ring";
2939 ring->id = BCS; 2942 ring->id = BCS;
2943 ring->exec_id = I915_EXEC_BLT;
2940 2944
2941 ring->mmio_base = BLT_RING_BASE; 2945 ring->mmio_base = BLT_RING_BASE;
2942 ring->write_tail = ring_write_tail; 2946 ring->write_tail = ring_write_tail;
@@ -2994,6 +2998,7 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
2994 2998
2995 ring->name = "video enhancement ring"; 2999 ring->name = "video enhancement ring";
2996 ring->id = VECS; 3000 ring->id = VECS;
3001 ring->exec_id = I915_EXEC_VEBOX;
2997 3002
2998 ring->mmio_base = VEBOX_RING_BASE; 3003 ring->mmio_base = VEBOX_RING_BASE;
2999 ring->write_tail = ring_write_tail; 3004 ring->write_tail = ring_write_tail;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 5b44ca63405d..b12f2aabd104 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -157,6 +157,7 @@ struct intel_engine_cs {
157 } id; 157 } id;
158#define I915_NUM_RINGS 5 158#define I915_NUM_RINGS 5
159#define _VCS(n) (VCS + (n)) 159#define _VCS(n) (VCS + (n))
160 unsigned int exec_id;
160 u32 mmio_base; 161 u32 mmio_base;
161 struct drm_device *dev; 162 struct drm_device *dev;
162 struct intel_ringbuffer *buffer; 163 struct intel_ringbuffer *buffer;