]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/lmem: Bypass aperture when lmem is available
authorAnusha Srivatsa <anusha.srivatsa@intel.com>
Tue, 27 Apr 2021 08:54:16 +0000 (09:54 +0100)
committerMatthew Auld <matthew.auld@intel.com>
Tue, 27 Apr 2021 15:21:47 +0000 (16:21 +0100)
In the scenario where local memory is available, we have
rely on CPU access via lmem directly instead of aperture.

v2:
gmch is only relevant for much older hw, therefore we can drop the
has_aperture check since it should always be present on such platforms.
(Chris)

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Chris P Wilson <chris.p.wilson@intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: CQ Tang <cq.tang@intel.com>
Signed-off-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210427085417.120246-6-matthew.auld@intel.com
drivers/gpu/drm/i915/display/intel_fbdev.c
drivers/gpu/drm/i915/gem/i915_gem_lmem.c
drivers/gpu/drm/i915/gem/i915_gem_lmem.h
drivers/gpu/drm/i915/i915_vma.c

index 2b37959da7473db9515a8f7f2686e43b815d8bd2..4af40229f5ec3f3e3a0307122d6592cd3d150eee 100644 (file)
@@ -139,14 +139,22 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
        size = mode_cmd.pitches[0] * mode_cmd.height;
        size = PAGE_ALIGN(size);
 
-       /* If the FB is too big, just don't use it since fbdev is not very
-        * important and we should probably use that space with FBC or other
-        * features. */
        obj = ERR_PTR(-ENODEV);
-       if (size * 2 < dev_priv->stolen_usable_size)
-               obj = i915_gem_object_create_stolen(dev_priv, size);
-       if (IS_ERR(obj))
-               obj = i915_gem_object_create_shmem(dev_priv, size);
+       if (HAS_LMEM(dev_priv)) {
+               obj = i915_gem_object_create_lmem(dev_priv, size,
+                                                 I915_BO_ALLOC_CONTIGUOUS);
+       } else {
+               /*
+                * If the FB is too big, just don't use it since fbdev is not very
+                * important and we should probably use that space with FBC or other
+                * features.
+                */
+               if (size * 2 < dev_priv->stolen_usable_size)
+                       obj = i915_gem_object_create_stolen(dev_priv, size);
+               if (IS_ERR(obj))
+                       obj = i915_gem_object_create_shmem(dev_priv, size);
+       }
+
        if (IS_ERR(obj)) {
                drm_err(&dev_priv->drm, "failed to allocate framebuffer\n");
                return PTR_ERR(obj);
index 017db8f71130ef63b097afeb1d3b78df1316869a..f44bdd08f7cb4551fd96e52ef2f29b1899edcdd2 100644 (file)
@@ -17,6 +17,21 @@ const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = {
        .release = i915_gem_object_release_memory_region,
 };
 
+void __iomem *
+i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
+                           unsigned long n,
+                           unsigned long size)
+{
+       resource_size_t offset;
+
+       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);
+}
+
 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
 {
        struct intel_memory_region *mr = obj->mm.region;
index 036d53c01de9543551ccb4039a729f8b8376ceb5..fac6bc5a5ebbcc2554c042dffc6e57e7b7b6bbcb 100644 (file)
@@ -14,6 +14,11 @@ struct intel_memory_region;
 
 extern const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops;
 
+void __iomem *
+i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
+                           unsigned long n,
+                           unsigned long size);
+
 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj);
 
 struct drm_i915_gem_object *
index eb01899ac6b7c2eb06817c9a6a406b862e387983..468317e3b4778c9d84d51ae1afdbcbb224a95404 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "display/intel_frontbuffer.h"
 
+#include "gem/i915_gem_lmem.h"
 #include "gt/intel_engine.h"
 #include "gt/intel_engine_heartbeat.h"
 #include "gt/intel_gt.h"
@@ -448,9 +449,11 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
        void __iomem *ptr;
        int err;
 
-       if (GEM_WARN_ON(!i915_vma_is_map_and_fenceable(vma))) {
-               err = -ENODEV;
-               goto err;
+       if (!i915_gem_object_is_lmem(vma->obj)) {
+               if (GEM_WARN_ON(!i915_vma_is_map_and_fenceable(vma))) {
+                       err = -ENODEV;
+                       goto err;
+               }
        }
 
        GEM_BUG_ON(!i915_vma_is_ggtt(vma));
@@ -458,9 +461,19 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
 
        ptr = READ_ONCE(vma->iomap);
        if (ptr == NULL) {
-               ptr = io_mapping_map_wc(&i915_vm_to_ggtt(vma->vm)->iomap,
-                                       vma->node.start,
-                                       vma->node.size);
+               /*
+                * TODO: consider just using i915_gem_object_pin_map() for lmem
+                * instead, which already supports mapping non-contiguous chunks
+                * of pages, that way we can also drop the
+                * I915_BO_ALLOC_CONTIGUOUS when allocating the object.
+                */
+               if (i915_gem_object_is_lmem(vma->obj))
+                       ptr = i915_gem_object_lmem_io_map(vma->obj, 0,
+                                                         vma->obj->base.size);
+               else
+                       ptr = io_mapping_map_wc(&i915_vm_to_ggtt(vma->vm)->iomap,
+                                               vma->node.start,
+                                               vma->node.size);
                if (ptr == NULL) {
                        err = -ENOMEM;
                        goto err;