File Index
Files and directories
Sign in
FILE

v3d_gemfs.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/v3d/v3d_gemfs.c C
 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 <drm/drm_print.h>
 9
10#include "v3d_drv.h"
11
12void v3d_gemfs_init(struct v3d_dev *v3d)
13{
14	struct file_system_type *type;
15	struct fs_context *fc;
16	struct vfsmount *gemfs;
17	int ret;
18
19	/*
20	 * By creating our own shmemfs mountpoint, we can pass in
21	 * mount flags that better match our usecase. However, we
22	 * only do so on platforms which benefit from it.
23	 */
24	if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
25		goto err;
26
27	/* The user doesn't want to enable Super Pages */
28	if (!super_pages)
29		goto err;
30
31	type = get_fs_type("tmpfs");
32	if (!type)
33		goto err;
34
35	fc = fs_context_for_mount(type, SB_KERNMOUNT);
36	if (IS_ERR(fc))
37		goto err;
38	ret = vfs_parse_fs_string(fc, "source", "tmpfs");
39	if (!ret)
40		ret = vfs_parse_fs_string(fc, "huge", "within_size");
41	if (!ret)
42		gemfs = fc_mount_longterm(fc);
43	put_fs_context(fc);
44	if (ret)
45		goto err;
46
47	v3d->gemfs = gemfs;
48	drm_info(&v3d->drm, "Using Transparent Hugepages\n");
49
50	return;
51
52err:
53	v3d->gemfs = NULL;
54	drm_notice(&v3d->drm,
55		   "Transparent Hugepage support is recommended for optimal performance on this platform!\n");
56}
57
58void v3d_gemfs_fini(struct v3d_dev *v3d)
59{
60	if (v3d->gemfs)
61		kern_unmount(v3d->gemfs);
62}
~/ Read-only file preview.