Skip to content

Commit

Permalink
[PATCH] shpchp: dont save PCI config for hotplug slots/devices
Browse files Browse the repository at this point in the history
This patch eliminates saving the PCI config header for devices
in hotplug capable slots. We now use the PCI core to get the
specific parts of the config header as required.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
rajesh.shah@intel.com authored and Greg Kroah-Hartman committed Oct 28, 2005
1 parent 1410dc1 commit 70b6091
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 338 deletions.
1 change: 0 additions & 1 deletion drivers/pci/hotplug/shpchp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ struct pci_func {
u8 switch_save;
u8 presence_save;
u8 pwr_save;
u32 config_space[0x20];
struct pci_dev* pci_dev;
};

Expand Down
7 changes: 0 additions & 7 deletions drivers/pci/hotplug/shpchp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,6 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
first_device_num = ctrl->slot_device_offset;
num_ctlr_slots = ctrl->num_slots;

/* Store PCI Config Space for all devices on this bus */
rc = shpchp_save_config(ctrl, ctrl->slot_bus, num_ctlr_slots, first_device_num);
if (rc) {
err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
goto err_out_free_ctrl_bus;
}

ctrl->add_support = 1;

/* Setup the slot information structures */
Expand Down
48 changes: 32 additions & 16 deletions drivers/pci/hotplug/shpchp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,20 @@ static int slot_remove(struct pci_func * old_slot)
/**
* bridge_slot_remove - Removes a node from the linked list of slots.
* @bridge: bridge to remove
* @secondaryBus: secondary PCI bus number for bridge being removed
* @subordinateBus: subordinate PCI bus number for bridge being removed
*
* Returns 0 if successful, !0 otherwise.
*/
static int bridge_slot_remove(struct pci_func *bridge)
static int bridge_slot_remove(struct pci_func *bridge, u8 secondaryBus,
u8 subordinateBus)
{
u8 subordinateBus, secondaryBus;
u8 tempBus;
struct pci_func *next;

if (bridge == NULL)
return(1);

secondaryBus = (bridge->config_space[0x06] >> 8) & 0xFF;
subordinateBus = (bridge->config_space[0x06] >> 16) & 0xFF;

for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) {
next = shpchp_slot_list[tempBus];

Expand Down Expand Up @@ -410,16 +409,23 @@ struct pci_func *shpchp_slot_find(u8 bus, u8 device, u8 index)
return(NULL);
}

static int is_bridge(struct pci_func * func)
static int is_bridge(struct pci_func *func, struct controller *ctrl)
{
/* Check the header type */
if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01)
u8 hdr_type;
struct pci_bus *bus = ctrl->pci_dev->subordinate;

/*
* Note: device may have just been hot-added and not yet scanned
* by the pci core, so its pci_dev structure may not exist yet
*/
pci_bus_read_config_byte(bus, PCI_DEVFN(func->device, func->function),
PCI_HEADER_TYPE, &hdr_type);
if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE)
return 1;
else
return 0;
}


/* The following routines constitute the bulk of the
hotplug controller logic
*/
Expand Down Expand Up @@ -709,8 +715,6 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
goto err_exit;
}

shpchp_save_slot_config(ctrl, func);

func->status = 0;
func->switch_save = 0x10;
func->is_a_board = 0x01;
Expand Down Expand Up @@ -769,10 +773,18 @@ static u32 remove_board(struct pci_func *func, struct controller *ctrl)
u8 hp_slot;
u32 rc;
struct slot *p_slot;
u8 secondary = 0, subordinate = 0;
int remove_bridge;

if (func == NULL)
return(1);

if ((remove_bridge = is_bridge(func, ctrl))) {
/* Stash away bus information before we destroy it */
secondary = func->pci_dev->subordinate->secondary;
subordinate = func->pci_dev->subordinate->subordinate;
}

if (shpchp_unconfigure_device(func))
return(1);

Expand Down Expand Up @@ -825,10 +837,11 @@ static u32 remove_board(struct pci_func *func, struct controller *ctrl)

if (ctrl->add_support) {
while (func) {
if (is_bridge(func)) {
if (remove_bridge) {
dbg("PCI Bridge Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus,
func->device, func->function);
bridge_slot_remove(func);
bridge_slot_remove(func, secondary,
subordinate);
} else
dbg("PCI Function Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus,
func->device, func->function);
Expand Down Expand Up @@ -1185,9 +1198,12 @@ int shpchp_enable_slot (struct slot *p_slot)

rc = board_added(func, p_slot->ctrl);
if (rc) {
if (is_bridge(func))
bridge_slot_remove(func);
else
if (is_bridge(func, p_slot->ctrl)) {
u8 secondary = func->pci_dev->subordinate->secondary;
u8 subordinate =
func->pci_dev->subordinate->subordinate;
bridge_slot_remove(func, secondary, subordinate);
} else
slot_remove(func);

/* Setup slot structure with entry for empty slot */
Expand Down
Loading

0 comments on commit 70b6091

Please sign in to comment.