Skip to content

Commit

Permalink
Merge branch 'pm-devfreq'
Browse files Browse the repository at this point in the history
* pm-devfreq:
  devfreq: rk3399_dmc: Don't use OPP structures outside of RCU locks
  devfreq: rk3399_dmc: Remove dangling rcu_read_unlock()
  devfreq: exynos: Don't use OPP structures outside of RCU locks
  PM / devfreq: rk3399_dmc: Use the resource-managed function to add devfreq dev
  PM / devfreq: correct comment typo.
  PM / devfreq: exynos-ppmu: Remove unused mutex from struct exynos_ppmu
  PM / devfreq: exynos-ppmu: ppmu_events array should not be NULL terminated
  PM / devfreq: exynos-ppmu: Fix module autoload
  PM / devfreq: rockchip-dfi: Fix module autoload
  PM / devfreq: exynos-nocp: Fix module autoload
  PM / devfreq: rk3399_dmc: Fix module autoload
  • Loading branch information
Rafael J. Wysocki committed Dec 12, 2016
2 parents 631ddab + e37d350 commit bbc17bb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
EXPORT_SYMBOL(devfreq_add_governor);

/**
* devfreq_remove_device() - Remove devfreq feature from a device.
* devfreq_remove_governor() - Remove devfreq feature from a device.
* @governor: the devfreq governor to be removed
*/
int devfreq_remove_governor(struct devfreq_governor *governor)
Expand Down
1 change: 1 addition & 0 deletions drivers/devfreq/event/exynos-nocp.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ static const struct of_device_id exynos_nocp_id_match[] = {
{ .compatible = "samsung,exynos5420-nocp", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, exynos_nocp_id_match);

static struct regmap_config exynos_nocp_regmap_config = {
.reg_bits = 32,
Expand Down
6 changes: 1 addition & 5 deletions drivers/devfreq/event/exynos-ppmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/suspend.h>
Expand All @@ -34,7 +33,6 @@ struct exynos_ppmu {
unsigned int num_events;

struct device *dev;
struct mutex lock;

struct exynos_ppmu_data ppmu;
};
Expand Down Expand Up @@ -90,8 +88,6 @@ struct __exynos_ppmu_events {
PPMU_EVENT(d1-cpu),
PPMU_EVENT(d1-general),
PPMU_EVENT(d1-rt),

{ /* sentinel */ },
};

static int exynos_ppmu_find_ppmu_id(struct devfreq_event_dev *edev)
Expand Down Expand Up @@ -351,6 +347,7 @@ static const struct of_device_id exynos_ppmu_id_match[] = {
},
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, exynos_ppmu_id_match);

static struct devfreq_event_ops *exynos_bus_get_ops(struct device_node *np)
{
Expand Down Expand Up @@ -463,7 +460,6 @@ static int exynos_ppmu_probe(struct platform_device *pdev)
if (!info)
return -ENOMEM;

mutex_init(&info->lock);
info->dev = &pdev->dev;

/* Parse dt data to get resource */
Expand Down
1 change: 1 addition & 0 deletions drivers/devfreq/event/rockchip-dfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ static const struct of_device_id rockchip_dfi_id_match[] = {
{ .compatible = "rockchip,rk3399-dfi" },
{ },
};
MODULE_DEVICE_TABLE(of, rockchip_dfi_id_match);

static int rockchip_dfi_probe(struct platform_device *pdev)
{
Expand Down
29 changes: 14 additions & 15 deletions drivers/devfreq/exynos-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct exynos_bus {
unsigned int edev_count;
struct mutex lock;

struct dev_pm_opp *curr_opp;
unsigned long curr_freq;

struct regulator *regulator;
struct clk *clk;
Expand Down Expand Up @@ -99,7 +99,7 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
{
struct exynos_bus *bus = dev_get_drvdata(dev);
struct dev_pm_opp *new_opp;
unsigned long old_freq, new_freq, old_volt, new_volt, tol;
unsigned long old_freq, new_freq, new_volt, tol;
int ret = 0;

/* Get new opp-bus instance according to new bus clock */
Expand All @@ -113,8 +113,7 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)

new_freq = dev_pm_opp_get_freq(new_opp);
new_volt = dev_pm_opp_get_voltage(new_opp);
old_freq = dev_pm_opp_get_freq(bus->curr_opp);
old_volt = dev_pm_opp_get_voltage(bus->curr_opp);
old_freq = bus->curr_freq;
rcu_read_unlock();

if (old_freq == new_freq)
Expand Down Expand Up @@ -146,7 +145,7 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
goto out;
}
}
bus->curr_opp = new_opp;
bus->curr_freq = new_freq;

dev_dbg(dev, "Set the frequency of bus (%lukHz -> %lukHz)\n",
old_freq/1000, new_freq/1000);
Expand All @@ -163,9 +162,7 @@ static int exynos_bus_get_dev_status(struct device *dev,
struct devfreq_event_data edata;
int ret;

rcu_read_lock();
stat->current_frequency = dev_pm_opp_get_freq(bus->curr_opp);
rcu_read_unlock();
stat->current_frequency = bus->curr_freq;

ret = exynos_bus_get_event(bus, &edata);
if (ret < 0) {
Expand Down Expand Up @@ -226,7 +223,7 @@ static int exynos_bus_passive_target(struct device *dev, unsigned long *freq,
}

new_freq = dev_pm_opp_get_freq(new_opp);
old_freq = dev_pm_opp_get_freq(bus->curr_opp);
old_freq = bus->curr_freq;
rcu_read_unlock();

if (old_freq == new_freq)
Expand All @@ -242,7 +239,7 @@ static int exynos_bus_passive_target(struct device *dev, unsigned long *freq,
}

*freq = new_freq;
bus->curr_opp = new_opp;
bus->curr_freq = new_freq;

dev_dbg(dev, "Set the frequency of bus (%lukHz -> %lukHz)\n",
old_freq/1000, new_freq/1000);
Expand Down Expand Up @@ -335,6 +332,7 @@ static int exynos_bus_parse_of(struct device_node *np,
struct exynos_bus *bus)
{
struct device *dev = bus->dev;
struct dev_pm_opp *opp;
unsigned long rate;
int ret;

Expand All @@ -352,22 +350,23 @@ static int exynos_bus_parse_of(struct device_node *np,
}

/* Get the freq and voltage from OPP table to scale the bus freq */
rcu_read_lock();
ret = dev_pm_opp_of_add_table(dev);
if (ret < 0) {
dev_err(dev, "failed to get OPP table\n");
rcu_read_unlock();
goto err_clk;
}

rate = clk_get_rate(bus->clk);
bus->curr_opp = devfreq_recommended_opp(dev, &rate, 0);
if (IS_ERR(bus->curr_opp)) {

rcu_read_lock();
opp = devfreq_recommended_opp(dev, &rate, 0);
if (IS_ERR(opp)) {
dev_err(dev, "failed to find dev_pm_opp\n");
rcu_read_unlock();
ret = PTR_ERR(bus->curr_opp);
ret = PTR_ERR(opp);
goto err_opp;
}
bus->curr_freq = dev_pm_opp_get_freq(opp);
rcu_read_unlock();

return 0;
Expand Down
15 changes: 7 additions & 8 deletions drivers/devfreq/rk3399_dmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ struct rk3399_dmcfreq {
struct regulator *vdd_center;
unsigned long rate, target_rate;
unsigned long volt, target_volt;
struct dev_pm_opp *curr_opp;
};

static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq,
Expand All @@ -102,9 +101,6 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq,
target_rate = dev_pm_opp_get_freq(opp);
target_volt = dev_pm_opp_get_voltage(opp);

dmcfreq->rate = dev_pm_opp_get_freq(dmcfreq->curr_opp);
dmcfreq->volt = dev_pm_opp_get_voltage(dmcfreq->curr_opp);

rcu_read_unlock();

if (dmcfreq->rate == target_rate)
Expand Down Expand Up @@ -165,7 +161,9 @@ static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq,
if (err)
dev_err(dev, "Cannot to set vol %lu uV\n", target_volt);

dmcfreq->curr_opp = opp;
dmcfreq->rate = target_rate;
dmcfreq->volt = target_volt;

out:
mutex_unlock(&dmcfreq->lock);
return err;
Expand Down Expand Up @@ -414,7 +412,6 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
*/
if (dev_pm_opp_of_add_table(dev)) {
dev_err(dev, "Invalid operating-points in device tree.\n");
rcu_read_unlock();
return -EINVAL;
}

Expand All @@ -431,12 +428,13 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
rcu_read_unlock();
return PTR_ERR(opp);
}
data->rate = dev_pm_opp_get_freq(opp);
data->volt = dev_pm_opp_get_voltage(opp);
rcu_read_unlock();
data->curr_opp = opp;

rk3399_devfreq_dmc_profile.initial_freq = data->rate;

data->devfreq = devfreq_add_device(dev,
data->devfreq = devm_devfreq_add_device(dev,
&rk3399_devfreq_dmc_profile,
"simple_ondemand",
&data->ondemand_data);
Expand All @@ -454,6 +452,7 @@ static const struct of_device_id rk3399dmc_devfreq_of_match[] = {
{ .compatible = "rockchip,rk3399-dmc" },
{ },
};
MODULE_DEVICE_TABLE(of, rk3399dmc_devfreq_of_match);

static struct platform_driver rk3399_dmcfreq_driver = {
.probe = rk3399_dmcfreq_probe,
Expand Down

0 comments on commit bbc17bb

Please sign in to comment.