From patchwork Tue Dec 8 09:21:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 11958123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75628C4361B for ; Tue, 8 Dec 2020 09:23:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A4B223A81 for ; Tue, 8 Dec 2020 09:23:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A4B223A81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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:In-Reply-To:References:List-Owner; bh=VMXhT9vZcN4K8Lz+s0ZZ1bOZsxaGYqTeYrS05JxxvGk=; b=gYjNGgSCBKO/9v4JX0/RGSOpv0 M2YvdFww4Wy286WvQ+2+wi0fS+CfxRLR3uPtHZ+BNA6erNxZcH5yfylAmv31dZUBlwB6WJj8ZA3Bk 4Qf3huSrUX8hzgizpKdA1jE42mCSacl5C+1YcVpjYowFgnDKnA8+fOtF9EjXNDvoNdoNG2W+2pYwZ IEw1fzoaL0SuOiDW7jewnzIZZzzJwFuIIGz/+It9CzWzUeRxlXH/OFdMoZGmpJP3LGUtRco3UpyFP Yelhh8qUJ0JdNi+UU5MS3M2ZzSqZxEpppg7AzgHiiRkxBNoH9G9qjYczzueOLcy6qkk5cAT0pa4Wi X1zwV1Lw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmZCO-00009h-P1; Tue, 08 Dec 2020 09:22:20 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmZCL-000077-5E for linux-arm-kernel@lists.infradead.org; Tue, 08 Dec 2020 09:22:17 +0000 Received: by mail-pl1-x642.google.com with SMTP id 4so6683129plk.5 for ; Tue, 08 Dec 2020 01:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Z5PVIm5f40Ykr9jrfkxQ9QiDEmPvmPkwevbJQJktVLc=; b=T5HkCUzFavECBYHXL00oNX4J7+4PnugKfPimRhmXUjZ4/coPgoNA0da8MuofvF3M1s 91fOhEEbfwmAvWaZSlGJRbeV2I6v855qe8seBFfw2aZnuIIkX3oJqRJdProcateDOQVT DyPFs9e++5mrex5buyLmdLjqVqIW0h91bK0LcDSGFi17MpqjP6qLE0GmQZaPVkHZ35HJ RSDQonVD+ia1OQK73bYeDJhxgfntA9+XxmFOsegR41E4zlVCtPmh1L6lwqz7chSy0Ap9 YsElhuK3z39Ae97d0TL1iFbnmpbxjMtADXIEpgGgwE7ROoJGJekCtbq+bJyDf8C2sMmI 8eVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Z5PVIm5f40Ykr9jrfkxQ9QiDEmPvmPkwevbJQJktVLc=; b=XLR9Z+D/hAMuL4nAWJVPpP4vHikWK0bajBTTywOpsnduQLsacUacNQBL5cjE4Hc7Z5 bwsVlDjnACeJfQziGLdUAPI7HOO1/OZtzoe633PCT7GWjEV+Xoyda5oyq+84+I66gFWz GgH0MuAWu4EGQvoXzXi8KKMHOSUGZFF8746S5IjrKN7X7utFohPcBkKmZwFQQZHAM/dq 72D7FvmNEDFBUE8aj3C5h3CHS6gQ/uIIhmD5UPXzvzIDRtWPRDMlRooI8w/9tvgC6W+I SrhGkolsj171TjsjBmomaB1ySlHECeEi+pSkdjcdiW/W/K3i5/1viLOJVVJHjLeGC0Gp K7uw== X-Gm-Message-State: AOAM532ti1rYzy8vJe7CX5f0HcE+Bh84bTL+WVWU+rBcGWxHbPuwIZNQ kXQTfLlRr+v+MxMKt/B8mfK3J4bM45vP X-Google-Smtp-Source: ABdhPJxm6roTwt1s1DaAPuWAXFLMeWuQaDcztKu3ME1XYrJ/J2QBWjzx5hvQ23Bz5IazSWxNUKZ+4w== X-Received: by 2002:a17:902:8d8b:b029:da:b943:dcf2 with SMTP id v11-20020a1709028d8bb02900dab943dcf2mr20142422plo.1.1607419331263; Tue, 08 Dec 2020 01:22:11 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b22sm11524157pfo.163.2020.12.08.01.21.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Dec 2020 01:22:10 -0800 (PST) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64/irq: report bug if NR_IPI greater than max SGI during compile time Date: Tue, 8 Dec 2020 17:21:44 +0800 Message-Id: <1607419304-26140-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201208_042217_219283_BF940030 X-CRM114-Status: GOOD ( 16.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Jason Cooper , Catalin Marinas , linux-kernel@vger.kernel.org, Pingfan Liu , Marc Zyngier , Thomas Gleixner , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Although there is a runtime WARN_ON() when NR_IPR > max SGI, it had better do the check during built time, and associate these related code together. Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- arch/arm64/kernel/smp.c | 2 ++ drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- include/linux/irqchip/arm-gic-common.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 18e9727..9fc383c 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,7 @@ enum ipi_msg_type { IPI_WAKEUP, NR_IPI }; +static_assert(NR_IPI <= MAX_SGI_NUM); static int ipi_irq_base __read_mostly; static int nr_ipi __read_mostly = NR_IPI; diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 16fecc0..ee13f85 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1162,7 +1162,7 @@ static void __init gic_smp_init(void) gic_starting_cpu, NULL); /* Register all 8 non-secure SGIs */ - base_sgi = __irq_domain_alloc_irqs(gic_data.domain, -1, 8, + base_sgi = __irq_domain_alloc_irqs(gic_data.domain, -1, MAX_SGI_NUM, NUMA_NO_NODE, &sgi_fwspec, false, NULL); if (WARN_ON(base_sgi <= 0)) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 6053245..07d36de 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -845,7 +845,7 @@ static __init void gic_smp_init(void) "irqchip/arm/gic:starting", gic_starting_cpu, NULL); - base_sgi = __irq_domain_alloc_irqs(gic_data[0].domain, -1, 8, + base_sgi = __irq_domain_alloc_irqs(gic_data[0].domain, -1, MAX_SGI_NUM, NUMA_NO_NODE, &sgi_fwspec, false, NULL); if (WARN_ON(base_sgi <= 0)) diff --git a/include/linux/irqchip/arm-gic-common.h b/include/linux/irqchip/arm-gic-common.h index fa8c045..7e45a9f 100644 --- a/include/linux/irqchip/arm-gic-common.h +++ b/include/linux/irqchip/arm-gic-common.h @@ -16,6 +16,8 @@ (GICD_INT_DEF_PRI << 8) |\ GICD_INT_DEF_PRI) +#define MAX_SGI_NUM 8 + enum gic_type { GIC_V2, GIC_V3,