]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/pciehp_pci.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / pciehp_pci.c
index 854aaea09e4db788bc048739ffbe9b20bc8e0140..9372a840b63dbd3d43147dca446c3f078455a2e5 100644 (file)
@@ -105,12 +105,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
        }
 
        /* Find Advanced Error Reporting Enhanced Capability */
-       pos = 256;
-       do {
-               pci_read_config_dword(dev, pos, &reg32);
-               if (PCI_EXT_CAP_ID(reg32) == PCI_EXT_CAP_ID_ERR)
-                       break;
-       } while ((pos = PCI_EXT_CAP_NEXT(reg32)));
+       pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
        if (!pos)
                return;
 
@@ -172,7 +167,7 @@ static void program_fw_provided_values(struct pci_dev *dev)
        }
 }
 
-static int pciehp_add_bridge(struct pci_dev *dev)
+static int __ref pciehp_add_bridge(struct pci_dev *dev)
 {
        struct pci_bus *parent = dev->bus;
        int pass, busnr, start = parent->secondary;
@@ -243,15 +238,20 @@ int pciehp_configure_device(struct slot *p_slot)
 
 int pciehp_unconfigure_device(struct slot *p_slot)
 {
-       int rc = 0;
+       int ret, rc = 0;
        int j;
        u8 bctl = 0;
+       u8 presence = 0;
        struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
+       u16 command;
 
        dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus,
                                p_slot->device);
+       ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence);
+       if (ret)
+               presence = 0;
 
-       for (j=0; j<8 ; j++) {
+       for (j = 0; j < 8; j++) {
                struct pci_dev* temp = pci_get_slot(parent,
                                (p_slot->device << 3) | j);
                if (!temp)
@@ -262,24 +262,33 @@ int pciehp_unconfigure_device(struct slot *p_slot)
                        pci_dev_put(temp);
                        continue;
                }
-               if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
+               if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) {
                        pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
                        if (bctl & PCI_BRIDGE_CTL_VGA) {
                                err("Cannot remove display device %s\n",
-                                               pci_name(temp));
+                                   pci_name(temp));
                                pci_dev_put(temp);
                                continue;
                        }
                }
                pci_remove_bus_device(temp);
+               /*
+                * Ensure that no new Requests will be generated from
+                * the device.
+                */
+               if (presence) {
+                       pci_read_config_word(temp, PCI_COMMAND, &command);
+                       command &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_SERR);
+                       command |= PCI_COMMAND_INTX_DISABLE;
+                       pci_write_config_word(temp, PCI_COMMAND, command);
+               }
                pci_dev_put(temp);
        }
-       /* 
+       /*
         * Some PCI Express root ports require fixup after hot-plug operation.
         */
-       if (pcie_mch_quirk) 
+       if (pcie_mch_quirk)
                pci_fixup_device(pci_fixup_final, p_slot->ctrl->pci_dev);
-       
+
        return rc;
 }
-