diff mbox series

drm/i915: Probe system memory regions before enabling HW

Message ID 20210211112051.14204-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915: Probe system memory regions before enabling HW | expand

Commit Message

Chris Wilson Feb. 11, 2021, 11:20 a.m. UTC
If we want to track system/stolen as memory regions, we need to setup
our bookkeeping *before* we want to start allocating and reserving
objects in those regions. In particular, in setup up the GGTT we will
try to preallocate stolen regions configured by the BIOS, and so should
prepare the system-stolen memory region beforehand.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Matthew Auld Feb. 11, 2021, 12:27 p.m. UTC | #1
On 11/02/2021 11:20, Chris Wilson wrote:
> If we want to track system/stolen as memory regions, we need to setup
> our bookkeeping *before* we want to start allocating and reserving
> objects in those regions. In particular, in setup up the GGTT we will
> try to preallocate stolen regions configured by the BIOS, and so should
> prepare the system-stolen memory region beforehand.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.auld@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_drv.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index b708517d3972..139cea4443fd 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -557,6 +557,10 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
>   
>   	i915_perf_init(dev_priv);
>   
> +	ret = intel_memory_regions_hw_probe(dev_priv);
> +	if (ret)
> +		goto err_ggtt;

Hmmm, adjust_stolen is also peeking at ggtt_total_entries(ggtt) on some 
old platforms.

> +
>   	ret = i915_ggtt_probe_hw(dev_priv);
>   	if (ret)
>   		goto err_perf;
> @@ -569,10 +573,6 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
>   	if (ret)
>   		goto err_ggtt;
>   
> -	ret = intel_memory_regions_hw_probe(dev_priv);
> -	if (ret)
> -		goto err_ggtt;
> -
>   	intel_gt_init_hw_early(&dev_priv->gt, &dev_priv->ggtt);
>   
>   	ret = intel_gt_probe_lmem(&dev_priv->gt);
>
Chris Wilson Feb. 11, 2021, 12:35 p.m. UTC | #2
Quoting Matthew Auld (2021-02-11 12:27:56)
> On 11/02/2021 11:20, Chris Wilson wrote:
> > If we want to track system/stolen as memory regions, we need to setup
> > our bookkeeping *before* we want to start allocating and reserving
> > objects in those regions. In particular, in setup up the GGTT we will
> > try to preallocate stolen regions configured by the BIOS, and so should
> > prepare the system-stolen memory region beforehand.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Matthew Auld <matthew.auld@intel.com>
> > ---
> >   drivers/gpu/drm/i915/i915_drv.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> > index b708517d3972..139cea4443fd 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.c
> > +++ b/drivers/gpu/drm/i915/i915_drv.c
> > @@ -557,6 +557,10 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
> >   
> >       i915_perf_init(dev_priv);
> >   
> > +     ret = intel_memory_regions_hw_probe(dev_priv);
> > +     if (ret)
> > +             goto err_ggtt;
> 
> Hmmm, adjust_stolen is also peeking at ggtt_total_entries(ggtt) on some 
> old platforms.

A nice catch-22. More splitting required. Maybe a fixup pass from
init_ggtt would work best.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index b708517d3972..139cea4443fd 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -557,6 +557,10 @@  static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 
 	i915_perf_init(dev_priv);
 
+	ret = intel_memory_regions_hw_probe(dev_priv);
+	if (ret)
+		goto err_ggtt;
+
 	ret = i915_ggtt_probe_hw(dev_priv);
 	if (ret)
 		goto err_perf;
@@ -569,10 +573,6 @@  static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
 	if (ret)
 		goto err_ggtt;
 
-	ret = intel_memory_regions_hw_probe(dev_priv);
-	if (ret)
-		goto err_ggtt;
-
 	intel_gt_init_hw_early(&dev_priv->gt, &dev_priv->ggtt);
 
 	ret = intel_gt_probe_lmem(&dev_priv->gt);