aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Raspl <raspl@linux.vnet.ibm.com>2013-04-07 18:19:27 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-08 17:16:57 -0400
commit65d8013cbdc661f9cb7645148de1facfe3d0c88a (patch)
treee2a977f555e08b420b9f4c926792d21cd10aba8a
parentf9c41a62bba3f3f7ef3541b2a025e3371bcbba97 (diff)
qeth: fix qeth_wait_for_threads() deadlock for OSN devices
Any recovery thread will deadlock when calling qeth_wait_for_threads(), most notably when triggering a recovery on an OSN device. This patch will store the recovery thread's task pointer on recovery invocation and check in qeth_wait_for_threads() respectively to avoid deadlocks. Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com> Signed-off-by: Frank Blaschka <blaschka@linux.vnet.ibm.com> Reviewed-by: Ursula Braun <ursula.braun@de.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/s390/net/qeth_core.h3
-rw-r--r--drivers/s390/net/qeth_core_main.c19
-rw-r--r--drivers/s390/net/qeth_l2_main.c2
-rw-r--r--drivers/s390/net/qeth_l3_main.c2
4 files changed, 26 insertions, 0 deletions
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index 8c0622399fcd..6ccb7457746b 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -769,6 +769,7 @@ struct qeth_card {
769 unsigned long thread_start_mask; 769 unsigned long thread_start_mask;
770 unsigned long thread_allowed_mask; 770 unsigned long thread_allowed_mask;
771 unsigned long thread_running_mask; 771 unsigned long thread_running_mask;
772 struct task_struct *recovery_task;
772 spinlock_t ip_lock; 773 spinlock_t ip_lock;
773 struct list_head ip_list; 774 struct list_head ip_list;
774 struct list_head *ip_tbd_list; 775 struct list_head *ip_tbd_list;
@@ -862,6 +863,8 @@ extern struct qeth_card_list_struct qeth_core_card_list;
862extern struct kmem_cache *qeth_core_header_cache; 863extern struct kmem_cache *qeth_core_header_cache;
863extern struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS]; 864extern struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS];
864 865
866void qeth_set_recovery_task(struct qeth_card *);
867void qeth_clear_recovery_task(struct qeth_card *);
865void qeth_set_allowed_threads(struct qeth_card *, unsigned long , int); 868void qeth_set_allowed_threads(struct qeth_card *, unsigned long , int);
866int qeth_threads_running(struct qeth_card *, unsigned long); 869int qeth_threads_running(struct qeth_card *, unsigned long);
867int qeth_wait_for_threads(struct qeth_card *, unsigned long); 870int qeth_wait_for_threads(struct qeth_card *, unsigned long);
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 0d73a999983d..451f92020599 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -177,6 +177,23 @@ const char *qeth_get_cardname_short(struct qeth_card *card)
177 return "n/a"; 177 return "n/a";
178} 178}
179 179
180void qeth_set_recovery_task(struct qeth_card *card)
181{
182 card->recovery_task = current;
183}
184EXPORT_SYMBOL_GPL(qeth_set_recovery_task);
185
186void qeth_clear_recovery_task(struct qeth_card *card)
187{
188 card->recovery_task = NULL;
189}
190EXPORT_SYMBOL_GPL(qeth_clear_recovery_task);
191
192static bool qeth_is_recovery_task(const struct qeth_card *card)
193{
194 return card->recovery_task == current;
195}
196
180void qeth_set_allowed_threads(struct qeth_card *card, unsigned long threads, 197void qeth_set_allowed_threads(struct qeth_card *card, unsigned long threads,
181 int clear_start_mask) 198 int clear_start_mask)
182{ 199{
@@ -205,6 +222,8 @@ EXPORT_SYMBOL_GPL(qeth_threads_running);
205 222
206int qeth_wait_for_threads(struct qeth_card *card, unsigned long threads) 223int qeth_wait_for_threads(struct qeth_card *card, unsigned long threads)
207{ 224{
225 if (qeth_is_recovery_task(card))
226 return 0;
208 return wait_event_interruptible(card->wait_q, 227 return wait_event_interruptible(card->wait_q,
209 qeth_threads_running(card, threads) == 0); 228 qeth_threads_running(card, threads) == 0);
210} 229}
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index d690166efeaf..155b101bd730 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1143,6 +1143,7 @@ static int qeth_l2_recover(void *ptr)
1143 QETH_CARD_TEXT(card, 2, "recover2"); 1143 QETH_CARD_TEXT(card, 2, "recover2");
1144 dev_warn(&card->gdev->dev, 1144 dev_warn(&card->gdev->dev,
1145 "A recovery process has been started for the device\n"); 1145 "A recovery process has been started for the device\n");
1146 qeth_set_recovery_task(card);
1146 __qeth_l2_set_offline(card->gdev, 1); 1147 __qeth_l2_set_offline(card->gdev, 1);
1147 rc = __qeth_l2_set_online(card->gdev, 1); 1148 rc = __qeth_l2_set_online(card->gdev, 1);
1148 if (!rc) 1149 if (!rc)
@@ -1153,6 +1154,7 @@ static int qeth_l2_recover(void *ptr)
1153 dev_warn(&card->gdev->dev, "The qeth device driver " 1154 dev_warn(&card->gdev->dev, "The qeth device driver "
1154 "failed to recover an error on the device\n"); 1155 "failed to recover an error on the device\n");
1155 } 1156 }
1157 qeth_clear_recovery_task(card);
1156 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); 1158 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
1157 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); 1159 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
1158 return 0; 1160 return 0;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 8710337dab3e..1f7edf1b26c3 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3515,6 +3515,7 @@ static int qeth_l3_recover(void *ptr)
3515 QETH_CARD_TEXT(card, 2, "recover2"); 3515 QETH_CARD_TEXT(card, 2, "recover2");
3516 dev_warn(&card->gdev->dev, 3516 dev_warn(&card->gdev->dev,
3517 "A recovery process has been started for the device\n"); 3517 "A recovery process has been started for the device\n");
3518 qeth_set_recovery_task(card);
3518 __qeth_l3_set_offline(card->gdev, 1); 3519 __qeth_l3_set_offline(card->gdev, 1);
3519 rc = __qeth_l3_set_online(card->gdev, 1); 3520 rc = __qeth_l3_set_online(card->gdev, 1);
3520 if (!rc) 3521 if (!rc)
@@ -3525,6 +3526,7 @@ static int qeth_l3_recover(void *ptr)
3525 dev_warn(&card->gdev->dev, "The qeth device driver " 3526 dev_warn(&card->gdev->dev, "The qeth device driver "
3526 "failed to recover an error on the device\n"); 3527 "failed to recover an error on the device\n");
3527 } 3528 }
3529 qeth_clear_recovery_task(card);
3528 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); 3530 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
3529 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); 3531 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
3530 return 0; 3532 return 0;