From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: [PATCHv2 1/5] evtchn: factor out freeing an event channel Date: Mon, 15 Jun 2015 16:48:15 +0100 Message-ID: <1434383299-21833-2-git-send-email-david.vrabel@citrix.com> References: <1434383299-21833-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z4XOs-0008W4-3u for xen-devel@lists.xenproject.org; Mon, 15 Jun 2015 16:38:18 +0000 In-Reply-To: <1434383299-21833-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Keir Fraser , Tim Deegan , David Vrabel , Jan Beulich , Ian Campbell List-Id: xen-devel@lists.xenproject.org We're going to want to free an event channel from two places. Factor out the code into a free_evtchn() function. Signed-off-by: David Vrabel --- xen/common/event_channel.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index bf9b2f8..947880f 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -192,6 +192,17 @@ static int get_free_port(struct domain *d) return port; } +static void free_evtchn(struct domain *d, struct evtchn *chn) +{ + /* Clear pending event to avoid unexpected behavior on re-bind. */ + evtchn_port_clear_pending(d, chn); + + /* Reset binding to vcpu0 when the channel is freed. */ + chn->state = ECS_FREE; + chn->notify_vcpu_id = 0; + + xsm_evtchn_close_post(chn); +} static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) { @@ -569,14 +580,7 @@ static long __evtchn_close(struct domain *d1, int port1) BUG(); } - /* Clear pending event to avoid unexpected behavior on re-bind. */ - evtchn_port_clear_pending(d1, chn1); - - /* Reset binding to vcpu0 when the channel is freed. */ - chn1->state = ECS_FREE; - chn1->notify_vcpu_id = 0; - - xsm_evtchn_close_post(chn1); + free_evtchn(d1, chn1); out: if ( d2 != NULL ) -- 1.7.10.4