Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4060479imm; Mon, 17 Sep 2018 07:36:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbU449q4V+mqsTC+O6NNUuZ+asb7WirxzB62AJIenNOEz5ALnUVP0ZkuPfn8opYUEVqR1Uk X-Received: by 2002:a63:ec43:: with SMTP id r3-v6mr17636664pgj.295.1537195010166; Mon, 17 Sep 2018 07:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537195010; cv=none; d=google.com; s=arc-20160816; b=oXLld8k7a+sznRBtBgt1LbMXGy7grFHbkhVKzWQytg4Tnv7XlJzVf1JqkIVIYjvDpb OtFbx32THMKUF03YglmT3ixl4SEa6/EMN+1q7t/uf3xAqlvsquxjW+RtdSCVBzAyaQHY 9aCmZLqCfSGBKf46UxQMstsKXqjPdHjh8TxYb3/huPWuBUiWDDoZoV6gZrxlUgkTEwtx cSOLACaSfmtNbgtR9OQfUYAuaVfltBDia+JL+1BSCgCvIUZB8lXtC9Oyq7asxDq2MOPI Qyk34lvioYBThaWgWp0pP3XgwS6y3ZQ4KEJS8xlkNd8bRCYxAAruh0cJfTg5ILAStbcJ JU0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nEl94gvCQ58xJ4u5L4Sgz/Ln+ePH4eWsZnvw71aHIbw=; b=0syQGxuYwaEQYsu+ooqmo+h7H9dGBhyEYK3JLN/FLNkF7n8pd9WBpB8DBMyW8rQ+MX Zl4/kt8ab/m3ygga51Cr08V8juuuVIgGH2bK/wB+mobicDvo98m1IiqWkUmrV8EYVO+a BslUPOoCPuyRlqShz1cGcaz+k5nJ7SveVny36O3kmsa2ze+CzzmOAyIWde7jbjaBYP2w OpVY4V6vDTEiL7ODYBjd1YOMzBiXgAft17kq40KvJwRxp7KZbVXdFrl/S/uZe8KhVkiU Yy5oU/ajCzvNallQFlweU5mO4fTGkSLBwFAWSeuZ4WwZPXs+cc2k2abCVHo6evX2LB3F dD6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="PO/O42CX"; 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 e186-v6si15810842pfc.176.2018.09.17.07.36.18; Mon, 17 Sep 2018 07:36:50 -0700 (PDT) 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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="PO/O42CX"; 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 S1728811AbeIQUD3 (ORCPT + 99 others); Mon, 17 Sep 2018 16:03:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46666 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727858AbeIQUD3 (ORCPT ); Mon, 17 Sep 2018 16:03:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nEl94gvCQ58xJ4u5L4Sgz/Ln+ePH4eWsZnvw71aHIbw=; b=PO/O42CXCjTu17qEMPEIhTbq9 eeyO8dJcxBKPqZWhkZPgkfZdrnHZkFRR/DNXet7qMSA8uhWOMt910vPO6/U1KtWNwBTthVuTC/wxw m6JXH0B5US5clrX4ZSv6FhHTWXvhKvPUlU8h4qzFDuTwazFu1UU8+mA8wgNVevS8IAl82Lhcd4hed PAnrYgUlvDiRk5PkowGcGOhkUHm1m4NSf4zEyTw6jryeyKi2dvzK5daQ94L08QDE75jBtpuWTf4DH 3b+mqfzZ5FApiYjO+KabrDPBPAjgzxvRrauqRVSa9/cxFhtYh8pbXFTaruB0Ck+7hmaw2Y40pmaZk qDA0oDqXA==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1g1ucw-0004Vq-Fv; Mon, 17 Sep 2018 14:35:50 +0000 Date: Mon, 17 Sep 2018 07:35:50 -0700 From: Christoph Hellwig To: Atish Patra Cc: palmer@sifive.com, linux-riscv@lists.infradead.org, hch@infradead.org, mark.rutland@arm.com, robh@kernel.org, Damien.LeMoal@wdc.com, marc.zyngier@arm.com, anup@brainfault.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Subject: Re: [RFC 3/3] RISC-V: Remove per cpu clocksource Message-ID: <20180917143550.GC15588@infradead.org> References: <1536962096-233842-1-git-send-email-atish.patra@wdc.com> <1536962096-233842-4-git-send-email-atish.patra@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1536962096-233842-4-git-send-email-atish.patra@wdc.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I think only having one clocksource is indeed the right thing. But that makes the whole TIMER_OF_DECLARE for each hart (cpu core for those not RISC-V savvy) even more questionable than it already is. I think we should just initialize the clocksource directly as it is architectually guaranteed to exist. Below is a completely untested (not even compiled) version of your patch that does what I think we should be doing here. But I'd rather hear from more timer and/or DT savvy folks before proceeding. diff --git a/drivers/clocksource/riscv_timer.c b/drivers/clocksource/riscv_timer.c index 4e8b347e43e2..2fe497c67283 100644 --- a/drivers/clocksource/riscv_timer.c +++ b/drivers/clocksource/riscv_timer.c @@ -48,7 +48,7 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) return get_cycles64(); } -static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = { +static struct clocksource, riscv_clocksource = { .name = "riscv_clocksource", .rating = 300, .mask = CLOCKSOURCE_MASK(BITS_PER_LONG), @@ -82,24 +82,16 @@ void riscv_timer_interrupt(void) evdev->event_handler(evdev); } -static int __init riscv_timer_init_dt(struct device_node *n) +static int __init riscv_timer_init(void) { - int cpu_id = riscv_of_processor_hart(n), error; - struct clocksource *cs; - - if (cpu_id != smp_processor_id()) - return 0; - - cs = per_cpu_ptr(&riscv_clocksource, cpu_id); - clocksource_register_hz(cs, riscv_timebase); + int error; + clocksource_register_hz(&riscv_clocksource, riscv_timebase); error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING, "clockevents/riscv/timer:starting", riscv_timer_starting_cpu, riscv_timer_dying_cpu); if (error) - pr_err("RISCV timer register failed [%d] for cpu = [%d]\n", - error, cpu_id); + pr_err("RISCV timer register failed: %d.\n", error); return error; } - -TIMER_OF_DECLARE(riscv_timer, "riscv", riscv_timer_init_dt); +core_initcall(riscv_timer_init);