2 * SPDX-License-Identifier: MIT
4 * Copyright © 2017 Intel Corporation
8 #include <linux/mount.h>
11 #include "i915_gemfs.h"
12 #include "i915_utils.h"
14 void i915_gemfs_init(struct drm_i915_private *i915)
16 char huge_opt[] = "huge=within_size"; /* r/w */
17 struct file_system_type *type;
18 struct vfsmount *gemfs;
21 * By creating our own shmemfs mountpoint, we can pass in
22 * mount flags that better match our usecase.
24 * One example, although it is probably better with a per-file
25 * control, is selecting huge page allocations ("huge=within_size").
26 * However, we only do so on platforms which benefit from it, or to
27 * offset the overhead of iommu lookups, where with latter it is a net
28 * win even on platforms which would otherwise see some performance
29 * regressions such a slow reads issue on Broadwell and Skylake.
32 if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915))
35 if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
38 type = get_fs_type("tmpfs");
42 gemfs = vfs_kern_mount(type, SB_KERNMOUNT, type->name, huge_opt);
46 i915->mm.gemfs = gemfs;
47 drm_info(&i915->drm, "Using Transparent Hugepages\n");
51 drm_notice(&i915->drm,
52 "Transparent Hugepage support is recommended for optimal performance%s\n",
53 GRAPHICS_VER(i915) >= 11 ? " on this platform!" :
54 " when IOMMU is enabled!");
57 void i915_gemfs_fini(struct drm_i915_private *i915)
59 kern_unmount(i915->mm.gemfs);