Page MenuHomeFreeBSD

Port sbsawdt (ARM SBSA generic watchdog) driver from NetBSD
Needs ReviewPublic

Authored by greg_unrelenting.technology on Jul 16 2019, 6:39 PM.

Details

Reviewers
manu
Group Reviewers
arm64
Contributor Reviews (base)
Summary

Looking at NetBSD on Ampere eMAG dmesg I noticed sbsawdt0… and decided that we need this :)

sbsawdt0: <ARM SBSA Generic Watchdog> iomem 0xf0600000-0xf0600fff,0xf0610000-0xf0610fff on acpi0
sbsawdt0: default watchdog period is 172 seconds
Test Plan

Tested on: Marvell MACCHIATObin (Armada8k) with upstream EDK2 firmware

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

@greg_unrelenting.technology do you have a git repo available with your work in it? It'd be slightly easier for me to just add your repo and grab changes directly.

@greg_unrelenting.technology do you have a git repo available with your work in it? It'd be slightly easier for me to just add your repo and grab changes directly.

https://github.com/myfreeweb/freebsd — I don't always update it before posting on phab but right now it's up to date

I can confirm this attaches on my eMAG but I cannot verify the watchdog functionality - were you able to test it?

I can confirm this attaches on my eMAG but I cannot verify the watchdog functionality - were you able to test it?

Yeah, I couldn't get it to trip on the eMAG at Packet either, but it works on my MACCHIATObin (dropping to debugger with "watchdog timeout" description on the first interrupt and then rebooting after some more time).

Would be nice to test on ThunderX2 :)

Would be nice to test on ThunderX2 :)

Does not attach on ThunderX2 (no sbsawdt0 in dmesg).

Would be nice to test on ThunderX2 :)

Does not attach on ThunderX2 (no sbsawdt0 in dmesg).

oh.. https://www.mail-archive.com/kernel-packages@lists.launchpad.net/msg272248.html

I guess we don't have any more platforms to test..

Can you show a diff of the NetBSD version to this? i.e. what you had to change in the port?
(I assume that we don't want to treat this as contrib code and will just adopt it.)

Can you show a diff of the NetBSD version to this? i.e. what you had to change in the port?
(I assume that we don't want to treat this as contrib code and will just adopt it.)

ACPI attachment is different (because API is different) and I changed bus_space_map / bus_space_write_4 / etc to bus_alloc_resource / bus_write_4 / etc because we have resources and setting them via BUS_SET_RESOURCE when walking the ACPI table is rather convenient.

The part that touches the device (in sbsawdt_acpi_watchdog_fn) is pretty much the same (that function is only adapted to our watchdog API which calls one function with a cmd).

The original is https://github.com/NetBSD/src/blob/trunk/sys/arch/arm/acpi/sbsawdt_acpi.c — a true diff would show most things (except the defines) as different, it's better to just visually compare :)

emaste added a comment.Sep 9 2019, 1:34 PM

The original is https://github.com/NetBSD/src/blob/trunk/sys/arch/arm/acpi/sbsawdt_acpi.c — a true diff would show most things (except the defines) as different, it's better to just visually compare :)

Thanks; my interest is really just in being able to track the version you started from, so we can review and manually apply any future changes/bug fixes from NetBSD. Maybe just add a comment along the lines of "Obtained from NetBSD sbsawdt_acpi.c r1.1" or such.

Would be nice to test on ThunderX2 :)

Does not attach on ThunderX2 (no sbsawdt0 in dmesg).

oh.. https://www.mail-archive.com/kernel-packages@lists.launchpad.net/msg272248.html
I guess we don't have any more platforms to test..

SBSA watchdog should work on ThunderX2, the specific issue was due to the linux driver not handling the full spec.
It is fixed here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=93ac3deb7c220cbcec032a967220a1f109d58431

emaste added a comment.Sep 9 2019, 8:53 PM

SBSA watchdog should work on ThunderX2, the specific issue was due to the linux driver not handling the full spec.

But the firmware version I have here does not even expose it so I cannot test on FreeBSD. Is there a known-good firmware version I should install?