Commit graph

28 commits

Author SHA1 Message Date
Dmitry Osipenko
2360175291 PM / devfreq: tegra: Rename tegra-devfreq.c to tegra30-devfreq.c
In order to reflect that driver serves NVIDIA Tegra30 and later SoC
generations, let's rename the driver's source file to "tegra30-devfreq.c".
This will make driver files to look more consistent after addition of a
driver for Tegra20.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
1ac3474885 PM / devfreq: tegra: Support Tegra30
The devfreq driver can be used on Tegra30 without any code change and
it works perfectly fine, the default Tegra124 parameters are good enough
for Tegra30.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
[Modified by MyungJoo to depends on Tegra30/114/124/210 only]
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
546ff09381 PM / devfreq: tegra: Reconfigure hardware on governor's restart
Move hardware configuration to governor's start/resume methods.
This allows to re-initialize hardware counters and reconfigure
cleanly if governor was stopped/paused. That is needed because we
are not aware of all hardware changes that happened while governor
was stopped and the paused state may get out of sync with reality,
hence it's better to start with a clean slate after the pause. In
a result there is no memory bandwidth starvation after resume from
suspend-to-ram that results in display controller underflowing that
happens on resume because of improper decision made by devfreq about
the required memory frequency. This change also cleans up code a tad
by moving hardware-configuration code into a single location.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
5a7e10c895 PM / devfreq: tegra: Move governor registration to driver's probe
There is no need to register the ACTMON's governor separately from
the driver, hence let's move the registration into the driver's probe
function for consistency and to make code cleaner a tad.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
386789ebbd PM / devfreq: tegra: Mark ACTMON's governor as immutable
The ACTMON's governor supports only the Tegra's devfreq device and there
is no need to use any other governor, hence let's mark Tegra governor as
immutable to permanently stick it with Tegra's devfreq device.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
151531f79a PM / devfreq: tegra: Avoid inconsistency of current frequency value
The frequency value potentially could change in-between. It doesn't
cause any real problem at all right now, but that could change in the
future. Hence let's avoid the inconsistency.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
8fda5c1fab PM / devfreq: tegra: Clean up driver's probe / remove
Reset hardware, disable ACTMON clock, release OPP's and handle all
possible error cases correctly, maintaining the correct tear down
order. Also use devm_platform_ioremap_resource() which is now available
in the kernel.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
7514dd05ea PM / devfreq: tegra: Properly disable interrupts
There is no guarantee that interrupt handling isn't running in parallel
with tegra_actmon_disable_interrupts(), hence it is necessary to protect
DEV_CTRL register accesses and clear IRQ status with ACTMON's IRQ being
disabled in the Interrupt Controller in order to ensure that device
interrupt is indeed being disabled.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
dd3f2616bb PM / devfreq: tegra: Drop primary interrupt handler
There is no real need in the primary interrupt handler, hence move
everything to the secondary (threaded) handler. In a result locking
is consistent now and there are no potential races with the interrupt
handler because it is protected with the devfreq's mutex.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
b061312f4b PM / devfreq: tegra: Don't set EMC clock rate to maximum on probe
There is no real benefit from doing so, hence let's drop that rate setting
for consistency.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
30af44fae8 PM / devfreq: tegra: Don't ignore clk errors
The clk_set_min_rate() could fail and in this case clk_set_rate() sets
rate to 0, which may drop EMC rate to minimum and make machine very
difficult to use.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
ed2a8dd22a PM / devfreq: tegra: Replace write memory barrier with the read barrier
The write memory barrier isn't needed because the BUS buffer is flushed
by read after write that happens after the removed wmb(), we will also
use readl() instead of the relaxed version to ensure that read is indeed
completed.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
efe9043db4 PM / devfreq: tegra: Replace readl-writel with relaxed versions
There is no need to insert memory barrier on each readl/writel
invocation, hence use the relaxed versions.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Dmitry Osipenko
62bacb06b9 PM / devfreq: tegra: Fix kHz to Hz conversion
The kHz to Hz is incorrectly converted in a few places in the code,
this results in a wrong frequency being calculated because devfreq core
uses OPP frequencies that are given in Hz to clamp the rate, while
tegra-devfreq gives to the core value in kHz and then it also expects to
receive value in kHz from the core. In a result memory freq is always set
to a value which is close to ULONG_MAX because of the bug. Hence the EMC
frequency is always capped to the maximum and the driver doesn't do
anything useful. This patch was tested on Tegra30 and Tegra124 SoC's, EMC
frequency scaling works properly now.

Cc: <stable@vger.kernel.org> # 4.14+
Tested-by: Steev Klimaszewski <steev@kali.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-24 20:11:12 +09:00
Thomas Gleixner
9952f6918d treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201
Based on 1 normalized pattern(s):

  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 http www gnu org
  licenses

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 228 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528171438.107155473@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:52 -07:00
Yangtao Li
1d1397c3ec PM / devfreq: tegra: remove unneeded variable
This variable is not used after initialization, so
remove it. And in order to unify the code style,
move the location where the dev_get_drvdata is called
by the way.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-04-16 09:29:18 +09:00
Randy Dunlap
ac3167257b headers: separate linux/mod_devicetable.h from linux/platform_device.h
At over 4000 #includes, <linux/platform_device.h> is the 9th most
#included header file in the Linux kernel.  It does not need
<linux/mod_devicetable.h>, so drop that header and explicitly add
<linux/mod_devicetable.h> to source files that need it.

   4146 #include <linux/platform_device.h>

After this patch, there are 225 files that use <linux/mod_devicetable.h>,
for a reduction of around 3900 times that <linux/mod_devicetable.h>
does not have to be read & parsed.

    225 #include <linux/mod_devicetable.h>

This patch was build-tested on 20 different arch-es.

It also makes these drivers SubmitChecklist#1 compliant.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kbuild test robot <lkp@intel.com> # drivers/media/platform/vimc/
Reported-by: kbuild test robot <lkp@intel.com> # drivers/pinctrl/pinctrl-u300.c
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-07 17:52:26 +02:00
Gustavo A. R. Silva
9e578b3750 PM / devfreq: tegra: fix error return code in tegra_devfreq_probe()
platform_get_irq() returns an error code, but the tegra-devfreq
driver ignores it and always returns -ENODEV. This is not correct,
and prevents -EPROBE_DEFER from being propagated properly.

Notice that platform_get_irq() no longer returns 0 on error:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af

Print and propagate the return value of platform_get_irq on failure.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2017-07-06 10:16:17 +09:00
Viresh Kumar
8a31d9d942 PM / OPP: Update OPP users to put reference
This patch updates dev_pm_opp_find_freq_*() routines to get a reference
to the OPPs returned by them.

Also updates the users of dev_pm_opp_find_freq_*() routines to call
dev_pm_opp_put() after they are done using the OPPs.

As it is guaranteed the that OPPs wouldn't get freed while being used,
the RCU read side locking present with the users isn't required anymore.
Drop it as well.

This patch also updates all users of devfreq_recommended_opp() which was
returning an OPP received from the OPP core.

Note that some of the OPP core routines have gained
rcu_read_{lock|unlock}() calls, as those still use RCU specific APIs
within them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> [Devfreq]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-01-30 09:22:21 +01:00
Tomeu Vizoso
dbb0c7c430 PM / devfreq: tegra: Set freq in rate callback
As per the documentation of the devfreq_dev_profile.target callback, set
the freq argument to the new frequency before returning.

This caused endless messages like this after recent changes in the core:

devfreq 6000c800.actmon: Couldn't update frequency transition information.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reported-by: Tyler Baker <tyler.baker@linaro.org>
Tested-by: Thierry Reding <treding@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2016-02-23 14:27:42 +09:00
MyungJoo Ham
14de390318 PM / devfreq: tegra: Update governor to use devfreq_update_stats()
Direct invocation of get_dev_status() is no more recommended.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-09-11 14:23:30 +09:00
Tomeu Vizoso
358b615f58 PM / devfreq: tegra: Register governor on module init
So this driver builds as a module.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31 13:17:15 +09:00
Tomeu Vizoso
34ed504008 PM / devfreq: tegra: Enable interrupts after resuming the devfreq monitor
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31 13:17:15 +09:00
Tomeu Vizoso
2da19b1a4d PM / devfreq: tegra: Set drvdata before enabling the irq
To avoid a race in which the interrupt will be handled before the
drvdata has been set up.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31 13:17:14 +09:00
Tomeu Vizoso
5d498b463a PM / devfreq: tegra: remove operating-points
As the DT bindings don't have an operating-points property any more,
build the OPP table from the frequencies supported by the EMC clock.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31 13:17:14 +09:00
Tomeu Vizoso
c70eea739f PM / devfreq: tegra: Use clock rate constraints
Now that we have per-user clocks and the possibility to set constraints
in a clock, set a floor constraint on the EMC clock.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31 13:17:13 +09:00
Tomeu Vizoso
11573e9132 PM / devfreq: tegra: Update to v5 of the submitted patches
There seemed to be some miscommunication and an old version of the
submitted patches was merged.

This commit updates the driver to v5, which had this changelog:

* Clarify the units of avg_dependency_threshold
* Remove unused references to platform_device
* Enable and disable interrupts on governor events
* Make sure we handle all interrupts for any of the devices we are sampling
* Move locking to be per-actmon-device

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
CC: Alex Frid <afrid@nvidia.com>
CC: Mikko Perttunen <mikko.perttunen@kapsi.fi>
[Added const to device ID by MyungJoo]
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-03-31 13:17:03 +09:00
Tomeu Vizoso
6234f38016 PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor
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 <afrid@nvidia.com> and Mikko
Perttunen <mikko.perttunen@kapsi.fi>.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2015-01-29 21:25:48 +09:00