18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2010 Google, Inc. 48c2ecf20Sopenharmony_ci * Author: Erik Gilling <konkers@android.com> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2011-2017 NVIDIA Corporation 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "../dev.h" 108c2ecf20Sopenharmony_ci#include "../debug.h" 118c2ecf20Sopenharmony_ci#include "../cdma.h" 128c2ecf20Sopenharmony_ci#include "../channel.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic void host1x_debug_show_channel_cdma(struct host1x *host, 158c2ecf20Sopenharmony_ci struct host1x_channel *ch, 168c2ecf20Sopenharmony_ci struct output *o) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci struct host1x_cdma *cdma = &ch->cdma; 198c2ecf20Sopenharmony_ci u32 dmaput, dmaget, dmactrl; 208c2ecf20Sopenharmony_ci u32 offset, class; 218c2ecf20Sopenharmony_ci u32 ch_stat; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci dmaput = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAPUT); 248c2ecf20Sopenharmony_ci dmaget = host1x_ch_readl(ch, HOST1X_CHANNEL_DMAGET); 258c2ecf20Sopenharmony_ci dmactrl = host1x_ch_readl(ch, HOST1X_CHANNEL_DMACTRL); 268c2ecf20Sopenharmony_ci offset = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDP_OFFSET); 278c2ecf20Sopenharmony_ci class = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDP_CLASS); 288c2ecf20Sopenharmony_ci ch_stat = host1x_ch_readl(ch, HOST1X_CHANNEL_CHANNELSTAT); 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u-%s: ", ch->id, dev_name(ch->dev)); 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci if (dmactrl & HOST1X_CHANNEL_DMACTRL_DMASTOP || 338c2ecf20Sopenharmony_ci !ch->cdma.push_buffer.mapped) { 348c2ecf20Sopenharmony_ci host1x_debug_output(o, "inactive\n\n"); 358c2ecf20Sopenharmony_ci return; 368c2ecf20Sopenharmony_ci } 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci if (class == HOST1X_CLASS_HOST1X && offset == HOST1X_UCLASS_WAIT_SYNCPT) 398c2ecf20Sopenharmony_ci host1x_debug_output(o, "waiting on syncpt\n"); 408c2ecf20Sopenharmony_ci else 418c2ecf20Sopenharmony_ci host1x_debug_output(o, "active class %02x, offset %04x\n", 428c2ecf20Sopenharmony_ci class, offset); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci host1x_debug_output(o, "DMAPUT %08x, DMAGET %08x, DMACTL %08x\n", 458c2ecf20Sopenharmony_ci dmaput, dmaget, dmactrl); 468c2ecf20Sopenharmony_ci host1x_debug_output(o, "CHANNELSTAT %02x\n", ch_stat); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci show_channel_gathers(o, cdma); 498c2ecf20Sopenharmony_ci host1x_debug_output(o, "\n"); 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic void host1x_debug_show_channel_fifo(struct host1x *host, 538c2ecf20Sopenharmony_ci struct host1x_channel *ch, 548c2ecf20Sopenharmony_ci struct output *o) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci#if HOST1X_HW <= 6 578c2ecf20Sopenharmony_ci u32 rd_ptr, wr_ptr, start, end; 588c2ecf20Sopenharmony_ci u32 payload = INVALID_PAYLOAD; 598c2ecf20Sopenharmony_ci unsigned int data_count = 0; 608c2ecf20Sopenharmony_ci#endif 618c2ecf20Sopenharmony_ci u32 val; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u: fifo:\n", ch->id); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci val = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDFIFO_STAT); 668c2ecf20Sopenharmony_ci host1x_debug_output(o, "CMDFIFO_STAT %08x\n", val); 678c2ecf20Sopenharmony_ci if (val & HOST1X_CHANNEL_CMDFIFO_STAT_EMPTY) { 688c2ecf20Sopenharmony_ci host1x_debug_output(o, "[empty]\n"); 698c2ecf20Sopenharmony_ci return; 708c2ecf20Sopenharmony_ci } 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci val = host1x_ch_readl(ch, HOST1X_CHANNEL_CMDFIFO_RDATA); 738c2ecf20Sopenharmony_ci host1x_debug_output(o, "CMDFIFO_RDATA %08x\n", val); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#if HOST1X_HW <= 6 768c2ecf20Sopenharmony_ci /* Peek pointer values are invalid during SLCG, so disable it */ 778c2ecf20Sopenharmony_ci host1x_hypervisor_writel(host, 0x1, HOST1X_HV_ICG_EN_OVERRIDE); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci val = 0; 808c2ecf20Sopenharmony_ci val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ENABLE; 818c2ecf20Sopenharmony_ci val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_CHANNEL(ch->id); 828c2ecf20Sopenharmony_ci host1x_hypervisor_writel(host, val, HOST1X_HV_CMDFIFO_PEEK_CTRL); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci val = host1x_hypervisor_readl(host, HOST1X_HV_CMDFIFO_PEEK_PTRS); 858c2ecf20Sopenharmony_ci rd_ptr = HOST1X_HV_CMDFIFO_PEEK_PTRS_RD_PTR_V(val); 868c2ecf20Sopenharmony_ci wr_ptr = HOST1X_HV_CMDFIFO_PEEK_PTRS_WR_PTR_V(val); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci val = host1x_hypervisor_readl(host, HOST1X_HV_CMDFIFO_SETUP(ch->id)); 898c2ecf20Sopenharmony_ci start = HOST1X_HV_CMDFIFO_SETUP_BASE_V(val); 908c2ecf20Sopenharmony_ci end = HOST1X_HV_CMDFIFO_SETUP_LIMIT_V(val); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci do { 938c2ecf20Sopenharmony_ci val = 0; 948c2ecf20Sopenharmony_ci val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ENABLE; 958c2ecf20Sopenharmony_ci val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_CHANNEL(ch->id); 968c2ecf20Sopenharmony_ci val |= HOST1X_HV_CMDFIFO_PEEK_CTRL_ADDR(rd_ptr); 978c2ecf20Sopenharmony_ci host1x_hypervisor_writel(host, val, 988c2ecf20Sopenharmony_ci HOST1X_HV_CMDFIFO_PEEK_CTRL); 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci val = host1x_hypervisor_readl(host, 1018c2ecf20Sopenharmony_ci HOST1X_HV_CMDFIFO_PEEK_READ); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci if (!data_count) { 1048c2ecf20Sopenharmony_ci host1x_debug_output(o, "%03x 0x%08x: ", 1058c2ecf20Sopenharmony_ci rd_ptr - start, val); 1068c2ecf20Sopenharmony_ci data_count = show_channel_command(o, val, &payload); 1078c2ecf20Sopenharmony_ci } else { 1088c2ecf20Sopenharmony_ci host1x_debug_cont(o, "%08x%s", val, 1098c2ecf20Sopenharmony_ci data_count > 1 ? ", " : "])\n"); 1108c2ecf20Sopenharmony_ci data_count--; 1118c2ecf20Sopenharmony_ci } 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci if (rd_ptr == end) 1148c2ecf20Sopenharmony_ci rd_ptr = start; 1158c2ecf20Sopenharmony_ci else 1168c2ecf20Sopenharmony_ci rd_ptr++; 1178c2ecf20Sopenharmony_ci } while (rd_ptr != wr_ptr); 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci if (data_count) 1208c2ecf20Sopenharmony_ci host1x_debug_cont(o, ", ...])\n"); 1218c2ecf20Sopenharmony_ci host1x_debug_output(o, "\n"); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci host1x_hypervisor_writel(host, 0x0, HOST1X_HV_CMDFIFO_PEEK_CTRL); 1248c2ecf20Sopenharmony_ci host1x_hypervisor_writel(host, 0x0, HOST1X_HV_ICG_EN_OVERRIDE); 1258c2ecf20Sopenharmony_ci#endif 1268c2ecf20Sopenharmony_ci} 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistatic void host1x_debug_show_mlocks(struct host1x *host, struct output *o) 1298c2ecf20Sopenharmony_ci{ 1308c2ecf20Sopenharmony_ci /* TODO */ 1318c2ecf20Sopenharmony_ci} 132