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: 168038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp987844vqb; Tue, 21 Nov 2023 15:49:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmTOXbCOkyldfAIbLAl9kvYRWjmqZ3pNOSHnTHi86bPoXemMvHYo2vm1se7VutBd5B5VJV X-Received: by 2002:a05:6a00:21d3:b0:6cb:a60c:2140 with SMTP id t19-20020a056a0021d300b006cba60c2140mr741600pfj.28.1700610587794; Tue, 21 Nov 2023 15:49:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700610587; cv=none; d=google.com; s=arc-20160816; b=Eqcn4GK/9PMyn0pCSksnLhv5Q/oPnNNTUHhMYMCn2ilTyPM6NrSMGdAoi75dCOk0kI kjPN44do1+UKRp11wP7mADuT7nFAU3uV38zDjp7a/0K1rNxueKHiKkNsfbnl4ItI5riz jZxeU5h5R43DmhMeOIHSfu3EThG8bk9b9qCZBl503hatjs+qWUTowH+3ZqxnYB+Gp8LL YbhKra4zVvdz7wXDBdk21RaOVE73DK/WEgIBp60H+IEdkGAzSWrMJCZC+RHhah3/xmN3 DQI6Uvub9pXiJtKp+u+UDzGupUj5ml0+HudV1guSVxCPweZb/uDKr8qGQh+DHD4+mAa8 ddqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AMOStd9fJlE8YG4cHDAqOao79PB5giUTAvN4hSNTpow=; fh=qgALqhvBfwh64qlTOA5xcM4euFCRJESH/+60UMp8eRY=; b=mcz4rTVmXjRoDJE5s5FubmqNNRVkRBHyUYbJkGg6wx1eopBnKPIv2NYnpU2YJmiQ+3 RQgrs+WVmqsvHxHnZC2zXjGRyBUAvWpC4X7DG6R0xrQA5SdJusWLOu27/5rA2U5J2rVM S9cJ72GPB73RSCskZIbjoKvYq2JBPGtyr/ks6+KvdUYAAji92pRlF+euwfAjbzT3hORo VIX9BxGCYSdFU4DGqzJbZ5EH/93Ssz7vqDjI3UvOsXXMwBC8Yef7rOnqjBUd62Rxlk7t ALNkFqcpnraQqrjsQjsK9CxRrQ71S0Cep+Kcq8VQrFF/kzbjw3YasXtlu/BuzpzBckep cP1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Uomp7nrd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a28-20020aa78e9c000000b0068a5877bfaesi11197427pfr.382.2023.11.21.15.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:49:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Uomp7nrd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5CACF804B87C; Tue, 21 Nov 2023 15:47:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234917AbjKUXro (ORCPT + 99 others); Tue, 21 Nov 2023 18:47:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234900AbjKUXrn (ORCPT ); Tue, 21 Nov 2023 18:47:43 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4D52D1 for ; Tue, 21 Nov 2023 15:47:39 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2851a2b30a2so2033650a91.3 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=vger.kernel.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=Uomp7nrdZ3nvrlUgQ0qBvW5GpSBTi60bLjaQ3lGURObcyyT+NNfxzHhdGVYMnJkMfN ULTzxEXxtvQTe2UNHpHyxDJ8oqlPGdrgjs32V8nbdIU302oDcmFYOJQIiIgSNZvzJfMe jI6ZdOBQEr/JcP4DzUFvjLoSZrno0IzasNpbK4s1yctRveHJcrnfCDYQKOXwqLb0XAxc 9C7DtATowjbVWCJvwMDKdaNbc2Z4cvFvA27/6XzLQI7wRanY0RPnny4YsNWznxG0bSFr FJUkiMvKAKLEFyLiid4/2tOFivD6Gs3s1hu2GfQDy6AI19P9xT/slwXTfNM+jZkTOvCW +wAg== 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=jPAiIFv7reLh3K+YM0oIWKY/EQJodeNYThfFthEmHU8hub4ytBAlLY/BPTgAyBphaq SD/M9dwWwNnDZ1isgp1CmoquECq80NKkljmh9ItH/qRzpsisXPTWcG2KqqVHwOC6vEjM kP6Qp9G364Fa7AA6o+p97sWhmK9k5z9/+E4/gSU8sM0RtkN8xTG6npy28noCjKiMTBZL B09C77ZDaNlZuPrVTiCXmMmpYuF0JBLOZtv0pw5Rd2e5iKnmMsXkWMnrUXX4VbPYE4HP ZMgu+hc3FaoYGI3QtggrNvtHJAlumbMYfA5wdenzc6DqBRnb3A8C3SHmGYDmJx14vor8 U7nQ== X-Gm-Message-State: AOJu0YzaKj3FfCW+d7xcbcMab728vj3iMwUL7kY5abk1/5h4/R6gUKwO 1FWRrzcvI+bZHOsbCnuenVU4uJ4axxenw2osgpA= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 15:47:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783219448013534884 X-GMAIL-MSGID: 1783219448013534884 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: 168039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp987858vqb; Tue, 21 Nov 2023 15:49:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEX0/v14b0EgjD5oTs6SXByUFCgfUdKBvKRH7ovEEw6197S1+B/sTAKwhTn4eZnQLYCIbPf X-Received: by 2002:a9d:694f:0:b0:6bd:78a:460 with SMTP id p15-20020a9d694f000000b006bd078a0460mr953566oto.32.1700610588668; Tue, 21 Nov 2023 15:49:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700610588; cv=none; d=google.com; s=arc-20160816; b=yul02JBjImbcCsZBOWWt5yWGUSx1ECQ7TkW9GrSq8VU2qFt6DyVhuj4uTDL8MC5XWF YJGrnRhdyT0MbB/GB8+PJF15IJlBEqi49xM4QfXOj1p/2Q+9Hh44j7OANf/NGD9hz2jA +ik/DmTCyEwqtISSpCf+AsFRl/2q29NDXD1ModckDPTZzdCVufE3azfnV9OXcZQVrhE4 yGaLf1tl34OKZNLBeu8Vptaskd++s78h3ETbLiIQWqFzGB65b7CJiijRN6AqCP/S4VsL QeevcxCDhXp9hL+6lIXJ05jthQQ2EgAg763/XMIXsn0PNJMU6PoilXv2Zx0MXZR4sQ0c xPUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i2mLSanzAu7xkVkTlVbQ+OCyp7a1LICmHfqJMNCQTMM=; fh=qgALqhvBfwh64qlTOA5xcM4euFCRJESH/+60UMp8eRY=; b=uNWgh3aKNEzeTnR+dmq+/BzM1qp0Pic+0OQgJMzq6mg4f3BMH/UGR1TI0c8TZhVj4a IlJhSKQG45gUr7FW0kQXSV8a6D9Jihu0zYi86GDi7q6uztY1m/i0HALyKP3KPybIvvQM dtzoQ9PlW/PdY4GKi7yLfs4qXQFf2ADAyBW23DHPbKIpNigcbLrbBScSnhvnUxRmVMHP 1BhkpwZdTdhGpSmESWCZ23VBWUnHrX1/SBpaNECxM/IxSsTCbd5MTDdHaQcDJVCKp/Vo ckyl6f3GYz8ivRoV0+1oD7+bKXyuJ2stYc9kSwVSQc5akYkVmPmBW4D6UfYkfAZSYfkx Z1rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QenDxS+3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id bx10-20020a056a02050a00b005bdd6c412dasi12496754pgb.108.2023.11.21.15.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:49:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QenDxS+3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C2C648043905; Tue, 21 Nov 2023 15:48:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234928AbjKUXrr (ORCPT + 99 others); Tue, 21 Nov 2023 18:47:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234920AbjKUXro (ORCPT ); Tue, 21 Nov 2023 18:47:44 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DC9194 for ; Tue, 21 Nov 2023 15:47:40 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6c396ef9a3dso5229679b3a.1 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=vger.kernel.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=QenDxS+3RWNRcbzX9ItHNPIYJXMPQ/Uh+sbOQ537H8PoqiWJQDof8t+vLjni4jP6p+ ZgxwmSKmvcVjflVB/fIo9nm7DaK1peRnhGgze3WSKaiezamwmYiTg364azkmBl4IhOj7 M4VGwWVS1OWDm0ftiRXvMRRgFH3ortIn0ziFCnTF2Eq9+VW2qy+JAcH7X770gCX/8ORL WjlxIoWicLGBVblyHB8dXTPf+yF85Y8RUurkzlGvPNROA4E/+r0GnsC2XtG3lJroorWP VyLkeDTv54kto5b9R55+odzWqFWKSBxqDWOq7mYEs6SQKpgnN3i7JJZfgjd7ddnoN+fq iYCA== 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=KWIVs/TRC6ygjQt4tBY3tJ6WIiu9+ovtwLST6cFb6kzvmyweq4RvyxsBVRufRBJzL1 Y+Ip1kQBly5AO6LUmjc4jsxWVEGEKlkdZSnpH6yw1ay4kTqC3zswaniQtHdPkiZPdZDN L8aSL/oNuV/fL/RZVNj9lNSU9QnnTV42qZdMH74omoKBNV5ykEODsAeO3bztVVT/amMD mG0ymPxuH57LlLoyMGxRkfm/EVFhKBBrG34esl4/HXlLvz2q/iMjvUWtH6bIcn+oHiLy pOaTMss+kNS565qQGXdngKMvGNyuuyC/PfEZFroNSkXTysw5NmdsJdgvFbXLwFreN+sv C5gQ== X-Gm-Message-State: AOJu0YzD/Oe0qb4A9hQA8p/LpCecFGPdd68vdcaCshnwO4G7mDofznHi 27c4DEp8wK72Bi/RMK2HwWzY8w== 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 15:48:05 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783219448274464226 X-GMAIL-MSGID: 1783219448274464226 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: 168037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp987559vqb; Tue, 21 Nov 2023 15:48:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+UFAkOnzpzBjeYBwam45em0SNZGozW0qv3WYH2SKDhYVdwWfQ48+EieECcUj+OFgbW0rL X-Received: by 2002:a17:902:ce81:b0:1cc:ef37:664a with SMTP id f1-20020a170902ce8100b001ccef37664amr871994plg.31.1700610536117; Tue, 21 Nov 2023 15:48:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700610536; cv=none; d=google.com; s=arc-20160816; b=qUfIg0kxe3zAf2d6LgWrP5JuMW5wHWZZIuzg8on2cHYHUzwq8Vv0Ikp37NwjsJi6zm JIbiesfm6utZnxju6INKZU1sbVOTlsR6OySzs64G2cNSnw1xaiIn8kR1vBcTLrYpD/lq zL66NDbdpXn0oT5BQ3Pjy15DmTT0kGJNImYLe1vtk6G0WjVtGRzLFG5U66aFqTfZDLBz Y+HH2Ee1ifWOMqL67nYRm1N6T4o/niwNsClQtJqtkWG8A4XR9RkyJFTuooLZBbt+w4g1 KB4bcMw34zzMissvQbCCePSGOAsTyMcv1NTHaecDgbjVIzHv3AkXCKzBr35/zNdOquaS Nlbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yfO2TsuP5+bzwc+1UBNKacN7ooenjZKMpjxDQuaWHLs=; fh=qgALqhvBfwh64qlTOA5xcM4euFCRJESH/+60UMp8eRY=; b=CSUYxw4qn3pcZMS+0zBH/lNB96IevKZfzB/ls4CnmpWrvS3j7h2u6Y6jpjCOQPISXo mmxIKO7BKV+ncXICVVXWMijVF7WoujHNhi+UwF+VxMePhoCBMNJJ30WDBPpXp/FD8jAa TijJwx0vgXqAo86k64EAMiHjEiW+vd2fZ/S8s3cqId4xUQg9nkT6SkQGiCyx3NwvA+rR 2eeAv+awPD3bWpjM3nPTFPh6JqcJB1d1D1T0/cTWFfTDqz3vDLJFQ69dgjf9L/sv47h8 yLHLrCTrZc6JEW00aWm0LeMd5G+UF3Dte7qvyfrnWZC1lhp50JqD+C91Z1Kgc9xtS8rg 0jQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=aZrT63Mg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f5-20020a170902ce8500b001c07bac13d0si11640404plg.383.2023.11.21.15.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:48:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=aZrT63Mg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id AF7EF817C1E7; Tue, 21 Nov 2023 15:48:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234931AbjKUXrt (ORCPT + 99 others); Tue, 21 Nov 2023 18:47:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234900AbjKUXrp (ORCPT ); Tue, 21 Nov 2023 18:47:45 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD4FC19E for ; Tue, 21 Nov 2023 15:47:41 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-285196aaecaso2339465a91.0 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=vger.kernel.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=aZrT63MgnuSZW4fEYf/0NWsduVv1PId3L91IjnWURSTnyE/T44v7vPbC5kuMGAqT0D 1kCJWNo6GONRkpF9EDupy47EueoEjG/tArf234YzpkaI3YOB/cpoKgy1OSneoYxXvORN DAJUvg5gBhZpm2t6KlFoo2YA7KlksPlY/64vIh0662J/TVmDd8J/OXRx/O/2vgRwpfPA 5TF+K1crnC+SZ3ZX2rtUlihyPhe86nNqCTCA9HALAeFuhDiBZxzeHtrTSUPpUyTHxQI6 rBQKdgSTvLdCS4El1suH7s3Qz8Y40rCjQ9AXtdL+xbzdsUL9/V76DrE1xjY7J260DgS3 yt/A== 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=t/YpmZH0SZOl0tqfCOARNSUSLQ9cLojpes6taKpL7MNJJ6q8pJtvr0T8G9ZXP6vZet +1DRa4Qu1VCpNYKs43LJYixlMVBU4zEfxvJEh3sL+2KHkUM4onPnvSauOm73jIoxqtNd YTnJZZdLK+dA47PmRFcDYqEimUNrR2Hn0F4FMwuIjm3ecSZorx3xqScY1bGCflsBZrFT WKEly3z5rbgQyn8ZghRVW20VJdEUfw4H5lnLPFrktTAzeVZhb/hAsIier0JnN8CqYRnn drrGlbfiLErCGfb6HFzUi8tLhPXMj2ZiotvZ2piDK7zl3Y1I+0x2rZ2ExPMjjWI08iNf hCew== X-Gm-Message-State: AOJu0YzweT0Of1CeeN4Kvxl++AZWPiYB287pYMWTi1mf/aZl8l1D2Czt jKKND/aimibSVozs10lO5jP1Mg== 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 15:48:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783219393510161328 X-GMAIL-MSGID: 1783219393510161328 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; }