linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v15] cpufreq: mediatek-hw: Add support for Mediatek cpufreq HW driver
@ 2021-09-03  8:39 Hector Yuan
  2021-09-03  8:39 ` [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW Hector Yuan
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Hector Yuan @ 2021-09-03  8:39 UTC (permalink / raw)
  To: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Viresh Kumar, Rob Herring, devicetree
  Cc: linux-kernel, wsd_upstream, hector.yuan

The CPUfreq HW present in some Mediatek chipsets offloads the steps necessary for changing the frequency of CPUs. 
The driver implements the cpufreq driver interface for this hardware engine. 

From v14 to v15, there are three modifications.
1. Move platform data from per-policy to probe
2. Update energy model register to callback function

From v13 to v14, there are three modifications.
1. Replace cpu domain map to policy driver data 
2. Remove dummy performance-domain parsing
3. Separate modification in cpufreq.h to another patch

From v12 to v13, there are two modifications.
1. Move related_cpus function to common place, so all performance-domain cpufreq driver can refer.
2. Make cpu resource init to each policy rather than per-cpu

From v11 to v12, there are two modifications.
1. Based on patchset[1], align binding with scmi for performance domain(latest version).
2. Shrink binding example wording. 

From v8 to v9, there are three more modifications.
1. Based on patchset[2], align binding with scmi for performance domain.
2. Add the CPUFREQ fast switch function support and define DVFS latency.
3. Based on patchser[3], add energy model API parameter for mW.

From v7 to v8, there are three more patches based on patchset v8[4].
This patchset is about to register power table to Energy model for EAS and thermal usage.
1. EM CPU power table
- Register energy model table for EAS and thermal cooling device usage.
- Read the coresponding LUT for power table.
2. SVS initialization
- The SVS(Smart Voltage Scaling) engine is a hardware which is
  used to calculate optimized voltage values for CPU power domain.
  DVFS driver could apply those optimized voltage values to reduce power consumption.
- Driver will polling if HW engine is done for SVS initialization.
  After that, driver will read power table and register it to EAS.
- CPUs must be in power on state when doing SVS. Use pm_qos to block cpu-idle state for SVS initializing.
3. Cooling device flag
- Add cooling device flag for thermal
[1]  https://lore.kernel.org/linux-devicetree/20210517155458.1016707-1-sudeep.holla@arm.com/
[2]  https://lore.kernel.org/lkml/20201116181356.804590-1-sudeep.holla@arm.com/
[3]  https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?h=linux-next&id=c250d50fe2ce627ca9805d9c8ac11cbbf922a4a6
[4]  https://lkml.org/lkml/2020/9/23/384


Hector.Yuan (3):
  dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW
  cpufreq: Add of_perf_domain_get_sharing_cpumask
  cpufreq: mediatek-hw: Add support for CPUFREQ HW

 .../bindings/cpufreq/cpufreq-mediatek-hw.yaml |  70 ++++
 drivers/cpufreq/Kconfig.arm                   |  12 +
 drivers/cpufreq/Makefile                      |   1 +
 drivers/cpufreq/mediatek-cpufreq-hw.c         | 340 ++++++++++++++++++
 include/linux/cpufreq.h                       |  46 ++-
 5 files changed, 468 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek-hw.yaml
 create mode 100644 drivers/cpufreq/mediatek-cpufreq-hw.c

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

* [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW
  2021-09-03  8:39 [PATCH v15] cpufreq: mediatek-hw: Add support for Mediatek cpufreq HW driver Hector Yuan
@ 2021-09-03  8:39 ` Hector Yuan
  2021-09-03 16:35   ` Rob Herring
  2021-09-03  8:39 ` [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Hector Yuan
  2021-09-03  8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
  2 siblings, 1 reply; 11+ messages in thread
From: Hector Yuan @ 2021-09-03  8:39 UTC (permalink / raw)
  To: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Viresh Kumar, Rob Herring, devicetree
  Cc: linux-kernel, wsd_upstream, hector.yuan

From: "Hector.Yuan" <hector.yuan@mediatek.com>

Add devicetree bindings for MediaTek HW driver.

Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
---
 .../bindings/cpufreq/cpufreq-mediatek-hw.yaml      |   70 ++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek-hw.yaml

diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek-hw.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek-hw.yaml
new file mode 100644
index 0000000..9cd42a6
--- /dev/null
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek-hw.yaml
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/cpufreq-mediatek-hw.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek's CPUFREQ Bindings
+
+maintainers:
+  - Hector Yuan <hector.yuan@mediatek.com>
+
+description:
+  CPUFREQ HW is a hardware engine used by MediaTek SoCs to
+  manage frequency in hardware. It is capable of controlling
+  frequency for multiple clusters.
+
+properties:
+  compatible:
+    const: mediatek,cpufreq-hw
+
+  reg:
+    minItems: 1
+    maxItems: 2
+    description:
+      Addresses and sizes for the memory of the HW bases in
+      each frequency domain. Each entry corresponds to
+      a register bank for each frequency domain present.
+
+  "#performance-domain-cells":
+    description:
+      Number of cells in a performance domain specifier.
+      Set const to 1 here for nodes providing multiple
+      performance domains.
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#performance-domain-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    cpus {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            cpu0: cpu@0 {
+                device_type = "cpu";
+                compatible = "arm,cortex-a55";
+                enable-method = "psci";
+                performance-domains = <&performance 0>;
+                reg = <0x000>;
+            };
+    };
+
+    /* ... */
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        performance: performance-controller@11bc00 {
+            compatible = "mediatek,cpufreq-hw";
+            reg = <0 0x0011bc10 0 0x120>, <0 0x0011bd30 0 0x120>;
+
+            #performance-domain-cells = <1>;
+        };
+    };
-- 
1.7.9.5


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

* [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask
  2021-09-03  8:39 [PATCH v15] cpufreq: mediatek-hw: Add support for Mediatek cpufreq HW driver Hector Yuan
  2021-09-03  8:39 ` [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW Hector Yuan
@ 2021-09-03  8:39 ` Hector Yuan
  2021-09-04 22:32   ` kernel test robot
  2021-09-06  9:43   ` Viresh Kumar
  2021-09-03  8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
  2 siblings, 2 replies; 11+ messages in thread
From: Hector Yuan @ 2021-09-03  8:39 UTC (permalink / raw)
  To: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Viresh Kumar, Rob Herring, devicetree
  Cc: linux-kernel, wsd_upstream, hector.yuan

From: "Hector.Yuan" <hector.yuan@mediatek.com>

Add of_perf_domain_get_sharing_cpumask function to group cpu
to specific performance domain.

Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
---
 include/linux/cpufreq.h |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 9fd7194..0246144 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -13,6 +13,8 @@
 #include <linux/completion.h>
 #include <linux/kobject.h>
 #include <linux/notifier.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/pm_qos.h>
 #include <linux/spinlock.h>
 #include <linux/sysfs.h>
@@ -995,6 +997,43 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy
 
 	return count;
 }
+
+static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
+						     const char *cell_name, struct cpumask *cpumask)
+{
+	struct device_node *cpu_np;
+	struct of_phandle_args args;
+	int target_idx;
+	int cpu, ret;
+
+	cpu_np = of_cpu_device_node_get(pcpu);
+	of_parse_phandle_with_args(cpu_np, list_name,
+				   cell_name, 0, &args);
+	of_node_put(cpu_np);
+	target_idx = args.args[0];
+
+	for_each_possible_cpu(cpu) {
+		if (cpu == pcpu)
+			continue;
+
+		cpu_np = of_cpu_device_node_get(cpu);
+		if (!cpu_np)
+			continue;
+
+		ret = of_parse_phandle_with_args(cpu_np, list_name,
+						 cell_name, 0,
+						 &args);
+
+		of_node_put(cpu_np);
+		if (ret < 0)
+			continue;
+
+		if (target_idx == args.args[0])
+			cpumask_set_cpu(cpu, cpumask);
+	}
+
+	return target_idx;
+}
 #else
 static inline int cpufreq_boost_trigger_state(int state)
 {
@@ -1014,6 +1053,12 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
 {
 	return false;
 }
+
+static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
+						     const char *cell_name, struct cpumask *cpumask)
+{
+	return -EOPNOTSUPP;
+}
 #endif
 
 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
