]> xenbits.xensource.com Git - people/royger/linux-2.6.18-xen.git/commitdiff
pciback: Fix SRIOV VF passthru
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 26 Feb 2010 17:15:45 +0000 (17:15 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 26 Feb 2010 17:15:45 +0000 (17:15 +0000)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
drivers/xen/pciback/conf_space_header.c

index f794e12224a77ad51a5598a5cf9f5e590c90bef4..0854b76e54f123e75f68cbfd95decfb88dc3338c 100644 (file)
@@ -73,17 +73,7 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
        /* A write to obtain the length must happen as a 32-bit write.
         * This does not (yet) support writing individual bytes
         */
-       if (value == ~PCI_ROM_ADDRESS_ENABLE)
-               bar->which = 1;
-       else {
-               u32 tmpval;
-               pci_read_config_dword(dev, offset, &tmpval);
-               if (tmpval != bar->val && value == bar->val) {
-                       /* Allow restoration of bar value. */
-                       pci_write_config_dword(dev, offset, bar->val);
-               }
-               bar->which = 0;
-       }
+       bar->which = (value == ~PCI_ROM_ADDRESS_ENABLE);
 
        /* Do we need to support enabling/disabling the rom address here? */
 
@@ -107,17 +97,7 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
        /* A write to obtain the length must happen as a 32-bit write.
         * This does not (yet) support writing individual bytes
         */
-       if (value == ~0)
-               bar->which = 1;
-       else {
-               u32 tmpval;
-               pci_read_config_dword(dev, offset, &tmpval);
-               if (tmpval != bar->val && value == bar->val) {
-                       /* Allow restoration of bar value. */
-                       pci_write_config_dword(dev, offset, bar->val);
-               }
-               bar->which = 0;
-       }
+       bar->which = (value == ~0);
 
        return 0;
 }
@@ -125,6 +105,10 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
 static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data)
 {
        struct pci_bar_info *bar = data;
+       int idx = (offset - 0x10) >> 2;
+
+       if (idx > PCI_STD_RESOURCE_END )
+               idx = PCI_ROM_RESOURCE;
 
        if (unlikely(!bar)) {
                printk(KERN_WARNING "pciback: driver data not found for %s\n",
@@ -132,7 +116,8 @@ static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data)
                return XEN_PCI_ERR_op_failed;
        }
 
-       *value = bar->which ? bar->len_val : bar->val;
+       *value = bar->which ? ~(pci_resource_len(dev, idx)-1) : pci_resource_start(dev, idx);
+       *value |= pci_resource_flags(dev, idx) & 0xf;
 
        return 0;
 }
@@ -193,6 +178,22 @@ static int interrupt_read(struct pci_dev *dev, int offset, u8 * value,
        return 0;
 }
 
+static int vendor_read(struct pci_dev *dev, int offset, u16 * value,
+                      void *data)
+{
+       *value = dev->vendor;
+
+       return 0;
+}
+
+static int device_read(struct pci_dev *dev, int offset, u16 * value,
+                      void *data)
+{
+       *value = dev->device;
+
+       return 0;
+}
+
 static int bist_write(struct pci_dev *dev, int offset, u8 value, void *data)
 {
        u8 cur_value;
@@ -211,6 +212,16 @@ static int bist_write(struct pci_dev *dev, int offset, u8 value, void *data)
 }
 
 static const struct config_field header_common[] = {
+       {
+        .offset    = PCI_VENDOR_ID,
+        .size      = 2,
+        .u.w.read  = vendor_read
+       },
+       {
+        .offset    = PCI_DEVICE_ID,
+        .size      = 2,
+        .u.w.read  = device_read
+       },
        {
         .offset    = PCI_COMMAND,
         .size      = 2,