drm/vkms: prime import support
PATCH 1/1 drm/vkms: prime import support
Bring dmabuf sharing through implementing prime_import_sg_table callback. This will help to validate userspace conformance in prime configurations without using any actual hardware (e.g. in the cloud).
--- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++ drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++++ drivers/gpu/drm/vkms/vkms_gem.c | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)
drivers/gpu/drm/vkms/vkms_drv.c +6 -0
@@ -10,6 +10,7 @@*/ #include <linux/module.h> +#include <linux/dma-buf.h> #include <drm/drm_gem.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h>
@@ -96,6 +97,8 @@ static struct drm_driver vkms_driver = { .gem_vm_ops = &vkms_gem_vm_ops, .gem_free_object_unlocked = vkms_gem_free_object, .get_vblank_timestamp = vkms_get_vblank_timestamp, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_import_sg_table = vkms_prime_import_sg_table, .name = DRIVER_NAME, .desc = DRIVER_DESC,
@@ -147,6 +150,9 @@ static int __init vkms_init(void) ret =drm_dev_init (&vkms_device->drm, &vkms_driver, &vkms_device->platform->dev); + +dma_coerce_mask_and_coherent (vkms_device->drm.dev, +DMA_BIT_MASK (64 ));if (ret) goto out_unregister;
drivers/gpu/drm/vkms/vkms_drv.h +9 -0
@@ -126,6 +126,9 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,u32 *handle, u64 size); +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size); +vm_fault_t vkms_gem_fault (struct vm_fault *vmf); int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,
@@ -137,6 +140,12 @@ int vkms_gem_vmap(struct drm_gem_object *obj);void vkms_gem_vunmap (struct drm_gem_object *obj); +/* Prime */ +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg); +/* CRC Support */ const char *const *vkms_get_crc_sources (struct drm_crtc *crtc,size_t *count);
drivers/gpu/drm/vkms/vkms_gem.c +46 -0
60 lines not on this page · raw message
Signature · 6 lines
2.22.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for drm/vkms: prime import support
== Series Details ==
== Series Details ==
Series: drm/vkms: prime import support
URL : https://patchwork.freedesktop.org/series/63213/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6408 -> Patchwork_13524
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/
Known issues
------------
Here are the changes found in Patchwork_13524 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_ctx_exec@basic:
- fi-icl-u3: [PASS][1] -> [DMESG-WARN][2] ([fdo#107724])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/fi-icl-u3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/fi-icl-u3/igt@[email protected]
#### Possible fixes ####
* igt@kms_frontbuffer_tracking@basic:
- fi-icl-dsi: [FAIL][3] ([fdo#103167]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/fi-icl-dsi/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/fi-icl-dsi/igt@[email protected]
- fi-icl-u2: [FAIL][5] ([fdo#103167]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/fi-icl-u2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/fi-icl-u2/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485
[fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
Participating hosts (53 -> 47)
------------------------------
Additional (2): fi-kbl-r fi-cml-u
Missing (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_6408 -> Patchwork_13524
CI_DRM_6408: ee60427a5d560ee44370d88f70db1497df9df979 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5082: f7c51e6fbf8da0784b64a1edaee5266aa9b9f829 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13524: 33cd7357002771577344d5efc010a46d28bdb198 @ git://anongit.freedesktop.org/gfx-ci/linux
== Kernel 32bit build ==
Warning: Kernel 32bit buildtest failed:
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/build_32bit.log
CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh CHK include/generated/compile.h
Kernel: arch/x86/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST 112 modules
ERROR: "__udivdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: "__divdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! scripts/Makefile.modpost:91: recipe for target '__modpost' failed make[1]: *** [__modpost] Error 1
Makefile:1287: recipe for target 'modules' failed
make: *** [modules] Error 2
== Linux commits ==
33cd73570027 drm/vkms: prime import support
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/vkms: prime import support
In reply to Oleg Vasilev== Series Details ==
== Series Details ==
Series: drm/vkms: prime import support
URL : https://patchwork.freedesktop.org/series/63213/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6408_full -> Patchwork_13524_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_13524_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_busy@close-race:
- shard-kbl: [PASS][1] -> [DMESG-FAIL][2] ([fdo#111063])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-kbl3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-kbl6/igt@[email protected]
* igt@gem_wait@write-wait-bcs0:
- shard-hsw: [PASS][3] -> [INCOMPLETE][4] ([fdo#103540])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-hsw1/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-hsw4/igt@[email protected]
* igt@gem_workarounds@suspend-resume-context:
- shard-apl: [PASS][5] -> [DMESG-WARN][6] ([fdo#108566]) +2 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-apl2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-apl5/igt@[email protected]
* igt@kms_addfb_basic@no-handle:
- shard-hsw: [PASS][7] -> [SKIP][8] ([fdo#109271])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-hsw1/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-hsw4/igt@[email protected]
* igt@kms_flip@flip-vs-expired-vblank:
- shard-skl: [PASS][9] -> [FAIL][10] ([fdo#105363])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl8/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl8/igt@[email protected]
* igt@kms_flip@plain-flip-ts-check:
- shard-glk: [PASS][11] -> [FAIL][12] ([fdo#100368])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-glk7/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-glk3/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbc-stridechange:
- shard-iclb: [PASS][13] -> [FAIL][14] ([fdo#103167]) +3 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-iclb2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-iclb8/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbc-tilingchange:
- shard-skl: [PASS][15] -> [FAIL][16] ([fdo#108040])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl3/igt@[email protected]
* igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-mmap-gtt:
- shard-skl: [PASS][17] -> [FAIL][18] ([fdo#103167])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl1/igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-mmap-gtt.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl3/igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-mmap-gtt.html
* igt@kms_plane_alpha_blend@pipe-a-coverage-7efc:
- shard-skl: [PASS][19] -> [FAIL][20] ([fdo#108145])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl1/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl3/igt@[email protected]
* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [PASS][21] -> [FAIL][22] ([fdo#108145] / [fdo#110403])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl3/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl9/igt@[email protected]
* igt@kms_psr2_su@frontbuffer:
- shard-iclb: [PASS][23] -> [SKIP][24] ([fdo#109642] / [fdo#111068])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-iclb2/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-iclb3/igt@[email protected]
* igt@kms_psr@no_drrs:
- shard-iclb: [PASS][25] -> [FAIL][26] ([fdo#108341])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-iclb7/igt@kms_psr@no_drrs.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-iclb1/igt@kms_psr@no_drrs.html
* igt@perf@polling:
- shard-skl: [PASS][27] -> [FAIL][28] ([fdo#110728])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl1/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl3/igt@[email protected]
#### Possible fixes ####
* igt@gem_softpin@noreloc-s3:
- shard-skl: [INCOMPLETE][29] ([fdo#104108]) -> [PASS][30] +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl9/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl1/igt@[email protected]
* igt@gem_tiled_fence_blits@normal:
- shard-iclb: [INCOMPLETE][31] ([fdo#107713]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-iclb7/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-iclb5/igt@[email protected]
* igt@kms_cursor_crc@pipe-c-cursor-suspend:
- shard-skl: [INCOMPLETE][33] ([fdo#110741]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-skl1/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-skl1/igt@[email protected]
* igt@kms_flip@flip-vs-suspend-interruptible:
- shard-apl: [DMESG-WARN][35] ([fdo#108566]) -> [PASS][36] +3 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-apl1/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-apl3/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbc-badstride:
- shard-iclb: [FAIL][37] ([fdo#103167]) -> [PASS][38] +7 similar issues
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-iclb5/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-iclb5/igt@[email protected]
* igt@kms_psr@psr2_cursor_render:
- shard-iclb: [SKIP][39] ([fdo#109441]) -> [PASS][40] +3 similar issues
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6408/shard-iclb1/igt@kms_psr@psr2_cursor_render.html
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/shard-iclb2/igt@kms_psr@psr2_cursor_render.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#100368]: https://bugs.freedesktop.org/show_bug.cgi?id=100368
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108040]: https://bugs.freedesktop.org/show_bug.cgi?id=108040
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
[fdo#110728]: https://bugs.freedesktop.org/show_bug.cgi?id=110728
[fdo#110741]: https://bugs.freedesktop.org/show_bug.cgi?id=110741
[fdo#111063]: https://bugs.freedesktop.org/show_bug.cgi?id=111063
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
Participating hosts (10 -> 10)
------------------------------
No changes in participating hosts
Build changes
-------------
* Linux: CI_DRM_6408 -> Patchwork_13524
CI_DRM_6408: ee60427a5d560ee44370d88f70db1497df9df979 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5082: f7c51e6fbf8da0784b64a1edaee5266aa9b9f829 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13524: 33cd7357002771577344d5efc010a46d28bdb198 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13524/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Oleg,
First of all, thank you for your patch and for working in this issue.
A few comments inline.
Quoted 20 lines · Oleg Vasilev
Bring dmabuf sharing through implementing
prime_import_sg_tablecallback. This will help to validate userspace conformance in prime configurations without using any actual hardware (e.g. in the cloud).Cc Rodrigo Siqueira <[email protected]>Cc Haneen Mohammed <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Oleg Vasilev <[email protected]>--- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++ drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++++ drivers/gpu/drm/vkms/vkms_gem.c | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)drivers/gpu/drm/vkms/vkms_drv.c +0
-0
drivers/gpu/drm/vkms/vkms_drv.c line 13
Quoted 4 lines
drivers/gpu/drm/vkms/vkms_drv.c +1
-0@@ -10,6 +10,7 @@*/ #include <linux/module.h> +#include <linux/dma-buf.h>
Maybe I missed something, but I think you don't need to add this include here since you already included it on vkms_gem.
Quoted 13 lines
drivers/gpu/drm/vkms/vkms_drv.c +2
-0#include <drm/drm_gem.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> @@ -96,6 +97,8 @@ static struct drm_driver vkms_driver = { .gem_vm_ops = &vkms_gem_vm_ops, .gem_free_object_unlocked = vkms_gem_free_object, .get_vblank_timestamp = vkms_get_vblank_timestamp, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_import_sg_table = vkms_prime_import_sg_table, .name = DRIVER_NAME, .desc = DRIVER_DESC,
drivers/gpu/drm/vkms/vkms_drv.c static int __init vkms_init(void) · line 155
Quoted 6 lines
drivers/gpu/drm/vkms/vkms_drv.c +3
-0@@ -147,6 +150,9 @@ static int __init vkms_init(void) ret =drm_dev_init (&vkms_device->drm, &vkms_driver, &vkms_device->platform->dev); + +dma_coerce_mask_and_coherent (vkms_device->drm.dev, +DMA_BIT_MASK (64 ));
How about capture the return value from dma_coerce_mask_and_coherent() and warn the user if something wrong happened? Something like:
ret = dma_coerce_mask_and_coherent(..);
if (ret)
DRM_WARN("Failed to set dma mask");
Additionally, I would like to suggest you move this code above drm_dev_init() since there's a return validation of ret in the below if.
Quoted 42 lines
drivers/gpu/drm/vkms/vkms_drv.c +0
-0if (ret) goto out_unregister;drivers/gpu/drm/vkms/vkms_drv.h +9
-0@@ -126,6 +126,9 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,u32 *handle, u64 size); +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size); +vm_fault_t vkms_gem_fault (struct vm_fault *vmf); int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,@@ -137,6 +140,12 @@ int vkms_gem_vmap(struct drm_gem_object *obj);void vkms_gem_vunmap (struct drm_gem_object *obj); +/* Prime */ +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg); +/* CRC Support */ const char *const *vkms_get_crc_sources (struct drm_crtc *crtc,size_t *count);drivers/gpu/drm/vkms/vkms_gem.c +1
-0@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ +#include <linux/dma-buf.h> #include <linux/shmem_fs.h> #include "vkms_drv.h"
drivers/gpu/drm/vkms/vkms_gem.c struct drm_gem_object *vkms_gem_create(struct drm_device *dev, · line 123
Quoted 6 lines
drivers/gpu/drm/vkms/vkms_gem.c +3
-0@@ -117,6 +118,25 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,return &obj->gem; } +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size) +{
I did not fully get the idea behind this function in this patch, and it looks like this function is never invoked. Am I right or I missed something?
drivers/gpu/drm/vkms/vkms_gem.c struct drm_gem_object *vkms_gem_create(struct drm_device *dev, · line 133
Quoted 10 lines
drivers/gpu/drm/vkms/vkms_gem.c +10
-0+struct vkms_gem_object *obj; + + obj =kzalloc (sizeof (*obj),GFP_KERNEL ); + +if (!obj) +return ERR_PTR (-ENOMEM ); + + size =roundup (size,PAGE_SIZE ); + +drm_gem_private_object_init (dev, &obj->gem, size);
Please, correct if I'm wrong, I'm trying to understand where this function should be placed and when it is invoked. If I correctly understood, you want to use this function for creating a separate gem object to be used as a private area to be shared with another device, am I right? If I am right, I'm wondering if we could reuse or update some of the functions available in the vkms_gem. If I am wrong, I'm wondering if we may have synchronization problems for handling multiples mutex for accessing pages. Could you help me here?
Quoted 20 lines
drivers/gpu/drm/vkms/vkms_gem.c +13
-0+ +mutex_init (&obj->pages_lock); + +return obj; +} +int vkms_dumb_create (struct drm_file *file,struct drm_device *dev,struct drm_mode_create_dumb *args) {@@ -217,3 +237,29 @@ int vkms_gem_vmap(struct drm_gem_object *obj)mutex_unlock (&vkms_obj->pages_lock);return ret; } + +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg) +{ +struct vkms_gem_object *obj;
drivers/gpu/drm/vkms/vkms_gem.c int vkms_gem_vmap(struct drm_gem_object *obj) · line 256
Quoted 10 lines
drivers/gpu/drm/vkms/vkms_gem.c +10
-0+int npages; + + obj =__vkms_gem_create (dev, attach->dmabuf->size); +if (IS_ERR (obj)) +return ERR_CAST (obj); + + npages =PAGE_ALIGN (attach->dmabuf->size) /PAGE_SIZE ; +DRM_DEBUG_PRIME ("Importing %d pages\n" , npages); + + obj->pages =kvmalloc_array (npages,sizeof (struct page *),GFP_KERNEL );
One question, why not use _get_pages() instead of using kvmalloc_array? Use _get_pages has the advantage of already handling some errors which may reduce the amount of code in this function.
drivers/gpu/drm/vkms/vkms_gem.c int vkms_gem_vmap(struct drm_gem_object *obj) · line 263
Quoted 7 lines
drivers/gpu/drm/vkms/vkms_gem.c +7
-0+if (!obj->pages) { +vkms_gem_free_object (&obj->gem); +return ERR_PTR (-ENOMEM ); + } + +drm_prime_sg_to_page_addr_arrays (sg, obj->pages,NULL , + npages);
Why not add npage in the same line?
Thanks you again.
Quoted 5 lines
drivers/gpu/drm/vkms/vkms_gem.c +2
-1+return &obj->gem; +} --2.22.0
Signature · 6 lines
Rodrigo Siqueira https://siqueira.tech _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Rodrigo,
Thanks for the review.
Quoted 33 lines · Rodrigo Siqueira
Hi Oleg,
First of all, thank you for your patch and for working in this issue.
A few comments inline.
Quoted 25 lines · Oleg Vasilev
Bring dmabuf sharing through implementing
prime_import_sg_tablecallback.
This will help to validate userspace conformance in prime configurations
without using any actual hardware (e.g. in the cloud).Cc Rodrigo Siqueira <[email protected]>Cc Haneen Mohammed <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Oleg Vasilev <[email protected]>--- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++ drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++++ drivers/gpu/drm/vkms/vkms_gem.c | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)drivers/gpu/drm/vkms/vkms_drv.c +0
-0@@ -10,6 +10,7 @@*/
Quoted 5 lines
drivers/gpu/drm/vkms/vkms_drv.c line 13
Quoted 2 lines
drivers/gpu/drm/vkms/vkms_drv.c +1
-0#include <linux/module.h> +#include <linux/dma-buf.h> Maybe I missed something, but I think you don't need to add this include here since you already included it on
vkms_gem.
You are right, we need
#include <linux/dma-mapping.h>
instead.
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/vkms/vkms_drv.c +2
-0#include <drm/drm_gem.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> @@ -96,6 +97,8 @@ static struct drm_driver vkms_driver = { .gem_vm_ops = &vkms_gem_vm_ops, .gem_free_object_unlocked = vkms_gem_free_object, .get_vblank_timestamp = vkms_get_vblank_timestamp, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_import_sg_table = vkms_prime_import_sg_table, .name = DRIVER_NAME, .desc = DRIVER_DESC,@@ -147,6 +150,9 @@ static int __init vkms_init(void)
Quoted 9 lines
drivers/gpu/drm/vkms/vkms_drv.c static int __init vkms_init(void) · line 155
Quoted 5 lines
drivers/gpu/drm/vkms/vkms_drv.c +3
-0ret =drm_dev_init (&vkms_device->drm, &vkms_driver, &vkms_device->platform->dev); + +dma_coerce_mask_and_coherent (vkms_device->drm.dev, +DMA_BIT_MASK (64 ));How about capture the return value from
dma_coerce_mask_and_coherent()
and warn the user if something wrong happened?
I've copypasted this from vgem, where they don't check return value. But I guess, DRM_WARN won't hurt.
Quoted 9 lines
Something like:
ret =dma_coerce_mask_and_coherent(..);if (ret)
DRM_WARN("Failed to set dma mask");Additionally, I would like to suggest you move this code above
drm_dev_init()since there's a return validation of ret in the below if.
Sure.
Quoted 52 lines
Quoted 52 lines
drivers/gpu/drm/vkms/vkms_drv.c +0
-0if (ret) goto out_unregister;drivers/gpu/drm/vkms/vkms_drv.h +3
-0@@ -126,6 +126,9 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, u32 *handle, u64 size); +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size); +vm_fault_t vkms_gem_fault (struct vm_fault *vmf);int vkms_dumb_create(struct
drm_file*file, structdrm_device
*dev,drivers/gpu/drm/vkms/vkms_drv.h +6
-0@@ -137,6 +140,12 @@ int vkms_gem_vmap(struct drm_gem_object *obj);void vkms_gem_vunmap (struct drm_gem_object *obj); +/* Prime */ +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg); +/* CRC Support */ const char *const *vkms_get_crc_sources (struct drm_crtc *crtc,size_t *count);drivers/gpu/drm/vkms/vkms_gem.c +1
-0@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ +#include <linux/dma-buf.h> #include <linux/shmem_fs.h> #include "vkms_drv.h" @@ -117,6 +118,25 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, return &obj->gem; }
Quoted 8 lines
drivers/gpu/drm/vkms/vkms_gem.c struct drm_gem_object *vkms_gem_create(struct drm_device *dev, · line 123
Quoted 4 lines
drivers/gpu/drm/vkms/vkms_gem.c +3
-0+struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size) +{I did not fully get the idea behind this function in this patch, and it looks like this function is never invoked. Am I right or I missed something?
That's true. I've initially intended to use it, but haven't. I keep it in the patch for the sake of consistency, since other drivers have it. I am not sure we have any usage for it at the moment. Should I remove it from the patch?
Quoted 12 lines
drivers/gpu/drm/vkms/vkms_gem.c struct drm_gem_object *vkms_gem_create(struct drm_device *dev, · line 133
Quoted 11 lines
drivers/gpu/drm/vkms/vkms_gem.c +10
-0+struct vkms_gem_object *obj; + + obj =kzalloc (sizeof (*obj),GFP_KERNEL ); + +if (!obj) +return ERR_PTR (-ENOMEM ); + + size =roundup (size,PAGE_SIZE ); + +drm_gem_private_object_init (dev, &obj->gem, size);
Quoted 8 lines
Please, correct if I'm wrong, I'm trying to understand where this function should be placed and when it is invoked. If I correctly understood, you want to use this function for creating a separate gem object to be used as a private area to be shared with another device, am I right? If I am right, I'm wondering if we could reuse or update some of the functions available in the
vkms_gem. If I am wrong, I'm wondering if we may have synchronization problems for handling multiples mutex for accessing pages. Could you help me here?
This private objects are used in i915 to handle prime import. It creates a private object, and then overwrites get/put_pages functions so that pages would come from the right place.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/vkms/vkms_gem.c +5
-0+mutex_init (&obj->pages_lock); + +return obj; +} + int vkms_dumb_create(struct drm_file *file, struct drm_device*dev,
structdrm_mode_create_dumb*args)
{drivers/gpu/drm/vkms/vkms_gem.c +14
-0@@ -217,3 +237,29 @@ int vkms_gem_vmap(struct drm_gem_object *obj)mutex_unlock (&vkms_obj->pages_lock);return ret; } + +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg) +{ +struct vkms_gem_object *obj; +int npages; + + obj =__vkms_gem_create (dev, attach->dmabuf->size); +if (IS_ERR (obj)) +return ERR_CAST (obj); + + npages =PAGE_ALIGN (attach->dmabuf->size) /PAGE_SIZE ;
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/vkms/vkms_gem.c +3
-0+DRM_DEBUG_PRIME ("Importing %d pages\n" , npages); + + obj->pages = kvmalloc_array(npages, sizeof(struct page *),
GFP_KERNEL);One question, why not use
_get_pages()instead of usingkvmalloc_array? Use_get_pageshas the advantage of already handling some errors which may reduce the amount of code in this function.
drm_gem_get_pages also allocates the pages itself. Here we need only the array of pointers, since pages come from the imported object.
Quoted 10 lines
drivers/gpu/drm/vkms/vkms_gem.c int vkms_gem_vmap(struct drm_gem_object *obj) · line 263
Quoted 8 lines
drivers/gpu/drm/vkms/vkms_gem.c +7
-0+if (!obj->pages) { +vkms_gem_free_object (&obj->gem); +return ERR_PTR (-ENOMEM ); + } + +drm_prime_sg_to_page_addr_arrays (sg, obj->pages,NULL , + npages);Why not add npage in the same line?
You are right.
Oleg
Quoted 8 lines
Thanks you again.
Quoted 5 lines
drivers/gpu/drm/vkms/vkms_gem.c +2
-1+return &obj->gem; +} --2.22.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Oleg Vasilev
Bring dmabuf sharing through implementing
prime_import_sg_tablecallback. This will help to validate userspace conformance in prime configurations without using any actual hardware (e.g. in the cloud).Cc Rodrigo Siqueira <[email protected]>Cc Haneen Mohammed <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Oleg Vasilev <[email protected]>
Btw which igt testcases does this enable? Are the igt patches already merged (I think as-is the igt prime tests won't run on vkms).
Imo for vkms we really want to make sure there's tests for everything, otherwise a fake driver for testing/validation is kinda pointless ... -Daniel
Quoted 134 lines
--- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++ drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++++ drivers/gpu/drm/vkms/vkms_gem.c | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)drivers/gpu/drm/vkms/vkms_drv.c +6
-0@@ -10,6 +10,7 @@*/ #include <linux/module.h> +#include <linux/dma-buf.h> #include <drm/drm_gem.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> @@ -96,6 +97,8 @@ static struct drm_driver vkms_driver = { .gem_vm_ops = &vkms_gem_vm_ops, .gem_free_object_unlocked = vkms_gem_free_object, .get_vblank_timestamp = vkms_get_vblank_timestamp, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_import_sg_table = vkms_prime_import_sg_table, .name = DRIVER_NAME, .desc = DRIVER_DESC,@@ -147,6 +150,9 @@ static int __init vkms_init(void) ret =drm_dev_init (&vkms_device->drm, &vkms_driver, &vkms_device->platform->dev); + +dma_coerce_mask_and_coherent (vkms_device->drm.dev, +DMA_BIT_MASK (64 ));if (ret) goto out_unregister;drivers/gpu/drm/vkms/vkms_drv.h +9
-0@@ -126,6 +126,9 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,u32 *handle, u64 size); +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size); +vm_fault_t vkms_gem_fault (struct vm_fault *vmf); int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,@@ -137,6 +140,12 @@ int vkms_gem_vmap(struct drm_gem_object *obj);void vkms_gem_vunmap (struct drm_gem_object *obj); +/* Prime */ +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg); +/* CRC Support */ const char *const *vkms_get_crc_sources (struct drm_crtc *crtc,size_t *count);drivers/gpu/drm/vkms/vkms_gem.c +46
-0@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ +#include <linux/dma-buf.h> #include <linux/shmem_fs.h> #include "vkms_drv.h" @@ -117,6 +118,25 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,return &obj->gem; } +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size) +{ +struct vkms_gem_object *obj; + + obj =kzalloc (sizeof (*obj),GFP_KERNEL ); + +if (!obj) +return ERR_PTR (-ENOMEM ); + + size =roundup (size,PAGE_SIZE ); + +drm_gem_private_object_init (dev, &obj->gem, size); + +mutex_init (&obj->pages_lock); + +return obj; +} +int vkms_dumb_create (struct drm_file *file,struct drm_device *dev,struct drm_mode_create_dumb *args) {@@ -217,3 +237,29 @@ int vkms_gem_vmap(struct drm_gem_object *obj)mutex_unlock (&vkms_obj->pages_lock);return ret; } + +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg) +{ +struct vkms_gem_object *obj; +int npages; + + obj =__vkms_gem_create (dev, attach->dmabuf->size); +if (IS_ERR (obj)) +return ERR_CAST (obj); + + npages =PAGE_ALIGN (attach->dmabuf->size) /PAGE_SIZE ; +DRM_DEBUG_PRIME ("Importing %d pages\n" , npages); + + obj->pages =kvmalloc_array (npages,sizeof (struct page *),GFP_KERNEL ); +if (!obj->pages) { +vkms_gem_free_object (&obj->gem); +return ERR_PTR (-ENOMEM ); + } + +drm_prime_sg_to_page_addr_arrays (sg, obj->pages,NULL , + npages); +return &obj->gem; +}Signature · 1 line
2.22.0
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
Quoted 12 lines · Daniel Vetter
Quoted 10 lines · Oleg Vasilev
Bring dmabuf sharing through implementing
prime_import_sg_tablecallback.
This will help to validate userspace conformance in prime configurations
without using any actual hardware (e.g. in the cloud).Cc Rodrigo Siqueira <[email protected]>Cc Haneen Mohammed <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Oleg Vasilev <[email protected]>
Quoted 7 lines
Btw which igt testcases does this enable? Are the igt patches already merged (I think as-is the igt prime tests won't run on vkms).
Imo for vkms we really want to make sure there's tests for everything,
otherwise a fake driver for testing/validation is kinda pointless ... -Daniel
I've submitted a patch to IGT, but it is not merged yet:
https://patchwork.freedesktop.org/series/63213/
Oleg
Quoted 138 lines
Quoted 138 lines
--- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++ drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++++ drivers/gpu/drm/vkms/vkms_gem.c | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)drivers/gpu/drm/vkms/vkms_drv.c +6
-0@@ -10,6 +10,7 @@*/ #include <linux/module.h> +#include <linux/dma-buf.h> #include <drm/drm_gem.h> #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> @@ -96,6 +97,8 @@ static struct drm_driver vkms_driver = { .gem_vm_ops = &vkms_gem_vm_ops, .gem_free_object_unlocked = vkms_gem_free_object, .get_vblank_timestamp = vkms_get_vblank_timestamp, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_import_sg_table = vkms_prime_import_sg_table, .name = DRIVER_NAME, .desc = DRIVER_DESC,@@ -147,6 +150,9 @@ static int __init vkms_init(void) ret =drm_dev_init (&vkms_device->drm, &vkms_driver, &vkms_device->platform->dev); + +dma_coerce_mask_and_coherent (vkms_device->drm.dev, +DMA_BIT_MASK (64 ));if (ret) goto out_unregister;drivers/gpu/drm/vkms/vkms_drv.h +3
-0@@ -126,6 +126,9 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, u32 *handle, u64 size); +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size); +vm_fault_t vkms_gem_fault (struct vm_fault *vmf);int vkms_dumb_create(struct
drm_file*file, structdrm_device
*dev,drivers/gpu/drm/vkms/vkms_drv.h +6
-0@@ -137,6 +140,12 @@ int vkms_gem_vmap(struct drm_gem_object *obj);void vkms_gem_vunmap (struct drm_gem_object *obj); +/* Prime */ +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg); +/* CRC Support */ const char *const *vkms_get_crc_sources (struct drm_crtc *crtc,size_t *count);drivers/gpu/drm/vkms/vkms_gem.c +20
-0@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ +#include <linux/dma-buf.h> #include <linux/shmem_fs.h> #include "vkms_drv.h" @@ -117,6 +118,25 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev, return &obj->gem; } +struct vkms_gem_object *vkms_gem_create_private (struct drm_device *dev, +u64 size) +{ +struct vkms_gem_object *obj; + + obj =kzalloc (sizeof (*obj),GFP_KERNEL ); + +if (!obj) +return ERR_PTR (-ENOMEM ); + + size =roundup (size,PAGE_SIZE ); + +drm_gem_private_object_init (dev, &obj->gem, size); + +mutex_init (&obj->pages_lock); + +return obj; +} + int vkms_dumb_create(struct drm_file *file, struct drm_device*dev,
drivers/gpu/drm/vkms/vkms_gem.c +17
-0struct drm_mode_create_dumb *args) {@@ -217,3 +237,29 @@ int vkms_gem_vmap(struct drm_gem_object *obj)mutex_unlock (&vkms_obj->pages_lock);return ret; } + +struct drm_gem_object * +vkms_prime_import_sg_table (struct drm_device *dev, +struct dma_buf_attachment *attach, +struct sg_table *sg) +{ +struct vkms_gem_object *obj; +int npages; + + obj =__vkms_gem_create (dev, attach->dmabuf->size); +if (IS_ERR (obj)) +return ERR_CAST (obj); + + npages =PAGE_ALIGN (attach->dmabuf->size) /PAGE_SIZE ; +DRM_DEBUG_PRIME ("Importing %d pages\n" , npages); + + obj->pages = kvmalloc_array(npages, sizeof(struct page *),
GFP_KERNEL);drivers/gpu/drm/vkms/vkms_gem.c +4
-0+if (!obj->pages) { +vkms_gem_free_object (&obj->gem); +return ERR_PTR (-ENOMEM ); + }
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/vkms/vkms_gem.c +5
-0+ +drm_prime_sg_to_page_addr_arrays (sg, obj->pages,NULL , + npages); +return &obj->gem; +}Signature · 1 line
2.22.0
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 17 lines · Oleg Vasilev
Quoted 16 lines · Daniel Vetter
Quoted 10 lines · Oleg Vasilev
Bring dmabuf sharing through implementing
prime_import_sg_tablecallback.
This will help to validate userspace conformance in prime configurations
without using any actual hardware (e.g. in the cloud).Cc Rodrigo Siqueira <[email protected]>Cc Haneen Mohammed <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Oleg Vasilev <[email protected]>Btw which igt testcases does this enable? Are the igt patches already
merged (I think as-is the igt prime tests won't run on vkms).
Quoted 8 lines
Quoted 5 lines
Imo for vkms we really want to make sure there's tests for everything,
otherwise a fake driver for testing/validation is kinda pointless
...
-DanielI've submitted a patch to IGT, but it is not merged yet:
https://patchwork.freedesktop.org/series/63213/
Oops, this one:
https://patchwork.freedesktop.org/patch/315659/?series=63216&rev=1
Quoted 1 line
Oleg
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 24 lines · Oleg
Quoted 23 lines · Oleg Vasilev
Quoted 21 lines · Daniel Vetter
Quoted 10 lines · Oleg Vasilev
Bring dmabuf sharing through implementing
prime_import_sg_tablecallback.
This will help to validate userspace conformance in prime configurations
without using any actual hardware (e.g. in the cloud).Cc Rodrigo Siqueira <[email protected]>Cc Haneen Mohammed <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Oleg Vasilev <[email protected]>Btw which igt testcases does this enable? Are the igt patches already
merged (I think as-is the igt prime tests won't run on vkms).Imo for vkms we really want to make sure there's tests for everything,
otherwise a fake driver for testing/validation is kinda pointless
...
-Daniel
Quoted 5 lines
Quoted 2 lines
I've submitted a patch to IGT, but it is not merged yet:
https://patchwork.freedesktop.org/series/63213/Oops, this one:
https://patchwork.freedesktop.org/patch/315659/?series=63216&rev=1
Ah, replied there. Let's polish the testcase first, then land the kernel side.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel