From patchwork Fri Oct 27 12:41:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 117309 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp725060qgn; Fri, 27 Oct 2017 05:42:23 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TBp6af/nPR43LjPTIUiZ4PshevWlzb25GrodkqhtkDSh6J9WGP9VxjjTdlsQWPzwjTogCT X-Received: by 10.84.128.229 with SMTP id a92mr302297pla.278.1509108143369; Fri, 27 Oct 2017 05:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509108143; cv=none; d=google.com; s=arc-20160816; b=PWAMJOZis3jnjNX7v+GlzC/VOAiCu7FNRvK/lfM4HeB2jmNj8WBDXZAdpFXSMygS1i 5d6/8vglojZlQ6YmuoZA1EPn12IEI6iRJdDxWYZsTCHDSsVHWC2IVwzt3jtfnVZjDvJB F49psWu2PN7Ul2uiZ7V6A27XusZF4dJ5OeRJOQO/6PnkgcX8hGukg/iguyUJvjd5fkt6 0qPAZgwkJRgkvNa85czDbwrjrUd+VEi/H/8nZwLHcojs1ig99im5KJePTdIvMEhgPnYj RlKad22+UdhxHKhlw2Bj8VSu0t+RI2bFdMMsLd0Jx+sb0tIM/Bz0sPipUWLuiSDAh96p /Hsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=jyZccx22yj9CSxKrgYA6BUnAR+DVbtiivC3Qn4h6C6E=; b=EIxYOgx9MNXVDdzlVp01ETbwhwCMs+q6NWq/xCsBdaDIVMfiEOde8HcBuKcnnUUEb4 SS1Tip/IXJFJTYUoZkmw2bcVDm4//CCMrqtqKZfqJZhLV21IQbJpyJ13KDrA6IuCTsgP hTzq8B5fC8ammQBCkTwwLBXymAnTsYrv/QBVQ3gaUE6jnxQflG8P58mFy6OCRNFOLFwc kI9UBD9U6dnb0BTj6IsPZALJOPYe6q8dyI8EbiPnAmxZrgtnMEOVaHZ+PjoJ2FEchZbD tZzYcW2p19+UEFVarBmiizo5YxVFDwHSBxuL/AUFS2ahXscqx/FmTYNU4CCOMslOmnBV 2U7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h64si4843952pge.382.2017.10.27.05.42.23; Fri, 27 Oct 2017 05:42:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752687AbdJ0MmV (ORCPT + 27 others); Fri, 27 Oct 2017 08:42:21 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:17163 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752608AbdJ0Mlv (ORCPT ); Fri, 27 Oct 2017 08:41:51 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9RCdf1J001921; Fri, 27 Oct 2017 14:41:50 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2dtg42yw51-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 27 Oct 2017 14:41:50 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 967DE38; Fri, 27 Oct 2017 12:41:49 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag7node2.st.com [10.75.127.20]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2CB0C2703; Fri, 27 Oct 2017 12:41:49 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 27 Oct 2017 14:41:48 +0200 From: Loic Pallardy To: , CC: , , , Loic Pallardy Subject: [PATCH 1/2] remoteproc: debug: add resource table dump feature Date: Fri, 27 Oct 2017 14:41:21 +0200 Message-ID: <1509108082-22201-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509108082-22201-1-git-send-email-loic.pallardy@st.com> References: <1509108082-22201-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-27_07:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the capability to display the content of the resource table associated to a remote processor firmware. Signed-off-by: Loic Pallardy --- drivers/remoteproc/remoteproc_debugfs.c | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) -- 1.9.1 diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c index 1c122e2..c1c9f58 100644 --- a/drivers/remoteproc/remoteproc_debugfs.c +++ b/drivers/remoteproc/remoteproc_debugfs.c @@ -155,6 +155,103 @@ static ssize_t rproc_recovery_read(struct file *filp, char __user *userbuf, .llseek = generic_file_llseek, }; +/* Expose resource table content via debugfs */ +static int rproc_rsc_table_show(struct seq_file *seq, void *p) +{ + static const char * const types[] = {"carveout", "devmem", "trace", "vdev"}; + struct rproc *rproc = seq->private; + struct resource_table *table = rproc->table_ptr; + struct fw_rsc_carveout *c; + struct fw_rsc_devmem *d; + struct fw_rsc_trace *t; + struct fw_rsc_vdev *v; + int i, j; + + if (!table) { + seq_puts(seq, "No resource table found\n"); + return 0; + } + + for (i = 0; i < table->num; i++) { + int offset = table->offset[i]; + struct fw_rsc_hdr *hdr = (void *)table + offset; + void *rsc = (void *)hdr + sizeof(*hdr); + + switch (hdr->type) { + case RSC_CARVEOUT: + c = rsc; + seq_printf(seq, "Entry %d is of type %s\n", i, types[hdr->type]); + seq_printf(seq, " Device Address 0x%x\n", c->da); + seq_printf(seq, " Physical Address 0x%x\n", c->pa); + seq_printf(seq, " Length 0x%x Bytes\n", c->len); + seq_printf(seq, " Flags 0x%x\n", c->flags); + seq_printf(seq, " Reserved (should be zero) [%d]\n", c->reserved); + seq_printf(seq, " Name %s\n\n", c->name); + break; + case RSC_DEVMEM: + d = rsc; + seq_printf(seq, "Entry %d is of type %s\n", i, types[hdr->type]); + seq_printf(seq, " Device Address 0x%x\n", d->da); + seq_printf(seq, " Physical Address 0x%x\n", d->pa); + seq_printf(seq, " Length 0x%x Bytes\n", d->len); + seq_printf(seq, " Flags 0x%x\n", d->flags); + seq_printf(seq, " Reserved (should be zero) [%d]\n", d->reserved); + seq_printf(seq, " Name %s\n\n", d->name); + break; + case RSC_TRACE: + t = rsc; + seq_printf(seq, "Entry %d is of type %s\n", i, types[hdr->type]); + seq_printf(seq, " Device Address 0x%x\n", t->da); + seq_printf(seq, " Length 0x%x Bytes\n", t->len); + seq_printf(seq, " Reserved (should be zero) [%d]\n", t->reserved); + seq_printf(seq, " Name %s\n\n", t->name); + break; + case RSC_VDEV: + v = rsc; + seq_printf(seq, "Entry %d is of type %s\n", i, types[hdr->type]); + + seq_printf(seq, " ID %d\n", v->id); + seq_printf(seq, " Notify ID %d\n", v->notifyid); + seq_printf(seq, " Device features 0x%x\n", v->dfeatures); + seq_printf(seq, " Guest features 0x%x\n", v->gfeatures); + seq_printf(seq, " Config length 0x%x\n", v->config_len); + seq_printf(seq, " Status 0x%x\n", v->status); + seq_printf(seq, " Number of vrings %d\n", v->num_of_vrings); + seq_printf(seq, " Reserved (should be zero) [%d][%d]\n\n", + v->reserved[0], v->reserved[1]); + + for (j = 0; j < v->num_of_vrings; j++) { + seq_printf(seq, " Vring %d\n", j); + seq_printf(seq, " Device Address 0x%x\n", v->vring[j].da); + seq_printf(seq, " Alignment %d\n", v->vring[j].align); + seq_printf(seq, " Number of buffers %d\n", v->vring[j].num); + seq_printf(seq, " Notify ID %d\n", v->vring[j].notifyid); + seq_printf(seq, " Physical Address 0x%x\n\n", + v->vring[j].pa); + } + break; + default: + seq_printf(seq, "Unknown resource type found: %d [hdr: %p]\n", + hdr->type, hdr); + break; + } + } + + return 0; +} + +static ssize_t rproc_rsc_table_open(struct inode *inode, struct file *file) +{ + return single_open(file, rproc_rsc_table_show, inode->i_private); +} + +static const struct file_operations rproc_rsc_table_ops = { + .open = rproc_rsc_table_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + void rproc_remove_trace_file(struct dentry *tfile) { debugfs_remove(tfile); @@ -198,6 +295,8 @@ void rproc_create_debug_dir(struct rproc *rproc) rproc, &rproc_name_ops); debugfs_create_file("recovery", 0400, rproc->dbg_dir, rproc, &rproc_recovery_ops); + debugfs_create_file("resource_table", 0400, rproc->dbg_dir, + rproc, &rproc_rsc_table_ops); } void __init rproc_init_debugfs(void)