Commit a1a5ea70 authored by Markus Lidel's avatar Markus Lidel Committed by Linus Torvalds

[PATCH] I2O: changed I2O API to create I2O messages in kernel memory

Changed the I2O API to create I2O messages first in kernel memory and then
transfer it at once over the PCI bus instead of sending each quad-word over
the PCI bus.
Signed-off-by: default avatarMarkus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 347a8dc3
...@@ -39,18 +39,18 @@ static struct i2o_class_id i2o_bus_class_id[] = { ...@@ -39,18 +39,18 @@ static struct i2o_class_id i2o_bus_class_id[] = {
*/ */
static int i2o_bus_scan(struct i2o_device *dev) static int i2o_bus_scan(struct i2o_device *dev)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return -ETIMEDOUT;
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.
tid);
return i2o_msg_post_wait(dev->iop, m, 60); return i2o_msg_post_wait(dev->iop, msg, 60);
}; };
/** /**
...@@ -59,8 +59,9 @@ static int i2o_bus_scan(struct i2o_device *dev) ...@@ -59,8 +59,9 @@ static int i2o_bus_scan(struct i2o_device *dev)
* *
* Returns count. * Returns count.
*/ */
static ssize_t i2o_bus_store_scan(struct device *d, struct device_attribute *attr, const char *buf, static ssize_t i2o_bus_store_scan(struct device *d,
size_t count) struct device_attribute *attr,
const char *buf, size_t count)
{ {
struct i2o_device *i2o_dev = to_i2o_device(d); struct i2o_device *i2o_dev = to_i2o_device(d);
int rc; int rc;
......
...@@ -35,18 +35,18 @@ ...@@ -35,18 +35,18 @@
static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
u32 type) u32 type)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return PTR_ERR(msg);
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid, &msg->u.head[1]); msg->u.head[1] =
writel(type, &msg->body[0]); cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid);
msg->body[0] = cpu_to_le32(type);
return i2o_msg_post_wait(dev->iop, m, 60); return i2o_msg_post_wait(dev->iop, msg, 60);
} }
/** /**
...@@ -419,10 +419,9 @@ int i2o_device_parse_lct(struct i2o_controller *c) ...@@ -419,10 +419,9 @@ int i2o_device_parse_lct(struct i2o_controller *c)
* ResultCount, ErrorInfoSize, BlockStatus and BlockSize. * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
*/ */
int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
int oplen, void *reslist, int reslen) int oplen, void *reslist, int reslen)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
u32 *res32 = (u32 *) reslist; u32 *res32 = (u32 *) reslist;
u32 *restmp = (u32 *) reslist; u32 *restmp = (u32 *) reslist;
int len = 0; int len = 0;
...@@ -437,26 +436,28 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, ...@@ -437,26 +436,28 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
if (i2o_dma_alloc(dev, &res, reslen, GFP_KERNEL)) if (i2o_dma_alloc(dev, &res, reslen, GFP_KERNEL))
return -ENOMEM; return -ENOMEM;
m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) { if (IS_ERR(msg)) {
i2o_dma_free(dev, &res); i2o_dma_free(dev, &res);
return -ETIMEDOUT; return PTR_ERR(msg);
} }
i = 0; i = 0;
writel(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid);
writel(0, &msg->body[i++]); msg->body[i++] = cpu_to_le32(0x00000000);
writel(0x4C000000 | oplen, &msg->body[i++]); /* OperationList */ msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */
memcpy_toio(&msg->body[i], oplist, oplen); memcpy(&msg->body[i], oplist, oplen);
i += (oplen / 4 + (oplen % 4 ? 1 : 0)); i += (oplen / 4 + (oplen % 4 ? 1 : 0));
writel(0xD0000000 | res.len, &msg->body[i++]); /* ResultList */ msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */
writel(res.phys, &msg->body[i++]); msg->body[i++] = cpu_to_le32(res.phys);
writel(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) | msg->u.head[0] =
SGL_OFFSET_5, &msg->u.head[0]); cpu_to_le32(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) |
SGL_OFFSET_5);
rc = i2o_msg_post_wait_mem(c, m, 10, &res); rc = i2o_msg_post_wait_mem(c, msg, 10, &res);
/* This only looks like a memory leak - don't "fix" it. */ /* This only looks like a memory leak - don't "fix" it. */
if (rc == -ETIMEDOUT) if (rc == -ETIMEDOUT)
......
...@@ -114,13 +114,12 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait) ...@@ -114,13 +114,12 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
* Returns 0 on success, negative error code on timeout or positive error * Returns 0 on success, negative error code on timeout or positive error
* code from reply. * code from reply.
*/ */
int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
timeout, struct i2o_dma *dma) unsigned long timeout, struct i2o_dma *dma)
{ {
DECLARE_WAIT_QUEUE_HEAD(wq); DECLARE_WAIT_QUEUE_HEAD(wq);
struct i2o_exec_wait *wait; struct i2o_exec_wait *wait;
static u32 tcntxt = 0x80000000; static u32 tcntxt = 0x80000000;
struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m);
int rc = 0; int rc = 0;
wait = i2o_exec_wait_alloc(); wait = i2o_exec_wait_alloc();
...@@ -138,15 +137,15 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long ...@@ -138,15 +137,15 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long
* We will only use transaction contexts >= 0x80000000 for POST WAIT, * We will only use transaction contexts >= 0x80000000 for POST WAIT,
* so we could find a POST WAIT reply easier in the reply handler. * so we could find a POST WAIT reply easier in the reply handler.
*/ */
writel(i2o_exec_driver.context, &msg->u.s.icntxt); msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
wait->tcntxt = tcntxt++; wait->tcntxt = tcntxt++;
writel(wait->tcntxt, &msg->u.s.tcntxt); msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt);
/* /*
* Post the message to the controller. At some point later it will * Post the message to the controller. At some point later it will
* return. If we time out before it returns then complete will be zero. * return. If we time out before it returns then complete will be zero.
*/ */
i2o_msg_post(c, m); i2o_msg_post(c, msg);
if (!wait->complete) { if (!wait->complete) {
wait->wq = &wq; wait->wq = &wq;
...@@ -266,7 +265,8 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m, ...@@ -266,7 +265,8 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
* *
* Returns number of bytes printed into buffer. * Returns number of bytes printed into buffer.
*/ */
static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute *attr, char *buf) static ssize_t i2o_exec_show_vendor_id(struct device *d,
struct device_attribute *attr, char *buf)
{ {
struct i2o_device *dev = to_i2o_device(d); struct i2o_device *dev = to_i2o_device(d);
u16 id; u16 id;
...@@ -286,7 +286,9 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute ...@@ -286,7 +286,9 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute
* *
* Returns number of bytes printed into buffer. * Returns number of bytes printed into buffer.
*/ */
static ssize_t i2o_exec_show_product_id(struct device *d, struct device_attribute *attr, char *buf) static ssize_t i2o_exec_show_product_id(struct device *d,
struct device_attribute *attr,
char *buf)
{ {
struct i2o_device *dev = to_i2o_device(d); struct i2o_device *dev = to_i2o_device(d);
u16 id; u16 id;
...@@ -385,23 +387,22 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m, ...@@ -385,23 +387,22 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
u32 context; u32 context;
if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) { if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {
struct i2o_message __iomem *pmsg;
u32 pm;
/* /*
* If Fail bit is set we must take the transaction context of * If Fail bit is set we must take the transaction context of
* the preserved message to find the right request again. * the preserved message to find the right request again.
*/ */
struct i2o_message __iomem *pmsg;
u32 pm;
pm = le32_to_cpu(msg->body[3]); pm = le32_to_cpu(msg->body[3]);
pmsg = i2o_msg_in_to_virt(c, pm); pmsg = i2o_msg_in_to_virt(c, pm);
context = readl(&pmsg->u.s.tcntxt);
i2o_report_status(KERN_INFO, "i2o_core", msg); i2o_report_status(KERN_INFO, "i2o_core", msg);
context = readl(&pmsg->u.s.tcntxt);
/* Release the preserved msg */ /* Release the preserved msg */
i2o_msg_nop(c, pm); i2o_msg_nop_mfa(c, pm);
} else } else
context = le32_to_cpu(msg->u.s.tcntxt); context = le32_to_cpu(msg->u.s.tcntxt);
...@@ -462,25 +463,26 @@ static void i2o_exec_event(struct i2o_event *evt) ...@@ -462,25 +463,26 @@ static void i2o_exec_event(struct i2o_event *evt)
*/ */
int i2o_exec_lct_get(struct i2o_controller *c) int i2o_exec_lct_get(struct i2o_controller *c)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
int i = 0; int i = 0;
int rc = -EAGAIN; int rc = -EAGAIN;
for (i = 1; i <= I2O_LCT_GET_TRIES; i++) { for (i = 1; i <= I2O_LCT_GET_TRIES; i++) {
m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return PTR_ERR(msg);
writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); msg->u.head[0] =
writel(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | ADAPTER_TID, cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
&msg->u.head[1]); msg->u.head[1] =
writel(0xffffffff, &msg->body[0]); cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
writel(0x00000000, &msg->body[1]); ADAPTER_TID);
writel(0xd0000000 | c->dlct.len, &msg->body[2]); msg->body[0] = cpu_to_le32(0xffffffff);
writel(c->dlct.phys, &msg->body[3]); msg->body[1] = cpu_to_le32(0x00000000);
msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
rc = i2o_msg_post_wait(c, m, I2O_TIMEOUT_LCT_GET); msg->body[3] = cpu_to_le32(c->dlct.phys);
rc = i2o_msg_post_wait(c, msg, I2O_TIMEOUT_LCT_GET);
if (rc < 0) if (rc < 0)
break; break;
...@@ -506,29 +508,28 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind) ...@@ -506,29 +508,28 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
{ {
i2o_status_block *sb = c->status_block.virt; i2o_status_block *sb = c->status_block.virt;
struct device *dev; struct device *dev;
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
dev = &c->pdev->dev; dev = &c->pdev->dev;
if (i2o_dma_realloc(dev, &c->dlct, sb->expected_lct_size, GFP_KERNEL)) if (i2o_dma_realloc(dev, &c->dlct, sb->expected_lct_size, GFP_KERNEL))
return -ENOMEM; return -ENOMEM;
m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return PTR_ERR(msg);
writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
writel(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | ADAPTER_TID, msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
&msg->u.head[1]); ADAPTER_TID);
writel(i2o_exec_driver.context, &msg->u.s.icntxt); msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
writel(0, &msg->u.s.tcntxt); /* FIXME */ msg->u.s.tcntxt = cpu_to_le32(0x00000000);
writel(0xffffffff, &msg->body[0]); msg->body[0] = cpu_to_le32(0xffffffff);
writel(change_ind, &msg->body[1]); msg->body[1] = cpu_to_le32(change_ind);
writel(0xd0000000 | c->dlct.len, &msg->body[2]); msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
writel(c->dlct.phys, &msg->body[3]); msg->body[3] = cpu_to_le32(c->dlct.phys);
i2o_msg_post(c, m); i2o_msg_post(c, msg);
return 0; return 0;
}; };
......
...@@ -130,20 +130,20 @@ static int i2o_block_remove(struct device *dev) ...@@ -130,20 +130,20 @@ static int i2o_block_remove(struct device *dev)
*/ */
static int i2o_block_device_flush(struct i2o_device *dev) static int i2o_block_device_flush(struct i2o_device *dev)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return PTR_ERR(msg);
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->lct_data.tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->
writel(60 << 16, &msg->body[0]); lct_data.tid);
msg->body[0] = cpu_to_le32(60 << 16);
osm_debug("Flushing...\n"); osm_debug("Flushing...\n");
return i2o_msg_post_wait(dev->iop, m, 60); return i2o_msg_post_wait(dev->iop, msg, 60);
}; };
/** /**
...@@ -181,21 +181,21 @@ static int i2o_block_issue_flush(request_queue_t * queue, struct gendisk *disk, ...@@ -181,21 +181,21 @@ static int i2o_block_issue_flush(request_queue_t * queue, struct gendisk *disk,
*/ */
static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); if (IS_ERR(msg))
if (m == I2O_QUEUE_EMPTY) return PTR_ERR(msg);
return -ETIMEDOUT;
msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[1] =
writel(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev->lct_data.tid, cpu_to_le32(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev->
&msg->u.head[1]); lct_data.tid);
writel(-1, &msg->body[0]); msg->body[0] = cpu_to_le32(-1);
writel(0, &msg->body[1]); msg->body[1] = cpu_to_le32(0x00000000);
osm_debug("Mounting...\n"); osm_debug("Mounting...\n");
return i2o_msg_post_wait(dev->iop, m, 2); return i2o_msg_post_wait(dev->iop, msg, 2);
}; };
/** /**
...@@ -210,20 +210,20 @@ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) ...@@ -210,20 +210,20 @@ 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) static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg) == I2O_QUEUE_EMPTY)
return -ETIMEDOUT; return PTR_ERR(msg);
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->
writel(-1, &msg->body[0]); lct_data.tid);
msg->body[0] = cpu_to_le32(-1);
osm_debug("Locking...\n"); osm_debug("Locking...\n");
return i2o_msg_post_wait(dev->iop, m, 2); return i2o_msg_post_wait(dev->iop, msg, 2);
}; };
/** /**
...@@ -238,20 +238,20 @@ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) ...@@ -238,20 +238,20 @@ 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) static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
{ {
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return PTR_ERR(msg);
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->
writel(media_id, &msg->body[0]); lct_data.tid);
msg->body[0] = cpu_to_le32(media_id);
osm_debug("Unlocking...\n"); osm_debug("Unlocking...\n");
return i2o_msg_post_wait(dev->iop, m, 2); return i2o_msg_post_wait(dev->iop, msg, 2);
}; };
/** /**
...@@ -267,21 +267,21 @@ static int i2o_block_device_power(struct i2o_block_device *dev, u8 op) ...@@ -267,21 +267,21 @@ static int i2o_block_device_power(struct i2o_block_device *dev, u8 op)
{ {
struct i2o_device *i2o_dev = dev->i2o_dev; struct i2o_device *i2o_dev = dev->i2o_dev;
struct i2o_controller *c = i2o_dev->iop; struct i2o_controller *c = i2o_dev->iop;
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
int rc; int rc;
m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return -ETIMEDOUT; return PTR_ERR(msg);
writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->lct_data. msg->u.head[1] =
tid, &msg->u.head[1]); cpu_to_le32(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->
writel(op << 24, &msg->body[0]); lct_data.tid);
msg->body[0] = cpu_to_le32(op << 24);
osm_debug("Power...\n"); osm_debug("Power...\n");
rc = i2o_msg_post_wait(c, m, 60); rc = i2o_msg_post_wait(c, msg, 60);
if (!rc) if (!rc)
dev->power = op; dev->power = op;
...@@ -331,7 +331,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq) ...@@ -331,7 +331,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
*/ */
static inline int i2o_block_sglist_alloc(struct i2o_controller *c, static inline int i2o_block_sglist_alloc(struct i2o_controller *c,
struct i2o_block_request *ireq, struct i2o_block_request *ireq,
u32 __iomem ** mptr) u32 ** mptr)
{ {
int nents; int nents;
enum dma_data_direction direction; enum dma_data_direction direction;
...@@ -745,10 +745,9 @@ static int i2o_block_transfer(struct request *req) ...@@ -745,10 +745,9 @@ static int i2o_block_transfer(struct request *req)
struct i2o_block_device *dev = req->rq_disk->private_data; struct i2o_block_device *dev = req->rq_disk->private_data;
struct i2o_controller *c; struct i2o_controller *c;
int tid = dev->i2o_dev->lct_data.tid; int tid = dev->i2o_dev->lct_data.tid;
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 __iomem *mptr; u32 *mptr;
struct i2o_block_request *ireq = req->special; struct i2o_block_request *ireq = req->special;
u32 m;
u32 tcntxt; u32 tcntxt;
u32 sgl_offset = SGL_OFFSET_8; u32 sgl_offset = SGL_OFFSET_8;
u32 ctl_flags = 0x00000000; u32 ctl_flags = 0x00000000;
...@@ -763,9 +762,9 @@ static int i2o_block_transfer(struct request *req) ...@@ -763,9 +762,9 @@ static int i2o_block_transfer(struct request *req)
c = dev->i2o_dev->iop; c = dev->i2o_dev->iop;
m = i2o_msg_get(c, &msg); msg = i2o_msg_get(c);
if (m == I2O_QUEUE_EMPTY) { if (IS_ERR(msg)) {
rc = -EBUSY; rc = PTR_ERR(msg);
goto exit; goto exit;
} }
...@@ -775,8 +774,8 @@ static int i2o_block_transfer(struct request *req) ...@@ -775,8 +774,8 @@ static int i2o_block_transfer(struct request *req)
goto nop_msg; goto nop_msg;
} }
writel(i2o_block_driver.context, &msg->u.s.icntxt); msg->u.s.icntxt = cpu_to_le32(i2o_block_driver.context);
writel(tcntxt, &msg->u.s.tcntxt); msg->u.s.tcntxt = cpu_to_le32(tcntxt);
mptr = &msg->body[0]; mptr = &msg->body[0];
...@@ -834,11 +833,11 @@ static int i2o_block_transfer(struct request *req) ...@@ -834,11 +833,11 @@ static int i2o_block_transfer(struct request *req)
sgl_offset = SGL_OFFSET_12; sgl_offset = SGL_OFFSET_12;
writel(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid);
writel(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC, mptr++); *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
writel(tid, mptr++); *mptr++ = cpu_to_le32(tid);
/* /*
* ENABLE_DISCONNECT * ENABLE_DISCONNECT
...@@ -853,22 +852,24 @@ static int i2o_block_transfer(struct request *req) ...@@ -853,22 +852,24 @@ static int i2o_block_transfer(struct request *req)
scsi_flags = 0xa0a0000a; scsi_flags = 0xa0a0000a;
} }
writel(scsi_flags, mptr++); *mptr++ = cpu_to_le32(scsi_flags);
*((u32 *) & cmd[2]) = cpu_to_be32(req->sector * hwsec); *((u32 *) & cmd[2]) = cpu_to_be32(req->sector * hwsec);
*((u16 *) & cmd[7]) = cpu_to_be16(req->nr_sectors * hwsec); *((u16 *) & cmd[7]) = cpu_to_be16(req->nr_sectors * hwsec);
memcpy_toio(mptr, cmd, 10); memcpy(mptr, cmd, 10);
mptr += 4; mptr += 4;
writel(req->nr_sectors << KERNEL_SECTOR_SHIFT, mptr++); *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT);
} else } else
#endif #endif
{ {
writel(cmd | HOST_TID << 12 | tid, &msg->u.head[1]); msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
writel(ctl_flags, mptr++); *mptr++ = cpu_to_le32(ctl_flags);
writel(req->nr_sectors << KERNEL_SECTOR_SHIFT, mptr++); *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT);
writel((u32) (req->sector << KERNEL_SECTOR_SHIFT), mptr++); *mptr++ =
writel(req->sector >> (32 - KERNEL_SECTOR_SHIFT), mptr++); cpu_to_le32((u32) (req->sector << KERNEL_SECTOR_SHIFT));
*mptr++ =
cpu_to_le32(req->sector >> (32 - KERNEL_SECTOR_SHIFT));
} }
if (!i2o_block_sglist_alloc(c, ireq, &mptr)) { if (!i2o_block_sglist_alloc(c, ireq, &mptr)) {
...@@ -876,13 +877,13 @@ static int i2o_block_transfer(struct request *req) ...@@ -876,13 +877,13 @@ static int i2o_block_transfer(struct request *req)
goto context_remove; goto context_remove;
} }
writel(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | msg->u.head[0] =
sgl_offset, &msg->u.head[0]); cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
list_add_tail(&ireq->queue, &dev->open_queue); list_add_tail(&ireq->queue, &dev->open_queue);
dev->open_queue_depth++; dev->open_queue_depth++;
i2o_msg_post(c, m); i2o_msg_post(c, msg);
return 0; return 0;
...@@ -890,7 +891,7 @@ static int i2o_block_transfer(struct request *req) ...@@ -890,7 +891,7 @@ static int i2o_block_transfer(struct request *req)
i2o_cntxt_list_remove(c, req); i2o_cntxt_list_remove(c, req);
nop_msg: nop_msg:
i2o_msg_nop(c, m); i2o_msg_nop(c, msg);
exit: exit:
return rc; return rc;
......
This diff is collapsed.
...@@ -510,8 +510,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -510,8 +510,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
struct i2o_controller *c; struct i2o_controller *c;
struct i2o_device *i2o_dev; struct i2o_device *i2o_dev;
int tid; int tid;
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
/* /*
* ENABLE_DISCONNECT * ENABLE_DISCONNECT
* SIMPLE_TAG * SIMPLE_TAG
...@@ -519,7 +518,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -519,7 +518,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
*/ */
u32 scsi_flags = 0x20a00000; u32 scsi_flags = 0x20a00000;
u32 sgl_offset; u32 sgl_offset;
u32 __iomem *mptr; u32 *mptr;
u32 cmd = I2O_CMD_SCSI_EXEC << 24; u32 cmd = I2O_CMD_SCSI_EXEC << 24;
int rc = 0; int rc = 0;
...@@ -576,8 +575,8 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -576,8 +575,8 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
* throw it back to the scsi layer * throw it back to the scsi layer
*/ */
m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get(c);
if (m == I2O_QUEUE_EMPTY) { if (IS_ERR(msg)) {
rc = SCSI_MLQUEUE_HOST_BUSY; rc = SCSI_MLQUEUE_HOST_BUSY;
goto exit; goto exit;
} }
...@@ -617,16 +616,16 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -617,16 +616,16 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
if (sgl_offset == SGL_OFFSET_10) if (sgl_offset == SGL_OFFSET_10)
sgl_offset = SGL_OFFSET_12; sgl_offset = SGL_OFFSET_12;
cmd = I2O_CMD_PRIVATE << 24; cmd = I2O_CMD_PRIVATE << 24;
writel(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC, mptr++); *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
writel(adpt_flags | tid, mptr++); *mptr++ = cpu_to_le32(adpt_flags | tid);
} }
#endif #endif
writel(cmd | HOST_TID << 12 | tid, &msg->u.head[1]); msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
writel(i2o_scsi_driver.context, &msg->u.s.icntxt); msg->u.s.icntxt = cpu_to_le32(i2o_scsi_driver.context);
/* We want the SCSI control block back */ /* We want the SCSI control block back */
writel(i2o_cntxt_list_add(c, SCpnt), &msg->u.s.tcntxt); msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, SCpnt));
/* LSI_920_PCI_QUIRK /* LSI_920_PCI_QUIRK
* *
...@@ -649,15 +648,15 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -649,15 +648,15 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
} }
*/ */
writel(scsi_flags | SCpnt->cmd_len, mptr++); *mptr++ = cpu_to_le32(scsi_flags | SCpnt->cmd_len);
/* Write SCSI command into the message - always 16 byte block */ /* Write SCSI command into the message - always 16 byte block */
memcpy_toio(mptr, SCpnt->cmnd, 16); memcpy(mptr, SCpnt->cmnd, 16);
mptr += 4; mptr += 4;
if (sgl_offset != SGL_OFFSET_0) { if (sgl_offset != SGL_OFFSET_0) {
/* write size of data addressed by SGL */ /* write size of data addressed by SGL */
writel(SCpnt->request_bufflen, mptr++); *mptr++ = cpu_to_le32(SCpnt->request_bufflen);
/* Now fill in the SGList and command */ /* Now fill in the SGList and command */
if (SCpnt->use_sg) { if (SCpnt->use_sg) {
...@@ -676,11 +675,11 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -676,11 +675,11 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
} }
/* Stick the headers on */ /* Stick the headers on */
writel(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset, msg->u.head[0] =
&msg->u.head[0]); cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
/* Queue the message */ /* Queue the message */
i2o_msg_post(c, m); i2o_msg_post(c, msg);
osm_debug("Issued %ld\n", SCpnt->serial_number); osm_debug("Issued %ld\n", SCpnt->serial_number);
...@@ -688,7 +687,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -688,7 +687,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
nomem: nomem:
rc = -ENOMEM; rc = -ENOMEM;
i2o_msg_nop(c, m); i2o_msg_nop(c, msg);
exit: exit:
return rc; return rc;
...@@ -709,8 +708,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt) ...@@ -709,8 +708,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
{ {
struct i2o_device *i2o_dev; struct i2o_device *i2o_dev;
struct i2o_controller *c; struct i2o_controller *c;
struct i2o_message __iomem *msg; struct i2o_message *msg;
u32 m;
int tid; int tid;
int status = FAILED; int status = FAILED;
...@@ -720,16 +718,16 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt) ...@@ -720,16 +718,16 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
c = i2o_dev->iop; c = i2o_dev->iop;
tid = i2o_dev->lct_data.tid; tid = i2o_dev->lct_data.tid;
m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
if (m == I2O_QUEUE_EMPTY) if (IS_ERR(msg))
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
writel(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid, msg->u.head[1] =
&msg->u.head[1]); cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid);
writel(i2o_cntxt_list_get_ptr(c, SCpnt), &msg->body[0]); msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt));
if (i2o_msg_post_wait(c, m, I2O_TIMEOUT_SCSI_SCB_ABORT)) if (i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT))
status = SUCCESS; status = SUCCESS;
return status; return status;
......
This diff is collapsed.
...@@ -483,4 +483,5 @@ void __exit i2o_pci_exit(void) ...@@ -483,4 +483,5 @@ void __exit i2o_pci_exit(void)
{ {
pci_unregister_driver(&i2o_pci_driver); pci_unregister_driver(&i2o_pci_driver);
}; };
MODULE_DEVICE_TABLE(pci, i2o_pci_ids); MODULE_DEVICE_TABLE(pci, i2o_pci_ids);
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment