#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/fs_context.h>
#include "i915_drv.h"
#include "i915_gemfs.h"
#include "i915_utils.h"
void i915_gemfs_init(struct drm_i915_private *i915)
{
#ifdef __linux__
struct file_system_type *type;
struct fs_context *fc;
struct vfsmount *gemfs;
int ret;
if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915))
return;
if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
goto err;
type = get_fs_type("tmpfs");
if (!type)
goto err;
fc = fs_context_for_mount(type, SB_KERNMOUNT);
if (IS_ERR(fc))
goto err;
ret = vfs_parse_fs_string(fc, "source", "tmpfs");
if (!ret)
ret = vfs_parse_fs_string(fc, "huge", "within_size");
if (!ret)
gemfs = fc_mount_longterm(fc);
put_fs_context(fc);
if (ret)
goto err;
i915->mm.gemfs = gemfs;
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!");
#endif
}
void i915_gemfs_fini(struct drm_i915_private *i915)
{
#ifdef __linux__
kern_unmount(i915->mm.gemfs);
#endif
}