Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17006929ybl; Wed, 1 Jan 2020 19:30:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzkVbf9WgQGmOoUWStR3mzYJj+KBlm7yANE10btO7VT5UObNwVaVwrD86OxBrTObRDgFEZX X-Received: by 2002:a9d:478:: with SMTP id 111mr88249257otc.359.1577935857675; Wed, 01 Jan 2020 19:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577935857; cv=none; d=google.com; s=arc-20160816; b=RGhbiUG/miuRDBKGM4AwnTUeaIu0x3hcLu9UjLa/otE5Hufhz7IfXJ9iivSEtp5s7c 8efQ5uhzeU38k/ZmJZAOg1l4w87HNlnCUgWcOpO3l5neJQw3kOzQ0Wm8eaRwgTstwY0O SMXu+V1Ocr/gtMwa+7QnofYQxO5wZHhwxwNk/trux7ZmXOkQIoNzsVCd49+fhFh+MnQt eEjWH511hubG7AlxxH4mR54pjAZBtTRhrrbu68SxL5HLiz+wUSrysQXbWPs5S2GUu6V4 t3U16CBXh2jvWDPG4obkp5oYcmAFtnelKcdpgjX04toqW92AxEPkbFlIW0Asc+WFJeNz blTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=3TBigpaC1sd02S2ObAZ7LixyP3lZ/nUHcxtblZZP4ug=; b=DdoPaw71JcgymZ0QQ5BnU8NkUofE82Prl7KRxl0dIXhZ2AsSsj/fYJavVAlO45mRdI Kt80ajPqMNiKTji+jlbejKyn4WL2BK7qP220FLgEJE3jJrJLPouhbEooEnECK/8Eux7j si4gGJ6sEnXIvlP3zE7dFC4OvId5hwh6QMafZCzmxeZ0kkXCvObqOL7f4O6ocELGwvPP fSGRk3gpcRI84PDLdMoBUSdxbrUApX9ZF2H371L5bGExSVDU2vNOixqI+iTY+zKb2org EIeCT1tLpNMHCgqlzufGen1RF5LLA5hb32l6syln+hIfn4jXw6m9r0BmHk9un3ljVIbu leoQ== 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 w23si23737038otp.109.2020.01.01.19.30.31; Wed, 01 Jan 2020 19:30:57 -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 S1727553AbgABD3B (ORCPT + 99 others); Wed, 1 Jan 2020 22:29:01 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:47838 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727525AbgABD3A (ORCPT ); Wed, 1 Jan 2020 22:29:00 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 00897EE174A26A3A4B6A; Thu, 2 Jan 2020 11:28:58 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Thu, 2 Jan 2020 11:28:48 +0800 From: Zeng Tao To: CC: , Zeng Tao , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , Subject: [PATCH] cpu-topology: Skip the exist but not possible cpu nodes Date: Thu, 2 Jan 2020 11:24:49 +0800 Message-ID: <1577935489-25245-1-git-send-email-prime.zeng@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_NR_CPUS is smaller than the cpu nodes defined in the device tree, the cpu node parsing will fail. And this is not reasonable for a legal device tree configs. In this patch, skip such cpu nodes rather than return an error. Signed-off-by: Zeng Tao --- drivers/base/arch_topology.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 5fe44b3..4cddfeb 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -250,20 +250,34 @@ core_initcall(free_raw_capacity); #if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) static int __init get_cpu_for_node(struct device_node *node) { - struct device_node *cpu_node; + struct device_node *cpu_node, *t; int cpu; + bool found = false; cpu_node = of_parse_phandle(node, "cpu", 0); if (!cpu_node) - return -1; + return -EINVAL; + + for_each_of_cpu_node(t) + if (t == cpu_node) { + found = true; + break; + } + + if (!found) { + pr_crit("Unable to find CPU node for %pOF\n", cpu_node); + return -EINVAL; + } cpu = of_cpu_node_to_id(cpu_node); if (cpu >= 0) topology_parse_cpu_capacity(cpu_node, cpu); - else - pr_crit("Unable to find CPU node for %pOF\n", cpu_node); + else { + pr_warn("CPU node for %pOF exist but the possible cpu range is :%*pbl\n", + cpu_node, cpumask_pr_args(cpu_possible_mask)); + cpu = -ENODEV; + } - of_node_put(cpu_node); return cpu; } @@ -287,10 +301,13 @@ static int __init parse_core(struct device_node *core, int package_id, cpu_topology[cpu].core_id = core_id; cpu_topology[cpu].thread_id = i; } else { - pr_err("%pOF: Can't get CPU for thread\n", - t); + if (cpu != -ENODEV) + pr_err("%pOF: Can't get CPU for thread\n", + t); + else + cpu = 0; of_node_put(t); - return -EINVAL; + return cpu; } of_node_put(t); } @@ -307,7 +324,7 @@ static int __init parse_core(struct device_node *core, int package_id, cpu_topology[cpu].package_id = package_id; cpu_topology[cpu].core_id = core_id; - } else if (leaf) { + } else if (leaf && cpu != -ENODEV) { pr_err("%pOF: Can't get CPU for leaf core\n", core); return -EINVAL; } -- 2.8.1