Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3983248imu; Mon, 12 Nov 2018 03:59:58 -0800 (PST) X-Google-Smtp-Source: AJdET5ekRQe/M8EhrKiaP/H/aYoI8GCc0H7fj4gQDs7v5pNfDGWr9J6DfshXmFhM1sXiV7MC55sQ X-Received: by 2002:a17:902:9043:: with SMTP id w3-v6mr664287plz.32.1542023998499; Mon, 12 Nov 2018 03:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542023998; cv=none; d=google.com; s=arc-20160816; b=EfEtK1REqccELrJIWOfDqq+JZtsR+v7RlyLSQ7SA+Zqg2NgxZRjtjVoBtEsnUMgbod E4vbkOz9w5w5+5dzAWJTVcZX1EQUP1mb42Cp4If7uxtmtekwgU+83sBrFpoPz742a+8Z z9gL9J27502f2+UZ5A2c2SrdbF+1amNN2y70RAUYnL7n+NiKvhDmcJYqyGk+lIzOk8UA /Au+M7/JpV/8/pWt/2hvvnWhRmYQquwRq71NdUGnGC+RPGua33amoO8AbpCqxPznPJ2c 5bXrnqTcYWVNFR66uCo/VQJ1R37C1x7d4BjwBCEiIvc4OByZeaC75UIoXc6IL7kh8AsO nN+w== 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=VMRMsm5aFdGgNXglUtNNgToMV8P/RnCbQCP4zfMErX8=; b=tsm9N9ZL4tW98iJIkXfUf5w8PzRp71f43VOFr54TEW1oRu28GRpynsJvM6YCtSMbPw pqdH+mK+Wyu1B1oMr0DxUVwJdl0o7L9Pa8gIqROJNedIeam11vvv6w5N0Rk4q9cqkxoc 86Y01CMJuSO4YGRHDiOO/9dsMYM/ewLVNwSQl0+mqP4GSCdbyZI6RM4TOHY9uauJvV43 ECyKUAKTlxCTywNqA+GL4b8DuQ/UW7V00DW+1K483YdgMxFXPfF9ZLGddQLruPzcYDKT 3ty2pU/eQ8vY5fcg0JFkrmxbhlW+tW0J+BzsiV0nF9JGYS+qZtckDRvvpThn+34W0vq/ K2SQ== 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 w3-v6si7024351plb.154.2018.11.12.03.59.43; Mon, 12 Nov 2018 03:59:58 -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 S1729936AbeKLVu4 (ORCPT + 99 others); Mon, 12 Nov 2018 16:50:56 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34668 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729756AbeKLVuy (ORCPT ); Mon, 12 Nov 2018 16:50:54 -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 5287580D; Mon, 12 Nov 2018 03:57:58 -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 3F7F23F5A0; Mon, 12 Nov 2018 03:57:56 -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 14/24] irqchip/gic-v3: Factor group0 detection into functions Date: Mon, 12 Nov 2018 11:57:05 +0000 Message-Id: <1542023835-21446-15-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 The code to detect whether Linux has access to group0 interrupts can prove useful in other parts of the driver. Provide a separate function to do this. Signed-off-by: Julien Thierry Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 55 +++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index e5d8c14..dbf5247 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -399,6 +399,39 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs } } +static u32 gic_get_pribits(void) +{ + u32 pribits; + + pribits = gic_read_ctlr(); + pribits &= ICC_CTLR_EL1_PRI_BITS_MASK; + pribits >>= ICC_CTLR_EL1_PRI_BITS_SHIFT; + pribits++; + + return pribits; +} + +static bool gic_has_group0(void) +{ + u32 val; + + /* + * Let's find out if Group0 is under control of EL3 or not by + * setting the highest possible, non-zero priority in PMR. + * + * If SCR_EL3.FIQ is set, the priority gets shifted down in + * order for the CPU interface to set bit 7, and keep the + * actual priority in the non-secure range. In the process, it + * looses the least significant bit and the actual priority + * becomes 0x80. Reading it back returns 0, indicating that + * we're don't have access to Group0. + */ + gic_write_pmr(BIT(8 - gic_get_pribits())); + val = gic_read_pmr(); + + return val != 0; +} + static void __init gic_dist_init(void) { unsigned int i; @@ -540,7 +573,7 @@ static void gic_cpu_sys_reg_init(void) u64 mpidr = cpu_logical_map(cpu); u64 need_rss = MPIDR_RS(mpidr); bool group0; - u32 val, pribits; + u32 pribits; /* * Need to check that the SRE bit has actually been set. If @@ -552,25 +585,9 @@ static void gic_cpu_sys_reg_init(void) if (!gic_enable_sre()) pr_err("GIC: unable to set SRE (disabled at EL2), panic ahead\n"); - pribits = gic_read_ctlr(); - pribits &= ICC_CTLR_EL1_PRI_BITS_MASK; - pribits >>= ICC_CTLR_EL1_PRI_BITS_SHIFT; - pribits++; + pribits = gic_get_pribits(); - /* - * Let's find out if Group0 is under control of EL3 or not by - * setting the highest possible, non-zero priority in PMR. - * - * If SCR_EL3.FIQ is set, the priority gets shifted down in - * order for the CPU interface to set bit 7, and keep the - * actual priority in the non-secure range. In the process, it - * looses the least significant bit and the actual priority - * becomes 0x80. Reading it back returns 0, indicating that - * we're don't have access to Group0. - */ - write_gicreg(BIT(8 - pribits), ICC_PMR_EL1); - val = read_gicreg(ICC_PMR_EL1); - group0 = val != 0; + group0 = gic_has_group0(); /* Set priority mask register */ write_gicreg(DEFAULT_PMR_VALUE, ICC_PMR_EL1); -- 1.9.1