Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2759404rwb; Wed, 30 Nov 2022 10:27:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TJz+DJVxz28T3t7QItjbAMo3XCb05M9XzM70NaAoUIeEXRqZGGol1w2qFcu/BknbPhMVr X-Received: by 2002:a05:6402:a41:b0:462:273b:6b5c with SMTP id bt1-20020a0564020a4100b00462273b6b5cmr55323204edb.57.1669832831631; Wed, 30 Nov 2022 10:27:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669832831; cv=none; d=google.com; s=arc-20160816; b=sWwaqdW17up1x+ItfXwTYyShT47VEI4h3opM0k+aQ829PMs2OC3+itX8pptjMRackt EDC/n6QJ81N8Wdpk9YufhBq192UOO9PyulRKW3QBLHqtV8ZT5fJA9DYmHEXkt1951Prl vBF9h/pLBzGHZbcvWISjDG4ppnEoOqgsS8pjRXhWT+GG6e/Di1aaUFZd+cznHApnEmBr W9YnDwgInmJit51RcAjuNBl9gxCM+MGjmIzNTnrUiyMKTfLEcdHLKLnGZl/sIJADQy8x VC/zvkZ/pwpM+iYNwVatQWTNfMbPJnc7PxaMm7WyYd/yzOi6U4O7zcKQV4hWxCAajOJD 45mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=lpfzLDwg0eAcIbNy+S7hKNwTaWiIGYnyHpXKjlfRUtc=; b=amyooZf76vMWxpCyMS6beuTgtrg56FTtSlvGDE4TSsX/ctEc1VBJlLzXmOdKvyOTDj IvEfGL6g8J6lcIBbfuBti67W7COWb+tWTa57ZVTO5bQsPc3Mc60ezHjUgC9bLTaRlqmQ MUI6w2ChFKTL46UEHWL2iFAPgOB94pzKi4pIboilm3Jrac2U9XZBz3pMTK/deNQmUm16 pfCLg5AVCLGzoAFMlSIrPC2XXsjPyZ5EPw4YD3BZZI3F+xDuZVN616b0dmNqfqo6M2d1 0qK98Z4K7U+UXWDNEOEpTMW06TeXD8y6okUlm7lDBoYuDy5ji8qtcK1LFiYioS99QwqQ 0FLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AKAaytmG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w16-20020a05640234d000b0046b999e8862si1833479edc.20.2022.11.30.10.26.51; Wed, 30 Nov 2022 10:27:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AKAaytmG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229977AbiK3SDA (ORCPT + 83 others); Wed, 30 Nov 2022 13:03:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbiK3SC6 (ORCPT ); Wed, 30 Nov 2022 13:02:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1172948424 for ; Wed, 30 Nov 2022 10:02:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 986F161D01 for ; Wed, 30 Nov 2022 18:02:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0E1EC433D7; Wed, 30 Nov 2022 18:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669831375; bh=Y9g7phTOGvNc4CFm3fAtwIfggfZ/yOOnreTfYzARfZ0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AKAaytmGy4nwo0o2XypCIP1SLXaibMtmFQYjTlLnYcPL3TlB01xbiZNsIplEOESVj f5DCVgc1txkD4EtOCo1kh5V+qF3vqN6am3iHZHNwiowyFEGK9nbhZxtabeMNk7VNXO 6T+xVbkTEBbjeMYy6Z4LVxQBCBhLwscACu2otNaYwtoezCHJ+Ye9O75dcKashEL/mj yJDTpdlI35BljepvO1zIGRqgg/Et4HGFbjDZI1DvO9Z9KjQwPNBo2EIANByBnrzJNJ WxPAvrUpWlBhx7wnEaWjsfPiqsj5JBDB0wr6sRPFVussoBRBltvUg43cd3k7w2tvNX If+pFYMl8jbKA== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1p0RQ2-009eMw-Ri; Wed, 30 Nov 2022 18:02:52 +0000 Date: Wed, 30 Nov 2022 18:02:29 +0000 Message-ID: <87o7sotj62.wl-maz@kernel.org> From: Marc Zyngier To: Anup Patel Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Daniel Lezcano , Atish Patra , Alistair Francis , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v13 4/7] RISC-V: Treat IPIs as normal Linux IRQs In-Reply-To: References: <20221129142449.886518-1-apatel@ventanamicro.com> <20221129142449.886518-5-apatel@ventanamicro.com> <86bkoomn4h.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: anup@brainfault.org, apatel@ventanamicro.com, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, daniel.lezcano@linaro.org, atishp@atishpatra.org, Alistair.Francis@wdc.com, 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 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Nov 2022 17:14:09 +0000, Anup Patel wrote: > > On Wed, Nov 30, 2022 at 9:48 PM Marc Zyngier wrote: > > > > On Tue, 29 Nov 2022 14:24:46 +0000, > > Anup Patel wrote: > > > > > > Currently, the RISC-V kernel provides arch specific hooks (i.e. > > > struct riscv_ipi_ops) to register IPI handling methods. The stats > > > gathering of IPIs is also arch specific in the RISC-V kernel. > > > > > > Other architectures (such as ARM, ARM64, and MIPS) have moved away > > > from custom arch specific IPI handling methods. Currently, these > > > architectures have Linux irqchip drivers providing a range of Linux > > > IRQ numbers to be used as IPIs and IPI triggering is done using > > > generic IPI APIs. This approach allows architectures to treat IPIs > > > as normal Linux IRQs and IPI stats gathering is done by the generic > > > Linux IRQ subsystem. > > > > > > We extend the RISC-V IPI handling as-per above approach so that arch > > > specific IPI handling methods (struct riscv_ipi_ops) can be removed > > > and the IPI handling is done through the Linux IRQ subsystem. > > > > > > Signed-off-by: Anup Patel > > > --- > > > arch/riscv/Kconfig | 2 + > > > arch/riscv/include/asm/sbi.h | 10 +- > > > arch/riscv/include/asm/smp.h | 35 ++++--- > > > arch/riscv/kernel/Makefile | 1 + > > > arch/riscv/kernel/cpu-hotplug.c | 3 +- > > > arch/riscv/kernel/irq.c | 3 +- > > > arch/riscv/kernel/sbi-ipi.c | 81 ++++++++++++++++ > > > arch/riscv/kernel/sbi.c | 106 +++----------------- > > > arch/riscv/kernel/smp.c | 155 +++++++++++++++--------------- > > > arch/riscv/kernel/smpboot.c | 5 +- > > > drivers/clocksource/timer-clint.c | 65 ++++++++++--- > > > drivers/irqchip/Kconfig | 1 + > > > drivers/irqchip/irq-riscv-intc.c | 55 +++++------ > > > 13 files changed, 287 insertions(+), 235 deletions(-) > > > create mode 100644 arch/riscv/kernel/sbi-ipi.c > > > > > > > [...] > > > > > diff --git a/arch/riscv/kernel/sbi-ipi.c b/arch/riscv/kernel/sbi-ipi.c > > > new file mode 100644 > > > index 000000000000..6466706b03a7 > > > --- /dev/null > > > +++ b/arch/riscv/kernel/sbi-ipi.c > > > @@ -0,0 +1,81 @@ > > > +// SPDX-License-Identifier: GPL-2.0-only > > > +/* > > > + * Multiplex several IPIs over a single HW IPI. > > > + * > > > + * Copyright (c) 2022 Ventana Micro Systems Inc. > > > + */ > > > + > > > +#define pr_fmt(fmt) "riscv: " fmt > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +static int sbi_ipi_virq; > > > +static DEFINE_PER_CPU_READ_MOSTLY(int, sbi_ipi_dummy_dev); > > > + > > > +static irqreturn_t sbi_ipi_handle(int irq, void *dev_id) > > > +{ > > > + csr_clear(CSR_IP, IE_SIE); > > > + ipi_mux_process(); > > > + return IRQ_HANDLED; > > > > Urgh... I really wish I hadn't seen this. This requires a chained > > handler. You had it before, and yet you dropped it. Why? > > > > Either you call ipi_mux_process() from your root interrupt controller, > > or you implement a chained handler. But not this. > > > > Same thing about the clint stuff. > > We had chained handler all along but there is problem (which > was pointed to us) in using chained handler because the parent > RISC-V INTC irqchip driver does not have irq_eoi() so the > chained_irq_enter() and chained_irq_exit() will do the interrupt > mask/unmask dance which seems unnecessary. > > Is there a better way to avoid the interrupt mask/unmask dance ? Well, you could have an IPI-specific irqchip, with an empty EOI callback. Or something. But not *that*. And next time you change something of that importance, add it to your change log. M. -- Without deviation from the norm, progress is not possible.