Commit 3a2c5dad authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6:
  PCI: remove unused resource assignment in pci_read_bridge_bases()
  PCI hotplug: shpchp: message refinement
  PCI hotplug: shpchp: replace printk with dev_printk
  PCI: add routines for debugging and handling lost interrupts
  PCI hotplug: pciehp: message refinement
  PCI: fix ARI code to be compatible with mixed ARI/non-ARI systems
  PCI hotplug: cpqphp: fix kernel NULL pointer dereference
parents 2242d5ef a491913f
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
# #
obj-y += access.o bus.o probe.o remove.o pci.o quirks.o slot.o \ obj-y += access.o bus.o probe.o remove.o pci.o quirks.o slot.o \
pci-driver.o search.o pci-sysfs.o rom.o setup-res.o pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \
irq.o
obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_PROC_FS) += proc.o
# Build PCI Express stuff if needed # Build PCI Express stuff if needed
......
...@@ -433,7 +433,7 @@ static int ctrl_slot_setup(struct controller *ctrl, ...@@ -433,7 +433,7 @@ static int ctrl_slot_setup(struct controller *ctrl,
slot->number, ctrl->slot_device_offset, slot->number, ctrl->slot_device_offset,
slot_number); slot_number);
result = pci_hp_register(hotplug_slot, result = pci_hp_register(hotplug_slot,
ctrl->pci_dev->subordinate, ctrl->pci_dev->bus,
slot->device, slot->device,
name); name);
if (result) { if (result) {
......
...@@ -188,7 +188,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) ...@@ -188,7 +188,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
return slot; return slot;
} }
ctrl_err(ctrl, "%s: slot (device=0x%x) not found\n", __func__, device); ctrl_err(ctrl, "Slot (device=0x%02x) not found\n", device);
return NULL; return NULL;
} }
......
...@@ -184,7 +184,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot) ...@@ -184,7 +184,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, hotplug_slot_name(hotplug_slot)); __func__, hotplug_slot_name(hotplug_slot));
kfree(hotplug_slot->info); kfree(hotplug_slot->info);
...@@ -216,9 +216,11 @@ static int init_slots(struct controller *ctrl) ...@@ -216,9 +216,11 @@ static int init_slots(struct controller *ctrl)
slot->hotplug_slot = hotplug_slot; slot->hotplug_slot = hotplug_slot;
snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); snprintf(name, SLOT_NAME_SIZE, "%u", slot->number);
ctrl_dbg(ctrl, "Registering bus=%x dev=%x hp_slot=%x sun=%x " ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x "
"slot_device_offset=%x\n", slot->bus, slot->device, "hp_slot=%x sun=%x slot_device_offset=%x\n",
slot->hp_slot, slot->number, ctrl->slot_device_offset); pci_domain_nr(ctrl->pci_dev->subordinate),
slot->bus, slot->device, slot->hp_slot, slot->number,
ctrl->slot_device_offset);
retval = pci_hp_register(hotplug_slot, retval = pci_hp_register(hotplug_slot,
ctrl->pci_dev->subordinate, ctrl->pci_dev->subordinate,
slot->device, slot->device,
...@@ -238,7 +240,7 @@ static int init_slots(struct controller *ctrl) ...@@ -238,7 +240,7 @@ static int init_slots(struct controller *ctrl)
&hotplug_slot_attr_lock.attr); &hotplug_slot_attr_lock.attr);
if (retval) { if (retval) {
pci_hp_deregister(hotplug_slot); pci_hp_deregister(hotplug_slot);
ctrl_err(ctrl, "cannot create additional sysfs " ctrl_err(ctrl, "Cannot create additional sysfs "
"entries\n"); "entries\n");
goto error_info; goto error_info;
} }
...@@ -273,7 +275,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) ...@@ -273,7 +275,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
hotplug_slot->info->attention_status = status; hotplug_slot->info->attention_status = status;
...@@ -289,7 +291,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) ...@@ -289,7 +291,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_sysfs_enable_slot(slot); return pciehp_sysfs_enable_slot(slot);
...@@ -300,7 +302,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) ...@@ -300,7 +302,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_sysfs_disable_slot(slot); return pciehp_sysfs_disable_slot(slot);
...@@ -311,7 +313,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -311,7 +313,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
retval = slot->hpc_ops->get_power_status(slot, value); retval = slot->hpc_ops->get_power_status(slot, value);
...@@ -326,7 +328,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -326,7 +328,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
retval = slot->hpc_ops->get_attention_status(slot, value); retval = slot->hpc_ops->get_attention_status(slot, value);
...@@ -341,7 +343,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -341,7 +343,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
retval = slot->hpc_ops->get_latch_status(slot, value); retval = slot->hpc_ops->get_latch_status(slot, value);
...@@ -356,7 +358,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -356,7 +358,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
retval = slot->hpc_ops->get_adapter_status(slot, value); retval = slot->hpc_ops->get_adapter_status(slot, value);
...@@ -372,7 +374,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, ...@@ -372,7 +374,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
retval = slot->hpc_ops->get_max_bus_speed(slot, value); retval = slot->hpc_ops->get_max_bus_speed(slot, value);
...@@ -387,7 +389,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe ...@@ -387,7 +389,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
retval = slot->hpc_ops->get_cur_bus_speed(slot, value); retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
...@@ -414,7 +416,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ ...@@ -414,7 +416,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
ctrl = pcie_init(dev); ctrl = pcie_init(dev);
if (!ctrl) { if (!ctrl) {
dev_err(&dev->device, "controller initialization failed\n"); dev_err(&dev->device, "Controller initialization failed\n");
goto err_out_none; goto err_out_none;
} }
set_service_data(dev, ctrl); set_service_data(dev, ctrl);
...@@ -423,10 +425,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ ...@@ -423,10 +425,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
rc = init_slots(ctrl); rc = init_slots(ctrl);
if (rc) { if (rc) {
if (rc == -EBUSY) if (rc == -EBUSY)
ctrl_warn(ctrl, "slot already registered by another " ctrl_warn(ctrl, "Slot already registered by another "
"hotplug driver\n"); "hotplug driver\n");
else else
ctrl_err(ctrl, "slot initialization failed\n"); ctrl_err(ctrl, "Slot initialization failed\n");
goto err_out_release_ctlr; goto err_out_release_ctlr;
} }
...@@ -523,7 +525,7 @@ static int __init pcied_init(void) ...@@ -523,7 +525,7 @@ static int __init pcied_init(void)
dbg("pcie_port_service_register = %d\n", retval); dbg("pcie_port_service_register = %d\n", retval);
info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
if (retval) if (retval)
dbg("%s: Failure to register service\n", __func__); dbg("Failure to register service\n");
return retval; return retval;
} }
......
...@@ -61,7 +61,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot) ...@@ -61,7 +61,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot)
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
/* Attention Button Change */ /* Attention Button Change */
ctrl_dbg(ctrl, "Attention button interrupt received.\n"); ctrl_dbg(ctrl, "Attention button interrupt received\n");
/* /*
* Button pressed - See if need to TAKE ACTION!!! * Button pressed - See if need to TAKE ACTION!!!
...@@ -81,7 +81,7 @@ u8 pciehp_handle_switch_change(struct slot *p_slot) ...@@ -81,7 +81,7 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
/* Switch Change */ /* Switch Change */
ctrl_dbg(ctrl, "Switch interrupt received.\n"); ctrl_dbg(ctrl, "Switch interrupt received\n");
p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (getstatus) { if (getstatus) {
...@@ -110,7 +110,7 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) ...@@ -110,7 +110,7 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
/* Presence Change */ /* Presence Change */
ctrl_dbg(ctrl, "Presence/Notify input change.\n"); ctrl_dbg(ctrl, "Presence/Notify input change\n");
/* Switch is open, assume a presence change /* Switch is open, assume a presence change
* Save the presence state * Save the presence state
...@@ -142,7 +142,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot) ...@@ -142,7 +142,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
/* power fault */ /* power fault */
ctrl_dbg(ctrl, "Power fault interrupt received.\n"); ctrl_dbg(ctrl, "Power fault interrupt received\n");
if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
/* /*
...@@ -157,7 +157,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot) ...@@ -157,7 +157,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
*/ */
ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot)); ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot));
event_type = INT_POWER_FAULT; event_type = INT_POWER_FAULT;
ctrl_info(ctrl, "power fault bit %x set\n", 0); ctrl_info(ctrl, "Power fault bit %x set\n", 0);
} }
queue_interrupt_event(p_slot, event_type); queue_interrupt_event(p_slot, event_type);
...@@ -175,8 +175,7 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -175,8 +175,7 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
if (pslot->hpc_ops->power_off_slot(pslot)) { if (pslot->hpc_ops->power_off_slot(pslot)) {
ctrl_err(ctrl, ctrl_err(ctrl,
"%s: Issue of Slot Power Off command failed\n", "Issue of Slot Power Off command failed\n");
__func__);
return; return;
} }
} }
...@@ -193,8 +192,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -193,8 +192,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
if (ATTN_LED(ctrl)) { if (ATTN_LED(ctrl)) {
if (pslot->hpc_ops->set_attention_status(pslot, 1)) { if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
ctrl_err(ctrl, "%s: Issue of Set Attention " ctrl_err(ctrl,
"Led command failed\n", __func__); "Issue of Set Attention Led command failed\n");
return; return;
} }
} }
...@@ -211,8 +210,9 @@ static int board_added(struct slot *p_slot) ...@@ -211,8 +210,9 @@ static int board_added(struct slot *p_slot)
{ {
int retval = 0; int retval = 0;
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
struct pci_bus *parent = ctrl->pci_dev->subordinate;
ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d ,%d\n", ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d, %d\n",
__func__, p_slot->device, ctrl->slot_device_offset, __func__, p_slot->device, ctrl->slot_device_offset,
p_slot->hp_slot); p_slot->hp_slot);
...@@ -229,22 +229,22 @@ static int board_added(struct slot *p_slot) ...@@ -229,22 +229,22 @@ static int board_added(struct slot *p_slot)
/* Check link training status */ /* Check link training status */
retval = p_slot->hpc_ops->check_lnk_status(ctrl); retval = p_slot->hpc_ops->check_lnk_status(ctrl);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s: Failed to check link status\n", __func__); ctrl_err(ctrl, "Failed to check link status\n");
set_slot_off(ctrl, p_slot); set_slot_off(ctrl, p_slot);
return retval; return retval;
} }
/* Check for a power fault */ /* Check for a power fault */
if (p_slot->hpc_ops->query_power_fault(p_slot)) { if (p_slot->hpc_ops->query_power_fault(p_slot)) {
ctrl_dbg(ctrl, "%s: power fault detected\n", __func__); ctrl_dbg(ctrl, "Power fault detected\n");
retval = POWER_FAILURE; retval = POWER_FAILURE;
goto err_exit; goto err_exit;
} }
retval = pciehp_configure_device(p_slot); retval = pciehp_configure_device(p_slot);
if (retval) { if (retval) {
ctrl_err(ctrl, "Cannot add device 0x%x:%x\n", ctrl_err(ctrl, "Cannot add device at %04x:%02x:%02x\n",
p_slot->bus, p_slot->device); pci_domain_nr(parent), p_slot->bus, p_slot->device);
goto err_exit; goto err_exit;
} }
...@@ -276,14 +276,14 @@ static int remove_board(struct slot *p_slot) ...@@ -276,14 +276,14 @@ static int remove_board(struct slot *p_slot)
if (retval) if (retval)
return retval; return retval;
ctrl_dbg(ctrl, "In %s, hp_slot = %d\n", __func__, p_slot->hp_slot); ctrl_dbg(ctrl, "%s: hp_slot = %d\n", __func__, p_slot->hp_slot);
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
/* power off slot */ /* power off slot */
retval = p_slot->hpc_ops->power_off_slot(p_slot); retval = p_slot->hpc_ops->power_off_slot(p_slot);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s: Issue of Slot Disable command " ctrl_err(ctrl,
"failed\n", __func__); "Issue of Slot Disable command failed\n");
return retval; return retval;
} }
} }
...@@ -324,8 +324,10 @@ static void pciehp_power_thread(struct work_struct *work) ...@@ -324,8 +324,10 @@ static void pciehp_power_thread(struct work_struct *work)
switch (p_slot->state) { switch (p_slot->state) {
case POWEROFF_STATE: case POWEROFF_STATE:
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
ctrl_dbg(p_slot->ctrl, "%s: disabling bus:device(%x:%x)\n", ctrl_dbg(p_slot->ctrl,
__func__, p_slot->bus, p_slot->device); "Disabling domain:bus:device=%04x:%02x:%02x\n",
pci_domain_nr(p_slot->ctrl->pci_dev->subordinate),
p_slot->bus, p_slot->device);
pciehp_disable_slot(p_slot); pciehp_disable_slot(p_slot);
mutex_lock(&p_slot->lock); mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
...@@ -433,7 +435,6 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -433,7 +435,6 @@ static void handle_button_press_event(struct slot *p_slot)
* expires to cancel hot-add or hot-remove * expires to cancel hot-add or hot-remove
*/ */
ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
ctrl_dbg(ctrl, "%s: button cancel\n", __func__);
cancel_delayed_work(&p_slot->work); cancel_delayed_work(&p_slot->work);
if (p_slot->state == BLINKINGOFF_STATE) { if (p_slot->state == BLINKINGOFF_STATE) {
if (PWR_LED(ctrl)) if (PWR_LED(ctrl))
...@@ -537,16 +538,15 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -537,16 +538,15 @@ int pciehp_enable_slot(struct slot *p_slot)
rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (rc || !getstatus) { if (rc || !getstatus) {
ctrl_info(ctrl, "%s: no adapter on slot(%s)\n", ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
__func__, slot_name(p_slot));
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
if (MRL_SENS(p_slot->ctrl)) { if (MRL_SENS(p_slot->ctrl)) {
rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (rc || getstatus) { if (rc || getstatus) {
ctrl_info(ctrl, "%s: latch open on slot(%s)\n", ctrl_info(ctrl, "Latch open on slot(%s)\n",
__func__, slot_name(p_slot)); slot_name(p_slot));
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
...@@ -555,8 +555,8 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -555,8 +555,8 @@ int pciehp_enable_slot(struct slot *p_slot)
if (POWER_CTRL(p_slot->ctrl)) { if (POWER_CTRL(p_slot->ctrl)) {
rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (rc || getstatus) { if (rc || getstatus) {
ctrl_info(ctrl, "%s: already enabled on slot(%s)\n", ctrl_info(ctrl, "Already enabled on slot(%s)\n",
__func__, slot_name(p_slot)); slot_name(p_slot));
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -EINVAL; return -EINVAL;
} }
...@@ -591,8 +591,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -591,8 +591,8 @@ int pciehp_disable_slot(struct slot *p_slot)
if (!HP_SUPR_RM(p_slot->ctrl)) { if (!HP_SUPR_RM(p_slot->ctrl)) {
ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (ret || !getstatus) { if (ret || !getstatus) {
ctrl_info(ctrl, "%s: no adapter on slot(%s)\n", ctrl_info(ctrl, "No adapter on slot(%s)\n",
__func__, slot_name(p_slot)); slot_name(p_slot));
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
...@@ -601,8 +601,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -601,8 +601,8 @@ int pciehp_disable_slot(struct slot *p_slot)
if (MRL_SENS(p_slot->ctrl)) { if (MRL_SENS(p_slot->ctrl)) {
ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (ret || getstatus) { if (ret || getstatus) {
ctrl_info(ctrl, "%s: latch open on slot(%s)\n", ctrl_info(ctrl, "Latch open on slot(%s)\n",
__func__, slot_name(p_slot)); slot_name(p_slot));
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
...@@ -611,8 +611,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -611,8 +611,8 @@ int pciehp_disable_slot(struct slot *p_slot)
if (POWER_CTRL(p_slot->ctrl)) { if (POWER_CTRL(p_slot->ctrl)) {
ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (ret || !getstatus) { if (ret || !getstatus) {
ctrl_info(ctrl, "%s: already disabled slot(%s)\n", ctrl_info(ctrl, "Already disabled on slot(%s)\n",
__func__, slot_name(p_slot)); slot_name(p_slot));
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -EINVAL; return -EINVAL;
} }
......
...@@ -316,22 +316,19 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) ...@@ -316,22 +316,19 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
* proceed forward to issue the next command according * proceed forward to issue the next command according
* to spec. Just print out the error message. * to spec. Just print out the error message.
*/ */
ctrl_dbg(ctrl, ctrl_dbg(ctrl, "CMD_COMPLETED not clear after 1 sec\n");
"%s: CMD_COMPLETED not clear after 1 sec.\n",
__func__);
} else if (!NO_CMD_CMPL(ctrl)) { } else if (!NO_CMD_CMPL(ctrl)) {
/* /*
* This controller semms to notify of command completed * This controller semms to notify of command completed
* event even though it supports none of power * event even though it supports none of power
* controller, attention led, power led and EMI. * controller, attention led, power led and EMI.
*/ */
ctrl_dbg(ctrl, "%s: Unexpected CMD_COMPLETED. Need to " ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Need to "
"wait for command completed event.\n", "wait for command completed event.\n");
__func__);
ctrl->no_cmd_complete = 0; ctrl->no_cmd_complete = 0;
} else { } else {
ctrl_dbg(ctrl, "%s: Unexpected CMD_COMPLETED. Maybe " ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Maybe "
"the controller is broken.\n", __func__); "the controller is broken.\n");
} }
} }
...@@ -347,8 +344,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) ...@@ -347,8 +344,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
smp_mb(); smp_mb();
retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl);
if (retval) if (retval)
ctrl_err(ctrl, "%s: Cannot write to SLOTCTRL register\n", ctrl_err(ctrl, "Cannot write to SLOTCTRL register\n");
__func__);
/* /*
* Wait for command completion. * Wait for command completion.
...@@ -418,15 +414,14 @@ static int hpc_check_lnk_status(struct controller *ctrl) ...@@ -418,15 +414,14 @@ static int hpc_check_lnk_status(struct controller *ctrl)
retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", ctrl_err(ctrl, "Cannot read LNKSTATUS register\n");
__func__);
return retval; return retval;
} }
ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) || if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) ||
!(lnk_status & NEG_LINK_WD)) { !(lnk_status & NEG_LINK_WD)) {
ctrl_err(ctrl, "%s : Link Training Error occurs \n", __func__); ctrl_err(ctrl, "Link Training Error occurs \n");
retval = -1; retval = -1;
return retval; return retval;
} }
...@@ -551,7 +546,7 @@ static int hpc_query_power_fault(struct slot *slot) ...@@ -551,7 +546,7 @@ static int hpc_query_power_fault(struct slot *slot)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s: Cannot check for power fault\n", __func__); ctrl_err(ctrl, "Cannot check for power fault\n");
return retval; return retval;
} }
pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1);
...@@ -567,7 +562,7 @@ static int hpc_get_emi_status(struct slot *slot, u8 *status) ...@@ -567,7 +562,7 @@ static int hpc_get_emi_status(struct slot *slot, u8 *status)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s : Cannot check EMI status\n", __func__); ctrl_err(ctrl, "Cannot check EMI status\n");
return retval; return retval;
} }
*status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT; *status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT;
...@@ -697,8 +692,7 @@ static int hpc_power_on_slot(struct slot * slot) ...@@ -697,8 +692,7 @@ static int hpc_power_on_slot(struct slot * slot)
retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s: Write %x command failed!\n", ctrl_err(ctrl, "Write %x command failed!\n", slot_cmd);
__func__, slot_cmd);
return -1; return -1;
} }
ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
...@@ -776,7 +770,7 @@ static int hpc_power_off_slot(struct slot * slot) ...@@ -776,7 +770,7 @@ static int hpc_power_off_slot(struct slot * slot)
retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
if (retval) { if (retval) {
ctrl_err(ctrl, "%s: Write command failed!\n", __func__); ctrl_err(ctrl, "Write command failed!\n");
retval = -1; retval = -1;
goto out; goto out;
} }
...@@ -1056,8 +1050,7 @@ int pcie_enable_notification(struct controller *ctrl) ...@@ -1056,8 +1050,7 @@ int pcie_enable_notification(struct controller *ctrl)
PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE;
if (pcie_write_cmd(ctrl, cmd, mask)) { if (pcie_write_cmd(ctrl, cmd, mask)) {
ctrl_err(ctrl, "%s: Cannot enable software notification\n", ctrl_err(ctrl, "Cannot enable software notification\n");
__func__);
return -1; return -1;
} }
return 0; return 0;
...@@ -1069,8 +1062,7 @@ static void pcie_disable_notification(struct controller *ctrl) ...@@ -1069,8 +1062,7 @@ static void pcie_disable_notification(struct controller *ctrl)
mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE |
PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE;
if (pcie_write_cmd(ctrl, 0, mask)) if (pcie_write_cmd(ctrl, 0, mask))
ctrl_warn(ctrl, "%s: Cannot disable software notification\n", ctrl_warn(ctrl, "Cannot disable software notification\n");
__func__);
} }
static int pcie_init_notification(struct controller *ctrl) static int pcie_init_notification(struct controller *ctrl)
...@@ -1179,7 +1171,7 @@ struct controller *pcie_init(struct pcie_device *dev) ...@@ -1179,7 +1171,7 @@ struct controller *pcie_init(struct pcie_device *dev)
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) { if (!ctrl) {
dev_err(&dev->device, "%s : out of memory\n", __func__); dev_err(&dev->device, "%s: Out of memory\n", __func__);
goto abort; goto abort;
} }
INIT_LIST_HEAD(&ctrl->slot_list); INIT_LIST_HEAD(&ctrl->slot_list);
...@@ -1188,12 +1180,11 @@ struct controller *pcie_init(struct pcie_device *dev) ...@@ -1188,12 +1180,11 @@ struct controller *pcie_init(struct pcie_device *dev)
ctrl->pci_dev = pdev; ctrl->pci_dev = pdev;
ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP);
if (!ctrl->cap_base) { if (!ctrl->cap_base) {
ctrl_err(ctrl, "%s: Cannot find PCI Express capability\n", ctrl_err(ctrl, "Cannot find PCI Express capability\n");
__func__);
goto abort_ctrl; goto abort_ctrl;
} }
if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) {
ctrl_err(ctrl, "%s: Cannot read SLOTCAP register\n", __func__); ctrl_err(ctrl, "Cannot read SLOTCAP register\n");
goto abort_ctrl; goto abort_ctrl;
} }
......
...@@ -39,8 +39,7 @@ static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp) ...@@ -39,8 +39,7 @@ static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp)
u16 pci_cmd, pci_bctl; u16 pci_cmd, pci_bctl;
if (hpp->revision > 1) { if (hpp->revision > 1) {
printk(KERN_WARNING "%s: Rev.%d type0 record not supported\n", warn("Rev.%d type0 record not supported\n", hpp->revision);
__func__, hpp->revision);
return; return;
} }
...@@ -81,8 +80,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) ...@@ -81,8 +80,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
u32 reg32; u32 reg32;
if (hpp->revision > 1) { if (hpp->revision > 1) {
printk(KERN_WARNING "%s: Rev.%d type2 record not supported\n", warn("Rev.%d type2 record not supported\n", hpp->revision);
__func__, hpp->revision);
return; return;
} }
...@@ -149,8 +147,7 @@ static void program_fw_provided_values(struct pci_dev *dev) ...@@ -149,8 +147,7 @@ static void program_fw_provided_values(struct pci_dev *dev)
return; return;
if (pciehp_get_hp_params_from_firmware(dev, &hpp)) { if (pciehp_get_hp_params_from_firmware(dev, &hpp)) {
printk(KERN_WARNING "%s: Could not get hotplug parameters\n", warn("Could not get hotplug parameters\n");
__func__);
return; return;
} }
...@@ -202,9 +199,9 @@ int pciehp_configure_device(struct slot *p_slot) ...@@ -202,9 +199,9 @@ int pciehp_configure_device(struct slot *p_slot)
dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
if (dev) { if (dev) {
ctrl_err(ctrl, ctrl_err(ctrl, "Device %s already exists "
"Device %s already exists at %x:%x, cannot hot-add\n", "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev),
pci_name(dev), p_slot->bus, p_slot->device); pci_domain_nr(parent), p_slot->bus, p_slot->device);
pci_dev_put(dev); pci_dev_put(dev);
return -EINVAL; return -EINVAL;
} }
...@@ -248,8 +245,8 @@ int pciehp_unconfigure_device(struct slot *p_slot) ...@@ -248,8 +245,8 @@ int pciehp_unconfigure_device(struct slot *p_slot)
u16 command; u16 command;
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
ctrl_dbg(ctrl, "%s: bus/dev = %x/%x\n", __func__, ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n",
p_slot->bus, p_slot->device); __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device);
ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence); ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence);
if (ret) if (ret)
presence = 0; presence = 0;
......
...@@ -59,6 +59,20 @@ extern struct workqueue_struct *shpchp_wq; ...@@ -59,6 +59,20 @@ extern struct workqueue_struct *shpchp_wq;
#define warn(format, arg...) \ #define warn(format, arg...) \
printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
#define ctrl_dbg(ctrl, format, arg...) \
do { \
if (shpchp_debug) \
dev_printk(, &ctrl->pci_dev->dev, \
format, ## arg); \
} while (0)
#define ctrl_err(ctrl, format, arg...) \
dev_err(&ctrl->pci_dev->dev, format, ## arg)
#define ctrl_info(ctrl, format, arg...) \
dev_info(&ctrl->pci_dev->dev, format, ## arg)
#define ctrl_warn(ctrl, format, arg...) \
dev_warn(&ctrl->pci_dev->dev, format, ## arg)
#define SLOT_NAME_SIZE 10 #define SLOT_NAME_SIZE 10
struct slot { struct slot {
u8 bus; u8 bus;
...@@ -239,7 +253,7 @@ static inline struct slot *shpchp_find_slot(struct controller *ctrl, u8 device) ...@@ -239,7 +253,7 @@ static inline struct slot *shpchp_find_slot(struct controller *ctrl, u8 device)
return slot; return slot;
} }
err("%s: slot (device=0x%x) not found\n", __func__, device); ctrl_err(ctrl, "Slot (device=0x%02x) not found\n", device);
return NULL; return NULL;
} }
...@@ -273,7 +287,9 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) ...@@ -273,7 +287,9 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg); pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg);
perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK; perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK;
if (perr_set) { if (perr_set) {
dbg ("%s W1C: Bridge_Errors[ PERR_OBSERVED = %08X]\n",__func__ , perr_set); ctrl_dbg(p_slot->ctrl,
"Bridge_Errors[ PERR_OBSERVED = %08X] (W1C)\n",
perr_set);
pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set); pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set);
} }
...@@ -282,7 +298,7 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot) ...@@ -282,7 +298,7 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg); pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg);
rse_set = pcix_mem_base_reg & RSE_MASK; rse_set = pcix_mem_base_reg & RSE_MASK;
if (rse_set) { if (rse_set) {
dbg ("%s W1C: Memory_Base_Limit[ RSE ]\n",__func__ ); ctrl_dbg(p_slot->ctrl, "Memory_Base_Limit[ RSE ] (W1C)\n");
pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set);
} }
......
...@@ -89,7 +89,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot) ...@@ -89,7 +89,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
kfree(slot->hotplug_slot->info); kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot); kfree(slot->hotplug_slot);
...@@ -135,13 +136,16 @@ static int init_slots(struct controller *ctrl) ...@@ -135,13 +136,16 @@ static int init_slots(struct controller *ctrl)
snprintf(name, SLOT_NAME_SIZE, "%d", slot->number); snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
hotplug_slot->ops = &shpchp_hotplug_slot_ops; hotplug_slot->ops = &shpchp_hotplug_slot_ops;
dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x "
"slot_device_offset=%x\n", slot->bus, slot->device, "hp_slot=%x sun=%x slot_device_offset=%x\n",
slot->hp_slot, slot->number, ctrl->slot_device_offset); pci_domain_nr(ctrl->pci_dev->subordinate),
slot->bus, slot->device, slot->hp_slot, slot->number,
ctrl->slot_device_offset);
retval = pci_hp_register(slot->hotplug_slot, retval = pci_hp_register(slot->hotplug_slot,
ctrl->pci_dev->subordinate, slot->device, name); ctrl->pci_dev->subordinate, slot->device, name);
if (retval) { if (retval) {
err("pci_hp_register failed with error %d\n", retval); ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
retval);
goto error_info; goto error_info;
} }
...@@ -187,7 +191,8 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) ...@@ -187,7 +191,8 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
{ {
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
hotplug_slot->info->attention_status = status; hotplug_slot->info->attention_status = status;
slot->hpc_ops->set_attention_status(slot, status); slot->hpc_ops->set_attention_status(slot, status);
...@@ -199,7 +204,8 @@ static int enable_slot (struct hotplug_slot *hotplug_slot) ...@@ -199,7 +204,8 @@ static int enable_slot (struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
return shpchp_sysfs_enable_slot(slot); return shpchp_sysfs_enable_slot(slot);
} }
...@@ -208,7 +214,8 @@ static int disable_slot (struct hotplug_slot *hotplug_slot) ...@@ -208,7 +214,8 @@ static int disable_slot (struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
return shpchp_sysfs_disable_slot(slot); return shpchp_sysfs_disable_slot(slot);
} }
...@@ -218,7 +225,8 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -218,7 +225,8 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
retval = slot->hpc_ops->get_power_status(slot, value); retval = slot->hpc_ops->get_power_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -232,7 +240,8 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -232,7 +240,8 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
retval = slot->hpc_ops->get_attention_status(slot, value); retval = slot->hpc_ops->get_attention_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -246,7 +255,8 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -246,7 +255,8 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
retval = slot->hpc_ops->get_latch_status(slot, value); retval = slot->hpc_ops->get_latch_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -260,7 +270,8 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -260,7 +270,8 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
retval = slot->hpc_ops->get_adapter_status(slot, value); retval = slot->hpc_ops->get_adapter_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -275,7 +286,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, ...@@ -275,7 +286,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
retval = slot->hpc_ops->get_max_bus_speed(slot, value); retval = slot->hpc_ops->get_max_bus_speed(slot, value);
if (retval < 0) if (retval < 0)
...@@ -289,7 +301,8 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp ...@@ -289,7 +301,8 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
struct slot *slot = get_slot(hotplug_slot); struct slot *slot = get_slot(hotplug_slot);
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot));
retval = slot->hpc_ops->get_cur_bus_speed(slot, value); retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
if (retval < 0) if (retval < 0)
...@@ -320,15 +333,14 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -320,15 +333,14 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) { if (!ctrl) {
err("%s : out of memory\n", __func__); dev_err(&pdev->dev, "%s: Out of memory\n", __func__);
goto err_out_none; goto err_out_none;
} }
INIT_LIST_HEAD(&ctrl->slot_list); INIT_LIST_HEAD(&ctrl->slot_list);
rc = shpc_init(ctrl, pdev); rc = shpc_init(ctrl, pdev);
if (rc) { if (rc) {
dbg("%s: controller initialization failed\n", ctrl_dbg(ctrl, "Controller initialization failed\n");
SHPC_MODULE_NAME);
goto err_out_free_ctrl; goto err_out_free_ctrl;
} }
...@@ -337,7 +349,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -337,7 +349,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* Setup the slot information structures */ /* Setup the slot information structures */
rc = init_slots(ctrl); rc = init_slots(ctrl);
if (rc) { if (rc) {
err("%s: slot initialization failed\n", SHPC_MODULE_NAME); ctrl_err(ctrl, "Slot initialization failed\n");
goto err_out_release_ctlr; goto err_out_release_ctlr;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -49,9 +49,7 @@ static void program_fw_provided_values(struct pci_dev *dev) ...@@ -49,9 +49,7 @@ static void program_fw_provided_values(struct pci_dev *dev)
/* use default values if we can't get them from firmware */ /* use default values if we can't get them from firmware */
if (get_hp_params_from_firmware(dev, &hpp) || if (get_hp_params_from_firmware(dev, &hpp) ||
!hpp.t0 || (hpp.t0->revision > 1)) { !hpp.t0 || (hpp.t0->revision > 1)) {
printk(KERN_WARNING warn("Could not get hotplug parameters. Use defaults\n");
"%s: Could not get hotplug parameters. Use defaults\n",
__func__);
hpp.t0 = &hpp.type0_data; hpp.t0 = &hpp.type0_data;
hpp.t0->revision = 0; hpp.t0->revision = 0;
hpp.t0->cache_line_size = 8; hpp.t0->cache_line_size = 8;
...@@ -101,18 +99,20 @@ int __ref shpchp_configure_device(struct slot *p_slot) ...@@ -101,18 +99,20 @@ int __ref shpchp_configure_device(struct slot *p_slot)
struct pci_dev *dev; struct pci_dev *dev;
struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
int num, fn; int num, fn;
struct controller *ctrl = p_slot->ctrl;
dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
if (dev) { if (dev) {
err("Device %s already exists at %x:%x, cannot hot-add\n", ctrl_err(ctrl, "Device %s already exists "
pci_name(dev), p_slot->bus, p_slot->device); "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev),
pci_domain_nr(parent), p_slot->bus, p_slot->device);
pci_dev_put(dev); pci_dev_put(dev);
return -EINVAL; return -EINVAL;
} }
num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
if (num == 0) { if (num == 0) {
err("No new device found\n"); ctrl_err(ctrl, "No new device found\n");
return -ENODEV; return -ENODEV;
} }
...@@ -121,8 +121,8 @@ int __ref shpchp_configure_device(struct slot *p_slot) ...@@ -121,8 +121,8 @@ int __ref shpchp_configure_device(struct slot *p_slot)
if (!dev) if (!dev)
continue; continue;
if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
err("Cannot hot-add display device %s\n", ctrl_err(ctrl, "Cannot hot-add display device %s\n",
pci_name(dev)); pci_name(dev));
pci_dev_put(dev); pci_dev_put(dev);
continue; continue;
} }
...@@ -138,14 +138,15 @@ int __ref shpchp_configure_device(struct slot *p_slot) ...@@ -138,14 +138,15 @@ int __ref shpchp_configure_device(struct slot *p_slot)
break; break;
} }
if (busnr >= end) { if (busnr >= end) {
err("No free bus for hot-added bridge\n"); ctrl_err(ctrl,
"No free bus for hot-added bridge\n");
pci_dev_put(dev); pci_dev_put(dev);
continue; continue;
} }
child = pci_add_new_bus(parent, dev, busnr); child = pci_add_new_bus(parent, dev, busnr);
if (!child) { if (!child) {
err("Cannot add new bus for %s\n", ctrl_err(ctrl, "Cannot add new bus for %s\n",
pci_name(dev)); pci_name(dev));
pci_dev_put(dev); pci_dev_put(dev);
continue; continue;
} }
...@@ -168,8 +169,10 @@ int shpchp_unconfigure_device(struct slot *p_slot) ...@@ -168,8 +169,10 @@ int shpchp_unconfigure_device(struct slot *p_slot)
int j; int j;
u8 bctl = 0; u8 bctl = 0;
struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
struct controller *ctrl = p_slot->ctrl;
dbg("%s: bus/dev = %x/%x\n", __func__, p_slot->bus, p_slot->device); ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n",
__func__, pci_domain_nr(parent), p_slot->bus, p_slot->device);
for (j=0; j<8 ; j++) { for (j=0; j<8 ; j++) {
struct pci_dev* temp = pci_get_slot(parent, struct pci_dev* temp = pci_get_slot(parent,
...@@ -177,16 +180,17 @@ int shpchp_unconfigure_device(struct slot *p_slot) ...@@ -177,16 +180,17 @@ int shpchp_unconfigure_device(struct slot *p_slot)
if (!temp) if (!temp)
continue; continue;
if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
err("Cannot remove display device %s\n", ctrl_err(ctrl, "Cannot remove display device %s\n",
pci_name(temp)); pci_name(temp));
pci_dev_put(temp); pci_dev_put(temp);
continue; continue;
} }
if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
if (bctl & PCI_BRIDGE_CTL_VGA) { if (bctl & PCI_BRIDGE_CTL_VGA) {
err("Cannot remove display device %s\n", ctrl_err(ctrl,
pci_name(temp)); "Cannot remove display device %s\n",
pci_name(temp));
pci_dev_put(temp); pci_dev_put(temp);
continue; continue;
} }
......
/*
* PCI IRQ failure handing code
*
* Copyright (c) 2008 James Bottomley <James.Bottomley@HansenPartnership.com>
*/
#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/pci.h>
static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason)
{
struct pci_dev *parent = to_pci_dev(pdev->dev.parent);
dev_printk(KERN_ERR, &pdev->dev,
"Potentially misrouted IRQ (Bridge %s %04x:%04x)\n",
parent->dev.bus_id, parent->vendor, parent->device);
dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason);
dev_printk(KERN_ERR, &pdev->dev, "Please report to linux-kernel@vger.kernel.org\n");
WARN_ON(1);
}
/**
* pci_lost_interrupt - reports a lost PCI interrupt
* @pdev: device whose interrupt is lost
*
* The primary function of this routine is to report a lost interrupt
* in a standard way which users can recognise (instead of blaming the
* driver).
*
* Returns:
* a suggestion for fixing it (although the driver is not required to
* act on this).
*/
enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *pdev)
{
if (pdev->msi_enabled || pdev->msix_enabled) {
enum pci_lost_interrupt_reason ret;
if (pdev->msix_enabled) {
pci_note_irq_problem(pdev, "MSIX routing failure");
ret = PCI_LOST_IRQ_DISABLE_MSIX;
} else {
pci_note_irq_problem(pdev, "MSI routing failure");
ret = PCI_LOST_IRQ_DISABLE_MSI;
}
return ret;
}
#ifdef CONFIG_ACPI
if (!(acpi_disabled || acpi_noirq)) {
pci_note_irq_problem(pdev, "Potential ACPI misrouting please reboot with acpi=noirq");
/* currently no way to fix acpi on the fly */
return PCI_LOST_IRQ_DISABLE_ACPI;
}
#endif
pci_note_irq_problem(pdev, "unknown cause (not MSI or ACPI)");
return PCI_LOST_IRQ_NO_INFORMATION;
}
EXPORT_SYMBOL(pci_lost_interrupt);
...@@ -1309,27 +1309,32 @@ void pci_enable_ari(struct pci_dev *dev) ...@@ -1309,27 +1309,32 @@ void pci_enable_ari(struct pci_dev *dev)
int pos; int pos;
u32 cap; u32 cap;
u16 ctrl; u16 ctrl;
struct pci_dev *bridge;
if (!dev->is_pcie) if (!dev->is_pcie || dev->devfn)
return; return;
if (dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI);
dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) if (!pos)
return; return;
pos = pci_find_capability(dev, PCI_CAP_ID_EXP); bridge = dev->bus->self;
if (!bridge || !bridge->is_pcie)
return;
pos = pci_find_capability(bridge, PCI_CAP_ID_EXP);
if (!pos) if (!pos)
return; return;
pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap); pci_read_config_dword(bridge, pos + PCI_EXP_DEVCAP2, &cap);
if (!(cap & PCI_EXP_DEVCAP2_ARI)) if (!(cap & PCI_EXP_DEVCAP2_ARI))
return; return;
pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl); pci_read_config_word(bridge, pos + PCI_EXP_DEVCTL2, &ctrl);
ctrl |= PCI_EXP_DEVCTL2_ARI; ctrl |= PCI_EXP_DEVCTL2_ARI;
pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl); pci_write_config_word(bridge, pos + PCI_EXP_DEVCTL2, ctrl);
dev->ari_enabled = 1; bridge->ari_enabled = 1;
} }
int int
......
...@@ -298,9 +298,6 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) ...@@ -298,9 +298,6 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
child->resource[i] = child->parent->resource[i - 3]; child->resource[i] = child->parent->resource[i - 3];
} }
for(i=0; i<3; i++)
child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i];
res = child->resource[0]; res = child->resource[0];
pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
......
...@@ -546,6 +546,13 @@ struct pci_dev __deprecated *pci_find_slot(unsigned int bus, ...@@ -546,6 +546,13 @@ struct pci_dev __deprecated *pci_find_slot(unsigned int bus,
unsigned int devfn); unsigned int devfn);
#endif /* CONFIG_PCI_LEGACY */ #endif /* CONFIG_PCI_LEGACY */
enum pci_lost_interrupt_reason {
PCI_LOST_IRQ_NO_INFORMATION = 0,
PCI_LOST_IRQ_DISABLE_MSI,
PCI_LOST_IRQ_DISABLE_MSIX,
PCI_LOST_IRQ_DISABLE_ACPI,
};
enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev);
int pci_find_capability(struct pci_dev *dev, int cap); int pci_find_capability(struct pci_dev *dev, int cap);
int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
int pci_find_ext_capability(struct pci_dev *dev, int cap); int pci_find_ext_capability(struct pci_dev *dev, int cap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment