linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes
@ 2021-03-23 21:04 Dmitry Osipenko
  2021-03-23 21:04 ` [PATCH v1 2/2] memory: tegra20: Protect debug code with a lock Dmitry Osipenko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2021-03-23 21:04 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Krzysztof Kozlowski
  Cc: linux-kernel, linux-tegra

The code was changed multiple times and the comment to MC_STAT
registers writes became slightly outdated. The MC_STAT programming
now isn't hardcoded to the "bandwidth" mode, let's clarify this in
the comment.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/memory/tegra/tegra20.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
index 14caf5b9324c..4659c0cea30d 100644
--- a/drivers/memory/tegra/tegra20.c
+++ b/drivers/memory/tegra/tegra20.c
@@ -451,9 +451,8 @@ static void tegra20_mc_stat_gather(struct tegra20_mc_stat *stat)
 	control_1 = tegra20_mc_stat_gather_control(&stat->gather1);
 
 	/*
-	 * Reset statistic gathers state, select bandwidth mode for the
-	 * statistics collection mode and set clocks counter saturation
-	 * limit to maximum.
+	 * Reset statistic gathers state, select statistics collection mode
+	 * and set clocks counter saturation limit to maximum.
 	 */
 	mc_writel(mc, 0x00000000, MC_STAT_CONTROL);
 	mc_writel(mc,  control_0, MC_STAT_EMC_CONTROL_0);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/2] memory: tegra20: Protect debug code with a lock
  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
  2021-03-25 17:20 ` [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes Dmitry Osipenko
  2021-03-26  7:36 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2021-03-23 21:04 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Krzysztof Kozlowski
  Cc: linux-kernel, linux-tegra

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes
  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 ` [PATCH v1 2/2] memory: tegra20: Protect debug code with a lock Dmitry Osipenko
@ 2021-03-25 17:20 ` Dmitry Osipenko
  2021-03-26  7:38   ` Krzysztof Kozlowski
  2021-03-26  7:36 ` Krzysztof Kozlowski
  2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Osipenko @ 2021-03-25 17:20 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Krzysztof Kozlowski
  Cc: linux-kernel, linux-tegra

24.03.2021 00:04, Dmitry Osipenko пишет:
> The code was changed multiple times and the comment to MC_STAT
> registers writes became slightly outdated. The MC_STAT programming
> now isn't hardcoded to the "bandwidth" mode, let's clarify this in
> the comment.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/memory/tegra/tegra20.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
> index 14caf5b9324c..4659c0cea30d 100644
> --- a/drivers/memory/tegra/tegra20.c
> +++ b/drivers/memory/tegra/tegra20.c
> @@ -451,9 +451,8 @@ static void tegra20_mc_stat_gather(struct tegra20_mc_stat *stat)
>  	control_1 = tegra20_mc_stat_gather_control(&stat->gather1);
>  
>  	/*
> -	 * Reset statistic gathers state, select bandwidth mode for the
> -	 * statistics collection mode and set clocks counter saturation
> -	 * limit to maximum.
> +	 * Reset statistic gathers state, select statistics collection mode
> +	 * and set clocks counter saturation limit to maximum.
>  	 */
>  	mc_writel(mc, 0x00000000, MC_STAT_CONTROL);
>  	mc_writel(mc,  control_0, MC_STAT_EMC_CONTROL_0);
> 

Krzysztof, please feel free to squash these 2 minor follow up patches
into the original patch which added the the debug support, if you prefer
this way more. I happened to notice these small itches only after you
already picked up the previous patch.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes
  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 ` [PATCH v1 2/2] memory: tegra20: Protect debug code with a lock Dmitry Osipenko
  2021-03-25 17:20 ` [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes Dmitry Osipenko
@ 2021-03-26  7:36 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-03-26  7:36 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, Dmitry Osipenko, Krzysztof Kozlowski
  Cc: Krzysztof Kozlowski, linux-tegra, linux-kernel

On Wed, 24 Mar 2021 00:04:45 +0300, Dmitry Osipenko wrote:
> The code was changed multiple times and the comment to MC_STAT
> registers writes became slightly outdated. The MC_STAT programming
> now isn't hardcoded to the "bandwidth" mode, let's clarify this in
> the comment.

Applied, thanks!

[1/2] memory: tegra20: Correct comment to MC_STAT registers writes
      (no commit info)
[2/2] memory: tegra20: Protect debug code with a lock
      (no commit info)

Best regards,
-- 
Krzysztof Kozlowski <krzk@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes
  2021-03-25 17:20 ` [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes Dmitry Osipenko
@ 2021-03-26  7:38   ` Krzysztof Kozlowski
  2021-03-26 13:22     ` Dmitry Osipenko
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2021-03-26  7:38 UTC (permalink / raw)
  To: Dmitry Osipenko, Thierry Reding, Jonathan Hunter
  Cc: linux-kernel, linux-tegra

On 25/03/2021 18:20, Dmitry Osipenko wrote:
> 24.03.2021 00:04, Dmitry Osipenko пишет:
>> The code was changed multiple times and the comment to MC_STAT
>> registers writes became slightly outdated. The MC_STAT programming
>> now isn't hardcoded to the "bandwidth" mode, let's clarify this in
>> the comment.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/memory/tegra/tegra20.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
>> index 14caf5b9324c..4659c0cea30d 100644
>> --- a/drivers/memory/tegra/tegra20.c
>> +++ b/drivers/memory/tegra/tegra20.c
>> @@ -451,9 +451,8 @@ static void tegra20_mc_stat_gather(struct tegra20_mc_stat *stat)
>>  	control_1 = tegra20_mc_stat_gather_control(&stat->gather1);
>>  
>>  	/*
>> -	 * Reset statistic gathers state, select bandwidth mode for the
>> -	 * statistics collection mode and set clocks counter saturation
>> -	 * limit to maximum.
>> +	 * Reset statistic gathers state, select statistics collection mode
>> +	 * and set clocks counter saturation limit to maximum.
>>  	 */
>>  	mc_writel(mc, 0x00000000, MC_STAT_CONTROL);
>>  	mc_writel(mc,  control_0, MC_STAT_EMC_CONTROL_0);
>>
> 
> Krzysztof, please feel free to squash these 2 minor follow up patches
> into the original patch which added the the debug support, if you prefer
> this way more. I happened to notice these small itches only after you
> already picked up the previous patch.

No problem, in general I prefer to have incremental improvements.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes
  2021-03-26  7:38   ` Krzysztof Kozlowski
@ 2021-03-26 13:22     ` Dmitry Osipenko
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2021-03-26 13:22 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Thierry Reding, Jonathan Hunter
  Cc: linux-kernel, linux-tegra

26.03.2021 10:38, Krzysztof Kozlowski пишет:
> On 25/03/2021 18:20, Dmitry Osipenko wrote:
>> 24.03.2021 00:04, Dmitry Osipenko пишет:
>>> The code was changed multiple times and the comment to MC_STAT
>>> registers writes became slightly outdated. The MC_STAT programming
>>> now isn't hardcoded to the "bandwidth" mode, let's clarify this in
>>> the comment.
>>>
>>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>>> ---
>>>  drivers/memory/tegra/tegra20.c | 5 ++---
>>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
>>> index 14caf5b9324c..4659c0cea30d 100644
>>> --- a/drivers/memory/tegra/tegra20.c
>>> +++ b/drivers/memory/tegra/tegra20.c
>>> @@ -451,9 +451,8 @@ static void tegra20_mc_stat_gather(struct tegra20_mc_stat *stat)
>>>  	control_1 = tegra20_mc_stat_gather_control(&stat->gather1);
>>>  
>>>  	/*
>>> -	 * Reset statistic gathers state, select bandwidth mode for the
>>> -	 * statistics collection mode and set clocks counter saturation
>>> -	 * limit to maximum.
>>> +	 * Reset statistic gathers state, select statistics collection mode
>>> +	 * and set clocks counter saturation limit to maximum.
>>>  	 */
>>>  	mc_writel(mc, 0x00000000, MC_STAT_CONTROL);
>>>  	mc_writel(mc,  control_0, MC_STAT_EMC_CONTROL_0);
>>>
>>
>> Krzysztof, please feel free to squash these 2 minor follow up patches
>> into the original patch which added the the debug support, if you prefer
>> this way more. I happened to notice these small itches only after you
>> already picked up the previous patch.
> 
> No problem, in general I prefer to have incremental improvements.

Thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-26 13:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v1 2/2] memory: tegra20: Protect debug code with a lock Dmitry Osipenko
2021-03-25 17:20 ` [PATCH v1 1/2] memory: tegra20: Correct comment to MC_STAT registers writes Dmitry Osipenko
2021-03-26  7:38   ` Krzysztof Kozlowski
2021-03-26 13:22     ` Dmitry Osipenko
2021-03-26  7:36 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).