@@ -1035,7 +1080,6 @@ void arch_set_freq_scale(const struct cpumask *cpus,
 {
 }
 #endif
-
 /* the following are really really optional */
 extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
 extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
-- 
1.7.9.5


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

* [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW
  2021-09-03  8:39 [PATCH v15] cpufreq: mediatek-hw: Add support for Mediatek cpufreq HW driver Hector Yuan
  2021-09-03  8:39 ` [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW Hector Yuan
  2021-09-03  8:39 ` [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Hector Yuan
@ 2021-09-03  8:39 ` Hector Yuan
  2021-09-03 15:54   ` kernel test robot
                     ` (2 more replies)
  2 siblings, 3 replies; 11+ messages in thread
From: Hector Yuan @ 2021-09-03  8:39 UTC (permalink / raw)
  To: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Viresh Kumar, Rob Herring, devicetree
  Cc: linux-kernel, wsd_upstream, hector.yuan

From: "Hector.Yuan" <hector.yuan@mediatek.com>

Introduce cpufreq HW driver which can support
CPU frequency adjust in MT6779 platform.

Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
---
 drivers/cpufreq/Kconfig.arm           |   12 ++
 drivers/cpufreq/Makefile              |    1 +
 drivers/cpufreq/mediatek-cpufreq-hw.c |  340 +++++++++++++++++++++++++++++++++
 3 files changed, 353 insertions(+)
 create mode 100644 drivers/cpufreq/mediatek-cpufreq-hw.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index a5c5f70..954749a 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -133,6 +133,18 @@ config ARM_MEDIATEK_CPUFREQ
 	help
 	  This adds the CPUFreq driver support for MediaTek SoCs.
 
+config ARM_MEDIATEK_CPUFREQ_HW
+	tristate "MediaTek CPUFreq HW driver"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	default m
+	help
+	  Support for the CPUFreq HW driver.
+	  Some MediaTek chipsets have a HW engine to offload the steps
+	  necessary for changing the frequency of the CPUs. Firmware loaded
+	  in this engine exposes a programming interface to the OS.
+	  The driver implements the cpufreq interface for this HW engine.
+	  Say Y if you want to support CPUFreq HW.
+
 config ARM_OMAP2PLUS_CPUFREQ
 	bool "TI OMAP2+"
 	depends on ARCH_OMAP2PLUS
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 27d3bd7..48ee585 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)		+= imx6q-cpufreq.o
 obj-$(CONFIG_ARM_IMX_CPUFREQ_DT)	+= imx-cpufreq-dt.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)	+= kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_MEDIATEK_CPUFREQ)	+= mediatek-cpufreq.o
+obj-$(CONFIG_ARM_MEDIATEK_CPUFREQ_HW)	+= mediatek-cpufreq-hw.o
 obj-$(CONFIG_MACH_MVEBU_V7)		+= mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)	+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)	+= pxa2xx-cpufreq.o
diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
new file mode 100644
index 0000000..9c6df1b
--- /dev/null
+++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
@@ -0,0 +1,340 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020 MediaTek Inc.
+ */
+
+#include <linux/bitfield.h>
+#include <linux/cpufreq.h>
+#include <linux/energy_model.h>
+#include <linux/init.h>
+#include <linux/iopoll.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/slab.h>
+
+#define LUT_MAX_ENTRIES			32U
+#define LUT_FREQ			GENMASK(11, 0)
+#define LUT_ROW_SIZE			0x4
+#define CPUFREQ_HW_STATUS		BIT(0)
+#define SVS_HW_STATUS			BIT(1)
+#define POLL_USEC			1000
+#define TIMEOUT_USEC			300000
+
+enum {
+	REG_FREQ_LUT_TABLE,
+	REG_FREQ_ENABLE,
+	REG_FREQ_PERF_STATE,
+	REG_FREQ_HW_STATE,
+	REG_EM_POWER_TBL,
+	REG_FREQ_LATENCY,
+
+	REG_ARRAY_SIZE,
+};
+
+struct mtk_cpufreq_drv;
+
+struct mtk_cpufreq_drv {
+	const u16 *offsets;
+};
+
+struct mtk_cpufreq_data {
+	struct cpufreq_frequency_table *table;
+	void __iomem *reg_bases[REG_ARRAY_SIZE];
+	int nr_opp;
+};
+
+static const u16 cpufreq_mtk_offsets[REG_ARRAY_SIZE] = {
+	[REG_FREQ_LUT_TABLE]	= 0x0,
+	[REG_FREQ_ENABLE]	= 0x84,
+	[REG_FREQ_PERF_STATE]	= 0x88,
+	[REG_FREQ_HW_STATE]	= 0x8c,
+	[REG_EM_POWER_TBL]	= 0x90,
+	[REG_FREQ_LATENCY]	= 0x110,
+};
+
+static int __maybe_unused
+mtk_cpufreq_get_cpu_power(unsigned long *mW,
+			  unsigned long *KHz, struct device *cpu_dev)
+{
+	struct mtk_cpufreq_data *data;
+	struct cpufreq_policy *policy;
+	int i;
+
+	policy = cpufreq_cpu_get_raw(cpu_dev->id);
+	if (!policy)
+		return 0;
+
+	data = policy->driver_data;
+
+	for (i = 0; i < data->nr_opp; i++) {
+		if (data->table[i].frequency < *KHz)
+			break;
+	}
+	i--;
+
+	*KHz = data->table[i].frequency;
+	*mW = readl_relaxed(data->reg_bases[REG_EM_POWER_TBL] +
+			    i * LUT_ROW_SIZE) / 1000;
+
+	return 0;
+}
+
+static int mtk_cpufreq_hw_target_index(struct cpufreq_policy *policy,
+				       unsigned int index)
+{
+	struct mtk_cpufreq_data *data = policy->driver_data;
+
+	writel_relaxed(index, data->reg_bases[REG_FREQ_PERF_STATE]);
+
+	return 0;
+}
+
+static unsigned int mtk_cpufreq_hw_get(unsigned int cpu)
+{
+	struct mtk_cpufreq_data *data;
+	struct cpufreq_policy *policy;
+	unsigned int index;
+
+	policy = cpufreq_cpu_get_raw(cpu);
+	if (!policy)
+		return 0;
+
+	data = policy->driver_data;
+
+	index = readl_relaxed(data->reg_bases[REG_FREQ_PERF_STATE]);
+	index = min(index, LUT_MAX_ENTRIES - 1);
+
+	return data->table[index].frequency;
+}
+
+static unsigned int mtk_cpufreq_hw_fast_switch(struct cpufreq_policy *policy,
+					       unsigned int target_freq)
+{
+	struct mtk_cpufreq_data *data = policy->driver_data;
+	unsigned int index;
+
+	index = cpufreq_table_find_index_dl(policy, target_freq);
+
+	writel_relaxed(index, data->reg_bases[REG_FREQ_PERF_STATE]);
+
+	return policy->freq_table[index].frequency;
+}
+
+static int mtk_cpu_create_freq_table(struct platform_device *pdev,
+				     struct mtk_cpufreq_data *data)
+{
+	struct device *dev = &pdev->dev;
+	void __iomem *base_table;
+	u32 temp, i, freq, prev_freq = 0;
+
+	data->table = devm_kcalloc(dev, LUT_MAX_ENTRIES + 1,
+				   sizeof(*data->table), GFP_KERNEL);
+	if (!data->table)
+		return -ENOMEM;
+
+	base_table = data->reg_bases[REG_FREQ_LUT_TABLE];
+
+	for (i = 0; i < LUT_MAX_ENTRIES; i++) {
+		temp = readl_relaxed(base_table + (i * LUT_ROW_SIZE));
+		freq = FIELD_GET(LUT_FREQ, temp) * 1000;
+
+		if (freq == prev_freq)
+			break;
+
+		data->table[i].frequency = freq;
+
+		dev_dbg(dev, "index=%d freq=%d\n", i, data->table[i].frequency);
+
+		prev_freq = freq;
+	}
+
+	data->table[i].frequency = CPUFREQ_TABLE_END;
+	data->nr_opp = i;
+
+	return 0;
+}
+
+static int mtk_cpu_resources_init(struct platform_device *pdev,
+				  struct cpufreq_policy *policy,
+				  const u16 *offsets)
+{
+	struct mtk_cpufreq_data *data;
+	struct device *dev = &pdev->dev;
+	void __iomem *base;
+	int ret, i;
+	int index;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	index = of_perf_domain_get_sharing_cpumask(policy->cpu, "performance-domains",
+						   "#performance-domain-cells",
+						   policy->cpus);
+	if (index < 0)
+		return index;
+
+	base = devm_platform_ioremap_resource(pdev, index);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	for (i = REG_FREQ_LUT_TABLE; i < REG_ARRAY_SIZE; i++)
+		data->reg_bases[i] = base + offsets[i];
+
+	ret = mtk_cpu_create_freq_table(pdev, data);
+	if (ret) {
+		dev_info(dev, "Domain-%d failed to create freq table\n", index);
+		return ret;
+	}
+
+	policy->freq_table = data->table;
+	policy->driver_data = data;
+
+	return 0;
+}
+
+static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
+{
+	struct platform_device *pdev = cpufreq_get_driver_data();
+	struct mtk_cpufreq_drv *drv = platform_get_drvdata(pdev);
+	int sig, pwr_hw = CPUFREQ_HW_STATUS | SVS_HW_STATUS;
+	struct mtk_cpufreq_data *data;
+	struct device *cpu_dev;
+	unsigned int latency;
+	int ret;
+
+	/* Get the bases of cpufreq for domains */
+	ret = mtk_cpu_resources_init(pdev, policy, drv->offsets);
+	if (ret) {
+		dev_info(&pdev->dev, "CPUFreq resource init failed\n");
+		return ret;
+	}
+
+	data = policy->driver_data;
+
+	latency = readl_relaxed(data->reg_bases[REG_FREQ_LATENCY]) * 1000;
+	if (!latency)
+		latency = CPUFREQ_ETERNAL;
+
+	/* us convert to ns */
+	policy->cpuinfo.transition_latency = latency;
+
+	policy->fast_switch_possible = true;
+
+	/* HW should be in enabled state to proceed now */
+	writel_relaxed(0x1, data->reg_bases[REG_FREQ_ENABLE]);
+	if (readl_poll_timeout(data->reg_bases[REG_FREQ_HW_STATE], sig,
+			       (sig & pwr_hw) == pwr_hw, POLL_USEC,
+			       TIMEOUT_USEC)) {
+		if (!(sig & CPUFREQ_HW_STATUS)) {
+			pr_info("cpufreq hardware of CPU%d is not enabled\n",
+				policy->cpu);
+			return -ENODEV;
+		}
+
+		pr_info("SVS of CPU%d is not enabled\n", policy->cpu);
+	}
+
+	cpu_dev = get_cpu_device(policy->cpu);
+	if (!cpu_dev) {
+		pr_info("failed to get cpu%d device\n", policy->cpu);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int mtk_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy)
+{
+	struct mtk_cpufreq_data *data = policy->driver_data;
+
+	/* HW should be in paused state now */
+	writel_relaxed(0x0, data->reg_bases[REG_FREQ_ENABLE]);
+
+	return 0;
+}
+
+static void mtk_cpufreq_register_em(struct cpufreq_policy *policy)
+{
+	struct em_data_callback em_cb = EM_DATA_CB(mtk_cpufreq_get_cpu_power);
+	struct mtk_cpufreq_data *data = policy->driver_data;
+
+	if (!data->nr_opp)
+		return;
+
+	em_dev_register_perf_domain(get_cpu_device(policy->cpu), data->nr_opp,
+				    &em_cb, policy->cpus, true);
+}
+
+static struct cpufreq_driver cpufreq_mtk_hw_driver = {
+	.flags		= CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+			  CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
+			  CPUFREQ_IS_COOLING_DEV,
+	.verify		= cpufreq_generic_frequency_table_verify,
+	.target_index	= mtk_cpufreq_hw_target_index,
+	.get		= mtk_cpufreq_hw_get,
+	.init		= mtk_cpufreq_hw_cpu_init,
+	.exit		= mtk_cpufreq_hw_cpu_exit,
+	.register_em	= mtk_cpufreq_register_em,
+	.fast_switch	= mtk_cpufreq_hw_fast_switch,
+	.name		= "mtk-cpufreq-hw",
+	.attr		= cpufreq_generic_attr,
+};
+
+static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
+{
+	struct mtk_cpufreq_drv *drv;
+	const u16 *offsets;
+	int ret;
+
+	offsets = of_device_get_match_data(&pdev->dev);
+	if (!offsets)
+		return -EINVAL;
+
+	drv = kzalloc(sizeof(*drv), GFP_KERNEL);
+	if (!drv)
+		return -ENOMEM;
+
+	drv->offsets = offsets;
+
+	platform_set_drvdata(pdev, drv);
+
+	cpufreq_mtk_hw_driver.driver_data = pdev;
+
+	ret = cpufreq_register_driver(&cpufreq_mtk_hw_driver);
+	if (ret)
+		dev_err(&pdev->dev, "CPUFreq HW driver failed to register\n");
+
+	return ret;
+}
+
+static int mtk_cpufreq_hw_driver_remove(struct platform_device *pdev)
+{
+	struct mtk_cpufreq_drv *drv = platform_get_drvdata(pdev);
+
+	kfree(drv->offsets);
+	kfree(drv);
+
+	return cpufreq_unregister_driver(&cpufreq_mtk_hw_driver);
+}
+
+static const struct of_device_id mtk_cpufreq_hw_match[] = {
+	{ .compatible = "mediatek,cpufreq-hw", .data = &cpufreq_mtk_offsets },
+	{}
+};
+
+static struct platform_driver mtk_cpufreq_hw_driver = {
+	.probe = mtk_cpufreq_hw_driver_probe,
+	.remove = mtk_cpufreq_hw_driver_remove,
+	.driver = {
+		.name = "mtk-cpufreq-hw",
+		.of_match_table = mtk_cpufreq_hw_match,
+	},
+};
+module_platform_driver(mtk_cpufreq_hw_driver);
+
+MODULE_AUTHOR("Hector Yuan <hector.yuan@mediatek.com>");
+MODULE_DESCRIPTION("Mediatek cpufreq-hw driver");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5


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

* Re: [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW
  2021-09-03  8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
@ 2021-09-03 15:54   ` kernel test robot
  2021-09-03 16:34   ` kernel test robot
  2021-09-06  9:44   ` Viresh Kumar
  2 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-09-03 15:54 UTC (permalink / raw)
  To: Hector Yuan, linux-mediatek, linux-arm-kernel, linux-pm,
	Rafael J. Wysocki, Viresh Kumar, Rob Herring, devicetree
  Cc: llvm, kbuild-all, linux-kernel, wsd_upstream, hector.yuan

[-- Attachment #1: Type: text/plain, Size: 2777 bytes --]

Hi Hector,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on robh/for-next v5.14]
[cannot apply to pm/linux-next next-20210903]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: arm-randconfig-c002-20210903 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1104e3258b5064e7110cc297e2cec60ac9acfc0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/a7148c526ed4198bbe953fb17e52257f0d50d8c4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
        git checkout a7148c526ed4198bbe953fb17e52257f0d50d8c4
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/cpufreq/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/cpufreq/mediatek-cpufreq-hw.c:280:3: error: field designator 'register_em' does not refer to any field in type 'struct cpufreq_driver'
           .register_em    = mtk_cpufreq_register_em,
            ^
   1 error generated.


vim +280 drivers/cpufreq/mediatek-cpufreq-hw.c

   270	
   271	static struct cpufreq_driver cpufreq_mtk_hw_driver = {
   272		.flags		= CPUFREQ_NEED_INITIAL_FREQ_CHECK |
   273				  CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
   274				  CPUFREQ_IS_COOLING_DEV,
   275		.verify		= cpufreq_generic_frequency_table_verify,
   276		.target_index	= mtk_cpufreq_hw_target_index,
   277		.get		= mtk_cpufreq_hw_get,
   278		.init		= mtk_cpufreq_hw_cpu_init,
   279		.exit		= mtk_cpufreq_hw_cpu_exit,
 > 280		.register_em	= mtk_cpufreq_register_em,
   281		.fast_switch	= mtk_cpufreq_hw_fast_switch,
   282		.name		= "mtk-cpufreq-hw",
   283		.attr		= cpufreq_generic_attr,
   284	};
   285	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39926 bytes --]

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

* Re: [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW
  2021-09-03  8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
  2021-09-03 15:54   ` kernel test robot
@ 2021-09-03 16:34   ` kernel test robot
  2021-09-06  9:44   ` Viresh Kumar
  2 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-09-03 16:34 UTC (permalink / raw)
  To: Hector Yuan, linux-mediatek, linux-arm-kernel, linux-pm,
	Rafael J. Wysocki, Viresh Kumar, Rob Herring, devicetree
  Cc: kbuild-all, linux-kernel, wsd_upstream, hector.yuan

[-- Attachment #1: Type: text/plain, Size: 3056 bytes --]

Hi Hector,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on soc/for-next]
[also build test ERROR on robh/for-next v5.14]
[cannot apply to pm/linux-next next-20210903]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: arm-defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/a7148c526ed4198bbe953fb17e52257f0d50d8c4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
        git checkout a7148c526ed4198bbe953fb17e52257f0d50d8c4
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/cpufreq/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/cpufreq/mediatek-cpufreq-hw.c:280:10: error: 'struct cpufreq_driver' has no member named 'register_em'
     280 |         .register_em    = mtk_cpufreq_register_em,
         |          ^~~~~~~~~~~
>> drivers/cpufreq/mediatek-cpufreq-hw.c:280:27: error: initialization of 'int (*)(struct cpufreq_policy *)' from incompatible pointer type 'void (*)(struct cpufreq_policy *)' [-Werror=incompatible-pointer-types]
     280 |         .register_em    = mtk_cpufreq_register_em,
         |                           ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/cpufreq/mediatek-cpufreq-hw.c:280:27: note: (near initialization for 'cpufreq_mtk_hw_driver.suspend')
   cc1: some warnings being treated as errors


vim +280 drivers/cpufreq/mediatek-cpufreq-hw.c

   270	
   271	static struct cpufreq_driver cpufreq_mtk_hw_driver = {
   272		.flags		= CPUFREQ_NEED_INITIAL_FREQ_CHECK |
   273				  CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
   274				  CPUFREQ_IS_COOLING_DEV,
   275		.verify		= cpufreq_generic_frequency_table_verify,
   276		.target_index	= mtk_cpufreq_hw_target_index,
   277		.get		= mtk_cpufreq_hw_get,
   278		.init		= mtk_cpufreq_hw_cpu_init,
   279		.exit		= mtk_cpufreq_hw_cpu_exit,
 > 280		.register_em	= mtk_cpufreq_register_em,
   281		.fast_switch	= mtk_cpufreq_hw_fast_switch,
   282		.name		= "mtk-cpufreq-hw",
   283		.attr		= cpufreq_generic_attr,
   284	};
   285	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54084 bytes --]

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

* Re: [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW
  2021-09-03  8:39 ` [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW Hector Yuan
@ 2021-09-03 16:35   ` Rob Herring
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2021-09-03 16:35 UTC (permalink / raw)
  To: Hector Yuan
  Cc: wsd_upstream, Rob Herring, Viresh Kumar, linux-mediatek,
	linux-arm-kernel, devicetree, linux-pm, Rafael J. Wysocki,
	linux-kernel

On Fri, 03 Sep 2021 16:39:22 +0800, Hector Yuan wrote:
> From: "Hector.Yuan" <hector.yuan@mediatek.com>
> 
> Add devicetree bindings for MediaTek HW driver.
> 
> Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
> ---
>  .../bindings/cpufreq/cpufreq-mediatek-hw.yaml      |   70 ++++++++++++++++++++
>  1 file changed, 70 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek-hw.yaml
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask
  2021-09-03  8:39 ` [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Hector Yuan
@ 2021-09-04 22:32   ` kernel test robot
  2021-09-06  9:43   ` Viresh Kumar
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-09-04 22:32 UTC (permalink / raw)
  To: Hector Yuan, linux-mediatek, linux-arm-kernel, linux-pm,
	Rafael J. Wysocki, Viresh Kumar, Rob Herring, devicetree
  Cc: llvm, kbuild-all, linux-kernel, wsd_upstream, hector.yuan

[-- Attachment #1: Type: text/plain, Size: 18830 bytes --]

Hi Hector,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on soc/for-next]
[also build test WARNING on robh/for-next v5.14]
[cannot apply to pm/linux-next next-20210903]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: i386-randconfig-r002-20210903 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 1104e3258b5064e7110cc297e2cec60ac9acfc0a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/47a2ae7200a52148136871a5a9c85eadd4c6c620
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Hector-Yuan/dt-bindings-cpufreq-add-bindings-for-MediaTek-cpufreq-HW/20210903-174004
        git checkout 47a2ae7200a52148136871a5a9c85eadd4c6c620
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
                                                                            ^
   include/linux/node.h:177:32: warning: unused parameter 'unreg' [-Wunused-parameter]
                                                   node_registration_func_t unreg)
                                                                            ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   In file included from include/linux/cpufreq.h:17:
   In file included from include/linux/of_device.h:5:
   In file included from include/linux/cpu.h:20:
   include/linux/cpuhotplug.h:417:55: warning: unused parameter 'state' [-Wunused-parameter]
   static inline void cpuhp_online_idle(enum cpuhp_state state) { }
                                                         ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   In file included from include/linux/cpufreq.h:17:
   In file included from include/linux/of_device.h:5:
   include/linux/cpu.h:111:40: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline int add_cpu(unsigned int cpu) { return 0;}
                                          ^
   include/linux/cpu.h:142:43: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline int remove_cpu(unsigned int cpu) { return -EPERM; }
                                             ^
   include/linux/cpu.h:143:59: warning: unused parameter 'primary_cpu' [-Wunused-parameter]
   static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
                                                             ^
   include/linux/cpu.h:226:41: warning: unused parameter 'force' [-Wunused-parameter]
   static inline void cpu_smt_disable(bool force) { }
                                           ^
   include/linux/cpu.h:230:60: warning: unused parameter 'ctrlval' [-Wunused-parameter]
   static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; }
                                                              ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   In file included from include/linux/cpufreq.h:17:
   In file included from include/linux/of_device.h:6:
   include/linux/platform_device.h:353:71: warning: unused parameter 'pdev' [-Wunused-parameter]
   static inline int is_sh_early_platform_device(struct platform_device *pdev)
                                                                         ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:6:
   include/linux/cpufreq.h:190:71: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
                                                                         ^
   include/linux/cpufreq.h:194:67: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
                                                                     ^
   include/linux/cpufreq.h:198:59: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_cpu_put(struct cpufreq_policy *policy) { }
                                                             ^
   include/linux/cpufreq.h:232:53: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_get(unsigned int cpu)
                                                       ^
   include/linux/cpufreq.h:236:59: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_quick_get(unsigned int cpu)
                                                             ^
   include/linux/cpufreq.h:240:63: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_quick_get_max(unsigned int cpu)
                                                                 ^
   include/linux/cpufreq.h:244:65: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline unsigned int cpufreq_get_hw_max_freq(unsigned int cpu)
                                                                   ^
   include/linux/cpufreq.h:261:70: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_stats_create_table(struct cpufreq_policy *policy) { }
                                                                        ^
   include/linux/cpufreq.h:262:68: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_stats_free_table(struct cpufreq_policy *policy) { }
                                                                      ^
   include/linux/cpufreq.h:263:75: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
                                                                             ^
   include/linux/cpufreq.h:264:23: warning: unused parameter 'new_freq' [-Wunused-parameter]
                                                      unsigned int new_freq) { }
                                                                   ^
   include/linux/cpufreq.h:500:68: warning: unused parameter 'nb' [-Wunused-parameter]
   static inline int cpufreq_register_notifier(struct notifier_block *nb,
                                                                      ^
   include/linux/cpufreq.h:501:20: warning: unused parameter 'list' [-Wunused-parameter]
                                                   unsigned int list)
                                                                ^
   include/linux/cpufreq.h:505:70: warning: unused parameter 'nb' [-Wunused-parameter]
   static inline int cpufreq_unregister_notifier(struct notifier_block *nb,
                                                                        ^
   include/linux/cpufreq.h:506:20: warning: unused parameter 'list' [-Wunused-parameter]
                                                   unsigned int list)
                                                                ^
   include/linux/cpufreq.h:676:64: warning: unused parameter 'dev' [-Wunused-parameter]
   static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
                                                                  ^
   include/linux/cpufreq.h:678:9: warning: unused parameter 'table' [-Wunused-parameter]
                                                   **table)
                                                     ^
   include/linux/cpufreq.h:683:65: warning: unused parameter 'dev' [-Wunused-parameter]
   static inline void dev_pm_opp_free_cpufreq_table(struct device *dev,
                                                                   ^
   include/linux/cpufreq.h:685:10: warning: unused parameter 'table' [-Wunused-parameter]
                                                    **table)
                                                      ^
   include/linux/cpufreq.h:1038:51: warning: unused parameter 'state' [-Wunused-parameter]
   static inline int cpufreq_boost_trigger_state(int state)
                                                     ^
   include/linux/cpufreq.h:1052:65: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
                                                                   ^
>> include/linux/cpufreq.h:1057:58: warning: unused parameter 'pcpu' [-Wunused-parameter]
   static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
                                                            ^
>> include/linux/cpufreq.h:1057:76: warning: unused parameter 'list_name' [-Wunused-parameter]
   static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
                                                                              ^
>> include/linux/cpufreq.h:1058:24: warning: unused parameter 'cell_name' [-Wunused-parameter]
                                                        const char *cell_name, struct cpumask *cpumask)
                                                                    ^
