From ffeff788d6b10e342b4a887f28d339dfec1737f6 Mon Sep 17 00:00:00 2001 From: Kristen Accardi Date: Wed, 2 Nov 2005 16:24:32 -0800 Subject: [PATCH] pci: store PCI_INTERRUPT_PIN in pci_dev Store the value of the INTERRUPT_PIN in the pci_dev structure so that it can be retrieved later. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index fce2cb2112d8..2f82e63323f3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -571,6 +571,7 @@ static void pci_read_irq(struct pci_dev *dev) unsigned char irq; pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq); + dev->pin = irq; if (irq) pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); dev->irq = irq; -- cgit v1.2.3 From 8015a01486a0f789c9e98e8bf1f12a3ccb535b30 Mon Sep 17 00:00:00 2001 From: Kristen Accardi Date: Wed, 2 Nov 2005 16:24:35 -0800 Subject: [PATCH] apci: use pin stored in pci_dev Use the stored value of the Interrupt Pin, rather than try to read it again. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/pci_irq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 09567c2edcfb..e567c03b238e 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c @@ -361,8 +361,7 @@ acpi_pci_irq_derive(struct pci_dev *dev, if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { /* PC card has the same IRQ as its cardbridge */ - pci_read_config_byte(bridge, PCI_INTERRUPT_PIN, - &bridge_pin); + bridge_pin = bridge->pin; if (!bridge_pin) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", @@ -412,7 +411,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) if (!dev) return_VALUE(-EINVAL); - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + pin = dev->pin; if (!pin) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No interrupt pin configured for device %s\n", @@ -503,7 +502,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev) if (!dev || !dev->bus) return_VOID; - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + pin = dev->pin; if (!pin) return_VOID; pin--; -- cgit v1.2.3 From 514d207db1fa3c3d2bd7990ebed8d81cebc7875b Mon Sep 17 00:00:00 2001 From: Kristen Accardi Date: Wed, 2 Nov 2005 16:24:39 -0800 Subject: [PATCH] pci: use pin stored in pci_dev Use the stored value of the interrupt pin rather than try to read the config again. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8e287a828d5d..81b9b8d9bceb 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -587,7 +587,7 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) { u8 pin; - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); + pin = dev->pin; if (!pin) return -1; pin--; -- cgit v1.2.3 From 3efd273b4d52f0d3ae5ce61b2161cb3752f360a0 Mon Sep 17 00:00:00 2001 From: Kristen Accardi Date: Wed, 2 Nov 2005 16:55:49 -0800 Subject: [PATCH] pci: call pci_read_irq for bridges Call pci_read_irq() for bridges too, so that the pin value is stored for bridges that require interrupts. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2f82e63323f3..79be37a53397 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -625,6 +625,7 @@ static int pci_setup_device(struct pci_dev * dev) /* The PCI-to-PCI bridge spec requires that subtractive decoding (i.e. transparent) bridge must have programming interface code of 0x01. */ + pci_read_irq(dev); dev->transparent = ((dev->class & 0xff) == 1); pci_read_bases(dev, 2, PCI_ROM_ADDRESS1); break; -- cgit v1.2.3 From 8c9ad508c8737ca46a4c55b1062d159b86f7cee2 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 14 Nov 2005 20:30:50 +0300 Subject: [PATCH] PCIE: make bus_id for PCI Express devices unique The bus_id string must be unique for all devices of that bus in the system, not just for devices with the same parent - otherwise multiple symlinks with identical names appear in /sys/bus/pci_express/devices. Signed-off-by: Sergey Vlasov Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pcie/portdrv_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 467a4ceccf10..e4e5f1e8d816 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -238,8 +238,8 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev, device->driver = NULL; device->driver_data = NULL; device->release = release_pcie_device; /* callback to free pcie dev */ - sprintf(&device->bus_id[0], "pcie%02x", - get_descriptor_id(port_type, service_type)); + snprintf(device->bus_id, sizeof(device->bus_id), "%s:pcie%02x", + pci_name(parent), get_descriptor_id(port_type, service_type)); device->parent = &parent->dev; } -- cgit v1.2.3 From 88d69a1dff4014889782ebad24ed3e964a8844bc Mon Sep 17 00:00:00 2001 From: "Jordan, William P" Date: Mon, 21 Nov 2005 22:51:57 -0800 Subject: [PATCH] PCI Hotplug: ibmphp_pci.c copy-n-paste fix I noticed what appears to be a cut/paste error in drivers/pci/hotplug/ibmphp_pci.c: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/ibmphp_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c index b1ba429e0a2d..155133fe5c12 100644 --- a/drivers/pci/hotplug/ibmphp_pci.c +++ b/drivers/pci/hotplug/ibmphp_pci.c @@ -969,7 +969,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) debug ("io 32\n"); need_io_upper = TRUE; } - if ((io_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { + if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { debug ("pfmem 64\n"); need_pfmem_upper = TRUE; } -- cgit v1.2.3 From 2555f7bdd3b0db47f6e1d7bb887981654e2261b3 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 21 Nov 2005 00:05:21 +0100 Subject: [PATCH] PCI Hotplug: cpqphp_ctrl.c: remove dead code The Coverity checker spotted that we already did return -ENOMEM if (!p_mem_node). Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/cpqphp_ctrl.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 10a5a7674a8a..771ed34b1819 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c @@ -2630,29 +2630,15 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func hold_mem_node = NULL; } - /* If we have prefetchable memory resources copy them and - * fill in the bridge's memory range registers. Otherwise, - * fill in the range registers with values that disable them. */ - if (p_mem_node) { - memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource)); - p_mem_node->next = NULL; - - /* set Pre Mem base and Limit registers */ - temp_word = p_mem_node->base >> 16; - rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); - - temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16; - rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); - } else { - temp_word = 0xFFFF; - rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); + memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource)); + p_mem_node->next = NULL; - temp_word = 0x0000; - rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); + /* set Pre Mem base and Limit registers */ + temp_word = p_mem_node->base >> 16; + rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); - kfree(hold_p_mem_node); - hold_p_mem_node = NULL; - } + temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16; + rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); /* Adjust this to compensate for extra adjustment in first loop */ irqs.barber_pole--; -- cgit v1.2.3 From e00e57efa3448b18c0deedce32732e28683cb73d Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Fri, 25 Nov 2005 12:21:25 +0900 Subject: [PATCH] shpchp: replace pci_find_slot() with pci_get_slot() This patch replaces pci_find_slot() with pci_get_slot() in the SHPCHP driver. This enables SHPCHP driver to work on multiple PCI segment systems. Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp_pci.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 38009bc0fd5d..19e1a5e1e30b 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c @@ -89,10 +89,11 @@ int shpchp_configure_device(struct slot *p_slot) struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; int num, fn; - dev = pci_find_slot(p_slot->bus, PCI_DEVFN(p_slot->device, 0)); + dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); if (dev) { err("Device %s already exists at %x:%x, cannot hot-add\n", pci_name(dev), p_slot->bus, p_slot->device); + pci_dev_put(dev); return -EINVAL; } @@ -103,12 +104,13 @@ int shpchp_configure_device(struct slot *p_slot) } for (fn = 0; fn < 8; fn++) { - if (!(dev = pci_find_slot(p_slot->bus, - PCI_DEVFN(p_slot->device, fn)))) + dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); + if (!dev) continue; if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { err("Cannot hot-add display device %s\n", pci_name(dev)); + pci_dev_put(dev); continue; } if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || @@ -124,18 +126,21 @@ int shpchp_configure_device(struct slot *p_slot) } if (busnr >= end) { err("No free bus for hot-added bridge\n"); + pci_dev_put(dev); continue; } child = pci_add_new_bus(parent, dev, busnr); if (!child) { err("Cannot add new bus for %s\n", pci_name(dev)); + pci_dev_put(dev); continue; } child->subordinate = pci_do_scan_bus(child); pci_bus_size_bridges(child); } program_fw_provided_values(dev); + pci_dev_put(dev); } pci_bus_assign_resources(parent); @@ -149,17 +154,19 @@ int shpchp_unconfigure_device(struct slot *p_slot) int rc = 0; int j; u8 bctl = 0; - + struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; + dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus, p_slot->device); for (j=0; j<8 ; j++) { - struct pci_dev* temp = pci_find_slot(p_slot->bus, + struct pci_dev* temp = pci_get_slot(parent, (p_slot->device << 3) | j); if (!temp) continue; if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { err("Cannot remove display device %s\n", pci_name(temp)); + pci_dev_put(temp); continue; } if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { @@ -167,10 +174,12 @@ int shpchp_unconfigure_device(struct slot *p_slot) if (bctl & PCI_BRIDGE_CTL_VGA) { err("Cannot remove display device %s\n", pci_name(temp)); + pci_dev_put(temp); continue; } } pci_remove_bus_device(temp); + pci_dev_put(temp); } return rc; } -- cgit v1.2.3 From 6558b6ab145ceead45632e4214cd5ef14f48f412 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 24 Nov 2005 13:44:01 +0900 Subject: [PATCH] shpchp: fix improper reference to Slot Avail Regsister The hpc_get_max_bus_speed() function of the SHPCHP driver seems to refer wrong bits in the "Slot Avail Register I" and "Slot Avail Register II". This patch fixes this bug. And this also cleanup the code. Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp_hpc.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 9987a6fd65b8..3c1d3b4b0408 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -1121,7 +1121,6 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) int retval = 0; u8 pi; u32 slot_avail1, slot_avail2; - int slot_num; DBG_ENTER_ROUTINE @@ -1140,39 +1139,39 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2); if (pi == 2) { - if ((slot_num = ((slot_avail2 & SLOT_133MHZ_PCIX_533) >> 27) ) != 0 ) + if (slot_avail2 & SLOT_133MHZ_PCIX_533) bus_speed = PCIX_133MHZ_533; - else if ((slot_num = ((slot_avail2 & SLOT_100MHZ_PCIX_533) >> 23) ) != 0 ) + else if (slot_avail2 & SLOT_100MHZ_PCIX_533) bus_speed = PCIX_100MHZ_533; - else if ((slot_num = ((slot_avail2 & SLOT_66MHZ_PCIX_533) >> 19) ) != 0 ) + else if (slot_avail2 & SLOT_66MHZ_PCIX_533) bus_speed = PCIX_66MHZ_533; - else if ((slot_num = ((slot_avail2 & SLOT_133MHZ_PCIX_266) >> 15) ) != 0 ) + else if (slot_avail2 & SLOT_133MHZ_PCIX_266) bus_speed = PCIX_133MHZ_266; - else if ((slot_num = ((slot_avail2 & SLOT_100MHZ_PCIX_266) >> 11) ) != 0 ) + else if (slot_avail2 & SLOT_100MHZ_PCIX_266) bus_speed = PCIX_100MHZ_266; - else if ((slot_num = ((slot_avail2 & SLOT_66MHZ_PCIX_266) >> 7) ) != 0 ) + else if (slot_avail2 & SLOT_66MHZ_PCIX_266) bus_speed = PCIX_66MHZ_266; - else if ((slot_num = ((slot_avail1 & SLOT_133MHZ_PCIX) >> 23) ) != 0 ) + else if (slot_avail1 & SLOT_133MHZ_PCIX) bus_speed = PCIX_133MHZ; - else if ((slot_num = ((slot_avail1 & SLOT_100MHZ_PCIX) >> 15) ) != 0 ) + else if (slot_avail1 & SLOT_100MHZ_PCIX) bus_speed = PCIX_100MHZ; - else if ((slot_num = ((slot_avail1 & SLOT_66MHZ_PCIX) >> 7) ) != 0 ) + else if (slot_avail1 & SLOT_66MHZ_PCIX) bus_speed = PCIX_66MHZ; - else if ((slot_num = (slot_avail2 & SLOT_66MHZ)) != 0 ) + else if (slot_avail2 & SLOT_66MHZ) bus_speed = PCI_66MHZ; - else if ((slot_num = (slot_avail1 & SLOT_33MHZ)) != 0 ) + else if (slot_avail1 & SLOT_33MHZ) bus_speed = PCI_33MHZ; else bus_speed = PCI_SPEED_UNKNOWN; } else { - if ((slot_num = ((slot_avail1 & SLOT_133MHZ_PCIX) >> 23) ) != 0 ) + if (slot_avail1 & SLOT_133MHZ_PCIX) bus_speed = PCIX_133MHZ; - else if ((slot_num = ((slot_avail1 & SLOT_100MHZ_PCIX) >> 15) ) != 0 ) + else if (slot_avail1 & SLOT_100MHZ_PCIX) bus_speed = PCIX_100MHZ; - else if ((slot_num = ((slot_avail1 & SLOT_66MHZ_PCIX) >> 7) ) != 0 ) + else if (slot_avail1 & SLOT_66MHZ_PCIX) bus_speed = PCIX_66MHZ; - else if ((slot_num = (slot_avail2 & SLOT_66MHZ)) != 0 ) + else if (slot_avail2 & SLOT_66MHZ) bus_speed = PCI_66MHZ; - else if ((slot_num = (slot_avail1 & SLOT_33MHZ)) != 0 ) + else if (slot_avail1 & SLOT_33MHZ) bus_speed = PCI_33MHZ; else bus_speed = PCI_SPEED_UNKNOWN; } -- cgit v1.2.3 From 87d6c5593111844f308af7d5106b3fd259b36514 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 24 Nov 2005 11:35:05 +0900 Subject: [PATCH] shpchp: fix improper reference to Mode 1 ECC Capability" bit The hpc_get_mode1_ECC_cap() function of SHPCHP driver seems to refer the wrong bit for refering the "Mode 1 ECC Capability" bit. This bug seems not to cause any problem so far. But I think this should be fixed. This patch fixes this bug. Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp_hpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index 3c1d3b4b0408..f5a8bf374634 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -604,7 +604,7 @@ static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode) sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG); if (pi == 2) { - *mode = (sec_bus_status & 0x0100) >> 7; + *mode = (sec_bus_status & 0x0100) >> 8; } else { retval = -1; } -- cgit v1.2.3 From 0455986cce45d28511f59a29d6cecc17d6b65720 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 24 Nov 2005 11:36:59 +0900 Subject: [PATCH] shpchp: fix improper mmio mapping Current SHPCHP driver seems not to map MMIO region properly. This patch fixes this bug. This patch also cleanup the code. Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp.h | 3 ++ drivers/pci/hotplug/shpchp_core.c | 2 -- drivers/pci/hotplug/shpchp_hpc.c | 73 ++++++++++++++++++++++++--------------- 3 files changed, 49 insertions(+), 29 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 08ad26a0cae7..55b0cd15f348 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h @@ -98,6 +98,9 @@ struct controller { enum pci_bus_speed speed; u32 first_slot; /* First physical slot number */ u8 slot_bus; /* Bus where the slots handled by this controller sit */ + u32 cap_offset; + unsigned long mmio_base; + unsigned long mmio_size; }; struct hotplug_params { diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 63628e01dd43..d81f8a75b495 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c @@ -377,8 +377,6 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_free_ctrl; } - ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ - pci_set_drvdata(pdev, ctrl); ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index f5a8bf374634..d82987f075b2 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -791,7 +791,7 @@ static void hpc_release_ctlr(struct controller *ctrl) } if (php_ctlr->pci_dev) { iounmap(php_ctlr->creg); - release_mem_region(pci_resource_start(php_ctlr->pci_dev, 0), pci_resource_len(php_ctlr->pci_dev, 0)); + release_mem_region(ctrl->mmio_base, ctrl->mmio_size); php_ctlr->pci_dev = NULL; } @@ -1320,19 +1320,34 @@ static struct hpc_ops shpchp_hpc_ops = { .check_cmd_status = hpc_check_cmd_status, }; +inline static int shpc_indirect_creg_read(struct controller *ctrl, int index, + u32 *value) +{ + int rc; + u32 cap_offset = ctrl->cap_offset; + struct pci_dev *pdev = ctrl->pci_dev; + + rc = pci_write_config_byte(pdev, cap_offset + DWORD_SELECT, index); + if (rc) + return rc; + return pci_read_config_dword(pdev, cap_offset + DWORD_DATA, value); +} + int shpc_init(struct controller * ctrl, struct pci_dev * pdev) { struct php_ctlr_state_s *php_ctlr, *p; void *instance_id = ctrl; - int rc; + int rc, num_slots = 0; u8 hp_slot; static int first = 1; - u32 shpc_cap_offset, shpc_base_offset; + u32 shpc_base_offset; u32 tempdword, slot_reg; u8 i; DBG_ENTER_ROUTINE + ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ + spin_lock_init(&list_lock); php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); @@ -1347,41 +1362,45 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device == PCI_DEVICE_ID_AMD_GOLAM_7450)) { - shpc_base_offset = 0; /* amd shpc driver doesn't use this; assume 0 */ + /* amd shpc driver doesn't use Base Offset; assume 0 */ + ctrl->mmio_base = pci_resource_start(pdev, 0); + ctrl->mmio_size = pci_resource_len(pdev, 0); } else { - if ((shpc_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC)) == 0) { - err("%s : shpc_cap_offset == 0\n", __FUNCTION__); + ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC); + if (!ctrl->cap_offset) { + err("%s : cap_offset == 0\n", __FUNCTION__); goto abort_free_ctlr; } - dbg("%s: shpc_cap_offset = %x\n", __FUNCTION__, shpc_cap_offset); - - rc = pci_write_config_byte(pdev, (u8)shpc_cap_offset + DWORD_SELECT , BASE_OFFSET); + dbg("%s: cap_offset = %x\n", __FUNCTION__, ctrl->cap_offset); + + rc = shpc_indirect_creg_read(ctrl, 0, &shpc_base_offset); if (rc) { - err("%s : pci_word_config_byte failed\n", __FUNCTION__); + err("%s: cannot read base_offset\n", __FUNCTION__); goto abort_free_ctlr; } - - rc = pci_read_config_dword(pdev, (u8)shpc_cap_offset + DWORD_DATA, &shpc_base_offset); + + rc = shpc_indirect_creg_read(ctrl, 3, &tempdword); if (rc) { - err("%s : pci_read_config_dword failed\n", __FUNCTION__); + err("%s: cannot read slot config\n", __FUNCTION__); goto abort_free_ctlr; } + num_slots = tempdword & SLOT_NUM; + dbg("%s: num_slots (indirect) %x\n", __FUNCTION__, num_slots); - for (i = 0; i <= 14; i++) { - rc = pci_write_config_byte(pdev, (u8)shpc_cap_offset + DWORD_SELECT , i); - if (rc) { - err("%s : pci_word_config_byte failed\n", __FUNCTION__); - goto abort_free_ctlr; - } - - rc = pci_read_config_dword(pdev, (u8)shpc_cap_offset + DWORD_DATA, &tempdword); + for (i = 0; i < 9 + num_slots; i++) { + rc = shpc_indirect_creg_read(ctrl, i, &tempdword); if (rc) { - err("%s : pci_read_config_dword failed\n", __FUNCTION__); + err("%s: cannot read creg (index = %d)\n", + __FUNCTION__, i); goto abort_free_ctlr; } dbg("%s: offset %d: value %x\n", __FUNCTION__,i, tempdword); } + + ctrl->mmio_base = + pci_resource_start(pdev, 0) + shpc_base_offset; + ctrl->mmio_size = 0x24 + 0x4 * num_slots; } if (first) { @@ -1395,16 +1414,16 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev) if (pci_enable_device(pdev)) goto abort_free_ctlr; - if (!request_mem_region(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0), MY_NAME)) { + if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { err("%s: cannot reserve MMIO region\n", __FUNCTION__); goto abort_free_ctlr; } - php_ctlr->creg = ioremap(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0)); + php_ctlr->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size); if (!php_ctlr->creg) { - err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, pci_resource_len(pdev, 0), - pci_resource_start(pdev, 0) + shpc_base_offset); - release_mem_region(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0)); + err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, + ctrl->mmio_size, ctrl->mmio_base); + release_mem_region(ctrl->mmio_base, ctrl->mmio_size); goto abort_free_ctlr; } dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); -- cgit v1.2.3 From f467f6187fc60c954a9509b3a3e17ef89a4f6f22 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Thu, 24 Nov 2005 11:39:29 +0900 Subject: [PATCH] shpchp: fix improper write to Command Completion Detect bit Current SHPCHP driver writes a '0' to the Command Completion Detect bit to clear the Command Complete Interrupt Pending. But according to the SHPC spec (See 4.7.3.1 System Interrupts), SHPCHP driver must write '1'. This patch fixes this bug. Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp_hpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index d82987f075b2..f25e11645071 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -1058,11 +1058,11 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) if (intr_loc & 0x0001) { /* * Command Complete Interrupt Pending - * RO only - clear by writing 0 to the Command Completion + * RO only - clear by writing 1 to the Command Completion * Detect bit in Controller SERR-INT register */ temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); - temp_dword &= 0xfffeffff; + temp_dword &= 0xfffdffff; writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); wake_up_interruptible(&ctrl->queue); } -- cgit v1.2.3 From bd62e271401c5ebf33a0dd24d89baf706f213251 Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Fri, 25 Nov 2005 12:28:53 +0900 Subject: [PATCH] shpchp: fix improper wait for command completion Current SHPCHP driver uses msleep_interruptible() function to wait for a command completion event. But I think this would cause an unnecessary long wait until timeout, if command completion interrupt came before task state was changed to TASK_INTERRUPTIBLE. This patch fixes this issue. With this patch, command completion becomes faster as follows: o Without this patch # time echo 1 > power real 0m4.708s user 0m0.000s sys 0m0.524s o With this patch # time echo 1 > power real 0m2.221s user 0m0.000s sys 0m0.532s Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp.h | 1 + drivers/pci/hotplug/shpchp_ctrl.c | 37 ------------------------------------- drivers/pci/hotplug/shpchp_hpc.c | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index 55b0cd15f348..ce0e9b6ce833 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h @@ -101,6 +101,7 @@ struct controller { u32 cap_offset; unsigned long mmio_base; unsigned long mmio_size; + volatile int cmd_busy; }; struct hotplug_params { diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c index 58619359ad08..25ccb0e47593 100644 --- a/drivers/pci/hotplug/shpchp_ctrl.c +++ b/drivers/pci/hotplug/shpchp_ctrl.c @@ -248,7 +248,6 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot, up(&ctrl->crit_sect); return WRONG_BUS_FREQUENCY; } - wait_for_ctrl_irq (ctrl); if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", @@ -330,9 +329,6 @@ static int board_added(struct slot *p_slot) up(&ctrl->crit_sect); return -1; } - - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); rc = p_slot->hpc_ops->check_cmd_status(ctrl); if (rc) { @@ -352,7 +348,6 @@ static int board_added(struct slot *p_slot) up(&ctrl->crit_sect); return WRONG_BUS_FREQUENCY; } - wait_for_ctrl_irq (ctrl); if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", @@ -367,7 +362,6 @@ static int board_added(struct slot *p_slot) up(&ctrl->crit_sect); return rc; } - wait_for_ctrl_irq (ctrl); if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); @@ -494,7 +488,6 @@ static int board_added(struct slot *p_slot) up(&ctrl->crit_sect); return rc; } - wait_for_ctrl_irq (ctrl); if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); @@ -532,9 +525,6 @@ static int board_added(struct slot *p_slot) p_slot->hpc_ops->green_led_on(p_slot); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); - /* Done with exclusive hardware access */ up(&ctrl->crit_sect); @@ -552,8 +542,6 @@ err_exit: up(&ctrl->crit_sect); return rc; } - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); rc = p_slot->hpc_ops->check_cmd_status(ctrl); if (rc) { @@ -603,8 +591,6 @@ static int remove_board(struct slot *p_slot) up(&ctrl->crit_sect); return rc; } - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); rc = p_slot->hpc_ops->check_cmd_status(ctrl); if (rc) { @@ -621,8 +607,6 @@ static int remove_board(struct slot *p_slot) up(&ctrl->crit_sect); return rc; } - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); /* Done with exclusive hardware access */ up(&ctrl->crit_sect); @@ -676,9 +660,6 @@ static void shpchp_pushbutton_thread (unsigned long slot) p_slot->hpc_ops->green_led_off(p_slot); - /* Wait for the command to complete */ - wait_for_ctrl_irq (p_slot->ctrl); - /* Done with exclusive hardware access */ up(&p_slot->ctrl->crit_sect); } @@ -790,14 +771,9 @@ static void interrupt_event_handler(struct controller *ctrl) down(&ctrl->crit_sect); p_slot->hpc_ops->green_led_on(p_slot); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); p_slot->hpc_ops->set_attention_status(p_slot, 0); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); - /* Done with exclusive hardware access */ up(&ctrl->crit_sect); break; @@ -806,12 +782,8 @@ static void interrupt_event_handler(struct controller *ctrl) down(&ctrl->crit_sect); p_slot->hpc_ops->green_led_off(p_slot); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); p_slot->hpc_ops->set_attention_status(p_slot, 0); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); /* Done with exclusive hardware access */ up(&ctrl->crit_sect); @@ -845,14 +817,9 @@ static void interrupt_event_handler(struct controller *ctrl) /* blink green LED and turn off amber */ p_slot->hpc_ops->green_led_blink(p_slot); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); p_slot->hpc_ops->set_attention_status(p_slot, 0); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); - /* Done with exclusive hardware access */ up(&ctrl->crit_sect); @@ -870,12 +837,8 @@ static void interrupt_event_handler(struct controller *ctrl) down(&ctrl->crit_sect); p_slot->hpc_ops->set_attention_status(p_slot, 1); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); p_slot->hpc_ops->green_led_off(p_slot); - /* Wait for the command to complete */ - wait_for_ctrl_irq (ctrl); /* Done with exclusive hardware access */ up(&ctrl->crit_sect); diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c index f25e11645071..b4226ff3a854 100644 --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -275,6 +275,25 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds) return; } +static inline int shpc_wait_cmd(struct controller *ctrl) +{ + int retval = 0; + unsigned int timeout_msec = shpchp_poll_mode ? 2000 : 1000; + unsigned long timeout = msecs_to_jiffies(timeout_msec); + int rc = wait_event_interruptible_timeout(ctrl->queue, + !ctrl->cmd_busy, timeout); + if (!rc) { + retval = -EIO; + err("Command not completed in %d msec\n", timeout_msec); + } else if (rc < 0) { + retval = -EINTR; + info("Command was interrupted by a signal\n"); + } + ctrl->cmd_busy = 0; + + return retval; +} + static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) { struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; @@ -314,8 +333,14 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) /* To make sure the Controller Busy bit is 0 before we send out the * command. */ + slot->ctrl->cmd_busy = 1; writew(temp_word, php_ctlr->creg + CMD); + /* + * Wait for command completion. + */ + retval = shpc_wait_cmd(slot->ctrl); + DBG_LEAVE_ROUTINE return retval; } @@ -1064,6 +1089,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs) temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); temp_dword &= 0xfffdffff; writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); + ctrl->cmd_busy = 0; wake_up_interruptible(&ctrl->queue); } -- cgit v1.2.3 From d681db4aed4453c7d34adfbb64956271186514e9 Mon Sep 17 00:00:00 2001 From: "linas@austin.ibm.com" Date: Thu, 1 Dec 2005 18:56:14 -0600 Subject: [PATCH] PCI Hotplug/powerpc: remove duplicated code The RPAPHP code contains a routine that duplicates some existing code. This patch removes the rpaphp version of the code. Signed-off-by: Linas Vepstas Acked-by: John Rose Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/rpadlpar_core.c | 3 ++- drivers/pci/hotplug/rpaphp_pci.c | 14 +------------- 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index cc03609f45d0..0173641c4149 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -154,7 +154,8 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) struct pci_controller *phb = pdn->phb; struct pci_dev *dev = NULL; - rpaphp_eeh_init_nodes(dn); + eeh_add_device_tree_early(dn); + /* Add EADS device to PHB bus, adding new entry to bus->devices */ dev = of_create_pci_dev(dn, phb->bus, pdn->devfn); if (!dev) { diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 4b35097b3d9f..fc2368710cf7 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -287,18 +287,6 @@ rpaphp_pci_config_slot(struct pci_bus *bus) return dev; } -void rpaphp_eeh_init_nodes(struct device_node *dn) -{ - struct device_node *sib; - - for (sib = dn->child; sib; sib = sib->sibling) - rpaphp_eeh_init_nodes(sib); - eeh_add_device_early(dn); - return; - -} -EXPORT_SYMBOL_GPL(rpaphp_eeh_init_nodes); - static void print_slot_pci_funcs(struct pci_bus *bus) { struct device_node *dn; @@ -324,7 +312,7 @@ int rpaphp_config_pci_adapter(struct pci_bus *bus) if (!dn) goto exit; - rpaphp_eeh_init_nodes(dn); + eeh_add_device_tree_early(dn); dev = rpaphp_pci_config_slot(bus); if (!dev) { err("%s: can't find any devices.\n", __FUNCTION__); -- cgit v1.2.3 From cd5b50be8d8e8e6170da3a261fc625fd603f9dc4 Mon Sep 17 00:00:00 2001 From: "linas@austin.ibm.com" Date: Thu, 1 Dec 2005 18:59:58 -0600 Subject: [PATCH] PCI Hotplug/powerpc: more removal of duplicated code The RPAPHP code contains two routines that appear to be gratuitous copies of very similar pci code. In particular, rpaphp_claim_resource ~~ pci_claim_resource (there is a minor, non-functional difference) rpadlpar_claim_one_bus == pcibios_claim_one_bus (the code is identical) This patch removes the rpaphp versions of the code. Signed-off-by: Linas Vepstas Acked-by: John Rose Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/rpadlpar_core.c | 24 +----------------------- drivers/pci/hotplug/rpaphp_pci.c | 24 +----------------------- 2 files changed, 2 insertions(+), 46 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 0173641c4149..7d93dbaf628d 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -112,28 +112,6 @@ static struct slot *find_slot(struct device_node *dn) return NULL; } -static void rpadlpar_claim_one_bus(struct pci_bus *b) -{ - struct list_head *ld; - struct pci_bus *child_bus; - - for (ld = b->devices.next; ld != &b->devices; ld = ld->next) { - struct pci_dev *dev = pci_dev_b(ld); - int i; - - for (i = 0; i < PCI_NUM_RESOURCES; i++) { - struct resource *r = &dev->resource[i]; - - if (r->parent || !r->start || !r->flags) - continue; - rpaphp_claim_resource(dev, i); - } - } - - list_for_each_entry(child_bus, &b->children, node) - rpadlpar_claim_one_bus(child_bus); -} - static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, struct device_node *dev_dn) { @@ -171,7 +149,7 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) rpaphp_init_new_devs(dev->subordinate); /* Claim new bus resources */ - rpadlpar_claim_one_bus(dev->bus); + pcibios_claim_one_bus(dev->bus); /* ioremap() for child bus, which may or may not succeed */ (void) remap_bus_range(dev->bus); diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index fc2368710cf7..6f21c73be3c0 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -62,28 +62,6 @@ struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn) } EXPORT_SYMBOL_GPL(rpaphp_find_pci_bus); -int rpaphp_claim_resource(struct pci_dev *dev, int resource) -{ - struct resource *res = &dev->resource[resource]; - struct resource *root = pci_find_parent_resource(dev, res); - char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge"; - int err = -EINVAL; - - if (root != NULL) { - err = request_resource(root, res); - } - - if (err) { - err("PCI: %s region %d of %s %s [%lx:%lx]\n", - root ? "Address space collision on" : - "No parent found for", - resource, dtype, pci_name(dev), res->start, res->end); - } - return err; -} - -EXPORT_SYMBOL_GPL(rpaphp_claim_resource); - static int rpaphp_get_sensor_state(struct slot *slot, int *state) { int rc; @@ -177,7 +155,7 @@ void rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus) if (r->parent || !r->start || !r->flags) continue; - rpaphp_claim_resource(dev, i); + pci_claim_resource(dev, i); } } } -- cgit v1.2.3 From 81f154427c0c50b6492d454abf98e15c1c2e354e Mon Sep 17 00:00:00 2001 From: Kenji Kaneshige Date: Mon, 5 Dec 2005 19:31:00 +0900 Subject: [PATCH] shpchp: Implement get_address callback The following patch implements .get_address callback of hotplug_slot_ops for SHPCHP driver. With this patch, we can see bus address of hotplug slots as follows: $ cat address 0000:0b:01 Signed-off-by: Kenji Kaneshige Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp_core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers') diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index d81f8a75b495..a2b3f0010cec 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c @@ -65,6 +65,7 @@ static int get_power_status (struct hotplug_slot *slot, u8 *value); static int get_attention_status (struct hotplug_slot *slot, u8 *value); static int get_latch_status (struct hotplug_slot *slot, u8 *value); static int get_adapter_status (struct hotplug_slot *slot, u8 *value); +static int get_address (struct hotplug_slot *slot, u32 *value); static int get_max_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); static int get_cur_bus_speed (struct hotplug_slot *slot, enum pci_bus_speed *value); @@ -77,6 +78,7 @@ static struct hotplug_slot_ops shpchp_hotplug_slot_ops = { .get_attention_status = get_attention_status, .get_latch_status = get_latch_status, .get_adapter_status = get_adapter_status, + .get_address = get_address, .get_max_bus_speed = get_max_bus_speed, .get_cur_bus_speed = get_cur_bus_speed, }; @@ -314,6 +316,18 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) return 0; } +static int get_address (struct hotplug_slot *hotplug_slot, u32 *value) +{ + struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); + struct pci_bus *bus = slot->ctrl->pci_dev->subordinate; + + dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); + + *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device; + + return 0; +} + static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value) { struct slot *slot = get_slot (hotplug_slot, __FUNCTION__); -- cgit v1.2.3 From 9d265124d051c2cf6716639239609d83f736dcdb Mon Sep 17 00:00:00 2001 From: Daniel Yeisley Date: Mon, 5 Dec 2005 07:06:43 -0500 Subject: [PATCH] PCI Quirk: 1K I/O space granularity on Intel P64H2 I've implemented a quirk to take advantage of the 1KB I/O space granularity option on the Intel P64H2 PCI Bridge. I had to change probe.c because it sets the resource start and end to be aligned on 4k boundaries (after the quirk sets them to 1k boundaries). I've tested this patch on a Unisys ES7000-600 both with and without the 1KB option enabled. I also tested this on a 2 processor Dell box that doesn't have a P64H2 to make sure there were no negative affects there. Signed-off-by: Dan Yeisley Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 6 ++++-- drivers/pci/quirks.c | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 79be37a53397..00ba6a03dca5 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -264,8 +264,10 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) if (base <= limit) { res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; - res->start = base; - res->end = limit + 0xfff; + if (!res->start) + res->start = base; + if (!res->end) + res->end = limit + 0xfff; } res = child->resource[1]; diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index f28ebdd3958a..605f0df0bfba 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1342,6 +1342,32 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) pci_do_fixups(dev, start, end); } +/* Enable 1k I/O space granularity on the Intel P64H2 */ +static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev) +{ + u16 en1k; + u8 io_base_lo, io_limit_lo; + unsigned long base, limit; + struct resource *res = dev->resource + PCI_BRIDGE_RESOURCES; + + pci_read_config_word(dev, 0x40, &en1k); + + if (en1k & 0x200) { + printk(KERN_INFO "PCI: Enable I/O Space to 1 KB Granularity\n"); + + pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); + pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); + base = (io_base_lo & (PCI_IO_RANGE_MASK | 0x0c)) << 8; + limit = (io_limit_lo & (PCI_IO_RANGE_MASK | 0x0c)) << 8; + + if (base <= limit) { + res->start = base; + res->end = limit + 0x3ff; + } + } +} +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io); + EXPORT_SYMBOL(pcie_mch_quirk); #ifdef CONFIG_HOTPLUG EXPORT_SYMBOL(pci_fixup_device); -- cgit v1.2.3 From c7ab337f91b59f71a30c3ab71e3bdfff41671977 Mon Sep 17 00:00:00 2001 From: Thomas Schaefer Date: Thu, 8 Dec 2005 11:55:57 -0800 Subject: [PATCH] pciehp: handle sticky power-fault status This patch disables power fault, MRL sensor and presence detection interrupts when a PCIe slot is powered-off and enables those interrupts when it is powered-on again. This is necessary to prevent the associated events from causing an endless cycle of interrupts due to the power-fault bit, which stays set till power is restored to the slot. Signed-off-by: Thomas Schaefer Signed-off-by: Rajesh Shah Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp_hpc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index ac1e495c314e..77e530321de2 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -787,8 +787,13 @@ static int hpc_power_on_slot(struct slot * slot) slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; + /* Enable detection that we turned off at slot power-off time */ if (!pciehp_poll_mode) - slot_cmd = slot_cmd | HP_INTR_ENABLE; + slot_cmd = slot_cmd | + PWR_FAULT_DETECT_ENABLE | + MRL_DETECT_ENABLE | + PRSN_DETECT_ENABLE | + HP_INTR_ENABLE; retval = pcie_write_cmd(slot, slot_cmd); @@ -833,8 +838,18 @@ static int hpc_power_off_slot(struct slot * slot) slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; + /* + * If we get MRL or presence detect interrupts now, the isr + * will notice the sticky power-fault bit too and issue power + * indicator change commands. This will lead to an endless loop + * of command completions, since the power-fault bit remains on + * till the slot is powered on again. + */ if (!pciehp_poll_mode) - slot_cmd = slot_cmd | HP_INTR_ENABLE; + slot_cmd = (slot_cmd & + ~PWR_FAULT_DETECT_ENABLE & + ~MRL_DETECT_ENABLE & + ~PRSN_DETECT_ENABLE) | HP_INTR_ENABLE; retval = pcie_write_cmd(slot, slot_cmd); -- cgit v1.2.3 From 0eb3bcfd088e3234f7af29e189a7900ccfdd278a Mon Sep 17 00:00:00 2001 From: Rajesh Shah Date: Thu, 8 Dec 2005 12:12:25 -0800 Subject: [PATCH] pciehp: allow bridged card hotplug This patch fixes bugs in the pciehp driver that prevent hot-add of a card with PCI bridges on it. Signed-off-by: Rajesh Shah Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp_pci.c | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 647673a7d224..4017fb03a0b8 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c @@ -34,6 +34,31 @@ #include "../pci.h" #include "pciehp.h" +static int pciehp_add_bridge(struct pci_dev *dev) +{ + struct pci_bus *parent = dev->bus; + int pass, busnr, start = parent->secondary; + int end = parent->subordinate; + + for (busnr = start; busnr <= end; busnr++) { + if (!pci_find_bus(pci_domain_nr(parent), busnr)) + break; + } + if (busnr-- > end) { + err("No bus number available for hot-added bridge %s\n", + pci_name(dev)); + return -1; + } + for (pass = 0; pass < 2; pass++) + busnr = pci_scan_bridge(parent, dev, busnr, pass); + if (!dev->subordinate) + return -1; + pci_bus_size_bridges(dev->subordinate); + pci_bus_assign_resources(parent); + pci_enable_bridges(parent); + pci_bus_add_devices(parent); + return 0; +} int pciehp_configure_device(struct slot *p_slot) { @@ -55,8 +80,8 @@ int pciehp_configure_device(struct slot *p_slot) } for (fn = 0; fn < 8; fn++) { - if (!(dev = pci_find_slot(p_slot->bus, - PCI_DEVFN(p_slot->device, fn)))) + dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); + if (!dev) continue; if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { err("Cannot hot-add display device %s\n", @@ -65,27 +90,7 @@ int pciehp_configure_device(struct slot *p_slot) } if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { - /* Find an unused bus number for the new bridge */ - struct pci_bus *child; - unsigned char busnr, start = parent->secondary; - unsigned char end = parent->subordinate; - for (busnr = start; busnr <= end; busnr++) { - if (!pci_find_bus(pci_domain_nr(parent), - busnr)) - break; - } - if (busnr >= end) { - err("No free bus for hot-added bridge\n"); - continue; - } - child = pci_add_new_bus(parent, dev, busnr); - if (!child) { - err("Cannot add new bus for %s\n", - pci_name(dev)); - continue; - } - child->subordinate = pci_do_scan_bus(child); - pci_bus_size_bridges(child); + pciehp_add_bridge(dev); } /* TBD: program firmware provided _HPP values */ /* program_fw_provided_values(dev); */ @@ -93,7 +98,6 @@ int pciehp_configure_device(struct slot *p_slot) pci_bus_assign_resources(parent); pci_bus_add_devices(parent); - pci_enable_bridges(parent); return 0; } -- cgit v1.2.3 From 498879417756effe6dc385ee04645a83d724fdef Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 8 Dec 2005 16:53:12 +0100 Subject: [PATCH] PCI: use bus numbers sparsely, if necessary Add a warning if a child bus may be inaccessible because the parent bridge has wrong secondary or subordinate bus numbers. Note that this may or may not happen on "transparent" bridges, as can be seen in bug #5557. Also, if we do not fix up the assignment of bus numbers, try to make use of the bus number space available. Signed-off-by: Dominik Brodowski Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 00ba6a03dca5..3c9834d80850 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -433,7 +433,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max { struct pci_bus *child; int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); - u32 buses, i; + u32 buses, i, j = 0; u16 bctl; pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); @@ -543,10 +543,29 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max * as cards with a PCI-to-PCI bridge can be * inserted later. */ - for (i=0; iparent) { + if ((!pcibios_assign_all_busses()) && + (parent->subordinate > max) && + (parent->subordinate <= max+i)) { + j = 1; + } + parent = parent->parent; + } + if (j) { + /* + * Often, there are two cardbus bridges + * -- try to leave one valid bus number + * for each one. + */ + i /= 2; + break; + } + } max += i; pci_fixup_parent_subordinate_busnr(child, max); } @@ -561,6 +580,22 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); + while (bus->parent) { + if ((child->subordinate > bus->subordinate) || + (child->number > bus->subordinate) || + (child->number < bus->number) || + (child->subordinate < bus->number)) { + printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) may be " + "hidden behind%s bridge #%02x (-#%02x)%s\n", + child->number, child->subordinate, + bus->self->transparent ? " transparent" : " ", + bus->number, bus->subordinate, + pcibios_assign_all_busses() ? " " : + " (try 'pci=assign-busses')"); + } + bus = bus->parent; + } + return max; } -- cgit v1.2.3 From ac7dc65ac0b945270548414491efa9c4357417d9 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 13 Dec 2005 18:09:16 +1100 Subject: [PATCH] PCI: Export pci_cfg_space_size The powerpc PCI code sets up the PCI tree without doing config space accesses in most cases, from the firmware tree. However, it still wants to call pci_cfg_space_size() under some conditions, thus it needs to be made non-static (though I don't see a point to export it to modules). Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Greg Kroah-Hartman --- drivers/pci/probe.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 3c9834d80850..adfad4fd6a13 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -717,7 +717,7 @@ static void pci_release_dev(struct device *dev) * reading the dword at 0x100 which must either be 0 or a valid extended * capability header. */ -static int pci_cfg_space_size(struct pci_dev *dev) +int pci_cfg_space_size(struct pci_dev *dev) { int pos; u32 status; diff --git a/include/linux/pci.h b/include/linux/pci.h index b32f70fe2dbd..d0e003926744 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -449,6 +449,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), void *userdata); +int pci_cfg_space_size(struct pci_dev *dev); /* kmem_cache style wrapper around pci_alloc_consistent() */ -- cgit v1.2.3 From efbf62e9f4d93c3716a4d6d3221d537c71e299a2 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 11 Dec 2005 06:42:18 +0100 Subject: [PATCH] PCI: Reduce nr of ptr derefs in drivers/pci/hotplug/cpqphp_core.c Here's a small patch to reduce the nr of pointer dereferences in drivers/pci/hotplug/cpqphp_core.c Benefits of this patch: - micro speed optimization due to fewer pointer derefs - generated code is slightly smaller - tiny line length and whitespace cleanup - better readability Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/cpqphp_core.c | 121 +++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index 9aed8efe6a11..d3644709a035 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c @@ -327,7 +327,9 @@ static int ctrl_slot_setup(struct controller *ctrl, void __iomem *smbios_start, void __iomem *smbios_table) { - struct slot *new_slot; + struct slot *slot; + struct hotplug_slot *hotplug_slot; + struct hotplug_slot_info *hotplug_slot_info; u8 number_of_slots; u8 slot_device; u8 slot_number; @@ -345,93 +347,105 @@ static int ctrl_slot_setup(struct controller *ctrl, slot_number = ctrl->first_slot; while (number_of_slots) { - new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL); - if (!new_slot) + slot = kmalloc(sizeof(*slot), GFP_KERNEL); + if (!slot) goto error; - memset(new_slot, 0, sizeof(struct slot)); - new_slot->hotplug_slot = kmalloc(sizeof(*(new_slot->hotplug_slot)), + memset(slot, 0, sizeof(struct slot)); + slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)), GFP_KERNEL); - if (!new_slot->hotplug_slot) + if (!slot->hotplug_slot) goto error_slot; - memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); + hotplug_slot = slot->hotplug_slot; + memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); - new_slot->hotplug_slot->info = - kmalloc(sizeof(*(new_slot->hotplug_slot->info)), + hotplug_slot->info = + kmalloc(sizeof(*(hotplug_slot->info)), GFP_KERNEL); - if (!new_slot->hotplug_slot->info) + if (!hotplug_slot->info) goto error_hpslot; - memset(new_slot->hotplug_slot->info, 0, + hotplug_slot_info = hotplug_slot->info; + memset(hotplug_slot_info, 0, sizeof(struct hotplug_slot_info)); - new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); - if (!new_slot->hotplug_slot->name) + hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); + + if (!hotplug_slot->name) goto error_info; - new_slot->ctrl = ctrl; - new_slot->bus = ctrl->bus; - new_slot->device = slot_device; - new_slot->number = slot_number; - dbg("slot->number = %d\n",new_slot->number); + slot->ctrl = ctrl; + slot->bus = ctrl->bus; + slot->device = slot_device; + slot->number = slot_number; + dbg("slot->number = %d\n", slot->number); slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, slot_entry); - while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != new_slot->number)) { + while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != + slot->number)) { slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, slot_entry); } - new_slot->p_sm_slot = slot_entry; + slot->p_sm_slot = slot_entry; - init_timer(&new_slot->task_event); - new_slot->task_event.expires = jiffies + 5 * HZ; - new_slot->task_event.function = cpqhp_pushbutton_thread; + init_timer(&slot->task_event); + slot->task_event.expires = jiffies + 5 * HZ; + slot->task_event.function = cpqhp_pushbutton_thread; //FIXME: these capabilities aren't used but if they are // they need to be correctly implemented - new_slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; - new_slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; + slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; + slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; - if (is_slot64bit(new_slot)) - new_slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; - if (is_slot66mhz(new_slot)) - new_slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; + if (is_slot64bit(slot)) + slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; + if (is_slot66mhz(slot)) + slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; if (ctrl->speed == PCI_SPEED_66MHz) - new_slot->capabilities |= PCISLOT_66_MHZ_OPERATION; + slot->capabilities |= PCISLOT_66_MHZ_OPERATION; - ctrl_slot = slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); + ctrl_slot = + slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); // Check presence - new_slot->capabilities |= ((((~tempdword) >> 23) | ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; + slot->capabilities |= + ((((~tempdword) >> 23) | + ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; // Check the switch state - new_slot->capabilities |= ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; + slot->capabilities |= + ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; // Check the slot enable - new_slot->capabilities |= ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; + slot->capabilities |= + ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; /* register this slot with the hotplug pci core */ - new_slot->hotplug_slot->release = &release_slot; - new_slot->hotplug_slot->private = new_slot; - make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); - new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops; + hotplug_slot->release = &release_slot; + hotplug_slot->private = slot; + make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot); + hotplug_slot->ops = &cpqphp_hotplug_slot_ops; - new_slot->hotplug_slot->info->power_status = get_slot_enabled(ctrl, new_slot); - new_slot->hotplug_slot->info->attention_status = cpq_get_attention_status(ctrl, new_slot); - new_slot->hotplug_slot->info->latch_status = cpq_get_latch_status(ctrl, new_slot); - new_slot->hotplug_slot->info->adapter_status = get_presence_status(ctrl, new_slot); + hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); + hotplug_slot_info->attention_status = + cpq_get_attention_status(ctrl, slot); + hotplug_slot_info->latch_status = + cpq_get_latch_status(ctrl, slot); + hotplug_slot_info->adapter_status = + get_presence_status(ctrl, slot); - dbg ("registering bus %d, dev %d, number %d, " + dbg("registering bus %d, dev %d, number %d, " "ctrl->slot_device_offset %d, slot %d\n", - new_slot->bus, new_slot->device, - new_slot->number, ctrl->slot_device_offset, + slot->bus, slot->device, + slot->number, ctrl->slot_device_offset, slot_number); - result = pci_hp_register (new_slot->hotplug_slot); + result = pci_hp_register(hotplug_slot); if (result) { - err ("pci_hp_register failed with error %d\n", result); + err("pci_hp_register failed with error %d\n", result); goto error_name; } - new_slot->next = ctrl->slot; - ctrl->slot = new_slot; + slot->next = ctrl->slot; + ctrl->slot = slot; number_of_slots--; slot_device++; @@ -439,15 +453,14 @@ static int ctrl_slot_setup(struct controller *ctrl, } return 0; - error_name: - kfree(new_slot->hotplug_slot->name); + kfree(hotplug_slot->name); error_info: - kfree(new_slot->hotplug_slot->info); + kfree(hotplug_slot_info); error_hpslot: - kfree(new_slot->hotplug_slot); + kfree(hotplug_slot); error_slot: - kfree(new_slot); + kfree(slot); error: return result; } -- cgit v1.2.3 From f5c99dfc11dce8f26c1ceedb6595fa0eac335ea3 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 11 Dec 2005 06:42:38 +0100 Subject: [PATCH] PCI: Reduce nr of ptr derefs in drivers/pci/hotplug/rpaphp_pci.c Here's a small patch to reduce the nr. of pointer dereferences in drivers/pci/hotplug/rpaphp_pci.c Benefits: - micro speed optimization due to fewer pointer derefs - generated code should be slightly smaller - better readability note: due to lack of both hardware and cross-compile tools this patch is, unfortunately, completely untested. Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/rpaphp_pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c index 6f21c73be3c0..396b54b0c847 100644 --- a/drivers/pci/hotplug/rpaphp_pci.c +++ b/drivers/pci/hotplug/rpaphp_pci.c @@ -336,13 +336,14 @@ EXPORT_SYMBOL_GPL(rpaphp_unconfig_pci_adapter); static int setup_pci_hotplug_slot_info(struct slot *slot) { + struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info; + dbg("%s Initilize the PCI slot's hotplug->info structure ...\n", __FUNCTION__); - rpaphp_get_power_status(slot, &slot->hotplug_slot->info->power_status); + rpaphp_get_power_status(slot, &hotplug_slot_info->power_status); rpaphp_get_pci_adapter_status(slot, 1, - &slot->hotplug_slot->info-> - adapter_status); - if (slot->hotplug_slot->info->adapter_status == NOT_VALID) { + &hotplug_slot_info->adapter_status); + if (hotplug_slot_info->adapter_status == NOT_VALID) { err("%s: NOT_VALID: skip dn->full_name=%s\n", __FUNCTION__, slot->dn->full_name); return -EINVAL; -- cgit v1.2.3 From c2dea6553090a3fd06ffa9ba512a09fdac4d1b6e Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 11 Dec 2005 06:43:09 +0100 Subject: [PATCH] PCI: Reduce nr of ptr derefs in drivers/pci/hotplug/pciehprm_acpi.c Here's a small patch to reduce the nr. of pointer dereferences in drivers/pci/hotplug/pciehprm_acpi.c Benefits: - micro speed optimization due to fewer pointer derefs - generated code is slightly smaller - better readability Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehprm_acpi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c index ae244e218620..2bdb30f68bf8 100644 --- a/drivers/pci/hotplug/pciehprm_acpi.c +++ b/drivers/pci/hotplug/pciehprm_acpi.c @@ -174,7 +174,9 @@ int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) acpi_status status; acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); struct pci_dev *pdev = dev; + struct pci_bus *parent; u8 *path_name; + /* * Per PCI firmware specification, we should run the ACPI _OSC * method to get control of hotplug hardware before using it. @@ -190,17 +192,18 @@ int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) */ if (!pdev || !pdev->bus->parent) break; + parent = pdev->bus->parent; dbg("Could not find %s in acpi namespace, trying parent\n", pci_name(pdev)); - if (!pdev->bus->parent->self) + if (!parent->self) /* Parent must be a host bridge */ handle = acpi_get_pci_rootbridge_handle( - pci_domain_nr(pdev->bus->parent), - pdev->bus->parent->number); + pci_domain_nr(parent), + parent->number); else handle = DEVICE_ACPI_HANDLE( - &(pdev->bus->parent->self->dev)); - pdev = pdev->bus->parent->self; + &(parent->self->dev)); + pdev = parent->self; } while (handle) { -- cgit v1.2.3 From 121082e2ab09d5e90ac27e38900c018e6f37bcdf Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 11 Dec 2005 06:41:42 +0100 Subject: [PATCH] PCI: Reduce nr of ptr derefs in drivers/pci/hotplug/pciehp_core.c Here's a small patch to reduce the nr. of pointer dereferences in drivers/pci/hotplug/pciehp_core.c Benefits: - micro speed optimization due to fewer pointer derefs - generated code is slightly smaller - small line length cleanup - better readability Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp_core.c | 90 ++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 40 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 8df704860348..986e202e0b0b 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -103,7 +103,10 @@ static void release_slot(struct hotplug_slot *hotplug_slot) static int init_slots(struct controller *ctrl) { - struct slot *new_slot; + struct slot *slot; + struct hpc_ops *hpc_ops; + struct hotplug_slot *hotplug_slot; + struct hotplug_slot_info *hotplug_slot_info; u8 number_of_slots; u8 slot_device; u32 slot_number; @@ -114,59 +117,66 @@ static int init_slots(struct controller *ctrl) slot_number = ctrl->first_slot; while (number_of_slots) { - new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL); - if (!new_slot) + slot = kmalloc(sizeof(*slot), GFP_KERNEL); + if (!slot) goto error; - memset(new_slot, 0, sizeof(struct slot)); - new_slot->hotplug_slot = - kmalloc(sizeof(*(new_slot->hotplug_slot)), + memset(slot, 0, sizeof(struct slot)); + slot->hotplug_slot = + kmalloc(sizeof(*(slot->hotplug_slot)), GFP_KERNEL); - if (!new_slot->hotplug_slot) + if (!slot->hotplug_slot) goto error_slot; - memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); + hotplug_slot = slot->hotplug_slot; + memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); - new_slot->hotplug_slot->info = - kmalloc(sizeof(*(new_slot->hotplug_slot->info)), + hotplug_slot->info = + kmalloc(sizeof(*(hotplug_slot->info)), GFP_KERNEL); - if (!new_slot->hotplug_slot->info) + if (!hotplug_slot->info) goto error_hpslot; - memset(new_slot->hotplug_slot->info, 0, + hotplug_slot_info = hotplug_slot->info; + memset(hotplug_slot_info, 0, sizeof(struct hotplug_slot_info)); - new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, - GFP_KERNEL); - if (!new_slot->hotplug_slot->name) + hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); + if (!hotplug_slot->name) goto error_info; - new_slot->ctrl = ctrl; - new_slot->bus = ctrl->slot_bus; - new_slot->device = slot_device; - new_slot->hpc_ops = ctrl->hpc_ops; + slot->ctrl = ctrl; + slot->bus = ctrl->slot_bus; + slot->device = slot_device; + slot->hpc_ops = hpc_ops = ctrl->hpc_ops; - new_slot->number = ctrl->first_slot; - new_slot->hp_slot = slot_device - ctrl->slot_device_offset; + slot->number = ctrl->first_slot; + slot->hp_slot = slot_device - ctrl->slot_device_offset; /* register this slot with the hotplug pci core */ - new_slot->hotplug_slot->private = new_slot; - new_slot->hotplug_slot->release = &release_slot; - make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); - new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; - - new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); - new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status)); - new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status)); - new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status)); - - dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", - new_slot->bus, new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset); - result = pci_hp_register (new_slot->hotplug_slot); + hotplug_slot->private = slot; + hotplug_slot->release = &release_slot; + make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot); + hotplug_slot->ops = &pciehp_hotplug_slot_ops; + + hpc_ops->get_power_status(slot, + &(hotplug_slot_info->power_status)); + hpc_ops->get_attention_status(slot, + &(hotplug_slot_info->attention_status)); + hpc_ops->get_latch_status(slot, + &(hotplug_slot_info->latch_status)); + hpc_ops->get_adapter_status(slot, + &(hotplug_slot_info->adapter_status)); + + dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " + "slot_device_offset=%x\n", + slot->bus, slot->device, slot->hp_slot, slot->number, + ctrl->slot_device_offset); + result = pci_hp_register(hotplug_slot); if (result) { err ("pci_hp_register failed with error %d\n", result); goto error_name; } - new_slot->next = ctrl->slot; - ctrl->slot = new_slot; + slot->next = ctrl->slot; + ctrl->slot = slot; number_of_slots--; slot_device++; @@ -176,13 +186,13 @@ static int init_slots(struct controller *ctrl) return 0; error_name: - kfree(new_slot->hotplug_slot->name); + kfree(hotplug_slot->name); error_info: - kfree(new_slot->hotplug_slot->info); + kfree(hotplug_slot_info); error_hpslot: - kfree(new_slot->hotplug_slot); + kfree(hotplug_slot); error_slot: - kfree(new_slot); + kfree(slot); error: return result; } -- cgit v1.2.3 From 9f3f4681291fc88864bb27f8f3832b95bb53aae5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 14 Dec 2005 09:37:26 -0800 Subject: [PATCH] PCI Hotplug: fix up the sysfs file in the compaq pci hotplug driver The Compaq PCI Hotplug driver was creating 2 sysfs files that contained nothing but debug information, and had way more than "one value" in them. This patch converts the code to use debugfs for these files instead. Compile tested only. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/cpqphp.h | 8 ++- drivers/pci/hotplug/cpqphp_core.c | 6 +- drivers/pci/hotplug/cpqphp_sysfs.c | 138 +++++++++++++++++++++++++++++++------ 3 files changed, 127 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h index 092491e25ef2..cb88404c89fe 100644 --- a/drivers/pci/hotplug/cpqphp.h +++ b/drivers/pci/hotplug/cpqphp.h @@ -317,6 +317,7 @@ struct controller { u16 vendor_id; struct work_struct int_task_event; wait_queue_head_t queue; /* sleep & wake process */ + struct dentry *dentry; /* debugfs dentry */ }; struct irq_mapping { @@ -399,8 +400,11 @@ struct resource_lists { #define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" -/* sysfs functions for the hotplug controller info */ -extern void cpqhp_create_ctrl_files (struct controller *ctrl); +/* debugfs functions for the hotplug controller info */ +extern void cpqhp_initialize_debugfs (void); +extern void cpqhp_shutdown_debugfs (void); +extern void cpqhp_create_debugfs_files (struct controller *ctrl); +extern void cpqhp_remove_debugfs_files (struct controller *ctrl); /* controller functions */ extern void cpqhp_pushbutton_thread (unsigned long event_pointer); diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index d3644709a035..b3659ffccac9 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c @@ -479,6 +479,8 @@ static int ctrl_slot_cleanup (struct controller * ctrl) old_slot = next_slot; } + cpqhp_remove_debugfs_files(ctrl); + //Free IRQ associated with hot plug device free_irq(ctrl->interrupt, ctrl); //Unmap the memory @@ -1275,7 +1277,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) // Done with exclusive hardware access up(&ctrl->crit_sect); - cpqhp_create_ctrl_files(ctrl); + cpqhp_create_debugfs_files(ctrl); return 0; @@ -1515,6 +1517,7 @@ static int __init cpqhpc_init(void) cpqhp_debug = debug; info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); + cpqhp_initialize_debugfs(); result = pci_register_driver(&cpqhpc_driver); dbg("pci_register_driver = %d\n", result); return result; @@ -1528,6 +1531,7 @@ static void __exit cpqhpc_cleanup(void) dbg("pci_unregister_driver\n"); pci_unregister_driver(&cpqhpc_driver); + cpqhp_shutdown_debugfs(); } diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c index 4c11048ad51b..bbfeed767ff1 100644 --- a/drivers/pci/hotplug/cpqphp_sysfs.c +++ b/drivers/pci/hotplug/cpqphp_sysfs.c @@ -33,22 +33,15 @@ #include #include #include +#include #include "cpqphp.h" - -/* A few routines that create sysfs entries for the hot plug controller */ - -static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf) +static int show_ctrl (struct controller *ctrl, char *buf) { - struct pci_dev *pci_dev; - struct controller *ctrl; - char * out = buf; + char *out = buf; int index; struct pci_resource *res; - pci_dev = container_of (dev, struct pci_dev, dev); - ctrl = pci_get_drvdata(pci_dev); - out += sprintf(buf, "Free resources: memory\n"); index = 11; res = ctrl->mem_head; @@ -80,22 +73,16 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha return out - buf; } -static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); -static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf) +static int show_dev (struct controller *ctrl, char *buf) { - struct pci_dev *pci_dev; - struct controller *ctrl; char * out = buf; int index; struct pci_resource *res; struct pci_func *new_slot; struct slot *slot; - pci_dev = container_of (dev, struct pci_dev, dev); - ctrl = pci_get_drvdata(pci_dev); - - slot=ctrl->slot; + slot = ctrl->slot; while (slot) { new_slot = cpqhp_slot_find(slot->bus, slot->device, 0); @@ -134,10 +121,117 @@ static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char return out - buf; } -static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL); -void cpqhp_create_ctrl_files (struct controller *ctrl) +static int spew_debug_info(struct controller *ctrl, char *data, int size) { - device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); - device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev); + int used; + + used = size - show_ctrl(ctrl, data); + used = (size - used) - show_dev(ctrl, &data[used]); + return used; +} + +struct ctrl_dbg { + int size; + char *data; + struct controller *ctrl; +}; + +#define MAX_OUTPUT (4*PAGE_SIZE) + +static int open(struct inode *inode, struct file *file) +{ + struct controller *ctrl = inode->u.generic_ip; + struct ctrl_dbg *dbg; + int retval = -ENOMEM; + + lock_kernel(); + dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); + if (!dbg) + goto exit; + dbg->data = kmalloc(MAX_OUTPUT, GFP_KERNEL); + if (!dbg->data) { + kfree(dbg); + goto exit; + } + dbg->size = spew_debug_info(ctrl, dbg->data, MAX_OUTPUT); + file->private_data = dbg; + retval = 0; +exit: + unlock_kernel(); + return retval; +} + +static loff_t lseek(struct file *file, loff_t off, int whence) +{ + struct ctrl_dbg *dbg; + loff_t new = -1; + + lock_kernel(); + dbg = file->private_data; + + switch (whence) { + case 0: + new = off; + break; + case 1: + new = file->f_pos + off; + break; + } + if (new < 0 || new > dbg->size) { + unlock_kernel(); + return -EINVAL; + } + unlock_kernel(); + return (file->f_pos = new); } + +static ssize_t read(struct file *file, char __user *buf, + size_t nbytes, loff_t *ppos) +{ + struct ctrl_dbg *dbg = file->private_data; + return simple_read_from_buffer(buf, nbytes, ppos, dbg->data, dbg->size); +} + +static int release(struct inode *inode, struct file *file) +{ + struct ctrl_dbg *dbg = file->private_data; + + kfree(dbg->data); + kfree(dbg); + return 0; +} + +static struct file_operations debug_ops = { + .owner = THIS_MODULE, + .open = open, + .llseek = lseek, + .read = read, + .release = release, +}; + +static struct dentry *root; + +void cpqhp_initialize_debugfs(void) +{ + if (!root) + root = debugfs_create_dir("cpqhp", NULL); +} + +void cpqhp_shutdown_debugfs(void) +{ + debugfs_remove(root); +} + +void cpqhp_create_debugfs_files(struct controller *ctrl) +{ + ctrl->dentry = debugfs_create_file(ctrl->pci_dev->dev.bus_id, S_IRUGO, root, ctrl, &debug_ops); +} + +void cpqhp_remove_debugfs_files(struct controller *ctrl) +{ + if (ctrl->dentry) + debugfs_remove(ctrl->dentry); + ctrl->dentry = NULL; +} + -- cgit v1.2.3 From c64b5eead93f9d3a8ca0e9ca0ffba0b99dc565b9 Mon Sep 17 00:00:00 2001 From: Kristen Accardi Date: Wed, 14 Dec 2005 09:37:26 -0800 Subject: [PATCH] acpiphp: only size new bus Only size the bus that has been added. Signed-off-by: Kristen Carlson Accardi Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/acpiphp_glue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 8e21f6ab89a1..509a5b3ae998 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -794,12 +794,14 @@ static int enable_device(struct acpiphp_slot *slot) if (PCI_SLOT(dev->devfn) != slot->device) continue; if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || - dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) + dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { max = pci_scan_bridge(bus, dev, max, pass); + if (pass && dev->subordinate) + pci_bus_size_bridges(dev->subordinate); + } } } - pci_bus_size_bridges(bus); pci_bus_assign_resources(bus); acpiphp_sanitize_bus(bus); pci_enable_bridges(bus); -- cgit v1.2.3 From 54c762fe62d9ff0982f38e80cbec9c59104311e9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 22 Dec 2005 01:08:52 +0100 Subject: [PATCH] PCI: drivers/pci: some cleanups This patch contains the following cleanups: - hotplug/pciehp_core.c: make the needlessly global hpdriver_context static - #if 0 the following unused functions: - pci.c: pci_bus_max_busnr() - pci.c: pci_max_busnr() - proc.c: pci_proc_attach_bus() - remove.c: pci_remove_device_safe Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/pciehp_core.c | 2 +- drivers/pci/pci.c | 5 +++-- drivers/pci/pci.h | 5 ----- drivers/pci/proc.c | 3 ++- drivers/pci/remove.c | 3 ++- 5 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 986e202e0b0b..4fb569018a24 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -512,7 +512,7 @@ static void __exit unload_pciehpd(void) } -int hpdriver_context = 0; +static int hpdriver_context = 0; static void pciehp_remove (struct pcie_device *device) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 81b9b8d9bceb..d2a633efa10a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -19,6 +19,7 @@ #include /* isa_dma_bridge_buggy */ #include "pci.h" +#if 0 /** * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children @@ -63,6 +64,8 @@ pci_max_busnr(void) return max; } +#endif /* 0 */ + static int __pci_find_next_cap(struct pci_bus *bus, unsigned int devfn, u8 pos, int cap) { u8 id; @@ -917,8 +920,6 @@ EXPORT_SYMBOL_GPL(pci_restore_bars); EXPORT_SYMBOL(pci_enable_device_bars); EXPORT_SYMBOL(pci_enable_device); EXPORT_SYMBOL(pci_disable_device); -EXPORT_SYMBOL(pci_max_busnr); -EXPORT_SYMBOL(pci_bus_max_busnr); EXPORT_SYMBOL(pci_find_capability); EXPORT_SYMBOL(pci_bus_find_capability); EXPORT_SYMBOL(pci_release_regions); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 294849d24590..a6dfee2f6d2b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -26,20 +26,15 @@ extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val); #ifdef CONFIG_PROC_FS extern int pci_proc_attach_device(struct pci_dev *dev); extern int pci_proc_detach_device(struct pci_dev *dev); -extern int pci_proc_attach_bus(struct pci_bus *bus); extern int pci_proc_detach_bus(struct pci_bus *bus); #else static inline int pci_proc_attach_device(struct pci_dev *dev) { return 0; } static inline int pci_proc_detach_device(struct pci_dev *dev) { return 0; } -static inline int pci_proc_attach_bus(struct pci_bus *bus) { return 0; } static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; } #endif /* Functions for PCI Hotplug drivers to use */ extern unsigned int pci_do_scan_bus(struct pci_bus *bus); -extern int pci_remove_device_safe(struct pci_dev *dev); -extern unsigned char pci_max_busnr(void); -extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); extern void pci_remove_legacy_files(struct pci_bus *bus); diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 9eb465727fce..d21894c63f8e 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -431,6 +431,7 @@ int pci_proc_detach_device(struct pci_dev *dev) return 0; } +#if 0 int pci_proc_attach_bus(struct pci_bus* bus) { struct proc_dir_entry *de = bus->procdir; @@ -447,6 +448,7 @@ int pci_proc_attach_bus(struct pci_bus* bus) } return 0; } +#endif /* 0 */ int pci_proc_detach_bus(struct pci_bus* bus) { @@ -612,7 +614,6 @@ __initcall(pci_proc_init); #ifdef CONFIG_HOTPLUG EXPORT_SYMBOL(pci_proc_attach_device); -EXPORT_SYMBOL(pci_proc_attach_bus); EXPORT_SYMBOL(pci_proc_detach_bus); #endif diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 27a294b6965d..1a6bf9de166f 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -48,6 +48,7 @@ static void pci_destroy_dev(struct pci_dev *dev) * in question is not being used by a driver. * Returns 0 on success. */ +#if 0 int pci_remove_device_safe(struct pci_dev *dev) { if (pci_dev_driver(dev)) @@ -55,7 +56,7 @@ int pci_remove_device_safe(struct pci_dev *dev) pci_destroy_dev(dev); return 0; } -EXPORT_SYMBOL(pci_remove_device_safe); +#endif /* 0 */ void pci_remove_bus(struct pci_bus *pci_bus) { -- cgit v1.2.3 From 9bfab8cec652c80b4864b4d9247520dca042c2df Mon Sep 17 00:00:00 2001 From: Richard Knutsson Date: Wed, 30 Nov 2005 00:59:34 +0100 Subject: [PATCH] drivers/block: Replace pci_module_init() with pci_register_driver() Replace obsolete pci_module_init() with pci_register_driver(). Signed-off-by: Richard Knutsson Signed-off-by: Greg Kroah-Hartman --- drivers/block/DAC960.c | 2 +- drivers/block/cciss.c | 2 +- drivers/block/sx8.c | 2 +- drivers/block/umem.c | 2 +- drivers/media/radio/radio-gemtek-pci.c | 2 +- drivers/media/radio/radio-maxiradio.c | 2 +- drivers/media/video/bttv-driver.c | 2 +- drivers/media/video/saa7134/saa7134-core.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 4a7bb7dfce85..6ede1f352c29 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -7179,7 +7179,7 @@ static int DAC960_init_module(void) { int ret; - ret = pci_module_init(&DAC960_pci_driver); + ret = pci_register_driver(&DAC960_pci_driver); #ifdef DAC960_GAM_MINOR if (!ret) DAC960_gam_init(); diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index e4e9f255bd1f..12d7b9bdfa93 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -3360,7 +3360,7 @@ static int __init cciss_init(void) printk(KERN_INFO DRIVER_NAME "\n"); /* Register for our PCI devices */ - return pci_module_init(&cciss_pci_driver); + return pci_register_driver(&cciss_pci_driver); } static void __exit cciss_cleanup(void) diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index c0cdc182a8b0..a7e0975c8c9f 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -1755,7 +1755,7 @@ static void carm_remove_one (struct pci_dev *pdev) static int __init carm_init(void) { - return pci_module_init(&carm_driver); + return pci_register_driver(&carm_driver); } static void __exit carm_exit(void) diff --git a/drivers/block/umem.c b/drivers/block/umem.c index 15299e7a1ade..a3614e6a68d0 100644 --- a/drivers/block/umem.c +++ b/drivers/block/umem.c @@ -1174,7 +1174,7 @@ static int __init mm_init(void) printk(KERN_INFO DRIVER_VERSION " : " DRIVER_DESC "\n"); - retval = pci_module_init(&mm_pci_driver); + retval = pci_register_driver(&mm_pci_driver); if (retval) return -ENOMEM; diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c index 630cc786d0a4..78b2888bf581 100644 --- a/drivers/media/radio/radio-gemtek-pci.c +++ b/drivers/media/radio/radio-gemtek-pci.c @@ -394,7 +394,7 @@ static struct pci_driver gemtek_pci_driver = static int __init gemtek_pci_init_module( void ) { - return pci_module_init( &gemtek_pci_driver ); + return pci_register_driver( &gemtek_pci_driver ); } static void __exit gemtek_pci_cleanup_module( void ) diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 02d39a50d5ed..7b33d8f2f8f8 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c @@ -337,7 +337,7 @@ static struct pci_driver maxiradio_driver = { static int __init maxiradio_radio_init(void) { - return pci_module_init(&maxiradio_driver); + return pci_register_driver(&maxiradio_driver); } static void __exit maxiradio_radio_exit(void) diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 1ddf9ba613ef..00bd8ea5eaeb 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c @@ -4253,7 +4253,7 @@ static int bttv_init_module(void) bttv_check_chipset(); bus_register(&bttv_sub_bus_type); - return pci_module_init(&bttv_pci_driver); + return pci_register_driver(&bttv_pci_driver); } static void bttv_cleanup_module(void) diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 23d8747338ed..21cb3d6be839 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c @@ -1156,7 +1156,7 @@ static int saa7134_init(void) printk(KERN_INFO "saa7130/34: snapshot date %04d-%02d-%02d\n", SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100); #endif - return pci_module_init(&saa7134_pci_driver); + return pci_register_driver(&saa7134_pci_driver); } static void saa7134_fini(void) -- cgit v1.2.3 From 93b47684f60cf25e8cefe19a21d94aa0257fdf36 Mon Sep 17 00:00:00 2001 From: Richard Knutsson Date: Wed, 30 Nov 2005 01:00:35 +0100 Subject: [PATCH] drivers/*rest*: Replace pci_module_init() with pci_register_driver() Replace obsolete pci_module_init() with pci_register_driver(). Signed-off-by: Richard Knutsson Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/vt8231.c | 2 +- drivers/parport/parport_serial.c | 2 +- drivers/pcmcia/vrc4173_cardu.c | 2 +- drivers/serial/serial_txx9.c | 2 +- drivers/video/cyblafb.c | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index d00a726d0239..3eb08f004c0f 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c @@ -841,7 +841,7 @@ static int __devinit vt8231_pci_probe(struct pci_dev *dev, static int __init sm_vt8231_init(void) { - return pci_module_init(&vt8231_pci_driver); + return pci_register_driver(&vt8231_pci_driver); } static void __exit sm_vt8231_exit(void) diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c index d3dad0aac7cb..76dd077e3184 100644 --- a/drivers/parport/parport_serial.c +++ b/drivers/parport/parport_serial.c @@ -464,7 +464,7 @@ static struct pci_driver parport_serial_pci_driver = { static int __init parport_serial_init (void) { - return pci_module_init (&parport_serial_pci_driver); + return pci_register_driver (&parport_serial_pci_driver); } static void __exit parport_serial_exit (void) diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c index 1b277d2c1c96..b502db2790e0 100644 --- a/drivers/pcmcia/vrc4173_cardu.c +++ b/drivers/pcmcia/vrc4173_cardu.c @@ -561,7 +561,7 @@ static int __devinit vrc4173_cardu_init(void) { vrc4173_cardu_slots = 0; - return pci_module_init(&vrc4173_cardu_driver); + return pci_register_driver(&vrc4173_cardu_driver); } static void __devexit vrc4173_cardu_exit(void) diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index f10c86d60b64..995d9dd9ddd5 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c @@ -1195,7 +1195,7 @@ static int __init serial_txx9_init(void) serial_txx9_register_ports(&serial_txx9_reg); #ifdef ENABLE_SERIAL_TXX9_PCI - ret = pci_module_init(&serial_txx9_pci_driver); + ret = pci_register_driver(&serial_txx9_pci_driver); #endif } return ret; diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c index e9f5dee67e3c..2b972461a030 100644 --- a/drivers/video/cyblafb.c +++ b/drivers/video/cyblafb.c @@ -1666,6 +1666,7 @@ static int __devinit cyblafb_init(void) #endif output("CyblaFB version %s initializing\n", VERSION); return pci_module_init(&cyblafb_pci_driver); + return pci_register_driver(&cyblafb_pci_driver); } static void __exit cyblafb_exit(void) -- cgit v1.2.3