From patchwork Wed Jun 22 02:46:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 70602 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2324011qgy; Tue, 21 Jun 2016 19:49:22 -0700 (PDT) X-Received: by 10.98.73.69 with SMTP id w66mr32043340pfa.104.1466563762040; Tue, 21 Jun 2016 19:49:22 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fd4si17239452pab.31.2016.06.21.19.49.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2016 19:49:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFYDP-0002jn-Eq; Wed, 22 Jun 2016 02:48:31 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFYDE-0002VO-1f for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2016 02:48:21 +0000 Received: by mail-pa0-x236.google.com with SMTP id hl6so12013466pac.2 for ; Tue, 21 Jun 2016 19:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9L37L7gTJ/bdTWaaQ8KKE4s/3SFPDePociz78kvvVGY=; b=IRDhyqXhiiAlUoOCgEiT7YGu4sd+/TBd5tD/VkmRQnkmzLU0RG21ErE21r7R1aW7XO 3ZqKFPgiA0FEuT7+7aPEaaaL25hsN5Qbs3d+PeNzEtqKZnr1Rl5GIWJErsLM7ALM7fJg V6nXDQqWYM62t2dsJm5FWqBXw2Mus7kgevo/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9L37L7gTJ/bdTWaaQ8KKE4s/3SFPDePociz78kvvVGY=; b=ee1QgvfachuXWVok4M5L5PPhMkSqNzM44WsO2cFV9Oo3h9t5EkGyPxZV/XVaHmZUSi QDBkmBi2y7jx2N8KA/oJxV9mK6OIdXrTXiJ/3AU3DrDA5mf6LuvvKZxNz9e9/UjhcpbE T6NzJ3B9oknUcg2mxLPySNWKK6ZjIwQ9s4A/03RIlNtru3pZPh6DZNkM7yfdeBJWhU2e q7SY4hsqmms96Y7YbSjK+i7M2bLlSQRC2/AEFmjwlsQn43fRbKsXWMu4ckseADaGPya0 GNyJ7qyLNCTTbi2+naqk7Eza+N3YBw7hHcz0hW/t8t2KbkjHJl9qE0Xzr1pL86me+588 gJ+w== X-Gm-Message-State: ALyK8tL6U0lMCE+LD5H4e6Z1WKp8oyUqHf350kAY5pudhMcSHTn/HP2kAKKWk1Wqd6qEoyep X-Received: by 10.66.25.8 with SMTP id y8mr31893617paf.106.1466563679289; Tue, 21 Jun 2016 19:47:59 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id y70sm98867836pff.25.2016.06.21.19.47.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Jun 2016 19:47:58 -0700 (PDT) From: Chunyan Zhang To: rostedt@goodmis.org, mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com, mingo@redhat.com Subject: [PATCH V2 2/4] STM Ftrace: Adding generic buffer interface driver Date: Wed, 22 Jun 2016 10:46:51 +0800 Message-Id: <1466563613-31578-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466563613-31578-1-git-send-email-zhang.chunyan@linaro.org> References: <1466563613-31578-1-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160621_194820_218453_55A01E16 X-CRM114-Status: GOOD ( 19.67 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:236 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhang.lyra@gmail.com, linux-kernel@vger.kernel.org, tor@ti.com, philippe.langlais@st.com, mike.leach@arm.com, nicolas.guion@st.com, linux-arm-kernel@lists.infradead.org, maxime.coquelin@st.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This patch adds a driver that models itself as an stm_source and who's sole purpose is to be an interface to the rest of the kernel. Once the stm and stm_source have been linked via sysfs, everything that is passed to the interface will endup in the STM trace engine. Signed-off-by: Chunyan Zhang --- drivers/hwtracing/stm/Kconfig | 10 ++++++ drivers/hwtracing/stm/Makefile | 2 ++ drivers/hwtracing/stm/ftrace.c | 77 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 drivers/hwtracing/stm/ftrace.c -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig index 847a39b..f4c69d2 100644 --- a/drivers/hwtracing/stm/Kconfig +++ b/drivers/hwtracing/stm/Kconfig @@ -39,4 +39,14 @@ config STM_SOURCE_HEARTBEAT If you want to send heartbeat messages over STM devices, say Y. +config STM_SOURCE_FTRACE + tristate "Copy the output from kernel Ftrace to STM engine" + help + This option can be used to copy the output from kernel Ftrace + to STM engine. Enabling this option will introduce a slight + timing effect. + + If you want to send kernel Ftrace messages over STM devices, + say Y. + endif diff --git a/drivers/hwtracing/stm/Makefile b/drivers/hwtracing/stm/Makefile index a9ce3d4..3abd84c 100644 --- a/drivers/hwtracing/stm/Makefile +++ b/drivers/hwtracing/stm/Makefile @@ -6,6 +6,8 @@ obj-$(CONFIG_STM_DUMMY) += dummy_stm.o obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o obj-$(CONFIG_STM_SOURCE_HEARTBEAT) += stm_heartbeat.o +obj-$(CONFIG_STM_SOURCE_FTRACE) += stm_ftrace.o stm_console-y := console.o stm_heartbeat-y := heartbeat.o +stm_ftrace-y := ftrace.o diff --git a/drivers/hwtracing/stm/ftrace.c b/drivers/hwtracing/stm/ftrace.c new file mode 100644 index 0000000..ccce91e --- /dev/null +++ b/drivers/hwtracing/stm/ftrace.c @@ -0,0 +1,77 @@ +/* + * Simple kernel driver to link kernel Ftrace and an STM device + * Copyright (c) 2016, Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include + +#define STM_FTRACE_NR_CHANNELS 1 + +static int stm_ftrace_link(struct stm_source_data *data); +static void stm_ftrace_unlink(struct stm_source_data *data); +static void stm_ftrace_write(struct stm_source_data *data, const char *buf, + unsigned int len, unsigned int chan); + +static struct stm_ftrace ftrace = { + .data = { + .name = "ftrace", + .nr_chans = STM_FTRACE_NR_CHANNELS, + .link = stm_ftrace_link, + .unlink = stm_ftrace_unlink, + }, + .write = stm_ftrace_write, +}; + +/** + * stm_ftrace_write() - write data to STM via 'stm_ftrace' source + * @buf: buffer containing the data packet + * @len: length of the data packet + * @chan: offset above the start channel number allocated to 'stm_ftrace' + */ +static void notrace stm_ftrace_write(struct stm_source_data *data, + const char *buf, unsigned int len, + unsigned int chan) +{ + stm_source_write(data, chan, buf, len); +} + +static int stm_ftrace_link(struct stm_source_data *data) +{ + struct stm_ftrace *sf = container_of(data, struct stm_ftrace, data); + + trace_add_output(sf); + + return 0; +} + +static void stm_ftrace_unlink(struct stm_source_data *data) +{ + trace_rm_output(); +} + +static int __init stm_ftrace_init(void) +{ + return stm_source_register_device(NULL, &ftrace.data); +} + +static void __exit stm_ftrace_exit(void) +{ + stm_source_unregister_device(&ftrace.data); +} + +module_init(stm_ftrace_init); +module_exit(stm_ftrace_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("stm_ftrace driver"); +MODULE_AUTHOR("Chunyan Zhang ");