>> include/linux/cpufreq.h:1058:51: warning: unused parameter 'cpumask' [-Wunused-parameter]
                                                        const char *cell_name, struct cpumask *cpumask)
                                                                                               ^
   include/linux/cpufreq.h:1068:73: warning: unused parameter 'policy' [-Wunused-parameter]
   static inline void sched_cpufreq_governor_change(struct cpufreq_policy *policy,
                                                                           ^
   include/linux/cpufreq.h:1069:29: warning: unused parameter 'old_gov' [-Wunused-parameter]
                           struct cpufreq_governor *old_gov) { }
                                                    ^
   include/linux/cpufreq.h:1077:48: warning: unused parameter 'cpus' [-Wunused-parameter]
   void arch_set_freq_scale(const struct cpumask *cpus,
                                                  ^
   include/linux/cpufreq.h:1078:19: warning: unused parameter 'cur_freq' [-Wunused-parameter]
                            unsigned long cur_freq,
                                          ^
   include/linux/cpufreq.h:1079:19: warning: unused parameter 'max_freq' [-Wunused-parameter]
                            unsigned long max_freq)
                                          ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:5:
   include/linux/context_tracking_state.h:51:53: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline bool context_tracking_enabled_cpu(int cpu) { return false; }
                                                       ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   include/linux/vtime.h:28:57: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_user_enter(struct task_struct *tsk) { }
                                                           ^
   include/linux/vtime.h:29:56: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_user_exit(struct task_struct *tsk) { }
                                                          ^
   include/linux/vtime.h:30:58: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_guest_enter(struct task_struct *tsk) { }
                                                            ^
   include/linux/vtime.h:31:57: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_guest_exit(struct task_struct *tsk) { }
                                                           ^
   include/linux/vtime.h:32:56: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
                                                          ^
   include/linux/vtime.h:32:65: warning: unused parameter 'cpu' [-Wunused-parameter]
   static inline void vtime_init_idle(struct task_struct *tsk, int cpu) { }
                                                                   ^
   include/linux/vtime.h:41:58: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { }
                                                            ^
   include/linux/vtime.h:41:76: warning: unused parameter 'offset' [-Wunused-parameter]
   static inline void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { }
                                                                              ^
   include/linux/vtime.h:42:62: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_account_softirq(struct task_struct *tsk) { }
                                                                ^
   include/linux/vtime.h:43:62: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_account_hardirq(struct task_struct *tsk) { }
                                                                ^
   include/linux/vtime.h:44:52: warning: unused parameter 'tsk' [-Wunused-parameter]
   static inline void vtime_flush(struct task_struct *tsk) { }
                                                      ^
   include/linux/vtime.h:117:58: warning: unused parameter 'prev' [-Wunused-parameter]
   static inline void vtime_task_switch(struct task_struct *prev) { }
                                                            ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   In file included from include/linux/interrupt.h:20:
   In file included from arch/x86/include/asm/sections.h:7:
   include/asm-generic/sections.h:70:53: warning: unused parameter 'addr' [-Wunused-parameter]
   static inline int arch_is_kernel_text(unsigned long addr)
                                                       ^
   include/asm-generic/sections.h:77:53: warning: unused parameter 'addr' [-Wunused-parameter]
   static inline int arch_is_kernel_data(unsigned long addr)
                                                       ^
   In file included from drivers/gpu/drm/i915/gt/intel_llc.c:8:
   In file included from drivers/gpu/drm/i915/i915_drv.h:36:
   In file included from arch/x86/include/asm/hypervisor.h:37:
   In file included from arch/x86/include/asm/kvm_para.h:7:
   include/linux/interrupt.h:346:49: warning: unused parameter 'irq' [-Wunused-parameter]
   static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
                                                   ^
   include/linux/interrupt.h:346:76: warning: unused parameter 'm' [-Wunused-parameter]
   static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)
                                                                              ^
   include/linux/interrupt.h:351:51: warning: unused parameter 'irq' [-Wunused-parameter]
   static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
                                                     ^
   include/linux/interrupt.h:351:78: warning: unused parameter 'cpumask' [-Wunused-parameter]
   static inline int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
                                                                                ^
   include/linux/interrupt.h:356:53: warning: unused parameter 'irq' [-Wunused-parameter]
   static inline int irq_can_set_affinity(unsigned int irq)
                                                       ^
   include/linux/interrupt.h:361:52: warning: unused parameter 'irq' [-Wunused-parameter]


