diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2018-01-25 16:35:22 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-02-01 16:54:08 -0500 |
commit | 9e283f9f40be0d357e90a355eae6d3b183073184 (patch) | |
tree | cd120793463ee1d52bb17859a9bc665844bac08e /drivers/gpu/nvgpu/common/linux/vm.c | |
parent | 8ca1a765ee066b9f04f39c69d8f3678c06557257 (diff) |
gpu: nvgpu: Add tracking of dma_buf_attachment
VM and CDE code assumes that dma_buf_attachment is stored as a pointer
in the private dma_buf_drvdata, so it is not tracked. In Linux trees
without dma_buf_*_drvdata() support this is not true, so change the
code to explicitly track dma_buf_attachment.
JIRA NVGPU-4
Change-Id: I692f05a19a6469195d5444a7e5ff6e92f77ae272
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1648004
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/vm.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vm.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vm.c b/drivers/gpu/nvgpu/common/linux/vm.c index 4529a322..e3ca4eda 100644 --- a/drivers/gpu/nvgpu/common/linux/vm.c +++ b/drivers/gpu/nvgpu/common/linux/vm.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, |
@@ -150,7 +150,8 @@ struct nvgpu_mapped_buf *nvgpu_vm_find_mapping(struct vm_gk20a *vm, | |||
150 | * If we find the mapping here then that means we have mapped it already | 150 | * If we find the mapping here then that means we have mapped it already |
151 | * and the prior pin and get must be undone. | 151 | * and the prior pin and get must be undone. |
152 | */ | 152 | */ |
153 | gk20a_mm_unpin(os_buf->dev, os_buf->dmabuf, mapped_buffer->os_priv.sgt); | 153 | gk20a_mm_unpin(os_buf->dev, os_buf->dmabuf, os_buf->attachment, |
154 | mapped_buffer->os_priv.sgt); | ||
154 | dma_buf_put(os_buf->dmabuf); | 155 | dma_buf_put(os_buf->dmabuf); |
155 | 156 | ||
156 | nvgpu_log(g, gpu_dbg_map, | 157 | nvgpu_log(g, gpu_dbg_map, |
@@ -184,21 +185,25 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm, | |||
184 | { | 185 | { |
185 | struct gk20a *g = gk20a_from_vm(vm); | 186 | struct gk20a *g = gk20a_from_vm(vm); |
186 | struct device *dev = dev_from_gk20a(g); | 187 | struct device *dev = dev_from_gk20a(g); |
187 | struct nvgpu_os_buffer os_buf = { dmabuf, dev }; | 188 | struct nvgpu_os_buffer os_buf; |
188 | struct sg_table *sgt; | 189 | struct sg_table *sgt; |
189 | struct nvgpu_sgt *nvgpu_sgt = NULL; | 190 | struct nvgpu_sgt *nvgpu_sgt = NULL; |
190 | struct nvgpu_mapped_buf *mapped_buffer = NULL; | 191 | struct nvgpu_mapped_buf *mapped_buffer = NULL; |
192 | struct dma_buf_attachment *attachment; | ||
191 | u64 map_addr = 0ULL; | 193 | u64 map_addr = 0ULL; |
192 | int err = 0; | 194 | int err = 0; |
193 | 195 | ||
194 | if (flags & NVGPU_VM_MAP_FIXED_OFFSET) | 196 | if (flags & NVGPU_VM_MAP_FIXED_OFFSET) |
195 | map_addr = offset_align; | 197 | map_addr = offset_align; |
196 | 198 | ||
197 | sgt = gk20a_mm_pin(dev, dmabuf); | 199 | sgt = gk20a_mm_pin(dev, dmabuf, &attachment); |
198 | if (IS_ERR(sgt)) { | 200 | if (IS_ERR(sgt)) { |
199 | nvgpu_warn(g, "Failed to pin dma_buf!"); | 201 | nvgpu_warn(g, "Failed to pin dma_buf!"); |
200 | return PTR_ERR(sgt); | 202 | return PTR_ERR(sgt); |
201 | } | 203 | } |
204 | os_buf.dmabuf = dmabuf; | ||
205 | os_buf.attachment = attachment; | ||
206 | os_buf.dev = dev; | ||
202 | 207 | ||
203 | if (gk20a_dmabuf_aperture(g, dmabuf) == APERTURE_INVALID) { | 208 | if (gk20a_dmabuf_aperture(g, dmabuf) == APERTURE_INVALID) { |
204 | err = -EINVAL; | 209 | err = -EINVAL; |
@@ -232,13 +237,14 @@ int nvgpu_vm_map_linux(struct vm_gk20a *vm, | |||
232 | } | 237 | } |
233 | 238 | ||
234 | mapped_buffer->os_priv.dmabuf = dmabuf; | 239 | mapped_buffer->os_priv.dmabuf = dmabuf; |
240 | mapped_buffer->os_priv.attachment = attachment; | ||
235 | mapped_buffer->os_priv.sgt = sgt; | 241 | mapped_buffer->os_priv.sgt = sgt; |
236 | 242 | ||
237 | *gpu_va = mapped_buffer->addr; | 243 | *gpu_va = mapped_buffer->addr; |
238 | return 0; | 244 | return 0; |
239 | 245 | ||
240 | clean_up: | 246 | clean_up: |
241 | gk20a_mm_unpin(dev, dmabuf, sgt); | 247 | gk20a_mm_unpin(dev, dmabuf, attachment, sgt); |
242 | 248 | ||
243 | return err; | 249 | return err; |
244 | } | 250 | } |
@@ -316,6 +322,7 @@ void nvgpu_vm_unmap_system(struct nvgpu_mapped_buf *mapped_buffer) | |||
316 | struct vm_gk20a *vm = mapped_buffer->vm; | 322 | struct vm_gk20a *vm = mapped_buffer->vm; |
317 | 323 | ||
318 | gk20a_mm_unpin(dev_from_vm(vm), mapped_buffer->os_priv.dmabuf, | 324 | gk20a_mm_unpin(dev_from_vm(vm), mapped_buffer->os_priv.dmabuf, |
325 | mapped_buffer->os_priv.attachment, | ||
319 | mapped_buffer->os_priv.sgt); | 326 | mapped_buffer->os_priv.sgt); |
320 | 327 | ||
321 | dma_buf_put(mapped_buffer->os_priv.dmabuf); | 328 | dma_buf_put(mapped_buffer->os_priv.dmabuf); |