Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2386080ybh; Mon, 9 Mar 2020 04:59:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuvnuw5xRK4g5u+clbHOJzuxlrJLum5BwPIDmbiXnHQ427j1WNUhy/L319/RVJCajE2ncmr X-Received: by 2002:a9d:30c7:: with SMTP id r7mr239236otg.289.1583755148779; Mon, 09 Mar 2020 04:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583755148; cv=none; d=google.com; s=arc-20160816; b=dBsC/vg18MLBb/NMHZ3d8umdzjpzHFcO5uW+fAQgHDZhlzJG15k0ucjHOcWkb//d3d jkq69E5CJgiwkrnGf2lHLdXp8zAKwsvPQEKfv15jNDvhalwpG7RId+VzGdWOPKr2Ubus 8FOevgu0IgNdpY/pMrQjShTnvtULZLOCjrmSi5jJd2jdF7qV3McjiBMMmf/21Ly0fxmD txWRGWMxpHTNP5Cg2qjoDsrzHaQOknJYCY50rtmRgdJQCsp9vAwDyNz5KgHMHbuhIgOx Q44KTakbT1aZo9gh6vflpdCOuZ/ZDHRur9vPNMSraH67N9sdBYrK9EKnlsTD5KrACbw7 j/ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iouomU3fha5mQRskwANgwh7TuSQV901CBUJScXX1uj0=; b=luGWTY/y9E3GiQRITmdvOICMaNCKCQ1utgGz0EBC+Sr9WbV88vrxLb8XyP06B8Yh4y fjokEuYpetziZixZ0sLu5Ms/XNywt04HYXxUbu+qXys7d8mOKYQfrF8f+3ZG7vmQpDyD M4Gr/CU/qL3d9NuUxP43kQUg3EIbB56dNeuLix4odhwp5hknt8dKSWCNUHLZvfgcnONH oEPSdX4nYpdRbpvpltre7IEd5d43XuKPsExbPySc+4jOMLZASPrrRQQS5pSGJkLJO7pS 6/AOL6gz4psh+3MhsoL+hG+80LTDOBdwK+xCIYTQ3flBJGXVItGlz8to5a0pPJpnkADo silQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=pJYC8nJJ; 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 l23si6202566ots.79.2020.03.09.04.58.56; Mon, 09 Mar 2020 04:59:08 -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=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=pJYC8nJJ; 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 S1726605AbgCIL6f (ORCPT + 99 others); Mon, 9 Mar 2020 07:58:35 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44340 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbgCIL6f (ORCPT ); Mon, 9 Mar 2020 07:58:35 -0400 Received: by mail-wr1-f68.google.com with SMTP id l18so640470wru.11 for ; Mon, 09 Mar 2020 04:58:34 -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; bh=iouomU3fha5mQRskwANgwh7TuSQV901CBUJScXX1uj0=; b=pJYC8nJJP+qpBuNr4ascYa7DIinBaYwRPte2DGewZ2ZK8SslwP7kjJRt9Fh2PPxjTM JH1SJ/KgU6nHhtfX9AXe2R+O8+RjzdyeLhzzcdYLhc6/fDVx0CySJD0avA6JO52iEReQ +/3JJUGB+exnvIJLaW+o21GhpmZ8pG/2YYDuI3jSj3Xfqxekrxon5JCLZQNOhAEQ2G9x 0BGhfL+QrdJb2e0pRBPbMsoLeuK5+jFPHWeu4KFmZzlHCTGgO7COUX0ATIQMlzu9xKf7 5JFyz15gNYegP50JifiO1parr/ayDRr+Z0vOHvuzQlxQkdKiRMlyLuH6yTCxuCz4o1Po 35fg== 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; bh=iouomU3fha5mQRskwANgwh7TuSQV901CBUJScXX1uj0=; b=KERXdV9W8xx21VotqoXkLl5ETrN3nW/rGf7jG+iEv2Akoo91CS1hYJSq+hcyN4aeWT HGajmwqXSLaqfFqoeygCl9jVptbESy36BXWAWtLIrdJGnUDpFZ/e/6rmcI03oj/s7DNM F/VU7w0C98U+UZzpKSy0S9N+VqpWHzU0FxB9ekB3Dse9gPKHct8tSC+3BjvE1G2066ug +vI+VmvFIu9RWky7pQ55bUP1jgjbxGL6pYtypyNCdm0pmXvT5tDADV6Era8n0NuHNGxZ 9CQSDHaNjyiHVj8kWdMRFkaBX/3c0wsO5wEahjCvLjKGC4IzHknoxKlOZzANce1fR+FI YLNA== X-Gm-Message-State: ANhLgQ1l/Hys4HAxIJZgqkw6qsyoIKcftGyhzDArzR0d688z9t1Qi7rf fg5LiPvjDscbeeIinQAL4k2Gopkx3zqxuohFiYLbMg== X-Received: by 2002:adf:ec45:: with SMTP id w5mr20444241wrn.230.1583755113268; Mon, 09 Mar 2020 04:58:33 -0700 (PDT) MIME-Version: 1.0 References: <20200309110211.91130-1-anup.patel@wdc.com> <20200309110211.91130-2-anup.patel@wdc.com> In-Reply-To: <20200309110211.91130-2-anup.patel@wdc.com> From: Anup Patel Date: Mon, 9 Mar 2020 17:28:19 +0530 Message-ID: Subject: Re: [PATCH v4 1/5] RISC-V: self-contained IPI handling routine To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Thomas Gleixner , Jason Cooper , Atish Patra , Alistair Francis , linux-riscv , "linux-kernel@vger.kernel.org List" , Marc Zyngier Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixed Marc's email address. On Mon, Mar 9, 2020 at 4:32 PM Anup Patel wrote: > > Currently, the IPI handling routine riscv_software_interrupt() does > not take any argument and also does not perform irq_enter()/irq_exit(). > > This patch makes IPI handling routine more self-contained by: > 1. Passing "pt_regs *" argument > 2. Explicitly doing irq_enter()/irq_exit() > 3. Explicitly save/restore "pt_regs *" using set_irq_regs() > > With above changes, IPI handling routine does not depend on caller > function to perform irq_enter()/irq_exit() and save/restore of > "pt_regs *" hence its more self-contained. This also enables us > to call IPI handling routine from IRQCHIP drivers. > > Signed-off-by: Anup Patel > --- > arch/riscv/include/asm/irq.h | 1 - > arch/riscv/include/asm/smp.h | 3 +++ > arch/riscv/kernel/irq.c | 16 ++++++++++------ > arch/riscv/kernel/smp.c | 11 +++++++++-- > 4 files changed, 22 insertions(+), 9 deletions(-) > > diff --git a/arch/riscv/include/asm/irq.h b/arch/riscv/include/asm/irq.h > index 6e1b0e0325eb..0183e15ace66 100644 > --- a/arch/riscv/include/asm/irq.h > +++ b/arch/riscv/include/asm/irq.h > @@ -13,7 +13,6 @@ > #define NR_IRQS 0 > > void riscv_timer_interrupt(void); > -void riscv_software_interrupt(void); > > #include > > diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h > index f4c7cfda6b7f..40bb1c15a731 100644 > --- a/arch/riscv/include/asm/smp.h > +++ b/arch/riscv/include/asm/smp.h > @@ -28,6 +28,9 @@ void show_ipi_stats(struct seq_file *p, int prec); > /* SMP initialization hook for setup_arch */ > void __init setup_smp(void); > > +/* Called from C code, this handles an IPI. */ > +void handle_IPI(struct pt_regs *regs); > + > /* Hook for the generic smp_call_function_many() routine. */ > void arch_send_call_function_ipi_mask(struct cpumask *mask); > > diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c > index 345c4f2eba13..bb0bfcd537e7 100644 > --- a/arch/riscv/kernel/irq.c > +++ b/arch/riscv/kernel/irq.c > @@ -19,12 +19,15 @@ int arch_show_interrupts(struct seq_file *p, int prec) > > asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs) > { > - struct pt_regs *old_regs = set_irq_regs(regs); > + struct pt_regs *old_regs; > > - irq_enter(); > switch (regs->cause & ~CAUSE_IRQ_FLAG) { > case RV_IRQ_TIMER: > + old_regs = set_irq_regs(regs); > + irq_enter(); > riscv_timer_interrupt(); > + irq_exit(); > + set_irq_regs(old_regs); > break; > #ifdef CONFIG_SMP > case RV_IRQ_SOFT: > @@ -32,19 +35,20 @@ asmlinkage __visible void __irq_entry do_IRQ(struct pt_regs *regs) > * We only use software interrupts to pass IPIs, so if a non-SMP > * system gets one, then we don't know what to do. > */ > - riscv_software_interrupt(); > + handle_IPI(regs); > break; > #endif > case RV_IRQ_EXT: > + old_regs = set_irq_regs(regs); > + irq_enter(); > handle_arch_irq(regs); > + irq_exit(); > + set_irq_regs(old_regs); > break; > default: > pr_alert("unexpected interrupt cause 0x%lx", regs->cause); > BUG(); > } > - irq_exit(); > - > - set_irq_regs(old_regs); > } > > void __init init_IRQ(void) > diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c > index eb878abcaaf8..1e8f44a47e14 100644 > --- a/arch/riscv/kernel/smp.c > +++ b/arch/riscv/kernel/smp.c > @@ -121,11 +121,14 @@ static inline void clear_ipi(void) > clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id())); > } > > -void riscv_software_interrupt(void) > +void handle_IPI(struct pt_regs *regs) > { > + struct pt_regs *old_regs = set_irq_regs(regs); > unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits; > unsigned long *stats = ipi_data[smp_processor_id()].stats; > > + irq_enter(); > + > clear_ipi(); > > while (true) { > @@ -136,7 +139,7 @@ void riscv_software_interrupt(void) > > ops = xchg(pending_ipis, 0); > if (ops == 0) > - return; > + goto done; > > if (ops & (1 << IPI_RESCHEDULE)) { > stats[IPI_RESCHEDULE]++; > @@ -158,6 +161,10 @@ void riscv_software_interrupt(void) > /* Order data access and bit testing. */ > mb(); > } > + > +done: > + irq_exit(); > + set_irq_regs(old_regs); > } > > static const char * const ipi_names[] = { > -- > 2.17.1 >