vim +/pcpu +1057 include/linux/cpufreq.h

  1000	
  1001	static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
  1002							     const char *cell_name, struct cpumask *cpumask)
  1003	{
  1004		struct device_node *cpu_np;
  1005		struct of_phandle_args args;
  1006		int target_idx;
  1007		int cpu, ret;
  1008	
  1009		cpu_np = of_cpu_device_node_get(pcpu);
  1010		of_parse_phandle_with_args(cpu_np, list_name,
  1011					   cell_name, 0, &args);
  1012		of_node_put(cpu_np);
  1013		target_idx = args.args[0];
  1014	
  1015		for_each_possible_cpu(cpu) {
  1016			if (cpu == pcpu)
  1017				continue;
  1018	
  1019			cpu_np = of_cpu_device_node_get(cpu);
  1020			if (!cpu_np)
  1021				continue;
  1022	
  1023			ret = of_parse_phandle_with_args(cpu_np, list_name,
  1024							 cell_name, 0,
  1025							 &args);
  1026	
  1027			of_node_put(cpu_np);
  1028			if (ret < 0)
  1029				continue;
  1030	
  1031			if (target_idx == args.args[0])
  1032				cpumask_set_cpu(cpu, cpumask);
  1033		}
  1034	
  1035		return target_idx;
  1036	}
  1037	#else
