diff mbox series

[v3,08/16] drm/i915: Fix region start during initial plane readout

Message ID 20240116075636.6121-9-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: (stolen) memory region related fixes | expand

Commit Message

Ville Syrjälä Jan. 16, 2024, 7:56 a.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

On MTL the stolen region starts at offset 8MiB from the start of
LMEMBAR. The dma addresses are thus also offset by 8MiB. However the
mm_node/etc. is zero based, and i915_pages_create_for_stolen() will
add the appropriate region.start into the sg dma address. So when
we do the readout we need to convert the dma address read from
the PTE to be zero based as well.

Note that currently we don't take this path on MTL, but we should
and thus this needs to be fixed. For lmem this works correctly
already as the lmem region.start==0.

While at it let's also make sure the address points to somewhere within
the memory region. We don't need to check the size as
i915_gem_object_create_region_at() should later fail if the object size
exceeds the region size.

Cc: Paz Zcharya <pazz@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_plane_initial.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Shankar, Uma Jan. 22, 2024, 3:07 p.m. UTC | #1
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville
> Syrjala
> Sent: Tuesday, January 16, 2024 1:26 PM
> To: intel-gfx@lists.freedesktop.org
> Subject: [PATCH v3 08/16] drm/i915: Fix region start during initial plane readout
> 
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> On MTL the stolen region starts at offset 8MiB from the start of LMEMBAR. The
> dma addresses are thus also offset by 8MiB. However the mm_node/etc. is zero
> based, and i915_pages_create_for_stolen() will add the appropriate region.start
> into the sg dma address. So when we do the readout we need to convert the dma
> address read from the PTE to be zero based as well.
> 
> Note that currently we don't take this path on MTL, but we should and thus this
> needs to be fixed. For lmem this works correctly already as the lmem
> region.start==0.
> 
> While at it let's also make sure the address points to somewhere within the
> memory region. We don't need to check the size as
> i915_gem_object_create_region_at() should later fail if the object size exceeds
> the region size.

Looks Good to me.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> Cc: Paz Zcharya <pazz@chromium.org>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_plane_initial.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> index ffc92b18fcf5..db594ccf0323 100644
> --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> @@ -79,16 +79,18 @@ initial_plane_vma(struct drm_i915_private *i915,
>  		 * We don't currently expect this to ever be placed in the
>  		 * stolen portion.
>  		 */
> -		if (phys_base >= resource_size(&mem->region)) {
> +		if (phys_base < mem->region.start || phys_base > mem-
> >region.end) {
>  			drm_err(&i915->drm,
> -				"Initial plane programming using invalid range,
> phys_base=%pa\n",
> -				&phys_base);
> +				"Initial plane programming using invalid range,
> phys_base=%pa (%s [%pa-%pa])\n",
> +				&phys_base, mem->region.name, &mem-
> >region.start,
> +&mem->region.end);
>  			return NULL;
>  		}
> 
>  		drm_dbg(&i915->drm,
>  			"Using phys_base=%pa, based on initial plane
> programming\n",
>  			&phys_base);
> +
> +		phys_base -= mem->region.start;
>  	} else {
>  		phys_base = base;
>  		mem = i915->mm.stolen_region;
> --
> 2.41.0
Paz Zcharya Jan. 30, 2024, 11:21 p.m. UTC | #2
On Mon, Jan 22, 2024 at 03:07:52PM +0000, Shankar, Uma wrote:
> 
> 
> > -----Original Message-----
> > From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville
> > Syrjala
> > Sent: Tuesday, January 16, 2024 1:26 PM
> > To: intel-gfx@lists.freedesktop.org
> > Subject: [PATCH v3 08/16] drm/i915: Fix region start during initial plane readout
> > 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > On MTL the stolen region starts at offset 8MiB from the start of LMEMBAR. The
> > dma addresses are thus also offset by 8MiB. However the mm_node/etc. is zero
> > based, and i915_pages_create_for_stolen() will add the appropriate region.start
> > into the sg dma address. So when we do the readout we need to convert the dma
> > address read from the PTE to be zero based as well.
> > 
> > Note that currently we don't take this path on MTL, but we should and thus this
> > needs to be fixed. For lmem this works correctly already as the lmem
> > region.start==0.
> > 
> > While at it let's also make sure the address points to somewhere within the
> > memory region. We don't need to check the size as
> > i915_gem_object_create_region_at() should later fail if the object size exceeds
> > the region size.
> 
> Looks Good to me.
> Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> 
> > Cc: Paz Zcharya <pazz@chromium.org>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Hi Ville,

Thank you so much for this incredible series.
It solves the issue regarding MTL initial plane readout
that Andrzej Hajda and I worked on in
https://patchwork.freedesktop.org/patch/570811/?series=127130&rev=2
In addition, it solved the issue with the new GOP.

I tested it on two different devices with Meteor Lake and it worked perfectly:
no i915 errors, no flickers or observable issues.

Tested-by: Paz Zcharya <pazz@chromium.org>

> > ---
> >  drivers/gpu/drm/i915/display/intel_plane_initial.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> > b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> > index ffc92b18fcf5..db594ccf0323 100644
> > --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> > +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> > @@ -79,16 +79,18 @@ initial_plane_vma(struct drm_i915_private *i915,
> >  		 * We don't currently expect this to ever be placed in the
> >  		 * stolen portion.
> >  		 */
> > -		if (phys_base >= resource_size(&mem->region)) {
> > +		if (phys_base < mem->region.start || phys_base > mem-
> > >region.end) {
> >  			drm_err(&i915->drm,
> > -				"Initial plane programming using invalid range,
> > phys_base=%pa\n",
> > -				&phys_base);
> > +				"Initial plane programming using invalid range,
> > phys_base=%pa (%s [%pa-%pa])\n",
> > +				&phys_base, mem->region.name, &mem-
> > >region.start,
> > +&mem->region.end);
> >  			return NULL;
> >  		}
> > 
> >  		drm_dbg(&i915->drm,
> >  			"Using phys_base=%pa, based on initial plane
> > programming\n",
> >  			&phys_base);
> > +
> > +		phys_base -= mem->region.start;
> >  	} else {
> >  		phys_base = base;
> >  		mem = i915->mm.stolen_region;
> > --
> > 2.41.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c b/drivers/gpu/drm/i915/display/intel_plane_initial.c
index ffc92b18fcf5..db594ccf0323 100644
--- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
+++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
@@ -79,16 +79,18 @@  initial_plane_vma(struct drm_i915_private *i915,
 		 * We don't currently expect this to ever be placed in the
 		 * stolen portion.
 		 */
-		if (phys_base >= resource_size(&mem->region)) {
+		if (phys_base < mem->region.start || phys_base > mem->region.end) {
 			drm_err(&i915->drm,
-				"Initial plane programming using invalid range, phys_base=%pa\n",
-				&phys_base);
+				"Initial plane programming using invalid range, phys_base=%pa (%s [%pa-%pa])\n",
+				&phys_base, mem->region.name, &mem->region.start, &mem->region.end);
 			return NULL;
 		}
 
 		drm_dbg(&i915->drm,
 			"Using phys_base=%pa, based on initial plane programming\n",
 			&phys_base);
+
+		phys_base -= mem->region.start;
 	} else {
 		phys_base = base;
 		mem = i915->mm.stolen_region;