Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp10370pxb; Mon, 8 Feb 2021 13:39:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZIBLXcd4mM6InZ+1X5Z2jAM+5ZzLHFBSEg6nSS23tU16fbURwYWQaWdYf3zofGQsyETbV X-Received: by 2002:a17:906:28d6:: with SMTP id p22mr19328969ejd.365.1612820357330; Mon, 08 Feb 2021 13:39:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612820357; cv=none; d=google.com; s=arc-20160816; b=h3mT60oftzkBpzWNHjzF/DSM2wotb5CiLLGCHXXFibv0RQZlQkalZTSiiXSuomuXZn 3qpng+PUNT46u5NQtRDbtCDLoSZ7H6IQ4iUgJzVPT88sxDuKRQKU/bJrpcFFW7B3G27Z YVLseErWG6hYI7DhFUk1FRh1Kbt7KVoJrr7FvdfWZE5WBWX8MP6GkqNWDXI8DWTCM+Dj w1IyLB5OP0kEzZ1oJ3wJe8mDlw1LI10vX+kpu3FuJbOGnyigvZ7seldJhmbqPHucqouB T6VrvJFKGhRRcGIvHYk3HSmwt4eD+NtKrYwg6TRQoyMOlI8sMrN60Itk2RpXPIqJ45Dh mryA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=aUVp9y2kbcCD3w0xMPNOVcdPDPsJuo8ux3a0lIWVKEM=; b=kBtfCsLf6mouhYwulk5BZ+6aJMut+w8UCmpAAzRNq8QEtFss2p47doyrt2rhQ9Cn6P 5GKOriAvT1aBFRouhRqfC5PQThXvfRrikpz6iaRwUD4qfUffDlT4HjjhaOe2lK4H245W wDoe2Ds/lTshdlor8HcXtiVWsssIQwKMfrdhHYckbYU3HKsFtij+xSRk0I7Fn0XxkW97 K9gTirhMA71+6DwcOD/h+EpAiHDSIpBAAV5icNBpSazoClUFlDAeXp3AQmbZRTn1f438 he/UgvVv7nHr8md8qKU25YAci4L1v0vYruRe4kT/SoCQ5l/Ahnj0Yy3QErYg0M3jmZ2B EE9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p14p7HLT; 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 s10si12623267edj.416.2021.02.08.13.38.53; Mon, 08 Feb 2021 13:39:17 -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=p14p7HLT; 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 S236933AbhBHVh6 (ORCPT + 99 others); Mon, 8 Feb 2021 16:37:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235799AbhBHUyJ (ORCPT ); Mon, 8 Feb 2021 15:54:09 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DACCDC061788 for ; Mon, 8 Feb 2021 12:53:28 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id w18so10480276pfu.9 for ; Mon, 08 Feb 2021 12:53:28 -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:mime-version :content-transfer-encoding; bh=aUVp9y2kbcCD3w0xMPNOVcdPDPsJuo8ux3a0lIWVKEM=; b=p14p7HLTvwUQxkszIWy1D0jXzdQ7Jv/1M8//23UsBMWdxYmR8W9Oa9pFEeUQ/pN+c8 FC73ALf4od9D9ewMLxOqDXH0e5s/GOvT1ecqSLjB2jJO6RKpDS7cLq8NfA4z3gu9/PIM izuXziI0Z0oNgWW4Q5J+uAGEYS6kIAGldZnGec1okq+S5dvNYwn2Lu42MO1cudNquxgi 02J18w2m/NajoLm0QcPqTAbnu+JOJEE7F1Q5wL1QeMcdMHpqpFRWsFliZhWhPWQpibyu L4t0+MIIY36yCPd/rhg1tRY3zUk/pvtsfHYmffGfHC5jAeTPi4qf1tTNZrPubbnSxQG7 AwWQ== 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:mime-version :content-transfer-encoding; bh=aUVp9y2kbcCD3w0xMPNOVcdPDPsJuo8ux3a0lIWVKEM=; b=SYq7yd/zorglr/nt/fM3F96cmAd/JMh44O0RIgE9FkXNAERm/DpKDNYbEHeyzsEr5j LwikCa7rm2F7WSQUk7Im9TYGgc0O2O6CGhbSw6uJl/jMQ8J+MjPTsbNwNb/LnSR6poI9 1zRmjD/sA4I5w/7NTnvQ3oA0npry9+TGpydI9/SPS8wT5hxHZsgr3HcR2sQAxEE1+OMY wwU+iXuTSQydKku/K8ViS4D6gvbJ9l+EpdVMzAKpXTmDP2+zJhwvVgV/JW2sXlicXm6t 5F4UBt5xalvM+nOxYKonCQoBlBr2BSfxH4CXRw4t9K6lLGHw/dRoDxpd/CD17ambsdjQ LjlA== X-Gm-Message-State: AOAM53375lSrRAkdSMUzWd/82CJw/VFjl//VnWso7V5mKDA8tfqJWPPF BeUSUs2RRmjHsPTVHmjKwID83BS0O8k= X-Received: by 2002:a65:4c43:: with SMTP id l3mr18529836pgr.327.1612817604629; Mon, 08 Feb 2021 12:53:24 -0800 (PST) Received: from localhost (g186.222-224-165.ppp.wakwak.ne.jp. [222.224.165.186]) by smtp.gmail.com with ESMTPSA id d1sm3018455pgl.17.2021.02.08.12.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 12:53:23 -0800 (PST) From: Stafford Horne To: LKML Cc: Jan Henrik Weinstock , Geert Uytterhoeven , Stafford Horne , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v3] openrisc: Use devicetree to determine present cpus Date: Tue, 9 Feb 2021 05:53:05 +0900 Message-Id: <20210208205307.4169579-1-shorne@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Henrik Weinstock Use the device tree to determine the present cpus instead of assuming all CONFIG_NRCPUS are actually present in the system. Signed-off-by: Jan Henrik Weinstock [shorne: Squashed 2 email commits and added summary from email] Cc: Geert Uytterhoeven Signed-off-by: Stafford Horne --- arch/openrisc/kernel/smp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index 29c82ef2e207..48e1092a64de 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -60,22 +61,32 @@ void __init smp_prepare_boot_cpu(void) void __init smp_init_cpus(void) { - int i; + struct device_node *cpu; + u32 cpu_id; - for (i = 0; i < NR_CPUS; i++) - set_cpu_possible(i, true); + for_each_of_cpu_node(cpu) { + if (of_property_read_u32(cpu, "reg", &cpu_id)) { + pr_warn("%s missing reg property", cpu->full_name); + continue; + } + + if (cpu_id < NR_CPUS) + set_cpu_possible(cpu_id, true); + } } void __init smp_prepare_cpus(unsigned int max_cpus) { - int i; + unsigned int cpu; /* * Initialise the present map, which describes the set of CPUs * actually populated at the present time. */ - for (i = 0; i < max_cpus; i++) - set_cpu_present(i, true); + for_each_possible_cpu(cpu) { + if (cpu < max_cpus) + set_cpu_present(cpu, true); + } } void __init smp_cpus_done(unsigned int max_cpus) -- 2.26.2