diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/block/cciss_scsi.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/block/cciss_scsi.c')
-rw-r--r-- | drivers/block/cciss_scsi.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 575495f3c4b8..696100241a6f 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c | |||
@@ -62,8 +62,8 @@ static int cciss_scsi_proc_info( | |||
62 | int length, /* length of data in buffer */ | 62 | int length, /* length of data in buffer */ |
63 | int func); /* 0 == read, 1 == write */ | 63 | int func); /* 0 == read, 1 == write */ |
64 | 64 | ||
65 | static int cciss_scsi_queue_command (struct scsi_cmnd *cmd, | 65 | static int cciss_scsi_queue_command (struct Scsi_Host *h, |
66 | void (* done)(struct scsi_cmnd *)); | 66 | struct scsi_cmnd *cmd); |
67 | static int cciss_eh_device_reset_handler(struct scsi_cmnd *); | 67 | static int cciss_eh_device_reset_handler(struct scsi_cmnd *); |
68 | static int cciss_eh_abort_handler(struct scsi_cmnd *); | 68 | static int cciss_eh_abort_handler(struct scsi_cmnd *); |
69 | 69 | ||
@@ -84,7 +84,6 @@ static struct scsi_host_template cciss_driver_template = { | |||
84 | .proc_name = "cciss", | 84 | .proc_name = "cciss", |
85 | .proc_info = cciss_scsi_proc_info, | 85 | .proc_info = cciss_scsi_proc_info, |
86 | .queuecommand = cciss_scsi_queue_command, | 86 | .queuecommand = cciss_scsi_queue_command, |
87 | .can_queue = SCSI_CCISS_CAN_QUEUE, | ||
88 | .this_id = 7, | 87 | .this_id = 7, |
89 | .cmd_per_lun = 1, | 88 | .cmd_per_lun = 1, |
90 | .use_clustering = DISABLE_CLUSTERING, | 89 | .use_clustering = DISABLE_CLUSTERING, |
@@ -108,16 +107,13 @@ struct cciss_scsi_cmd_stack_elem_t { | |||
108 | 107 | ||
109 | #pragma pack() | 108 | #pragma pack() |
110 | 109 | ||
111 | #define CMD_STACK_SIZE (SCSI_CCISS_CAN_QUEUE * \ | ||
112 | CCISS_MAX_SCSI_DEVS_PER_HBA + 2) | ||
113 | // plus two for init time usage | ||
114 | |||
115 | #pragma pack(1) | 110 | #pragma pack(1) |
116 | struct cciss_scsi_cmd_stack_t { | 111 | struct cciss_scsi_cmd_stack_t { |
117 | struct cciss_scsi_cmd_stack_elem_t *pool; | 112 | struct cciss_scsi_cmd_stack_elem_t *pool; |
118 | struct cciss_scsi_cmd_stack_elem_t *elem[CMD_STACK_SIZE]; | 113 | struct cciss_scsi_cmd_stack_elem_t **elem; |
119 | dma_addr_t cmd_pool_handle; | 114 | dma_addr_t cmd_pool_handle; |
120 | int top; | 115 | int top; |
116 | int nelems; | ||
121 | }; | 117 | }; |
122 | #pragma pack() | 118 | #pragma pack() |
123 | 119 | ||
@@ -191,7 +187,7 @@ scsi_cmd_free(ctlr_info_t *h, CommandList_struct *c) | |||
191 | sa = h->scsi_ctlr; | 187 | sa = h->scsi_ctlr; |
192 | stk = &sa->cmd_stack; | 188 | stk = &sa->cmd_stack; |
193 | stk->top++; | 189 | stk->top++; |
194 | if (stk->top >= CMD_STACK_SIZE) { | 190 | if (stk->top >= stk->nelems) { |
195 | dev_err(&h->pdev->dev, | 191 | dev_err(&h->pdev->dev, |
196 | "scsi_cmd_free called too many times.\n"); | 192 | "scsi_cmd_free called too many times.\n"); |
197 | BUG(); | 193 | BUG(); |
@@ -206,13 +202,14 @@ scsi_cmd_stack_setup(ctlr_info_t *h, struct cciss_scsi_adapter_data_t *sa) | |||
206 | struct cciss_scsi_cmd_stack_t *stk; | 202 | struct cciss_scsi_cmd_stack_t *stk; |
207 | size_t size; | 203 | size_t size; |
208 | 204 | ||
205 | stk = &sa->cmd_stack; | ||
206 | stk->nelems = cciss_tape_cmds + 2; | ||
209 | sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(h, | 207 | sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(h, |
210 | h->chainsize, CMD_STACK_SIZE); | 208 | h->chainsize, stk->nelems); |
211 | if (!sa->cmd_sg_list && h->chainsize > 0) | 209 | if (!sa->cmd_sg_list && h->chainsize > 0) |
212 | return -ENOMEM; | 210 | return -ENOMEM; |
213 | 211 | ||
214 | stk = &sa->cmd_stack; | 212 | size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems; |
215 | size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; | ||
216 | 213 | ||
217 | /* Check alignment, see cciss_cmd.h near CommandList_struct def. */ | 214 | /* Check alignment, see cciss_cmd.h near CommandList_struct def. */ |
218 | BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0); | 215 | BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0); |
@@ -221,18 +218,23 @@ scsi_cmd_stack_setup(ctlr_info_t *h, struct cciss_scsi_adapter_data_t *sa) | |||
221 | pci_alloc_consistent(h->pdev, size, &stk->cmd_pool_handle); | 218 | pci_alloc_consistent(h->pdev, size, &stk->cmd_pool_handle); |
222 | 219 | ||
223 | if (stk->pool == NULL) { | 220 | if (stk->pool == NULL) { |
224 | cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE); | 221 | cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems); |
225 | sa->cmd_sg_list = NULL; | 222 | sa->cmd_sg_list = NULL; |
226 | return -ENOMEM; | 223 | return -ENOMEM; |
227 | } | 224 | } |
228 | 225 | stk->elem = kmalloc(sizeof(stk->elem[0]) * stk->nelems, GFP_KERNEL); | |
229 | for (i=0; i<CMD_STACK_SIZE; i++) { | 226 | if (!stk->elem) { |
227 | pci_free_consistent(h->pdev, size, stk->pool, | ||
228 | stk->cmd_pool_handle); | ||
229 | return -1; | ||
230 | } | ||
231 | for (i = 0; i < stk->nelems; i++) { | ||
230 | stk->elem[i] = &stk->pool[i]; | 232 | stk->elem[i] = &stk->pool[i]; |
231 | stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + | 233 | stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + |
232 | (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); | 234 | (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); |
233 | stk->elem[i]->cmdindex = i; | 235 | stk->elem[i]->cmdindex = i; |
234 | } | 236 | } |
235 | stk->top = CMD_STACK_SIZE-1; | 237 | stk->top = stk->nelems-1; |
236 | return 0; | 238 | return 0; |
237 | } | 239 | } |
238 | 240 | ||
@@ -245,16 +247,18 @@ scsi_cmd_stack_free(ctlr_info_t *h) | |||
245 | 247 | ||
246 | sa = h->scsi_ctlr; | 248 | sa = h->scsi_ctlr; |
247 | stk = &sa->cmd_stack; | 249 | stk = &sa->cmd_stack; |
248 | if (stk->top != CMD_STACK_SIZE-1) { | 250 | if (stk->top != stk->nelems-1) { |
249 | dev_warn(&h->pdev->dev, | 251 | dev_warn(&h->pdev->dev, |
250 | "bug: %d scsi commands are still outstanding.\n", | 252 | "bug: %d scsi commands are still outstanding.\n", |
251 | CMD_STACK_SIZE - stk->top); | 253 | stk->nelems - stk->top); |
252 | } | 254 | } |
253 | size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE; | 255 | size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems; |
254 | 256 | ||
255 | pci_free_consistent(h->pdev, size, stk->pool, stk->cmd_pool_handle); | 257 | pci_free_consistent(h->pdev, size, stk->pool, stk->cmd_pool_handle); |
256 | stk->pool = NULL; | 258 | stk->pool = NULL; |
257 | cciss_free_sg_chain_blocks(sa->cmd_sg_list, CMD_STACK_SIZE); | 259 | cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems); |
260 | kfree(stk->elem); | ||
261 | stk->elem = NULL; | ||
258 | } | 262 | } |
259 | 263 | ||
260 | #if 0 | 264 | #if 0 |
@@ -824,13 +828,18 @@ static void complete_scsi_command(CommandList_struct *c, int timeout, | |||
824 | break; | 828 | break; |
825 | case CMD_UNSOLICITED_ABORT: | 829 | case CMD_UNSOLICITED_ABORT: |
826 | cmd->result = DID_ABORT << 16; | 830 | cmd->result = DID_ABORT << 16; |
827 | dev_warn(&h->pdev->dev, "%p aborted do to an " | 831 | dev_warn(&h->pdev->dev, "%p aborted due to an " |
828 | "unsolicited abort\n", c); | 832 | "unsolicited abort\n", c); |
829 | break; | 833 | break; |
830 | case CMD_TIMEOUT: | 834 | case CMD_TIMEOUT: |
831 | cmd->result = DID_TIME_OUT << 16; | 835 | cmd->result = DID_TIME_OUT << 16; |
832 | dev_warn(&h->pdev->dev, "%p timedout\n", c); | 836 | dev_warn(&h->pdev->dev, "%p timedout\n", c); |
833 | break; | 837 | break; |
838 | case CMD_UNABORTABLE: | ||
839 | cmd->result = DID_ERROR << 16; | ||
840 | dev_warn(&h->pdev->dev, "c %p command " | ||
841 | "unabortable\n", c); | ||
842 | break; | ||
834 | default: | 843 | default: |
835 | cmd->result = DID_ERROR << 16; | 844 | cmd->result = DID_ERROR << 16; |
836 | dev_warn(&h->pdev->dev, | 845 | dev_warn(&h->pdev->dev, |
@@ -854,6 +863,7 @@ cciss_scsi_detect(ctlr_info_t *h) | |||
854 | sh->io_port = 0; // good enough? FIXME, | 863 | sh->io_port = 0; // good enough? FIXME, |
855 | sh->n_io_port = 0; // I don't think we use these two... | 864 | sh->n_io_port = 0; // I don't think we use these two... |
856 | sh->this_id = SELF_SCSI_ID; | 865 | sh->this_id = SELF_SCSI_ID; |
866 | sh->can_queue = cciss_tape_cmds; | ||
857 | sh->sg_tablesize = h->maxsgentries; | 867 | sh->sg_tablesize = h->maxsgentries; |
858 | sh->max_cmd_len = MAX_COMMAND_SIZE; | 868 | sh->max_cmd_len = MAX_COMMAND_SIZE; |
859 | 869 | ||
@@ -1007,11 +1017,15 @@ cciss_scsi_interpret_error(ctlr_info_t *h, CommandList_struct *c) | |||
1007 | break; | 1017 | break; |
1008 | case CMD_UNSOLICITED_ABORT: | 1018 | case CMD_UNSOLICITED_ABORT: |
1009 | dev_warn(&h->pdev->dev, | 1019 | dev_warn(&h->pdev->dev, |
1010 | "%p aborted do to an unsolicited abort\n", c); | 1020 | "%p aborted due to an unsolicited abort\n", c); |
1011 | break; | 1021 | break; |
1012 | case CMD_TIMEOUT: | 1022 | case CMD_TIMEOUT: |
1013 | dev_warn(&h->pdev->dev, "%p timedout\n", c); | 1023 | dev_warn(&h->pdev->dev, "%p timedout\n", c); |
1014 | break; | 1024 | break; |
1025 | case CMD_UNABORTABLE: | ||
1026 | dev_warn(&h->pdev->dev, | ||
1027 | "%p unabortable\n", c); | ||
1028 | break; | ||
1015 | default: | 1029 | default: |
1016 | dev_warn(&h->pdev->dev, | 1030 | dev_warn(&h->pdev->dev, |
1017 | "%p returned unknown status %x\n", | 1031 | "%p returned unknown status %x\n", |
@@ -1406,7 +1420,7 @@ static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *c, | |||
1406 | 1420 | ||
1407 | 1421 | ||
1408 | static int | 1422 | static int |
1409 | cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *)) | 1423 | cciss_scsi_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) |
1410 | { | 1424 | { |
1411 | ctlr_info_t *h; | 1425 | ctlr_info_t *h; |
1412 | int rc; | 1426 | int rc; |
@@ -1504,6 +1518,8 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd | |||
1504 | return 0; | 1518 | return 0; |
1505 | } | 1519 | } |
1506 | 1520 | ||
1521 | static DEF_SCSI_QCMD(cciss_scsi_queue_command) | ||
1522 | |||
1507 | static void cciss_unregister_scsi(ctlr_info_t *h) | 1523 | static void cciss_unregister_scsi(ctlr_info_t *h) |
1508 | { | 1524 | { |
1509 | struct cciss_scsi_adapter_data_t *sa; | 1525 | struct cciss_scsi_adapter_data_t *sa; |