From patchwork Mon Mar 12 06:49:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 10275539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 639E360211 for ; Mon, 12 Mar 2018 06:52:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50A2D28711 for ; Mon, 12 Mar 2018 06:52:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 443E428790; Mon, 12 Mar 2018 06:52:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DAEBD28711 for ; Mon, 12 Mar 2018 06:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VtzOgSOYOIFPX57Spr/j7FmcyhWjPEDAXN6iDBpEnpA=; b=FJtZgpXl08kASA JY7SCbIHn4exHsIEo2QZuUBsgc85Dhu46iAG9ynO2y1g4U4pOGIRBuM0X6mnysBuhWT3Mhv36SaR3 x4by9/JuFLvgmZHhbyqiIH3EnWwCsVK12tqNwm5kmTio4ngoG7mTXJR7kNOOcW4c7watp6H0DZGte c7SGiQJKP6Y0F2HFDhbpr8iHOi/yM/4Ucd0KG+asGw+ZZCTBEihzysgb3TaKd5Nx8LCTw1yZZfstk AW19JSdQC8Mc4uJBC0eHaK+k1p2+MkQiEcFdo+QZwqWyX0ZVa33zSi9VCyYSHsT/gQ76e9oXrZsMI im+do3KtvwjXB/LlVj0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1evHJr-0006Ny-G3; Mon, 12 Mar 2018 06:52:27 +0000 Received: from [45.249.212.32] (helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1evHIA-0005Qx-5y for linux-arm-kernel@lists.infradead.org; Mon, 12 Mar 2018 06:50:45 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 62D1910263E61; Mon, 12 Mar 2018 14:50:11 +0800 (CST) Received: from localhost (10.177.19.219) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.361.1; Mon, 12 Mar 2018 14:50:05 +0800 From: Yang Yingliang To: Subject: [RFC PATCH 1/4] irqchip/gic-v3: add common_aff_lpi field in struct rdists Date: Mon, 12 Mar 2018 14:49:52 +0800 Message-ID: <1520837395-10288-2-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1520837395-10288-1-git-send-email-yangyingliang@huawei.com> References: <1520837395-10288-1-git-send-email-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.219] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180311_235042_565741_65127307 X-CRM114-Status: GOOD ( 11.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, yangyingliang@huawei.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Read CommonLPIAff from GICR_TYPER and check whether the values are same in each register. If they are different, prints warning message and set CommonLPIAff to zero. Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3.c | 20 ++++++++++++++++++++ include/linux/irqchip/arm-gic-v3.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index d99cc07..58f55da 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -598,6 +598,10 @@ static int gic_dist_supports_lpis(void) static void gic_cpu_init(void) { void __iomem *rbase; + u32 typer; + unsigned long flags; + u16 common_aff_lpi; + int cpu = smp_processor_id(); /* Register ourselves with the rest of the world */ if (gic_populate_rdist()) @@ -612,6 +616,21 @@ static void gic_cpu_init(void) gic_cpu_config(rbase, gic_redist_wait_for_rwp); + typer = gic_read_typer(gic_data_rdist_rd_base() + GICR_TYPER); + common_aff_lpi = GICR_TYPER_COMMON_AFF_LPI(typer); + if (!cpu) { + gic_data.rdists.common_aff_lpi = common_aff_lpi; + } else { + raw_spin_lock_irqsave(&gic_data.rdists.lock, flags); + if (common_aff_lpi != gic_data.rdists.common_aff_lpi) { + pr_warn_once("The CommonLPIAff is not consistent.\ + It's %d in CPU0, but %d in CPU%d, set CommonLPIAff to 0.\n", + gic_data.rdists.common_aff_lpi, cpu, common_aff_lpi); + gic_data.rdists.common_aff_lpi = 0; + } + raw_spin_unlock_irqrestore(&gic_data.rdists.lock, flags); + } + /* Give LPIs a spin */ if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis()) its_cpu_init(); @@ -1029,6 +1048,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_data.rdists.rdist = alloc_percpu(typeof(*gic_data.rdists.rdist)); gic_data.rdists.has_vlpis = true; gic_data.rdists.has_direct_lpi = true; + raw_spin_lock_init(&gic_data.rdists.lock); if (WARN_ON(!gic_data.domain) || WARN_ON(!gic_data.rdists.rdist)) { err = -ENOMEM; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index c00c4c33..6da670a 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -108,6 +108,7 @@ #define GICR_CTLR_ENABLE_LPIS (1UL << 0) #define GICR_TYPER_CPU_NUMBER(r) (((r) >> 8) & 0xffff) +#define GICR_TYPER_COMMON_AFF_LPI(r) (((r) >> 24) & 3) #define GICR_WAKER_ProcessorSleep (1U << 1) #define GICR_WAKER_ChildrenAsleep (1U << 2) @@ -577,6 +578,8 @@ struct rdists { u64 flags; bool has_vlpis; bool has_direct_lpi; + u16 common_aff_lpi; + raw_spinlock_t lock; }; struct irq_domain;