From patchwork Fri May 29 13:10:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 49184 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2DAA9218E7 for ; Fri, 29 May 2015 13:18:03 +0000 (UTC) Received: by wibbk2 with SMTP id bk2sf6227822wib.2 for ; Fri, 29 May 2015 06:18:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=eIMznWlLm8xKRKHUs2Nms6T5zN10dw6OuAtcY/o9pCA=; b=QYxdsxrrCnqsosowfUKQgdrgLB7YjyZkoBuLqhEXoXVEzIpEZ0Poqr3+izKQzyTDjD 9GmEJfK9sYEGbyKKuuhwYxG5gOtLIZekmEf0FeIrDZXOodSJth+zGm+W7AkeTvld9nl3 yhX+zRWcSpzfhSTo5r3bcjLkHB9Ax2538o2Teaj3MZXahYcnEJwG9Q91j257v0NJqmwA eZe5keON7SzxQBXgrfUdBZMR7LX/VcmJHgAlm7MqGN7ni5/k2Wp6SK0x92yDG5heXc9I Lwb3ScVPGI9myzXQYBe8HyuB1L0LRqmR+GEJliNC2bDnEZ900MdTzzoWCXqDlGXm+rFQ vu7A== X-Gm-Message-State: ALoCoQnP60QsRe/rIChPqVM/qYRegmteQ5Klt3qLm8LqVBphBbwWAySdYMVw+LWViBD6vHTODkEM X-Received: by 10.112.29.39 with SMTP id g7mr7376104lbh.1.1432905482438; Fri, 29 May 2015 06:18:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.72 with SMTP id h8ls347827laa.71.gmail; Fri, 29 May 2015 06:18:02 -0700 (PDT) X-Received: by 10.152.21.5 with SMTP id r5mr7842035lae.24.1432905482294; Fri, 29 May 2015 06:18:02 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id mj2si4679251lbc.68.2015.05.29.06.18.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 06:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbuc2 with SMTP id uc2so48312837lbb.2 for ; Fri, 29 May 2015 06:18:02 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr8141254lbc.32.1432905482173; Fri, 29 May 2015 06:18:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp325757lbb; Fri, 29 May 2015 06:18:01 -0700 (PDT) X-Received: by 10.140.109.119 with SMTP id k110mr9315165qgf.53.1432905480689; Fri, 29 May 2015 06:18:00 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b184si5540877qka.84.2015.05.29.06.18.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 29 May 2015 06:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:35809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyKAh-0007Ds-KZ for patch@linaro.org; Fri, 29 May 2015 09:17:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyK3z-0003wv-Ea for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyK3w-0003b9-Rn for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:03 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyK3w-0003US-Kp for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:00 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YyK3h-0005mZ-RR for qemu-devel@nongnu.org; Fri, 29 May 2015 14:10:45 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 29 May 2015 14:10:19 +0100 Message-Id: <1432905045-22138-14-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432905045-22138-1-git-send-email-peter.maydell@linaro.org> References: <1432905045-22138-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 13/39] target-arm: Don't halt on WFI unless we don't have any work X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Just NOP the WFI instruction if we have work to do. This doesn't make much difference currently (though it does avoid jumping out to the top level loop and immediately restarting), but the distinction between "halt" and "don't halt" will become more important when the decision to halt requires us to trap to a higher exception level instead. Suggested-by: Edgar E. Iglesias Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias --- target-arm/op_helper.c | 7 +++++++ target-arm/translate-a64.c | 4 ++++ target-arm/translate.c | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 79e7d10..0ea4ed4 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -252,6 +252,13 @@ void HELPER(wfi)(CPUARMState *env) { CPUState *cs = CPU(arm_env_get_cpu(env)); + if (cpu_has_work(cs)) { + /* Don't bother to go into our "low power state" if + * we would just wake up immediately. + */ + return; + } + cs->exception_index = EXCP_HLT; cs->halted = 1; cpu_loop_exit(cs); diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 8d08ccd..ffa6cb8 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -11113,6 +11113,10 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu, */ gen_a64_set_pc_im(dc->pc); gen_helper_wfi(cpu_env); + /* The helper doesn't necessarily throw an exception, but we + * must go back to the main loop to check for interrupts anyway. + */ + tcg_gen_exit_tb(0); break; } } diff --git a/target-arm/translate.c b/target-arm/translate.c index ed2c43d..6493b9a 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -11351,6 +11351,10 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu, break; case DISAS_WFI: gen_helper_wfi(cpu_env); + /* The helper doesn't necessarily throw an exception, but we + * must go back to the main loop to check for interrupts anyway. + */ + tcg_gen_exit_tb(0); break; case DISAS_WFE: gen_helper_wfe(cpu_env);