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