diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2016-05-12 02:32:05 -0400 |
---|---|---|
committer | Ken Adams <kadams@nvidia.com> | 2016-05-13 10:11:33 -0400 |
commit | 6eebc87d99f9f04b2b68e0bc0142c161ab3e669d (patch) | |
tree | 08e437890869d76072f291ea66f709f05ea07c8a /drivers/gpu/nvgpu/gk20a/debug_gk20a.c | |
parent | 14ef0dacc94077bc3dae4c942ff8c279cc4c92ba (diff) |
gpu: nvgpu: refactor gk20a_mem_{wr,rd} for vidmem
To support vidmem, pass g and mem_desc to the buffer memory accessor
functions. This allows the functions to select the memory access method
based on the buffer aperture instead of using the cpu pointer directly
(like until now). The selection and aperture support will be in another
patch; this patch only refactors these accessors, but keeps the
underlying functionality as-is.
gk20a_mem_{rd,wr}32() work as previously; add also gk20a_mem_{rd,wr}()
for byte-indexed accesses, gk20a_mem_{rd,wr}_n() for memcpy()-like
functionality, and gk20a_memset() for filling buffers with a constant.
The 8 and 16 bit accessor functions are removed.
vmap()/vunmap() pairs are abstracted to gk20a_mem_{begin,end}() to
support other types of mappings or conditions where mapping the buffer
is unnecessary or different.
Several function arguments that would access these buffers are also
changed to take a mem_desc instead of a plain cpu pointer. Some relevant
occasions are changed to use the accessor functions instead of cpu
pointers without them (e.g., memcpying to and from), but the majority of
direct accesses will be adjusted later, when the buffers are moved to
support vidmem.
JIRA DNVGPU-23
Change-Id: I3dd22e14290c4ab742d42e2dd327ebeb5cd3f25a
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1121143
Reviewed-by: Ken Adams <kadams@nvidia.com>
Tested-by: Ken Adams <kadams@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/debug_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/debug_gk20a.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c index c2285c8a..a3fa2ea5 100644 --- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c | |||
@@ -36,7 +36,7 @@ unsigned int gk20a_debug_trace_cmdbuf; | |||
36 | struct ch_state { | 36 | struct ch_state { |
37 | int pid; | 37 | int pid; |
38 | int refs; | 38 | int refs; |
39 | u8 inst_block[0]; | 39 | u32 inst_block[0]; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static const char * const ccsr_chan_status_str[] = { | 42 | static const char * const ccsr_chan_status_str[] = { |
@@ -108,15 +108,15 @@ static void gk20a_debug_show_channel(struct gk20a *g, | |||
108 | u32 channel = gk20a_readl(g, ccsr_channel_r(hw_chid)); | 108 | u32 channel = gk20a_readl(g, ccsr_channel_r(hw_chid)); |
109 | u32 status = ccsr_channel_status_v(channel); | 109 | u32 status = ccsr_channel_status_v(channel); |
110 | u32 syncpointa, syncpointb; | 110 | u32 syncpointa, syncpointb; |
111 | void *inst_ptr; | 111 | u32 *inst_mem; |
112 | 112 | ||
113 | if (!ch_state) | 113 | if (!ch_state) |
114 | return; | 114 | return; |
115 | 115 | ||
116 | inst_ptr = &ch_state->inst_block[0]; | 116 | inst_mem = &ch_state->inst_block[0]; |
117 | 117 | ||
118 | syncpointa = gk20a_mem_rd32(inst_ptr, ram_fc_syncpointa_w()); | 118 | syncpointa = inst_mem[ram_fc_syncpointa_w()]; |
119 | syncpointb = gk20a_mem_rd32(inst_ptr, ram_fc_syncpointb_w()); | 119 | syncpointb = inst_mem[ram_fc_syncpointb_w()]; |
120 | 120 | ||
121 | gk20a_debug_output(o, "%d-%s, pid %d, refs: %d: ", hw_chid, | 121 | gk20a_debug_output(o, "%d-%s, pid %d, refs: %d: ", hw_chid, |
122 | dev_name(g->dev), | 122 | dev_name(g->dev), |
@@ -129,23 +129,22 @@ static void gk20a_debug_show_channel(struct gk20a *g, | |||
129 | gk20a_debug_output(o, "TOP: %016llx PUT: %016llx GET: %016llx " | 129 | gk20a_debug_output(o, "TOP: %016llx PUT: %016llx GET: %016llx " |
130 | "FETCH: %016llx\nHEADER: %08x COUNT: %08x\n" | 130 | "FETCH: %016llx\nHEADER: %08x COUNT: %08x\n" |
131 | "SYNCPOINT %08x %08x SEMAPHORE %08x %08x %08x %08x\n", | 131 | "SYNCPOINT %08x %08x SEMAPHORE %08x %08x %08x %08x\n", |
132 | (u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_top_level_get_w()) + | 132 | (u64)inst_mem[ram_fc_pb_top_level_get_w()] + |
133 | ((u64)gk20a_mem_rd32(inst_ptr, | 133 | ((u64)inst_mem[ram_fc_pb_top_level_get_hi_w()] << 32ULL), |
134 | ram_fc_pb_top_level_get_hi_w()) << 32ULL), | 134 | (u64)inst_mem[ram_fc_pb_put_w()] + |
135 | (u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_put_w()) + | 135 | ((u64)inst_mem[ram_fc_pb_put_hi_w()] << 32ULL), |
136 | ((u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_put_hi_w()) << 32ULL), | 136 | (u64)inst_mem[ram_fc_pb_get_w()] + |
137 | (u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_get_w()) + | 137 | ((u64)inst_mem[ram_fc_pb_get_hi_w()] << 32ULL), |
138 | ((u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_get_hi_w()) << 32ULL), | 138 | (u64)inst_mem[ram_fc_pb_fetch_w()] + |
139 | (u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_fetch_w()) + | 139 | ((u64)inst_mem[ram_fc_pb_fetch_hi_w()] << 32ULL), |
140 | ((u64)gk20a_mem_rd32(inst_ptr, ram_fc_pb_fetch_hi_w()) << 32ULL), | 140 | inst_mem[ram_fc_pb_header_w()], |
141 | gk20a_mem_rd32(inst_ptr, ram_fc_pb_header_w()), | 141 | inst_mem[ram_fc_pb_count_w()], |
142 | gk20a_mem_rd32(inst_ptr, ram_fc_pb_count_w()), | ||
143 | syncpointa, | 142 | syncpointa, |
144 | syncpointb, | 143 | syncpointb, |
145 | gk20a_mem_rd32(inst_ptr, ram_fc_semaphorea_w()), | 144 | inst_mem[ram_fc_semaphorea_w()], |
146 | gk20a_mem_rd32(inst_ptr, ram_fc_semaphoreb_w()), | 145 | inst_mem[ram_fc_semaphoreb_w()], |
147 | gk20a_mem_rd32(inst_ptr, ram_fc_semaphorec_w()), | 146 | inst_mem[ram_fc_semaphorec_w()], |
148 | gk20a_mem_rd32(inst_ptr, ram_fc_semaphored_w())); | 147 | inst_mem[ram_fc_semaphored_w()]); |
149 | 148 | ||
150 | #ifdef CONFIG_TEGRA_GK20A | 149 | #ifdef CONFIG_TEGRA_GK20A |
151 | if ((pbdma_syncpointb_op_v(syncpointb) == pbdma_syncpointb_op_wait_v()) | 150 | if ((pbdma_syncpointb_op_v(syncpointb) == pbdma_syncpointb_op_wait_v()) |
@@ -246,17 +245,15 @@ void gk20a_debug_show_dump(struct gk20a *g, struct gk20a_debug_output *o) | |||
246 | 245 | ||
247 | for (chid = 0; chid < f->num_channels; chid++) { | 246 | for (chid = 0; chid < f->num_channels; chid++) { |
248 | struct channel_gk20a *ch = &f->channel[chid]; | 247 | struct channel_gk20a *ch = &f->channel[chid]; |
249 | if (ch_state[chid]) { | 248 | if (!ch_state[chid]) |
250 | if (ch->inst_block.cpu_va) { | 249 | continue; |
251 | ch_state[chid]->pid = ch->pid; | 250 | |
252 | ch_state[chid]->refs = | 251 | ch_state[chid]->pid = ch->pid; |
253 | atomic_read(&ch->ref_count); | 252 | ch_state[chid]->refs = atomic_read(&ch->ref_count); |
254 | memcpy(&ch_state[chid]->inst_block[0], | 253 | gk20a_mem_rd_n(g, &ch->inst_block, 0, |
255 | ch->inst_block.cpu_va, | 254 | &ch_state[chid]->inst_block[0], |
256 | ram_in_alloc_size_v()); | 255 | ram_in_alloc_size_v()); |
257 | } | 256 | gk20a_channel_put(ch); |
258 | gk20a_channel_put(ch); | ||
259 | } | ||
260 | } | 257 | } |
261 | for (chid = 0; chid < f->num_channels; chid++) { | 258 | for (chid = 0; chid < f->num_channels; chid++) { |
262 | if (ch_state[chid]) { | 259 | if (ch_state[chid]) { |