Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1176506lqt; Tue, 19 Mar 2024 15:30:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXm4KW1qsNE5Hlw/MWDx2a8dj+iLd6T8YA4SWzgzEfjbD9ZOiCnFCDyhXBmb5RmL18WlEN2Y/ySds9PV2tAn7FGT4TelM1zkWtS62rItw== X-Google-Smtp-Source: AGHT+IHbHbGjv0DaEGGqW02rpYSl0Y2TUWv/B0v91n2sx1nWXMhqB/9pVipqJ4x69Fx9tV8iz8rp X-Received: by 2002:ad4:5183:0:b0:696:4488:dcd8 with SMTP id b3-20020ad45183000000b006964488dcd8mr538624qvp.29.1710887414986; Tue, 19 Mar 2024 15:30:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710887414; cv=pass; d=google.com; s=arc-20160816; b=OW0RN2S76Pk3vmzAauFfqIfAVCQqXCT+FBxySoq3w5oD3WJ1aXIwAx4d/w0raySmER B9WvE8PWm2AEIfdGcSY4wOoh5IR+ZJ0t3gYm+fjRaBoWr1iIzL5BrK8xKs0s62P1rZ8Z 7Z2kDdnlXDjv6j8G45po/2YkDN8c1NtBs0jl5q8ysF2WDJRnB78oEmba0MN3HjrL+UCl los2D7JS9qRE/jlnlyxUu83z5SzAQDvs/+QTwgpaEt0m0xxL4stVjdWK1Dxc7gRwa3h5 xn4TzSWFBqX6RVi0b8RkE9YL4PwJnTcbrPwJr7DPSTrvrO1X7K/Lir7Wit08hGE60kIs G5bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=t8EtD8zegIhUQWzA/oDS70j+Z9o9c4kykZ4EUai9up0=; fh=9pvGSGvYVh6MOIfLwyYfPKCr3n8ze8nbHveQAaEHwvo=; b=rZE/18oQ9pQn/pGGTrWug99a15El083vByi2oEVQEQ6pRM3EmVoGPz2im61qNTLgTE xVBVg76bDEVELHERNljal7zMtokZ8P9But1JvRml/AMWnywOh8bmw3KjHqHj/YGOFYvu UoZXBb2eRIqWT7oZ6iEesBZleWvs43B/6DyZ9bPFoNRUz4mgz2Xvyzktcspo6qAc5r17 q1ObyyhyYf/H66Tx19n5uiIHQ5Hd8qtYghZHy42vNiln7eCb1qsn0A1V0l6T8/jkz3Em hv1wvVE2q6PDFxfELhzzsflaZdnuXgZWfU7aMK+WmUVdHjUUQRzwNeZ8+a5IakdjWFv0 tSXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ofVfAAXS; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r14-20020a056214124e00b0068fb8db15fdsi11671339qvv.54.2024.03.19.15.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 15:30:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ofVfAAXS; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A80421C22544 for ; Tue, 19 Mar 2024 22:30:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87A605F87C; Tue, 19 Mar 2024 22:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ofVfAAXS" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0467B33CCF for ; Tue, 19 Mar 2024 22:30:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710887407; cv=none; b=Bnpz8dnm9LAIpjYeBy2RPTI+VXbmRseJYjDTsu2WPBEWaC53mY46C5ryb8Ud7K+vPSYxwDwzVi8DiHICoVZ5bDB+ChWWdXRTZ6tg8I1lBgjqE/Hk+gbBaOeMjgo3rrJ+0CeEt7xHbU1MNXWZ4cxBtQ9reWUlVEvaEVQCjgdK70k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710887407; c=relaxed/simple; bh=wtbRGprG246JSinZ1zeJ0g2NwwsbkPDYzZmmC7vbRTg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=R3fjfDW0TCXNewgd3CA+WWnxH3YLRYCS7ygN9+PP5ypsnRdeVT3h4dRBCl+ZeE9JGz/AxBoJMFIz+HanBvWpbCE1m8hovE1pWQWQjQ2V8SVXOBeNGH5u2HsoLdKqdziRNK0lO1+uoXvg7vGm88pwuLKCR3UIfn0WZlJUDu9An9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ofVfAAXS; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-413f8c8192eso38915e9.0 for ; Tue, 19 Mar 2024 15:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710887404; x=1711492204; 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=t8EtD8zegIhUQWzA/oDS70j+Z9o9c4kykZ4EUai9up0=; b=ofVfAAXSVDz8umrvv14pK2V/4/3P3kzsOjuxfKAom8Ki59bDmUAF1ZZeWjIBSUQbKQ OfXIJR+vPGDajLBH9qCmNiEbA/7RtRlba9C8M12whYQ7Q67DVEqA9GaoZs0lhuWOpVsn inK1zngi7gQ3VUaCl+YdO3Br3OP9NWCD/Hr3L3Y7i6AeaQYmq5ZHTl/gBOsxC5D8xsrA UjLIBbcUUEjz+IYZaereQMCv89gJ6b4wMcPFly4nwrKNvTVIH/+kesT7ruQbm4BCG0ON Ho93su6n6Xp9Bt+rc1w4GoRvH5It59jwEoy0Cxl4snlxWSL2R+YpWUfjti9Mx8VlOOe1 WgQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710887404; x=1711492204; 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=t8EtD8zegIhUQWzA/oDS70j+Z9o9c4kykZ4EUai9up0=; b=C06mW7ioBvwoKxXX60Ptscvyr9FxfOJ/dllg4GEaIAGnPsxJvAgdulv8YIW+VbTIp9 JQPAOmabtW23my/H/3g7JQ+fkTlJKNvtdCQ9UksJpvzng47pPQwgx8bUBFVUPdCq5n5A kW7yfM8uz/gpLcXlckDrs+cOqbhD4AgD7zzgQHfRKjLAKo208zhjfrnVZl4+MkTVnMle WN2VOUetfo5mPTyZKh08p5658/vq1bP0sr3m3H/HRY+ioSAQ1bySKX2tc7bKSroteU2A L4LvbmVMtdv3xv5nst31BGqDTt3EdnQYJi6LP/RwQBBUT+ZOSRiIIOcmA53WL6t5Uij+ Odng== X-Forwarded-Encrypted: i=1; AJvYcCXKEaRQSk5nPTrJuPe2+MgscfnbbWpQoOvsVFT0TwIKn5KG4C9lVwFMZCEsijKDdO9sY7Pum4yBhJQatx91LBPI+mammbwUFa4IQodM X-Gm-Message-State: AOJu0YwaoW0n+1ZPknmJewBqHR/857P4j5yL9NB0kLff6hpLwEXUYMYg hgWNklru7Yqj/L5ZkckowoOWbN6UNYRkSAUH48x6pWxx2WST4je0Q1vFkCpKntcBXuWjxkmgts+ QjACldr1qDGJLJD7UYY19Vhm/ay3/6fTTzpI= X-Received: by 2002:a05:600c:3051:b0:414:1ee:f399 with SMTP id n17-20020a05600c305100b0041401eef399mr89401wmh.2.1710887404353; Tue, 19 Mar 2024 15:30:04 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240319130547.4195-1-lakshmi.sowjanya.d@intel.com> <20240319130547.4195-3-lakshmi.sowjanya.d@intel.com> In-Reply-To: <20240319130547.4195-3-lakshmi.sowjanya.d@intel.com> From: John Stultz Date: Tue, 19 Mar 2024 15:29:51 -0700 Message-ID: Subject: Re: [PATCH v5 02/11] timekeeping: Add function to convert realtime to base clock To: lakshmi.sowjanya.d@intel.com Cc: tglx@linutronix.de, giometti@enneenne.com, corbet@lwn.net, linux-kernel@vger.kernel.org, x86@kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, intel-wired-lan@lists.osuosl.org, andriy.shevchenko@linux.intel.com, eddie.dong@intel.com, christopher.s.hall@intel.com, jesse.brandeburg@intel.com, davem@davemloft.net, alexandre.torgue@foss.st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com, perex@perex.cz, linux-sound@vger.kernel.org, anthony.l.nguyen@intel.com, peter.hilber@opensynergy.com, pandith.n@intel.com, mallikarjunappa.sangannavar@intel.com, subramanian.mohan@intel.com, basavaraj.goudar@intel.com, thejesh.reddy.t.r@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2024 at 6:06=E2=80=AFAM wrot= e: > > From: Lakshmi Sowjanya D > > PPS(Pulse Per Second) generates signals in realtime, but Timed IO > hardware understands time in base clock reference. Add an interface, > ktime_real_to_base_clock() to convert realtime to base clock. > > Convert the base clock to the system clock using convert_base_to_cs() in > get_device_system_crosststamp(). > > Add the helper function timekeeping_clocksource_has_base(), to check > whether the current clocksource has the same base clock. This will be > used by Timed IO device to check if the base clock is X86_ART(Always > Running Timer). > > Co-developed-by: Thomas Gleixner > Signed-off-by: Thomas Gleixner > Co-developed-by: Christopher S. Hall > Signed-off-by: Christopher S. Hall > Signed-off-by: Lakshmi Sowjanya D > --- > include/linux/timekeeping.h | 6 +++ > kernel/time/timekeeping.c | 105 +++++++++++++++++++++++++++++++++++- > 2 files changed, 109 insertions(+), 2 deletions(-) > > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h > index 7e50cbd97f86..1b2a4a37bf93 100644 > --- a/include/linux/timekeeping.h > +++ b/include/linux/timekeeping.h > @@ -275,12 +275,18 @@ struct system_device_crosststamp { > * timekeeping code to verify comparability of two cycle val= ues. > * The default ID, CSID_GENERIC, does not identify a specifi= c > * clocksource. > + * @nsecs: @cycles is in nanoseconds. > */ > struct system_counterval_t { > u64 cycles; > enum clocksource_ids cs_id; > + bool nsecs; Apologies, this is a bit of an annoying bikeshed request, but maybe use_nsecs here? There are plenty of places where nsecs fields hold actual nanoseconds, so what you have might be easy to misread in the future. Also, at least in this series, I'm not sure I see where this nsecs value gets set? Maybe something to split out and add in a separate patch, where its use is more clear? > +bool timekeeping_clocksource_has_base(enum clocksource_ids id) > +{ > + unsigned int seq; > + bool ret; > + > + do { > + seq =3D read_seqcount_begin(&tk_core.seq); > + ret =3D tk_core.timekeeper.tkr_mono.clock->base ? > + tk_core.timekeeper.tkr_mono.clock->base->id =3D=3D id : f= alse; Again, bikeshed nit: I know folks like ternaries for conciseness, but once you've crossed a single line, I'd often prefer to read an if statement. thanks -john