diff mbox series

drm/i915: Fix display problems after resume

Message ID 20220912121957.31310-1-thomas.hellstrom@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Fix display problems after resume | expand

Commit Message

Thomas Hellstrom Sept. 12, 2022, 12:19 p.m. UTC
Commit 39a2bd34c933 ("drm/i915: Use the vma resource as argument for gtt
binding / unbinding") introduced a regression that due to the vma resource
tracking of the binding state, dpt ptes were not correctly repopulated.
Fix this by clearing the vma resource state before repopulating.
The state will subsequently be restored by the bind_vma operation.

Fixes: 39a2bd34c933 ("drm/i915: Use the vma resource as argument for gtt binding / unbinding")
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_ggtt.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Ville Syrjälä Sept. 12, 2022, 12:43 p.m. UTC | #1
On Mon, Sep 12, 2022 at 02:19:57PM +0200, Thomas Hellström wrote:
> Commit 39a2bd34c933 ("drm/i915: Use the vma resource as argument for gtt
> binding / unbinding") introduced a regression that due to the vma resource
> tracking of the binding state, dpt ptes were not correctly repopulated.

Doesn't this mean all ggtt ptes weren't repopulated? So I'm
wondering how anything at all has been working?

> Fix this by clearing the vma resource state before repopulating.
> The state will subsequently be restored by the bind_vma operation.
> 
> Fixes: 39a2bd34c933 ("drm/i915: Use the vma resource as argument for gtt binding / unbinding")
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/gt/intel_ggtt.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c
> index 30cf5c3369d9..2049a00417af 100644
> --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
> +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
> @@ -1275,10 +1275,16 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)
>  			atomic_read(&vma->flags) & I915_VMA_BIND_MASK;
>  
>  		GEM_BUG_ON(!was_bound);
> -		if (!retained_ptes)
> +		if (!retained_ptes) {
> +			/*
> +			 * Clear the bound flags of the vma resource to allow
> +			 * ptes to be repopulated.
> +			 */
> +			vma->resource->bound_flags = 0;
>  			vma->ops->bind_vma(vm, NULL, vma->resource,
>  					   obj ? obj->cache_level : 0,
>  					   was_bound);
> +		}
>  		if (obj) { /* only used during resume => exclusive access */
>  			write_domain_objs |= fetch_and_zero(&obj->write_domain);
>  			obj->read_domains |= I915_GEM_DOMAIN_GTT;
> -- 
> 2.34.1
Thomas Hellstrom Sept. 12, 2022, 12:48 p.m. UTC | #2
On Mon, 2022-09-12 at 15:43 +0300, Ville Syrjälä wrote:
> On Mon, Sep 12, 2022 at 02:19:57PM +0200, Thomas Hellström wrote:
> > Commit 39a2bd34c933 ("drm/i915: Use the vma resource as argument
> > for gtt
> > binding / unbinding") introduced a regression that due to the vma
> > resource
> > tracking of the binding state, dpt ptes were not correctly
> > repopulated.
> 
> Doesn't this mean all ggtt ptes weren't repopulated? So I'm
> wondering how anything at all has been working?

ggtt ptes had a different check that was copy-pasted from the pre-vma-
resource code and that wasn't that strict. Hence why it worked.

/Thomas

> 
> > Fix this by clearing the vma resource state before repopulating.
> > The state will subsequently be restored by the bind_vma operation.
> > 
> > Fixes: 39a2bd34c933 ("drm/i915: Use the vma resource as argument
> > for gtt binding / unbinding")
> > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/gt/intel_ggtt.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > b/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > index 30cf5c3369d9..2049a00417af 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
> > @@ -1275,10 +1275,16 @@ bool i915_ggtt_resume_vm(struct
> > i915_address_space *vm)
> >                         atomic_read(&vma->flags) &
> > I915_VMA_BIND_MASK;
> >  
> >                 GEM_BUG_ON(!was_bound);
> > -               if (!retained_ptes)
> > +               if (!retained_ptes) {
> > +                       /*
> > +                        * Clear the bound flags of the vma
> > resource to allow
> > +                        * ptes to be repopulated.
> > +                        */
> > +                       vma->resource->bound_flags = 0;
> >                         vma->ops->bind_vma(vm, NULL, vma->resource,
> >                                            obj ? obj->cache_level :
> > 0,
> >                                            was_bound);
> > +               }
> >                 if (obj) { /* only used during resume => exclusive
> > access */
> >                         write_domain_objs |= fetch_and_zero(&obj-
> > >write_domain);
> >                         obj->read_domains |= I915_GEM_DOMAIN_GTT;
> > -- 
> > 2.34.1
>
Ville Syrjälä Sept. 12, 2022, 4:49 p.m. UTC | #3
On Mon, Sep 12, 2022 at 02:48:54PM +0200, Thomas Hellström wrote:
> On Mon, 2022-09-12 at 15:43 +0300, Ville Syrjälä wrote:
> > On Mon, Sep 12, 2022 at 02:19:57PM +0200, Thomas Hellström wrote:
> > > Commit 39a2bd34c933 ("drm/i915: Use the vma resource as argument
> > > for gtt
> > > binding / unbinding") introduced a regression that due to the vma
> > > resource
> > > tracking of the binding state, dpt ptes were not correctly
> > > repopulated.
> > 
> > Doesn't this mean all ggtt ptes weren't repopulated? So I'm
> > wondering how anything at all has been working?
> 
> ggtt ptes had a different check that was copy-pasted from the pre-vma-
> resource code and that wasn't that strict. Hence why it worked.

The ggtt one seems to want to skip if the vma is already bound 
with the other flag than what we're using this time, but doesn't
skip if it's already bound with the same flag(s). I have no idea
what it's trying to achieve there.

The dpt case skips if it's a bound at all, which seems much more
obvious but the fact that ggtt code never did that makes me
suspect it's not that clear cut.

So seems to me that the two checks are trying to do achieve
different goals, but at least I can't tell why that is.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 30cf5c3369d9..2049a00417af 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -1275,10 +1275,16 @@  bool i915_ggtt_resume_vm(struct i915_address_space *vm)
 			atomic_read(&vma->flags) & I915_VMA_BIND_MASK;
 
 		GEM_BUG_ON(!was_bound);
-		if (!retained_ptes)
+		if (!retained_ptes) {
+			/*
+			 * Clear the bound flags of the vma resource to allow
+			 * ptes to be repopulated.
+			 */
+			vma->resource->bound_flags = 0;
 			vma->ops->bind_vma(vm, NULL, vma->resource,
 					   obj ? obj->cache_level : 0,
 					   was_bound);
+		}
 		if (obj) { /* only used during resume => exclusive access */
 			write_domain_objs |= fetch_and_zero(&obj->write_domain);
 			obj->read_domains |= I915_GEM_DOMAIN_GTT;