diff options
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.c')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.c | 446 |
1 files changed, 316 insertions, 130 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index d95d2f274cb3..670241efa4b5 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * for access to MPT (Message Passing Technology) firmware. | 3 | * for access to MPT (Message Passing Technology) firmware. |
4 | * | 4 | * |
5 | * This code is based on drivers/scsi/mpt2sas/mpt2_base.c | 5 | * This code is based on drivers/scsi/mpt2sas/mpt2_base.c |
6 | * Copyright (C) 2007-2008 LSI Corporation | 6 | * Copyright (C) 2007-2009 LSI Corporation |
7 | * (mailto:DL-MPTFusionLinux@lsi.com) | 7 | * (mailto:DL-MPTFusionLinux@lsi.com) |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
@@ -63,7 +63,7 @@ | |||
63 | static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS]; | 63 | static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS]; |
64 | 64 | ||
65 | #define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */ | 65 | #define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */ |
66 | #define MPT2SAS_MAX_REQUEST_QUEUE 500 /* maximum controller queue depth */ | 66 | #define MPT2SAS_MAX_REQUEST_QUEUE 600 /* maximum controller queue depth */ |
67 | 67 | ||
68 | static int max_queue_depth = -1; | 68 | static int max_queue_depth = -1; |
69 | module_param(max_queue_depth, int, 0); | 69 | module_param(max_queue_depth, int, 0); |
@@ -543,13 +543,13 @@ mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code) | |||
543 | * _base_display_reply_info - | 543 | * _base_display_reply_info - |
544 | * @ioc: pointer to scsi command object | 544 | * @ioc: pointer to scsi command object |
545 | * @smid: system request message index | 545 | * @smid: system request message index |
546 | * @VF_ID: virtual function id | 546 | * @msix_index: MSIX table index supplied by the OS |
547 | * @reply: reply message frame(lower 32bit addr) | 547 | * @reply: reply message frame(lower 32bit addr) |
548 | * | 548 | * |
549 | * Return nothing. | 549 | * Return nothing. |
550 | */ | 550 | */ |
551 | static void | 551 | static void |
552 | _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, | 552 | _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, |
553 | u32 reply) | 553 | u32 reply) |
554 | { | 554 | { |
555 | MPI2DefaultReply_t *mpi_reply; | 555 | MPI2DefaultReply_t *mpi_reply; |
@@ -572,22 +572,24 @@ _base_display_reply_info(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, | |||
572 | * mpt2sas_base_done - base internal command completion routine | 572 | * mpt2sas_base_done - base internal command completion routine |
573 | * @ioc: pointer to scsi command object | 573 | * @ioc: pointer to scsi command object |
574 | * @smid: system request message index | 574 | * @smid: system request message index |
575 | * @VF_ID: virtual function id | 575 | * @msix_index: MSIX table index supplied by the OS |
576 | * @reply: reply message frame(lower 32bit addr) | 576 | * @reply: reply message frame(lower 32bit addr) |
577 | * | 577 | * |
578 | * Return nothing. | 578 | * Return 1 meaning mf should be freed from _base_interrupt |
579 | * 0 means the mf is freed from this function. | ||
579 | */ | 580 | */ |
580 | void | 581 | u8 |
581 | mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) | 582 | mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, |
583 | u32 reply) | ||
582 | { | 584 | { |
583 | MPI2DefaultReply_t *mpi_reply; | 585 | MPI2DefaultReply_t *mpi_reply; |
584 | 586 | ||
585 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); | 587 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); |
586 | if (mpi_reply && mpi_reply->Function == MPI2_FUNCTION_EVENT_ACK) | 588 | if (mpi_reply && mpi_reply->Function == MPI2_FUNCTION_EVENT_ACK) |
587 | return; | 589 | return 1; |
588 | 590 | ||
589 | if (ioc->base_cmds.status == MPT2_CMD_NOT_USED) | 591 | if (ioc->base_cmds.status == MPT2_CMD_NOT_USED) |
590 | return; | 592 | return 1; |
591 | 593 | ||
592 | ioc->base_cmds.status |= MPT2_CMD_COMPLETE; | 594 | ioc->base_cmds.status |= MPT2_CMD_COMPLETE; |
593 | if (mpi_reply) { | 595 | if (mpi_reply) { |
@@ -596,18 +598,20 @@ mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) | |||
596 | } | 598 | } |
597 | ioc->base_cmds.status &= ~MPT2_CMD_PENDING; | 599 | ioc->base_cmds.status &= ~MPT2_CMD_PENDING; |
598 | complete(&ioc->base_cmds.done); | 600 | complete(&ioc->base_cmds.done); |
601 | return 1; | ||
599 | } | 602 | } |
600 | 603 | ||
601 | /** | 604 | /** |
602 | * _base_async_event - main callback handler for firmware asyn events | 605 | * _base_async_event - main callback handler for firmware asyn events |
603 | * @ioc: pointer to scsi command object | 606 | * @ioc: pointer to scsi command object |
604 | * @VF_ID: virtual function id | 607 | * @msix_index: MSIX table index supplied by the OS |
605 | * @reply: reply message frame(lower 32bit addr) | 608 | * @reply: reply message frame(lower 32bit addr) |
606 | * | 609 | * |
607 | * Return nothing. | 610 | * Return 1 meaning mf should be freed from _base_interrupt |
611 | * 0 means the mf is freed from this function. | ||
608 | */ | 612 | */ |
609 | static void | 613 | static u8 |
610 | _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply) | 614 | _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) |
611 | { | 615 | { |
612 | Mpi2EventNotificationReply_t *mpi_reply; | 616 | Mpi2EventNotificationReply_t *mpi_reply; |
613 | Mpi2EventAckRequest_t *ack_request; | 617 | Mpi2EventAckRequest_t *ack_request; |
@@ -615,9 +619,9 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply) | |||
615 | 619 | ||
616 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); | 620 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); |
617 | if (!mpi_reply) | 621 | if (!mpi_reply) |
618 | return; | 622 | return 1; |
619 | if (mpi_reply->Function != MPI2_FUNCTION_EVENT_NOTIFICATION) | 623 | if (mpi_reply->Function != MPI2_FUNCTION_EVENT_NOTIFICATION) |
620 | return; | 624 | return 1; |
621 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 625 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING |
622 | _base_display_event_data(ioc, mpi_reply); | 626 | _base_display_event_data(ioc, mpi_reply); |
623 | #endif | 627 | #endif |
@@ -635,16 +639,47 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply) | |||
635 | ack_request->Function = MPI2_FUNCTION_EVENT_ACK; | 639 | ack_request->Function = MPI2_FUNCTION_EVENT_ACK; |
636 | ack_request->Event = mpi_reply->Event; | 640 | ack_request->Event = mpi_reply->Event; |
637 | ack_request->EventContext = mpi_reply->EventContext; | 641 | ack_request->EventContext = mpi_reply->EventContext; |
638 | ack_request->VF_ID = VF_ID; | 642 | ack_request->VF_ID = 0; /* TODO */ |
639 | mpt2sas_base_put_smid_default(ioc, smid, VF_ID); | 643 | ack_request->VP_ID = 0; |
644 | mpt2sas_base_put_smid_default(ioc, smid); | ||
640 | 645 | ||
641 | out: | 646 | out: |
642 | 647 | ||
643 | /* scsih callback handler */ | 648 | /* scsih callback handler */ |
644 | mpt2sas_scsih_event_callback(ioc, VF_ID, reply); | 649 | mpt2sas_scsih_event_callback(ioc, msix_index, reply); |
645 | 650 | ||
646 | /* ctl callback handler */ | 651 | /* ctl callback handler */ |
647 | mpt2sas_ctl_event_callback(ioc, VF_ID, reply); | 652 | mpt2sas_ctl_event_callback(ioc, msix_index, reply); |
653 | |||
654 | return 1; | ||
655 | } | ||
656 | |||
657 | /** | ||
658 | * _base_get_cb_idx - obtain the callback index | ||
659 | * @ioc: per adapter object | ||
660 | * @smid: system request message index | ||
661 | * | ||
662 | * Return callback index. | ||
663 | */ | ||
664 | static u8 | ||
665 | _base_get_cb_idx(struct MPT2SAS_ADAPTER *ioc, u16 smid) | ||
666 | { | ||
667 | int i; | ||
668 | u8 cb_idx = 0xFF; | ||
669 | |||
670 | if (smid >= ioc->hi_priority_smid) { | ||
671 | if (smid < ioc->internal_smid) { | ||
672 | i = smid - ioc->hi_priority_smid; | ||
673 | cb_idx = ioc->hpr_lookup[i].cb_idx; | ||
674 | } else { | ||
675 | i = smid - ioc->internal_smid; | ||
676 | cb_idx = ioc->internal_lookup[i].cb_idx; | ||
677 | } | ||
678 | } else { | ||
679 | i = smid - 1; | ||
680 | cb_idx = ioc->scsi_lookup[i].cb_idx; | ||
681 | } | ||
682 | return cb_idx; | ||
648 | } | 683 | } |
649 | 684 | ||
650 | /** | 685 | /** |
@@ -680,7 +715,6 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) | |||
680 | { | 715 | { |
681 | u32 him_register; | 716 | u32 him_register; |
682 | 717 | ||
683 | writel(0, &ioc->chip->HostInterruptStatus); | ||
684 | him_register = readl(&ioc->chip->HostInterruptMask); | 718 | him_register = readl(&ioc->chip->HostInterruptMask); |
685 | him_register &= ~MPI2_HIM_RIM; | 719 | him_register &= ~MPI2_HIM_RIM; |
686 | writel(him_register, &ioc->chip->HostInterruptMask); | 720 | writel(him_register, &ioc->chip->HostInterruptMask); |
@@ -712,9 +746,10 @@ _base_interrupt(int irq, void *bus_id) | |||
712 | u16 smid; | 746 | u16 smid; |
713 | u8 cb_idx; | 747 | u8 cb_idx; |
714 | u32 reply; | 748 | u32 reply; |
715 | u8 VF_ID; | 749 | u8 msix_index; |
716 | struct MPT2SAS_ADAPTER *ioc = bus_id; | 750 | struct MPT2SAS_ADAPTER *ioc = bus_id; |
717 | Mpi2ReplyDescriptorsUnion_t *rpf; | 751 | Mpi2ReplyDescriptorsUnion_t *rpf; |
752 | u8 rc; | ||
718 | 753 | ||
719 | if (ioc->mask_interrupts) | 754 | if (ioc->mask_interrupts) |
720 | return IRQ_NONE; | 755 | return IRQ_NONE; |
@@ -733,7 +768,7 @@ _base_interrupt(int irq, void *bus_id) | |||
733 | reply = 0; | 768 | reply = 0; |
734 | cb_idx = 0xFF; | 769 | cb_idx = 0xFF; |
735 | smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1); | 770 | smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1); |
736 | VF_ID = rpf->Default.VF_ID; | 771 | msix_index = rpf->Default.MSIxIndex; |
737 | if (request_desript_type == | 772 | if (request_desript_type == |
738 | MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { | 773 | MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { |
739 | reply = le32_to_cpu | 774 | reply = le32_to_cpu |
@@ -745,16 +780,18 @@ _base_interrupt(int irq, void *bus_id) | |||
745 | MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS) | 780 | MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS) |
746 | goto next; | 781 | goto next; |
747 | if (smid) | 782 | if (smid) |
748 | cb_idx = ioc->scsi_lookup[smid - 1].cb_idx; | 783 | cb_idx = _base_get_cb_idx(ioc, smid); |
749 | if (smid && cb_idx != 0xFF) { | 784 | if (smid && cb_idx != 0xFF) { |
750 | mpt_callbacks[cb_idx](ioc, smid, VF_ID, reply); | 785 | rc = mpt_callbacks[cb_idx](ioc, smid, msix_index, |
786 | reply); | ||
751 | if (reply) | 787 | if (reply) |
752 | _base_display_reply_info(ioc, smid, VF_ID, | 788 | _base_display_reply_info(ioc, smid, msix_index, |
753 | reply); | 789 | reply); |
754 | mpt2sas_base_free_smid(ioc, smid); | 790 | if (rc) |
791 | mpt2sas_base_free_smid(ioc, smid); | ||
755 | } | 792 | } |
756 | if (!smid) | 793 | if (!smid) |
757 | _base_async_event(ioc, VF_ID, reply); | 794 | _base_async_event(ioc, msix_index, reply); |
758 | 795 | ||
759 | /* reply free queue handling */ | 796 | /* reply free queue handling */ |
760 | if (reply) { | 797 | if (reply) { |
@@ -1191,19 +1228,6 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) | |||
1191 | } | 1228 | } |
1192 | 1229 | ||
1193 | /** | 1230 | /** |
1194 | * mpt2sas_base_get_msg_frame_dma - obtain request mf pointer phys addr | ||
1195 | * @ioc: per adapter object | ||
1196 | * @smid: system request message index(smid zero is invalid) | ||
1197 | * | ||
1198 | * Returns phys pointer to message frame. | ||
1199 | */ | ||
1200 | dma_addr_t | ||
1201 | mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid) | ||
1202 | { | ||
1203 | return ioc->request_dma + (smid * ioc->request_sz); | ||
1204 | } | ||
1205 | |||
1206 | /** | ||
1207 | * mpt2sas_base_get_msg_frame - obtain request mf pointer | 1231 | * mpt2sas_base_get_msg_frame - obtain request mf pointer |
1208 | * @ioc: per adapter object | 1232 | * @ioc: per adapter object |
1209 | * @smid: system request message index(smid zero is invalid) | 1233 | * @smid: system request message index(smid zero is invalid) |
@@ -1258,7 +1282,7 @@ mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr) | |||
1258 | } | 1282 | } |
1259 | 1283 | ||
1260 | /** | 1284 | /** |
1261 | * mpt2sas_base_get_smid - obtain a free smid | 1285 | * mpt2sas_base_get_smid - obtain a free smid from internal queue |
1262 | * @ioc: per adapter object | 1286 | * @ioc: per adapter object |
1263 | * @cb_idx: callback index | 1287 | * @cb_idx: callback index |
1264 | * | 1288 | * |
@@ -1272,6 +1296,39 @@ mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) | |||
1272 | u16 smid; | 1296 | u16 smid; |
1273 | 1297 | ||
1274 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 1298 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
1299 | if (list_empty(&ioc->internal_free_list)) { | ||
1300 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1301 | printk(MPT2SAS_ERR_FMT "%s: smid not available\n", | ||
1302 | ioc->name, __func__); | ||
1303 | return 0; | ||
1304 | } | ||
1305 | |||
1306 | request = list_entry(ioc->internal_free_list.next, | ||
1307 | struct request_tracker, tracker_list); | ||
1308 | request->cb_idx = cb_idx; | ||
1309 | smid = request->smid; | ||
1310 | list_del(&request->tracker_list); | ||
1311 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1312 | return smid; | ||
1313 | } | ||
1314 | |||
1315 | /** | ||
1316 | * mpt2sas_base_get_smid_scsiio - obtain a free smid from scsiio queue | ||
1317 | * @ioc: per adapter object | ||
1318 | * @cb_idx: callback index | ||
1319 | * @scmd: pointer to scsi command object | ||
1320 | * | ||
1321 | * Returns smid (zero is invalid) | ||
1322 | */ | ||
1323 | u16 | ||
1324 | mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx, | ||
1325 | struct scsi_cmnd *scmd) | ||
1326 | { | ||
1327 | unsigned long flags; | ||
1328 | struct request_tracker *request; | ||
1329 | u16 smid; | ||
1330 | |||
1331 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
1275 | if (list_empty(&ioc->free_list)) { | 1332 | if (list_empty(&ioc->free_list)) { |
1276 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 1333 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
1277 | printk(MPT2SAS_ERR_FMT "%s: smid not available\n", | 1334 | printk(MPT2SAS_ERR_FMT "%s: smid not available\n", |
@@ -1281,6 +1338,36 @@ mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) | |||
1281 | 1338 | ||
1282 | request = list_entry(ioc->free_list.next, | 1339 | request = list_entry(ioc->free_list.next, |
1283 | struct request_tracker, tracker_list); | 1340 | struct request_tracker, tracker_list); |
1341 | request->scmd = scmd; | ||
1342 | request->cb_idx = cb_idx; | ||
1343 | smid = request->smid; | ||
1344 | list_del(&request->tracker_list); | ||
1345 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1346 | return smid; | ||
1347 | } | ||
1348 | |||
1349 | /** | ||
1350 | * mpt2sas_base_get_smid_hpr - obtain a free smid from hi-priority queue | ||
1351 | * @ioc: per adapter object | ||
1352 | * @cb_idx: callback index | ||
1353 | * | ||
1354 | * Returns smid (zero is invalid) | ||
1355 | */ | ||
1356 | u16 | ||
1357 | mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) | ||
1358 | { | ||
1359 | unsigned long flags; | ||
1360 | struct request_tracker *request; | ||
1361 | u16 smid; | ||
1362 | |||
1363 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
1364 | if (list_empty(&ioc->hpr_free_list)) { | ||
1365 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1366 | return 0; | ||
1367 | } | ||
1368 | |||
1369 | request = list_entry(ioc->hpr_free_list.next, | ||
1370 | struct request_tracker, tracker_list); | ||
1284 | request->cb_idx = cb_idx; | 1371 | request->cb_idx = cb_idx; |
1285 | smid = request->smid; | 1372 | smid = request->smid; |
1286 | list_del(&request->tracker_list); | 1373 | list_del(&request->tracker_list); |
@@ -1300,10 +1387,32 @@ void | |||
1300 | mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) | 1387 | mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) |
1301 | { | 1388 | { |
1302 | unsigned long flags; | 1389 | unsigned long flags; |
1390 | int i; | ||
1303 | 1391 | ||
1304 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 1392 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
1305 | ioc->scsi_lookup[smid - 1].cb_idx = 0xFF; | 1393 | if (smid >= ioc->hi_priority_smid) { |
1306 | list_add_tail(&ioc->scsi_lookup[smid - 1].tracker_list, | 1394 | if (smid < ioc->internal_smid) { |
1395 | /* hi-priority */ | ||
1396 | i = smid - ioc->hi_priority_smid; | ||
1397 | ioc->hpr_lookup[i].cb_idx = 0xFF; | ||
1398 | list_add_tail(&ioc->hpr_lookup[i].tracker_list, | ||
1399 | &ioc->hpr_free_list); | ||
1400 | } else { | ||
1401 | /* internal queue */ | ||
1402 | i = smid - ioc->internal_smid; | ||
1403 | ioc->internal_lookup[i].cb_idx = 0xFF; | ||
1404 | list_add_tail(&ioc->internal_lookup[i].tracker_list, | ||
1405 | &ioc->internal_free_list); | ||
1406 | } | ||
1407 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1408 | return; | ||
1409 | } | ||
1410 | |||
1411 | /* scsiio queue */ | ||
1412 | i = smid - 1; | ||
1413 | ioc->scsi_lookup[i].cb_idx = 0xFF; | ||
1414 | ioc->scsi_lookup[i].scmd = NULL; | ||
1415 | list_add_tail(&ioc->scsi_lookup[i].tracker_list, | ||
1307 | &ioc->free_list); | 1416 | &ioc->free_list); |
1308 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 1417 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
1309 | 1418 | ||
@@ -1352,21 +1461,19 @@ static inline void _base_writeq(__u64 b, volatile void __iomem *addr, | |||
1352 | * mpt2sas_base_put_smid_scsi_io - send SCSI_IO request to firmware | 1461 | * mpt2sas_base_put_smid_scsi_io - send SCSI_IO request to firmware |
1353 | * @ioc: per adapter object | 1462 | * @ioc: per adapter object |
1354 | * @smid: system request message index | 1463 | * @smid: system request message index |
1355 | * @vf_id: virtual function id | ||
1356 | * @handle: device handle | 1464 | * @handle: device handle |
1357 | * | 1465 | * |
1358 | * Return nothing. | 1466 | * Return nothing. |
1359 | */ | 1467 | */ |
1360 | void | 1468 | void |
1361 | mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id, | 1469 | mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u16 handle) |
1362 | u16 handle) | ||
1363 | { | 1470 | { |
1364 | Mpi2RequestDescriptorUnion_t descriptor; | 1471 | Mpi2RequestDescriptorUnion_t descriptor; |
1365 | u64 *request = (u64 *)&descriptor; | 1472 | u64 *request = (u64 *)&descriptor; |
1366 | 1473 | ||
1367 | 1474 | ||
1368 | descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO; | 1475 | descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO; |
1369 | descriptor.SCSIIO.VF_ID = vf_id; | 1476 | descriptor.SCSIIO.MSIxIndex = 0; /* TODO */ |
1370 | descriptor.SCSIIO.SMID = cpu_to_le16(smid); | 1477 | descriptor.SCSIIO.SMID = cpu_to_le16(smid); |
1371 | descriptor.SCSIIO.DevHandle = cpu_to_le16(handle); | 1478 | descriptor.SCSIIO.DevHandle = cpu_to_le16(handle); |
1372 | descriptor.SCSIIO.LMID = 0; | 1479 | descriptor.SCSIIO.LMID = 0; |
@@ -1379,20 +1486,18 @@ mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id, | |||
1379 | * mpt2sas_base_put_smid_hi_priority - send Task Managment request to firmware | 1486 | * mpt2sas_base_put_smid_hi_priority - send Task Managment request to firmware |
1380 | * @ioc: per adapter object | 1487 | * @ioc: per adapter object |
1381 | * @smid: system request message index | 1488 | * @smid: system request message index |
1382 | * @vf_id: virtual function id | ||
1383 | * | 1489 | * |
1384 | * Return nothing. | 1490 | * Return nothing. |
1385 | */ | 1491 | */ |
1386 | void | 1492 | void |
1387 | mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, | 1493 | mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid) |
1388 | u8 vf_id) | ||
1389 | { | 1494 | { |
1390 | Mpi2RequestDescriptorUnion_t descriptor; | 1495 | Mpi2RequestDescriptorUnion_t descriptor; |
1391 | u64 *request = (u64 *)&descriptor; | 1496 | u64 *request = (u64 *)&descriptor; |
1392 | 1497 | ||
1393 | descriptor.HighPriority.RequestFlags = | 1498 | descriptor.HighPriority.RequestFlags = |
1394 | MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; | 1499 | MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; |
1395 | descriptor.HighPriority.VF_ID = vf_id; | 1500 | descriptor.HighPriority.MSIxIndex = 0; /* TODO */ |
1396 | descriptor.HighPriority.SMID = cpu_to_le16(smid); | 1501 | descriptor.HighPriority.SMID = cpu_to_le16(smid); |
1397 | descriptor.HighPriority.LMID = 0; | 1502 | descriptor.HighPriority.LMID = 0; |
1398 | descriptor.HighPriority.Reserved1 = 0; | 1503 | descriptor.HighPriority.Reserved1 = 0; |
@@ -1404,18 +1509,17 @@ mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, | |||
1404 | * mpt2sas_base_put_smid_default - Default, primarily used for config pages | 1509 | * mpt2sas_base_put_smid_default - Default, primarily used for config pages |
1405 | * @ioc: per adapter object | 1510 | * @ioc: per adapter object |
1406 | * @smid: system request message index | 1511 | * @smid: system request message index |
1407 | * @vf_id: virtual function id | ||
1408 | * | 1512 | * |
1409 | * Return nothing. | 1513 | * Return nothing. |
1410 | */ | 1514 | */ |
1411 | void | 1515 | void |
1412 | mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id) | 1516 | mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid) |
1413 | { | 1517 | { |
1414 | Mpi2RequestDescriptorUnion_t descriptor; | 1518 | Mpi2RequestDescriptorUnion_t descriptor; |
1415 | u64 *request = (u64 *)&descriptor; | 1519 | u64 *request = (u64 *)&descriptor; |
1416 | 1520 | ||
1417 | descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; | 1521 | descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; |
1418 | descriptor.Default.VF_ID = vf_id; | 1522 | descriptor.Default.MSIxIndex = 0; /* TODO */ |
1419 | descriptor.Default.SMID = cpu_to_le16(smid); | 1523 | descriptor.Default.SMID = cpu_to_le16(smid); |
1420 | descriptor.Default.LMID = 0; | 1524 | descriptor.Default.LMID = 0; |
1421 | descriptor.Default.DescriptorTypeDependent = 0; | 1525 | descriptor.Default.DescriptorTypeDependent = 0; |
@@ -1427,21 +1531,20 @@ mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id) | |||
1427 | * mpt2sas_base_put_smid_target_assist - send Target Assist/Status to firmware | 1531 | * mpt2sas_base_put_smid_target_assist - send Target Assist/Status to firmware |
1428 | * @ioc: per adapter object | 1532 | * @ioc: per adapter object |
1429 | * @smid: system request message index | 1533 | * @smid: system request message index |
1430 | * @vf_id: virtual function id | ||
1431 | * @io_index: value used to track the IO | 1534 | * @io_index: value used to track the IO |
1432 | * | 1535 | * |
1433 | * Return nothing. | 1536 | * Return nothing. |
1434 | */ | 1537 | */ |
1435 | void | 1538 | void |
1436 | mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, | 1539 | mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, |
1437 | u8 vf_id, u16 io_index) | 1540 | u16 io_index) |
1438 | { | 1541 | { |
1439 | Mpi2RequestDescriptorUnion_t descriptor; | 1542 | Mpi2RequestDescriptorUnion_t descriptor; |
1440 | u64 *request = (u64 *)&descriptor; | 1543 | u64 *request = (u64 *)&descriptor; |
1441 | 1544 | ||
1442 | descriptor.SCSITarget.RequestFlags = | 1545 | descriptor.SCSITarget.RequestFlags = |
1443 | MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET; | 1546 | MPI2_REQ_DESCRIPT_FLAGS_SCSI_TARGET; |
1444 | descriptor.SCSITarget.VF_ID = vf_id; | 1547 | descriptor.SCSITarget.MSIxIndex = 0; /* TODO */ |
1445 | descriptor.SCSITarget.SMID = cpu_to_le16(smid); | 1548 | descriptor.SCSITarget.SMID = cpu_to_le16(smid); |
1446 | descriptor.SCSITarget.LMID = 0; | 1549 | descriptor.SCSITarget.LMID = 0; |
1447 | descriptor.SCSITarget.IoIndex = cpu_to_le16(io_index); | 1550 | descriptor.SCSITarget.IoIndex = cpu_to_le16(io_index); |
@@ -1717,6 +1820,8 @@ _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc) | |||
1717 | } | 1820 | } |
1718 | 1821 | ||
1719 | kfree(ioc->scsi_lookup); | 1822 | kfree(ioc->scsi_lookup); |
1823 | kfree(ioc->hpr_lookup); | ||
1824 | kfree(ioc->internal_lookup); | ||
1720 | } | 1825 | } |
1721 | 1826 | ||
1722 | 1827 | ||
@@ -1736,7 +1841,6 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1736 | u16 num_of_reply_frames; | 1841 | u16 num_of_reply_frames; |
1737 | u16 chains_needed_per_io; | 1842 | u16 chains_needed_per_io; |
1738 | u32 sz, total_sz; | 1843 | u32 sz, total_sz; |
1739 | u16 i; | ||
1740 | u32 retry_sz; | 1844 | u32 retry_sz; |
1741 | u16 max_request_credit; | 1845 | u16 max_request_credit; |
1742 | 1846 | ||
@@ -1764,7 +1868,10 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1764 | MPT2SAS_MAX_REQUEST_QUEUE) ? MPT2SAS_MAX_REQUEST_QUEUE : | 1868 | MPT2SAS_MAX_REQUEST_QUEUE) ? MPT2SAS_MAX_REQUEST_QUEUE : |
1765 | facts->RequestCredit; | 1869 | facts->RequestCredit; |
1766 | } | 1870 | } |
1767 | ioc->request_depth = max_request_credit; | 1871 | |
1872 | ioc->hba_queue_depth = max_request_credit; | ||
1873 | ioc->hi_priority_depth = facts->HighPriorityCredit; | ||
1874 | ioc->internal_depth = ioc->hi_priority_depth + 5; | ||
1768 | 1875 | ||
1769 | /* request frame size */ | 1876 | /* request frame size */ |
1770 | ioc->request_sz = facts->IOCRequestFrameSize * 4; | 1877 | ioc->request_sz = facts->IOCRequestFrameSize * 4; |
@@ -1802,7 +1909,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1802 | ioc->chains_needed_per_io = chains_needed_per_io; | 1909 | ioc->chains_needed_per_io = chains_needed_per_io; |
1803 | 1910 | ||
1804 | /* reply free queue sizing - taking into account for events */ | 1911 | /* reply free queue sizing - taking into account for events */ |
1805 | num_of_reply_frames = ioc->request_depth + 32; | 1912 | num_of_reply_frames = ioc->hba_queue_depth + 32; |
1806 | 1913 | ||
1807 | /* number of replies frames can't be a multiple of 16 */ | 1914 | /* number of replies frames can't be a multiple of 16 */ |
1808 | /* decrease number of reply frames by 1 */ | 1915 | /* decrease number of reply frames by 1 */ |
@@ -1823,7 +1930,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1823 | * frames | 1930 | * frames |
1824 | */ | 1931 | */ |
1825 | 1932 | ||
1826 | queue_size = ioc->request_depth + num_of_reply_frames + 1; | 1933 | queue_size = ioc->hba_queue_depth + num_of_reply_frames + 1; |
1827 | /* round up to 16 byte boundary */ | 1934 | /* round up to 16 byte boundary */ |
1828 | if (queue_size % 16) | 1935 | if (queue_size % 16) |
1829 | queue_size += 16 - (queue_size % 16); | 1936 | queue_size += 16 - (queue_size % 16); |
@@ -1837,60 +1944,85 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1837 | if (queue_diff % 16) | 1944 | if (queue_diff % 16) |
1838 | queue_diff += 16 - (queue_diff % 16); | 1945 | queue_diff += 16 - (queue_diff % 16); |
1839 | 1946 | ||
1840 | /* adjust request_depth, reply_free_queue_depth, | 1947 | /* adjust hba_queue_depth, reply_free_queue_depth, |
1841 | * and queue_size | 1948 | * and queue_size |
1842 | */ | 1949 | */ |
1843 | ioc->request_depth -= queue_diff; | 1950 | ioc->hba_queue_depth -= queue_diff; |
1844 | ioc->reply_free_queue_depth -= queue_diff; | 1951 | ioc->reply_free_queue_depth -= queue_diff; |
1845 | queue_size -= queue_diff; | 1952 | queue_size -= queue_diff; |
1846 | } | 1953 | } |
1847 | ioc->reply_post_queue_depth = queue_size; | 1954 | ioc->reply_post_queue_depth = queue_size; |
1848 | 1955 | ||
1849 | /* max scsi host queue depth */ | ||
1850 | ioc->shost->can_queue = ioc->request_depth - INTERNAL_CMDS_COUNT; | ||
1851 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host queue: depth" | ||
1852 | "(%d)\n", ioc->name, ioc->shost->can_queue)); | ||
1853 | |||
1854 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: " | 1956 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: " |
1855 | "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), " | 1957 | "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), " |
1856 | "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, | 1958 | "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, |
1857 | ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, | 1959 | ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, |
1858 | ioc->chains_needed_per_io)); | 1960 | ioc->chains_needed_per_io)); |
1859 | 1961 | ||
1962 | ioc->scsiio_depth = ioc->hba_queue_depth - | ||
1963 | ioc->hi_priority_depth - ioc->internal_depth; | ||
1964 | |||
1965 | /* set the scsi host can_queue depth | ||
1966 | * with some internal commands that could be outstanding | ||
1967 | */ | ||
1968 | ioc->shost->can_queue = ioc->scsiio_depth - (2); | ||
1969 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: " | ||
1970 | "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue)); | ||
1971 | |||
1860 | /* contiguous pool for request and chains, 16 byte align, one extra " | 1972 | /* contiguous pool for request and chains, 16 byte align, one extra " |
1861 | * "frame for smid=0 | 1973 | * "frame for smid=0 |
1862 | */ | 1974 | */ |
1863 | ioc->chain_depth = ioc->chains_needed_per_io * ioc->request_depth; | 1975 | ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth; |
1864 | sz = ((ioc->request_depth + 1 + ioc->chain_depth) * ioc->request_sz); | 1976 | sz = ((ioc->scsiio_depth + 1 + ioc->chain_depth) * ioc->request_sz); |
1977 | |||
1978 | /* hi-priority queue */ | ||
1979 | sz += (ioc->hi_priority_depth * ioc->request_sz); | ||
1980 | |||
1981 | /* internal queue */ | ||
1982 | sz += (ioc->internal_depth * ioc->request_sz); | ||
1865 | 1983 | ||
1866 | ioc->request_dma_sz = sz; | 1984 | ioc->request_dma_sz = sz; |
1867 | ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); | 1985 | ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); |
1868 | if (!ioc->request) { | 1986 | if (!ioc->request) { |
1869 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " | 1987 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " |
1870 | "failed: req_depth(%d), chains_per_io(%d), frame_sz(%d), " | 1988 | "failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), " |
1871 | "total(%d kB)\n", ioc->name, ioc->request_depth, | 1989 | "total(%d kB)\n", ioc->name, ioc->hba_queue_depth, |
1872 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); | 1990 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); |
1873 | if (ioc->request_depth < MPT2SAS_SAS_QUEUE_DEPTH) | 1991 | if (ioc->scsiio_depth < MPT2SAS_SAS_QUEUE_DEPTH) |
1874 | goto out; | 1992 | goto out; |
1875 | retry_sz += 64; | 1993 | retry_sz += 64; |
1876 | ioc->request_depth = max_request_credit - retry_sz; | 1994 | ioc->hba_queue_depth = max_request_credit - retry_sz; |
1877 | goto retry_allocation; | 1995 | goto retry_allocation; |
1878 | } | 1996 | } |
1879 | 1997 | ||
1880 | if (retry_sz) | 1998 | if (retry_sz) |
1881 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " | 1999 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " |
1882 | "succeed: req_depth(%d), chains_per_io(%d), frame_sz(%d), " | 2000 | "succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), " |
1883 | "total(%d kb)\n", ioc->name, ioc->request_depth, | 2001 | "total(%d kb)\n", ioc->name, ioc->hba_queue_depth, |
1884 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); | 2002 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); |
1885 | 2003 | ||
1886 | ioc->chain = ioc->request + ((ioc->request_depth + 1) * | 2004 | |
2005 | /* hi-priority queue */ | ||
2006 | ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) * | ||
2007 | ioc->request_sz); | ||
2008 | ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) * | ||
2009 | ioc->request_sz); | ||
2010 | |||
2011 | /* internal queue */ | ||
2012 | ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth * | ||
2013 | ioc->request_sz); | ||
2014 | ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth * | ||
2015 | ioc->request_sz); | ||
2016 | |||
2017 | ioc->chain = ioc->internal + (ioc->internal_depth * | ||
1887 | ioc->request_sz); | 2018 | ioc->request_sz); |
1888 | ioc->chain_dma = ioc->request_dma + ((ioc->request_depth + 1) * | 2019 | ioc->chain_dma = ioc->internal_dma + (ioc->internal_depth * |
1889 | ioc->request_sz); | 2020 | ioc->request_sz); |
2021 | |||
1890 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): " | 2022 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): " |
1891 | "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, | 2023 | "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, |
1892 | ioc->request, ioc->request_depth, ioc->request_sz, | 2024 | ioc->request, ioc->hba_queue_depth, ioc->request_sz, |
1893 | ((ioc->request_depth + 1) * ioc->request_sz)/1024)); | 2025 | (ioc->hba_queue_depth * ioc->request_sz)/1024)); |
1894 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth" | 2026 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth" |
1895 | "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain, | 2027 | "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain, |
1896 | ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth * | 2028 | ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth * |
@@ -1899,7 +2031,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1899 | ioc->name, (unsigned long long) ioc->request_dma)); | 2031 | ioc->name, (unsigned long long) ioc->request_dma)); |
1900 | total_sz += sz; | 2032 | total_sz += sz; |
1901 | 2033 | ||
1902 | ioc->scsi_lookup = kcalloc(ioc->request_depth, | 2034 | ioc->scsi_lookup = kcalloc(ioc->scsiio_depth, |
1903 | sizeof(struct request_tracker), GFP_KERNEL); | 2035 | sizeof(struct request_tracker), GFP_KERNEL); |
1904 | if (!ioc->scsi_lookup) { | 2036 | if (!ioc->scsi_lookup) { |
1905 | printk(MPT2SAS_ERR_FMT "scsi_lookup: kcalloc failed\n", | 2037 | printk(MPT2SAS_ERR_FMT "scsi_lookup: kcalloc failed\n", |
@@ -1907,12 +2039,38 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1907 | goto out; | 2039 | goto out; |
1908 | } | 2040 | } |
1909 | 2041 | ||
1910 | /* initialize some bits */ | 2042 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsiio(0x%p): " |
1911 | for (i = 0; i < ioc->request_depth; i++) | 2043 | "depth(%d)\n", ioc->name, ioc->request, |
1912 | ioc->scsi_lookup[i].smid = i + 1; | 2044 | ioc->scsiio_depth)); |
2045 | |||
2046 | /* initialize hi-priority queue smid's */ | ||
2047 | ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth, | ||
2048 | sizeof(struct request_tracker), GFP_KERNEL); | ||
2049 | if (!ioc->hpr_lookup) { | ||
2050 | printk(MPT2SAS_ERR_FMT "hpr_lookup: kcalloc failed\n", | ||
2051 | ioc->name); | ||
2052 | goto out; | ||
2053 | } | ||
2054 | ioc->hi_priority_smid = ioc->scsiio_depth + 1; | ||
2055 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hi_priority(0x%p): " | ||
2056 | "depth(%d), start smid(%d)\n", ioc->name, ioc->hi_priority, | ||
2057 | ioc->hi_priority_depth, ioc->hi_priority_smid)); | ||
2058 | |||
2059 | /* initialize internal queue smid's */ | ||
2060 | ioc->internal_lookup = kcalloc(ioc->internal_depth, | ||
2061 | sizeof(struct request_tracker), GFP_KERNEL); | ||
2062 | if (!ioc->internal_lookup) { | ||
2063 | printk(MPT2SAS_ERR_FMT "internal_lookup: kcalloc failed\n", | ||
2064 | ioc->name); | ||
2065 | goto out; | ||
2066 | } | ||
2067 | ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth; | ||
2068 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "internal(0x%p): " | ||
2069 | "depth(%d), start smid(%d)\n", ioc->name, ioc->internal, | ||
2070 | ioc->internal_depth, ioc->internal_smid)); | ||
1913 | 2071 | ||
1914 | /* sense buffers, 4 byte align */ | 2072 | /* sense buffers, 4 byte align */ |
1915 | sz = ioc->request_depth * SCSI_SENSE_BUFFERSIZE; | 2073 | sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE; |
1916 | ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, | 2074 | ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, |
1917 | 0); | 2075 | 0); |
1918 | if (!ioc->sense_dma_pool) { | 2076 | if (!ioc->sense_dma_pool) { |
@@ -1929,7 +2087,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1929 | } | 2087 | } |
1930 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT | 2088 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT |
1931 | "sense pool(0x%p): depth(%d), element_size(%d), pool_size" | 2089 | "sense pool(0x%p): depth(%d), element_size(%d), pool_size" |
1932 | "(%d kB)\n", ioc->name, ioc->sense, ioc->request_depth, | 2090 | "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth, |
1933 | SCSI_SENSE_BUFFERSIZE, sz/1024)); | 2091 | SCSI_SENSE_BUFFERSIZE, sz/1024)); |
1934 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n", | 2092 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n", |
1935 | ioc->name, (unsigned long long)ioc->sense_dma)); | 2093 | ioc->name, (unsigned long long)ioc->sense_dma)); |
@@ -2304,7 +2462,7 @@ _base_handshake_req_reply_wait(struct MPT2SAS_ADAPTER *ioc, int request_bytes, | |||
2304 | ((request_bytes/4)<<MPI2_DOORBELL_ADD_DWORDS_SHIFT)), | 2462 | ((request_bytes/4)<<MPI2_DOORBELL_ADD_DWORDS_SHIFT)), |
2305 | &ioc->chip->Doorbell); | 2463 | &ioc->chip->Doorbell); |
2306 | 2464 | ||
2307 | if ((_base_wait_for_doorbell_int(ioc, 5, sleep_flag))) { | 2465 | if ((_base_wait_for_doorbell_int(ioc, 5, NO_SLEEP))) { |
2308 | printk(MPT2SAS_ERR_FMT "doorbell handshake " | 2466 | printk(MPT2SAS_ERR_FMT "doorbell handshake " |
2309 | "int failed (line=%d)\n", ioc->name, __LINE__); | 2467 | "int failed (line=%d)\n", ioc->name, __LINE__); |
2310 | return -EFAULT; | 2468 | return -EFAULT; |
@@ -2454,7 +2612,8 @@ mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc, | |||
2454 | if (mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || | 2612 | if (mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || |
2455 | mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET) | 2613 | mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET) |
2456 | ioc->ioc_link_reset_in_progress = 1; | 2614 | ioc->ioc_link_reset_in_progress = 1; |
2457 | mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); | 2615 | mpt2sas_base_put_smid_default(ioc, smid); |
2616 | init_completion(&ioc->base_cmds.done); | ||
2458 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, | 2617 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, |
2459 | msecs_to_jiffies(10000)); | 2618 | msecs_to_jiffies(10000)); |
2460 | if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || | 2619 | if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET || |
@@ -2555,7 +2714,8 @@ mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc, | |||
2555 | request = mpt2sas_base_get_msg_frame(ioc, smid); | 2714 | request = mpt2sas_base_get_msg_frame(ioc, smid); |
2556 | ioc->base_cmds.smid = smid; | 2715 | ioc->base_cmds.smid = smid; |
2557 | memcpy(request, mpi_request, sizeof(Mpi2SepReply_t)); | 2716 | memcpy(request, mpi_request, sizeof(Mpi2SepReply_t)); |
2558 | mpt2sas_base_put_smid_default(ioc, smid, mpi_request->VF_ID); | 2717 | mpt2sas_base_put_smid_default(ioc, smid); |
2718 | init_completion(&ioc->base_cmds.done); | ||
2559 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, | 2719 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, |
2560 | msecs_to_jiffies(10000)); | 2720 | msecs_to_jiffies(10000)); |
2561 | if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { | 2721 | if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { |
@@ -2701,13 +2861,12 @@ _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
2701 | /** | 2861 | /** |
2702 | * _base_send_ioc_init - send ioc_init to firmware | 2862 | * _base_send_ioc_init - send ioc_init to firmware |
2703 | * @ioc: per adapter object | 2863 | * @ioc: per adapter object |
2704 | * @VF_ID: virtual function id | ||
2705 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | 2864 | * @sleep_flag: CAN_SLEEP or NO_SLEEP |
2706 | * | 2865 | * |
2707 | * Returns 0 for success, non-zero for failure. | 2866 | * Returns 0 for success, non-zero for failure. |
2708 | */ | 2867 | */ |
2709 | static int | 2868 | static int |
2710 | _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | 2869 | _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) |
2711 | { | 2870 | { |
2712 | Mpi2IOCInitRequest_t mpi_request; | 2871 | Mpi2IOCInitRequest_t mpi_request; |
2713 | Mpi2IOCInitReply_t mpi_reply; | 2872 | Mpi2IOCInitReply_t mpi_reply; |
@@ -2719,7 +2878,8 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | |||
2719 | memset(&mpi_request, 0, sizeof(Mpi2IOCInitRequest_t)); | 2878 | memset(&mpi_request, 0, sizeof(Mpi2IOCInitRequest_t)); |
2720 | mpi_request.Function = MPI2_FUNCTION_IOC_INIT; | 2879 | mpi_request.Function = MPI2_FUNCTION_IOC_INIT; |
2721 | mpi_request.WhoInit = MPI2_WHOINIT_HOST_DRIVER; | 2880 | mpi_request.WhoInit = MPI2_WHOINIT_HOST_DRIVER; |
2722 | mpi_request.VF_ID = VF_ID; | 2881 | mpi_request.VF_ID = 0; /* TODO */ |
2882 | mpi_request.VP_ID = 0; | ||
2723 | mpi_request.MsgVersion = cpu_to_le16(MPI2_VERSION); | 2883 | mpi_request.MsgVersion = cpu_to_le16(MPI2_VERSION); |
2724 | mpi_request.HeaderVersion = cpu_to_le16(MPI2_HEADER_VERSION); | 2884 | mpi_request.HeaderVersion = cpu_to_le16(MPI2_HEADER_VERSION); |
2725 | 2885 | ||
@@ -2795,13 +2955,12 @@ _base_send_ioc_init(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | |||
2795 | /** | 2955 | /** |
2796 | * _base_send_port_enable - send port_enable(discovery stuff) to firmware | 2956 | * _base_send_port_enable - send port_enable(discovery stuff) to firmware |
2797 | * @ioc: per adapter object | 2957 | * @ioc: per adapter object |
2798 | * @VF_ID: virtual function id | ||
2799 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | 2958 | * @sleep_flag: CAN_SLEEP or NO_SLEEP |
2800 | * | 2959 | * |
2801 | * Returns 0 for success, non-zero for failure. | 2960 | * Returns 0 for success, non-zero for failure. |
2802 | */ | 2961 | */ |
2803 | static int | 2962 | static int |
2804 | _base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | 2963 | _base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) |
2805 | { | 2964 | { |
2806 | Mpi2PortEnableRequest_t *mpi_request; | 2965 | Mpi2PortEnableRequest_t *mpi_request; |
2807 | u32 ioc_state; | 2966 | u32 ioc_state; |
@@ -2829,9 +2988,11 @@ _base_send_port_enable(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | |||
2829 | ioc->base_cmds.smid = smid; | 2988 | ioc->base_cmds.smid = smid; |
2830 | memset(mpi_request, 0, sizeof(Mpi2PortEnableRequest_t)); | 2989 | memset(mpi_request, 0, sizeof(Mpi2PortEnableRequest_t)); |
2831 | mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE; | 2990 | mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE; |
2832 | mpi_request->VF_ID = VF_ID; | 2991 | mpi_request->VF_ID = 0; /* TODO */ |
2992 | mpi_request->VP_ID = 0; | ||
2833 | 2993 | ||
2834 | mpt2sas_base_put_smid_default(ioc, smid, VF_ID); | 2994 | mpt2sas_base_put_smid_default(ioc, smid); |
2995 | init_completion(&ioc->base_cmds.done); | ||
2835 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, | 2996 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, |
2836 | 300*HZ); | 2997 | 300*HZ); |
2837 | if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { | 2998 | if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { |
@@ -2892,13 +3053,12 @@ _base_unmask_events(struct MPT2SAS_ADAPTER *ioc, u16 event) | |||
2892 | /** | 3053 | /** |
2893 | * _base_event_notification - send event notification | 3054 | * _base_event_notification - send event notification |
2894 | * @ioc: per adapter object | 3055 | * @ioc: per adapter object |
2895 | * @VF_ID: virtual function id | ||
2896 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | 3056 | * @sleep_flag: CAN_SLEEP or NO_SLEEP |
2897 | * | 3057 | * |
2898 | * Returns 0 for success, non-zero for failure. | 3058 | * Returns 0 for success, non-zero for failure. |
2899 | */ | 3059 | */ |
2900 | static int | 3060 | static int |
2901 | _base_event_notification(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | 3061 | _base_event_notification(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) |
2902 | { | 3062 | { |
2903 | Mpi2EventNotificationRequest_t *mpi_request; | 3063 | Mpi2EventNotificationRequest_t *mpi_request; |
2904 | unsigned long timeleft; | 3064 | unsigned long timeleft; |
@@ -2926,11 +3086,13 @@ _base_event_notification(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, int sleep_flag) | |||
2926 | ioc->base_cmds.smid = smid; | 3086 | ioc->base_cmds.smid = smid; |
2927 | memset(mpi_request, 0, sizeof(Mpi2EventNotificationRequest_t)); | 3087 | memset(mpi_request, 0, sizeof(Mpi2EventNotificationRequest_t)); |
2928 | mpi_request->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; | 3088 | mpi_request->Function = MPI2_FUNCTION_EVENT_NOTIFICATION; |
2929 | mpi_request->VF_ID = VF_ID; | 3089 | mpi_request->VF_ID = 0; /* TODO */ |
3090 | mpi_request->VP_ID = 0; | ||
2930 | for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) | 3091 | for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) |
2931 | mpi_request->EventMasks[i] = | 3092 | mpi_request->EventMasks[i] = |
2932 | le32_to_cpu(ioc->event_masks[i]); | 3093 | le32_to_cpu(ioc->event_masks[i]); |
2933 | mpt2sas_base_put_smid_default(ioc, smid, VF_ID); | 3094 | mpt2sas_base_put_smid_default(ioc, smid); |
3095 | init_completion(&ioc->base_cmds.done); | ||
2934 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); | 3096 | timeleft = wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ); |
2935 | if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { | 3097 | if (!(ioc->base_cmds.status & MPT2_CMD_COMPLETE)) { |
2936 | printk(MPT2SAS_ERR_FMT "%s: timeout\n", | 3098 | printk(MPT2SAS_ERR_FMT "%s: timeout\n", |
@@ -2981,7 +3143,7 @@ mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type) | |||
2981 | return; | 3143 | return; |
2982 | 3144 | ||
2983 | mutex_lock(&ioc->base_cmds.mutex); | 3145 | mutex_lock(&ioc->base_cmds.mutex); |
2984 | _base_event_notification(ioc, 0, CAN_SLEEP); | 3146 | _base_event_notification(ioc, CAN_SLEEP); |
2985 | mutex_unlock(&ioc->base_cmds.mutex); | 3147 | mutex_unlock(&ioc->base_cmds.mutex); |
2986 | } | 3148 | } |
2987 | 3149 | ||
@@ -3006,7 +3168,6 @@ _base_diag_reset(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
3006 | 3168 | ||
3007 | drsprintk(ioc, printk(MPT2SAS_DEBUG_FMT "clear interrupts\n", | 3169 | drsprintk(ioc, printk(MPT2SAS_DEBUG_FMT "clear interrupts\n", |
3008 | ioc->name)); | 3170 | ioc->name)); |
3009 | writel(0, &ioc->chip->HostInterruptStatus); | ||
3010 | 3171 | ||
3011 | count = 0; | 3172 | count = 0; |
3012 | do { | 3173 | do { |
@@ -3160,30 +3321,60 @@ _base_make_ioc_ready(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, | |||
3160 | /** | 3321 | /** |
3161 | * _base_make_ioc_operational - put controller in OPERATIONAL state | 3322 | * _base_make_ioc_operational - put controller in OPERATIONAL state |
3162 | * @ioc: per adapter object | 3323 | * @ioc: per adapter object |
3163 | * @VF_ID: virtual function id | ||
3164 | * @sleep_flag: CAN_SLEEP or NO_SLEEP | 3324 | * @sleep_flag: CAN_SLEEP or NO_SLEEP |
3165 | * | 3325 | * |
3166 | * Returns 0 for success, non-zero for failure. | 3326 | * Returns 0 for success, non-zero for failure. |
3167 | */ | 3327 | */ |
3168 | static int | 3328 | static int |
3169 | _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, | 3329 | _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) |
3170 | int sleep_flag) | ||
3171 | { | 3330 | { |
3172 | int r, i; | 3331 | int r, i; |
3173 | unsigned long flags; | 3332 | unsigned long flags; |
3174 | u32 reply_address; | 3333 | u32 reply_address; |
3334 | u16 smid; | ||
3335 | struct _tr_list *delayed_tr, *delayed_tr_next; | ||
3175 | 3336 | ||
3176 | dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, | 3337 | dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, |
3177 | __func__)); | 3338 | __func__)); |
3178 | 3339 | ||
3340 | /* clean the delayed target reset list */ | ||
3341 | list_for_each_entry_safe(delayed_tr, delayed_tr_next, | ||
3342 | &ioc->delayed_tr_list, list) { | ||
3343 | list_del(&delayed_tr->list); | ||
3344 | kfree(delayed_tr); | ||
3345 | } | ||
3346 | |||
3179 | /* initialize the scsi lookup free list */ | 3347 | /* initialize the scsi lookup free list */ |
3180 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 3348 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
3181 | INIT_LIST_HEAD(&ioc->free_list); | 3349 | INIT_LIST_HEAD(&ioc->free_list); |
3182 | for (i = 0; i < ioc->request_depth; i++) { | 3350 | smid = 1; |
3351 | for (i = 0; i < ioc->scsiio_depth; i++, smid++) { | ||
3183 | ioc->scsi_lookup[i].cb_idx = 0xFF; | 3352 | ioc->scsi_lookup[i].cb_idx = 0xFF; |
3353 | ioc->scsi_lookup[i].smid = smid; | ||
3354 | ioc->scsi_lookup[i].scmd = NULL; | ||
3184 | list_add_tail(&ioc->scsi_lookup[i].tracker_list, | 3355 | list_add_tail(&ioc->scsi_lookup[i].tracker_list, |
3185 | &ioc->free_list); | 3356 | &ioc->free_list); |
3186 | } | 3357 | } |
3358 | |||
3359 | /* hi-priority queue */ | ||
3360 | INIT_LIST_HEAD(&ioc->hpr_free_list); | ||
3361 | smid = ioc->hi_priority_smid; | ||
3362 | for (i = 0; i < ioc->hi_priority_depth; i++, smid++) { | ||
3363 | ioc->hpr_lookup[i].cb_idx = 0xFF; | ||
3364 | ioc->hpr_lookup[i].smid = smid; | ||
3365 | list_add_tail(&ioc->hpr_lookup[i].tracker_list, | ||
3366 | &ioc->hpr_free_list); | ||
3367 | } | ||
3368 | |||
3369 | /* internal queue */ | ||
3370 | INIT_LIST_HEAD(&ioc->internal_free_list); | ||
3371 | smid = ioc->internal_smid; | ||
3372 | for (i = 0; i < ioc->internal_depth; i++, smid++) { | ||
3373 | ioc->internal_lookup[i].cb_idx = 0xFF; | ||
3374 | ioc->internal_lookup[i].smid = smid; | ||
3375 | list_add_tail(&ioc->internal_lookup[i].tracker_list, | ||
3376 | &ioc->internal_free_list); | ||
3377 | } | ||
3187 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 3378 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
3188 | 3379 | ||
3189 | /* initialize Reply Free Queue */ | 3380 | /* initialize Reply Free Queue */ |
@@ -3196,7 +3387,7 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, | |||
3196 | for (i = 0; i < ioc->reply_post_queue_depth; i++) | 3387 | for (i = 0; i < ioc->reply_post_queue_depth; i++) |
3197 | ioc->reply_post_free[i].Words = ULLONG_MAX; | 3388 | ioc->reply_post_free[i].Words = ULLONG_MAX; |
3198 | 3389 | ||
3199 | r = _base_send_ioc_init(ioc, VF_ID, sleep_flag); | 3390 | r = _base_send_ioc_init(ioc, sleep_flag); |
3200 | if (r) | 3391 | if (r) |
3201 | return r; | 3392 | return r; |
3202 | 3393 | ||
@@ -3207,14 +3398,14 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, | |||
3207 | writel(0, &ioc->chip->ReplyPostHostIndex); | 3398 | writel(0, &ioc->chip->ReplyPostHostIndex); |
3208 | 3399 | ||
3209 | _base_unmask_interrupts(ioc); | 3400 | _base_unmask_interrupts(ioc); |
3210 | r = _base_event_notification(ioc, VF_ID, sleep_flag); | 3401 | r = _base_event_notification(ioc, sleep_flag); |
3211 | if (r) | 3402 | if (r) |
3212 | return r; | 3403 | return r; |
3213 | 3404 | ||
3214 | if (sleep_flag == CAN_SLEEP) | 3405 | if (sleep_flag == CAN_SLEEP) |
3215 | _base_static_config_pages(ioc); | 3406 | _base_static_config_pages(ioc); |
3216 | 3407 | ||
3217 | r = _base_send_port_enable(ioc, VF_ID, sleep_flag); | 3408 | r = _base_send_port_enable(ioc, sleep_flag); |
3218 | if (r) | 3409 | if (r) |
3219 | return r; | 3410 | return r; |
3220 | 3411 | ||
@@ -3278,6 +3469,17 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3278 | if (r) | 3469 | if (r) |
3279 | goto out_free_resources; | 3470 | goto out_free_resources; |
3280 | 3471 | ||
3472 | ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, | ||
3473 | sizeof(Mpi2PortFactsReply_t), GFP_KERNEL); | ||
3474 | if (!ioc->pfacts) | ||
3475 | goto out_free_resources; | ||
3476 | |||
3477 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { | ||
3478 | r = _base_get_port_facts(ioc, i, CAN_SLEEP); | ||
3479 | if (r) | ||
3480 | goto out_free_resources; | ||
3481 | } | ||
3482 | |||
3281 | r = _base_allocate_memory_pools(ioc, CAN_SLEEP); | 3483 | r = _base_allocate_memory_pools(ioc, CAN_SLEEP); |
3282 | if (r) | 3484 | if (r) |
3283 | goto out_free_resources; | 3485 | goto out_free_resources; |
@@ -3286,7 +3488,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3286 | 3488 | ||
3287 | /* base internal command bits */ | 3489 | /* base internal command bits */ |
3288 | mutex_init(&ioc->base_cmds.mutex); | 3490 | mutex_init(&ioc->base_cmds.mutex); |
3289 | init_completion(&ioc->base_cmds.done); | ||
3290 | ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3491 | ioc->base_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3291 | ioc->base_cmds.status = MPT2_CMD_NOT_USED; | 3492 | ioc->base_cmds.status = MPT2_CMD_NOT_USED; |
3292 | 3493 | ||
@@ -3294,7 +3495,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3294 | ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3495 | ioc->transport_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3295 | ioc->transport_cmds.status = MPT2_CMD_NOT_USED; | 3496 | ioc->transport_cmds.status = MPT2_CMD_NOT_USED; |
3296 | mutex_init(&ioc->transport_cmds.mutex); | 3497 | mutex_init(&ioc->transport_cmds.mutex); |
3297 | init_completion(&ioc->transport_cmds.done); | ||
3298 | 3498 | ||
3299 | /* task management internal command bits */ | 3499 | /* task management internal command bits */ |
3300 | ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3500 | ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
@@ -3310,7 +3510,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3310 | ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3510 | ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3311 | ioc->ctl_cmds.status = MPT2_CMD_NOT_USED; | 3511 | ioc->ctl_cmds.status = MPT2_CMD_NOT_USED; |
3312 | mutex_init(&ioc->ctl_cmds.mutex); | 3512 | mutex_init(&ioc->ctl_cmds.mutex); |
3313 | init_completion(&ioc->ctl_cmds.done); | ||
3314 | 3513 | ||
3315 | for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) | 3514 | for (i = 0; i < MPI2_EVENT_NOTIFY_EVENTMASK_WORDS; i++) |
3316 | ioc->event_masks[i] = -1; | 3515 | ioc->event_masks[i] = -1; |
@@ -3327,18 +3526,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3327 | _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); | 3526 | _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); |
3328 | _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL); | 3527 | _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL); |
3329 | _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); | 3528 | _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); |
3330 | 3529 | r = _base_make_ioc_operational(ioc, CAN_SLEEP); | |
3331 | ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, | ||
3332 | sizeof(Mpi2PortFactsReply_t), GFP_KERNEL); | ||
3333 | if (!ioc->pfacts) | ||
3334 | goto out_free_resources; | ||
3335 | |||
3336 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { | ||
3337 | r = _base_get_port_facts(ioc, i, CAN_SLEEP); | ||
3338 | if (r) | ||
3339 | goto out_free_resources; | ||
3340 | } | ||
3341 | r = _base_make_ioc_operational(ioc, 0, CAN_SLEEP); | ||
3342 | if (r) | 3530 | if (r) |
3343 | goto out_free_resources; | 3531 | goto out_free_resources; |
3344 | 3532 | ||
@@ -3466,7 +3654,7 @@ _wait_for_commands_to_complete(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
3466 | 3654 | ||
3467 | /* pending command count */ | 3655 | /* pending command count */ |
3468 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 3656 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
3469 | for (i = 0; i < ioc->request_depth; i++) | 3657 | for (i = 0; i < ioc->scsiio_depth; i++) |
3470 | if (ioc->scsi_lookup[i].cb_idx != 0xFF) | 3658 | if (ioc->scsi_lookup[i].cb_idx != 0xFF) |
3471 | ioc->pending_io_count++; | 3659 | ioc->pending_io_count++; |
3472 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 3660 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
@@ -3490,7 +3678,7 @@ int | |||
3490 | mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, | 3678 | mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, |
3491 | enum reset_type type) | 3679 | enum reset_type type) |
3492 | { | 3680 | { |
3493 | int r, i; | 3681 | int r; |
3494 | unsigned long flags; | 3682 | unsigned long flags; |
3495 | 3683 | ||
3496 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name, | 3684 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: enter\n", ioc->name, |
@@ -3513,9 +3701,7 @@ mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag, | |||
3513 | if (r) | 3701 | if (r) |
3514 | goto out; | 3702 | goto out; |
3515 | _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET); | 3703 | _base_reset_handler(ioc, MPT2_IOC_AFTER_RESET); |
3516 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) | 3704 | r = _base_make_ioc_operational(ioc, sleep_flag); |
3517 | r = _base_make_ioc_operational(ioc, ioc->pfacts[i].VF_ID, | ||
3518 | sleep_flag); | ||
3519 | if (!r) | 3705 | if (!r) |
3520 | _base_reset_handler(ioc, MPT2_IOC_DONE_RESET); | 3706 | _base_reset_handler(ioc, MPT2_IOC_DONE_RESET); |
3521 | out: | 3707 | out: |