From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B8B2C04A6A for ; Mon, 7 Aug 2023 13:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234045AbjHGNfo (ORCPT ); Mon, 7 Aug 2023 09:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbjHGNfk (ORCPT ); Mon, 7 Aug 2023 09:35:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01F5618C; Mon, 7 Aug 2023 06:35:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F3781FB; Mon, 7 Aug 2023 06:26:03 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.32.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777963F64C; Mon, 7 Aug 2023 06:25:17 -0700 (PDT) Date: Mon, 7 Aug 2023 14:25:08 +0100 From: Mark Rutland To: Sumit Garg Cc: Douglas Anderson , Marc Zyngier , Catalin Marinas , Will Deacon , Daniel Thompson , linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 1/7] irqchip/gic-v3: Enable support for SGIs to act as NMIs Message-ID: References: <20230601213440.2488667-1-dianders@chromium.org> <20230601143109.v9.1.I1223c11c88937bd0cbd9b086d4ef216985797302@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 07, 2023 at 04:52:40PM +0530, Sumit Garg wrote: > On Mon, 7 Aug 2023 at 15:20, Mark Rutland wrote: > > On Thu, Jun 01, 2023 at 02:31:45PM -0700, Douglas Anderson wrote: > > > @@ -542,16 +543,22 @@ static int gic_irq_nmi_setup(struct irq_data *d) > > > return -EINVAL; > > > > > > /* desc lock should already be held */ > > > - if (gic_irq_in_rdist(d)) { > > > - u32 idx = gic_get_ppi_index(d); > > > + switch (get_intid_range(d)) { > > > + case SGI_RANGE: > > > + break; > > > + case PPI_RANGE: > > > + case EPPI_RANGE: > > > + idx = gic_get_ppi_index(d); > > > > > > /* Setting up PPI as NMI, only switch handler for first NMI */ > > > if (!refcount_inc_not_zero(&ppi_nmi_refs[idx])) { > > > refcount_set(&ppi_nmi_refs[idx], 1); > > > desc->handle_irq = handle_percpu_devid_fasteoi_nmi; > > > } > > > - } else { > > > + break; > > > + default: > > > desc->handle_irq = handle_fasteoi_nmi; > > > + break; > > > } > > > > As above, I reckon this isn't right, and we should treat all rdist interrupts > > (which are all percpu) the same. > > > > I reckon what we should be doing here is make ppi_nmi_refs cover all of the > > rdist interrupts (e.g. make that rdist_nmi_refs, add a gic_get_rdist_idx() > > helper), and then here have something like: > > > > if (gic_irq_in_rdist(d)) { > > u32 idx = gic_get_rdist_idx(d); > > > > /* > > * Setting up a percpu interrupt as NMI, only switch handler > > * for first NMI > > */ > > if (!refcount_inc_not_zero(&rdist_nmi_refs[idx])) { > > refcount_set(&ppi_nmi_refs[idx], 1); > > desc->handle_irq = handle_percpu_devid_fasteoi_nmi; > > } > > } > > It looks like you missed the else part here as follows for all other > interrupt types: > > } else { > desc->handle_irq = handle_fasteoi_nmi; > } Yes, sorry; I had meant for that to be included, i.e. if (gic_irq_in_rdist(d)) { u32 idx = gic_get_rdist_idx(d); /* * Setting up a percpu interrupt as NMI, only switch handler * for first NMI */ if (!refcount_inc_not_zero(&rdist_nmi_refs[idx])) { refcount_set(&ppi_nmi_refs[idx], 1); desc->handle_irq = handle_percpu_devid_fasteoi_nmi; } } else { desc->handle_irq = handle_fasteoi_nmi; } > Apart from that, your logic sounds good to me. Great! Thanks, Mark.