Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp670071rdb; Fri, 6 Oct 2023 15:25:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOgL4a0DP6lo5OaDJbiJtyxhSeMGyfN4XCBF8hoA43c2dif34oxqyV2cwYRXP/8fG2OnNV X-Received: by 2002:a05:6a20:918d:b0:16b:9b5d:155d with SMTP id v13-20020a056a20918d00b0016b9b5d155dmr2820778pzd.30.1696631105441; Fri, 06 Oct 2023 15:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696631105; cv=none; d=google.com; s=arc-20160816; b=SBYt0E7w19t8uW04PSm0PGfz3/JjtViNEGf5MukE6lhXb0Kdv/Z75RZWFwoVxDuIHH 9+eHPGapHTcvbKucm77OXvUlU+pre5yeMcE6EWuYiXCt/BDLK1QV+uood7LgT36ZVVrr r6VQLFfb+7dhvyahFCgdsdLZ752lAOnEScuhI33cVdjr0v1BVy8zBHOCOs33/ftr+9f1 6WR3ihTCerbwMMcL2qGg0B5Ze6CiMV91UbEEe9K8JUFBcmYruwjrDmDmNsGKHTdsG5ln xrRd2hq9kk3ehoVIUaO6R2wS3VAmSOC61dxBhJM1CQX68Z/n9tymNQedZIhCwTYypa+7 QkyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ah+07OPEhZZsuPf2759AKk30s58BSNVoBkJCXV+g2rA=; fh=nPqPCKNGXTu12VgKxItg8J1QciMp/+T7opsFSGA9KRg=; b=B+f+JoCjpMWiNUMyJgOfSUaBKRVaJYkzyeTxSRfftSTxqO0qj9eQf26NTyq7to9vqq aiSXcsN9EWrZoYeWtu3NEQncnMUqP9bC6A7w1kEn/sTW5hY2b9MuUHhORLKw6HAmcgK1 C8EcZiaedtBtJIs6xKDhjSBfXOfjARUbjQoSXWJlqmt4jUVaGny1wNLZTgC2ZqI60lxk v9aEbjhANkcdzMv3Clo6dHLF64tn3Su50luGN862XQBLWyd53d5x+8sK/21D//0/YX3N I1JhnGU+EX5vP0zLoJPhk0VXy5AgyIt9/C80u7e6JPuDedmNI5KN6+4/BKe24OEnJWY1 tfXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="y3SKA/dh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m17-20020a170902c45100b001c3f6dbe2bdsi1046130plm.105.2023.10.06.15.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 15:25:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="y3SKA/dh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 97A30801D142; Fri, 6 Oct 2023 15:25:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233722AbjJFWZB (ORCPT + 99 others); Fri, 6 Oct 2023 18:25:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233690AbjJFWZA (ORCPT ); Fri, 6 Oct 2023 18:25:00 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 035F1BD for ; Fri, 6 Oct 2023 15:24:58 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40662119cd0so10875e9.1 for ; Fri, 06 Oct 2023 15:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696631096; x=1697235896; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ah+07OPEhZZsuPf2759AKk30s58BSNVoBkJCXV+g2rA=; b=y3SKA/dh7RqieCZ3ebwPxW4EOi0ttcUfOJDXkkcNbj9i5LvZYIgpJUu4nmjMn3jjvk b0ep1w1BCNhwVIB3q6iyPuvKb/ph3f2kFi+4/0BaqgDd9dBrnhPomCeuWFud8VxS323s GMXBhu+5lKAaGGwTsTgXz59voyDsRUieNCmxIh1lOl0Ydfix9g+Uu676iLqoYspSrxCY RtN3C0ENzUuQHCkV4bJUu0TkIsZUzv4wR5t382bSOEE1+xtc+hICSLttGg/tKqYAPKYK EzGnjznH/K4xSCfgTx5bk3Z8XhJsdQRzw2fmzy/Y6zcwkyfodVXWCIh7fW5b1M5YrnKk x7SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696631096; x=1697235896; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ah+07OPEhZZsuPf2759AKk30s58BSNVoBkJCXV+g2rA=; b=py90wxM9luW5JZDVq6jzZOJeDV8bs4eo8wPzHLF2GPCvP03REl8cKGLBUTw6z4EixH N1TanysmhYN5FYwpryA21eXSJW0eUsaUFq1QygY5zp6hmOjqmnZNkZ8RtRtFsEg17Xnk emj6X9zy8FLeqwnD1eVCIcYhXTcvkYVQsqmOYmVVtpBVF53/Xk2vJ+ZSo0TLlTQ+ABCu Y+5LMgK3/SuMqT6pPengoBcFf28r4kYTUsnHJ68DJigNz4/VKqMRLT0N6wpFxjGXPyg6 E4gEeNIpWnfI7uwkCWoKgVToZMxRx26AH1WlMqpWFfZ0QE8/jCtOn7wjNAAStjyNx5m6 QJxw== X-Gm-Message-State: AOJu0YxPkVfp04mOXzndqA8hbiwc6ZBnm47Wapol8BUskUHfTMrZGU0G VzqXzwnrcynJTiJ+Kgsm70dfVTjGDEqaZVo+vWMf X-Received: by 2002:a05:600c:1e25:b0:406:5779:181d with SMTP id ay37-20020a05600c1e2500b004065779181dmr221063wmb.2.1696631096239; Fri, 06 Oct 2023 15:24:56 -0700 (PDT) MIME-Version: 1.0 References: <20231003041701.1745953-1-maheshb@google.com> In-Reply-To: <20231003041701.1745953-1-maheshb@google.com> From: John Stultz Date: Fri, 6 Oct 2023 15:24:44 -0700 Message-ID: Subject: Re: [PATCHv2 next 1/3] ptp: add ptp_gettimex64any() support To: Mahesh Bandewar Cc: Netdev , Linux , David Miller , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Jonathan Corbet , Don Hatchett , Yuliang Li , Mahesh Bandewar , Richard Cochran Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 15:25:04 -0700 (PDT) On Mon, Oct 2, 2023 at 9:17=E2=80=AFPM Mahesh Bandewar = wrote: > > add support for TS sandwich of the user preferred timebase. The options > supported are PTP_TS_REAL (CLOCK_REALTIME), PTP_TS_MONO (CLOCK_MONOTONIC)= , > and PTP_TS_RAW (CLOCK_MONOTONIC_RAW) > > Option of PTP_TS_REAL is equivalent of using ptp_gettimex64(). > > Signed-off-by: Mahesh Bandewar > CC: Richard Cochran > CC: "David S. Miller" > CC: netdev@vger.kernel.org > --- > include/linux/ptp_clock_kernel.h | 51 ++++++++++++++++++++++++++++++++ > include/uapi/linux/ptp_clock.h | 7 +++++ > 2 files changed, 58 insertions(+) Hey Mahesh, Thanks for sending this out! I've got a few thoughts below. > diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_k= ernel.h > index 1ef4e0f9bd2a..fd7be98e7bba 100644 > --- a/include/linux/ptp_clock_kernel.h > +++ b/include/linux/ptp_clock_kernel.h > @@ -102,6 +102,15 @@ struct ptp_system_timestamp { > * reading the lowest bits of the PHC timestamp and the se= cond > * reading immediately follows that. > * > + * @gettimex64any: Reads the current time from the hardware clock and > + optionally also any of the MONO, MONO_RAW, or SYS clock= . > + * parameter ts: Holds the PHC timestamp. > + * parameter sts: If not NULL, it holds a pair of timestam= ps from > + * the clock of choice. The first reading is made right be= fore > + * reading the lowest bits of the PHC timestamp and the se= cond > + * reading immediately follows that. > + * parameter type: any one of the TS opt from ptp_timestam= p_types. > + * > * @getcrosststamp: Reads the current time from the hardware clock and > * system clock simultaneously. > * parameter cts: Contains timestamp (device,system) p= air, > @@ -180,6 +189,9 @@ struct ptp_clock_info { > int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *t= s); > int (*gettimex64)(struct ptp_clock_info *ptp, struct timespec64 *= ts, > struct ptp_system_timestamp *sts); > + int (*gettimex64any)(struct ptp_clock_info *ptp, struct timespec6= 4 *ts, > + struct ptp_system_timestamp *sts, > + enum ptp_ts_types type); > int (*getcrosststamp)(struct ptp_clock_info *ptp, > struct system_device_crosststamp *cts); > int (*settime64)(struct ptp_clock_info *p, const struct timespec6= 4 *ts); So I don't see anything in this series that wires into this hook. Did a patch go missing? Or am I maybe looking in the wrong place? > @@ -464,4 +476,43 @@ static inline void ptp_read_system_postts(struct ptp= _system_timestamp *sts) > ktime_get_real_ts64(&sts->post_ts); > } > > +static inline void ptp_read_any_prets(struct ptp_system_timestamp *sts, > + enum ptp_ts_types type) > +{ > + if (sts) { > + switch (type) { > + case PTP_TS_REAL: > + ktime_get_real_ts64(&sts->pre_ts); > + break; > + case PTP_TS_MONO: > + ktime_get_ts64(&sts->pre_ts); > + break; > + case PTP_TS_RAW: > + ktime_get_raw_ts64(&sts->pre_ts); > + break; > + default: > + break; > + } > + } > +} > + > +static inline void ptp_read_any_postts(struct ptp_system_timestamp *sts, > + enum ptp_ts_types type) > +{ > + if (sts) { > + switch (type) { > + case PTP_TS_REAL: > + ktime_get_real_ts64(&sts->post_ts); > + break; > + case PTP_TS_MONO: > + ktime_get_ts64(&sts->post_ts); > + break; > + case PTP_TS_RAW: > + ktime_get_raw_ts64(&sts->post_ts); > + break; > + default: > + break; > + } > + } > +} Similarly, I'm a little confused as to who the users of these two functions are? I don't see them in this patch series. Additionally it seems like instead of two functions, you could maybe have one ptp_read_any_ts(enum ptp_ts_types type, struct timespec64 *ts) function that the caller passes the sts->pre_ts or sts->post_ts to? And finally, I'm not sure if it makes sense, but other logic in the kernel that does similar clockid multiplexing includes timens_add_monotonic() or timens_add_boottime() (though the latter doesn't apply here) for namespace offsets. I was never excited about time namespaces (hard enough to keep one sense of time :), but there are some good reasons, and I suspect we might want to avoid cases where clock_gettime() returns potentially different values compared to this interface. thanks again! -john