diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2007-12-10 18:49:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-10 22:43:55 -0500 |
commit | 522939d45c293388e6a360210905f9230298df16 (patch) | |
tree | 38c37c6688a5095ab49c8fd42425e2bf3fb61ae9 /drivers/scsi | |
parent | 794e64d5e9c7f088378e093a48eb36a30091d82d (diff) |
esp_scsi: fix reset cleanup spinlock recursion
The esp_reset_cleanup() function is called with the host lock held and
invokes starget_for_each_device() which wants to take it too. Here is a
fix along the lines of shost_for_each_device()/__shost_for_each_device()
adding a __starget_for_each_device() counterpart which assumes the lock
has already been taken.
Eventually, I think the driver should get modified so that more work is
done as a softirq rather than in the interrupt context, but for now it
fixes a bug that causes the spinlock debugger to fire.
While at it, it fixes a small number of cosmetic problems with
starget_for_each_device() too.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/esp_scsi.c | 4 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 31 |
2 files changed, 31 insertions, 4 deletions
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index 4ed3a5297066..bfdee5968892 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c | |||
@@ -2026,8 +2026,8 @@ static void esp_reset_cleanup(struct esp *esp) | |||
2026 | tp->flags |= ESP_TGT_CHECK_NEGO; | 2026 | tp->flags |= ESP_TGT_CHECK_NEGO; |
2027 | 2027 | ||
2028 | if (tp->starget) | 2028 | if (tp->starget) |
2029 | starget_for_each_device(tp->starget, NULL, | 2029 | __starget_for_each_device(tp->starget, NULL, |
2030 | esp_clear_hold); | 2030 | esp_clear_hold); |
2031 | } | 2031 | } |
2032 | esp->flags &= ~ESP_FLAG_RESETTING; | 2032 | esp->flags &= ~ESP_FLAG_RESETTING; |
2033 | } | 2033 | } |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 192948822455..0fb1709ce5e3 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -896,11 +896,11 @@ EXPORT_SYMBOL(__scsi_iterate_devices); | |||
896 | * starget_for_each_device - helper to walk all devices of a target | 896 | * starget_for_each_device - helper to walk all devices of a target |
897 | * @starget: target whose devices we want to iterate over. | 897 | * @starget: target whose devices we want to iterate over. |
898 | * | 898 | * |
899 | * This traverses over each devices of @shost. The devices have | 899 | * This traverses over each device of @starget. The devices have |
900 | * a reference that must be released by scsi_host_put when breaking | 900 | * a reference that must be released by scsi_host_put when breaking |
901 | * out of the loop. | 901 | * out of the loop. |
902 | */ | 902 | */ |
903 | void starget_for_each_device(struct scsi_target *starget, void * data, | 903 | void starget_for_each_device(struct scsi_target *starget, void *data, |
904 | void (*fn)(struct scsi_device *, void *)) | 904 | void (*fn)(struct scsi_device *, void *)) |
905 | { | 905 | { |
906 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | 906 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); |
@@ -915,6 +915,33 @@ void starget_for_each_device(struct scsi_target *starget, void * data, | |||
915 | EXPORT_SYMBOL(starget_for_each_device); | 915 | EXPORT_SYMBOL(starget_for_each_device); |
916 | 916 | ||
917 | /** | 917 | /** |
918 | * __starget_for_each_device - helper to walk all devices of a target | ||
919 | * (UNLOCKED) | ||
920 | * @starget: target whose devices we want to iterate over. | ||
921 | * | ||
922 | * This traverses over each device of @starget. It does _not_ | ||
923 | * take a reference on the scsi_device, so the whole loop must be | ||
924 | * protected by shost->host_lock. | ||
925 | * | ||
926 | * Note: The only reason why drivers would want to use this is because | ||
927 | * they need to access the device list in irq context. Otherwise you | ||
928 | * really want to use starget_for_each_device instead. | ||
929 | **/ | ||
930 | void __starget_for_each_device(struct scsi_target *starget, void *data, | ||
931 | void (*fn)(struct scsi_device *, void *)) | ||
932 | { | ||
933 | struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); | ||
934 | struct scsi_device *sdev; | ||
935 | |||
936 | __shost_for_each_device(sdev, shost) { | ||
937 | if ((sdev->channel == starget->channel) && | ||
938 | (sdev->id == starget->id)) | ||
939 | fn(sdev, data); | ||
940 | } | ||
941 | } | ||
942 | EXPORT_SYMBOL(__starget_for_each_device); | ||
943 | |||
944 | /** | ||
918 | * __scsi_device_lookup_by_target - find a device given the target (UNLOCKED) | 945 | * __scsi_device_lookup_by_target - find a device given the target (UNLOCKED) |
919 | * @starget: SCSI target pointer | 946 | * @starget: SCSI target pointer |
920 | * @lun: SCSI Logical Unit Number | 947 | * @lun: SCSI Logical Unit Number |