1 /* 2 * SPDX-License-Identifier: MIT 3 * 4 * Copyright © 2017 Intel Corporation 5 */ 6 7 #include <linux/fs.h> 8 #include <linux/mount.h> 9 #include <linux/pagemap.h> 10 11 #include "i915_drv.h" 12 #include "i915_gemfs.h" 13 14 int i915_gemfs_init(struct drm_i915_private *i915) 15 { 16 struct file_system_type *type; 17 struct vfsmount *gemfs; 18 19 type = get_fs_type("tmpfs"); 20 if (!type) 21 return -ENODEV; 22 23 gemfs = kern_mount(type); 24 if (IS_ERR(gemfs)) 25 return PTR_ERR(gemfs); 26 27 /* 28 * Enable huge-pages for objects that are at least HPAGE_PMD_SIZE, most 29 * likely 2M. Note that within_size may overallocate huge-pages, if say 30 * we allocate an object of size 2M + 4K, we may get 2M + 2M, but under 31 * memory pressure shmem should split any huge-pages which can be 32 * shrunk. 33 */ 34 35 if (has_transparent_hugepage()) { 36 struct super_block *sb = gemfs->mnt_sb; 37 /* FIXME: Disabled until we get W/A for read BW issue. */ 38 char options[] = "huge=never"; 39 int flags = 0; 40 int err; 41 42 err = sb->s_op->remount_fs(sb, &flags, options); 43 if (err) { 44 kern_unmount(gemfs); 45 return err; 46 } 47 } 48 49 i915->mm.gemfs = gemfs; 50 51 return 0; 52 } 53 54 void i915_gemfs_fini(struct drm_i915_private *i915) 55 { 56 kern_unmount(i915->mm.gemfs); 57 } 58