diff mbox

[2/2] drm/i915: use the ICL stolen memory

Message ID 20180504203252.28048-2-paulo.r.zanoni@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zanoni, Paulo R May 4, 2018, 8:32 p.m. UTC
Now that our stolen memory is already reserved by the x86 subsystem
(since commit "x86/gpu: reserve ICL's graphics stolen memory"), make
use of it.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: x86@kernel.org
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_stolen.c | 38 +++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_reg.h        |  1 +
 2 files changed, 38 insertions(+), 1 deletion(-)

Comments

Lucas De Marchi July 7, 2018, 2:09 a.m. UTC | #1
On Fri, May 4, 2018 at 1:33 PM Paulo Zanoni <paulo.r.zanoni@intel.com> wrote:
>
> Now that our stolen memory is already reserved by the x86 subsystem
> (since commit "x86/gpu: reserve ICL's graphics stolen memory"), make
> use of it.
>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: x86@kernel.org
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_stolen.c | 38 +++++++++++++++++++++++++++++++++-
>  drivers/gpu/drm/i915/i915_reg.h        |  1 +
>  2 files changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index ad949cc30928..99556f0dbedc 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -343,6 +343,35 @@ static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
>         *size = stolen_top - *base;
>  }
>
> +static void icl_get_stolen_reserved(struct drm_i915_private *dev_priv,
> +                                   resource_size_t *base,
> +                                   resource_size_t *size)
> +{
> +       u64 reg_val = I915_READ64(GEN6_STOLEN_RESERVED);

are you sure it's still the same address? Either I'm looking to the
wrong place or this needs to be changed.

Lucas De Marchi

> +
> +       DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = 0x%016llx\n", reg_val);
> +
> +       *base = reg_val & GEN11_STOLEN_RESERVED_ADDR_MASK;
> +
> +       switch (reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK) {
> +       case GEN8_STOLEN_RESERVED_1M:
> +               *size = 1024 * 1024;
> +               break;
> +       case GEN8_STOLEN_RESERVED_2M:
> +               *size = 2 * 1024 * 1024;
> +               break;
> +       case GEN8_STOLEN_RESERVED_4M:
> +               *size = 4 * 1024 * 1024;
> +               break;
> +       case GEN8_STOLEN_RESERVED_8M:
> +               *size = 8 * 1024 * 1024;
> +               break;
> +       default:
> +               *size = 8 * 1024 * 1024;
> +               MISSING_CASE(reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK);
> +       }
> +}
> +
>  int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
>  {
>         resource_size_t reserved_base, stolen_top;
> @@ -399,7 +428,9 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
>                         gen7_get_stolen_reserved(dev_priv,
>                                                  &reserved_base, &reserved_size);
>                 break;
> -       default:
> +       case 8:
> +       case 9:
> +       case 10:
>                 if (IS_LP(dev_priv))
>                         chv_get_stolen_reserved(dev_priv,
>                                                 &reserved_base, &reserved_size);
> @@ -407,6 +438,11 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
>                         bdw_get_stolen_reserved(dev_priv,
>                                                 &reserved_base, &reserved_size);
>                 break;
> +       case 11:
> +       default:
> +               icl_get_stolen_reserved(dev_priv, &reserved_base,
> +                                       &reserved_size);
> +               break;
>         }
>
>         /*
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 15daf3553d40..c5bc7c808e31 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -398,6 +398,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
>  #define GEN8_STOLEN_RESERVED_4M                (2 << 7)
>  #define GEN8_STOLEN_RESERVED_8M                (3 << 7)
>  #define GEN6_STOLEN_RESERVED_ENABLE    (1 << 0)
> +#define GEN11_STOLEN_RESERVED_ADDR_MASK        (0xFFFFFFFFFFFULL << 20)
>
>  /* VGA stuff */
>
> --
> 2.14.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Rodrigo Vivi July 9, 2018, 7:13 p.m. UTC | #2
On Fri, Jul 06, 2018 at 07:09:15PM -0700, Lucas De Marchi wrote:
> On Fri, May 4, 2018 at 1:33 PM Paulo Zanoni <paulo.r.zanoni@intel.com> wrote:
> >
> > Now that our stolen memory is already reserved by the x86 subsystem
> > (since commit "x86/gpu: reserve ICL's graphics stolen memory"), make
> > use of it.
> >
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> > Cc: x86@kernel.org
> > Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_gem_stolen.c | 38 +++++++++++++++++++++++++++++++++-
> >  drivers/gpu/drm/i915/i915_reg.h        |  1 +
> >  2 files changed, 38 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> > index ad949cc30928..99556f0dbedc 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> > @@ -343,6 +343,35 @@ static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
> >         *size = stolen_top - *base;
> >  }
> >
> > +static void icl_get_stolen_reserved(struct drm_i915_private *dev_priv,
> > +                                   resource_size_t *base,
> > +                                   resource_size_t *size)
> > +{
> > +       u64 reg_val = I915_READ64(GEN6_STOLEN_RESERVED);
> 
> are you sure it's still the same address? Either I'm looking to the
> wrong place or this needs to be changed.

The only thing that changed was the size s/32/64
and the reg name s/MPAVPC/PAVPC_REG

BSpec: 19481

So, since this question made me look to the spec:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>


> 
> Lucas De Marchi
> 
> > +
> > +       DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = 0x%016llx\n", reg_val);
> > +
> > +       *base = reg_val & GEN11_STOLEN_RESERVED_ADDR_MASK;
> > +
> > +       switch (reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK) {
> > +       case GEN8_STOLEN_RESERVED_1M:
> > +               *size = 1024 * 1024;
> > +               break;
> > +       case GEN8_STOLEN_RESERVED_2M:
> > +               *size = 2 * 1024 * 1024;
> > +               break;
> > +       case GEN8_STOLEN_RESERVED_4M:
> > +               *size = 4 * 1024 * 1024;
> > +               break;
> > +       case GEN8_STOLEN_RESERVED_8M:
> > +               *size = 8 * 1024 * 1024;
> > +               break;
> > +       default:
> > +               *size = 8 * 1024 * 1024;
> > +               MISSING_CASE(reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK);
> > +       }
> > +}
> > +
> >  int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
> >  {
> >         resource_size_t reserved_base, stolen_top;
> > @@ -399,7 +428,9 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
> >                         gen7_get_stolen_reserved(dev_priv,
> >                                                  &reserved_base, &reserved_size);
> >                 break;
> > -       default:
> > +       case 8:
> > +       case 9:
> > +       case 10:
> >                 if (IS_LP(dev_priv))
> >                         chv_get_stolen_reserved(dev_priv,
> >                                                 &reserved_base, &reserved_size);
> > @@ -407,6 +438,11 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
> >                         bdw_get_stolen_reserved(dev_priv,
> >                                                 &reserved_base, &reserved_size);
> >                 break;
> > +       case 11:
> > +       default:
> > +               icl_get_stolen_reserved(dev_priv, &reserved_base,
> > +                                       &reserved_size);
> > +               break;
> >         }
> >
> >         /*
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > index 15daf3553d40..c5bc7c808e31 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -398,6 +398,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
> >  #define GEN8_STOLEN_RESERVED_4M                (2 << 7)
> >  #define GEN8_STOLEN_RESERVED_8M                (3 << 7)
> >  #define GEN6_STOLEN_RESERVED_ENABLE    (1 << 0)
> > +#define GEN11_STOLEN_RESERVED_ADDR_MASK        (0xFFFFFFFFFFFULL << 20)
> >
> >  /* VGA stuff */
> >
> > --
> > 2.14.3
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> 
> 
> -- 
> Lucas De Marchi
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Zanoni, Paulo R July 9, 2018, 11:44 p.m. UTC | #3
Em Sex, 2018-07-06 às 19:09 -0700, Lucas De Marchi escreveu:
> On Fri, May 4, 2018 at 1:33 PM Paulo Zanoni <paulo.r.zanoni@intel.com
> > wrote:
> > 
> > Now that our stolen memory is already reserved by the x86 subsystem
> > (since commit "x86/gpu: reserve ICL's graphics stolen memory"),
> > make
> > use of it.
> > 
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> > Cc: x86@kernel.org
> > Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_gem_stolen.c | 38
> > +++++++++++++++++++++++++++++++++-
> >  drivers/gpu/drm/i915/i915_reg.h        |  1 +
> >  2 files changed, 38 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c
> > b/drivers/gpu/drm/i915/i915_gem_stolen.c
> > index ad949cc30928..99556f0dbedc 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> > @@ -343,6 +343,35 @@ static void bdw_get_stolen_reserved(struct
> > drm_i915_private *dev_priv,
> >         *size = stolen_top - *base;
> >  }
> > 
> > +static void icl_get_stolen_reserved(struct drm_i915_private
> > *dev_priv,
> > +                                   resource_size_t *base,
> > +                                   resource_size_t *size)
> > +{
> > +       u64 reg_val = I915_READ64(GEN6_STOLEN_RESERVED);
> 
> are you sure it's still the same address? Either I'm looking to the
> wrong place or this needs to be changed.

Spec page 19481 tells me me I'm correct, but notice that this is now 64
bits.

> 
> Lucas De Marchi
> 
> > +
> > +       DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = 0x%016llx\n",
> > reg_val);
> > +
> > +       *base = reg_val & GEN11_STOLEN_RESERVED_ADDR_MASK;
> > +
> > +       switch (reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK) {
> > +       case GEN8_STOLEN_RESERVED_1M:
> > +               *size = 1024 * 1024;
> > +               break;
> > +       case GEN8_STOLEN_RESERVED_2M:
> > +               *size = 2 * 1024 * 1024;
> > +               break;
> > +       case GEN8_STOLEN_RESERVED_4M:
> > +               *size = 4 * 1024 * 1024;
> > +               break;
> > +       case GEN8_STOLEN_RESERVED_8M:
> > +               *size = 8 * 1024 * 1024;
> > +               break;
> > +       default:
> > +               *size = 8 * 1024 * 1024;
> > +               MISSING_CASE(reg_val &
> > GEN8_STOLEN_RESERVED_SIZE_MASK);
> > +       }
> > +}
> > +
> >  int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
> >  {
> >         resource_size_t reserved_base, stolen_top;
> > @@ -399,7 +428,9 @@ int i915_gem_init_stolen(struct
> > drm_i915_private *dev_priv)
> >                         gen7_get_stolen_reserved(dev_priv,
> >                                                  &reserved_base,
> > &reserved_size);
> >                 break;
> > -       default:
> > +       case 8:
> > +       case 9:
> > +       case 10:
> >                 if (IS_LP(dev_priv))
> >                         chv_get_stolen_reserved(dev_priv,
> >                                                 &reserved_base,
> > &reserved_size);
> > @@ -407,6 +438,11 @@ int i915_gem_init_stolen(struct
> > drm_i915_private *dev_priv)
> >                         bdw_get_stolen_reserved(dev_priv,
> >                                                 &reserved_base,
> > &reserved_size);
> >                 break;
> > +       case 11:
> > +       default:
> > +               icl_get_stolen_reserved(dev_priv, &reserved_base,
> > +                                       &reserved_size);
> > +               break;
> >         }
> > 
> >         /*
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h
> > b/drivers/gpu/drm/i915/i915_reg.h
> > index 15daf3553d40..c5bc7c808e31 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -398,6 +398,7 @@ static inline bool
> > i915_mmio_reg_valid(i915_reg_t reg)
> >  #define GEN8_STOLEN_RESERVED_4M                (2 << 7)
> >  #define GEN8_STOLEN_RESERVED_8M                (3 << 7)
> >  #define GEN6_STOLEN_RESERVED_ENABLE    (1 << 0)
> > +#define GEN11_STOLEN_RESERVED_ADDR_MASK        (0xFFFFFFFFFFFULL
> > << 20)
> > 
> >  /* VGA stuff */
> > 
> > --
> > 2.14.3
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> 
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index ad949cc30928..99556f0dbedc 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -343,6 +343,35 @@  static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
 	*size = stolen_top - *base;
 }
 
