Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1170916pxu; Wed, 2 Dec 2020 12:59:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx71H4uphP9YwvKTPdWXV4cmfQLX3mVhPZXTgaSUwSqRSwNgPnRnUmH99Vv7Iy+Sl2hw0lO X-Received: by 2002:a50:9344:: with SMTP id n4mr1800388eda.85.1606942788670; Wed, 02 Dec 2020 12:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606942788; cv=none; d=google.com; s=arc-20160816; b=oo3Nw30rDWSpGscL2fQHQ85Yi5OaA1FpFh0nnoD0UbMzO7Al7ldmV+x1cafvA2HGau xpP0QjSdtCuzjZ4jVeCfjUQaHNo7B4X5uYHcbtG0BEctHzNo6ZWhrCfkpYLT9OuTvjji oOmnbP07c+4kdEiESSrtksH8zy85qluX9JItOhPVSW+Pa4Ud6YnW3SbkiwHoi4omV0VG ftgOMWLHIwclrqHjxX06kqWKpYb8fGb6nW+/xjKFc35IZ/WYXdpCd8drCzUHQRwUhS+u wsy5BiB4R0BHGmc4VTx145OEpSEcBhB0UsL0TI1BFSPLgcZnDX+4xyJa8SfWR7iMsGCE ulCA== 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=LJ26q0n10bl+7oiAlsJxQE/h29ZkG7NqJxeeT+DRUvg=; b=Af4GU9y+7YaGaSVEBbee8vupSQxjJZl9L1u6zGJyocE9lyAYcY2ZkA1pZp8KEu2ORb B/RCUDSxciGMaAc9zTXTxniJ3ofCAM8yRLtnaggrBgEK9elfsd1pwO6VwmBKmpx+UTqv l3YEUgk7JFzoGpJFYnp+6RQQIDZTSEBO5pnxC4ZSunH/jfzK1xdBhwBWKUYvIcFqBsSK Lf5ej7HhKstCaT68aaFFvoqGagIbD9SLkSNUzPXGXU8oj42npkUp4Jqydq2PDdsgUgwg /AQnquo++vt5tKYZw6UyloYlXkHbY03H0XQytmt+ugwrI82OkVc9TCPNddy/1KfXZ0v9 a4cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=d3Ero40D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a29si676226edm.401.2020.12.02.12.59.25; Wed, 02 Dec 2020 12:59:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=d3Ero40D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725866AbgLBUzC (ORCPT + 99 others); Wed, 2 Dec 2020 15:55:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbgLBUzB (ORCPT ); Wed, 2 Dec 2020 15:55:01 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3B6C0617A6 for ; Wed, 2 Dec 2020 12:54:20 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id v11so2113779qtq.12 for ; Wed, 02 Dec 2020 12:54:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LJ26q0n10bl+7oiAlsJxQE/h29ZkG7NqJxeeT+DRUvg=; b=d3Ero40D15RLJlIIy6qIO+xEB3IrtJb9QhUFwMJG3mpVZsiPbQAVqBnr+YgeoWLGZ7 aFjjB1mjdP76e4ahLe85Orspkqyfy5R2OZSogrqj5LPIMBHytOQN0KeVFDAPl3gh2CE2 gZxvRf8epSA5wFwfbLaxG+nMZ6J3AaLbq7mHbcx0gWbway39qJsr3ndJiFykUk3keKf7 5wdme6rhMyXyfk7sajyOxAyHfSm/suyigiQRTf1sRb1e7ZJqXaJ9tUBlEGkVFh4oNV1Y bYuyPe9azu91sfPWQH6FWQ7Klsrj6R7E2/TDyZl2n27MDQAmJtP/3v9cHDAL+lwzc1RZ Hj9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LJ26q0n10bl+7oiAlsJxQE/h29ZkG7NqJxeeT+DRUvg=; b=gIDvvFyq/27XV0YinYo94dXpywEKGc5xoo4ZeLoWALaE69MlY6vKH4lkTpJyVuE6ue vBwNmqDI20dLAEo3150whRAJ1Rqb6OM/RiGP/GlwC+FEpTOi8/cprdhxirITrZqeEQtw FzU2r1a6LCUSpaTmu/7Z3Pq/9KTC0zi1bKit01loJUFKs67+qBObO/9ZbxR5mEPKqiP8 RhGbbfjXunR43MuQdKIDrXmlp+tz1oha0EXfL7FnMfln+grBrDSSbR+mij/GKgW5uuTg nx0cz3IkZUdBLNoUATj2W2iIJkOg16ylAy3fQkTAV9LsEgj6Mi9OE9ULMIwDd0wJqAK+ botQ== X-Gm-Message-State: AOAM533lrZsHvy0RNeTZLTzMAeZ1vrpcle2ONxtXUpjqDLNe/nISRlCY hEQePFNNLRZpcvBaapVY8X/oGA== X-Received: by 2002:aed:38c8:: with SMTP id k66mr4537800qte.385.1606942460006; Wed, 02 Dec 2020 12:54:20 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id u15sm2791457qkj.122.2020.12.02.12.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 12:54:19 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kkZ8k-005Chy-RC; Wed, 02 Dec 2020 16:54:18 -0400 Date: Wed, 2 Dec 2020 16:54:18 -0400 From: Jason Gunthorpe To: Thomas Gleixner Cc: Miroslav Lichvar , linux-kernel@vger.kernel.org, John Stultz , Prarit Bhargava Subject: Re: [PATCH] rtc: adapt allowed RTC update error Message-ID: <20201202205418.GN5487@ziepe.ca> References: <20201201143835.2054508-1-mlichvar@redhat.com> <20201201161224.GF5487@ziepe.ca> <20201201171420.GN1900232@localhost> <20201201173540.GH5487@ziepe.ca> <87mtywe2zu.fsf@nanos.tec.linutronix.de> <20201202162723.GJ5487@ziepe.ca> <87a6uwdnfn.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6uwdnfn.fsf@nanos.tec.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 02, 2020 at 08:21:00PM +0100, Thomas Gleixner wrote: > On Wed, Dec 02 2020 at 12:27, Jason Gunthorpe wrote: > > On Wed, Dec 02, 2020 at 02:44:53PM +0100, Thomas Gleixner wrote: > >> if (IS_ENABLED(CONFIG_GENERIC_CMOS_UPDATE) || > >> IS_ENABLED(CONFIG_RTC_SYSTOHC)) > >> - queue_delayed_work(system_power_efficient_wq, &sync_work, 0); > >> + queue_work(system_power_efficient_wq, &sync_work); > > > > As Miroslav noted, probably the right thing to do here is to reset the > > hrtimer and remove the sync_work? I think this code was to expedite an > > RTC sync when NTP fixes the clock on boot. > > This has two purposes: > > 1) Initiating the update on boot once ntp is synced. > > 2) Reinitiating the sync after ntp lost sync and the work did not > reschedule itself because it observed !ntp_synced(). > > In both cases it's highly unlikely that the write actually happens when > the work is queued because do_adjtimex() would have to be exactly around > the valid update window. Yes > So it will not write immediately. It will run through at least one > retry. Right, bascially this is scheduling a WQ to do sched_sync_hw_clock() which will only call hrtimer_start() - seems like jsut calling hrtimer_start instead of queue_work above would be equivilant > I don't think the timer should be canceled if the ntp_synced() state did > not change. Otherwise every do_adtimex() call will cancel/restart > it, which does not make sense. Lemme stare at it some more. That makes sense, being conditional on the STA_UNSYNC prior to doing any hrtimer_start seems OK? > > Also x86 needs a touch, it already has RTC lib, no idea why it also > > provides this old path too > > Because nobody had the stomach and/or cycles to touch it :) Hahaha yes.. I vaugely remember looking at this once.. Lets see: arch/x86/kernel/kvmclock.c: x86_platform.set_wallclock = kvm_set_wallclock; arch/x86/kernel/x86_init.c: x86_platform.set_wallclock = set_rtc_noop; arch/x86/xen/time.c: x86_platform.set_wallclock = xen_set_wallclock; arch/x86/xen/time.c: x86_platform.set_wallclock = xen_set_wallclock; All returns -ENODEV/EINVAL arch/x86/kernel/x86_init.c: .set_wallclock = mach_set_rtc_mmss, This is already rtclib under drivers/rtc/rtc-mc146818-lib.c I suppose the issue here is the rtclib driver only binds via PNP and very old x86 systems won't have the PNP tables? It seems doable to check for a PNP device after late init and manually create a platform_device for the RTC arch/x86/platform/intel-mid/intel_mid_vrtc.c: x86_platform.set_wallclock = vrtc_set_mmss; This is also already in rtclib under rtc-mrst.c, and this is already wired to create the rtc platform device during init So it is very close now to be able to delete all this for x86. Do you know of something I've missed? > > I wonder if the cmos path could be killed off under the dead HW > > principle? > > Unfortunately that code path is not that dead on x86. You need to fix > all the (ab)users first. :) Assuming x86 can be resolved as above, that leaves two 20 year old MIPS platforms and the PPC list from before. ARM is gone compared to last time I looked! Progress :) Thanks, Jason