Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2816970rwb; Wed, 30 Nov 2022 11:14:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf79H7d7Yp0uyF76HZsJWDZ5KONDhXNRkzFYygcnMPyFnaE3QXQNWqa4zBAicaRllYhrpZUW X-Received: by 2002:a05:6402:2488:b0:467:3ea1:acdd with SMTP id q8-20020a056402248800b004673ea1acddmr58540975eda.96.1669835655280; Wed, 30 Nov 2022 11:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669835655; cv=none; d=google.com; s=arc-20160816; b=t07WdcuHe6wjzI6wqfZMPb6NA2FRUKPfbQ7B8B+A5yAksXEdfdEmyvskflZVCSKEFG UlvKqIFZQvs8hsPYrt88gEqea6ZobislHQ0yKpy92xM+Y9rmQQ55GK3k4AKjWBUKnpqZ UgTzkVY8hHfU47VIGSsMnZQsaasB/mMUEBTENnlgtG50afHuy/ORTigxTn8c1wwnVxOp T9R87jl6C1eSCQoW/j8eDCzDggxmEQlMltVXjHa4ctF02rtSZn+r/sUcXbs7gyMVewCI B+ZjuLWjtrh5n3QNWEksckWjyt7TVvvGlM1lteMsGzmiTIsZC5gvQXaPWDg6GZQORrg8 wH0g== 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=j7K3QQjgetcF0dnn3oVBs1JgDTRJdaG+fBSNdtFt0EA=; b=zzfzG4hvtfxt/Gpab/mr0fFRKRsKLwKht611ee2/zd8N0EQw0yZWwgfzINOgGXdDbP YXqQcYWBFrFNilKtrbUf+TUIY7DWe+WM2dwLAp9XS51M+MkZgud42fpddznOQGMAPBML HMm/j5TqtiruMvh1MnirQhWLlnJWGSUkjnIfbUFVx1zwanSjDb5WnrlR5oKfEyC4fW5K KOdBqQZW8Eh7ZEzKxTHbP1eSyHb8uYjIP67WvOOXd/+kf5k9bNNrbpmpINjjNa6oHR4H g+y2lDDKooz3kA0YRys71pmwDUsR4h5mFH7hS+fKVJjELZoi7jYLTVlE1L5h2wN9aAjx ySeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=Lk7DM7Xh; 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 ss2-20020a170907c00200b007bed39516b0si1462577ejc.921.2022.11.30.11.13.54; Wed, 30 Nov 2022 11:14:15 -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=Lk7DM7Xh; 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 S229795AbiK3SQY (ORCPT + 83 others); Wed, 30 Nov 2022 13:16:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbiK3SQF (ORCPT ); Wed, 30 Nov 2022 13:16:05 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 781D592080 for ; Wed, 30 Nov 2022 10:14:40 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id z20so25160356edc.13 for ; Wed, 30 Nov 2022 10:14:40 -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=j7K3QQjgetcF0dnn3oVBs1JgDTRJdaG+fBSNdtFt0EA=; b=Lk7DM7XhMtPu5Cq9CE5ZDFKoOKUT6mHLWd98yCqFse4aDUwytBmZ4YTHSrCY9SDbbV 5GNe6VYUHia592/EGt6Aw2Ms/Nxx3i5XDODt6qHqTKfiJASGf0U8v7V3b77aTTCid0f4 RsmsbiaDAMdUiAib7vvpXjCVipj88D6c2kLSoCUojsh+N81VU5hiI/shxf2QxrE/GOBT giA87QJP1iqm3bte6q7Tk1AjMyo6uw15OD0B1KZpRBFHKStnGmF6TqrXmPzUnvL61AJu 5uOjwp1O6iWjUgy7P+fzoUDCeGeLGLp54c8jYTrrL8j+n0jV7Hbl+4a0o6aM7yNPeUOV loog== 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=j7K3QQjgetcF0dnn3oVBs1JgDTRJdaG+fBSNdtFt0EA=; b=juNMqGCWc+NTlg9nDzi9Cd3Wl9q/CeSQ6xO4lN1IhJBDqS7ezsCZRXR8eUmexcE75c 53c9pfXkFES0IgTJpeyPLP2RhvNE8VB37Ox0gnf9tvz0z2TZtNc7tJmjSexMF/kP6qTE 4WAA9O1aX2fJ+ayo5pkSI5JAeaK2emA+ZApVI8wCOwRJNC3qwnIr1RenFxYzfh+5zPbd w9sEkbQbg7fMbSUiB+vK4ylsnep3hV1kmWpFEq+jwIkFNObYcLzvKIIWOhyekppCgzuU EknkjJlnjrgpmU/wVaU4bR8tqNdvzTnpkNNBoSmSy+BDVyG5pbyyY+OG9MLejOA3E3uQ UIeQ== X-Gm-Message-State: ANoB5pkvQ8W/3uVJOGeLAHv5TEv/dV9FqZw7LY3GfVgPLKe1v+u+bnNS 1ILX/R4lMiiyjG7A7Qg0XLSGkxFqFPPG88joz+67ww== X-Received: by 2002:aa7:c859:0:b0:461:17e9:4ea3 with SMTP id g25-20020aa7c859000000b0046117e94ea3mr56716157edt.49.1669832078541; Wed, 30 Nov 2022 10:14:38 -0800 (PST) MIME-Version: 1.0 References: <20221129142449.886518-1-apatel@ventanamicro.com> <20221129142449.886518-5-apatel@ventanamicro.com> <86bkoomn4h.wl-maz@kernel.org> <87o7sotj62.wl-maz@kernel.org> In-Reply-To: <87o7sotj62.wl-maz@kernel.org> From: Anup Patel Date: Wed, 30 Nov 2022 23:44:27 +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 11:32 PM Marc Zyngier wrote: > > 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*. Is it okay to add an empty irq_eoi() in drivers/irqchip/irq-riscv-intc.c with detailed comments since this driver uses handle_percpu_devid_irq() flow ? > > And next time you change something of that importance, add it to your > change log. Sure, will do. > > M. > > -- > Without deviation from the norm, progress is not possible. Regards, Anup