summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2018-01-22 05:19:08 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-03-01 15:24:06 -0500
commitba8fa334f40223ad491ab61a6c072a276017787f (patch)
treeeb06807ed4fdee3a708f66949c6daf82f193a531 /drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
parent5a35a95654d561fce09a3b9abf6b82bb7a29d74b (diff)
gpu: nvgpu: introduce explicit nvgpu_sgl type
The operations in struct nvgpu_sgt_ops have a scatter-gather list (sgl) argument which is a void pointer. Change the type signatures to take struct nvgpu_sgl * which is an opaque marker type that makes it more difficult to pass around wrong arguments, as anything goes for void *. Explicit types add also self-documentation to the code. For some added safety, some explicit type casts are now required in implementors of the nvgpu_sgt_ops interface when converting between the general nvgpu_sgl type and implementation-specific types. This is not purely a bad thing because the casts explain clearly where type conversions are happening. Jira NVGPU-30 Jira NVGPU-52 Jira NVGPU-305 Change-Id: Ic64eed6d2d39ca5786e62b172ddb7133af16817a Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1643555 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/nvgpu_mem.c')
-rw-r--r--drivers/gpu/nvgpu/common/mm/nvgpu_mem.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
index 73b6b2a7..f7c51f42 100644
--- a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c
+++ b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.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 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
@@ -28,27 +28,29 @@
28 28
29#include "gk20a/gk20a.h" 29#include "gk20a/gk20a.h"
30 30
31void *nvgpu_sgt_get_next(struct nvgpu_sgt *sgt, void *sgl) 31struct nvgpu_sgl *nvgpu_sgt_get_next(struct nvgpu_sgt *sgt,
32 struct nvgpu_sgl *sgl)
32{ 33{
33 return sgt->ops->sgl_next(sgl); 34 return sgt->ops->sgl_next(sgl);
34} 35}
35 36
36u64 nvgpu_sgt_get_phys(struct nvgpu_sgt *sgt, void *sgl) 37u64 nvgpu_sgt_get_phys(struct nvgpu_sgt *sgt, struct nvgpu_sgl *sgl)
37{ 38{
38 return sgt->ops->sgl_phys(sgl); 39 return sgt->ops->sgl_phys(sgl);
39} 40}
40 41
41u64 nvgpu_sgt_get_dma(struct nvgpu_sgt *sgt, void *sgl) 42u64 nvgpu_sgt_get_dma(struct nvgpu_sgt *sgt, struct nvgpu_sgl *sgl)
42{ 43{
43 return sgt->ops->sgl_dma(sgl); 44 return sgt->ops->sgl_dma(sgl);
44} 45}
45 46
46u64 nvgpu_sgt_get_length(struct nvgpu_sgt *sgt, void *sgl) 47u64 nvgpu_sgt_get_length(struct nvgpu_sgt *sgt, struct nvgpu_sgl *sgl)
47{ 48{
48 return sgt->ops->sgl_length(sgl); 49 return sgt->ops->sgl_length(sgl);
49} 50}
50 51
51u64 nvgpu_sgt_get_gpu_addr(struct gk20a *g, struct nvgpu_sgt *sgt, void *sgl, 52u64 nvgpu_sgt_get_gpu_addr(struct gk20a *g, struct nvgpu_sgt *sgt,
53 struct nvgpu_sgl *sgl,
52 struct nvgpu_gmmu_attrs *attrs) 54 struct nvgpu_gmmu_attrs *attrs)
53{ 55{
54 return sgt->ops->sgl_gpu_addr(g, sgl, attrs); 56 return sgt->ops->sgl_gpu_addr(g, sgl, attrs);
@@ -88,7 +90,7 @@ u64 nvgpu_mem_iommu_translate(struct gk20a *g, u64 phys)
88u64 nvgpu_sgt_alignment(struct gk20a *g, struct nvgpu_sgt *sgt) 90u64 nvgpu_sgt_alignment(struct gk20a *g, struct nvgpu_sgt *sgt)
89{ 91{
90 u64 align = 0, chunk_align = 0; 92 u64 align = 0, chunk_align = 0;
91 void *sgl; 93 struct nvgpu_sgl *sgl;
92 94
93 /* 95 /*
94 * If this SGT is iommuable and we want to use the IOMMU address then 96 * If this SGT is iommuable and we want to use the IOMMU address then