Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1280391ybg; Fri, 18 Oct 2019 15:08:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPUbCAj4HWiqzchHY7sHzTk+vxM3kCHTVaZjwtpmIoebgG/PB/X65Vu+IHWxizrNsaGKKp X-Received: by 2002:aa7:de02:: with SMTP id h2mr12223645edv.212.1571436507830; Fri, 18 Oct 2019 15:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571436507; cv=none; d=google.com; s=arc-20160816; b=GSjFb7aRVo7LqjVVe2BYedpA37QcDdv1p6NanZbKCAWvBhXC9qOt5GkWhKl4vFu/hs 8PJ00TM63csulvWThGUqdr/9XzKooObC4YmRfBfdwcoRvsAOpapHR5dzLr04Ld/+LlWa AMExRoyaSOwWZOMcBePo0ajyiplRzwWPf5Qiz//9xZSs+DPjLp/gba7QN7Mhg0MtdCVi 0JRzNyvFl269jGBD7Zg5o9D077Gj9BskcC5dtTwIvWOVfnjQXmwc6znjiYmFGS2jLzpG ZuMl8ZFirs7qGI1+GXqa6fcBr83wtlsVxU19wy1bB5Nkm2HoQs1VGtoa33ngZeBvpJD1 tPtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bnzQn0VGk8xHz69eK/5CBIE5DQC7a3O2W+HZ1/ChbyQ=; b=t7WbZaz6zdgK2qVUXm9RBCMjq3OwEW5agkllqeNrLlKvILkkLWcy1Of2xudNVDg3S2 iajVB3q6Xr3L/bGVAqgscvt2reFKfh6SI2AHdGzo7nYMSpMpyFtKFaEPHJPR1tul2XzA lGV5qudEW+Legebci4NN1VkhoLKFK/zT1QE9ENpTC/fWrf73OBKmQhrdfVj9cmgPgFvi 5V4Q/Iq1LpYbkKdFfeGvpZvapafZyUvpXH9gmc6b6oKo5XbJ4WWRpNRWdMMLa82q9Xg/ d5gOAwE1rwwWF436w60bCFqfodsb0lV0yCkTTdxgSN1fk7zs6BrC2pqkeEShop4ld50j S5tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fCHDMiNz; 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 gl26si4337784ejb.17.2019.10.18.15.08.04; Fri, 18 Oct 2019 15:08:27 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fCHDMiNz; 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 S2503170AbfJQRim (ORCPT + 99 others); Thu, 17 Oct 2019 13:38:42 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35992 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503073AbfJQRiD (ORCPT ); Thu, 17 Oct 2019 13:38:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bnzQn0VGk8xHz69eK/5CBIE5DQC7a3O2W+HZ1/ChbyQ=; b=fCHDMiNzO3RdURiYDiRbBoUi7f 3cswLJDvrEmnifYG39WPH0Ut22SVLcJKdc5qb2CPsGbsbID6ACbc9UxvGv3sm4YFUylszUVrNCsd/ cd16xrAJqr09/eylCTds+xm9xljshtHg5ODKzq5ngkSFT+PJ9DHSS7v2aDKYngmsyiBGmr3RihO8u 4k7/H+GT6irEPAFyl1Qsa5X7cwODtFd1yANlH/dUFnlj8gVaIN9ZAfOzUb7xzYJfRmVhl6iEtinQi 8AHk5bCUzxgOVutfSXjMoqVmdxunGTT0j8tmyiK33mYC40ZeiQ5gHGGqtmQveO4wYGwlbq7+93HqU V9JerTIA==; Received: from [2001:4bb8:18c:d7b:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL9iq-0007eW-RX; Thu, 17 Oct 2019 17:38:01 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Atish Patra Subject: [PATCH 06/15] riscv: cleanup the default power off implementation Date: Thu, 17 Oct 2019 19:37:34 +0200 Message-Id: <20191017173743.5430-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017173743.5430-1-hch@lst.de> References: <20191017173743.5430-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the sbi poweroff to a separate function and file that is only compiled if CONFIG_SBI is set. Provide a new default fallback power off that just sits in a wfi loop to save some power. Signed-off-by: Christoph Hellwig Reviewed-by: Atish Patra --- arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/reset.c | 5 ++--- arch/riscv/kernel/sbi.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/kernel/sbi.c diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 696020ff72db..d8c35fa93cc6 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -41,5 +41,6 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += mcount-dyn.o obj-$(CONFIG_PERF_EVENTS) += perf_event.o obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o +obj-$(CONFIG_RISCV_SBI) += sbi.o clean: diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c index d0fe623bfb8f..5e4e69859af1 100644 --- a/arch/riscv/kernel/reset.c +++ b/arch/riscv/kernel/reset.c @@ -4,12 +4,11 @@ */ #include -#include static void default_power_off(void) { - sbi_shutdown(); - while (1); + while (1) + wait_for_interrupt(); } void (*pm_power_off)(void) = default_power_off; diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c new file mode 100644 index 000000000000..f6c7c3e82d28 --- /dev/null +++ b/arch/riscv/kernel/sbi.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include + +static void sbi_power_off(void) +{ + sbi_shutdown(); +} + +static int __init sbi_init(void) +{ + pm_power_off = sbi_power_off; + return 0; +} +early_initcall(sbi_init); -- 2.20.1