Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752602AbbLDM0h (ORCPT ); Fri, 4 Dec 2015 07:26:37 -0500 Received: from mail-db3on0073.outbound.protection.outlook.com ([157.55.234.73]:50459 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751116AbbLDM0f convert rfc822-to-8bit (ORCPT ); Fri, 4 Dec 2015 07:26:35 -0500 From: Noam Camus To: Daniel Lezcano , "linux-snps-arc@lists.infradead.org" CC: "linux-kernel@vger.kernel.org" , "Chris Metcalf" , Rob Herring , "Thomas Gleixner" , John Stultz Subject: Re: [PATCH v3 03/18] clocksource: Add NPS400 timers driver Thread-Topic: [PATCH v3 03/18] clocksource: Add NPS400 timers driver Thread-Index: AQHRLDjqFrSZ737A3kOvBnIhoAKa1J66j4yAgAAqzRU= Date: Fri, 4 Dec 2015 12:26:32 +0000 Message-ID: References: <1448974985-11487-1-git-send-email-noamc@ezchip.com> <1448974985-11487-4-git-send-email-noamc@ezchip.com>,<56615927.30201@linaro.org> In-Reply-To: <56615927.30201@linaro.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=noamc@ezchip.com; x-originating-ip: [85.64.158.114] x-microsoft-exchange-diagnostics: 1;AMSPR02MB120;5:+9w24z8r0q750S1jZojSjTnKOSk2hKPloL5J3QXzkXGF1IReuUbhU2IhsS538d4iUME4SVvgxj1X6GL9rdunPqg+YvclFzh+Uf8+p4d42sJ1gkb6OKNpNx3GvrTpllZM4EcYNBinSMLR9qmjKXLjXA==;24:2rwRvpbjSc38+LTzVgox95bdvS9sOsq1XOpQh/bQBzMf+3TzHXyoPHOhI7g7P7ntESePFC5Y+djBO5LsOho1sx2RQI8g/FJEbpsPbTcahFg= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AMSPR02MB120; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001);SRVR:AMSPR02MB120;BCL:0;PCL:0;RULEID:;SRVR:AMSPR02MB120; x-forefront-prvs: 07807C55DC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(377454003)(43784003)(189002)(199003)(5001770100001)(76176999)(74316001)(86362001)(97736004)(5001960100002)(3846002)(586003)(40100003)(122556002)(92566002)(77096005)(1096002)(102836003)(2900100001)(6116002)(2950100001)(81156007)(2501003)(5008740100001)(5003600100002)(1220700001)(66066001)(54356999)(189998001)(50986999)(5002640100001)(105586002)(10400500002)(106116001)(106356001)(19580395003)(11100500001)(87936001)(33656002)(101416001)(5004730100002)(19580405001)(76576001);DIR:OUT;SFP:1101;SCL:1;SRVR:AMSPR02MB120;H:DB5PR02MB1141.eurprd02.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT MIME-Version: 1.0 X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Dec 2015 12:26:32.0877 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR02MB120 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3040 Lines: 96 >From: Daniel Lezcano >Sent: Friday, December 4, 2015 11:13 AM >> +obj-$(CONFIG_ARC_PLAT_EZNPS) += timer-nps.o >CONFIG_CLKSRC_NPS I wish this driver to be build only for this specific ARC platform. This clock source is embedded in our SoC. It is not meant to be built for any other architecture. This is why below I include header from our ARC platform to avoid code duplicity. >> +#include >Why do you need this header ? nps_host_reg ? Correct we use common code from our platform. >We prevent to include headers from in the drivers directory. You >should find a way to get rid of it. The Only way I can think of is code duplicity and I prefer not to. I see some include to asm/mach headers in clocksource, what is the difference? Could you suggest a better place for me to place my header file. >> +static void *nps_msu_reg_low_addr[NPS_CLUSTER_NUM] __read_mostly; > >Perhaps a small optimization... Thanks >static DEFINE_PER_CPU_READ_MOSTLY(void __iomem *, baseaddr); >static cycle_t nps_clksrc_read(struct clocksource *clksrc) >{ > void __iomem *base = per_cpu(baseaddr, raw_smp_processor_id()); > > return (cycle_t)ioread32be(base); >} >and in the init function: >for_each_cpu(cpu) { > per_cpu(baseaddr, cpu) = nps_host_reg(cpu, > NPS_MSU_BLKID, > NPS_MSU_TICK_LOW >} Thanks again >> +static cycle_t nps_clksrc_read(struct clocksource *clksrc) >> +{ >> + int cluster = raw_smp_processor_id() >> NPS_CLUSTER_OFFSET; >> + >> + return (cycle_t)ioread32be(nps_msu_reg_low_addr[cluster]); >,AFAICT, there is a memory barrier with ioread32be, are you really sure >we have to use it in this code path ? Are you saying to remove use of ioread32be? What should I use instead? >> + >> + dt_root = of_get_flat_dt_root(); >> + rate = (u32)of_get_flat_dt_prop(dt_root, "clock-frequency", NULL); >I don't get why this is done this way. The Kconfig option help says the >clocksource rate is 1GHz but in the DT the clock is 88MHz. It says that clock source is up to 1GHz >It would be cleaner to define a fixed clock and then add a phandle in >the DT. > timer_clk: timer_clk { > #clock-cells = <0>; > compatible = "fixed-clock"; > clock-frequency = <123456789>; > }; > timer { > compatible = "ezchip,nps400-timer"; > clocks = <&timer_clk>; > } >That will result in the same code than the other drivers. > clk = of_clk_get(np, 0); > if (IS_ERR(clk)) { > pr_err("%s: invalid clock\n", np->full_name); > return; > } > rate = clk_get_rate(clk); Once again thanks I will fix this. -Noam -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/