From patchwork Sat Jun 29 02:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongfeng Wang X-Patchwork-Id: 11023691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E59761398 for ; Sat, 29 Jun 2019 02:46:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E73662886B for ; Sat, 29 Jun 2019 02:46:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7C882883D; Sat, 29 Jun 2019 02:46:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8687D2883D for ; Sat, 29 Jun 2019 02:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AxOUzeGLsvZNoirgcBGesUvzA1ieo3xVWEz2aJYXk+4=; b=o1iKYgfra1xNi4 TElMPkqULn0YzTtF6/gFuPwa1Y7n6Lqfy2jRcTa59qJ/872SrfikyGKg+RikXRtSlwTfW+EEYG2bL EQByLNga31bVkPw0HQSP+Qw/PYMbHJGT/6aP761VcNMcXSCg7flANTD/FBILA1Mn36w6nbdRsnMxu xsknIR0Tl5swJCRtaXB9TWpTq9WJKNNaE7JCc+ErKhAnorcvym3KKUu2jC36ojmsX9hCbQA96ELGX CreYdPNuJZ5MmJJMgrdVEUqXxDOjL8HCx5YYtcAxpykrHqmsYpisOqapJSBiPGxyEVQeZUBd/R3xT 0CLGRsIBHQa6Wc5oDUlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hh3O9-0007PO-Ic; Sat, 29 Jun 2019 02:46:53 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hh3MG-0004qF-FG for linux-arm-kernel@lists.infradead.org; Sat, 29 Jun 2019 02:45:09 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3471AF8A73B0CB831ABA; Sat, 29 Jun 2019 10:44:51 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Sat, 29 Jun 2019 10:44:42 +0800 From: Xiongfeng Wang To: , , Subject: [RFC PATCH v2 1/3] ACPI / scan: evaluate _STA for processors declared via ASL Device statement Date: Sat, 29 Jun 2019 10:42:33 +0800 Message-ID: <1561776155-38975-2-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1561776155-38975-1-git-send-email-wangxiongfeng2@huawei.com> References: <1561776155-38975-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190628_194456_860460_066F1393 X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiexiuqi@huawei.com, jonathan.cameron@huawei.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, huawei.libin@huawei.com, guohanjun@huawei.com, wangxiongfeng2@huawei.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When we scan all the acpi namespace node in acpi_scan_init()->acpi_bus_scan(), we evaluate '_STA' method for processor type node to determine whether the device is present. But processors can also be declared via ASL Device statement. ACPI 6.3 spec specifically says that the Processor statement is deprecated and a Device statement should be used for processors. In that case, acpi_object_type is ACPI_TYPE_DEVICE rather than ACPI_TYPE_PROCESSOR. Current code doesn't evaluate '_STA' for nodes with ACPI_TYPE_DEVICE, and the device status is set to 'present' as default. This patch get the device status from '_STA' method for processors declared via ASL Device statement if it does have a '_STA' method. Signed-off-by: Xiongfeng Wang --- I am not sure if I should set 'type' as ACPI_BUS_TYPE_PROCESSOR rather than ACPI_BUS_TYPE_DEVICE for processors declared via ASL Device statement. --- drivers/acpi/scan.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 0e28270..cec43f6 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -16,6 +16,7 @@ #include #include +#include #include #include "internal.h" @@ -1687,6 +1688,7 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, { acpi_status status; acpi_object_type acpi_type; + struct acpi_device_info *info; status = acpi_get_type(handle, &acpi_type); if (ACPI_FAILURE(status)) @@ -1699,6 +1701,16 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, return -ENODEV; *type = ACPI_BUS_TYPE_DEVICE; + + status = acpi_get_object_info(handle, &info); + if (ACPI_SUCCESS(status) && info->valid & ACPI_VALID_HID && + !strcmp(info->hardware_id.string, + ACPI_PROCESSOR_DEVICE_HID)) { + status = acpi_bus_get_status_handle(handle, sta); + if (ACPI_SUCCESS(status)) + break; + } + /* * acpi_add_single_object updates this once we've an acpi_device * so that acpi_bus_get_status' quirk handling can be used. From patchwork Sat Jun 29 02:42:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongfeng Wang X-Patchwork-Id: 11023689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D966138D for ; Sat, 29 Jun 2019 02:46:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215F32883D for ; Sat, 29 Jun 2019 02:46:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15F2428875; Sat, 29 Jun 2019 02:46:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A35232883D for ; Sat, 29 Jun 2019 02:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cC9jyzYjfbwTvqfiMoewPl8IHhbAouUQTwJ2zTroUGE=; b=trHhecA9nxQDqu WFwjiPxr/aWXgXVDYfqV/BOwGq8zfNzubydbKOkh6WKDLq6KyGppwPC+4s5uF0LRtE1UOo/X8Hk2y 2JqhuyMkYWpRqoILiat3QPv7iaEohSWMCrU4ajtCa2dWnp6vFwSIZO8mdXPETSnBPCQgmXMOTo/x4 X1p9YWBZm/7yDPNhxHxYDQtmlKJB+OUZ+RwXiNK16ScGUFZvGLVfz/pwswiMlvvZNyRza7N4vHjJS uUk7aXPZ5nm0l4WtyVGl128SDCCLd2nfYWE35s88spG03aaIZMQi0yKPHYGmfE8U0naRoFYISalSG Ij4Fkj1HPSHH8MtkMh3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hh3Nq-0007Ap-9F; Sat, 29 Jun 2019 02:46:34 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hh3MG-0004qI-FJ for linux-arm-kernel@lists.infradead.org; Sat, 29 Jun 2019 02:45:02 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 298FF9071D527054F3DD; Sat, 29 Jun 2019 10:44:51 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Sat, 29 Jun 2019 10:44:43 +0800 From: Xiongfeng Wang To: , , Subject: [RFC PATCH v2 2/3] arm64: mark all the GICC nodes in MADT as possible cpu Date: Sat, 29 Jun 2019 10:42:34 +0800 Message-ID: <1561776155-38975-3-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1561776155-38975-1-git-send-email-wangxiongfeng2@huawei.com> References: <1561776155-38975-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190628_194456_841985_99235678 X-CRM114-Status: GOOD ( 12.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiexiuqi@huawei.com, jonathan.cameron@huawei.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, huawei.libin@huawei.com, guohanjun@huawei.com, wangxiongfeng2@huawei.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We set 'cpu_possible_mask' based on the enabled GICC node in MADT. If the GICC node is disabled, we will skip initializing the kernel data structure for that CPU. To support CPU hotplug, we need to initialize some CPU related data structure in advance. This patch mark all the GICC nodes as possible CPU and only these enabled GICC nodes as present CPU. Signed-off-by: Xiongfeng Wang --- arch/arm64/kernel/setup.c | 2 +- arch/arm64/kernel/smp.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 7e541f9..7f4d12a 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -359,7 +359,7 @@ static int __init topology_init(void) for_each_online_node(i) register_one_node(i); - for_each_possible_cpu(i) { + for_each_online_cpu(i) { struct cpu *cpu = &per_cpu(cpu_data.cpu, i); cpu->hotpluggable = 1; register_cpu(cpu, i); diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 6dcf960..6d9983c 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -525,16 +525,14 @@ struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu) { u64 hwid = processor->arm_mpidr; - if (!(processor->flags & ACPI_MADT_ENABLED)) { - pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid); - return; - } - if (hwid & ~MPIDR_HWID_BITMASK || hwid == INVALID_HWID) { pr_err("skipping CPU entry with invalid MPIDR 0x%llx\n", hwid); return; } + if (!(processor->flags & ACPI_MADT_ENABLED)) + pr_debug("disabled CPU entry with 0x%llx MPIDR\n", hwid); + if (is_mpidr_duplicate(cpu_count, hwid)) { pr_err("duplicate CPU MPIDR 0x%llx in MADT\n", hwid); return; @@ -755,7 +753,8 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (err) continue; - set_cpu_present(cpu, true); + if ((cpu_madt_gicc[cpu].flags & ACPI_MADT_ENABLED)) + set_cpu_present(cpu, true); numa_store_cpu_info(cpu); } } From patchwork Sat Jun 29 02:42:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongfeng Wang X-Patchwork-Id: 11023693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A5D41398 for ; Sat, 29 Jun 2019 02:47:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB642883D for ; Sat, 29 Jun 2019 02:47:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00A5D2886C; Sat, 29 Jun 2019 02:47:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E0222883D for ; Sat, 29 Jun 2019 02:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R0eLbko3RZlDysfKLUfaoGpLFQlqUidtAtupN/QglC4=; b=AjTMjCuKfe4m0k 923HFZITw5Ll/pBY3wn/AmU2pdjOIou1+UBEc+CBCdSZYxd3X9QY+DH77Eq0zhLSYjE9b3avsTB7D NPlZtapJQrWQQcqICLWx8i4z12PMe0FYEtAR4sYl9vpK85i8pLz8PD7uTTnqyDEVKjaO4amcVzBfd 96o1QoN3K4SFMFc7QuIFxtB6psDpoPQYdIo4QV8+HddU7GWyY3EYZ19sTcie+FhfninCCJ1M+DGab FxiYwq1nLdfJtbzJOUB/kmvInFvvvCKMfRc3/W0gQSwuIiy3fxPnepg/Y36A5v2i3wv5Og5EV6cJk a+r7hhj3BIrVbnd7W4XA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hh3ON-0007dq-RP; Sat, 29 Jun 2019 02:47:07 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hh3MG-0004qJ-FK for linux-arm-kernel@lists.infradead.org; Sat, 29 Jun 2019 02:45:06 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 24138748E1AEC8CEF4C4; Sat, 29 Jun 2019 10:44:51 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Sat, 29 Jun 2019 10:44:43 +0800 From: Xiongfeng Wang To: , , Subject: [RFC PATCH v2 3/3] arm64: Add CPU hotplug support Date: Sat, 29 Jun 2019 10:42:35 +0800 Message-ID: <1561776155-38975-4-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1561776155-38975-1-git-send-email-wangxiongfeng2@huawei.com> References: <1561776155-38975-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190628_194456_849819_0E62C875 X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiexiuqi@huawei.com, jonathan.cameron@huawei.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, huawei.libin@huawei.com, guohanjun@huawei.com, wangxiongfeng2@huawei.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To support CPU hotplug, we need to implement 'acpi_(un)map_cpu()' and 'arch_(un)register_cpu()' for ARM64. These functions are called in 'acpi_processor_hotadd_init()/acpi_processor_remove()' when the CPU is hot added into or hot removed from the system. Signed-off-by: Xiongfeng Wang --- arch/arm64/kernel/acpi.c | 22 ++++++++++++++++++++++ arch/arm64/kernel/setup.c | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 2804330..57835fa 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -284,3 +285,24 @@ int apei_claim_sea(struct pt_regs *regs) return err; } + +int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, + int *pcpu) +{ + int cpu; + + cpu = acpi_map_cpuid(physid, acpi_id); + *pcpu = cpu; + set_cpu_present(cpu, true); + + return 0; +} +EXPORT_SYMBOL(acpi_map_cpu); + +int acpi_unmap_cpu(int cpu) +{ + set_cpu_present(cpu, false); + + return 0; +} +EXPORT_SYMBOL(acpi_unmap_cpu); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 7f4d12a..f2a881e 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -398,3 +398,20 @@ static int __init register_kernel_offset_dumper(void) return 0; } __initcall(register_kernel_offset_dumper); + +int arch_register_cpu(int num) +{ + struct cpu *cpu = &per_cpu(cpu_data.cpu, num); + + cpu->hotpluggable = 1; + return register_cpu(cpu, num); +} +EXPORT_SYMBOL(arch_register_cpu); + +void arch_unregister_cpu(int num) +{ + struct cpu *cpu = &per_cpu(cpu_data.cpu, num); + + unregister_cpu(cpu); +} +EXPORT_SYMBOL(arch_unregister_cpu);