Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1596673

[PATCH v6 10/11] drivers: perf: hisi: use poll method when no IRQ for MN counter overflow

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Anurup M <anurupvasu@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v6 10/11] drivers: perf: hisi: use poll method when no IRQ for MN counter overflow
Date Fri, 10 Mar 2017 07:30:01 +0100
Message-ID <tjmdP-87B-1@gated-at.bofh.it> (permalink)
X-Original-To mark.rutland@arm.com, will.deacon@arm.com
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uAyOy9VDZumpwIlICCgS3/un2PyCMBjHzOecQIpNaSE=; b=B8pZyrdc7P/5XY7sfBcl2cWcApojcq6LXyi1rfEvi4wtBb1jesVvlMHvy8D5VJKSIr TgSw1jRZ/tequ78Be1y1cMXIrNuh29vcWrweUfiCzLFaHluq9FGn5igtJvGM8zRaULhf LYgv1GFptHJrJ7+7pF5qdh5s/gcrZsnXYmuvm/JQWaLcUpDmrY4/QKNB13TwgqWaLGxP HESZ/Gv70C5UxbYDDe18oLbS80tU7Bjtgm5+w3gWh9I65HhQLe4BTMma2hcrYah+1xvh 6ChkBgFVaSAr1n7SH6SzoX6Dy39VhtrDCcXJovsVsTXaHylBKBXYTNGnHOjmxki0TcCi 0Xmw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uAyOy9VDZumpwIlICCgS3/un2PyCMBjHzOecQIpNaSE=; b=c8Q8bmWeiRbHPVutKLz0JLi/SSTd5MU5yRBM+lhz51DAja0yvdKTiFY7evqVCi/+LA id9nDaxgEuAWWhPYMdEwv7jx0P31eCQZOR7Mugp/3LW5kGKoa72kgDEWbuk6XWMBXwW1 xUUATyPEoZfyBq7JXNFtp5/VeSpjVcLf/580tq6HzBaCnXuJeNpiHFsWjuh4KN/CQmVx RMOh2nn9KMQ47sWrAs3kklPCMNsZ1AZlcCByFAoGHFqkvhKYRazPwunxrHqb45Dy0vLF hyfPY6fKtXiZHNOqb4b9fszRq5uowRZrGWzvJLj1Zybz9uC5cM9/qxI0lOUUdnAStas+ q7tw==
X-Gm-Message-State AMke39nfGIbTXdk/QN4XJQHWKtrIIqXCLGR0McPb17h8l5VBf83cBGLUm/25/SRBK4Wh0g==
X-Received by 10.98.29.216 with SMTP id d207mr18856784pfd.144.1489127349221; Thu, 09 Mar 2017 22:29:09 -0800 (PST)
X-Google-Original-From Anurup M <anurup.m@huawei.com>
X-Mailer git-send-email 2.1.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 96
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, anurup.m@huawei.com, zhangshaokun@hisilicon.com, tanxiaojun@huawei.com, xuwei5@hisilicon.com, sanil.kumar@hisilicon.com, john.garry@huawei.com, gabriele.paoloni@huawei.com, shiju.jose@huawei.com, huangdaode@hisilicon.com, linuxarm@huawei.com, dikshit.n@huawei.com, shyju.pv@huawei.com, anurupvasu@gmail.com
X-Original-Date Fri, 10 Mar 2017 01:29:01 -0500
X-Original-Message-ID <1489127341-112908-1-git-send-email-anurup.m@huawei.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1596673

Show key headers only | View raw


When no IRQ is supported in hardware, use hrtimer to poll and
update event counter and avoid overflow condition for MN PMU.
An interval of 8 seconds is used for the hrtimer.

Signed-off-by: Anurup M <anurup.m@huawei.com>
Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
Signed-off-by: Dikshit N <dikshit.n@huawei.com>
---
 drivers/perf/hisilicon/hisi_uncore_mn.c | 39 +++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/perf/hisilicon/hisi_uncore_mn.c b/drivers/perf/hisilicon/hisi_uncore_mn.c
index 18316dc..55b6165 100644
--- a/drivers/perf/hisilicon/hisi_uncore_mn.c
+++ b/drivers/perf/hisilicon/hisi_uncore_mn.c
@@ -20,6 +20,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/bitmap.h>
+#include <linux/hrtimer.h>
+#include <linux/ktime.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -56,6 +58,15 @@ enum armv8_hisi_mn_counters {
 
 #define GET_MODULE_ID(hwmod_data) hwmod_data->mn_hwcfg.module_id
 
+/*
+ * Default timer frequency to poll and avoid counter overflow.
+ * CPU speed = 2.4Ghz and number of CPU cores in a SCCL is 16.
+ * For a single MN event on a CPU core consumes 200 cycles.
+ * So overflow time = (2^31 * 200) / (16 * 2.4G) which is about 21 seconds
+ * So on a safe side we use a timer interval of 8sec
+ */
+#define MN1_HRTIMER_INTERVAL (8LL * MSEC_PER_SEC)
+
 struct hisi_mn_hwcfg {
 	u32 module_id;
 };
@@ -272,6 +283,15 @@ static const struct of_device_id mn_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mn_of_match);
 
+/* Use hrtimer when no IRQ, to poll for avoiding counter overflow */
+static void hisi_mn_hrtimer_init(struct hisi_pmu *mn_pmu)
+{
+	INIT_LIST_HEAD(&mn_pmu->active_list);
+	mn_pmu->ops->start_hrtimer = hisi_hrtimer_start;
+	mn_pmu->ops->stop_hrtimer = hisi_hrtimer_stop;
+	hisi_hrtimer_init(mn_pmu, MN1_HRTIMER_INTERVAL);
+}
+
 static int hisi_mn_init_data(struct hisi_pmu *mn_pmu,
 			     struct hisi_djtag_client *client)
 {
@@ -314,6 +334,12 @@ static int hisi_mn_init_data(struct hisi_pmu *mn_pmu,
 	} else
 		return -EINVAL;
 
+	/*
+	 * Use poll method to avoid counter overflow as
+	 * overflow IRQ is not supported in hardware.
+	 */
+	hisi_mn_hrtimer_init(mn_pmu);
+
 	return 0;
 }
 
@@ -361,11 +387,24 @@ static const struct attribute_group hisi_mn_cpumask_attr_group = {
 	.attrs = hisi_mn_cpumask_attrs,
 };
 
+static DEVICE_ATTR(hrtimer_interval, 0444, hisi_hrtimer_interval_sysfs_show,
+		   NULL);
+
+static struct attribute *hisi_mn_hrtimer_interval_attrs[] = {
+	&dev_attr_hrtimer_interval.attr,
+	NULL,
+};
+
+static const struct attribute_group hisi_mn_hrtimer_interval_attr_group = {
+	.attrs = hisi_mn_hrtimer_interval_attrs,
+};
+
 static const struct attribute_group *hisi_mn_pmu_attr_groups[] = {
 	&hisi_mn_attr_group,
 	&hisi_mn_format_group,
 	&hisi_mn_events_group,
 	&hisi_mn_cpumask_attr_group,
+	&hisi_mn_hrtimer_interval_attr_group,
 	NULL,
 };
 
-- 
2.1.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v6 10/11] drivers: perf: hisi: use poll method when no IRQ for MN counter overflow Anurup M <anurupvasu@gmail.com> - 2017-03-10 07:30 +0100

csiph-web