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-2013 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 cbstat, cbread; 218c2ecf20Sopenharmony_ci u32 val, base, baseval; 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 cbread = host1x_sync_readl(host, HOST1X_SYNC_CBREAD(ch->id)); 278c2ecf20Sopenharmony_ci cbstat = host1x_sync_readl(host, HOST1X_SYNC_CBSTAT(ch->id)); 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u-%s: ", ch->id, dev_name(ch->dev)); 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci if (HOST1X_CHANNEL_DMACTRL_DMASTOP_V(dmactrl) || 328c2ecf20Sopenharmony_ci !ch->cdma.push_buffer.mapped) { 338c2ecf20Sopenharmony_ci host1x_debug_output(o, "inactive\n\n"); 348c2ecf20Sopenharmony_ci return; 358c2ecf20Sopenharmony_ci } 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == HOST1X_CLASS_HOST1X && 388c2ecf20Sopenharmony_ci HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 398c2ecf20Sopenharmony_ci HOST1X_UCLASS_WAIT_SYNCPT) 408c2ecf20Sopenharmony_ci host1x_debug_output(o, "waiting on syncpt %d val %d\n", 418c2ecf20Sopenharmony_ci cbread >> 24, cbread & 0xffffff); 428c2ecf20Sopenharmony_ci else if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == 438c2ecf20Sopenharmony_ci HOST1X_CLASS_HOST1X && 448c2ecf20Sopenharmony_ci HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 458c2ecf20Sopenharmony_ci HOST1X_UCLASS_WAIT_SYNCPT_BASE) { 468c2ecf20Sopenharmony_ci base = (cbread >> 16) & 0xff; 478c2ecf20Sopenharmony_ci baseval = 488c2ecf20Sopenharmony_ci host1x_sync_readl(host, HOST1X_SYNC_SYNCPT_BASE(base)); 498c2ecf20Sopenharmony_ci val = cbread & 0xffff; 508c2ecf20Sopenharmony_ci host1x_debug_output(o, "waiting on syncpt %d val %d (base %d = %d; offset = %d)\n", 518c2ecf20Sopenharmony_ci cbread >> 24, baseval + val, base, 528c2ecf20Sopenharmony_ci baseval, val); 538c2ecf20Sopenharmony_ci } else 548c2ecf20Sopenharmony_ci host1x_debug_output(o, "active class %02x, offset %04x, val %08x\n", 558c2ecf20Sopenharmony_ci HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat), 568c2ecf20Sopenharmony_ci HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat), 578c2ecf20Sopenharmony_ci cbread); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci host1x_debug_output(o, "DMAPUT %08x, DMAGET %08x, DMACTL %08x\n", 608c2ecf20Sopenharmony_ci dmaput, dmaget, dmactrl); 618c2ecf20Sopenharmony_ci host1x_debug_output(o, "CBREAD %08x, CBSTAT %08x\n", cbread, cbstat); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci show_channel_gathers(o, cdma); 648c2ecf20Sopenharmony_ci host1x_debug_output(o, "\n"); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic void host1x_debug_show_channel_fifo(struct host1x *host, 688c2ecf20Sopenharmony_ci struct host1x_channel *ch, 698c2ecf20Sopenharmony_ci struct output *o) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci u32 val, rd_ptr, wr_ptr, start, end; 728c2ecf20Sopenharmony_ci unsigned int data_count = 0; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u: fifo:\n", ch->id); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci val = host1x_ch_readl(ch, HOST1X_CHANNEL_FIFOSTAT); 778c2ecf20Sopenharmony_ci host1x_debug_output(o, "FIFOSTAT %08x\n", val); 788c2ecf20Sopenharmony_ci if (HOST1X_CHANNEL_FIFOSTAT_CFEMPTY_V(val)) { 798c2ecf20Sopenharmony_ci host1x_debug_output(o, "[empty]\n"); 808c2ecf20Sopenharmony_ci return; 818c2ecf20Sopenharmony_ci } 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci host1x_sync_writel(host, 0x0, HOST1X_SYNC_CFPEEK_CTRL); 848c2ecf20Sopenharmony_ci host1x_sync_writel(host, HOST1X_SYNC_CFPEEK_CTRL_ENA_F(1) | 858c2ecf20Sopenharmony_ci HOST1X_SYNC_CFPEEK_CTRL_CHANNR_F(ch->id), 868c2ecf20Sopenharmony_ci HOST1X_SYNC_CFPEEK_CTRL); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci val = host1x_sync_readl(host, HOST1X_SYNC_CFPEEK_PTRS); 898c2ecf20Sopenharmony_ci rd_ptr = HOST1X_SYNC_CFPEEK_PTRS_CF_RD_PTR_V(val); 908c2ecf20Sopenharmony_ci wr_ptr = HOST1X_SYNC_CFPEEK_PTRS_CF_WR_PTR_V(val); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci val = host1x_sync_readl(host, HOST1X_SYNC_CF_SETUP(ch->id)); 938c2ecf20Sopenharmony_ci start = HOST1X_SYNC_CF_SETUP_BASE_V(val); 948c2ecf20Sopenharmony_ci end = HOST1X_SYNC_CF_SETUP_LIMIT_V(val); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci do { 978c2ecf20Sopenharmony_ci host1x_sync_writel(host, 0x0, HOST1X_SYNC_CFPEEK_CTRL); 988c2ecf20Sopenharmony_ci host1x_sync_writel(host, HOST1X_SYNC_CFPEEK_CTRL_ENA_F(1) | 998c2ecf20Sopenharmony_ci HOST1X_SYNC_CFPEEK_CTRL_CHANNR_F(ch->id) | 1008c2ecf20Sopenharmony_ci HOST1X_SYNC_CFPEEK_CTRL_ADDR_F(rd_ptr), 1018c2ecf20Sopenharmony_ci HOST1X_SYNC_CFPEEK_CTRL); 1028c2ecf20Sopenharmony_ci val = host1x_sync_readl(host, HOST1X_SYNC_CFPEEK_READ); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci if (!data_count) { 1058c2ecf20Sopenharmony_ci host1x_debug_output(o, "%08x: ", val); 1068c2ecf20Sopenharmony_ci data_count = show_channel_command(o, val, NULL); 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_sync_writel(host, 0x0, HOST1X_SYNC_CFPEEK_CTRL); 1248c2ecf20Sopenharmony_ci} 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cistatic void host1x_debug_show_mlocks(struct host1x *host, struct output *o) 1278c2ecf20Sopenharmony_ci{ 1288c2ecf20Sopenharmony_ci unsigned int i; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci host1x_debug_output(o, "---- mlocks ----\n"); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci for (i = 0; i < host1x_syncpt_nb_mlocks(host); i++) { 1338c2ecf20Sopenharmony_ci u32 owner = 1348c2ecf20Sopenharmony_ci host1x_sync_readl(host, HOST1X_SYNC_MLOCK_OWNER(i)); 1358c2ecf20Sopenharmony_ci if (HOST1X_SYNC_MLOCK_OWNER_CH_OWNS_V(owner)) 1368c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u: locked by channel %u\n", 1378c2ecf20Sopenharmony_ci i, HOST1X_SYNC_MLOCK_OWNER_CHID_V(owner)); 1388c2ecf20Sopenharmony_ci else if (HOST1X_SYNC_MLOCK_OWNER_CPU_OWNS_V(owner)) 1398c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u: locked by cpu\n", i); 1408c2ecf20Sopenharmony_ci else 1418c2ecf20Sopenharmony_ci host1x_debug_output(o, "%u: unlocked\n", i); 1428c2ecf20Sopenharmony_ci } 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci host1x_debug_output(o, "\n"); 1458c2ecf20Sopenharmony_ci} 146