X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmessage%2Fi2o%2Fi2o_block.c;h=7b74c87b569e77869cbbe72a8c574c1a258059f7;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=102fb83164c071f0ca79687051a531e63295a6f5;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 102fb8316..7b74c87b5 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -61,6 +61,10 @@ #include "i2o_block.h" +#define OSM_NAME "block-osm" +#define OSM_VERSION "$Rev$" +#define OSM_DESCRIPTION "I2O Block Device OSM" + static struct i2o_driver i2o_block_driver; /* global Block OSM request mempool */ @@ -100,8 +104,7 @@ static int i2o_block_remove(struct device *dev) struct i2o_device *i2o_dev = to_i2o_device(dev); struct i2o_block_device *i2o_blk_dev = dev_get_drvdata(dev); - printk(KERN_INFO "block-osm: Device removed %s\n", - i2o_blk_dev->gd->disk_name); + osm_info("Device removed %s\n", i2o_blk_dev->gd->disk_name); i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0); @@ -126,7 +129,7 @@ static int i2o_block_remove(struct device *dev) */ static int i2o_block_device_flush(struct i2o_device *dev) { - struct i2o_message *msg; + struct i2o_message __iomem *msg; u32 m; m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); @@ -137,7 +140,7 @@ static int i2o_block_device_flush(struct i2o_device *dev) writel(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->lct_data.tid, &msg->u.head[1]); writel(60 << 16, &msg->body[0]); - pr_debug("Flushing...\n"); + osm_debug("Flushing...\n"); return i2o_msg_post_wait(dev->iop, m, 60); }; @@ -154,7 +157,7 @@ static int i2o_block_device_flush(struct i2o_device *dev) */ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) { - struct i2o_message *msg; + struct i2o_message __iomem *msg; u32 m; m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); @@ -166,7 +169,7 @@ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) &msg->u.head[1]); writel(-1, &msg->body[0]); writel(0, &msg->body[1]); - pr_debug("Mounting...\n"); + osm_debug("Mounting...\n"); return i2o_msg_post_wait(dev->iop, m, 2); }; @@ -183,7 +186,7 @@ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) */ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) { - struct i2o_message *msg; + struct i2o_message __iomem *msg; u32 m; m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); @@ -194,7 +197,7 @@ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) writel(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, &msg->u.head[1]); writel(-1, &msg->body[0]); - pr_debug("Locking...\n"); + osm_debug("Locking...\n"); return i2o_msg_post_wait(dev->iop, m, 2); }; @@ -211,7 +214,7 @@ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) */ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id) { - struct i2o_message *msg; + struct i2o_message __iomem *msg; u32 m; m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); @@ -222,7 +225,7 @@ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id) writel(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, &msg->u.head[1]); writel(media_id, &msg->body[0]); - pr_debug("Unlocking...\n"); + osm_debug("Unlocking...\n"); return i2o_msg_post_wait(dev->iop, m, 2); }; @@ -240,7 +243,7 @@ static int i2o_block_device_power(struct i2o_block_device *dev, u8 op) { struct i2o_device *i2o_dev = dev->i2o_dev; struct i2o_controller *c = i2o_dev->iop; - struct i2o_message *msg; + struct i2o_message __iomem *msg; u32 m; int rc; @@ -252,7 +255,7 @@ static int i2o_block_device_power(struct i2o_block_device *dev, u8 op) writel(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->lct_data. tid, &msg->u.head[1]); writel(op << 24, &msg->body[0]); - pr_debug("Power...\n"); + osm_debug("Power...\n"); rc = i2o_msg_post_wait(c, m, 60); if (!rc) @@ -350,7 +353,7 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req) /* request is already processed by us, so return */ if (req->flags & REQ_SPECIAL) { - pr_debug("REQ_SPECIAL already set!\n"); + osm_debug("REQ_SPECIAL already set!\n"); req->flags |= REQ_DONTPREP; return BLKPREP_OK; } @@ -359,7 +362,7 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req) if (!req->special) { ireq = i2o_block_request_alloc(); if (unlikely(IS_ERR(ireq))) { - pr_debug("unable to allocate i2o_block_request!\n"); + osm_debug("unable to allocate i2o_block_request!\n"); return BLKPREP_DEFER; } @@ -416,11 +419,10 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, unsigned long flags; /* FAILed message */ - if (unlikely(readl(&msg->u.head[0]) & (1 << 13))) { + if (unlikely(le32_to_cpu(msg->u.head[0]) & (1 << 13))) { struct i2o_message *pmsg; u32 pm; - printk(KERN_WARNING "FAIL"); /* * FAILed message from controller * We increment the error count and abort it @@ -431,12 +433,12 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, * better be on the safe side since no one really follows * the spec to the book :) */ - pm = readl(&msg->body[3]); - pmsg = c->in_queue.virt + pm; + pm = le32_to_cpu(msg->body[3]); + pmsg = i2o_msg_in_to_virt(c, pm); - req = i2o_cntxt_list_get(c, readl(&pmsg->u.s.tcntxt)); + req = i2o_cntxt_list_get(c, le32_to_cpu(pmsg->u.s.tcntxt)); if (unlikely(!req)) { - printk(KERN_ERR "block-osm: NULL reply received!\n"); + osm_err("NULL reply received!\n"); return -1; } @@ -449,7 +451,7 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, spin_lock_irqsave(q->queue_lock, flags); while (end_that_request_chunk(req, !req->errors, - readl(&pmsg->body[1]))) ; + le32_to_cpu(pmsg->body[1]))) ; end_that_request_last(req); dev->open_queue_depth--; @@ -464,9 +466,9 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, return -1; } - req = i2o_cntxt_list_get(c, readl(&msg->u.s.tcntxt)); + req = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt)); if (unlikely(!req)) { - printk(KERN_ERR "block-osm: NULL reply received!\n"); + osm_err("NULL reply received!\n"); return -1; } @@ -483,11 +485,10 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, * goes kaput... */ req->errors++; - printk(KERN_WARNING - "I2O Block: Data transfer to deleted device!\n"); + osm_warn("Data transfer to deleted device!\n"); spin_lock_irqsave(q->queue_lock, flags); while (end_that_request_chunk - (req, !req->errors, readl(&msg->body[1]))) ; + (req, !req->errors, le32_to_cpu(msg->body[1]))) ; end_that_request_last(req); dev->open_queue_depth--; @@ -503,7 +504,7 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, * request in the context. */ - st = readl(&msg->body[0]) >> 24; + st = le32_to_cpu(msg->body[0]) >> 24; if (st != 0) { int err; @@ -524,7 +525,7 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, "Volume has changed, waiting for acknowledgement" }; - err = readl(&msg->body[0]) & 0xffff; + err = le32_to_cpu(msg->body[0]) & 0xffff; /* * Device not ready means two things. One is that the @@ -538,17 +539,18 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, * Don't stick a supertrak100 into cache aggressive modes */ - printk(KERN_ERR "\n/dev/%s error: %s", dev->gd->disk_name, - bsa_errors[readl(&msg->body[0]) & 0xffff]); - if (readl(&msg->body[0]) & 0x00ff0000) - printk(" - DDM attempted %d retries", - (readl(&msg->body[0]) >> 16) & 0x00ff); - printk(".\n"); + osm_err("block-osm: /dev/%s error: %s", dev->gd->disk_name, + bsa_errors[le32_to_cpu(msg->body[0]) & 0xffff]); + if (le32_to_cpu(msg->body[0]) & 0x00ff0000) + printk(KERN_ERR " - DDM attempted %d retries", + (le32_to_cpu(msg->body[0]) >> 16) & 0x00ff); + printk(KERN_ERR ".\n"); req->errors++; } else req->errors = 0; - if (!end_that_request_chunk(req, !req->errors, readl(&msg->body[1]))) { + if (!end_that_request_chunk + (req, !req->errors, le32_to_cpu(msg->body[1]))) { add_disk_randomness(req->rq_disk); spin_lock_irqsave(q->queue_lock, flags); @@ -563,184 +565,16 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m, i2o_block_sglist_free(ireq); i2o_block_request_free(ireq); } else - printk(KERN_ERR "still remaining chunks\n"); + osm_err("still remaining chunks\n"); return 1; }; static void i2o_block_event(struct i2o_event *evt) { - printk(KERN_INFO "block-osm: event received\n"); + osm_info("block-osm: event received\n"); }; -#if 0 -static int i2o_block_event(void *dummy) -{ - unsigned int evt; - unsigned long flags; - struct i2o_block_device *dev; - int unit; - //The only event that has data is the SCSI_SMART event. - struct i2o_reply { - u32 header[4]; - u32 evt_indicator; - u8 ASC; - u8 ASCQ; - u16 pad; - u8 data[16]; - } *evt_local; - - daemonize("i2oblock"); - allow_signal(SIGKILL); - - evt_running = 1; - - while (1) { - if (down_interruptible(&i2ob_evt_sem)) { - evt_running = 0; - printk("exiting..."); - break; - } - - /* - * Keep another CPU/interrupt from overwriting the - * message while we're reading it - * - * We stuffed the unit in the TxContext and grab the event mask - * None of the BSA we care about events have EventData - */ - spin_lock_irqsave(&i2ob_evt_lock, flags); - evt_local = (struct i2o_reply *)evt_msg; - spin_unlock_irqrestore(&i2ob_evt_lock, flags); - - unit = le32_to_cpu(evt_local->header[3]); - evt = le32_to_cpu(evt_local->evt_indicator); - - dev = &i2o_blk_dev[unit]; - switch (evt) { - /* - * New volume loaded on same TID, so we just re-install. - * The TID/controller don't change as it is the same - * I2O device. It's just new media that we have to - * rescan. - */ - case I2O_EVT_IND_BSA_VOLUME_LOAD: - { - i2ob_install_device(dev->i2o_device->iop, - dev->i2o_device, unit); - add_disk(dev->gendisk); - break; - } - - /* - * No media, so set all parameters to 0 and set the media - * change flag. The I2O device is still valid, just doesn't - * have media, so we don't want to clear the controller or - * device pointer. - */ - case I2O_EVT_IND_BSA_VOLUME_UNLOAD: - { - struct gendisk *p = dev->gendisk; - blk_queue_max_sectors(dev->gendisk->queue, 0); - del_gendisk(p); - put_disk(p); - dev->gendisk = NULL; - dev->media_change_flag = 1; - break; - } - - case I2O_EVT_IND_BSA_VOLUME_UNLOAD_REQ: - printk(KERN_WARNING - "%s: Attempt to eject locked media\n", - dev->i2o_device->dev_name); - break; - - /* - * The capacity has changed and we are going to be - * updating the max_sectors and other information - * about this disk. We try a revalidate first. If - * the block device is in use, we don't want to - * do that as there may be I/Os bound for the disk - * at the moment. In that case we read the size - * from the device and update the information ourselves - * and the user can later force a partition table - * update through an ioctl. - */ - case I2O_EVT_IND_BSA_CAPACITY_CHANGE: - { - u64 size; - - if (i2ob_query_device(dev, 0x0004, 0, &size, 8) - != 0) - i2ob_query_device(dev, 0x0000, 4, &size, - 8); - - spin_lock_irqsave(dev->req_queue->queue_lock, - flags); - set_capacity(dev->gendisk, size >> 9); - spin_unlock_irqrestore(dev->req_queue-> - queue_lock, flags); - break; - } - - /* - * We got a SCSI SMART event, we just log the relevant - * information and let the user decide what they want - * to do with the information. - */ - case I2O_EVT_IND_BSA_SCSI_SMART: - { - char buf[16]; - printk(KERN_INFO - "I2O Block: %s received a SCSI SMART Event\n", - dev->i2o_device->dev_name); - evt_local->data[16] = '\0'; - sprintf(buf, "%s", &evt_local->data[0]); - printk(KERN_INFO " Disk Serial#:%s\n", - buf); - printk(KERN_INFO " ASC 0x%02x \n", - evt_local->ASC); - printk(KERN_INFO " ASCQ 0x%02x \n", - evt_local->ASCQ); - break; - } - - /* - * Non event - */ - - case 0: - break; - - /* - * An event we didn't ask for. Call the card manufacturer - * and tell them to fix their firmware :) - */ - - case 0x20: - /* - * If a promise card reports 0x20 event then the brown stuff - * hit the fan big time. The card seems to recover but loses - * the pending writes. Deeply ungood except for testing fsck - */ - if (dev->i2o_device->iop->promise) - panic - ("I2O controller firmware failed. Reboot and force a filesystem check.\n"); - default: - printk(KERN_INFO - "%s: Received event 0x%X we didn't register for\n" - KERN_INFO - " Blame the I2O card manufacturer 8)\n", - dev->i2o_device->dev_name, evt); - break; - } - }; - - complete_and_exit(&i2ob_thread_dead, 0); - return 0; -} -#endif - /* * SCSI-CAM for ioctl geometry mapping * Duplicated with SCSI - this should be moved into somewhere common @@ -816,7 +650,7 @@ static int i2o_block_open(struct inode *inode, struct file *file) i2o_block_device_lock(dev->i2o_dev, -1); - pr_debug("Ready.\n"); + osm_debug("Ready.\n"); return 0; }; @@ -945,8 +779,8 @@ static int i2o_block_transfer(struct request *req) struct i2o_block_device *dev = req->rq_disk->private_data; struct i2o_controller *c = dev->i2o_dev->iop; int tid = dev->i2o_dev->lct_data.tid; - struct i2o_message *msg; - void *mptr; + struct i2o_message __iomem *msg; + void __iomem *mptr; struct i2o_block_request *ireq = req->special; struct scatterlist *sg; int sgnum; @@ -1045,11 +879,11 @@ static int i2o_block_transfer(struct request *req) (unsigned long)&msg->u.head[0]) >> 2) | SGL_OFFSET_8, &msg->u.head[0]); - i2o_msg_post(c, m); - list_add_tail(&ireq->queue, &dev->open_queue); dev->open_queue_depth++; + i2o_msg_post(c, m); + return 0; context_remove: @@ -1104,7 +938,7 @@ static void i2o_block_request_fn(struct request_queue *q) INIT_WORK(&dreq->work, i2o_block_delayed_request_fn, dreq); - printk(KERN_INFO "block-osm: transfer error\n"); + osm_info("transfer error\n"); if (!queue_delayed_work(i2o_block_driver.event_queue, &dreq->work, I2O_BLOCK_RETRY_TIME)) @@ -1145,8 +979,7 @@ static struct i2o_block_device *i2o_block_device_alloc(void) dev = kmalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { - printk(KERN_ERR "block-osm: Insufficient memory to allocate " - "I2O Block disk.\n"); + osm_err("Insufficient memory to allocate I2O Block disk.\n"); rc = -ENOMEM; goto exit; } @@ -1160,8 +993,7 @@ static struct i2o_block_device *i2o_block_device_alloc(void) /* allocate a gendisk with 16 partitions */ gd = alloc_disk(16); if (!gd) { - printk(KERN_ERR "block-osm: Insufficient memory to allocate " - "gendisk.\n"); + osm_err("Insufficient memory to allocate gendisk.\n"); rc = -ENOMEM; goto cleanup_dev; } @@ -1169,8 +1001,7 @@ static struct i2o_block_device *i2o_block_device_alloc(void) /* initialize the request queue */ queue = blk_init_queue(i2o_block_request_fn, &dev->lock); if (!queue) { - printk(KERN_ERR "block-osm: Insufficient memory to allocate " - "request queue.\n"); + osm_err("Insufficient memory to allocate request queue.\n"); rc = -ENOMEM; goto cleanup_queue; } @@ -1222,24 +1053,21 @@ static int i2o_block_probe(struct device *dev) /* skip devices which are used by IOP */ if (i2o_dev->lct_data.user_tid != 0xfff) { - pr_debug("skipping used device %03x\n", i2o_dev->lct_data.tid); + osm_debug("skipping used device %03x\n", i2o_dev->lct_data.tid); return -ENODEV; } - printk(KERN_INFO "block-osm: New device detected (TID: %03x)\n", - i2o_dev->lct_data.tid); + osm_info("New device detected (TID: %03x)\n", i2o_dev->lct_data.tid); if (i2o_device_claim(i2o_dev)) { - printk(KERN_WARNING "block-osm: Unable to claim device. " - "Installation aborted\n"); + osm_warn("Unable to claim device. Installation aborted\n"); rc = -EFAULT; goto exit; } i2o_blk_dev = i2o_block_device_alloc(); if (IS_ERR(i2o_blk_dev)) { - printk(KERN_ERR "block-osm: could not alloc a new I2O block" - "device"); + osm_err("could not alloc a new I2O block device"); rc = PTR_ERR(i2o_blk_dev); goto claim_release; } @@ -1274,9 +1102,9 @@ static int i2o_block_probe(struct device *dev) blk_queue_max_hw_segments(queue, segments); - pr_debug("max sectors: %d\n", I2O_MAX_SECTORS); - pr_debug("phys segments: %d\n", I2O_MAX_SEGMENTS); - pr_debug("hw segments: %d\n", segments); + osm_debug("max sectors = %d\n", I2O_MAX_SECTORS); + osm_debug("phys segments = %d\n", I2O_MAX_SEGMENTS); + osm_debug("hw segments = %d\n", segments); /* * Ask for the current media data. If that isn't supported @@ -1287,7 +1115,7 @@ static int i2o_block_probe(struct device *dev) i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4); i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8); } - pr_debug("blocksize: %d\n", blocksize); + osm_debug("blocksize = %d\n", blocksize); if (i2o_parm_field_get(i2o_dev, 0x0000, 2, &power, 2)) power = 0; @@ -1313,7 +1141,7 @@ static int i2o_block_probe(struct device *dev) /* Block OSM driver struct */ static struct i2o_driver i2o_block_driver = { - .name = "block-osm", + .name = OSM_NAME, .event = i2o_block_event, .reply = i2o_block_reply, .classes = i2o_block_class_id, @@ -1336,8 +1164,7 @@ static int __init i2o_block_init(void) int rc; int size; - printk(KERN_INFO "I2O Block Storage OSM v0.9\n"); - printk(KERN_INFO " (c) Copyright 1999-2001 Red Hat Software.\n"); + printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); /* Allocate request mempool and slab */ size = sizeof(struct i2o_block_request); @@ -1345,7 +1172,7 @@ static int __init i2o_block_init(void) SLAB_HWCACHE_ALIGN, NULL, NULL); if (!i2o_blk_req_pool.slab) { - printk(KERN_ERR "block-osm: can't init request slab\n"); + osm_err("can't init request slab\n"); rc = -ENOMEM; goto exit; } @@ -1355,7 +1182,7 @@ static int __init i2o_block_init(void) mempool_free_slab, i2o_blk_req_pool.slab); if (!i2o_blk_req_pool.pool) { - printk(KERN_ERR "block-osm: can't init request mempool\n"); + osm_err("can't init request mempool\n"); rc = -ENOMEM; goto free_slab; } @@ -1363,18 +1190,17 @@ static int __init i2o_block_init(void) /* Register the block device interfaces */ rc = register_blkdev(I2O_MAJOR, "i2o_block"); if (rc) { - printk(KERN_ERR "block-osm: unable to register block device\n"); + osm_err("unable to register block device\n"); goto free_mempool; } #ifdef MODULE - printk(KERN_INFO "block-osm: registered device at major %d\n", - I2O_MAJOR); + osm_info("registered device at major %d\n", I2O_MAJOR); #endif /* Register Block OSM into I2O core */ rc = i2o_driver_register(&i2o_block_driver); if (rc) { - printk(KERN_ERR "block-osm: Could not register Block driver\n"); + osm_err("Could not register Block driver\n"); goto unregister_blkdev; } @@ -1413,8 +1239,9 @@ static void __exit i2o_block_exit(void) }; MODULE_AUTHOR("Red Hat"); -MODULE_DESCRIPTION("I2O Block Device OSM"); MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION(OSM_DESCRIPTION); +MODULE_VERSION(OSM_VERSION); module_init(i2o_block_init); module_exit(i2o_block_exit);