xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/i915/gem/i915_gemfs.c (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: i915_gemfs.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $	*/
2 
3 /*
4  * SPDX-License-Identifier: MIT
5  *
6  * Copyright © 2017 Intel Corporation
7  */
8 
9 #include <sys/cdefs.h>
10 __KERNEL_RCSID(0, "$NetBSD: i915_gemfs.c,v 1.2 2021/12/18 23:45:30 riastradh Exp $");
11 
12 #include <linux/fs.h>
13 #include <linux/mount.h>
14 #include <linux/pagemap.h>
15 
16 #include "i915_drv.h"
17 #include "i915_gemfs.h"
18 
i915_gemfs_init(struct drm_i915_private * i915)19 int i915_gemfs_init(struct drm_i915_private *i915)
20 {
21 	struct file_system_type *type;
22 	struct vfsmount *gemfs;
23 
24 	type = get_fs_type("tmpfs");
25 	if (!type)
26 		return -ENODEV;
27 
28 	/*
29 	 * By creating our own shmemfs mountpoint, we can pass in
30 	 * mount flags that better match our usecase.
31 	 *
32 	 * One example, although it is probably better with a per-file
33 	 * control, is selecting huge page allocations ("huge=within_size").
34 	 * Currently unused due to bandwidth issues (slow reads) on Broadwell+.
35 	 */
36 
37 	gemfs = kern_mount(type);
38 	if (IS_ERR(gemfs))
39 		return PTR_ERR(gemfs);
40 
41 	i915->mm.gemfs = gemfs;
42 
43 	return 0;
44 }
45 
i915_gemfs_fini(struct drm_i915_private * i915)46 void i915_gemfs_fini(struct drm_i915_private *i915)
47 {
48 	kern_unmount(i915->mm.gemfs);
49 }
50