From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: [PATCH v1 2/2] memory: tegra20: Protect debug code with a lock
Date: Wed, 24 Mar 2021 00:04:46 +0300 [thread overview]
Message-ID: <20210323210446.24867-2-digetx@gmail.com> (raw)
In-Reply-To: <20210323210446.24867-1-digetx@gmail.com>
Simultaneous accesses to MC_STAT h/w shouldn't be allowed since one
collection process stomps on another. There is no good reason for
polling stats in parallel in practice, nevertheless let's add a
protection lock, just for consistency.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/memory/tegra/tegra20.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
index 4659c0cea30d..2db68a913b7a 100644
--- a/drivers/memory/tegra/tegra20.c
+++ b/drivers/memory/tegra/tegra20.c
@@ -5,6 +5,7 @@
#include <linux/bitfield.h>
#include <linux/delay.h>
+#include <linux/mutex.h>
#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -55,6 +56,8 @@
/* we store collected statistics as a fixed point values */
#define MC_FX_FRAC_SCALE 100
+static DEFINE_MUTEX(tegra20_mc_stat_lock);
+
struct tegra20_mc_stat_gather {
unsigned int pri_filter;
unsigned int pri_event;
@@ -615,8 +618,12 @@ static int tegra20_mc_stats_show(struct seq_file *s, void *unused)
if (!stats)
return -ENOMEM;
+ mutex_lock(&tegra20_mc_stat_lock);
+
tegra20_mc_collect_stats(mc, stats);
+ mutex_unlock(&tegra20_mc_stat_lock);
+
seq_puts(s, "Memory client Events Timeout High priority Bandwidth ARB RW change Successive Page miss\n");
seq_puts(s, "-----------------------------------------------------------------------------------------------------\n");
--
2.30.2
next prev parent reply other threads:[~2021-03-23 21:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 21:04 [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes Dmitry Osipenko
2021-03-23 21:04 ` Dmitry Osipenko [this message]
2021-03-25 17:20 ` Dmitry Osipenko
2021-03-26 7:38 ` Krzysztof Kozlowski
2021-03-26 13:22 ` Dmitry Osipenko
2021-03-26 7:36 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210323210446.24867-2-digetx@gmail.com \
--to=digetx@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome