Skip to content

Commit

Permalink
[PATCH] shpchp: use the PCI core for hotplug resource management
Browse files Browse the repository at this point in the history
This patch converts the standard hotplug controller driver to use
the PCI core for resource management. This eliminates a whole lot
of duplicated code, and integrates shpchp in the system's normal
PCI handling code.

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 e3b1bd5 commit dbd7a78
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 3,756 deletions.
57 changes: 1 addition & 56 deletions drivers/pci/hotplug/shpchp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,7 @@ struct pci_func {
u8 switch_save;
u8 presence_save;
u8 pwr_save;
u32 base_length[0x06];
u8 base_type[0x06];
u16 reserved2;
u32 config_space[0x20];
struct pci_resource *mem_head;
struct pci_resource *p_mem_head;
struct pci_resource *io_head;
struct pci_resource *bus_head;
struct pci_dev* pci_dev;
};

Expand All @@ -96,12 +89,6 @@ struct slot {
struct list_head slot_list;
};

struct pci_resource {
struct pci_resource * next;
u32 base;
u32 length;
};

struct event_info {
u32 event_type;
u8 hp_slot;
Expand All @@ -113,10 +100,6 @@ struct controller {
void * hpc_ctlr_handle; /* HPC controller handle */
int num_slots; /* Number of slots on ctlr */
int slot_num_inc; /* 1 or -1 */
struct pci_resource *mem_head;
struct pci_resource *p_mem_head;
struct pci_resource *io_head;
struct pci_resource *bus_head;
struct pci_dev *pci_dev;
struct pci_bus *pci_bus;
struct event_info event_queue[10];
Expand All @@ -139,20 +122,6 @@ struct controller {
u16 vendor_id;
};

struct irq_mapping {
u8 barber_pole;
u8 valid_INT;
u8 interrupt[4];
};

struct resource_lists {
struct pci_resource *mem_head;
struct pci_resource *p_mem_head;
struct pci_resource *io_head;
struct pci_resource *bus_head;
struct irq_mapping *irqs;
};

/* Define AMD SHPC ID */
#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450

Expand Down Expand Up @@ -197,7 +166,6 @@ struct resource_lists {
#define msg_HPC_rev_error "Unsupported revision of the PCI hot plug controller found.\n"
#define msg_HPC_non_shpc "The PCI hot plug controller is not supported by this driver.\n"
#define msg_HPC_not_supported "This system is not supported by this version of shpcphd mdoule. Upgrade to a newer version of shpchpd\n"
#define msg_unable_to_save "Unable to store PCI hot plug add resource information. This system must be rebooted before adding any PCI devices.\n"
#define msg_button_on "PCI slot #%d - powering on due to button press.\n"
#define msg_button_off "PCI slot #%d - powering off due to button press.\n"
#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n"
Expand All @@ -207,7 +175,6 @@ struct resource_lists {
extern void shpchp_create_ctrl_files (struct controller *ctrl);

/* controller functions */
extern int shpchprm_find_available_resources(struct controller *ctrl);
extern int shpchp_event_start_thread(void);
extern void shpchp_event_stop_thread(void);
extern struct pci_func *shpchp_slot_create(unsigned char busnumber);
Expand All @@ -220,30 +187,17 @@ extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id);
extern u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id);
extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id);

/* resource functions */
extern int shpchp_resource_sort_and_combine(struct pci_resource **head);

/* pci functions */
extern int shpchp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
/*extern int shpchp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num, struct slot *slot);*/
extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num);
extern int shpchp_save_used_resources(struct controller *ctrl, struct pci_func * func, int flag);
extern int shpchp_save_slot_config(struct controller *ctrl, struct pci_func * new_slot);
extern void shpchp_destroy_board_resources(struct pci_func * func);
extern int shpchp_return_board_resources(struct pci_func * func, struct resource_lists * resources);
extern void shpchp_destroy_resource_list(struct resource_lists * resources);
extern int shpchp_configure_device(struct controller* ctrl, struct pci_func* func);
extern int shpchp_configure_device(struct slot *p_slot);
extern int shpchp_unconfigure_device(struct pci_func* func);


/* Global variables */
extern struct controller *shpchp_ctrl_list;
extern struct pci_func *shpchp_slot_list[256];

/* These are added to support AMD shpc */
extern u8 shpchp_nic_irq;
extern u8 shpchp_disk_irq;

struct ctrl_reg {
volatile u32 base_offset;
volatile u32 slot_avail1;
Expand Down Expand Up @@ -398,15 +352,6 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl)
return retval;
}

/* Puts node back in the resource list pointed to by head */
static inline void return_resource(struct pci_resource **head, struct pci_resource *node)
{
if (!node || !head)
return;
node->next = *head;
*head = node;
}

#define SLOT_NAME_SIZE 10

static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
Expand Down
36 changes: 2 additions & 34 deletions drivers/pci/hotplug/shpchp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,8 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_free_ctrl_bus;
}

/* Get IO, memory, and IRQ resources for new devices */
rc = shpchprm_find_available_resources(ctrl);
ctrl->add_support = !rc;
ctrl->add_support = 1;

if (rc) {
dbg("shpchprm_find_available_resources = %#x\n", rc);
err("unable to locate PCI configuration resources for hot plug add.\n");
goto err_out_free_ctrl_bus;
}

/* Setup the slot information structures */
rc = init_slots(ctrl);
if (rc) {
Expand Down Expand Up @@ -497,18 +489,6 @@ static int shpc_start_thread(void)
return retval;
}

static inline void __exit
free_shpchp_res(struct pci_resource *res)
{
struct pci_resource *tres;

while (res) {
tres = res;
res = res->next;
kfree(tres);
}
}

static void __exit unload_shpchpd(void)
{
struct pci_func *next;
Expand All @@ -522,11 +502,6 @@ static void __exit unload_shpchpd(void)
while (ctrl) {
cleanup_slots(ctrl);

free_shpchp_res(ctrl->io_head);
free_shpchp_res(ctrl->mem_head);
free_shpchp_res(ctrl->p_mem_head);
free_shpchp_res(ctrl->bus_head);

kfree (ctrl->pci_bus);

dbg("%s: calling release_ctlr\n", __FUNCTION__);
Expand All @@ -541,11 +516,6 @@ static void __exit unload_shpchpd(void)
for (loop = 0; loop < 256; loop++) {
next = shpchp_slot_list[loop];
while (next != NULL) {
free_shpchp_res(next->io_head);
free_shpchp_res(next->mem_head);
free_shpchp_res(next->p_mem_head);
free_shpchp_res(next->bus_head);

TempSlot = next;
next = next->next;
kfree(TempSlot);
Expand Down Expand Up @@ -607,9 +577,7 @@ static int __init shpcd_init(void)
if (retval) {
shpchprm_cleanup();
shpchp_event_stop_thread();
} else
shpchprm_print_pirt();

}
return retval;
}

Expand Down
Loading

0 comments on commit dbd7a78

Please sign in to comment.