From nobody Wed Jun 01 07:25:14 2022 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E3A2D1B4A722 for ; Wed, 1 Jun 2022 07:25:25 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4LCgfD6rvgz3LK8 for ; Wed, 1 Jun 2022 07:25:24 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.55.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by phk.freebsd.dk (Postfix) with ESMTPS id B994789298; Wed, 1 Jun 2022 07:25:16 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.16.1/8.16.1) with ESMTPS id 2517PGfq036704 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 1 Jun 2022 07:25:16 GMT (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.16.1/8.16.1/Submit) id 2517PEfF036703; Wed, 1 Jun 2022 07:25:14 GMT (envelope-from phk) Message-Id: <202206010725.2517PEfF036703@critter.freebsd.dk> To: Sebastian Huber cc: hackers@freebsd.org Subject: Re: pps_capture() and pps_fetch() In-reply-to: <5b8310db-c94b-709f-8c57-bec2d413a80f@embedded-brains.de> From: "Poul-Henning Kamp" References: <5b8310db-c94b-709f-8c57-bec2d413a80f@embedded-brains.de> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <36701.1654068314.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Wed, 01 Jun 2022 07:25:14 +0000 X-Rspamd-Queue-Id: 4LCgfD6rvgz3LK8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of phk@critter.freebsd.dk designates 130.225.244.222 as permitted sender) smtp.mailfrom=phk@critter.freebsd.dk X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEFALL_USER(0.00)[phk]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.dk]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; MLMMJ_DEST(0.00)[hackers]; FORGED_SENDER(0.30)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:1835, ipnet:130.225.0.0/16, country:EU]; FROM_NEQ_ENVFROM(0.00)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N -------- Sebastian Huber writes: > I try to understand how the PPS synchronization works in FreeBSD. It = > seems that pps_capture() starts a transaction and pps_event() completes = > the transaction if nothing interfered in the meantime. The answer to most of your questions are in ./i386/i386/elan-mmcr.c The PPS capture in the Soekris 4501 used two hardware counters, counting a= t the same rate. The first of the two were the timecounter, the other was started by the ha= rdware signal. Sometime later the hardware signals interrupt processing would happen. By reading read both counters as close to instantaneously as possible, and= compensated for the interrupt latency by subtracting the event-started co= unter from the timecounter. (See also: http://phk.freebsd.dk/soekris/pps/) -- = Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe = Never attribute to malice what can adequately be explained by incompetence= .