From patchwork Mon Aug 4 09:56:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 34827 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0988321F5F for ; Mon, 4 Aug 2014 09:58:23 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf48449142pab.9 for ; Mon, 04 Aug 2014 02:58:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=jzCliwtQEmY4W0Kmh5495yw9KLJbr5NYx6qIJp/wWCY=; b=fGE8FOfhquPoAPRODx+wzNPvBhtI7igrCOJn9ss7YKpqtkJ3obDpVQDXhwrjkGUdAF Bq1R8UU6b6P9pVKkJ5HknKt8gCovEKMeUaWcd1bh6zqTonhDqzSmvb8I8xx6+PG0F8Q8 QmvDOhKI7+xevCPUxpaI+lqByN4LphMi5+igMPGHK51ZHAdGvs1xJz0F19RnsGxAMq7C yLyuuGVdKfNrHSlkAOonhH75vyXcskjaRJi2ODczKpIzYiZmC6OSTf3ilTqAFbvrfbKj TzmyB5YH4qKUKVbUYKNMEn/oC8hSPj7LWGhSy6fS9NM6VsdF+kfXTL4ee2KPTUJTzg23 VEZQ== X-Gm-Message-State: ALoCoQngJcZRiIAbCXbY9N2GPvFcZkh6/aCknQ8Jm9Lut3Iky1CiI1NZ7RnuyM0fhBrvu7oVzBnG X-Received: by 10.66.136.71 with SMTP id py7mr3950997pab.35.1407146301629; Mon, 04 Aug 2014 02:58:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.37 with SMTP id q34ls836519qgd.5.gmail; Mon, 04 Aug 2014 02:58:21 -0700 (PDT) X-Received: by 10.52.231.226 with SMTP id tj2mr18842602vdc.16.1407146301490; Mon, 04 Aug 2014 02:58:21 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id h18si11600487vdt.8.2014.08.04.02.58.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 02:58:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so10455287vcb.22 for ; Mon, 04 Aug 2014 02:58:21 -0700 (PDT) X-Received: by 10.220.182.1 with SMTP id ca1mr22310918vcb.21.1407146301398; Mon, 04 Aug 2014 02:58:21 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp291832vcb; Mon, 4 Aug 2014 02:58:20 -0700 (PDT) X-Received: by 10.70.140.139 with SMTP id rg11mr14733086pdb.13.1407146300323; Mon, 04 Aug 2014 02:58:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ns7si17014134pbb.248.2014.08.04.02.58.19 for ; Mon, 04 Aug 2014 02:58:20 -0700 (PDT) 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 S1752102AbaHDJ6P (ORCPT + 20 others); Mon, 4 Aug 2014 05:58:15 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:41089 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbaHDJ6K (ORCPT ); Mon, 4 Aug 2014 05:58:10 -0400 Received: by mail-pa0-f50.google.com with SMTP id et14so9829830pad.9 for ; Mon, 04 Aug 2014 02:58:09 -0700 (PDT) X-Received: by 10.70.134.165 with SMTP id pl5mr12014193pdb.20.1407146289243; Mon, 04 Aug 2014 02:58:09 -0700 (PDT) Received: from [192.168.0.113] ([183.247.163.231]) by mx.google.com with ESMTPSA id rm9sm61647543pab.4.2014.08.04.02.58.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 02:58:08 -0700 (PDT) Message-ID: <53DF58CD.9000704@linaro.org> Date: Mon, 04 Aug 2014 17:56:29 +0800 From: Hanjun Guo User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Olof Johansson , Geoff Levand CC: Catalin Marinas , "Rafael J. Wysocki" , Mark Rutland , Graeme Gregory , Arnd Bergmann , Grant Likely , Sudeep Holla , Will Deacon , Jason Cooper , Marc Zyngier , Bjorn Helgaas , Daniel Lezcano , Mark Brown , Robert Richter , Lv Zheng , Robert Moore , Lorenzo Pieralisi , Liviu Dudau , Randy Dunlap , Charles.Garcia-Tobin@arm.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-acpi-private@linaro.org, Tomasz Nowicki Subject: Re: [PATCH 10/19] ARM64 / ACPI: Get the enable method for SMP initialization in ACPI way References: <1406206825-15590-1-git-send-email-hanjun.guo@linaro.org> <1406206825-15590-11-git-send-email-hanjun.guo@linaro.org> <20140731065426.GA876@quad.lixom.net> <53DA2110.8060000@linaro.org> In-Reply-To: <53DA2110.8060000@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: hanjun.guo@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.220.177 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: , Hi Olof, On 2014-7-31 18:57, Hanjun Guo wrote: > On 2014-7-31 14:54, Olof Johansson wrote: [...] >>> +static void __init acpi_smp_init_cpus(void) >>> +{ >>> + int cpu; >>> + >>> + for_each_possible_cpu(cpu) { >>> + if (cpu_acpi_read_ops(cpu) != 0) >>> + continue; >>> + >>> + cpu_ops[cpu]->cpu_init(NULL, cpu); >>> + } >>> +} >>> + >>> +void __init smp_init_cpus(void) >>> +{ >>> + if (acpi_disabled) >>> + of_smp_init_cpus(); >>> + else >>> + acpi_smp_init_cpus(); >> >> I'm liking these deeply split code paths less and less every time I see >> them. :( >> >> I would prefer to set up shared state in separate functions, but keep the >> control flow the same. Right now you're splitting it completely. >> >> I.e. split data setup between the two, but do the loop calling cpu_init() >> the same way. (Yes, that will require you to refactor the DT code path >> a bit too...) > > OK, I will dive into the code and figure out if I can fix that as you > suggested, thanks for your comments :) After some investigation of the code, it seems that it is pretty hard to do so, the major gap to do that is DT needs the device node of CPU to init CPUs, but ACPI just needs the logical CPU number. In DT mode, it needs to search the DT and get the CPU device node to get its enable method, but in ACPI mode, it is a flag to indicate the CPU enable (boot) method. the code can be modified as below, but the logic is the same: Does it make sense to you? Thanks Hanjun --- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 40f38f4..71a625b 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -320,6 +320,17 @@ void __init smp_init_cpus(void) unsigned int i, cpu = 1; bool bootcpu_valid = false; + if (!acpi_disabled) { + for_each_possible_cpu(cpu) { + if (cpu_read_ops(NULL, cpu) != 0) + continue; + + cpu_ops[cpu]->cpu_init(NULL, cpu); + } + + return; + } + while ((dn = of_find_node_by_type(dn, "cpu"))) { const u32 *cell; u64 hwid;