Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp655553ybh; Tue, 21 Jul 2020 04:52:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvgAwYXyl6XHFsqZfPx0FCg96eUDxVBWoLyeFEkqsloIEfHK+3XvxSE3COJe3lPbox1Kku X-Received: by 2002:a05:6402:49:: with SMTP id f9mr19011980edu.112.1595332341450; Tue, 21 Jul 2020 04:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595332341; cv=none; d=google.com; s=arc-20160816; b=HebaDwwGFOQJBujtUp9JcaaeUGHQ+VFeYFMs5hoIWU/ZCiwqlAsZNaaxHY+QT8M+mG PWK+lNY74w1/Cj/OK95qp8tDhRPAZIXx9GUAABpfu7FWx+DGU9jlWuegtaa0KeY8oz69 XUwhJxgiNWXQbkp3AoQr7bXgL4ObQoFafkNX7qheIjZLaQjQYqvWLOayagUybugoTHZQ XTYXS0S7sJsv9PfYLgGwKYt8FZInzZctuv3ribXyMM036QrFa/idoDjQOu+QCXuSoWG8 +s0h4qmgJyxxUPL3eV5NqnGFyCN+Pg9djygm5O2PVYcB0sVZK5gAaWCEM2xeXr1W6ht8 Cwfg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YhhhVF8z1SLInJUZAiDAnUC6bgocyhhgqr0w45WOgKE=; b=f/QuEgcbJ8sU0m48L251Bz1Xbu/C4++YQbrJBlOVAkhnwiBapeGfGP7720FwEn+26h Q563XlUA1SuBx+WQvLsmRrZnm3cD8rU5JzylIqKAX1DLN61T7JfuuNIHgzrYkq2YRbl3 +4a3JFJUxzxoQeCEsXop/JE+cEYhnkzrgb8cGuZ/hwWuYnHn0veGPDR1lXjYfmcCYaZz pf6dGB5kHC4aE30EuvE8YDuPvVcK4uRdDjxXupY8cCR4ObuMG/a0kZEUKzSF4iaGCBqU Sh8yRIbDPvTNXGaXmKnddtDzuu642iVCJ3IysVOEqLDrnM45NCaDyCSmzFE3DVRS1TI6 5l9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=nDMU+vQz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn22si15229516edb.477.2020.07.21.04.51.58; Tue, 21 Jul 2020 04:52:21 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=nDMU+vQz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729499AbgGULtR (ORCPT + 99 others); Tue, 21 Jul 2020 07:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726755AbgGULtR (ORCPT ); Tue, 21 Jul 2020 07:49:17 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FFFDC061794 for ; Tue, 21 Jul 2020 04:49:15 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id b6so20874113wrs.11 for ; Tue, 21 Jul 2020 04:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=YhhhVF8z1SLInJUZAiDAnUC6bgocyhhgqr0w45WOgKE=; b=nDMU+vQzOjCBxZoK6uTXWTLLlkjbn/xqdnt0a9+YzT7k59y3jQCMaQAe+lzs4f1Las XDwKkAOt7VTkpqUppn/Ui+XJtYhVaSXB0vyxysiL4kRDOisE/ROVpZ3AoIZdTplZBmqu Lhhk9rAkBsz8ok9kvWiUTc+PNvZ6t5yWrw5aJ+Kwzrc6DEqD1Bdq5gpDmnH2flD+V2/1 Xt+HuqKywm++0CeGmTJDxv9g4hdcRFwvkolInSoU/r0RMWb2MXaDyVkcFHyvNA6zKHZs GR6cOef7oKX74v1/UyuvC3SjbMs+8wP7Q7TBvDEbEOm6e2vukNUll5XyaWU/AaSnmzXX cFRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YhhhVF8z1SLInJUZAiDAnUC6bgocyhhgqr0w45WOgKE=; b=QSfzDi85jhAAALj3mqZrXhbwmvKj79xy1SHBtPAHverS2z1COP5maIOWYz3j1Oz7OP L3zRlc6q6VAyl9Pb+tWWRL/WxJbfErD7//F6remBwfLaTLoO7PWrrT/GXWqw1PF1A68a e8fTvoLixS82zL4ISGiehPfVi0TGx9HGllkjkI3+kub1XRX/ayVdSwmErqZErnOZBqOP JZ3nyF3cs4mh8R804nUX5AHN27Dwuz3j6yBgxlTetso4YP0MBWK9lpS+N/VmXVG8pR/m Y0WYEEnfnv4SaypIlS8Z3f0kfSf3jI5aa24mME38W4rvtbgqiEETAytBQlwEleQfECon ClUQ== X-Gm-Message-State: AOAM533aS0wdxEa+qqqy7Nfv17NFmHKzyhOCRz7CtJKgjE0q68pCZ8zX gCF3CVswKOX/cv5gnmp217bYKDU1BEILFKiFQ6rJeQ== X-Received: by 2002:adf:9203:: with SMTP id 3mr9713351wrj.144.1595332154204; Tue, 21 Jul 2020 04:49:14 -0700 (PDT) MIME-Version: 1.0 References: <20200717075101.263332-1-anup.patel@wdc.com> <20200717075101.263332-3-anup.patel@wdc.com> <63f65ddd-b7c4-b8fd-151c-a77e8c87efed@linaro.org> In-Reply-To: <63f65ddd-b7c4-b8fd-151c-a77e8c87efed@linaro.org> From: Anup Patel Date: Tue, 21 Jul 2020 17:19:02 +0530 Message-ID: Subject: Re: [PATCH v4 2/4] clocksource/drivers: Add CLINT timer driver To: Daniel Lezcano Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Albert Ou , Rob Herring , Thomas Gleixner , Damien Le Moal , Atish Patra , Alistair Francis , linux-riscv , "linux-kernel@vger.kernel.org List" , devicetree@vger.kernel.org, Emil Renner Berhing Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 21, 2020 at 4:32 PM Daniel Lezcano wrote: > > 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 CLI= NT > > + driver is usually used for NoMMU RISC-V systems. > > V3 has a comment about fixing the Kconfig option. I have removed "default y" from the Kconfig option as-per your suggestions. I looked at other Timer Kconfig options. Most of them have menuconfig name. Also, we can certainly have different timer MMIO timer drivers in future. D= o you still insist on making this kconfig option totally silent ?? > > [ ... ] > > > +{ > > + bool *registered =3D per_cpu_ptr(&clint_clock_event_registered, c= pu); > > + struct clock_event_device *ce =3D per_cpu_ptr(&clint_clock_event,= cpu); > > + > > + if (!(*registered)) { > > + ce->cpumask =3D cpumask_of(cpu); > > + clockevents_config_and_register(ce, clint_timer_freq, 200= , > > + ULONG_MAX); > > + *registered =3D 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. Okay, will revert these changes. > > > + enable_percpu_irq(clint_timer_irq, > > + irq_get_trigger_type(clint_timer_irq)); > > + return 0; > > +} > > + > > [ ... ] > > > -- > Linaro.org =E2=94=82 Open source software for AR= M SoCs > > Follow Linaro: Facebook | > Twitter | > Blog Regards, Anup