Skip to content

Commit

Permalink
Merge tag 'cpufreq-arm-updates-6.1' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/vireshk/pm

Pull cpufreq/arm updates for 6.1-rc1 from Viresh Kumar:

"- Add SM6115 to cpufreq-dt blocklist (Adam Skladowski).
 - Add support for Tegra239 and minor cleanups (Sumit Gupta, ye xingchen,
   and Yang Yingliang).
 - Add freq qos for qcom cpufreq driver and minor cleanups (Xuewen Yan,
   and Viresh Kumar).
 - Minor cleanups around functions called at module_init() (Xiu Jianfeng).
 - Use module_init and add module_exit for bmips driver (Zhang
   Jianhua)."

* tag 'cpufreq-arm-updates-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  cpufreq: qcom-cpufreq-hw: Add cpufreq qos for LMh
  cpufreq: Add __init annotation to module init funcs
  cpufreq: tegra194: change tegra239_cpufreq_soc to static
  cpufreq: tegra194: Add support for Tegra239
  cpufreq: qcom-cpufreq-hw: Fix uninitialized throttled_freq warning
  cpufreq: tegra194: Remove the unneeded result variable
  cpufreq: bmips-cpufreq: Use module_init and add module_exit
  cpufreq: Add SM6115 to cpufreq-dt-platdev blocklist
  • Loading branch information
Rafael J. Wysocki committed Sep 28, 2022
2 parents 71bb5c8 + c4c0efb commit 8e3d086
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 29 deletions.
10 changes: 8 additions & 2 deletions drivers/cpufreq/bmips-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static struct cpufreq_driver bmips_cpufreq_driver = {
.name = BMIPS_CPUFREQ_PREFIX,
};

static int __init bmips_cpufreq_probe(void)
static int __init bmips_cpufreq_driver_init(void)
{
struct cpufreq_compat *cc;
struct device_node *np;
Expand All @@ -176,7 +176,13 @@ static int __init bmips_cpufreq_probe(void)

return cpufreq_register_driver(&bmips_cpufreq_driver);
}
device_initcall(bmips_cpufreq_probe);
module_init(bmips_cpufreq_driver_init);

static void __exit bmips_cpufreq_driver_exit(void)
{
cpufreq_unregister_driver(&bmips_cpufreq_driver);
}
module_exit(bmips_cpufreq_driver_exit);

MODULE_AUTHOR("Markus Mayer <mmayer@broadcom.com>");
MODULE_DESCRIPTION("CPUfreq driver for Broadcom BMIPS SoCs");
Expand Down
1 change: 1 addition & 0 deletions drivers/cpufreq/cpufreq-dt-platdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static const struct of_device_id blocklist[] __initconst = {
{ .compatible = "qcom,sc8180x", },
{ .compatible = "qcom,sc8280xp", },
{ .compatible = "qcom,sdm845", },
{ .compatible = "qcom,sm6115", },
{ .compatible = "qcom,sm6350", },
{ .compatible = "qcom,sm8150", },
{ .compatible = "qcom,sm8250", },
Expand Down
2 changes: 1 addition & 1 deletion drivers/cpufreq/highbank-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static struct notifier_block hb_cpufreq_clk_nb = {
.notifier_call = hb_cpufreq_clk_notify,
};

static int hb_cpufreq_driver_init(void)
static int __init hb_cpufreq_driver_init(void)
{
struct platform_device_info devinfo = { .name = "cpufreq-dt", };
struct device *cpu_dev;
Expand Down
24 changes: 19 additions & 5 deletions drivers/cpufreq/qcom-cpufreq-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/pm_opp.h>
#include <linux/pm_qos.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/units.h>
Expand Down Expand Up @@ -56,6 +57,8 @@ struct qcom_cpufreq_data {
struct cpufreq_policy *policy;

bool per_core_dcvs;

struct freq_qos_request throttle_freq_req;
};

static unsigned long cpu_hw_rate, xo_rate;
Expand Down Expand Up @@ -316,14 +319,16 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data)
if (IS_ERR(opp)) {
dev_warn(dev, "Can't find the OPP for throttling: %pe!\n", opp);
} else {
throttled_freq = freq_hz / HZ_PER_KHZ;

/* Update thermal pressure (the boost frequencies are accepted) */
arch_update_thermal_pressure(policy->related_cpus, throttled_freq);

dev_pm_opp_put(opp);
}

throttled_freq = freq_hz / HZ_PER_KHZ;

freq_qos_update_request(&data->throttle_freq_req, throttled_freq);

/* Update thermal pressure (the boost frequencies are accepted) */
arch_update_thermal_pressure(policy->related_cpus, throttled_freq);

/*
* In the unlikely case policy is unregistered do not enable
* polling or h/w interrupt
Expand Down Expand Up @@ -413,6 +418,14 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index)
if (data->throttle_irq < 0)
return data->throttle_irq;

ret = freq_qos_add_request(&policy->constraints,
&data->throttle_freq_req, FREQ_QOS_MAX,
FREQ_QOS_MAX_DEFAULT_VALUE);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to add freq constraint (%d)\n", ret);
return ret;
}

data->cancel_throttle = false;
data->policy = policy;

Expand Down Expand Up @@ -479,6 +492,7 @@ static void qcom_cpufreq_hw_lmh_exit(struct qcom_cpufreq_data *data)
if (data->throttle_irq <= 0)
return;

freq_qos_remove_request(&data->throttle_freq_req);
free_irq(data->throttle_irq, data);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/cpufreq/sti-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static int sti_cpufreq_fetch_syscon_registers(void)
return 0;
}

static int sti_cpufreq_init(void)
static int __init sti_cpufreq_init(void)
{
int ret;

Expand Down
35 changes: 16 additions & 19 deletions drivers/cpufreq/tegra194-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
/* cpufreq transisition latency */
#define TEGRA_CPUFREQ_TRANSITION_LATENCY (300 * 1000) /* unit in nanoseconds */

enum cluster {
CLUSTER0,
CLUSTER1,
CLUSTER2,
CLUSTER3,
MAX_CLUSTERS,
};

struct tegra_cpu_ctr {
u32 cpu;
u32 coreclk_cnt, last_coreclk_cnt;
Expand All @@ -67,12 +59,12 @@ struct tegra_cpufreq_ops {
struct tegra_cpufreq_soc {
struct tegra_cpufreq_ops *ops;
int maxcpus_per_cluster;
unsigned int num_clusters;
phys_addr_t actmon_cntr_base;
};

struct tegra194_cpufreq_data {
void __iomem *regs;
size_t num_clusters;
struct cpufreq_frequency_table **tables;
const struct tegra_cpufreq_soc *soc;
};
Expand Down Expand Up @@ -166,6 +158,14 @@ static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = {
.ops = &tegra234_cpufreq_ops,
.actmon_cntr_base = 0x9000,
.maxcpus_per_cluster = 4,
.num_clusters = 3,
};

static const struct tegra_cpufreq_soc tegra239_cpufreq_soc = {
.ops = &tegra234_cpufreq_ops,
.actmon_cntr_base = 0x4000,
.maxcpus_per_cluster = 8,
.num_clusters = 1,
};

static void tegra194_get_cpu_cluster_id(u32 cpu, u32 *cpuid, u32 *clusterid)
Expand Down Expand Up @@ -314,11 +314,7 @@ static void tegra194_get_cpu_ndiv_sysreg(void *ndiv)

static int tegra194_get_cpu_ndiv(u32 cpu, u32 cpuid, u32 clusterid, u64 *ndiv)
{
int ret;

ret = smp_call_function_single(cpu, tegra194_get_cpu_ndiv_sysreg, &ndiv, true);

return ret;
return smp_call_function_single(cpu, tegra194_get_cpu_ndiv_sysreg, &ndiv, true);
}

static void tegra194_set_cpu_ndiv_sysreg(void *data)
Expand Down Expand Up @@ -382,7 +378,7 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy)

data->soc->ops->get_cpu_cluster_id(policy->cpu, NULL, &clusterid);

if (clusterid >= data->num_clusters || !data->tables[clusterid])
if (clusterid >= data->soc->num_clusters || !data->tables[clusterid])
return -EINVAL;

start_cpu = rounddown(policy->cpu, maxcpus_per_cluster);
Expand Down Expand Up @@ -433,6 +429,7 @@ static struct tegra_cpufreq_ops tegra194_cpufreq_ops = {
static const struct tegra_cpufreq_soc tegra194_cpufreq_soc = {
.ops = &tegra194_cpufreq_ops,
.maxcpus_per_cluster = 2,
.num_clusters = 4,
};

static void tegra194_cpufreq_free_resources(void)
Expand Down Expand Up @@ -525,15 +522,14 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)

soc = of_device_get_match_data(&pdev->dev);

if (soc->ops && soc->maxcpus_per_cluster) {
if (soc->ops && soc->maxcpus_per_cluster && soc->num_clusters) {
data->soc = soc;
} else {
dev_err(&pdev->dev, "soc data missing\n");
return -EINVAL;
}

data->num_clusters = MAX_CLUSTERS;
data->tables = devm_kcalloc(&pdev->dev, data->num_clusters,
data->tables = devm_kcalloc(&pdev->dev, data->soc->num_clusters,
sizeof(*data->tables), GFP_KERNEL);
if (!data->tables)
return -ENOMEM;
Expand All @@ -558,7 +554,7 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)
goto put_bpmp;
}

for (i = 0; i < data->num_clusters; i++) {
for (i = 0; i < data->soc->num_clusters; i++) {
data->tables[i] = init_freq_table(pdev, bpmp, i);
if (IS_ERR(data->tables[i])) {
err = PTR_ERR(data->tables[i]);
Expand Down Expand Up @@ -590,6 +586,7 @@ static int tegra194_cpufreq_remove(struct platform_device *pdev)
static const struct of_device_id tegra194_cpufreq_of_match[] = {
{ .compatible = "nvidia,tegra194-ccplex", .data = &tegra194_cpufreq_soc },
{ .compatible = "nvidia,tegra234-ccplex-cluster", .data = &tegra234_cpufreq_soc },
{ .compatible = "nvidia,tegra239-ccplex-cluster", .data = &tegra239_cpufreq_soc },
{ /* sentinel */ }
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/cpufreq/ti-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
return ret;
}

static int ti_cpufreq_init(void)
static int __init ti_cpufreq_init(void)
{
const struct of_device_id *match;

Expand Down

0 comments on commit 8e3d086

Please sign in to comment.