Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7226842imu; Thu, 31 Jan 2019 07:02:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RrHBRcaE4d+syxQT8l0ih5BsIzYuDzHFf28lhu+nanymD1c6IbywOcfL4VncCAM1kGUS0 X-Received: by 2002:a17:902:9887:: with SMTP id s7mr34265056plp.199.1548946945659; Thu, 31 Jan 2019 07:02:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548946945; cv=none; d=google.com; s=arc-20160816; b=QKXBe30vbL5hSPgbR2uGydpBr5FOGZeGOWDgFFpxRoXCUSoQUbqo3KYwqMLM9TwBPd yj9rlv0eHblyqzii145VhmGlY+Kk4vBPNpEreqJXfZvWR+uGY92O6usNKIq1SD6Ivp+f Srgl2nSjnHRP99gtv3IfKPhhaO2wIwvI095Yu/NFCwkIMoaO4Ujv4x251+sczbBpXiKw USnyT2aXtMqWYVW1RuP0d/lBGvVCasIPR+nklCLTVvgqf3C20p4nOEPOaXTQ5nnU+OKG QAjwVCdNyYALibqg1xdysLhZ5PSDHmKX/xF/Cpifm6ZhcNRUL1GsHKLo7syqM5WpGD5j k1HQ== 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=YMmM7eIZLkIYnCUspL4lLPdvFmTwPBJLNPF6Cs95wGQ=; b=hbmbz3nJlGIv/MmN8luPr272pmohmy8PuxUATKlFx2JvkHPiJEjkXIt0YsyhUAR4x2 wucFo/1HuD+iepMQ1Qw6jboQzjCtQLLMpuSWYtEyIBaFIK67G1JYt8d4iHRH3gsdk+uw ogg18ij2dY73SwcHghBfQDcr/OEj4YvFHGoi0kwb58R3/rdzeZJSUgETsCXVmbiBU7zL cM0fG5SFNJXrrUtSpzc91SyDC9sfB0P9Gia0NKQE6xI8cwkcPsF6sz0t2Zp4hgbqbQ6i C/3ORaRDEO5QHE2IcgsEeQmzt1M9X5tPHHbxnGU7dFkvGx+d0YD0gL8PuVPVE2ZCS0fh RVqg== 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 p5si4644277pls.338.2019.01.31.07.02.05; Thu, 31 Jan 2019 07:02:25 -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 S1733105AbfAaO74 (ORCPT + 99 others); Thu, 31 Jan 2019 09:59:56 -0500 Received: from foss.arm.com ([217.140.101.70]:45656 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733045AbfAaO7y (ORCPT ); Thu, 31 Jan 2019 09:59: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 5CCEF15BF; Thu, 31 Jan 2019 06:59:54 -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 1D2973F59C; Thu, 31 Jan 2019 06:59:51 -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, mark.rutland@arm.com, Julien Thierry , Thomas Gleixner , Jason Cooper Subject: [PATCH v10 16/25] irqchip/gic-v3: Factor group0 detection into functions Date: Thu, 31 Jan 2019 14:58:54 +0000 Message-Id: <1548946743-38979-17-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548946743-38979-1-git-send-email-julien.thierry@arm.com> References: <1548946743-38979-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 Acked-by: Marc Zyngier 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 8148a92..da547e0 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -400,6 +400,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; @@ -541,7 +574,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 @@ -553,25 +586,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