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: 4669081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E00EEC0338 for ; Mon, 4 Aug 2014 10:00:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B85E220166 for ; Mon, 4 Aug 2014 10:00:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D7B692013A for ; Mon, 4 Aug 2014 10:00:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEF2L-0006Uk-TK; Mon, 04 Aug 2014 09:58:37 +0000 Received: from mail-pa0-f53.google.com ([209.85.220.53]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEF2E-0006O3-Sm for linux-arm-kernel@lists.infradead.org; Mon, 04 Aug 2014 09:58:35 +0000 Received: by mail-pa0-f53.google.com with SMTP id rd3so9733648pab.40 for ; Mon, 04 Aug 2014 02:58:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=3Tuq09fZtwvHNjco0i2jTp7kprdL+YPzw9P2AYx4cyU=; b=j8oCa2FNfeNKZhFjADp1aQFxHoqk52sQFk1MP0kI52wEV0yI7squG53u+yeSukzN29 SB/g2bwtNh5O6Aktr2odSaIEf1BOGrQHoJDfIa5dI9k4xk9FQcsCYcE+ItOH2BU0YJIv NmtjkfG5MFyI5Dk75b1nCWlqmJl9ZbpkJxhhyD+m7PdfooNHu2NiIpmvo6RU9jjXqwui qkvrCRYbwdYksfkIiyF7gl2kLDIbr984Lxt0pyVPUhFKrATVNbqztz7UWD7t0Qhanncs iLgoVTE9lUk3KCe6AG9lHMCbM5RX/TOG/5xHqvRmGo5IdmI5RLkJ5SWwjlj97qSsypGQ eX4A== X-Gm-Message-State: ALoCoQmqymG3PaqNkQjbmzUUqB6Isyt27m2X70eVCe4y6nUwLfuEIlJlFgBgcdNrc6mcr9OMPAZo 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140804_025830_946584_8FC7E192 X-CRM114-Status: GOOD ( 17.26 ) X-Spam-Score: -1.4 (-) Cc: Mark Rutland , Mark Brown , Catalin Marinas , Will Deacon , Lv Zheng , Lorenzo Pieralisi , Daniel Lezcano , Robert Moore , linux-acpi@vger.kernel.org, Grant Likely , Charles.Garcia-Tobin@arm.com, Robert Richter , Jason Cooper , Arnd Bergmann , Marc Zyngier , Liviu Dudau , Tomasz Nowicki , linaro-acpi-private@linaro.org, Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Graeme Gregory , Randy Dunlap , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Sudeep Holla X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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;