From patchwork Tue Sep 25 16:16:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10614391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0637112B for ; Tue, 25 Sep 2018 16:16:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0D862971D for ; Tue, 25 Sep 2018 16:16:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3D8D297C1; Tue, 25 Sep 2018 16:16:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B40842971D for ; Tue, 25 Sep 2018 16:16:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C8BC46E3BA; Tue, 25 Sep 2018 16:16:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F28D6E0B3 for ; Tue, 25 Sep 2018 16:16:16 +0000 (UTC) Received: from ezexps.par1.mozilla.com (unknown [IPv6:2a00:8c40:243:232:20d1:1683:13e1:7cd]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ezequiel) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id D51AE27DB46; Tue, 25 Sep 2018 17:16:14 +0100 (BST) From: Ezequiel Garcia To: dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Subject: [PATCH 3/3] virtio: Support prime objects vmap/vunmap Date: Tue, 25 Sep 2018 18:16:06 +0200 Message-Id: <20180925161606.17980-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.19.0.rc2 In-Reply-To: <20180925161606.17980-1-ezequiel@collabora.com> References: <20180925161606.17980-1-ezequiel@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Ezequiel Garcia , Gerd Hoffmann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Implement vmap/vunmap so we can export dmabufs to other drivers, such as video4linux. Tested with a virtio-gpu / vivid (virtual capture driver) pipeline, where the vivid driver imports the dmabufs exported by virtio-gpu. Note that dma_buf_vmap() does its own vmap counting, so it's not needed to take care of it in the driver. Signed-off-by: Ezequiel Garcia --- drivers/gpu/drm/virtio/virtgpu_prime.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index d27a1688714f..86ce0ae93f59 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -55,13 +55,18 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table( void *virtgpu_gem_prime_vmap(struct drm_gem_object *obj) { - WARN_ONCE(1, "not implemented"); - return ERR_PTR(-ENODEV); + struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); + int ret; + + ret = virtio_gpu_object_kmap(bo); + if (ret) + return NULL; + return bo->vmap; } void virtgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) { - WARN_ONCE(1, "not implemented"); + virtio_gpu_object_kunmap(gem_to_virtio_gpu_obj(obj)); } int virtgpu_gem_prime_mmap(struct drm_gem_object *obj,