Just map the region directly, otherwise we are just limiting ourselves to the size of the mappable aperture. We still keep the same behaviour with matching the size of the mappable_end, but that can now be configured with its own modparam, such that we can configure larger sizes. Signed-off-by: Matthew Auld <matthew.auld@xxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/i915_params.c | 2 + drivers/gpu/drm/i915/i915_params.h | 1 + drivers/gpu/drm/i915/intel_memory_region.h | 3 -- drivers/gpu/drm/i915/intel_region_lmem.c | 45 ++++++---------------- 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index 1dd1f3652795..21be0f1ced82 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -182,6 +182,8 @@ i915_param_named(enable_gvt, bool, 0400, #if IS_ENABLED(CONFIG_DRM_I915_UNSTABLE_FAKE_LMEM) i915_param_named_unsafe(fake_lmem_start, ulong, 0600, "Fake LMEM start offset (default: 0)"); +i915_param_named_unsafe(fake_lmem_size, ulong, 0600, + "Fake LMEM size (default: 0)"); #endif static __always_inline void _print_param(struct drm_printer *p, diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h index 31b88f297fbc..57078a45e6ba 100644 --- a/drivers/gpu/drm/i915/i915_params.h +++ b/drivers/gpu/drm/i915/i915_params.h @@ -67,6 +67,7 @@ struct drm_printer; param(int, enable_dpcd_backlight, 0) \ param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE) \ param(unsigned long, fake_lmem_start, 0) \ + param(unsigned long, fake_lmem_size, 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) \ diff --git a/drivers/gpu/drm/i915/intel_memory_region.h b/drivers/gpu/drm/i915/intel_memory_region.h index 0c8e35be76a3..6e0c0d4c100e 100644 --- a/drivers/gpu/drm/i915/intel_memory_region.h +++ b/drivers/gpu/drm/i915/intel_memory_region.h @@ -77,9 +77,6 @@ struct intel_memory_region { struct io_mapping iomap; struct resource region; - /* For fake LMEM */ - struct drm_mm_node fake_mappable; - /* XXX: filthy midlayers */ struct drm_mm stolen; struct i915_buddy_mm mm; diff --git a/drivers/gpu/drm/i915/intel_region_lmem.c b/drivers/gpu/drm/i915/intel_region_lmem.c index e6a6b571dad4..aedffa2918c2 100644 --- a/drivers/gpu/drm/i915/intel_region_lmem.c +++ b/drivers/gpu/drm/i915/intel_region_lmem.c @@ -12,53 +12,29 @@ static int init_fake_lmem_bar(struct intel_memory_region *mem) { struct drm_i915_private *i915 = mem->i915; - struct i915_ggtt *ggtt = &i915->ggtt; - unsigned long n; - int ret; - - /* We want to 1:1 map the mappable aperture to our reserved region */ - - mem->fake_mappable.start = 0; - mem->fake_mappable.size = resource_size(&mem->region); - mem->fake_mappable.color = I915_COLOR_UNEVICTABLE; - - ret = drm_mm_reserve_node(&ggtt->vm.mm, &mem->fake_mappable); - if (ret) - return ret; mem->remap_addr = dma_map_resource(&i915->drm.pdev->dev, mem->region.start, - mem->fake_mappable.size, + resource_size(&mem->region), PCI_DMA_BIDIRECTIONAL, DMA_ATTR_FORCE_CONTIGUOUS); - if (dma_mapping_error(&i915->drm.pdev->dev, mem->remap_addr)) { - drm_mm_remove_node(&mem->fake_mappable); + if (dma_mapping_error(&i915->drm.pdev->dev, mem->remap_addr)) return -EINVAL; - } - - for (n = 0; n < mem->fake_mappable.size >> PAGE_SHIFT; ++n) { - ggtt->vm.insert_page(&ggtt->vm, - mem->remap_addr + (n << PAGE_SHIFT), - n << PAGE_SHIFT, - I915_CACHE_NONE, 0); - } mem->region = (struct resource)DEFINE_RES_MEM(mem->remap_addr, - mem->fake_mappable.size); + resource_size(&mem->region)); return 0; } static void release_fake_lmem_bar(struct intel_memory_region *mem) { - if (!drm_mm_node_allocated(&mem->fake_mappable)) + if (!i915_modparams.fake_lmem_start) return; - drm_mm_remove_node(&mem->fake_mappable); - dma_unmap_resource(&mem->i915->drm.pdev->dev, mem->remap_addr, - mem->fake_mappable.size, + resource_size(&mem->region), PCI_DMA_BIDIRECTIONAL, DMA_ATTR_FORCE_CONTIGUOUS); } @@ -107,22 +83,23 @@ intel_setup_fake_lmem(struct drm_i915_private *i915) struct pci_dev *pdev = i915->drm.pdev; struct intel_memory_region *mem; resource_size_t mappable_end; - resource_size_t io_start; resource_size_t start; + resource_size_t size; GEM_BUG_ON(i915_ggtt_has_aperture(&i915->ggtt)); GEM_BUG_ON(!i915_modparams.fake_lmem_start); - /* Your mappable aperture belongs to me now! */ mappable_end = pci_resource_len(pdev, 2); - io_start = pci_resource_start(pdev, 2), start = i915_modparams.fake_lmem_start; + size = i915_modparams.fake_lmem_size; + if (!size) + size = mappable_end; mem = intel_memory_region_create(i915, start, - mappable_end, + size, PAGE_SIZE, - io_start, + start, &intel_region_lmem_ops); if (!IS_ERR(mem)) { DRM_INFO("Intel graphics fake LMEM: %pR\n", &mem->region); -- 2.20.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx