From patchwork Wed Jun 1 11:18:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 9147197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E53E60777 for ; Wed, 1 Jun 2016 11:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5175F2040D for ; Wed, 1 Jun 2016 11:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 466A02699B; Wed, 1 Jun 2016 11:21:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EFE452040D for ; Wed, 1 Jun 2016 11:21:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b84Bh-0008GJ-Qi; Wed, 01 Jun 2016 11:19:49 +0000 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b84Bd-00089W-0e for linux-arm-kernel@lists.infradead.org; Wed, 01 Jun 2016 11:19:46 +0000 Received: by mail-pf0-x22d.google.com with SMTP id b124so13611579pfb.0 for ; Wed, 01 Jun 2016 04:19:24 -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=y4cdqTOy7GQNtPogtGM0eYE7hmh49brFXtcoZq9HvZk=; b=TwpmbDBNrG38qlR+6CY61FJNkGkfKASK4Kiepc1Hf/jg6JJ6+K8io5cEaPw1xM9VwZ NRHHVepK7Gb4NbrgDbI1gTDcmeZhHVcyc00HOGrauI57Ml/bag+sbM8UsNGqnyzSpa6I Phksx9PZX7blHfAQk6OaOlsglgNMuqfRIylzU= 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=y4cdqTOy7GQNtPogtGM0eYE7hmh49brFXtcoZq9HvZk=; b=HE4j2Q6DlCSHk58HXmv630DBkESMoEYmikTTRE5PndYrDFNnovRNcavq/GIn0EOs7S FCUbP33WSnxuoU5fTSd1k4IcKgWbGqxz4t9I9YcUks62Ri27JZE/6H8EatDbYplFMH0o vZ0Fuezm20mXzGwXssXErs8IqbKvK8SP2S6rzkB9ne9KxeKVXVG/DdjADgJ+Wqg9rPjh hw99RN5ndvm7DLmw8RAQmr5EIAy59PlJw0Ewz/feGZ+QRmLu6FKUH4KwPkpv6/5XRSH9 AgLtxFr5mWM09PV5g01Wpx+Wz6xqKDKdtlmQKXa4ZSofn4r7g2XAD98GSjH0kW3/AOMB AABQ== X-Gm-Message-State: ALyK8tJvQod7y3mbgL34lbLsR4i9m+8ZH1BmEvYI8EHzsWxjqWNnkjp3k00R8BMlu1K/7NSg X-Received: by 10.98.32.140 with SMTP id m12mr7594124pfj.119.1464779964075; Wed, 01 Jun 2016 04:19:24 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id o64sm13254234pfb.76.2016.06.01.04.19.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 04:19:23 -0700 (PDT) From: Chunyan Zhang To: rostedt@goodmis.org, mathieu.poirier@linaro.org, alexander.shishkin@linux.intel.com, mingo@redhat.com Subject: [RFC PATCH 1/4] STM Ftrace: Adding generic buffer interface driver Date: Wed, 1 Jun 2016 19:18:56 +0800 Message-Id: <1464779939-24986-2-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464779939-24986-1-git-send-email-zhang.chunyan@linaro.org> References: <1464779939-24986-1-git-send-email-zhang.chunyan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160601_041945_172041_47DCBC88 X-CRM114-Status: GOOD ( 18.97 ) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a driver that models itself as an stm_source and who's sole purpose is to export 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 | 9 +++++++ drivers/hwtracing/stm/Makefile | 2 ++ drivers/hwtracing/stm/stm_ftrace.c | 54 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 drivers/hwtracing/stm/stm_ftrace.c diff --git a/drivers/hwtracing/stm/Kconfig b/drivers/hwtracing/stm/Kconfig index 847a39b..a36633a 100644 --- a/drivers/hwtracing/stm/Kconfig +++ b/drivers/hwtracing/stm/Kconfig @@ -39,4 +39,13 @@ config STM_SOURCE_HEARTBEAT If you want to send heartbeat messages over STM devices, say Y. +config STM_FTRACE + tristate "Redirect/copy the output from kernel Ftrace to STM engine" + help + This option can be used to redirect or 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..5eef041 100644 --- a/drivers/hwtracing/stm/Makefile +++ b/drivers/hwtracing/stm/Makefile @@ -9,3 +9,5 @@ obj-$(CONFIG_STM_SOURCE_HEARTBEAT) += stm_heartbeat.o stm_console-y := console.o stm_heartbeat-y := heartbeat.o + +obj-$(CONFIG_STM_FTRACE) += stm_ftrace.o diff --git a/drivers/hwtracing/stm/stm_ftrace.c b/drivers/hwtracing/stm/stm_ftrace.c new file mode 100644 index 0000000..0b4eb70 --- /dev/null +++ b/drivers/hwtracing/stm/stm_ftrace.c @@ -0,0 +1,54 @@ +/* + * 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 +#include +#include +#include + +static struct stm_source_data stm_ftrace_data = { + .name = "stm_ftrace", + .nr_chans = 1, +}; + +/** + * 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' + */ +void notrace stm_ftrace_write(const char *buf, unsigned int len, + unsigned int chan) +{ + stm_source_write(&stm_ftrace_data, chan, buf, len); +} +EXPORT_SYMBOL_GPL(stm_ftrace_write); + +static int __init stm_ftrace_init(void) +{ + return stm_source_register_device(NULL, &stm_ftrace_data); +} + +static void __exit stm_ftrace_exit(void) +{ + stm_source_unregister_device(&stm_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 ");