Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6361784imu; Mon, 21 Jan 2019 07:37:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN56N4gPMcradBuJbiU+2C8GWL4WkCaIXZwGHhsP/uYfr+NVKPAIS5Ch9lSa3cVvexc94QYL X-Received: by 2002:a17:902:2b8a:: with SMTP id l10mr29075220plb.70.1548085069723; Mon, 21 Jan 2019 07:37:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548085069; cv=none; d=google.com; s=arc-20160816; b=UAKbNFNYYGVZhg//mHwXqE26cwuF4THU4jGCKUGAFMeIPHNrKQR56aY6ESLvvuEmPD E4GiCsFWWSy5nQ7AhLPPtklstwlgbrV1/8ilgzraHcXcZWe1oJChKwgtlVg5l2Vezq+x TYQeEKM29qO4t0cvrJ189TyHBkBXsAIh4ziGvaRGPL5NHYpmC4x9qplkaAv1/6WADn68 j0ERLEw4N1/OrMOj+z0Q9VX9XafArBZER161Cf+1H0wlD6gqaHofmRt14ALxTcPR7Jr/ QqQLURQcuD26Fps0qufZrGCFR3lxr6XxChJbKn++DuFVZ/AtNb20ce3zefZQuwZFxt/a zAyg== 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=0THuG1JZq7kvlgqlty8reTMUysD3YUt9PRwA1TOSMmM=; b=cmNHp6o6++UY2VYiEvCTdK06h0OWyz/qlzZ82mKH9kY3paL2WdWjz2AeTRxl+jS+xq Q/vuG2wJmqadfJNHQn4+ZDNQn34YYpvOUjArngpnvEbTP5E/mratMMlj+HqljQi/5Ukn +8PYTDR+101e1071Tgn6dsDeB0N6XLBYDAdpRj/wsrgbEXCV4TTLIGOqlcbikTF4o/l3 HREcY75CVaBTJwm+LE95zQqHKpRNAbaSrkrRT2ZSJ1bVNL4DpPOXA9gTIheM0Q+arMXp /BorS/1Da/z7ax7DjfYtWDkxrJWUM0X0nJodvmIptNsEfD5XpVhFxZwVnhVz4jhyz9/d iqdQ== 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 z5si13952416plh.133.2019.01.21.07.37.34; Mon, 21 Jan 2019 07:37:49 -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 S1729971AbfAUPfx (ORCPT + 99 others); Mon, 21 Jan 2019 10:35:53 -0500 Received: from foss.arm.com ([217.140.101.70]:36574 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730135AbfAUPej (ORCPT ); Mon, 21 Jan 2019 10:34:39 -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 BDE771688; Mon, 21 Jan 2019 07:34: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 7DD153F5C1; Mon, 21 Jan 2019 07:34: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, mark.rutland@arm.com, Julien Thierry , Thomas Gleixner , Jason Cooper Subject: [PATCH v9 16/26] irqchip/gic-v3: Factor group0 detection into functions Date: Mon, 21 Jan 2019 15:33:35 +0000 Message-Id: <1548084825-8803-17-git-send-email-julien.thierry@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548084825-8803-1-git-send-email-julien.thierry@arm.com> References: <1548084825-8803-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 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