Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3033075pxu; Tue, 8 Dec 2020 01:27:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQXHkizJ0uWUuO0BzpuwDomi1qYC140kkZ99MjgXr/AoH8a5xvYsAcMl4OZC5/jg/GAzRZ X-Received: by 2002:a50:e0c9:: with SMTP id j9mr23713333edl.380.1607419655979; Tue, 08 Dec 2020 01:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607419655; cv=none; d=google.com; s=arc-20160816; b=Q4nRWkYiMFYMIdoD7Qxg5ZtG0EABeNTB/bRHtqQhMEf8bvdvYbO9Iym6Z9wEhFXPP3 CmQdOosY6rhlq8OmArmGCSB+0DvnCwz2OKL0vSrdsKflmbP/y+NlqaS1X3aM+MG6JM14 TjscErj72sNlQNMdQQSR7PvaixAoWVFIVy/so8FTRNotgaH105NijiKERhK2G8zyZlrm Vp9cYRXULipS8gRv1coUBezCX874zrj38iVDj+m2WSKr3Bk/uZsUSrlGrxSorDXyk0Qu ABpbNZ/9TIcH0cNU3ptA8hBAIOe0yJpa3sNhv7WEjxjZr/70uQ6D6ZKZZlyDA8fqwNZU fAhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=Z5PVIm5f40Ykr9jrfkxQ9QiDEmPvmPkwevbJQJktVLc=; b=GO4BRtnvKcolCP0vQjSM36pI4aTUzudtb+OVJ4giubCyjgalisG/YYnHM7S1VwcZJ0 gkY9fbaijofFJMlcdCcLRKBTSCe8KtUribJrC5Kv+elFZxjpSq9TUl6TIy+LdGQ/uQHp D6LHKpF/H3/yo313gm384tLdSDf2svYo9j+eWZbJCdD6IVumJM0uOJtRVs4K3nbGUB9w 7oQ5ajGioyTGWa/gC01tWEvNiPgYZXuXrs12WYZguVMZH2R9CzRWYACEHPsWKdKGkGOY luWGhKqOd19wyeHe02zig+89pYbg9flhUE9/2ldWQ2Bv8HgKmk3OXyO4zH5E4roHe0WS lTOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T5HkCUzF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o30si9660661edi.32.2020.12.08.01.27.13; Tue, 08 Dec 2020 01:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T5HkCUzF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728763AbgLHJWy (ORCPT + 99 others); Tue, 8 Dec 2020 04:22:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728617AbgLHJWv (ORCPT ); Tue, 8 Dec 2020 04:22:51 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EF5DC061749 for ; Tue, 8 Dec 2020 01:22:11 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id p6so6679477plo.6 for ; Tue, 08 Dec 2020 01:22:11 -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=EuypwtAytvwe4uD3rAZFoFKovB6xMLF2i06o9n59PRXCHsyKD3nE2X6oJHRUtyc+wx 52iKnS7/pcj+XxcSUfpY4QfoI5RbqpFHavlleZx5I3IqgInmGQFs564AEjoUUP+u/Rjq uvPhscOe/OCjOP8MeyWReU0Boar0iLChNUzRFnmorqRZ5imtqN+DbAD3pf8z+t/lzyp5 /g+1nNN+VGzWxlNx0uhKjWPPoqfzSrbsQG38yanvzZ7zOPIZe+bjL0Ehgd7C31g5o2U5 UmsKmEV1bqQtFNYeVXCOnLOJ2UOEusP3JRR/Yiy+HRwD5dwE9qKX5b6ANV/jBW/XU2U+ JBiQ== X-Gm-Message-State: AOAM533pTE8Vqq1o6ii6aX+ngPeFHj9CMVsw2ns19/JLdg1H9idr1XUQ CmqViiREAZ6wB06ornJ/RXz/8hCNpXXw 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 Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Thomas Gleixner , Jason Cooper , Marc Zyngier , Mark Rutland , linux-kernel@vger.kernel.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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, -- 2.7.5