Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7827689imu; Tue, 22 Jan 2019 12:20:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BLnYXYkHwlXaeLDLX1DJl5J6NGDySzgpW38oVhwvWiTBfrDpPm0gBCGa1qiLnh6CQJRoa X-Received: by 2002:a65:5c02:: with SMTP id u2mr33027908pgr.13.1548188448544; Tue, 22 Jan 2019 12:20:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548188448; cv=none; d=google.com; s=arc-20160816; b=uL4nQSmzKoEyLmJxdSFDqAYmSolYwzkuaLMmCDQtkqB9fVUsuTld/CMKfAGZiiDoJH 3XAS8awwmRXBXJ8xlbVqB3R9mmGGa0bci3aTYN1JhA7l58IiNZk/ReXa61FY2DAgg3hq bJIMyaT6xiEi7UMQfRWTgEKG+qgwfg7vysuOnNob2Prk0SzjB2JRFn0b394roy0ftm7n qvsUml8L+mGH5ukVsFT9NgsLj4yRTUrKbhU77oCnGLERcv4miFEsx+j3cdHMaNHhjONy Ea3/Bym2ax4KCvQ5bfB3znyyr8i3Q8yJRvVhoqCj/2jBgyTKj+5Hq9G8C0liU0yfLplT YE2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rJT1F0qIq8Tsw54r6HJtqhgv9rAheiXApZ/xRhlov+g=; b=HhaPIyRj3mHWno78a5E6wgL84dEegPKwHCbvxsMLyDCQeI+J9A2kU4vMxQ+0HO8GNw 5a+iT1LK3loQXuzM0DKNM3gBKbQYIODZkpuXf++jaNrPd2xTwFLRBrBwnrybqK4Y3hE6 kBNuX5v5RyAmxo4fxdtjT9z3VsdQ0rmbS12FhAfpR/JCrKXkZ+dJH3BYTimQEMG9j5pd uwnuNdnSnj+TH7MCGyXpQ3UiIvcpB0c+qIloaLvG4PLmtPE5dC2mOeUgWYssXupWJBJA lrLrbCtl4CvMf1T5LTYpEoTmlrXJ3jAqesb/GEHuLeYL+ktgSRd00OoOfA2ttU7j+NBm GZyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TMGS+hSs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si17548469pgn.355.2019.01.22.12.20.32; Tue, 22 Jan 2019 12:20:48 -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; dkim=pass header.i=@linaro.org header.s=google header.b=TMGS+hSs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726271AbfAVUS6 (ORCPT + 99 others); Tue, 22 Jan 2019 15:18:58 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:53115 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbfAVUS6 (ORCPT ); Tue, 22 Jan 2019 15:18:58 -0500 Received: by mail-it1-f194.google.com with SMTP id g76so23716614itg.2 for ; Tue, 22 Jan 2019 12:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rJT1F0qIq8Tsw54r6HJtqhgv9rAheiXApZ/xRhlov+g=; b=TMGS+hSszdm5dq5n7TUbrF3ZUFew9a3yYBPtEZ+R29vkEOqdAEpSoDXdXJZyysl4vA xwgtzm7TmWHimBbbNPZboUppWT3r+Wt4EZLAh0hTyS1kRfInpsC2S0QCgWdoChKQV6sS jtVeafZ5wfqo/gsZxX0qpOpTyf4dShH8BvN/k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rJT1F0qIq8Tsw54r6HJtqhgv9rAheiXApZ/xRhlov+g=; b=iTQPn2ey+FeJysWk3vsBLPcB/kD4M/DxqW4R2lonuSSNrwBNZeHNJQlX2tXrrxmmQQ bxIoMh/mUp53mzecK1xxUA6+y97t8aqj13S+F1sRHGmJ7XkdR7V+abvb6ZQRTmbFcc3H jinacVNjFMQ6Gpf4qU48D5FdXrYXBuAYr2r+vbWeJOX8UhiB7xEwb6p39xKqPbH53xDn yAiro73KAtgVbxYUmx1RK44JOjzdhOj4KXC+bENq/n1S07tBnkCaFSqQ091IpJuAJDU7 Gw7zlrMRPjnjwFWrVkNrwVfXkMtqOc8tdTWh1Dnill85T/xjFWmBzVbpxmHhO0UMZyYo 8PJw== X-Gm-Message-State: AJcUukfU4Ix8EzPPIXag4jV6Fou3drXOnqmV9whzHSkdGrNrKWqDUOcQ h+HxGmY+EfskImZFiqipLUvXZcxUZvUoCDnUHaVmtQ== X-Received: by 2002:a24:710:: with SMTP id f16mr2660624itf.121.1548188337202; Tue, 22 Jan 2019 12:18:57 -0800 (PST) MIME-Version: 1.0 References: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> <1548084825-8803-10-git-send-email-julien.thierry@arm.com> In-Reply-To: <1548084825-8803-10-git-send-email-julien.thierry@arm.com> From: Ard Biesheuvel Date: Tue, 22 Jan 2019 21:18:45 +0100 Message-ID: Subject: Re: [PATCH v9 09/26] arm64: Unmask PMR before going idle To: Julien Thierry Cc: linux-arm-kernel , Mark Rutland , Daniel Thompson , Marc Zyngier , Catalin Marinas , Will Deacon , Linux Kernel Mailing List , Christoffer Dall , James Morse , Joel Fernandes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Jan 2019 at 16:36, Julien Thierry wrote: > > CPU does not received signals for interrupts with a priority masked by > ICC_PMR_EL1. This means the CPU might not come back from a WFI > instruction. > > Make sure ICC_PMR_EL1 does not mask interrupts when doing a WFI. > > Since the logic of cpu_do_idle is becoming a bit more complex than just > two instructions, lets turn it from ASM to C. > > Signed-off-by: Julien Thierry > Suggested-by: Daniel Thompson > Cc: Catalin Marinas > Cc: Will Deacon > --- > arch/arm64/kernel/process.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > arch/arm64/mm/proc.S | 11 ----------- > 2 files changed, 45 insertions(+), 11 deletions(-) > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 6d410fc..f05b63f 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -51,6 +51,7 @@ > #include > > #include > +#include > #include > #include > #include > @@ -74,6 +75,50 @@ > > void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd); > > +static inline void __cpu_do_idle(void) > +{ > + dsb(sy); > + wfi(); > +} > + > +static inline void __cpu_do_idle_irqprio(void) Can we drop the 'inline's from all the function definitions in .c files? (not just in this patch) We tend to leave that to the compiler. > +{ > + unsigned long pmr; > + unsigned long daif_bits; > + > + daif_bits = read_sysreg(daif); > + write_sysreg(daif_bits | PSR_I_BIT, daif); > + > + /* > + * Unmask PMR before going idle to make sure interrupts can > + * be raised. > + */ > + pmr = gic_read_pmr(); > + gic_write_pmr(GIC_PRIO_IRQON); > + > + __cpu_do_idle(); > + > + gic_write_pmr(pmr); > + write_sysreg(daif_bits, daif); > +} > + > +/* > + * cpu_do_idle() > + * > + * Idle the processor (wait for interrupt). > + * > + * If the CPU supports priority masking we must do additional work to > + * ensure that interrupts are not masked at the PMR (because the core will > + * not wake up if we block the wake up signal in the interrupt controller). > + */ > +void cpu_do_idle(void) > +{ > + if (system_uses_irq_prio_masking()) > + __cpu_do_idle_irqprio(); > + else > + __cpu_do_idle(); > +} > + > /* > * This is our default idle handler. > */ > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > index 73886a5..3ea4f3b 100644 > --- a/arch/arm64/mm/proc.S > +++ b/arch/arm64/mm/proc.S > @@ -55,17 +55,6 @@ > > #define MAIR(attr, mt) ((attr) << ((mt) * 8)) > > -/* > - * cpu_do_idle() > - * > - * Idle the processor (wait for interrupt). > - */ > -ENTRY(cpu_do_idle) > - dsb sy // WFI may enter a low-power mode > - wfi > - ret > -ENDPROC(cpu_do_idle) > - > #ifdef CONFIG_CPU_PM > /** > * cpu_do_suspend - save CPU registers context > -- > 1.9.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel