Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2792174imu; Thu, 29 Nov 2018 10:15:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/WhATl7j+YYZD3R/Tt2OeaJH69hF0yOJPGKFh5UviWg8QGlWGLcAVbKJbzZaWyGmikqSvUb X-Received: by 2002:a63:d846:: with SMTP id k6mr937256pgj.251.1543515357747; Thu, 29 Nov 2018 10:15:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543515357; cv=none; d=google.com; s=arc-20160816; b=ddt9LTWe1TJqPQcXcqhrV0QRgNI8K5EbiAI41PBWWAS59zBL/twF6/Da7R2Y47xBA5 5WXPLiqLPFEEfGEw7bTTl2H0YSFf6GouXyy1MeFDqlMm7GQ9vMqhBOJ7e03o3wny9RtQ NG+NN1CYjHJ3DMI544IOdiJTfThvGYjuyXGqMfMYlPKs8I2XAtPey6b5PoNrHvpF9tcO +cemA+if2F/wtJHhj5F7s7xJHU4OnkxbVyttOpviHRhtL73wmPPuS39Nv5k7XnLZMycu eUt+9JEE19tZoJgTRqknI6JxqTs4qXZXKoIvvRXfPy9D0BYvy+XwWAcuj4AsjmYRXJAc Tv1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=LkbVS9lCQE8diX2qHl9ND1UYKqZ8ixYYdJstc1kNpts=; b=oBObIDjdiV+2rHbpPL/39I4f8PkEPeLlsYg1PQCCq6XRNKYgv/iv9q/e6N2/0e4xmF 8j8+pTBPKLLil5WOoa+GlzAQD1JUtUB52gzhWt85bK4Xo8s4qp0PtiY/RnR9zMolXdNv /vKmic2W0s1zxfRbP9zr5ucpCFCUXHMKeOwh1lnBwoiibpNFLtDtTsUvoRtzGnLh6G9T rMJP3ykM9gMGFRua9IPYgWIsHpy1LYZHaYjTkP+2ImRLq3ngM8ITf+isiEE5VTKKpeaF zWmSaOmGwRKY8OluhUMi+XpJ8BHaLLEpUCai5LH9y8BixNOWqMyj+33Uf1qQhzAPS6Tr ziRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si2632661pgr.500.2018.11.29.10.15.31; Thu, 29 Nov 2018 10:15:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727361AbeK3FTS (ORCPT + 99 others); Fri, 30 Nov 2018 00:19:18 -0500 Received: from foss.arm.com ([217.140.101.70]:42580 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbeK3FTS (ORCPT ); Fri, 30 Nov 2018 00:19:18 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96B2E80D; Thu, 29 Nov 2018 10:13:03 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 814393F575; Thu, 29 Nov 2018 10:13:01 -0800 (PST) Date: Thu, 29 Nov 2018 18:12:59 +0000 From: Mark Rutland To: Julien Thierry Cc: linux-arm-kernel@lists.infradead.org, daniel.thompson@linaro.org, Jason Cooper , marc.zyngier@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, christoffer.dall@arm.com, james.morse@arm.com, joel@joelfernandes.org, Thomas Gleixner Subject: Re: [PATCH v6 05/24] irqchip/gic-v3: Switch to PMR masking before calling IRQ handler Message-ID: <20181129181258.jo6s4e7s3zwkp4sk@lakrids.cambridge.arm.com> References: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> <1542023835-21446-6-git-send-email-julien.thierry@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1542023835-21446-6-git-send-email-julien.thierry@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 12, 2018 at 11:56:56AM +0000, Julien Thierry wrote: > Mask the IRQ priority through PMR and re-enable IRQs at CPU level, > allowing only higher priority interrupts to be received during interrupt > handling. > > Signed-off-by: Julien Thierry > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Thomas Gleixner > Cc: Jason Cooper > Cc: Marc Zyngier > --- > arch/arm/include/asm/arch_gicv3.h | 17 +++++++++++++++++ > arch/arm64/include/asm/arch_gicv3.h | 17 +++++++++++++++++ > drivers/irqchip/irq-gic-v3.c | 10 ++++++++++ > 3 files changed, 44 insertions(+) > > diff --git a/arch/arm/include/asm/arch_gicv3.h b/arch/arm/include/asm/arch_gicv3.h > index bef0b5d..f6f485f 100644 > --- a/arch/arm/include/asm/arch_gicv3.h > +++ b/arch/arm/include/asm/arch_gicv3.h > @@ -363,5 +363,22 @@ static inline void gits_write_vpendbaser(u64 val, void * __iomem addr) > > #define gits_read_vpendbaser(c) __gic_readq_nonatomic(c) > > +static inline bool gic_prio_masking_enabled(void) > +{ > + return false; > +} > + > +static inline void gic_pmr_mask_irqs(void) > +{ > + /* Should not get called. */ > + WARN_ON_ONCE(true); > +} > + > +static inline void gic_arch_enable_irqs(void) > +{ > + /* Should not get called. */ > + WARN_ON_ONCE(true); > +} > + > #endif /* !__ASSEMBLY__ */ > #endif /* !__ASM_ARCH_GICV3_H */ > diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h > index 37193e2..3f8d5f4 100644 > --- a/arch/arm64/include/asm/arch_gicv3.h > +++ b/arch/arm64/include/asm/arch_gicv3.h > @@ -155,5 +155,22 @@ static inline u32 gic_read_rpr(void) > #define gits_write_vpendbaser(v, c) writeq_relaxed(v, c) > #define gits_read_vpendbaser(c) readq_relaxed(c) > > +static inline bool gic_prio_masking_enabled(void) > +{ > + return system_supports_irq_prio_masking(); > +} > + > +static inline void gic_pmr_mask_irqs(void) > +{ > + /* Should not get called yet. */ > + WARN_ON_ONCE(true); > +} > + > +static inline void gic_arch_enable_irqs(void) > +{ > + /* Should not get called yet. */ > + WARN_ON_ONCE(true); > +} > + > #endif /* __ASSEMBLY__ */ > #endif /* __ASM_ARCH_GICV3_H */ > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index 8f87f40..e5d8c14 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -353,6 +353,11 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs > if (likely(irqnr > 15 && irqnr < 1020) || irqnr >= 8192) { > int err; > > + if (gic_prio_masking_enabled()) { > + gic_pmr_mask_irqs(); > + gic_arch_enable_irqs(); > + } IIUC, if we have two pNMIs, this will allow one to preempt another, e.g. < pNMI#1 asserted > < CPU takes IRQ exception for pNMI #1> irqnr = gic_read_iar(); // pNMI #1 < pNMI#2 asserted > // masks IRQs at GIC, leaves other pNMIs unmasked gic_pmr_mask_irqs() gic_arch_enable_irqs(); ... < CPU takes IRQ exception for pNMI #2 > ... or is that not a problem? Is the NMI code re-entrant? > + > if (static_branch_likely(&supports_deactivate_key)) > gic_write_eoir(irqnr); > else > @@ -371,6 +376,11 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs > return; > } > if (irqnr < 16) { > + if (gic_prio_masking_enabled()) { > + gic_pmr_mask_irqs(); > + gic_arch_enable_irqs(); > + } Can we pull this above the two cases, or is there a problem with doing this for spurious IRQs? Where is the corresponding unmask of the PMR, and disable of IRQs? It's difficult to follow the logic if that's in another patch. Thanks, Mark.