int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, unsigned long timeout, struct i2o_dma *dma) { DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); struct i2o_exec_wait *wait; static u32 tcntxt = 0x80000000; unsigned long flags; int rc = 0; wait = i2o_exec_wait_alloc(); if (!wait) { i2o_msg_nop(c, msg); return -ENOMEM; } if (tcntxt == 0xffffffff) tcntxt = 0x80000000; if (dma) wait->dma = *dma; /* */ msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); wait->tcntxt = tcntxt++; msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt); wait->wq = &wq; /* */ list_add(&wait->list, &i2o_exec_wait_list); /* */ i2o_msg_post(c, msg); wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ); spin_lock_irqsave(&wait->lock, flags); wait->wq = NULL; if (wait->complete) rc = le32_to_cpu(wait->msg->body[0]) >> 24; else { /* */ if (dma)
/** * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers * @c: controller * @msg: message to post * @timeout: time in seconds to wait * @dma: i2o_dma struct of the DMA buffer to free on failure * * This API allows an OSM to post a message and then be told whether or * not the system received a successful reply. If the message times out * then the value '-ETIMEDOUT' is returned. This is a special case. In * this situation the message may (should) complete at an indefinite time * in the future. When it completes it will use the memory buffer * attached to the request. If -ETIMEDOUT is returned then the memory * buffer must not be freed. Instead the event completion will free them * for you. In all other cases the buffer are your problem. * * Returns 0 on success, negative error code on timeout or positive error * code from reply. */ int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, unsigned long timeout, struct i2o_dma *dma) { DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); struct i2o_exec_wait *wait; static u32 tcntxt = 0x80000000; unsigned long flags; int rc = 0; wait = i2o_exec_wait_alloc(); if (!wait) { i2o_msg_nop(c, msg); return -ENOMEM; } if (tcntxt == 0xffffffff) tcntxt = 0x80000000; if (dma) wait->dma = *dma; /* * Fill in the message initiator context and transaction context. * We will only use transaction contexts >= 0x80000000 for POST WAIT, * so we could find a POST WAIT reply easier in the reply handler. */ msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); wait->tcntxt = tcntxt++; msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt); wait->wq = &wq; /* * we add elements to the head, because if a entry in the list will * never be removed, we have to iterate over it every time */ list_add(&wait->list, &i2o_exec_wait_list); /* * 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. */ i2o_msg_post(c, msg); wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ); spin_lock_irqsave(&wait->lock, flags); wait->wq = NULL; if (wait->complete) rc = le32_to_cpu(wait->msg->body[0]) >> 24; else { /* * We cannot remove it now. This is important. When it does * terminate (which it must do if the controller has not * died...) then it will otherwise scribble on stuff. * * FIXME: try abort message */ if (dma)
/** * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers * @c: controller * @m: message to post * @timeout: time in seconds to wait * @dma: i2o_dma struct of the DMA buffer to free on failure * * This API allows an OSM to post a message and then be told whether or * not the system received a successful reply. If the message times out * then the value '-ETIMEDOUT' is returned. This is a special case. In * this situation the message may (should) complete at an indefinite time * in the future. When it completes it will use the memory buffer * attached to the request. If -ETIMEDOUT is returned then the memory * buffer must not be freed. Instead the event completion will free them * for you. In all other cases the buffer are your problem. * * Returns 0 on success, negative error code on timeout or positive error * code from reply. */ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long timeout, struct i2o_dma *dma) { DECLARE_WAIT_QUEUE_HEAD(wq); struct i2o_exec_wait *wait; static u32 tcntxt = 0x80000000; struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m); int rc = 0; wait = i2o_exec_wait_alloc(); if (!wait) return -ENOMEM; if (tcntxt == 0xffffffff) tcntxt = 0x80000000; if (dma) wait->dma = *dma; /* * Fill in the message initiator context and transaction context. * We will only use transaction contexts >= 0x80000000 for POST WAIT, * so we could find a POST WAIT reply easier in the reply handler. */ writel(i2o_exec_driver.context, &msg->u.s.icntxt); wait->tcntxt = tcntxt++; writel(wait->tcntxt, &msg->u.s.tcntxt); /* * 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. */ i2o_msg_post(c, m); if (!wait->complete) { wait->wq = &wq; /* * we add elements add the head, because if a entry in the list * will never be removed, we have to iterate over it every time */ list_add(&wait->list, &i2o_exec_wait_list); wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ); wait->wq = NULL; } barrier(); if (wait->complete) { rc = le32_to_cpu(wait->msg->body[0]) >> 24; i2o_flush_reply(c, wait->m); i2o_exec_wait_free(wait); } else {