From patchwork Tue Nov 21 23:47:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13463772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E6ECBC61D98 for ; Tue, 21 Nov 2023 23:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TxLGWzikk9woJmOG3EFNVBX6TtKSkhJLQeqNoHn5odk=; b=eSbbLpgPbQDrDD Iw9JFlhlYUSWGAgx7/W/aNEfZ/HFMIB6v9Wuj7Bp+smMDwz8or1uz1IoRV1rZdVNuJno1JE3c4dlo hY4z831o9n8E3SLjYvJyG79CwsZ78OUji+fbJEKxJQwS1kh9NXsP0DqBudTOTBJEexZWY7pjyGBza AVVzko41Blr0MGaVW6mREppf04ImU0cqbd3/09z+bbxIYEpZsIRzSW4NFCYbLSLTY/1+9NbjLLg67 3V6Bg7QTMRYpnDaQFUmkE7/lTnQDqwqUYROof6UnpoAwI4GeqNzJsFA7iLdwW0FtlW8YXYB4/Gluc tlAwrVqpqfgMdRbJfvzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5aT0-000HqV-3D; Tue, 21 Nov 2023 23:47:43 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5aSy-000HpB-0w for linux-riscv@lists.infradead.org; Tue, 21 Nov 2023 23:47:41 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5c239897895so1899122a12.2 for ; Tue, 21 Nov 2023 15:47:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700610459; x=1701215259; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AMOStd9fJlE8YG4cHDAqOao79PB5giUTAvN4hSNTpow=; b=OHX+G4pOhtXC/kR4X4R3I/I5Zz4oiO2DIp+5llXMHFJB3K9QVlrRW0Fgc8Rk/DyAts fWU/RWOngmqM1UJmZldfJssv3Ejc8X7wHF+ZQsg4U8wNVPgLoPH5+EXnemzMc8DSgPNg UPrhj35RoID50ZsaBO9K1BdUf+HMbXfnse/wKMw6/VnQKjEJ0RQLlffS4BCgcApU5tMf RpsW0iQaamuvGJDjv2Dzn0eAKEqLFA84fltkWueUQHpt5cwfaFBQ0RUP3zZyLcDEXJLK ImjdZEP4Z6X9Nx1yapAbaM2IK/XACYBssys8CHPMzRqRB9LLL789j1KQoEotcP/TVqHE kykw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700610459; x=1701215259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AMOStd9fJlE8YG4cHDAqOao79PB5giUTAvN4hSNTpow=; b=qQ4aUG0Fb0v8otGLi+gohCYcPkrDWqJ7fv7OtDRshgQUJWlpOSBNFwtWR7CfSDQyIq 5BGQ3wxxPg0hDVC8fIXCj6zTh9fPOhEgv5zFzEsnrdJdmlrDUlTM86bU/sj0C8rIkw0a tfnKBqST4udFQZ+R/rxnqBafGNyKOygfesS+zJmdPPy/g6Mkx5H6YDX66zrZAaynxTl1 SKrnB72mdgvRznoL4JSASpWuD9WjEvJgCJgFA46TTTG40M/UtivpWtJ2EE/QxvQL8pPc o2MFdgaL77edzSvEffm9rPMARddwURRnOti4SwS8w21qfv7/vP4gi9X5FkRz9gx82NKx 9p6A== X-Gm-Message-State: AOJu0YwkPW+Gz9o1+8BNgAfmDUhHgpTz4g/0RYBlJLYuR6QNfOS9dibW Ez5g1yKAuHAbowvZSMpthQF2YA== X-Google-Smtp-Source: AGHT+IFbfZAuqOej5wkX0K6/vS8Oyqjn7BLG0X6YPrfr8dn7T6pNtB3Wv/zbSWQDnxrj0rMNrcKVig== X-Received: by 2002:a17:90b:4b0b:b0:281:1c2e:9e6a with SMTP id lx11-20020a17090b4b0b00b002811c2e9e6amr742314pjb.39.1700610459263; Tue, 21 Nov 2023 15:47:39 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id f8-20020a17090ace0800b002802d9d4e96sm82234pju.54.2023.11.21.15.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:47:38 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 1/3] riscv: Deduplicate code in setup_smp() Date: Tue, 21 Nov 2023 15:47:24 -0800 Message-ID: <20231121234736.3489608-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231121234736.3489608-1-samuel.holland@sifive.com> References: <20231121234736.3489608-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_154740_323690_29C413AE X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Both the ACPI and DT implementations contain some of the same code. Move it to the calling function so it is not duplicated. Signed-off-by: Samuel Holland Reviewed-by: Conor Dooley --- arch/riscv/kernel/smpboot.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index d162bf339beb..1c68e61fb852 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -125,18 +125,7 @@ static int __init acpi_parse_rintc(union acpi_subtable_headers *header, const un static void __init acpi_parse_and_init_cpus(void) { - int cpuid; - - cpu_set_ops(0); - acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, acpi_parse_rintc, 0); - - for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) { - if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) { - cpu_set_ops(cpuid); - set_cpu_possible(cpuid, true); - } - } } #else #define acpi_parse_and_init_cpus(...) do { } while (0) @@ -150,8 +139,6 @@ static void __init of_parse_and_init_cpus(void) int cpuid = 1; int rc; - cpu_set_ops(0); - for_each_of_cpu_node(dn) { rc = riscv_early_of_processor_hartid(dn, &hart); if (rc < 0) @@ -179,21 +166,25 @@ static void __init of_parse_and_init_cpus(void) if (cpuid > nr_cpu_ids) pr_warn("Total number of cpus [%d] is greater than nr_cpus option value [%d]\n", cpuid, nr_cpu_ids); - - for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) { - if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) { - cpu_set_ops(cpuid); - set_cpu_possible(cpuid, true); - } - } } void __init setup_smp(void) { + int cpuid; + + cpu_set_ops(0); + if (acpi_disabled) of_parse_and_init_cpus(); else acpi_parse_and_init_cpus(); + + for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) { + if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) { + cpu_set_ops(cpuid); + set_cpu_possible(cpuid, true); + } + } } static int start_secondary_cpu(int cpu, struct task_struct *tidle) From patchwork Tue Nov 21 23:47:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13463774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CBBDAC61D98 for ; Tue, 21 Nov 2023 23:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5QmOZ0JNMkDL9FcpPMTXTS2Md9bhueuN+qOcWzGAVK0=; b=2cK1oUasaQGyLX yFZr9IpveZcbEDH/ZNr4SFbEGWa2X9PiHeJ8zhls7xCkBUh73EW7ksnnhLiPtZB+/BLDrMKEUTjtO rV0zex5lmjE3J7S2ekewmoRT38GMUoUFUqbvCAEeKn3nj85x8gLVoiqowbfDduiOErMFmwgPl291W vbBDijCKsAoDpTaGIKbB/mL4L4noHFPpAnRfNq7bI3AT0OJJdU3BBiJ9FdAsGk8JhT+8Q/mUY24iA EEM17kaMq430C1Ysnky+LPt7Oh8ueUM5fzEp6Mc1DulTyRSOOzI86+/DCDqZC/zrT6Y261AdE1j9V DIpr5QspAaXChBzXPhGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5aT4-000Hrk-2T; Tue, 21 Nov 2023 23:47:46 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5aSz-000Hpg-0H for linux-riscv@lists.infradead.org; Tue, 21 Nov 2023 23:47:42 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5c239897895so1899129a12.2 for ; Tue, 21 Nov 2023 15:47:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700610460; x=1701215260; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i2mLSanzAu7xkVkTlVbQ+OCyp7a1LICmHfqJMNCQTMM=; b=G+S3Ib14TnIVOaagP2fZIZd8pncIe1qIPaR7T3vnk9fTdNBecJsXaETccx6wzz8qY9 JGQ0xWP16MJ1bxmdXNVxIcgIgBMV/ZFAffJABau7NJSXpBVpstQKt7oioAIQqgiWVJKx 3th9mOImNOkLMp86qtY8bUw81meniREdW39bHdvlrmEGsrQidnhvYTMgaZ1uaBdbGci+ zacHILANbjJVHU28GfBSkqegcv9yUo86TIFuDTvolF8PnsPw9D6T1gP8Z0GKNvh2muC3 2HGsUNyFjdFvpAzGpMuh2Xen2Ya8ZpsVAvEhb3RoglhNWbnruGF46WJgtD4NzGdhMC/M nhwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700610460; x=1701215260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i2mLSanzAu7xkVkTlVbQ+OCyp7a1LICmHfqJMNCQTMM=; b=XouOHRaN9J+JyJwtjUHvWkAWvHFpls2ahg7WYiA2OaU+0rxffSgDpm7gSgOEP/xabY wlMCILIgo2cORCMcpK6oX7zV2KlvkC2wNsRbelBXmP1LuvXg0HFleAzv5uyL/+NH2mOs 3fXPSg1K8OsBXrw8NHxKl9djIQUvMWj1y/JZM3BepgXucAKn7LeZgeK3eR+hFeA7xFUh OcPohuknTsORmoYz0B9osqFokx4LO24rLNhrGnZ2lwNfCug6MhcR/xBlReMWzxKZSs5x IBIjJ2Ni6lR732YasayXCoIgQOj2HlEOz+xEGlaht+cQRwaleYuJpV+LRBv2RUbeORdF Aowg== X-Gm-Message-State: AOJu0Yx+dr2/lP4DtviTHCM+JLPI/bdLnh+VF+P2SmzBo5Rg9Q6CQjoS ewlk6rB7hzNhEdAizTJC0HcGvA== X-Google-Smtp-Source: AGHT+IHoez2A3aRDrdQwxK18whZwJQR498ZFuayF3Kusj3dBV4VtpQAp7G00A3jzOcyqkuPlxbXNnA== X-Received: by 2002:a05:6a21:a585:b0:187:cc5f:dbf4 with SMTP id gd5-20020a056a21a58500b00187cc5fdbf4mr692350pzc.42.1700610460323; Tue, 21 Nov 2023 15:47:40 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id f8-20020a17090ace0800b002802d9d4e96sm82234pju.54.2023.11.21.15.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:47:40 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 2/3] riscv: Remove unused members from struct cpu_operations Date: Tue, 21 Nov 2023 15:47:25 -0800 Message-ID: <20231121234736.3489608-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231121234736.3489608-1-samuel.holland@sifive.com> References: <20231121234736.3489608-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_154741_123326_AAD32AD7 X-CRM114-Status: GOOD ( 18.78 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org name is not used anywhere at all. cpu_prepare and cpu_disable do nothing and always return 0 if implemented. Signed-off-by: Samuel Holland Reviewed-by: Conor Dooley --- arch/riscv/include/asm/cpu_ops.h | 10 ---------- arch/riscv/kernel/cpu-hotplug.c | 9 +-------- arch/riscv/kernel/cpu_ops.c | 2 -- arch/riscv/kernel/cpu_ops_sbi.c | 19 ------------------- arch/riscv/kernel/cpu_ops_spinwait.c | 11 ----------- arch/riscv/kernel/head.S | 1 - arch/riscv/kernel/setup.c | 1 - arch/riscv/kernel/smpboot.c | 6 ------ 8 files changed, 1 insertion(+), 58 deletions(-) diff --git a/arch/riscv/include/asm/cpu_ops.h b/arch/riscv/include/asm/cpu_ops.h index aa128466c4d4..18af75e6873c 100644 --- a/arch/riscv/include/asm/cpu_ops.h +++ b/arch/riscv/include/asm/cpu_ops.h @@ -13,26 +13,16 @@ /** * struct cpu_operations - Callback operations for hotplugging CPUs. * - * @name: Name of the boot protocol. - * @cpu_prepare: Early one-time preparation step for a cpu. If there - * is a mechanism for doing so, tests whether it is - * possible to boot the given HART. * @cpu_start: Boots a cpu into the kernel. - * @cpu_disable: Prepares a cpu to die. May fail for some - * mechanism-specific reason, which will cause the hot - * unplug to be aborted. Called from the cpu to be killed. * @cpu_stop: Makes a cpu leave the kernel. Must not fail. Called from * the cpu being stopped. * @cpu_is_stopped: Ensures a cpu has left the kernel. Called from another * cpu. */ struct cpu_operations { - const char *name; - int (*cpu_prepare)(unsigned int cpu); int (*cpu_start)(unsigned int cpu, struct task_struct *tidle); #ifdef CONFIG_HOTPLUG_CPU - int (*cpu_disable)(unsigned int cpu); void (*cpu_stop)(void); int (*cpu_is_stopped)(unsigned int cpu); #endif diff --git a/arch/riscv/kernel/cpu-hotplug.c b/arch/riscv/kernel/cpu-hotplug.c index 457a18efcb11..934eb64da0d0 100644 --- a/arch/riscv/kernel/cpu-hotplug.c +++ b/arch/riscv/kernel/cpu-hotplug.c @@ -29,25 +29,18 @@ bool cpu_has_hotplug(unsigned int cpu) */ int __cpu_disable(void) { - int ret = 0; unsigned int cpu = smp_processor_id(); if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_stop) return -EOPNOTSUPP; - if (cpu_ops[cpu]->cpu_disable) - ret = cpu_ops[cpu]->cpu_disable(cpu); - - if (ret) - return ret; - remove_cpu_topology(cpu); numa_remove_cpu(cpu); set_cpu_online(cpu, false); riscv_ipi_disable(); irq_migrate_all_off_this_cpu(); - return ret; + return 0; } #ifdef CONFIG_HOTPLUG_CPU diff --git a/arch/riscv/kernel/cpu_ops.c b/arch/riscv/kernel/cpu_ops.c index eb479a88a954..5540e2880abb 100644 --- a/arch/riscv/kernel/cpu_ops.c +++ b/arch/riscv/kernel/cpu_ops.c @@ -18,8 +18,6 @@ const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; extern const struct cpu_operations cpu_ops_sbi; #ifndef CONFIG_RISCV_BOOT_SPINWAIT const struct cpu_operations cpu_ops_spinwait = { - .name = "", - .cpu_prepare = NULL, .cpu_start = NULL, }; #endif diff --git a/arch/riscv/kernel/cpu_ops_sbi.c b/arch/riscv/kernel/cpu_ops_sbi.c index efa0f0816634..1cc7df740edd 100644 --- a/arch/riscv/kernel/cpu_ops_sbi.c +++ b/arch/riscv/kernel/cpu_ops_sbi.c @@ -79,23 +79,7 @@ static int sbi_cpu_start(unsigned int cpuid, struct task_struct *tidle) return sbi_hsm_hart_start(hartid, boot_addr, hsm_data); } -static int sbi_cpu_prepare(unsigned int cpuid) -{ - if (!cpu_ops_sbi.cpu_start) { - pr_err("cpu start method not defined for CPU [%d]\n", cpuid); - return -ENODEV; - } - return 0; -} - #ifdef CONFIG_HOTPLUG_CPU -static int sbi_cpu_disable(unsigned int cpuid) -{ - if (!cpu_ops_sbi.cpu_stop) - return -EOPNOTSUPP; - return 0; -} - static void sbi_cpu_stop(void) { int ret; @@ -118,11 +102,8 @@ static int sbi_cpu_is_stopped(unsigned int cpuid) #endif const struct cpu_operations cpu_ops_sbi = { - .name = "sbi", - .cpu_prepare = sbi_cpu_prepare, .cpu_start = sbi_cpu_start, #ifdef CONFIG_HOTPLUG_CPU - .cpu_disable = sbi_cpu_disable, .cpu_stop = sbi_cpu_stop, .cpu_is_stopped = sbi_cpu_is_stopped, #endif diff --git a/arch/riscv/kernel/cpu_ops_spinwait.c b/arch/riscv/kernel/cpu_ops_spinwait.c index d98d19226b5f..613872b0a21a 100644 --- a/arch/riscv/kernel/cpu_ops_spinwait.c +++ b/arch/riscv/kernel/cpu_ops_spinwait.c @@ -39,15 +39,6 @@ static void cpu_update_secondary_bootdata(unsigned int cpuid, WRITE_ONCE(__cpu_spinwait_task_pointer[hartid], tidle); } -static int spinwait_cpu_prepare(unsigned int cpuid) -{ - if (!cpu_ops_spinwait.cpu_start) { - pr_err("cpu start method not defined for CPU [%d]\n", cpuid); - return -ENODEV; - } - return 0; -} - static int spinwait_cpu_start(unsigned int cpuid, struct task_struct *tidle) { /* @@ -64,7 +55,5 @@ static int spinwait_cpu_start(unsigned int cpuid, struct task_struct *tidle) } const struct cpu_operations cpu_ops_spinwait = { - .name = "spinwait", - .cpu_prepare = spinwait_cpu_prepare, .cpu_start = spinwait_cpu_start, }; diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index b77397432403..0349e5cdfe1d 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 535a837de55d..2bf882804624 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 1c68e61fb852..5551945255cd 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -49,7 +49,6 @@ void __init smp_prepare_boot_cpu(void) void __init smp_prepare_cpus(unsigned int max_cpus) { int cpuid; - int ret; unsigned int curr_cpuid; init_cpu_topology(); @@ -66,11 +65,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus) for_each_possible_cpu(cpuid) { if (cpuid == curr_cpuid) continue; - if (cpu_ops[cpuid]->cpu_prepare) { - ret = cpu_ops[cpuid]->cpu_prepare(cpuid); - if (ret) - continue; - } set_cpu_present(cpuid, true); numa_store_cpu_info(cpuid); } From patchwork Tue Nov 21 23:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13463775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F2B39C61D85 for ; Tue, 21 Nov 2023 23:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3lNj5JJ4Q9+uRjJ865R06Nt3EXSowDLp8LEMupNht94=; b=pUKkOevvxmrjvc FvWjj0swR52xKuCqMmrwvM6QFZ2VHfqLoooUufymEvW7MwtqmHOhtzZvdVjatnHeYDezZfeAsra8s ZGYGMcEYLf6l3mDvb3h1/4QNA/vxGnHvhpcwy0QZeFvzWCsosUfGzfwaYu2jlIPvXdqn9gGu/Y2/u Fkv1eziD45kJ7pviqq1crAtwKm9f4igoqtyUKmbidzhJ/9n2zJYLGpGcUV/vuhDmVfFC1LtZNLD4f XHuT5ztnyOnoT+59qG8uWt8gUM/v6hLb4y+7DddtCf0AqUrqCY/QM2OV+9rLi7n6s65eBOmVrDFwI YsM+HwVjnAoVnYCsGq3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5aT5-000HsM-1H; Tue, 21 Nov 2023 23:47:47 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5aT1-000Hq6-0A for linux-riscv@lists.infradead.org; Tue, 21 Nov 2023 23:47:44 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2802c41b716so4857024a91.1 for ; Tue, 21 Nov 2023 15:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1700610461; x=1701215261; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yfO2TsuP5+bzwc+1UBNKacN7ooenjZKMpjxDQuaWHLs=; b=BHBE4bl0LIc7f81cPOHOsS/vZttIKp8fSeX31X8E9fJTvvySWcxAxoXUHa6+bD7Hzr aW+fVJhXe8qnvHgf+bIGJNFs/e/4RpMnknB4BNdHu21Hif3fyW05nm8QwEuDecPKv25w Vra3UG9pPxIldFXavN1l6IhaGB5KNXeEeprntOj53rX/9WMGWfrStKQLUphXGMXHO8i+ JOninQ10xooK4ykweFemWjeOfonmrY5I32c+D/F3Z7gKWf5xHmIKc34tUwo/903nk1EV Pa7OdllFBheIRj2CdIAVFssD1i8VcRTyW36DwoLJk3rKmLa0xuDS2l5CtVKWXQ/qaKS8 Qghg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700610461; x=1701215261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yfO2TsuP5+bzwc+1UBNKacN7ooenjZKMpjxDQuaWHLs=; b=F73X9nJMBbPccBbMPDehww7izpb5A/WYGemalH4sFigQ9gmjdBzin5AJQaYiOoXHHq 5C1dsxu5aZfiCYDPq3ftGOiCEasz5HRhUe5yVBMSmouxPfkGF0GZLSQMvc5PJuWS+SsA /WYuOkjkrRvRcgEuMZ6XRsOCgFwbg7omupIX7TqDcGyK0ipuZj434Ig9L6qvtG/uFxyz 8Vp9zwDjd0axvvaxu6G1rSYdB7FDx9QROu7yRmsEbuXq5vodn4FxwUCQwQQHQThNBV5F Ty8vVEBrHy/1DxdaHWmajwT15XJRuGSHWCzhg9BZA/wlJH2AQqVvQPqF8sDVTFdE0i2R SjYA== X-Gm-Message-State: AOJu0YzCZrv+mWkNfMBTHnbXTy6i16Hv7EyaZ5TSl/DrKHLznZyD2oAD QWMbQvd3UlFVFJbatCJLEVWb4A== X-Google-Smtp-Source: AGHT+IEuxWeyQyxVZpHs2HhfPBfaktXQRoOaYpXSTZYzhyVnj051EXkgI0JValZG2raCSDzrUvzGGg== X-Received: by 2002:a17:90b:17c9:b0:27d:661f:59ac with SMTP id me9-20020a17090b17c900b0027d661f59acmr803651pjb.38.1700610461416; Tue, 21 Nov 2023 15:47:41 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id f8-20020a17090ace0800b002802d9d4e96sm82234pju.54.2023.11.21.15.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:47:41 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 3/3] riscv: Use the same CPU operations for all CPUs Date: Tue, 21 Nov 2023 15:47:26 -0800 Message-ID: <20231121234736.3489608-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231121234736.3489608-1-samuel.holland@sifive.com> References: <20231121234736.3489608-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_154743_100034_64F7BE50 X-CRM114-Status: GOOD ( 18.04 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org RISC-V provides no binding (ACPI or DT) to describe per-cpu start/stop operations, so cpu_set_ops() will always detect the same operations for every CPU. Replace the cpu_ops array with a single pointer to save space and reduce boot time. Signed-off-by: Samuel Holland Reviewed-by: Conor Dooley --- arch/riscv/include/asm/cpu_ops.h | 4 ++-- arch/riscv/kernel/cpu-hotplug.c | 10 +++++----- arch/riscv/kernel/cpu_ops.c | 12 +++++------- arch/riscv/kernel/smp.c | 2 +- arch/riscv/kernel/smpboot.c | 13 +++++-------- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/arch/riscv/include/asm/cpu_ops.h b/arch/riscv/include/asm/cpu_ops.h index 18af75e6873c..176b570ef982 100644 --- a/arch/riscv/include/asm/cpu_ops.h +++ b/arch/riscv/include/asm/cpu_ops.h @@ -29,7 +29,7 @@ struct cpu_operations { }; extern const struct cpu_operations cpu_ops_spinwait; -extern const struct cpu_operations *cpu_ops[NR_CPUS]; -void __init cpu_set_ops(int cpu); +extern const struct cpu_operations *cpu_ops; +void __init cpu_set_ops(void); #endif /* ifndef __ASM_CPU_OPS_H */ diff --git a/arch/riscv/kernel/cpu-hotplug.c b/arch/riscv/kernel/cpu-hotplug.c index 934eb64da0d0..28b58fc5ad19 100644 --- a/arch/riscv/kernel/cpu-hotplug.c +++ b/arch/riscv/kernel/cpu-hotplug.c @@ -18,7 +18,7 @@ bool cpu_has_hotplug(unsigned int cpu) { - if (cpu_ops[cpu]->cpu_stop) + if (cpu_ops->cpu_stop) return true; return false; @@ -31,7 +31,7 @@ int __cpu_disable(void) { unsigned int cpu = smp_processor_id(); - if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_stop) + if (!cpu_ops->cpu_stop) return -EOPNOTSUPP; remove_cpu_topology(cpu); @@ -55,8 +55,8 @@ void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu) pr_notice("CPU%u: off\n", cpu); /* Verify from the firmware if the cpu is really stopped*/ - if (cpu_ops[cpu]->cpu_is_stopped) - ret = cpu_ops[cpu]->cpu_is_stopped(cpu); + if (cpu_ops->cpu_is_stopped) + ret = cpu_ops->cpu_is_stopped(cpu); if (ret) pr_warn("CPU%d may not have stopped: %d\n", cpu, ret); } @@ -70,7 +70,7 @@ void __noreturn arch_cpu_idle_dead(void) cpuhp_ap_report_dead(); - cpu_ops[smp_processor_id()]->cpu_stop(); + cpu_ops->cpu_stop(); /* It should never reach here */ BUG(); } diff --git a/arch/riscv/kernel/cpu_ops.c b/arch/riscv/kernel/cpu_ops.c index 5540e2880abb..6a8bd8f4db07 100644 --- a/arch/riscv/kernel/cpu_ops.c +++ b/arch/riscv/kernel/cpu_ops.c @@ -13,7 +13,7 @@ #include #include -const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; +const struct cpu_operations *cpu_ops __ro_after_init = &cpu_ops_spinwait; extern const struct cpu_operations cpu_ops_sbi; #ifndef CONFIG_RISCV_BOOT_SPINWAIT @@ -22,14 +22,12 @@ const struct cpu_operations cpu_ops_spinwait = { }; #endif -void __init cpu_set_ops(int cpuid) +void __init cpu_set_ops(void) { #if IS_ENABLED(CONFIG_RISCV_SBI) if (sbi_probe_extension(SBI_EXT_HSM)) { - if (!cpuid) - pr_info("SBI HSM extension detected\n"); - cpu_ops[cpuid] = &cpu_ops_sbi; - } else + pr_info("SBI HSM extension detected\n"); + cpu_ops = &cpu_ops_sbi; + } #endif - cpu_ops[cpuid] = &cpu_ops_spinwait; } diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 40420afbb1a0..45dd4035416e 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -81,7 +81,7 @@ static inline void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) #ifdef CONFIG_HOTPLUG_CPU if (cpu_has_hotplug(cpu)) - cpu_ops[cpu]->cpu_stop(); + cpu_ops->cpu_stop(); #endif for(;;) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 5551945255cd..519b6bd946e5 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -166,25 +166,22 @@ void __init setup_smp(void) { int cpuid; - cpu_set_ops(0); + cpu_set_ops(); if (acpi_disabled) of_parse_and_init_cpus(); else acpi_parse_and_init_cpus(); - for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) { - if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) { - cpu_set_ops(cpuid); + for (cpuid = 1; cpuid < nr_cpu_ids; cpuid++) + if (cpuid_to_hartid_map(cpuid) != INVALID_HARTID) set_cpu_possible(cpuid, true); - } - } } static int start_secondary_cpu(int cpu, struct task_struct *tidle) { - if (cpu_ops[cpu]->cpu_start) - return cpu_ops[cpu]->cpu_start(cpu, tidle); + if (cpu_ops->cpu_start) + return cpu_ops->cpu_start(cpu, tidle); return -EOPNOTSUPP; }