Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2516956rwb; Wed, 30 Nov 2022 07:33:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zBbDFF/Y36l1DlQB2E3FhRlWsfsXriMh9UH74ZWAGhYFYTK6rMGjEc2Qenx2dRhdOmZrp X-Received: by 2002:a17:906:7848:b0:7ad:b286:72da with SMTP id p8-20020a170906784800b007adb28672damr53290988ejm.152.1669822430337; Wed, 30 Nov 2022 07:33:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669822430; cv=none; d=google.com; s=arc-20160816; b=pAtZjxMzcRSlhvMBMv/w/Pqddyk1IOK4+iGnm9mCu3mUL3vn2+tLUQclXvbNog2Aul Jp3rEHX9+d04qHEBfStO4EGEPeb+4ft74KJxzkULDPw4ueb5mEpRZ66xTuvZFeT+WbGi YsvkdP8D8DTBMaFzxptJ+BhbPtm4sRv7IU2Bn13roG3qhVoaEgrNF0d0dxNBHboOfVwf 4EPq+DNGvFp7HmczOLfYFONXHlc9ioOUvL2weWx0shbomhP27yoPU/mF22hQYBjVWt1Z xAapNw44Nx0lpa2AacZu9zDSUgbIchnvVwPgTVaM5rLsQPoIwmF1W+s8ELpWmFw064ka Y74w== 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=+9aJVWSMGimMjRLzLc5e2lneBAo5cm2RjVGUpsGnr9c=; b=atiZikg/FMizcawx5KMgNF0fCS68XVt/rRVi9vDL7prhFZAMZ7HGPtl+nXQh0hrygR HSDmMxbGydD89Tx5uwsC8vndTFL6Rh/BIdOA1vzPAl5Kd3/M8AB0fJfSaz/P+K+Z9oLe YoSveJgijq4ANHvsLug0N/6C4vAq6Oip978pyTU8jCuwZB/h/J9gbGDmlXPZTIfOPgZy qh1uWrF8svmbud2s1LDjF673N5OMwHtOhIh/VtWQ3xWEuK0DcWwikNrM3V9ODKgL7z0a dCLmu4HUhqCls3a7M4IJfgTnQByWMENpfNtn6kqNrr/u5Ux/nYD32ech7Zfw9Hb69Hm3 9qkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ALxY+CFY; 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 dr3-20020a170907720300b007ba49ec6d3bsi1583185ejc.390.2022.11.30.07.33.29; Wed, 30 Nov 2022 07:33:50 -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=ALxY+CFY; 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 S229576AbiK3OsF (ORCPT + 83 others); Wed, 30 Nov 2022 09:48:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiK3OsE (ORCPT ); Wed, 30 Nov 2022 09:48:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4CF520366 for ; Wed, 30 Nov 2022 06:48:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id 78217B81B8F for ; Wed, 30 Nov 2022 14:47:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3557EC433D6; Wed, 30 Nov 2022 14:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669819678; bh=BW3glwJdAgcquisZ858SN49s35yyYqpIA+9FpdjY5iM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ALxY+CFYvAbplLO+Hx/N4O3NpzbvaySvk0nfAT4kVUupPtk8eiIJEPauPSRiKSQYQ jaEuk3EQLF7HMDsTLopSF/oBX0cD0uebGk6BERbAQRvCQBVyuguvV0yeCzr9KfHjYs h6ZIWPf+1uJ6M5GpIRIHtPCODP2CxLD4vg0xAucrg0jwvJKz/SUOxsyllejrWpHkE0 Lw1/lk8/UqU2nETjhIp7rghqczNwpgCxVw2uOWK8+ps5NivouB7uph1TlyA7hD+9MZ rPO59hBKCZYd8624e85H14YKrtM3oU/BQPxLKWRc416Vv+xzLGoreojgr2Gxmf68qu 4M81D54/BGyfw== 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 1p0ONP-009bnX-Qd; Wed, 30 Nov 2022 14:47:56 +0000 Date: Wed, 30 Nov 2022 14:47:55 +0000 Message-ID: <86cz94mrc4.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 3/7] genirq: Add mechanism to multiplex a single HW IPI In-Reply-To: <20221129142449.886518-4-apatel@ventanamicro.com> References: <20221129142449.886518-1-apatel@ventanamicro.com> <20221129142449.886518-4-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:45 +0000, Anup Patel wrote: > > All RISC-V platforms have a single HW IPI provided by the INTC local > interrupt controller. The HW method to trigger INTC IPI can be through > external irqchip (e.g. RISC-V AIA), through platform specific device > (e.g. SiFive CLINT timer), or through firmware (e.g. SBI IPI call). > > To support multiple IPIs on RISC-V, we add a generic IPI multiplexing > mechanism which help us create multiple virtual IPIs using a single > HW IPI. This generic IPI multiplexing is inspired from the Apple AIC > irqchip driver and it is shared by various RISC-V irqchip drivers. > > Signed-off-by: Anup Patel > --- > include/linux/irq.h | 3 + > kernel/irq/Kconfig | 5 ++ > kernel/irq/Makefile | 1 + > kernel/irq/ipi-mux.c | 193 +++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 202 insertions(+) > create mode 100644 kernel/irq/ipi-mux.c [...] This is finally starting to look acceptable. My only changes are: diff --git a/kernel/irq/ipi-mux.c b/kernel/irq/ipi-mux.c index 626c564233e9..1a6ba19b736c 100644 --- a/kernel/irq/ipi-mux.c +++ b/kernel/irq/ipi-mux.c @@ -69,6 +69,12 @@ static void ipi_mux_send_mask(struct irq_data *d, const struct cpumask *mask) */ smp_mb__after_atomic(); + /* + * The flag writes must complete before the physical IPI is + * issued to another CPU. This is implied by the control + * dependency on the result of atomic_read() below, which is + * itself already ordered after the vIPI flag write. + */ if (!(pending & ibit) && (atomic_read(&icpu->enable) & ibit)) ipi_mux_send(cpu); } @@ -160,7 +166,7 @@ int ipi_mux_create(unsigned int nr_ipi, void (*mux_send)(unsigned int cpu)) goto fail_free_cpu; } - domain = irq_domain_create_simple(fwnode, nr_ipi, 0, + domain = irq_domain_create_linear(fwnode, nr_ipi, &ipi_mux_domain_ops, NULL); if (!domain) { pr_err("unable to add IPI Mux domain\n"); The first hunk preserve an important piece of information about how delicate the ordering is, while the second only allocates the irqdesc structures as needed, not upfront. I'll shortly go over the rest of the irqchip code and can apply the above myself if there is nothing more to fix. I've also converted the AIC driver over to this[1], and nothing broke so far... M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=irq/ipi-mux -- Without deviation from the norm, progress is not possible.