lkml.org 
[lkml]   [2022]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rtc: cros-ec: Limit RTC alarm range if needed
Hi,

On 02/11/2022 11:48:04-0700, Guenter Roeck wrote:
> Alexandre,
>
> On Mon, Oct 31, 2022 at 04:07:51PM -0700, Guenter Roeck wrote:
> [ ... ]
> > > >
> > > > On a side note, I tried an alternate implementation by adding a retry into
> > > > alarmtimer_suspend(), where it would request a smaller timeout if the
> > > > requested timeout failed. I did not pursue/submit this since it seemed
> > > > hacky. To solve that problem, I'd rather discuss extending the RTC API
> > > > to provide a maximum offset to its users. Such a solution would probably
> > > > be desirable, but that it more longer term and would not solve the
> > > > immediate problem.
> > >
> > > Yes, this is what I was aiming for. This is something that is indeed
> > > missing in the RTC API and that I already thought about. But indeed, it
> > > would be great to have a way to set the alarm range separately from the
> > > time keeping range. This would indeed have to be a range relative to the
> > > current time.
> > >
> > > alarmtimer_suspend() can then get the allowed alarm range for the RTC,
> > > and set the alarm to max(alarm range, timer value) and loop until the
> > > timer has expired. Once we have this API, userspace can do the same.
> > >
> > > I guess that ultimately, this doesn't help your driver unless you are
> > > wanting to wakeup all the chromebooks at least once a day regardless of
> > > their EC.
> >
> > That is a no-go. It would reduce battery lifetime on all Chromebooks,
> > including those not affected by the problem (that is, almost all of them).
> >
> > To implement reporting the maximum supported offset, I'd probably either
> > try to identify affected Chromebooks using devicetree information,
> > or by sending am alarm request > 24h in the future in the probe function
> > and setting the maximum offset just below 24h if that request fails.
> > We'd have to discuss the best approach internally.
> >
> > Either case, that doesn't help with the short term problem that we
> > have to solve now and that can be backported to older kernels. It also
> > won't help userspace - userspace alarm requests, as Brian has pointed out,
> > are separate from limits supported by the RTC hardware. We can not change
> > the API for CLOCK_xxx_ALARM to userspace, and doing so would not make
> > sense anyway since it works just fine as long as the system isn't
> > suspended. Besides, changing alarmtimer_suspend() as you suggest above
> > would solve the problem for userspace, so I don't see a need for a
> > userspace API/ABI change unless I am missing something.
> >
>
> Would you be open to accepting this patch, with me starting to work
> on the necessary infastructure changes as suggested above for a more
> comprehensive solution ?
>

I'll take the patch as-is so you can backport it and have a solution.
I'll also work on the alarm range and I'll let you get the series once
this is ready so you can test.


--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

\
 
 \ /
  Last update: 2022-11-07 23:53    [W:1.537 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site