From patchwork Mon Jul 14 13:51:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 33592 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 99A7920CAD for ; Mon, 14 Jul 2014 13:54:49 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wn1sf22675171obc.2 for ; Mon, 14 Jul 2014 06:54: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: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=g4y++wpjpe4Vcq+CnlViuPZ9rCCIoRUFAbdFzEvdE/8=; b=D6fRlLCTCM/xWBqZnyCQc8OKZ5zRXc7bs/4M3GGU8BAe3SOQz4btYNiFZCuRZNyhk2 z9KSVPDozpKimBcOslViq+pGEF89YYhT3lAWAMBIDYImxcHJu45jit5l7DkP+cDcE7Ja Fi+9V+MgBGZvHTtLricZr/Uja5sVlemhv/82AuADWM7mC+TghnwQOawtdpxrqbr6jhGV QsRdzUdrf9uLLoEctSWK+20B2UD21+oOpSfvm/gPWnbHUCvtqi/V9K3hE0SJYIDjqA+2 9URy6Cr0gfZcQsVpMtTJ520MYciuYqAobTBFJ+7OIrY+d4C1jFHWvan7iCtG+I1lPqkT 6Dsw== X-Gm-Message-State: ALoCoQnVJAXrh4ljpqiVOdobGyRVZGzu6gUG4YruE5DwCJVQmQSry9zYjizqzAHMtpVO42n6FX3y X-Received: by 10.42.90.68 with SMTP id j4mr5459040icm.3.1405346089101; Mon, 14 Jul 2014 06:54:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.36.229 with SMTP id p92ls1056264qgp.92.gmail; Mon, 14 Jul 2014 06:54:49 -0700 (PDT) X-Received: by 10.58.123.193 with SMTP id mc1mr464533veb.44.1405346089006; Mon, 14 Jul 2014 06:54:49 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id g6si5384333vcn.29.2014.07.14.06.54.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 06:54:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id id10so7249752vcb.16 for ; Mon, 14 Jul 2014 06:54:48 -0700 (PDT) X-Received: by 10.58.247.167 with SMTP id yf7mr447278vec.46.1405346088912; Mon, 14 Jul 2014 06:54:48 -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 tc5csp136741vcb; Mon, 14 Jul 2014 06:54:48 -0700 (PDT) X-Received: by 10.221.63.195 with SMTP id xf3mr467921vcb.36.1405346088417; Mon, 14 Jul 2014 06:54:48 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ak16si5347498vdc.93.2014.07.14.06.54.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 14 Jul 2014 06:54:48 -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 1X6gfx-0000Fa-Gt; Mon, 14 Jul 2014 13:52:17 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X6gfv-0000FV-UR for xen-devel@lists.xen.org; Mon, 14 Jul 2014 13:52:16 +0000 Received: from [193.109.254.147:53863] by server-1.bemta-14.messagelabs.com id D1/94-14887-E80E3C35; Mon, 14 Jul 2014 13:52:14 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1405345932!17326952!1 X-Originating-IP: [209.85.192.178] 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 2849 invoked from network); 14 Jul 2014 13:52:14 -0000 Received: from mail-pd0-f178.google.com (HELO mail-pd0-f178.google.com) (209.85.192.178) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 14 Jul 2014 13:52:14 -0000 Received: by mail-pd0-f178.google.com with SMTP id r10so5264190pdi.37 for ; Mon, 14 Jul 2014 06:52:12 -0700 (PDT) X-Received: by 10.70.127.230 with SMTP id nj6mr43486pdb.164.1405345932119; Mon, 14 Jul 2014 06:52:12 -0700 (PDT) Received: from parthd-ubunutu.qualcomm.com ([202.46.23.62]) by mx.google.com with ESMTPSA id f5sm14629892pdl.30.2014.07.14.06.52.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Jul 2014 06:52:11 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 14 Jul 2014 19:21:53 +0530 Message-Id: <1405345914-7189-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 v4 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.220.171 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 - renamed vcpu_block_event to vcpu_block_unless_event_pending Signed-off-by: Parth Dixit --- Changelog v4 - added space in comments - renamed vcpu_block_event to vcpu_block_unless_event_pending 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..7ddd2d8 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_unless_event_pending(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..8102540 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_unless_event_pending(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..5330dfe 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_unless_event_pending(struct vcpu *v); static inline int vcpu_event_delivery_is_enabled(struct vcpu *v) {