drm/i915: Only setup private tmpfs mount when needed and fix logging
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 29 Apr 2022 10:04:14 +0000 (11:04 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Mon, 9 May 2022 13:03:50 +0000 (14:03 +0100)
If i915 does not want to use huge pages there is a) no point in setting up
the private mount and b) should former fail, it is misleading to log THP
support is disabled in the caller, which does not even know if callee
tried to enable it.

Fix both by restructuring the flow in i915_gemfs_init and at the same time
note the failure to set it up in all cases.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Eero Tamminen <eero.t.tamminen@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220429100414.647857-2-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/gem/i915_gem_shmem.c
drivers/gpu/drm/i915/gem/i915_gemfs.c
drivers/gpu/drm/i915/gem/i915_gemfs.h

index c2a3e388fcb4c424543a7e58a2dbb8b8a22218cb..955844f191935de19d875b501dcd46a12088459c 100644 (file)
@@ -671,17 +671,10 @@ fail:
 
 static int init_shmem(struct intel_memory_region *mem)
 {
-       int err;
-
-       err = i915_gemfs_init(mem->i915);
-       if (err) {
-               DRM_NOTE("Unable to create a private tmpfs mount, hugepage support will be disabled(%d).\n",
-                        err);
-       }
-
+       i915_gemfs_init(mem->i915);
        intel_memory_region_set_name(mem, "system");
 
-       return 0; /* Don't error, we can simply fallback to the kernel mnt */
+       return 0; /* We have fallback to the kernel mnt if gemfs init failed. */
 }
 
 static int release_shmem(struct intel_memory_region *mem)
index c5a6bbc842fc487b8e2f27840ebc573b8fe6bb64..46b9a17d6abc6e64a2e46f2e825746022faa842d 100644 (file)
 #include "i915_gemfs.h"
 #include "i915_utils.h"
 
-int i915_gemfs_init(struct drm_i915_private *i915)
+void i915_gemfs_init(struct drm_i915_private *i915)
 {
        char huge_opt[] = "huge=within_size"; /* r/w */
        struct file_system_type *type;
        struct vfsmount *gemfs;
-       char *opts;
-
-       type = get_fs_type("tmpfs");
-       if (!type)
-               return -ENODEV;
 
        /*
         * By creating our own shmemfs mountpoint, we can pass in
@@ -34,29 +29,29 @@ int i915_gemfs_init(struct drm_i915_private *i915)
         * regressions such a slow reads issue on Broadwell and Skylake.
         */
 
-       opts = NULL;
-       if (GRAPHICS_VER(i915) >= 11 || i915_vtd_active(i915)) {
-               if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
-                       opts = huge_opt;
-                       drm_info(&i915->drm,
-                                "Transparent Hugepage mode '%s'\n",
-                                opts);
-               } else {
-                       drm_notice(&i915->drm,
-                                  "Transparent Hugepage support is recommended for optimal performance%s\n",
-                                  GRAPHICS_VER(i915) >= 11 ?
-                                  " on this platform!" :
-                                  " when IOMMU is enabled!");
-               }
-       }
+       if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915))
+               return;
+
+       if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
+               goto err;
 
-       gemfs = vfs_kern_mount(type, SB_KERNMOUNT, type->name, opts);
+       type = get_fs_type("tmpfs");
+       if (!type)
+               goto err;
+
+       gemfs = vfs_kern_mount(type, SB_KERNMOUNT, type->name, huge_opt);
        if (IS_ERR(gemfs))
-               return PTR_ERR(gemfs);
+               goto err;
 
        i915->mm.gemfs = gemfs;
-
-       return 0;
+       drm_info(&i915->drm, "Using Transparent Hugepages\n");
+       return;
+
+err:
+       drm_notice(&i915->drm,
+                  "Transparent Hugepage support is recommended for optimal performance%s\n",
+                  GRAPHICS_VER(i915) >= 11 ? " on this platform!" :
+                                             " when IOMMU is enabled!");
 }
 
 void i915_gemfs_fini(struct drm_i915_private *i915)
index 2a1e59af3e4a1616b26964290e594b20acc8eee6..5d835e44c4f6eba6691557b14dad3f0945445194 100644 (file)
@@ -9,8 +9,7 @@
 
 struct drm_i915_private;
 
-int i915_gemfs_init(struct drm_i915_private *i915);
-
+void i915_gemfs_init(struct drm_i915_private *i915);
 void i915_gemfs_fini(struct drm_i915_private *i915);
 
 #endif