+static void icl_get_stolen_reserved(struct drm_i915_private *dev_priv,
+				    resource_size_t *base,
+				    resource_size_t *size)
+{
+	u64 reg_val = I915_READ64(GEN6_STOLEN_RESERVED);
+
+	DRM_DEBUG_DRIVER("GEN6_STOLEN_RESERVED = 0x%016llx\n", reg_val);
+
+	*base = reg_val & GEN11_STOLEN_RESERVED_ADDR_MASK;
+
+	switch (reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK) {
+	case GEN8_STOLEN_RESERVED_1M:
+		*size = 1024 * 1024;
+		break;
+	case GEN8_STOLEN_RESERVED_2M:
+		*size = 2 * 1024 * 1024;
+		break;
+	case GEN8_STOLEN_RESERVED_4M:
+		*size = 4 * 1024 * 1024;
+		break;
+	case GEN8_STOLEN_RESERVED_8M:
+		*size = 8 * 1024 * 1024;
+		break;
+	default:
+		*size = 8 * 1024 * 1024;
+		MISSING_CASE(reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK);
+	}
+}
+
 int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 {
 	resource_size_t reserved_base, stolen_top;
@@ -399,7 +428,9 @@  int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 			gen7_get_stolen_reserved(dev_priv,
 						 &reserved_base, &reserved_size);
 		break;
-	default:
+	case 8:
+	case 9:
+	case 10:
 		if (IS_LP(dev_priv))
 			chv_get_stolen_reserved(dev_priv,
 						&reserved_base, &reserved_size);
@@ -407,6 +438,11 @@  int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 			bdw_get_stolen_reserved(dev_priv,
 						&reserved_base, &reserved_size);
 		break;
+	case 11:
+	default:
+		icl_get_stolen_reserved(dev_priv, &reserved_base,
+					&reserved_size);
+		break;
 	}
 
 	/*
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 15daf3553d40..c5bc7c808e31 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -398,6 +398,7 @@  static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 #define GEN8_STOLEN_RESERVED_4M		(2 << 7)
 #define GEN8_STOLEN_RESERVED_8M		(3 << 7)
 #define GEN6_STOLEN_RESERVED_ENABLE	(1 << 0)
+#define GEN11_STOLEN_RESERVED_ADDR_MASK	(0xFFFFFFFFFFFULL << 20)
 
 /* VGA stuff */