From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755549AbcIJTMM (ORCPT ); Sat, 10 Sep 2016 15:12:12 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35103 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753877AbcIJTLy (ORCPT ); Sat, 10 Sep 2016 15:11:54 -0400 From: Nicolai Stange To: Thomas Gleixner Cc: Nicolai Stange , John Stultz , linux-kernel@vger.kernel.org Subject: Re: [RFC v6 01/23] clocksource: sh_cmt: compute rate before registration again References: <20160909200033.32103-1-nicstange@gmail.com> <20160909200033.32103-2-nicstange@gmail.com> Date: Sat, 10 Sep 2016 21:11:34 +0200 In-Reply-To: (Thomas Gleixner's message of "Sat, 10 Sep 2016 14:56:47 +0200 (CEST)") Message-ID: <87k2ejd0yh.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thomas Gleixner writes: > On Fri, 9 Sep 2016, Nicolai Stange wrote: >> @@ -339,17 +339,14 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) >> sh_cmt_start_stop_ch(ch, 0); >> >> /* configure channel, periodic mode and maximum timeout */ >> - if (ch->cmt->info->width == 16) { >> - *rate = clk_get_rate(ch->cmt->clk) / 512; >> + if (ch->cmt->info->width == 16) >> sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE | >> SH_CMT16_CMCSR_CKS512); >> - } else { >> - *rate = clk_get_rate(ch->cmt->clk) / 8; >> + else >> sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM | >> SH_CMT32_CMCSR_CMTOUT_IE | >> SH_CMT32_CMCSR_CMR_IRQ | >> SH_CMT32_CMCSR_CKS_RCLK8); >> - } > > Removing the braces here is just wrong. Completely convinced, will redo. >> @@ -824,6 +810,12 @@ static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch, >> ced->suspend = sh_cmt_clock_event_suspend; >> ced->resume = sh_cmt_clock_event_resume; >> >> + /* TODO: calculate good shift from rate and counter bit width */ >> + ced->shift = 32; >> + ced->mult = div_sc(ch->cmt->rate, NSEC_PER_SEC, ced->shift); > > > Errm. clockevents_calc_mult_shift() Or even clockevents_config_and_register()? The reason why I left this mult/shift initialization as is (it has only been moved from sh_cmt_clock_event_start() by this patch) is that I was unsure about why this conversion hadn't been done before. That TODO comment seems to imply that a shift value as calculated by clockevents_config() isn't always the perfect choice... However, do you want me to a.) simply change this patch to use clockevents_config_and_register(), b.) add a separate patch to this series doing this cleanup, c.) send such a patch on its own d.) or leave this initalization as is? Thanks, Nicolai Stange