Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1293904ybm; Sat, 30 May 2020 04:44:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtHQjavee6H9mkwjV48pEEQipLt3jh5xxYwQ/zl4e8tzgi6ZiVcauPfkPDi1yq+ql2tQyo X-Received: by 2002:a17:906:1088:: with SMTP id u8mr12163102eju.428.1590839066188; Sat, 30 May 2020 04:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590839066; cv=none; d=google.com; s=arc-20160816; b=cuCXQvauV6ysYtWLfsDQcyZJldtC/lbkWLBZD8XK1p9c+lQcR8aEwQvke5J6RkY7CU w4puujKqbL7lIvn3/dGDtqgRdXKkU81xhcrA9+dpm5lUQvQt904FntWfhKhwLdRLMEuo XmrBzIUIbtQc1SkEszTkx66bHvm4TWrvtqiI73rttH1r/GDL+kXNP94aX0cfS7WQ6MxX ADcXBSqKuCTmV1Mw/xY1Sy35kb1yMsM1LR9idk8pwNCDEyxreKbsFuT7UyiDO1vKa2Q2 7vEXjg1wlUDJcSZ3CVE9EGqSURWMGJfpiCHzFAtuax57Ngqp8gJKQm+3vNQWF4MBeIK5 kAvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=21sQP/zmnQFf41fXE4vZsoQf5A/BB95S7p3I3br0iJQ=; b=KHj+WpDdsJEnfriZW4NiV04XcFmnvb9Bz0Mh+i8r8NjEvmzb+ILI2tJbiGNauV6Si2 4l2biE5PSJ6FWTUKHwqGIxUXv6AV6OS1ppUAFwIG0Jj3QHgOjRCZIckcaq89jXoRj8mb 9jbnfqltN2JjzoGfGSQzjcbm2th/GxlSpdLe4BEE62KbZ9FnilOitBUYI7Lt1uZtS5fB SCllsF8gm0zECy/ZY4Jp94/3rP2Fg35c7xmPsVhUyKDbL5toI9gwB7QvqECLWF4tMBOY iTjNfOcjQ+GmynlfjeBf1yjiK05Fse69PFjecrlxynpBUgnhVUXVjjPXONuKVvokP6XK hB7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AdD51k26; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si7518859ejz.660.2020.05.30.04.44.02; Sat, 30 May 2020 04:44:26 -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=@kernel.org header.s=default header.b=AdD51k26; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728941AbgE3Ll0 (ORCPT + 99 others); Sat, 30 May 2020 07:41:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:47830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727947AbgE3LlZ (ORCPT ); Sat, 30 May 2020 07:41:25 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 854CF206C3; Sat, 30 May 2020 11:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590838884; bh=rVDhV2vAFhEf0xk3y1F3ElGbH9lOTyved4Q4Ncoc9sY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AdD51k266D3EFq7x6xbTQZDCUr0bLCc1yUqez9xWVWX456N+2E6Wbq1Um6/oYFj3Q /UEwj/rbA9oRmoodiJmN8LkDQpJTUHuIxY3QLJpnpoW33DueTnAnbA0HruDwYAwhXW UwYoyoRIhU98vahB5v9FNmY+Fr2rUMgwyajR4iPQ= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jezrf-00GX4B-0j; Sat, 30 May 2020 12:41:23 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 30 May 2020 12:41:22 +0100 From: Marc Zyngier To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Thomas Gleixner , Jason Cooper , Atish Patra , Alistair Francis , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 4/6] clocksource/drivers/timer-riscv: Use per-CPU timer interrupt In-Reply-To: <20200530100725.265481-5-anup.patel@wdc.com> References: <20200530100725.265481-1-anup.patel@wdc.com> <20200530100725.265481-5-anup.patel@wdc.com> User-Agent: Roundcube Webmail/1.4.4 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: anup.patel@wdc.com, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, daniel.lezcano@linaro.org, tglx@linutronix.de, jason@lakedaemon.net, atish.patra@wdc.com, Alistair.Francis@wdc.com, anup@brainfault.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-30 11:07, Anup Patel wrote: > Instead of directly calling RISC-V timer interrupt handler from > RISC-V local interrupt conntroller driver, this patch implements > RISC-V timer interrupt as a per-CPU interrupt using per-CPU APIs > of Linux IRQ subsystem. > > Signed-off-by: Anup Patel > Reviewed-by: Atish Patra > --- > arch/riscv/include/asm/irq.h | 2 -- > drivers/clocksource/timer-riscv.c | 41 ++++++++++++++++++++++++++++--- > drivers/irqchip/irq-riscv-intc.c | 8 ------ > 3 files changed, 38 insertions(+), 13 deletions(-) > > diff --git a/arch/riscv/include/asm/irq.h > b/arch/riscv/include/asm/irq.h > index a9e5f07a7e9c..9807ad164015 100644 > --- a/arch/riscv/include/asm/irq.h > +++ b/arch/riscv/include/asm/irq.h > @@ -10,8 +10,6 @@ > #include > #include > > -void riscv_timer_interrupt(void); > - > #include > > #endif /* _ASM_RISCV_IRQ_H */ > diff --git a/drivers/clocksource/timer-riscv.c > b/drivers/clocksource/timer-riscv.c > index c4f15c4068c0..1fe847983f50 100644 > --- a/drivers/clocksource/timer-riscv.c > +++ b/drivers/clocksource/timer-riscv.c > @@ -12,8 +12,11 @@ > #include > #include > #include > +#include > #include > #include > +#include > +#include > #include > #include > > @@ -39,6 +42,7 @@ static int riscv_clock_next_event(unsigned long > delta, > return 0; > } > > +static unsigned int riscv_clock_event_irq; > static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = > { > .name = "riscv_timer_clockevent", > .features = CLOCK_EVT_FEAT_ONESHOT, > @@ -74,30 +78,36 @@ static int riscv_timer_starting_cpu(unsigned int > cpu) > struct clock_event_device *ce = per_cpu_ptr(&riscv_clock_event, cpu); > > ce->cpumask = cpumask_of(cpu); > + ce->irq = riscv_clock_event_irq; > clockevents_config_and_register(ce, riscv_timebase, 100, 0x7fffffff); > > - csr_set(CSR_IE, IE_TIE); > + enable_percpu_irq(riscv_clock_event_irq, > + irq_get_trigger_type(riscv_clock_event_irq)); > return 0; > } > > static int riscv_timer_dying_cpu(unsigned int cpu) > { > - csr_clear(CSR_IE, IE_TIE); > + disable_percpu_irq(riscv_clock_event_irq); > return 0; > } > > /* called directly from the low-level interrupt handler */ > -void riscv_timer_interrupt(void) > +static irqreturn_t riscv_timer_interrupt(int irq, void *dev_id) > { > struct clock_event_device *evdev = this_cpu_ptr(&riscv_clock_event); > > csr_clear(CSR_IE, IE_TIE); > evdev->event_handler(evdev); > + > + return IRQ_HANDLED; > } > > static int __init riscv_timer_init_dt(struct device_node *n) > { > int cpuid, hartid, error; > + struct device_node *child; > + struct irq_domain *domain; > > hartid = riscv_of_processor_hartid(n); > if (hartid < 0) { > @@ -115,6 +125,23 @@ static int __init riscv_timer_init_dt(struct > device_node *n) > if (cpuid != smp_processor_id()) > return 0; > > + domain = NULL; > + for_each_child_of_node(n, child) { > + domain = irq_find_host(child); > + if (domain) > + break; > + } This is a bit clumsy, and probably better written as: child = of_get_compatible(n, "riscv,cpu-intc"); if (!child) { error out } domain = irq_find_host(child); It would be even better if each CPU would have its per-CPU interrupt controller designated as such (with an interrupt-parent property), meaning that you wouldn't have to do anything at all. Too late for that anyway. M. -- Jazz is not dead. It just smells funny...