summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
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/gk20a
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/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h5
-rw-r--r--drivers/gpu/nvgpu/gk20a/pramin_gk20a.c6
-rw-r--r--drivers/gpu/nvgpu/gk20a/pramin_gk20a.h8
3 files changed, 11 insertions, 8 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index ac3364b0..5de2b439 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -823,9 +823,10 @@ struct gpu_ops {
823 size_t size); 823 size_t size);
824 struct { 824 struct {
825 u32 (*enter)(struct gk20a *g, struct nvgpu_mem *mem, 825 u32 (*enter)(struct gk20a *g, struct nvgpu_mem *mem,
826 struct nvgpu_sgt *sgt, void *sgl, u32 w); 826 struct nvgpu_sgt *sgt, struct nvgpu_sgl *sgl,
827 u32 w);
827 void (*exit)(struct gk20a *g, struct nvgpu_mem *mem, 828 void (*exit)(struct gk20a *g, struct nvgpu_mem *mem,
828 void *sgl); 829 struct nvgpu_sgl *sgl);
829 u32 (*data032_r)(u32 i); 830 u32 (*data032_r)(u32 i);
830 } pramin; 831 } pramin;
831 struct { 832 struct {
diff --git a/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c
index 05d0473e..bb8831e0 100644
--- a/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.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"),
@@ -32,7 +32,7 @@
32 32
33/* WARNING: returns pramin_window_lock taken, complement with pramin_exit() */ 33/* WARNING: returns pramin_window_lock taken, complement with pramin_exit() */
34u32 gk20a_pramin_enter(struct gk20a *g, struct nvgpu_mem *mem, 34u32 gk20a_pramin_enter(struct gk20a *g, struct nvgpu_mem *mem,
35 struct nvgpu_sgt *sgt, void *sgl, u32 w) 35 struct nvgpu_sgt *sgt, struct nvgpu_sgl *sgl, u32 w)
36{ 36{
37 u64 bufbase = nvgpu_sgt_get_phys(sgt, sgl); 37 u64 bufbase = nvgpu_sgt_get_phys(sgt, sgl);
38 u64 addr = bufbase + w * sizeof(u32); 38 u64 addr = bufbase + w * sizeof(u32);
@@ -64,7 +64,7 @@ u32 gk20a_pramin_enter(struct gk20a *g, struct nvgpu_mem *mem,
64} 64}
65 65
66void gk20a_pramin_exit(struct gk20a *g, struct nvgpu_mem *mem, 66void gk20a_pramin_exit(struct gk20a *g, struct nvgpu_mem *mem,
67 void *sgl) 67 struct nvgpu_sgl *sgl)
68{ 68{
69 gk20a_dbg(gpu_dbg_mem, "end for %p,%p", mem, sgl); 69 gk20a_dbg(gpu_dbg_mem, "end for %p,%p", mem, sgl);
70 70
diff --git a/drivers/gpu/nvgpu/gk20a/pramin_gk20a.h b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.h
index e25bda0c..a0a28088 100644
--- a/drivers/gpu/nvgpu/gk20a/pramin_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.h
@@ -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,7 +28,9 @@ struct nvgpu_mem;
28struct nvgpu_mem_sgl; 28struct nvgpu_mem_sgl;
29 29
30u32 gk20a_pramin_enter(struct gk20a *g, struct nvgpu_mem *mem, 30u32 gk20a_pramin_enter(struct gk20a *g, struct nvgpu_mem *mem,
31 struct nvgpu_sgt *sgt, void *sgl, u32 w); 31 struct nvgpu_sgt *sgt,
32 struct nvgpu_sgl *sgl,
33 u32 w);
32void gk20a_pramin_exit(struct gk20a *g, struct nvgpu_mem *mem, 34void gk20a_pramin_exit(struct gk20a *g, struct nvgpu_mem *mem,
33 void *sgl); 35 struct nvgpu_sgl *sgl);
34#endif 36#endif