gpu: nvgpu: Add sub-nvgpu_mem

Add an API for creating a special sub-nvgpu_mem struct. This struct
comes with some fairly important caveats but is very useful for the
semaphore code.

Also, make sure that in nvgpu_mem_begin() and nvgpu_mem_end() no
additional mappings are made if not necessary. More importantly during
nvgpu_mem_end() it would be possible to vunmap() a CPU mapping of a
DMA allocation that does not expect this to happen.

JIRA NVGPU-12
JIRA NVGPU-30

Change-Id: I579429da9ff7288488753a113bafc558e0f17a0f
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1464077
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
This commit is contained in:
Alex Waterman
2017-04-10 13:27:47 -07:00
committed by mobile promotions
parent 39524b0941
commit 6a14d980cf
3 changed files with 115 additions and 1 deletions

View File

@@ -334,7 +334,8 @@ static void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem)
{
struct device *d = dev_from_gk20a(g);
if (mem->cpu_va || mem->priv.pages) {
if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) &&
(mem->cpu_va || mem->priv.pages)) {
if (mem->priv.flags) {
DEFINE_DMA_ATTRS(dma_attrs);