ac/virtio: add virtio-only AMDGPU_GEM_CREATE flag
On the host side virglrenderer creates dmabuf on demand when: * cpu mapping is requested * setting up scan out * sharing buffers between guest processes On-demand dmabuf creation only works if the ctx that created the BO still exists and knows about this BO. This assumption works ok for the first 2 cases, but can break with the last one (and it does cause issues on Android). eg: * process A allocates BO and exports it as a guest dmabuf * process A closes its handle to the BO (-> detach_resource) * process B imports the guest dmabuf -> this triggers the attach_resource function in virglrenderer. If the given resource isn't a VIRGL_RESOURCE_FD_DMABUF it'll try to get one... But for this to work, process A needs to be used -> this fails because this resource was detached from it. The reason we create dmabuf on demand is to avoid hitting the number of open file descriptor limit. So to cover the 3rd case, we'll use the VIRTGPU_BLOB_FLAG_USE_SHAREABLE flag, but try to limit to as few possible buffers as possible. Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21658>
This commit is contained in:
committed by
Marge Bot
parent
6b6340fea1
commit
6c0e4a0ece
@@ -403,4 +403,9 @@ enum amd_cmp_class_flags
|
||||
P_INFINITY = 1 << 9 // Positive infinity
|
||||
};
|
||||
|
||||
/* Use the last bit of AMDGPU_GEM_CREATE_* flag as a virtio-only
|
||||
* flag.
|
||||
*/
|
||||
#define AMDGPU_GEM_CREATE_VIRTIO_SHARED 1u << 31
|
||||
|
||||
#endif /* _SID_H */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "util/os_mman.h"
|
||||
#include "util/os_time.h"
|
||||
#include "util/u_math.h"
|
||||
#include "sid.h"
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <string.h>
|
||||
@@ -177,6 +178,11 @@ int amdvgpu_bo_alloc(amdvgpu_device_handle dev,
|
||||
if (!(request->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS))
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_MAPPABLE;
|
||||
|
||||
if (request->flags & AMDGPU_GEM_CREATE_VIRTIO_SHARED) {
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
|
||||
req.r.flags &= ~AMDGPU_GEM_CREATE_VIRTIO_SHARED;
|
||||
}
|
||||
|
||||
/* blob_id 0 is reserved for the shared memory buffer. */
|
||||
assert(req.blob_id > 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user