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: 69018 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp33232qge; Wed, 1 Jun 2016 04:19:32 -0700 (PDT) X-Received: by 10.36.83.65 with SMTP id n62mr18137592itb.71.1464779968923; Wed, 01 Jun 2016 04:19:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zk7si2401010pac.15.2016.06.01.04.19.28; Wed, 01 Jun 2016 04:19:28 -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=@linaro.org; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757491AbcFALT1 (ORCPT + 30 others); Wed, 1 Jun 2016 07:19:27 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34419 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbcFALTZ (ORCPT ); Wed, 1 Jun 2016 07:19:25 -0400 Received: by mail-pf0-f181.google.com with SMTP id 62so13573820pfd.1 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=T2PF1OCAlKPtpI/JIyDgs5O4MkOVm9UCjMWpc8+bqL4mPYJ9l2WBzfxEBfyodqIuio qEqjmtt5Ummj/qZZQC0p1q+C768e30YuzT6lISijtx9CoxNBWJwmkIMpb86CVUYjZ0DX WfVJ56u5K5nRGoeLhi3+p9epN7tmcFq7U5B/+hVDsafNss9w6SwZeIpG+MjdMCvsV5ds R7NXl9YakFihZkM1oMd/rffS/Mj3gAZEM5zIUA3kcd2rfQxh1OIarMm20F9ZduCqQpMy wbZDrJCEY82Z36JMqB9/Xnihx8mz4VDdWXu2zF3Y204OjWdRELGGB21/LDmukSWu0SgF FTJw== X-Gm-Message-State: ALyK8tJ99lQTphToTdZN3AfWhnhSiJfKI4kYjc7a5xfdC/OPlaGVA9KAyC71Ir48zmmq/hvw 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 Cc: mike.leach@arm.com, tor@ti.com, maxime.coquelin@st.com, philippe.langlais@st.com, nicolas.guion@st.com, zhang.lyra@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 1.9.1 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 ");