Re: [PATCH v2 09/26] cpufreq: qcom-nvmem: create L2 cache device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26/06/2023 14:50, Konrad Dybcio wrote:
On 25.06.2023 22:25, Dmitry Baryshkov wrote:
Scaling the frequencies on some of Qualcomm Krait platforms (e.g.
APQ8064) also requires scaling of the L2 cache frequency. As the
l2-cache device node is places under /cpus/ path, it is not created by
default by the OF code. Create corresponding device here.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
---
I think a generic solution (i.e. for each cpu node call
of_platform_populate in drivers/of/platform.c :
of_platform_default_populate_init) could be beneficial

Yep. I thought about it, but I saw no direct benefit for it. Note, that we do not instantiate cpu devices directly. But, maybe something like /devices/system/cache/foo would make sense.


Konrad
  drivers/cpufreq/qcom-cpufreq-nvmem.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)

diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c
index a88b6fe5db50..ab78ef1531d0 100644
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -380,6 +380,7 @@ static int __init qcom_cpufreq_init(void)
  {
  	struct device_node *np = of_find_node_by_path("/");
  	const struct of_device_id *match;
+	unsigned int cpu;
  	int ret;
if (!np)
@@ -390,6 +391,25 @@ static int __init qcom_cpufreq_init(void)
  	if (!match)
  		return -ENODEV;
+ for_each_possible_cpu(cpu) {
+		struct device *dev = get_cpu_device(cpu);
+		struct device_node *cache;
+		struct platform_device *pdev;
+
+		cache = of_find_next_cache_node(dev->of_node);
+		if (!cache)
+			continue;
+
+		if (of_device_is_compatible(cache, "qcom,krait-l2-cache")) {
+			pdev = of_platform_device_create(cache, NULL, NULL);
+			if (IS_ERR(pdev))
+				pr_err("%s: %pe, failed to create L2 cache node\n", __func__, pdev);
+			/* the error is not fatal */
+		}
+
+		of_node_put(cache);
+	}
+
  	ret = platform_driver_register(&qcom_cpufreq_driver);
  	if (unlikely(ret < 0))
  		return ret;

--
With best wishes
Dmitry




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux