From patchwork Tue May 19 18:33:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 48767 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B0752121F for ; Tue, 19 May 2015 18:33:50 +0000 (UTC) Received: by wgbgf7 with SMTP id gf7sf7174637wgb.2 for ; Tue, 19 May 2015 11:33:49 -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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=symIqe1uSFK2scq/XzHiVfC617R6dcuhWg5ZLZoJluY=; b=Ro3szI89IO+YTRyVXajdXJG5AErNFbaD0lraE2ObWLHOlgoqY42B9VeSM1EY1oQd5L MIol+MnZINYBug0iJanpM0Pd9X5GmNiNRk2Tz87tH7wQWnyhKaa6qGhKYSsQXYvoduJ0 a+CjS+gAF3lreOBbAadvI2B3Yd9HZZLJ1dR7s1GpT2CLXJgkoWJ3Iu8ShUsJL72VW+lE 8HQXqHSuJCNdS4ThXSpTAmqTG8M9K03AEgMvG+njlitwdtTonctzdsw2UFa12lel3nKA PwloyVn0n1dsGwXWMwefiZYyKd4ZRnzV0WzLrEsxsIE2e/7YxMl4C7YziQRYy01r1Zy8 9Ivw== X-Gm-Message-State: ALoCoQmeOsGtZmTx9f7Uo/q9rx6o5YQ54i6UsByXMmDpLV1gVbn6oMJZCq60/PnqCBFDDj9D91qD X-Received: by 10.152.8.17 with SMTP id n17mr22971420laa.0.1432060429838; Tue, 19 May 2015 11:33:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.6 with SMTP id i6ls102757lam.4.gmail; Tue, 19 May 2015 11:33:49 -0700 (PDT) X-Received: by 10.112.210.103 with SMTP id mt7mr22418531lbc.27.1432060429694; Tue, 19 May 2015 11:33:49 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id xn1si9589781lbb.112.2015.05.19.11.33.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 11:33:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lagr1 with SMTP id r1so37922882lag.0 for ; Tue, 19 May 2015 11:33:49 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr15174160lae.19.1432060429536; Tue, 19 May 2015 11:33:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp992952lbb; Tue, 19 May 2015 11:33:48 -0700 (PDT) X-Received: by 10.66.229.9 with SMTP id sm9mr56462673pac.1.1432060423148; Tue, 19 May 2015 11:33:43 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id k5si22593789pdo.20.2015.05.19.11.33.41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 May 2015 11:33:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YumKc-0001N5-Ot; Tue, 19 May 2015 19:33:34 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, alex.bennee@linaro.org, agraf@suse.de, serge.fdrv@gmail.com, edgar.iglesias@xilinx.com Subject: [PATCH 13/14] target-arm: Don't halt on WFI unless we don't have any work Date: Tue, 19 May 2015 19:33:33 +0100 Message-Id: <1432060414-5195-14-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432060414-5195-1-git-send-email-peter.maydell@linaro.org> References: <1432060414-5195-1-git-send-email-peter.maydell@linaro.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.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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 5963f3b..517dacc 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);