> 1038	static inline int cpufreq_boost_trigger_state(int state)
  1039	{
  1040		return 0;
  1041	}
  1042	static inline int cpufreq_boost_enabled(void)
  1043	{
  1044		return 0;
  1045	}
  1046	
  1047	static inline int cpufreq_enable_boost_support(void)
  1048	{
  1049		return -EINVAL;
  1050	}
  1051	
> 1052	static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
  1053	{
  1054		return false;
  1055	}
  1056	
> 1057	static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
> 1058							     const char *cell_name, struct cpumask *cpumask)
  1059	{
  1060		return -EOPNOTSUPP;
  1061	}
  1062	#endif
  1063	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35878 bytes --]

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

* Re: [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask
  2021-09-03  8:39 ` [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Hector Yuan
  2021-09-04 22:32   ` kernel test robot
@ 2021-09-06  9:43   ` Viresh Kumar
  2021-09-06 13:11     ` Hector Yuan
  1 sibling, 1 reply; 11+ messages in thread
From: Viresh Kumar @ 2021-09-06  9:43 UTC (permalink / raw)
  To: Hector Yuan
  Cc: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Rob Herring, devicetree, linux-kernel, wsd_upstream

On 03-09-21, 16:39, Hector Yuan wrote:
> From: "Hector.Yuan" <hector.yuan@mediatek.com>
> 
> Add of_perf_domain_get_sharing_cpumask function to group cpu
> to specific performance domain.
> 
> Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
> ---
>  include/linux/cpufreq.h |   46 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 45 insertions(+), 1 deletion(-)

To speed things up, I have applied this with following changes. Please
test my branch and see if something breaks:

https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git/log/?h=cpufreq/arm/linux-next

-- 
viresh

-------------------------8<-------------------------
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 9eb1fa17a8a4..acd3ee5b8b0a 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -1006,37 +1006,49 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy
        return count;
 }

-static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
-                                                    const char *cell_name, struct cpumask *cpumask)
+static inline int parse_perf_domain(int cpu, const char *list_name,
+                                   const char *cell_name)
 {
        struct device_node *cpu_np;
        struct of_phandle_args args;
+       int ret;
+
+       cpu_np = of_cpu_device_node_get(cpu);
+       if (!cpu_np)
+               return -ENODEV;
+
+       ret = of_parse_phandle_with_args(cpu_np, list_name, cell_name, 0,
+                                        &args);
+       if (ret < 0)
+               return ret;
+
+       of_node_put(cpu_np);
+
+       return args.args[0];
+}
+
+static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name,
+                                                    const char *cell_name, struct cpumask *cpumask)
+{
        int target_idx;
        int cpu, ret;

-       cpu_np = of_cpu_device_node_get(pcpu);
-       of_parse_phandle_with_args(cpu_np, list_name,
-                                  cell_name, 0, &args);
-       of_node_put(cpu_np);
-       target_idx = args.args[0];
+       ret = parse_perf_domain(pcpu, list_name, cell_name);
+       if (ret < 0)
+               return ret;
+
+       target_idx = ret;
+       cpumask_set_cpu(pcpu, cpumask);

        for_each_possible_cpu(cpu) {
                if (cpu == pcpu)
                        continue;

-               cpu_np = of_cpu_device_node_get(cpu);
-               if (!cpu_np)
-                       continue;
-
-               ret = of_parse_phandle_with_args(cpu_np, list_name,
-                                                cell_name, 0,
-                                                &args);
-
-               of_node_put(cpu_np);
+               ret = parse_perf_domain(pcpu, list_name, cell_name);
                if (ret < 0)
                        continue;

-               if (target_idx == args.args[0])
+               if (target_idx == ret)
                        cpumask_set_cpu(cpu, cpumask);
        }


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

* Re: [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW
  2021-09-03  8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
  2021-09-03 15:54   ` kernel test robot
  2021-09-03 16:34   ` kernel test robot
@ 2021-09-06  9:44   ` Viresh Kumar
  2 siblings, 0 replies; 11+ messages in thread
From: Viresh Kumar @ 2021-09-06  9:44 UTC (permalink / raw)
  To: Hector Yuan
  Cc: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Rob Herring, devicetree, linux-kernel, wsd_upstream

On 03-09-21, 16:39, Hector Yuan wrote:
> From: "Hector.Yuan" <hector.yuan@mediatek.com>
> 
> Introduce cpufreq HW driver which can support
> CPU frequency adjust in MT6779 platform.
> 
> Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
> ---
>  drivers/cpufreq/Kconfig.arm           |   12 ++
>  drivers/cpufreq/Makefile              |    1 +
>  drivers/cpufreq/mediatek-cpufreq-hw.c |  340 +++++++++++++++++++++++++++++++++
>  3 files changed, 353 insertions(+)
>  create mode 100644 drivers/cpufreq/mediatek-cpufreq-hw.c

Here as well, I have added below diff to the original patch. Lemme
know if you don't like something.

diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
index 9c6df1b00f3e..0cf18dd46b92 100644
--- a/drivers/cpufreq/mediatek-cpufreq-hw.c
+++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
@@ -33,12 +33,6 @@ enum {
        REG_ARRAY_SIZE,
 };

-struct mtk_cpufreq_drv;
-
-struct mtk_cpufreq_drv {
-       const u16 *offsets;
-};
-
 struct mtk_cpufreq_data {
        struct cpufreq_frequency_table *table;
        void __iomem *reg_bases[REG_ARRAY_SIZE];
@@ -126,8 +120,8 @@ static int mtk_cpu_create_freq_table(struct platform_device *pdev,
                                     struct mtk_cpufreq_data *data)
 {
        struct device *dev = &pdev->dev;
-       void __iomem *base_table;
        u32 temp, i, freq, prev_freq = 0;
+       void __iomem *base_table;

        data->table = devm_kcalloc(dev, LUT_MAX_ENTRIES + 1,
                                   sizeof(*data->table), GFP_KERNEL);
@@ -198,15 +192,13 @@ static int mtk_cpu_resources_init(struct platform_device *pdev,
 static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
 {
        struct platform_device *pdev = cpufreq_get_driver_data();
-       struct mtk_cpufreq_drv *drv = platform_get_drvdata(pdev);
        int sig, pwr_hw = CPUFREQ_HW_STATUS | SVS_HW_STATUS;
        struct mtk_cpufreq_data *data;
-       struct device *cpu_dev;
        unsigned int latency;
        int ret;

        /* Get the bases of cpufreq for domains */
-       ret = mtk_cpu_resources_init(pdev, policy, drv->offsets);
+       ret = mtk_cpu_resources_init(pdev, policy, platform_get_drvdata(pdev));
        if (ret) {
                dev_info(&pdev->dev, "CPUFreq resource init failed\n");
                return ret;
@@ -218,9 +210,7 @@ static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
        if (!latency)
                latency = CPUFREQ_ETERNAL;

-       /* us convert to ns */
        policy->cpuinfo.transition_latency = latency;
-
        policy->fast_switch_possible = true;

        /* HW should be in enabled state to proceed now */
@@ -237,12 +227,6 @@ static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
                pr_info("SVS of CPU%d is not enabled\n", policy->cpu);
        }

-       cpu_dev = get_cpu_device(policy->cpu);
-       if (!cpu_dev) {
-               pr_info("failed to get cpu%d device\n", policy->cpu);
-               return -ENODEV;
-       }
-
        return 0;
 }

@@ -261,9 +245,6 @@ static void mtk_cpufreq_register_em(struct cpufreq_policy *policy)
        struct em_data_callback em_cb = EM_DATA_CB(mtk_cpufreq_get_cpu_power);
        struct mtk_cpufreq_data *data = policy->driver_data;

-       if (!data->nr_opp)
-               return;
-
        em_dev_register_perf_domain(get_cpu_device(policy->cpu), data->nr_opp,
                                    &em_cb, policy->cpus, true);
 }
@@ -285,22 +266,14 @@ static struct cpufreq_driver cpufreq_mtk_hw_driver = {

 static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
 {
-       struct mtk_cpufreq_drv *drv;
-       const u16 *offsets;
+       const void *data;
        int ret;

-       offsets = of_device_get_match_data(&pdev->dev);
-       if (!offsets)
+       data = of_device_get_match_data(&pdev->dev);
+       if (!data)
                return -EINVAL;

-       drv = kzalloc(sizeof(*drv), GFP_KERNEL);
-       if (!drv)
-               return -ENOMEM;
-
-       drv->offsets = offsets;
-
-       platform_set_drvdata(pdev, drv);
-
+       platform_set_drvdata(pdev, (void *) data);
        cpufreq_mtk_hw_driver.driver_data = pdev;

        ret = cpufreq_register_driver(&cpufreq_mtk_hw_driver);
@@ -312,11 +285,6 @@ static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)

 static int mtk_cpufreq_hw_driver_remove(struct platform_device *pdev)
 {
-       struct mtk_cpufreq_drv *drv = platform_get_drvdata(pdev);
-
-       kfree(drv->offsets);
-       kfree(drv);
-
        return cpufreq_unregister_driver(&cpufreq_mtk_hw_driver);
 }


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

* Re: [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask
  2021-09-06  9:43   ` Viresh Kumar
@ 2021-09-06 13:11     ` Hector Yuan
  0 siblings, 0 replies; 11+ messages in thread
From: Hector Yuan @ 2021-09-06 13:11 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: linux-mediatek, linux-arm-kernel, linux-pm, Rafael J. Wysocki,
	Rob Herring, devicetree, linux-kernel, wsd_upstream

On Mon, 2021-09-06 at 15:13 +0530, Viresh Kumar wrote:
> On 03-09-21, 16:39, Hector Yuan wrote:
> > From: "Hector.Yuan" <hector.yuan@mediatek.com>
> > 
> > Add of_perf_domain_get_sharing_cpumask function to group cpu
> > to specific performance domain.
> > 
> > Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
> > ---
> >  include/linux/cpufreq.h |   46
> > +++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 45 insertions(+), 1 deletion(-)
> 
> To speed things up, I have applied this with following changes.
> Please
> test my branch and see if something breaks:
> 
> 
https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git/log/?h=cpufreq*arm*linux-next__;Ly8!!CTRNKA9wMg0ARbw!1FkaXVRm8cyf4CDTMMNDmFZ3X8eLd3gf1jK92brq9m-OryGK_peVZW963ettt0DF588$
>  
> 
Hi, Viresh:

I've tested the code in your branch and its okay. Thanks for the review
and your guideness. Thanks.


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

end of thread, other threads:[~2021-09-06 13:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  8:39 [PATCH v15] cpufreq: mediatek-hw: Add support for Mediatek cpufreq HW driver Hector Yuan
2021-09-03  8:39 ` [PATCH v15 1/3] dt-bindings: cpufreq: add bindings for MediaTek cpufreq HW Hector Yuan
2021-09-03 16:35   ` Rob Herring
2021-09-03  8:39 ` [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Hector Yuan
2021-09-04 22:32   ` kernel test robot
2021-09-06  9:43   ` Viresh Kumar
2021-09-06 13:11     ` Hector Yuan
2021-09-03  8:39 ` [PATCH v15 3/3] cpufreq: mediatek-hw: Add support for CPUFREQ HW Hector Yuan
2021-09-03 15:54   ` kernel test robot
2021-09-03 16:34   ` kernel test robot
2021-09-06  9:44   ` Viresh Kumar

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