All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] minios: cleanup events.c
@ 2009-02-19 18:04 Rolf Neugebauer
  2009-02-24  0:28 ` Samuel Thibault
  2009-03-02 10:28 ` [PATCH 2/3] minios: cleanup events.c [resend] Rolf Neugebauer
  0 siblings, 2 replies; 3+ messages in thread
From: Rolf Neugebauer @ 2009-02-19 18:04 UTC (permalink / raw)
  To: Xen-devel; +Cc: samuel.thibault

Don't throw away hypercall error codes. They might be useful. Also some 
minor coding style cleanups.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@netronome.com>
---
diff -r 35577e8fb3fe extras/mini-os/events.c
--- a/extras/mini-os/events.c	Thu Feb 19 16:39:02 2009 +0000
+++ b/extras/mini-os/events.c	Thu Feb 19 16:41:22 2009 +0000
@@ -42,19 +42,23 @@
      int cpu = 0;
      shared_info_t *s = HYPERVISOR_shared_info;
      vcpu_info_t   *vcpu_info = &s->vcpu_info[cpu];
+    int rc;

-    for (i = 0; i < NR_EVS; i++)
+    for ( i = 0; i < NR_EVS; i++ )
      {
-        if (i == start_info.console.domU.evtchn ||
-            i == start_info.store_evtchn)
+        if ( i == start_info.console.domU.evtchn ||
+             i == start_info.store_evtchn)
              continue;
-        if (test_and_clear_bit(i, bound_ports))
+
+        if ( test_and_clear_bit(i, bound_ports) )
          {
              struct evtchn_close close;
              printk("port %d still bound!\n", i);
              mask_evtchn(i);
              close.port = i;
-            HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+            rc = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+            if ( rc )
+                printk("WARN: close_port %s failed rc=%d. ignored\n", 
i, rc);
              clear_evtchn(i);
          }
      }
@@ -71,8 +75,9 @@

      clear_evtchn(port);

-    if (port >= NR_EVS) {
-        printk("Port number too large: %d\n", port);
+    if ( port >= NR_EVS )
+    {
+        printk("WARN: do_event(): Port number too large: %d\n", port);
          return 1;
      }

@@ -89,9 +94,9 @@
  evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler,
  						  void *data)
  {
- 	if(ev_actions[port].handler != default_handler)
+ 	if ( ev_actions[port].handler != default_handler )
          printk("WARN: Handler for port %d already registered, 
replacing\n",
-				port);
+               port);

  	ev_actions[port].data = data;
  	wmb();
@@ -104,8 +109,9 @@
  void unbind_evtchn(evtchn_port_t port )
  {
  	struct evtchn_close close;
+    int rc;

-	if (ev_actions[port].handler == default_handler)
+	if ( ev_actions[port].handler == default_handler )
  		printk("WARN: No handler for port %d when unbinding\n", port);
  	mask_evtchn(port);
  	clear_evtchn(port);
@@ -116,37 +122,43 @@
  	clear_bit(port, bound_ports);

  	close.port = port;
-	HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+	rc = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+    if ( rc )
+        printk("WARN: close_port %s failed rc=%d. ignored\n", port, rc);
+
  }

  evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void 
*data)
  {
  	evtchn_bind_virq_t op;
+    int rc;

  	/* Try to bind the virq to a port */
  	op.virq = virq;
  	op.vcpu = smp_processor_id();

-	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op) != 0 )
+	if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op)) != 0 )
  	{
-		printk("Failed to bind virtual IRQ %d\n", virq);
+		printk("Failed to bind virtual IRQ %d with rc=%d\n", virq, rc);
  		return -1;
      }
      bind_evtchn(op.port, handler, data);
  	return op.port;
  }

-evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t 
handler, void *data)
+evtchn_port_t bind_pirq(uint32_t pirq, int will_share,
+                        evtchn_handler_t handler, void *data)
  {
  	evtchn_bind_pirq_t op;
+    int rc;

  	/* Try to bind the pirq to a port */
  	op.pirq = pirq;
  	op.flags = will_share ? BIND_PIRQ__WILL_SHARE : 0;

-	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op) != 0 )
+	if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op)) != 0 )
  	{
-		printk("Failed to bind physical IRQ %d\n", pirq);
+		printk("Failed to bind physical IRQ %d with rc=%d\n", pirq, rc);
  		return -1;
  	}
  	bind_evtchn(op.port, handler, data);
