From patchwork Mon Jan 19 16:53:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 43333 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95A362034D for ; Mon, 19 Jan 2015 16:53:38 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id l18sf3776051wgh.3 for ; Mon, 19 Jan 2015 08:53:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=PkuZ09XtPJpsUws/+u7Y5uOf81k0XuS8GM9C289QFQM=; b=SP1rkZ/Hf97YRqvHq0fqhc3B3z50ciJyU56jrCtNKBzvgBwEcZVqWplo6nc3VPPwEV xnR35A4Zz7Mw8d4g49SmhXV4+a91rtZ5hopEeAZnrDbf/LSuSz3vCTALrzVolwumyasd xNa8TdUi7bmtJT6CELxCW48sFg7Z2U5qLOZTPXEQizZSw+iKXTpurLEmu48y9Yttp1p2 mPNeTnlWhIwqVomABQwCVXNBn91x2rm1d033E8zqVGuyBD5Qggzq3F2uFoR4kSrIjA2e 7U2v7RRLhxI3gesRCzchNo9ALLjWd2FTIvAhPdceem9tFpit/wU6yyL+0j+ZAbS07S4u 4wYw== X-Gm-Message-State: ALoCoQn3wlGu2LHpgiTgjlp+I7BXOURYrzwRTY/Zngb+bw8QfJnTAuXPC3yEmbqT7hZoRKtA48x7 X-Received: by 10.112.171.74 with SMTP id as10mr465006lbc.8.1421686417832; Mon, 19 Jan 2015 08:53:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.6 with SMTP id 6ls583499lai.95.gmail; Mon, 19 Jan 2015 08:53:37 -0800 (PST) X-Received: by 10.153.4.44 with SMTP id cb12mr33117764lad.30.1421686417661; Mon, 19 Jan 2015 08:53:37 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id t1si13961149laa.10.2015.01.19.08.53.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 08:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so14607862lam.2 for ; Mon, 19 Jan 2015 08:53:37 -0800 (PST) X-Received: by 10.112.170.36 with SMTP id aj4mr32592842lbc.3.1421686417569; Mon, 19 Jan 2015 08:53:37 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1150479lbb; Mon, 19 Jan 2015 08:53:36 -0800 (PST) X-Received: by 10.68.201.201 with SMTP id kc9mr37949223pbc.79.1421686415568; Mon, 19 Jan 2015 08:53:35 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pv10si4623978pdb.223.2015.01.19.08.53.34; Mon, 19 Jan 2015 08:53:35 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752362AbbASQxb (ORCPT + 28 others); Mon, 19 Jan 2015 11:53:31 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:35794 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbbASQxL (ORCPT ); Mon, 19 Jan 2015 11:53:11 -0500 Received: by mail-wg0-f45.google.com with SMTP id y19so32828323wgg.4 for ; Mon, 19 Jan 2015 08:53:09 -0800 (PST) X-Received: by 10.180.20.177 with SMTP id o17mr23594313wie.20.1421686389852; Mon, 19 Jan 2015 08:53:09 -0800 (PST) Received: from localhost.localdomain (135-224-190-109.dsl.ovh.fr. [109.190.224.135]) by mx.google.com with ESMTPSA id u13sm17945724wjr.26.2015.01.19.08.53.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Jan 2015 08:53:09 -0800 (PST) From: Daniel Lezcano To: arnd@arndb.de, olof@lixom.net, linux@arm.linux.org.uk Cc: thomas.petazzoni@free-electrons.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] ARM: Factor out the smp_init_cpus function Date: Mon, 19 Jan 2015 17:53:01 +0100 Message-Id: <1421686381-12397-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421686381-12397-1-git-send-email-daniel.lezcano@linaro.org> References: <1421686381-12397-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The set_cpu_possible loop and the ncores clipping is duplicated again and again across the different platforms. As the smp_init_cpus is returning the number of cores, use this information to do the same thing than what does the duplicate code in the different platforms. Signed-off-by: Daniel Lezcano --- arch/arm/kernel/smp.c | 16 ++++++++++++++-- arch/arm/mach-exynos/platsmp.c | 15 +-------------- arch/arm/mach-omap2/omap-smp.c | 10 ---------- arch/arm/mach-realview/platsmp.c | 15 +-------------- arch/arm/mach-socfpga/platsmp.c | 19 +------------------ arch/arm/mach-spear/platsmp.c | 13 +------------ arch/arm/mach-ux500/platsmp.c | 15 +-------------- arch/arm/mach-zynq/platsmp.c | 9 +-------- 8 files changed, 20 insertions(+), 92 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 86ef244..ecf2993 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -141,8 +141,20 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) /* platform specific SMP operations */ void __init smp_init_cpus(void) { - if (smp_ops.smp_init_cpus) - smp_ops.smp_init_cpus(); + int i, ncores; + + if (!smp_ops.smp_init_cpus) + return; + + ncores = smp_ops.smp_init_cpus(); + if (ncores > nr_cpu_ids) { + pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", + ncores, nr_cpu_ids); + ncores = nr_cpu_ids; + } + + for (i = 0; i < ncores; i++) + set_cpu_possible(i, true); } int platform_can_cpu_hotplug(void) diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c index 686f42a..406cc8b 100644 --- a/arch/arm/mach-exynos/platsmp.c +++ b/arch/arm/mach-exynos/platsmp.c @@ -376,28 +376,15 @@ fail: static int __init exynos_smp_init_cpus(void) { void __iomem *scu_base = scu_base_addr(); - unsigned int i, ncores; if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) - ncores = scu_base ? scu_get_core_count(scu_base) : 1; + return scu_base ? scu_get_core_count(scu_base) : 1; else /* * CPU Nodes are passed thru DT and set_cpu_possible * is set by "arm_dt_init_cpu_maps". */ return 0; - - /* sanity check */ - if (ncores > nr_cpu_ids) { - pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", - ncores, nr_cpu_ids); - ncores = nr_cpu_ids; - } - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - - return ncores; } static void __init exynos_smp_prepare_cpus(unsigned int max_cpus) diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c index 4d31fea..2fa48bd 100644 --- a/arch/arm/mach-omap2/omap-smp.c +++ b/arch/arm/mach-omap2/omap-smp.c @@ -193,16 +193,6 @@ static int __init omap4_smp_init_cpus(void) ncores = OMAP5_CORE_COUNT; } - /* sanity check */ - if (ncores > nr_cpu_ids) { - pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", - ncores, nr_cpu_ids); - ncores = nr_cpu_ids; - } - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - return ncores; } diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c index 0612f2d..eb9885f 100644 --- a/arch/arm/mach-realview/platsmp.c +++ b/arch/arm/mach-realview/platsmp.c @@ -45,21 +45,8 @@ static void __iomem *scu_base_addr(void) static int __init realview_smp_init_cpus(void) { void __iomem *scu_base = scu_base_addr(); - unsigned int i, ncores; - ncores = scu_base ? scu_get_core_count(scu_base) : 1; - - /* sanity check */ - if (ncores > nr_cpu_ids) { - pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", - ncores, nr_cpu_ids); - ncores = nr_cpu_ids; - } - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - - return ncores; + return scu_base ? scu_get_core_count(scu_base) : 1; } static void __init realview_smp_prepare_cpus(unsigned int max_cpus) diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c index 45d4d87..de14efc 100644 --- a/arch/arm/mach-socfpga/platsmp.c +++ b/arch/arm/mach-socfpga/platsmp.c @@ -60,24 +60,7 @@ static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle) */ static int __init socfpga_smp_init_cpus(void) { - unsigned int i, ncores; - - ncores = scu_get_core_count(socfpga_scu_base_addr); - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - - /* sanity check */ - if (ncores > num_possible_cpus()) { - pr_warn("socfpga: no. of cores (%d) greater than configured" - "maximum of %d - clipping\n", ncores, num_possible_cpus()); - ncores = num_possible_cpus(); - } - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - - return ncores; + return scu_get_core_count(socfpga_scu_base_addr); } static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus) diff --git a/arch/arm/mach-spear/platsmp.c b/arch/arm/mach-spear/platsmp.c index a6ef1ad..da4b4ac 100644 --- a/arch/arm/mach-spear/platsmp.c +++ b/arch/arm/mach-spear/platsmp.c @@ -95,18 +95,7 @@ static int spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle) */ static int __init spear13xx_smp_init_cpus(void) { - unsigned int i, ncores = scu_get_core_count(scu_base); - - if (ncores > nr_cpu_ids) { - pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", - ncores, nr_cpu_ids); - ncores = nr_cpu_ids; - } - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - - return ncores; + return scu_get_core_count(scu_base); } static void __init spear13xx_smp_prepare_cpus(unsigned int max_cpus) diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c index c8d8d4c..74485bc 100644 --- a/arch/arm/mach-ux500/platsmp.c +++ b/arch/arm/mach-ux500/platsmp.c @@ -136,21 +136,8 @@ static void __init wakeup_secondary(void) static int __init ux500_smp_init_cpus(void) { void __iomem *scu_base = scu_base_addr(); - unsigned int i, ncores; - ncores = scu_base ? scu_get_core_count(scu_base) : 1; - - /* sanity check */ - if (ncores > nr_cpu_ids) { - pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", - ncores, nr_cpu_ids); - ncores = nr_cpu_ids; - } - - for (i = 0; i < ncores; i++) - set_cpu_possible(i, true); - - return ncores; + return scu_base ? scu_get_core_count(scu_base) : 1; } static void __init ux500_smp_prepare_cpus(unsigned int max_cpus) diff --git a/arch/arm/mach-zynq/platsmp.c b/arch/arm/mach-zynq/platsmp.c index 1ab85e7..6b9e101 100644 --- a/arch/arm/mach-zynq/platsmp.c +++ b/arch/arm/mach-zynq/platsmp.c @@ -99,14 +99,7 @@ static int zynq_boot_secondary(unsigned int cpu, */ static int __init zynq_smp_init_cpus(void) { - int i; - - ncores = scu_get_core_count(zynq_scu_base); - - for (i = 0; i < ncores && i < CONFIG_NR_CPUS; i++) - set_cpu_possible(i, true); - - return ncores; + return scu_get_core_count(zynq_scu_base); } static void __init zynq_smp_prepare_cpus(unsigned int max_cpus)