Commit 16292243 authored by Matthew Auld's avatar Matthew Auld Committed by Chris Wilson
Browse files

drm/i915/lmem: add the fake lmem region



Intended for upstream testing so that we can still exercise the LMEM
plumbing and !i915_ggtt_has_aperture paths. Smoke tested on Skull Canyon
device. This works by allocating an intel_memory_region for a reserved
portion of system memory, which we treat like LMEM. For the LMEMBAR we
steal the aperture and 1:1 it map to the stolen region.

To enable simply set the i915 modparam fake_lmem_start= on the kernel
cmdline with the start of reserved region(see memmap=). The size of the
region we can use is determined by the size of the mappable aperture, so
the size of reserved region should be >= mappable_end. For now we only
enable for the selftests. Depends on CONFIG_DRM_I915_UNSTABLE being
enabled.

eg. memmap=2G$16G i915.fake_lmem_start=0x400000000

v2: make fake_lmem_start an i915 modparam

Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20191030173320.8850-1-matthew.auld@intel.com
parent 49748264
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -19,3 +19,11 @@ config DRM_I915_UNSTABLE
	  Recommended for driver developers _only_.

	  If in the slightest bit of doubt, say "N".

config DRM_I915_UNSTABLE_FAKE_LMEM
	bool "Enable the experimental fake lmem"
	depends on DRM_I915_UNSTABLE
	default n
	help
	  Convert some system memory into a fake local memory region for
	  testing.
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ i915_gem_object_lmem_io_map_page(struct drm_i915_gem_object *obj,
	resource_size_t offset;

	offset = i915_gem_object_get_dma_address(obj, n);
	offset -= obj->mm.region->region.start;

	return io_mapping_map_wc(&obj->mm.region->iomap, offset, PAGE_SIZE);
}
@@ -35,6 +36,7 @@ i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object *obj,
	resource_size_t offset;

	offset = i915_gem_object_get_dma_address(obj, n);
	offset -= obj->mm.region->region.start;

	return io_mapping_map_atomic_wc(&obj->mm.region->iomap, offset);
}
@@ -49,6 +51,7 @@ i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
	GEM_BUG_ON(!i915_gem_object_is_contiguous(obj));

	offset = i915_gem_object_get_dma_address(obj, n);
	offset -= obj->mm.region->region.start;

	return io_mapping_map_wc(&obj->mm.region->iomap, offset, size);
}
+15 −0
Original line number Diff line number Diff line
@@ -1483,6 +1483,21 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
	if (!i915_modparams.nuclear_pageflip && match_info->gen < 5)
		dev_priv->drm.driver_features &= ~DRIVER_ATOMIC;

	/*
	 * Check if we support fake LMEM -- for now we only unleash this for
	 * the live selftests(test-and-exit).
	 */
	if (IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)) {
		if (INTEL_GEN(dev_priv) >= 9 && i915_selftest.live < 0 &&
		    i915_modparams.fake_lmem_start) {
			mkwrite_device_info(dev_priv)->memory_regions =
				REGION_SMEM | REGION_LMEM | REGION_STOLEN;
			mkwrite_device_info(dev_priv)->is_dgfx = true;
			GEM_BUG_ON(!HAS_LMEM(dev_priv));
			GEM_BUG_ON(!IS_DGFX(dev_priv));
		}
	}

	ret = pci_enable_device(pdev);
	if (ret)
		goto out_fini;
+7 −0
Original line number Diff line number Diff line
@@ -179,6 +179,11 @@ i915_param_named(enable_gvt, bool, 0400,
	"Enable support for Intel GVT-g graphics virtualization host support(default:false)");
#endif

#if IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM)
i915_param_named_unsafe(fake_lmem_start, ulong, 0600,
	"Fake LMEM start offset (default: 0)");
#endif

static __always_inline void _print_param(struct drm_printer *p,
					 const char *name,
					 const char *type,
@@ -190,6 +195,8 @@ static __always_inline void _print_param(struct drm_printer *p,
		drm_printf(p, "i915.%s=%d\n", name, *(const int *)x);
	else if (!__builtin_strcmp(type, "unsigned int"))
		drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x);
	else if (!__builtin_strcmp(type, "unsigned long"))
		drm_printf(p, "i915.%s=%lu\n", name, *(const unsigned long *)x);
	else if (!__builtin_strcmp(type, "char *"))
		drm_printf(p, "i915.%s=%s\n", name, *(const char **)x);
	else
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ struct drm_printer;
	param(int, fastboot, -1) \
	param(int, enable_dpcd_backlight, 0) \
	param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE) \
	param(unsigned long, fake_lmem_start, 0) \
	/* leave bools at the end to not create holes */ \
	param(bool, alpha_support, IS_ENABLED(CONFIG_DRM_I915_ALPHA_SUPPORT)) \
	param(bool, enable_hangcheck, true) \
Loading