Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp522913imm; Thu, 26 Jul 2018 07:39:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHhm/OWIr9u4uaKWd7Ren4BekE4OryH48N/1ttDRMWYvMeb6BH/LjxCHGb9jqNzlhWJ7wz X-Received: by 2002:aa7:8307:: with SMTP id t7-v6mr2408422pfm.81.1532615946047; Thu, 26 Jul 2018 07:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532615946; cv=none; d=google.com; s=arc-20160816; b=LMFRNi5bdICQpgnv5WLCuHounMp0MSKQeXT2ArC+acYYs46aKgWgxNY6hogCowek5/ 1xVvHBJ/jQp9GjDXpDZmqThdTsxdBDno4TOYsF70RfQdEOFNItfmmar4vkvgBR54NMm1 XVTnd6T34orc966sg/a4gZbPis2YxXYrQQ6I/50EjgoHpr0J9XZRnOXGSUeJl5ncSn2s lyC54ZkqiLh/qDGv1sywiC700lAJdQtsrmaUlOzUng41NX283T6lq2Kkvy8DeC2P3/NT 4Gho6OxXBI0sNhCWL4L+9QLkDFWm0D/pf+N0fVcUSqIVk7xP6oysCr5cbDBQOZIm1SHR VoCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EFVeN7WbbZw6vRuuORh8CD4rJRx53TVZwG89sQVyxzI=; b=gT9npKjLlkoCne7Pw0BQ31seumjzuhdQGWW1r3KYNThwq/3nvZSiDn2j0LWucQnu5m /LvK5/C5B9/3wWQYrWG0ELW9WXYzRLjsoOdj7XQ0VMs7HdoVXt1BxaELU2QTay5zMyHu x6DVz5ipFpcHq+shvjimqdUgz9dkyQ6OZp//ZqcnI+sDr3/EK4kiA2v1shcSLJuzwT6j SY00YsRU9IoBk8gRUcP1zLApcwQWZdgCTCedRvZ6QYP3ypUJ1ftRXhb09CJuZ/MCudzl HKQAe+deOZfhV6mRR31eub7GXkasJinY0X1JpOucWYPsNgBbtXnpRPHg1ARq1cNsT0xF RibQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=G4vZBDFy; 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 5-v6si1353630pls.450.2018.07.26.07.38.51; Thu, 26 Jul 2018 07:39:06 -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=G4vZBDFy; 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 S1731587AbeGZPzB (ORCPT + 99 others); Thu, 26 Jul 2018 11:55:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57894 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729506AbeGZPzB (ORCPT ); Thu, 26 Jul 2018 11:55:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: 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=EFVeN7WbbZw6vRuuORh8CD4rJRx53TVZwG89sQVyxzI=; b=G4vZBDFyRYzkFeLX0XMg0TizK kQb6XA033UAXdKLYg41W0QcBuXDQW5Ro+2wgxJ7ogAs8JSsKbJWI0WZ1TPkmCeyJKp7xYoLIvUHcT Ahfjj04OSGNJ/+oD060YR+u8YGRaHKlOyEiuHIqaiOVRC47Oo1eNX4fIVJXWJpZHlCekSEI9uMTfp 2rrzrl7oyeQurV2eowJsUCmZodpVLUjFznxniipMaApcZ1RjgPPIBQO2xz0bATXp1+vIQme0qfZzh teozTrBidR69e3JYi30reTgXUqZwWvGB57k90PaXWwOWr/VDaCBfVjpfy1HPkuUDSd+RMvpRhTd00 g19m/1afg==; Received: from 213-225-8-157.nat.highway.a1.net ([213.225.8.157] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fihOl-0005oI-Dx; Thu, 26 Jul 2018 14:37:48 +0000 From: Christoph Hellwig To: tglx@linutronix.de, palmer@sifive.com, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: anup@brainfault.org, atish.patra@wdc.com, devicetree@vger.kernel.org, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, shorne@gmail.com, Palmer Dabbelt Subject: [PATCH 6/9] RISC-V: Support per-hart timebase-frequency Date: Thu, 26 Jul 2018 16:37:20 +0200 Message-Id: <20180726143723.16585-7-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180726143723.16585-1-hch@lst.de> References: <20180726143723.16585-1-hch@lst.de> 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 From: Palmer Dabbelt This isn't actually how I want to do it, I just needed something right now. Signed-off-by: Palmer Dabbelt --- arch/riscv/kernel/time.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c index 0df9b2cbd645..1bb01dc2d0f1 100644 --- a/arch/riscv/kernel/time.c +++ b/arch/riscv/kernel/time.c @@ -24,17 +24,24 @@ void __init init_clockevent(void) csr_set(sie, SIE_STIE); } -void __init time_init(void) +static long __init timebase_frequency(void) { struct device_node *cpu; u32 prop; cpu = of_find_node_by_path("/cpus"); - if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop)) - panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n"); - riscv_timebase = prop; + if (cpu && !of_property_read_u32(cpu, "timebase-frequency", &prop)) + return prop; + cpu = of_find_node_by_path("/cpus/cpu@0"); + if (cpu && !of_property_read_u32(cpu, "timebase-frequency", &prop)) + return prop; - lpj_fine = riscv_timebase / HZ; + panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n"); +} +void __init time_init(void) +{ + riscv_timebase = timebase_frequency(); + lpj_fine = riscv_timebase / HZ; init_clockevent(); } -- 2.18.0