Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp626592ybh; Tue, 21 Jul 2020 04:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtBNRuEGYdsufMsAVCSrAnPHShVwjz0g6vs7bjrTfu1NC/wbyj2RFzwCYCwiMWOKiGZLL+ X-Received: by 2002:aa7:c407:: with SMTP id j7mr25059916edq.96.1595329566366; Tue, 21 Jul 2020 04:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595329566; cv=none; d=google.com; s=arc-20160816; b=KoCGU8SEalfR7BLwS3bDfDubjviNzW8ScPUgePY38YyrdYFg9H8YIFUVZvp7m6ktOz VwObMHzLOPauSkGRKKebH5Nr14Tv7SDPDRCWMvAQadzfYb3pQUanKrvZpuXO/bdtr+N9 hWGN1KBCocbT0o9gfc44qCuC9tEQ5TpI7XGhz7/onGzG7fLZHWHS4K11v5yAW2aoMip/ 2tcvjvKAo7+PtCLIh/Llbn00KBEIetGCMLyPI3MuwbjHuja237pr1cgOOa40Gb1Rithv 82tRwjGmr/zHO0/XxvA/Sj1kfiU6mmIRg+obtk4/1zsrLyQ+2ZsI+Rmbj/e2yCdpW6Dt g/MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=CPqRjmeULxuLVoEjy9aA3UQhI9sTfnd10elbtAQrDro=; b=EGH0jfHAy41hm1JMLWC0ct14Yqtz+Vlu/7e8ross8JbTuFjwZoPpZY2B62fMG3nTQa fE7l0xATrByXmc7q+d0JUlU7ZsD8rja/BtoEnBwmILR6GJFtNWqwEJCgEPceWzm3eiuL c1K/ySjDslCJq6tNS2j7wMcaX9lIb5Dr/22Tcbu2FquCT7F4Oj3HdtpQoaaSTLM0ClIQ lVItrOIERZ+3uwAfVGkw1c/Hs+ZMTFnxq9nYUe9Pkj8JMMqTu3oFguHsaawKjmRt24qh 3igclLbzIwYmLGWoE7UXEk8Fzk5tkyrOGiwgZyHF+3tCF5YgrzpzImVPeDWS64W07WVn aA5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q3PTt388; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si11848741edn.299.2020.07.21.04.05.42; Tue, 21 Jul 2020 04:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q3PTt388; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729417AbgGULCt (ORCPT + 99 others); Tue, 21 Jul 2020 07:02:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727043AbgGULCs (ORCPT ); Tue, 21 Jul 2020 07:02:48 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79514C0619D8 for ; Tue, 21 Jul 2020 04:02:48 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id o2so2438887wmh.2 for ; Tue, 21 Jul 2020 04:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CPqRjmeULxuLVoEjy9aA3UQhI9sTfnd10elbtAQrDro=; b=q3PTt388dGTnzDpVwzvX6J60ZQKkYn/bYlCxdn54F6eINTC2t/AidA+9Em79HiEZRt lavrMoQiz13W5VNdzEGkAZDZOy4WCxvC2LGYETtYQrLBrSesCPem+2KnQZNDvq9REXRL oOrUs7OF4A3Yr9oKdXRBigpkeKEb46CLGy2q+phezgBG+EEhywNBZqsa1oFPDlVszg8e iPeyiyu4ytWfy6HBiQU+IIjba9r0/2MaZ1ShQUSedgi+eIHyTVeXGn5Hc+bg+mM7MwYq EWe02FiTsvsrcAgW9M2u4viKWhX+d0dp4COZjIhCwTvTxY++9dLalWkh0XmV95/70I/Q b9fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CPqRjmeULxuLVoEjy9aA3UQhI9sTfnd10elbtAQrDro=; b=nPOoA1BWHXIS50tIv2pXcUokmRVGrrn5j1xeJDBy+Rskstr95U/yqXectPjocu778L JjE+1c1UZRi+vudvIHks+qfHB3LpDJgiNrXzjBJIRPhjW5FaXoQvw99VJbtlQ4eiSDY/ 3sF0WGX+L7iKjmNSvYeaiPrIBAyNoPdhg6z6N4QUXjuyOt8MFvo4si2hJKDRQjxGk7Oo g/28HJk34LKqi2CzxVysJzowZfvRXiKRuWFv/hU+WVG5yynuyPh+o8xNPkz7Gn79jlyS agC869MAZFTD21e2GHZGP8t786edwIoxNWh/4kTHdNdbabMqGbghZUEd7POqUlbKCli4 tJeg== X-Gm-Message-State: AOAM530K5rI6QYgX/QJYyIhzGuOpmKhnlaAl2sO9KT+njG0pqFmnPy3r E9MA3JsMILNcG52a6Zf66BL6AQ== X-Received: by 2002:a7b:ce83:: with SMTP id q3mr3481693wmj.5.1595329366936; Tue, 21 Jul 2020 04:02:46 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:3590:b402:869a:11fc? ([2a01:e34:ed2f:f020:3590:b402:869a:11fc]) by smtp.googlemail.com with ESMTPSA id d14sm4547519wre.44.2020.07.21.04.02.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2020 04:02:46 -0700 (PDT) Subject: Re: [PATCH v4 2/4] clocksource/drivers: Add CLINT timer driver To: Anup Patel , Palmer Dabbelt , Paul Walmsley , Albert Ou , Rob Herring , Thomas Gleixner Cc: Damien Le Moal , Atish Patra , Alistair Francis , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Emil Renner Berhing References: <20200717075101.263332-1-anup.patel@wdc.com> <20200717075101.263332-3-anup.patel@wdc.com> From: Daniel Lezcano Message-ID: <63f65ddd-b7c4-b8fd-151c-a77e8c87efed@linaro.org> Date: Tue, 21 Jul 2020 13:02:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200717075101.263332-3-anup.patel@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/07/2020 09:50, Anup Patel wrote: > We add a separate CLINT timer driver for Linux RISC-V M-mode (i.e. > RISC-V NoMMU kernel). > > The CLINT MMIO device provides three things: > 1. 64bit free running counter register > 2. 64bit per-CPU time compare registers > 3. 32bit per-CPU inter-processor interrupt registers > > Unlike other timer devices, CLINT provides IPI registers along with > timer registers. To use CLINT IPI registers, the CLINT timer driver > provides IPI related callbacks to arch/riscv. > > Signed-off-by: Anup Patel > Tested-by: Emil Renner Berhing > --- > drivers/clocksource/Kconfig | 9 ++ > drivers/clocksource/Makefile | 1 + > drivers/clocksource/timer-clint.c | 231 ++++++++++++++++++++++++++++++ > include/linux/cpuhotplug.h | 1 + > 4 files changed, 242 insertions(+) > create mode 100644 drivers/clocksource/timer-clint.c > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig > index 91418381fcd4..e1ce0d510a03 100644 > --- a/drivers/clocksource/Kconfig > +++ b/drivers/clocksource/Kconfig > @@ -658,6 +658,15 @@ config RISCV_TIMER > is accessed via both the SBI and the rdcycle instruction. This is > required for all RISC-V systems. > > +config CLINT_TIMER > + bool "Timer for the RISC-V platform" > + depends on GENERIC_SCHED_CLOCK && RISCV_M_MODE > + select TIMER_PROBE > + select TIMER_OF > + help > + This option enables the CLINT timer for RISC-V systems. The CLINT > + driver is usually used for NoMMU RISC-V systems. V3 has a comment about fixing the Kconfig option. [ ... ] > +{ > + bool *registered = per_cpu_ptr(&clint_clock_event_registered, cpu); > + struct clock_event_device *ce = per_cpu_ptr(&clint_clock_event, cpu); > + > + if (!(*registered)) { > + ce->cpumask = cpumask_of(cpu); > + clockevents_config_and_register(ce, clint_timer_freq, 200, > + ULONG_MAX); > + *registered = true; > + } I was unsure about the clockevents_config_and_register() multiple calls when doing the comment. It seems like it is fine to call it several times and that is done in several places like riscv or arch_arm_timer. It is probably safe to drop the 'registered' code here, sorry for the confusion. > + enable_percpu_irq(clint_timer_irq, > + irq_get_trigger_type(clint_timer_irq)); > + return 0; > +} > + [ ... ] -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog