drm: mmap fixups
Subsystems (3)
cover drm: mmap fixups
Tested on qemu, with bochs (vram helpers) and cirrus (shmem helpers). Cc'ing intel-gfx for CI coverage.
Gerd Hoffmann (2):
drm: call drm_gem_object_funcs.mmap with fake offset
drm: share address space for dma bufs
include/drm/drm_gem.h | 4 +--- drivers/gpu/drm/drm_gem.c | 3 --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ drivers/gpu/drm/drm_prime.c | 7 ++++++- drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ------- 5 files changed, 10 insertions(+), 14 deletions(-)
Signature · 6 lines
2.18.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 drm: call drm_gem_object_funcs.mmap with fake offset
The fake offset is going to stay, so change the calling convention for drm_gem_object_funcs.mmap to include the fake offset. Update all users accordingly.
--- include/drm/drm_gem.h | 4 +--- drivers/gpu/drm/drm_gem.c | 3 --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ drivers/gpu/drm/drm_prime.c | 3 +++ drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ------- 5 files changed, 7 insertions(+), 13 deletions(-)
include/drm/drm_gem.h +1 -3
@@ -159,9 +159,7 @@ struct drm_gem_object_funcs {* * The callback is used by by both drm_gem_mmap_obj() and * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not -* used, the @mmap callback must set vma->vm_ops instead. The @mmap -* callback is always called with a 0 offset. The caller will remove -* the fake offset as necessary. +* used, the @mmap callback must set vma->vm_ops instead. */ int (*mmap)(struct drm_gem_object *obj,struct vm_area_struct *vma);
drivers/gpu/drm/drm_gem.c +0 -3
@@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,return -EINVAL ;if (obj->funcs && obj->funcs->mmap) { -/* Remove the fake offset */ - vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); - ret = obj->funcs->mmap (obj, vma);if (ret)return ret;
drivers/gpu/drm/drm_gem_shmem_helper.c +3 -0
@@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)struct drm_gem_shmem_object *shmem;int ret; +/* Remove the fake offset */ + vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); + shmem =to_drm_gem_shmem_obj (obj); ret =drm_gem_shmem_get_pages (shmem);
drivers/gpu/drm/drm_prime.c +3 -0
@@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)int ret;if (obj->funcs && obj->funcs->mmap) { +/* Add the fake offset */ + vma->vm_pgoff +=drm_vma_node_start (&obj->vma_node); + ret = obj->funcs->mmap (obj, vma);if (ret)return ret;
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -7
@@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap);int ttm_bo_mmap_obj (struct vm_area_struct *vma,struct ttm_buffer_object *bo) {ttm_bo_get (bo); - -/* -* FIXME: &drm_gem_object_funcs.mmap is called with the fake offset -* removed. Add it back here until the rest of TTM works without it. -*/ - vma->vm_pgoff +=drm_vma_node_start (&bo->base.vma_node); -ttm_bo_mmap_vma_setup (bo, vma);return 0 ; }
Signature · 1 line
2.18.1
Re: [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset
Quoted 3 lines · Gerd Hoffmann
The fake offset is going to stay, so change the calling convention for drm_gem_object_funcs.mmap to include the fake offset. Update all users accordingly.
Please add to the commit message:
Note that this reverts 83b8a6f242ea ("drm/gem: Fix mmap fake offset handling for drm_gem_object_funcs.mmap") and on top then adds the fake offset to drm_gem_prime_mmap to make sure all paths leading to obj->funcs->mmap are consistent.
With that also Reviewed-by: Daniel Vetter <[email protected]> -Daniel
Quoted 88 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_gem.h | 4 +--- drivers/gpu/drm/drm_gem.c | 3 --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ drivers/gpu/drm/drm_prime.c | 3 +++ drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ------- 5 files changed, 7 insertions(+), 13 deletions(-)include/drm/drm_gem.h +1
-3@@ -159,9 +159,7 @@ struct drm_gem_object_funcs {* * The callback is used by by both drm_gem_mmap_obj() and * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not -* used, the @mmap callback must set vma->vm_ops instead. The @mmap -* callback is always called with a 0 offset. The caller will remove -* the fake offset as necessary. +* used, the @mmap callback must set vma->vm_ops instead. */ int (*mmap)(struct drm_gem_object *obj,struct vm_area_struct *vma);drivers/gpu/drm/drm_gem.c +0
-3@@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,return -EINVAL ;if (obj->funcs && obj->funcs->mmap) { -/* Remove the fake offset */ - vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); - ret = obj->funcs->mmap (obj, vma);if (ret)return ret;drivers/gpu/drm/drm_gem_shmem_helper.c +3
-0@@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)struct drm_gem_shmem_object *shmem;int ret; +/* Remove the fake offset */ + vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); + shmem =to_drm_gem_shmem_obj (obj); ret =drm_gem_shmem_get_pages (shmem);drivers/gpu/drm/drm_prime.c +3
-0@@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)int ret;if (obj->funcs && obj->funcs->mmap) { +/* Add the fake offset */ + vma->vm_pgoff +=drm_vma_node_start (&obj->vma_node); + ret = obj->funcs->mmap (obj, vma);if (ret)return ret;drivers/gpu/drm/ttm/ttm_bo_vm.c +0
-7@@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap);int ttm_bo_mmap_obj (struct vm_area_struct *vma,struct ttm_buffer_object *bo) {ttm_bo_get (bo); - -/* -* FIXME: &drm_gem_object_funcs.mmap is called with the fake offset -* removed. Add it back here until the rest of TTM works without it. -*/ - vma->vm_pgoff +=drm_vma_node_start (&bo->base.vma_node); -ttm_bo_mmap_vma_setup (bo, vma);return 0 ; }Signature · 1 line
2.18.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/2] drm: call drm_gem_object_funcs.mmap with fake offset
Quoted 12 lines · Daniel Vetter
Quoted 3 lines · Gerd Hoffmann
The fake offset is going to stay, so change the calling convention for drm_gem_object_funcs.mmap to include the fake offset. Update all users accordingly.
Please add to the commit message:
Note that this reverts
83b8a6f242ea("drm/gem: Fix mmap fake offset handling for drm_gem_object_funcs.mmap") and on top then adds the fake offset todrm_gem_prime_mmapto make sure all paths leading toobj->funcs->mmapare consistent.
Quoted 6 lines
Fixes 83b8a6f242ea ("drm/gem: Fix mmap fake offset handling for drm_gem_object_funcs.mmap")Cc Gerd Hoffmann <[email protected]>Cc Daniel Vetter <[email protected]>Cc Rob Herring <[email protected]>With that also Reviewed-by: Daniel Vetter <[email protected]>
Also added Rob to cc here.
Rob, can you pls take a look an ack? The sage took another turn :-) -Daniel
Quoted 94 lines
-Daniel
Quoted 88 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- include/drm/drm_gem.h | 4 +--- drivers/gpu/drm/drm_gem.c | 3 --- drivers/gpu/drm/drm_gem_shmem_helper.c | 3 +++ drivers/gpu/drm/drm_prime.c | 3 +++ drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ------- 5 files changed, 7 insertions(+), 13 deletions(-)include/drm/drm_gem.h +1
-3@@ -159,9 +159,7 @@ struct drm_gem_object_funcs {* * The callback is used by by both drm_gem_mmap_obj() and * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not -* used, the @mmap callback must set vma->vm_ops instead. The @mmap -* callback is always called with a 0 offset. The caller will remove -* the fake offset as necessary. +* used, the @mmap callback must set vma->vm_ops instead. */ int (*mmap)(struct drm_gem_object *obj,struct vm_area_struct *vma);drivers/gpu/drm/drm_gem.c +0
-3@@ -1106,9 +1106,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,return -EINVAL ;if (obj->funcs && obj->funcs->mmap) { -/* Remove the fake offset */ - vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); - ret = obj->funcs->mmap (obj, vma);if (ret)return ret;drivers/gpu/drm/drm_gem_shmem_helper.c +3
-0@@ -528,6 +528,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)struct drm_gem_shmem_object *shmem;int ret; +/* Remove the fake offset */ + vma->vm_pgoff -=drm_vma_node_start (&obj->vma_node); + shmem =to_drm_gem_shmem_obj (obj); ret =drm_gem_shmem_get_pages (shmem);drivers/gpu/drm/drm_prime.c +3
-0@@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)int ret;if (obj->funcs && obj->funcs->mmap) { +/* Add the fake offset */ + vma->vm_pgoff +=drm_vma_node_start (&obj->vma_node); + ret = obj->funcs->mmap (obj, vma);if (ret)return ret;drivers/gpu/drm/ttm/ttm_bo_vm.c +0
-7@@ -514,13 +514,6 @@ EXPORT_SYMBOL(ttm_bo_mmap);int ttm_bo_mmap_obj (struct vm_area_struct *vma,struct ttm_buffer_object *bo) {ttm_bo_get (bo); - -/* -* FIXME: &drm_gem_object_funcs.mmap is called with the fake offset -* removed. Add it back here until the rest of TTM works without it. -*/ - vma->vm_pgoff +=drm_vma_node_start (&bo->base.vma_node); -ttm_bo_mmap_vma_setup (bo, vma);return 0 ; }Signature · 1 line
2.18.1Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 2/2 drm: share address space for dma bufs
In reply to Gerd HoffmannUse the shared address space of the drm device (see drm_open() in drm_file.c) for dma-bufs too. That removes a difference betweem drm device mmap vmas and dma-buf mmap vmas and fixes corner cases like unmaps not working properly.
--- drivers/gpu/drm/drm_prime.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_prime.c +3 -1
@@ -240,6 +240,7 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info) { +struct drm_gem_object *obj = exp_info->priv;struct dma_buf *dma_buf; dma_buf =dma_buf_export (exp_info);
@@ -247,7 +248,8 @@ struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,return dma_buf;drm_dev_get (dev); -drm_gem_object_get (exp_info->priv); +drm_gem_object_get (obj); + dma_buf->file->f_mapping = obj->dev->anon_inode->i_mapping;return dma_buf; }
Signature · 6 lines
2.18.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm: share address space for dma bufs
Quoted 23 lines · Gerd Hoffmann
Use the shared address space of the drm device (see
drm_open()indrm_file.c) for dma-bufs too. That removes a difference betweem drm device mmap vmas and dma-buf mmap vmas and fixes corner cases like unmaps not working properly.Signed-off-by Gerd Hoffmann <[email protected]>--- drivers/gpu/drm/drm_prime.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_prime.c +1
-0@@ -240,6 +240,7 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info) { +struct drm_gem_object *obj = exp_info->priv;struct dma_buf *dma_buf; dma_buf =dma_buf_export (exp_info);
drivers/gpu/drm/drm_prime.c struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, · line 252
Quoted 6 lines
drivers/gpu/drm/drm_prime.c +2
-1@@ -247,7 +248,8 @@ struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev,return dma_buf;drm_dev_get (dev); -drm_gem_object_get (exp_info->priv); +drm_gem_object_get (obj); + dma_buf->file->f_mapping = obj->dev->anon_inode->i_mapping;
Can you pls also throw the change to amdgpu_gem_prime_export on top here? Imo makes a lot more sense that way. With that added I'm happy to r-b. -Daniel
Quoted 6 lines
drivers/gpu/drm/drm_prime.c +0
-0return dma_buf; }Signature · 1 line
2.18.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
RE: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
In reply to Gerd HoffmannQuoted 10 lines
-----Original Message-----
From: Intel-gfx <[email protected]> On Behalf Of Gerd Hoffmann
Sent: Thursday, November 21, 2019 5:38 AM
To: [email protected]
Cc: David Airlie <[email protected]>; [email protected]; open list <[email protected]>; Maxime Ripard <[email protected]>; Gerd Hoffmann <[email protected]>
Subject: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
Quoted 4 lines
Use the shared address space of the drm device (see
drm_open()indrm_file.c) for dma-bufs too. That removes a difference betweem drm device mmap vmas and dma-buf mmap vmas and fixes corner cases like unmaps not working properly.
Hi Gerd,
Just want to make sure I understand this...
So unmaps will not work correctly for mappings when a driver does a drm_vma_node_unamp()?
I.e. the dmabuf mappings will not get cleaned up correctly?
This is a day one bug?
Thanks,
Mike
Quoted 36 lines
Signed-off-by Gerd Hoffmann <[email protected]>---
drivers/gpu/drm/drm_prime.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_prime.c +1
-0@@ -240,6 +240,7 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)struct dma_buf *drm_gem_dmabuf_export (struct drm_device *dev,struct dma_buf_export_info *exp_info) { +struct drm_gem_object *obj = exp_info->priv;struct dma_buf *dma_buf;dma_buf = dma_buf_export(exp_info);drivers/gpu/drm/drm_prime.c +2
-1@@ -247,7 +248,8 @@ struct dma_buf *drm_gem_dmabuf_export(structdrm_device *dev, return dma_buf;drm_dev_get (dev); -drm_gem_object_get (exp_info->priv); +drm_gem_object_get (obj); + dma_buf->file->f_mapping = obj->dev->anon_inode->i_mapping;return dma_buf;}
--
2.18.1_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufs
Quoted 15 lines · Michael J
Quoted 10 lines
-----Original Message-----
From: Intel-gfx <[email protected]> On Behalf Of Gerd Hoffmann
Sent: Thursday, November 21, 2019 5:38 AM
To: [email protected]
Cc: David Airlie <[email protected]>; [email protected]; open list <[email protected]>; Maxime Ripard <[email protected]>; Gerd Hoffmann <[email protected]>
Subject: [Intel-gfx] [PATCH 2/2] drm: share address space for dma bufsQuoted 4 lines
Use the shared address space of the drm device (see
drm_open()indrm_file.c) for dma-bufs too. That removes a difference betweem drm device mmap vmas and dma-buf mmap vmas and fixes corner cases like unmaps not working properly.
Quoted 6 lines
Hi Gerd,
Just want to make sure I understand this...
So unmaps will not work correctly for mappings when a driver does a
drm_vma_node_unamp()?
Completely removing the mapping (aka munmap syscall) works fine. Zapping the pte's (using madvise(dontneed) for example) doesn't.
Quoted 1 line
This is a day one bug?
I guess so, but I'll leave that to others being active longer than me in drm hacking to answer ...
cheers,
Gerd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for drm: mmap fixups
In reply to Gerd Hoffmann== Series Details ==
== Series Details ==
Series: drm: mmap fixups
URL : https://patchwork.freedesktop.org/series/69820/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_7398 -> Patchwork_15373
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/index.html
Known issues
------------
Here are the changes found in Patchwork_15373 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_pm_rpm@module-reload:
- fi-skl-lmem: [PASS][1] -> [DMESG-WARN][2] ([fdo#112261])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7398/fi-skl-lmem/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/fi-skl-lmem/igt@[email protected]
* igt@kms_chamelium@dp-crc-fast:
- fi-icl-u2: [PASS][3] -> [FAIL][4] ([fdo#109635 ] / [fdo#110387])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7398/fi-icl-u2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/fi-icl-u2/igt@[email protected]
#### Possible fixes ####
* igt@gem_sync@basic-many-each:
- {fi-tgl-u}: [INCOMPLETE][5] ([fdo#111880] / [fdo#111998]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7398/fi-tgl-u/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/fi-tgl-u/igt@[email protected]
* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [FAIL][7] ([fdo#108511]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7398/fi-skl-6770hq/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/fi-skl-6770hq/igt@[email protected]
* igt@i915_selftest@live_blt:
- fi-hsw-peppy: [DMESG-FAIL][9] ([fdo#112147]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7398/fi-hsw-peppy/igt@i915_selftest@live_blt.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/fi-hsw-peppy/igt@i915_selftest@live_blt.html
* igt@i915_selftest@live_gem_contexts:
- fi-bsw-nick: [INCOMPLETE][11] ([fdo# 111542]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7398/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo# 111542]: https://bugs.freedesktop.org/show_bug.cgi?id= 111542 [fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#109635 ]: https://bugs.freedesktop.org/show_bug.cgi?id=109635
[fdo#109964]: https://bugs.freedesktop.org/show_bug.cgi?id=109964
[fdo#110387]: https://bugs.freedesktop.org/show_bug.cgi?id=110387
[fdo#111880]: https://bugs.freedesktop.org/show_bug.cgi?id=111880
[fdo#111998]: https://bugs.freedesktop.org/show_bug.cgi?id=111998
[fdo#112147]: https://bugs.freedesktop.org/show_bug.cgi?id=112147
[fdo#112261]: https://bugs.freedesktop.org/show_bug.cgi?id=112261
[fdo#112298]: https://bugs.freedesktop.org/show_bug.cgi?id=112298
Participating hosts (50 -> 44)
------------------------------
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_7398 -> Patchwork_15373
CI-20190529: 20190529
CI_DRM_7398: 1b4907894c189a4607bad6661d9f3073151c08ae @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5299: 65fed6a79adea14f7bef6d55530da47d7731d370 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_15373: 35e853db5823227e1efc88423093a56ea70a6ffc @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
35e853db5823 drm: share address space for dma bufs bafb6d61d97b drm: call drm_gem_object_funcs.mmap with fake offset
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15373/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx