Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-12-03 Thread Tomeu Vizoso
On 2 December 2014 at 12:15, Thierry Reding  wrote:
> On Mon, Nov 24, 2014 at 01:28:17PM +0100, Tomeu Vizoso wrote:
>> The ACTMON block can monitor several counters, providing averaging and firing
>> interrupts based on watermarking configuration. This implementation monitors
>> the MCALL and MCCPU counters to choose an appropriate frequency for the
>> external memory clock.
>>
>> This patch is based on work by Alex Frid  and Mikko
>> Perttunen .
>>
>> Signed-off-by: Tomeu Vizoso 
>>
>> ---
>>
>> v2:   * Use devfreq
>> ---
>>  drivers/devfreq/Kconfig |  10 +
>>  drivers/devfreq/Makefile|   1 +
>>  drivers/devfreq/tegra-devfreq.c | 718 
>> 
>>  3 files changed, 729 insertions(+)
>>  create mode 100644 drivers/devfreq/tegra-devfreq.c
>>
>> diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
>> index faf4e70..4aab799 100644
>> --- a/drivers/devfreq/Kconfig
>> +++ b/drivers/devfreq/Kconfig
>> @@ -87,4 +87,14 @@ config ARM_EXYNOS5_BUS_DEVFREQ
>> It reads PPMU counters of memory controllers and adjusts the
>> operating frequencies and voltages with OPP support.
>>
>> +config ARM_TEGRA_DEVFREQ
>> +   tristate "Tegra DEVFREQ Driver"
>> +   depends on ARCH_TEGRA_124_SOC
>
> I think ACTMON exists at least on Tegra30 and Tegra114 as well and it
> would be surprising if it didn't exist on Tegra132, so perhaps make this
> dependency simply ARCH_TEGRA?

Ok.

>> +   select DEVFREQ_GOV_SIMPLE_ONDEMAND
>> +   select PM_OPP
>> +   help
>> + This adds the DEVFREQ driver for the Tegra family of SoCs.
>> + It reads ACTMON counters of memory controllers and adjusts the
>> + operating frequencies and voltages with OPP support.
>> +
>>  endif # PM_DEVFREQ
>> diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
>> index 16138c9..0ea991f 100644
>> --- a/drivers/devfreq/Makefile
>> +++ b/drivers/devfreq/Makefile
>> @@ -7,3 +7,4 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)   += governor_userspace.o
>>  # DEVFREQ Drivers
>>  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)+= exynos/
>>  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)+= exynos/
>> +obj-$(CONFIG_ARM_TEGRA_DEVFREQ)  += tegra-devfreq.o
>> diff --git a/drivers/devfreq/tegra-devfreq.c 
>> b/drivers/devfreq/tegra-devfreq.c
>> new file mode 100644
>> index 000..3479096
>> --- /dev/null
>> +++ b/drivers/devfreq/tegra-devfreq.c
>> @@ -0,0 +1,718 @@
>> +/*
>> + * A devfreq driver for NVIDIA Tegra SoCs
>> + *
>> + * Copyright (c) 2014 NVIDIA CORPORATION. All rights reserved.
>> + * Copyright (C) 2014 Google, Inc
>> + *
>> + * 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.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program. If not, see .
>> + *
>> + */
>> +
> [...]
>> +/* activity counter is incremented every 256 memory transactions, and each
>
> Proper block-comments should be:
>
> /*
>  * activity counter...
>  * ...
>  */
>
> Also it's a sentence, therefore should start with a capital 'A'.

Done.

>> + * transaction takes 4 EMC clocks for Tegra124; So the COUNT_WEIGHT is
>> + * 4 * 256 = 1024.
>> + */
>> +#define ACTMON_COUNT_WEIGHT  0x400
>> +
>> +/*
>> + * ACTMON_AVERAGE_WINDOW_LOG2: default value for @DEV_CTRL_K_VAL, which
>> + * translates to 2 ^ (K_VAL + 1). ex: 2 ^ (6 + 1) = 128
>> + */
>> +#define ACTMON_AVERAGE_WINDOW_LOG2   6
>> +#define ACTMON_SAMPLING_PERIOD   12 /* ms */
>> +#define ACTMON_DEFAULT_AVG_BAND  6  /* 1/10 of 
>> % */
>> +
>> +#define KHZ  1000
>> +
>> +/* Assume that the bus is saturated if the utilization is 25% */
>> +#define BUS_SATURATION_RATIO 25
> [...]
>> +static void tegra_actmon_configure_device(struct tegra_devfreq *tegra,
>> +   struct tegra_devfreq_device *dev)
>> +{
>> + u32 val;
>> +
>> + dev->avg_band_freq = tegra->max_freq * ACTMON_DEFAULT_AVG_BAND / KHZ;
>> + dev->target_freq = tegra->cur_freq;
>> +
>> + dev->avg_count = tegra->cur_freq * ACTMON_SAMPLING_PERIOD;
>> + writel(dev->avg_count, dev->regs + ACTMON_DEV_INIT_AVG);
>> +
>> + tegra_devfreq_update_avg_wmark(dev);
>> + tegra_devfreq_update_wmark(tegra, dev);
>> +
>> + writel(ACTMON_COUNT_WEIGHT, dev->regs + ACTMON_DEV_COUNT_WEIGHT);
>> + writel(ACTMON_I

Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-12-02 Thread Tomeu Vizoso
On 26 November 2014 at 11:02, Alexandre Courbot  wrote:
> On Mon, Nov 24, 2014 at 9:28 PM, Tomeu Vizoso
>  wrote:
>> The ACTMON block can monitor several counters, providing averaging and firing
>> interrupts based on watermarking configuration. This implementation monitors
>> the MCALL and MCCPU counters to choose an appropriate frequency for the
>> external memory clock.
>>
>> This patch is based on work by Alex Frid  and Mikko
>> Perttunen .
>
> Thanks for taking the time to adapt this driver to use devfreq.
> Looking at it, I am more and more convinced that's the correct way to
> do.
>
> I made some comments inline, but I'd like to bring Arto Merilainen
> into this discussion. Arto thought (and might even have some code)
> about adding watermarks support to devfreq's core and using a generic
> "watermark" governor which I believe would greatly benefit this patch
> set.

Do you know of any other SoC family that would be able to use that code?

> Arto, do you have some concrete code you could submit here? If
> you lack the time for doing so, some guidance so we could implement
> this support ourselves would be great.
>
>>
>> Signed-off-by: Tomeu Vizoso 
>>
>> ---
>>
>> v2: * Use devfreq
>> ---
>>  drivers/devfreq/Kconfig |  10 +
>>  drivers/devfreq/Makefile|   1 +
>>  drivers/devfreq/tegra-devfreq.c | 718 
>> 
>>  3 files changed, 729 insertions(+)
>>  create mode 100644 drivers/devfreq/tegra-devfreq.c
>>
>> diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
>> index faf4e70..4aab799 100644
>> --- a/drivers/devfreq/Kconfig
>> +++ b/drivers/devfreq/Kconfig
>> @@ -87,4 +87,14 @@ config ARM_EXYNOS5_BUS_DEVFREQ
>>   It reads PPMU counters of memory controllers and adjusts the
>>   operating frequencies and voltages with OPP support.
>>
>> +config ARM_TEGRA_DEVFREQ
>> +   tristate "Tegra DEVFREQ Driver"
>> +   depends on ARCH_TEGRA_124_SOC
>> +   select DEVFREQ_GOV_SIMPLE_ONDEMAND
>> +   select PM_OPP
>> +   help
>> + This adds the DEVFREQ driver for the Tegra family of SoCs.
>> + It reads ACTMON counters of memory controllers and adjusts the
>> + operating frequencies and voltages with OPP support.
>> +
>>  endif # PM_DEVFREQ
>> diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
>> index 16138c9..0ea991f 100644
>> --- a/drivers/devfreq/Makefile
>> +++ b/drivers/devfreq/Makefile
>> @@ -7,3 +7,4 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += 
>> governor_userspace.o
>>  # DEVFREQ Drivers
>>  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)  += exynos/
>>  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)  += exynos/
>> +obj-$(CONFIG_ARM_TEGRA_DEVFREQ)+= tegra-devfreq.o
>> diff --git a/drivers/devfreq/tegra-devfreq.c 
>> b/drivers/devfreq/tegra-devfreq.c
>> new file mode 100644
>> index 000..3479096
>> --- /dev/null
>> +++ b/drivers/devfreq/tegra-devfreq.c
>
> This file should probably be named tegra-actmon-devfreq.c, for nothing
> guarantees that we will not have more devfreq devices for Tegra in the
> future.

Good point.

>> @@ -0,0 +1,718 @@
>> +/*
>> + * A devfreq driver for NVIDIA Tegra SoCs
>> + *
>> + * Copyright (c) 2014 NVIDIA CORPORATION. All rights reserved.
>> + * Copyright (C) 2014 Google, Inc
>> + *
>> + * 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.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program. If not, see .
>> + *
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "governor.h"
>> +
>> +#define ACTMON_GLB_STATUS  0x0
>> +#define ACTMON_GLB_PERIOD_CTRL 0x4
>> +
>> +#define ACTMON_DEV_CTRL0x0
>> +#define ACTMON_DEV_CTRL_K_VAL_SHIFT10
>> +#define ACTMON_DEV_CTRL_ENB_PERIODIC   BIT(18)
>> +#define ACTMON_DEV_CTRL_AVG_BELOW_WMARK_EN BIT(20)
>> +#define ACTMON_DEV_CTRL_AVG_ABOVE_WMARK_EN BIT(21)
>> +#define ACTMON_DEV_CTRL_CONSECUTIVE_BELOW_WMARK_NUM_SHIFT  23
>> +#define ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_NUM_SHIFT  26
>> +#define ACTMON_DEV_CTRL_CONSECUTIVE_BELOW_WMARK_EN BIT(29)
>> +#define ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_EN BIT(30)
>> +#define ACTMON_DEV_CTRL_ENB   

Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-12-02 Thread Thierry Reding
On Mon, Nov 24, 2014 at 01:28:17PM +0100, Tomeu Vizoso wrote:
> The ACTMON block can monitor several counters, providing averaging and firing
> interrupts based on watermarking configuration. This implementation monitors
> the MCALL and MCCPU counters to choose an appropriate frequency for the
> external memory clock.
> 
> This patch is based on work by Alex Frid  and Mikko
> Perttunen .
> 
> Signed-off-by: Tomeu Vizoso 
> 
> ---
> 
> v2:   * Use devfreq
> ---
>  drivers/devfreq/Kconfig |  10 +
>  drivers/devfreq/Makefile|   1 +
>  drivers/devfreq/tegra-devfreq.c | 718 
> 
>  3 files changed, 729 insertions(+)
>  create mode 100644 drivers/devfreq/tegra-devfreq.c
> 
> diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
> index faf4e70..4aab799 100644
> --- a/drivers/devfreq/Kconfig
> +++ b/drivers/devfreq/Kconfig
> @@ -87,4 +87,14 @@ config ARM_EXYNOS5_BUS_DEVFREQ
> It reads PPMU counters of memory controllers and adjusts the
> operating frequencies and voltages with OPP support.
>  
> +config ARM_TEGRA_DEVFREQ
> +   tristate "Tegra DEVFREQ Driver"
> +   depends on ARCH_TEGRA_124_SOC

I think ACTMON exists at least on Tegra30 and Tegra114 as well and it
would be surprising if it didn't exist on Tegra132, so perhaps make this
dependency simply ARCH_TEGRA?

> +   select DEVFREQ_GOV_SIMPLE_ONDEMAND
> +   select PM_OPP
> +   help
> + This adds the DEVFREQ driver for the Tegra family of SoCs.
> + It reads ACTMON counters of memory controllers and adjusts the
> + operating frequencies and voltages with OPP support.
> +
>  endif # PM_DEVFREQ
> diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
> index 16138c9..0ea991f 100644
> --- a/drivers/devfreq/Makefile
> +++ b/drivers/devfreq/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE)   += governor_userspace.o
>  # DEVFREQ Drivers
>  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)+= exynos/
>  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)+= exynos/
> +obj-$(CONFIG_ARM_TEGRA_DEVFREQ)  += tegra-devfreq.o
> diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
> new file mode 100644
> index 000..3479096
> --- /dev/null
> +++ b/drivers/devfreq/tegra-devfreq.c
> @@ -0,0 +1,718 @@
> +/*
> + * A devfreq driver for NVIDIA Tegra SoCs
> + *
> + * Copyright (c) 2014 NVIDIA CORPORATION. All rights reserved.
> + * Copyright (C) 2014 Google, Inc
> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see .
> + *
> + */
> +
[...]
> +/* activity counter is incremented every 256 memory transactions, and each

Proper block-comments should be:

/*
 * activity counter...
 * ...
 */

Also it's a sentence, therefore should start with a capital 'A'.

> + * transaction takes 4 EMC clocks for Tegra124; So the COUNT_WEIGHT is
> + * 4 * 256 = 1024.
> + */
> +#define ACTMON_COUNT_WEIGHT  0x400
> +
> +/*
> + * ACTMON_AVERAGE_WINDOW_LOG2: default value for @DEV_CTRL_K_VAL, which
> + * translates to 2 ^ (K_VAL + 1). ex: 2 ^ (6 + 1) = 128
> + */
> +#define ACTMON_AVERAGE_WINDOW_LOG2   6
> +#define ACTMON_SAMPLING_PERIOD   12 /* ms */
> +#define ACTMON_DEFAULT_AVG_BAND  6  /* 1/10 of % 
> */
> +
> +#define KHZ  1000
> +
> +/* Assume that the bus is saturated if the utilization is 25% */
> +#define BUS_SATURATION_RATIO 25
[...]
> +static void tegra_actmon_configure_device(struct tegra_devfreq *tegra,
> +   struct tegra_devfreq_device *dev)
> +{
> + u32 val;
> +
> + dev->avg_band_freq = tegra->max_freq * ACTMON_DEFAULT_AVG_BAND / KHZ;
> + dev->target_freq = tegra->cur_freq;
> +
> + dev->avg_count = tegra->cur_freq * ACTMON_SAMPLING_PERIOD;
> + writel(dev->avg_count, dev->regs + ACTMON_DEV_INIT_AVG);
> +
> + tegra_devfreq_update_avg_wmark(dev);
> + tegra_devfreq_update_wmark(tegra, dev);
> +
> + writel(ACTMON_COUNT_WEIGHT, dev->regs + ACTMON_DEV_COUNT_WEIGHT);
> + writel(ACTMON_INTR_STATUS_CLEAR, dev->regs + ACTMON_DEV_INTR_STATUS);
> +
> + val = 0;

You could initialize this to 0 and then save this one line.

> + val |= ACTMON_DEV_CTRL_ENB_PERIODIC |
> +

Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-11-26 Thread Alexandre Courbot
On Mon, Nov 24, 2014 at 9:28 PM, Tomeu Vizoso
 wrote:
> The ACTMON block can monitor several counters, providing averaging and firing
> interrupts based on watermarking configuration. This implementation monitors
> the MCALL and MCCPU counters to choose an appropriate frequency for the
> external memory clock.
>
> This patch is based on work by Alex Frid  and Mikko
> Perttunen .

Thanks for taking the time to adapt this driver to use devfreq.
Looking at it, I am more and more convinced that's the correct way to
do.

I made some comments inline, but I'd like to bring Arto Merilainen
into this discussion. Arto thought (and might even have some code)
about adding watermarks support to devfreq's core and using a generic
"watermark" governor which I believe would greatly benefit this patch
set. Arto, do you have some concrete code you could submit here? If
you lack the time for doing so, some guidance so we could implement
this support ourselves would be great.

>
> Signed-off-by: Tomeu Vizoso 
>
> ---
>
> v2: * Use devfreq
> ---
>  drivers/devfreq/Kconfig |  10 +
>  drivers/devfreq/Makefile|   1 +
>  drivers/devfreq/tegra-devfreq.c | 718 
> 
>  3 files changed, 729 insertions(+)
>  create mode 100644 drivers/devfreq/tegra-devfreq.c
>
> diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
> index faf4e70..4aab799 100644
> --- a/drivers/devfreq/Kconfig
> +++ b/drivers/devfreq/Kconfig
> @@ -87,4 +87,14 @@ config ARM_EXYNOS5_BUS_DEVFREQ
>   It reads PPMU counters of memory controllers and adjusts the
>   operating frequencies and voltages with OPP support.
>
> +config ARM_TEGRA_DEVFREQ
> +   tristate "Tegra DEVFREQ Driver"
> +   depends on ARCH_TEGRA_124_SOC
> +   select DEVFREQ_GOV_SIMPLE_ONDEMAND
> +   select PM_OPP
> +   help
> + This adds the DEVFREQ driver for the Tegra family of SoCs.
> + It reads ACTMON counters of memory controllers and adjusts the
> + operating frequencies and voltages with OPP support.
> +
>  endif # PM_DEVFREQ
> diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
> index 16138c9..0ea991f 100644
> --- a/drivers/devfreq/Makefile
> +++ b/drivers/devfreq/Makefile
> @@ -7,3 +7,4 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += 
> governor_userspace.o
>  # DEVFREQ Drivers
>  obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)  += exynos/
>  obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)  += exynos/
> +obj-$(CONFIG_ARM_TEGRA_DEVFREQ)+= tegra-devfreq.o
> diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
> new file mode 100644
> index 000..3479096
> --- /dev/null
> +++ b/drivers/devfreq/tegra-devfreq.c

This file should probably be named tegra-actmon-devfreq.c, for nothing
guarantees that we will not have more devfreq devices for Tegra in the
future.

> @@ -0,0 +1,718 @@
> +/*
> + * A devfreq driver for NVIDIA Tegra SoCs
> + *
> + * Copyright (c) 2014 NVIDIA CORPORATION. All rights reserved.
> + * Copyright (C) 2014 Google, Inc
> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see .
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "governor.h"
> +
> +#define ACTMON_GLB_STATUS  0x0
> +#define ACTMON_GLB_PERIOD_CTRL 0x4
> +
> +#define ACTMON_DEV_CTRL0x0
> +#define ACTMON_DEV_CTRL_K_VAL_SHIFT10
> +#define ACTMON_DEV_CTRL_ENB_PERIODIC   BIT(18)
> +#define ACTMON_DEV_CTRL_AVG_BELOW_WMARK_EN BIT(20)
> +#define ACTMON_DEV_CTRL_AVG_ABOVE_WMARK_EN BIT(21)
> +#define ACTMON_DEV_CTRL_CONSECUTIVE_BELOW_WMARK_NUM_SHIFT  23
> +#define ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_NUM_SHIFT  26
> +#define ACTMON_DEV_CTRL_CONSECUTIVE_BELOW_WMARK_EN BIT(29)
> +#define ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_EN BIT(30)
> +#define ACTMON_DEV_CTRL_ENBBIT(31)
> +
> +#define ACTMON_DEV_UPPER_WMARK 0x4
> +#define ACTMON_DEV_LOWER_WMARK 0x8
> +#define ACTMON_DEV_INIT_AVG0xc
> +#define ACTMON_DEV_AVG_UPPER_WMARK 

Re: Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-11-25 Thread MyungJoo Ham
> On 25 November 2014 at 08:07, MyungJoo Ham  wrote:
> >> The ACTMON block can monitor several counters, providing averaging and 
> >> firing
> >> interrupts based on watermarking configuration. This implementation 
> >> monitors
> >> the MCALL and MCCPU counters to choose an appropriate frequency for the
> >> external memory clock.
> >>
> >> This patch is based on work by Alex Frid  and Mikko
> >> Perttunen .
> >>
> >> Signed-off-by: Tomeu Vizoso 
> >
> > Signed-off-by: MyungJoo Ham 
> >
> > How are you going to integrate other two patches?
> 
> I think they should go through the Tegra tree.
> 
> > May I just go ahead with this patch only?
> 
> Yes, I think that would be fine as the other patches aren't actual
> build or runtime dependencies. This driver shouldn't cause problems
> either if it's ran without the EMC and CPUFreq patches (though won't
> be fully functional, of course).

Ok, then, as long as the other two patches (for DT support) get
ACKed (seems fairly straightforward as well) or Signed-off by
corresponding tree maintainers, I feel fine to
send this patch along with the next pull request.

Thank you.

Cheers,
MyungJoo

> 
> Regards,
> 
> Tomeu
> 
> > Cheers,
> > MyungJoo.
> >
> 
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�&j:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-11-25 Thread Tomeu Vizoso
On 25 November 2014 at 08:07, MyungJoo Ham  wrote:
>> The ACTMON block can monitor several counters, providing averaging and firing
>> interrupts based on watermarking configuration. This implementation monitors
>> the MCALL and MCCPU counters to choose an appropriate frequency for the
>> external memory clock.
>>
>> This patch is based on work by Alex Frid  and Mikko
>> Perttunen .
>>
>> Signed-off-by: Tomeu Vizoso 
>
> Signed-off-by: MyungJoo Ham 
>
> How are you going to integrate other two patches?

I think they should go through the Tegra tree.

> May I just go ahead with this patch only?

Yes, I think that would be fine as the other patches aren't actual
build or runtime dependencies. This driver shouldn't cause problems
either if it's ran without the EMC and CPUFreq patches (though won't
be fully functional, of course).

Regards,

Tomeu

> Cheers,
> MyungJoo.
>
>>
>> ---
>>
>> v2:   * Use devfreq
>> ---
>>  drivers/devfreq/Kconfig |  10 +
>>  drivers/devfreq/Makefile|   1 +
>>  drivers/devfreq/tegra-devfreq.c | 718 
>> 
>>  3 files changed, 729 insertions(+)
>>  create mode 100644 drivers/devfreq/tegra-devfreq.c
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-11-24 Thread MyungJoo Ham
> The ACTMON block can monitor several counters, providing averaging and firing
> interrupts based on watermarking configuration. This implementation monitors
> the MCALL and MCCPU counters to choose an appropriate frequency for the
> external memory clock.
> 
> This patch is based on work by Alex Frid  and Mikko
> Perttunen .
> 
> Signed-off-by: Tomeu Vizoso 

Signed-off-by: MyungJoo Ham 

How are you going to integrate other two patches?
May I just go ahead with this patch only?


Cheers,
MyungJoo.

> 
> ---
> 
> v2:   * Use devfreq
> ---
>  drivers/devfreq/Kconfig |  10 +
>  drivers/devfreq/Makefile|   1 +
>  drivers/devfreq/tegra-devfreq.c | 718 
> 
>  3 files changed, 729 insertions(+)
>  create mode 100644 drivers/devfreq/tegra-devfreq.c
> 
N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�&j:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

[PATCH v2 2/3] PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor

2014-11-24 Thread Tomeu Vizoso
The ACTMON block can monitor several counters, providing averaging and firing
interrupts based on watermarking configuration. This implementation monitors
the MCALL and MCCPU counters to choose an appropriate frequency for the
external memory clock.

This patch is based on work by Alex Frid  and Mikko
Perttunen .

Signed-off-by: Tomeu Vizoso 

---

v2: * Use devfreq
---
 drivers/devfreq/Kconfig |  10 +
 drivers/devfreq/Makefile|   1 +
 drivers/devfreq/tegra-devfreq.c | 718 
 3 files changed, 729 insertions(+)
 create mode 100644 drivers/devfreq/tegra-devfreq.c

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index faf4e70..4aab799 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -87,4 +87,14 @@ config ARM_EXYNOS5_BUS_DEVFREQ
  It reads PPMU counters of memory controllers and adjusts the
  operating frequencies and voltages with OPP support.
 
+config ARM_TEGRA_DEVFREQ
+   tristate "Tegra DEVFREQ Driver"
+   depends on ARCH_TEGRA_124_SOC
+   select DEVFREQ_GOV_SIMPLE_ONDEMAND
+   select PM_OPP
+   help
+ This adds the DEVFREQ driver for the Tegra family of SoCs.
+ It reads ACTMON counters of memory controllers and adjusts the
+ operating frequencies and voltages with OPP support.
+
 endif # PM_DEVFREQ
diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile
index 16138c9..0ea991f 100644
--- a/drivers/devfreq/Makefile
+++ b/drivers/devfreq/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += governor_userspace.o
 # DEVFREQ Drivers
 obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ)  += exynos/
 obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ)  += exynos/
+obj-$(CONFIG_ARM_TEGRA_DEVFREQ)+= tegra-devfreq.o
diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
new file mode 100644
index 000..3479096
--- /dev/null
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -0,0 +1,718 @@
+/*
+ * A devfreq driver for NVIDIA Tegra SoCs
+ *
+ * Copyright (c) 2014 NVIDIA CORPORATION. All rights reserved.
+ * Copyright (C) 2014 Google, Inc
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "governor.h"
+
+#define ACTMON_GLB_STATUS  0x0
+#define ACTMON_GLB_PERIOD_CTRL 0x4
+
+#define ACTMON_DEV_CTRL0x0
+#define ACTMON_DEV_CTRL_K_VAL_SHIFT10
+#define ACTMON_DEV_CTRL_ENB_PERIODIC   BIT(18)
+#define ACTMON_DEV_CTRL_AVG_BELOW_WMARK_EN BIT(20)
+#define ACTMON_DEV_CTRL_AVG_ABOVE_WMARK_EN BIT(21)
+#define ACTMON_DEV_CTRL_CONSECUTIVE_BELOW_WMARK_NUM_SHIFT  23
+#define ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_NUM_SHIFT  26
+#define ACTMON_DEV_CTRL_CONSECUTIVE_BELOW_WMARK_EN BIT(29)
+#define ACTMON_DEV_CTRL_CONSECUTIVE_ABOVE_WMARK_EN BIT(30)
+#define ACTMON_DEV_CTRL_ENBBIT(31)
+
+#define ACTMON_DEV_UPPER_WMARK 0x4
+#define ACTMON_DEV_LOWER_WMARK 0x8
+#define ACTMON_DEV_INIT_AVG0xc
+#define ACTMON_DEV_AVG_UPPER_WMARK 0x10
+#define ACTMON_DEV_AVG_LOWER_WMARK 0x14
+#define ACTMON_DEV_COUNT_WEIGHT0x18
+#define ACTMON_DEV_AVG_COUNT   0x20
+#define ACTMON_DEV_INTR_STATUS 0x24
+
+#define ACTMON_INTR_STATUS_CLEAR   0x
+
+#define ACTMON_DEV_INTR_CONSECUTIVE_UPPER  BIT(31)
+#define ACTMON_DEV_INTR_CONSECUTIVE_LOWER  BIT(30)
+
+#define ACTMON_ABOVE_WMARK_WINDOW  1
+#define ACTMON_BELOW_WMARK_WINDOW  3
+#define ACTMON_BOOST_FREQ_STEP 16000
+
+/* activity counter is incremented every 256 memory transactions, and each
+ * transaction takes 4 EMC clocks for Tegra124; So the COUNT_WEIGHT is
+ * 4 * 256 = 1024.
+ */
+#define ACTMON_COUNT_WEIGHT0x400
+
+/*
+ * ACTMON_AVERAGE_WINDOW_LO