Preventing zero GPU virtual address allocation

Song, Ruiling
2015-03-05T02:56:52Z

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

Hi Daniel,

OpenCL language support NULL pointer, using zero as the NULL pointer is the obvious way. That is zero will be treated as invalid address.
Then it requires drm won't allocate zero to drm buffer. And David in CC list has help us make a patch, please see attached. The logic is only for
ppgtt, and he said zero offset is used under ggtt. My question is what is offset zero used under ggtt? Will it make sure zero is not allocatable to drm buffer object?

Ruiling

[-- Attachment #2: nozerooffset2.patch --]
[-- Type: application/octet-stream, Size: 583 bytes --]

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 996f60fae212..72657aa40319 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3530,6 +3530,12 @@ i915_gem_object_bind_to_vm(struct drm_i915_gem_object *obj,
struct i915_vma *vma;
int ret;

+ /* We reserve address 0 when using ppgtt,
+ * since it's used by opencl as the NULL pointer
+ */
+ if (start == 0 && !i915_is_ggtt(vm))
+ start = 1;
+
fence_size = i915_gem_get_gtt_size(dev,
obj->base.size,
obj->tiling_mode);

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]

_______________________________________________
Beignet mailing list
Beignet@lists.freedesktop.org