Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2210904ybf; Mon, 2 Mar 2020 04:17:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwfC5L0Wrp/wTUrzlKK/WPk3s76MxDrwi4FoTsh4JTqh0qyxPow0E1TR4ottxPfjLe3ej1N X-Received: by 2002:a9d:51cb:: with SMTP id d11mr7097984oth.219.1583151478135; Mon, 02 Mar 2020 04:17:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583151478; cv=none; d=google.com; s=arc-20160816; b=eJOUPTORKHWrivCZTpj+8BHQTN/2y5mytm6Kcx7lUgUD/bq4bFjJitLBxHW1XbH3w1 akSylV5HEOlrATOh8iPPR/ot854j5ALDMe3np61RK/BEcsyTj/PVri7z/MI/iRb4LN1v JeiVxAhQ+UJ965OJj47UzIBqDQm+wQUCWHSvOiVbM3X4/K7DjACzZSstCD611tEhRaox TqUgB82/iZSr9nwQdSqJPXkMXB3RU+G6VL5heRxwNXc6/3S8v/DvNk4fcymOuM5d11fH dGfojK3hXjTw1xNGuOU58yGH9htmarJfutUBgN3JZrTlAg188qxBjwi+nZDajrCkFhzM cU6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tDVKWN8XWWDBkIxhOMDWJ8WNqkbJxq41FKX/p0TJDsQ=; b=VbK4i6CUGH2j3nUZOlhpvUjkOU5wfVj+Z3VeIMviC9mzIlcqUMQRC33Wv2vAcTwW8h 5Ns/GjpNivCdO8e0eUemiZMClHBSbdRB522F6Wq3EDk4gadDb8c39PXJJhYNH+7rQASQ la13GGa4Al9jB6azDpzKO20buQO7wsXwQkGhyaCnnOmIe40KsT/9YAL1Wj5SDXmpMacH rSk5nuZ3iRFgaMmry8kC1DmWFDnhNkjTnicy8VRL05HqQPDxExmaLfzybpPPYQlYH1L+ G1FU6faoLoj12J5Jf+Z50DGgqe8q1LOLsRS3/Tvq/OL6GCriAL5+DVZqOLjNAWoon0Rd TMGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RbeH33OK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z24si3385471otq.201.2020.03.02.04.17.45; Mon, 02 Mar 2020 04:17:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RbeH33OK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbgCBMPk (ORCPT + 99 others); Mon, 2 Mar 2020 07:15:40 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37808 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbgCBMPk (ORCPT ); Mon, 2 Mar 2020 07:15:40 -0500 Received: by mail-pg1-f196.google.com with SMTP id z12so5355273pgl.4 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=OQ9TcVRKMnLs8IKdMdrPCkfNgdsjO2SxxbUyHpdAghFEGQKR6bpJMJQR/NDMuP/92g Z9Q1vCdfuyueoXf23O6AAbwiRR+q4Ps+MrY3n2CdK5fSOtRrso4W1Xooj05oo9aAXUrW urARmccv5+DnvDlxLinHm220lID19lJ2WJeuF0BYQF/+4nnpDbATYrqys+Ujx79UUTia nKeRpEsnva+wJzDk458wDYBq3QyE/W9Yw4fwYrEBU1ZIUcmqTAPnhnFjQh3L2HEFVt+G EOaCAsKsmlqRY5ENKD7iMS2emfM2irwkU12qABOqyVU13MaK3vmqtcr1RaFIZDKeKfRY QuOw== X-Gm-Message-State: APjAAAWbbG0RTR04N1KYos8A4FE37N+Qv1C4f0hz2U45813ULuwcG3OP bS4vm9A4g/g1Fbj8MmpILFWfGa/ozh8= 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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__ */ -- 2.25.0.265.gbab2e86ba0-goog