Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3543381ybf; Tue, 3 Mar 2020 07:51:23 -0800 (PST) X-Google-Smtp-Source: ADFU+vsTM45eNGuoS6dDQBfrrqkT+8ZcUbgzsMz4zzIK19Wb6NUo9G39+aphlmhZ1iVjV7FH/VI+ X-Received: by 2002:a05:6808:84:: with SMTP id s4mr2928047oic.147.1583250682917; Tue, 03 Mar 2020 07:51:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583250682; cv=none; d=google.com; s=arc-20160816; b=dkq0XW17lTz1KX7ypLZSrLIN0jEkqmNXZUTSE71nOHpvR6+yBQWRp2vzA4Ocw+SYfa ByaLcSmcT5YbzjjxxCHg9cN3SpEhoQZ8DUFjQqhtX0dMI5jswyN/cPZumKiDQBZAA1ip U5fh8m4vCKDQUlQ7h383tSUODxdIJnIjhhwz8dVWswaBopGQlylrBS9LFrlH8vhwxX1Y 8lcK4YUrIMEwTeo5m6C3Pqr7bZYbOrEJsZImCNdLwm2SHrZSpe0e1tgw4E4ZnttVVdFk e20YbEdaSw59PwJ/sKeP6MzMNfnH6YJugmdMdPAUyscMTkpgAzq/n69oHHFfr1JvQ3hb Vglg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=SXFxMssbvjSGPYGurA6CbrNZwicGCEZnDohE7MVcFUk=; b=CysDv/2zINDACKLHhPVNllxi+Apcqqopy8mriiCOhCF519InNobVVA5/wOyCt712dx J4jdcXZEjdWehqqM16HmbIkFckCf6RFb3wqr/FxZ+DBIeBuF7ER5GARO9JaEQHe5ZWEw whWRIEhBmzxkEB0JJDIJcHfqvEZbs7EMf8ozVsPL/135m7d0YQxVAmGGuvKP5M2eX3c2 5kFKmoznEYgGqs5EjT4sSXzvzoU0xv44ocHFoDkTrPEBNuytu+SyvHf3LEkpj05MO8de aaCzRPudmdm25lbCdAWXCNy3pnVftOZ3j+jacDF13n0UIZtm/XNF31MB9TXFejBt9J4s CuSw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h136si2674415oib.141.2020.03.03.07.51.10; Tue, 03 Mar 2020 07:51:22 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729909AbgCCPYZ (ORCPT + 99 others); Tue, 3 Mar 2020 10:24:25 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:44776 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729898AbgCCPYZ (ORCPT ); Tue, 3 Mar 2020 10:24:25 -0500 Received: from [5.158.153.55] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j99Oy-0000QR-QO; Tue, 03 Mar 2020 16:24:08 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 432AF104098; Tue, 3 Mar 2020 16:24:03 +0100 (CET) From: Thomas Gleixner To: Linus Walleij , Bartosz Golaszewski , Jonathan Cameron Cc: "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 In-Reply-To: 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> Date: Tue, 03 Mar 2020 16:24:03 +0100 Message-ID: <87wo81cvho.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :) > 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. Thanks, tglx