diff options
author | Kashyap, Desai <kashyap.desai@lsi.com> | 2009-08-20 03:54:31 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-09-05 10:36:30 -0400 |
commit | 5b768581ea722172f059ad5a5eebea9008961af0 (patch) | |
tree | 1bd620747bcbcf6abae9e8f8e46ce0beb6029bfc /drivers/scsi/mpt2sas/mpt2sas_base.c | |
parent | ed79f1280d1bc54f168abcffc8c3e0bf8ffb1873 (diff) |
[SCSI] mpt2sas: cleanup interrupt routine and config_request optimization
Cleaned up base_interrupt routine to be more effiecent.
Deleted about a third of the config page API by moving redundant code from all
the calling functions to _config_request.
Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.c')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.c | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 2e4bc3d2b435..d95d2f274cb3 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -687,6 +687,14 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) | |||
687 | ioc->mask_interrupts = 0; | 687 | ioc->mask_interrupts = 0; |
688 | } | 688 | } |
689 | 689 | ||
690 | union reply_descriptor { | ||
691 | u64 word; | ||
692 | struct { | ||
693 | u32 low; | ||
694 | u32 high; | ||
695 | } u; | ||
696 | }; | ||
697 | |||
690 | /** | 698 | /** |
691 | * _base_interrupt - MPT adapter (IOC) specific interrupt handler. | 699 | * _base_interrupt - MPT adapter (IOC) specific interrupt handler. |
692 | * @irq: irq number (not used) | 700 | * @irq: irq number (not used) |
@@ -698,47 +706,38 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) | |||
698 | static irqreturn_t | 706 | static irqreturn_t |
699 | _base_interrupt(int irq, void *bus_id) | 707 | _base_interrupt(int irq, void *bus_id) |
700 | { | 708 | { |
701 | union reply_descriptor { | ||
702 | u64 word; | ||
703 | struct { | ||
704 | u32 low; | ||
705 | u32 high; | ||
706 | } u; | ||
707 | }; | ||
708 | union reply_descriptor rd; | 709 | union reply_descriptor rd; |
709 | u32 post_index, post_index_next, completed_cmds; | 710 | u32 completed_cmds; |
710 | u8 request_desript_type; | 711 | u8 request_desript_type; |
711 | u16 smid; | 712 | u16 smid; |
712 | u8 cb_idx; | 713 | u8 cb_idx; |
713 | u32 reply; | 714 | u32 reply; |
714 | u8 VF_ID; | 715 | u8 VF_ID; |
715 | int i; | ||
716 | struct MPT2SAS_ADAPTER *ioc = bus_id; | 716 | struct MPT2SAS_ADAPTER *ioc = bus_id; |
717 | Mpi2ReplyDescriptorsUnion_t *rpf; | ||
717 | 718 | ||
718 | if (ioc->mask_interrupts) | 719 | if (ioc->mask_interrupts) |
719 | return IRQ_NONE; | 720 | return IRQ_NONE; |
720 | 721 | ||
721 | post_index = ioc->reply_post_host_index; | 722 | rpf = &ioc->reply_post_free[ioc->reply_post_host_index]; |
722 | request_desript_type = ioc->reply_post_free[post_index]. | 723 | request_desript_type = rpf->Default.ReplyFlags |
723 | Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; | 724 | & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; |
724 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) | 725 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) |
725 | return IRQ_NONE; | 726 | return IRQ_NONE; |
726 | 727 | ||
727 | completed_cmds = 0; | 728 | completed_cmds = 0; |
728 | do { | 729 | do { |
729 | rd.word = ioc->reply_post_free[post_index].Words; | 730 | rd.word = rpf->Words; |
730 | if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX) | 731 | if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX) |
731 | goto out; | 732 | goto out; |
732 | reply = 0; | 733 | reply = 0; |
733 | cb_idx = 0xFF; | 734 | cb_idx = 0xFF; |
734 | smid = le16_to_cpu(ioc->reply_post_free[post_index]. | 735 | smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1); |
735 | Default.DescriptorTypeDependent1); | 736 | VF_ID = rpf->Default.VF_ID; |
736 | VF_ID = ioc->reply_post_free[post_index]. | ||
737 | Default.VF_ID; | ||
738 | if (request_desript_type == | 737 | if (request_desript_type == |
739 | MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { | 738 | MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) { |
740 | reply = le32_to_cpu(ioc->reply_post_free[post_index]. | 739 | reply = le32_to_cpu |
741 | AddressReply.ReplyFrameAddress); | 740 | (rpf->AddressReply.ReplyFrameAddress); |
742 | } else if (request_desript_type == | 741 | } else if (request_desript_type == |
743 | MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER) | 742 | MPI2_RPY_DESCRIPT_FLAGS_TARGET_COMMAND_BUFFER) |
744 | goto next; | 743 | goto next; |
@@ -765,21 +764,27 @@ _base_interrupt(int irq, void *bus_id) | |||
765 | 0 : ioc->reply_free_host_index + 1; | 764 | 0 : ioc->reply_free_host_index + 1; |
766 | ioc->reply_free[ioc->reply_free_host_index] = | 765 | ioc->reply_free[ioc->reply_free_host_index] = |
767 | cpu_to_le32(reply); | 766 | cpu_to_le32(reply); |
767 | wmb(); | ||
768 | writel(ioc->reply_free_host_index, | 768 | writel(ioc->reply_free_host_index, |
769 | &ioc->chip->ReplyFreeHostIndex); | 769 | &ioc->chip->ReplyFreeHostIndex); |
770 | wmb(); | ||
771 | } | 770 | } |
772 | 771 | ||
773 | next: | 772 | next: |
774 | post_index_next = (post_index == (ioc->reply_post_queue_depth - | 773 | |
775 | 1)) ? 0 : post_index + 1; | 774 | rpf->Words = ULLONG_MAX; |
775 | ioc->reply_post_host_index = (ioc->reply_post_host_index == | ||
776 | (ioc->reply_post_queue_depth - 1)) ? 0 : | ||
777 | ioc->reply_post_host_index + 1; | ||
776 | request_desript_type = | 778 | request_desript_type = |
777 | ioc->reply_post_free[post_index_next].Default.ReplyFlags | 779 | ioc->reply_post_free[ioc->reply_post_host_index].Default. |
778 | & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; | 780 | ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; |
779 | completed_cmds++; | 781 | completed_cmds++; |
780 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) | 782 | if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) |
781 | goto out; | 783 | goto out; |
782 | post_index = post_index_next; | 784 | if (!ioc->reply_post_host_index) |
785 | rpf = ioc->reply_post_free; | ||
786 | else | ||
787 | rpf++; | ||
783 | } while (1); | 788 | } while (1); |
784 | 789 | ||
785 | out: | 790 | out: |
@@ -787,19 +792,8 @@ _base_interrupt(int irq, void *bus_id) | |||
787 | if (!completed_cmds) | 792 | if (!completed_cmds) |
788 | return IRQ_NONE; | 793 | return IRQ_NONE; |
789 | 794 | ||
790 | /* reply post descriptor handling */ | ||
791 | post_index_next = ioc->reply_post_host_index; | ||
792 | for (i = 0 ; i < completed_cmds; i++) { | ||
793 | post_index = post_index_next; | ||
794 | /* poison the reply post descriptor */ | ||
795 | ioc->reply_post_free[post_index_next].Words = ULLONG_MAX; | ||
796 | post_index_next = (post_index == | ||
797 | (ioc->reply_post_queue_depth - 1)) | ||
798 | ? 0 : post_index + 1; | ||
799 | } | ||
800 | ioc->reply_post_host_index = post_index_next; | ||
801 | writel(post_index_next, &ioc->chip->ReplyPostHostIndex); | ||
802 | wmb(); | 795 | wmb(); |
796 | writel(ioc->reply_post_host_index, &ioc->chip->ReplyPostHostIndex); | ||
803 | return IRQ_HANDLED; | 797 | return IRQ_HANDLED; |
804 | } | 798 | } |
805 | 799 | ||
@@ -1650,7 +1644,7 @@ _base_static_config_pages(struct MPT2SAS_ADAPTER *ioc) | |||
1650 | iounit_pg1_flags |= | 1644 | iounit_pg1_flags |= |
1651 | MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING; | 1645 | MPI2_IOUNITPAGE1_DISABLE_TASK_SET_FULL_HANDLING; |
1652 | ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); | 1646 | ioc->iounit_pg1.Flags = cpu_to_le32(iounit_pg1_flags); |
1653 | mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, ioc->iounit_pg1); | 1647 | mpt2sas_config_set_iounit_pg1(ioc, &mpi_reply, &ioc->iounit_pg1); |
1654 | } | 1648 | } |
1655 | 1649 | ||
1656 | /** | 1650 | /** |
@@ -3306,13 +3300,11 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3306 | ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3300 | ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3307 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; | 3301 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; |
3308 | mutex_init(&ioc->tm_cmds.mutex); | 3302 | mutex_init(&ioc->tm_cmds.mutex); |
3309 | init_completion(&ioc->tm_cmds.done); | ||
3310 | 3303 | ||
3311 | /* config page internal command bits */ | 3304 | /* config page internal command bits */ |
3312 | ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3305 | ioc->config_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
3313 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; | 3306 | ioc->config_cmds.status = MPT2_CMD_NOT_USED; |
3314 | mutex_init(&ioc->config_cmds.mutex); | 3307 | mutex_init(&ioc->config_cmds.mutex); |
3315 | init_completion(&ioc->config_cmds.done); | ||
3316 | 3308 | ||
3317 | /* ctl module internal command bits */ | 3309 | /* ctl module internal command bits */ |
3318 | ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); | 3310 | ioc->ctl_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL); |
@@ -3436,6 +3428,7 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) | |||
3436 | if (ioc->config_cmds.status & MPT2_CMD_PENDING) { | 3428 | if (ioc->config_cmds.status & MPT2_CMD_PENDING) { |
3437 | ioc->config_cmds.status |= MPT2_CMD_RESET; | 3429 | ioc->config_cmds.status |= MPT2_CMD_RESET; |
3438 | mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); | 3430 | mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid); |
3431 | ioc->config_cmds.smid = USHORT_MAX; | ||
3439 | complete(&ioc->config_cmds.done); | 3432 | complete(&ioc->config_cmds.done); |
3440 | } | 3433 | } |
3441 | break; | 3434 | break; |