Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1760070ybh; Sun, 8 Mar 2020 12:15:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu9i7JyORG63TqTLm0zfZAaG6JZ9sMAMGL5w5JFYAsLXKKktXEaifuvglGdDFavlHo1VeuZ X-Received: by 2002:aca:8d5:: with SMTP id 204mr8887684oii.141.1583694916063; Sun, 08 Mar 2020 12:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583694916; cv=none; d=google.com; s=arc-20160816; b=fZuaAPLB++QwVRxwl9yyI0sz6RhPn9/TbNfleU09+EmSOtCSe/WctYOjSFHoSazo8L N16iYuRfSqnsNs6tvI84UczzspG82T+ddmWQwFpXcmX5RReKWua7zsAH8tXJQr8N3+1T Cd02DA6/fVNt/KigAyzyo3OMH00PWTdRaBCClOygEkHoPvMBOS6Rp5NBdn0TxLa9RPCr ub/qvGafgPp/8Acy4fnB4kTS3dYQVx+xHaaCpeYv87bLo7a0KI3tlLWBCSKn4WYsqCkF Rc0mqMbjW+ZVAfzElrJkynmy+qxzu4hyjHrZ9ldPm6wtYn93fOLFRvZeXNSU1wl8lfci /nlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=egmFFsoWunoJ+wguyatT8OnHTmD4cOfUrB8s3esqyag=; b=LStiji2wV7DSfoa+5WmICpW2nzmuDFOL/B61YtvdDS3UqOFomaByfHQMckwYnrQT+5 tSkbxGJVBHXNJojwc5P8WnlVt9K+7PFN5Em3dkcru0rDDsP1jarT4RJFivGArsJeCmde JCkCPFnORRcTPYOH27xRyovZNX8iiVSGszgZVjVv3mFyXeLeYBFI4K8wVvuRkpoACSEu 0nYLAxcutxKonTDU2iGvAVG2ZMWQOd9xmScGGJr635iVCeBbQjD1d9xgZzG9Pgpi08/e 6qatK5m/xIOY4r5yCd1mnYBfXR/nc80IptvekCxu+9PG9gv2WST3QAKkqRmMS4u2FZiX uFxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KybbOW2y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q124si3247852oig.228.2020.03.08.12.15.03; Sun, 08 Mar 2020 12:15:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KybbOW2y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbgCHTOr (ORCPT + 99 others); Sun, 8 Mar 2020 15:14:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:35314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbgCHTOr (ORCPT ); Sun, 8 Mar 2020 15:14:47 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9029B206D5; Sun, 8 Mar 2020 19:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583694886; bh=9qdy5RIOWebOniyIfKswarc6hNqqoEAjbTJFvBPRDGA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KybbOW2yu4lzLxdriSYezxxCBz0EqEKTL3kseV827LvPmiJ5nwUwFZCFTJRQGq8Px LvSox0dvlkW4utxfuXjg5IFU/S4qdj4chiD4gteFzVEPhSc9uOZSQe3dlC9j4v8Jle 1ai+BgShmOlsT1kZY2WW0UPvDlKGbdyBYQbeZFhs= Date: Sun, 8 Mar 2020 19:14:41 +0000 From: Jonathan Cameron To: Thomas Gleixner Cc: Linus Walleij , Bartosz Golaszewski , "Christopher S. Hall" , netdev , "linux-kernel\@vger.kernel.org" , "H. Peter Anvin" , Ingo Molnar , "maintainer\:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , jacob.e.keller@intel.com, Richard Cochran , "David S. Miller" , Sean V Kelley Subject: Re: [Intel PMC TGPIO Driver 0/5] Add support for Intel PMC Time GPIO Driver with PHC interface changes to support additional H/W Features Message-ID: <20200308191441.1eed786e@archlinux> In-Reply-To: <87wo81cvho.fsf@nanos.tec.linutronix.de> References: <20191211214852.26317-1-christopher.s.hall@intel.com> <87eevf4hnq.fsf@nanos.tec.linutronix.de> <20200224224059.GC1508@skl-build> <87mu95ne3q.fsf@nanos.tec.linutronix.de> <87wo81cvho.fsf@nanos.tec.linutronix.de> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 03 Mar 2020 16:24:03 +0100 Thomas Gleixner wrote: > Linus Walleij writes: > > On Thu, Feb 27, 2020 at 12:06 AM Thomas Gleixner wrote: > >> "Christopher S. Hall" writes: > > IIO has a config file in sysfs that lets them select the source of the > > timestamp like so (drivers/iio/industrialio-core.c): > > > > s64 iio_get_time_ns(const struct iio_dev *indio_dev) > > { > > struct timespec64 tp; > > > > switch (iio_device_get_clock(indio_dev)) { > > case CLOCK_REALTIME: > > return ktime_get_real_ns(); > > case CLOCK_MONOTONIC: > > return ktime_get_ns(); > > case CLOCK_MONOTONIC_RAW: > > return ktime_get_raw_ns(); > > case CLOCK_REALTIME_COARSE: > > return ktime_to_ns(ktime_get_coarse_real()); > > case CLOCK_MONOTONIC_COARSE: > > ktime_get_coarse_ts64(&tp); > > return timespec64_to_ns(&tp); > > case CLOCK_BOOTTIME: > > return ktime_get_boottime_ns(); > > case CLOCK_TAI: > > return ktime_get_clocktai_ns(); > > default: > > BUG(); > > } > > } > > That's a nice example of overengineering :) Yeah. There was some ugly history behind that including some 'ancient' stupidity from me :( I certainly don't recommend anyone copies it. We may have overcompensated for having an odd default by allowing lots of other odd choices. > > > After discussion with Arnd we concluded the only timestamp that > > makes sense is ktime_get_ns(). So in GPIO we just use that, all the > > userspace I can think of certainly prefers monotonic time. > > (If tglx does not agree with that I stand corrected to whatever > > he says, I suppose.) > > In general, CLOCK_MONOTONIC is what makes most sense. > > The only other interesting clock which makes sense from an application > POV is CLOCK_TAI which is becoming more popular in terms of network wide > time coordination and TSN. > > CLOCK_REALTIME is a pain to deal with due to leap seconds, daylight > savings etc. > > > Anyway in GPIO we could also make it configurable for users who > > know what they are doing. > > > > HW timestamps would be something more elaborate and > > nice CLOCK_HW_SPECIFIC or so. Some of the IIO sensors also > > have that, we just don't expose it as of now. > > HW timestamps are just more accurate than the software timestamps which > we have now and from a portability and interface POV they should just be > converted converted / mapped to clock MONOTONIC or clock TAI. So your > existing interface (maybe extended to TAI in the future) is just > working, but more accurate. > > Exposing the HW timestamp itself based on some random and potentially > unknown clock might still be useful for some specialized applications, > but that want's to be through a distinct interface so there is no chance > to confuse it with something generally useful. Agreed, though it would be nice to actually have some hardware that supports sane synchronization between a hardware timestamp and sensible clocks in the system. In IIO we have some nasty filtering in some drivers to attempt to align hardware timestamps and deal with jitter in interrupt handling. Good luck (or maybe you do have a rare sane system!) Jonathan > > Thanks, > > tglx