From patchwork Sat Sep 5 17:43:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1358098 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BkMhX3h3Cz9sRK for ; Sun, 6 Sep 2020 03:57:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dbZEGsAP; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BkMhX2R7gzDqfp for ; Sun, 6 Sep 2020 03:57:48 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dbZEGsAP; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BkMNY4YRCzDqdM for ; Sun, 6 Sep 2020 03:43:57 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id h2so2605591plr.0 for ; Sat, 05 Sep 2020 10:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LpXuMAPwMF1gsfeNwpqv0N9egJv79W+WNZUg3630ZXA=; b=dbZEGsAPTJ7i/F1BJSHeqMw8SCXDGzBxf7fHVx6WbpUEwXYOE0p6VX2qdrPEWzKOFe Z1zSmpIy2130Qvt803VrmBLxn1b7Agck/x+gb+xOvEaCdtkq5d1KvYu6imjL3NgoBhd/ rAogCNW8fUZDHqHdBUXEO3jSdwUa9hM3eXRPJ9ltBEIU0R7O20KJkNN+0Gz2Iw2OaVNP Uk84HFqSqBMXPDUr5bxAlwESQEvGUTWMRyTItXeSmAoqs4Z2SeFPzeEtjuyllk1TP45/ 8vdDrSmlOpHsEKW2OmVm7qWNB2GKs/CziNV+U1kB/8Ne/J75f+SEyk1z9L4K6PN0v/lW b1kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LpXuMAPwMF1gsfeNwpqv0N9egJv79W+WNZUg3630ZXA=; b=ummSFoYvhNbqf2s79r0i9pKlqwBYmqnBbd9P0pdmhxxNjwmD3TykNQQUBG+jxrkd2r a+vLy5zk8nLqDXJlDd1Ym0JNiuks8netmQsRitKAUYYuE/SaQw2TitWgFYNTALjphNO1 nHeG7Zc7D22kIb1CDAdIYwMYtvesv6ezMSeV8gSGpFf70Xh6dOi2SHohTDXF41LvT32W 5D87MtQKjgBzPSr2ERSnxUgC7YDAGS1KSF8pMcgowzh7RKTGNJJ7CmJ0ZjN8XCWRWaoL Rf2URFYzB4DNShqgVsSP5Ze5fXnul3J/p05WBPmYr0vcWUl13HyATeDGYDvqvXWeRvn4 tbdw== X-Gm-Message-State: AOAM531mX+UWPHkCHjtG3I9TzDRLIa+YwowuyPdlmT80e8Y3gF5noyMx cSKhKPiliJZ8DzfWnOzqINw= X-Google-Smtp-Source: ABdhPJyLwRk4gkyp0XCM61dn+jFYvbtPlftwRvk5cqIqYcuiEwtVp6HVQHaSwWDEyWnXkzA8I/D6Yw== X-Received: by 2002:a17:902:a715:b029:d0:89f3:28cf with SMTP id w21-20020a170902a715b02900d089f328cfmr11889156plq.11.1599327835346; Sat, 05 Sep 2020 10:43:55 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([203.185.249.227]) by smtp.gmail.com with ESMTPSA id i1sm10405317pfk.21.2020.09.05.10.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2020 10:43:54 -0700 (PDT) From: Nicholas Piggin To: Subject: [RFC PATCH 04/12] powerpc: add interrupt_cond_local_irq_enable helper Date: Sun, 6 Sep 2020 03:43:27 +1000 Message-Id: <20200905174335.3161229-5-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200905174335.3161229-1-npiggin@gmail.com> References: <20200905174335.3161229-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Simple helper for synchronous interrupt handlers to use to enable interrupts if they were taken in interrupt-enabled context. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/interrupt.h | 7 +++++++ arch/powerpc/kernel/traps.c | 24 +++++++----------------- arch/powerpc/mm/fault.c | 4 +--- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h index 7c7e58541171..7231949fc1c8 100644 --- a/arch/powerpc/include/asm/interrupt.h +++ b/arch/powerpc/include/asm/interrupt.h @@ -3,6 +3,7 @@ #define _ASM_POWERPC_INTERRUPT_H #include +#include #include /** @@ -198,4 +199,10 @@ DECLARE_INTERRUPT_HANDLER_ASYNC(unknown_async_exception); void replay_system_reset(void); void replay_soft_interrupts(void); +static inline void interrupt_cond_local_irq_enable(struct pt_regs *regs) +{ + if (!arch_irq_disabled_regs(regs)) + local_irq_enable(); +} + #endif /* _ASM_POWERPC_INTERRUPT_H */ diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 96fa2d7e088c..a850647b7062 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -343,8 +343,8 @@ static bool exception_common(int signr, struct pt_regs *regs, int code, show_signal_msg(signr, regs, code, addr); - if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs)) - local_irq_enable(); + if (arch_irqs_disabled()) + interrupt_cond_local_irq_enable(regs); current->thread.trap_nr = code; @@ -1579,9 +1579,7 @@ DEFINE_INTERRUPT_HANDLER(program_check_exception) if (!user_mode(regs)) goto sigill; - /* We restore the interrupt state now */ - if (!arch_irq_disabled_regs(regs)) - local_irq_enable(); + interrupt_cond_local_irq_enable(regs); /* (reason & REASON_ILLEGAL) would be the obvious thing here, * but there seems to be a hardware bug on the 405GP (RevD) @@ -1635,9 +1633,7 @@ DEFINE_INTERRUPT_HANDLER(alignment_exception) int sig, code, fixed = 0; unsigned long reason; - /* We restore the interrupt state now */ - if (!arch_irq_disabled_regs(regs)) - local_irq_enable(); + interrupt_cond_local_irq_enable(regs); reason = get_reason(regs); @@ -1798,9 +1794,7 @@ DEFINE_INTERRUPT_HANDLER(facility_unavailable_exception) die("Unexpected facility unavailable exception", regs, SIGABRT); } - /* We restore the interrupt state now */ - if (!arch_irq_disabled_regs(regs)) - local_irq_enable(); + interrupt_cond_local_irq_enable(regs); if (status == FSCR_DSCR_LG) { /* @@ -2145,9 +2139,7 @@ void SPEFloatingPointException(struct pt_regs *regs) int code = FPE_FLTUNK; int err; - /* We restore the interrupt state now */ - if (!arch_irq_disabled_regs(regs)) - local_irq_enable(); + interrupt_cond_local_irq_enable(regs); flush_spe_to_thread(current); @@ -2194,9 +2186,7 @@ void SPEFloatingPointRoundException(struct pt_regs *regs) extern int speround_handler(struct pt_regs *regs); int err; - /* We restore the interrupt state now */ - if (!arch_irq_disabled_regs(regs)) - local_irq_enable(); + interrupt_cond_local_irq_enable(regs); preempt_disable(); if (regs->msr & MSR_SPE) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 7d63b5512068..fd8e28944293 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -441,9 +441,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, return bad_area_nosemaphore(regs, address); } - /* We restore the interrupt state now */ - if (!arch_irq_disabled_regs(regs)) - local_irq_enable(); + interrupt_cond_local_irq_enable(regs); perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);