Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2726753rwb; Wed, 30 Nov 2022 10:03:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf50gCBaVFOUsaoSZQ0+Z7ENuaT0USTBC4EghbSHz9xV+RGBRh0rGx0fmEZCdC3pYZYG9vMQ X-Received: by 2002:a17:902:8d98:b0:189:8e39:3c88 with SMTP id v24-20020a1709028d9800b001898e393c88mr15681971plo.102.1669831412108; Wed, 30 Nov 2022 10:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669831412; cv=none; d=google.com; s=arc-20160816; b=M0OVDj3d4L5WJPxeyG3OmpdSSlsqbbqRkxJggIdeTeRUxO4cu1+4ZA8+1iRVHhY/df 7fw3EvE0YCubXgSL4YEyYJx/Up0h2UDKnwXrWnBpG6Yc/nCq5pjiY/hThbVBm5ZNZxcr 6/UzwqU3OMQzMQ9dYC2Ogz0QXU2GzoHdU8fFb55H6ZB/bU2RsdDYwE2Gc6CrsdVeUzIn ez1XWyamd5OOZ69e0IwyT4HugiDMommPQd3Ye2ew2OlIOcqDu8miZrE+gFklLr4XaBMM SUzJDvur5wXqva2EORxG4Rn+qWrPIbrqcpQ9qk42kdiPkAMF28p61eNsa02HpS48bOzv ohVA== 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=7bqEm6dhy2mtmL31o/UB0N7eJH0FMW9uyfWpHaycfE4=; b=XeP/xlilOHfUjHcHb8xDd70QonfWw8sl5mTD3Nk2qRQ2LxqlV+qKpnb1bMTQ6VR2GG oX0JKEgnLrYIXWdePcB1uoGQymC4nu+70/JRWozlYDlYFgktqTQCgJdBmCybszoixE9f O6FZ/mvcroOzvjLoxTd31GO4Ezql1qtFkcNs3y/SiZ1KoDMe6krgLIkqmwOs5Yw/a+RC nUG+3mIqAJBaNEowKCb8xvQdTFAD/XoXBVe5dlJC23fNR2wERHVClAWAKpsn/NhOYl9Q v1qUErvrgJceomyhRnfDtTE0z2yhMNAyYAFR9Cd1I8GqyVClzVL4eO6AW0xlR/zJ6gMZ njRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iIsVl68C; 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 u14-20020a056a00158e00b005747e0112e0si2264381pfk.310.2022.11.30.10.03.21; Wed, 30 Nov 2022 10:03:32 -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=iIsVl68C; 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 S229589AbiK3QTB (ORCPT + 83 others); Wed, 30 Nov 2022 11:19:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiK3QTA (ORCPT ); Wed, 30 Nov 2022 11:19:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC8682AE07 for ; Wed, 30 Nov 2022 08:18:58 -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 67FED61C7B for ; Wed, 30 Nov 2022 16:18:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF3D3C433C1; Wed, 30 Nov 2022 16:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669825137; bh=6finBBhB41rftQpLaBk5vk/KMUvYxNjc4FlI2SQgK4o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iIsVl68CpjNQALNiIfuVDhoRoZnkBMZY2gLRT5+yI+bUDBV5tGBYU7MD0JItgEICT byzsKlJGX6jbzbvI9WVlpTwglKvj4V6BJxVOfd/09LC7VEd4c1yew97L2VNagSKHoS XHCczQMqRuM5fZOECJeUESLXdb6MEXUra8B1ZYOm3liQl28Stq0Oiu+eLUlzna0GMJ 7t3QSjuSIMJXuypCCQA2Grr9+mzAb1e4O9avFcGaV6Lv1I23ZPAPAL27qSiJI4xg/k hbGqOCsUGRwJfo35hrIyozyMZ72XA8y/3hYE7y7eKGejdNKOPSfq5y8zDX6rpa8cRz U7XrP6rdd/ktg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1p0PnS-009cnr-Hp; Wed, 30 Nov 2022 16:18:54 +0000 Date: Wed, 30 Nov 2022 16:18:54 +0000 Message-ID: <86bkoomn4h.wl-maz@kernel.org> From: Marc Zyngier To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Daniel Lezcano , Atish Patra , Alistair Francis , Anup Patel , 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: <20221129142449.886518-5-apatel@ventanamicro.com> References: <20221129142449.886518-1-apatel@ventanamicro.com> <20221129142449.886518-5-apatel@ventanamicro.com> 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 (aarch64-unknown-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.219.108.64 X-SA-Exim-Rcpt-To: apatel@ventanamicro.com, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, daniel.lezcano@linaro.org, atishp@atishpatra.org, 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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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. M. -- Without deviation from the norm, progress is not possible.