Closed
Description
Describe the bug
PiKVM uses the PCF8563 chip to implement a second hardware watchdog. When updating the kernel from 6.1.61 to 6.6.21 (d3d2454), the /sys/class/rtc/rtc0/wakealarm file disappeared at all while hwclock seems to be working fine. So the alarm is now broken.
Steps to reproduce the behaviour
Connect any PCF8563-based clock to I2C and add the overlay to /boot/config.txt: dtoverlay=i2c-rtc,pcf8563. After reboot you should see the file /sys/class/rtc/rtc0/wakealarm.
Device (s)
Raspberry Pi CM4 Lite
System
Arch Linux ARM
Feb 29 2024 12:24:53
Copyright (c) 2012 Broadcom
version f4e2138c2adc8f3a92a3a65939e458f11d7298ba (clean) (release) (start)
Linux pikvm 6.6.21-1-rpi #1 SMP Tue Mar 12 14:24:18 UTC 2024 armv7l GNU/Linux
Logs
Nothing special. Looks exactly as on old working kernel.
[root@pikvm ~]# dmesg | grep rtc
[ 9.019505] rtc-pcf8563 1-0051: registered as rtc0
[ 9.047961] rtc-pcf8563 1-0051: setting system clock to 2024-03-12T19:47:50 UTC (1710272870)
Additional context
For PiKVM, we have dyndbg enabled in the kernel, so if you can tell me what to enable for diagnostics, I can do it.
Metadata
Metadata
Assignees
Labels
No labels
Activity
pelwell commentedon Mar 13, 2024
How is wakealarm working on 6.1? The i2c-rtc overlay doesn't configure an IRQ for it, and without one RTC_FEATURE_ALARM is cleared.
mdevaev commentedon Mar 13, 2024
This is a surprise to me because it has always just worked, even on 5.x (and 4.x as I remember)
pelwell commentedon Mar 13, 2024
How do you think it works without an IRQ? Is the kernel polling for the alarm status on a timer? That doesn't sound like it would work well as a watchdog.
The kernel RTC admin guide says:
mdevaev commentedon Mar 13, 2024
Probably, somehow the IRQ was still being configured. We're using it on 6.1 right now. The PCF chip controls a solid state relay that cuts the CM4 power line. I raise the wakealarm, perform a poweroff, and after a minute the alarm actually goes off. The CM4 is powered off, as intended in our scheme.
pelwell commentedon Mar 13, 2024
If an IRQ is claimed then it should show up in /proc/interrupts somewhere.
mdevaev commentedon Mar 13, 2024
This is a listing on 6.1. Okay, to be honest I don't see any related with alarm. However, the file for wakealarm is here.
mdevaev commentedon Mar 13, 2024
In more detail, how we use it. We have a small demon that raises the wakealarm and then bumpes it. If the OS freezes or power off has been performed, the PC chip pulls the relay: https://github.com/pikvm/kvmd/blob/master/kvmd/apps/watchdog/__init__.py
So we need to get this functionality back somehow, because it's used by all customers.
pelwell commentedon Mar 13, 2024
The dependency on a configured IRQ was introduced with this commit: 60cfac1
I can't currently see why it was not present in rpi-6.1.y, since it seems to have been introduced around 6.1-rc6.
mdevaev commentedon Mar 13, 2024
I can revert it and check.
pelwell commentedon Mar 13, 2024
Yours is a fairly unusual use case, with the IRQ not being wired to the SPI, but it isn't invalid. Obviously it is possible for us to revert it in our downstream trees, but we try to avoid accumulating downstream patches that don't have a limited life.
I think you need to petition the kernel devs to revert it. @vwax submitted it and @alexandrebelloni approved it - perhaps they have some input.
alexandrebelloni commentedon Mar 13, 2024
It is not unusual but the driver lacks support for this case. Can you try this patch: alexandrebelloni/linux@7b6c32a after adding the wakeup-source property to your node?
mdevaev commentedon Mar 13, 2024
I understand. Actually, I thought everything was fine here - I just used the API for the chip.
@pelwell I've reverted that commit and everything is working now.
@alexandrebelloni Thank you! I'll try now.
But please guide me a bit: what exactly I need to do with
wakeup-source? Just add it to options?dtoverlay=i2c-rtc,pcf8563,wakeup-source?pelwell commentedon Mar 13, 2024
You'll have to patch the overlay as well so it knows that the wakeup-source property makes sense for the pcf8563 (we can add this in our tree once you've got it all working):
pelwell commentedon Mar 13, 2024
(that goes in arch/arm/boot/dts/overlays/i2c-rtc-common.dtsi)
6by9 commentedon Mar 13, 2024
torvalds/linux@60cfac1 says it features in tags 6.2-rc1 and later.
10 remaining items
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source
overlays: i2c-rtc: pcf8563 supports wakeup-source