Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2881848rwb; Mon, 15 Aug 2022 13:13:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SsXJfGbhYsLfOzYXFp719DtN9V2gcZHzTGvh2CtxgUly2FG9QG6hilEOqfj60JJH1F3xC X-Received: by 2002:a05:6402:32a8:b0:43e:5490:295f with SMTP id f40-20020a05640232a800b0043e5490295fmr15825191eda.193.1660594424274; Mon, 15 Aug 2022 13:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594424; cv=none; d=google.com; s=arc-20160816; b=Qb8/Yaa6DPusJIDKkXAqEQDEeYenR/3ANT/4KKAxJslGo9N4XnQyaFE6jYXhWn+S+c FD3vx1xUQCGpx+HaWSVu4aOeqLPOu3cH7/i02x0d+hrRmXpkol0Xve9qrT6zUKsbgknf 1tH5oUr/ZXo4pUA2T7XAUYe/iYBl+dD3A4BR82UluQkuX53Xt5LV3nJBWucOOVez9gPJ /xabuPCk/rZts1HBUTQASvS51gYx4TXNDF3aLpe7/uEv1OJdfpa3jt+dwYYA3ipB2rxZ dcZK257SRSTsnYSTU3uDXvCR6tMdOs7eobj93m3/UL8CgOfv5jowVXQ+i2JiHu4of3T5 TfOQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HgLYKlyeEMudaNb/HAD40pMYf13g/xio265DvWlVKWc=; b=XclhBenXnQSFiy/aSRENqs5SPbaSKG3gO548C4z5ExAnYD5rnnCp13fvr3Ln90kDy2 qCDqzz61yUXnLU3a6xxKW5ggT7PiU3S0a0x/3l+8SJsg0fl6SaRkk47B/7EzUvxai53m 6qRBiX/xzqe/NUHS77XvDyOuR2EgJ8m/Akd9/UPGtsfrOQCktJ/8KnljdGC8XKRldYpq EhkHb3i97O6CWAVRnAFx+RUTP9VH7eedwssSu0n+srvx0rhRlPbSomMuhrNK6pLCID9u LjIY3s3Wh+YSmKsGe/pZgUE8WvIeWW4XxaXwyPBbOH6LFPtscgr3X7A1SFoSuNl4Jp9J QNbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XbX1j8ur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp39-20020a1709073e2700b007262c51b07dsi9589274ejc.724.2022.08.15.13.13.18; Mon, 15 Aug 2022 13:13:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XbX1j8ur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239251AbiHOSQm (ORCPT + 99 others); Mon, 15 Aug 2022 14:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233806AbiHOSP1 (ORCPT ); Mon, 15 Aug 2022 14:15:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 512602A947; Mon, 15 Aug 2022 11:14:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E218061255; Mon, 15 Aug 2022 18:14:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAD69C433C1; Mon, 15 Aug 2022 18:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587276; bh=Yr7okvVqXnDFjMSzgjiWDpsS49DA0YngByrlZroVnJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XbX1j8urCtDuY4Gmp6AMrK1tU/id3P6LpFVgFUAuAvOPgHbCmnrjpIKnHNfyVS7TH dkk1zF+qqZ3abNn0PKTlXxC6hxUWGblSs/FwtILAW18FbtDJe8E6jf5nuaOaCSAUv7 UbY7zMdjFJUbCF7RkdEB39fePdAsHDSVoLvzJdrc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dimitri John Ledkov , Anup Patel , Ron Economos , Palmer Dabbelt , Nathan Chancellor Subject: [PATCH 5.15 034/779] riscv: set default pm_power_off to NULL Date: Mon, 15 Aug 2022 19:54:38 +0200 Message-Id: <20220815180338.699223605@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Dimitri John Ledkov commit f2928e224d85e7cc139009ab17cefdfec2df5d11 upstream. Set pm_power_off to NULL like on all other architectures, check if it is set in machine_halt() and machine_power_off() and fallback to default_power_off if no other power driver got registered. This brings riscv architecture inline with all other architectures, and allows to reuse exiting power drivers unmodified. Kernels without legacy SBI v0.1 extensions (CONFIG_RISCV_SBI_V01 is not set), do not set pm_power_off to sbi_shutdown(). There is no support for SBI v0.3 system reset extension either. This prevents using gpio_poweroff on SiFive HiFive Unmatched. Tested on SiFive HiFive unmatched, with a dtb specifying gpio-poweroff node and kernel complied without CONFIG_RISCV_SBI_V01. BugLink: https://bugs.launchpad.net/bugs/1942806 Signed-off-by: Dimitri John Ledkov Reviewed-by: Anup Patel Tested-by: Ron Economos Signed-off-by: Palmer Dabbelt Cc: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/reset.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/arch/riscv/kernel/reset.c +++ b/arch/riscv/kernel/reset.c @@ -12,7 +12,7 @@ static void default_power_off(void) wait_for_interrupt(); } -void (*pm_power_off)(void) = default_power_off; +void (*pm_power_off)(void) = NULL; EXPORT_SYMBOL(pm_power_off); void machine_restart(char *cmd) @@ -23,10 +23,16 @@ void machine_restart(char *cmd) void machine_halt(void) { - pm_power_off(); + if (pm_power_off != NULL) + pm_power_off(); + else + default_power_off(); } void machine_power_off(void) { - pm_power_off(); + if (pm_power_off != NULL) + pm_power_off(); + else + default_power_off(); }