From 4964814d6fe44e6eb1defea40355c160973876ce Mon Sep 17 00:00:00 2001 From: Taniya Das Date: Thu, 3 Oct 2019 09:05:45 +0530 Subject: [PATCH 1/2] cpufreq: qcom: Fix multiple request of IRQs The cpufreq init would be invoked every cpu online and thus resulting into multiple IRQ requests, so fix the same. Change-Id: I271cd7f82e2ddde7466fa0949b8627c8d7573c47 Signed-off-by: Taniya Das --- drivers/cpufreq/qcom-cpufreq-hw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index d509bc6a2f1a..e50c8533d3ed 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -66,6 +66,7 @@ struct cpufreq_qcom { int dcvsh_irq; char dcvsh_irq_name[MAX_FN_SIZE]; bool is_irq_enabled; + bool is_irq_requested; }; struct cpufreq_counter { @@ -295,7 +296,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) dev_pm_opp_of_register_em(policy->cpus); - if (c->dcvsh_irq > 0) { + if (c->dcvsh_irq > 0 && !c->is_irq_requested) { snprintf(c->dcvsh_irq_name, sizeof(c->dcvsh_irq_name), "dcvsh-irq-%d", policy->cpu); ret = devm_request_threaded_irq(cpu_dev, c->dcvsh_irq, NULL, @@ -306,6 +307,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) return ret; } + c->is_irq_requested = true; c->is_irq_enabled = true; writel_relaxed(LT_IRQ_STATUS, c->base + offsets[REG_INTR_EN]); c->freq_limit_attr.attr.name = "dcvsh_freq_limit"; From 6bdf36294f3d8684a5acf3017a3807258ad2d871 Mon Sep 17 00:00:00 2001 From: Taniya Das Date: Fri, 18 Oct 2019 16:40:49 +0530 Subject: [PATCH 2/2] cpufreq: qcom: Add a property for max lut entries Add a device tree property for max look-up table entries present on various targets. Change-Id: I0ee06b0e8113c950958e25a9f59a5c27ef692fec Signed-off-by: Taniya Das --- drivers/cpufreq/qcom-cpufreq-hw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index e50c8533d3ed..d0b80538de40 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -53,6 +53,7 @@ enum { static unsigned long cpu_hw_rate, xo_rate; static const u16 *offsets; static unsigned int lut_row_size = LUT_ROW_SIZE; +static unsigned int lut_max_entries = LUT_MAX_ENTRIES; static bool accumulative_counter; struct cpufreq_qcom { @@ -114,7 +115,7 @@ static unsigned long limits_mitigation_notify(struct cpufreq_qcom *c) max_vc = readl_relaxed(c->base + offsets[REG_LLM_DCVS_VC_VOTE]) & GENMASK(13, 8); - for (i = 0; i < LUT_MAX_ENTRIES; i++) { + for (i = 0; i < lut_max_entries; i++) { if (c->table[i].driver_data != max_vc) continue; else { @@ -243,7 +244,7 @@ static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) return 0; index = readl_relaxed(policy->driver_data + offsets[REG_PERF_STATE]); - index = min(index, LUT_MAX_ENTRIES - 1); + index = min(index, lut_max_entries - 1); return policy->freq_table[index].frequency; } @@ -376,14 +377,14 @@ static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev, u32 data, src, lval, i, core_count, prev_cc, prev_freq, freq, volt; unsigned long cpu; - c->table = devm_kcalloc(dev, LUT_MAX_ENTRIES + 1, + c->table = devm_kcalloc(dev, lut_max_entries + 1, sizeof(*c->table), GFP_KERNEL); if (!c->table) return -ENOMEM; cpu = cpumask_first(&c->related_cpus); - for (i = 0; i < LUT_MAX_ENTRIES; i++) { + for (i = 0; i < lut_max_entries; i++) { data = readl_relaxed(c->base + offsets[REG_FREQ_LUT] + i * lut_row_size); src = FIELD_GET(LUT_SRC, data); @@ -547,6 +548,9 @@ static int qcom_resources_init(struct platform_device *pdev) of_property_read_u32(pdev->dev.of_node, "qcom,lut-row-size", &lut_row_size); + of_property_read_u32(pdev->dev.of_node, "qcom,lut-max-entries", + &lut_max_entries); + for_each_possible_cpu(cpu) { cpu_np = of_cpu_device_node_get(cpu); if (!cpu_np) {