From patchwork Mon Mar 2 12:15:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Stevens X-Patchwork-Id: 210772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36457C3F2D2 for ; Mon, 2 Mar 2020 12:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 096D62173E for ; Mon, 2 Mar 2020 12:15:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RbeH33OK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgCBMPk (ORCPT ); Mon, 2 Mar 2020 07:15:40 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34086 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbgCBMPk (ORCPT ); Mon, 2 Mar 2020 07:15:40 -0500 Received: by mail-pf1-f193.google.com with SMTP id y21so1986902pfp.1 for ; Mon, 02 Mar 2020 04:15:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tDVKWN8XWWDBkIxhOMDWJ8WNqkbJxq41FKX/p0TJDsQ=; b=RbeH33OKo6ex4yBiWGoHZuPQZDFiMdnr74+jO7xV8RBZ/HBqXUwdgRgeWFajr7tksx nkaHJorAAEdADlX0fiP8/9c5+GvwCWUWeQ4VEYBE6+cMhEG6KMgTVJkGriOPtN/faamn kQPWVhol1Rc4kvzN1WSkWTuwQMD/+N+ZL/elI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tDVKWN8XWWDBkIxhOMDWJ8WNqkbJxq41FKX/p0TJDsQ=; b=T2jF2+dtV3aCF3n8nFyWkohpqy43veuIvrsGP9UnRJ9dKriZ1V9MN9DW0w43SK9bzk wdy5Dc/5lN+F6X6zas0oTjmYz5VLUdUVztiejMAJncnx2VgbWKbkjbGfMKbcNle72vvm A4QeSsGa1gD3KOtDeC/gWvcjCVb9+nGmuGe1/v9Bvtj2514GUaJroRPVsWGWvmunzoLR +WCleE0l6RPJ1j16sw6wRHQfeG55gEFxzHxeQTGKbFBXRapVnvq5WFUKGLUPNqCDfxxG PyJmFjbzoUa1+Y/eAp53a/hgwraNvdasyC5nZ8JmPmw0Q66Lq63+e0sR8rhOOwkMCiyS cHSw== X-Gm-Message-State: APjAAAXwbhH7/hxh9YA0tSz1zxMFS8uhjhpJB+Yu2rg4v08q7DwprVCZ 5W/hdzIHicdWJshI+yII4ATlqg== X-Google-Smtp-Source: APXvYqxZ1YfM7I9O5uFy/PJVuxbZj1mE7Mg7Fm9ZeSEO9i+JiSLEETE1w1UTUusb8qRcUt3IahS3Fw== X-Received: by 2002:a65:53c9:: with SMTP id z9mr17640332pgr.405.1583151339181; Mon, 02 Mar 2020 04:15:39 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:30f2:7a9c:387e:6c7]) by smtp.gmail.com with ESMTPSA id e9sm12708987pjt.16.2020.03.02.04.15.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Mar 2020 04:15:38 -0800 (PST) From: David Stevens To: Gerd Hoffmann , David Airlie Cc: Daniel Vetter , "Michael S . Tsirkin" , Jason Wang , Sumit Semwal , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Stevens , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, virtio-dev@lists.oasis-open.org Subject: [PATCH v2 1/4] dma-buf: add support for virtio exported objects Date: Mon, 2 Mar 2020 21:15:21 +0900 Message-Id: <20200302121524.7543-2-stevensd@chromium.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200302121524.7543-1-stevensd@chromium.org> References: <20200302121524.7543-1-stevensd@chromium.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This change adds a new dma-buf operation that allows dma-bufs to be used by virtio drivers to share exported objects. The new operation allows the importing driver to query the exporting driver for the UUID which identifies the underlying exported object. Signed-off-by: David Stevens --- drivers/dma-buf/dma-buf.c | 14 ++++++++++++++ include/linux/dma-buf.h | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index d4097856c86b..a04632284ec2 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1158,6 +1158,20 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr) } EXPORT_SYMBOL_GPL(dma_buf_vunmap); +#ifdef CONFIG_VIRTIO +int dma_buf_get_uuid(struct dma_buf *dmabuf, uuid_t *uuid) +{ + if (WARN_ON(!dmabuf) || !uuid) + return -EINVAL; + + if (!dmabuf->ops->get_uuid) + return -ENODEV; + + return dmabuf->ops->get_uuid(dmabuf, uuid); +} +EXPORT_SYMBOL_GPL(dma_buf_get_uuid); +#endif + #ifdef CONFIG_DEBUG_FS static int dma_buf_debug_show(struct seq_file *s, void *unused) { diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index abf5459a5b9d..f5fecf8abe6a 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -251,6 +251,23 @@ struct dma_buf_ops { void *(*vmap)(struct dma_buf *); void (*vunmap)(struct dma_buf *, void *vaddr); + +#ifdef CONFIG_VIRTIO + /** + * @get_uuid + * + * This is called by dma_buf_get_uuid to get the UUID which identifies + * the buffer to virtio devices. + * + * This callback is optional. + * + * Returns: + * + * 0 on success or a negative error code on failure. On success uuid + * will be populated with the buffer's UUID. + */ + int (*get_uuid)(struct dma_buf *dmabuf, uuid_t *uuid); +#endif }; /** @@ -444,4 +461,9 @@ int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *, unsigned long); void *dma_buf_vmap(struct dma_buf *); void dma_buf_vunmap(struct dma_buf *, void *vaddr); + +#ifdef CONFIG_VIRTIO +int dma_buf_get_uuid(struct dma_buf *dmabuf, uuid_t *uuid); +#endif + #endif /* __DMA_BUF_H__ */ From patchwork Mon Mar 2 12:15:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Stevens X-Patchwork-Id: 210771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45CF2C3F2D2 for ; Mon, 2 Mar 2020 12:15:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DAB021739 for ; Mon, 2 Mar 2020 12:15:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kr+5lA7A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727894AbgCBMPu (ORCPT ); Mon, 2 Mar 2020 07:15:50 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44649 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbgCBMPu (ORCPT ); Mon, 2 Mar 2020 07:15:50 -0500 Received: by mail-pg1-f195.google.com with SMTP id a14so5334005pgb.11 for ; Mon, 02 Mar 2020 04:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0PjKVZqL/5Sq/Vlrjx4wKontU7cZeb+ck8gZ9rnWcpM=; b=kr+5lA7AGDXNd+BvQnHGEUM/YIVpMyxfacyW7nSyKmfmJ396uP5V0PPdFEhY/J/GrT XnFMiPJIw/H18rdDZmI1srW8uWy9sb6BAkU12ExSK5qOTQUGo48VcuLz0dlmky47ozdw H2wdzbTsXbAseGijc2gPEB2RiJ3eoe/IqoUd4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0PjKVZqL/5Sq/Vlrjx4wKontU7cZeb+ck8gZ9rnWcpM=; b=gTKLjJOzG9s+vUipfD91LJ7l7Ddfa9t/6HjB7Y0crhRZFGhXEj9l5bILFAE31s0y9U dFZj7CwC9gzCLE2ESBgLyQv8eoj8dYRua9SCeIc99usXpl2yOR2XGsmzH9bPB8l1lS9A aaUjjU7hEtqjt0MPbV4ar6MfZbkiLFrmn0RCTuOB6ajlBbHYk9P14iFtpEvT+4n52phJ d+UV/Eyw0xL05mSk9ip4uu2v3ixb24CqCyR7vSEYYmJF29igNeqfT4LAcdFy9fs8HMJc X8IQK9vFLcgkVy7JiXDb7GD4NSZJY+Lm/iaR+8bLyFOQvMF6m//aL2Vyhwadj0VO2CnT C6WQ== X-Gm-Message-State: ANhLgQ2hBVJR8JFukdojrYF4iVt31tw3kCOjfV999Sn9n1qGp/UbQVEO RkLm0/S8Mz559EJi/dpz/Ag0zA== X-Google-Smtp-Source: ADFU+vv5mcufWUUox/xVUeGl7qutZsD4Ml5QQnKXpnnlbs5XGUy1cyC9WyVCUBNHXvEEfnGjQw1kXQ== X-Received: by 2002:a62:5c2:: with SMTP id 185mr7620057pff.175.1583151349151; Mon, 02 Mar 2020 04:15:49 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:30f2:7a9c:387e:6c7]) by smtp.gmail.com with ESMTPSA id y5sm20788008pfr.169.2020.03.02.04.15.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Mar 2020 04:15:48 -0800 (PST) From: David Stevens To: Gerd Hoffmann , David Airlie Cc: Daniel Vetter , "Michael S . Tsirkin" , Jason Wang , Sumit Semwal , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Stevens , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, virtio-dev@lists.oasis-open.org Subject: [PATCH v2 3/4] virtio-gpu: add VIRTIO_GPU_F_RESOURCE_UUID feature Date: Mon, 2 Mar 2020 21:15:23 +0900 Message-Id: <20200302121524.7543-4-stevensd@chromium.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200302121524.7543-1-stevensd@chromium.org> References: <20200302121524.7543-1-stevensd@chromium.org> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This feature allows the guest to request a UUID from the host for a particular virtio_gpu resource. The UUID can then be shared with other virtio devices, to allow the other host devices to access the virtio_gpu's corresponding host resource. Signed-off-by: David Stevens --- include/uapi/linux/virtio_gpu.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h index 0c85914d9369..9721d58b4d58 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -50,6 +50,10 @@ * VIRTIO_GPU_CMD_GET_EDID */ #define VIRTIO_GPU_F_EDID 1 +/* + * VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID + */ +#define VIRTIO_GPU_F_RESOURCE_UUID 2 enum virtio_gpu_ctrl_type { VIRTIO_GPU_UNDEFINED = 0, @@ -66,6 +70,7 @@ enum virtio_gpu_ctrl_type { VIRTIO_GPU_CMD_GET_CAPSET_INFO, VIRTIO_GPU_CMD_GET_CAPSET, VIRTIO_GPU_CMD_GET_EDID, + VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID, /* 3d commands */ VIRTIO_GPU_CMD_CTX_CREATE = 0x0200, @@ -87,6 +92,7 @@ enum virtio_gpu_ctrl_type { VIRTIO_GPU_RESP_OK_CAPSET_INFO, VIRTIO_GPU_RESP_OK_CAPSET, VIRTIO_GPU_RESP_OK_EDID, + VIRTIO_GPU_RESP_OK_RESOURCE_UUID, /* error responses */ VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200, @@ -340,4 +346,17 @@ enum virtio_gpu_formats { VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134, }; +/* VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID */ +struct virtio_gpu_resource_assign_uuid { + struct virtio_gpu_ctrl_hdr hdr; + __le32 resource_id; + __le32 padding; +}; + +/* VIRTIO_GPU_RESP_OK_RESOURCE_UUID */ +struct virtio_gpu_resp_resource_uuid { + struct virtio_gpu_ctrl_hdr hdr; + __u8 uuid[16]; +}; + #endif