From patchwork Thu Jul 3 12:22:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 33023 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 112AB21131 for ; Thu, 3 Jul 2014 12:24:56 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id t59sf407033yho.10 for ; Thu, 03 Jul 2014 05:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=0XQ+vOiS74xBCsAgfy9MIITrvNjR4YqZyiWYqW4T8sE=; b=hSiOIa079Npe61Am6YGkBDsiCyhm/eBTphR+QF2BeQI9SIl+d+uN38fniMwAJ4mFBe Q2cXQf4xtc8s7xb6gKJWGpdweaiuNMLuAdH+oCbEUHaEOcCfidDax1Xq+u9oOJf78h06 OZIcZthuL8mhpIoOZHnF2yWXgAO58soPp0ubiscllEcdJYqC7PVxyykx7YYDKp9JiCL2 jdWXoYEZRyVK7hFeWvrsm+m27AQtMTk7ceMhIuKAEt++N+tfOdu15idXLZpOvmAcCgIx UDrDSaDm7HqcUHizaWmtbDd8kfb7V9UzZZDA75s29YNpFDhgqrSpvRdIWSt7pNrTQ/wh wPjg== X-Gm-Message-State: ALoCoQnQtuWdigfeuYaUI0XqBc9v4o/wX6RcTqaeLdwYMGXekhyTdMOlbL9gbWAK9ckWOdYlhugW X-Received: by 10.236.207.164 with SMTP id n24mr2079453yho.5.1404390295810; Thu, 03 Jul 2014 05:24:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.101 with SMTP id c92ls393704qge.90.gmail; Thu, 03 Jul 2014 05:24:55 -0700 (PDT) X-Received: by 10.52.232.133 with SMTP id to5mr2928596vdc.16.1404390295737; Thu, 03 Jul 2014 05:24:55 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id sb6si14123706veb.66.2014.07.03.05.24.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 05:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so122869veb.37 for ; Thu, 03 Jul 2014 05:24:55 -0700 (PDT) X-Received: by 10.52.25.228 with SMTP id f4mr67003vdg.62.1404390295671; Thu, 03 Jul 2014 05:24:55 -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.221.37.5 with SMTP id tc5csp368701vcb; Thu, 3 Jul 2014 05:24:55 -0700 (PDT) X-Received: by 10.220.89.4 with SMTP id c4mr73703vcm.53.1404390295162; Thu, 03 Jul 2014 05:24:55 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t2si14107427vcs.89.2014.07.03.05.24.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Jul 2014 05:24:55 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2g2a-0005XD-7n; Thu, 03 Jul 2014 12:23:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2g2Z-0005X0-5f for xen-devel@lists.xen.org; Thu, 03 Jul 2014 12:23:03 +0000 Received: from [85.158.139.211:5864] by server-15.bemta-5.messagelabs.com id CC/4D-19516-62B45B35; Thu, 03 Jul 2014 12:23:02 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-7.tower-206.messagelabs.com!1404390180!13494987!1 X-Originating-IP: [209.85.220.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19864 invoked from network); 3 Jul 2014 12:23:01 -0000 Received: from mail-pa0-f41.google.com (HELO mail-pa0-f41.google.com) (209.85.220.41) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 3 Jul 2014 12:23:01 -0000 Received: by mail-pa0-f41.google.com with SMTP id fb1so143716pad.14 for ; Thu, 03 Jul 2014 05:22:59 -0700 (PDT) X-Received: by 10.66.159.34 with SMTP id wz2mr4234546pab.96.1404390179906; Thu, 03 Jul 2014 05:22:59 -0700 (PDT) Received: from parthd-ubunutu.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id tg9sm40928121pbc.29.2014.07.03.05.22.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Jul 2014 05:22:58 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Thu, 3 Jul 2014 17:52:37 +0530 Message-Id: <1404390158-21542-1-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 Cc: ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, julien.grall@linaro.org, tim@xen.org, Parth Dixit , christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v3 1/2] xen/arm : Adding helper function for WFI X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@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.128.178 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 List-Archive: WFI functionality is required at different places in xen. Moving it to seperate helper function so that it is easier to call WFI function and avoid duplication of code Signed-off-by: Parth Dixit --- Changelog v3 : - new patch for helper function, this functionality existed in same patch in v2 xen/arch/arm/domain.c | 13 +++++++++++++ xen/arch/arm/traps.c | 10 +--------- xen/include/asm-arm/event.h | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 2ae6941..bc5e56d 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -779,6 +779,19 @@ void vcpu_mark_events_pending(struct vcpu *v) vgic_vcpu_inject_irq(v, v->domain->arch.evtchn_irq, 1); } +/* The ARM spec declares that even if local irqs are masked in +* the CPSR register, an irq should wake up a cpu from WFI anyway. +* For this reason we need to check for irqs that need delivery, +* ignoring the CPSR register, *after* calling SCHEDOP_block to +* avoid races with vgic_vcpu_inject_irq. +*/ +void vcpu_block_event(struct vcpu *v) +{ + vcpu_block(); + if ( local_events_need_delivery_nomask() ) + vcpu_unblock(current); +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 03a3da6..8d2e308 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1670,15 +1670,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) return; } /* at the moment we only trap WFI */ - vcpu_block(); - /* The ARM spec declares that even if local irqs are masked in - * the CPSR register, an irq should wake up a cpu from WFI anyway. - * For this reason we need to check for irqs that need delivery, - * ignoring the CPSR register, *after* calling SCHEDOP_block to - * avoid races with vgic_vcpu_inject_irq. - */ - if ( local_events_need_delivery_nomask() ) - vcpu_unblock(current); + vcpu_block_event(current); advance_pc(regs, hsr); break; case HSR_EC_CP15_32: diff --git a/xen/include/asm-arm/event.h b/xen/include/asm-arm/event.h index dd3ad13..a94ba2e 100644 --- a/xen/include/asm-arm/event.h +++ b/xen/include/asm-arm/event.h @@ -6,6 +6,7 @@ void vcpu_kick(struct vcpu *v); void vcpu_mark_events_pending(struct vcpu *v); +void vcpu_block_event(struct vcpu *v); static inline int vcpu_event_delivery_is_enabled(struct vcpu *v) {