From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932757AbcC3Qqd (ORCPT ); Wed, 30 Mar 2016 12:46:33 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:37401 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754396AbcC3Qqc (ORCPT ); Wed, 30 Mar 2016 12:46:32 -0400 Subject: Re: Export clocks_calc_mult_shift() function To: , , References: <56DF5158.4010205@ti.com> <56E6D874.8030603@ti.com> CC: "Kristo, Tero" From: Murali Karicheri Organization: Texas Instruments Message-ID: <56FC02E9.1030408@ti.com> Date: Wed, 30 Mar 2016 12:46:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56E6D874.8030603@ti.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/14/2016 11:27 AM, Murali Karicheri wrote: > On 03/08/2016 05:25 PM, Murali Karicheri wrote: >> Hi, >> >> I found a patch posted sometime back to export the clocksource >> function clocks_calc_mult_shift() so that it can be called by >> drivers that are dynamically loadable. I have not seen any >> comment against this. Wondering why this is not merged. We require >> this function exported for use in our driver as well. Can you merge >> the patch please. Or do you suggest me to repost the same? >> >> http://lkml.iu.edu/hypermail/linux/kernel/1502.2/01641.html >> >> Thanks >> > John, > > Some reason, your response didn't make into my inbox. So I am > reproducing it below. > >> Why would the clocksource driver need to calculate the hz/shift value >> instead of using the clocksource_register_hz/khz functions? >> >> thanks >> -john > > John, > > In this use case, the timestamp for Tx/Rx is generated by a firmware > that attach the timestamp raw count to the packet meta data when the > same is received from the Packet Accelerator h/w at the ingress. > We need to convert this raw count value to nano second and use a code > like this. > > /* Convert a raw PA timer count to nanoseconds > */ > static inline u64 tstamp_raw_to_ns(struct pa_core_device *core_dev, u32 lo, > u32 hi) > { > u32 mult = core_dev->timestamp_info.mult; > u32 shift = core_dev->timestamp_info.shift; > u64 result; > > /* Minimize overflow errors by doing this in pieces */ > result = ((u64)lo * mult) >> shift; > result += ((u64)hi << (32 - shift)) * mult; > > return result; > } > > The mult, shift values are obtained using the existing clocks_calc_mult_shift() > that will not work, if our driver is built as a dynamically loadable module > as the symbol is not exported. > > Is there an alternative way of doing this without exporting this function. > clocksource_register_hz/khz() can't help in this, right? > John, I didn't see any response? Can I send a patch to export clocks_calc_mult_shift() function?? -- Murali Karicheri Linux Kernel, Keystone