28 #include <linux/module.h>
31 #include <linux/sched.h>
32 #include <linux/slab.h>
35 #define OSM_NAME "i2o"
36 #define OSM_VERSION "1.325"
37 #define OSM_DESCRIPTION "I2O subsystem"
46 static struct i2o_dma i2o_systab;
68 while (IS_ERR(msg = i2o_msg_get(c))) {
70 osm_debug(
"%s: Timeout waiting for message frame.\n",
80 #if BITS_PER_LONG == 64
98 osm_err(
"%s: couldn't add NULL pointer to context list!\n",
103 osm_err(
"%s: Could not allocate memory for context list element"
110 INIT_LIST_HEAD(&entry->
list);
119 list_add(&entry->
list, &c->context_list);
121 spin_unlock_irqrestore(&c->context_list_lock, flags);
146 if (entry->ptr == ptr) {
152 spin_unlock_irqrestore(&c->context_list_lock, flags);
155 osm_warn(
"%s: Could not remove nonexistent ptr %p\n", c->
name,
158 osm_debug(
"%s: remove ptr from context list %d -> %p\n", c->
name,
180 if (entry->context == context) {
186 spin_unlock_irqrestore(&c->context_list_lock, flags);
189 osm_warn(
"%s: context id %d not found\n", c->
name, context);
191 osm_debug(
"%s: get ptr from context list %d -> %p\n", c->
name, context,
213 if (entry->ptr == ptr) {
217 spin_unlock_irqrestore(&c->context_list_lock, flags);
220 osm_warn(
"%s: Could not find nonexistent ptr %p\n", c->
name,
223 osm_debug(
"%s: get context id from context list %p -> %d\n", c->
name,
303 if ((rc = i2o_msg_post_wait(c, msg, 240)))
304 osm_info(
"%s: Unable to quiesce (status=%#x).\n", c->
name, -rc);
343 if ((rc = i2o_msg_post_wait(c, msg, 240)))
344 osm_err(
"%s: Could not enable (status=%#x).\n", c->
name, -rc);
358 static inline void i2o_iop_quiesce_all(
void)
373 static inline void i2o_iop_enable_all(
void)
402 i2o_iop_quiesce_all();
409 if ((rc = i2o_msg_post_wait(c, msg, 30)))
410 osm_info(
"%s: Unable to clear (status=%#x).\n", c->name, -rc);
415 i2o_iop_enable_all();
458 i2o_msg_post(c, msg);
473 i2o_flush_reply(c, m);
492 volatile u8 *status = c->
status.virt;
494 unsigned long timeout;
507 i2o_iop_quiesce_all();
520 i2o_msg_post(c, msg);
546 osm_debug(
"%s: Reset in progress, waiting for reboot...\n",
566 osm_warn(
"%s: reset completed, but adapter not in RESET"
567 " state.\n", c->
name);
581 i2o_iop_enable_all();
606 osm_info(
"%s: Unable to obtain status, attempting a reset.\n",
608 rc = i2o_iop_reset(c);
614 osm_err(
"%s: Not running version 1.5 of the I2O Specification."
628 osm_debug(
"%s: already running, trying to reset...\n", c->
name);
629 rc = i2o_iop_reset(c);
637 rc = i2o_iop_init_outbound_queue(c);
648 osm_err(
"%s: failed to bring IOP into HOLD state\n", c->
name);
652 return i2o_hrt_get(c);
677 osm_info(
"%s: requires private memory resources.\n", c->
name);
686 osm_info(
"%s: allocated %llu bytes of PCI memory at "
687 "0x%016llX.\n", c->
name,
688 (
unsigned long long)resource_size(res),
689 (
unsigned long long)res->
start);
699 osm_info(
"%s: requires private memory resources.\n", c->
name);
708 osm_info(
"%s: allocated %llu bytes of PCI I/O at "
709 "0x%016llX.\n", c->
name,
710 (
unsigned long long)resource_size(res),
711 (
unsigned long long)res->
start);
719 i2o_systab.phys =
dma_map_single(dev, i2o_systab.virt, i2o_systab.len,
721 if (!i2o_systab.phys) {
746 rc = i2o_msg_post_wait(c, msg, 120);
752 osm_err(
"%s: Unable to set SysTab (status=%#x).\n", c->
name,
772 rc = i2o_iop_systab_set(c);
778 rc = i2o_iop_enable(c);
821 static int i2o_systab_build(
void)
824 int num_controllers = 0;
833 change_ind = systab->change_ind;
834 kfree(i2o_systab.virt);
838 i2o_systab.len =
sizeof(
struct i2o_sys_tbl) + num_controllers *
841 systab = i2o_systab.virt = kzalloc(i2o_systab.len,
GFP_KERNEL);
843 osm_err(
"unable to allocate memory for System Table\n");
853 if (count >= num_controllers) {
854 osm_err(
"controller added while building system table"
869 osm_err(
"%s: Deleting b/c could not get status while "
870 "attempting to build system table\n", c->
name);
882 systab->
iops[
count].last_changed = change_ind;
925 unsigned long timeout;
946 i2o_msg_post(c, msg);
950 while (status_block[87] != 0xFF) {
1000 osm_err(
"%s: Unable to get HRT (status=%#x)\n", c->
name,
1006 if (size > c->
hrt.len) {
1012 return i2o_parse_hrt(c);
1015 osm_err(
"%s: Unable to get HRT after %d tries, giving up\n", c->
name,
1028 static void i2o_iop_release(
struct device *dev)
1046 static int unit = 0;
1052 osm_err(
"i2o: Insufficient memory to allocate a I2O controller."
1060 snprintf(poolname,
sizeof(poolname),
"i2o_%s_msg_inpool", c->
name);
1074 c->
device.release = &i2o_iop_release;
1078 #if BITS_PER_LONG == 64
1081 INIT_LIST_HEAD(&c->context_list);
1101 osm_err(
"%s: could not add controller\n", c->
name);
1105 osm_info(
"%s: Activating I2O controller...\n", c->
name);
1106 osm_info(
"%s: This may take a few minutes if there are many devices\n",
1109 if ((rc = i2o_iop_activate(c))) {
1110 osm_err(
"%s: could not activate controller\n", c->
name);
1116 if ((rc = i2o_systab_build()))
1121 if ((rc = i2o_iop_online(c)))
1160 int tcntxt,
u32 evt_mask)
1167 return PTR_ERR(msg);
1177 i2o_msg_post(c, msg);
1190 static int __init i2o_iop_init(
void)
1222 static void __exit i2o_iop_exit(
void)
1237 #if BITS_PER_LONG == 64