From patchwork Fri Jan 5 20:55:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 10147067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 926DE60153 for ; Fri, 5 Jan 2018 20:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ABA32097A for ; Fri, 5 Jan 2018 20:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F46120952; Fri, 5 Jan 2018 20:55:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C77B20952 for ; Fri, 5 Jan 2018 20:55:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753049AbeAEUzx (ORCPT ); Fri, 5 Jan 2018 15:55:53 -0500 Received: from mout.gmx.net ([212.227.15.18]:52457 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753045AbeAEUzw (ORCPT ); Fri, 5 Jan 2018 15:55:52 -0500 Received: from ls3530.fritz.box ([193.159.16.218]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LfjlS-1fH3zz2j4U-00pOPM; Fri, 05 Jan 2018 21:55:41 +0100 Date: Fri, 5 Jan 2018 21:55:38 +0100 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Cc: Richard Henderson Subject: [PATCH] parisc: QEMU host idle sleep support Message-ID: <20180105205538.GA25474@ls3530.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) X-Provags-ID: V03:K0:O/h1eijf+HowgCPdz6tAumxehA6IVfbiRsYe6FNzkZb/EIYKjrW TpKpdSyOjDosHpSdRq/dKzd/PSvrgFMaWRB/n/7fQ0Nu1eJZW4UXyh5fQy53zz4XuHVzMUP fLazMEwURUJX23nL23peG0rJfam3z62Hf7uHm74pzXW9q/dsczd/r9hvUavTgM0m2NRNoJu rr1kNDrZtQld5vgGHB8Fw== X-UI-Out-Filterresults: notjunk:1; V01:K0:grUZhpVfAl4=:8QvbEMwAwGVVE7Jgij6LXY YsA50hee7L/ONRne7bMCl564IRFZXZOnVhusp1HqavqF5ObV+xpIOUh/UXuSLRx1cqV2ZgUOM UGJMIWOGupCsgWBE7pBCyRtH+fckCNEn/vLqPdhnyJVuKonPu6Q0LB4zpdvrMhb33FrVWZzOH fSBElSOD0OVooOZsPz436n2XbxBVEtSgGfmYK4q8GvcF5Pm7UcJonJVIEtdGCk6C3sPyyrAji GMKk7rkgWZgzIt+j7l9sED8v/uVRh8LsQOoqflyZ8VPOSd1tijI5rzvx5xW7iRU4Bmo+S7CeU 4P64fGn9kyH7QnV9M4GcdH8KY5+r96q+u1mRCPT6cu6ujUauiCM+jCLMXL1fPCXE9G9c0I8I0 TW0hBbDgssYDD2IOZNouBUxUnWl4eTk2NVqxuIAP4OnKmCPOg4hean59u+LvUSYO7FqwwpUbb UkvZq1kSb/XmA+rvpsGTXJuwo5m+nyvNTD3kP4xdB623sRjqT4ya/w2memQ4Vw6Lab7kDLQBt Bu+ZkS/oJqqUVOjq+KY5nwScufdcL282bydrnuHXvUEmooLy1vHnMW6pkdLgB9ldGC0aFxJKy nyN80gJk04oIAhtoZQ4yoDVewsFkBal5rlgznyOcMnMrzYWBX64by1DxCq+cFs7Yy47on53GO I9fD4WqEKec4piG9bvPZAsg6XivhgYy7+7WZ8gLvAmepJBDt47xZVW4MKetlLzHUqNhTkW9Hq kqpL+x2dk4fcJiJk4drMRdvO0MtbS4u0lMf4+Ecrz/QxB+u+AjiuWmHwnEpFQDNS7PQgnN5yt LXRffIwna1dGSEj74vJ7vBYwnMMwQ== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add QEMU host idle sleep support when running under QEMU with SeaBIOS PDC Firmware. Like ppc64 we use "or" assembler instructions (which translate to nops on real hardware) to indicate that qemu shall idle sleep. Signed-off-by: Helge Deller Cc: Richard Henderson CC: stable@vger.kernel.org # v4.9+ --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 30f92391a93e..cad3e8661cd6 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -184,6 +185,44 @@ int dump_task_fpu (struct task_struct *tsk, elf_fpregset_t *r) } /* + * Idle thread support + * + * Detect when running on QEMU with SeaBIOS PDC Firmware and let + * QEMU idle the host too. + */ + +int running_on_qemu __read_mostly; + +void __cpuidle arch_cpu_idle_dead(void) +{ + /* nop on real hardware, qemu will offline CPU. */ + asm volatile("or %%r31,%%r31,%%r31\n":::); +} + +void __cpuidle arch_cpu_idle(void) +{ + local_irq_enable(); + + /* nop on real hardware, qemu will idle sleep. */ + asm volatile("or %%r10,%%r10,%%r10\n":::); +} + +static int __init parisc_idle_init(void) +{ + const char *marker; + + /* check QEMU/SeaBIOS marker in PAGE0 */ + marker = (char *) &PAGE0->pad0; + running_on_qemu = (memcmp(marker, "SeaBIOS", 8) == 0); + + if (!running_on_qemu) + cpu_idle_poll_ctrl(1); + + return 0; +} +arch_initcall(parisc_idle_init); + +/* * Copy architecture-specific thread state */ int