@@ -173,7 +185,8 @@
      asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
      wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */
      cpu0_pda.irqcount = -1;
-    cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * 
STACK_SIZE) & ~(STACK_SIZE - 1));
+    cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * 
STACK_SIZE)
+                                    & ~(STACK_SIZE - 1));
  #endif
      /* initialize event handler */
      for ( i = 0; i < NR_EVS; i++ )
@@ -207,15 +220,19 @@
  int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler,
  						 void *data, evtchn_port_t *port)
  {
-    int err;
+    int rc;
+
      evtchn_alloc_unbound_t op;
      op.dom = DOMID_SELF;
      op.remote_dom = pal;
-    err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
-    if (err)
-		return err;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
+    if ( rc )
+    {
+        printk("ERROR: alloc_unbound failed with rc=%d", rc);
+		return rc;
+    }
      *port = bind_evtchn(op.port, handler, data);
-    return err;
+    return rc;
  }

  /* Connect to a port so as to allow the exchange of notifications with
@@ -225,15 +242,28 @@
  			    evtchn_handler_t handler, void *data,
  			    evtchn_port_t *local_port)
  {
-    int err;
+    int rc;
      evtchn_port_t port;
      evtchn_bind_interdomain_t op;
      op.remote_dom = pal;
      op.remote_port = remote_port;
-    err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
-    if (err)
-		return err;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
+    if ( rc )
+    {
+        printk("ERROR: bind_interdomain failed with rc=%d", rc);
+		return rc;
+    }
      port = op.local_port;
      *local_port = bind_evtchn(port, handler, data);
-    return err;
+    return rc;
  }
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] minios: cleanup events.c
  2009-02-19 18:04 [PATCH 2/3] minios: cleanup events.c Rolf Neugebauer
@ 2009-02-24  0:28 ` Samuel Thibault
  2009-03-02 10:28 ` [PATCH 2/3] minios: cleanup events.c [resend] Rolf Neugebauer
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2009-02-24  0:28 UTC (permalink / raw)
  To: Rolf Neugebauer; +Cc: Xen-devel

Rolf Neugebauer, le Thu 19 Feb 2009 18:04:43 +0000, a écrit :
> Don't throw away hypercall error codes. They might be useful. Also some 
> minor coding style cleanups.
> 
> Signed-off-by: Rolf Neugebauer <rolf.neugebauer@netronome.com>

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] minios: cleanup events.c [resend]
  2009-02-19 18:04 [PATCH 2/3] minios: cleanup events.c Rolf Neugebauer
  2009-02-24  0:28 ` Samuel Thibault
@ 2009-03-02 10:28 ` Rolf Neugebauer
  1 sibling, 0 replies; 3+ messages in thread
From: Rolf Neugebauer @ 2009-03-02 10:28 UTC (permalink / raw)
  To: Xen-devel

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

Don't throw away hypercall error codes. They might be useful. Also some
minor coding style cleanups.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@netronome.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---


[-- Attachment #2: minios-events.patch --]
[-- Type: text/x-patch, Size: 5634 bytes --]

diff -r 35577e8fb3fe extras/mini-os/events.c
--- a/extras/mini-os/events.c	Thu Feb 19 16:39:02 2009 +0000
+++ b/extras/mini-os/events.c	Thu Feb 19 16:41:22 2009 +0000
@@ -42,19 +42,23 @@
     int cpu = 0;
     shared_info_t *s = HYPERVISOR_shared_info;
     vcpu_info_t   *vcpu_info = &s->vcpu_info[cpu];
+    int rc;
 
-    for (i = 0; i < NR_EVS; i++)
+    for ( i = 0; i < NR_EVS; i++ )
     {
-        if (i == start_info.console.domU.evtchn ||
-            i == start_info.store_evtchn)
+        if ( i == start_info.console.domU.evtchn ||
+             i == start_info.store_evtchn)
             continue;
-        if (test_and_clear_bit(i, bound_ports))
+
+        if ( test_and_clear_bit(i, bound_ports) )
         {
             struct evtchn_close close;
             printk("port %d still bound!\n", i);
             mask_evtchn(i);
             close.port = i;
-            HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+            rc = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+            if ( rc )
+                printk("WARN: close_port %s failed rc=%d. ignored\n", i, rc);
             clear_evtchn(i);
         }
     }
@@ -71,8 +75,9 @@
 
     clear_evtchn(port);
 
-    if (port >= NR_EVS) {
-        printk("Port number too large: %d\n", port);
+    if ( port >= NR_EVS )
+    {
+        printk("WARN: do_event(): Port number too large: %d\n", port);
         return 1;
     }
 
@@ -89,9 +94,9 @@
 evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler,
 						  void *data)
 {
- 	if(ev_actions[port].handler != default_handler)
+ 	if ( ev_actions[port].handler != default_handler )
         printk("WARN: Handler for port %d already registered, replacing\n",
-				port);
+               port);
 
 	ev_actions[port].data = data;
 	wmb();
@@ -104,8 +109,9 @@
 void unbind_evtchn(evtchn_port_t port )
 {
 	struct evtchn_close close;
+    int rc;
 
-	if (ev_actions[port].handler == default_handler)
+	if ( ev_actions[port].handler == default_handler )
 		printk("WARN: No handler for port %d when unbinding\n", port);
 	mask_evtchn(port);
 	clear_evtchn(port);
@@ -116,37 +122,43 @@
 	clear_bit(port, bound_ports);
 
 	close.port = port;
-	HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+	rc = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
+    if ( rc )
+        printk("WARN: close_port %s failed rc=%d. ignored\n", port, rc);
+        
 }
 
 evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
 {
 	evtchn_bind_virq_t op;
+    int rc;
 
 	/* Try to bind the virq to a port */
 	op.virq = virq;
 	op.vcpu = smp_processor_id();
 
