diff mbox series

[1/2] drm/i915/gem: Adjust vma offset for framebuffer mmap offset

Message ID 20240802083850.103694-2-andi.shyti@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Fix mmap memory boundary calculation | expand

Commit Message

Andi Shyti Aug. 2, 2024, 8:38 a.m. UTC
When mapping a framebuffer object, the virtual memory area (VMA)
offset ('vm_pgoff') should be adjusted by the start of the
'vma_node' associated with the object. This ensures that the VMA
offset is correctly aligned with the corresponding offset within
the GGTT aperture.

Increment vm_pgoff by the start of the vma_node with the offset=
provided by the user.

Suggested-by: Chris Wilson <chris.p.wilson@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Cavitt, Jonathan Aug. 2, 2024, 5:08 p.m. UTC | #1
-----Original Message-----
From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Andi Shyti
Sent: Friday, August 2, 2024 1:39 AM
To: intel-gfx <intel-gfx@lists.freedesktop.org>; dri-devel <dri-devel@lists.freedesktop.org>
Cc: Jann Horn <jannh@chromium.org>; Jani Nikula <jani.nikula@linux.intel.com>; Joonas Lahtinen <joonas.lahtinen@linux.intel.com>; Vivi, Rodrigo <rodrigo.vivi@intel.com>; Tvrtko Ursulin <tursulin@ursulin.net>; Jann Horn <jannh@google.com>; Chris Wilson <chris.p.wilson@linux.intel.com>; Niemiec, Krzysztof <krzysztof.niemiec@intel.com>; Andi Shyti <andi.shyti@kernel.org>; Auld, Matthew <matthew.auld@intel.com>; Andi Shyti <andi.shyti@linux.intel.com>
Subject: [PATCH 1/2] drm/i915/gem: Adjust vma offset for framebuffer mmap offset
> 
> When mapping a framebuffer object, the virtual memory area (VMA)
> offset ('vm_pgoff') should be adjusted by the start of the
> 'vma_node' associated with the object. This ensures that the VMA
> offset is correctly aligned with the corresponding offset within
> the GGTT aperture.
> 
> Increment vm_pgoff by the start of the vma_node with the offset=
> provided by the user.
> 
> Suggested-by: Chris Wilson <chris.p.wilson@linux.intel.com>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>

LGTM.
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
-Jonathan Cavitt

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index a2195e28b625..ce10dd259812 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -1084,6 +1084,8 @@ int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma
>  		mmo = mmap_offset_attach(obj, mmap_type, NULL);
>  		if (IS_ERR(mmo))
>  			return PTR_ERR(mmo);
> +
> +		vma->vm_pgoff += drm_vma_node_start(&mmo->vma_node);
>  	}
>  
>  	/*
> -- 
> 2.45.2
> 
>
Rodrigo Vivi Aug. 5, 2024, 9:12 p.m. UTC | #2
On Fri, Aug 02, 2024 at 10:38:49AM +0200, Andi Shyti wrote:
> When mapping a framebuffer object, the virtual memory area (VMA)
> offset ('vm_pgoff') should be adjusted by the start of the
> 'vma_node' associated with the object. This ensures that the VMA
> offset is correctly aligned with the corresponding offset within
> the GGTT aperture.
> 
> Increment vm_pgoff by the start of the vma_node with the offset=
> provided by the user.
> 
> Suggested-by: Chris Wilson <chris.p.wilson@linux.intel.com>
> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index a2195e28b625..ce10dd259812 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -1084,6 +1084,8 @@ int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma
>  		mmo = mmap_offset_attach(obj, mmap_type, NULL);
>  		if (IS_ERR(mmo))
>  			return PTR_ERR(mmo);
> +
> +		vma->vm_pgoff += drm_vma_node_start(&mmo->vma_node);
>  	}
>  
>  	/*
> -- 
> 2.45.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index a2195e28b625..ce10dd259812 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -1084,6 +1084,8 @@  int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma
 		mmo = mmap_offset_attach(obj, mmap_type, NULL);
 		if (IS_ERR(mmo))
 			return PTR_ERR(mmo);
+
+		vma->vm_pgoff += drm_vma_node_start(&mmo->vma_node);
 	}
 
 	/*