Netgear R7800 exploration (IPQ8065, QCA9984)

I'm on mobile and has misclicked tabs, and by error thought that cpufreq-DT.h has been moved intact, but it didn't. Previous link won't work. :confused:

There's generic cpufreq-DT-platdev driver now, it can be put in there like in my semi-wrong patch.

Check patches 0047-1, 0047-2, 0047-3 from https://github.com/dissent1/r7800/tree/sta27/target/linux/ipq806x/patches-4.9

I made my own version meanwhile. I deleted the "0046 remove" patch and replaced it with a patch that should fix things for qcom-cpufreq. Pretty much same items as your approach, except that I switch the .h file definition in qcom-cpufreq.c from 0045 instead of using the cpufreq-dt-platdev.c

Currently compiling my own approach.

--- a/drivers/cpufreq/cpufreq-dt.h
+++ b/drivers/cpufreq/cpufreq-dt.h
@@ -14,6 +14,7 @@
 
 struct cpufreq_dt_platform_data {
 	bool have_governor_per_policy;
+	bool independent_clocks;
 };
 
 #endif /* __CPUFREQ_DT_H__ */
--- a/drivers/cpufreq/qcom-cpufreq.c
+++ a/drivers/cpufreq/qcom-cpufreq.c
@@ -20,7 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_opp.h>
 #include <linux/slab.h>
