* [BK PATCH] PCI hotplug changes for 2.5.63
@ 2003-02-25 1:13 Greg KH
2003-02-25 1:15 ` [PATCH] " Greg KH
2003-02-28 23:59 ` [BK PATCH] " Greg KH
0 siblings, 2 replies; 20+ messages in thread
From: Greg KH @ 2003-02-25 1:13 UTC (permalink / raw)
To: torvalds, scottm; +Cc: linux-kernel, pcihpd-discuss
Hi,
Here's some patches that clean up the remove logic a lot for the PCI
hotplug drivers. The main PCI patches were done by Russell King and
Christoph Hellwig, and then I went and cleaned up the PCI Hotplug
drivers a lot based on their changes. I also fixed up some exit logic
in the IBM PCI hotplug driver, as it was a mess.
Scott, I modified the cPCI core in order to get it to build and link
properly again, but as I don't have the hardware to test it, you should
probably look over the change and see if I messed anything up or not.
Also, I think you are the last user of the pci_visit structure, make
sure you really need it, otherwise we can get rid of it entirely from
the PCI core.
Please pull from: bk://kernel.bkbits.net/gregkh/linux/pci-2.5
thanks,
greg k-h
drivers/hotplug/cpqphp_proc.c | 143 ---------
drivers/hotplug/Makefile | 2
drivers/hotplug/acpiphp_pci.c | 191 -------------
drivers/hotplug/cpci_hotplug_pci.c | 34 --
drivers/hotplug/cpqphp.h | 27 -
drivers/hotplug/cpqphp_core.c | 18 -
drivers/hotplug/cpqphp_pci.c | 204 --------------
drivers/hotplug/cpqphp_proc.c | 96 +-----
drivers/hotplug/cpqphp_sysfs.c | 143 +++++++++
drivers/hotplug/ibmphp.h | 6
drivers/hotplug/ibmphp_core.c | 538 +++++++++----------------------------
drivers/hotplug/ibmphp_hpc.c | 2
drivers/hotplug/pci_hotplug_core.c | 18 -
drivers/pci/hotplug.c | 63 +++-
drivers/pci/probe.c | 1
include/linux/pci.h | 4
16 files changed, 380 insertions(+), 1110 deletions(-)
-----
ChangeSet@1.1022.1.14, 2003-02-24 16:35:48-08:00, greg@kroah.com
[PATCH] CPCI core: remove unneeded visit device on unconfigure.
The driver now links properly, but this is untested due to my
lack of cPCI hardware.
drivers/hotplug/cpci_hotplug_pci.c | 34 ----------------------------------
1 files changed, 34 deletions(-)
------
ChangeSet@1.1022.1.13, 2003-02-24 16:33:09-08:00, greg@kroah.com
[PATCH] PCI: export pci_scan_bus_parented which is needed by the IBM pci hotplug driver.
drivers/pci/probe.c | 1 +
1 files changed, 1 insertion(+)
------
ChangeSet@1.1022.1.12, 2003-02-24 16:32:16-08:00, greg@kroah.com
[PATCH] IBM PCI Hotplug: convert driver to use pci_bus_remove_device()
Also cleaned up a lot of unnecessary bus walking on device startup
and shutdown.
drivers/hotplug/ibmphp_core.c | 136 ------------------------------------------
1 files changed, 3 insertions(+), 133 deletions(-)
------
ChangeSet@1.1022.1.11, 2003-02-24 16:31:00-08:00, greg@kroah.com
[PATCH] ACPI PCI hotplug: convert to use pci_remove_bus_device()
Also got rid of some unneeded bus walking on device init and shutdown.
drivers/hotplug/acpiphp_pci.c | 146 ------------------------------------------
1 files changed, 3 insertions(+), 143 deletions(-)
------
ChangeSet@1.1022.1.10, 2003-02-24 16:30:40-08:00, greg@kroah.com
[PATCH] Compaq PCI Hotplug: remove unused walk of the device on insertion.
drivers/hotplug/cpqphp_pci.c | 54 -------------------------------------------
1 files changed, 54 deletions(-)
------
ChangeSet@1.1022.1.9, 2003-02-24 16:29:53-08:00, greg@kroah.com
[PATCH] Compaq PCI Hotplug: convert to use pci_remove_bus_device instead of custom code.
drivers/hotplug/cpqphp_pci.c | 104 +------------------------------------------
1 files changed, 3 insertions(+), 101 deletions(-)
------
ChangeSet@1.1022.1.8, 2003-02-24 16:28:58-08:00, rmk@arm.linux.org.uk
[PATCH] PCI: Make hot unplugging of PCI buses work
Here's the updated patch:
- Scott spotted a leak my handling of procfs wrt buses.
- I've also killed pci_remove_device() entirely - it is now inlined.
- After one of Alan's mails, I decided that pci_remove_behind_bridge()
is a much better name than pci_remove_all_bus_devices()
drivers/pci/hotplug.c | 63 ++++++++++++++++++++++++++++++++++++++++++++------
include/linux/pci.h | 3 +-
2 files changed, 58 insertions(+), 8 deletions(-)
------
ChangeSet@1.1022.1.7, 2003-02-24 16:27:59-08:00, hch@lst.de
[PATCH] PCI: remove check_region abuse (and code duplication) from pci hp code
We have a function pci_dev_driver() to check whether a pci_dev has an
driver attached to it. It's handling of legacy devices is a bit simpler
than what the hotplug code did (duplicated in various places), but if
that stuff is really needed the generic code should be updated.
drivers/hotplug/acpiphp_pci.c | 45 +----------------------------------------
drivers/hotplug/cpqphp_pci.c | 46 +-----------------------------------------
drivers/hotplug/ibmphp_core.c | 37 +--------------------------------
include/linux/pci.h | 1
4 files changed, 6 insertions(+), 123 deletions(-)
------
ChangeSet@1.1022.1.6, 2003-02-24 16:27:32-08:00, greg@kroah.com
[PATCH] Compaq PCI Hotplug: rename cpqphp_proc.c to cpqphp_sysfs.c
drivers/hotplug/cpqphp_proc.c | 143 -----------------------------------------
drivers/hotplug/Makefile | 2
drivers/hotplug/cpqphp_sysfs.c | 143 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+), 144 deletions(-)
------
ChangeSet@1.1022.1.5, 2003-02-24 16:26:59-08:00, greg@kroah.com
[PATCH] Compaq PCI Hotplug: move /proc files to sysfs
drivers/hotplug/cpqphp.h | 27 -----------
drivers/hotplug/cpqphp_core.c | 18 -------
drivers/hotplug/cpqphp_proc.c | 96 +++++++++---------------------------------
3 files changed, 25 insertions(+), 116 deletions(-)
------
ChangeSet@1.1022.1.4, 2003-02-24 16:26:14-08:00, greg@kroah.com
[PATCH] PCI Hotplug: remove the list_lock, as we rely on sysfs to detect any duplicate slot names.
drivers/hotplug/pci_hotplug_core.c | 18 +-----------------
1 files changed, 1 insertion(+), 17 deletions(-)
------
ChangeSet@1.1022.1.3, 2003-02-24 16:25:54-08:00, greg@kroah.com
[PATCH] IBM PCI Hotplug: get rid of unneeded ops structure and surrounding logic.
drivers/hotplug/ibmphp.h | 5 ---
drivers/hotplug/ibmphp_core.c | 69 +++++++++---------------------------------
2 files changed, 15 insertions(+), 59 deletions(-)
------
ChangeSet@1.1022.1.2, 2003-02-24 16:25:28-08:00, greg@kroah.com
[PATCH] IBM PCI Hotplug: fix typo in previous patch.
drivers/hotplug/ibmphp_core.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
------
ChangeSet@1.1022.1.1, 2003-02-24 16:24:48-08:00, greg@kroah.com
[PATCH] IBM PCI Hotplug: Clean up the error handling logic for a number of functions, and fix a locking mess.
Push file://home/greg/linux/BK/pci-2.5 -> file://home/greg/linux/BK/bleed-2.5
drivers/hotplug/ibmphp.h | 1
drivers/hotplug/ibmphp_core.c | 294 ++++++++++++++++--------------------------
drivers/hotplug/ibmphp_hpc.c | 2
3 files changed, 120 insertions(+), 177 deletions(-)
------
^ permalink raw reply [flat|nested] 20+ messages in thread* [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:13 [BK PATCH] PCI hotplug changes for 2.5.63 Greg KH @ 2003-02-25 1:15 ` Greg KH 2003-02-25 1:15 ` Greg KH 2003-02-28 23:59 ` [BK PATCH] " Greg KH 1 sibling, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:15 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.1, 2003/02/24 16:24:48-08:00, greg@kroah.com [PATCH] IBM PCI Hotplug: Clean up the error handling logic for a number of functions, and fix a locking mess. diff -Nru a/drivers/hotplug/ibmphp.h b/drivers/hotplug/ibmphp.h --- a/drivers/hotplug/ibmphp.h Mon Feb 24 17:16:04 2003 +++ b/drivers/hotplug/ibmphp.h Mon Feb 24 17:16:04 2003 @@ -761,6 +761,7 @@ extern int ibmphp_init_devno (struct slot **); /* This function is called from EBDA, so we need it not be static */ extern int ibmphp_disable_slot (struct hotplug_slot *); /* This function is called from HPC, so we need it to not be static */ +extern int ibmphp_do_disable_slot (struct slot *slot_cur); extern int ibmphp_update_slot_info (struct slot *); /* This function is called from HPC, so we need it to not be be static */ extern int ibmphp_configure_card (struct pci_func *, u8); extern int ibmphp_unconfigure_card (struct slot **, int); diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c --- a/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:16:04 2003 +++ b/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:16:04 2003 @@ -1274,7 +1274,6 @@ int rc, i, rcpr; struct slot *slot_cur; u8 function; - u8 faulted = 0; struct pci_func *tmp_func; ibmphp_lock_operations (); @@ -1284,16 +1283,7 @@ if ((rc = validate (slot_cur, ENABLE))) { err ("validate function failed \n"); - attn_off (slot_cur); /* need to turn off if was blinking b4 */ - attn_on (slot_cur); - rc = slot_update (&slot_cur); - if (rc) { - ibmphp_unlock_operations(); - return rc; - } - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return rc; + goto error_nopower; } attn_LED_blink (slot_cur); @@ -1301,10 +1291,7 @@ rc = set_bus (slot_cur); if (rc) { err ("was not able to set the bus \n"); - attn_off (slot_cur); - attn_on (slot_cur); - ibmphp_unlock_operations (); - return -ENODEV; + goto error_nopower; } /*-----------------debugging------------------------------*/ @@ -1314,18 +1301,12 @@ rc = check_limitations (slot_cur); if (rc) { - err ("Adding this card exceeds the limitations of this bus. \n"); - err ("(i.e., >1 133MHz cards running on same bus, or >2 66 PCI cards running on same bus \n. Try hot-adding into another bus \n"); - attn_off (slot_cur); - attn_on (slot_cur); - - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -ENODEV; - } - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return -EINVAL; + err ("Adding this card exceeds the limitations of this bus.\n"); + err ("(i.e., >1 133MHz cards running on same bus, or " + ">2 66 PCI cards running on same bus\n."); + err ("Try hot-adding into another bus \n"); + rc = -EINVAL; + goto error_nopower; } rc = power_on (slot_cur); @@ -1338,8 +1319,8 @@ if (slot_update (&slot_cur)) { attn_off (slot_cur); attn_on (slot_cur); - ibmphp_unlock_operations (); - return -ENODEV; + rc = -ENODEV; + goto exit; } /* Check to see the error of why it failed */ if ((SLOT_POWER (slot_cur->status)) && !(SLOT_PWRGD (slot_cur->status))) @@ -1352,8 +1333,7 @@ print_card_capability (slot_cur); } ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return rc; + goto exit; } debug ("after power_on\n"); /*-----------------------debugging---------------------------*/ @@ -1362,61 +1342,32 @@ /*----------------------------------------------------------*/ rc = slot_update (&slot_cur); - if (rc) { - attn_off (slot_cur); - attn_on (slot_cur); - rcpr = power_off (slot_cur); - if (rcpr) { - ibmphp_unlock_operations (); - return rcpr; - } - ibmphp_unlock_operations (); - return rc; - } + if (rc) + goto error_power; + rc = -EINVAL; if (SLOT_POWER (slot_cur->status) && !(SLOT_PWRGD (slot_cur->status))) { - faulted = 1; err ("power fault occured trying to power up... \n"); - } else if (SLOT_POWER (slot_cur->status) && (SLOT_BUS_SPEED (slot_cur->status))) { - faulted = 1; + goto error_power; + } + if (SLOT_POWER (slot_cur->status) && (SLOT_BUS_SPEED (slot_cur->status))) { err ("bus speed mismatch occured. please check current bus speed and card capability \n"); print_card_capability (slot_cur); + goto error_power; } /* Don't think this case will happen after above checks... but just in case, for paranoia sake */ - else if (!(SLOT_POWER (slot_cur->status))) { + if (!(SLOT_POWER (slot_cur->status))) { err ("power on failed... \n"); - faulted = 1; - } - if (faulted) { - attn_off (slot_cur); /* need to turn off b4 on */ - attn_on (slot_cur); - rcpr = power_off (slot_cur); - if (rcpr) { - ibmphp_unlock_operations (); - return rcpr; - } - - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -ENODEV; - } - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return -EINVAL; + goto error_power; } slot_cur->func = (struct pci_func *) kmalloc (sizeof (struct pci_func), GFP_KERNEL); - if (!slot_cur->func) { /* We cannot do update_slot_info here, since no memory for kmalloc n.e.ways, and update_slot_info allocates some */ + if (!slot_cur->func) { + /* We cannot do update_slot_info here, since no memory for + * kmalloc n.e.ways, and update_slot_info allocates some */ err ("out of system memory \n"); - attn_off (slot_cur); - attn_on (slot_cur); - rcpr = power_off (slot_cur); - if (rcpr) { - ibmphp_unlock_operations (); - return rcpr; - } - ibmphp_unlock_operations (); - return -ENOMEM; + rc = -ENOMEM; + goto error_power; } memset (slot_cur->func, 0, sizeof (struct pci_func)); slot_cur->func->busno = slot_cur->bus; @@ -1431,21 +1382,10 @@ ibmphp_unconfigure_card (&slot_cur, 1); /* true because don't need to actually deallocate resources, just remove references */ debug ("after unconfigure_card\n"); slot_cur->func = NULL; - attn_off (slot_cur); /* need to turn off in case was blinking */ - attn_on (slot_cur); - rcpr = power_off (slot_cur); - if (rcpr) { - ibmphp_unlock_operations (); - return rcpr; - } - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations(); - return -ENODEV; - } - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return -ENOMEM; + rc = -ENOMEM; + goto error_power; } + function = 0x00; do { tmp_func = ibm_slot_find (slot_cur->bus, slot_cur->func->device, function++); @@ -1455,13 +1395,36 @@ attn_off (slot_cur); if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -EFAULT; + rc = -EFAULT; + goto exit; } ibmphp_print_test (); rc = ibmphp_update_slot_info (slot_cur); +exit: ibmphp_unlock_operations(); return rc; + +error_nopower: + attn_off (slot_cur); /* need to turn off if was blinking b4 */ + attn_on (slot_cur); +error_cont: + rcpr = slot_update (&slot_cur); + if (rcpr) { + rc = rcpr; + goto exit; + } + ibmphp_update_slot_info (slot_cur); + goto exit; + +error_power: + attn_off (slot_cur); /* need to turn off if was blinking b4 */ + attn_on (slot_cur); + rcpr = power_off (slot_cur); + if (rcpr) { + rc = rcpr; + goto exit; + } + goto error_cont; } /************************************************************** @@ -1472,45 +1435,34 @@ **************************************************************/ int ibmphp_disable_slot (struct hotplug_slot *hotplug_slot) { + struct slot *slot = hotplug_slot->private; + int rc; + + ibmphp_lock_operations(); + rc = ibmphp_do_disable_slot(slot); + ibmphp_unlock_operations(); + return rc; +} + +int ibmphp_do_disable_slot (struct slot *slot_cur) +{ int rc; - struct slot *slot_cur = (struct slot *) hotplug_slot->private; u8 flag; int parm = 0; debug ("DISABLING SLOT... \n"); - if (slot_cur == NULL) { - ibmphp_unlock_operations (); - return -ENODEV; - } - - if (slot_cur->ctrl == NULL) { - ibmphp_unlock_operations (); + if ((slot_cur == NULL) || (slot_cur->ctrl == NULL)) { return -ENODEV; } - flag = slot_cur->flag; /* to see if got here from polling */ - - if (flag) - ibmphp_lock_operations (); - + flag = slot_cur->flag; slot_cur->flag = TRUE; if (flag == TRUE) { rc = validate (slot_cur, DISABLE); /* checking if powered off already & valid slot # */ - if (rc) { - /* Need to turn off if was blinking b4 */ - attn_off (slot_cur); - attn_on (slot_cur); - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -EFAULT; - } - - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return rc; - } + if (rc) + goto error; } attn_LED_blink (slot_cur); @@ -1519,10 +1471,8 @@ slot_cur->func = (struct pci_func *) kmalloc (sizeof (struct pci_func), GFP_KERNEL); if (!slot_cur->func) { err ("out of system memory \n"); - attn_off (slot_cur); - attn_on (slot_cur); - ibmphp_unlock_operations (); - return -ENOMEM; + rc = -ENOMEM; + goto error; } memset (slot_cur->func, 0, sizeof (struct pci_func)); slot_cur->func->busno = slot_cur->bus; @@ -1531,11 +1481,9 @@ if ((rc = ibm_unconfigure_device (slot_cur->func))) { err ("removing from kernel failed... \n"); - err ("Please check to see if it was statically linked or is in use otherwise. (perhaps the driver is not 'hot-removable')\n"); - attn_off (slot_cur); - attn_on (slot_cur); - ibmphp_unlock_operations (); - return rc; + err ("Please check to see if it was statically linked or is " + "in use otherwise. (perhaps the driver is not 'hot-removable')\n"); + goto error; } /* If we got here from latch suddenly opening on operating card or @@ -1554,43 +1502,34 @@ debug ("in disable_slot. after unconfigure_card\n"); if (rc) { err ("could not unconfigure card.\n"); - attn_off (slot_cur); /* need to turn off if was blinking b4 */ - attn_on (slot_cur); - - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -EFAULT; - } - - if (flag) - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return -EFAULT; + goto error; } - rc = ibmphp_hpc_writeslot (hotplug_slot->private, HPC_SLOT_OFF); - if (rc) { - attn_off (slot_cur); - attn_on (slot_cur); - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -EFAULT; - } - - ibmphp_update_slot_info (slot_cur); - ibmphp_unlock_operations (); - return rc; - } + rc = ibmphp_hpc_writeslot (slot_cur, HPC_SLOT_OFF); + if (rc) + goto error; attn_off (slot_cur); - if (slot_update (&slot_cur)) { - ibmphp_unlock_operations (); - return -EFAULT; - } + rc = slot_update (&slot_cur); + if (rc) + goto exit; + rc = ibmphp_update_slot_info (slot_cur); ibmphp_print_test (); - ibmphp_unlock_operations(); +exit: return rc; + +error: + /* Need to turn off if was blinking b4 */ + attn_off (slot_cur); + attn_on (slot_cur); + if (slot_update (&slot_cur)) { + rc = -EFAULT; + goto exit; + } + if (flag) + ibmphp_update_slot_info (slot_cur); + goto exit; } struct hotplug_slot_ops ibmphp_hotplug_slot_ops = { @@ -1622,6 +1561,7 @@ debug ("after ebda hpc \n"); ibmphp_free_ebda_pci_rsrc_queue (); debug ("after ebda pci rsrc \n"); + kfree (ibmphp_pci_bus); } static int __init ibmphp_init (void) @@ -1637,13 +1577,15 @@ ibmphp_pci_bus = kmalloc (sizeof (*ibmphp_pci_bus), GFP_KERNEL); if (!ibmphp_pci_bus) { err ("out of memory\n"); - return -ENOMEM; + rc = -ENOMEM; + goto exit; } bus = ibmphp_find_bus (0); if (!bus) { err ("Can't find the root pci bus, can not continue\n"); - return -ENODEV; + rc -ENODEV; + goto error; } memcpy (ibmphp_pci_bus, bus, sizeof (*ibmphp_pci_bus)); @@ -1654,39 +1596,39 @@ for (i = 0; i < 16; i++) irqs[i] = 0; - if ((rc = ibmphp_access_ebda ())) { - ibmphp_unload (); - return rc; - } + if ((rc = ibmphp_access_ebda ())) + goto error; debug ("after ibmphp_access_ebda ()\n"); - if ((rc = ibmphp_rsrc_init ())) { - ibmphp_unload (); - return rc; - } + if ((rc = ibmphp_rsrc_init ())) + goto error; debug ("AFTER Resource & EBDA INITIALIZATIONS\n"); max_slots = get_max_slots (); - if ((rc = ibmphp_register_pci ())) { - ibmphp_unload (); - return rc; - } + if ((rc = ibmphp_register_pci ())) + goto error; if (init_ops ()) { - ibmphp_unload (); - return -ENODEV; + rc = -ENODEV; + goto error; } + ibmphp_print_test (); if ((rc = ibmphp_hpc_start_poll_thread ())) { - ibmphp_unload (); - return -ENODEV; + goto error; } - /* if no NVRAM module selected, lock ourselves into memory with a - * module count of -1 so that no one can unload us. */ + /* lock ourselves into memory with a module + * count of -1 so that no one can unload us. */ MOD_DEC_USE_COUNT; - return 0; + +exit: + return rc; + +error: + ibmphp_unload (); + goto exit; } static void __exit ibmphp_exit (void) diff -Nru a/drivers/hotplug/ibmphp_hpc.c b/drivers/hotplug/ibmphp_hpc.c --- a/drivers/hotplug/ibmphp_hpc.c Mon Feb 24 17:16:04 2003 +++ b/drivers/hotplug/ibmphp_hpc.c Mon Feb 24 17:16:04 2003 @@ -1063,7 +1063,7 @@ if (disable) { debug ("process_changeinstatus - disable slot\n"); pslot->flag = FALSE; - rc = ibmphp_disable_slot (pslot->hotplug_slot); + rc = ibmphp_do_disable_slot (pslot); } if (update || disable) { ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:15 ` [PATCH] " Greg KH @ 2003-02-25 1:15 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:15 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.2, 2003/02/24 16:25:28-08:00, greg@kroah.com [PATCH] IBM PCI Hotplug: fix typo in previous patch. diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c --- a/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:59 2003 +++ b/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:59 2003 @@ -1584,7 +1584,7 @@ bus = ibmphp_find_bus (0); if (!bus) { err ("Can't find the root pci bus, can not continue\n"); - rc -ENODEV; + rc = -ENODEV; goto error; } memcpy (ibmphp_pci_bus, bus, sizeof (*ibmphp_pci_bus)); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:15 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.3, 2003/02/24 16:25:54-08:00, greg@kroah.com [PATCH] IBM PCI Hotplug: get rid of unneeded ops structure and surrounding logic. diff -Nru a/drivers/hotplug/ibmphp.h b/drivers/hotplug/ibmphp.h --- a/drivers/hotplug/ibmphp.h Mon Feb 24 17:15:55 2003 +++ b/drivers/hotplug/ibmphp.h Mon Feb 24 17:15:55 2003 @@ -683,11 +683,6 @@ #define ENABLE 1 #define DISABLE 0 -#define ADD 0 -#define REMOVE 1 -#define DETAIL 2 - -#define MAX_OPS 3 #define CARD_INFO 0x07 #define PCIX133 0x07 #define PCIX66 0x05 diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c --- a/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:55 2003 +++ b/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:55 2003 @@ -55,7 +55,6 @@ MODULE_LICENSE ("GPL"); MODULE_DESCRIPTION (DRIVER_DESC); -static int *ops[MAX_OPS + 1]; struct pci_bus *ibmphp_pci_bus; static int max_slots; @@ -550,20 +549,6 @@ struct list_head *tmp; int retval; int rc; - int j; - - for (j = 0; j < MAX_OPS; j++) { - ops[j] = (int *) kmalloc ((max_slots + 1) * sizeof (int), GFP_KERNEL); - memset (ops[j], 0, (max_slots + 1) * sizeof (int)); - if (!ops[j]) { - err ("out of system memory \n"); - return -ENOMEM; - } - } - - ops[ADD][0] = 0; - ops[REMOVE][0] = 0; - ops[DETAIL][0] = 0; list_for_each (tmp, &ibmphp_slot_head) { slot_cur = list_entry (tmp, struct slot, ibm_slot_list); @@ -588,24 +573,15 @@ if (retval) return retval; - debug ("status = %x, ext_status = %x\n", slot_cur->status, slot_cur->ext_status); - debug ("SLOT_POWER = %x, SLOT_PRESENT = %x, SLOT_LATCH = %x\n", SLOT_POWER (slot_cur->status), SLOT_PRESENT (slot_cur->status), SLOT_LATCH (slot_cur->status)); - - if (!(SLOT_PWRGD (slot_cur->status)) && (SLOT_PRESENT (slot_cur->status)) && !(SLOT_LATCH (slot_cur->status))) - /* No power, adapter, and latch closed */ - ops[ADD][slot_cur->number] = 1; - else - ops[ADD][slot_cur->number] = 0; - - ops[DETAIL][slot_cur->number] = 1; - - if ((SLOT_PWRGD (slot_cur->status)) && (SLOT_PRESENT (slot_cur->status)) && !(SLOT_LATCH (slot_cur->status))) - /*Power,adapter,latch closed */ - ops[REMOVE][slot_cur->number] = 1; - else - ops[REMOVE][slot_cur->number] = 0; - - if ((SLOT_PWRGD (slot_cur->status)) && !(SLOT_PRESENT (slot_cur->status)) && !(SLOT_LATCH (slot_cur->status))) { + debug ("status = %x\n", slot_cur->status); + debug ("ext_status = %x\n", slot_cur->ext_status); + debug ("SLOT_POWER = %x\n", SLOT_POWER (slot_cur->status)); + debug ("SLOT_PRESENT = %x\n", SLOT_PRESENT (slot_cur->status)); + debug ("SLOT_LATCH = %x\n", SLOT_LATCH (slot_cur->status)); + + if ((SLOT_PWRGD (slot_cur->status)) && + !(SLOT_PRESENT (slot_cur->status)) && + !(SLOT_LATCH (slot_cur->status))) { debug ("BEFORE POWER OFF COMMAND\n"); rc = power_off (slot_cur); if (rc) @@ -643,35 +619,20 @@ if (retval) return retval; - if (!(SLOT_PWRGD (slot_cur->status)) && (SLOT_PRESENT (slot_cur->status)) - && !(SLOT_LATCH (slot_cur->status))) - ops[ADD][number] = 1; - else - ops[ADD][number] = 0; - - ops[DETAIL][number] = 1; - - if ((SLOT_PWRGD (slot_cur->status)) && (SLOT_PRESENT (slot_cur->status)) - && !(SLOT_LATCH (slot_cur->status))) - ops[REMOVE][number] = 1; - else - ops[REMOVE][number] = 0; - switch (opn) { case ENABLE: - if (ops[ADD][number]) + if (!(SLOT_PWRGD (slot_cur->status)) && + (SLOT_PRESENT (slot_cur->status)) && + !(SLOT_LATCH (slot_cur->status))) return 0; break; case DISABLE: - if (ops[REMOVE][number]) - return 0; - break; - case DETAIL: - if (ops[DETAIL][number]) + if ((SLOT_PWRGD (slot_cur->status)) && + (SLOT_PRESENT (slot_cur->status)) && + !(SLOT_LATCH (slot_cur->status))) return 0; break; default: - return -EINVAL; break; } err ("validate failed....\n"); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.4, 2003/02/24 16:26:14-08:00, greg@kroah.com [PATCH] PCI Hotplug: remove the list_lock, as we rely on sysfs to detect any duplicate slot names. diff -Nru a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c --- a/drivers/hotplug/pci_hotplug_core.c Mon Feb 24 17:15:50 2003 +++ b/drivers/hotplug/pci_hotplug_core.c Mon Feb 24 17:15:50 2003 @@ -67,8 +67,6 @@ ////////////////////////////////////////////////////////////////// -static spinlock_t list_lock; - static LIST_HEAD(pci_hotplug_slot_list); static struct subsystem hotplug_slots_subsys; @@ -531,23 +529,16 @@ if ((slot->info == NULL) || (slot->ops == NULL)) return -EINVAL; - /* make sure we have not already registered this slot */ - spin_lock (&list_lock); - if (get_slot_from_name (slot->name) != NULL) { - spin_unlock (&list_lock); - return -EINVAL; - } - strncpy(slot->kobj.name, slot->name, KOBJ_NAME_LEN); kobj_set_kset_s(slot, hotplug_slots_subsys); + /* this can fail if we have already registered a slot with the same name */ if (kobject_register(&slot->kobj)) { err("Unable to register kobject"); return -EINVAL; } list_add (&slot->slot_list, &pci_hotplug_slot_list); - spin_unlock (&list_lock); result = fs_add_slot (slot); dbg ("Added slot %s to the list\n", slot->name); @@ -570,16 +561,11 @@ if (slot == NULL) return -ENODEV; - /* make sure we have this slot in our list before trying to delete it */ - spin_lock (&list_lock); temp = get_slot_from_name (slot->name); if (temp != slot) { - spin_unlock (&list_lock); return -ENODEV; } - list_del (&slot->slot_list); - spin_unlock (&list_lock); fs_remove_slot (slot); dbg ("Removed slot %s from the list\n", slot->name); @@ -638,8 +624,6 @@ static int __init pci_hotplug_init (void) { int result; - - spin_lock_init(&list_lock); kset_set_kset_s(&hotplug_slots_subsys, pci_bus_type.subsys); result = subsystem_register(&hotplug_slots_subsys); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.5, 2003/02/24 16:26:59-08:00, greg@kroah.com [PATCH] Compaq PCI Hotplug: move /proc files to sysfs diff -Nru a/drivers/hotplug/cpqphp.h b/drivers/hotplug/cpqphp.h --- a/drivers/hotplug/cpqphp.h Mon Feb 24 17:15:46 2003 +++ b/drivers/hotplug/cpqphp.h Mon Feb 24 17:15:46 2003 @@ -403,31 +403,8 @@ #define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" -/* Proc functions for the hotplug controller info */ -#ifdef CONFIG_PROC_FS -extern int cpqhp_proc_init_ctrl (void); -extern int cpqhp_proc_destroy_ctrl (void); -extern int cpqhp_proc_create_ctrl (struct controller *ctrl); -extern int cpqhp_proc_remove_ctrl (struct controller *ctrl); -#else -static inline int cpqhp_proc_init_ctrl (void) -{ - return 0; -} -static inline int cpqhp_proc_destroy_ctrl (void) -{ - return 0; -} -static inline int cpqhp_proc_create_ctrl (struct controller *ctrl) -{ - return 0; -} -static inline int cpqhp_proc_remove_ctrl (struct controller *ctrl) -{ - return 0; -} -#endif - +/* sysfs functions for the hotplug controller info */ +extern void cpqhp_create_ctrl_files (struct controller *ctrl); /* controller functions */ extern void cpqhp_pushbutton_thread (unsigned long event_pointer); diff -Nru a/drivers/hotplug/cpqphp_core.c b/drivers/hotplug/cpqphp_core.c --- a/drivers/hotplug/cpqphp_core.c Mon Feb 24 17:15:46 2003 +++ b/drivers/hotplug/cpqphp_core.c Mon Feb 24 17:15:46 2003 @@ -1038,6 +1038,7 @@ dbg (" pcix_support %s\n", ctrl->pcix_support == 0 ? "not supported" : "supported"); ctrl->pci_dev = pdev; + pci_set_drvdata(pdev, ctrl); /* make our own copy of the pci bus structure, as we like tweaking it a lot */ ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); @@ -1231,11 +1232,7 @@ // Done with exclusive hardware access up(&ctrl->crit_sect); - rc = cpqhp_proc_create_ctrl (ctrl); - if (rc) { - err("cpqhp_proc_create_ctrl failed\n"); - goto err_free_irq; - } + cpqhp_create_ctrl_files (ctrl); return 0; @@ -1309,10 +1306,6 @@ goto error; } - retval = cpqhp_proc_init_ctrl(); - if (retval) - goto error; - initialized = 1; return retval; @@ -1343,8 +1336,6 @@ ctrl = cpqhp_ctrl_list; while (ctrl) { - cpqhp_proc_remove_ctrl (ctrl); - if (ctrl->hpc_reg) { u16 misc; rc = read_slot_enable (ctrl); @@ -1431,8 +1422,6 @@ } } - remove_proc_entry("hpc", 0); - // Stop the notification mechanism cpqhp_event_stop_thread(); @@ -1490,9 +1479,6 @@ static void __exit cpqhpc_cleanup(void) { - dbg("cleaning up proc entries\n"); - cpqhp_proc_destroy_ctrl(); - dbg("unload_cpqphpd()\n"); unload_cpqphpd(); diff -Nru a/drivers/hotplug/cpqphp_proc.c b/drivers/hotplug/cpqphp_proc.c --- a/drivers/hotplug/cpqphp_proc.c Mon Feb 24 17:15:46 2003 +++ b/drivers/hotplug/cpqphp_proc.c Mon Feb 24 17:15:46 2003 @@ -2,7 +2,7 @@ * Compaq Hot Plug Controller Driver * * Copyright (c) 1995,2001 Compaq Computer Corporation - * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com) + * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com) * Copyright (c) 2001 IBM Corp. * * All rights reserved. @@ -36,27 +36,20 @@ #include "cpqphp.h" +/* A few routines that create sysfs entries for the hot plug controller */ -static struct proc_dir_entry *ctrl_proc_root; - -/* A few routines that create proc entries for the hot plug controller */ - -static int read_ctrl (char *buf, char **start, off_t offset, int len, int *eof, void *data) +static int show_ctrl (struct device *dev, char *buf) { - struct controller *ctrl = (struct controller *)data; + struct pci_dev *pci_dev; + struct controller *ctrl; char * out = buf; int index; struct pci_resource *res; - if (offset > 0) return 0; /* no partial requests */ - len = 0; - *eof = 1; - - out += sprintf(out, "hot plug ctrl Info Page\n"); - out += sprintf(out, "bus = %d, device = %d, function = %d\n", - ctrl->bus, PCI_SLOT(ctrl->pci_dev->devfn), - PCI_FUNC(ctrl->pci_dev->devfn)); - out += sprintf(out, "Free resources: memory\n"); + 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; while (res && index--) { @@ -85,29 +78,22 @@ res = res->next; } - *start = buf; - len = out-buf; - - return len; + return out - buf; } +static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); -static int read_dev (char *buf, char **start, off_t offset, int len, int *eof, void *data) +static int show_dev (struct device *dev, char *buf) { - struct controller *ctrl = (struct controller *)data; + 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; - if (offset > 0) return 0; /* no partial requests */ - len = 0; - *eof = 1; - - out += sprintf(out, "hot plug ctrl Info Page\n"); - out += sprintf(out, "bus = %d, device = %d, function = %d\n", - ctrl->bus, PCI_SLOT(ctrl->pci_dev->devfn), - PCI_FUNC(ctrl->pci_dev->devfn)); + pci_dev = container_of (dev, struct pci_dev, dev); + ctrl = pci_get_drvdata(pci_dev); slot=ctrl->slot; @@ -146,52 +132,12 @@ slot=slot->next; } - *start = buf; - len = out-buf; - - return len; + return out - buf; } +static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL); -int cpqhp_proc_create_ctrl (struct controller *ctrl) +void cpqhp_create_ctrl_files (struct controller *ctrl) { - strcpy(ctrl->proc_name, "hpca"); - ctrl->proc_name[3] = 'a' + ctrl->bus; - - ctrl->proc_entry = create_proc_entry(ctrl->proc_name, S_IFREG | S_IRUGO, ctrl_proc_root); - ctrl->proc_entry->data = ctrl; - ctrl->proc_entry->read_proc = &read_ctrl; - - strcpy(ctrl->proc_name2, "slot_a"); - ctrl->proc_name2[5] = 'a' + ctrl->bus; - ctrl->proc_entry2 = create_proc_entry(ctrl->proc_name2, S_IFREG | S_IRUGO, ctrl_proc_root); - ctrl->proc_entry2->data = ctrl; - ctrl->proc_entry2->read_proc = &read_dev; - - return 0; + device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); + device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev); } - -int cpqhp_proc_remove_ctrl (struct controller *ctrl) -{ - if (ctrl->proc_entry) - remove_proc_entry(ctrl->proc_name, ctrl_proc_root); - if (ctrl->proc_entry2) - remove_proc_entry(ctrl->proc_name2, ctrl_proc_root); - - return 0; -} - -int cpqhp_proc_init_ctrl (void) -{ - ctrl_proc_root = proc_mkdir("hpc", proc_root_driver); - if (!ctrl_proc_root) - return -ENOMEM; - ctrl_proc_root->owner = THIS_MODULE; - return 0; -} - -int cpqhp_proc_destroy_ctrl (void) -{ - remove_proc_entry("hpc", proc_root_driver); - return 0; -} - ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.6, 2003/02/24 16:27:32-08:00, greg@kroah.com [PATCH] Compaq PCI Hotplug: rename cpqphp_proc.c to cpqphp_sysfs.c diff -Nru a/drivers/hotplug/Makefile b/drivers/hotplug/Makefile --- a/drivers/hotplug/Makefile Mon Feb 24 17:15:41 2003 +++ b/drivers/hotplug/Makefile Mon Feb 24 17:15:41 2003 @@ -18,7 +18,7 @@ cpqphp-objs := cpqphp_core.o \ cpqphp_ctrl.o \ - cpqphp_proc.o \ + cpqphp_sysfs.o \ cpqphp_pci.o ibmphp-objs := ibmphp_core.o \ diff -Nru a/drivers/hotplug/cpqphp_proc.c b/drivers/hotplug/cpqphp_proc.c --- a/drivers/hotplug/cpqphp_proc.c Mon Feb 24 17:15:41 2003 +++ /dev/null Wed Dec 31 16:00:00 1969 @@ -1,143 +0,0 @@ -/* - * Compaq Hot Plug Controller Driver - * - * Copyright (c) 1995,2001 Compaq Computer Corporation - * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com) - * Copyright (c) 2001 IBM Corp. - * - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Send feedback to <greg@kroah.com> - * - */ - -#include <linux/config.h> -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/types.h> -#include <linux/proc_fs.h> -#include <linux/workqueue.h> -#include <linux/pci.h> -#include "cpqphp.h" - - -/* A few routines that create sysfs entries for the hot plug controller */ - -static int show_ctrl (struct device *dev, char *buf) -{ - struct pci_dev *pci_dev; - struct controller *ctrl; - 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; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - out += sprintf(out, "Free resources: prefetchable memory\n"); - index = 11; - res = ctrl->p_mem_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - out += sprintf(out, "Free resources: IO\n"); - index = 11; - res = ctrl->io_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - out += sprintf(out, "Free resources: bus numbers\n"); - index = 11; - res = ctrl->bus_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - - return out - buf; -} -static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); - -static int show_dev (struct device *dev, 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; - - while (slot) { - new_slot = cpqhp_slot_find(slot->bus, slot->device, 0); - if (!new_slot) - break; - out += sprintf(out, "assigned resources: memory\n"); - index = 11; - res = new_slot->mem_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - out += sprintf(out, "assigned resources: prefetchable memory\n"); - index = 11; - res = new_slot->p_mem_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - out += sprintf(out, "assigned resources: IO\n"); - index = 11; - res = new_slot->io_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - out += sprintf(out, "assigned resources: bus numbers\n"); - index = 11; - res = new_slot->bus_head; - while (res && index--) { - out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); - res = res->next; - } - slot=slot->next; - } - - return out - buf; -} -static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL); - -void cpqhp_create_ctrl_files (struct controller *ctrl) -{ - device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); - device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev); -} diff -Nru a/drivers/hotplug/cpqphp_sysfs.c b/drivers/hotplug/cpqphp_sysfs.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/drivers/hotplug/cpqphp_sysfs.c Mon Feb 24 17:15:41 2003 @@ -0,0 +1,143 @@ +/* + * Compaq Hot Plug Controller Driver + * + * Copyright (c) 1995,2001 Compaq Computer Corporation + * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com) + * Copyright (c) 2001 IBM Corp. + * + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or + * NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Send feedback to <greg@kroah.com> + * + */ + +#include <linux/config.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/proc_fs.h> +#include <linux/workqueue.h> +#include <linux/pci.h> +#include "cpqphp.h" + + +/* A few routines that create sysfs entries for the hot plug controller */ + +static int show_ctrl (struct device *dev, char *buf) +{ + struct pci_dev *pci_dev; + struct controller *ctrl; + 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; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + out += sprintf(out, "Free resources: prefetchable memory\n"); + index = 11; + res = ctrl->p_mem_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + out += sprintf(out, "Free resources: IO\n"); + index = 11; + res = ctrl->io_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + out += sprintf(out, "Free resources: bus numbers\n"); + index = 11; + res = ctrl->bus_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + + return out - buf; +} +static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); + +static int show_dev (struct device *dev, 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; + + while (slot) { + new_slot = cpqhp_slot_find(slot->bus, slot->device, 0); + if (!new_slot) + break; + out += sprintf(out, "assigned resources: memory\n"); + index = 11; + res = new_slot->mem_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + out += sprintf(out, "assigned resources: prefetchable memory\n"); + index = 11; + res = new_slot->p_mem_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + out += sprintf(out, "assigned resources: IO\n"); + index = 11; + res = new_slot->io_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + out += sprintf(out, "assigned resources: bus numbers\n"); + index = 11; + res = new_slot->bus_head; + while (res && index--) { + out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); + res = res->next; + } + slot=slot->next; + } + + return out - buf; +} +static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL); + +void cpqhp_create_ctrl_files (struct controller *ctrl) +{ + device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); + device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev); +} ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.7, 2003/02/24 16:27:59-08:00, hch@lst.de [PATCH] PCI: remove check_region abuse (and code duplication) from pci hp code We have a function pci_dev_driver() to check whether a pci_dev has an driver attached to it. It's handling of legacy devices is a bit simpler than what the hotplug code did (duplicated in various places), but if that stuff is really needed the generic code should be updated. diff -Nru a/drivers/hotplug/acpiphp_pci.c b/drivers/hotplug/acpiphp_pci.c --- a/drivers/hotplug/acpiphp_pci.c Mon Feb 24 17:15:37 2003 +++ b/drivers/hotplug/acpiphp_pci.c Mon Feb 24 17:15:37 2003 @@ -217,47 +217,6 @@ return 0; } - -static int is_pci_dev_in_use (struct pci_dev* dev) -{ - /* - * dev->driver will be set if the device is in use by a new-style - * driver -- otherwise, check the device's regions to see if any - * driver has claimed them - */ - - int i, inuse=0; - - if (dev->driver) return 1; //assume driver feels responsible - - for (i = 0; !dev->driver && !inuse && (i < 6); i++) { - if (!pci_resource_start(dev, i)) - continue; - - if (pci_resource_flags(dev, i) & IORESOURCE_IO) - inuse = check_region(pci_resource_start(dev, i), - pci_resource_len(dev, i)); - else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) - inuse = check_mem_region(pci_resource_start(dev, i), - pci_resource_len(dev, i)); - } - - return inuse; -} - - -static int pci_hp_remove_device (struct pci_dev *dev) -{ - if (is_pci_dev_in_use(dev)) { - err("***Cannot safely power down device -- " - "it appears to be in use***\n"); - return -EBUSY; - } - pci_remove_device(dev); - return 0; -} - - /* remove device driver */ static int unconfigure_pci_dev_driver (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) { @@ -274,7 +233,7 @@ dev->driver = NULL; } - return is_pci_dev_in_use(dev); + return (pci_dev_driver(dev) != NULL); } @@ -285,7 +244,7 @@ /* Now, remove the Linux Representation */ if (dev) { - if (pci_hp_remove_device(dev) == 0) { + if (pci_remove_device_safe(dev) == 0) { info("Device %s removed\n", dev->slot_name); kfree(dev); /* Now, remove */ } else { diff -Nru a/drivers/hotplug/cpqphp_pci.c b/drivers/hotplug/cpqphp_pci.c --- a/drivers/hotplug/cpqphp_pci.c Mon Feb 24 17:15:37 2003 +++ b/drivers/hotplug/cpqphp_pci.c Mon Feb 24 17:15:37 2003 @@ -44,48 +44,6 @@ static u16 unused_IRQ; - -static int is_pci_dev_in_use(struct pci_dev* dev) -{ - /* - * dev->driver will be set if the device is in use by a new-style - * driver -- otherwise, check the device's regions to see if any - * driver has claimed them - */ - - int i, inuse=0; - - if (dev->driver) return 1; //assume driver feels responsible - - for (i = 0; !dev->driver && !inuse && (i < 6); i++) { - if (!pci_resource_start(dev, i)) - continue; - - if (pci_resource_flags(dev, i) & IORESOURCE_IO) - inuse = check_region(pci_resource_start(dev, i), - pci_resource_len(dev, i)); - else if (pci_resource_flags(dev, i) & IORESOURCE_MEM) - inuse = check_mem_region(pci_resource_start(dev, i), - pci_resource_len(dev, i)); - } - - return inuse; - -} - - -static int pci_hp_remove_device(struct pci_dev *dev) -{ - if (is_pci_dev_in_use(dev)) { - err("***Cannot safely power down device -- " - "it appears to be in use***\n"); - return -EBUSY; - } - pci_remove_device(dev); - return 0; -} - - /* * detect_HRT_floating_pointer * @@ -176,7 +134,7 @@ //Now, remove the Linux Representation if (dev) { - if (pci_hp_remove_device(dev) == 0) { + if (pci_remove_device_safe(dev) == 0) { kfree(dev); //Now, remove } else { return -1; // problems while freeing, abort visitation @@ -228,7 +186,7 @@ dev->driver = NULL; } - return is_pci_dev_in_use(dev); + return (pci_dev_driver(dev) != NULL); } diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c --- a/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:37 2003 +++ b/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:37 2003 @@ -781,39 +781,6 @@ debug ("%s -- exit\n", __FUNCTION__); } -static int ibm_is_pci_dev_in_use (struct pci_dev *dev) -{ - int i = 0; - int inuse = 0; - - if (dev->driver) - return 1; - - for (i = 0; !dev->driver && !inuse && (i < 6); i++) { - - if (!pci_resource_start (dev, i)) - continue; - - if (pci_resource_flags (dev, i) & IORESOURCE_IO) - inuse = check_region (pci_resource_start (dev, i), pci_resource_len (dev, i)); - - else if (pci_resource_flags (dev, i) & IORESOURCE_MEM) - inuse = check_mem_region (pci_resource_start (dev, i), pci_resource_len (dev, i)); - } - - return inuse; -} - -static int ibm_pci_hp_remove_device (struct pci_dev *dev) -{ - if (ibm_is_pci_dev_in_use (dev)) { - err ("***Cannot safely power down device -- it appears to be in use***\n"); - return -EBUSY; - } - pci_remove_device (dev); - return 0; -} - static int ibm_unconfigure_visit_pci_dev_phase2 (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) { struct pci_dev *dev = wrapped_dev->dev; @@ -825,7 +792,7 @@ } while (temp_func && (temp_func->function != (dev->devfn & 0x07))); if (dev) { - if (ibm_pci_hp_remove_device (dev) == 0) + if (pci_remove_device_safe(dev) == 0) kfree (dev); /* Now, remove */ else return -1; @@ -872,7 +839,7 @@ dev->driver = NULL; } - return ibm_is_pci_dev_in_use (dev); + return (pci_dev_driver(dev) != NULL); } static struct pci_visit ibm_unconfigure_functions_phase1 = { diff -Nru a/include/linux/pci.h b/include/linux/pci.h --- a/include/linux/pci.h Mon Feb 24 17:15:37 2003 +++ b/include/linux/pci.h Mon Feb 24 17:15:37 2003 @@ -692,7 +692,6 @@ extern int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_parent); -extern int pci_is_dev_in_use(struct pci_dev *dev); extern int pci_remove_device_safe(struct pci_dev *dev); #endif /* CONFIG_PCI */ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.8, 2003/02/24 16:28:58-08:00, rmk@arm.linux.org.uk [PATCH] PCI: Make hot unplugging of PCI buses work Here's the updated patch: - Scott spotted a leak my handling of procfs wrt buses. - I've also killed pci_remove_device() entirely - it is now inlined. - After one of Alan's mails, I decided that pci_remove_behind_bridge() is a much better name than pci_remove_all_bus_devices() diff -Nru a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c --- a/drivers/pci/hotplug.c Mon Feb 24 17:15:33 2003 +++ b/drivers/pci/hotplug.c Mon Feb 24 17:15:33 2003 @@ -10,6 +10,7 @@ #define DBG(x...) #endif +static void pci_free_resources(struct pci_dev *dev); #ifdef CONFIG_HOTPLUG int pci_hotplug (struct device *dev, char **envp, int num_envp, @@ -185,7 +186,13 @@ { if (pci_dev_driver(dev)) return -EBUSY; - pci_remove_device(dev); + device_unregister(&dev->dev); + list_del(&dev->bus_list); + list_del(&dev->global_list); + pci_free_resources(dev); +#ifdef CONFIG_PROC_FS + pci_proc_detach_device(dev); +#endif return 0; } EXPORT_SYMBOL(pci_remove_device_safe); @@ -233,15 +240,33 @@ } /** - * pci_remove_device - remove a pci device + * pci_remove_bus_device - remove a PCI device and any children * @dev: the device to remove * - * Delete the device structure from the device lists, - * remove the /proc entry, and notify userspace (/sbin/hotplug). + * Remove a PCI device from the device lists, informing the drivers + * that the device has been removed. We also remove any subordinate + * buses and children in a depth-first manner. + * + * For each device we remove, delete the device structure from the + * device lists, remove the /proc entry, and notify userspace + * (/sbin/hotplug). */ -void -pci_remove_device(struct pci_dev *dev) +void pci_remove_bus_device(struct pci_dev *dev) { + if (dev->subordinate) { + struct pci_bus *b = dev->subordinate; + + pci_remove_behind_bridge(dev); + +#ifdef CONFIG_PROC_FS + pci_proc_detach_bus(b); +#endif + + list_del(&b->node); + kfree(b); + dev->subordinate = NULL; + } + device_unregister(&dev->dev); list_del(&dev->bus_list); list_del(&dev->global_list); @@ -249,9 +274,33 @@ #ifdef CONFIG_PROC_FS pci_proc_detach_device(dev); #endif + + kfree(dev); +} + +/** + * pci_remove_behind_bridge - remove all devices behind a PCI bridge + * @dev: PCI bridge device + * + * Remove all devices on the bus, except for the parent bridge. + * This also removes any child buses, and any devices they may + * contain in a depth-first manner. + */ +void pci_remove_behind_bridge(struct pci_dev *dev) +{ + struct list_head *l, *n; + + if (dev->subordinate) { + list_for_each_safe(l, n, &dev->subordinate->devices) { + struct pci_dev *dev = pci_dev_b(l); + + pci_remove_bus_device(dev); + } + } } #ifdef CONFIG_HOTPLUG EXPORT_SYMBOL(pci_insert_device); -EXPORT_SYMBOL(pci_remove_device); +EXPORT_SYMBOL(pci_remove_bus_device); +EXPORT_SYMBOL(pci_remove_behind_bridge); #endif diff -Nru a/include/linux/pci.h b/include/linux/pci.h --- a/include/linux/pci.h Mon Feb 24 17:15:33 2003 +++ b/include/linux/pci.h Mon Feb 24 17:15:33 2003 @@ -645,7 +645,8 @@ int pci_register_driver(struct pci_driver *); void pci_unregister_driver(struct pci_driver *); void pci_insert_device(struct pci_dev *, struct pci_bus *); -void pci_remove_device(struct pci_dev *); +void pci_remove_bus_device(struct pci_dev *); +void pci_remove_behind_bridge(struct pci_dev *); struct pci_driver *pci_dev_driver(const struct pci_dev *); const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev); unsigned int pci_do_scan_bus(struct pci_bus *bus); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.9, 2003/02/24 16:29:53-08:00, greg@kroah.com [PATCH] Compaq PCI Hotplug: convert to use pci_remove_bus_device instead of custom code. diff -Nru a/drivers/hotplug/cpqphp_pci.c b/drivers/hotplug/cpqphp_pci.c --- a/drivers/hotplug/cpqphp_pci.c Mon Feb 24 17:15:28 2003 +++ b/drivers/hotplug/cpqphp_pci.c Mon Feb 24 17:15:28 2003 @@ -117,94 +117,11 @@ } -static int unconfigure_visit_pci_dev_phase2 (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev* dev = wrapped_dev->dev; - - struct pci_func *temp_func; - int i=0; - - //We need to remove the hotplug function representation with the linux representation - do { - temp_func = cpqhp_slot_find(dev->bus->number, dev->devfn >> 3, i++); - if (temp_func) { - dbg("temp_func->function = %d\n", temp_func->function); - } - } while (temp_func && (temp_func->function != (dev->devfn & 0x07))); - - //Now, remove the Linux Representation - if (dev) { - if (pci_remove_device_safe(dev) == 0) { - kfree(dev); //Now, remove - } else { - return -1; // problems while freeing, abort visitation - } - } - - if (temp_func) { - temp_func->pci_dev = NULL; - } else { - dbg("No pci_func representation for bus, devfn = %d, %x\n", dev->bus->number, dev->devfn); - } - - return 0; -} - - -static int unconfigure_visit_pci_bus_phase2 (struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_dev) -{ - struct pci_bus* bus = wrapped_bus->bus; - - //The cleanup code for proc entries regarding buses should be in the kernel... - if (bus->procdir) - dbg("detach_pci_bus %s\n", bus->procdir->name); - pci_proc_detach_bus(bus); - // The cleanup code should live in the kernel... - bus->self->subordinate = NULL; - // unlink from parent bus - list_del(&bus->node); - - // Now, remove - if (bus) - kfree(bus); - - return 0; -} - - -static int unconfigure_visit_pci_dev_phase1 (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev* dev = wrapped_dev->dev; - - dbg("attempting removal of driver for device (%x, %x, %x)\n", dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); - //Now, remove the Linux Driver Representation - if (dev->driver) { - if (dev->driver->remove) { - dev->driver->remove(dev); - dbg("driver was properly removed\n"); - } - dev->driver = NULL; - } - - return (pci_dev_driver(dev) != NULL); -} - - static struct pci_visit configure_functions = { .visit_pci_dev = configure_visit_pci_dev, }; -static struct pci_visit unconfigure_functions_phase1 = { - .post_visit_pci_dev = unconfigure_visit_pci_dev_phase1 -}; - -static struct pci_visit unconfigure_functions_phase2 = { - .post_visit_pci_bus = unconfigure_visit_pci_bus_phase2, - .post_visit_pci_dev = unconfigure_visit_pci_dev_phase2 -}; - - int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) { unsigned char bus; @@ -258,31 +175,16 @@ int cpqhp_unconfigure_device(struct pci_func* func) { - int rc = 0; int j; - struct pci_dev_wrapped wrapped_dev; - struct pci_bus_wrapped wrapped_bus; - memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); - memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); - dbg("%s: bus/dev/func = %x/%x/%x\n", __FUNCTION__, func->bus, func->device, func->function); for (j=0; j<8 ; j++) { struct pci_dev* temp = pci_find_slot(func->bus, (func->device << 3) | j); - if (temp) { - wrapped_dev.dev = temp; - wrapped_bus.bus = temp->bus; - rc = pci_visit_dev(&unconfigure_functions_phase1, &wrapped_dev, &wrapped_bus); - if (rc) - break; - - rc = pci_visit_dev(&unconfigure_functions_phase2, &wrapped_dev, &wrapped_bus); - if (rc) - break; - } + if (temp) + pci_remove_bus_device(temp); } - return rc; + return 0; } static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 offset, u32 *value) ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.10, 2003/02/24 16:30:40-08:00, greg@kroah.com [PATCH] Compaq PCI Hotplug: remove unused walk of the device on insertion. diff -Nru a/drivers/hotplug/cpqphp_pci.c b/drivers/hotplug/cpqphp_pci.c --- a/drivers/hotplug/cpqphp_pci.c Mon Feb 24 17:15:24 2003 +++ b/drivers/hotplug/cpqphp_pci.c Mon Feb 24 17:15:24 2003 @@ -80,61 +80,14 @@ return fp; } -static int configure_visit_pci_dev (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_bus* bus = wrapped_bus->bus; - struct pci_dev* dev = wrapped_dev->dev; - struct pci_func *temp_func; - int i=0; - - //We need to fix up the hotplug function representation with the linux representation - do { - temp_func = cpqhp_slot_find(dev->bus->number, dev->devfn >> 3, i++); - } while (temp_func && (temp_func->function != (dev->devfn & 0x07))); - - if (temp_func) { - temp_func->pci_dev = dev; - } else { - //We did not even find a hotplug rep of the function, create it - //This code might be taken out if we can guarantee the creation of functions - //in parallel (hotplug and Linux at the same time). - dbg("@@@@@@@@@@@ cpqhp_slot_create in %s\n", __FUNCTION__); - temp_func = cpqhp_slot_create(bus->number); - if (temp_func == NULL) - return -ENOMEM; - temp_func->pci_dev = dev; - } - - //Create /proc/bus/pci proc entry for this device and bus device is on - //Notify the drivers of the change - if (temp_func->pci_dev) { -// pci_insert_device (temp_func->pci_dev, bus); -// pci_proc_attach_device(temp_func->pci_dev); -// pci_announce_device_to_drivers(temp_func->pci_dev); - } - - return 0; -} - - -static struct pci_visit configure_functions = { - .visit_pci_dev = configure_visit_pci_dev, -}; - int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) { unsigned char bus; struct pci_dev dev0; struct pci_bus *child; - struct pci_dev* temp; int rc = 0; - struct pci_dev_wrapped wrapped_dev; - struct pci_bus_wrapped wrapped_bus; - memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); - memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); - memset(&dev0, 0, sizeof(struct pci_dev)); if (func->pci_dev == NULL) @@ -162,13 +115,6 @@ } - temp = func->pci_dev; - - if (temp) { - wrapped_dev.dev = temp; - wrapped_bus.bus = temp->bus; - rc = pci_visit_dev(&configure_functions, &wrapped_dev, &wrapped_bus); - } return rc; } ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.11, 2003/02/24 16:31:00-08:00, greg@kroah.com [PATCH] ACPI PCI hotplug: convert to use pci_remove_bus_device() Also got rid of some unneeded bus walking on device init and shutdown. diff -Nru a/drivers/hotplug/acpiphp_pci.c b/drivers/hotplug/acpiphp_pci.c --- a/drivers/hotplug/acpiphp_pci.c Mon Feb 24 17:15:19 2003 +++ b/drivers/hotplug/acpiphp_pci.c Mon Feb 24 17:15:19 2003 @@ -194,92 +194,6 @@ return 0; } - -/* enable pci_dev */ -static int configure_pci_dev (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct acpiphp_func *func; - struct acpiphp_bridge *bridge; - struct pci_dev *dev; - - func = (struct acpiphp_func *)wrapped_dev->data; - bridge = (struct acpiphp_bridge *)wrapped_bus->data; - dev = wrapped_dev->dev; - - /* TBD: support PCI-to-PCI bridge case */ - if (!func || !bridge) - return 0; - - //pci_proc_attach_device(dev); - //pci_announce_device_to_drivers(dev); - info("Device %s configured\n", dev->slot_name); - - return 0; -} - -/* remove device driver */ -static int unconfigure_pci_dev_driver (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev *dev = wrapped_dev->dev; - - dbg("attempting removal of driver for device %s\n", dev->slot_name); - - /* Now, remove the Linux Driver Representation */ - if (dev->driver) { - if (dev->driver->remove) { - dev->driver->remove(dev); - dbg("driver was properly removed\n"); - } - dev->driver = NULL; - } - - return (pci_dev_driver(dev) != NULL); -} - - -/* remove pci_dev itself from system */ -static int unconfigure_pci_dev (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev *dev = wrapped_dev->dev; - - /* Now, remove the Linux Representation */ - if (dev) { - if (pci_remove_device_safe(dev) == 0) { - info("Device %s removed\n", dev->slot_name); - kfree(dev); /* Now, remove */ - } else { - return -1; /* problems while freeing, abort visitation */ - } - } - - return 0; -} - - -/* remove pci_bus itself from system */ -static int unconfigure_pci_bus (struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_dev) -{ - struct pci_bus *bus = wrapped_bus->bus; - -#ifdef CONFIG_PROC_FS - /* Now, remove the Linux Representation */ - if (bus->procdir) { - pci_proc_detach_bus(bus); - } -#endif - /* the cleanup code should live in the kernel ... */ - bus->self->subordinate = NULL; - /* unlink from parent bus */ - list_del(&bus->node); - - /* Now, remove */ - if (bus) - kfree(bus); - - return 0; -} - - /* detect_used_resource - subtract resource under dev from bridge */ static int detect_used_resource (struct acpiphp_bridge *bridge, struct pci_dev *dev) { @@ -551,22 +465,6 @@ return retval; } - -/* for pci_visit_dev() */ -static struct pci_visit configure_functions = { - .post_visit_pci_dev = configure_pci_dev -}; - -static struct pci_visit unconfigure_functions_phase1 = { - .post_visit_pci_dev = unconfigure_pci_dev_driver -}; - -static struct pci_visit unconfigure_functions_phase2 = { - .post_visit_pci_bus = unconfigure_pci_bus, - .post_visit_pci_dev = unconfigure_pci_dev -}; - - /** * acpiphp_configure_function - configure PCI function * @func: function to be configured @@ -577,33 +475,10 @@ */ int acpiphp_configure_function (struct acpiphp_func *func) { - int retval = 0; - struct pci_dev_wrapped wrapped_dev; - struct pci_bus_wrapped wrapped_bus; - struct acpiphp_bridge *bridge; - - /* if pci_dev is NULL, ignore it */ - if (!func->pci_dev) - goto err_exit; - - bridge = func->slot->bridge; - - memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); - memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); - wrapped_dev.dev = func->pci_dev; - wrapped_dev.data = func; - wrapped_bus.bus = bridge->pci_bus; - wrapped_bus.data = bridge; - - retval = pci_visit_dev(&configure_functions, &wrapped_dev, &wrapped_bus); - if (retval) - goto err_exit; - - err_exit: - return retval; + /* all handled by the pci core now */ + return 0; } - /** * acpiphp_unconfigure_function - unconfigure PCI function * @func: function to be unconfigured @@ -612,28 +487,13 @@ int acpiphp_unconfigure_function (struct acpiphp_func *func) { struct acpiphp_bridge *bridge; - struct pci_dev_wrapped wrapped_dev; - struct pci_bus_wrapped wrapped_bus; int retval = 0; /* if pci_dev is NULL, ignore it */ if (!func->pci_dev) goto err_exit; - memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); - memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); - wrapped_dev.dev = func->pci_dev; - //wrapped_dev.data = func; - wrapped_bus.bus = func->slot->bridge->pci_bus; - //wrapped_bus.data = func->slot->bridge; - - retval = pci_visit_dev(&unconfigure_functions_phase1, &wrapped_dev, &wrapped_bus); - if (retval) - goto err_exit; - - retval = pci_visit_dev(&unconfigure_functions_phase2, &wrapped_dev, &wrapped_bus); - if (retval) - goto err_exit; + pci_remove_bus_device(func->pci_dev); /* free all resources */ bridge = func->slot->bridge; ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.12, 2003/02/24 16:32:16-08:00, greg@kroah.com [PATCH] IBM PCI Hotplug: convert driver to use pci_bus_remove_device() Also cleaned up a lot of unnecessary bus walking on device startup and shutdown. diff -Nru a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c --- a/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:15 2003 +++ b/drivers/hotplug/ibmphp_core.c Mon Feb 24 17:15:15 2003 @@ -781,141 +781,23 @@ debug ("%s -- exit\n", __FUNCTION__); } -static int ibm_unconfigure_visit_pci_dev_phase2 (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev *dev = wrapped_dev->dev; - struct pci_func *temp_func; - int i = 0; - - do { - temp_func = ibm_slot_find (dev->bus->number, dev->devfn >> 3, i++); - } while (temp_func && (temp_func->function != (dev->devfn & 0x07))); - - if (dev) { - if (pci_remove_device_safe(dev) == 0) - kfree (dev); /* Now, remove */ - else - return -1; - } - - if (temp_func) - temp_func->dev = NULL; - else - debug ("No pci_func representation for bus, devfn = %d, %x\n", dev->bus->number, dev->devfn); - - return 0; -} - -static int ibm_unconfigure_visit_pci_bus_phase2 (struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_dev) -{ - struct pci_bus *bus = wrapped_bus->bus; - - pci_proc_detach_bus (bus); - /* The cleanup code should live in the kernel... */ - bus->self->subordinate = NULL; - /* unlink from parent bus */ - list_del (&bus->node); - - /* Now, remove */ - if (bus) - kfree (bus); - - return 0; -} - -static int ibm_unconfigure_visit_pci_dev_phase1 (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev *dev = wrapped_dev->dev; - - debug ("attempting removal of driver for device (%x, %x, %x)\n", dev->bus->number, PCI_SLOT (dev->devfn), PCI_FUNC (dev->devfn)); - - /* Now, remove the Linux Driver Representation */ - if (dev->driver) { - debug ("is there a driver?\n"); - if (dev->driver->remove) { - dev->driver->remove (dev); - debug ("driver was properly removed\n"); - } - dev->driver = NULL; - } - - return (pci_dev_driver(dev) != NULL); -} - -static struct pci_visit ibm_unconfigure_functions_phase1 = { - .post_visit_pci_dev = ibm_unconfigure_visit_pci_dev_phase1, -}; - -static struct pci_visit ibm_unconfigure_functions_phase2 = { - .post_visit_pci_bus = ibm_unconfigure_visit_pci_bus_phase2, - .post_visit_pci_dev = ibm_unconfigure_visit_pci_dev_phase2, -}; - static int ibm_unconfigure_device (struct pci_func *func) { - int rc = 0; - struct pci_dev_wrapped wrapped_dev; - struct pci_bus_wrapped wrapped_bus; struct pci_dev *temp; u8 j; - memset (&wrapped_dev, 0, sizeof (struct pci_dev_wrapped)); - memset (&wrapped_bus, 0, sizeof (struct pci_bus_wrapped)); - - debug ("inside ibm_unconfigure_device\n"); + debug ("inside %s\n", __FUNCTION__); debug ("func->device = %x, func->function = %x\n", func->device, func->function); debug ("func->device << 3 | 0x0 = %x\n", func->device << 3 | 0x0); for (j = 0; j < 0x08; j++) { temp = pci_find_slot (func->busno, (func->device << 3) | j); - if (temp) { - wrapped_dev.dev = temp; - wrapped_bus.bus = temp->bus; - rc = pci_visit_dev (&ibm_unconfigure_functions_phase1, &wrapped_dev, &wrapped_bus); - if (rc) - break; - - rc = pci_visit_dev (&ibm_unconfigure_functions_phase2, &wrapped_dev, &wrapped_bus); - if (rc) - break; - } + if (temp) + pci_remove_bus_device(temp); } - debug ("rc in ibm_unconfigure_device b4 returning is %d \n", rc); - return rc; -} - -static int configure_visit_pci_dev (struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) -{ - // struct pci_bus *bus = wrapped_bus->bus; /* We don't need this, since we don't create in the else statement */ - struct pci_dev *dev = wrapped_dev->dev; - struct pci_func *temp_func; - int i = 0; - - do { - temp_func = ibm_slot_find (dev->bus->number, dev->devfn >> 3, i++); - } while (temp_func && (temp_func->function != (dev->devfn & 0x07))); - - if (temp_func) - temp_func->dev = dev; - else { - /* This should not really happen, since we create functions - first and then call to configure */ - debug (" We shouldn't come here \n"); - } - - if (temp_func->dev) { -// pci_proc_attach_device (temp_func->dev); -// pci_announce_device_to_drivers (temp_func->dev); - } - return 0; } -static struct pci_visit configure_functions = { - .visit_pci_dev =configure_visit_pci_dev, -}; - - /* * The following function is to fix kernel bug regarding * getting bus entries, here we manually add those primary @@ -965,15 +847,9 @@ unsigned char bus; struct pci_dev dev0; struct pci_bus *child; - struct pci_dev *temp; int rc = 0; int flag = 0; /* this is to make sure we don't double scan the bus, for bridged devices primarily */ - struct pci_dev_wrapped wrapped_dev; - struct pci_bus_wrapped wrapped_bus; - - memset (&wrapped_dev, 0, sizeof (struct pci_dev_wrapped)); - memset (&wrapped_bus, 0, sizeof (struct pci_bus_wrapped)); memset (&dev0, 0, sizeof (struct pci_dev)); if (!(bus_structure_fixup (func->busno))) @@ -1001,12 +877,6 @@ pci_do_scan_bus (child); } - temp = func->dev; - if (temp) { - wrapped_dev.dev = temp; - wrapped_bus.bus = temp->bus; - rc = pci_visit_dev (&configure_functions, &wrapped_dev, &wrapped_bus); - } return rc; } ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.13, 2003/02/24 16:33:09-08:00, greg@kroah.com [PATCH] PCI: export pci_scan_bus_parented which is needed by the IBM pci hotplug driver. diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c --- a/drivers/pci/probe.c Mon Feb 24 17:15:10 2003 +++ b/drivers/pci/probe.c Mon Feb 24 17:15:10 2003 @@ -609,6 +609,7 @@ } return b; } +EXPORT_SYMBOL(pci_scan_bus_parented); EXPORT_SYMBOL(pci_devices); EXPORT_SYMBOL(pci_root_buses); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:16 ` Greg KH @ 2003-02-25 1:16 ` Greg KH 0 siblings, 0 replies; 20+ messages in thread From: Greg KH @ 2003-02-25 1:16 UTC (permalink / raw) To: linux-kernel, pcihpd-discuss ChangeSet 1.1022.1.14, 2003/02/24 16:35:48-08:00, greg@kroah.com [PATCH] CPCI core: remove unneeded visit device on unconfigure. The driver now links properly, but this is untested due to my lack of cPCI hardware. diff -Nru a/drivers/hotplug/cpci_hotplug_pci.c b/drivers/hotplug/cpci_hotplug_pci.c --- a/drivers/hotplug/cpci_hotplug_pci.c Mon Feb 24 17:15:06 2003 +++ b/drivers/hotplug/cpci_hotplug_pci.c Mon Feb 24 17:15:06 2003 @@ -483,29 +483,6 @@ return 0; } -static int unconfigure_visit_pci_dev_phase1(struct pci_dev_wrapped *wrapped_dev, - struct pci_bus_wrapped *wrapped_bus) -{ - struct pci_dev *dev = wrapped_dev->dev; - - dbg("%s - enter", __FUNCTION__); - - dbg("attempting removal of driver for device %02x:%02x.%x", - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); - - /* Now, remove the Linux Driver representation */ - if(dev->driver) { - dbg("device is attached to a driver"); - if(dev->driver->remove) { - dev->driver->remove(dev); - dbg("driver was removed"); - } - dev->driver = NULL; - } - dbg("%s - exit", __FUNCTION__); - return pci_is_dev_in_use(dev); -} - static int unconfigure_visit_pci_dev_phase2(struct pci_dev_wrapped *wrapped_dev, struct pci_bus_wrapped *wrapped_bus) { @@ -577,10 +554,6 @@ .visit_pci_dev = configure_visit_pci_dev, }; -static struct pci_visit unconfigure_functions_phase1 = { - .post_visit_pci_dev = unconfigure_visit_pci_dev_phase1 -}; - static struct pci_visit unconfigure_functions_phase2 = { .post_visit_pci_bus = unconfigure_visit_pci_bus_phase2, .post_visit_pci_dev = unconfigure_visit_pci_dev_phase2 @@ -668,13 +641,6 @@ if(dev) { wrapped_dev.dev = dev; wrapped_bus.bus = dev->bus; - dbg("%s - unconfigure phase 1", __FUNCTION__); - rc = pci_visit_dev(&unconfigure_functions_phase1, - &wrapped_dev, &wrapped_bus); - if(rc) { - break; - } - dbg("%s - unconfigure phase 2", __FUNCTION__); rc = pci_visit_dev(&unconfigure_functions_phase2, &wrapped_dev, &wrapped_bus); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [BK PATCH] PCI hotplug changes for 2.5.63 2003-02-25 1:13 [BK PATCH] PCI hotplug changes for 2.5.63 Greg KH 2003-02-25 1:15 ` [PATCH] " Greg KH @ 2003-02-28 23:59 ` Greg KH 2003-03-01 18:55 ` Linus Torvalds 1 sibling, 1 reply; 20+ messages in thread From: Greg KH @ 2003-02-28 23:59 UTC (permalink / raw) To: torvalds; +Cc: linux-kernel, pcihpd-discuss On Mon, Feb 24, 2003 at 05:13:03PM -0800, Greg KH wrote: > Hi, > > Here's some patches that clean up the remove logic a lot for the PCI > hotplug drivers. The main PCI patches were done by Russell King and > Christoph Hellwig, and then I went and cleaned up the PCI Hotplug > drivers a lot based on their changes. I also fixed up some exit logic > in the IBM PCI hotplug driver, as it was a mess. > > Please pull from: bk://kernel.bkbits.net/gregkh/linux/pci-2.5 I've merged with your latest tree again, and it's available at the above place. Could you please pull these changes? thanks, greg k-h ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [BK PATCH] PCI hotplug changes for 2.5.63 2003-02-28 23:59 ` [BK PATCH] " Greg KH @ 2003-03-01 18:55 ` Linus Torvalds 2003-03-01 21:38 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Linus Torvalds @ 2003-03-01 18:55 UTC (permalink / raw) To: Greg KH; +Cc: linux-kernel, pcihpd-discuss On Fri, 28 Feb 2003, Greg KH wrote: > > I've merged with your latest tree again, and it's available at the above > place. Could you please pull these changes? This causes drivers/built-in.o(.text+0xedc7e): In function `cb_free': : undefined reference to `pci_remove_device' make: *** [.tmp_vmlinux1] Error 1 Ehh? Linus ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [BK PATCH] PCI hotplug changes for 2.5.63 2003-03-01 18:55 ` Linus Torvalds @ 2003-03-01 21:38 ` Greg KH 2003-03-01 22:00 ` Linus Torvalds 0 siblings, 1 reply; 20+ messages in thread From: Greg KH @ 2003-03-01 21:38 UTC (permalink / raw) To: Linus Torvalds; +Cc: linux-kernel, pcihpd-discuss On Sat, Mar 01, 2003 at 10:55:50AM -0800, Linus Torvalds wrote: > > On Fri, 28 Feb 2003, Greg KH wrote: > > > > I've merged with your latest tree again, and it's available at the above > > place. Could you please pull these changes? > > This causes > > drivers/built-in.o(.text+0xedc7e): In function `cb_free': > : undefined reference to `pci_remove_device' > make: *** [.tmp_vmlinux1] Error 1 > > Ehh? Oops, looks like Russell and I didn't test on a cardbus machine :) I've made the following change to the repository, so you can just pull it if you want to (from bk://kernel.bkbits.net/gregkh/linux/pci-2.5 ) or you can just apply this patch. It looks right to me, but I don't have a working cardbus machine at the moment, so I can't test it, sorry. Again, sorry about this. greg k-h # Cardbus: change cb_free to use pci_remove_device_safe() diff -Nru a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c --- a/drivers/pcmcia/cardbus.c Sat Mar 1 13:49:27 2003 +++ b/drivers/pcmcia/cardbus.c Sat Mar 1 13:49:27 2003 @@ -313,7 +313,7 @@ s->cb_config = NULL; for (i = 0 ; i < s->functions ; i++) - pci_remove_device(&c[i].dev); + pci_remove_device_safe(&c[i].dev); kfree(c); printk(KERN_INFO "cs: cb_free(bus %d)\n", s->cap.cb_dev->subordinate->number); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [BK PATCH] PCI hotplug changes for 2.5.63 2003-03-01 21:38 ` Greg KH @ 2003-03-01 22:00 ` Linus Torvalds 2003-03-01 22:25 ` Greg KH 0 siblings, 1 reply; 20+ messages in thread From: Linus Torvalds @ 2003-03-01 22:00 UTC (permalink / raw) To: Greg KH; +Cc: linux-kernel, pcihpd-discuss On Sat, 1 Mar 2003, Greg KH wrote: > > It looks right to me, but I don't have a working cardbus machine at the > moment, so I can't test it, sorry. I don't think this is right. When we unplug a device, we're unplugging it whether it is unused or not, and pci_remove_device_safe() is the wrong thing. It should use the "remove_behind_bridge()" thing, so I think Russell's patch is closer to working, but that one looked like it will certainly corrupt memory with any multi-function device, so I really would want to see something that has actually been tested too. Linus ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [BK PATCH] PCI hotplug changes for 2.5.63 2003-03-01 22:00 ` Linus Torvalds @ 2003-03-01 22:25 ` Greg KH 0 siblings, 0 replies; 20+ messages in thread From: Greg KH @ 2003-03-01 22:25 UTC (permalink / raw) To: Linus Torvalds; +Cc: linux-kernel, pcihpd-discuss On Sat, Mar 01, 2003 at 02:00:58PM -0800, Linus Torvalds wrote: > > On Sat, 1 Mar 2003, Greg KH wrote: > > > > It looks right to me, but I don't have a working cardbus machine at the > > moment, so I can't test it, sorry. > > I don't think this is right. When we unplug a device, we're unplugging it > whether it is unused or not, and pci_remove_device_safe() is the wrong > thing. It should use the "remove_behind_bridge()" thing, so I think > Russell's patch is closer to working, but that one looked like it will > certainly corrupt memory with any multi-function device, so I really would > want to see something that has actually been tested too. Fair enough, I'll try to get my laptop up and running this evening and test these changes out on it. thanks, greg k-h ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2003-03-01 22:24 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-02-25 1:13 [BK PATCH] PCI hotplug changes for 2.5.63 Greg KH 2003-02-25 1:15 ` [PATCH] " Greg KH 2003-02-25 1:15 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-25 1:16 ` Greg KH 2003-02-28 23:59 ` [BK PATCH] " Greg KH 2003-03-01 18:55 ` Linus Torvalds 2003-03-01 21:38 ` Greg KH 2003-03-01 22:00 ` Linus Torvalds 2003-03-01 22:25 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox