aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2012-03-28 17:42:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 20:14:36 -0400
commitf60adf42ad55405d1b17e9e5c33fdb63f1eb8861 (patch)
treeb4a7689884c8ee44dc21656ab03b74f56877c672 /drivers/char
parent895dcfd1cab84d7e1c22af645a7f2f3c9bb5f24e (diff)
ipmi: simplify locking
Now that the the IPMI driver is using a tasklet, we can simplify the locking in the driver and get rid of the message lock. Signed-off-by: Corey Minyard <cminyard@mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c54
1 files changed, 21 insertions, 33 deletions
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 01e53cd105dd..3c7e693018d9 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -171,7 +171,6 @@ struct smi_info {
171 struct si_sm_handlers *handlers; 171 struct si_sm_handlers *handlers;
172 enum si_type si_type; 172 enum si_type si_type;
173 spinlock_t si_lock; 173 spinlock_t si_lock;
174 spinlock_t msg_lock;
175 struct list_head xmit_msgs; 174 struct list_head xmit_msgs;
176 struct list_head hp_xmit_msgs; 175 struct list_head hp_xmit_msgs;
177 struct ipmi_smi_msg *curr_msg; 176 struct ipmi_smi_msg *curr_msg;
@@ -350,13 +349,6 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
350 struct timeval t; 349 struct timeval t;
351#endif 350#endif
352 351
353 /*
354 * No need to save flags, we aleady have interrupts off and we
355 * already hold the SMI lock.
356 */
357 if (!smi_info->run_to_completion)
358 spin_lock(&(smi_info->msg_lock));
359
360 /* Pick the high priority queue first. */ 352 /* Pick the high priority queue first. */
361 if (!list_empty(&(smi_info->hp_xmit_msgs))) { 353 if (!list_empty(&(smi_info->hp_xmit_msgs))) {
362 entry = smi_info->hp_xmit_msgs.next; 354 entry = smi_info->hp_xmit_msgs.next;
@@ -394,9 +386,6 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
394 rv = SI_SM_CALL_WITHOUT_DELAY; 386 rv = SI_SM_CALL_WITHOUT_DELAY;
395 } 387 }
396 out: 388 out:
397 if (!smi_info->run_to_completion)
398 spin_unlock(&(smi_info->msg_lock));
399
400 return rv; 389 return rv;
401} 390}
402 391
@@ -879,19 +868,6 @@ static void sender(void *send_info,
879 printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec); 868 printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec);
880#endif 869#endif
881 870
882 /*
883 * last_timeout_jiffies is updated here to avoid
884 * smi_timeout() handler passing very large time_diff
885 * value to smi_event_handler() that causes
886 * the send command to abort.
887 */
888 smi_info->last_timeout_jiffies = jiffies;
889
890 mod_timer(&smi_info->si_timer, jiffies + SI_TIMEOUT_JIFFIES);
891
892 if (smi_info->thread)
893 wake_up_process(smi_info->thread);
894
895 if (smi_info->run_to_completion) { 871 if (smi_info->run_to_completion) {
896 /* 872 /*
897 * If we are running to completion, then throw it in 873 * If we are running to completion, then throw it in
@@ -914,15 +890,26 @@ static void sender(void *send_info,
914 return; 890 return;
915 } 891 }
916 892
917 spin_lock_irqsave(&smi_info->msg_lock, flags); 893 spin_lock_irqsave(&smi_info->si_lock, flags);
918 if (priority > 0) 894 if (priority > 0)
919 list_add_tail(&msg->link, &smi_info->hp_xmit_msgs); 895 list_add_tail(&msg->link, &smi_info->hp_xmit_msgs);
920 else 896 else
921 list_add_tail(&msg->link, &smi_info->xmit_msgs); 897 list_add_tail(&msg->link, &smi_info->xmit_msgs);
922 spin_unlock_irqrestore(&smi_info->msg_lock, flags);
923 898
924 spin_lock_irqsave(&smi_info->si_lock, flags);
925 if (smi_info->si_state == SI_NORMAL && smi_info->curr_msg == NULL) { 899 if (smi_info->si_state == SI_NORMAL && smi_info->curr_msg == NULL) {
900 /*
901 * last_timeout_jiffies is updated here to avoid
902 * smi_timeout() handler passing very large time_diff
903 * value to smi_event_handler() that causes
904 * the send command to abort.
905 */
906 smi_info->last_timeout_jiffies = jiffies;
907
908 mod_timer(&smi_info->si_timer, jiffies + SI_TIMEOUT_JIFFIES);
909
910 if (smi_info->thread)
911 wake_up_process(smi_info->thread);
912
926 start_next_msg(smi_info); 913 start_next_msg(smi_info);
927 smi_event_handler(smi_info, 0); 914 smi_event_handler(smi_info, 0);
928 } 915 }
@@ -1026,16 +1013,19 @@ static int ipmi_thread(void *data)
1026static void poll(void *send_info) 1013static void poll(void *send_info)
1027{ 1014{
1028 struct smi_info *smi_info = send_info; 1015 struct smi_info *smi_info = send_info;
1029 unsigned long flags; 1016 unsigned long flags = 0;
1017 int run_to_completion = smi_info->run_to_completion;
1030 1018
1031 /* 1019 /*
1032 * Make sure there is some delay in the poll loop so we can 1020 * Make sure there is some delay in the poll loop so we can
1033 * drive time forward and timeout things. 1021 * drive time forward and timeout things.
1034 */ 1022 */
1035 udelay(10); 1023 udelay(10);
1036 spin_lock_irqsave(&smi_info->si_lock, flags); 1024 if (!run_to_completion)
1025 spin_lock_irqsave(&smi_info->si_lock, flags);
1037 smi_event_handler(smi_info, 10); 1026 smi_event_handler(smi_info, 10);
1038 spin_unlock_irqrestore(&smi_info->si_lock, flags); 1027 if (!run_to_completion)
1028 spin_unlock_irqrestore(&smi_info->si_lock, flags);
1039} 1029}
1040 1030
1041static void request_events(void *send_info) 1031static void request_events(void *send_info)
@@ -1672,10 +1662,8 @@ static struct smi_info *smi_info_alloc(void)
1672{ 1662{
1673 struct smi_info *info = kzalloc(sizeof(*info), GFP_KERNEL); 1663 struct smi_info *info = kzalloc(sizeof(*info), GFP_KERNEL);
1674 1664
1675 if (info) { 1665 if (info)
1676 spin_lock_init(&info->si_lock); 1666 spin_lock_init(&info->si_lock);
1677 spin_lock_init(&info->msg_lock);
1678 }
1679 return info; 1667 return info;
1680} 1668}
1681 1669