Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3985937imu; Mon, 12 Nov 2018 04:02:12 -0800 (PST) X-Google-Smtp-Source: AJdET5fU1VH1roxZxKkSiEDOFU8Cn6BL1Vei/srCMJCXJl+5nUAJx1789acInTVkrA0Cn6BOp8NB X-Received: by 2002:a62:682:: with SMTP id 124-v6mr612007pfg.161.1542024132588; Mon, 12 Nov 2018 04:02:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542024132; cv=none; d=google.com; s=arc-20160816; b=lIx1yW6fHMM4BhBRK4yqT4C7hIAtC9jhAFoeRM5ZGWV4RG4bVgcJpWqgLw1SQ6esWu qftOdsgbWFG9XY9FVPmi0Dv7ahxK/QA3fTY6sqjmlfhNzJa8JBfazo0h1wPNyXnqiAQA GVQx2iqwCYCG/r7Rh5PleRVt9cVQzf1mJCyrflz1SCnjUX8clIFUfKPoDMnxySk5+8Ni 4++aZdS8GxhIuqwPeZObORYw3ZNUyRNIFGNO03nQ4HKdIXkennJCDdtimtZGKrv0sWNR xJKcTCatGUpPydsRVQkj1EoQ26azy6P0bhuOjJQ17dj9K3Var0rVNS3po5psj3db8LUl 4IwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=KAv+ShzoQSYaAqprjuZuJ1QhzlpmZ6j5kBFGo3lz8xI=; b=mb4XdD4zIIvcigaIMr/NLc0vhyAqLPRZAWE+fttbgP/Nj0FrH5ZKLmvYQF+WxWKNnQ gt3EOm4L5F4xi7TLfHDFdFtsXuurbojtsHu60/ikeNwI1ISxJaN6XmpuSxGsCfXtmmTI u0y7v5n9D8XMwixVCGU5lKsqIxF0O6XgKyfDQD7yOaQmz6yoFp0NzsTyEn4O0DWnZsNV gWpSelpR0O4dEZDqWupw/gwZSkoT44F9Qj04SfI+ebUyeBpuH7KQU4PWHa1IPNfCwOJP K615T/NobKGj8t0C5rpwABsnke0TUqUXclFo1uCGP82Zbykil2gx/BH4mhUIpE5Id1ga 3pPQ== 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 a59-v6si14061298plc.48.2018.11.12.04.01.51; Mon, 12 Nov 2018 04:02:12 -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 S1729665AbeKLVug (ORCPT + 99 others); Mon, 12 Nov 2018 16:50:36 -0500 Received: from foss.arm.com ([217.140.101.70]:34550 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729647AbeKLVuf (ORCPT ); Mon, 12 Nov 2018 16:50:35 -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 978311684; Mon, 12 Nov 2018 03:57:38 -0800 (PST) Received: from e112298-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7B7623F5A0; Mon, 12 Nov 2018 03:57:36 -0800 (PST) From: Julien Thierry To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, daniel.thompson@linaro.org, joel@joelfernandes.org, marc.zyngier@arm.com, christoffer.dall@arm.com, james.morse@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, Julien Thierry , Thomas Gleixner , Jason Cooper Subject: [PATCH v6 05/24] irqchip/gic-v3: Switch to PMR masking before calling IRQ handler Date: Mon, 12 Nov 2018 11:56:56 +0000 Message-Id: <1542023835-21446-6-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> References: <1542023835-21446-1-git-send-email-julien.thierry@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); + } + 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(); + } + gic_write_eoir(irqnr); if (static_branch_likely(&supports_deactivate_key)) gic_write_dir(irqnr); -- 1.9.1