Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1679081ioo; Mon, 23 May 2022 00:03:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFZtLnn3DDcMjLvZGefbC1aaqbRaR1ud/+AOfTNiDBVjB7kbjL4zY9RV8Aj4eGa4rr+aTg X-Received: by 2002:a17:90b:946:b0:1df:4b91:9924 with SMTP id dw6-20020a17090b094600b001df4b919924mr24530197pjb.180.1653289392374; Mon, 23 May 2022 00:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653289392; cv=none; d=google.com; s=arc-20160816; b=ni4Vy4OGoed+GotfT3g/c7+MyNy/v9L/gXY5CgIHQYQofZZLopCClPoxaE40OgI7f7 TVxo+0I6zowdNJZQ+/vvgoZWpzDHfigJnRYUaPzAJ9f2UNWIoDdGJtB2lUmNwzjEXVuc 4T7+1v3dh1QRJiqV5zU+FlVnGYxivag+cHYtr/2SFkobOUhe9qUMiBfSlhbD/zNNhFjf FfWw0WhCccRRndtrh9tj4TNtkldSGeY7KoC8R2YzQsmJq7fdOmyi4nYhTmk0ltTzx1ny 0fVI+/W95cr72DSE6fjhajhkmyXHOwZKbn89zxrjnJL4+9R+o+CBRTAkXUhIiz6geQSb EsWQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=A9WAfYeuw2rM/x9RDm1gVc1LuP/yWR8j3Z6vMIFpmHE=; b=x6FM2jc8dFpOq1L8MokHenjncPjOo73ubDFHYFGz5GNyE/hG+jKPOBFdgJy6Bf7Lvt 8qFOJAT/+OW2pL77zTQPApgrLTnCckc+sl78NqFNsgpq53K37rk9CdsW1V6Ae4GWiE7c aT4eK+mjigFqQJ/DDUUzEVhIkKGkguJNUsDQOWNGcjgDHGUjgoNdwKl0xk2Ha+FzwFAh xpUWyJs+Ge4t9biLU9gcMpIFz9W7WLVIsY0Sj24Jn9t51eqVWlCQHf6Z1dH9AjuK30gk AhPJDfZv7ZMMP2vgDR9YOa8X9ec0Ps10lquPZiM7TtMPuDIsHswr5cPIedWBdQ/qkfPm WJeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AEP0hwK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s70-20020a632c49000000b003fa74c5ecf9si1487024pgs.588.2022.05.23.00.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:03:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AEP0hwK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EC30ABC3; Sun, 22 May 2022 23:26:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351530AbiEUBx5 (ORCPT + 99 others); Fri, 20 May 2022 21:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232367AbiEUBxy (ORCPT ); Fri, 20 May 2022 21:53:54 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED997195BE5 for ; Fri, 20 May 2022 18:53:50 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id l14so9433885pjk.2 for ; Fri, 20 May 2022 18:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=A9WAfYeuw2rM/x9RDm1gVc1LuP/yWR8j3Z6vMIFpmHE=; b=AEP0hwK7eENdujB43s0AppydtVZW8WoJ97TELyc6SbvsrUEE3OMviBxGDctnbSTa7m Vqj6z2y2mJjyte/ZWcrTBkuHCO3TMas5gqAPbhRMaBSNa8mUi597dM6ulffqHUTDELci 1UM3CtQZM+O06orSWrLuGbUYnCIH9ePZWrDvfbI+IF2dIKp7uYARvvZG/pli2wFQsJu4 k2DDVfr6KU7HdDE47gzawF4gsyVKVicIC+L1zCMqOj1Hv0BF2LZRZSVsOwa9vyucfa6j frXtEM+oi/dVPAUFVZ1LwHsglkv0o4QYnpR+AF+H+ZuP8x2tpEa+Jq/bKvrZho/8ZWhj MIEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=A9WAfYeuw2rM/x9RDm1gVc1LuP/yWR8j3Z6vMIFpmHE=; b=ZWj7kAAQeaWT2AtK51vTHfKIMBfSs6pw1999s1hyRNSWF6OPUQNKv8stz0H+CpoMNA LucMnAtd4MA/toE4DPGg5r4aPCNPQpNjhVCz8UjVRm+bN/NZV49BMJlICRO1C5PROA2S lQdZ0udB1gH2tdCeKRBhyz/v9tRlQ1LU+7F9bK2RHr7rt0aG7459gfQsDOb6C1/5EXgd xRDBA48htkbXSSHKyrmdB0ckQ+rHHd1fRXdMRCQG5AUzgC2a2MYZy/uDjE6660lKjwYx 8uK8pEuipMceN1s/lD6tixUcD6dJzN5d8uUaCkmFXRwO6UvaDh2lhHoSSDuJH6dlx9B5 Q3Cw== X-Gm-Message-State: AOAM531XyKTNO6mqpKvluhyXNVBLux/xSYKLaKxGJD8+xFPqRryBEQAb 4DUTt5VlHXfiY7oqEoh8YeF6cqg/ytY= X-Received: by 2002:a17:902:b941:b0:14d:af72:3f23 with SMTP id h1-20020a170902b94100b0014daf723f23mr12589600pls.6.1653098029956; Fri, 20 May 2022 18:53:49 -0700 (PDT) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id q13-20020a170902f78d00b0015e8d4eb242sm363598pln.140.2022.05.20.18.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 18:53:49 -0700 (PDT) From: Stafford Horne To: LKML Cc: Openrisc , Stafford Horne , "Jason A . Donenfeld" , Jonas Bonn , Stefan Kristiansson , Kees Cook , "Russell King (Oracle)" , "Peter Zijlstra (Intel)" , Masahiro Yamada , Alexey Dobriyan Subject: [PATCH] openrisc: Allow power off handler overriding Date: Sat, 21 May 2022 10:53:21 +0900 Message-Id: <20220521015322.188707-1-shorne@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 The OpenRISC platform always defines a default pm_power_off hanlder which is only useful for simulators. Having this set also means power management drivers like syscon-power are not able to wire in their own pm_power_off handlers. Fix this by not setting the pm_power_off handler by default and fallback to the simulator power off handler if no handler is set. This has been tested with a new OpenRISC virt platform I am working on for QEMU. https://github.com/stffrdhrn/qemu/commits/or1k-virt Cc: Jason A. Donenfeld Signed-off-by: Stafford Horne --- arch/openrisc/kernel/process.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c index 3c0c91bcdcba..1cca89a3b0c8 100644 --- a/arch/openrisc/kernel/process.c +++ b/arch/openrisc/kernel/process.c @@ -60,6 +60,16 @@ void machine_restart(char *cmd) while (1); } +/* + * This is used if pm_power_off has not been set by a power management + * driver, in this case we can assume we are on a simulator. On + * OpenRISC simulators l.nop 1 will trigger the simulator exit. + */ +static void default_power_off(void) +{ + __asm__("l.nop 1"); +} + /* * Similar to machine_power_off, but don't shut off power. Add code * here to freeze the system for e.g. post-mortem debug purpose when @@ -75,7 +85,10 @@ void machine_halt(void) void machine_power_off(void) { printk(KERN_INFO "*** MACHINE POWER OFF ***\n"); - __asm__("l.nop 1"); + if (pm_power_off != NULL) + pm_power_off(); + else + default_power_off(); } /* @@ -89,7 +102,7 @@ void arch_cpu_idle(void) mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME); } -void (*pm_power_off) (void) = machine_power_off; +void (*pm_power_off)(void) = NULL; EXPORT_SYMBOL(pm_power_off); /* -- 2.31.1