Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0+
2/* Copyright (C) 2024 Raspberry Pi */
3
4#include <linux/fs.h>
5#include <linux/mount.h>
6#include <linux/fs_context.h>
7
8#include "v3d_drv.h"
9
10void v3d_gemfs_init(struct v3d_dev *v3d)
11{
12 struct file_system_type *type;
13 struct fs_context *fc;
14 struct vfsmount *gemfs;
15 int ret;
16
17 /*
18 * By creating our own shmemfs mountpoint, we can pass in
19 * mount flags that better match our usecase. However, we
20 * only do so on platforms which benefit from it.
21 */
22 if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
23 goto err;
24
25 /* The user doesn't want to enable Super Pages */
26 if (!super_pages)
27 goto err;
28
29 type = get_fs_type("tmpfs");
30 if (!type)
31 goto err;
32
33 fc = fs_context_for_mount(type, SB_KERNMOUNT);
34 if (IS_ERR(fc))
35 goto err;
36 ret = vfs_parse_fs_string(fc, "source", "tmpfs");
37 if (!ret)
38 ret = vfs_parse_fs_string(fc, "huge", "within_size");
39 if (!ret)
40 gemfs = fc_mount_longterm(fc);
41 put_fs_context(fc);
42 if (ret)
43 goto err;
44
45 v3d->gemfs = gemfs;
46 drm_info(&v3d->drm, "Using Transparent Hugepages\n");
47
48 return;
49
50err:
51 v3d->gemfs = NULL;
52 drm_notice(&v3d->drm,
53 "Transparent Hugepage support is recommended for optimal performance on this platform!\n");
54}
55
56void v3d_gemfs_fini(struct v3d_dev *v3d)
57{
58 if (v3d->gemfs)
59 kern_unmount(v3d->gemfs);
60}