aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorStephen Cameron <stephenmcameron@gmail.com>2015-01-23 17:43:04 -0500
committerJames Bottomley <JBottomley@Parallels.com>2015-02-02 12:57:39 -0500
commit45fcb86e4663122590d243a466eb21ae45890f03 (patch)
tree0e312378e2f99b5af9e68300d718922d5ace34dd /drivers/scsi
parentd54c5c24870ff4d581ce17f09d0c5fcb728c1d02 (diff)
hpsa: get rid of cmd_special_alloc and cmd_special_free
We have commands reserved for internal use. This is laying the groundwork for removing the internal queue of commands from the driver so that the locks that protect that queue may be removed. 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.c106
-rw-r--r--drivers/scsi/hpsa.h2
2 files changed, 31 insertions, 77 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 99c32a0ea15b..26e3e5b80555 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -205,9 +205,7 @@ static int hpsa_compat_ioctl(struct scsi_device *dev, int cmd,
205#endif 205#endif
206 206
207static void cmd_free(struct ctlr_info *h, struct CommandList *c); 207static void cmd_free(struct ctlr_info *h, struct CommandList *c);
208static void cmd_special_free(struct ctlr_info *h, struct CommandList *c);
209static struct CommandList *cmd_alloc(struct ctlr_info *h); 208static struct CommandList *cmd_alloc(struct ctlr_info *h);
210static struct CommandList *cmd_special_alloc(struct ctlr_info *h);
211static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, 209static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
212 void *buff, size_t size, u16 page_code, unsigned char *scsi3addr, 210 void *buff, size_t size, u16 page_code, unsigned char *scsi3addr,
213 int cmd_type); 211 int cmd_type);
@@ -2057,10 +2055,10 @@ static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,
2057 struct CommandList *c; 2055 struct CommandList *c;
2058 struct ErrorInfo *ei; 2056 struct ErrorInfo *ei;
2059 2057
2060 c = cmd_special_alloc(h); 2058 c = cmd_alloc(h);
2061 2059
2062 if (c == NULL) { /* trouble... */ 2060 if (c == NULL) { /* trouble... */
2063 dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 2061 dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
2064 return -ENOMEM; 2062 return -ENOMEM;
2065 } 2063 }
2066 2064
@@ -2076,7 +2074,7 @@ static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,
2076 rc = -1; 2074 rc = -1;
2077 } 2075 }
2078out: 2076out:
2079 cmd_special_free(h, c); 2077 cmd_free(h, c);
2080 return rc; 2078 return rc;
2081} 2079}
2082 2080
@@ -2088,10 +2086,9 @@ static int hpsa_bmic_ctrl_mode_sense(struct ctlr_info *h,
2088 struct CommandList *c; 2086 struct CommandList *c;
2089 struct ErrorInfo *ei; 2087 struct ErrorInfo *ei;
2090 2088
2091 c = cmd_special_alloc(h); 2089 c = cmd_alloc(h);
2092
2093 if (c == NULL) { /* trouble... */ 2090 if (c == NULL) { /* trouble... */
2094 dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 2091 dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
2095 return -ENOMEM; 2092 return -ENOMEM;
2096 } 2093 }
2097 2094
@@ -2107,7 +2104,7 @@ static int hpsa_bmic_ctrl_mode_sense(struct ctlr_info *h,
2107 rc = -1; 2104 rc = -1;
2108 } 2105 }
2109out: 2106out:
2110 cmd_special_free(h, c); 2107 cmd_free(h, c);
2111 return rc; 2108 return rc;
2112 } 2109 }
2113 2110
@@ -2118,10 +2115,10 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
2118 struct CommandList *c; 2115 struct CommandList *c;
2119 struct ErrorInfo *ei; 2116 struct ErrorInfo *ei;
2120 2117
2121 c = cmd_special_alloc(h); 2118 c = cmd_alloc(h);
2122 2119
2123 if (c == NULL) { /* trouble... */ 2120 if (c == NULL) { /* trouble... */
2124 dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 2121 dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
2125 return -ENOMEM; 2122 return -ENOMEM;
2126 } 2123 }
2127 2124
@@ -2137,7 +2134,7 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
2137 hpsa_scsi_interpret_error(h, c); 2134 hpsa_scsi_interpret_error(h, c);
2138 rc = -1; 2135 rc = -1;
2139 } 2136 }
2140 cmd_special_free(h, c); 2137 cmd_free(h, c);
2141 return rc; 2138 return rc;
2142} 2139}
2143 2140
@@ -2245,26 +2242,26 @@ static int hpsa_get_raid_map(struct ctlr_info *h,
2245 struct CommandList *c; 2242 struct CommandList *c;
2246 struct ErrorInfo *ei; 2243 struct ErrorInfo *ei;
2247 2244
2248 c = cmd_special_alloc(h); 2245 c = cmd_alloc(h);
2249 if (c == NULL) { 2246 if (c == NULL) {
2250 dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 2247 dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
2251 return -ENOMEM; 2248 return -ENOMEM;
2252 } 2249 }
2253 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map, 2250 if (fill_cmd(c, HPSA_GET_RAID_MAP, h, &this_device->raid_map,
2254 sizeof(this_device->raid_map), 0, 2251 sizeof(this_device->raid_map), 0,
2255 scsi3addr, TYPE_CMD)) { 2252 scsi3addr, TYPE_CMD)) {
2256 dev_warn(&h->pdev->dev, "Out of memory in hpsa_get_raid_map()\n"); 2253 dev_warn(&h->pdev->dev, "Out of memory in hpsa_get_raid_map()\n");
2257 cmd_special_free(h, c); 2254 cmd_free(h, c);
2258 return -ENOMEM; 2255 return -ENOMEM;
2259 } 2256 }
2260 hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE); 2257 hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE);
2261 ei = c->err_info; 2258 ei = c->err_info;
2262 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) { 2259 if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
2263 hpsa_scsi_interpret_error(h, c); 2260 hpsa_scsi_interpret_error(h, c);
2264 cmd_special_free(h, c); 2261 cmd_free(h, c);
2265 return -1; 2262 return -1;
2266 } 2263 }
2267 cmd_special_free(h, c); 2264 cmd_free(h, c);
2268 2265
2269 /* @todo in the future, dynamically allocate RAID map memory */ 2266 /* @todo in the future, dynamically allocate RAID map memory */
2270 if (le32_to_cpu(this_device->raid_map.structure_size) > 2267 if (le32_to_cpu(this_device->raid_map.structure_size) >
@@ -2384,9 +2381,9 @@ static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical,
2384 unsigned char scsi3addr[8]; 2381 unsigned char scsi3addr[8];
2385 struct ErrorInfo *ei; 2382 struct ErrorInfo *ei;
2386 2383
2387 c = cmd_special_alloc(h); 2384 c = cmd_alloc(h);
2388 if (c == NULL) { /* trouble... */ 2385 if (c == NULL) { /* trouble... */
2389 dev_err(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 2386 dev_err(&h->pdev->dev, "cmd_alloc returned NULL!\n");
2390 return -1; 2387 return -1;
2391 } 2388 }
2392 /* address the controller */ 2389 /* address the controller */
@@ -2414,7 +2411,7 @@ static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical,
2414 } 2411 }
2415 } 2412 }
2416out: 2413out:
2417 cmd_special_free(h, c); 2414 cmd_free(h, c);
2418 return rc; 2415 return rc;
2419} 2416}
2420 2417
@@ -4102,7 +4099,7 @@ static int wait_for_device_to_become_ready(struct ctlr_info *h,
4102 int waittime = 1; /* seconds */ 4099 int waittime = 1; /* seconds */
4103 struct CommandList *c; 4100 struct CommandList *c;
4104 4101
4105 c = cmd_special_alloc(h); 4102 c = cmd_alloc(h);
4106 if (!c) { 4103 if (!c) {
4107 dev_warn(&h->pdev->dev, "out of memory in " 4104 dev_warn(&h->pdev->dev, "out of memory in "
4108 "wait_for_device_to_become_ready.\n"); 4105 "wait_for_device_to_become_ready.\n");
@@ -4148,7 +4145,7 @@ static int wait_for_device_to_become_ready(struct ctlr_info *h,
4148 else 4145 else
4149 dev_warn(&h->pdev->dev, "device is ready.\n"); 4146 dev_warn(&h->pdev->dev, "device is ready.\n");
4150 4147
4151 cmd_special_free(h, c); 4148 cmd_free(h, c);
4152 return rc; 4149 return rc;
4153} 4150}
4154 4151
@@ -4230,9 +4227,9 @@ static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,
4230 struct ErrorInfo *ei; 4227 struct ErrorInfo *ei;
4231 __le32 tagupper, taglower; 4228 __le32 tagupper, taglower;
4232 4229
4233 c = cmd_special_alloc(h); 4230 c = cmd_alloc(h);
4234 if (c == NULL) { /* trouble... */ 4231 if (c == NULL) { /* trouble... */
4235 dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 4232 dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
4236 return -ENOMEM; 4233 return -ENOMEM;
4237 } 4234 }
4238 4235
@@ -4261,7 +4258,7 @@ static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,
4261 rc = -1; 4258 rc = -1;
4262 break; 4259 break;
4263 } 4260 }
4264 cmd_special_free(h, c); 4261 cmd_free(h, c);
4265 dev_dbg(&h->pdev->dev, "%s: Tag:0x%08x:%08x: Finished.\n", 4262 dev_dbg(&h->pdev->dev, "%s: Tag:0x%08x:%08x: Finished.\n",
4266 __func__, tagupper, taglower); 4263 __func__, tagupper, taglower);
4267 return rc; 4264 return rc;
@@ -4610,40 +4607,6 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
4610 return c; 4607 return c;
4611} 4608}
4612 4609
4613/* For operations that can wait for kmalloc to possibly sleep,
4614 * this routine can be called. Lock need not be held to call
4615 * cmd_special_alloc. cmd_special_free() is the complement.
4616 */
4617static struct CommandList *cmd_special_alloc(struct ctlr_info *h)
4618{
4619 struct CommandList *c;
4620 dma_addr_t cmd_dma_handle, err_dma_handle;
4621
4622 c = pci_zalloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle);
4623 if (c == NULL)
4624 return NULL;
4625
4626 c->cmd_type = CMD_SCSI;
4627 c->cmdindex = -1;
4628
4629 c->err_info = pci_zalloc_consistent(h->pdev, sizeof(*c->err_info),
4630 &err_dma_handle);
4631
4632 if (c->err_info == NULL) {
4633 pci_free_consistent(h->pdev,
4634 sizeof(*c), c, cmd_dma_handle);
4635 return NULL;
4636 }
4637
4638 INIT_LIST_HEAD(&c->list);
4639 c->busaddr = (u32) cmd_dma_handle;
4640 c->ErrDesc.Addr = cpu_to_le64(err_dma_handle);
4641 c->ErrDesc.Len = cpu_to_le32(sizeof(*c->err_info));
4642
4643 c->h = h;
4644 return c;
4645}
4646
4647static void cmd_free(struct ctlr_info *h, struct CommandList *c) 4610static void cmd_free(struct ctlr_info *h, struct CommandList *c)
4648{ 4611{
4649 int i; 4612 int i;
@@ -4653,15 +4616,6 @@ static void cmd_free(struct ctlr_info *h, struct CommandList *c)
4653 h->cmd_pool_bits + (i / BITS_PER_LONG)); 4616 h->cmd_pool_bits + (i / BITS_PER_LONG));
4654} 4617}
4655 4618
4656static void cmd_special_free(struct ctlr_info *h, struct CommandList *c)
4657{
4658 pci_free_consistent(h->pdev, sizeof(*c->err_info),
4659 c->err_info,
4660 (dma_addr_t) le64_to_cpu(c->ErrDesc.Addr));
4661 pci_free_consistent(h->pdev, sizeof(*c),
4662 c, (dma_addr_t) (c->busaddr & DIRECT_LOOKUP_MASK));
4663}
4664
4665#ifdef CONFIG_COMPAT 4619#ifdef CONFIG_COMPAT
4666 4620
4667static int hpsa_ioctl32_passthru(struct scsi_device *dev, int cmd, 4621static int hpsa_ioctl32_passthru(struct scsi_device *dev, int cmd,
@@ -4840,7 +4794,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
4840 memset(buff, 0, iocommand.buf_size); 4794 memset(buff, 0, iocommand.buf_size);
4841 } 4795 }
4842 } 4796 }
4843 c = cmd_special_alloc(h); 4797 c = cmd_alloc(h);
4844 if (c == NULL) { 4798 if (c == NULL) {
4845 rc = -ENOMEM; 4799 rc = -ENOMEM;
4846 goto out_kfree; 4800 goto out_kfree;
@@ -4899,7 +4853,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
4899 } 4853 }
4900 } 4854 }
4901out: 4855out:
4902 cmd_special_free(h, c); 4856 cmd_free(h, c);
4903out_kfree: 4857out_kfree:
4904 kfree(buff); 4858 kfree(buff);
4905 return rc; 4859 return rc;
@@ -4977,7 +4931,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
4977 data_ptr += sz; 4931 data_ptr += sz;
4978 sg_used++; 4932 sg_used++;
4979 } 4933 }
4980 c = cmd_special_alloc(h); 4934 c = cmd_alloc(h);
4981 if (c == NULL) { 4935 if (c == NULL) {
4982 status = -ENOMEM; 4936 status = -ENOMEM;
4983 goto cleanup1; 4937 goto cleanup1;
@@ -5034,7 +4988,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
5034 } 4988 }
5035 status = 0; 4989 status = 0;
5036cleanup0: 4990cleanup0:
5037 cmd_special_free(h, c); 4991 cmd_free(h, c);
5038cleanup1: 4992cleanup1:
5039 if (buff) { 4993 if (buff) {
5040 int i; 4994 int i;
@@ -6188,7 +6142,7 @@ static int hpsa_supports_chained_sg_blocks(struct ctlr_info *h)
6188static void hpsa_find_board_params(struct ctlr_info *h) 6142static void hpsa_find_board_params(struct ctlr_info *h)
6189{ 6143{
6190 hpsa_get_max_perf_mode_cmds(h); 6144 hpsa_get_max_perf_mode_cmds(h);
6191 h->nr_cmds = h->max_commands - 4; /* Allow room for some ioctls */ 6145 h->nr_cmds = h->max_commands;
6192 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); 6146 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements));
6193 h->fw_support = readl(&(h->cfgtable->misc_fw_support)); 6147 h->fw_support = readl(&(h->cfgtable->misc_fw_support));
6194 if (hpsa_supports_chained_sg_blocks(h)) { 6148 if (hpsa_supports_chained_sg_blocks(h)) {
@@ -7064,9 +7018,9 @@ static void hpsa_flush_cache(struct ctlr_info *h)
7064 if (!flush_buf) 7018 if (!flush_buf)
7065 return; 7019 return;
7066 7020
7067 c = cmd_special_alloc(h); 7021 c = cmd_alloc(h);
7068 if (!c) { 7022 if (!c) {
7069 dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n"); 7023 dev_warn(&h->pdev->dev, "cmd_alloc returned NULL!\n");
7070 goto out_of_memory; 7024 goto out_of_memory;
7071 } 7025 }
7072 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0, 7026 if (fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0,
@@ -7078,7 +7032,7 @@ static void hpsa_flush_cache(struct ctlr_info *h)
7078out: 7032out:
7079 dev_warn(&h->pdev->dev, 7033 dev_warn(&h->pdev->dev,
7080 "error flushing cache on controller\n"); 7034 "error flushing cache on controller\n");
7081 cmd_special_free(h, c); 7035 cmd_free(h, c);
7082out_of_memory: 7036out_of_memory:
7083 kfree(flush_buf); 7037 kfree(flush_buf);
7084} 7038}
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 5ee6c6a73b0c..06c9e430a64a 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -170,7 +170,7 @@ struct ctlr_info {
170 unsigned long transMethod; 170 unsigned long transMethod;
171 171
172 /* cap concurrent passthrus at some reasonable maximum */ 172 /* cap concurrent passthrus at some reasonable maximum */
173#define HPSA_MAX_CONCURRENT_PASSTHRUS (20) 173#define HPSA_MAX_CONCURRENT_PASSTHRUS (10)
174 spinlock_t passthru_count_lock; /* protects passthru_count */ 174 spinlock_t passthru_count_lock; /* protects passthru_count */
175 int passthru_count; 175 int passthru_count;
176 176