diff options
author | Don Brace <don.brace@pmcs.com> | 2015-01-23 17:43:46 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2015-02-02 12:57:41 -0500 |
commit | 34f0c6277c686b191936cc321faebd15b28f9ece (patch) | |
tree | f2ef7d5a9f24993e1b6bd86ac667ae31d3ecb289 /drivers/scsi | |
parent | 33811026a0a4208dd5725183d37fc92d5e88b0a2 (diff) |
hpsa: count passthru cmds with atomics, not a spin locked int
Performance enhancement. Remove spin_locks from the driver.
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/hpsa.c | 39 | ||||
-rw-r--r-- | drivers/scsi/hpsa.h | 3 |
2 files changed, 6 insertions, 36 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 72abcf3bfabf..bae3759e30e2 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -5105,35 +5105,6 @@ static void check_ioctl_unit_attention(struct ctlr_info *h, | |||
5105 | (void) check_for_unit_attention(h, c); | 5105 | (void) check_for_unit_attention(h, c); |
5106 | } | 5106 | } |
5107 | 5107 | ||
5108 | static int increment_passthru_count(struct ctlr_info *h) | ||
5109 | { | ||
5110 | unsigned long flags; | ||
5111 | |||
5112 | spin_lock_irqsave(&h->passthru_count_lock, flags); | ||
5113 | if (h->passthru_count >= HPSA_MAX_CONCURRENT_PASSTHRUS) { | ||
5114 | spin_unlock_irqrestore(&h->passthru_count_lock, flags); | ||
5115 | return -1; | ||
5116 | } | ||
5117 | h->passthru_count++; | ||
5118 | spin_unlock_irqrestore(&h->passthru_count_lock, flags); | ||
5119 | return 0; | ||
5120 | } | ||
5121 | |||
5122 | static void decrement_passthru_count(struct ctlr_info *h) | ||
5123 | { | ||
5124 | unsigned long flags; | ||
5125 | |||
5126 | spin_lock_irqsave(&h->passthru_count_lock, flags); | ||
5127 | if (h->passthru_count <= 0) { | ||
5128 | spin_unlock_irqrestore(&h->passthru_count_lock, flags); | ||
5129 | /* not expecting to get here. */ | ||
5130 | dev_warn(&h->pdev->dev, "Bug detected, passthru_count seems to be incorrect.\n"); | ||
5131 | return; | ||
5132 | } | ||
5133 | h->passthru_count--; | ||
5134 | spin_unlock_irqrestore(&h->passthru_count_lock, flags); | ||
5135 | } | ||
5136 | |||
5137 | /* | 5108 | /* |
5138 | * ioctl | 5109 | * ioctl |
5139 | */ | 5110 | */ |
@@ -5156,16 +5127,16 @@ static int hpsa_ioctl(struct scsi_device *dev, int cmd, void __user *arg) | |||
5156 | case CCISS_GETDRIVVER: | 5127 | case CCISS_GETDRIVVER: |
5157 | return hpsa_getdrivver_ioctl(h, argp); | 5128 | return hpsa_getdrivver_ioctl(h, argp); |
5158 | case CCISS_PASSTHRU: | 5129 | case CCISS_PASSTHRU: |
5159 | if (increment_passthru_count(h)) | 5130 | if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) |
5160 | return -EAGAIN; | 5131 | return -EAGAIN; |
5161 | rc = hpsa_passthru_ioctl(h, argp); | 5132 | rc = hpsa_passthru_ioctl(h, argp); |
5162 | decrement_passthru_count(h); | 5133 | atomic_inc(&h->passthru_cmds_avail); |
5163 | return rc; | 5134 | return rc; |
5164 | case CCISS_BIG_PASSTHRU: | 5135 | case CCISS_BIG_PASSTHRU: |
5165 | if (increment_passthru_count(h)) | 5136 | if (atomic_dec_if_positive(&h->passthru_cmds_avail) < 0) |
5166 | return -EAGAIN; | 5137 | return -EAGAIN; |
5167 | rc = hpsa_big_passthru_ioctl(h, argp); | 5138 | rc = hpsa_big_passthru_ioctl(h, argp); |
5168 | decrement_passthru_count(h); | 5139 | atomic_inc(&h->passthru_cmds_avail); |
5169 | return rc; | 5140 | return rc; |
5170 | default: | 5141 | default: |
5171 | return -ENOTTY; | 5142 | return -ENOTTY; |
@@ -6852,7 +6823,7 @@ reinit_after_soft_reset: | |||
6852 | spin_lock_init(&h->lock); | 6823 | spin_lock_init(&h->lock); |
6853 | spin_lock_init(&h->offline_device_lock); | 6824 | spin_lock_init(&h->offline_device_lock); |
6854 | spin_lock_init(&h->scan_lock); | 6825 | spin_lock_init(&h->scan_lock); |
6855 | spin_lock_init(&h->passthru_count_lock); | 6826 | atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); |
6856 | 6827 | ||
6857 | h->resubmit_wq = alloc_workqueue("hpsa", WQ_MEM_RECLAIM, 0); | 6828 | h->resubmit_wq = alloc_workqueue("hpsa", WQ_MEM_RECLAIM, 0); |
6858 | if (!h->resubmit_wq) { | 6829 | if (!h->resubmit_wq) { |
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h index 981479a13935..1856445f883a 100644 --- a/drivers/scsi/hpsa.h +++ b/drivers/scsi/hpsa.h | |||
@@ -183,8 +183,7 @@ struct ctlr_info { | |||
183 | 183 | ||
184 | /* cap concurrent passthrus at some reasonable maximum */ | 184 | /* cap concurrent passthrus at some reasonable maximum */ |
185 | #define HPSA_MAX_CONCURRENT_PASSTHRUS (10) | 185 | #define HPSA_MAX_CONCURRENT_PASSTHRUS (10) |
186 | spinlock_t passthru_count_lock; /* protects passthru_count */ | 186 | atomic_t passthru_cmds_avail; |
187 | int passthru_count; | ||
188 | 187 | ||
189 | /* | 188 | /* |
190 | * Performant mode completion buffers | 189 | * Performant mode completion buffers |