diff options
author | Ralph Wuerthner <rwuerthn@de.ibm.com> | 2007-03-26 14:42:42 -0400 |
---|---|---|
committer | Heiko Carstens <heiko.carstens@de.ibm.com> | 2007-03-26 14:43:47 -0400 |
commit | c6a48264739e3486f66e5b21a543c9573b713621 (patch) | |
tree | a25c70053be8fa8e3a97f7b0bf377f37fa98e31f /drivers/s390 | |
parent | 25c61a1fe8c97d1352a2dc0eda25128b3be0db27 (diff) |
[S390] zcrypt: Fix possible dead lock in AP bus module.
If a AP device is unconfigured __ap_poll_all() will call
device_unregister() in software interrupt context which can cause
dead locks. To fix this the device will be only marked as unconfigured
and the device_unregister() call will be done later by either
ap_scan_bus() or ap_queue_message() in process context.
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Ralph Wuerthner <rwuerthn@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/crypto/ap_bus.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 181b51772b1b..a817dade37c0 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -757,10 +757,16 @@ static void ap_scan_bus(struct work_struct *unused) | |||
757 | (void *)(unsigned long)qid, | 757 | (void *)(unsigned long)qid, |
758 | __ap_scan_bus); | 758 | __ap_scan_bus); |
759 | rc = ap_query_queue(qid, &queue_depth, &device_type); | 759 | rc = ap_query_queue(qid, &queue_depth, &device_type); |
760 | if (dev && rc) { | 760 | if (dev) { |
761 | put_device(dev); | 761 | ap_dev = to_ap_dev(dev); |
762 | device_unregister(dev); | 762 | spin_lock_bh(&ap_dev->lock); |
763 | continue; | 763 | if (rc || ap_dev->unregistered) { |
764 | spin_unlock_bh(&ap_dev->lock); | ||
765 | put_device(dev); | ||
766 | device_unregister(dev); | ||
767 | continue; | ||
768 | } else | ||
769 | spin_unlock_bh(&ap_dev->lock); | ||
764 | } | 770 | } |
765 | if (dev) { | 771 | if (dev) { |
766 | put_device(dev); | 772 | put_device(dev); |
@@ -994,7 +1000,7 @@ void ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg) | |||
994 | ap_dev->unregistered = 1; | 1000 | ap_dev->unregistered = 1; |
995 | } else { | 1001 | } else { |
996 | ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); | 1002 | ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); |
997 | rc = 0; | 1003 | rc = -ENODEV; |
998 | } | 1004 | } |
999 | spin_unlock_bh(&ap_dev->lock); | 1005 | spin_unlock_bh(&ap_dev->lock); |
1000 | if (rc == -ENODEV) | 1006 | if (rc == -ENODEV) |
@@ -1044,18 +1050,12 @@ static void ap_poll_timeout(unsigned long unused) | |||
1044 | */ | 1050 | */ |
1045 | static int __ap_poll_all(struct ap_device *ap_dev, unsigned long *flags) | 1051 | static int __ap_poll_all(struct ap_device *ap_dev, unsigned long *flags) |
1046 | { | 1052 | { |
1047 | int rc; | ||
1048 | |||
1049 | spin_lock(&ap_dev->lock); | 1053 | spin_lock(&ap_dev->lock); |
1050 | if (!ap_dev->unregistered) { | 1054 | if (!ap_dev->unregistered) { |
1051 | rc = ap_poll_queue(ap_dev, flags); | 1055 | if (ap_poll_queue(ap_dev, flags)) |
1052 | if (rc) | ||
1053 | ap_dev->unregistered = 1; | 1056 | ap_dev->unregistered = 1; |
1054 | } else | 1057 | } |
1055 | rc = 0; | ||
1056 | spin_unlock(&ap_dev->lock); | 1058 | spin_unlock(&ap_dev->lock); |
1057 | if (rc) | ||
1058 | device_unregister(&ap_dev->device); | ||
1059 | return 0; | 1059 | return 0; |
1060 | } | 1060 | } |
1061 | 1061 | ||