Skip to content

Commit e416e1d

Browse files
mairacanalpopcornmix
authored andcommitted
drm/v3d: Use gemfs/THP in BO creation if available
Commit 20d69e8 upstream Although Big/Super Pages could appear naturally, it would be quite hard to have 1MB or 64KB allocated contiguously naturally. Therefore, we can force the creation of large pages allocated contiguously by using a mountpoint with "huge=within_size" enabled. Therefore, as V3D has a mountpoint with "huge=within_size" (if user has THP enabled), use this mountpoint for BO creation if available. This will allow us to create large pages allocated contiguously and make use of Big/Super Pages. Signed-off-by: Maíra Canal <mcanal@igalia.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240923141348.2422499-10-mcanal@igalia.com
1 parent 97e4d77 commit e416e1d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

drivers/gpu/drm/v3d/v3d_bo.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ v3d_bo_create_finish(struct drm_gem_object *obj)
107107
struct v3d_dev *v3d = to_v3d_dev(obj->dev);
108108
struct v3d_bo *bo = to_v3d_bo(obj);
109109
struct sg_table *sgt;
110+
u64 align;
110111
int ret;
111112

112113
/* So far we pin the BO in the MMU for its lifetime, so use
@@ -116,14 +117,23 @@ v3d_bo_create_finish(struct drm_gem_object *obj)
116117
if (IS_ERR(sgt))
117118
return PTR_ERR(sgt);
118119

120+
if (!v3d->gemfs)
121+
align = SZ_4K;
122+
else if (obj->size >= SZ_1M)
123+
align = SZ_1M;
124+
else if (obj->size >= SZ_64K)
125+
align = SZ_64K;
126+
else
127+
align = SZ_4K;
128+
119129
spin_lock(&v3d->mm_lock);
120130
/* Allocate the object's space in the GPU's page tables.
121131
* Inserting PTEs will happen later, but the offset is for the
122132
* lifetime of the BO.
123133
*/
124134
ret = drm_mm_insert_node_generic(&v3d->mm, &bo->node,
125135
obj->size >> V3D_MMU_PAGE_SHIFT,
126-
SZ_4K >> V3D_MMU_PAGE_SHIFT, 0, 0);
136+
align >> V3D_MMU_PAGE_SHIFT, 0, 0);
127137
spin_unlock(&v3d->mm_lock);
128138
if (ret)
129139
return ret;
@@ -143,10 +153,17 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
143153
size_t unaligned_size)
144154
{
145155
struct drm_gem_shmem_object *shmem_obj;
156+
struct v3d_dev *v3d = to_v3d_dev(dev);
146157
struct v3d_bo *bo;
147158
int ret;
148159

149-
shmem_obj = drm_gem_shmem_create(dev, unaligned_size);
160+
/* Let the user opt out of allocating the BOs with THP */
161+
if (v3d->gemfs)
162+
shmem_obj = drm_gem_shmem_create_with_mnt(dev, unaligned_size,
163+
v3d->gemfs);
164+
else
165+
shmem_obj = drm_gem_shmem_create(dev, unaligned_size);
166+
150167
if (IS_ERR(shmem_obj))
151168
return ERR_CAST(shmem_obj);
152169
bo = to_v3d_bo(&shmem_obj->base);

0 commit comments

Comments
 (0)