Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: host1x: Handle CDMA wraparound when debug printing

During channel debug information dump, when printing CDMA
opcodes, the circular nature of the CDMA pushbuffer wasn't being
taken into account, sometimes accessing past the end. Change
the printing to take this into account.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240425050238.2943404-2-cyndis@kapsi.fi

authored by

Mikko Perttunen and committed by
Thierry Reding
e436a408 955df44b

+12 -3
+12 -3
drivers/gpu/host1x/hw/debug_hw.c
··· 177 177 178 178 for (i = 0; i < words; i++) { 179 179 dma_addr_t addr = phys_addr + i * 4; 180 - u32 val = *(map_addr + offset / 4 + i); 180 + u32 voffset = offset + i * 4; 181 + u32 val; 182 + 183 + /* If we reach the RESTART opcode, continue at the beginning of pushbuffer */ 184 + if (cdma && voffset >= cdma->push_buffer.size) { 185 + addr -= cdma->push_buffer.size; 186 + voffset -= cdma->push_buffer.size; 187 + } 188 + 189 + val = *(map_addr + voffset / 4); 181 190 182 191 if (!data_count) { 183 192 host1x_debug_output(o, " %pad: %08x: ", &addr, val); ··· 212 203 job->num_slots, job->num_unpins); 213 204 214 205 show_gather(o, pb->dma + job->first_get, job->num_slots * 2, cdma, 215 - pb->dma + job->first_get, pb->mapped + job->first_get); 206 + pb->dma, pb->mapped); 216 207 217 208 for (i = 0; i < job->num_cmds; i++) { 218 209 struct host1x_job_gather *g; ··· 236 227 host1x_debug_output(o, " GATHER at %pad+%#x, %d words\n", 237 228 &g->base, g->offset, g->words); 238 229 239 - show_gather(o, g->base + g->offset, g->words, cdma, 230 + show_gather(o, g->base + g->offset, g->words, NULL, 240 231 g->base, mapped); 241 232 242 233 if (!job->gather_copy_mapped)