-	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op) != 0 )
+	if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op)) != 0 )
 	{
-		printk("Failed to bind virtual IRQ %d\n", virq);
+		printk("Failed to bind virtual IRQ %d with rc=%d\n", virq, rc);
 		return -1;
     }
     bind_evtchn(op.port, handler, data);
 	return op.port;
 }
 
-evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data)
+evtchn_port_t bind_pirq(uint32_t pirq, int will_share,
+                        evtchn_handler_t handler, void *data)
 {
 	evtchn_bind_pirq_t op;
+    int rc;
 
 	/* Try to bind the pirq to a port */
 	op.pirq = pirq;
 	op.flags = will_share ? BIND_PIRQ__WILL_SHARE : 0;
 
-	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op) != 0 )
+	if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op)) != 0 )
 	{
-		printk("Failed to bind physical IRQ %d\n", pirq);
+		printk("Failed to bind physical IRQ %d with rc=%d\n", pirq, rc);
 		return -1;
 	}
 	bind_evtchn(op.port, handler, data);
@@ -173,7 +185,8 @@
     asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
     wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */
     cpu0_pda.irqcount = -1;
-    cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE) & ~(STACK_SIZE - 1));
+    cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE)
+                                    & ~(STACK_SIZE - 1));
 #endif
     /* initialize event handler */
     for ( i = 0; i < NR_EVS; i++ )
@@ -207,15 +220,19 @@
 int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler,
 						 void *data, evtchn_port_t *port)
 {
-    int err;
+    int rc;
+
     evtchn_alloc_unbound_t op;
     op.dom = DOMID_SELF;
     op.remote_dom = pal;
-    err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
-    if (err)
-		return err;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
+    if ( rc )
+    {
+        printk("ERROR: alloc_unbound failed with rc=%d", rc);
+		return rc;
+    }
     *port = bind_evtchn(op.port, handler, data);
-    return err;
+    return rc;
 }
 
 /* Connect to a port so as to allow the exchange of notifications with
@@ -225,15 +242,28 @@
 			    evtchn_handler_t handler, void *data,
 			    evtchn_port_t *local_port)
 {
-    int err;
+    int rc;
     evtchn_port_t port;
     evtchn_bind_interdomain_t op;
     op.remote_dom = pal;
     op.remote_port = remote_port;
-    err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
-    if (err)
-		return err;
+    rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
+    if ( rc )
+    {
+        printk("ERROR: bind_interdomain failed with rc=%d", rc);
+		return rc;
+    }
     port = op.local_port;
     *local_port = bind_evtchn(port, handler, data);
-    return err;
+    return rc;
 }
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-02 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-19 18:04 [PATCH 2/3] minios: cleanup events.c Rolf Neugebauer
2009-02-24  0:28 ` Samuel Thibault
2009-03-02 10:28 ` [PATCH 2/3] minios: cleanup events.c [resend] Rolf Neugebauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.