Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2736854ybh; Mon, 9 Mar 2020 11:58:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv5xpCCuI61koUpu0Lnju24etkOdxc1fHSkZTZEx6TmP1pGwJCo/XJLfd+l0a++bQ5eyt4E X-Received: by 2002:a9d:178:: with SMTP id 111mr14664834otu.238.1583780338523; Mon, 09 Mar 2020 11:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583780338; cv=none; d=google.com; s=arc-20160816; b=bhJWhIJalkenDJphtDP8nny8DLsavWRU5iL6rirpHTKWesg4NdqmGVZKzbLdGsjgHJ V7YOcuQDNfgUWniOAearECPRfsZylQAEoJT/aFcNez3X7TMC3aJwLJngtPbXRYn8nZii Ca8l17AXX99I4ZySjenKE5Jaz2karLCCFbxv0ozlcHDechY86LFJJb/bVim2u3S36vte rz5GlbpW8muJe4JsQSyewi0jolR0natHq+iOnszwOt9N27MVc0VpvGjqy3ySjpu4+lS5 1ficva9sBO4NW30N20bugl2wllaBBhaBABuoBdySlRt+abO5TH76g7c1UIDrmwLn1BHu nErw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=g2u/OLAgiInGN4xLm0+9cr6hTH+ZT1QAXVX+7llX76w=; b=Lrg3hq2K3rvwGf7oNi1yRMpwMlUuIe4D8djYUqSx4SfkTv0mnCTD5AqAP2VDVTdjjk X2AgzXUNTs93yLaKuQoDfRpIPvI5u5zcIn/BvcKkMe8UBynyGDGGj9qYIUo/oJ9aZlRK qKxc3IyWy9+WfBrao/Qepy3rI2qzee15Ibki54bVPrhgth03ByaWbYqamZcEIbhTzDzv 5T3uowsdOoimY8D8irduJD4uWbzM5d5/zSA8OVVloN31e80RcVRpEsKayascqKfF2UB2 qrfYvxBhJdlxGBME09+fF8boBr16JZ/gI2qg8P0JfItu2i488SuRH/GLnnNVvPNwpP3a YEPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HTGfEese; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si6366800otr.97.2020.03.09.11.58.42; Mon, 09 Mar 2020 11:58:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HTGfEese; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgCIS5H (ORCPT + 99 others); Mon, 9 Mar 2020 14:57:07 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35781 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727380AbgCIS5G (ORCPT ); Mon, 9 Mar 2020 14:57:06 -0400 Received: by mail-pl1-f194.google.com with SMTP id g6so4375050plt.2 for ; Mon, 09 Mar 2020 11:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=g2u/OLAgiInGN4xLm0+9cr6hTH+ZT1QAXVX+7llX76w=; b=HTGfEeseSiG/j8RRQVcEwDBh/c1A0F9xo9jtWZIJetjxQKhi7UIJGvJWIxidZf1gQA EfqEPOEfd6nFdkI2/0YCKJar2DBNmKMbJo7oETTCLZDm12GO7A/66QrZORz1hqVDu89o Oz6vvrF4PTJVd96BjlozF/GAsU4V4TY4R6U7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=g2u/OLAgiInGN4xLm0+9cr6hTH+ZT1QAXVX+7llX76w=; b=SEPBu54DS3fTzGQCaO7XjqyJ3gND6ynDK0mkmu+kF+kf9DzUkA0BxtmtO+blwNZ624 tc6dey2gpMEAqvVbSqAWKEw6eeTzfcwK0VbRviwIzo1SB1/MTTDcaxy6655Cj/+YStk7 7/uQN40pR+SJYNJD4TwgzIEBhTH1Uh57sVxSbbtojMWFOpL7PvCmS+2HzTqJpT9WIa2l dIn4Ce6iyVuh0lrPqHaOg2luPpZyEuPfmeVsyizvaaRBio0vaJYY8nGkNDOZnYY2TBmD PaNY7G0oUfWUO4YB4GyfJhLEDUcdcX27CkxMK7V8viK6ljjjhMKmmFPGuynmjfKb+Af5 /EpQ== X-Gm-Message-State: ANhLgQ3OZNBrHCc10UbMP148h59tZSb/m/kKti1ruoQ4RCUaXC42CrqC GhRp4369vdNOxcKVwWQNlz8wOg== X-Received: by 2002:a17:90a:a616:: with SMTP id c22mr761854pjq.47.1583780225613; Mon, 09 Mar 2020 11:57:05 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id k8sm9007674pfk.1.2020.03.09.11.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 11:57:05 -0700 (PDT) From: Stephen Boyd To: Andy Gross , Bjorn Andersson Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Lina Iyer , Maulik Shah Subject: [PATCH] soc: qcom: cmd-db: Add debugfs dumping file Date: Mon, 9 Mar 2020 11:57:04 -0700 Message-Id: <20200309185704.2491-1-swboyd@chromium.org> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's useful for kernel devs to understand what resources and data is stored inside command db. Add a file in debugufs called 'cmd-db' to dump the memory contents and strings for resources along with their addresses. E.g. Command DB DUMP Slave ARC (v16.0) ------------------------- 0x00030000: cx.lvl [00 00 10 00 40 00 80 00 c0 00 00 01 80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00] 0x00030004: cx.tmr 0x00030010: mx.lvl [00 00 10 00 00 01 80 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00] 0x00030014: mx.tmr Cc: Lina Iyer Cc: Maulik Shah Signed-off-by: Stephen Boyd --- drivers/soc/qcom/cmd-db.c | 79 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index f6c3d17b05c7..6c308f92a13c 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ +#include #include #include #include -#include #include #include +#include #include #include @@ -236,6 +237,78 @@ enum cmd_db_hw_type cmd_db_read_slave_id(const char *id) } EXPORT_SYMBOL(cmd_db_read_slave_id); +#ifdef CONFIG_DEBUG_FS +static int cmd_db_debugfs_dump(struct seq_file *seq, void *p) +{ + int i, j; + const struct rsc_hdr *rsc; + const struct entry_header *ent; + const char *name; + u16 len, version; + u8 major, minor; + + seq_puts(seq, "Command DB DUMP\n"); + + for (i = 0; i < MAX_SLV_ID; i++) { + + rsc = &cmd_db_header->header[i]; + if (!rsc->slv_id) + break; + + switch (rsc->slv_id) { + case CMD_DB_HW_ARC: + name = "ARC"; + break; + case CMD_DB_HW_VRM: + name = "VRM"; + break; + case CMD_DB_HW_BCM: + name = "BCM"; + break; + default: + name = "Unknown"; + break; + } + + version = le16_to_cpu(rsc->version); + major = version >> 8; + minor = version; + + seq_printf(seq, "Slave %s (v%u.%u)\n", name, major, minor); + seq_puts(seq, "-------------------------\n"); + + ent = rsc_to_entry_header(rsc); + for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) { + seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr), + sizeof(ent->id), ent->id); + + len = le16_to_cpu(ent->len); + if (len) { + seq_printf(seq, " [%*ph]", + len, rsc_offset(rsc, ent)); + } + seq_putc(seq, '\n'); + } + } + + return 0; +} + +static int open_cmd_db_debugfs(struct inode *inode, struct file *file) +{ + return single_open(file, cmd_db_debugfs_dump, inode->i_private); +} +#endif + +static const struct file_operations cmd_db_debugfs_ops = { +#ifdef CONFIG_DEBUG_FS + .open = open_cmd_db_debugfs, +#endif + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static int cmd_db_dev_probe(struct platform_device *pdev) { struct reserved_mem *rmem; @@ -259,12 +332,14 @@ static int cmd_db_dev_probe(struct platform_device *pdev) return -EINVAL; } + debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops); + return 0; } static const struct of_device_id cmd_db_match_table[] = { { .compatible = "qcom,cmd-db" }, - { }, + { } }; static struct platform_driver cmd_db_dev_driver = { base-commit: 2c523b344dfa65a3738e7039832044aa133c75fb -- Sent by a computer, using git, on the internet