Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp3626734lfb; Mon, 9 May 2022 00:17:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG5X8/46uQEn4//bHvlS+rKpjxZDYRp3/pLLokVZojaNcOx2TE/VfWR0RWHG9czxQ1A7Ns X-Received: by 2002:a17:902:d145:b0:15e:d1a8:7f33 with SMTP id t5-20020a170902d14500b0015ed1a87f33mr15184349plt.66.1652080634606; Mon, 09 May 2022 00:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652080634; cv=none; d=google.com; s=arc-20160816; b=Q4iHp/NBCnTayaRuGl7ZHLnzP02IShuQm/Ho1Z7xCBDVj3D6ES0BX57ZghQaGZvG84 YroKW4gzsFIte5c40kodeB+/bAdz/IEcLJqDfCR8IboBqq6QzrPadBbSPSoJirniyAeH M7r9PxA1PaVW6dcfFTPtoFgP9om1UZS4chDfffHgsKGYzm0EZTsgyvTHudWAtOxPYZD4 ZT8Yc7EJ0VkVlB4jTF9PnIlt5rLQNTkHreP3On+gy7s4FwFsQaKTDTbP7TKZ+2zs2YAV akyWG+YKfdktLJXhhW9HQGm0965vqko4BmoCwxJKRd7Y9AezYbNwsbbhTYeiskIIZkWo 4wGQ== 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:date:cc:to:from:subject:message-id :dkim-signature; bh=U5WbZH+WeKI2vj4A+qmUfG9NrJtfArR7c1yTS1Ik7Og=; b=bdBqDs7dILlHVEj3M05UcAH2u4mcnGTGinDT3ueYXM5doEnPQHl+ZJX/zSxWHhLdIh AB1s5UiP9XzMpw4EUnVlOP2pIdkYK9Wi+Pm1TXXnTkItWok4Ax5ZkLnm8YhbFbCDBjTI fp0uxLivRHmFQyTFvZd78t0P3UB0KXRkjHN5a2dcplADrc3MJPOK2C+SZciAUeKDI47H YJWJV0liIOjzpepsipuNKWm8eYynvwZVau6v51voFFSxRtNDSFUJBPFoXdJd1SpOXRGX ApeTwD3BY45DgqPmpTiuAufW7SHdXOt45fnRgIF7XSPI/8yti+xZZ9dsE/IEWQWWCwSA zVCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aUq+IhcV; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g16-20020a056a000b9000b004f784a59a59si17900818pfj.0.2022.05.09.00.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 00:17:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aUq+IhcV; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 932711AB79C; Mon, 9 May 2022 00:13:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383467AbiEGHpH (ORCPT + 69 others); Sat, 7 May 2022 03:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235270AbiEGHpF (ORCPT ); Sat, 7 May 2022 03:45:05 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65AAD51E75; Sat, 7 May 2022 00:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651909280; x=1683445280; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=B/wLy1WHMXvMEi+PTF4fxeilLSxaSgG5N6MO4b5BZN8=; b=aUq+IhcVVn1glTJf95LHC27o8w6a8JTrwEF6n+qq5zI8SovZzYHVSFXu 8l3L5ZMuWY76sDxxaf9RIVkrrv5w5YMIPTB5E3Fx1fN3H9m4bVKoaAKv7 cwFH1cBQcmFMGDsVi4DzbNJfvOlyNY4KtongLav/TXeLyTLGbun1cxORQ W8PRHYT/b1cRD5GmqogM+KdcV6pmnbklweaheXgxZX8EanKsi4YpuxaEO RW57nkyrxF733Svmu9g6szqcdz8OQw4/wH/KDayD+7HS5/MxAII+9btK8 5hAhf7JSHYPhg0NPp5zbbk45qqugDbLoExG/U8aACY9xER9dZmmobz43E w==; X-IronPort-AV: E=McAfee;i="6400,9594,10339"; a="267512235" X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="267512235" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 00:41:20 -0700 X-IronPort-AV: E=Sophos;i="5.91,206,1647327600"; d="scan'208";a="586409140" Received: from xinmeigo-mobl.ccr.corp.intel.com ([10.255.29.106]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2022 00:41:16 -0700 Message-ID: <831d118f3eaa6abde991ea3c9f55b6befa956f15.camel@intel.com> Subject: Re: [PATCH 7/7] rtc: cmos: Add suspend/resume endurance testing hook From: Zhang Rui To: Alexandre Belloni Cc: rjw@rjwysocki.net, kvalo@kernel.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-wireless@vger.kernel.org, daniel.lezcano@linaro.org, merez@codeaurora.org, mat.jonczyk@o2.pl, sumeet.r.pawnikar@intel.com, len.brown@intel.com Date: Sat, 07 May 2022 15:41:13 +0800 In-Reply-To: References: <20220505015814.3727692-1-rui.zhang@intel.com> <20220505015814.3727692-8-rui.zhang@intel.com> <320773e042a538782411f4db838bdc70a1b0851b.camel@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-wireless@vger.kernel.org On Sat, 2022-05-07 at 09:31 +0200, Alexandre Belloni wrote: > On 07/05/2022 10:00:40+0800, Zhang Rui wrote: > > Hi, Alexandre, > > > > Thanks for reviewing the patch. > > > > On Fri, 2022-05-06 at 23:46 +0200, Alexandre Belloni wrote: > > > Hello, > > > > > > I assume I can ignore this patch as this seems to be only for > > > testing > > > > The main purpose of this patch is for automate testing. > > But this doesn't mean it cannot be part of upstream code, right? > > > > > I'm not even sure why this is needed as this completely breaks > > > setting > > > the alarm time. > > > > Or overrides the alarm time, :) > > > > People rely on the rtc alarm in the automated suspend stress test, > > which suspend and resume the system for over 1000 iterations. > > As I mentioned in the cover letter of this patch series, if the > > system > > suspend time varies from under 1 second to over 60 seconds, how to > > alarm the RTC before suspend? > > This feature is critical in this scenario. > > > > Plus, the current solution is transparent to people who don't > > known/use > > this "rtc_wake_override_sec" parameter. And for people who use > > this, > > they should know that the previous armed RTC alarm will be overrode > > whenever a system suspend is triggered. I can add a message when > > the > > parameter is set, if needed. > > > > It is not transparent, if I read your patch properly, this breaks > wakeup > for everyone... > > > > On 05/05/2022 09:58:14+0800, Zhang Rui wrote: > > > > +static int cmos_pm_notify(struct notifier_block *nb, unsigned > > > > long > > > > mode, void *_unused) > > > > +{ > > > > + struct cmos_rtc *cmos = container_of(nb, struct > > > > cmos_rtc, > > > > pm_nb); > > > > + struct rtc_device *rtc = cmos->rtc; > > > > + unsigned long now; > > > > + struct rtc_wkalrm alm; > > > > + > > > > + if (rtc_wake_override_sec == 0) > > > > + return NOTIFY_OK; > > > > + > > > > + switch (mode) { > > > > + case PM_SUSPEND_PREPARE: > > > > + /* > > > > + * Cancel the timer to make sure it won't fire > > > > + * before rtc is rearmed later. > > > > + */ > > > > + rtc_timer_cancel(rtc, &rtc->aie_timer); > > > > + break; > > > > + case PM_SUSPEND_LATE: > > > > + if (rtc_read_time(rtc, &alm.time)) > > > > + return NOTIFY_BAD; > > > > + > > > > + now = rtc_tm_to_time64(&alm.time); > > > > + memset(&alm, 0, sizeof(alm)); > > > > + rtc_time64_to_tm(now + rtc_wake_override_sec, > > > > &alm.time); > > > > + alm.enabled = true; > > > > + if (rtc_set_alarm(rtc, &alm)) > > > > + return NOTIFY_BAD; > > ... because if rtc_wake_override_sec is not set, this sets the alarm > to > now which is the current RTC time, ensuring the alarm will never > trigger. No. As the code below > > > > > > > > if (rtc_wake_override_sec == 0) > > > > + return NOTIFY_OK; We check for rtc_wake_override_sec at the beginning of the notifier callback. So it takes effect only if a) rtc_wake_override_sec is set, AND b) a suspend is triggered. thanks, rui