-#include <linux/cpufreq-dt.h>
+#include "cpufreq-dt.h"
 
 static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver)
 {
--- a/drivers/cpufreq/cpufreq-dt.c
+++ a/drivers/cpufreq/cpufreq-dt.c
@@ -221,7 +221,10 @@
 	}
 
 	if (fallback) {
-		cpumask_setall(policy->cpus);
+		struct cpufreq_dt_platform_data *pd = cpufreq_get_driver_data();
+
+		if (!pd || !pd->independent_clocks)
+			cpumask_setall(policy->cpus);
 
 		/*
 		 * OPP tables are initialized only for policy->cpu, do it for

Looks like my own approach did not work. The frequencies are still moving in tandem.
I will try yours next.

If you want yours to work, you should disable CONFIG_CPUFREQ_DT_PLATDEV as this driver has the same name as platform data that you have left in cpufreq-qcom

Your approach fails too. Or at least there is no frequency scaling data available as component registration fails due to duplicate filename(?). Looks like some tweaking is needed.

Below are the errors from the bootlog. The key items are sysfs: cannot create duplicate filename '/devices/platform/cpufreq-dt' and kobject_add_internal failed for cpufreq-dt with -EEXIST, don't try to register things with the same name in the same directory.

[    3.452556] ------------[ cut here ]------------
[    3.453165] WARNING: CPU: 0 PID: 1 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x50/0x70
[    3.457930] sysfs: cannot create duplicate filename '/devices/platform/cpufreq-dt'
[    3.465402] Modules linked in:
[    3.475721] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.14 #0
[    3.475808] Hardware name: Generic DT based system
[    3.481572] [<c0215670>] (unwind_backtrace) from [<c0211f1c>] (show_stack+0x10/0x14)
[    3.486422] [<c0211f1c>] (show_stack) from [<c0387844>] (dump_stack+0x7c/0x9c)
[    3.494319] [<c0387844>] (dump_stack) from [<c021d70c>] (__warn+0xbc/0xec)
[    3.501343] [<c021d70c>] (__warn) from [<c021d770>] (warn_slowpath_fmt+0x34/0x44)
[    3.508201] [<c021d770>] (warn_slowpath_fmt) from [<c03107dc>] (sysfs_warn_dup+0x50/0x70)
[    3.515753] [<c03107dc>] (sysfs_warn_dup) from [<c03108b8>] (sysfs_create_dir_ns+0x74/0x84)
[    3.523918] [<c03108b8>] (sysfs_create_dir_ns) from [<c0389aac>] (kobject_add_internal+0xe0/0x2a4)
[    3.532077] [<c0389aac>] (kobject_add_internal) from [<c0389cdc>] (kobject_add+0x6c/0x8c)
[    3.541104] [<c0389cdc>] (kobject_add) from [<c0409e88>] (device_add+0xf4/0x4fc)
[    3.549355] [<c0409e88>] (device_add) from [<c040d830>] (platform_device_add+0x128/0x1b8)
[    3.556817] [<c040d830>] (platform_device_add) from [<c040dfa0>] (platform_device_register_full+0xa4/0xf4)
[    3.564896] [<c040dfa0>] (platform_device_register_full) from [<c070b534>] (qcom_cpufreq_driver_init+0x368/0x3e0)
[    3.574440] [<c070b534>] (qcom_cpufreq_driver_init) from [<c0209778>] (do_one_initcall+0xb8/0x174)
[    3.584777] [<c0209778>] (do_one_initcall) from [<c06f5dc8>] (kernel_init_freeable+0x120/0x1e8)
[    3.593622] [<c06f5dc8>] (kernel_init_freeable) from [<c05a75f4>] (kernel_init+0xc/0xf4)
[    3.602216] [<c05a75f4>] (kernel_init) from [<c020ec78>] (ret_from_fork+0x14/0x3c)
[    3.610648] ---[ end trace 207ca0134f46ba8c ]---
[    3.617911] ------------[ cut here ]------------
[    3.622770] WARNING: CPU: 0 PID: 1 at lib/kobject.c:240 kobject_add_internal+0x24c/0x2a4
[    3.627292] kobject_add_internal failed for cpufreq-dt with -EEXIST, don't try to register things with the same name in the same directory.
[    3.635438] Modules linked in:
[    3.650785] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.9.14 #0
[    3.650813] Hardware name: Generic DT based system
[    3.657944] [<c0215670>] (unwind_backtrace) from [<c0211f1c>] (show_stack+0x10/0x14)
[    3.662631] [<c0211f1c>] (show_stack) from [<c0387844>] (dump_stack+0x7c/0x9c)
[    3.670528] [<c0387844>] (dump_stack) from [<c021d70c>] (__warn+0xbc/0xec)
[    3.677556] [<c021d70c>] (__warn) from [<c021d770>] (warn_slowpath_fmt+0x34/0x44)
[    3.684417] [<c021d770>] (warn_slowpath_fmt) from [<c0389c18>] (kobject_add_internal+0x24c/0x2a4)
[    3.691973] [<c0389c18>] (kobject_add_internal) from [<c0389cdc>] (kobject_add+0x6c/0x8c)
[    3.700823] [<c0389cdc>] (kobject_add) from [<c0409e88>] (device_add+0xf4/0x4fc)
[    3.708983] [<c0409e88>] (device_add) from [<c040d830>] (platform_device_add+0x128/0x1b8)
[    3.716449] [<c040d830>] (platform_device_add) from [<c040dfa0>] (platform_device_register_full+0xa4/0xf4)
[    3.724527] [<c040dfa0>] (platform_device_register_full) from [<c070b534>] (qcom_cpufreq_driver_init+0x368/0x3e0)
[    3.734073] [<c070b534>] (qcom_cpufreq_driver_init) from [<c0209778>] (do_one_initcall+0xb8/0x174)
[    3.744405] [<c0209778>] (do_one_initcall) from [<c06f5dc8>] (kernel_init_freeable+0x120/0x1e8)
[    3.753253] [<c06f5dc8>] (kernel_init_freeable) from [<c05a75f4>] (kernel_init+0xc/0xf4)
[    3.761849] [<c05a75f4>] (kernel_init) from [<c020ec78>] (ret_from_fork+0x14/0x3c)
[    3.770249] ---[ end trace 207ca0134f46ba8d ]---

Have you restored 0046 patch when tried my approach?

[ 3.724527] [] (platform_device_register_full) is renamed with 0046 patch

[quote="dissent1, post:247, topic:285, full:true"]
Have you restored 0046 patch when tried my approach?

[ 3.724527] [] (platform_device_register_full) is renamed with 0046 patch
[/quote]Yes, I restored it.
But you are right that it looks like there is some leftover code as that function should not be in the call stack. I will re-build tomorrow. (might have been a partially dirty build env)

EDIT:
I recompiled. Same result.

I think that platform_device_register shouldn't be there as it tries to register already existing name.

Check updated patches 46, 47-1/-2/-3

Does not seem to work. dmesg shows the initial frequency setup, but there is noting in sys/devices to monitor it afterward.

what does CPUFREQ_DT_PLATDEV do actually? Do we need it or did it get enabled in 4.9 just for fun? I am thinking to reverting to my approach and disabling that (if that config item is conflicting).

Well, with current defaults the CPU frequency works in any case (all cores simultaneously), so it is much better than with mvebu (where no cpufreq driver seems to be available for my wrt3200acm).

That platdev driver seem to be an unification to store duplicate code from all cpufreq drivers in one place. It is selected in Kconfig when selecting cpufreq-dt, so we have to workaround this if we want to do it the right way :slight_smile:

I got my approach to work. In my first try I had not noticed the upstream commit "cpufreq: dt: Remove unused code" https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/drivers/cpufreq/cpufreq-dt.c?h=linux-4.9.y&id=e86eee6bc2aaa6b3637f6497b26beee09a91bde9

After reverting also that it works:

The solution is to replace the current 0046 patch with the patch below. Last time I had not included the one line change at line 379:

--- a/drivers/cpufreq/cpufreq-dt.h
+++ b/drivers/cpufreq/cpufreq-dt.h
@@ -14,6 +14,7 @@
 
 struct cpufreq_dt_platform_data {
 	bool have_governor_per_policy;
+	bool independent_clocks;
 };
 
 #endif /* __CPUFREQ_DT_H__ */
--- a/drivers/cpufreq/qcom-cpufreq.c
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -20,7 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_opp.h>
 #include <linux/slab.h>
-#include <linux/cpufreq-dt.h>
+#include "cpufreq-dt.h"
 
 static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver)
 {
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -221,7 +221,10 @@ static int cpufreq_init(struct cpufreq_p
 	}
 
 	if (fallback) {
-		cpumask_setall(policy->cpus);
+		struct cpufreq_dt_platform_data *pd = cpufreq_get_driver_data();
+
+		if (!pd || !pd->independent_clocks)
+			cpumask_setall(policy->cpus);
 
 		/*
 		 * OPP tables are initialized only for policy->cpu, do it for
@@ -376,6 +379,8 @@ static int dt_cpufreq_probe(struct platf
 	if (data && data->have_governor_per_policy)
 		dt_cpufreq_driver.flags |= CPUFREQ_HAVE_GOVERNOR_PER_POLICY;
 
+	dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
+
 	ret = cpufreq_register_driver(&dt_cpufreq_driver);
 	if (ret)
 		dev_err(&pdev->dev, "failed register driver: %d\n", ret);

EDIT:
I made a PR about it: https://github.com/lede-project/source/pull/962

1 Like

BTW, on the topic of the serial console, it turned out that it was probably a grounding issue or a line length issue. I picked up an AdaFruit FTDI Friend, and the console works flawlessly. Deets: https://plus.google.com/+TedLemon/posts/j31qJbQksLb

Hello there folks!

May I ask someone of R7800 owners to tell about 'overlay' size in LEDE FW? I suppose there the same issue like with WNDR3700v4 and OpenWRT 15.x FW - not full NAND size available to use (because some part of 128MB is reserved for unknown reasons) until recompile FW with some fixes.

Cheers!

@Bobb, look there - everything is explained

Thanks a lot Wally! Your help was really precious! Did you consider placing '...R7800-large-squashfs-factory.img' to LEDE download section (If it possible of course)? I doubt that only two lads like to utilize about 98MB as ubi (overlay). :wink:

Nope, it's not my build. It't custom build made by @cezary and hosted at his server. But You can download from that and if any problem occurs don't hestitate to ask at his forum: eko.one.pl forum. Language is not a problem and it isn't limited to Polish only.

Thank you Wally for answer and advices! Yes I have read your history (like a lab mouse!) You have nice sense of humor! :slight_smile: I mean maybe that img (created by @cezary) could be second variant of official release (primary for official layout and secondary for non-standard layout) if LEDE maintainers would included fixes suggested by @hnyman into official branch for buildbot. Undoubtedly this necessary only in case more than two men use this layout. I don't ask for it just suppose it will be useful.

I don't think that could be possible as LEDE should be easily reverted to OFW. Unfortunatelly 'netgear' partition contains data used by OFW (I found some data that I set/changed in OFW before removing it) and without it could be faulty.
The only 'proper' way is custom build as many users do. So if you want use whole nand space, You could made custom build yourself (there are patches in @cezary's repo) or use his build.
Maybe there could be such info in wiki/faq but this request/suggestion have to be posted on documentation forum, I think.

Oh, OK! Now I understand the reason of standard layout in LEDE FW. Thanks a lot Wally for your exhaustive explanation!