Problem importing buffer allocated by etnaviv to imx-drm
Martin Fuzzey
martin.fuzzey at flowbird.group
Thu Jul 12 14:28:02 UTC 2018
Hi Robert,
Latest update: it works!
Thank you for your help!
On 12/07/18 14:45, Robert Foss wrote:
> Hey Martin (& Chris),
>
> This has been a re-occuring pain point on devices with multiple DRM
> nodes to chose from, but recently I added node probing support to mesa
> which lets you avoid hardcoded paths.
>
> https://cgit.freedesktop.org/mesa/mesa/commit/?id=c7bb82136b48b99427465ba4fa3ce477cf09e097
>
>
Yes indeed thank you, I just saw that. It should let me get rid of the
hack below
>>
>> I also tried leaving the gbm_gralloc allocation parameter alone and
>> modifying imx_drm_screen_create() to use /dev/dri/card1 for .kms_fd
>> with the same result.
>>
>> --- a/src/gallium/winsys/imx/drm/imx_drm_winsys.c
>> +++ b/src/gallium/winsys/imx/drm/imx_drm_winsys.c
>> struct pipe_screen *imx_drm_screen_create(int fd)
>> {
>> struct renderonly ro = {
>> .create_for_resource =
>> renderonly_create_kms_dumb_buffer_for_resource,
>> - .kms_fd = fd,
>> + //.kms_fd = fd,
>> + .kms_fd = open("/dev/dri/card1", O_RDWR | O_CLOEXEC), // MF Hack
>> .gpu_fd = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC)
>> };
>>
>>
> Rob Herrings has mentioned that pushing a dev branch for the
> gbm_gralloc handle support is on his Todo list.
> But for now there is another branch, which reportedly has been working
> better.
>
> https://github.com/robherring/gbm_gralloc/commits/handle-rework-v2
>
Yes, just found that this morning too.
That is the key to getting it to work due to this patch which is on that
branch:
commit 137cc39aaa57f8c64db3397cd6ec7600a191a88d
Author: Mauro Rossi <issor.oruam at gmail.com>
Date: Fri Jun 29 13:45:10 2018 +0200
Update usage flag handling for hwc
Add support for GRALLOC_USAGE_HW_COMPOSER usage flag
mapping it to GBM flags, inspired by minigbm implementation.
Fixes the artifacts issues with vulkan hal radv with the following apps
with benefit to all apps using HWC layers:
V1 - GPU Benchmark Pro (Vulkan API)
PPSSPP - PSP emulator
Sascha Willems Vulkan Examples (e.g. Vulkan Gears, Vulkan Texture)
Signed-off-by: Mauro Rossi <issor.oruam at gmail.com>
Signed-off-by: Rob Herring <robh at kernel.org>
diff --git a/gralloc_gbm.cpp b/gralloc_gbm.cpp
index 247fba7..cd37f4d 100644
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -147,6 +147,8 @@ static unsigned int get_pipe_bind(int usage)
bind |= GBM_BO_USE_RENDERING;
if (usage & GRALLOC_USAGE_HW_FB)
bind |= GBM_BO_USE_SCANOUT;
+ if (usage & GRALLOC_USAGE_HW_COMPOSER)
+ bind |= GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
return bind;
}
Since android tags buffers that will be sent to HWC with
GRALLOC_USAGE_HW_COMPOSER they will now be allocated from imx-drm rather
than etnaviv which solves the import problem.
That branch also fixes the structure mismatch problem I mentionned but
requires cherry picking this commit from mesa master so that egl will
compile
commit 3f7bca44d9a9f07eaafc5de850ec65bdd00707b9
Author: Rob Herring <robh at kernel.org>
Date: Thu Apr 26 16:02:01 2018 +0200
egl/android: #ifdef out flink name support
So, I now have it all working, at least to the bootanimation (my boot
doesn't go further for the moment, for reasons unrelated to the graphics
stack).
The only nasty thing remaining is the DRM permissions hack in the kernel.
This is required because the renderonly code uses the imx-drm node to
allocate scanout and hw composer buffers and also to do
drmPrimeHandleToFD() from the graphics allocator process.
But the same device node is opened by the HWC process and it is HWC
that is DRM master.
So, without the kernel hack, drmPrimeHandleToFD() for the scanout / hw
composer buffers fails.
Ways I can think of to fix this:
1) Use AUTHMAGIC ? (But I think that's more or less deprecated today)
and it would require communicating the token between HWC and gralloc
2) Share the fd between gralloc and hwc? Seems to be creating unwanted
coupling.
3) Modify the imx-drm kernel driver to provide a render node and use
that in the renderonly code
#3 looks the best to me at the moment.
Regards,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/etnaviv/attachments/20180712/c5f33dc7/attachment.html>
More information about the etnaviv
mailing list