diff mbox series

[2/2] drm/i915: restore stolen memory behaviour for DG2

Message ID 20221005153148.758822-2-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: add back GEN12_BDSM_MASK | expand

Commit Message

Matthew Auld Oct. 5, 2022, 3:31 p.m. UTC
Restore the previous behaviour here where we compare the
pci_resource_len() with the actual lmem_size, and not the dsm size,
since dsm here is just some subset snipped off the end of the lmem.
Otherwise we will incorrectly report an io_size > 0 on small-bar
systems.

It doesn't looks like MTL is expecting small-bar with its stolen memory,
based on:

  GEM_BUG_ON(pci_resource_len(pdev, GEN12_LMEM_BAR) != SZ_256M)
  GEM_BUG_ON((dsm_size + SZ_8M) > lmem_size)

So just move the HAS_BAR2_SMEM_STOLEN() check first, which then ignores
the small bar part, and we can go back to checking lmem_size against the
BAR size.

Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7007
Fixes: dbb2ffbfd708 ("drm/i915/mtl: enable local stolen memory")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Lucas De Marchi Oct. 5, 2022, 4:23 p.m. UTC | #1
On Wed, Oct 05, 2022 at 04:31:48PM +0100, Matthew Auld wrote:
>Restore the previous behaviour here where we compare the
>pci_resource_len() with the actual lmem_size, and not the dsm size,
>since dsm here is just some subset snipped off the end of the lmem.
>Otherwise we will incorrectly report an io_size > 0 on small-bar
>systems.
>
>It doesn't looks like MTL is expecting small-bar with its stolen memory,
>based on:
>
>  GEM_BUG_ON(pci_resource_len(pdev, GEN12_LMEM_BAR) != SZ_256M)
>  GEM_BUG_ON((dsm_size + SZ_8M) > lmem_size)
>
>So just move the HAS_BAR2_SMEM_STOLEN() check first, which then ignores
>the small bar part, and we can go back to checking lmem_size against the
>BAR size.
>
>Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7007
>Fixes: dbb2ffbfd708 ("drm/i915/mtl: enable local stolen memory")
>Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>Cc: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
>Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>Cc: Matt Roper <matthew.d.roper@intel.com>


Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

Lucas De Marchi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
index 2c4922961f33..1e00cf4d3ace 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c
@@ -917,11 +917,11 @@  i915_gem_stolen_lmem_setup(struct drm_i915_private *i915, u16 type,
 	}
 
 	io_size = dsm_size;
-	if (pci_resource_len(pdev, GEN12_LMEM_BAR) < dsm_size) {
+	if (HAS_BAR2_SMEM_STOLEN(i915)) {
+		io_start = pci_resource_start(pdev, GEN12_LMEM_BAR) + SZ_8M;
+	} else if (pci_resource_len(pdev, GEN12_LMEM_BAR) < lmem_size) {
 		io_start = 0;
 		io_size = 0;
-	} else if (HAS_BAR2_SMEM_STOLEN(i915)) {
-		io_start = pci_resource_start(pdev, GEN12_LMEM_BAR) + SZ_8M;
 	} else {
 		io_start = pci_resource_start(pdev, GEN12_LMEM_BAR) + dsm_base;
 	}