summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/include
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2018-09-12 05:40:10 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-24 18:53:48 -0400
commitc47eab005ad9a26a36d2c7ca1595c790ff1bc40d (patch)
treebfaa8f27f141a98478b664ba8b2ae5ba788546a6 /drivers/gpu/nvgpu/include
parent5c7a740403fe5b65149b8b30d1007fd02b33c890 (diff)
gpu: nvgpu: move tsg code to common
tsg_gk20a.c doesn't depend on any specific hardware, so move it to the common directory. Rename the posix tsg file to posix-tsg.c. Jira NVGPU-967 Change-Id: I6e8908a8f6cf43132db8dffe3a99e424e4f764b1 Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1821509 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/include')
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/gk20a.h2
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/tsg.h128
2 files changed, 129 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
index 2fd533c6..ad77f802 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
@@ -66,11 +66,11 @@ struct nvgpu_gpfifo_args;
66#include <nvgpu/nvlink.h> 66#include <nvgpu/nvlink.h>
67#include <nvgpu/sim.h> 67#include <nvgpu/sim.h>
68#include <nvgpu/ecc.h> 68#include <nvgpu/ecc.h>
69#include <nvgpu/tsg.h>
69 70
70#include "gk20a/clk_gk20a.h" 71#include "gk20a/clk_gk20a.h"
71#include "gk20a/ce2_gk20a.h" 72#include "gk20a/ce2_gk20a.h"
72#include "gk20a/fifo_gk20a.h" 73#include "gk20a/fifo_gk20a.h"
73#include "gk20a/tsg_gk20a.h"
74#include "clk/clk.h" 74#include "clk/clk.h"
75#include "perf/perf.h" 75#include "perf/perf.h"
76#include "pmgr/pmgr.h" 76#include "pmgr/pmgr.h"
diff --git a/drivers/gpu/nvgpu/include/nvgpu/tsg.h b/drivers/gpu/nvgpu/include/nvgpu/tsg.h
new file mode 100644
index 00000000..bed84986
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/nvgpu/tsg.h
@@ -0,0 +1,128 @@
1/*
2 * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22#ifndef TSG_GK20A_H
23#define TSG_GK20A_H
24
25#include <nvgpu/lock.h>
26#include <nvgpu/kref.h>
27#include <nvgpu/rwsem.h>
28
29#include "gk20a/gr_gk20a.h"
30
31#define NVGPU_INVALID_TSG_ID (-1)
32
33struct channel_gk20a;
34
35bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch);
36struct tsg_gk20a *gk20a_tsg_open(struct gk20a *g, pid_t pid);
37void gk20a_tsg_release(struct nvgpu_ref *ref);
38
39int gk20a_init_tsg_support(struct gk20a *g, u32 tsgid);
40struct tsg_gk20a *tsg_gk20a_from_ch(struct channel_gk20a *ch);
41
42struct nvgpu_tsg_sm_error_state {
43 u32 hww_global_esr;
44 u32 hww_warp_esr;
45 u64 hww_warp_esr_pc;
46 u32 hww_global_esr_report_mask;
47 u32 hww_warp_esr_report_mask;
48};
49
50struct tsg_gk20a {
51 struct gk20a *g;
52
53 struct vm_gk20a *vm;
54 struct nvgpu_mem *eng_method_buffers;
55
56
57 struct nvgpu_gr_ctx gr_ctx;
58 struct nvgpu_ref refcount;
59
60 struct nvgpu_list_node ch_list;
61 struct nvgpu_list_node event_id_list;
62 struct nvgpu_rwsem ch_list_lock;
63 struct nvgpu_mutex event_id_list_lock;
64 int num_active_channels;
65
66 unsigned int timeslice_us;
67 unsigned int timeslice_timeout;
68 unsigned int timeslice_scale;
69
70 u32 interleave_level;
71 int tsgid;
72
73 u32 runlist_id;
74 pid_t tgid;
75 u32 num_active_tpcs;
76 u8 tpc_pg_enabled;
77 bool tpc_num_initialized;
78 bool in_use;
79
80 struct nvgpu_tsg_sm_error_state *sm_error_states;
81
82#define NVGPU_SM_EXCEPTION_TYPE_MASK_NONE (0x0U)
83#define NVGPU_SM_EXCEPTION_TYPE_MASK_FATAL (0x1U << 0)
84 u32 sm_exception_mask_type;
85};
86
87int gk20a_enable_tsg(struct tsg_gk20a *tsg);
88int gk20a_disable_tsg(struct tsg_gk20a *tsg);
89int gk20a_tsg_bind_channel(struct tsg_gk20a *tsg,
90 struct channel_gk20a *ch);
91int gk20a_tsg_unbind_channel(struct channel_gk20a *ch);
92
93void gk20a_tsg_event_id_post_event(struct tsg_gk20a *tsg,
94 int event_id);
95int gk20a_tsg_set_runlist_interleave(struct tsg_gk20a *tsg, u32 level);
96int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice);
97u32 gk20a_tsg_get_timeslice(struct tsg_gk20a *tsg);
98int gk20a_tsg_set_priority(struct gk20a *g, struct tsg_gk20a *tsg,
99 u32 priority);
100int gk20a_tsg_alloc_sm_error_states_mem(struct gk20a *g,
101 struct tsg_gk20a *tsg,
102 u32 num_sm);
103void gk20a_tsg_update_sm_error_state_locked(struct tsg_gk20a *tsg,
104 u32 sm_id,
105 struct nvgpu_tsg_sm_error_state *sm_error_state);
106
107struct gk20a_event_id_data {
108 struct gk20a *g;
109
110 int id; /* ch or tsg */
111 int pid;
112 u32 event_id;
113
114 bool event_posted;
115
116 struct nvgpu_cond event_id_wq;
117 struct nvgpu_mutex lock;
118 struct nvgpu_list_node event_id_node;
119};
120
121static inline struct gk20a_event_id_data *
122gk20a_event_id_data_from_event_id_node(struct nvgpu_list_node *node)
123{
124 return (struct gk20a_event_id_data *)
125 ((uintptr_t)node - offsetof(struct gk20a_event_id_data, event_id_node));
126};
127
128#endif /* TSG_GK20A_H */