diff options
Diffstat (limited to 'drivers/pci/hotplug/cpqphp_ctrl.c')
-rw-r--r-- | drivers/pci/hotplug/cpqphp_ctrl.c | 124 |
1 files changed, 38 insertions, 86 deletions
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 771ed34b1819..55d2dc7e39ca 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
@@ -1282,9 +1282,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1282 | u8 hp_slot; | 1282 | u8 hp_slot; |
1283 | u8 temp_byte; | 1283 | u8 temp_byte; |
1284 | u8 adapter_speed; | 1284 | u8 adapter_speed; |
1285 | u32 index; | ||
1286 | u32 rc = 0; | 1285 | u32 rc = 0; |
1287 | u32 src = 8; | ||
1288 | 1286 | ||
1289 | hp_slot = func->device - ctrl->slot_device_offset; | 1287 | hp_slot = func->device - ctrl->slot_device_offset; |
1290 | 1288 | ||
@@ -1299,7 +1297,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1299 | **********************************/ | 1297 | **********************************/ |
1300 | rc = CARD_FUNCTIONING; | 1298 | rc = CARD_FUNCTIONING; |
1301 | } else { | 1299 | } else { |
1302 | down(&ctrl->crit_sect); | 1300 | mutex_lock(&ctrl->crit_sect); |
1303 | 1301 | ||
1304 | /* turn on board without attaching to the bus */ | 1302 | /* turn on board without attaching to the bus */ |
1305 | enable_slot_power (ctrl, hp_slot); | 1303 | enable_slot_power (ctrl, hp_slot); |
@@ -1333,12 +1331,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1333 | /* Wait for SOBS to be unset */ | 1331 | /* Wait for SOBS to be unset */ |
1334 | wait_for_ctrl_irq (ctrl); | 1332 | wait_for_ctrl_irq (ctrl); |
1335 | 1333 | ||
1336 | up(&ctrl->crit_sect); | 1334 | mutex_unlock(&ctrl->crit_sect); |
1337 | 1335 | ||
1338 | if (rc) | 1336 | if (rc) |
1339 | return rc; | 1337 | return rc; |
1340 | 1338 | ||
1341 | down(&ctrl->crit_sect); | 1339 | mutex_lock(&ctrl->crit_sect); |
1342 | 1340 | ||
1343 | slot_enable (ctrl, hp_slot); | 1341 | slot_enable (ctrl, hp_slot); |
1344 | green_LED_blink (ctrl, hp_slot); | 1342 | green_LED_blink (ctrl, hp_slot); |
@@ -1350,7 +1348,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1350 | /* Wait for SOBS to be unset */ | 1348 | /* Wait for SOBS to be unset */ |
1351 | wait_for_ctrl_irq (ctrl); | 1349 | wait_for_ctrl_irq (ctrl); |
1352 | 1350 | ||
1353 | up(&ctrl->crit_sect); | 1351 | mutex_unlock(&ctrl->crit_sect); |
1354 | 1352 | ||
1355 | /* Wait for ~1 second because of hot plug spec */ | 1353 | /* Wait for ~1 second because of hot plug spec */ |
1356 | long_delay(1*HZ); | 1354 | long_delay(1*HZ); |
@@ -1368,76 +1366,30 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1368 | 1366 | ||
1369 | rc = cpqhp_configure_board(ctrl, func); | 1367 | rc = cpqhp_configure_board(ctrl, func); |
1370 | 1368 | ||
1371 | if (rc || src) { | 1369 | /* If configuration fails, turn it off |
1372 | /* If configuration fails, turn it off | 1370 | * Get slot won't work for devices behind |
1373 | * Get slot won't work for devices behind | 1371 | * bridges, but in this case it will always be |
1374 | * bridges, but in this case it will always be | 1372 | * called for the "base" bus/dev/func of an |
1375 | * called for the "base" bus/dev/func of an | 1373 | * adapter. */ |
1376 | * adapter. */ | ||
1377 | 1374 | ||
1378 | down(&ctrl->crit_sect); | 1375 | mutex_lock(&ctrl->crit_sect); |
1379 | 1376 | ||
1380 | amber_LED_on (ctrl, hp_slot); | 1377 | amber_LED_on (ctrl, hp_slot); |
1381 | green_LED_off (ctrl, hp_slot); | 1378 | green_LED_off (ctrl, hp_slot); |
1382 | slot_disable (ctrl, hp_slot); | 1379 | slot_disable (ctrl, hp_slot); |
1383 | |||
1384 | set_SOGO(ctrl); | ||
1385 | |||
1386 | /* Wait for SOBS to be unset */ | ||
1387 | wait_for_ctrl_irq (ctrl); | ||
1388 | |||
1389 | up(&ctrl->crit_sect); | ||
1390 | |||
1391 | if (rc) | ||
1392 | return rc; | ||
1393 | else | ||
1394 | return 1; | ||
1395 | } | ||
1396 | |||
1397 | func->status = 0; | ||
1398 | func->switch_save = 0x10; | ||
1399 | |||
1400 | index = 1; | ||
1401 | while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) { | ||
1402 | rc |= cpqhp_configure_board(ctrl, func); | ||
1403 | index++; | ||
1404 | } | ||
1405 | |||
1406 | if (rc) { | ||
1407 | /* If configuration fails, turn it off | ||
1408 | * Get slot won't work for devices behind | ||
1409 | * bridges, but in this case it will always be | ||
1410 | * called for the "base" bus/dev/func of an | ||
1411 | * adapter. */ | ||
1412 | |||
1413 | down(&ctrl->crit_sect); | ||
1414 | |||
1415 | amber_LED_on (ctrl, hp_slot); | ||
1416 | green_LED_off (ctrl, hp_slot); | ||
1417 | slot_disable (ctrl, hp_slot); | ||
1418 | |||
1419 | set_SOGO(ctrl); | ||
1420 | |||
1421 | /* Wait for SOBS to be unset */ | ||
1422 | wait_for_ctrl_irq (ctrl); | ||
1423 | |||
1424 | up(&ctrl->crit_sect); | ||
1425 | |||
1426 | return rc; | ||
1427 | } | ||
1428 | /* Done configuring so turn LED on full time */ | ||
1429 | |||
1430 | down(&ctrl->crit_sect); | ||
1431 | |||
1432 | green_LED_on (ctrl, hp_slot); | ||
1433 | 1380 | ||
1434 | set_SOGO(ctrl); | 1381 | set_SOGO(ctrl); |
1435 | 1382 | ||
1436 | /* Wait for SOBS to be unset */ | 1383 | /* Wait for SOBS to be unset */ |
1437 | wait_for_ctrl_irq (ctrl); | 1384 | wait_for_ctrl_irq (ctrl); |
1438 | 1385 | ||
1439 | up(&ctrl->crit_sect); | 1386 | mutex_unlock(&ctrl->crit_sect); |
1440 | rc = 0; | 1387 | |
1388 | if (rc) | ||
1389 | return rc; | ||
1390 | else | ||
1391 | return 1; | ||
1392 | |||
1441 | } else { | 1393 | } else { |
1442 | /* Something is wrong | 1394 | /* Something is wrong |
1443 | 1395 | ||
@@ -1445,7 +1397,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1445 | * in this case it will always be called for the "base" | 1397 | * in this case it will always be called for the "base" |
1446 | * bus/dev/func of an adapter. */ | 1398 | * bus/dev/func of an adapter. */ |
1447 | 1399 | ||
1448 | down(&ctrl->crit_sect); | 1400 | mutex_lock(&ctrl->crit_sect); |
1449 | 1401 | ||
1450 | amber_LED_on (ctrl, hp_slot); | 1402 | amber_LED_on (ctrl, hp_slot); |
1451 | green_LED_off (ctrl, hp_slot); | 1403 | green_LED_off (ctrl, hp_slot); |
@@ -1456,7 +1408,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl) | |||
1456 | /* Wait for SOBS to be unset */ | 1408 | /* Wait for SOBS to be unset */ |
1457 | wait_for_ctrl_irq (ctrl); | 1409 | wait_for_ctrl_irq (ctrl); |
1458 | 1410 | ||
1459 | up(&ctrl->crit_sect); | 1411 | mutex_unlock(&ctrl->crit_sect); |
1460 | } | 1412 | } |
1461 | 1413 | ||
1462 | } | 1414 | } |
@@ -1488,7 +1440,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1488 | dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", | 1440 | dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", |
1489 | __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); | 1441 | __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); |
1490 | 1442 | ||
1491 | down(&ctrl->crit_sect); | 1443 | mutex_lock(&ctrl->crit_sect); |
1492 | 1444 | ||
1493 | /* turn on board without attaching to the bus */ | 1445 | /* turn on board without attaching to the bus */ |
1494 | enable_slot_power(ctrl, hp_slot); | 1446 | enable_slot_power(ctrl, hp_slot); |
@@ -1522,7 +1474,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1522 | /* Wait for SOBS to be unset */ | 1474 | /* Wait for SOBS to be unset */ |
1523 | wait_for_ctrl_irq(ctrl); | 1475 | wait_for_ctrl_irq(ctrl); |
1524 | 1476 | ||
1525 | up(&ctrl->crit_sect); | 1477 | mutex_unlock(&ctrl->crit_sect); |
1526 | 1478 | ||
1527 | if (rc) | 1479 | if (rc) |
1528 | return rc; | 1480 | return rc; |
@@ -1532,7 +1484,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1532 | /* turn on board and blink green LED */ | 1484 | /* turn on board and blink green LED */ |
1533 | 1485 | ||
1534 | dbg("%s: before down\n", __FUNCTION__); | 1486 | dbg("%s: before down\n", __FUNCTION__); |
1535 | down(&ctrl->crit_sect); | 1487 | mutex_lock(&ctrl->crit_sect); |
1536 | dbg("%s: after down\n", __FUNCTION__); | 1488 | dbg("%s: after down\n", __FUNCTION__); |
1537 | 1489 | ||
1538 | dbg("%s: before slot_enable\n", __FUNCTION__); | 1490 | dbg("%s: before slot_enable\n", __FUNCTION__); |
@@ -1553,7 +1505,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1553 | dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); | 1505 | dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); |
1554 | 1506 | ||
1555 | dbg("%s: before up\n", __FUNCTION__); | 1507 | dbg("%s: before up\n", __FUNCTION__); |
1556 | up(&ctrl->crit_sect); | 1508 | mutex_unlock(&ctrl->crit_sect); |
1557 | dbg("%s: after up\n", __FUNCTION__); | 1509 | dbg("%s: after up\n", __FUNCTION__); |
1558 | 1510 | ||
1559 | /* Wait for ~1 second because of hot plug spec */ | 1511 | /* Wait for ~1 second because of hot plug spec */ |
@@ -1607,7 +1559,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1607 | cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); | 1559 | cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); |
1608 | 1560 | ||
1609 | if (rc) { | 1561 | if (rc) { |
1610 | down(&ctrl->crit_sect); | 1562 | mutex_lock(&ctrl->crit_sect); |
1611 | 1563 | ||
1612 | amber_LED_on (ctrl, hp_slot); | 1564 | amber_LED_on (ctrl, hp_slot); |
1613 | green_LED_off (ctrl, hp_slot); | 1565 | green_LED_off (ctrl, hp_slot); |
@@ -1618,7 +1570,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1618 | /* Wait for SOBS to be unset */ | 1570 | /* Wait for SOBS to be unset */ |
1619 | wait_for_ctrl_irq (ctrl); | 1571 | wait_for_ctrl_irq (ctrl); |
1620 | 1572 | ||
1621 | up(&ctrl->crit_sect); | 1573 | mutex_unlock(&ctrl->crit_sect); |
1622 | return rc; | 1574 | return rc; |
1623 | } else { | 1575 | } else { |
1624 | cpqhp_save_slot_config(ctrl, func); | 1576 | cpqhp_save_slot_config(ctrl, func); |
@@ -1640,7 +1592,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1640 | } | 1592 | } |
1641 | } while (new_slot); | 1593 | } while (new_slot); |
1642 | 1594 | ||
1643 | down(&ctrl->crit_sect); | 1595 | mutex_lock(&ctrl->crit_sect); |
1644 | 1596 | ||
1645 | green_LED_on (ctrl, hp_slot); | 1597 | green_LED_on (ctrl, hp_slot); |
1646 | 1598 | ||
@@ -1649,9 +1601,9 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1649 | /* Wait for SOBS to be unset */ | 1601 | /* Wait for SOBS to be unset */ |
1650 | wait_for_ctrl_irq (ctrl); | 1602 | wait_for_ctrl_irq (ctrl); |
1651 | 1603 | ||
1652 | up(&ctrl->crit_sect); | 1604 | mutex_unlock(&ctrl->crit_sect); |
1653 | } else { | 1605 | } else { |
1654 | down(&ctrl->crit_sect); | 1606 | mutex_lock(&ctrl->crit_sect); |
1655 | 1607 | ||
1656 | amber_LED_on (ctrl, hp_slot); | 1608 | amber_LED_on (ctrl, hp_slot); |
1657 | green_LED_off (ctrl, hp_slot); | 1609 | green_LED_off (ctrl, hp_slot); |
@@ -1662,7 +1614,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl) | |||
1662 | /* Wait for SOBS to be unset */ | 1614 | /* Wait for SOBS to be unset */ |
1663 | wait_for_ctrl_irq (ctrl); | 1615 | wait_for_ctrl_irq (ctrl); |
1664 | 1616 | ||
1665 | up(&ctrl->crit_sect); | 1617 | mutex_unlock(&ctrl->crit_sect); |
1666 | 1618 | ||
1667 | return rc; | 1619 | return rc; |
1668 | } | 1620 | } |
@@ -1721,7 +1673,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control | |||
1721 | func->status = 0x01; | 1673 | func->status = 0x01; |
1722 | func->configured = 0; | 1674 | func->configured = 0; |
1723 | 1675 | ||
1724 | down(&ctrl->crit_sect); | 1676 | mutex_lock(&ctrl->crit_sect); |
1725 | 1677 | ||
1726 | green_LED_off (ctrl, hp_slot); | 1678 | green_LED_off (ctrl, hp_slot); |
1727 | slot_disable (ctrl, hp_slot); | 1679 | slot_disable (ctrl, hp_slot); |
@@ -1736,7 +1688,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control | |||
1736 | /* Wait for SOBS to be unset */ | 1688 | /* Wait for SOBS to be unset */ |
1737 | wait_for_ctrl_irq (ctrl); | 1689 | wait_for_ctrl_irq (ctrl); |
1738 | 1690 | ||
1739 | up(&ctrl->crit_sect); | 1691 | mutex_unlock(&ctrl->crit_sect); |
1740 | 1692 | ||
1741 | if (!replace_flag && ctrl->add_support) { | 1693 | if (!replace_flag && ctrl->add_support) { |
1742 | while (func) { | 1694 | while (func) { |
@@ -1899,7 +1851,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1899 | dbg("button cancel\n"); | 1851 | dbg("button cancel\n"); |
1900 | del_timer(&p_slot->task_event); | 1852 | del_timer(&p_slot->task_event); |
1901 | 1853 | ||
1902 | down(&ctrl->crit_sect); | 1854 | mutex_lock(&ctrl->crit_sect); |
1903 | 1855 | ||
1904 | if (p_slot->state == BLINKINGOFF_STATE) { | 1856 | if (p_slot->state == BLINKINGOFF_STATE) { |
1905 | /* slot is on */ | 1857 | /* slot is on */ |
@@ -1922,7 +1874,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1922 | /* Wait for SOBS to be unset */ | 1874 | /* Wait for SOBS to be unset */ |
1923 | wait_for_ctrl_irq (ctrl); | 1875 | wait_for_ctrl_irq (ctrl); |
1924 | 1876 | ||
1925 | up(&ctrl->crit_sect); | 1877 | mutex_unlock(&ctrl->crit_sect); |
1926 | } | 1878 | } |
1927 | /*** button Released (No action on press...) */ | 1879 | /*** button Released (No action on press...) */ |
1928 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { | 1880 | else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { |
@@ -1937,7 +1889,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1937 | p_slot->state = BLINKINGON_STATE; | 1889 | p_slot->state = BLINKINGON_STATE; |
1938 | info(msg_button_on, p_slot->number); | 1890 | info(msg_button_on, p_slot->number); |
1939 | } | 1891 | } |
1940 | down(&ctrl->crit_sect); | 1892 | mutex_lock(&ctrl->crit_sect); |
1941 | 1893 | ||
1942 | dbg("blink green LED and turn off amber\n"); | 1894 | dbg("blink green LED and turn off amber\n"); |
1943 | 1895 | ||
@@ -1949,7 +1901,7 @@ static void interrupt_event_handler(struct controller *ctrl) | |||
1949 | /* Wait for SOBS to be unset */ | 1901 | /* Wait for SOBS to be unset */ |
1950 | wait_for_ctrl_irq (ctrl); | 1902 | wait_for_ctrl_irq (ctrl); |
1951 | 1903 | ||
1952 | up(&ctrl->crit_sect); | 1904 | mutex_unlock(&ctrl->crit_sect); |
1953 | init_timer(&p_slot->task_event); | 1905 | init_timer(&p_slot->task_event); |
1954 | p_slot->hp_slot = hp_slot; | 1906 | p_slot->hp_slot = hp_slot; |
1955 | p_slot->ctrl = ctrl; | 1907 | p_slot->ctrl = ctrl; |