Skip to contentSkip to conversation

drm/panfrost: Align GEM objects GPU VA to 2MB

PATCH In review Rob Herring 2 participants 2 messages Jun 10, 2019 – Jun 13, 2019

Subsystems (3)
lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 drm/panfrost: Align GEM objects GPU VA to 2MB

In order to increase the chances of using 2MB pages, we need to align the GPU VA mapping to 2MB. Only do this if the object size is 2MB or more.

Cc Robin Murphy <[email protected]>
Cc Steven Price <[email protected]>
Cc Tomeu Vizoso <[email protected]>
---
 drivers/gpu/drm/panfrost/panfrost_gem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_gem.c +6 -2
index a5528a360ef4..886875ae31d3 100644
@@ -52,6 +52,7 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t
 	int ret;
 	struct panfrost_device *pfdev = dev->dev_private;
 	struct panfrost_gem_object *obj;
+	u64 align;
 
 	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
 	if (!obj)
@@ -59,9 +60,12 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t
 
 	obj->base.base.funcs = &panfrost_gem_funcs;
 
+	size = roundup(size, PAGE_SIZE);
+	align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0;
+
 	spin_lock(&pfdev->mm_lock);
-	ret = drm_mm_insert_node(&pfdev->mm, &obj->node,
-				 roundup(size, PAGE_SIZE) >> PAGE_SHIFT);
+	ret = drm_mm_insert_node_generic(&pfdev->mm, &obj->node,
+					 size >> PAGE_SHIFT, align, 0, 0);
 	spin_unlock(&pfdev->mm_lock);
 	if (ret)
 		goto free_obj;
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Rob Herring

In order to increase the chances of using 2MB pages, we need to align the GPU VA mapping to 2MB. Only do this if the object size is 2MB or more.

Cc Robin Murphy <[email protected]>
Cc Steven Price <[email protected]>
Cc Tomeu Vizoso <[email protected]>

Thanks!

Tomeu

Quoted 34 lines
---
 drivers/gpu/drm/panfrost/panfrost_gem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_gem.c +6 -3
index a5528a360ef4..886875ae31d3 100644
@@ -52,6 +52,7 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t
        int ret;
        struct panfrost_device *pfdev = dev->dev_private;
        struct panfrost_gem_object *obj;
+       u64 align;
 
        obj = kzalloc(sizeof(*obj), GFP_KERNEL);
        if (!obj)
@@ -59,9 +60,12 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t
 
        obj->base.base.funcs = &panfrost_gem_funcs;
 
+       size = roundup(size, PAGE_SIZE);
+       align = size >= SZ_2M ? SZ_2M >> PAGE_SHIFT : 0;
+
        spin_lock(&pfdev->mm_lock);
-       ret = drm_mm_insert_node(&pfdev->mm, &obj->node,
-                                roundup(size, PAGE_SIZE) >> PAGE_SHIFT);
+       ret = drm_mm_insert_node_generic(&pfdev->mm, &obj->node,
+                                        size >> PAGE_SHIFT, align, 0, 0);
        spin_unlock(&pfdev->mm_lock);
        if (ret)
                goto free_obj;
--

2.20.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel