Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2237862yba; Thu, 25 Apr 2019 12:58:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlgDa0ST+t9glyzkTMvpxD3xrfgYCl9YMmlE0MtIMdCjPUeAukmag4W0kMo4tjoq1qEJc5 X-Received: by 2002:a63:f212:: with SMTP id v18mr36456589pgh.231.1556222337123; Thu, 25 Apr 2019 12:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556222337; cv=none; d=google.com; s=arc-20160816; b=pEpEg23VhZdt189mVvDdIFtpr6Y8XGEldIajQsMU8LDsKgAWl2lzqJN1phuX2GDCNX UTt7/82QVD5BWJJtfHS2KPh0MGCdem1m5aVsiPuiArG8AfpO5JUqV8KglBin6otcZ1CN OJORWa3hYQ6SeU1hfmmyqVCjhCpHnsddrR4gdJkD8225/JntDE2D/FGT3GmRME5qCuSy Vg0dOARzpVKXNW0Uwu+eY9PW30RMledDkPTzAjfB0iOxiTGnHIHSXaP2V3gRBZsTEcGs +/rFYGydVLKAWaLfqoc5lnRHSWIP/in8OaHC2iaFXh4GyF+wUxDVQRUrRQkt/L2qCfHz rWMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=gvwc2z4S6BD6uWlEMi4IucZ2NoOc2SvZD8TjjoytUcY=; b=sivXvDO6HZ4wOabw/6xx0E0PxyJ5+m4OQwCzJz2MnbMn3HEfOrSXgvzIr6pE/SLLBJ R4IdHIP4TuwWORsPDbpPGPbUO+kIHVrbsSKpBiZ6qdpiNbAVs2ZsaTKstnoORnZtddZe 9ZAUBsAvAGYw2XTIkyIRQpoK7JmUvoVpvJ9jLJ9yXnAlTKmh24a7knMSdytbhW7G8Ll/ zoKBQkD850VecmT+QO2drRLltYfqefmwZaA65dH2ox16/nTttqEKWCmR+E2o4sLBd5RL VUfhau2wiQszuZx7yUykcGEHHuvBlQWehwHRn2YuD7X04EzVgpZ/F4UCoTcxVH4L+lIE vFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=mj7u0XCT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j64si22364932pgd.537.2019.04.25.12.58.41; Thu, 25 Apr 2019 12:58:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=mj7u0XCT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730687AbfDYT5O (ORCPT + 99 others); Thu, 25 Apr 2019 15:57:14 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:36163 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729259AbfDYT5N (ORCPT ); Thu, 25 Apr 2019 15:57:13 -0400 Received: by mail-it1-f195.google.com with SMTP id y10so2184639itc.1 for ; Thu, 25 Apr 2019 12:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=gvwc2z4S6BD6uWlEMi4IucZ2NoOc2SvZD8TjjoytUcY=; b=mj7u0XCTY89HpkX0rB6pEM6G9cN6dFJV7R66tTAw7uYiAQtFjBSVi9RLv6syTFdrnY YLUwYsQhOY7lyffrxcjZSQOZRcNQH09RuuG+25zPhuTKCmzkYfiC0txxsoyV/knfI8Nm mKKoAJTXoikIsAV4Ei8d4YW3PHr/tPNZc2CbzRJBkILzC4/3OchxfNDU9tbm9GH4KHOK RvT8z24Nha/ML2F/mkcPW1+YBgCyg3xi4q2EqEJUswisH59HQ5G6rP7/XsdBw0dYMJaX pukbWyejRCZWSheiE83PzWJjqKY1+th3lCOH33QEV5y5Ad7HsEomdNC3Um7p5kIsefoH Qdzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=gvwc2z4S6BD6uWlEMi4IucZ2NoOc2SvZD8TjjoytUcY=; b=ecPXFnOc2PcRZ6hDE/8FvOjb0+hj9H39m7oG4rKEsGEflP7+l5SOH3hgHfcRtPeVo9 84ek1jZufm6SeK1+NoeIf+9WnpaDrEOmA9yW+sNiUmVTr0h4e7DLhFjzYW5uI4Ecu7Ni G6zVle3Qa436leTGjDkvbIYOp3kc1oQj5wK48QBPaPtAkxUd/LVm3+pcu18j2mJY/1hu zt8zQ5rFuNdQxaCbibvOuK/uyQQHbdgKOLLheZtLcflHvrptoJmnhy9hlQjh23qIHMs5 6zhG5a0UGnvGki498hqpfAdovv2OypJ0pLH3ZC5/TOjJc5BpGlZCkbZ75YivjqAm7NH0 l1Nw== X-Gm-Message-State: APjAAAVF7+O8zy2cfbaw5bzDL/Ft+Fvl+US4PTPbzwigYFeoh5ZXr8Hy /Bh8XFYJQl3Wig8ILHQEVfBMLA== X-Received: by 2002:a05:660c:3c7:: with SMTP id c7mr4972199itl.2.1556222232601; Thu, 25 Apr 2019 12:57:12 -0700 (PDT) Received: from localhost (c-73-95-159-87.hsd1.co.comcast.net. [73.95.159.87]) by smtp.gmail.com with ESMTPSA id t67sm11013344ita.35.2019.04.25.12.57.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 12:57:11 -0700 (PDT) Date: Thu, 25 Apr 2019 12:57:11 -0700 (PDT) From: Paul Walmsley X-X-Sender: paulw@viisi.sifive.com To: Christoph Hellwig cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH 9/9] riscv: call pm_power_off from machine_halt / machine_power_off In-Reply-To: <20190411115623.5749-10-hch@lst.de> Message-ID: References: <20190411115623.5749-1-hch@lst.de> <20190411115623.5749-10-hch@lst.de> User-Agent: Alpine 2.21.9999 (DEB 301 2018-08-15) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Apr 2019, Christoph Hellwig wrote: > This way any override of pm_power_off also affects the halt path and > we don't need additional infrastructure for it. > > Also remove the pm_power_off export - at least for now we don't have > any modular drivers overriding it. I'd propose that we keep the pm_power_off export - both to align with other architectures: $ fgrep -r pm_power_off arch/ | grep EXPORT arch/s390/kernel/setup.c:EXPORT_SYMBOL_GPL(pm_power_off); arch/m68k/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/hexagon/kernel/reset.c:EXPORT_SYMBOL(pm_power_off); arch/ia64/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/sparc/kernel/process_32.c:EXPORT_SYMBOL(pm_power_off); arch/sparc/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off); arch/sh/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off); arch/um/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off); arch/openrisc/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/nios2/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/arc/kernel/reset.c:EXPORT_SYMBOL(pm_power_off); arch/arm/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off); arch/nds32/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/csky/kernel/power.c:EXPORT_SYMBOL(pm_power_off); arch/alpha/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/arm64/kernel/process.c:EXPORT_SYMBOL_GPL(pm_power_off); arch/unicore32/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/c6x/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/xtensa/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/h8300/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/powerpc/kernel/setup-common.c:EXPORT_SYMBOL_GPL(pm_power_off); arch/mips/kernel/reset.c:EXPORT_SYMBOL(pm_power_off); arch/riscv/kernel/reset.c:EXPORT_SYMBOL(pm_power_off); arch/microblaze/kernel/process.c:EXPORT_SYMBOL(pm_power_off); arch/x86/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off); arch/parisc/kernel/process.c:EXPORT_SYMBOL(pm_power_off); $ and to make sure there's no hassle with the drivers that expect to assign something to it: $ fgrep -r pm_power_off drivers/ | fgrep = | cut -f1 -d: | sort -u | wc -l 39 $ For what it's worth, I agree with the implied criticism that reassigning pm_power_off is not a good interface. There is the obvious problem that more than one chunk of independent code could all try to assign to pm_power_off. However, to avoid creating a RISC-V-specific mess when someone uses a TI PMIC driver on a RISC-V board, or tries to use ACPI with RISC-V, fixing that seems best done as a separate tree-wide series. ... Replacing machine_power_off() with a call to your default_power_off() looks fine to me. However I think it makes sense to change our existing machine_halt() (which was not added by your patch). Looking at other major architectures - x86, ARM64, and ARM - they don't actually try to power down the system in machine_halt(), instead just entering an infinite loop, WFI, or calling into firmware or a hypervisor. I'd propose that we align with that approach. - Paul > > Signed-off-by: Christoph Hellwig > --- > arch/riscv/kernel/reset.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c > index 2a53d26ffdd6..ed637aee514b 100644 > --- a/arch/riscv/kernel/reset.c > +++ b/arch/riscv/kernel/reset.c > @@ -12,11 +12,15 @@ > */ > > #include > -#include > #include > > -void (*pm_power_off)(void) = machine_power_off; > -EXPORT_SYMBOL(pm_power_off); > +static void default_power_off(void) > +{ > + sbi_shutdown(); > + while (1); > +} > + > +void (*pm_power_off)(void) = default_power_off; > > void machine_restart(char *cmd) > { > @@ -26,11 +30,10 @@ void machine_restart(char *cmd) > > void machine_halt(void) > { > - machine_power_off(); > + pm_power_off(); > } > > void machine_power_off(void) > { > - sbi_shutdown(); > - while (1); > + pm_power_off(); > } > -- > 2.20.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv >