]> git.ipfire.org Git - thirdparty/openwrt.git/blob
d2355fbe784c13b6793ce9944d6d2a933d21f28f
[thirdparty/openwrt.git] /
1 From 9aa5f00f839d261bfef937425e9c2e929c0db118 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= <mcanal@igalia.com>
3 Date: Mon, 23 Sep 2024 10:55:08 -0300
4 Subject: [PATCH] drm/gem: Create a drm_gem_object_init_with_mnt() function
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Commit 0992b2541e1cd9580c2e70fab7a78558de054bae upstream
10
11 For some applications, such as applications that uses huge pages, we might
12 want to have a different mountpoint, for which we pass mount flags that
13 better match our usecase.
14
15 Therefore, create a new function `drm_gem_object_init_with_mnt()` that
16 allow us to define the tmpfs mountpoint where the GEM object will be
17 created. If this parameter is NULL, then we fallback to `shmem_file_setup()`.
18
19 Signed-off-by: MaĆ­ra Canal <mcanal@igalia.com>
20 Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
21 Link: https://patchwork.freedesktop.org/patch/msgid/20240923141348.2422499-5-mcanal@igalia.com
22 ---
23 drivers/gpu/drm/drm_gem.c | 34 ++++++++++++++++++++++++++++++----
24 include/drm/drm_gem.h | 3 +++
25 2 files changed, 33 insertions(+), 4 deletions(-)
26
27 --- a/drivers/gpu/drm/drm_gem.c
28 +++ b/drivers/gpu/drm/drm_gem.c
29 @@ -114,22 +114,32 @@ drm_gem_init(struct drm_device *dev)
30 }
31
32 /**
33 - * drm_gem_object_init - initialize an allocated shmem-backed GEM object
34 + * drm_gem_object_init_with_mnt - initialize an allocated shmem-backed GEM
35 + * object in a given shmfs mountpoint
36 + *
37 * @dev: drm_device the object should be initialized for
38 * @obj: drm_gem_object to initialize
39 * @size: object size
40 + * @gemfs: tmpfs mount where the GEM object will be created. If NULL, use
41 + * the usual tmpfs mountpoint (`shm_mnt`).
42 *
43 * Initialize an already allocated GEM object of the specified size with
44 * shmfs backing store.
45 */
46 -int drm_gem_object_init(struct drm_device *dev,
47 - struct drm_gem_object *obj, size_t size)
48 +int drm_gem_object_init_with_mnt(struct drm_device *dev,
49 + struct drm_gem_object *obj, size_t size,
50 + struct vfsmount *gemfs)
51 {
52 struct file *filp;
53
54 drm_gem_private_object_init(dev, obj, size);
55
56 - filp = shmem_file_setup("drm mm object", size, VM_NORESERVE);
57 + if (gemfs)
58 + filp = shmem_file_setup_with_mnt(gemfs, "drm mm object", size,
59 + VM_NORESERVE);
60 + else
61 + filp = shmem_file_setup("drm mm object", size, VM_NORESERVE);
62 +
63 if (IS_ERR(filp))
64 return PTR_ERR(filp);
65
66 @@ -137,6 +147,22 @@ int drm_gem_object_init(struct drm_devic
67
68 return 0;
69 }
70 +EXPORT_SYMBOL(drm_gem_object_init_with_mnt);
71 +
72 +/**
73 + * drm_gem_object_init - initialize an allocated shmem-backed GEM object
74 + * @dev: drm_device the object should be initialized for
75 + * @obj: drm_gem_object to initialize
76 + * @size: object size
77 + *
78 + * Initialize an already allocated GEM object of the specified size with
79 + * shmfs backing store.
80 + */
81 +int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj,
82 + size_t size)
83 +{
84 + return drm_gem_object_init_with_mnt(dev, obj, size, NULL);
85 +}
86 EXPORT_SYMBOL(drm_gem_object_init);
87
88 /**
89 --- a/include/drm/drm_gem.h
90 +++ b/include/drm/drm_gem.h
91 @@ -473,6 +473,9 @@ void drm_gem_object_release(struct drm_g
92 void drm_gem_object_free(struct kref *kref);
93 int drm_gem_object_init(struct drm_device *dev,
94 struct drm_gem_object *obj, size_t size);
95 +int drm_gem_object_init_with_mnt(struct drm_device *dev,
96 + struct drm_gem_object *obj, size_t size,
97 + struct vfsmount *gemfs);
98 void drm_gem_private_object_init(struct drm_device *dev,
99 struct drm_gem_object *obj, size_t size);
100 void drm_gem_private_object_fini(struct drm_gem_object *obj);