FILE
i915_gemfs.c
File preview with syntax highlighting.
linux-6.19.14/drivers/gpu/drm/i915/gem/i915_gemfs.c
1// SPDX-License-Identifier: MIT 2/* 3 * Copyright © 2017 Intel Corporation 4 */ 5 6#include <linux/fs.h> 7#include <linux/mount.h> 8#include <linux/fs_context.h> 9 10#include <drm/drm_print.h> 11 12#include "i915_drv.h" 13#include "i915_gemfs.h" 14#include "i915_utils.h" 15 16void i915_gemfs_init(struct drm_i915_private *i915) 17{ 18 struct file_system_type *type; 19 struct fs_context *fc; 20 struct vfsmount *gemfs; 21 int ret; 22 23 /* 24 * By creating our own shmemfs mountpoint, we can pass in 25 * mount flags that better match our usecase. 26 * 27 * One example, although it is probably better with a per-file 28 * control, is selecting huge page allocations ("huge=within_size"). 29 * However, we only do so on platforms which benefit from it, or to 30 * offset the overhead of iommu lookups, where with latter it is a net 31 * win even on platforms which would otherwise see some performance 32 * regressions such a slow reads issue on Broadwell and Skylake. 33 */ 34 35 if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915)) 36 return; 37 38 if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) 39 goto err; 40 41 type = get_fs_type("tmpfs"); 42 if (!type) 43 goto err; 44 45 fc = fs_context_for_mount(type, SB_KERNMOUNT); 46 if (IS_ERR(fc)) 47 goto err; 48 ret = vfs_parse_fs_string(fc, "source", "tmpfs"); 49 if (!ret) 50 ret = vfs_parse_fs_string(fc, "huge", "within_size"); 51 if (!ret) 52 gemfs = fc_mount_longterm(fc); 53 put_fs_context(fc); 54 if (ret) 55 goto err; 56 57 i915->mm.gemfs = gemfs; 58 drm_info(&i915->drm, "Using Transparent Hugepages\n"); 59 return; 60 61err: 62 drm_notice(&i915->drm, 63 "Transparent Hugepage support is recommended for optimal performance%s\n", 64 GRAPHICS_VER(i915) >= 11 ? " on this platform!" : 65 " when IOMMU is enabled!"); 66} 67 68void i915_gemfs_fini(struct drm_i915_private *i915) 69{ 70 kern_unmount(i915->mm.gemfs); 71}
~/
Read-only file preview.