From patchwork Wed Feb 12 00:43:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11377337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3962192A for ; Wed, 12 Feb 2020 00:48:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17BDF20724 for ; Wed, 12 Feb 2020 00:48:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D/uIIYiD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NHf9h2sl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17BDF20724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=yROGqxELv/bfK/kCQ+at7moyOaEWNcFvQ1uphgzWPrw=; b=D/uIIYiDT4FI7U W7YIcclt+nh7OAIZ5uOUwV5lRRaMDv2EAv3RjxfzD64K6cx837C/NC1bJieH5aAwJhdc36mbpu3CO DtVL6IQX6S3zdLr3R1OELTm9wDTGxFO5amxhR5wvZ+FFE32f4g4q/QFGsAV7U4xHRA5+hmpY1rji+ 4b9XqAph+wLEHmIAjvDHeYM8EkXlujmZwa3TWpIQCBu+RjL2aW9q+H6eUWoZKIuCOTILh87PJY7XA glMo+p0E0J8Q4Cy+YQ5HAUUvY6GOqvIM45xmNEOhMN+3r38kzoNj9jUQOi24bY+rkuBS0K2CmIe6Y fI/5TbqYgaAF/6W5KXdg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1gCt-0000PR-Dt; Wed, 12 Feb 2020 00:48:47 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1g8M-0003Iv-KH for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2020 00:44:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581468244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J+coPInJKB/ZK83E2rv0xKYdopET9tZ0sSZsSRcXGHY=; b=NHf9h2sl106/1TuXXAjwJA2U3shlVk7TGhDWAAFxoRP3Bn2Y23pP9gee6Tpw2hnVhuJaGG unobH2XngI7GnuAE8eCphZTy6VQPSNyKQbX6upfdvSQK/MyTQ8CD5P8wiySDxCIH5JtMZC AULwEBbu1UNZi2urMjHSdaHSS/aBzcg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-lmUSPTvnNiev9MxBdYzhsw-1; Tue, 11 Feb 2020 19:44:03 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB50E800D41; Wed, 12 Feb 2020 00:44:01 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-85.bne.redhat.com [10.64.54.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 122605D9E2; Wed, 12 Feb 2020 00:43:58 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/5] arm64: Declare ACPI parking protocol CPU operation if needed Date: Wed, 12 Feb 2020 11:43:47 +1100 Message-Id: <20200212004351.66576-2-gshan@redhat.com> In-Reply-To: <20200212004351.66576-1-gshan@redhat.com> References: <20200212004351.66576-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: lmUSPTvnNiev9MxBdYzhsw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_164406_750217_CF0C77A4 X-CRM114-Status: UNSURE ( 8.71 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [205.139.110.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, will@kernel.org, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org It's obvious we needn't declare the corresponding CPU operation when CONFIG_ARM64_ACPI_PARKING_PROTOCOL is disabled. Signed-off-by: Gavin Shan --- arch/arm64/kernel/cpu_ops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index 7e07072757af..2082cfb1be86 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -15,7 +15,9 @@ #include extern const struct cpu_operations smp_spin_table_ops; +#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL extern const struct cpu_operations acpi_parking_protocol_ops; +#endif extern const struct cpu_operations cpu_psci_ops; const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; From patchwork Wed Feb 12 00:43:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11377339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08B16139A for ; Wed, 12 Feb 2020 00:49:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF1BD20842 for ; Wed, 12 Feb 2020 00:49:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CAsIxY5Z"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MQvE3GyM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF1BD20842 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=2XtsRq2X96AVnO5POKcgj6G6fbaeQbO39Ty0CZ6/n9w=; b=CAsIxY5ZIg7Pap ZpH/s4K5gZylf4x+IMW0GDvDZDKXEM1s4Yj6llwFK1YOubSOANLjCy23CGYeF3EEVxBMks3faDzMx w07H85lEVE7Fiehs4Xb8RTja+eM0TQkGHul8fyS2a3KtZf7XEpKbtlwJwJ9/AIHrM0lEV+n6QoTkK rFIzATzMSK0OIj50YBgL/nBeBL9t3cUJMswi6WVseaEfBIja8MhZr4x87IJ6w1vjYajSl07WZNxA5 L66uRaK6ps3YxO/vVd/1Nr5DOM+MwUNHSYeiTgtKyxPIaFc30351bIaDFC3pirBDx8TIFFgw1U0pD 88Y5J+NKpHrTIE0p1J8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1gD3-0000cM-6I; Wed, 12 Feb 2020 00:48:57 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1g8P-0003Mu-LF for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2020 00:44:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581468248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xLS3Y9hDyx60/oXsMxVZGXYUWngEqsQwLyUpz8bQoGc=; b=MQvE3GyMyWUISrYJNOpt4gn+3n4e/aUoqdRok2Z1QeFtXaltTiWfUvpn9/sfh3zF04CBtM pdQQUKgEkaAFM6Dt/+SGVG7AAZVu8dJvv4T5BiphzIonSwqomFNzltjTr7Pej4cIgwtKrx e9Ypg9FvR/CWX+8aYiRNHJRFqgFd6DE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-U7APUEAFOJ2kV1cQl6m5oQ-1; Tue, 11 Feb 2020 19:44:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BDBC800D41; Wed, 12 Feb 2020 00:44:05 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-85.bne.redhat.com [10.64.54.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AFF65D9E2; Wed, 12 Feb 2020 00:44:02 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/5] arm64: Rename cpu_read_ops() to init_cpu_ops() Date: Wed, 12 Feb 2020 11:43:48 +1100 Message-Id: <20200212004351.66576-3-gshan@redhat.com> In-Reply-To: <20200212004351.66576-1-gshan@redhat.com> References: <20200212004351.66576-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: U7APUEAFOJ2kV1cQl6m5oQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_164409_780449_D0F21159 X-CRM114-Status: GOOD ( 11.77 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, will@kernel.org, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This renames cpu_read_ops() to init_cpu_ops() as the function it's only called in initialization phase. Also, we will introduce get_cpu_ops() in the subsequent patches, to retireve the CPU operation by the given CPU index. The usage of cpu_read_ops() and get_cpu_ops() are difficult to be distinguish from their names. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/cpu_ops.h | 6 +++--- arch/arm64/kernel/cpu_ops.c | 2 +- arch/arm64/kernel/setup.c | 2 +- arch/arm64/kernel/smp.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index 86aabf1e0199..baa13b5db2ca 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -56,11 +56,11 @@ struct cpu_operations { }; extern const struct cpu_operations *cpu_ops[NR_CPUS]; -int __init cpu_read_ops(int cpu); +int __init init_cpu_ops(int cpu); -static inline void __init cpu_read_bootcpu_ops(void) +static inline void __init init_bootcpu_ops(void) { - cpu_read_ops(0); + init_cpu_ops(0); } #endif /* ifndef __ASM_CPU_OPS_H */ diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index 2082cfb1be86..a6c3c816b618 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -96,7 +96,7 @@ static const char *__init cpu_read_enable_method(int cpu) /* * Read a cpu's enable method and record it in cpu_ops. */ -int __init cpu_read_ops(int cpu) +int __init init_cpu_ops(int cpu) { const char *enable_method = cpu_read_enable_method(cpu); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index a34890bf309f..f66bd260cce8 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -344,7 +344,7 @@ void __init setup_arch(char **cmdline_p) else psci_acpi_init(); - cpu_read_bootcpu_ops(); + init_bootcpu_ops(); smp_init_cpus(); smp_build_mpidr_hash(); diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index d4ed9a19d8fe..6f8477d7f3be 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -488,7 +488,7 @@ static bool __init is_mpidr_duplicate(unsigned int cpu, u64 hwid) */ static int __init smp_cpu_setup(int cpu) { - if (cpu_read_ops(cpu)) + if (init_cpu_ops(cpu)) return -ENODEV; if (cpu_ops[cpu]->cpu_init(cpu)) From patchwork Wed Feb 12 00:43:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11377341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8614892A for ; Wed, 12 Feb 2020 00:49:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 39A4620724 for ; Wed, 12 Feb 2020 00:49:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UPOoYiLD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KJnwvQck" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39A4620724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=DHQ4zLutzZ3oIyTAuh6AVmyO47CeB9R6DdiX3/fC9nM=; b=UPOoYiLD+n7+eh QsHHnZoAI3ANpoJeBj68Wc6gIhYRaVg8+ZyVJ/SAby9hdN1UfSiLUgh08hTQa7/VEIg+ijIrEyCKj J4tbqOc6nlLEqUlAn4pHnguPNDofxDErpbBsW3WnjRn1Jsbq+fIcdjJESqpVGJ2MI5ZzjcfM95heP W7VvNTItAwzGZ30PYyW8pbrNFjHCggpZVy00U1pq+EsEOGyrMZUCAyAb/gUYItWMsRgRXtQG9TJ28 6SXxJtwQwzIvMOGs9G0w14VeUhDFAtLoys+W0v4kQhJBq3jIT8g/WBPGaS6cygoPiJvIRsth9pGEY h7BB+MVFfCgBKAxNc3rA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1gDL-0000uW-RO; Wed, 12 Feb 2020 00:49:15 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1g8V-0003RT-3Q for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2020 00:44:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581468253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N1TQ8ZELNKvVUfyizFZ7f9BlXlskAtMqcb6AYCMUOOQ=; b=KJnwvQckW8aG0WRQ0Xk7/MZwLfjAbFNKyMWzqimqiu8TgmYBKWO8P4B07x0K5+AHedVvx5 aBssamS64tW4Bu77Sm8qi4ubl6rPxp5AudLLGk5tSkwU/gGRJjHMakYW7xYPtKoPQF0fWr y62io0d5Un2uMfbf26uclA34VqFpf1M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-hOZPjq1mOlOhWMygQOVuJg-1; Tue, 11 Feb 2020 19:44:11 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2962B8017CC; Wed, 12 Feb 2020 00:44:10 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-85.bne.redhat.com [10.64.54.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id D16DD5D9E2; Wed, 12 Feb 2020 00:44:06 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 3/5] arm64: Introduce get_cpu_ops() helper function Date: Wed, 12 Feb 2020 11:43:49 +1100 Message-Id: <20200212004351.66576-4-gshan@redhat.com> In-Reply-To: <20200212004351.66576-1-gshan@redhat.com> References: <20200212004351.66576-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: hOZPjq1mOlOhWMygQOVuJg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_164415_519484_AFED73CA X-CRM114-Status: GOOD ( 15.44 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, will@kernel.org, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This introduces get_cpu_ops() to return the CPU operations according to the given CPU index. For now, it simply returns the @cpu_ops[cpu] as before. So it shouldn't introduce any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/cpu_ops.h | 2 +- arch/arm64/kernel/cpu_ops.c | 7 +++- arch/arm64/kernel/cpuidle.c | 9 ++--- arch/arm64/kernel/setup.c | 6 ++-- arch/arm64/kernel/smp.c | 57 ++++++++++++++++++++++---------- 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index baa13b5db2ca..d28e8f37d3b4 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -55,8 +55,8 @@ struct cpu_operations { #endif }; -extern const struct cpu_operations *cpu_ops[NR_CPUS]; int __init init_cpu_ops(int cpu); +extern const struct cpu_operations *get_cpu_ops(int cpu); static inline void __init init_bootcpu_ops(void) { diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index a6c3c816b618..e133011f64b5 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -20,7 +20,7 @@ extern const struct cpu_operations acpi_parking_protocol_ops; #endif extern const struct cpu_operations cpu_psci_ops; -const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; +static const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; static const struct cpu_operations *const dt_supported_cpu_ops[] __initconst = { &smp_spin_table_ops, @@ -111,3 +111,8 @@ int __init init_cpu_ops(int cpu) return 0; } + +const struct cpu_operations *get_cpu_ops(int cpu) +{ + return cpu_ops[cpu]; +} diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c index e4d6af2fdec7..b512b5503f6e 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/arch/arm64/kernel/cpuidle.c @@ -18,11 +18,11 @@ int arm_cpuidle_init(unsigned int cpu) { + const struct cpu_operations *ops = get_cpu_ops(cpu); int ret = -EOPNOTSUPP; - if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend && - cpu_ops[cpu]->cpu_init_idle) - ret = cpu_ops[cpu]->cpu_init_idle(cpu); + if (ops && ops->cpu_suspend && ops->cpu_init_idle) + ret = ops->cpu_init_idle(cpu); return ret; } @@ -37,8 +37,9 @@ int arm_cpuidle_init(unsigned int cpu) int arm_cpuidle_suspend(int index) { int cpu = smp_processor_id(); + const struct cpu_operations *ops = get_cpu_ops(cpu); - return cpu_ops[cpu]->cpu_suspend(index); + return ops->cpu_suspend(index); } #ifdef CONFIG_ACPI diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index f66bd260cce8..3fd2c11c09fc 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -371,8 +371,10 @@ void __init setup_arch(char **cmdline_p) static inline bool cpu_can_disable(unsigned int cpu) { #ifdef CONFIG_HOTPLUG_CPU - if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_can_disable) - return cpu_ops[cpu]->cpu_can_disable(cpu); + const struct cpu_operations *ops = get_cpu_ops(cpu); + + if (ops && ops->cpu_can_disable) + return ops->cpu_can_disable(cpu); #endif return false; } diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 6f8477d7f3be..5e1af1a3c521 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -93,8 +93,10 @@ static inline int op_cpu_kill(unsigned int cpu) */ static int boot_secondary(unsigned int cpu, struct task_struct *idle) { - if (cpu_ops[cpu]->cpu_boot) - return cpu_ops[cpu]->cpu_boot(cpu); + const struct cpu_operations *ops = get_cpu_ops(cpu); + + if (ops->cpu_boot) + return ops->cpu_boot(cpu); return -EOPNOTSUPP; } @@ -196,6 +198,7 @@ asmlinkage notrace void secondary_start_kernel(void) { u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; struct mm_struct *mm = &init_mm; + const struct cpu_operations *ops; unsigned int cpu; cpu = task_cpu(current); @@ -227,8 +230,9 @@ asmlinkage notrace void secondary_start_kernel(void) */ check_local_cpu_capabilities(); - if (cpu_ops[cpu]->cpu_postboot) - cpu_ops[cpu]->cpu_postboot(); + ops = get_cpu_ops(cpu); + if (ops->cpu_postboot) + ops->cpu_postboot(); /* * Log the CPU info before it is marked online and might get read. @@ -266,19 +270,21 @@ asmlinkage notrace void secondary_start_kernel(void) #ifdef CONFIG_HOTPLUG_CPU static int op_cpu_disable(unsigned int cpu) { + const struct cpu_operations *ops = get_cpu_ops(cpu); + /* * If we don't have a cpu_die method, abort before we reach the point * of no return. CPU0 may not have an cpu_ops, so test for it. */ - if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_die) + if (!ops || !ops->cpu_die) return -EOPNOTSUPP; /* * We may need to abort a hot unplug for some other mechanism-specific * reason. */ - if (cpu_ops[cpu]->cpu_disable) - return cpu_ops[cpu]->cpu_disable(cpu); + if (ops->cpu_disable) + return ops->cpu_disable(cpu); return 0; } @@ -314,15 +320,17 @@ int __cpu_disable(void) static int op_cpu_kill(unsigned int cpu) { + const struct cpu_operations *ops = get_cpu_ops(cpu); + /* * If we have no means of synchronising with the dying CPU, then assume * that it is really dead. We can only wait for an arbitrary length of * time and hope that it's dead, so let's skip the wait and just hope. */ - if (!cpu_ops[cpu]->cpu_kill) + if (!ops->cpu_kill) return 0; - return cpu_ops[cpu]->cpu_kill(cpu); + return ops->cpu_kill(cpu); } /* @@ -357,6 +365,7 @@ void __cpu_die(unsigned int cpu) void cpu_die(void) { unsigned int cpu = smp_processor_id(); + const struct cpu_operations *ops = get_cpu_ops(cpu); idle_task_exit(); @@ -370,7 +379,7 @@ void cpu_die(void) * mechanism must perform all required cache maintenance to ensure that * no dirty lines are lost in the process of shutting down the CPU. */ - cpu_ops[cpu]->cpu_die(cpu); + ops->cpu_die(cpu); BUG(); } @@ -383,6 +392,7 @@ void cpu_die(void) void cpu_die_early(void) { int cpu = smp_processor_id(); + const struct cpu_operations *ops = get_cpu_ops(cpu); pr_crit("CPU%d: will not boot\n", cpu); @@ -392,8 +402,8 @@ void cpu_die_early(void) #ifdef CONFIG_HOTPLUG_CPU update_cpu_boot_status(CPU_KILL_ME); /* Check if we can park ourselves */ - if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_die) - cpu_ops[cpu]->cpu_die(cpu); + if (ops && ops->cpu_die) + ops->cpu_die(cpu); #endif update_cpu_boot_status(CPU_STUCK_IN_KERNEL); @@ -488,10 +498,13 @@ static bool __init is_mpidr_duplicate(unsigned int cpu, u64 hwid) */ static int __init smp_cpu_setup(int cpu) { + const struct cpu_operations *ops; + if (init_cpu_ops(cpu)) return -ENODEV; - if (cpu_ops[cpu]->cpu_init(cpu)) + ops = get_cpu_ops(cpu); + if (ops->cpu_init(cpu)) return -ENODEV; set_cpu_possible(cpu, true); @@ -714,6 +727,7 @@ void __init smp_init_cpus(void) void __init smp_prepare_cpus(unsigned int max_cpus) { + const struct cpu_operations *ops; int err; unsigned int cpu; unsigned int this_cpu; @@ -744,10 +758,11 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (cpu == smp_processor_id()) continue; - if (!cpu_ops[cpu]) + ops = get_cpu_ops(cpu); + if (!ops) continue; - err = cpu_ops[cpu]->cpu_prepare(cpu); + err = ops->cpu_prepare(cpu); if (err) continue; @@ -855,6 +870,10 @@ static atomic_t waiting_for_crash_ipi = ATOMIC_INIT(0); static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) { +#ifdef CONFIG_HOTPLUG_CPU + const struct cpu_operations *ops; +#endif + #ifdef CONFIG_KEXEC_CORE crash_save_cpu(regs, cpu); @@ -864,8 +883,9 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) sdei_mask_local_cpu(); #ifdef CONFIG_HOTPLUG_CPU - if (cpu_ops[cpu]->cpu_die) - cpu_ops[cpu]->cpu_die(cpu); + ops = get_cpu_ops(cpu); + if (ops->cpu_die) + ops->cpu_die(cpu); #endif /* just in case */ @@ -1044,8 +1064,9 @@ static bool have_cpu_die(void) { #ifdef CONFIG_HOTPLUG_CPU int any_cpu = raw_smp_processor_id(); + const struct cpu_operations *ops = get_cpu_ops(any_cpu); - if (cpu_ops[any_cpu] && cpu_ops[any_cpu]->cpu_die) + if (ops && ops->cpu_die) return true; #endif return false; From patchwork Wed Feb 12 00:43:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11377343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED78092A for ; Wed, 12 Feb 2020 00:49:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB2C720724 for ; Wed, 12 Feb 2020 00:49:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ca3t3FTE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TxlVM5+9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB2C720724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=24zCL9uti/pNcA3JbXvTO5E+wa86Vjgna2qA+pijFY0=; b=Ca3t3FTEHO33pi m+rykLzM65CyAtVqG73i6tQlf7Yx7VMImXSKBzw72WdlIMd8XV0vwDzpWcAmNWtn5nyOzn5QK+8jx ssq0gdkHC1aXKOwM0KOLerWshLZk4AYQm9ZrCDjaTIzQMWQ3kCN6+Xdxlk+UE/kuYVprVRVVKH1mQ RdKEXO5NiNFdPYM9YumvCVCluQaYBHqfMEECRLw7KC1604P0JaUBCD2KVW12mxqBTQIG0swtT8Xmw M3VIg6GYPYebYL3PsICT5Jfy/5pIGrkxmasHeFwDoiLX47Ks1tXqlHOPg8yFHDBhJXW/0nbimMYJi rU5IXwtKI7oBj9hAVvug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1gDX-0001Cf-F5; Wed, 12 Feb 2020 00:49:27 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1g8Y-0003VN-Td for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2020 00:44:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581468257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=56Wd+pLLPTvSUVpTG+MSZeAreq3mpebS3/vGvKPY2Vc=; b=TxlVM5+9Yi/vekZbfqEhivvTpUjigAubtMcAXQAOUS+GZ1omZ5LDq/TyqUepXQwLLKanHn KogOycGTjw13ExTDjC1iYobwDE6BPGYlZuZhmfMqsq9zg8rsjd7VNz5XvbzgKtVHy1XGZ2 oqhttIdt7zstNZY43l70PQDSfc9Y+80= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-VjwPVUpHP5mfyhGG08MoZQ-1; Tue, 11 Feb 2020 19:44:15 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FEBE107ACCA; Wed, 12 Feb 2020 00:44:14 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-85.bne.redhat.com [10.64.54.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B0FA5D9E2; Wed, 12 Feb 2020 00:44:11 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 4/5] arm64: Remove CPU operations dereferencing array Date: Wed, 12 Feb 2020 11:43:50 +1100 Message-Id: <20200212004351.66576-5-gshan@redhat.com> In-Reply-To: <20200212004351.66576-1-gshan@redhat.com> References: <20200212004351.66576-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: VjwPVUpHP5mfyhGG08MoZQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_164419_067764_15FA01EF X-CRM114-Status: GOOD ( 12.66 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, will@kernel.org, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org One CPU operations is maintained through array @cpu_ops[NR_CPUS]. 2KB memory is consumed when CONFIG_NR_CPUS is set to 256. It seems too much memory has been used for this. Also, all CPUs must use same CPU operations and we shouldn't bring up the broken CPU, as Lorenzo Pieralisi pointed out. This introduces variable (@cpu_ops_index) to store the unified CPU operations index. The CPU, which has different index, won't be brought up. With this, the CPU operations dereferencing array is removed and 2KB memory is saved. Signed-off-by: Gavin Shan --- arch/arm64/kernel/cpu_ops.c | 62 ++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index e133011f64b5..f59c087d6284 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -4,7 +4,6 @@ * * Copyright (C) 2013 ARM Ltd. */ - #include #include #include @@ -20,39 +19,32 @@ extern const struct cpu_operations acpi_parking_protocol_ops; #endif extern const struct cpu_operations cpu_psci_ops; -static const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; - -static const struct cpu_operations *const dt_supported_cpu_ops[] __initconst = { +/* + * Each element of the index array is shared by 4 CPUs. It means each + * CPU index uses 2 bits. + */ +static const struct cpu_operations *const cpu_ops[] = { &smp_spin_table_ops, - &cpu_psci_ops, - NULL, -}; - -static const struct cpu_operations *const acpi_supported_cpu_ops[] __initconst = { #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL &acpi_parking_protocol_ops, #endif &cpu_psci_ops, - NULL, }; +static int cpu_ops_index __ro_after_init = INT_MAX; -static const struct cpu_operations * __init cpu_get_ops(const char *name) +static int __init get_cpu_ops_index(const char *name) { - const struct cpu_operations *const *ops; - - ops = acpi_disabled ? dt_supported_cpu_ops : acpi_supported_cpu_ops; - - while (*ops) { - if (!strcmp(name, (*ops)->name)) - return *ops; + int index; - ops++; + for (index = 0; index < ARRAY_SIZE(cpu_ops); index++) { + if (!strcmp(cpu_ops[index]->name, name)) + return index; } - return NULL; + return -ERANGE; } -static const char *__init cpu_read_enable_method(int cpu) +static const char *__init get_cpu_method(int cpu) { const char *enable_method; @@ -93,26 +85,40 @@ static const char *__init cpu_read_enable_method(int cpu) return enable_method; } -/* - * Read a cpu's enable method and record it in cpu_ops. - */ + int __init init_cpu_ops(int cpu) { - const char *enable_method = cpu_read_enable_method(cpu); + const char *enable_method = get_cpu_method(cpu); + int index; if (!enable_method) return -ENODEV; - cpu_ops[cpu] = cpu_get_ops(enable_method); - if (!cpu_ops[cpu]) { + index = get_cpu_ops_index(enable_method); + if (index < 0) { pr_warn("Unsupported enable-method: %s\n", enable_method); return -EOPNOTSUPP; } + /* Update the index directly if it's invalid */ + if (cpu_ops_index == INT_MAX) { + cpu_ops_index = index; + return 0; + } + + if (index != cpu_ops_index) { + pr_warn("Invalid CPU operations index %d (%d) on CPU %d\n", + index, cpu_ops_index, cpu); + return -EINVAL; + } + return 0; } const struct cpu_operations *get_cpu_ops(int cpu) { - return cpu_ops[cpu]; + if (cpu_ops_index == INT_MAX) + return NULL; + + return cpu_ops[cpu_ops_index]; } From patchwork Wed Feb 12 00:43:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 11377345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8486A139A for ; Wed, 12 Feb 2020 00:49:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 612F320724 for ; Wed, 12 Feb 2020 00:49:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZQgxhAE5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GeMzW3ef" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 612F320724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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=LKtXjimhdAxrTxkaE4cAFlfglX4kqmoFe+S1lmQz+wQ=; b=ZQgxhAE5Uuu4sN Xklbt+8A/YpXukazTLAz3dAoh8pOTVj0NmomNr8ZFeavFNGQuVf76J/8GGkEedo1MhU8MT34jWVM3 3CBGyZ6eqKvCwl9T5ioycWIIiAN9HDrft+nRQ9vJbkR8paCZuDL6dtWGDh/orypglbbzlizINX40m vf37f14Q1zDg5aoe6lD7aM0k7tTXgmPDtaiKVfYUfYlu6VLb7aq97WKw7jiUDHBulMJixh4vViHB/ +p9FpGZ+CQ07I1eATUw8Mc4zE9usaBf1hzEYY7X0BXGqn98t/HR5IDXij2y+8VsK082+7HuE4iAxF MhPCmOIdQGX41qQ8U88A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1gDr-0001Vw-Bv; Wed, 12 Feb 2020 00:49:47 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1g8d-0003Z4-2s for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2020 00:44:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581468261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rfFV5qYHl49NJFDgjcLOFqNujHORxmqMOvdY/t12RZg=; b=GeMzW3efqCf1QCk3b1aAUtyDJTGaWwLrpJ+JEf0OGmsC4kwm8a+rVZAFHqoG68nKF7AJDO bMSBiu2jQ/mHgbEMQ52PYAFs82rDDmHNUE9CGdqO0xWOmEyRaC8adgShaKq6IjcSoctikr GsdibUvgWiYkd7KY8pNzEr/BE+nZd4U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-p54O2yKXPAC7KeyXaNWtXg-1; Tue, 11 Feb 2020 19:44:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CB3C13F8; Wed, 12 Feb 2020 00:44:18 +0000 (UTC) Received: from localhost.localdomain.com (vpn2-54-85.bne.redhat.com [10.64.54.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1CA45D9E2; Wed, 12 Feb 2020 00:44:15 +0000 (UTC) From: Gavin Shan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 5/5] arm64: Remove argument @cpu of get_cpu_ops() Date: Wed, 12 Feb 2020 11:43:51 +1100 Message-Id: <20200212004351.66576-6-gshan@redhat.com> In-Reply-To: <20200212004351.66576-1-gshan@redhat.com> References: <20200212004351.66576-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: p54O2yKXPAC7KeyXaNWtXg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200211_164423_322233_FDB17B75 X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.81 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 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: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, will@kernel.org, catalin.marinas@arm.com, sudeep.holla@arm.com, robin.murphy@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The argument @cpu of get_cpu_ops() isn't used, to remove it. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/cpu_ops.h | 2 +- arch/arm64/kernel/cpu_ops.c | 2 +- arch/arm64/kernel/cpuidle.c | 5 ++--- arch/arm64/kernel/setup.c | 2 +- arch/arm64/kernel/smp.c | 21 ++++++++++----------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index d28e8f37d3b4..1d5c514ca053 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -56,7 +56,7 @@ struct cpu_operations { }; int __init init_cpu_ops(int cpu); -extern const struct cpu_operations *get_cpu_ops(int cpu); +extern const struct cpu_operations *get_cpu_ops(void); static inline void __init init_bootcpu_ops(void) { diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index f59c087d6284..67b90399fb4b 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -115,7 +115,7 @@ int __init init_cpu_ops(int cpu) return 0; } -const struct cpu_operations *get_cpu_ops(int cpu) +const struct cpu_operations *get_cpu_ops(void) { if (cpu_ops_index == INT_MAX) return NULL; diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c index b512b5503f6e..da2db14d2d45 100644 --- a/arch/arm64/kernel/cpuidle.c +++ b/arch/arm64/kernel/cpuidle.c @@ -18,7 +18,7 @@ int arm_cpuidle_init(unsigned int cpu) { - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); int ret = -EOPNOTSUPP; if (ops && ops->cpu_suspend && ops->cpu_init_idle) @@ -36,8 +36,7 @@ int arm_cpuidle_init(unsigned int cpu) */ int arm_cpuidle_suspend(int index) { - int cpu = smp_processor_id(); - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); return ops->cpu_suspend(index); } diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 3fd2c11c09fc..5c68fa2d9d1b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -371,7 +371,7 @@ void __init setup_arch(char **cmdline_p) static inline bool cpu_can_disable(unsigned int cpu) { #ifdef CONFIG_HOTPLUG_CPU - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); if (ops && ops->cpu_can_disable) return ops->cpu_can_disable(cpu); diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 5e1af1a3c521..0180d4163e17 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -93,7 +93,7 @@ static inline int op_cpu_kill(unsigned int cpu) */ static int boot_secondary(unsigned int cpu, struct task_struct *idle) { - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); if (ops->cpu_boot) return ops->cpu_boot(cpu); @@ -230,7 +230,7 @@ asmlinkage notrace void secondary_start_kernel(void) */ check_local_cpu_capabilities(); - ops = get_cpu_ops(cpu); + ops = get_cpu_ops(); if (ops->cpu_postboot) ops->cpu_postboot(); @@ -270,7 +270,7 @@ asmlinkage notrace void secondary_start_kernel(void) #ifdef CONFIG_HOTPLUG_CPU static int op_cpu_disable(unsigned int cpu) { - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); /* * If we don't have a cpu_die method, abort before we reach the point @@ -320,7 +320,7 @@ int __cpu_disable(void) static int op_cpu_kill(unsigned int cpu) { - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); /* * If we have no means of synchronising with the dying CPU, then assume @@ -365,7 +365,7 @@ void __cpu_die(unsigned int cpu) void cpu_die(void) { unsigned int cpu = smp_processor_id(); - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); idle_task_exit(); @@ -392,7 +392,7 @@ void cpu_die(void) void cpu_die_early(void) { int cpu = smp_processor_id(); - const struct cpu_operations *ops = get_cpu_ops(cpu); + const struct cpu_operations *ops = get_cpu_ops(); pr_crit("CPU%d: will not boot\n", cpu); @@ -503,7 +503,7 @@ static int __init smp_cpu_setup(int cpu) if (init_cpu_ops(cpu)) return -ENODEV; - ops = get_cpu_ops(cpu); + ops = get_cpu_ops(); if (ops->cpu_init(cpu)) return -ENODEV; @@ -758,7 +758,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (cpu == smp_processor_id()) continue; - ops = get_cpu_ops(cpu); + ops = get_cpu_ops(); if (!ops) continue; @@ -883,7 +883,7 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) sdei_mask_local_cpu(); #ifdef CONFIG_HOTPLUG_CPU - ops = get_cpu_ops(cpu); + ops = get_cpu_ops(); if (ops->cpu_die) ops->cpu_die(cpu); #endif @@ -1063,8 +1063,7 @@ int setup_profiling_timer(unsigned int multiplier) static bool have_cpu_die(void) { #ifdef CONFIG_HOTPLUG_CPU - int any_cpu = raw_smp_processor_id(); - const struct cpu_operations *ops = get_cpu_ops(any_cpu); + const struct cpu_operations *ops = get_cpu_ops(); if (ops && ops->cpu_die) return true;