summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/dmabuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/dmabuf.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/dmabuf.c35
1 files changed, 1 insertions, 34 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/dmabuf.c b/drivers/gpu/nvgpu/common/linux/dmabuf.c
index 08cf5f2b..580dfcae 100644
--- a/drivers/gpu/nvgpu/common/linux/dmabuf.c
+++ b/drivers/gpu/nvgpu/common/linux/dmabuf.c
@@ -1,5 +1,5 @@
1/* 1/*
2* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. 2* Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -140,7 +140,6 @@ int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev)
140{ 140{
141 struct gk20a *g = gk20a_get_platform(dev)->g; 141 struct gk20a *g = gk20a_get_platform(dev)->g;
142 struct gk20a_dmabuf_priv *priv; 142 struct gk20a_dmabuf_priv *priv;
143 static u64 priv_count = 0;
144 143
145 priv = dma_buf_get_drvdata(dmabuf, dev); 144 priv = dma_buf_get_drvdata(dmabuf, dev);
146 if (likely(priv)) 145 if (likely(priv))
@@ -159,7 +158,6 @@ int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev)
159 158
160 nvgpu_mutex_init(&priv->lock); 159 nvgpu_mutex_init(&priv->lock);
161 nvgpu_init_list_node(&priv->states); 160 nvgpu_init_list_node(&priv->states);
162 priv->buffer_id = ++priv_count;
163 priv->g = g; 161 priv->g = g;
164 dma_buf_set_drvdata(dmabuf, dev, priv, gk20a_mm_delete_priv); 162 dma_buf_set_drvdata(dmabuf, dev, priv, gk20a_mm_delete_priv);
165 163
@@ -214,34 +212,3 @@ out:
214 *state = s; 212 *state = s;
215 return err; 213 return err;
216} 214}
217
218int gk20a_mm_get_buffer_info(struct device *dev, int dmabuf_fd,
219 u64 *buffer_id, u64 *buffer_len)
220{
221 struct dma_buf *dmabuf;
222 struct gk20a_dmabuf_priv *priv;
223 int err = 0;
224
225 dmabuf = dma_buf_get(dmabuf_fd);
226 if (IS_ERR(dmabuf)) {
227 dev_warn(dev, "%s: fd %d is not a dmabuf", __func__, dmabuf_fd);
228 return PTR_ERR(dmabuf);
229 }
230
231 err = gk20a_dmabuf_alloc_drvdata(dmabuf, dev);
232 if (err) {
233 dev_warn(dev, "Failed to allocate dmabuf drvdata (err = %d)",
234 err);
235 goto clean_up;
236 }
237
238 priv = dma_buf_get_drvdata(dmabuf, dev);
239 if (likely(priv)) {
240 *buffer_id = priv->buffer_id;
241 *buffer_len = dmabuf->size;
242 }
243
244clean_up:
245 dma_buf_put(dmabuf);
246 return err;
247}