Skip to content

Commit

Permalink
CHROMIUM: drm/virtio: Add interfaces to share dma bufs via virtwl.
Browse files Browse the repository at this point in the history
BUG=chromium:892342
TEST=xeyes repeatedly does not fail

Change-Id: Ib74f0992bd9ee2bde10097722c361cdd3e94b64f
Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1351815
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
  • Loading branch information
David Riley authored and chrome-bot committed Jan 8, 2019
1 parent aeb585a commit cea7ac7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions drivers/gpu/drm/virtio/virtgpu_object.c
Expand Up @@ -23,6 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include <linux/dma-buf.h>
#include "virtgpu_drv.h"

static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
Expand Down Expand Up @@ -172,3 +173,22 @@ int virtio_gpu_object_wait(struct virtio_gpu_object *bo, bool no_wait)
return r;
}

int virtio_gpu_dma_buf_to_handle(struct dma_buf *dma_buf, bool no_wait,
uint32_t *handle)
{
struct virtio_gpu_object *qobj;
struct virtio_gpu_device *vgdev;

if (dma_buf->ops != &virtgpu_dmabuf_ops)
return -EINVAL;

qobj = gem_to_virtio_gpu_obj(dma_buf->priv);
vgdev = (struct virtio_gpu_device *)qobj->gem_base.dev->dev_private;
if (!qobj->create_callback_done && !no_wait)
wait_event(vgdev->resp_wq, qobj->create_callback_done);
if (!qobj->create_callback_done)
return -ETIMEDOUT;

*handle = qobj->hw_res_handle;
return 0;
}
24 changes: 24 additions & 0 deletions include/drm/virtio_drm.h
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Virtio GPU interfaces for sharing data.
*
* Copyright (C) 2018 Google, Inc.
*/

#ifndef _VIRTIO_DRM_H
#define _VIRTIO_DRM_H

/*
* The following methods are to share dma bufs with a host via the
* virtio Wayland (virtwl) device.
*/

/*
* Converts the given dma_buf to the virtio-gpu specific resource handle
* backing the dma_buf, waiting for creation to be confirmed by the host
* if necessary.
*/
extern int virtio_gpu_dma_buf_to_handle(struct dma_buf *buf, bool no_wait,
uint32_t *handle);

#endif /* _VIRTIO_DRM_H */

0 comments on commit cea7ac7

Please sign in to comment.