Bug 278188 - Marvell Armada 385: clkdev_device_lock not implemented after upgrade to 14.0
Summary: Marvell Armada 385: clkdev_device_lock not implemented after upgrade to 14.0
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 14.0-RELEASE
Hardware: arm Any
: --- Affects Many People
Assignee: Mitchell Horne
URL:
Keywords: crash, regression
Depends on:
Blocks:
 
Reported: 2024-04-05 20:54 UTC by solo_code
Modified: 2025-03-04 15:15 UTC (History)
3 users (show)

See Also:
mhorne: mfc-stable14+
mhorne: mfc-stable13-


Attachments
Kernel config (1.53 KB, text/plain)
2024-04-05 20:54 UTC, solo_code
no flags Details
implement armada38x_gateclk clkdev methods (4.02 KB, patch)
2024-04-17 16:10 UTC, Mitchell Horne
no flags Details | Diff
add support for the Kobol Helios4 NAS (2.86 KB, patch)
2024-12-21 18:34 UTC, solo_code
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description solo_code 2024-04-05 20:54:02 UTC
Created attachment 249745 [details]
Kernel config

I run FreeBSD on this NAS SBC for several years now:

https://wiki.kobol.io/helios4/intro/

It has a Marvell Armada 385 SOC. After updating to 14.0 and issuing "sysctl -a" I get this kernel panic:

panic: clkdev_device_lock not implemented
cpuid = 1
time = 1712347555
KDB: stack backtrace:
#0 0xc029ad50 at kdb_backtrace+0x40
#1 0xc0243adc at vpanic+0x140
#2 0xc024399c at vpanic+0
#3 0xc007e4d4 at clkdev_default_device_unlock+0
#4 0xc007f5b0 at clknode_gate_get_gate+0x68
#5 0xc007bd24 at clknode_sysctl+0x164
#6 0xc0257c9c at sysctl_root_handler_locked+0x10c
#7 0xc02570f4 at sysctl_root+0x220
#8 0xc0257710 at userland_sysctl+0x178
#9 0xc0257554 at sys___sysctl+0x7c
#10 0xc0586738 at swi_handler+0x148
#11 0xc05677c4 at swi_exit+0

My kernel config (attached) is very close to "sys/arm/conf/ARMADA38X", so this might be a bug.
Comment 1 Mitchell Horne freebsd_committer freebsd_triage 2024-04-17 16:10:12 UTC
Created attachment 250030 [details]
implement armada38x_gateclk clkdev methods

Are you able to test changes easily?

The attached change will, I believe, resolve the problem. I do not have access to this hardware myself, however.

The commit 1a74d77f85121 seems to have introduced new sysctl nodes exporting the status of gated clocks. The relevant clock driver for this hardware appears incomplete, and so we see the resulting panic.
Comment 2 solo_code 2024-06-10 19:14:14 UTC
Hi Mitchell,

thank you for your work. I am able to test kernel code changes, just not easily. Will definitely try it asap.
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2024-12-06 18:10:56 UTC
(In reply to solo_code from comment #2)
Have you had a chance to test the patch?
Comment 4 solo_code 2024-12-16 17:51:20 UTC
Hi Mark,

sorry for taking so long. Every time it costs me a lot of effort to boot myself into system building. I'm already planning to do a rebuild for this machine in the holiday season around years change. Maybe even in the next days. Will definitely do it as I rely on this machine.
Comment 5 solo_code 2024-12-21 18:34:15 UTC
Created attachment 256018 [details]
add support for the Kobol Helios4 NAS
Comment 6 solo_code 2024-12-21 18:35:07 UTC
Hi Mitchell, Mark,

the patch indeed solves the issue. Awesome!

I applied it to a clean checkout of releng/14.2 and built kernel and base. Please incorporate this into 14 and hopefully 15 too. The Marvell Armada platform is in good shape again. If you want to work on other bits too, you can have me test it within a few days.

I also attached a small patch with kernel config and dts selection that allows to directly build a kernel for the Kobol Helios 4 NAS. Do you see a chance for this to be included into kernel source?

Anyway, thanks for your work. You rock!
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-01-16 17:33:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6f2775548278c76e7c33b15aaaaa759270a8dcd5

commit 6f2775548278c76e7c33b15aaaaa759270a8dcd5
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-04-15 20:18:25 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2025-01-16 17:27:00 +0000

    armada38x: implement gateclk clkdev methods

    Implement basic clkdev methods required by the generic clk_gate device.
    This should make it functional, and prevent panics when invoking the
    clock's CLKNODE_GET_GATE method (e.g. with `sysctl -a`).

    Additionally, we need to fill in other key fields of the clk_gate_def
    structure before registering each clk.

    PR:             278188
    Reported by:    solo_code@protonmail.com
    Tested by:      solo_code@protonmail.com
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D48419

 sys/arm/mv/clk/armada38x_gateclk.c | 99 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 94 insertions(+), 5 deletions(-)
Comment 8 Mitchell Horne freebsd_committer freebsd_triage 2025-01-16 17:39:15 UTC
(In reply to solo_code from comment #6)

Thanks a lot for reporting back! The code will land in stable/14 next week.
Comment 9 Mark Linimon freebsd_committer freebsd_triage 2025-03-02 11:57:57 UTC
^Triage: set MFC flags as reminder.
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-03-04 15:14:39 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d09ec2eeb0d81528066fdb05db8a121f0f1e0c01

commit d09ec2eeb0d81528066fdb05db8a121f0f1e0c01
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-04-15 20:18:25 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2025-03-04 15:11:46 +0000

    armada38x: implement gateclk clkdev methods

    Implement basic clkdev methods required by the generic clk_gate device.
    This should make it functional, and prevent panics when invoking the
    clock's CLKNODE_GET_GATE method (e.g. with `sysctl -a`).

    Additionally, we need to fill in other key fields of the clk_gate_def
    structure before registering each clk.

    PR:             278188
    Reported by:    solo_code@protonmail.com
    Tested by:      solo_code@protonmail.com
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D48419

    (cherry picked from commit 6f2775548278c76e7c33b15aaaaa759270a8dcd5)

 sys/arm/mv/clk/armada38x_gateclk.c | 99 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 94 insertions(+), 5 deletions(-)
Comment 11 Mitchell Horne freebsd_committer freebsd_triage 2025-03-04 15:14:56 UTC
(In reply to Mark Linimon from comment #9)

Thanks for the ping, Mark.