drm/i915: Round up object allocations
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/5 drm/i915: Round up object allocations
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_gem.c +2 -0
@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask; + size =round_up (size,PAGE_SIZE ); + obj =i915_gem_object_alloc (dev);if (obj ==NULL )return NULL ;
Signature · 1 line
1.8.5.3
Quoted 14 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask; + size =round_up (size,PAGE_SIZE ); +
Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a WARN_ON and early return in here.
-Daniel
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +0
-0obj =i915_gem_object_alloc (dev);if (obj ==NULL )return NULL ;Signature · 6 lines
1.8.5.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-Daniel
Why?
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 27 lines · Ben Widawsky
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-Daniel
Quoted 1 line
Why?
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an -EINVAL if libdrm does the right rounding ... -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 28 lines · Daniel Vetter
Quoted 27 lines · Ben Widawsky
Quoted 25 lines · Daniel Vetter
Quoted 14 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask; + size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-Daniel
Quoted 7 lines
Quoted 1 line
Why?
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an
-EINVALif libdrm does the right rounding ...
We already have an -EINVAL guard on our create ioctl(s). -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 31 lines · Chris Wilson
Quoted 30 lines · Daniel Vetter
Quoted 28 lines · Ben Widawsky
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-DanielWhy?
Quoted 7 lines
Quoted 5 lines
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an
-EINVALif libdrm does the right rounding ...We already have an
-EINVALguard on our create ioctl(s).
Only for size == 0, not for non-aligned size, at least afaics (no coffee yet ...).
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 38 lines · Daniel Vetter
Quoted 37 lines · Chris Wilson
Quoted 35 lines · Daniel Vetter
Quoted 27 lines · Ben Widawsky
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-DanielQuoted 1 line
Why?
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an
-EINVALif libdrm does the right rounding ...
Quoted 4 lines
Quoted 1 line
We already have an
-EINVALguard on our create ioctl(s).Only for size == 0, not for non-aligned size, at least afaics (no coffee yet ...).
The lack of caffeine was mine. I say if (blah(PAGE_SIZE)) return -EINVAL and was happy.
But as it happens it still implies that the BUG_ON in drm/drm_gem.c is relevant as is and we shouldn't be papering over it.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 44 lines · Chris Wilson
Quoted 38 lines · Daniel Vetter
Quoted 37 lines · Chris Wilson
Quoted 35 lines · Daniel Vetter
Quoted 27 lines · Ben Widawsky
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-DanielQuoted 1 line
Why?
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an
-EINVALif libdrm does the right rounding ...Quoted 4 lines
Quoted 1 line
We already have an
-EINVALguard on our create ioctl(s).Only for size == 0, not for non-aligned size, at least afaics (no coffee yet ...).
Quoted 7 lines
The lack of caffeine was mine. I say if (
blah(PAGE_SIZE)) return-EINVALand was happy.But as it happens it still implies that the
BUG_ONindrm/drm_gem.cis relevant as is and we shouldn't be papering over it.
-Chris
I was referring to internal, driver callers. If all internal callers round up, we may as well do it for them. If the earlier assertion is that we block bad sizes already at the IOCTL hanlder... then what's the problem again?
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 53 lines · Ben Widawsky
Quoted 44 lines · Chris Wilson
Quoted 38 lines · Daniel Vetter
Quoted 37 lines · Chris Wilson
Quoted 35 lines · Daniel Vetter
Quoted 27 lines · Ben Widawsky
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-DanielQuoted 1 line
Why?
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an
-EINVALif libdrm does the right rounding ...Quoted 4 lines
Quoted 1 line
We already have an
-EINVALguard on our create ioctl(s).Only for size == 0, not for non-aligned size, at least afaics (no coffee yet ...).
Quoted 7 lines
The lack of caffeine was mine. I say if (
blah(PAGE_SIZE)) return-EINVALand was happy.But as it happens it still implies that the
BUG_ONindrm/drm_gem.cis relevant as is and we shouldn't be papering over it.
-Chris
Quoted 4 lines
I was referring to internal, driver callers. If all internal callers round up, we may as well do it for them. If the earlier assertion is that we block bad sizes already at the IOCTL hanlder... then what's the problem again?
create2_ioctl should imo reject non-page-aligned requests. I guess we could dig through libdrm history and check whether that's also possible for the current create ioctl.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 53 lines · Ben Widawsky
Quoted 44 lines · Chris Wilson
Quoted 38 lines · Daniel Vetter
Quoted 37 lines · Chris Wilson
Quoted 35 lines · Daniel Vetter
Quoted 27 lines · Ben Widawsky
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Ben Widawsky
DRM gets very mad when you request an object which occupies a partial page. As a DRM driver, i915 never really wants to anger DRM, and would always just want the rounding done for us.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/i915/i915_gem.c +0
-0@@ -4168,6 +4168,8 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,struct address_space *mapping;gfp_t mask;Quoted 7 lines
drivers/gpu/drm/i915/i915_gem.c struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, · line 4172
Quoted 2 lines
drivers/gpu/drm/i915/i915_gem.c +2
-0+ size =round_up (size,PAGE_SIZE ); +Nope, if there's some code that doesn't do page-aligend bo allocations it needs to be fixed there. If you want throw a
WARN_ONand early return in here.
-DanielQuoted 1 line
Why?
Because allocating a non-page aligned gem bo is a bug. All current in-kernel allocations are already aligned. I've thought that we also reject unaligned request from userspace but apparently we help out since forever (i.e. gem was merged). Might be worth a shot to turn that into an
-EINVALif libdrm does the right rounding ...Quoted 4 lines
Quoted 1 line
We already have an
-EINVALguard on our create ioctl(s).Only for size == 0, not for non-aligned size, at least afaics (no coffee yet ...).
Quoted 7 lines
The lack of caffeine was mine. I say if (
blah(PAGE_SIZE)) return-EINVALand was happy.But as it happens it still implies that the
BUG_ONindrm/drm_gem.cis relevant as is and we shouldn't be papering over it.
-Chris
Quoted 4 lines
I was referring to internal, driver callers. If all internal callers round up, we may as well do it for them. If the earlier assertion is that we block bad sizes already at the IOCTL hanlder... then what's the problem again?
You are suggesting we write:
size = PAGE_ALIGN(size);
BUG_ON(size & ~PAGE_MASK);
If you want to change something remove the BUG_ON, do the rounding and update all callers to not worry about page alignment. Tell me how many call sites require alteration? It seems to be an almost universal assumption that the size is page-aligned (despite my own attempts to get subpage allocations into the ABI).
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre