Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3852234imu; Mon, 12 Nov 2018 01:21:26 -0800 (PST) X-Google-Smtp-Source: AJdET5f+Ed4lxm6Wi6gtzXA76H171Ec+qN2FpWO5eRErG3s6yyzrKkxER47NGAuaL4pgo+kt/ASo X-Received: by 2002:a63:310:: with SMTP id 16mr151030pgd.79.1542014486189; Mon, 12 Nov 2018 01:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542014486; cv=none; d=google.com; s=arc-20160816; b=YesRF0oQ3ZVu/2OxBys93X92i3DdgPaW8eGw31oUjYt/Ukbef9zy9egBK4TVxmi8Fl jhMYZHtHJtjcWfao20nMSkHcsRYXP05h7zZu2QYLQVtfp45ukNtRWdCGbepbq6hcPSH7 pysZkQAoENVuueK08gZw+KGZeNMsFHaNuxZTr+4GrJRdAu8fi+6zEhFmB5IY4U1Pt03j 3JLlIzqoYESeGuq+Xc3WtUXYY16tIPVsZuqYNFOJdsb8GlpfGoLnE+OeEAX+fTgcOz+G djnBrImjr8xpiTC+mmMvyB9OMcoc2me9R+68BcsAviKQ70ckPF6Uq/p7stSEXECIzxG1 h11w== 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=LHrItRLPwLDB74NHxLa9ZaLokjB3AVCe11SdpfwC1h0=; b=DQNyGSMCGzci5Ab88GYNPO5mOfbVoKo4SFWnC2l3q5jbxS4ZFWBMv6l0OKUim6O9ux JMSCIXzu7YSY+mVMz3D/afvfsiHD5dnsGOmrXVZlpFZwbKpS1xFzh6JCyuRyV/NB5/9R WI/JKiBx4vex3MkJa964GlKhlCmX7SvT2Hpp9mAZ5k8O6CH85wlNRl+mUfDZSz/Vxg8D mijpHPh1q4SpDK2Muw+tpatl1DUnmTi5xuGNN2Husl2EV0dy7fLvfp4qjfAo4XLZcyjR ijtq4YV3NakBmAJhATRiC+BlsbptvyuN6QBn/pG8nVzjJ0biqnrVBHp1mVSfmmKbccfy JAOQ== 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 j128-v6si18736252pfg.238.2018.11.12.01.21.10; Mon, 12 Nov 2018 01:21:26 -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 S1728518AbeKLTNI (ORCPT + 99 others); Mon, 12 Nov 2018 14:13:08 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:52236 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726161AbeKLTNH (ORCPT ); Mon, 12 Nov 2018 14:13:07 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by kvm5.telegraphics.com.au (Postfix) with ESMTP id 23541297DB; Mon, 12 Nov 2018 04:20:43 -0500 (EST) Date: Mon, 12 Nov 2018 20:21:02 +1100 (AEDT) From: Finn Thain To: Geert Uytterhoeven cc: Arnd Bergmann , Stephen N Chivers , Thomas Gleixner , Daniel Lezcano , John Stultz , linux-m68k , Linux Kernel Mailing List Subject: Re: [RFC PATCH 07/13] m68k: amiga: Convert to clocksource API 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 Mon, 12 Nov 2018, Geert Uytterhoeven wrote: > Hi Finn, > > On Mon, Nov 12, 2018 at 5:46 AM Finn Thain wrote: > > Add a platform clocksource by adapting the existing arch_gettimeoffset > > implementation. > > > > Signed-off-by: Finn Thain > > Thanks for your patch! > Thanks for your review. > > --- a/arch/m68k/amiga/config.c > > +++ b/arch/m68k/amiga/config.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -461,7 +462,30 @@ void __init config_amiga(void) > > *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80; > > } > > > > +static u64 amiga_read_clk(struct clocksource *cs); > > + > > +static struct clocksource amiga_clk = { > > + .name = "ciab", > > + .rating = 250, > > + .read = amiga_read_clk, > > + .mask = CLOCKSOURCE_MASK(32), > > + .flags = CLOCK_SOURCE_IS_CONTINUOUS, > > +}; > > + > > static unsigned short jiffy_ticks; > > +static u32 clk_total; > > Shouldn't clk_total be u64? > Well, it was intentionally u32, and amiga_clk.mask was intentionally CLOCKSOURCE_MASK(32)... > > + > > +static irqreturn_t ciab_timer_handler(int irq, void *data) > > +{ > > + irq_handler_t timer_routine = data; > > + unsigned long flags; > > + > > + local_irq_save(flags); > > + clk_total += jiffy_ticks; > > + local_irq_restore(flags); > > + > > + return timer_routine(irq, data); > > +} > > [...] > > > -static u32 amiga_gettimeoffset(void) > > +static u64 amiga_read_clk(struct clocksource *cs) > > { > > unsigned long flags; > > unsigned short hi, lo, hi2; > > @@ -512,14 +537,13 @@ static u32 amiga_gettimeoffset(void) > > if (ticks > jiffy_ticks / 2) > > /* check for pending interrupt */ > > if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA) > > - offset = 10000; > > + offset = jiffy_ticks; > > > > local_irq_restore(flags); > > > > ticks = jiffy_ticks - ticks; > > - ticks = (10000 * ticks) / jiffy_ticks; > > > > - return (ticks + offset) * 1000; > > + return clk_total + ticks + offset; > > ... to return a full 64-bit value here? > It's certainly possible. Is it better? It sounds like a question about the cost of wrap-around in the clocksource core vs. the cost of 64-bit additions in the arch code. Looking at __clocksource_update_freq_scale() there are some consequences to choosing a 32-bit mask -- * For clocksources which have a mask > 32-bit * we need to limit the max sleep time to have a good * conversion precision. I don't know the answer, sorry. -- > Gr{oetje,eeting}s, > > Geert > >