From patchwork Fri Sep 15 15:22:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 140595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1228133vqi; Fri, 15 Sep 2023 11:03:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESKOAaS6W6aRWwYU9nuix/esvzts8hAv/O6wtYlIKukBbw/5dh7ABjWkOjA7lNBtbpo/eS X-Received: by 2002:a05:6a21:47c8:b0:14c:84e6:1ab4 with SMTP id as8-20020a056a2147c800b0014c84e61ab4mr2326550pzc.33.1694801016559; Fri, 15 Sep 2023 11:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694801016; cv=none; d=google.com; s=arc-20160816; b=klMMuMJC1qZbptxuxL1dk9uUMMOz0LHA3pexnZFdm8RZ6fG8wiU+ug2QESecs0eP30 xh9UXiOGMlHP4QXer9pzwrtB6dkTUu5r/zvspC5UTV5Jac45Jwhm2GzN9ZqyrC29i3YZ WXLZQz9bJQklLmb6yzBZOLI1/sZSs1NwrVe089rq+9rQPjRcQFINs3uPnd3IWhIbySY2 9vb8kKyPW+A43h4x8qk57ZZ9NLBpeR/R8JkyyMSmRTx5W8DNVwzMRRlbXCEmvMhPTvR8 mAt73PtDUjpNaZX3+5bjpJq51otheHN4thGO3QjHPv+x/nKB+tUfUcgnhcd/IW67s5v+ iCxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=ZAtiGPafozJ8Gn4LX27neNus+M3+xNnQ73f695UuZME=; fh=S9RdpwfKQ5rXEWn1rrM8k4mwVEdXu40CNytibZpR15k=; b=MDyF97s+nPACp8kgZpSqGOQG12H086auH4iruW33Zn6YJQHdyyET7WXzEnVc/7F8FI 49ajzNFWAjUViWkl/37FErltFM40b/xH1piX4gbf2tVozR9KF9HRsId6S86z8cnsxg+R nb0kRNWmnpE110wItYmnial1oJhaNb6j5eompI609tWvfgA2zNYJTpX4RlM+mPGw7S/t drL7PSTWWHPAgiCMTl2Rh7Ji9dQEYA5cn7hBmqBOr9z5zbQyayHvqLZoyiY1LjbU5Bmh WA0pxni7YmI4h1/izzRjCiFT+HX6WZQwdNKxp+oAyiwwkWLd8p05jtSXd316FppD+NYr D3Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ajnQ1nhk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id m7-20020a632607000000b00563e15edb8fsi3593007pgm.544.2023.09.15.11.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 11:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ajnQ1nhk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7DD28801B800; Fri, 15 Sep 2023 08:23:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236077AbjIOPWy (ORCPT + 31 others); Fri, 15 Sep 2023 11:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236057AbjIOPWw (ORCPT ); Fri, 15 Sep 2023 11:22:52 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23380E6D; Fri, 15 Sep 2023 08:22:45 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-34df2a961a0so7823285ab.2; Fri, 15 Sep 2023 08:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694791364; x=1695396164; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=ZAtiGPafozJ8Gn4LX27neNus+M3+xNnQ73f695UuZME=; b=ajnQ1nhkcm0HF8oqx83ps/MEr7N1R/VpBouAEz7GCKA/06uPYQpKxyMaVEvG/yCWjC 508LqvzkbIojmjpRMDMJw5wndiM1g39r74SO60kQnbfQW5KjM0d+W7Pcfc/vp5iwnjWk BsXBcu75aHEOkjtKpTwHGDyNQRxmV1LqAd2K6chmGix9MROtkBFMGbqKIgtAG7XwlEqw DXZrgfpx5nolRS0utcjMbt5Tl7bl8aIEhHpvwBnUh7UXx+Iap9hamXEw9SxZOktN9CMT OXrgsSlFNGsv6vGDxL6YpRRQ2faOIcpB2jL5tZRODZEGCRpKyngXuCSEgH10yh+x8laQ KPEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694791364; x=1695396164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZAtiGPafozJ8Gn4LX27neNus+M3+xNnQ73f695UuZME=; b=KOTBiLdpWVZD0jHs7viN96ajlwi74rI1Cfex5jgoFglTDvH9Xh4PsMgOuOX2AjF1je IhsaJ1g/T4XUXZnZMmlTeZyXYzzViagakOsBhv0KNHup6QaHRZhXEt7tA6Et9wsXqzyu 9pJ6HHhryT/Lr9o1Q2Cl9jhvrfIGGhEUugFxU349IQNBZelBZ75v6L4XdTGPkclc+JKg qCXtk3q8KTQCnsLrwgXx7FeSMh3MGI9nlViwBYqqqjxHtoEl2ZMrkV9IWUtk63PJMXvd +lcsPP7IVY+wSfk/Chh1TK1WLBXARW7kj7DQkTtPIQQry0sRuOSyqGyQKJf5Jt+X/JF9 ZOcA== X-Gm-Message-State: AOJu0Yzaw7M+Zi0ZJXnmbAbfKZ/pFu67nufCSfTNn3oVZRp8pQmoxN/n V8UYxDrcMip0e/gWBtl3Mso= X-Received: by 2002:a05:6e02:1546:b0:34f:6f44:aec4 with SMTP id j6-20020a056e02154600b0034f6f44aec4mr2940164ilu.8.1694791364381; Fri, 15 Sep 2023 08:22:44 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id s27-20020a02cc9b000000b0043321a50c29sm1085612jap.93.2023.09.15.08.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:22:44 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Alexandre Belloni , John Stultz Cc: Alessandro Zummo , Thomas Gleixner , Stephen Boyd , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Brian Norris , Guenter Roeck Subject: [PATCH v2 1/2] rtc: Add API function to return alarm time bound by rtc limit Date: Fri, 15 Sep 2023 08:22:37 -0700 Message-Id: <20230915152238.1144706-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915152238.1144706-1-linux@roeck-us.net> References: <20230915152238.1144706-1-linux@roeck-us.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:23:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777127670771936348 X-GMAIL-MSGID: 1777127670771936348 Add rtc_bound_alarmtime() to return the requested alarm timeout bound by the maxmum alarm timeout that is supported by a given rtc. Signed-off-by: Guenter Roeck --- v2: Added patch to provide API function include/linux/rtc.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 4c0bcbeb1f00..5f8e438a0312 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -225,6 +225,23 @@ static inline bool is_leap_year(unsigned int year) return (!(year % 4) && (year % 100)) || !(year % 400); } +/** + * rtc_bound_alarmtime() - Return alarm time bound by rtc limit + * @rtc: Pointer to rtc device structure + * @requested: Requested alarm timeout + * + * Return: Alarm timeout bound by maximum alarm time supported by rtc. + */ +static inline ktime_t rtc_bound_alarmtime(struct rtc_device *rtc, + ktime_t requested) +{ + if (rtc->alarm_offset_max && + rtc->alarm_offset_max * MSEC_PER_SEC < ktime_to_ms(requested)) + return ms_to_ktime(rtc->alarm_offset_max * MSEC_PER_SEC); + + return requested; +} + #define devm_rtc_register_device(device) \ __devm_rtc_register_device(THIS_MODULE, device) From patchwork Fri Sep 15 15:22:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 140822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1400742vqi; Fri, 15 Sep 2023 17:26:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUp8zFtGorL+m9HobGsLKnTLszQT4DMIUUNrqvcSWqIzVj30IXhh+eZrkBjtvFBHwGfYwl X-Received: by 2002:a17:902:ce89:b0:1bf:7aeb:c488 with SMTP id f9-20020a170902ce8900b001bf7aebc488mr4341486plg.29.1694824010352; Fri, 15 Sep 2023 17:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694824010; cv=none; d=google.com; s=arc-20160816; b=kxLaLXWQGddiyIK73GtoVA9S9H5YS2faW9eC/jFYiltMcuAJPQHx9QJXjD9jbys9YX ls9m3QSzy3EaWz0pGiULl+KGjq/zR1iC53rImXSbVtuIYWAMP+KKHGmLiRzdiaT8mfPM g6SOy0/oNDFAybxw8aZPJiTNCfWAmErmSH2+pgLrkx28IL7qQDzXwYo41nua0UokbIBo ofU4Fis2JudIQlXu45tr98lP1so57FLI2n0I95OSdm8NWqRCnsR3c+TrjYFysw7wiRJT 0wG6KRWiIbKZLdh9pHpfCVi75HxwLHldM6vutlFFNZZNBDv0/9npn8D9Wq6ALohEe8J7 hsUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=CS9ubDurv0r2cFDb63lHGeCIPsttTPXuX+wI81MOIt8=; fh=S9RdpwfKQ5rXEWn1rrM8k4mwVEdXu40CNytibZpR15k=; b=KdwqnwDH0rWnPQOXOTe/XE3iMe+Ixk1+KJFSF3Gwb6xWMadDHOxW7L3KBVOUkU0xPN 5MRaoOD+H01U2rjkhXIcS6Ny5sZxT0yovBzNi4kyEYMwmNdfZv7ElRqwmWt2fHhULitX 1ji6m7xfMsxjV2Qk40RF7Z5xjej5SLxO64M1cQ7RNuGhe8UDz7blcRvbVCJJINIuuszu LpBM+Yn/nWVF1EuE7DhUgRD+4qrbqQcvfweo2G3u+6S8RR80Wl92mt+bod5wCVTDrZPa FpyBI06Xlsni5ufvKFkyoFiCLVBEwpIk8I2B7SrJe+Qjw7VktKi+7cyZp+0r1zbQSJmm 3wew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bXey5s/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id b2-20020a170902d40200b001bb792749a2si3960264ple.146.2023.09.15.17.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:26:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bXey5s/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 09259801BCA5; Fri, 15 Sep 2023 08:23:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236040AbjIOPXR (ORCPT + 31 others); Fri, 15 Sep 2023 11:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236075AbjIOPWw (ORCPT ); Fri, 15 Sep 2023 11:22:52 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C12B2170E; Fri, 15 Sep 2023 08:22:46 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-34961362f67so8606855ab.0; Fri, 15 Sep 2023 08:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694791366; x=1695396166; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=CS9ubDurv0r2cFDb63lHGeCIPsttTPXuX+wI81MOIt8=; b=bXey5s/Nso8JNKxFYxU4I8UtXopSoWBEJdpmdLUjqGwUk4PPTX0RNF7FErLFAlJZLP e4PKYPCFY73MZ6YWSUDs1hhKFkG6kkApQhb3k80RnJi9Cnduo/4cA+ceJ9G2hB5jbc0y u969XjajlWwOr+3PzD4S6ZIXncFZxIk9GQ1YdT6Ys/KUwq3DPh/UfLkCpGRwBR51LugN QUyMffoEFyDiHZkNzY+CfdLc5PEeKDR/ZMbrdiMauslYqEejN6Rd3ChQdG3LsD9yxK0u 15/zPQ0V9PiRkWEewrwS5wROygYqHHhAkNvDvmrt403gWn7ilI+KpmUknXPmgHp6RXmC 0qtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694791366; x=1695396166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CS9ubDurv0r2cFDb63lHGeCIPsttTPXuX+wI81MOIt8=; b=ic3z/mn9a9F3joIN4VB+WM6Bp1zJY9nwhb3g7tBH9Mfr2zfyUFswH9VBNcqFhSKLVB Y17+qutkz20SsVElI6t9CHW+dThb2odUBrGiGlg1re2CFXkvuC56xvicA3w276Ngy7qz yaMMepaqRqNSvS6T3CnS3deuze9LW503mUB1H8TfkslekTNfpbnjGEoJDHOuTpZAVgRA qQd40dGsyQ8mmPGjKA9rG0DRPIM43xNVHRL/1K/L5TcLYnsKvfTW15ItJt7EJe7Yr2Np LCLp4z83gkPMDrudnI6Ale9ezkxQvFNkudH5PKdrMF1XKwZa9BVETTde7MQo/mXuhFNU jW1w== X-Gm-Message-State: AOJu0YyNCd+kfS0TGVJgTve74Uu3VOjdApC3F3FhJi9JtetQAwtNls3M WZ3KsdfQJEU76PDGGyEmz0E= X-Received: by 2002:a05:6e02:1b04:b0:348:c606:bd1a with SMTP id i4-20020a056e021b0400b00348c606bd1amr2338515ilv.15.1694791366105; Fri, 15 Sep 2023 08:22:46 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h1-20020a92d841000000b0034f13bcaf9asm1170309ilq.22.2023.09.15.08.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 08:22:45 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Alexandre Belloni , John Stultz Cc: Alessandro Zummo , Thomas Gleixner , Stephen Boyd , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Brian Norris , Guenter Roeck Subject: [PATCH 2/2] rtc: alarmtimer: Use maximum alarm time offset Date: Fri, 15 Sep 2023 08:22:38 -0700 Message-Id: <20230915152238.1144706-3-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230915152238.1144706-1-linux@roeck-us.net> References: <20230915152238.1144706-1-linux@roeck-us.net> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 08:23:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777122673114346531 X-GMAIL-MSGID: 1777151781637153200 Some userspace applications use timerfd_create() to request wakeups after a long period of time. For example, a backup application may request a wakeup once per week. This is perfectly fine as long as the system does not try to suspend. However, if the system tries to suspend and the system's RTC does not support the required alarm timeout, the suspend operation will fail with an error such as rtc_cmos 00:01: Alarms can be up to one day in the future PM: dpm_run_callback(): platform_pm_suspend+0x0/0x4a returns -22 alarmtimer alarmtimer.4.auto: platform_pm_suspend+0x0/0x4a returned -22 after 117 usecs PM: Device alarmtimer.4.auto failed to suspend: error -22 This results in a refusal to suspend the system, causing substantial battery drain on affected systems. To fix the problem, use the maximum alarm time offset as reported by rtc drivers to set the maximum alarm time. While this may result in early wakeups from suspend, it is still much better than not suspending at all. This patch standardizes system behavior if the requested alarm timeout is larger than the alarm timeout supported by the rtc chip. Currently, in this situation, the rtc driver will do one of the following. - It may return an error. - It may limit the alarm timeout to the maximum supported by the rtc chip. - It may mask the timeout by the maximum alarm timeout supported by the RTC chip (i.e. a requested timeout of 1 day + 1 minute may result in a 1 minute timeout). With this patch in place, if the rtc driver reports the maximum alarm timeout supported by the rtc chip, the system will always limit the alarm timeout to the maximum supported by the rtc chip. Cc: Brian Norris Signed-off-by: Guenter Roeck --- v2: Use API function instead of accessing rtc core internals directly. Modify comment in code per feedback received. kernel/time/alarmtimer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 8d9f13d847f0..0dc68372efd0 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -290,6 +290,17 @@ static int alarmtimer_suspend(struct device *dev) rtc_timer_cancel(rtc, &rtctimer); rtc_read_time(rtc, &tm); now = rtc_tm_to_ktime(tm); + + /* + * If the RTC alarm timer only supports a limited time offset, set the + * alarm time to the maximum supported value. + * The system may wake up earlier (possibly much earlier) than expected + * when the alarmtimer runs. This is the best the kernel can do if + * the alarmtimer exceeds the time that the rtc device can be programmed + * for. + */ + min = rtc_bound_alarmtime(rtc, min); + now = ktime_add(now, min); /* Set alarm, if in the past reject suspend briefly to handle */