[PATCH] I2O: new sysfs attributes and Adaptec specific block device access and 64...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / message / i2o / i2o_scsi.c
blobc3b0c29ac02da5efc382358990b60ae19130409b
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2, or (at your option) any
5 * later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * For the avoidance of doubt the "preferred form" of this code is one which
13 * is in an open non patent encumbered format. Where cryptographic key signing
14 * forms part of the process of creating an executable the information
15 * including keys needed to generate an equivalently functional executable
16 * are deemed to be part of the source code.
18 * Complications for I2O scsi
20 * o Each (bus,lun) is a logical device in I2O. We keep a map
21 * table. We spoof failed selection for unmapped units
22 * o Request sense buffers can come back for free.
23 * o Scatter gather is a bit dynamic. We have to investigate at
24 * setup time.
25 * o Some of our resources are dynamically shared. The i2o core
26 * needs a message reservation protocol to avoid swap v net
27 * deadlocking. We need to back off queue requests.
29 * In general the firmware wants to help. Where its help isn't performance
30 * useful we just ignore the aid. Its not worth the code in truth.
32 * Fixes/additions:
33 * Steve Ralston:
34 * Scatter gather now works
35 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
36 * Minor fixes for 2.6.
38 * To Do:
39 * 64bit cleanups
40 * Fix the resource management problems.
43 #define DEBUG 1
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/types.h>
47 #include <linux/string.h>
48 #include <linux/ioport.h>
49 #include <linux/jiffies.h>
50 #include <linux/interrupt.h>
51 #include <linux/timer.h>
52 #include <linux/delay.h>
53 #include <linux/proc_fs.h>
54 #include <linux/prefetch.h>
55 #include <linux/pci.h>
56 #include <linux/blkdev.h>
57 #include <linux/i2o.h>
59 #include <asm/dma.h>
60 #include <asm/system.h>
61 #include <asm/io.h>
62 #include <asm/atomic.h>
64 #include <scsi/scsi.h>
65 #include <scsi/scsi_host.h>
66 #include <scsi/scsi_device.h>
67 #include <scsi/scsi_cmnd.h>
69 #define OSM_NAME "scsi-osm"
70 #define OSM_VERSION "$Rev$"
71 #define OSM_DESCRIPTION "I2O SCSI Peripheral OSM"
73 static struct i2o_driver i2o_scsi_driver;
75 static int i2o_scsi_max_id = 16;
76 static int i2o_scsi_max_lun = 8;
78 struct i2o_scsi_host {
79 struct Scsi_Host *scsi_host; /* pointer to the SCSI host */
80 struct i2o_controller *iop; /* pointer to the I2O controller */
81 struct i2o_device *channel[0]; /* channel->i2o_dev mapping table */
84 static struct scsi_host_template i2o_scsi_host_template;
86 #define I2O_SCSI_CAN_QUEUE 4
88 /* SCSI OSM class handling definition */
89 static struct i2o_class_id i2o_scsi_class_id[] = {
90 {I2O_CLASS_SCSI_PERIPHERAL},
91 {I2O_CLASS_END}
94 static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c)
96 struct i2o_scsi_host *i2o_shost;
97 struct i2o_device *i2o_dev;
98 struct Scsi_Host *scsi_host;
99 int max_channel = 0;
100 u8 type;
101 int i;
102 size_t size;
103 i2o_status_block *sb;
105 list_for_each_entry(i2o_dev, &c->devices, list)
106 if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
107 if (i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
108 && (type == 0x01)) /* SCSI bus */
109 max_channel++;
112 if (!max_channel) {
113 osm_warn("no channels found on %s\n", c->name);
114 return ERR_PTR(-EFAULT);
117 size = max_channel * sizeof(struct i2o_device *)
118 + sizeof(struct i2o_scsi_host);
120 scsi_host = scsi_host_alloc(&i2o_scsi_host_template, size);
121 if (!scsi_host) {
122 osm_warn("Could not allocate SCSI host\n");
123 return ERR_PTR(-ENOMEM);
126 scsi_host->max_channel = max_channel - 1;
127 scsi_host->max_id = i2o_scsi_max_id;
128 scsi_host->max_lun = i2o_scsi_max_lun;
129 scsi_host->this_id = c->unit;
131 sb = c->status_block.virt;
133 scsi_host->sg_tablesize = (sb->inbound_frame_size -
134 sizeof(struct i2o_message) / 4 - 6) / 2;
136 i2o_shost = (struct i2o_scsi_host *)scsi_host->hostdata;
137 i2o_shost->scsi_host = scsi_host;
138 i2o_shost->iop = c;
140 i = 0;
141 list_for_each_entry(i2o_dev, &c->devices, list)
142 if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
143 if (i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) || (type == 1)) /* only SCSI bus */
144 i2o_shost->channel[i++] = i2o_dev;
146 if (i >= max_channel)
147 break;
150 return i2o_shost;
154 * i2o_scsi_get_host - Get an I2O SCSI host
155 * @c: I2O controller to for which to get the SCSI host
157 * If the I2O controller already exists as SCSI host, the SCSI host
158 * is returned, otherwise the I2O controller is added to the SCSI
159 * core.
161 * Returns pointer to the I2O SCSI host on success or NULL on failure.
163 static struct i2o_scsi_host *i2o_scsi_get_host(struct i2o_controller *c)
165 return c->driver_data[i2o_scsi_driver.context];
169 * i2o_scsi_remove - Remove I2O device from SCSI core
170 * @dev: device which should be removed
172 * Removes the I2O device from the SCSI core again.
174 * Returns 0 on success.
176 static int i2o_scsi_remove(struct device *dev)
178 struct i2o_device *i2o_dev = to_i2o_device(dev);
179 struct i2o_controller *c = i2o_dev->iop;
180 struct i2o_scsi_host *i2o_shost;
181 struct scsi_device *scsi_dev;
183 osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
185 i2o_shost = i2o_scsi_get_host(c);
187 shost_for_each_device(scsi_dev, i2o_shost->scsi_host)
188 if (scsi_dev->hostdata == i2o_dev) {
189 sysfs_remove_link(&i2o_dev->device.kobj, "scsi");
190 scsi_remove_device(scsi_dev);
191 scsi_device_put(scsi_dev);
192 break;
195 return 0;
199 * i2o_scsi_probe - verify if dev is a I2O SCSI device and install it
200 * @dev: device to verify if it is a I2O SCSI device
202 * Retrieve channel, id and lun for I2O device. If everthing goes well
203 * register the I2O device as SCSI device on the I2O SCSI controller.
205 * Returns 0 on success or negative error code on failure.
207 static int i2o_scsi_probe(struct device *dev)
209 struct i2o_device *i2o_dev = to_i2o_device(dev);
210 struct i2o_controller *c = i2o_dev->iop;
211 struct i2o_scsi_host *i2o_shost;
212 struct Scsi_Host *scsi_host;
213 struct i2o_device *parent;
214 struct scsi_device *scsi_dev;
215 u32 id;
216 u64 lun;
217 int channel = -1;
218 int i;
220 i2o_shost = i2o_scsi_get_host(c);
221 if (!i2o_shost)
222 return -EFAULT;
224 scsi_host = i2o_shost->scsi_host;
226 if (i2o_parm_field_get(i2o_dev, 0, 3, &id, 4) < 0)
227 return -EFAULT;
229 if (id >= scsi_host->max_id) {
230 osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)", id,
231 scsi_host->max_id);
232 return -EFAULT;
235 if (i2o_parm_field_get(i2o_dev, 0, 4, &lun, 8) < 0)
236 return -EFAULT;
237 if (lun >= scsi_host->max_lun) {
238 osm_warn("SCSI device id (%d) >= max_lun of I2O host (%d)",
239 (unsigned int)lun, scsi_host->max_lun);
240 return -EFAULT;
243 parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid);
244 if (!parent) {
245 osm_warn("can not find parent of device %03x\n",
246 i2o_dev->lct_data.tid);
247 return -EFAULT;
250 for (i = 0; i <= i2o_shost->scsi_host->max_channel; i++)
251 if (i2o_shost->channel[i] == parent)
252 channel = i;
254 if (channel == -1) {
255 osm_warn("can not find channel of device %03x\n",
256 i2o_dev->lct_data.tid);
257 return -EFAULT;
260 scsi_dev =
261 __scsi_add_device(i2o_shost->scsi_host, channel, id, lun, i2o_dev);
263 if (IS_ERR(scsi_dev)) {
264 osm_warn("can not add SCSI device %03x\n",
265 i2o_dev->lct_data.tid);
266 return PTR_ERR(scsi_dev);
269 sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, "scsi");
271 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %d\n",
272 i2o_dev->lct_data.tid, channel, id, (unsigned int)lun);
274 return 0;
277 static const char *i2o_scsi_info(struct Scsi_Host *SChost)
279 struct i2o_scsi_host *hostdata;
280 hostdata = (struct i2o_scsi_host *)SChost->hostdata;
281 return hostdata->iop->name;
285 * i2o_scsi_reply - SCSI OSM message reply handler
286 * @c: controller issuing the reply
287 * @m: message id for flushing
288 * @msg: the message from the controller
290 * Process reply messages (interrupts in normal scsi controller think).
291 * We can get a variety of messages to process. The normal path is
292 * scsi command completions. We must also deal with IOP failures,
293 * the reply to a bus reset and the reply to a LUN query.
295 * Returns 0 on success and if the reply should not be flushed or > 0
296 * on success and if the reply should be flushed. Returns negative error
297 * code on failure and if the reply should be flushed.
299 static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
300 struct i2o_message *msg)
302 struct scsi_cmnd *cmd;
303 struct device *dev;
304 u8 as, ds, st;
306 cmd = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
308 if (msg->u.head[0] & (1 << 13)) {
309 struct i2o_message __iomem *pmsg; /* preserved message */
310 u32 pm;
311 int err = DID_ERROR;
313 pm = le32_to_cpu(msg->body[3]);
315 pmsg = i2o_msg_in_to_virt(c, pm);
317 osm_err("IOP fail.\n");
318 osm_err("From %d To %d Cmd %d.\n",
319 (msg->u.head[1] >> 12) & 0xFFF,
320 msg->u.head[1] & 0xFFF, msg->u.head[1] >> 24);
321 osm_err("Failure Code %d.\n", msg->body[0] >> 24);
322 if (msg->body[0] & (1 << 16))
323 osm_err("Format error.\n");
324 if (msg->body[0] & (1 << 17))
325 osm_err("Path error.\n");
326 if (msg->body[0] & (1 << 18))
327 osm_err("Path State.\n");
328 if (msg->body[0] & (1 << 18))
330 osm_err("Congestion.\n");
331 err = DID_BUS_BUSY;
334 osm_debug("Failing message is %p.\n", pmsg);
336 cmd = i2o_cntxt_list_get(c, readl(&pmsg->u.s.tcntxt));
337 if (!cmd)
338 return 1;
340 cmd->result = err << 16;
341 cmd->scsi_done(cmd);
343 /* Now flush the message by making it a NOP */
344 i2o_msg_nop(c, pm);
346 return 1;
350 * Low byte is device status, next is adapter status,
351 * (then one byte reserved), then request status.
353 ds = (u8) le32_to_cpu(msg->body[0]);
354 as = (u8) (le32_to_cpu(msg->body[0]) >> 8);
355 st = (u8) (le32_to_cpu(msg->body[0]) >> 24);
358 * Is this a control request coming back - eg an abort ?
361 if (!cmd) {
362 if (st)
363 osm_warn("SCSI abort: %08X", le32_to_cpu(msg->body[0]));
364 osm_info("SCSI abort completed.\n");
365 return -EFAULT;
368 osm_debug("Completed %ld\n", cmd->serial_number);
370 if (st) {
371 u32 count, error;
372 /* An error has occurred */
374 switch (st) {
375 case 0x06:
376 count = le32_to_cpu(msg->body[1]);
377 if (count < cmd->underflow) {
378 int i;
380 osm_err("SCSI underflow 0x%08X 0x%08X\n", count,
381 cmd->underflow);
382 osm_debug("Cmd: ");
383 for (i = 0; i < 15; i++)
384 pr_debug("%02X ", cmd->cmnd[i]);
385 pr_debug(".\n");
386 cmd->result = (DID_ERROR << 16);
388 break;
390 default:
391 error = le32_to_cpu(msg->body[0]);
393 osm_err("SCSI error %08x\n", error);
395 if ((error & 0xff) == 0x02 /*CHECK_CONDITION */ ) {
396 int i;
397 u32 len = sizeof(cmd->sense_buffer);
398 len = (len > 40) ? 40 : len;
399 // Copy over the sense data
400 memcpy(cmd->sense_buffer, (void *)&msg->body[3],
401 len);
402 for (i = 0; i <= len; i++)
403 osm_info("%02x\n",
404 cmd->sense_buffer[i]);
405 if (cmd->sense_buffer[0] == 0x70
406 && cmd->sense_buffer[2] == DATA_PROTECT) {
407 /* This is to handle an array failed */
408 cmd->result = (DID_TIME_OUT << 16);
409 printk(KERN_WARNING "%s: SCSI Data "
410 "Protect-Device (%d,%d,%d) "
411 "hba_status=0x%x, dev_status="
412 "0x%x, cmd=0x%x\n", c->name,
413 (u32) cmd->device->channel,
414 (u32) cmd->device->id,
415 (u32) cmd->device->lun,
416 (error >> 8) & 0xff,
417 error & 0xff, cmd->cmnd[0]);
418 } else
419 cmd->result = (DID_ERROR << 16);
421 break;
424 switch (as) {
425 case 0x0E:
426 /* SCSI Reset */
427 cmd->result = DID_RESET << 16;
428 break;
430 case 0x0F:
431 cmd->result = DID_PARITY << 16;
432 break;
434 default:
435 cmd->result = DID_ERROR << 16;
436 break;
439 break;
442 cmd->scsi_done(cmd);
443 return 1;
446 cmd->result = DID_OK << 16 | ds;
448 dev = &c->pdev->dev;
449 if (cmd->use_sg)
450 dma_unmap_sg(dev, (struct scatterlist *)cmd->buffer,
451 cmd->use_sg, cmd->sc_data_direction);
452 else if (cmd->request_bufflen)
453 dma_unmap_single(dev, (dma_addr_t) ((long)cmd->SCp.ptr),
454 cmd->request_bufflen, cmd->sc_data_direction);
456 cmd->scsi_done(cmd);
458 return 1;
462 * i2o_scsi_notify_controller_add - Retrieve notifications of added
463 * controllers
464 * @c: the controller which was added
466 * If a I2O controller is added, we catch the notification to add a
467 * corresponding Scsi_Host.
469 static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
471 struct i2o_scsi_host *i2o_shost;
472 int rc;
474 i2o_shost = i2o_scsi_host_alloc(c);
475 if (IS_ERR(i2o_shost)) {
476 osm_err("Could not initialize SCSI host\n");
477 return;
480 rc = scsi_add_host(i2o_shost->scsi_host, &c->device);
481 if (rc) {
482 osm_err("Could not add SCSI host\n");
483 scsi_host_put(i2o_shost->scsi_host);
484 return;
487 c->driver_data[i2o_scsi_driver.context] = i2o_shost;
489 osm_debug("new I2O SCSI host added\n");
493 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed
494 * controllers
495 * @c: the controller which was removed
497 * If a I2O controller is removed, we catch the notification to remove the
498 * corresponding Scsi_Host.
500 static void i2o_scsi_notify_controller_remove(struct i2o_controller *c)
502 struct i2o_scsi_host *i2o_shost;
503 i2o_shost = i2o_scsi_get_host(c);
504 if (!i2o_shost)
505 return;
507 c->driver_data[i2o_scsi_driver.context] = NULL;
509 scsi_remove_host(i2o_shost->scsi_host);
510 scsi_host_put(i2o_shost->scsi_host);
511 osm_debug("I2O SCSI host removed\n");
514 /* SCSI OSM driver struct */
515 static struct i2o_driver i2o_scsi_driver = {
516 .name = OSM_NAME,
517 .reply = i2o_scsi_reply,
518 .classes = i2o_scsi_class_id,
519 .notify_controller_add = i2o_scsi_notify_controller_add,
520 .notify_controller_remove = i2o_scsi_notify_controller_remove,
521 .driver = {
522 .probe = i2o_scsi_probe,
523 .remove = i2o_scsi_remove,
528 * i2o_scsi_queuecommand - queue a SCSI command
529 * @SCpnt: scsi command pointer
530 * @done: callback for completion
532 * Issue a scsi command asynchronously. Return 0 on success or 1 if
533 * we hit an error (normally message queue congestion). The only
534 * minor complication here is that I2O deals with the device addressing
535 * so we have to map the bus/dev/lun back to an I2O handle as well
536 * as faking absent devices ourself.
538 * Locks: takes the controller lock on error path only
541 static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
542 void (*done) (struct scsi_cmnd *))
544 struct i2o_controller *c;
545 struct Scsi_Host *host;
546 struct i2o_device *i2o_dev;
547 struct device *dev;
548 int tid;
549 struct i2o_message __iomem *msg;
550 u32 m;
552 * ENABLE_DISCONNECT
553 * SIMPLE_TAG
554 * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME
556 u32 scsi_flags = 0x20a00000;
557 u32 sg_flags;
558 u32 __iomem *mptr;
559 u32 __iomem *lenptr;
560 u32 len;
561 int i;
564 * Do the incoming paperwork
567 i2o_dev = SCpnt->device->hostdata;
568 host = SCpnt->device->host;
569 c = i2o_dev->iop;
570 dev = &c->pdev->dev;
572 SCpnt->scsi_done = done;
574 if (unlikely(!i2o_dev)) {
575 osm_warn("no I2O device in request\n");
576 SCpnt->result = DID_NO_CONNECT << 16;
577 done(SCpnt);
578 return 0;
581 tid = i2o_dev->lct_data.tid;
583 osm_debug("qcmd: Tid = %03x\n", tid);
584 osm_debug("Real scsi messages.\n");
587 * Obtain an I2O message. If there are none free then
588 * throw it back to the scsi layer
591 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
592 if (m == I2O_QUEUE_EMPTY)
593 return SCSI_MLQUEUE_HOST_BUSY;
595 mptr = &msg->body[0];
598 * Put together a scsi execscb message
601 switch (SCpnt->sc_data_direction) {
602 case PCI_DMA_NONE:
603 /* DATA NO XFER */
604 sg_flags = 0x00000000;
605 break;
607 case PCI_DMA_TODEVICE:
608 /* DATA OUT (iop-->dev) */
609 scsi_flags |= 0x80000000;
610 sg_flags = 0x14000000;
611 break;
613 case PCI_DMA_FROMDEVICE:
614 /* DATA IN (iop<--dev) */
615 scsi_flags |= 0x40000000;
616 sg_flags = 0x10000000;
617 break;
619 default:
620 /* Unknown - kill the command */
621 SCpnt->result = DID_NO_CONNECT << 16;
622 done(SCpnt);
623 return 0;
626 writel(I2O_CMD_SCSI_EXEC << 24 | HOST_TID << 12 | tid, &msg->u.head[1]);
627 writel(i2o_scsi_driver.context, &msg->u.s.icntxt);
629 /* We want the SCSI control block back */
630 writel(i2o_cntxt_list_add(c, SCpnt), &msg->u.s.tcntxt);
632 /* LSI_920_PCI_QUIRK
634 * Intermittant observations of msg frame word data corruption
635 * observed on msg[4] after:
636 * WRITE, READ-MODIFY-WRITE
637 * operations. 19990606 -sralston
639 * (Hence we build this word via tag. Its good practice anyway
640 * we don't want fetches over PCI needlessly)
643 /* Attach tags to the devices */
645 if(SCpnt->device->tagged_supported) {
646 if(SCpnt->tag == HEAD_OF_QUEUE_TAG)
647 scsi_flags |= 0x01000000;
648 else if(SCpnt->tag == ORDERED_QUEUE_TAG)
649 scsi_flags |= 0x01800000;
653 writel(scsi_flags | SCpnt->cmd_len, mptr++);
655 /* Write SCSI command into the message - always 16 byte block */
656 memcpy_toio(mptr, SCpnt->cmnd, 16);
657 mptr += 4;
658 lenptr = mptr++; /* Remember me - fill in when we know */
660 /* Now fill in the SGList and command */
661 if (SCpnt->use_sg) {
662 struct scatterlist *sg;
663 int sg_count;
665 sg = SCpnt->request_buffer;
666 len = 0;
668 sg_count = dma_map_sg(dev, sg, SCpnt->use_sg,
669 SCpnt->sc_data_direction);
671 if (unlikely(sg_count <= 0))
672 return -ENOMEM;
674 for (i = SCpnt->use_sg; i > 0; i--) {
675 if (i == 1)
676 sg_flags |= 0xC0000000;
677 writel(sg_flags | sg_dma_len(sg), mptr++);
678 writel(sg_dma_address(sg), mptr++);
679 len += sg_dma_len(sg);
680 sg++;
683 writel(len, lenptr);
684 } else {
685 len = SCpnt->request_bufflen;
687 writel(len, lenptr);
689 if (len > 0) {
690 dma_addr_t dma_addr;
692 dma_addr = dma_map_single(dev, SCpnt->request_buffer,
693 SCpnt->request_bufflen,
694 SCpnt->sc_data_direction);
695 if (!dma_addr)
696 return -ENOMEM;
698 SCpnt->SCp.ptr = (void *)(unsigned long)dma_addr;
699 sg_flags |= 0xC0000000;
700 writel(sg_flags | SCpnt->request_bufflen, mptr++);
701 writel(dma_addr, mptr++);
705 /* Stick the headers on */
706 writel((mptr - &msg->u.head[0]) << 16 | SGL_OFFSET_10, &msg->u.head[0]);
708 /* Queue the message */
709 i2o_msg_post(c, m);
711 osm_debug("Issued %ld\n", SCpnt->serial_number);
713 return 0;
717 * i2o_scsi_abort - abort a running command
718 * @SCpnt: command to abort
720 * Ask the I2O controller to abort a command. This is an asynchrnous
721 * process and our callback handler will see the command complete with an
722 * aborted message if it succeeds.
724 * Returns 0 if the command is successfully aborted or negative error code
725 * on failure.
727 static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
729 struct i2o_device *i2o_dev;
730 struct i2o_controller *c;
731 struct i2o_message __iomem *msg;
732 u32 m;
733 int tid;
734 int status = FAILED;
736 osm_warn("Aborting command block.\n");
738 i2o_dev = SCpnt->device->hostdata;
739 c = i2o_dev->iop;
740 tid = i2o_dev->lct_data.tid;
742 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
743 if (m == I2O_QUEUE_EMPTY)
744 return SCSI_MLQUEUE_HOST_BUSY;
746 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
747 writel(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid,
748 &msg->u.head[1]);
749 writel(i2o_cntxt_list_get_ptr(c, SCpnt), &msg->body[0]);
751 if (i2o_msg_post_wait(c, m, I2O_TIMEOUT_SCSI_SCB_ABORT))
752 status = SUCCESS;
754 return status;
758 * i2o_scsi_bios_param - Invent disk geometry
759 * @sdev: scsi device
760 * @dev: block layer device
761 * @capacity: size in sectors
762 * @ip: geometry array
764 * This is anyones guess quite frankly. We use the same rules everyone
765 * else appears to and hope. It seems to work.
768 static int i2o_scsi_bios_param(struct scsi_device *sdev,
769 struct block_device *dev, sector_t capacity,
770 int *ip)
772 int size;
774 size = capacity;
775 ip[0] = 64; /* heads */
776 ip[1] = 32; /* sectors */
777 if ((ip[2] = size >> 11) > 1024) { /* cylinders, test for big disk */
778 ip[0] = 255; /* heads */
779 ip[1] = 63; /* sectors */
780 ip[2] = size / (255 * 63); /* cylinders */
782 return 0;
785 static struct scsi_host_template i2o_scsi_host_template = {
786 .proc_name = OSM_NAME,
787 .name = OSM_DESCRIPTION,
788 .info = i2o_scsi_info,
789 .queuecommand = i2o_scsi_queuecommand,
790 .eh_abort_handler = i2o_scsi_abort,
791 .bios_param = i2o_scsi_bios_param,
792 .can_queue = I2O_SCSI_CAN_QUEUE,
793 .sg_tablesize = 8,
794 .cmd_per_lun = 6,
795 .use_clustering = ENABLE_CLUSTERING,
799 * i2o_scsi_init - SCSI OSM initialization function
801 * Register SCSI OSM into I2O core.
803 * Returns 0 on success or negative error code on failure.
805 static int __init i2o_scsi_init(void)
807 int rc;
809 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
811 /* Register SCSI OSM into I2O core */
812 rc = i2o_driver_register(&i2o_scsi_driver);
813 if (rc) {
814 osm_err("Could not register SCSI driver\n");
815 return rc;
818 return 0;
822 * i2o_scsi_exit - SCSI OSM exit function
824 * Unregisters SCSI OSM from I2O core.
826 static void __exit i2o_scsi_exit(void)
828 /* Unregister I2O SCSI OSM from I2O core */
829 i2o_driver_unregister(&i2o_scsi_driver);
832 MODULE_AUTHOR("Red Hat Software");
833 MODULE_LICENSE("GPL");
834 MODULE_DESCRIPTION(OSM_DESCRIPTION);
835 MODULE_VERSION(OSM_VERSION);
837 module_init(i2o_scsi_init);
838 module_exit(i2o_scsi_exit);