aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/megaraid
diff options
context:
space:
mode:
authorSumant Patro <sumantp@lsil.com>2006-05-30 15:03:37 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-06-06 10:57:18 -0400
commite4a082c7c1f9a7b11fece6918e7ee5519b39ac46 (patch)
tree8aa1d865b2ddfb9b897e30e97dede3268c00b582 /drivers/scsi/megaraid
parentf70e9c5f91f1d2d9ce79dc45221540e25b4e4ac0 (diff)
[SCSI] megaraid_sas: switch fw_outstanding to an atomic_t
This patch( originally submitted by Christoph Hellwig) removes instance_lock and changes fw_outstanding variable data type to atomic_t. Signed-off-by: Sumant Patro <Sumant.Patro@lsil.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/megaraid')
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c26
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.h3
2 files changed, 11 insertions, 18 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 39729460b00e..0c9516ff636f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -741,7 +741,6 @@ static int
741megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *)) 741megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
742{ 742{
743 u32 frame_count; 743 u32 frame_count;
744 unsigned long flags;
745 struct megasas_cmd *cmd; 744 struct megasas_cmd *cmd;
746 struct megasas_instance *instance; 745 struct megasas_instance *instance;
747 746
@@ -776,9 +775,7 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *))
776 /* 775 /*
777 * Issue the command to the FW 776 * Issue the command to the FW
778 */ 777 */
779 spin_lock_irqsave(&instance->instance_lock, flags); 778 atomic_inc(&instance->fw_outstanding);
780 instance->fw_outstanding++;
781 spin_unlock_irqrestore(&instance->instance_lock, flags);
782 779
783 instance->instancet->fire_cmd(cmd->frame_phys_addr ,cmd->frame_count-1,instance->reg_set); 780 instance->instancet->fire_cmd(cmd->frame_phys_addr ,cmd->frame_count-1,instance->reg_set);
784 781
@@ -826,19 +823,20 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
826 823
827 for (i = 0; i < wait_time; i++) { 824 for (i = 0; i < wait_time; i++) {
828 825
829 if (!instance->fw_outstanding) 826 int outstanding = atomic_read(&instance->fw_outstanding);
827
828 if (!outstanding)
830 break; 829 break;
831 830
832 if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) { 831 if (!(i % MEGASAS_RESET_NOTICE_INTERVAL)) {
833 printk(KERN_NOTICE "megasas: [%2d]waiting for %d " 832 printk(KERN_NOTICE "megasas: [%2d]waiting for %d "
834 "commands to complete\n", i, 833 "commands to complete\n",i,outstanding);
835 instance->fw_outstanding);
836 } 834 }
837 835
838 msleep(1000); 836 msleep(1000);
839 } 837 }
840 838
841 if (instance->fw_outstanding) { 839 if (atomic_read(&instance->fw_outstanding)) {
842 instance->hw_crit_error = 1; 840 instance->hw_crit_error = 1;
843 return FAILED; 841 return FAILED;
844 } 842 }
@@ -1050,7 +1048,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
1050{ 1048{
1051 int exception = 0; 1049 int exception = 0;
1052 struct megasas_header *hdr = &cmd->frame->hdr; 1050 struct megasas_header *hdr = &cmd->frame->hdr;
1053 unsigned long flags;
1054 1051
1055 if (cmd->scmd) { 1052 if (cmd->scmd) {
1056 cmd->scmd->SCp.ptr = (char *)0; 1053 cmd->scmd->SCp.ptr = (char *)0;
@@ -1082,9 +1079,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
1082 1079
1083 if (exception) { 1080 if (exception) {
1084 1081
1085 spin_lock_irqsave(&instance->instance_lock, flags); 1082 atomic_dec(&instance->fw_outstanding);
1086 instance->fw_outstanding--;
1087 spin_unlock_irqrestore(&instance->instance_lock, flags);
1088 1083
1089 megasas_unmap_sgbuf(instance, cmd); 1084 megasas_unmap_sgbuf(instance, cmd);
1090 cmd->scmd->scsi_done(cmd->scmd); 1085 cmd->scmd->scsi_done(cmd->scmd);
@@ -1132,9 +1127,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
1132 break; 1127 break;
1133 } 1128 }
1134 1129
1135 spin_lock_irqsave(&instance->instance_lock, flags); 1130 atomic_dec(&instance->fw_outstanding);
1136 instance->fw_outstanding--;
1137 spin_unlock_irqrestore(&instance->instance_lock, flags);
1138 1131
1139 megasas_unmap_sgbuf(instance, cmd); 1132 megasas_unmap_sgbuf(instance, cmd);
1140 cmd->scmd->scsi_done(cmd->scmd); 1133 cmd->scmd->scsi_done(cmd->scmd);
@@ -2171,11 +2164,12 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2171 */ 2164 */
2172 INIT_LIST_HEAD(&instance->cmd_pool); 2165 INIT_LIST_HEAD(&instance->cmd_pool);
2173 2166
2167 atomic_set(&instance->fw_outstanding,0);
2168
2174 init_waitqueue_head(&instance->int_cmd_wait_q); 2169 init_waitqueue_head(&instance->int_cmd_wait_q);
2175 init_waitqueue_head(&instance->abort_cmd_wait_q); 2170 init_waitqueue_head(&instance->abort_cmd_wait_q);
2176 2171
2177 spin_lock_init(&instance->cmd_pool_lock); 2172 spin_lock_init(&instance->cmd_pool_lock);
2178 spin_lock_init(&instance->instance_lock);
2179 2173
2180 sema_init(&instance->aen_mutex, 1); 2174 sema_init(&instance->aen_mutex, 1);
2181 sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS); 2175 sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS);
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 89639f0c38ef..927d6ffef05f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1077,9 +1077,8 @@ struct megasas_instance {
1077 struct pci_dev *pdev; 1077 struct pci_dev *pdev;
1078 u32 unique_id; 1078 u32 unique_id;
1079 1079
1080 u32 fw_outstanding; 1080 atomic_t fw_outstanding;
1081 u32 hw_crit_error; 1081 u32 hw_crit_error;
1082 spinlock_t instance_lock;
1083 1082
1084 struct megasas_instance_template *instancet; 1083 struct megasas_instance_template *instancet;
1085}; 1084};