From patchwork Mon Nov 6 17:09:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 118072 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2993347qgn; Mon, 6 Nov 2017 09:10:28 -0800 (PST) X-Google-Smtp-Source: ABhQp+RoPMJcEaCLiB3eKGID6TZSm6+NgFXpzSherHmr34IlRC6EwpfAFAWRpimqDzI64F8mhw4s X-Received: by 10.98.93.136 with SMTP id n8mr17606578pfj.215.1509988228391; Mon, 06 Nov 2017 09:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509988228; cv=none; d=google.com; s=arc-20160816; b=AvAani3v+e6asgJdJ9vxRhN20vo6/BVbX3SY2onE6zk3aEeFron/U27STQsNlCcK80 WWllmlHekZtCAZ5aCKcIZDxihneRl8HSM1XSK3Z5n7dleG/enZ0O2C2IvGNjTe81V57D z5LMUqaoUOEk6XUdfgmq8bU8ergw/a/FfxIKpXMmL1QNregQ01LFo4AckyMCAwyMs2Yy BVvJHwI+vreGQcwibsLwGT843OOsy4wSC7nJEZR0xLl2VLWlj/+9FZ5qL4YyA1Dh/9bE HxgG9CZuTNyqSFl+5MpkJ19XVd+HLz6icFn61gEfOtLq0WnDZyW8UzI9xlMMWWKn67VV 9Aiw== 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=79rsjm8MNBqVIg8j0Ov5MYunEotNHvn8Go9s9tKLK3s=; b=NjoTPJauoR5g5Y7LzCjZEDALpiGL5wy89bWjvAVJHhg/QD64SWAGadC2azNNQVJ0mk 912PEe683/y2PR1kPB8OpCIY+aeTxKZv3n+oSHIWjwNoM9SKyRnkIWIweipeE/h6qz0P wMRZ0zHDL0ppKskCkkPoXSziUNRg+0TR4XF8UQugsC2vGwN+Yc8H3LOpccnwKRcNPKGP kw+yQ6pc4V6ZmT8lukXLU3BWFhXCGbqZe/SqMy2EL/Of7hTq7H8kvwpDjwwLR/fmuYhz w+lCc7jU6Bk1TmA4TIOGoqTq3glpkPrfswkC4fCpNXYfJMTt+J1T2kII6gKRzm9D6DPV ouAw== 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 n1si11833832pgt.498.2017.11.06.09.10.28; Mon, 06 Nov 2017 09:10:28 -0800 (PST) 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 S1753911AbdKFRK0 (ORCPT + 26 others); Mon, 6 Nov 2017 12:10:26 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52754 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751705AbdKFRKH (ORCPT ); Mon, 6 Nov 2017 12:10:07 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA6H9V1l027445; Mon, 6 Nov 2017 18:10:05 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2e15ahkr59-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 06 Nov 2017 18:10:05 +0100 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 20CE931; Mon, 6 Nov 2017 17:10:05 +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 F311528D1; Mon, 6 Nov 2017 17:10:04 +0000 (GMT) Received: from localhost (10.75.127.51) by SFHDAG7NODE2.st.com (10.75.127.20) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 6 Nov 2017 18:10:04 +0100 From: Loic Pallardy To: , CC: , , , , Loic Pallardy Subject: [PATCH v2 1/2] remoteproc: debug: add resource table dump feature Date: Mon, 6 Nov 2017 18:09:55 +0100 Message-ID: <1509988196-24377-2-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509988196-24377-1-git-send-email-loic.pallardy@st.com> References: <1509988196-24377-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG7NODE2.st.com (10.75.127.20) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-06_06:, , 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 --- V2 : - Fix 0-DAY reported issues on open function prototype 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..dc5e259 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 int 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)