Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1969279imu; Wed, 21 Nov 2018 04:56:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/WS/S8bPfkY3FGJwSG5vaXOLME4dDbTHuUwn5X7+f6lovXBR5c17NTYS9KR6DgHiZUrmF79 X-Received: by 2002:a17:902:b78b:: with SMTP id e11mr6723674pls.90.1542804996689; Wed, 21 Nov 2018 04:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542804996; cv=none; d=google.com; s=arc-20160816; b=Pr5+p8A3dOIyaaggs4yIH8bsVBgvSW7zxrK4N46VPn4EY9hbcSGaEJFipYZ3D/jLV+ 5gErB98tsPrQtke0ECqV8EdPBImNkUo0AP67nBUoj7KSKScHWf6mxtgsdz4VslZNcC9B C1KLd3HeYKdnr806DnVdmuuFQPz+9hKv6mPCjmy154Ov+DnEKBLZRTUDBTsapNAvopBP NOiHaj26/QZ+dgzWZuCxFhv1Ezg0WlId6brBZhtod6UXGSd0f1sht2Nd7gabBq5TB24Z ZLMFeU0DR15t9cN685xGW9xenUO64rXk0ZODDWu3ZBs/QtlMPQoR/tafZ1DUa6hcrMfc OItw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=MG6xHQ7fW2VR3dbe58xAEEzPLv3RyG/Q9Cl98AJj7g8=; b=rpf7cDk1WKHP0cT2kuGCLp9IxoanAARgYcYzP+HoQvUXN6legRE54A9lttKrrEVYaK ukVral0EQK0kzPrwSp/GN0u4Yts+lIUzPoiz7MUIzRSgep0H+EEasgX/WtBxgCbP9hre UvJS8ntbgvoeZn+QxRwhNPjzMoJXX61eKCzBN9NuVK3EFUiKZRWxQuKWWo1AyNUySVwN 8S1xso1To3RfsktHSKOsPIwBC1wejt6HIXhNttc7rOgaJnN5JNGWMwyG8UmJaG14I0ux sMD6rmhCtVkamex3ZsLwh/otAJjxUAvyJb7+TdG7D+JOeGSfJVzCjLWiiau9Z5bTI6mQ CgTA== 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 g23si17999651pgb.229.2018.11.21.04.56.21; Wed, 21 Nov 2018 04:56:36 -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 S1730009AbeKUVsJ (ORCPT + 99 others); Wed, 21 Nov 2018 16:48:09 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:59688 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729833AbeKUVsJ (ORCPT ); Wed, 21 Nov 2018 16:48:09 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 2EDAE22D7F; Wed, 21 Nov 2018 06:13:57 -0500 (EST) Date: Wed, 21 Nov 2018 22:14:03 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Kars de Jong , Philip Blundell , Andreas Schwab , Arnd Bergmann , Stephen N Chivers , Thomas Gleixner , Daniel Lezcano , Michael Schmitz , John Stultz , Linus Walleij , linux-m68k , Linux Kernel Mailing List Subject: Re: [RFC PATCH v2 09/14] m68k: hp300: Remove hp300_gettimeoffset() In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Nov 2018, Geert Uytterhoeven wrote: > > This suggests that either 0 or N (the latched value) would result from > > a read from the counter immediately following an interrupt. Who can > > say which? Just have to try it. The answer should allow us to avoid > > the risk of a clocksource that jumps forwards and backwards. > > The code in amiga_gettimeoffset() does: > > ticks = hi << 8 | lo; > > if (ticks > jiffy_ticks / 2) > /* check for pending interrupt */ > if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA) > offset = 10000; > That _suggests_ that there's no interrupt when ticks == 0. But look what happens next: > ticks = jiffy_ticks - ticks; > > ticks = (10000 * ticks) / jiffy_ticks; > > return (ticks + offset) * 1000; If (hi << 8 | lo) == 0, and you set offset = 10000, then the return value would be maximal. Let's immediately call this function again. This time (hi << 8 | lo) == N. Let's add the offset again. I'm afraid the clock just jumped backwards. So the logic you quoted has a rationale which is unrelated to the question. --