Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2698280rwb; Wed, 30 Nov 2022 09:40:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf5967FF78moUPfD1/Bp2UuViOOUqJHyFvsviK+54RHVtaqXZl/+IOLBwVLYXgJjRwSqLpkj X-Received: by 2002:a17:907:b60f:b0:787:8884:78df with SMTP id vl15-20020a170907b60f00b00787888478dfmr36876153ejc.246.1669830018141; Wed, 30 Nov 2022 09:40:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669830018; cv=none; d=google.com; s=arc-20160816; b=Mn6BG2vnHc4k8IW8jcLuIMJOkGPqv48YXUqmjHrrA49RWvJFaZO5N/y+ZgS3NL7oF/ LFTx10Iv6vikXDZ+hCv8n97ycstiV3x6q1b5BTODTFYBuYSfk6ir6QD7ns/S0lEAXduA o+iy49XPr0HY8yQY35mWyi8Fbp8eRpu/4zZ7OKPHdP8NxLPxuBsP7gq1YoVkZ1x4xUqe 2uP2xhDoOP/CX+FS2hWFdHSjGrWIyLHD/hv/niKglT9wKW65vG/elDCojt7hfK8b8FEg cu96Jonp9YsfrS9yBMchBzrAy/NMtmPcPjl2TnvB0yujmyqcWGhew2SnPewjPM+CEZyz NxNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Yj3StdHBGTawh0e6h/e+Le5dr9aX+Vm1MyzuqjyovbM=; b=eiUSDZ4xUTJ65T9kY83ecImhzxuyG7VmP8ywWYxTudpjBN9JzCuPsG1FMTrcOksksM gRbUD6f2QKOLQUOZ6gE2Jm9i9wQCOH6DDMcwGX7vGr0oyQe9Bd8TkkrqZk54w09K8E5Y mGl9lM3g16EBaUyY7pukSNXwH077P9dVN6HQLaDSrKgCHdvrWj/BWcxd1JkqzEyWJF58 j+2PqtTUR8ppWW9rixMkMhjIG0k3ozZHUTL7r5E8tpRx5AxoAw1OWxJxbKU0dO+JO7DR t6QhsCd4o4+vNiixkQE8H88DyqDoORiWTh8MekgAGps5n4DFXVsBrWFXKlk7Z4PoIdm5 RCRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=scadwmJX; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a05640227c600b0046a222b78a5si1961609ede.249.2022.11.30.09.39.58; Wed, 30 Nov 2022 09:40:18 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=scadwmJX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbiK3RQH (ORCPT + 83 others); Wed, 30 Nov 2022 12:16:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbiK3RP0 (ORCPT ); Wed, 30 Nov 2022 12:15:26 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA533B08 for ; Wed, 30 Nov 2022 09:14:22 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id a16so3474526edb.9 for ; Wed, 30 Nov 2022 09:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Yj3StdHBGTawh0e6h/e+Le5dr9aX+Vm1MyzuqjyovbM=; b=scadwmJXHd6bp347syF/H4ak1MBvj9K1DEb/9kP+TIsR5O8zYHvZEwO+GZWZhJuZKC 5DuqFIz+i5YyZevQxZH4jWzqELHY1hV2r+5SpE9Js4gvW6kSu1Ve2u/Ua/OC9iEKKrii 9uRw5oFpAkeSOj4AF59t2Ape7Fta4KFwvw860JaR59lda2r1SxEuxKDXwoYsH2joxtiL MPChT6+w1uKq1HLeMVNkyc48sIQvi98DZoLKFOAVcfaebVmhuE4j1KxCasqBCYlWN3Zc FZEAtKAFgVNw5lYv1a7J4SkGFcGwGvWuuW3mc6007J9Rp9XvcVxkiBvj35EESHYpj8iu 48dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Yj3StdHBGTawh0e6h/e+Le5dr9aX+Vm1MyzuqjyovbM=; b=cJ+YoU0CXHxtgUFRMFcQxDipGrDWpugTP62xDCm0mxyCbW8Qa5yMJ+c3ynULhKVb3K /MjHKp/kwVTVFWXSdm+13lCta5uHBCgWqDQuDs7paaA7n37rb01uGoXsKnwLUhfk0BkM FfwpiaPaYoB14sgCpN5864Jbf1YCLB/J82Nc4fM/dty5BsjTh4LA4shTYA/i3CLagxGB p2PCPZoleiKGSoKKZuLvhRIK/yhdx2hToifm+loHqTv8POr2u0DFpiz+jjhOUEXUIPaZ u7l+BYSb0xkVJSfc8TfGqGRI+tmlNvDhYR/2LubHLLozB1VLPmYe52OaXXxj4zfFclkm 5bbg== X-Gm-Message-State: ANoB5pl8wIQJeV8gEmPBw9zV4xBCiEypfxoImQeStL90PVgRA/JXd5Bb nzD2jT1szLJjQBP0220V9FaC66ncI3SZWKB1uGuE4w== X-Received: by 2002:aa7:d7d4:0:b0:46b:7f11:10a4 with SMTP id e20-20020aa7d7d4000000b0046b7f1110a4mr7764818eds.59.1669828461075; Wed, 30 Nov 2022 09:14:21 -0800 (PST) MIME-Version: 1.0 References: <20221129142449.886518-1-apatel@ventanamicro.com> <20221129142449.886518-5-apatel@ventanamicro.com> <86bkoomn4h.wl-maz@kernel.org> In-Reply-To: <86bkoomn4h.wl-maz@kernel.org> From: Anup Patel Date: Wed, 30 Nov 2022 22:44:09 +0530 Message-ID: Subject: Re: [PATCH v13 4/7] RISC-V: Treat IPIs as normal Linux IRQs To: Marc Zyngier 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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, 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 ? Regards, Anup > > M. > > -- > Without deviation from the norm, progress is not possible.