Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp834363qtx; Mon, 31 Oct 2022 15:16:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TeHbmvjn2wpP9N9G6O9sasTvpLMpeJqF9OSMQQZNtKLKt6QPxXMInj7g7Lc0Gl+0fg/IH X-Received: by 2002:a50:8717:0:b0:461:aa10:cb0c with SMTP id i23-20020a508717000000b00461aa10cb0cmr15411edb.383.1667254562360; Mon, 31 Oct 2022 15:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667254562; cv=none; d=google.com; s=arc-20160816; b=WdQuJ4uZzVjFITw33MBEFBmbHGSj9ZXoa8vwh3lzE8Or3iZGLHsX/HzsgLoGg+kNsN UMwx7dFsGb5ZZrWjmJHDdCD+XajB5t+rTJAJ/g3JeWwnqSR3+aBZrlqs71gPDryTq9JD NHe28SbIAb1wlJ3kz3HADoeA6CP7Dnpz959Z8Z+4J05ysHcgL0/18sqFgMWcLTgimF7h HOljq+wUs8ScXqN4B+5ca5bdhdnTOOPQ2WbfYSLJtPUtFeFRNrsX8Mb/KzNKlCAIHifG wcdmJTP/D8v5QhjechGjahtlvQvNuJLcv6+Fs8Q8wyg2MKWgnuw8QcttsX6jQkrKKzvA ParQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y9TGJAtdtjk5IN4wFS84yVevB7Syr2Cb58PAmAkCAa8=; b=JNbjurYdqCUfPvCVx9zfBq7hv/TX1dq/TQbauRrRWIglN0b7gErg9SktGfoksyKDvE 4sJp2vITdoNa2y09FfEqIhwycaad6IpXKdsoGzRaTxFKIAB6e1vwdK7GqnRHAdlfSWxW WQH1YssXvhS1y94xCqxZZMn4zQSfcVnlN8v5ZkzQHo/RV9oRxLK+pHWFLwhAw8PsWWR+ Md2JAtS1xpBNvWTGEWXCaut4o3Ct0SIEMh3Mi5NLUlESW64tlFlMe5k5jPrtM9zg1zx3 /J64qPJgzITgj5QP28QMYzI1kcJucTQsXLbUdp8sw6v8A/rbKBhTpatgspUaE12p/Am8 aPTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jvrmXiQE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk7-20020a1709077f8700b0077fc66b581esi9584166ejc.688.2022.10.31.15.15.33; Mon, 31 Oct 2022 15:16:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=jvrmXiQE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbiJaVz1 (ORCPT + 99 others); Mon, 31 Oct 2022 17:55:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiJaVzZ (ORCPT ); Mon, 31 Oct 2022 17:55:25 -0400 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [IPv6:2001:4b98:dc4:8::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 758E1140B2; Mon, 31 Oct 2022 14:55:24 -0700 (PDT) Received: (Authenticated sender: alexandre.belloni@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 9A816240003; Mon, 31 Oct 2022 21:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667253322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Y9TGJAtdtjk5IN4wFS84yVevB7Syr2Cb58PAmAkCAa8=; b=jvrmXiQEc6YbTbjp6KPJDeMgUKPU0UKz5K+jnxPUTMAoxCFYQmzL/ZER7xXS5RYUR7F/7S wGTzHoKGZdeYx9I2R4u/nO3Wa8ZxuSkLHcA5m7gEzwUL1f0LoT+Pcq0LiV8j19hAvILUD/ rDgdqRtFIdriADNyUmSEB4Yk9A4Ix23eHhT7/RarEkZgTnIileOVPYj4r9JFAdS3j7w15s xdeWUM2S7q0LKyEy8kfKpNUBKMkNgnSQUVbc/KaCQxZ1UxHopDeDmQA/bkKXPxpScAV2/h DhD1/13kJLpDVXwdVZKzjgOlDgLuvZUj51JfrpuMZBhE+TjEbxZeTISHFnmv/g== Date: Mon, 31 Oct 2022 22:55:21 +0100 From: Alexandre Belloni To: Brian Norris Cc: Guenter Roeck , Alessandro Zummo , Benson Leung , linux-rtc@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, John Stultz , Stephen Boyd , Thomas Gleixner Subject: Re: [PATCH] rtc: cros-ec: Limit RTC alarm range if needed Message-ID: References: <20221029005400.2712577-1-linux@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/10/2022 10:56:16-0700, Brian Norris wrote: > CC kernel/time/alarmtimer.c maintainers > > On Mon, Oct 31, 2022 at 06:10:53PM +0100, Alexandre Belloni wrote: > > On 28/10/2022 17:54:00-0700, Guenter Roeck wrote: > > > RTC chips on some older Chromebooks can only handle alarms less than 24 > > > hours in the future. Attempts to set an alarm beyond that range fails. > > > The most severe impact of this limitation is that suspend requests fail > > > if alarmtimer_suspend() tries to set an alarm for more than 24 hours > > > in the future. > > > > > > Try to set the real-time alarm to just below 24 hours if setting it to > > > a larger value fails to work around the problem. While not perfect, it > > > is better than just failing the call. A similar workaround is already > > > implemented in the rtc-tps6586x driver. > > > > I'm not super convinced this is actually better than failing the call > > because your are implementing policy in the driver which is bad from a > > user point of view. It would be way better to return -ERANGE and let > > userspace select a better alarm time. > > There is no way to signal user space. alarmtimer_suspend() is doing this > on behalf of CLOCK_BOOTTIME_ALARM or CLOCK_REALTIME_ALARM timers, which > were set long ago. We could possibly figure out some way to change the > clock API to signal some kind of error back to the timer handlers, but > that seems destined to be overly complex and not really help anyone > (stable ABI, etc.). The right answer for alarmtimer is to just wake up a > little early, IMO. (And failing alarmtimer_suspend() is Bad.) But it is not the right answer from the RTC subsystem point of view because there are many uses cases were you don't want to forcefully wake up earlier or you are going to unnecessarily deplete a battery for example or you may be able to select another RTC device which can wake you later on. > I think Guenter considered some alternative change to teach > drivers/rtc/* and alarmtimer_suspend() to agree on an error code > (ERANGE? or EDOM?) to do some automatic backoff there. But given the > existing example (rtc-tps6586x) and the inconsistent use of error codes The existing example predates actual maintenance of the subsystem. You can't complain about inconsistent use of error codes (which I believe has been cut down) and at the same time introduce inconsistent behaviour. > in drivers/rtc/, this seemed just as good of an option to me. > > But if we want to shave more yaks, then we'll have a more complex / > riskier patch set and a harder time backporting the fix. That's OK too. > The issue with the current patch is that it forbids going for a better solution because you will then take for granted that this driver can't ever fail. -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com