diff mbox series

[07/11] drm/i915/gem: Try allocating va from free space

Message ID 20200331213108.11340-7-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [01/11] drm/i915/gem: Ignore readonly failures when updating relocs | expand

Commit Message

Chris Wilson March 31, 2020, 9:31 p.m. UTC
If the current node/entry location is occupied, and the object is not
pinned, try assigning it some free space. We cannot wait here, so if in
doubt, we unreserve and try to grab all at once.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Matthew Auld April 1, 2020, 6:20 p.m. UTC | #1
On Tue, 31 Mar 2020 at 22:31, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> If the current node/entry location is occupied, and the object is not
> pinned, try assigning it some free space. We cannot wait here, so if in
> doubt, we unreserve and try to grab all at once.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index bc8aa9604787..d8c746108d85 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -446,8 +446,17 @@ eb_pin_vma(struct i915_execbuffer *eb,
>         if (unlikely(ev->flags & EXEC_OBJECT_NEEDS_GTT))
>                 pin_flags |= PIN_GLOBAL;
>
> -       if (unlikely(i915_vma_pin(vma, 0, 0, pin_flags)))
> -               return false;
> +       if (unlikely(i915_vma_pin(vma, 0, 0, pin_flags))) {
> +               if (entry->flags & EXEC_OBJECT_PINNED)
> +                       return false;
> +
> +               pin_flags &= ~PIN_OFFSET_FIXED;
> +               if (unlikely(i915_vma_pin(vma,
> +                                         entry->pad_to_size,
> +                                         entry->alignment,
> +                                         pin_flags)))

Just curious, why not just apply the rest of the flags here(MAP, 48B,
BIAS etc) which saves us from having to bind/unbind/bind if it's
trivially misplaced?

Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Chris Wilson April 1, 2020, 6:30 p.m. UTC | #2
Quoting Matthew Auld (2020-04-01 19:20:56)
> On Tue, 31 Mar 2020 at 22:31, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >
> > If the current node/entry location is occupied, and the object is not
> > pinned, try assigning it some free space. We cannot wait here, so if in
> > doubt, we unreserve and try to grab all at once.
> >
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> > index bc8aa9604787..d8c746108d85 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> > @@ -446,8 +446,17 @@ eb_pin_vma(struct i915_execbuffer *eb,
> >         if (unlikely(ev->flags & EXEC_OBJECT_NEEDS_GTT))
> >                 pin_flags |= PIN_GLOBAL;
> >
> > -       if (unlikely(i915_vma_pin(vma, 0, 0, pin_flags)))
> > -               return false;
> > +       if (unlikely(i915_vma_pin(vma, 0, 0, pin_flags))) {
> > +               if (entry->flags & EXEC_OBJECT_PINNED)
> > +                       return false;
> > +
> > +               pin_flags &= ~PIN_OFFSET_FIXED;
> > +               if (unlikely(i915_vma_pin(vma,
> > +                                         entry->pad_to_size,
> > +                                         entry->alignment,
> > +                                         pin_flags)))
> 
> Just curious, why not just apply the rest of the flags here(MAP, 48B,
> BIAS etc) which saves us from having to bind/unbind/bind if it's
> trivially misplaced?

That required actually doing some work to refactor the flag selection!
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index bc8aa9604787..d8c746108d85 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -446,8 +446,17 @@  eb_pin_vma(struct i915_execbuffer *eb,
 	if (unlikely(ev->flags & EXEC_OBJECT_NEEDS_GTT))
 		pin_flags |= PIN_GLOBAL;
 
-	if (unlikely(i915_vma_pin(vma, 0, 0, pin_flags)))
-		return false;
+	if (unlikely(i915_vma_pin(vma, 0, 0, pin_flags))) {
+		if (entry->flags & EXEC_OBJECT_PINNED)
+			return false;
+
+		pin_flags &= ~PIN_OFFSET_FIXED;
+		if (unlikely(i915_vma_pin(vma,
+					  entry->pad_to_size,
+					  entry->alignment,
+					  pin_flags)))
+			return false;
+	}
 
 	if (unlikely(ev->flags & EXEC_OBJECT_NEEDS_FENCE)) {
 		if (unlikely(i915_vma_pin_fence(vma))) {