Blame view
drivers/block/cciss_scsi.c
46.4 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
bd4f36d6d cciss: update cop... |
2 3 |
* Disk Array driver for HP Smart Array controllers, SCSI Tape module. * (C) Copyright 2001, 2007 Hewlett-Packard Development Company, L.P. |
1da177e4c Linux-2.6.12-rc2 |
4 5 6 |
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by |
bd4f36d6d cciss: update cop... |
7 |
* the Free Software Foundation; version 2 of the License. |
1da177e4c Linux-2.6.12-rc2 |
8 9 10 |
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bd4f36d6d cciss: update cop... |
11 12 |
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. |
1da177e4c Linux-2.6.12-rc2 |
13 14 15 |
* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software |
bd4f36d6d cciss: update cop... |
16 17 |
* Foundation, Inc., 59 Temple Place, Suite 300, Boston, MA * 02111-1307, USA. |
1da177e4c Linux-2.6.12-rc2 |
18 19 |
* * Questions/Comments/Bugfixes to iss_storagedev@hp.com |
f08896384 cciss: Fix checkp... |
20 |
* |
1da177e4c Linux-2.6.12-rc2 |
21 22 23 |
* Author: Stephen M. Cameron */ #ifdef CONFIG_CISS_SCSI_TAPE |
f08896384 cciss: Fix checkp... |
24 25 |
/* Here we have code to present the driver as a scsi driver as it is simultaneously presented as a block driver. The |
1da177e4c Linux-2.6.12-rc2 |
26 |
reason for doing this is to allow access to SCSI tape drives |
f08896384 cciss: Fix checkp... |
27 |
through the array controller. Note in particular, neither |
1da177e4c Linux-2.6.12-rc2 |
28 |
physical nor logical disks are presented through the scsi layer. */ |
4e57b6817 [PATCH] fix missi... |
29 30 31 32 |
#include <linux/timer.h> #include <linux/completion.h> #include <linux/slab.h> #include <linux/string.h> |
60063497a atomic: use <linu... |
33 |
#include <linux/atomic.h> |
4e57b6817 [PATCH] fix missi... |
34 |
|
1da177e4c Linux-2.6.12-rc2 |
35 36 |
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_device.h> |
f08896384 cciss: Fix checkp... |
37 |
#include <scsi/scsi_host.h> |
1da177e4c Linux-2.6.12-rc2 |
38 39 |
#include "cciss_scsi.h" |
3da8b713d [SCSI] cciss: scs... |
40 41 |
#define CCISS_ABORT_MSG 0x00 #define CCISS_RESET_MSG 0x01 |
f70dba836 cciss: use consis... |
42 |
static int fill_cmd(ctlr_info_t *h, CommandList_struct *c, __u8 cmd, void *buff, |
88f627ae3 cciss: fix SCSI d... |
43 |
size_t size, |
b57695fe1 cciss: simplify i... |
44 |
__u8 page_code, unsigned char *scsi3addr, |
88f627ae3 cciss: fix SCSI d... |
45 |
int cmd_type); |
6b4d96b87 cciss: separate c... |
46 47 48 49 |
static CommandList_struct *cmd_alloc(ctlr_info_t *h); static CommandList_struct *cmd_special_alloc(ctlr_info_t *h); static void cmd_free(ctlr_info_t *h, CommandList_struct *c); static void cmd_special_free(ctlr_info_t *h, CommandList_struct *c); |
1da177e4c Linux-2.6.12-rc2 |
50 |
|
e88b7bb00 cciss: switch to ... |
51 |
static int cciss_scsi_write_info(struct Scsi_Host *sh, |
1da177e4c Linux-2.6.12-rc2 |
52 |
char *buffer, /* data buffer */ |
e88b7bb00 cciss: switch to ... |
53 54 55 |
int length); /* length of data in buffer */ static int cciss_scsi_show_info(struct seq_file *m, struct Scsi_Host *sh); |
1da177e4c Linux-2.6.12-rc2 |
56 |
|
f281233d3 SCSI host lock pu... |
57 58 |
static int cciss_scsi_queue_command (struct Scsi_Host *h, struct scsi_cmnd *cmd); |
3da8b713d [SCSI] cciss: scs... |
59 60 |
static int cciss_eh_device_reset_handler(struct scsi_cmnd *); static int cciss_eh_abort_handler(struct scsi_cmnd *); |
1da177e4c Linux-2.6.12-rc2 |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = { { .name = "cciss0", .ndevices = 0 }, { .name = "cciss1", .ndevices = 0 }, { .name = "cciss2", .ndevices = 0 }, { .name = "cciss3", .ndevices = 0 }, { .name = "cciss4", .ndevices = 0 }, { .name = "cciss5", .ndevices = 0 }, { .name = "cciss6", .ndevices = 0 }, { .name = "cciss7", .ndevices = 0 }, }; static struct scsi_host_template cciss_driver_template = { .module = THIS_MODULE, .name = "cciss", .proc_name = "cciss", |
e88b7bb00 cciss: switch to ... |
77 78 |
.write_info = cciss_scsi_write_info, .show_info = cciss_scsi_show_info, |
1da177e4c Linux-2.6.12-rc2 |
79 |
.queuecommand = cciss_scsi_queue_command, |
1da177e4c Linux-2.6.12-rc2 |
80 |
.this_id = 7, |
1da177e4c Linux-2.6.12-rc2 |
81 |
.use_clustering = DISABLE_CLUSTERING, |
3da8b713d [SCSI] cciss: scs... |
82 83 84 |
/* Can't have eh_bus_reset_handler or eh_host_reset_handler for cciss */ .eh_device_reset_handler= cciss_eh_device_reset_handler, .eh_abort_handler = cciss_eh_abort_handler, |
1da177e4c Linux-2.6.12-rc2 |
85 86 87 |
}; #pragma pack(1) |
1b7d0d28a cciss: detect bad... |
88 |
|
5e216153c cciss: add perfor... |
89 90 |
#define SCSI_PAD_32 8 #define SCSI_PAD_64 8 |
1b7d0d28a cciss: detect bad... |
91 |
|
1da177e4c Linux-2.6.12-rc2 |
92 93 94 95 |
struct cciss_scsi_cmd_stack_elem_t { CommandList_struct cmd; ErrorInfo_struct Err; __u32 busaddr; |
87c3a922a cciss: Fix proble... |
96 |
int cmdindex; |
1b7d0d28a cciss: detect bad... |
97 |
u8 pad[IS_32_BIT * SCSI_PAD_32 + IS_64_BIT * SCSI_PAD_64]; |
1da177e4c Linux-2.6.12-rc2 |
98 99 100 |
}; #pragma pack() |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 |
#pragma pack(1) struct cciss_scsi_cmd_stack_t { struct cciss_scsi_cmd_stack_elem_t *pool; |
8a4ec67bd cciss: add cciss_... |
104 |
struct cciss_scsi_cmd_stack_elem_t **elem; |
1da177e4c Linux-2.6.12-rc2 |
105 106 |
dma_addr_t cmd_pool_handle; int top; |
8a4ec67bd cciss: add cciss_... |
107 |
int nelems; |
1da177e4c Linux-2.6.12-rc2 |
108 109 110 111 112 113 |
}; #pragma pack() struct cciss_scsi_adapter_data_t { struct Scsi_Host *scsi_host; struct cciss_scsi_cmd_stack_t cmd_stack; |
87c3a922a cciss: Fix proble... |
114 |
SGDescriptor_struct **cmd_sg_list; |
1da177e4c Linux-2.6.12-rc2 |
115 |
int registered; |
f08896384 cciss: Fix checkp... |
116 |
spinlock_t lock; // to protect ccissscsi[ctlr]; |
1da177e4c Linux-2.6.12-rc2 |
117 |
}; |
f70dba836 cciss: use consis... |
118 119 120 121 |
#define CPQ_TAPE_LOCK(h, flags) spin_lock_irqsave( \ &h->scsi_ctlr->lock, flags); #define CPQ_TAPE_UNLOCK(h, flags) spin_unlock_irqrestore( \ &h->scsi_ctlr->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
122 123 124 125 126 |
static CommandList_struct * scsi_cmd_alloc(ctlr_info_t *h) { /* assume only one process in here at a time, locking done by caller. */ |
f70dba836 cciss: use consis... |
127 |
/* use h->lock */ |
1da177e4c Linux-2.6.12-rc2 |
128 129 130 131 132 133 134 135 |
/* might be better to rewrite how we allocate scsi commands in a way that */ /* needs no locking at all. */ /* take the top memory chunk off the stack and return it, if any. */ struct cciss_scsi_cmd_stack_elem_t *c; struct cciss_scsi_adapter_data_t *sa; struct cciss_scsi_cmd_stack_t *stk; u64bit temp64; |
aad9fb6f2 cciss: do not use... |
136 |
sa = h->scsi_ctlr; |
f08896384 cciss: Fix checkp... |
137 |
stk = &sa->cmd_stack; |
1da177e4c Linux-2.6.12-rc2 |
138 |
|
f08896384 cciss: Fix checkp... |
139 |
if (stk->top < 0) |
1da177e4c Linux-2.6.12-rc2 |
140 |
return NULL; |
f08896384 cciss: Fix checkp... |
141 |
c = stk->elem[stk->top]; |
1da177e4c Linux-2.6.12-rc2 |
142 143 144 145 |
/* memset(c, 0, sizeof(*c)); */ memset(&c->cmd, 0, sizeof(c->cmd)); memset(&c->Err, 0, sizeof(c->Err)); /* set physical addr of cmd and addr of scsi parameters */ |
f08896384 cciss: Fix checkp... |
146 |
c->cmd.busaddr = c->busaddr; |
87c3a922a cciss: Fix proble... |
147 |
c->cmd.cmdindex = c->cmdindex; |
f08896384 cciss: Fix checkp... |
148 |
/* (__u32) (stk->cmd_pool_handle + |
1da177e4c Linux-2.6.12-rc2 |
149 150 151 |
(sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top)); */ temp64.val = (__u64) (c->busaddr + sizeof(CommandList_struct)); |
f08896384 cciss: Fix checkp... |
152 |
/* (__u64) (stk->cmd_pool_handle + |
1da177e4c Linux-2.6.12-rc2 |
153 154 155 156 157 158 |
(sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top) + sizeof(CommandList_struct)); */ stk->top--; c->cmd.ErrDesc.Addr.lower = temp64.val32.lower; c->cmd.ErrDesc.Addr.upper = temp64.val32.upper; c->cmd.ErrDesc.Len = sizeof(ErrorInfo_struct); |
f08896384 cciss: Fix checkp... |
159 |
|
1da177e4c Linux-2.6.12-rc2 |
160 161 162 163 164 |
c->cmd.ctlr = h->ctlr; c->cmd.err_info = &c->Err; return (CommandList_struct *) c; } |
f08896384 cciss: Fix checkp... |
165 |
static void |
f70dba836 cciss: use consis... |
166 |
scsi_cmd_free(ctlr_info_t *h, CommandList_struct *c) |
1da177e4c Linux-2.6.12-rc2 |
167 168 |
{ /* assume only one process in here at a time, locking done by caller. */ |
f70dba836 cciss: use consis... |
169 |
/* use h->lock */ |
1da177e4c Linux-2.6.12-rc2 |
170 171 172 173 |
/* drop the free memory chunk on top of the stack. */ struct cciss_scsi_adapter_data_t *sa; struct cciss_scsi_cmd_stack_t *stk; |
aad9fb6f2 cciss: do not use... |
174 |
sa = h->scsi_ctlr; |
f08896384 cciss: Fix checkp... |
175 |
stk = &sa->cmd_stack; |
713b68649 cciss: call BUG()... |
176 |
stk->top++; |
8a4ec67bd cciss: add cciss_... |
177 |
if (stk->top >= stk->nelems) { |
b2a4a43db cciss: change pri... |
178 179 180 |
dev_err(&h->pdev->dev, "scsi_cmd_free called too many times. "); |
1da177e4c Linux-2.6.12-rc2 |
181 182 |
BUG(); } |
f70dba836 cciss: use consis... |
183 |
stk->elem[stk->top] = (struct cciss_scsi_cmd_stack_elem_t *) c; |
1da177e4c Linux-2.6.12-rc2 |
184 185 186 |
} static int |
f70dba836 cciss: use consis... |
187 |
scsi_cmd_stack_setup(ctlr_info_t *h, struct cciss_scsi_adapter_data_t *sa) |
1da177e4c Linux-2.6.12-rc2 |
188 189 190 191 |
{ int i; struct cciss_scsi_cmd_stack_t *stk; size_t size; |
8a4ec67bd cciss: add cciss_... |
192 193 |
stk = &sa->cmd_stack; stk->nelems = cciss_tape_cmds + 2; |
f70dba836 cciss: use consis... |
194 |
sa->cmd_sg_list = cciss_allocate_sg_chain_blocks(h, |
8a4ec67bd cciss: add cciss_... |
195 |
h->chainsize, stk->nelems); |
f70dba836 cciss: use consis... |
196 |
if (!sa->cmd_sg_list && h->chainsize > 0) |
87c3a922a cciss: Fix proble... |
197 |
return -ENOMEM; |
8a4ec67bd cciss: add cciss_... |
198 |
size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems; |
1da177e4c Linux-2.6.12-rc2 |
199 |
|
1b7d0d28a cciss: detect bad... |
200 201 202 |
/* Check alignment, see cciss_cmd.h near CommandList_struct def. */ BUILD_BUG_ON((sizeof(*stk->pool) % COMMANDLIST_ALIGNMENT) != 0); /* pci_alloc_consistent guarantees 32-bit DMA address will be used */ |
1da177e4c Linux-2.6.12-rc2 |
203 |
stk->pool = (struct cciss_scsi_cmd_stack_elem_t *) |
f70dba836 cciss: use consis... |
204 |
pci_alloc_consistent(h->pdev, size, &stk->cmd_pool_handle); |
1da177e4c Linux-2.6.12-rc2 |
205 206 |
if (stk->pool == NULL) { |
8a4ec67bd cciss: add cciss_... |
207 |
cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems); |
87c3a922a cciss: Fix proble... |
208 209 |
sa->cmd_sg_list = NULL; return -ENOMEM; |
1da177e4c Linux-2.6.12-rc2 |
210 |
} |
8a4ec67bd cciss: add cciss_... |
211 212 213 214 215 216 217 |
stk->elem = kmalloc(sizeof(stk->elem[0]) * stk->nelems, GFP_KERNEL); if (!stk->elem) { pci_free_consistent(h->pdev, size, stk->pool, stk->cmd_pool_handle); return -1; } for (i = 0; i < stk->nelems; i++) { |
1da177e4c Linux-2.6.12-rc2 |
218 |
stk->elem[i] = &stk->pool[i]; |
f08896384 cciss: Fix checkp... |
219 |
stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle + |
1da177e4c Linux-2.6.12-rc2 |
220 |
(sizeof(struct cciss_scsi_cmd_stack_elem_t) * i)); |
87c3a922a cciss: Fix proble... |
221 |
stk->elem[i]->cmdindex = i; |
1da177e4c Linux-2.6.12-rc2 |
222 |
} |
8a4ec67bd cciss: add cciss_... |
223 |
stk->top = stk->nelems-1; |
1da177e4c Linux-2.6.12-rc2 |
224 225 226 227 |
return 0; } static void |
f70dba836 cciss: use consis... |
228 |
scsi_cmd_stack_free(ctlr_info_t *h) |
1da177e4c Linux-2.6.12-rc2 |
229 230 231 232 |
{ struct cciss_scsi_adapter_data_t *sa; struct cciss_scsi_cmd_stack_t *stk; size_t size; |
f70dba836 cciss: use consis... |
233 |
sa = h->scsi_ctlr; |
f08896384 cciss: Fix checkp... |
234 |
stk = &sa->cmd_stack; |
8a4ec67bd cciss: add cciss_... |
235 |
if (stk->top != stk->nelems-1) { |
b2a4a43db cciss: change pri... |
236 237 238 |
dev_warn(&h->pdev->dev, "bug: %d scsi commands are still outstanding. ", |
8a4ec67bd cciss: add cciss_... |
239 |
stk->nelems - stk->top); |
1da177e4c Linux-2.6.12-rc2 |
240 |
} |
8a4ec67bd cciss: add cciss_... |
241 |
size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * stk->nelems; |
1da177e4c Linux-2.6.12-rc2 |
242 |
|
f70dba836 cciss: use consis... |
243 |
pci_free_consistent(h->pdev, size, stk->pool, stk->cmd_pool_handle); |
1da177e4c Linux-2.6.12-rc2 |
244 |
stk->pool = NULL; |
8a4ec67bd cciss: add cciss_... |
245 246 247 |
cciss_free_sg_chain_blocks(sa->cmd_sg_list, stk->nelems); kfree(stk->elem); stk->elem = NULL; |
1da177e4c Linux-2.6.12-rc2 |
248 |
} |
400bb2369 [PATCH] cciss_scs... |
249 |
#if 0 |
1da177e4c Linux-2.6.12-rc2 |
250 251 252 253 254 255 256 257 258 |
static void print_cmd(CommandList_struct *cp) { printk("queue:%d ", cp->Header.ReplyQueue); printk("sglist:%d ", cp->Header.SGList); printk("sgtot:%d ", cp->Header.SGTotal); |
f08896384 cciss: Fix checkp... |
259 260 |
printk("Tag:0x%08x/0x%08x ", cp->Header.Tag.upper, |
1da177e4c Linux-2.6.12-rc2 |
261 |
cp->Header.Tag.lower); |
8d9c1f86a scsi: cciss: repl... |
262 263 |
printk("LUN:0x%8phN ", cp->Header.LUN.LunAddrBytes); |
1da177e4c Linux-2.6.12-rc2 |
264 265 266 267 268 269 270 271 272 273 |
printk("CDBLen:%d ", cp->Request.CDBLen); printk("Type:%d ",cp->Request.Type.Type); printk("Attr:%d ",cp->Request.Type.Attribute); printk(" Dir:%d ",cp->Request.Type.Direction); printk("Timeout:%d ",cp->Request.Timeout); |
8d9c1f86a scsi: cciss: repl... |
274 275 |
printk("CDB: %16ph ", cp->Request.CDB); |
f08896384 cciss: Fix checkp... |
276 277 278 |
printk("edesc.Addr: 0x%08x/0%08x, Len = %d ", cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower, |
1da177e4c Linux-2.6.12-rc2 |
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
cp->ErrDesc.Len); printk("sgs..........Errorinfo: "); printk("scsistatus:%d ", cp->err_info->ScsiStatus); printk("senselen:%d ", cp->err_info->SenseLen); printk("cmd status:%d ", cp->err_info->CommandStatus); printk("resid cnt:%d ", cp->err_info->ResidualCnt); printk("offense size:%d ", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size); printk("offense byte:%d ", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num); printk("offense value:%d ", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value); |
1da177e4c Linux-2.6.12-rc2 |
296 |
} |
1da177e4c Linux-2.6.12-rc2 |
297 |
#endif |
f08896384 cciss: Fix checkp... |
298 |
static int |
f70dba836 cciss: use consis... |
299 |
find_bus_target_lun(ctlr_info_t *h, int *bus, int *target, int *lun) |
1da177e4c Linux-2.6.12-rc2 |
300 301 |
{ /* finds an unused bus, target, lun for a new device */ |
f70dba836 cciss: use consis... |
302 |
/* assumes h->scsi_ctlr->lock is held */ |
1da177e4c Linux-2.6.12-rc2 |
303 304 305 306 |
int i, found=0; unsigned char target_taken[CCISS_MAX_SCSI_DEVS_PER_HBA]; memset(&target_taken[0], 0, CCISS_MAX_SCSI_DEVS_PER_HBA); |
f08896384 cciss: Fix checkp... |
307 |
target_taken[SELF_SCSI_ID] = 1; |
f70dba836 cciss: use consis... |
308 309 |
for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) target_taken[ccissscsi[h->ctlr].dev[i].target] = 1; |
f08896384 cciss: Fix checkp... |
310 |
|
f70dba836 cciss: use consis... |
311 |
for (i = 0; i < CCISS_MAX_SCSI_DEVS_PER_HBA; i++) { |
1da177e4c Linux-2.6.12-rc2 |
312 313 314 315 316 |
if (!target_taken[i]) { *bus = 0; *target=i; *lun = 0; found=1; break; } } |
f08896384 cciss: Fix checkp... |
317 |
return (!found); |
1da177e4c Linux-2.6.12-rc2 |
318 |
} |
f4a93bcda cciss: change the... |
319 320 321 322 |
struct scsi2map { char scsi3addr[8]; int bus, target, lun; }; |
1da177e4c Linux-2.6.12-rc2 |
323 |
|
f08896384 cciss: Fix checkp... |
324 |
static int |
f70dba836 cciss: use consis... |
325 |
cciss_scsi_add_entry(ctlr_info_t *h, int hostno, |
905bd78f2 cciss: Fix cciss ... |
326 |
struct cciss_scsi_dev_t *device, |
f4a93bcda cciss: change the... |
327 |
struct scsi2map *added, int *nadded) |
1da177e4c Linux-2.6.12-rc2 |
328 |
{ |
f70dba836 cciss: use consis... |
329 330 |
/* assumes h->scsi_ctlr->lock is held */ int n = ccissscsi[h->ctlr].ndevices; |
1da177e4c Linux-2.6.12-rc2 |
331 |
struct cciss_scsi_dev_t *sd; |
935dc8d75 cciss: add suppor... |
332 333 |
int i, bus, target, lun; unsigned char addr1[8], addr2[8]; |
1da177e4c Linux-2.6.12-rc2 |
334 335 |
if (n >= CCISS_MAX_SCSI_DEVS_PER_HBA) { |
b2a4a43db cciss: change pri... |
336 337 338 |
dev_warn(&h->pdev->dev, "Too many devices, " "some will be inaccessible. "); |
1da177e4c Linux-2.6.12-rc2 |
339 340 |
return -1; } |
f4a93bcda cciss: change the... |
341 |
|
935dc8d75 cciss: add suppor... |
342 343 344 345 |
bus = target = -1; lun = 0; /* Is this device a non-zero lun of a multi-lun device */ /* byte 4 of the 8-byte LUN addr will contain the logical unit no. */ |
905bd78f2 cciss: Fix cciss ... |
346 |
if (device->scsi3addr[4] != 0) { |
935dc8d75 cciss: add suppor... |
347 348 349 350 |
/* Search through our list and find the device which */ /* has the same 8 byte LUN address, excepting byte 4. */ /* Assign the same bus and target for this new LUN. */ /* Use the logical unit number from the firmware. */ |
905bd78f2 cciss: Fix cciss ... |
351 |
memcpy(addr1, device->scsi3addr, 8); |
935dc8d75 cciss: add suppor... |
352 353 |
addr1[4] = 0; for (i = 0; i < n; i++) { |
f70dba836 cciss: use consis... |
354 |
sd = &ccissscsi[h->ctlr].dev[i]; |
935dc8d75 cciss: add suppor... |
355 356 357 358 359 360 |
memcpy(addr2, sd->scsi3addr, 8); addr2[4] = 0; /* differ only in byte 4? */ if (memcmp(addr1, addr2, 8) == 0) { bus = sd->bus; target = sd->target; |
905bd78f2 cciss: Fix cciss ... |
361 |
lun = device->scsi3addr[4]; |
935dc8d75 cciss: add suppor... |
362 363 364 365 |
break; } } } |
f70dba836 cciss: use consis... |
366 |
sd = &ccissscsi[h->ctlr].dev[n]; |
935dc8d75 cciss: add suppor... |
367 |
if (lun == 0) { |
f70dba836 cciss: use consis... |
368 |
if (find_bus_target_lun(h, |
935dc8d75 cciss: add suppor... |
369 370 371 372 373 374 375 |
&sd->bus, &sd->target, &sd->lun) != 0) return -1; } else { sd->bus = bus; sd->target = target; sd->lun = lun; } |
f4a93bcda cciss: change the... |
376 377 378 379 |
added[*nadded].bus = sd->bus; added[*nadded].target = sd->target; added[*nadded].lun = sd->lun; (*nadded)++; |
905bd78f2 cciss: Fix cciss ... |
380 381 382 383 384 |
memcpy(sd->scsi3addr, device->scsi3addr, 8); memcpy(sd->vendor, device->vendor, sizeof(sd->vendor)); memcpy(sd->revision, device->revision, sizeof(sd->revision)); memcpy(sd->device_id, device->device_id, sizeof(sd->device_id)); sd->devtype = device->devtype; |
f70dba836 cciss: use consis... |
385 |
ccissscsi[h->ctlr].ndevices++; |
1da177e4c Linux-2.6.12-rc2 |
386 |
|
f08896384 cciss: Fix checkp... |
387 388 |
/* initially, (before registering with scsi layer) we don't know our hostno and we don't want to print anything first |
1da177e4c Linux-2.6.12-rc2 |
389 390 |
time anyway (the scsi layer's inquiries will show that info) */ if (hostno != -1) |
b2a4a43db cciss: change pri... |
391 392 393 |
dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d added. ", scsi_device_type(sd->devtype), hostno, |
1da177e4c Linux-2.6.12-rc2 |
394 395 396 397 398 |
sd->bus, sd->target, sd->lun); return 0; } static void |
f70dba836 cciss: use consis... |
399 |
cciss_scsi_remove_entry(ctlr_info_t *h, int hostno, int entry, |
f4a93bcda cciss: change the... |
400 |
struct scsi2map *removed, int *nremoved) |
1da177e4c Linux-2.6.12-rc2 |
401 |
{ |
f70dba836 cciss: use consis... |
402 |
/* assumes h->ctlr]->scsi_ctlr->lock is held */ |
1da177e4c Linux-2.6.12-rc2 |
403 404 405 406 |
int i; struct cciss_scsi_dev_t sd; if (entry < 0 || entry >= CCISS_MAX_SCSI_DEVS_PER_HBA) return; |
f70dba836 cciss: use consis... |
407 |
sd = ccissscsi[h->ctlr].dev[entry]; |
f4a93bcda cciss: change the... |
408 409 410 411 |
removed[*nremoved].bus = sd.bus; removed[*nremoved].target = sd.target; removed[*nremoved].lun = sd.lun; (*nremoved)++; |
f70dba836 cciss: use consis... |
412 413 414 |
for (i = entry; i < ccissscsi[h->ctlr].ndevices-1; i++) ccissscsi[h->ctlr].dev[i] = ccissscsi[h->ctlr].dev[i+1]; ccissscsi[h->ctlr].ndevices--; |
b2a4a43db cciss: change pri... |
415 416 417 |
dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d removed. ", scsi_device_type(sd.devtype), hostno, |
1da177e4c Linux-2.6.12-rc2 |
418 419 420 421 422 423 424 425 426 427 428 429 430 |
sd.bus, sd.target, sd.lun); } #define SCSI3ADDR_EQ(a,b) ( \ (a)[7] == (b)[7] && \ (a)[6] == (b)[6] && \ (a)[5] == (b)[5] && \ (a)[4] == (b)[4] && \ (a)[3] == (b)[3] && \ (a)[2] == (b)[2] && \ (a)[1] == (b)[1] && \ (a)[0] == (b)[0]) |
f70dba836 cciss: use consis... |
431 |
static void fixup_botched_add(ctlr_info_t *h, char *scsi3addr) |
f4a93bcda cciss: change the... |
432 433 434 435 436 |
{ /* called when scsi_add_device fails in order to re-adjust */ /* ccissscsi[] to match the mid layer's view. */ unsigned long flags; int i, j; |
f70dba836 cciss: use consis... |
437 438 |
CPQ_TAPE_LOCK(h, flags); for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) { |
f4a93bcda cciss: change the... |
439 |
if (memcmp(scsi3addr, |
f70dba836 cciss: use consis... |
440 441 442 443 444 |
ccissscsi[h->ctlr].dev[i].scsi3addr, 8) == 0) { for (j = i; j < ccissscsi[h->ctlr].ndevices-1; j++) ccissscsi[h->ctlr].dev[j] = ccissscsi[h->ctlr].dev[j+1]; ccissscsi[h->ctlr].ndevices--; |
f4a93bcda cciss: change the... |
445 446 447 |
break; } } |
f70dba836 cciss: use consis... |
448 |
CPQ_TAPE_UNLOCK(h, flags); |
f4a93bcda cciss: change the... |
449 |
} |
905bd78f2 cciss: Fix cciss ... |
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
static int device_is_the_same(struct cciss_scsi_dev_t *dev1, struct cciss_scsi_dev_t *dev2) { return dev1->devtype == dev2->devtype && memcmp(dev1->scsi3addr, dev2->scsi3addr, sizeof(dev1->scsi3addr)) == 0 && memcmp(dev1->device_id, dev2->device_id, sizeof(dev1->device_id)) == 0 && memcmp(dev1->vendor, dev2->vendor, sizeof(dev1->vendor)) == 0 && memcmp(dev1->model, dev2->model, sizeof(dev1->model)) == 0 && memcmp(dev1->revision, dev2->revision, sizeof(dev1->revision)) == 0; } |
1da177e4c Linux-2.6.12-rc2 |
465 |
static int |
f70dba836 cciss: use consis... |
466 |
adjust_cciss_scsi_table(ctlr_info_t *h, int hostno, |
1da177e4c Linux-2.6.12-rc2 |
467 468 469 470 471 |
struct cciss_scsi_dev_t sd[], int nsds) { /* sd contains scsi3 addresses and devtypes, but bus target and lun are not filled in. This funciton takes what's in sd to be the current and adjusts |
f08896384 cciss: Fix checkp... |
472 |
ccissscsi[] to be in line with what's in sd. */ |
1da177e4c Linux-2.6.12-rc2 |
473 474 475 476 |
int i,j, found, changes=0; struct cciss_scsi_dev_t *csd; unsigned long flags; |
f4a93bcda cciss: change the... |
477 478 479 480 481 482 483 484 485 486 |
struct scsi2map *added, *removed; int nadded, nremoved; struct Scsi_Host *sh = NULL; added = kzalloc(sizeof(*added) * CCISS_MAX_SCSI_DEVS_PER_HBA, GFP_KERNEL); removed = kzalloc(sizeof(*removed) * CCISS_MAX_SCSI_DEVS_PER_HBA, GFP_KERNEL); if (!added || !removed) { |
b2a4a43db cciss: change pri... |
487 488 489 |
dev_warn(&h->pdev->dev, "Out of memory in adjust_cciss_scsi_table "); |
f4a93bcda cciss: change the... |
490 491 |
goto free_and_out; } |
1da177e4c Linux-2.6.12-rc2 |
492 |
|
f70dba836 cciss: use consis... |
493 |
CPQ_TAPE_LOCK(h, flags); |
1da177e4c Linux-2.6.12-rc2 |
494 |
|
f4a93bcda cciss: change the... |
495 |
if (hostno != -1) /* if it's not the first time... */ |
f70dba836 cciss: use consis... |
496 |
sh = h->scsi_ctlr->scsi_host; |
f4a93bcda cciss: change the... |
497 |
|
f08896384 cciss: Fix checkp... |
498 |
/* find any devices in ccissscsi[] that are not in |
1da177e4c Linux-2.6.12-rc2 |
499 500 501 |
sd[] and remove them from ccissscsi[] */ i = 0; |
f4a93bcda cciss: change the... |
502 503 |
nremoved = 0; nadded = 0; |
f70dba836 cciss: use consis... |
504 505 |
while (i < ccissscsi[h->ctlr].ndevices) { csd = &ccissscsi[h->ctlr].dev[i]; |
1da177e4c Linux-2.6.12-rc2 |
506 507 508 509 |
found=0; for (j=0;j<nsds;j++) { if (SCSI3ADDR_EQ(sd[j].scsi3addr, csd->scsi3addr)) { |
905bd78f2 cciss: Fix cciss ... |
510 |
if (device_is_the_same(&sd[j], csd)) |
1da177e4c Linux-2.6.12-rc2 |
511 512 513 514 515 516 |
found=2; else found=1; break; } } |
f08896384 cciss: Fix checkp... |
517 |
if (found == 0) { /* device no longer present. */ |
1da177e4c Linux-2.6.12-rc2 |
518 |
changes++; |
f70dba836 cciss: use consis... |
519 |
cciss_scsi_remove_entry(h, hostno, i, |
f4a93bcda cciss: change the... |
520 521 |
removed, &nremoved); /* remove ^^^, hence i not incremented */ |
905bd78f2 cciss: Fix cciss ... |
522 |
} else if (found == 1) { /* device is different in some way */ |
1da177e4c Linux-2.6.12-rc2 |
523 |
changes++; |
b2a4a43db cciss: change pri... |
524 525 526 527 |
dev_info(&h->pdev->dev, "device c%db%dt%dl%d has changed. ", hostno, csd->bus, csd->target, csd->lun); |
f70dba836 cciss: use consis... |
528 |
cciss_scsi_remove_entry(h, hostno, i, |
f4a93bcda cciss: change the... |
529 530 |
removed, &nremoved); /* remove ^^^, hence i not incremented */ |
f70dba836 cciss: use consis... |
531 |
if (cciss_scsi_add_entry(h, hostno, &sd[j], |
f4a93bcda cciss: change the... |
532 533 534 |
added, &nadded) != 0) /* we just removed one, so add can't fail. */ BUG(); |
1da177e4c Linux-2.6.12-rc2 |
535 |
csd->devtype = sd[j].devtype; |
905bd78f2 cciss: Fix cciss ... |
536 537 538 539 540 541 542 543 |
memcpy(csd->device_id, sd[j].device_id, sizeof(csd->device_id)); memcpy(csd->vendor, sd[j].vendor, sizeof(csd->vendor)); memcpy(csd->model, sd[j].model, sizeof(csd->model)); memcpy(csd->revision, sd[j].revision, sizeof(csd->revision)); |
1da177e4c Linux-2.6.12-rc2 |
544 545 546 547 548 549 550 551 552 |
} else /* device is same as it ever was, */ i++; /* so just move along. */ } /* Now, make sure every device listed in sd[] is also listed in ccissscsi[], adding them if they aren't found */ for (i=0;i<nsds;i++) { found=0; |
f70dba836 cciss: use consis... |
553 554 |
for (j = 0; j < ccissscsi[h->ctlr].ndevices; j++) { csd = &ccissscsi[h->ctlr].dev[j]; |
1da177e4c Linux-2.6.12-rc2 |
555 556 |
if (SCSI3ADDR_EQ(sd[i].scsi3addr, csd->scsi3addr)) { |
905bd78f2 cciss: Fix cciss ... |
557 |
if (device_is_the_same(&sd[i], csd)) |
1da177e4c Linux-2.6.12-rc2 |
558 559 560 561 562 563 564 565 |
found=2; /* found device */ else found=1; /* found a bug. */ break; } } if (!found) { changes++; |
f70dba836 cciss: use consis... |
566 |
if (cciss_scsi_add_entry(h, hostno, &sd[i], |
f4a93bcda cciss: change the... |
567 |
added, &nadded) != 0) |
1da177e4c Linux-2.6.12-rc2 |
568 569 570 571 |
break; } else if (found == 1) { /* should never happen... */ changes++; |
b2a4a43db cciss: change pri... |
572 573 574 |
dev_warn(&h->pdev->dev, "device unexpectedly changed "); |
1da177e4c Linux-2.6.12-rc2 |
575 576 577 |
/* but if it does happen, we just ignore that device */ } } |
f70dba836 cciss: use consis... |
578 |
CPQ_TAPE_UNLOCK(h, flags); |
1da177e4c Linux-2.6.12-rc2 |
579 |
|
f4a93bcda cciss: change the... |
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
/* Don't notify scsi mid layer of any changes the first time through */ /* (or if there are no changes) scsi_scan_host will do it later the */ /* first time through. */ if (hostno == -1 || !changes) goto free_and_out; /* Notify scsi mid layer of any removed devices */ for (i = 0; i < nremoved; i++) { struct scsi_device *sdev = scsi_device_lookup(sh, removed[i].bus, removed[i].target, removed[i].lun); if (sdev != NULL) { scsi_remove_device(sdev); scsi_device_put(sdev); } else { /* We don't expect to get here. */ /* future cmds to this device will get selection */ /* timeout as if the device was gone. */ |
b2a4a43db cciss: change pri... |
598 |
dev_warn(&h->pdev->dev, "didn't find " |
f4a93bcda cciss: change the... |
599 600 |
"c%db%dt%dl%d for removal.", |
b2a4a43db cciss: change pri... |
601 |
hostno, removed[i].bus, |
f4a93bcda cciss: change the... |
602 603 604 605 606 607 608 609 610 611 612 |
removed[i].target, removed[i].lun); } } /* Notify scsi mid layer of any added devices */ for (i = 0; i < nadded; i++) { int rc; rc = scsi_add_device(sh, added[i].bus, added[i].target, added[i].lun); if (rc == 0) continue; |
b2a4a43db cciss: change pri... |
613 |
dev_warn(&h->pdev->dev, "scsi_add_device " |
f4a93bcda cciss: change the... |
614 615 |
"c%db%dt%dl%d failed, device not added. ", |
b2a4a43db cciss: change pri... |
616 |
hostno, added[i].bus, added[i].target, added[i].lun); |
f4a93bcda cciss: change the... |
617 618 |
/* now we have to remove it from ccissscsi, */ /* since it didn't get added to scsi mid layer */ |
f70dba836 cciss: use consis... |
619 |
fixup_botched_add(h, added[i].scsi3addr); |
f4a93bcda cciss: change the... |
620 |
} |
1da177e4c Linux-2.6.12-rc2 |
621 |
|
f4a93bcda cciss: change the... |
622 623 624 |
free_and_out: kfree(added); kfree(removed); |
1da177e4c Linux-2.6.12-rc2 |
625 626 627 628 |
return 0; } static int |
f70dba836 cciss: use consis... |
629 |
lookup_scsi3addr(ctlr_info_t *h, int bus, int target, int lun, char *scsi3addr) |
1da177e4c Linux-2.6.12-rc2 |
630 631 632 633 |
{ int i; struct cciss_scsi_dev_t *sd; unsigned long flags; |
f70dba836 cciss: use consis... |
634 635 636 |
CPQ_TAPE_LOCK(h, flags); for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) { sd = &ccissscsi[h->ctlr].dev[i]; |
1da177e4c Linux-2.6.12-rc2 |
637 638 639 640 |
if (sd->bus == bus && sd->target == target && sd->lun == lun) { memcpy(scsi3addr, &sd->scsi3addr[0], 8); |
f70dba836 cciss: use consis... |
641 |
CPQ_TAPE_UNLOCK(h, flags); |
1da177e4c Linux-2.6.12-rc2 |
642 643 644 |
return 0; } } |
f70dba836 cciss: use consis... |
645 |
CPQ_TAPE_UNLOCK(h, flags); |
1da177e4c Linux-2.6.12-rc2 |
646 647 |
return -1; } |
f08896384 cciss: Fix checkp... |
648 |
static void |
f70dba836 cciss: use consis... |
649 |
cciss_scsi_setup(ctlr_info_t *h) |
1da177e4c Linux-2.6.12-rc2 |
650 651 |
{ struct cciss_scsi_adapter_data_t * shba; |
f70dba836 cciss: use consis... |
652 |
ccissscsi[h->ctlr].ndevices = 0; |
48efbfbf6 cciss: Remove kma... |
653 |
shba = kmalloc(sizeof(*shba), GFP_KERNEL); |
1da177e4c Linux-2.6.12-rc2 |
654 655 656 657 658 |
if (shba == NULL) return; shba->scsi_host = NULL; spin_lock_init(&shba->lock); shba->registered = 0; |
f70dba836 cciss: use consis... |
659 |
if (scsi_cmd_stack_setup(h, shba) != 0) { |
1da177e4c Linux-2.6.12-rc2 |
660 661 662 |
kfree(shba); shba = NULL; } |
f70dba836 cciss: use consis... |
663 |
h->scsi_ctlr = shba; |
1da177e4c Linux-2.6.12-rc2 |
664 665 |
return; } |
f70dba836 cciss: use consis... |
666 667 |
static void complete_scsi_command(CommandList_struct *c, int timeout, __u32 tag) |
1da177e4c Linux-2.6.12-rc2 |
668 669 |
{ struct scsi_cmnd *cmd; |
f70dba836 cciss: use consis... |
670 |
ctlr_info_t *h; |
1da177e4c Linux-2.6.12-rc2 |
671 |
ErrorInfo_struct *ei; |
f70dba836 cciss: use consis... |
672 |
ei = c->err_info; |
1da177e4c Linux-2.6.12-rc2 |
673 674 |
/* First, see if it was a message rather than a command */ |
f70dba836 cciss: use consis... |
675 676 |
if (c->Request.Type.Type == TYPE_MSG) { c->cmd_type = CMD_MSG_DONE; |
1da177e4c Linux-2.6.12-rc2 |
677 678 |
return; } |
f70dba836 cciss: use consis... |
679 680 |
cmd = (struct scsi_cmnd *) c->scsi_cmd; h = hba[c->ctlr]; |
1da177e4c Linux-2.6.12-rc2 |
681 |
|
41ce639a1 [SCSI] cciss: con... |
682 |
scsi_dma_unmap(cmd); |
f70dba836 cciss: use consis... |
683 684 |
if (c->Header.SGTotal > h->max_cmd_sgentries) cciss_unmap_sg_chain_block(h, c); |
1da177e4c Linux-2.6.12-rc2 |
685 686 687 688 689 690 691 692 693 694 |
cmd->result = (DID_OK << 16); /* host byte */ cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */ /* cmd->result |= (GOOD < 1); */ /* status byte */ cmd->result |= (ei->ScsiStatus); /* printk("Scsistatus is 0x%02x ", ei->ScsiStatus); */ /* copy the sense data whether we need to or not. */ |
f08896384 cciss: Fix checkp... |
695 |
memcpy(cmd->sense_buffer, ei->SenseInfo, |
1da177e4c Linux-2.6.12-rc2 |
696 |
ei->SenseLen > SCSI_SENSE_BUFFERSIZE ? |
f08896384 cciss: Fix checkp... |
697 |
SCSI_SENSE_BUFFERSIZE : |
1da177e4c Linux-2.6.12-rc2 |
698 |
ei->SenseLen); |
41ce639a1 [SCSI] cciss: con... |
699 |
scsi_set_resid(cmd, ei->ResidualCnt); |
1da177e4c Linux-2.6.12-rc2 |
700 |
|
19a5e10c3 cciss: Fix checkp... |
701 702 |
if (ei->CommandStatus != 0) { /* an error has occurred */ switch (ei->CommandStatus) { |
1da177e4c Linux-2.6.12-rc2 |
703 704 |
case CMD_TARGET_STATUS: /* Pass it up to the upper layers... */ |
b0cf0b118 cciss: fix incorr... |
705 |
if (!ei->ScsiStatus) { |
f08896384 cciss: Fix checkp... |
706 |
|
1da177e4c Linux-2.6.12-rc2 |
707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
/* Ordinarily, this case should never happen, but there is a bug in some released firmware revisions that allows it to happen if, for example, a 4100 backplane loses power and the tape drive is in it. We assume that it's a fatal error of some kind because we can't show that it wasn't. We will make it look like selection timeout since that is the most common reason for this to occur, and it's severe enough. */ cmd->result = DID_NO_CONNECT << 16; } break; case CMD_DATA_UNDERRUN: /* let mid layer handle it. */ break; case CMD_DATA_OVERRUN: |
b2a4a43db cciss: change pri... |
721 |
dev_warn(&h->pdev->dev, "%p has" |
1da177e4c Linux-2.6.12-rc2 |
722 |
" completed with data overrun " |
f70dba836 cciss: use consis... |
723 724 |
"reported ", c); |
1da177e4c Linux-2.6.12-rc2 |
725 726 |
break; case CMD_INVALID: { |
8d9c1f86a scsi: cciss: repl... |
727 728 729 730 |
/* print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, c, sizeof(*c), false); print_cmd(c); */ |
1da177e4c Linux-2.6.12-rc2 |
731 |
/* We get CMD_INVALID if you address a non-existent tape drive instead |
f08896384 cciss: Fix checkp... |
732 |
of a selection timeout (no response). You will see this if you yank |
1da177e4c Linux-2.6.12-rc2 |
733 734 735 736 737 738 739 |
out a tape drive, then try to access it. This is kind of a shame because it means that any other CMD_INVALID (e.g. driver bug) will get interpreted as a missing target. */ cmd->result = DID_NO_CONNECT << 16; } break; case CMD_PROTOCOL_ERR: |
2453f5f99 cciss: fix handli... |
740 |
cmd->result = DID_ERROR << 16; |
b2a4a43db cciss: change pri... |
741 742 743 |
dev_warn(&h->pdev->dev, "%p has protocol error ", c); |
1da177e4c Linux-2.6.12-rc2 |
744 745 746 |
break; case CMD_HARDWARE_ERR: cmd->result = DID_ERROR << 16; |
b2a4a43db cciss: change pri... |
747 748 749 |
dev_warn(&h->pdev->dev, "%p had hardware error ", c); |
1da177e4c Linux-2.6.12-rc2 |
750 751 752 |
break; case CMD_CONNECTION_LOST: cmd->result = DID_ERROR << 16; |
b2a4a43db cciss: change pri... |
753 754 755 |
dev_warn(&h->pdev->dev, "%p had connection lost ", c); |
1da177e4c Linux-2.6.12-rc2 |
756 757 758 |
break; case CMD_ABORTED: cmd->result = DID_ABORT << 16; |
b2a4a43db cciss: change pri... |
759 760 |
dev_warn(&h->pdev->dev, "%p was aborted ", c); |
1da177e4c Linux-2.6.12-rc2 |
761 762 763 |
break; case CMD_ABORT_FAILED: cmd->result = DID_ERROR << 16; |
b2a4a43db cciss: change pri... |
764 765 766 |
dev_warn(&h->pdev->dev, "%p reports abort failed ", c); |
1da177e4c Linux-2.6.12-rc2 |
767 768 769 |
break; case CMD_UNSOLICITED_ABORT: cmd->result = DID_ABORT << 16; |
6d9a4f9e2 cciss: fix missed... |
770 |
dev_warn(&h->pdev->dev, "%p aborted due to an " |
b2a4a43db cciss: change pri... |
771 772 |
"unsolicited abort ", c); |
1da177e4c Linux-2.6.12-rc2 |
773 774 775 |
break; case CMD_TIMEOUT: cmd->result = DID_TIME_OUT << 16; |
b2a4a43db cciss: change pri... |
776 777 |
dev_warn(&h->pdev->dev, "%p timedout ", c); |
1da177e4c Linux-2.6.12-rc2 |
778 |
break; |
6d9a4f9e2 cciss: fix missed... |
779 780 781 782 783 784 |
case CMD_UNABORTABLE: cmd->result = DID_ERROR << 16; dev_warn(&h->pdev->dev, "c %p command " "unabortable ", c); break; |
1da177e4c Linux-2.6.12-rc2 |
785 786 |
default: cmd->result = DID_ERROR << 16; |
b2a4a43db cciss: change pri... |
787 788 789 |
dev_warn(&h->pdev->dev, "%p returned unknown status %x ", c, |
f08896384 cciss: Fix checkp... |
790 |
ei->CommandStatus); |
1da177e4c Linux-2.6.12-rc2 |
791 792 |
} } |
1da177e4c Linux-2.6.12-rc2 |
793 |
cmd->scsi_done(cmd); |
f70dba836 cciss: use consis... |
794 |
scsi_cmd_free(h, c); |
1da177e4c Linux-2.6.12-rc2 |
795 796 797 |
} static int |
f70dba836 cciss: use consis... |
798 |
cciss_scsi_detect(ctlr_info_t *h) |
1da177e4c Linux-2.6.12-rc2 |
799 800 801 802 803 804 805 |
{ struct Scsi_Host *sh; int error; sh = scsi_host_alloc(&cciss_driver_template, sizeof(struct ctlr_info *)); if (sh == NULL) goto fail; |
f08896384 cciss: Fix checkp... |
806 |
sh->io_port = 0; // good enough? FIXME, |
1da177e4c Linux-2.6.12-rc2 |
807 |
sh->n_io_port = 0; // I don't think we use these two... |
f08896384 cciss: Fix checkp... |
808 |
sh->this_id = SELF_SCSI_ID; |
8a4ec67bd cciss: add cciss_... |
809 |
sh->can_queue = cciss_tape_cmds; |
f70dba836 cciss: use consis... |
810 |
sh->sg_tablesize = h->maxsgentries; |
79600aadc cciss: set SCSI m... |
811 |
sh->max_cmd_len = MAX_COMMAND_SIZE; |
395d28752 cciss: Initialize... |
812 |
sh->max_sectors = h->cciss_max_sectors; |
1da177e4c Linux-2.6.12-rc2 |
813 |
|
f08896384 cciss: Fix checkp... |
814 |
((struct cciss_scsi_adapter_data_t *) |
f70dba836 cciss: use consis... |
815 816 817 |
h->scsi_ctlr)->scsi_host = sh; sh->hostdata[0] = (unsigned long) h; sh->irq = h->intr[SIMPLE_MODE_INT]; |
1da177e4c Linux-2.6.12-rc2 |
818 |
sh->unique_id = sh->irq; |
f70dba836 cciss: use consis... |
819 |
error = scsi_add_host(sh, &h->pdev->dev); |
1da177e4c Linux-2.6.12-rc2 |
820 821 822 823 824 825 826 827 828 829 830 831 832 |
if (error) goto fail_host_put; scsi_scan_host(sh); return 1; fail_host_put: scsi_host_put(sh); fail: return 0; } static void cciss_unmap_one(struct pci_dev *pdev, |
f70dba836 cciss: use consis... |
833 |
CommandList_struct *c, |
1da177e4c Linux-2.6.12-rc2 |
834 835 836 837 |
size_t buflen, int data_direction) { u64bit addr64; |
f70dba836 cciss: use consis... |
838 839 |
addr64.val32.lower = c->SG[0].Addr.lower; addr64.val32.upper = c->SG[0].Addr.upper; |
1da177e4c Linux-2.6.12-rc2 |
840 841 842 843 844 |
pci_unmap_single(pdev, (dma_addr_t) addr64.val, buflen, data_direction); } static void cciss_map_one(struct pci_dev *pdev, |
f70dba836 cciss: use consis... |
845 |
CommandList_struct *c, |
1da177e4c Linux-2.6.12-rc2 |
846 847 848 849 850 851 852 |
unsigned char *buf, size_t buflen, int data_direction) { __u64 addr64; addr64 = (__u64) pci_map_single(pdev, buf, buflen, data_direction); |
f70dba836 cciss: use consis... |
853 |
c->SG[0].Addr.lower = |
1da177e4c Linux-2.6.12-rc2 |
854 |
(__u32) (addr64 & (__u64) 0x00000000FFFFFFFF); |
f70dba836 cciss: use consis... |
855 |
c->SG[0].Addr.upper = |
1da177e4c Linux-2.6.12-rc2 |
856 |
(__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF); |
f70dba836 cciss: use consis... |
857 858 859 |
c->SG[0].Len = buflen; c->Header.SGList = (__u8) 1; /* no. SGs contig in this cmd */ c->Header.SGTotal = (__u16) 1; /* total sgs in this cmd list */ |
1da177e4c Linux-2.6.12-rc2 |
860 861 862 |
} static int |
f70dba836 cciss: use consis... |
863 864 |
cciss_scsi_do_simple_cmd(ctlr_info_t *h, CommandList_struct *c, |
f08896384 cciss: Fix checkp... |
865 |
unsigned char *scsi3addr, |
1da177e4c Linux-2.6.12-rc2 |
866 867 868 869 870 |
unsigned char *cdb, unsigned char cdblen, unsigned char *buf, int bufsize, int direction) { |
6e9a4738c [PATCH] completio... |
871 |
DECLARE_COMPLETION_ONSTACK(wait); |
1da177e4c Linux-2.6.12-rc2 |
872 |
|
f70dba836 cciss: use consis... |
873 874 875 876 877 |
c->cmd_type = CMD_IOCTL_PEND; /* treat this like an ioctl */ c->scsi_cmd = NULL; c->Header.ReplyQueue = 0; /* unused in simple mode */ memcpy(&c->Header.LUN, scsi3addr, sizeof(c->Header.LUN)); c->Header.Tag.lower = c->busaddr; /* Use k. address of cmd as tag */ |
1da177e4c Linux-2.6.12-rc2 |
878 |
// Fill in the request block... |
f08896384 cciss: Fix checkp... |
879 880 |
/* printk("Using scsi3addr 0x%02x%0x2%0x2%0x2%0x2%0x2%0x2%0x2 ", |
1da177e4c Linux-2.6.12-rc2 |
881 882 |
scsi3addr[0], scsi3addr[1], scsi3addr[2], scsi3addr[3], scsi3addr[4], scsi3addr[5], scsi3addr[6], scsi3addr[7]); */ |
f70dba836 cciss: use consis... |
883 884 885 886 887 888 889 |
memset(c->Request.CDB, 0, sizeof(c->Request.CDB)); memcpy(c->Request.CDB, cdb, cdblen); c->Request.Timeout = 0; c->Request.CDBLen = cdblen; c->Request.Type.Type = TYPE_CMD; c->Request.Type.Attribute = ATTR_SIMPLE; c->Request.Type.Direction = direction; |
1da177e4c Linux-2.6.12-rc2 |
890 891 |
/* Fill in the SG list and do dma mapping */ |
f70dba836 cciss: use consis... |
892 |
cciss_map_one(h->pdev, c, (unsigned char *) buf, |
f08896384 cciss: Fix checkp... |
893 |
bufsize, DMA_FROM_DEVICE); |
1da177e4c Linux-2.6.12-rc2 |
894 |
|
f70dba836 cciss: use consis... |
895 896 |
c->waiting = &wait; enqueue_cmd_and_start_io(h, c); |
1da177e4c Linux-2.6.12-rc2 |
897 898 899 |
wait_for_completion(&wait); /* undo the dma mapping */ |
f70dba836 cciss: use consis... |
900 |
cciss_unmap_one(h->pdev, c, bufsize, DMA_FROM_DEVICE); |
1da177e4c Linux-2.6.12-rc2 |
901 902 |
return(0); } |
f08896384 cciss: Fix checkp... |
903 |
static void |
b2a4a43db cciss: change pri... |
904 |
cciss_scsi_interpret_error(ctlr_info_t *h, CommandList_struct *c) |
1da177e4c Linux-2.6.12-rc2 |
905 906 |
{ ErrorInfo_struct *ei; |
f70dba836 cciss: use consis... |
907 |
ei = c->err_info; |
19a5e10c3 cciss: Fix checkp... |
908 |
switch (ei->CommandStatus) { |
1da177e4c Linux-2.6.12-rc2 |
909 |
case CMD_TARGET_STATUS: |
b2a4a43db cciss: change pri... |
910 911 912 913 914 915 916 |
dev_warn(&h->pdev->dev, "cmd %p has completed with errors ", c); dev_warn(&h->pdev->dev, "cmd %p has SCSI Status = %x ", c, ei->ScsiStatus); |
1da177e4c Linux-2.6.12-rc2 |
917 |
if (ei->ScsiStatus == 0) |
b2a4a43db cciss: change pri... |
918 919 |
dev_warn(&h->pdev->dev, "SCSI status is abnormally zero. " |
1da177e4c Linux-2.6.12-rc2 |
920 921 922 923 924 925 |
"(probably indicates selection timeout " "reported incorrectly due to a known " "firmware bug, circa July, 2001.) "); break; case CMD_DATA_UNDERRUN: /* let mid layer handle it. */ |
b2a4a43db cciss: change pri... |
926 927 |
dev_info(&h->pdev->dev, "UNDERRUN "); |
1da177e4c Linux-2.6.12-rc2 |
928 929 |
break; case CMD_DATA_OVERRUN: |
b2a4a43db cciss: change pri... |
930 |
dev_warn(&h->pdev->dev, "%p has" |
1da177e4c Linux-2.6.12-rc2 |
931 |
" completed with data overrun " |
f70dba836 cciss: use consis... |
932 933 |
"reported ", c); |
1da177e4c Linux-2.6.12-rc2 |
934 935 936 937 |
break; case CMD_INVALID: { /* controller unfortunately reports SCSI passthru's */ /* to non-existent targets as invalid commands. */ |
b2a4a43db cciss: change pri... |
938 939 |
dev_warn(&h->pdev->dev, "%p is reported invalid (probably means " |
f70dba836 cciss: use consis... |
940 941 |
"target device no longer present) ", c); |
8d9c1f86a scsi: cciss: repl... |
942 943 944 945 |
/* print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, c, sizeof(*c), false); print_cmd(c); */ |
1da177e4c Linux-2.6.12-rc2 |
946 947 948 |
} break; case CMD_PROTOCOL_ERR: |
b2a4a43db cciss: change pri... |
949 950 |
dev_warn(&h->pdev->dev, "%p has protocol error ", c); |
1da177e4c Linux-2.6.12-rc2 |
951 952 953 |
break; case CMD_HARDWARE_ERR: /* cmd->result = DID_ERROR << 16; */ |
b2a4a43db cciss: change pri... |
954 955 |
dev_warn(&h->pdev->dev, "%p had hardware error ", c); |
1da177e4c Linux-2.6.12-rc2 |
956 957 |
break; case CMD_CONNECTION_LOST: |
b2a4a43db cciss: change pri... |
958 959 |
dev_warn(&h->pdev->dev, "%p had connection lost ", c); |
1da177e4c Linux-2.6.12-rc2 |
960 961 |
break; case CMD_ABORTED: |
b2a4a43db cciss: change pri... |
962 963 |
dev_warn(&h->pdev->dev, "%p was aborted ", c); |
1da177e4c Linux-2.6.12-rc2 |
964 965 |
break; case CMD_ABORT_FAILED: |
b2a4a43db cciss: change pri... |
966 967 968 |
dev_warn(&h->pdev->dev, "%p reports abort failed ", c); |
1da177e4c Linux-2.6.12-rc2 |
969 970 |
break; case CMD_UNSOLICITED_ABORT: |
b2a4a43db cciss: change pri... |
971 |
dev_warn(&h->pdev->dev, |
6d9a4f9e2 cciss: fix missed... |
972 973 |
"%p aborted due to an unsolicited abort ", c); |
1da177e4c Linux-2.6.12-rc2 |
974 975 |
break; case CMD_TIMEOUT: |
b2a4a43db cciss: change pri... |
976 977 |
dev_warn(&h->pdev->dev, "%p timedout ", c); |
1da177e4c Linux-2.6.12-rc2 |
978 |
break; |
6d9a4f9e2 cciss: fix missed... |
979 980 981 982 983 |
case CMD_UNABORTABLE: dev_warn(&h->pdev->dev, "%p unabortable ", c); break; |
1da177e4c Linux-2.6.12-rc2 |
984 |
default: |
b2a4a43db cciss: change pri... |
985 986 987 988 |
dev_warn(&h->pdev->dev, "%p returned unknown status %x ", c, ei->CommandStatus); |
1da177e4c Linux-2.6.12-rc2 |
989 990 991 992 |
} } static int |
f70dba836 cciss: use consis... |
993 |
cciss_scsi_do_inquiry(ctlr_info_t *h, unsigned char *scsi3addr, |
905bd78f2 cciss: Fix cciss ... |
994 995 |
unsigned char page, unsigned char *buf, unsigned char bufsize) |
1da177e4c Linux-2.6.12-rc2 |
996 997 |
{ int rc; |
f70dba836 cciss: use consis... |
998 |
CommandList_struct *c; |
1da177e4c Linux-2.6.12-rc2 |
999 1000 1001 |
char cdb[6]; ErrorInfo_struct *ei; unsigned long flags; |
f70dba836 cciss: use consis... |
1002 1003 1004 |
spin_lock_irqsave(&h->lock, flags); c = scsi_cmd_alloc(h); spin_unlock_irqrestore(&h->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1005 |
|
f70dba836 cciss: use consis... |
1006 |
if (c == NULL) { /* trouble... */ |
1da177e4c Linux-2.6.12-rc2 |
1007 1008 1009 1010 |
printk("cmd_alloc returned NULL! "); return -1; } |
f70dba836 cciss: use consis... |
1011 |
ei = c->err_info; |
1da177e4c Linux-2.6.12-rc2 |
1012 1013 |
cdb[0] = CISS_INQUIRY; |
905bd78f2 cciss: Fix cciss ... |
1014 1015 |
cdb[1] = (page != 0); cdb[2] = page; |
1da177e4c Linux-2.6.12-rc2 |
1016 |
cdb[3] = 0; |
47922d068 [PATCH] cciss: On... |
1017 |
cdb[4] = bufsize; |
1da177e4c Linux-2.6.12-rc2 |
1018 |
cdb[5] = 0; |
f70dba836 cciss: use consis... |
1019 |
rc = cciss_scsi_do_simple_cmd(h, c, scsi3addr, cdb, |
47922d068 [PATCH] cciss: On... |
1020 |
6, buf, bufsize, XFER_READ); |
1da177e4c Linux-2.6.12-rc2 |
1021 1022 |
if (rc != 0) return rc; /* something went wrong */ |
f08896384 cciss: Fix checkp... |
1023 |
if (ei->CommandStatus != 0 && |
1da177e4c Linux-2.6.12-rc2 |
1024 |
ei->CommandStatus != CMD_DATA_UNDERRUN) { |
b2a4a43db cciss: change pri... |
1025 |
cciss_scsi_interpret_error(h, c); |
1da177e4c Linux-2.6.12-rc2 |
1026 1027 |
rc = -1; } |
f70dba836 cciss: use consis... |
1028 1029 1030 |
spin_lock_irqsave(&h->lock, flags); scsi_cmd_free(h, c); spin_unlock_irqrestore(&h->lock, flags); |
f08896384 cciss: Fix checkp... |
1031 |
return rc; |
1da177e4c Linux-2.6.12-rc2 |
1032 |
} |
905bd78f2 cciss: Fix cciss ... |
1033 |
/* Get the device id from inquiry page 0x83 */ |
f70dba836 cciss: use consis... |
1034 |
static int cciss_scsi_get_device_id(ctlr_info_t *h, unsigned char *scsi3addr, |
905bd78f2 cciss: Fix cciss ... |
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
unsigned char *device_id, int buflen) { int rc; unsigned char *buf; if (buflen > 16) buflen = 16; buf = kzalloc(64, GFP_KERNEL); if (!buf) return -1; |
f70dba836 cciss: use consis... |
1045 |
rc = cciss_scsi_do_inquiry(h, scsi3addr, 0x83, buf, 64); |
905bd78f2 cciss: Fix cciss ... |
1046 1047 1048 1049 1050 |
if (rc == 0) memcpy(device_id, &buf[8], buflen); kfree(buf); return rc != 0; } |
1da177e4c Linux-2.6.12-rc2 |
1051 |
static int |
f70dba836 cciss: use consis... |
1052 |
cciss_scsi_do_report_phys_luns(ctlr_info_t *h, |
1da177e4c Linux-2.6.12-rc2 |
1053 1054 1055 |
ReportLunData_struct *buf, int bufsize) { int rc; |
f70dba836 cciss: use consis... |
1056 |
CommandList_struct *c; |
1da177e4c Linux-2.6.12-rc2 |
1057 |
unsigned char cdb[12]; |
f08896384 cciss: Fix checkp... |
1058 |
unsigned char scsi3addr[8]; |
1da177e4c Linux-2.6.12-rc2 |
1059 1060 |
ErrorInfo_struct *ei; unsigned long flags; |
f70dba836 cciss: use consis... |
1061 1062 1063 1064 |
spin_lock_irqsave(&h->lock, flags); c = scsi_cmd_alloc(h); spin_unlock_irqrestore(&h->lock, flags); if (c == NULL) { /* trouble... */ |
1da177e4c Linux-2.6.12-rc2 |
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
printk("cmd_alloc returned NULL! "); return -1; } memset(&scsi3addr[0], 0, 8); /* address the controller */ cdb[0] = CISS_REPORT_PHYS; cdb[1] = 0; cdb[2] = 0; cdb[3] = 0; cdb[4] = 0; cdb[5] = 0; cdb[6] = (bufsize >> 24) & 0xFF; //MSB cdb[7] = (bufsize >> 16) & 0xFF; cdb[8] = (bufsize >> 8) & 0xFF; cdb[9] = bufsize & 0xFF; cdb[10] = 0; cdb[11] = 0; |
f70dba836 cciss: use consis... |
1083 |
rc = cciss_scsi_do_simple_cmd(h, c, scsi3addr, |
f08896384 cciss: Fix checkp... |
1084 1085 |
cdb, 12, (unsigned char *) buf, |
1da177e4c Linux-2.6.12-rc2 |
1086 1087 1088 |
bufsize, XFER_READ); if (rc != 0) return rc; /* something went wrong */ |
f70dba836 cciss: use consis... |
1089 |
ei = c->err_info; |
f08896384 cciss: Fix checkp... |
1090 |
if (ei->CommandStatus != 0 && |
1da177e4c Linux-2.6.12-rc2 |
1091 |
ei->CommandStatus != CMD_DATA_UNDERRUN) { |
b2a4a43db cciss: change pri... |
1092 |
cciss_scsi_interpret_error(h, c); |
1da177e4c Linux-2.6.12-rc2 |
1093 1094 |
rc = -1; } |
f70dba836 cciss: use consis... |
1095 1096 1097 |
spin_lock_irqsave(&h->lock, flags); scsi_cmd_free(h, c); spin_unlock_irqrestore(&h->lock, flags); |
f08896384 cciss: Fix checkp... |
1098 |
return rc; |
1da177e4c Linux-2.6.12-rc2 |
1099 1100 1101 |
} static void |
f70dba836 cciss: use consis... |
1102 |
cciss_update_non_disk_devices(ctlr_info_t *h, int hostno) |
1da177e4c Linux-2.6.12-rc2 |
1103 1104 |
{ /* the idea here is we could get notified from /proc |
f08896384 cciss: Fix checkp... |
1105 1106 |
that some devices have changed, so we do a report physical luns cmd, and adjust our list of devices |
1da177e4c Linux-2.6.12-rc2 |
1107 |
accordingly. (We can't rely on the scsi-mid layer just |
f08896384 cciss: Fix checkp... |
1108 |
doing inquiries, because the "busses" that the scsi |
1da177e4c Linux-2.6.12-rc2 |
1109 1110 |
mid-layer probes are totally fabricated by this driver, so new devices wouldn't show up. |
f08896384 cciss: Fix checkp... |
1111 1112 1113 |
the scsi3addr's of devices won't change so long as the adapter is not reset. That means we can rescan and tell which devices we already know about, vs. new |
1da177e4c Linux-2.6.12-rc2 |
1114 1115 1116 |
devices, vs. disappearing devices. Also, if you yank out a tape drive, then put in a disk |
f08896384 cciss: Fix checkp... |
1117 1118 1119 1120 |
in it's place, (say, a configured volume from another array controller for instance) _don't_ poke this driver (so it thinks it's still a tape, but _do_ poke the scsi mid layer, so it does an inquiry... the scsi mid layer |
1da177e4c Linux-2.6.12-rc2 |
1121 |
will see the physical disk. This would be bad. Need to |
f08896384 cciss: Fix checkp... |
1122 |
think about how to prevent that. One idea would be to |
1da177e4c Linux-2.6.12-rc2 |
1123 1124 1125 |
snoop all scsi responses and if an inquiry repsonse comes back that reports a disk, chuck it an return selection timeout instead and adjust our table... Not sure i like |
f08896384 cciss: Fix checkp... |
1126 |
that though. |
1da177e4c Linux-2.6.12-rc2 |
1127 1128 |
*/ |
47922d068 [PATCH] cciss: On... |
1129 1130 |
#define OBDR_TAPE_INQ_SIZE 49 #define OBDR_TAPE_SIG "$DR-10" |
1da177e4c Linux-2.6.12-rc2 |
1131 |
ReportLunData_struct *ld_buff; |
47922d068 [PATCH] cciss: On... |
1132 |
unsigned char *inq_buff; |
1da177e4c Linux-2.6.12-rc2 |
1133 |
unsigned char scsi3addr[8]; |
1da177e4c Linux-2.6.12-rc2 |
1134 1135 |
__u32 num_luns=0; unsigned char *ch; |
905bd78f2 cciss: Fix cciss ... |
1136 |
struct cciss_scsi_dev_t *currentsd, *this_device; |
1da177e4c Linux-2.6.12-rc2 |
1137 1138 1139 |
int ncurrent=0; int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8; int i; |
06ff37ffb [PATCH] kzalloc()... |
1140 |
ld_buff = kzalloc(reportlunsize, GFP_KERNEL); |
47922d068 [PATCH] cciss: On... |
1141 |
inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); |
905bd78f2 cciss: Fix cciss ... |
1142 1143 1144 1145 1146 1147 |
currentsd = kzalloc(sizeof(*currentsd) * (CCISS_MAX_SCSI_DEVS_PER_HBA+1), GFP_KERNEL); if (ld_buff == NULL || inq_buff == NULL || currentsd == NULL) { printk(KERN_ERR "cciss: out of memory "); goto out; |
1da177e4c Linux-2.6.12-rc2 |
1148 |
} |
905bd78f2 cciss: Fix cciss ... |
1149 |
this_device = ¤tsd[CCISS_MAX_SCSI_DEVS_PER_HBA]; |
f70dba836 cciss: use consis... |
1150 |
if (cciss_scsi_do_report_phys_luns(h, ld_buff, reportlunsize) == 0) { |
1da177e4c Linux-2.6.12-rc2 |
1151 1152 1153 |
ch = &ld_buff->LUNListLength[0]; num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8; if (num_luns > CISS_MAX_PHYS_LUN) { |
f08896384 cciss: Fix checkp... |
1154 |
printk(KERN_WARNING |
1da177e4c Linux-2.6.12-rc2 |
1155 |
"cciss: Maximum physical LUNs (%d) exceeded. " |
f08896384 cciss: Fix checkp... |
1156 1157 |
"%d LUNs ignored. ", CISS_MAX_PHYS_LUN, |
1da177e4c Linux-2.6.12-rc2 |
1158 1159 1160 1161 1162 1163 1164 1165 1166 |
num_luns - CISS_MAX_PHYS_LUN); num_luns = CISS_MAX_PHYS_LUN; } } else { printk(KERN_ERR "cciss: Report physical LUNs failed. "); goto out; } |
f08896384 cciss: Fix checkp... |
1167 |
/* adjust our table of devices */ |
905bd78f2 cciss: Fix cciss ... |
1168 |
for (i = 0; i < num_luns; i++) { |
1da177e4c Linux-2.6.12-rc2 |
1169 1170 |
/* for each physical lun, do an inquiry */ if (ld_buff->LUN[i][3] & 0xC0) continue; |
47922d068 [PATCH] cciss: On... |
1171 |
memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE); |
1da177e4c Linux-2.6.12-rc2 |
1172 |
memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); |
f70dba836 cciss: use consis... |
1173 |
if (cciss_scsi_do_inquiry(h, scsi3addr, 0, inq_buff, |
905bd78f2 cciss: Fix cciss ... |
1174 |
(unsigned char) OBDR_TAPE_INQ_SIZE) != 0) |
1da177e4c Linux-2.6.12-rc2 |
1175 |
/* Inquiry failed (msg printed already) */ |
905bd78f2 cciss: Fix cciss ... |
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
continue; /* so we will skip this device. */ this_device->devtype = (inq_buff[0] & 0x1f); this_device->bus = -1; this_device->target = -1; this_device->lun = -1; memcpy(this_device->scsi3addr, scsi3addr, 8); memcpy(this_device->vendor, &inq_buff[8], sizeof(this_device->vendor)); memcpy(this_device->model, &inq_buff[16], sizeof(this_device->model)); memcpy(this_device->revision, &inq_buff[32], sizeof(this_device->revision)); memset(this_device->device_id, 0, sizeof(this_device->device_id)); |
f70dba836 cciss: use consis... |
1191 |
cciss_scsi_get_device_id(h, scsi3addr, |
905bd78f2 cciss: Fix cciss ... |
1192 |
this_device->device_id, sizeof(this_device->device_id)); |
19a5e10c3 cciss: Fix checkp... |
1193 |
switch (this_device->devtype) { |
47922d068 [PATCH] cciss: On... |
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
case 0x05: /* CD-ROM */ { /* We don't *really* support actual CD-ROM devices, * just this "One Button Disaster Recovery" tape drive * which temporarily pretends to be a CD-ROM drive. * So we check that the device is really an OBDR tape * device by checking for "$DR-10" in bytes 43-48 of * the inquiry data. */ char obdr_sig[7]; strncpy(obdr_sig, &inq_buff[43], 6); obdr_sig[6] = '\0'; if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0) /* Not OBDR device, ignore it. */ break; } /* fall through . . . */ |
1da177e4c Linux-2.6.12-rc2 |
1212 1213 1214 1215 |
case 0x01: /* sequential access, (tape) */ case 0x08: /* medium changer */ if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { printk(KERN_INFO "cciss%d: %s ignored, " |
f70dba836 cciss: use consis... |
1216 1217 |
"too many devices. ", h->ctlr, |
905bd78f2 cciss: Fix cciss ... |
1218 |
scsi_device_type(this_device->devtype)); |
1da177e4c Linux-2.6.12-rc2 |
1219 1220 |
break; } |
905bd78f2 cciss: Fix cciss ... |
1221 |
currentsd[ncurrent] = *this_device; |
1da177e4c Linux-2.6.12-rc2 |
1222 1223 |
ncurrent++; break; |
f08896384 cciss: Fix checkp... |
1224 |
default: |
1da177e4c Linux-2.6.12-rc2 |
1225 1226 1227 |
break; } } |
f70dba836 cciss: use consis... |
1228 |
adjust_cciss_scsi_table(h, hostno, currentsd, ncurrent); |
1da177e4c Linux-2.6.12-rc2 |
1229 1230 1231 |
out: kfree(inq_buff); kfree(ld_buff); |
905bd78f2 cciss: Fix cciss ... |
1232 |
kfree(currentsd); |
1da177e4c Linux-2.6.12-rc2 |
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 |
return; } static int is_keyword(char *ptr, int len, char *verb) // Thanks to ncr53c8xx.c { int verb_len = strlen(verb); if (len >= verb_len && !memcmp(verb,ptr,verb_len)) return verb_len; else return 0; } static int |
f70dba836 cciss: use consis... |
1247 |
cciss_scsi_user_command(ctlr_info_t *h, int hostno, char *buffer, int length) |
1da177e4c Linux-2.6.12-rc2 |
1248 1249 1250 1251 |
{ int arg_len; if ((arg_len = is_keyword(buffer, length, "rescan")) != 0) |
f70dba836 cciss: use consis... |
1252 |
cciss_update_non_disk_devices(h, hostno); |
1da177e4c Linux-2.6.12-rc2 |
1253 1254 1255 1256 |
else return -EINVAL; return length; } |
1da177e4c Linux-2.6.12-rc2 |
1257 |
static int |
e88b7bb00 cciss: switch to ... |
1258 |
cciss_scsi_write_info(struct Scsi_Host *sh, |
1da177e4c Linux-2.6.12-rc2 |
1259 |
char *buffer, /* data buffer */ |
e88b7bb00 cciss: switch to ... |
1260 |
int length) /* length of data in buffer */ |
1da177e4c Linux-2.6.12-rc2 |
1261 |
{ |
e88b7bb00 cciss: switch to ... |
1262 1263 1264 |
ctlr_info_t *h = (ctlr_info_t *) sh->hostdata[0]; if (h == NULL) /* This really shouldn't ever happen. */ return -EINVAL; |
1da177e4c Linux-2.6.12-rc2 |
1265 |
|
e88b7bb00 cciss: switch to ... |
1266 |
return cciss_scsi_user_command(h, sh->host_no, |
f08896384 cciss: Fix checkp... |
1267 1268 |
buffer, length); } |
e88b7bb00 cciss: switch to ... |
1269 1270 1271 1272 1273 1274 |
static int cciss_scsi_show_info(struct seq_file *m, struct Scsi_Host *sh) { ctlr_info_t *h = (ctlr_info_t *) sh->hostdata[0]; |
b9f0bd089 [PATCH] cciss: SC... |
1275 |
int i; |
1da177e4c Linux-2.6.12-rc2 |
1276 |
|
f70dba836 cciss: use consis... |
1277 |
if (h == NULL) /* This really shouldn't ever happen. */ |
1da177e4c Linux-2.6.12-rc2 |
1278 |
return -EINVAL; |
e88b7bb00 cciss: switch to ... |
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 |
seq_printf(m, "cciss%d: SCSI host: %d ", h->ctlr, sh->host_no); /* this information is needed by apps to know which cciss device corresponds to which scsi host number without having to open a scsi target device node. The device information is not a duplicate of /proc/scsi/scsi because the two may be out of sync due to scsi hotplug, rather this info is for an app to be able to use to know how to get them back in sync. */ for (i = 0; i < ccissscsi[h->ctlr].ndevices; i++) { struct cciss_scsi_dev_t *sd = &ccissscsi[h->ctlr].dev[i]; seq_printf(m, "c%db%dt%dl%d %02d " "0x%02x%02x%02x%02x%02x%02x%02x%02x ", sh->host_no, sd->bus, sd->target, sd->lun, sd->devtype, sd->scsi3addr[0], sd->scsi3addr[1], sd->scsi3addr[2], sd->scsi3addr[3], sd->scsi3addr[4], sd->scsi3addr[5], sd->scsi3addr[6], sd->scsi3addr[7]); } return 0; } |
1da177e4c Linux-2.6.12-rc2 |
1306 |
|
f08896384 cciss: Fix checkp... |
1307 1308 |
/* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci dma mapping and fills in the scatter gather entries of the |
f70dba836 cciss: use consis... |
1309 |
cciss command, c. */ |
1da177e4c Linux-2.6.12-rc2 |
1310 |
|
f70dba836 cciss: use consis... |
1311 |
static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *c, |
87c3a922a cciss: Fix proble... |
1312 |
struct scsi_cmnd *cmd) |
1da177e4c Linux-2.6.12-rc2 |
1313 |
{ |
41ce639a1 [SCSI] cciss: con... |
1314 1315 |
unsigned int len; struct scatterlist *sg; |
1da177e4c Linux-2.6.12-rc2 |
1316 |
__u64 addr64; |
87c3a922a cciss: Fix proble... |
1317 1318 1319 1320 1321 1322 1323 1324 |
int request_nsgs, i, chained, sg_index; struct cciss_scsi_adapter_data_t *sa = h->scsi_ctlr; SGDescriptor_struct *curr_sg; BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); chained = 0; sg_index = 0; |
f70dba836 cciss: use consis... |
1325 |
curr_sg = c->SG; |
87c3a922a cciss: Fix proble... |
1326 1327 1328 1329 1330 1331 1332 |
request_nsgs = scsi_dma_map(cmd); if (request_nsgs) { scsi_for_each_sg(cmd, sg, request_nsgs, i) { if (sg_index + 1 == h->max_cmd_sgentries && !chained && request_nsgs - i > 1) { chained = 1; sg_index = 0; |
f70dba836 cciss: use consis... |
1333 |
curr_sg = sa->cmd_sg_list[c->cmdindex]; |
87c3a922a cciss: Fix proble... |
1334 |
} |
41ce639a1 [SCSI] cciss: con... |
1335 1336 |
addr64 = (__u64) sg_dma_address(sg); len = sg_dma_len(sg); |
87c3a922a cciss: Fix proble... |
1337 1338 1339 1340 1341 1342 1343 |
curr_sg[sg_index].Addr.lower = (__u32) (addr64 & 0x0FFFFFFFFULL); curr_sg[sg_index].Addr.upper = (__u32) ((addr64 >> 32) & 0x0FFFFFFFFULL); curr_sg[sg_index].Len = len; curr_sg[sg_index].Ext = 0; ++sg_index; |
1da177e4c Linux-2.6.12-rc2 |
1344 |
} |
87c3a922a cciss: Fix proble... |
1345 |
if (chained) |
f70dba836 cciss: use consis... |
1346 1347 |
cciss_map_sg_chain_block(h, c, sa->cmd_sg_list[c->cmdindex], |
87c3a922a cciss: Fix proble... |
1348 1349 |
(request_nsgs - (h->max_cmd_sgentries - 1)) * sizeof(SGDescriptor_struct)); |
41ce639a1 [SCSI] cciss: con... |
1350 |
} |
87c3a922a cciss: Fix proble... |
1351 1352 1353 |
/* track how many SG entries we are using */ if (request_nsgs > h->maxSG) h->maxSG = request_nsgs; |
bc67f6365 cciss: Fix scsi t... |
1354 |
c->Header.SGTotal = (u16) request_nsgs + chained; |
87c3a922a cciss: Fix proble... |
1355 |
if (request_nsgs > h->max_cmd_sgentries) |
f70dba836 cciss: use consis... |
1356 |
c->Header.SGList = h->max_cmd_sgentries; |
87c3a922a cciss: Fix proble... |
1357 |
else |
f70dba836 cciss: use consis... |
1358 |
c->Header.SGList = c->Header.SGTotal; |
1da177e4c Linux-2.6.12-rc2 |
1359 1360 1361 1362 1363 |
return; } static int |
f281233d3 SCSI host lock pu... |
1364 |
cciss_scsi_queue_command_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) |
1da177e4c Linux-2.6.12-rc2 |
1365 |
{ |
f70dba836 cciss: use consis... |
1366 1367 |
ctlr_info_t *h; int rc; |
1da177e4c Linux-2.6.12-rc2 |
1368 |
unsigned char scsi3addr[8]; |
f70dba836 cciss: use consis... |
1369 |
CommandList_struct *c; |
1da177e4c Linux-2.6.12-rc2 |
1370 1371 1372 1373 |
unsigned long flags; // Get the ptr to our adapter structure (hba[i]) out of cmd->host. // We violate cmd->host privacy here. (Is there another way?) |
f70dba836 cciss: use consis... |
1374 |
h = (ctlr_info_t *) cmd->device->host->hostdata[0]; |
1da177e4c Linux-2.6.12-rc2 |
1375 |
|
f70dba836 cciss: use consis... |
1376 |
rc = lookup_scsi3addr(h, cmd->device->channel, cmd->device->id, |
1da177e4c Linux-2.6.12-rc2 |
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 |
cmd->device->lun, scsi3addr); if (rc != 0) { /* the scsi nexus does not match any that we presented... */ /* pretend to mid layer that we got selection timeout */ cmd->result = DID_NO_CONNECT << 16; done(cmd); /* we might want to think about registering controller itself as a processor device on the bus so sg binds to it. */ return 0; } |
1da177e4c Linux-2.6.12-rc2 |
1387 1388 |
/* Ok, we have a reasonable scsi nexus, so send the cmd down, and see what the device thinks of it. */ |
f70dba836 cciss: use consis... |
1389 1390 1391 1392 |
spin_lock_irqsave(&h->lock, flags); c = scsi_cmd_alloc(h); spin_unlock_irqrestore(&h->lock, flags); if (c == NULL) { /* trouble... */ |
b2a4a43db cciss: change pri... |
1393 1394 |
dev_warn(&h->pdev->dev, "scsi_cmd_alloc returned NULL! "); |
1da177e4c Linux-2.6.12-rc2 |
1395 1396 1397 1398 1399 1400 1401 |
/* FIXME: next 3 lines are -> BAD! <- */ cmd->result = DID_NO_CONNECT << 16; done(cmd); return 0; } // Fill in the command list header |
f08896384 cciss: Fix checkp... |
1402 |
cmd->scsi_done = done; // save this for use by completion code |
1da177e4c Linux-2.6.12-rc2 |
1403 |
|
f70dba836 cciss: use consis... |
1404 1405 |
/* save c in case we have to abort it */ cmd->host_scribble = (unsigned char *) c; |
1da177e4c Linux-2.6.12-rc2 |
1406 |
|
f70dba836 cciss: use consis... |
1407 1408 1409 1410 1411 |
c->cmd_type = CMD_SCSI; c->scsi_cmd = cmd; c->Header.ReplyQueue = 0; /* unused in simple mode */ memcpy(&c->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8); c->Header.Tag.lower = c->busaddr; /* Use k. address of cmd as tag */ |
f08896384 cciss: Fix checkp... |
1412 |
|
1da177e4c Linux-2.6.12-rc2 |
1413 |
// Fill in the request block... |
f70dba836 cciss: use consis... |
1414 1415 1416 1417 1418 1419 1420 |
c->Request.Timeout = 0; memset(c->Request.CDB, 0, sizeof(c->Request.CDB)); BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB)); c->Request.CDBLen = cmd->cmd_len; memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len); c->Request.Type.Type = TYPE_CMD; c->Request.Type.Attribute = ATTR_SIMPLE; |
19a5e10c3 cciss: Fix checkp... |
1421 |
switch (cmd->sc_data_direction) { |
f70dba836 cciss: use consis... |
1422 1423 1424 1425 1426 1427 1428 1429 1430 |
case DMA_TO_DEVICE: c->Request.Type.Direction = XFER_WRITE; break; case DMA_FROM_DEVICE: c->Request.Type.Direction = XFER_READ; break; case DMA_NONE: c->Request.Type.Direction = XFER_NONE; break; |
1da177e4c Linux-2.6.12-rc2 |
1431 1432 1433 1434 |
case DMA_BIDIRECTIONAL: // This can happen if a buggy application does a scsi passthru // and sets both inlen and outlen to non-zero. ( see // ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() ) |
f70dba836 cciss: use consis... |
1435 |
c->Request.Type.Direction = XFER_RSVD; |
1da177e4c Linux-2.6.12-rc2 |
1436 |
// This is technically wrong, and cciss controllers should |
f08896384 cciss: Fix checkp... |
1437 1438 |
// reject it with CMD_INVALID, which is the most correct // response, but non-fibre backends appear to let it |
1da177e4c Linux-2.6.12-rc2 |
1439 1440 1441 1442 1443 |
// slide by, and give the same results as if this field // were set correctly. Either way is acceptable for // our purposes here. break; |
f08896384 cciss: Fix checkp... |
1444 |
default: |
b2a4a43db cciss: change pri... |
1445 1446 |
dev_warn(&h->pdev->dev, "unknown data direction: %d ", |
1da177e4c Linux-2.6.12-rc2 |
1447 1448 1449 1450 |
cmd->sc_data_direction); BUG(); break; } |
f70dba836 cciss: use consis... |
1451 1452 |
cciss_scatter_gather(h, c, cmd); enqueue_cmd_and_start_io(h, c); |
1da177e4c Linux-2.6.12-rc2 |
1453 1454 1455 |
/* the cmd'll come back via intr handler in complete_scsi_command() */ return 0; } |
f281233d3 SCSI host lock pu... |
1456 |
static DEF_SCSI_QCMD(cciss_scsi_queue_command) |
f70dba836 cciss: use consis... |
1457 |
static void cciss_unregister_scsi(ctlr_info_t *h) |
1da177e4c Linux-2.6.12-rc2 |
1458 1459 1460 1461 1462 1463 |
{ struct cciss_scsi_adapter_data_t *sa; struct cciss_scsi_cmd_stack_t *stk; unsigned long flags; /* we are being forcibly unloaded, and may not refuse. */ |
f70dba836 cciss: use consis... |
1464 1465 |
spin_lock_irqsave(&h->lock, flags); sa = h->scsi_ctlr; |
f08896384 cciss: Fix checkp... |
1466 |
stk = &sa->cmd_stack; |
1da177e4c Linux-2.6.12-rc2 |
1467 |
|
f08896384 cciss: Fix checkp... |
1468 |
/* if we weren't ever actually registered, don't unregister */ |
1da177e4c Linux-2.6.12-rc2 |
1469 |
if (sa->registered) { |
f70dba836 cciss: use consis... |
1470 |
spin_unlock_irqrestore(&h->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1471 1472 |
scsi_remove_host(sa->scsi_host); scsi_host_put(sa->scsi_host); |
f70dba836 cciss: use consis... |
1473 |
spin_lock_irqsave(&h->lock, flags); |
1da177e4c Linux-2.6.12-rc2 |
1474 |
} |
f08896384 cciss: Fix checkp... |
1475 |
/* set scsi_host to NULL so our detect routine will |
1da177e4c Linux-2.6.12-rc2 |
1476 1477 |
find us on register */ sa->scsi_host = NULL; |
f70dba836 cciss: use consis... |
1478 1479 |
spin_unlock_irqrestore(&h->lock, flags); scsi_cmd_stack_free(h); |
1da177e4c Linux-2.6.12-rc2 |
1480 |
kfree(sa); |
1da177e4c Linux-2.6.12-rc2 |
1481 |
} |
f70dba836 cciss: use consis... |
1482 |
static int cciss_engage_scsi(ctlr_info_t *h) |
1da177e4c Linux-2.6.12-rc2 |
1483 1484 1485 1486 |
{ struct cciss_scsi_adapter_data_t *sa; struct cciss_scsi_cmd_stack_t *stk; unsigned long flags; |
f70dba836 cciss: use consis... |
1487 1488 |
spin_lock_irqsave(&h->lock, flags); sa = h->scsi_ctlr; |
f08896384 cciss: Fix checkp... |
1489 |
stk = &sa->cmd_stack; |
1da177e4c Linux-2.6.12-rc2 |
1490 |
|
f4a93bcda cciss: change the... |
1491 |
if (sa->registered) { |
b2a4a43db cciss: change pri... |
1492 1493 |
dev_info(&h->pdev->dev, "SCSI subsystem already engaged. "); |
f70dba836 cciss: use consis... |
1494 |
spin_unlock_irqrestore(&h->lock, flags); |
8721c81f6 cciss: Fix weird ... |
1495 |
return -ENXIO; |
1da177e4c Linux-2.6.12-rc2 |
1496 |
} |
f4a93bcda cciss: change the... |
1497 |
sa->registered = 1; |
f70dba836 cciss: use consis... |
1498 1499 1500 |
spin_unlock_irqrestore(&h->lock, flags); cciss_update_non_disk_devices(h, -1); cciss_scsi_detect(h); |
1da177e4c Linux-2.6.12-rc2 |
1501 1502 1503 1504 |
return 0; } static void |
f70dba836 cciss: use consis... |
1505 |
cciss_seq_tape_report(struct seq_file *seq, ctlr_info_t *h) |
1da177e4c Linux-2.6.12-rc2 |
1506 1507 |
{ unsigned long flags; |
1da177e4c Linux-2.6.12-rc2 |
1508 |
|
f70dba836 cciss: use consis... |
1509 |
CPQ_TAPE_LOCK(h, flags); |
89b6e7437 resubmit: cciss: ... |
1510 |
seq_printf(seq, |
b9f0bd089 [PATCH] cciss: SC... |
1511 1512 1513 |
"Sequential access devices: %d ", |
f70dba836 cciss: use consis... |
1514 1515 |
ccissscsi[h->ctlr].ndevices); CPQ_TAPE_UNLOCK(h, flags); |
1da177e4c Linux-2.6.12-rc2 |
1516 |
} |
88f627ae3 cciss: fix SCSI d... |
1517 1518 1519 1520 1521 1522 1523 |
static int wait_for_device_to_become_ready(ctlr_info_t *h, unsigned char lunaddr[]) { int rc; int count = 0; int waittime = HZ; CommandList_struct *c; |
6b4d96b87 cciss: separate c... |
1524 |
c = cmd_alloc(h); |
88f627ae3 cciss: fix SCSI d... |
1525 |
if (!c) { |
b2a4a43db cciss: change pri... |
1526 1527 1528 |
dev_warn(&h->pdev->dev, "out of memory in " "wait_for_device_to_become_ready. "); |
88f627ae3 cciss: fix SCSI d... |
1529 1530 1531 1532 1533 1534 1535 1536 1537 |
return IO_ERROR; } /* Send test unit ready until device ready, or give up. */ while (count < 20) { /* Wait for a bit. do this first, because if we send * the TUR right away, the reset will just abort it. */ |
40df6ae42 cciss: Use schedu... |
1538 |
schedule_timeout_uninterruptible(waittime); |
88f627ae3 cciss: fix SCSI d... |
1539 1540 1541 1542 1543 1544 1545 |
count++; /* Increase wait time with each try, up to a point. */ if (waittime < (HZ * 30)) waittime = waittime * 2; /* Send the Test Unit Ready */ |
f70dba836 cciss: use consis... |
1546 |
rc = fill_cmd(h, c, TEST_UNIT_READY, NULL, 0, 0, |
88f627ae3 cciss: fix SCSI d... |
1547 |
lunaddr, TYPE_CMD); |
85cc61ae4 cciss: change SCS... |
1548 1549 1550 1551 |
if (rc == 0) rc = sendcmd_withirq_core(h, c, 0); (void) process_sendcmd_error(h, c); |
88f627ae3 cciss: fix SCSI d... |
1552 |
|
3969251b8 cciss: decode uni... |
1553 1554 |
if (rc != 0) goto retry_tur; |
88f627ae3 cciss: fix SCSI d... |
1555 |
|
3969251b8 cciss: decode uni... |
1556 |
if (c->err_info->CommandStatus == CMD_SUCCESS) |
88f627ae3 cciss: fix SCSI d... |
1557 |
break; |
3969251b8 cciss: decode uni... |
1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 |
if (c->err_info->CommandStatus == CMD_TARGET_STATUS && c->err_info->ScsiStatus == SAM_STAT_CHECK_CONDITION) { if (c->err_info->SenseInfo[2] == NO_SENSE) break; if (c->err_info->SenseInfo[2] == UNIT_ATTENTION) { unsigned char asc; asc = c->err_info->SenseInfo[12]; check_for_unit_attention(h, c); if (asc == POWER_OR_RESET) break; } } retry_tur: |
b2a4a43db cciss: change pri... |
1571 |
dev_warn(&h->pdev->dev, "Waiting %d secs " |
88f627ae3 cciss: fix SCSI d... |
1572 1573 |
"for device to become ready. ", |
b2a4a43db cciss: change pri... |
1574 |
waittime / HZ); |
88f627ae3 cciss: fix SCSI d... |
1575 1576 1577 1578 |
rc = 1; /* device not ready. */ } if (rc) |
b2a4a43db cciss: change pri... |
1579 1580 |
dev_warn(&h->pdev->dev, "giving up on device. "); |
88f627ae3 cciss: fix SCSI d... |
1581 |
else |
b2a4a43db cciss: change pri... |
1582 1583 |
dev_warn(&h->pdev->dev, "device is ready. "); |
88f627ae3 cciss: fix SCSI d... |
1584 |
|
6b4d96b87 cciss: separate c... |
1585 |
cmd_free(h, c); |
88f627ae3 cciss: fix SCSI d... |
1586 1587 |
return rc; } |
89b6e7437 resubmit: cciss: ... |
1588 |
|
f08896384 cciss: Fix checkp... |
1589 1590 |
/* Need at least one of these error handlers to keep ../scsi/hosts.c from * complaining. Doing a host- or bus-reset can't do anything good here. |
3da8b713d [SCSI] cciss: scs... |
1591 1592 1593 1594 |
* Despite what it might say in scsi_error.c, there may well be commands * on the controller, as the cciss driver registers twice, once as a block * device for the logical drives, and once as a scsi device, for any tape * drives. So we know there are no commands out on the tape drives, but we |
f08896384 cciss: Fix checkp... |
1595 |
* don't know there are no commands on the controller, and it is likely |
3da8b713d [SCSI] cciss: scs... |
1596 1597 1598 1599 1600 1601 1602 1603 |
* that there probably are, as the cciss block device is most commonly used * as a boot device (embedded controller on HP/Compaq systems.) */ static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd) { int rc; CommandList_struct *cmd_in_trouble; |
88f627ae3 cciss: fix SCSI d... |
1604 |
unsigned char lunaddr[8]; |
f70dba836 cciss: use consis... |
1605 |
ctlr_info_t *h; |
3da8b713d [SCSI] cciss: scs... |
1606 1607 |
/* find the controller to which the command to be aborted was sent */ |
f70dba836 cciss: use consis... |
1608 1609 |
h = (ctlr_info_t *) scsicmd->device->host->hostdata[0]; if (h == NULL) /* paranoia */ |
3da8b713d [SCSI] cciss: scs... |
1610 |
return FAILED; |
b2a4a43db cciss: change pri... |
1611 1612 |
dev_warn(&h->pdev->dev, "resetting tape drive or medium changer. "); |
3da8b713d [SCSI] cciss: scs... |
1613 1614 |
/* find the command that's giving us trouble */ cmd_in_trouble = (CommandList_struct *) scsicmd->host_scribble; |
88f627ae3 cciss: fix SCSI d... |
1615 |
if (cmd_in_trouble == NULL) /* paranoia */ |
3da8b713d [SCSI] cciss: scs... |
1616 |
return FAILED; |
88f627ae3 cciss: fix SCSI d... |
1617 |
memcpy(lunaddr, &cmd_in_trouble->Header.LUN.LunAddrBytes[0], 8); |
3da8b713d [SCSI] cciss: scs... |
1618 |
/* send a reset to the SCSI LUN which the command was sent to */ |
f70dba836 cciss: use consis... |
1619 |
rc = sendcmd_withirq(h, CCISS_RESET_MSG, NULL, 0, 0, lunaddr, |
3da8b713d [SCSI] cciss: scs... |
1620 |
TYPE_MSG); |
f70dba836 cciss: use consis... |
1621 |
if (rc == 0 && wait_for_device_to_become_ready(h, lunaddr) == 0) |
3da8b713d [SCSI] cciss: scs... |
1622 |
return SUCCESS; |
b2a4a43db cciss: change pri... |
1623 1624 |
dev_warn(&h->pdev->dev, "resetting device failed. "); |
3da8b713d [SCSI] cciss: scs... |
1625 1626 1627 1628 1629 1630 1631 |
return FAILED; } static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd) { int rc; CommandList_struct *cmd_to_abort; |
85cc61ae4 cciss: change SCS... |
1632 |
unsigned char lunaddr[8]; |
f70dba836 cciss: use consis... |
1633 |
ctlr_info_t *h; |
3da8b713d [SCSI] cciss: scs... |
1634 1635 |
/* find the controller to which the command to be aborted was sent */ |
f70dba836 cciss: use consis... |
1636 1637 |
h = (ctlr_info_t *) scsicmd->device->host->hostdata[0]; if (h == NULL) /* paranoia */ |
3da8b713d [SCSI] cciss: scs... |
1638 |
return FAILED; |
b2a4a43db cciss: change pri... |
1639 1640 |
dev_warn(&h->pdev->dev, "aborting tardy SCSI cmd "); |
3da8b713d [SCSI] cciss: scs... |
1641 1642 1643 1644 1645 |
/* find the command to be aborted */ cmd_to_abort = (CommandList_struct *) scsicmd->host_scribble; if (cmd_to_abort == NULL) /* paranoia */ return FAILED; |
85cc61ae4 cciss: change SCS... |
1646 |
memcpy(lunaddr, &cmd_to_abort->Header.LUN.LunAddrBytes[0], 8); |
f70dba836 cciss: use consis... |
1647 |
rc = sendcmd_withirq(h, CCISS_ABORT_MSG, &cmd_to_abort->Header.Tag, |
85cc61ae4 cciss: change SCS... |
1648 |
0, 0, lunaddr, TYPE_MSG); |
3da8b713d [SCSI] cciss: scs... |
1649 1650 1651 1652 1653 |
if (rc == 0) return SUCCESS; return FAILED; } |
1da177e4c Linux-2.6.12-rc2 |
1654 1655 1656 1657 1658 |
#else /* no CONFIG_CISS_SCSI_TAPE */ /* If no tape support, then these become defined out of existence */ #define cciss_scsi_setup(cntl_num) |
0007a4c90 cciss: auto engag... |
1659 |
#define cciss_engage_scsi(h) |
1da177e4c Linux-2.6.12-rc2 |
1660 1661 |
#endif /* CONFIG_CISS_SCSI_TAPE */ |