WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [rfc 3/4] ioemu: make __insert_to_pci_slot indempotent

To: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Subject: [Xen-devel] [rfc 3/4] ioemu: make __insert_to_pci_slot indempotent
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Sat, 21 Mar 2009 09:24:38 +1100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 20 Mar 2009 15:29:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090320222435.469444366@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: ioemu-remote/hw/pass-through.c
===================================================================
--- ioemu-remote.orig/hw/pass-through.c 2009-03-20 21:33:32.000000000 +1100
+++ ioemu-remote/hw/pass-through.c      2009-03-20 21:34:06.000000000 +1100
@@ -835,6 +835,16 @@ static int get_next_keyval(char **option
     return 0;
 }
 
+static int pci_slot_match(int bus, int dev, int func, int slot)
+{
+    if (test_pci_slot(slot) == 1 &&
+        dpci_infos.php_devs[slot].r_bus == bus &&
+        dpci_infos.php_devs[slot].r_dev  == dev &&
+        dpci_infos.php_devs[slot].r_func == func )
+        return 1;
+    return 0;
+}
+
 /* Insert a new pass-through device into a specific pci slot.
  * input  dom:bus:dev.func@slot, chose free one if slot == AUTO_PHP_SLOT
  * return -2: requested slot not available
@@ -851,6 +861,9 @@ static int __insert_to_pci_slot(int bus,
     {
         if ( !test_pci_slot(slot) && !pci_devfn_in_use(e_bus, slot << 3) )
             goto found;
+        if ( pci_slot_match(bus, dev, func, slot) )
+            /* The slot is already here, just return */
+            return slot;
         return -2;
     }
 
@@ -920,10 +933,7 @@ int bdf_to_slot(char *bdf_str)
     /* locate the virtual pci slot for this VTd device */
     for ( i = 0; i < NR_PCI_DEV; i++ )
     {
-        if ( dpci_infos.php_devs[i].valid &&
-           dpci_infos.php_devs[i].r_bus == bus &&
-           dpci_infos.php_devs[i].r_dev  == dev &&
-           dpci_infos.php_devs[i].r_func == func )
+        if ( pci_slot_match(bus, dev, func, slot) )
             return i;
     }
 

-- 

-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en


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