linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support
@ 2019-04-11 22:29 Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion Dmitry Osipenko
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

Hello,

I tried to utilize the Tegra devfreq driver on Tegra30 and found out that
it doesn't work properly due to improper Hz<->kHz conversions made by the
driver. After fixing that problem and doing some more testing I noticed
that there are things that could be improved and in result here is this
patchset that fixes the problems, makes some improvements and adds support
for NVIDIA Tegra30 SoC's. This series was tested on Tegra30 and Tegra124
machines.

Dmitry Osipenko (8):
  PM / devfreq: tegra: Fix kHz to Hz conversion
  PM / devfreq: tegra: Replace readl-writel with relaxed versions
  PM / devfreq: tegra: Don't ignore clk errors
  PM / devfreq: tegra: Don't release IRQ manually on driver removal
  PM / devfreq: tegra: Don't set EMC clock rate to maximum on probe
  PM / devfreq: tegra: Drop spinlock
  PM / devfreq: tegra: Remove OPP entries on driver removal
  PM / devfreq: tegra: Support Tegra30

 drivers/devfreq/Kconfig         |  2 +-
 drivers/devfreq/tegra-devfreq.c | 66 ++++++++++++++-------------------
 2 files changed, 29 insertions(+), 39 deletions(-)

-- 
2.21.0


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

* [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
       [not found]   ` <20190412013413.4D52D20818@mail.kernel.org>
  2019-04-12 16:56   ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 2/8] PM / devfreq: tegra: Replace readl-writel with relaxed versions Dmitry Osipenko
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

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. Let's provide OPP with rates in kHz since this eliminates
few multiplies and divisions in the code. This patch was tested on Tegra30
and Tegra124 SoC's, EMC frequency scaling works properly now.

Cc: <stable@vger.kernel.org>
Tested-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra-devfreq.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index c89ba7b834ff..ec4ff55f5eea 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -394,7 +394,7 @@ static int tegra_actmon_rate_notify_cb(struct notifier_block *nb,
 
 	tegra = container_of(nb, struct tegra_devfreq, rate_change_nb);
 
-	tegra->cur_freq = data->new_rate / KHZ;
+	tegra->cur_freq = data->new_rate;
 
 	for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) {
 		dev = &tegra->devices[i];
@@ -486,21 +486,19 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
 {
 	struct tegra_devfreq *tegra = dev_get_drvdata(dev);
 	struct dev_pm_opp *opp;
-	unsigned long rate = *freq * KHZ;
+	unsigned long rate;
 
-	opp = devfreq_recommended_opp(dev, &rate, flags);
+	opp = devfreq_recommended_opp(dev, freq, flags);
 	if (IS_ERR(opp)) {
 		dev_err(dev, "Failed to find opp for %lu KHz\n", *freq);
 		return PTR_ERR(opp);
 	}
-	rate = dev_pm_opp_get_freq(opp);
+	rate = dev_pm_opp_get_freq(opp) * KHZ;
 	dev_pm_opp_put(opp);
 
 	clk_set_min_rate(tegra->emc_clock, rate);
 	clk_set_rate(tegra->emc_clock, 0);
 
-	*freq = rate;
-
 	return 0;
 }
 
@@ -682,7 +680,7 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
 
 	for (rate = 0; rate <= tegra->max_freq * KHZ; rate++) {
 		rate = clk_round_rate(tegra->emc_clock, rate);
-		dev_pm_opp_add(&pdev->dev, rate, 0);
+		dev_pm_opp_add(&pdev->dev, rate / KHZ, 0);
 	}
 
 	irq = platform_get_irq(pdev, 0);
-- 
2.21.0


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

* [PATCH v1 2/8] PM / devfreq: tegra: Replace readl-writel with relaxed versions
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 3/8] PM / devfreq: tegra: Don't ignore clk errors Dmitry Osipenko
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

There is no need to insert memory barrier on each readl/writel
invocation, hence use the relaxed versions.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra-devfreq.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index ec4ff55f5eea..d749399f67ae 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -191,23 +191,23 @@ static struct tegra_actmon_emc_ratio actmon_emc_ratios[] = {
 
 static u32 actmon_readl(struct tegra_devfreq *tegra, u32 offset)
 {
-	return readl(tegra->regs + offset);
+	return readl_relaxed(tegra->regs + offset);
 }
 
 static void actmon_writel(struct tegra_devfreq *tegra, u32 val, u32 offset)
 {
-	writel(val, tegra->regs + offset);
+	writel_relaxed(val, tegra->regs + offset);
 }
 
 static u32 device_readl(struct tegra_devfreq_device *dev, u32 offset)
 {
-	return readl(dev->regs + offset);
+	return readl_relaxed(dev->regs + offset);
 }
 
 static void device_writel(struct tegra_devfreq_device *dev, u32 val,
 			  u32 offset)
 {
-	writel(val, dev->regs + offset);
+	writel_relaxed(val, dev->regs + offset);
 }
 
 static unsigned long do_percent(unsigned long val, unsigned int pct)
-- 
2.21.0


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

* [PATCH v1 3/8] PM / devfreq: tegra: Don't ignore clk errors
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 2/8] PM / devfreq: tegra: Replace readl-writel with relaxed versions Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 4/8] PM / devfreq: tegra: Don't release IRQ manually on driver removal Dmitry Osipenko
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

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.

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

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index d749399f67ae..6185e7ab20a8 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -487,6 +487,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
 	struct tegra_devfreq *tegra = dev_get_drvdata(dev);
 	struct dev_pm_opp *opp;
 	unsigned long rate;
+	int err;
 
 	opp = devfreq_recommended_opp(dev, freq, flags);
 	if (IS_ERR(opp)) {
@@ -496,8 +497,13 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
 	rate = dev_pm_opp_get_freq(opp) * KHZ;
 	dev_pm_opp_put(opp);
 
-	clk_set_min_rate(tegra->emc_clock, rate);
-	clk_set_rate(tegra->emc_clock, 0);
+	err = clk_set_min_rate(tegra->emc_clock, rate);
+	if (err)
+		return err;
+
+	err = clk_set_rate(tegra->emc_clock, 0);
+	if (err)
+		return err;
 
 	return 0;
 }
-- 
2.21.0


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

* [PATCH v1 4/8] PM / devfreq: tegra: Don't release IRQ manually on driver removal
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
                   ` (2 preceding siblings ...)
  2019-04-11 22:29 ` [PATCH v1 3/8] PM / devfreq: tegra: Don't ignore clk errors Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 5/8] PM / devfreq: tegra: Don't set EMC clock rate to maximum on probe Dmitry Osipenko
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

The IRQ releasing is handled by "managed resources", hence there is no
need to release IRQ manually.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra-devfreq.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index 6185e7ab20a8..ed67d7a48176 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -717,7 +717,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
 static int tegra_devfreq_remove(struct platform_device *pdev)
 {
 	struct tegra_devfreq *tegra = platform_get_drvdata(pdev);
-	int irq = platform_get_irq(pdev, 0);
 	u32 val;
 	unsigned int i;
 
@@ -729,8 +728,6 @@ static int tegra_devfreq_remove(struct platform_device *pdev)
 
 	actmon_write_barrier(tegra);
 
-	devm_free_irq(&pdev->dev, irq, tegra);
-
 	clk_notifier_unregister(tegra->emc_clock, &tegra->rate_change_nb);
 
 	clk_disable_unprepare(tegra->clock);
-- 
2.21.0


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

* [PATCH v1 5/8] PM / devfreq: tegra: Don't set EMC clock rate to maximum on probe
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
                   ` (3 preceding siblings ...)
  2019-04-11 22:29 ` [PATCH v1 4/8] PM / devfreq: tegra: Don't release IRQ manually on driver removal Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 6/8] PM / devfreq: tegra: Drop spinlock Dmitry Osipenko
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

There is no real benefit from doing so, hence let's drop that rate setting
for consistency.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra-devfreq.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index ed67d7a48176..aefd4874b5a2 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -648,8 +648,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
 		return PTR_ERR(tegra->emc_clock);
 	}
 
-	clk_set_rate(tegra->emc_clock, ULONG_MAX);
-
 	tegra->rate_change_nb.notifier_call = tegra_actmon_rate_notify_cb;
 	err = clk_notifier_register(tegra->emc_clock, &tegra->rate_change_nb);
 	if (err) {
-- 
2.21.0


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

* [PATCH v1 6/8] PM / devfreq: tegra: Drop spinlock
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
                   ` (4 preceding siblings ...)
  2019-04-11 22:29 ` [PATCH v1 5/8] PM / devfreq: tegra: Don't set EMC clock rate to maximum on probe Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 7/8] PM / devfreq: tegra: Remove OPP entries on driver removal Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 8/8] PM / devfreq: tegra: Support Tegra30 Dmitry Osipenko
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

There is no real need to use locking since we can simply read out the
volatile variable value once and the watermark changing shouldn't clash
with the changes made by the interrupt handler.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra-devfreq.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index aefd4874b5a2..96f1e8e64e46 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -144,7 +144,6 @@ static struct tegra_devfreq_device_config actmon_device_configs[] = {
 struct tegra_devfreq_device {
 	const struct tegra_devfreq_device_config *config;
 	void __iomem *regs;
-	spinlock_t lock;
 
 	/* Average event count sampled in the last interrupt */
 	u32 avg_count;
@@ -250,11 +249,8 @@ static void actmon_write_barrier(struct tegra_devfreq *tegra)
 static void actmon_isr_device(struct tegra_devfreq *tegra,
 			      struct tegra_devfreq_device *dev)
 {
-	unsigned long flags;
 	u32 intr_status, dev_ctrl;
 
-	spin_lock_irqsave(&dev->lock, flags);
-
 	dev->avg_count = device_readl(dev, ACTMON_DEV_AVG_COUNT);
 	tegra_devfreq_update_avg_wmark(tegra, dev);
 
@@ -303,8 +299,6 @@ static void actmon_isr_device(struct tegra_devfreq *tegra,
 	device_writel(dev, ACTMON_INTR_STATUS_CLEAR, ACTMON_DEV_INTR_STATUS);
 
 	actmon_write_barrier(tegra);
-
-	spin_unlock_irqrestore(&dev->lock, flags);
 }
 
 static irqreturn_t actmon_isr(int irq, void *data)
@@ -349,24 +343,21 @@ static void actmon_update_target(struct tegra_devfreq *tegra,
 	unsigned long cpu_freq = 0;
 	unsigned long static_cpu_emc_freq = 0;
 	unsigned int avg_sustain_coef;
-	unsigned long flags;
+	u32 avg_count;
 
 	if (dev->config->avg_dependency_threshold) {
 		cpu_freq = cpufreq_get(0);
 		static_cpu_emc_freq = actmon_cpu_to_emc_rate(tegra, cpu_freq);
 	}
 
-	spin_lock_irqsave(&dev->lock, flags);
-
-	dev->target_freq = dev->avg_count / ACTMON_SAMPLING_PERIOD;
+	avg_count = READ_ONCE(dev->avg_count);
+	dev->target_freq = avg_count / ACTMON_SAMPLING_PERIOD;
 	avg_sustain_coef = 100 * 100 / dev->config->boost_up_threshold;
 	dev->target_freq = do_percent(dev->target_freq, avg_sustain_coef);
 	dev->target_freq += dev->boost_freq;
 
-	if (dev->avg_count >= dev->config->avg_dependency_threshold)
+	if (avg_count >= dev->config->avg_dependency_threshold)
 		dev->target_freq = max(dev->target_freq, static_cpu_emc_freq);
-
-	spin_unlock_irqrestore(&dev->lock, flags);
 }
 
 static irqreturn_t actmon_thread_isr(int irq, void *data)
@@ -387,7 +378,6 @@ static int tegra_actmon_rate_notify_cb(struct notifier_block *nb,
 	struct tegra_devfreq *tegra;
 	struct tegra_devfreq_device *dev;
 	unsigned int i;
-	unsigned long flags;
 
 	if (action != POST_RATE_CHANGE)
 		return NOTIFY_OK;
@@ -399,9 +389,7 @@ static int tegra_actmon_rate_notify_cb(struct notifier_block *nb,
 	for (i = 0; i < ARRAY_SIZE(tegra->devices); i++) {
 		dev = &tegra->devices[i];
 
-		spin_lock_irqsave(&dev->lock, flags);
 		tegra_devfreq_update_wmark(tegra, dev);
-		spin_unlock_irqrestore(&dev->lock, flags);
 	}
 
 	actmon_write_barrier(tegra);
@@ -677,7 +665,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
 		dev = tegra->devices + i;
 		dev->config = actmon_device_configs + i;
 		dev->regs = tegra->regs + dev->config->offset;
-		spin_lock_init(&dev->lock);
 
 		tegra_actmon_configure_device(tegra, dev);
 	}
-- 
2.21.0


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

* [PATCH v1 7/8] PM / devfreq: tegra: Remove OPP entries on driver removal
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
                   ` (5 preceding siblings ...)
  2019-04-11 22:29 ` [PATCH v1 6/8] PM / devfreq: tegra: Drop spinlock Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  2019-04-11 22:29 ` [PATCH v1 8/8] PM / devfreq: tegra: Support Tegra30 Dmitry Osipenko
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

This fixes "_opp_is_duplicate" warning messages on driver's module reload.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra-devfreq.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index 96f1e8e64e46..0985c02b75fe 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -691,10 +691,10 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
 	}
 
 	tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock);
-	tegra->devfreq = devm_devfreq_add_device(&pdev->dev,
-						 &tegra_devfreq_profile,
-						 "tegra_actmon",
-						 NULL);
+	tegra->devfreq = devfreq_add_device(&pdev->dev,
+					    &tegra_devfreq_profile,
+					    "tegra_actmon",
+					    NULL);
 
 	return 0;
 }
@@ -705,6 +705,9 @@ static int tegra_devfreq_remove(struct platform_device *pdev)
 	u32 val;
 	unsigned int i;
 
+	devfreq_remove_device(tegra->devfreq);
+	dev_pm_opp_remove_all_dynamic(&pdev->dev);
+
 	for (i = 0; i < ARRAY_SIZE(actmon_device_configs); i++) {
 		val = device_readl(&tegra->devices[i], ACTMON_DEV_CTRL);
 		val &= ~ACTMON_DEV_CTRL_ENB;
-- 
2.21.0


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

* [PATCH v1 8/8] PM / devfreq: tegra: Support Tegra30
  2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
                   ` (6 preceding siblings ...)
  2019-04-11 22:29 ` [PATCH v1 7/8] PM / devfreq: tegra: Remove OPP entries on driver removal Dmitry Osipenko
@ 2019-04-11 22:29 ` Dmitry Osipenko
  7 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-11 22:29 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

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>
---
 drivers/devfreq/Kconfig         | 2 +-
 drivers/devfreq/tegra-devfreq.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index 6a172d338f6d..6bae9688a52b 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -93,7 +93,7 @@ config ARM_EXYNOS_BUS_DEVFREQ
 
 config ARM_TEGRA_DEVFREQ
 	tristate "Tegra DEVFREQ Driver"
-	depends on ARCH_TEGRA_124_SOC
+	depends on ARCH_TEGRA
 	select DEVFREQ_GOV_SIMPLE_ONDEMAND
 	select PM_OPP
 	help
diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
index 0985c02b75fe..a0a3dafa9188 100644
--- a/drivers/devfreq/tegra-devfreq.c
+++ b/drivers/devfreq/tegra-devfreq.c
@@ -724,6 +724,7 @@ static int tegra_devfreq_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id tegra_devfreq_of_match[] = {
+	{ .compatible = "nvidia,tegra30-actmon" },
 	{ .compatible = "nvidia,tegra124-actmon" },
 	{ },
 };
-- 
2.21.0


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

* Re: [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion
       [not found]   ` <20190412013413.4D52D20818@mail.kernel.org>
@ 2019-04-12 10:14     ` Dmitry Osipenko
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-12 10:14 UTC (permalink / raw)
  To: Sasha Levin, Thierry Reding; +Cc: linux-tegra, linux-kernel, stable

12.04.2019 4:34, Sasha Levin пишет:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
> 
> The bot has tested the following trees: v5.0.7, v4.19.34, v4.14.111, v4.9.168, v4.4.178, v3.18.138.
> 
> v5.0.7: Build OK!
> v4.19.34: Build OK!
> v4.14.111: Build OK!
> v4.9.168: Failed to apply! Possible dependencies:
>     0f0fe7e01327 ("PM / OPP: Manage supply's voltage/current in a separate structure")
>     37a73ec0c9bb ("PM / OPP: Add per OPP table mutex")
>     63a69ea4b88f ("PM / OPP: Rename _allocate_opp() to _opp_allocate()")
>     7034764a1e4a ("PM / OPP: Add 'struct kref' to struct dev_pm_opp")
>     8a31d9d94297 ("PM / OPP: Update OPP users to put reference")
>     947355850fcb ("PM / OPP: Separate out _generic_set_opp()")
>     969fceb3c7e6 ("PM / OPP: Add light weight _opp_free() routine")
>     ce31781a7574 ("PM / OPP: Pass struct dev_pm_opp_supply to _set_opp_voltage()")
>     dfbe4678d709 ("PM / OPP: Add infrastructure to manage multiple regulators")
> 
> v4.4.178: Failed to apply! Possible dependencies:
>     01fb4d3c39d3 ("PM / OPP: Parse 'opp-<prop>-<name>' bindings")
>     0c717d0f9cb4 ("PM / OPP: Initialize regulator pointer to an error value")
>     2c2709dc6921 ("PM / OPP: Rename structures for clarity")
>     50f8cfbd5897 ("PM / OPP: Parse clock-latency and voltage-tolerance for v1 bindings")
>     655c9df96175 ("PM / OPP: Introduce dev_pm_opp_get_max_volt_latency()")
>     7de36b0aa51a ("PM / OPP: Parse 'opp-supported-hw' binding")
>     8a31d9d94297 ("PM / OPP: Update OPP users to put reference")
>     9f8ea969d5cf ("PM / OPP: get/put regulators from OPP core")
>     d54974c2513f ("PM / OPP: Manage device clk")
>     dc4e7b1fa20a ("PM / OPP: Add missing doc comments")
>     deaa51465105 ("PM / OPP: Add debugfs support")
> 
> v3.18.138: Failed to apply! Possible dependencies:
>     07cce74a7b25 ("PM / OPP: handle allocation of device_opp in a separate routine")
>     0fe30da2cb43 ("PM / OPP: fix warning in of_free_opp_table()")
>     11573e9132ae ("PM / devfreq: tegra: Update to v5 of the submitted patches")
>     129eec55df6a ("PM / OPP Introduce APIs to remove OPPs")
>     29df0ee1b14a ("PM / OPP: reuse find_device_opp() instead of duplicating code")
>     2c2709dc6921 ("PM / OPP: Rename structures for clarity")
>     327854c87117 ("PM / OPP: Ensure consistent naming of static functions")
>     38393409da34 ("PM / OPP mark OPPs as 'static' or 'dynamic'")
>     6234f38016ad ("PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor")
>     737002b5de3d ("PM / OPP: Relocate few routines")
>     86453b473b1f ("PM / OPP: Staticize __dev_pm_opp_remove()")
>     87b4115db023 ("PM / OPP: Protect updates to list_dev with mutex")
>     8a31d9d94297 ("PM / OPP: Update OPP users to put reference")
>     8d4d4e98acd6 ("PM / OPP: Add helpers for initializing CPU OPPs")
>     984f16c8490c ("PM / OPP: Update kernel documentation")
>     a7470db6fec4 ("PM / OPP don't match for existing OPPs when list is empty")
>     b02ded246d01 ("PM / OPP: add some lockdep annotations")
>     b4037aaa584b ("PM / OPP replace kfree_rcu() with call_srcu() in opp_set_availability()")
>     cd1a068a52ee ("PM / OPP rename 'head' as 'rcu_head' or 'srcu_head' based on its type")
>     f59d3ee8480d ("PM / OPP: Move cpu specific code to opp/cpu.c")
> 
> 
> How should we proceed with this patch?

Don't backport to v4.9 and older, it's not a critical fix at all.

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

* Re: [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion
  2019-04-11 22:29 ` [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion Dmitry Osipenko
       [not found]   ` <20190412013413.4D52D20818@mail.kernel.org>
@ 2019-04-12 16:56   ` Dmitry Osipenko
  1 sibling, 0 replies; 11+ messages in thread
From: Dmitry Osipenko @ 2019-04-12 16:56 UTC (permalink / raw)
  To: Thierry Reding, Jonathan Hunter, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi
  Cc: linux-tegra, linux-kernel, linux-pm

12.04.2019 1:29, Dmitry Osipenko пишет:
> 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. Let's provide OPP with rates in kHz since this eliminates
> few multiplies and divisions in the code. This patch was tested on Tegra30
> and Tegra124 SoC's, EMC frequency scaling works properly now.
> 
> Cc: <stable@vger.kernel.org>
> Tested-by: Steev Klimaszewski <steev@kali.org>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/devfreq/tegra-devfreq.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c
> index c89ba7b834ff..ec4ff55f5eea 100644
> --- a/drivers/devfreq/tegra-devfreq.c
> +++ b/drivers/devfreq/tegra-devfreq.c
> @@ -394,7 +394,7 @@ static int tegra_actmon_rate_notify_cb(struct notifier_block *nb,
>  
>  	tegra = container_of(nb, struct tegra_devfreq, rate_change_nb);
>  
> -	tegra->cur_freq = data->new_rate / KHZ;
> +	tegra->cur_freq = data->new_rate;

This was a last-minute change and it is incorrect. The cur_freq should be kept in kHz, I'll fix it up in v2 and re-test everything properly once again.

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

end of thread, other threads:[~2019-04-12 16:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 22:29 [PATCH v1 0/8] devfreq: Tegra devfreq fixes / improvements and Tegra30 support Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 1/8] PM / devfreq: tegra: Fix kHz to Hz conversion Dmitry Osipenko
     [not found]   ` <20190412013413.4D52D20818@mail.kernel.org>
2019-04-12 10:14     ` Dmitry Osipenko
2019-04-12 16:56   ` Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 2/8] PM / devfreq: tegra: Replace readl-writel with relaxed versions Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 3/8] PM / devfreq: tegra: Don't ignore clk errors Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 4/8] PM / devfreq: tegra: Don't release IRQ manually on driver removal Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 5/8] PM / devfreq: tegra: Don't set EMC clock rate to maximum on probe Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 6/8] PM / devfreq: tegra: Drop spinlock Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 7/8] PM / devfreq: tegra: Remove OPP entries on driver removal Dmitry Osipenko
2019-04-11 22:29 ` [PATCH v1 8/8] PM / devfreq: tegra: Support Tegra30 Dmitry Osipenko

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).