PCI hotplug: shpchp: replace printk with dev_printk

This patch replaces printks within shpchp module with dev_printks.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

authored by Taku Izumi and committed by Jesse Barnes f98ca311 388c8c16

+224 -159
+20 -3
drivers/pci/hotplug/shpchp.h
··· 59 #define warn(format, arg...) \ 60 printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 61 62 #define SLOT_NAME_SIZE 10 63 struct slot { 64 u8 bus; ··· 253 return slot; 254 } 255 256 - err("%s: slot (device=0x%x) not found\n", __func__, device); 257 return NULL; 258 } 259 ··· 287 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg); 288 perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK; 289 if (perr_set) { 290 - dbg ("%s W1C: Bridge_Errors[ PERR_OBSERVED = %08X]\n",__func__ , perr_set); 291 292 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set); 293 } ··· 298 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg); 299 rse_set = pcix_mem_base_reg & RSE_MASK; 300 if (rse_set) { 301 - dbg ("%s W1C: Memory_Base_Limit[ RSE ]\n",__func__ ); 302 303 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); 304 }
··· 59 #define warn(format, arg...) \ 60 printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 61 62 + #define ctrl_dbg(ctrl, format, arg...) \ 63 + do { \ 64 + if (shpchp_debug) \ 65 + dev_printk(, &ctrl->pci_dev->dev, \ 66 + format, ## arg); \ 67 + } while (0) 68 + #define ctrl_err(ctrl, format, arg...) \ 69 + dev_err(&ctrl->pci_dev->dev, format, ## arg) 70 + #define ctrl_info(ctrl, format, arg...) \ 71 + dev_info(&ctrl->pci_dev->dev, format, ## arg) 72 + #define ctrl_warn(ctrl, format, arg...) \ 73 + dev_warn(&ctrl->pci_dev->dev, format, ## arg) 74 + 75 + 76 #define SLOT_NAME_SIZE 10 77 struct slot { 78 u8 bus; ··· 239 return slot; 240 } 241 242 + ctrl_err(ctrl, "%s: slot (device=0x%x) not found\n", __func__, device); 243 return NULL; 244 } 245 ··· 273 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, &pcix_bridge_errors_reg); 274 perr_set = pcix_bridge_errors_reg & PERR_OBSERVED_MASK; 275 if (perr_set) { 276 + ctrl_dbg(p_slot->ctrl, 277 + "%s W1C: Bridge_Errors[ PERR_OBSERVED = %08X]\n", 278 + __func__ , perr_set); 279 280 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISC_BRIDGE_ERRORS_OFFSET, perr_set); 281 } ··· 282 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, &pcix_mem_base_reg); 283 rse_set = pcix_mem_base_reg & RSE_MASK; 284 if (rse_set) { 285 + ctrl_dbg(p_slot->ctrl, "%s W1C: Memory_Base_Limit[ RSE ]\n", 286 + __func__); 287 288 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); 289 }
+28 -18
drivers/pci/hotplug/shpchp_core.c
··· 89 { 90 struct slot *slot = hotplug_slot->private; 91 92 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 93 94 kfree(slot->hotplug_slot->info); 95 kfree(slot->hotplug_slot); ··· 136 snprintf(name, SLOT_NAME_SIZE, "%d", slot->number); 137 hotplug_slot->ops = &shpchp_hotplug_slot_ops; 138 139 - dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " 140 - "slot_device_offset=%x\n", slot->bus, slot->device, 141 - slot->hp_slot, slot->number, ctrl->slot_device_offset); 142 retval = pci_hp_register(slot->hotplug_slot, 143 ctrl->pci_dev->subordinate, slot->device, name); 144 if (retval) { 145 - err("pci_hp_register failed with error %d\n", retval); 146 goto error_info; 147 } 148 ··· 189 { 190 struct slot *slot = get_slot(hotplug_slot); 191 192 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 193 194 hotplug_slot->info->attention_status = status; 195 slot->hpc_ops->set_attention_status(slot, status); ··· 202 { 203 struct slot *slot = get_slot(hotplug_slot); 204 205 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 206 207 return shpchp_sysfs_enable_slot(slot); 208 } ··· 212 { 213 struct slot *slot = get_slot(hotplug_slot); 214 215 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 216 217 return shpchp_sysfs_disable_slot(slot); 218 } ··· 223 struct slot *slot = get_slot(hotplug_slot); 224 int retval; 225 226 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 227 228 retval = slot->hpc_ops->get_power_status(slot, value); 229 if (retval < 0) ··· 238 struct slot *slot = get_slot(hotplug_slot); 239 int retval; 240 241 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 242 243 retval = slot->hpc_ops->get_attention_status(slot, value); 244 if (retval < 0) ··· 253 struct slot *slot = get_slot(hotplug_slot); 254 int retval; 255 256 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 257 258 retval = slot->hpc_ops->get_latch_status(slot, value); 259 if (retval < 0) ··· 268 struct slot *slot = get_slot(hotplug_slot); 269 int retval; 270 271 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 272 273 retval = slot->hpc_ops->get_adapter_status(slot, value); 274 if (retval < 0) ··· 284 struct slot *slot = get_slot(hotplug_slot); 285 int retval; 286 287 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 288 289 retval = slot->hpc_ops->get_max_bus_speed(slot, value); 290 if (retval < 0) ··· 299 struct slot *slot = get_slot(hotplug_slot); 300 int retval; 301 302 - dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 303 304 retval = slot->hpc_ops->get_cur_bus_speed(slot, value); 305 if (retval < 0) ··· 331 332 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 333 if (!ctrl) { 334 - err("%s : out of memory\n", __func__); 335 goto err_out_none; 336 } 337 INIT_LIST_HEAD(&ctrl->slot_list); 338 339 rc = shpc_init(ctrl, pdev); 340 if (rc) { 341 - dbg("%s: controller initialization failed\n", 342 - SHPC_MODULE_NAME); 343 goto err_out_free_ctrl; 344 } 345 ··· 347 /* Setup the slot information structures */ 348 rc = init_slots(ctrl); 349 if (rc) { 350 - err("%s: slot initialization failed\n", SHPC_MODULE_NAME); 351 goto err_out_release_ctlr; 352 } 353
··· 89 { 90 struct slot *slot = hotplug_slot->private; 91 92 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 93 + __func__, slot_name(slot)); 94 95 kfree(slot->hotplug_slot->info); 96 kfree(slot->hotplug_slot); ··· 135 snprintf(name, SLOT_NAME_SIZE, "%d", slot->number); 136 hotplug_slot->ops = &shpchp_hotplug_slot_ops; 137 138 + ctrl_dbg(ctrl, "Registering bus=%x dev=%x hp_slot=%x sun=%x " 139 + "slot_device_offset=%x\n", slot->bus, slot->device, 140 + slot->hp_slot, slot->number, ctrl->slot_device_offset); 141 retval = pci_hp_register(slot->hotplug_slot, 142 ctrl->pci_dev->subordinate, slot->device, name); 143 if (retval) { 144 + ctrl_err(ctrl, "pci_hp_register failed with error %d\n", 145 + retval); 146 goto error_info; 147 } 148 ··· 187 { 188 struct slot *slot = get_slot(hotplug_slot); 189 190 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 191 + __func__, slot_name(slot)); 192 193 hotplug_slot->info->attention_status = status; 194 slot->hpc_ops->set_attention_status(slot, status); ··· 199 { 200 struct slot *slot = get_slot(hotplug_slot); 201 202 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 203 + __func__, slot_name(slot)); 204 205 return shpchp_sysfs_enable_slot(slot); 206 } ··· 208 { 209 struct slot *slot = get_slot(hotplug_slot); 210 211 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 212 + __func__, slot_name(slot)); 213 214 return shpchp_sysfs_disable_slot(slot); 215 } ··· 218 struct slot *slot = get_slot(hotplug_slot); 219 int retval; 220 221 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 222 + __func__, slot_name(slot)); 223 224 retval = slot->hpc_ops->get_power_status(slot, value); 225 if (retval < 0) ··· 232 struct slot *slot = get_slot(hotplug_slot); 233 int retval; 234 235 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 236 + __func__, slot_name(slot)); 237 238 retval = slot->hpc_ops->get_attention_status(slot, value); 239 if (retval < 0) ··· 246 struct slot *slot = get_slot(hotplug_slot); 247 int retval; 248 249 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 250 + __func__, slot_name(slot)); 251 252 retval = slot->hpc_ops->get_latch_status(slot, value); 253 if (retval < 0) ··· 260 struct slot *slot = get_slot(hotplug_slot); 261 int retval; 262 263 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 264 + __func__, slot_name(slot)); 265 266 retval = slot->hpc_ops->get_adapter_status(slot, value); 267 if (retval < 0) ··· 275 struct slot *slot = get_slot(hotplug_slot); 276 int retval; 277 278 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 279 + __func__, slot_name(slot)); 280 281 retval = slot->hpc_ops->get_max_bus_speed(slot, value); 282 if (retval < 0) ··· 289 struct slot *slot = get_slot(hotplug_slot); 290 int retval; 291 292 + ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n", 293 + __func__, slot_name(slot)); 294 295 retval = slot->hpc_ops->get_cur_bus_speed(slot, value); 296 if (retval < 0) ··· 320 321 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 322 if (!ctrl) { 323 + dev_err(&pdev->dev, "%s : out of memory\n", __func__); 324 goto err_out_none; 325 } 326 INIT_LIST_HEAD(&ctrl->slot_list); 327 328 rc = shpc_init(ctrl, pdev); 329 if (rc) { 330 + ctrl_dbg(ctrl, "controller initialization failed\n"); 331 goto err_out_free_ctrl; 332 } 333 ··· 337 /* Setup the slot information structures */ 338 rc = init_slots(ctrl); 339 if (rc) { 340 + ctrl_err(ctrl, "slot initialization failed\n"); 341 goto err_out_release_ctlr; 342 } 343
+93 -69
drivers/pci/hotplug/shpchp_ctrl.c
··· 62 u32 event_type; 63 64 /* Attention Button Change */ 65 - dbg("shpchp: Attention button interrupt received.\n"); 66 67 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 68 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); ··· 70 /* 71 * Button pressed - See if need to TAKE ACTION!!! 72 */ 73 - info("Button pressed on Slot(%s)\n", slot_name(p_slot)); 74 event_type = INT_BUTTON_PRESS; 75 76 queue_interrupt_event(p_slot, event_type); ··· 86 u32 event_type; 87 88 /* Switch Change */ 89 - dbg("shpchp: Switch interrupt received.\n"); 90 91 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 92 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); 93 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 94 - dbg("%s: Card present %x Power status %x\n", __func__, 95 - p_slot->presence_save, p_slot->pwr_save); 96 97 if (getstatus) { 98 /* 99 * Switch opened 100 */ 101 - info("Latch open on Slot(%s)\n", slot_name(p_slot)); 102 event_type = INT_SWITCH_OPEN; 103 if (p_slot->pwr_save && p_slot->presence_save) { 104 event_type = INT_POWER_FAULT; 105 - err("Surprise Removal of card\n"); 106 } 107 } else { 108 /* 109 * Switch closed 110 */ 111 - info("Latch close on Slot(%s)\n", slot_name(p_slot)); 112 event_type = INT_SWITCH_CLOSE; 113 } 114 ··· 123 u32 event_type; 124 125 /* Presence Change */ 126 - dbg("shpchp: Presence/Notify input change.\n"); 127 128 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 129 ··· 135 /* 136 * Card Present 137 */ 138 - info("Card present on Slot(%s)\n", slot_name(p_slot)); 139 event_type = INT_PRESENCE_ON; 140 } else { 141 /* 142 * Not Present 143 */ 144 - info("Card not present on Slot(%s)\n", slot_name(p_slot)); 145 event_type = INT_PRESENCE_OFF; 146 } 147 ··· 158 u32 event_type; 159 160 /* Power fault */ 161 - dbg("shpchp: Power fault interrupt received.\n"); 162 163 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 164 ··· 166 /* 167 * Power fault Cleared 168 */ 169 - info("Power fault cleared on Slot(%s)\n", slot_name(p_slot)); 170 p_slot->status = 0x00; 171 event_type = INT_POWER_FAULT_CLEAR; 172 } else { 173 /* 174 * Power fault 175 */ 176 - info("Power fault on Slot(%s)\n", slot_name(p_slot)); 177 event_type = INT_POWER_FAULT; 178 /* set power fault status for this board */ 179 p_slot->status = 0xFF; 180 - info("power fault bit %x set\n", hp_slot); 181 } 182 183 queue_interrupt_event(p_slot, event_type); ··· 194 { 195 int rc = 0; 196 197 - dbg("%s: change to speed %d\n", __func__, speed); 198 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { 199 - err("%s: Issue of set bus speed mode command failed\n", 200 - __func__); 201 return WRONG_BUS_FREQUENCY; 202 } 203 return rc; ··· 215 */ 216 if (flag) { 217 if (asp < bsp) { 218 - err("%s: speed of bus %x and adapter %x mismatch\n", 219 - __func__, bsp, asp); 220 rc = WRONG_BUS_FREQUENCY; 221 } 222 return rc; ··· 249 250 hp_slot = p_slot->device - ctrl->slot_device_offset; 251 252 - dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", 253 - __func__, p_slot->device, 254 - ctrl->slot_device_offset, hp_slot); 255 256 /* Power on slot without connecting to bus */ 257 rc = p_slot->hpc_ops->power_on_slot(p_slot); 258 if (rc) { 259 - err("%s: Failed to power on slot\n", __func__); 260 return -1; 261 } 262 ··· 265 return WRONG_BUS_FREQUENCY; 266 267 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 268 - err("%s: Issue of set bus speed mode command failed\n", __func__); 269 return WRONG_BUS_FREQUENCY; 270 } 271 272 /* turn on board, blink green LED, turn off Amber LED */ 273 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 274 - err("%s: Issue of Slot Enable command failed\n", __func__); 275 return rc; 276 } 277 } 278 279 rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); 280 if (rc) { 281 - err("%s: Can't get adapter speed or bus mode mismatch\n", 282 - __func__); 283 return WRONG_BUS_FREQUENCY; 284 } 285 286 rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp); 287 if (rc) { 288 - err("%s: Can't get bus operation speed\n", __func__); 289 return WRONG_BUS_FREQUENCY; 290 } 291 292 rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp); 293 if (rc) { 294 - err("%s: Can't get max bus operation speed\n", __func__); 295 msp = bsp; 296 } 297 ··· 302 if (!list_empty(&ctrl->pci_dev->subordinate->devices)) 303 slots_not_empty = 1; 304 305 - dbg("%s: slots_not_empty %d, adapter_speed %d, bus_speed %d, " 306 - "max_bus_speed %d\n", __func__, slots_not_empty, asp, 307 - bsp, msp); 308 309 rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp); 310 if (rc) ··· 312 313 /* turn on board, blink green LED, turn off Amber LED */ 314 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 315 - err("%s: Issue of Slot Enable command failed\n", __func__); 316 return rc; 317 } 318 319 /* Wait for ~1 second */ 320 msleep(1000); 321 322 - dbg("%s: slot status = %x\n", __func__, p_slot->status); 323 /* Check for a power fault */ 324 if (p_slot->status == 0xFF) { 325 /* power fault occurred, but it was benign */ 326 - dbg("%s: power fault\n", __func__); 327 rc = POWER_FAILURE; 328 p_slot->status = 0; 329 goto err_exit; 330 } 331 332 if (shpchp_configure_device(p_slot)) { 333 - err("Cannot add device at 0x%x:0x%x\n", p_slot->bus, 334 - p_slot->device); 335 goto err_exit; 336 } 337 ··· 348 /* turn off slot, turn on Amber LED, turn off Green LED */ 349 rc = p_slot->hpc_ops->slot_disable(p_slot); 350 if (rc) { 351 - err("%s: Issue of Slot Disable command failed\n", __func__); 352 return rc; 353 } 354 ··· 373 hp_slot = p_slot->device - ctrl->slot_device_offset; 374 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 375 376 - dbg("In %s, hp_slot = %d\n", __func__, hp_slot); 377 378 /* Change status to shutdown */ 379 if (p_slot->is_a_board) ··· 382 /* turn off slot, turn on Amber LED, turn off Green LED */ 383 rc = p_slot->hpc_ops->slot_disable(p_slot); 384 if (rc) { 385 - err("%s: Issue of Slot Disable command failed\n", __func__); 386 return rc; 387 } 388 389 rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); 390 if (rc) { 391 - err("%s: Issue of Set Attention command failed\n", __func__); 392 return rc; 393 } 394 ··· 449 450 info = kmalloc(sizeof(*info), GFP_KERNEL); 451 if (!info) { 452 - err("%s: Cannot allocate memory\n", __func__); 453 return; 454 } 455 info->p_slot = p_slot; ··· 497 static void handle_button_press_event(struct slot *p_slot) 498 { 499 u8 getstatus; 500 501 switch (p_slot->state) { 502 case STATIC_STATE: 503 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 504 if (getstatus) { 505 p_slot->state = BLINKINGOFF_STATE; 506 - info("PCI slot #%s - powering off due to button " 507 - "press.\n", slot_name(p_slot)); 508 } else { 509 p_slot->state = BLINKINGON_STATE; 510 - info("PCI slot #%s - powering on due to button " 511 - "press.\n", slot_name(p_slot)); 512 } 513 /* blink green LED and turn off amber */ 514 p_slot->hpc_ops->green_led_blink(p_slot); ··· 524 * press the attention again before the 5 sec. limit 525 * expires to cancel hot-add or hot-remove 526 */ 527 - info("Button cancel on Slot(%s)\n", slot_name(p_slot)); 528 - dbg("%s: button cancel\n", __func__); 529 cancel_delayed_work(&p_slot->work); 530 if (p_slot->state == BLINKINGOFF_STATE) 531 p_slot->hpc_ops->green_led_on(p_slot); 532 else 533 p_slot->hpc_ops->green_led_off(p_slot); 534 p_slot->hpc_ops->set_attention_status(p_slot, 0); 535 - info("PCI slot #%s - action canceled due to button press\n", 536 - slot_name(p_slot)); 537 p_slot->state = STATIC_STATE; 538 break; 539 case POWEROFF_STATE: ··· 544 * this means that the previous attention button action 545 * to hot-add or hot-remove is undergoing 546 */ 547 - info("Button ignore on Slot(%s)\n", slot_name(p_slot)); 548 update_slot_info(p_slot); 549 break; 550 default: 551 - warn("Not a valid state\n"); 552 break; 553 } 554 } ··· 565 handle_button_press_event(p_slot); 566 break; 567 case INT_POWER_FAULT: 568 - dbg("%s: power fault\n", __func__); 569 p_slot->hpc_ops->set_attention_status(p_slot, 1); 570 p_slot->hpc_ops->green_led_off(p_slot); 571 break; ··· 583 { 584 u8 getstatus = 0; 585 int rc, retval = -ENODEV; 586 587 /* Check to see if (latch closed, card present, power off) */ 588 mutex_lock(&p_slot->ctrl->crit_sect); 589 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 590 if (rc || !getstatus) { 591 - info("No adapter on slot(%s)\n", slot_name(p_slot)); 592 goto out; 593 } 594 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 595 if (rc || getstatus) { 596 - info("Latch open on slot(%s)\n", slot_name(p_slot)); 597 goto out; 598 } 599 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 600 if (rc || getstatus) { 601 - info("Already enabled on slot(%s)\n", slot_name(p_slot)); 602 goto out; 603 } 604 ··· 609 /* We have to save the presence info for these slots */ 610 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); 611 p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save)); 612 - dbg("%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); 613 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 614 615 if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || ··· 640 { 641 u8 getstatus = 0; 642 int rc, retval = -ENODEV; 643 644 if (!p_slot->ctrl) 645 return -ENODEV; ··· 650 651 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 652 if (rc || !getstatus) { 653 - info("No adapter on slot(%s)\n", slot_name(p_slot)); 654 goto out; 655 } 656 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 657 if (rc || getstatus) { 658 - info("Latch open on slot(%s)\n", slot_name(p_slot)); 659 goto out; 660 } 661 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 662 if (rc || !getstatus) { 663 - info("Already disabled slot(%s)\n", slot_name(p_slot)); 664 goto out; 665 } 666 ··· 675 int shpchp_sysfs_enable_slot(struct slot *p_slot) 676 { 677 int retval = -ENODEV; 678 679 mutex_lock(&p_slot->lock); 680 switch (p_slot->state) { ··· 689 p_slot->state = STATIC_STATE; 690 break; 691 case POWERON_STATE: 692 - info("Slot %s is already in powering on state\n", 693 - slot_name(p_slot)); 694 break; 695 case BLINKINGOFF_STATE: 696 case POWEROFF_STATE: 697 - info("Already enabled on slot %s\n", slot_name(p_slot)); 698 break; 699 default: 700 - err("Not a valid state on slot %s\n", slot_name(p_slot)); 701 break; 702 } 703 mutex_unlock(&p_slot->lock); ··· 710 int shpchp_sysfs_disable_slot(struct slot *p_slot) 711 { 712 int retval = -ENODEV; 713 714 mutex_lock(&p_slot->lock); 715 switch (p_slot->state) { ··· 724 p_slot->state = STATIC_STATE; 725 break; 726 case POWEROFF_STATE: 727 - info("Slot %s is already in powering off state\n", 728 - slot_name(p_slot)); 729 break; 730 case BLINKINGON_STATE: 731 case POWERON_STATE: 732 - info("Already disabled on slot %s\n", slot_name(p_slot)); 733 break; 734 default: 735 - err("Not a valid state on slot %s\n", slot_name(p_slot)); 736 break; 737 } 738 mutex_unlock(&p_slot->lock);
··· 62 u32 event_type; 63 64 /* Attention Button Change */ 65 + ctrl_dbg(ctrl, "Attention button interrupt received.\n"); 66 67 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 68 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); ··· 70 /* 71 * Button pressed - See if need to TAKE ACTION!!! 72 */ 73 + ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot)); 74 event_type = INT_BUTTON_PRESS; 75 76 queue_interrupt_event(p_slot, event_type); ··· 86 u32 event_type; 87 88 /* Switch Change */ 89 + ctrl_dbg(ctrl, "Switch interrupt received.\n"); 90 91 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 92 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); 93 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 94 + ctrl_dbg(ctrl, "%s: Card present %x Power status %x\n", 95 + __func__, p_slot->presence_save, p_slot->pwr_save); 96 97 if (getstatus) { 98 /* 99 * Switch opened 100 */ 101 + ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot)); 102 event_type = INT_SWITCH_OPEN; 103 if (p_slot->pwr_save && p_slot->presence_save) { 104 event_type = INT_POWER_FAULT; 105 + ctrl_err(ctrl, "Surprise Removal of card\n"); 106 } 107 } else { 108 /* 109 * Switch closed 110 */ 111 + ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot)); 112 event_type = INT_SWITCH_CLOSE; 113 } 114 ··· 123 u32 event_type; 124 125 /* Presence Change */ 126 + ctrl_dbg(ctrl, "Presence/Notify input change.\n"); 127 128 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 129 ··· 135 /* 136 * Card Present 137 */ 138 + ctrl_info(ctrl, "Card present on Slot(%s)\n", 139 + slot_name(p_slot)); 140 event_type = INT_PRESENCE_ON; 141 } else { 142 /* 143 * Not Present 144 */ 145 + ctrl_info(ctrl, "Card not present on Slot(%s)\n", 146 + slot_name(p_slot)); 147 event_type = INT_PRESENCE_OFF; 148 } 149 ··· 156 u32 event_type; 157 158 /* Power fault */ 159 + ctrl_dbg(ctrl, "Power fault interrupt received.\n"); 160 161 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 162 ··· 164 /* 165 * Power fault Cleared 166 */ 167 + ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n", 168 + slot_name(p_slot)); 169 p_slot->status = 0x00; 170 event_type = INT_POWER_FAULT_CLEAR; 171 } else { 172 /* 173 * Power fault 174 */ 175 + ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot)); 176 event_type = INT_POWER_FAULT; 177 /* set power fault status for this board */ 178 p_slot->status = 0xFF; 179 + ctrl_info(ctrl, "power fault bit %x set\n", hp_slot); 180 } 181 182 queue_interrupt_event(p_slot, event_type); ··· 191 { 192 int rc = 0; 193 194 + ctrl_dbg(ctrl, "%s: change to speed %d\n", __func__, speed); 195 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { 196 + ctrl_err(ctrl, "%s: Issue of set bus speed mode command " 197 + "failed\n", __func__); 198 return WRONG_BUS_FREQUENCY; 199 } 200 return rc; ··· 212 */ 213 if (flag) { 214 if (asp < bsp) { 215 + ctrl_err(ctrl, "%s: speed of bus %x and adapter %x " 216 + "mismatch\n", __func__, bsp, asp); 217 rc = WRONG_BUS_FREQUENCY; 218 } 219 return rc; ··· 246 247 hp_slot = p_slot->device - ctrl->slot_device_offset; 248 249 + ctrl_dbg(ctrl, 250 + "%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", 251 + __func__, p_slot->device, ctrl->slot_device_offset, hp_slot); 252 253 /* Power on slot without connecting to bus */ 254 rc = p_slot->hpc_ops->power_on_slot(p_slot); 255 if (rc) { 256 + ctrl_err(ctrl, "%s: Failed to power on slot\n", __func__); 257 return -1; 258 } 259 ··· 262 return WRONG_BUS_FREQUENCY; 263 264 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 265 + ctrl_err(ctrl, "%s: Issue of set bus speed mode command" 266 + " failed\n", __func__); 267 return WRONG_BUS_FREQUENCY; 268 } 269 270 /* turn on board, blink green LED, turn off Amber LED */ 271 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 272 + ctrl_err(ctrl, "%s: Issue of Slot Enable command" 273 + " failed\n", __func__); 274 return rc; 275 } 276 } 277 278 rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp); 279 if (rc) { 280 + ctrl_err(ctrl, "%s: Can't get adapter speed or bus mode " 281 + "mismatch\n", __func__); 282 return WRONG_BUS_FREQUENCY; 283 } 284 285 rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp); 286 if (rc) { 287 + ctrl_err(ctrl, "%s: Can't get bus operation speed\n", __func__); 288 return WRONG_BUS_FREQUENCY; 289 } 290 291 rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp); 292 if (rc) { 293 + ctrl_err(ctrl, "%s: Can't get max bus operation speed\n", 294 + __func__); 295 msp = bsp; 296 } 297 ··· 296 if (!list_empty(&ctrl->pci_dev->subordinate->devices)) 297 slots_not_empty = 1; 298 299 + ctrl_dbg(ctrl, "%s: slots_not_empty %d, adapter_speed %d, bus_speed %d," 300 + " max_bus_speed %d\n", __func__, slots_not_empty, asp, 301 + bsp, msp); 302 303 rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp); 304 if (rc) ··· 306 307 /* turn on board, blink green LED, turn off Amber LED */ 308 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 309 + ctrl_err(ctrl, "%s: Issue of Slot Enable command failed\n", 310 + __func__); 311 return rc; 312 } 313 314 /* Wait for ~1 second */ 315 msleep(1000); 316 317 + ctrl_dbg(ctrl, "%s: slot status = %x\n", __func__, p_slot->status); 318 /* Check for a power fault */ 319 if (p_slot->status == 0xFF) { 320 /* power fault occurred, but it was benign */ 321 + ctrl_dbg(ctrl, "%s: power fault\n", __func__); 322 rc = POWER_FAILURE; 323 p_slot->status = 0; 324 goto err_exit; 325 } 326 327 if (shpchp_configure_device(p_slot)) { 328 + ctrl_err(ctrl, "Cannot add device at 0x%x:0x%x\n", 329 + p_slot->bus, p_slot->device); 330 goto err_exit; 331 } 332 ··· 341 /* turn off slot, turn on Amber LED, turn off Green LED */ 342 rc = p_slot->hpc_ops->slot_disable(p_slot); 343 if (rc) { 344 + ctrl_err(ctrl, "%s: Issue of Slot Disable command failed\n", 345 + __func__); 346 return rc; 347 } 348 ··· 365 hp_slot = p_slot->device - ctrl->slot_device_offset; 366 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 367 368 + ctrl_dbg(ctrl, "In %s, hp_slot = %d\n", __func__, hp_slot); 369 370 /* Change status to shutdown */ 371 if (p_slot->is_a_board) ··· 374 /* turn off slot, turn on Amber LED, turn off Green LED */ 375 rc = p_slot->hpc_ops->slot_disable(p_slot); 376 if (rc) { 377 + ctrl_err(ctrl, "%s: Issue of Slot Disable command failed\n", 378 + __func__); 379 return rc; 380 } 381 382 rc = p_slot->hpc_ops->set_attention_status(p_slot, 0); 383 if (rc) { 384 + ctrl_err(ctrl, "%s: Issue of Set Attention command failed\n", 385 + __func__); 386 return rc; 387 } 388 ··· 439 440 info = kmalloc(sizeof(*info), GFP_KERNEL); 441 if (!info) { 442 + ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n", 443 + __func__); 444 return; 445 } 446 info->p_slot = p_slot; ··· 486 static void handle_button_press_event(struct slot *p_slot) 487 { 488 u8 getstatus; 489 + struct controller *ctrl = p_slot->ctrl; 490 491 switch (p_slot->state) { 492 case STATIC_STATE: 493 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 494 if (getstatus) { 495 p_slot->state = BLINKINGOFF_STATE; 496 + ctrl_info(ctrl, "PCI slot #%s - powering off due to " 497 + "button press.\n", slot_name(p_slot)); 498 } else { 499 p_slot->state = BLINKINGON_STATE; 500 + ctrl_info(ctrl, "PCI slot #%s - powering on due to " 501 + "button press.\n", slot_name(p_slot)); 502 } 503 /* blink green LED and turn off amber */ 504 p_slot->hpc_ops->green_led_blink(p_slot); ··· 512 * press the attention again before the 5 sec. limit 513 * expires to cancel hot-add or hot-remove 514 */ 515 + ctrl_info(ctrl, "Button cancel on Slot(%s)\n", 516 + slot_name(p_slot)); 517 + ctrl_dbg(ctrl, "%s: button cancel\n", __func__); 518 cancel_delayed_work(&p_slot->work); 519 if (p_slot->state == BLINKINGOFF_STATE) 520 p_slot->hpc_ops->green_led_on(p_slot); 521 else 522 p_slot->hpc_ops->green_led_off(p_slot); 523 p_slot->hpc_ops->set_attention_status(p_slot, 0); 524 + ctrl_info(ctrl, "PCI slot #%s - action canceled due to " 525 + "button press\n", slot_name(p_slot)); 526 p_slot->state = STATIC_STATE; 527 break; 528 case POWEROFF_STATE: ··· 531 * this means that the previous attention button action 532 * to hot-add or hot-remove is undergoing 533 */ 534 + ctrl_info(ctrl, "Button ignore on Slot(%s)\n", 535 + slot_name(p_slot)); 536 update_slot_info(p_slot); 537 break; 538 default: 539 + ctrl_warn(ctrl, "Not a valid state\n"); 540 break; 541 } 542 } ··· 551 handle_button_press_event(p_slot); 552 break; 553 case INT_POWER_FAULT: 554 + ctrl_dbg(p_slot->ctrl, "%s: power fault\n", __func__); 555 p_slot->hpc_ops->set_attention_status(p_slot, 1); 556 p_slot->hpc_ops->green_led_off(p_slot); 557 break; ··· 569 { 570 u8 getstatus = 0; 571 int rc, retval = -ENODEV; 572 + struct controller *ctrl = p_slot->ctrl; 573 574 /* Check to see if (latch closed, card present, power off) */ 575 mutex_lock(&p_slot->ctrl->crit_sect); 576 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 577 if (rc || !getstatus) { 578 + ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); 579 goto out; 580 } 581 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 582 if (rc || getstatus) { 583 + ctrl_info(ctrl, "Latch open on slot(%s)\n", slot_name(p_slot)); 584 goto out; 585 } 586 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 587 if (rc || getstatus) { 588 + ctrl_info(ctrl, "Already enabled on slot(%s)\n", 589 + slot_name(p_slot)); 590 goto out; 591 } 592 ··· 593 /* We have to save the presence info for these slots */ 594 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save)); 595 p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save)); 596 + ctrl_dbg(ctrl, "%s: p_slot->pwr_save %x\n", __func__, p_slot->pwr_save); 597 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 598 599 if(((p_slot->ctrl->pci_dev->vendor == PCI_VENDOR_ID_AMD) || ··· 624 { 625 u8 getstatus = 0; 626 int rc, retval = -ENODEV; 627 + struct controller *ctrl = p_slot->ctrl; 628 629 if (!p_slot->ctrl) 630 return -ENODEV; ··· 633 634 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 635 if (rc || !getstatus) { 636 + ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); 637 goto out; 638 } 639 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 640 if (rc || getstatus) { 641 + ctrl_info(ctrl, "Latch open on slot(%s)\n", slot_name(p_slot)); 642 goto out; 643 } 644 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 645 if (rc || !getstatus) { 646 + ctrl_info(ctrl, "Already disabled slot(%s)\n", 647 + slot_name(p_slot)); 648 goto out; 649 } 650 ··· 657 int shpchp_sysfs_enable_slot(struct slot *p_slot) 658 { 659 int retval = -ENODEV; 660 + struct controller *ctrl = p_slot->ctrl; 661 662 mutex_lock(&p_slot->lock); 663 switch (p_slot->state) { ··· 670 p_slot->state = STATIC_STATE; 671 break; 672 case POWERON_STATE: 673 + ctrl_info(ctrl, "Slot %s is already in powering on state\n", 674 + slot_name(p_slot)); 675 break; 676 case BLINKINGOFF_STATE: 677 case POWEROFF_STATE: 678 + ctrl_info(ctrl, "Already enabled on slot %s\n", 679 + slot_name(p_slot)); 680 break; 681 default: 682 + ctrl_err(ctrl, "Not a valid state on slot %s\n", 683 + slot_name(p_slot)); 684 break; 685 } 686 mutex_unlock(&p_slot->lock); ··· 689 int shpchp_sysfs_disable_slot(struct slot *p_slot) 690 { 691 int retval = -ENODEV; 692 + struct controller *ctrl = p_slot->ctrl; 693 694 mutex_lock(&p_slot->lock); 695 switch (p_slot->state) { ··· 702 p_slot->state = STATIC_STATE; 703 break; 704 case POWEROFF_STATE: 705 + ctrl_info(ctrl, "Slot %s is already in powering off state\n", 706 + slot_name(p_slot)); 707 break; 708 case BLINKINGON_STATE: 709 case POWERON_STATE: 710 + ctrl_info(ctrl, "Already disabled on slot %s\n", 711 + slot_name(p_slot)); 712 break; 713 default: 714 + ctrl_err(ctrl, "Not a valid state on slot %s\n", 715 + slot_name(p_slot)); 716 break; 717 } 718 mutex_unlock(&p_slot->lock);
+64 -56
drivers/pci/hotplug/shpchp_hpc.c
··· 300 !is_ctrl_busy(ctrl), timeout); 301 if (!rc && is_ctrl_busy(ctrl)) { 302 retval = -EIO; 303 - err("Command not completed in 1000 msec\n"); 304 } else if (rc < 0) { 305 retval = -EINTR; 306 - info("Command was interrupted by a signal\n"); 307 } 308 309 return retval; ··· 320 321 if (!shpc_poll_ctrl_busy(ctrl)) { 322 /* After 1 sec and and the controller is still busy */ 323 - err("%s : Controller is still busy after 1 sec.\n", 324 - __func__); 325 retval = -EBUSY; 326 goto out; 327 } 328 329 ++t_slot; 330 temp_word = (t_slot << 8) | (cmd & 0xFF); 331 - dbg("%s: t_slot %x cmd %x\n", __func__, t_slot, cmd); 332 333 /* To make sure the Controller Busy bit is 0 before we send out the 334 * command. ··· 344 345 cmd_status = hpc_check_cmd_status(slot->ctrl); 346 if (cmd_status) { 347 - err("%s: Failed to issued command 0x%x (error code = %d)\n", 348 - __func__, cmd, cmd_status); 349 retval = -EIO; 350 } 351 out: ··· 364 break; 365 case 1: 366 retval = SWITCH_OPEN; 367 - err("%s: Switch opened!\n", __func__); 368 break; 369 case 2: 370 retval = INVALID_CMD; 371 - err("%s: Invalid HPC command!\n", __func__); 372 break; 373 case 4: 374 retval = INVALID_SPEED_MODE; 375 - err("%s: Invalid bus speed/mode!\n", __func__); 376 break; 377 default: 378 retval = cmd_status; ··· 483 return -ENODEV; 484 } 485 486 - dbg("%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", 487 - __func__, slot_reg, pcix_cap, m66_cap); 488 489 switch (pcix_cap) { 490 case 0x0: ··· 509 break; 510 } 511 512 - dbg("Adapter speed = %d\n", *value); 513 return retval; 514 } 515 ··· 526 retval = -1; 527 } 528 529 - dbg("Mode 1 ECC cap = %d\n", *mode); 530 return retval; 531 } 532 ··· 629 630 retval = shpc_write_cmd(slot, slot->hp_slot, SET_SLOT_PWR); 631 if (retval) 632 - err("%s: Write command failed!\n", __func__); 633 634 return retval; 635 } ··· 642 retval = shpc_write_cmd(slot, slot->hp_slot, 643 SET_SLOT_ENABLE | SET_PWR_BLINK | SET_ATTN_OFF); 644 if (retval) 645 - err("%s: Write command failed!\n", __func__); 646 647 return retval; 648 } ··· 655 retval = shpc_write_cmd(slot, slot->hp_slot, 656 SET_SLOT_DISABLE | SET_PWR_OFF | SET_ATTN_ON); 657 if (retval) 658 - err("%s: Write command failed!\n", __func__); 659 660 return retval; 661 } ··· 719 720 retval = shpc_write_cmd(slot, 0, cmd); 721 if (retval) 722 - err("%s: Write command failed!\n", __func__); 723 724 return retval; 725 } ··· 735 if (!intr_loc) 736 return IRQ_NONE; 737 738 - dbg("%s: intr_loc = %x\n",__func__, intr_loc); 739 740 if(!shpchp_poll_mode) { 741 /* ··· 748 shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int); 749 750 intr_loc2 = shpc_readl(ctrl, INTR_LOC); 751 - dbg("%s: intr_loc2 = %x\n",__func__, intr_loc2); 752 } 753 754 if (intr_loc & CMD_INTR_PENDING) { ··· 773 continue; 774 775 slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); 776 - dbg("%s: Slot %x with intr, slot register = %x\n", 777 - __func__, hp_slot, slot_reg); 778 779 if (slot_reg & MRL_CHANGE_DETECTED) 780 shpchp_handle_switch_change(hp_slot, ctrl); ··· 843 } 844 845 *value = bus_speed; 846 - dbg("Max bus speed = %d\n", bus_speed); 847 848 return retval; 849 } ··· 911 break; 912 } 913 914 - dbg("Current bus speed = %d\n", bus_speed); 915 return retval; 916 } 917 ··· 958 } else { 959 ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC); 960 if (!ctrl->cap_offset) { 961 - err("%s : cap_offset == 0\n", __func__); 962 goto abort; 963 } 964 - dbg("%s: cap_offset = %x\n", __func__, ctrl->cap_offset); 965 966 rc = shpc_indirect_read(ctrl, 0, &shpc_base_offset); 967 if (rc) { 968 - err("%s: cannot read base_offset\n", __func__); 969 goto abort; 970 } 971 972 rc = shpc_indirect_read(ctrl, 3, &tempdword); 973 if (rc) { 974 - err("%s: cannot read slot config\n", __func__); 975 goto abort; 976 } 977 num_slots = tempdword & SLOT_NUM; 978 - dbg("%s: num_slots (indirect) %x\n", __func__, num_slots); 979 980 for (i = 0; i < 9 + num_slots; i++) { 981 rc = shpc_indirect_read(ctrl, i, &tempdword); 982 if (rc) { 983 - err("%s: cannot read creg (index = %d)\n", 984 - __func__, i); 985 goto abort; 986 } 987 - dbg("%s: offset %d: value %x\n", __func__,i, 988 - tempdword); 989 } 990 991 ctrl->mmio_base = ··· 997 ctrl->mmio_size = 0x24 + 0x4 * num_slots; 998 } 999 1000 - info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 1001 - pdev->subsystem_device); 1002 1003 rc = pci_enable_device(pdev); 1004 if (rc) { 1005 - err("%s: pci_enable_device failed\n", __func__); 1006 goto abort; 1007 } 1008 1009 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { 1010 - err("%s: cannot reserve MMIO region\n", __func__); 1011 rc = -1; 1012 goto abort; 1013 } 1014 1015 ctrl->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size); 1016 if (!ctrl->creg) { 1017 - err("%s: cannot remap MMIO region %lx @ %lx\n", __func__, 1018 - ctrl->mmio_size, ctrl->mmio_base); 1019 release_mem_region(ctrl->mmio_base, ctrl->mmio_size); 1020 rc = -1; 1021 goto abort; 1022 } 1023 - dbg("%s: ctrl->creg %p\n", __func__, ctrl->creg); 1024 1025 mutex_init(&ctrl->crit_sect); 1026 mutex_init(&ctrl->cmd_lock); ··· 1040 1041 /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */ 1042 tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); 1043 - dbg("%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); 1044 tempdword |= (GLOBAL_INTR_MASK | GLOBAL_SERR_MASK | 1045 COMMAND_INTR_MASK | ARBITER_SERR_MASK); 1046 tempdword &= ~SERR_INTR_RSVDZ_MASK; 1047 shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); 1048 tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); 1049 - dbg("%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); 1050 1051 /* Mask the MRL sensor SERR Mask of individual slot in 1052 * Slot SERR-INT Mask & clear all the existing event if any 1053 */ 1054 for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { 1055 slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); 1056 - dbg("%s: Default Logical Slot Register %d value %x\n", __func__, 1057 - hp_slot, slot_reg); 1058 slot_reg |= (PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | 1059 BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | 1060 CON_PFAULT_INTR_MASK | MRL_CHANGE_SERR_MASK | ··· 1071 /* Installs the interrupt handler */ 1072 rc = pci_enable_msi(pdev); 1073 if (rc) { 1074 - info("Can't get msi for the hotplug controller\n"); 1075 - info("Use INTx for the hotplug controller\n"); 1076 } 1077 1078 rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED, 1079 MY_NAME, (void *)ctrl); 1080 - dbg("%s: request_irq %d for hpc%d (returns %d)\n", 1081 - __func__, ctrl->pci_dev->irq, 1082 atomic_read(&shpchp_num_controllers), rc); 1083 if (rc) { 1084 - err("Can't get irq %d for the hotplug controller\n", 1085 - ctrl->pci_dev->irq); 1086 goto abort_iounmap; 1087 } 1088 } 1089 - dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __func__, 1090 - pdev->bus->number, PCI_SLOT(pdev->devfn), 1091 - PCI_FUNC(pdev->devfn), pdev->irq); 1092 1093 /* 1094 * If this is the first controller to be initialized, ··· 1109 */ 1110 for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { 1111 slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); 1112 - dbg("%s: Default Logical Slot Register %d value %x\n", __func__, 1113 - hp_slot, slot_reg); 1114 slot_reg &= ~(PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | 1115 BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | 1116 CON_PFAULT_INTR_MASK | SLOT_REG_RSVDZ_MASK); ··· 1123 SERR_INTR_RSVDZ_MASK); 1124 shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); 1125 tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); 1126 - dbg("%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); 1127 } 1128 1129 return 0;
··· 300 !is_ctrl_busy(ctrl), timeout); 301 if (!rc && is_ctrl_busy(ctrl)) { 302 retval = -EIO; 303 + ctrl_err(ctrl, "Command not completed in 1000 msec\n"); 304 } else if (rc < 0) { 305 retval = -EINTR; 306 + ctrl_info(ctrl, "Command was interrupted by a signal\n"); 307 } 308 309 return retval; ··· 320 321 if (!shpc_poll_ctrl_busy(ctrl)) { 322 /* After 1 sec and and the controller is still busy */ 323 + ctrl_err(ctrl, "%s : Controller is still busy after 1 sec.\n", 324 + __func__); 325 retval = -EBUSY; 326 goto out; 327 } 328 329 ++t_slot; 330 temp_word = (t_slot << 8) | (cmd & 0xFF); 331 + ctrl_dbg(ctrl, "%s: t_slot %x cmd %x\n", __func__, t_slot, cmd); 332 333 /* To make sure the Controller Busy bit is 0 before we send out the 334 * command. ··· 344 345 cmd_status = hpc_check_cmd_status(slot->ctrl); 346 if (cmd_status) { 347 + ctrl_err(ctrl, "%s: Failed to issued command 0x%x " 348 + "(error code = %d)\n", __func__, cmd, cmd_status); 349 retval = -EIO; 350 } 351 out: ··· 364 break; 365 case 1: 366 retval = SWITCH_OPEN; 367 + ctrl_err(ctrl, "%s: Switch opened!\n", __func__); 368 break; 369 case 2: 370 retval = INVALID_CMD; 371 + ctrl_err(ctrl, "%s: Invalid HPC command!\n", __func__); 372 break; 373 case 4: 374 retval = INVALID_SPEED_MODE; 375 + ctrl_err(ctrl, "%s: Invalid bus speed/mode!\n", __func__); 376 break; 377 default: 378 retval = cmd_status; ··· 483 return -ENODEV; 484 } 485 486 + ctrl_dbg(ctrl, "%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n", 487 + __func__, slot_reg, pcix_cap, m66_cap); 488 489 switch (pcix_cap) { 490 case 0x0: ··· 509 break; 510 } 511 512 + ctrl_dbg(ctrl, "Adapter speed = %d\n", *value); 513 return retval; 514 } 515 ··· 526 retval = -1; 527 } 528 529 + ctrl_dbg(ctrl, "Mode 1 ECC cap = %d\n", *mode); 530 return retval; 531 } 532 ··· 629 630 retval = shpc_write_cmd(slot, slot->hp_slot, SET_SLOT_PWR); 631 if (retval) 632 + ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__); 633 634 return retval; 635 } ··· 642 retval = shpc_write_cmd(slot, slot->hp_slot, 643 SET_SLOT_ENABLE | SET_PWR_BLINK | SET_ATTN_OFF); 644 if (retval) 645 + ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__); 646 647 return retval; 648 } ··· 655 retval = shpc_write_cmd(slot, slot->hp_slot, 656 SET_SLOT_DISABLE | SET_PWR_OFF | SET_ATTN_ON); 657 if (retval) 658 + ctrl_err(slot->ctrl, "%s: Write command failed!\n", __func__); 659 660 return retval; 661 } ··· 719 720 retval = shpc_write_cmd(slot, 0, cmd); 721 if (retval) 722 + ctrl_err(ctrl, "%s: Write command failed!\n", __func__); 723 724 return retval; 725 } ··· 735 if (!intr_loc) 736 return IRQ_NONE; 737 738 + ctrl_dbg(ctrl, "%s: intr_loc = %x\n", __func__, intr_loc); 739 740 if(!shpchp_poll_mode) { 741 /* ··· 748 shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int); 749 750 intr_loc2 = shpc_readl(ctrl, INTR_LOC); 751 + ctrl_dbg(ctrl, "%s: intr_loc2 = %x\n", __func__, intr_loc2); 752 } 753 754 if (intr_loc & CMD_INTR_PENDING) { ··· 773 continue; 774 775 slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); 776 + ctrl_dbg(ctrl, "%s: Slot %x with intr, slot register = %x\n", 777 + __func__, hp_slot, slot_reg); 778 779 if (slot_reg & MRL_CHANGE_DETECTED) 780 shpchp_handle_switch_change(hp_slot, ctrl); ··· 843 } 844 845 *value = bus_speed; 846 + ctrl_dbg(ctrl, "Max bus speed = %d\n", bus_speed); 847 848 return retval; 849 } ··· 911 break; 912 } 913 914 + ctrl_dbg(ctrl, "Current bus speed = %d\n", bus_speed); 915 return retval; 916 } 917 ··· 958 } else { 959 ctrl->cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC); 960 if (!ctrl->cap_offset) { 961 + ctrl_err(ctrl, "%s : cap_offset == 0\n", __func__); 962 goto abort; 963 } 964 + ctrl_dbg(ctrl, "%s: cap_offset = %x\n", __func__, 965 + ctrl->cap_offset); 966 967 rc = shpc_indirect_read(ctrl, 0, &shpc_base_offset); 968 if (rc) { 969 + ctrl_err(ctrl, "%s: cannot read base_offset\n", 970 + __func__); 971 goto abort; 972 } 973 974 rc = shpc_indirect_read(ctrl, 3, &tempdword); 975 if (rc) { 976 + ctrl_err(ctrl, "%s: cannot read slot config\n", 977 + __func__); 978 goto abort; 979 } 980 num_slots = tempdword & SLOT_NUM; 981 + ctrl_dbg(ctrl, "%s: num_slots (indirect) %x\n", 982 + __func__, num_slots); 983 984 for (i = 0; i < 9 + num_slots; i++) { 985 rc = shpc_indirect_read(ctrl, i, &tempdword); 986 if (rc) { 987 + ctrl_err(ctrl, "%s: cannot read creg " 988 + "(index = %d)\n", __func__, i); 989 goto abort; 990 } 991 + ctrl_dbg(ctrl, "%s: offset %d: value %x\n", 992 + __func__, i, tempdword); 993 } 994 995 ctrl->mmio_base = ··· 993 ctrl->mmio_size = 0x24 + 0x4 * num_slots; 994 } 995 996 + ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", 997 + pdev->vendor, pdev->device, pdev->subsystem_vendor, 998 + pdev->subsystem_device); 999 1000 rc = pci_enable_device(pdev); 1001 if (rc) { 1002 + ctrl_err(ctrl, "%s: pci_enable_device failed\n", __func__); 1003 goto abort; 1004 } 1005 1006 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { 1007 + ctrl_err(ctrl, "%s: cannot reserve MMIO region\n", __func__); 1008 rc = -1; 1009 goto abort; 1010 } 1011 1012 ctrl->creg = ioremap(ctrl->mmio_base, ctrl->mmio_size); 1013 if (!ctrl->creg) { 1014 + ctrl_err(ctrl, "%s: cannot remap MMIO region %lx @ %lx\n", 1015 + __func__, ctrl->mmio_size, ctrl->mmio_base); 1016 release_mem_region(ctrl->mmio_base, ctrl->mmio_size); 1017 rc = -1; 1018 goto abort; 1019 } 1020 + ctrl_dbg(ctrl, "%s: ctrl->creg %p\n", __func__, ctrl->creg); 1021 1022 mutex_init(&ctrl->crit_sect); 1023 mutex_init(&ctrl->cmd_lock); ··· 1035 1036 /* Mask Global Interrupt Mask & Command Complete Interrupt Mask */ 1037 tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); 1038 + ctrl_dbg(ctrl, "%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); 1039 tempdword |= (GLOBAL_INTR_MASK | GLOBAL_SERR_MASK | 1040 COMMAND_INTR_MASK | ARBITER_SERR_MASK); 1041 tempdword &= ~SERR_INTR_RSVDZ_MASK; 1042 shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); 1043 tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); 1044 + ctrl_dbg(ctrl, "%s: SERR_INTR_ENABLE = %x\n", __func__, tempdword); 1045 1046 /* Mask the MRL sensor SERR Mask of individual slot in 1047 * Slot SERR-INT Mask & clear all the existing event if any 1048 */ 1049 for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { 1050 slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); 1051 + ctrl_dbg(ctrl, "%s: Default Logical Slot Register %d " 1052 + "value %x\n", __func__, hp_slot, slot_reg); 1053 slot_reg |= (PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | 1054 BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | 1055 CON_PFAULT_INTR_MASK | MRL_CHANGE_SERR_MASK | ··· 1066 /* Installs the interrupt handler */ 1067 rc = pci_enable_msi(pdev); 1068 if (rc) { 1069 + ctrl_info(ctrl, 1070 + "Can't get msi for the hotplug controller\n"); 1071 + ctrl_info(ctrl, 1072 + "Use INTx for the hotplug controller\n"); 1073 } 1074 1075 rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED, 1076 MY_NAME, (void *)ctrl); 1077 + ctrl_dbg(ctrl, "%s: request_irq %d for hpc%d (returns %d)\n", 1078 + __func__, ctrl->pci_dev->irq, 1079 atomic_read(&shpchp_num_controllers), rc); 1080 if (rc) { 1081 + ctrl_err(ctrl, "Can't get irq %d for the hotplug " 1082 + "controller\n", ctrl->pci_dev->irq); 1083 goto abort_iounmap; 1084 } 1085 } 1086 + ctrl_dbg(ctrl, "%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", 1087 + __func__, pdev->bus->number, PCI_SLOT(pdev->devfn), 1088 + PCI_FUNC(pdev->devfn), pdev->irq); 1089 1090 /* 1091 * If this is the first controller to be initialized, ··· 1102 */ 1103 for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) { 1104 slot_reg = shpc_readl(ctrl, SLOT_REG(hp_slot)); 1105 + ctrl_dbg(ctrl, "%s: Default Logical Slot Register %d " 1106 + "value %x\n", __func__, hp_slot, slot_reg); 1107 slot_reg &= ~(PRSNT_CHANGE_INTR_MASK | ISO_PFAULT_INTR_MASK | 1108 BUTTON_PRESS_INTR_MASK | MRL_CHANGE_INTR_MASK | 1109 CON_PFAULT_INTR_MASK | SLOT_REG_RSVDZ_MASK); ··· 1116 SERR_INTR_RSVDZ_MASK); 1117 shpc_writel(ctrl, SERR_INTR_ENABLE, tempdword); 1118 tempdword = shpc_readl(ctrl, SERR_INTR_ENABLE); 1119 + ctrl_dbg(ctrl, "%s: SERR_INTR_ENABLE = %x\n", 1120 + __func__, tempdword); 1121 } 1122 1123 return 0;
+19 -13
drivers/pci/hotplug/shpchp_pci.c
··· 101 struct pci_dev *dev; 102 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 103 int num, fn; 104 105 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); 106 if (dev) { 107 - err("Device %s already exists at %x:%x, cannot hot-add\n", 108 - pci_name(dev), p_slot->bus, p_slot->device); 109 pci_dev_put(dev); 110 return -EINVAL; 111 } 112 113 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); 114 if (num == 0) { 115 - err("No new device found\n"); 116 return -ENODEV; 117 } 118 ··· 123 if (!dev) 124 continue; 125 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 126 - err("Cannot hot-add display device %s\n", 127 - pci_name(dev)); 128 pci_dev_put(dev); 129 continue; 130 } ··· 140 break; 141 } 142 if (busnr >= end) { 143 - err("No free bus for hot-added bridge\n"); 144 pci_dev_put(dev); 145 continue; 146 } 147 child = pci_add_new_bus(parent, dev, busnr); 148 if (!child) { 149 - err("Cannot add new bus for %s\n", 150 - pci_name(dev)); 151 pci_dev_put(dev); 152 continue; 153 } ··· 171 int j; 172 u8 bctl = 0; 173 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 174 175 - dbg("%s: bus/dev = %x/%x\n", __func__, p_slot->bus, p_slot->device); 176 177 for (j=0; j<8 ; j++) { 178 struct pci_dev* temp = pci_get_slot(parent, ··· 182 if (!temp) 183 continue; 184 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 185 - err("Cannot remove display device %s\n", 186 - pci_name(temp)); 187 pci_dev_put(temp); 188 continue; 189 } 190 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 191 pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); 192 if (bctl & PCI_BRIDGE_CTL_VGA) { 193 - err("Cannot remove display device %s\n", 194 - pci_name(temp)); 195 pci_dev_put(temp); 196 continue; 197 }
··· 101 struct pci_dev *dev; 102 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 103 int num, fn; 104 + struct controller *ctrl = p_slot->ctrl; 105 106 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); 107 if (dev) { 108 + ctrl_err(ctrl, 109 + "Device %s already exists at %x:%x, cannot hot-add\n", 110 + pci_name(dev), p_slot->bus, p_slot->device); 111 pci_dev_put(dev); 112 return -EINVAL; 113 } 114 115 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); 116 if (num == 0) { 117 + ctrl_err(ctrl, "No new device found\n"); 118 return -ENODEV; 119 } 120 ··· 121 if (!dev) 122 continue; 123 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 124 + ctrl_err(ctrl, "Cannot hot-add display device %s\n", 125 + pci_name(dev)); 126 pci_dev_put(dev); 127 continue; 128 } ··· 138 break; 139 } 140 if (busnr >= end) { 141 + ctrl_err(ctrl, 142 + "No free bus for hot-added bridge\n"); 143 pci_dev_put(dev); 144 continue; 145 } 146 child = pci_add_new_bus(parent, dev, busnr); 147 if (!child) { 148 + ctrl_err(ctrl, "Cannot add new bus for %s\n", 149 + pci_name(dev)); 150 pci_dev_put(dev); 151 continue; 152 } ··· 168 int j; 169 u8 bctl = 0; 170 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 171 + struct controller *ctrl = p_slot->ctrl; 172 173 + ctrl_dbg(ctrl, "%s: bus/dev = %x/%x\n", 174 + __func__, p_slot->bus, p_slot->device); 175 176 for (j=0; j<8 ; j++) { 177 struct pci_dev* temp = pci_get_slot(parent, ··· 177 if (!temp) 178 continue; 179 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 180 + ctrl_err(ctrl, "Cannot remove display device %s\n", 181 + pci_name(temp)); 182 pci_dev_put(temp); 183 continue; 184 } 185 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 186 pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); 187 if (bctl & PCI_BRIDGE_CTL_VGA) { 188 + ctrl_err(ctrl, 189 + "Cannot remove display device %s\n", 190 + pci_name(temp)); 191 pci_dev_put(temp); 192 continue; 193 }