diff options
Diffstat (limited to 'drivers/message/i2o/iop.c')
-rw-r--r-- | drivers/message/i2o/iop.c | 566 |
1 files changed, 279 insertions, 287 deletions
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index 50c8cedf7a2d..42f8b810d6e5 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c | |||
@@ -28,8 +28,10 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/i2o.h> | 29 | #include <linux/i2o.h> |
30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
31 | #include "core.h" | ||
31 | 32 | ||
32 | #define OSM_VERSION "$Rev$" | 33 | #define OSM_NAME "i2o" |
34 | #define OSM_VERSION "1.288" | ||
33 | #define OSM_DESCRIPTION "I2O subsystem" | 35 | #define OSM_DESCRIPTION "I2O subsystem" |
34 | 36 | ||
35 | /* global I2O controller list */ | 37 | /* global I2O controller list */ |
@@ -43,20 +45,6 @@ static struct i2o_dma i2o_systab; | |||
43 | 45 | ||
44 | static int i2o_hrt_get(struct i2o_controller *c); | 46 | static int i2o_hrt_get(struct i2o_controller *c); |
45 | 47 | ||
46 | /* Module internal functions from other sources */ | ||
47 | extern struct i2o_driver i2o_exec_driver; | ||
48 | extern int i2o_exec_lct_get(struct i2o_controller *); | ||
49 | extern void i2o_device_remove(struct i2o_device *); | ||
50 | |||
51 | extern int __init i2o_driver_init(void); | ||
52 | extern void __exit i2o_driver_exit(void); | ||
53 | extern int __init i2o_exec_init(void); | ||
54 | extern void __exit i2o_exec_exit(void); | ||
55 | extern int __init i2o_pci_init(void); | ||
56 | extern void __exit i2o_pci_exit(void); | ||
57 | extern int i2o_device_init(void); | ||
58 | extern void i2o_device_exit(void); | ||
59 | |||
60 | /** | 48 | /** |
61 | * i2o_msg_nop - Returns a message which is not used | 49 | * i2o_msg_nop - Returns a message which is not used |
62 | * @c: I2O controller from which the message was created | 50 | * @c: I2O controller from which the message was created |
@@ -68,7 +56,7 @@ extern void i2o_device_exit(void); | |||
68 | */ | 56 | */ |
69 | void i2o_msg_nop(struct i2o_controller *c, u32 m) | 57 | void i2o_msg_nop(struct i2o_controller *c, u32 m) |
70 | { | 58 | { |
71 | struct i2o_message __iomem *msg = c->in_queue.virt + m; | 59 | struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m); |
72 | 60 | ||
73 | writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); | 61 | writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); |
74 | writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID, | 62 | writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID, |
@@ -92,16 +80,16 @@ void i2o_msg_nop(struct i2o_controller *c, u32 m) | |||
92 | * address from the read port (see the i2o spec). If no message is | 80 | * address from the read port (see the i2o spec). If no message is |
93 | * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. | 81 | * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. |
94 | */ | 82 | */ |
95 | u32 i2o_msg_get_wait(struct i2o_controller *c, struct i2o_message __iomem **msg, | 83 | u32 i2o_msg_get_wait(struct i2o_controller *c, |
96 | int wait) | 84 | struct i2o_message __iomem ** msg, int wait) |
97 | { | 85 | { |
98 | unsigned long timeout = jiffies + wait * HZ; | 86 | unsigned long timeout = jiffies + wait * HZ; |
99 | u32 m; | 87 | u32 m; |
100 | 88 | ||
101 | while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) { | 89 | while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) { |
102 | if (time_after(jiffies, timeout)) { | 90 | if (time_after(jiffies, timeout)) { |
103 | pr_debug("%s: Timeout waiting for message frame.\n", | 91 | osm_debug("%s: Timeout waiting for message frame.\n", |
104 | c->name); | 92 | c->name); |
105 | return I2O_QUEUE_EMPTY; | 93 | return I2O_QUEUE_EMPTY; |
106 | } | 94 | } |
107 | set_current_state(TASK_UNINTERRUPTIBLE); | 95 | set_current_state(TASK_UNINTERRUPTIBLE); |
@@ -129,13 +117,13 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr) | |||
129 | unsigned long flags; | 117 | unsigned long flags; |
130 | 118 | ||
131 | if (!ptr) | 119 | if (!ptr) |
132 | printk(KERN_ERR "%s: couldn't add NULL pointer to context list!" | 120 | osm_err("%s: couldn't add NULL pointer to context list!\n", |
133 | "\n", c->name); | 121 | c->name); |
134 | 122 | ||
135 | entry = kmalloc(sizeof(*entry), GFP_ATOMIC); | 123 | entry = kmalloc(sizeof(*entry), GFP_ATOMIC); |
136 | if (!entry) { | 124 | if (!entry) { |
137 | printk(KERN_ERR "%s: Could not allocate memory for context " | 125 | osm_err("%s: Could not allocate memory for context list element" |
138 | "list element\n", c->name); | 126 | "\n", c->name); |
139 | return 0; | 127 | return 0; |
140 | } | 128 | } |
141 | 129 | ||
@@ -154,7 +142,7 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr) | |||
154 | 142 | ||
155 | spin_unlock_irqrestore(&c->context_list_lock, flags); | 143 | spin_unlock_irqrestore(&c->context_list_lock, flags); |
156 | 144 | ||
157 | pr_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context); | 145 | osm_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context); |
158 | 146 | ||
159 | return entry->context; | 147 | return entry->context; |
160 | }; | 148 | }; |
@@ -186,11 +174,11 @@ u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr) | |||
186 | spin_unlock_irqrestore(&c->context_list_lock, flags); | 174 | spin_unlock_irqrestore(&c->context_list_lock, flags); |
187 | 175 | ||
188 | if (!context) | 176 | if (!context) |
189 | printk(KERN_WARNING "%s: Could not remove nonexistent ptr " | 177 | osm_warn("%s: Could not remove nonexistent ptr %p\n", c->name, |
190 | "%p\n", c->name, ptr); | 178 | ptr); |
191 | 179 | ||
192 | pr_debug("%s: remove ptr from context list %d -> %p\n", c->name, | 180 | osm_debug("%s: remove ptr from context list %d -> %p\n", c->name, |
193 | context, ptr); | 181 | context, ptr); |
194 | 182 | ||
195 | return context; | 183 | return context; |
196 | }; | 184 | }; |
@@ -220,11 +208,10 @@ void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context) | |||
220 | spin_unlock_irqrestore(&c->context_list_lock, flags); | 208 | spin_unlock_irqrestore(&c->context_list_lock, flags); |
221 | 209 | ||
222 | if (!ptr) | 210 | if (!ptr) |
223 | printk(KERN_WARNING "%s: context id %d not found\n", c->name, | 211 | osm_warn("%s: context id %d not found\n", c->name, context); |
224 | context); | ||
225 | 212 | ||
226 | pr_debug("%s: get ptr from context list %d -> %p\n", c->name, context, | 213 | osm_debug("%s: get ptr from context list %d -> %p\n", c->name, context, |
227 | ptr); | 214 | ptr); |
228 | 215 | ||
229 | return ptr; | 216 | return ptr; |
230 | }; | 217 | }; |
@@ -252,11 +239,11 @@ u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void *ptr) | |||
252 | spin_unlock_irqrestore(&c->context_list_lock, flags); | 239 | spin_unlock_irqrestore(&c->context_list_lock, flags); |
253 | 240 | ||
254 | if (!context) | 241 | if (!context) |
255 | printk(KERN_WARNING "%s: Could not find nonexistent ptr " | 242 | osm_warn("%s: Could not find nonexistent ptr %p\n", c->name, |
256 | "%p\n", c->name, ptr); | 243 | ptr); |
257 | 244 | ||
258 | pr_debug("%s: get context id from context list %p -> %d\n", c->name, | 245 | osm_debug("%s: get context id from context list %p -> %d\n", c->name, |
259 | ptr, context); | 246 | ptr, context); |
260 | 247 | ||
261 | return context; | 248 | return context; |
262 | }; | 249 | }; |
@@ -336,10 +323,9 @@ static int i2o_iop_quiesce(struct i2o_controller *c) | |||
336 | 323 | ||
337 | /* Long timeout needed for quiesce if lots of devices */ | 324 | /* Long timeout needed for quiesce if lots of devices */ |
338 | if ((rc = i2o_msg_post_wait(c, m, 240))) | 325 | if ((rc = i2o_msg_post_wait(c, m, 240))) |
339 | printk(KERN_INFO "%s: Unable to quiesce (status=%#x).\n", | 326 | osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc); |
340 | c->name, -rc); | ||
341 | else | 327 | else |
342 | pr_debug("%s: Quiesced.\n", c->name); | 328 | osm_debug("%s: Quiesced.\n", c->name); |
343 | 329 | ||
344 | i2o_status_get(c); // Entered READY state | 330 | i2o_status_get(c); // Entered READY state |
345 | 331 | ||
@@ -377,10 +363,9 @@ static int i2o_iop_enable(struct i2o_controller *c) | |||
377 | 363 | ||
378 | /* How long of a timeout do we need? */ | 364 | /* How long of a timeout do we need? */ |
379 | if ((rc = i2o_msg_post_wait(c, m, 240))) | 365 | if ((rc = i2o_msg_post_wait(c, m, 240))) |
380 | printk(KERN_ERR "%s: Could not enable (status=%#x).\n", | 366 | osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc); |
381 | c->name, -rc); | ||
382 | else | 367 | else |
383 | pr_debug("%s: Enabled.\n", c->name); | 368 | osm_debug("%s: Enabled.\n", c->name); |
384 | 369 | ||
385 | i2o_status_get(c); // entered OPERATIONAL state | 370 | i2o_status_get(c); // entered OPERATIONAL state |
386 | 371 | ||
@@ -444,20 +429,78 @@ static int i2o_iop_clear(struct i2o_controller *c) | |||
444 | &msg->u.head[1]); | 429 | &msg->u.head[1]); |
445 | 430 | ||
446 | if ((rc = i2o_msg_post_wait(c, m, 30))) | 431 | if ((rc = i2o_msg_post_wait(c, m, 30))) |
447 | printk(KERN_INFO "%s: Unable to clear (status=%#x).\n", | 432 | osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc); |
448 | c->name, -rc); | ||
449 | else | 433 | else |
450 | pr_debug("%s: Cleared.\n", c->name); | 434 | osm_debug("%s: Cleared.\n", c->name); |
451 | 435 | ||
452 | /* Enable all IOPs */ | 436 | /* Enable all IOPs */ |
453 | i2o_iop_enable_all(); | 437 | i2o_iop_enable_all(); |
454 | 438 | ||
455 | i2o_status_get(c); | ||
456 | |||
457 | return rc; | 439 | return rc; |
458 | } | 440 | } |
459 | 441 | ||
460 | /** | 442 | /** |
443 | * i2o_iop_init_outbound_queue - setup the outbound message queue | ||
444 | * @c: I2O controller | ||
445 | * | ||
446 | * Clear and (re)initialize IOP's outbound queue and post the message | ||
447 | * frames to the IOP. | ||
448 | * | ||
449 | * Returns 0 on success or a negative errno code on failure. | ||
450 | */ | ||
451 | static int i2o_iop_init_outbound_queue(struct i2o_controller *c) | ||
452 | { | ||
453 | volatile u8 *status = c->status.virt; | ||
454 | u32 m; | ||
455 | struct i2o_message __iomem *msg; | ||
456 | ulong timeout; | ||
457 | int i; | ||
458 | |||
459 | osm_debug("%s: Initializing Outbound Queue...\n", c->name); | ||
460 | |||
461 | memset(c->status.virt, 0, 4); | ||
462 | |||
463 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); | ||
464 | if (m == I2O_QUEUE_EMPTY) | ||
465 | return -ETIMEDOUT; | ||
466 | |||
467 | writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); | ||
468 | writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID, | ||
469 | &msg->u.head[1]); | ||
470 | writel(i2o_exec_driver.context, &msg->u.s.icntxt); | ||
471 | writel(0x00000000, &msg->u.s.tcntxt); | ||
472 | writel(PAGE_SIZE, &msg->body[0]); | ||
473 | /* Outbound msg frame size in words and Initcode */ | ||
474 | writel(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); | ||
475 | writel(0xd0000004, &msg->body[2]); | ||
476 | writel(i2o_dma_low(c->status.phys), &msg->body[3]); | ||
477 | writel(i2o_dma_high(c->status.phys), &msg->body[4]); | ||
478 | |||
479 | i2o_msg_post(c, m); | ||
480 | |||
481 | timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ; | ||
482 | while (*status <= I2O_CMD_IN_PROGRESS) { | ||
483 | if (time_after(jiffies, timeout)) { | ||
484 | osm_warn("%s: Timeout Initializing\n", c->name); | ||
485 | return -ETIMEDOUT; | ||
486 | } | ||
487 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
488 | schedule_timeout(1); | ||
489 | } | ||
490 | |||
491 | m = c->out_queue.phys; | ||
492 | |||
493 | /* Post frames */ | ||
494 | for (i = 0; i < I2O_MAX_OUTBOUND_MSG_FRAMES; i++) { | ||
495 | i2o_flush_reply(c, m); | ||
496 | udelay(1); /* Promise */ | ||
497 | m += I2O_OUTBOUND_MSG_FRAME_SIZE * sizeof(u32); | ||
498 | } | ||
499 | |||
500 | return 0; | ||
501 | } | ||
502 | |||
503 | /** | ||
461 | * i2o_iop_reset - reset an I2O controller | 504 | * i2o_iop_reset - reset an I2O controller |
462 | * @c: controller to reset | 505 | * @c: controller to reset |
463 | * | 506 | * |
@@ -468,20 +511,20 @@ static int i2o_iop_clear(struct i2o_controller *c) | |||
468 | */ | 511 | */ |
469 | static int i2o_iop_reset(struct i2o_controller *c) | 512 | static int i2o_iop_reset(struct i2o_controller *c) |
470 | { | 513 | { |
471 | u8 *status = c->status.virt; | 514 | volatile u8 *status = c->status.virt; |
472 | struct i2o_message __iomem *msg; | 515 | struct i2o_message __iomem *msg; |
473 | u32 m; | 516 | u32 m; |
474 | unsigned long timeout; | 517 | unsigned long timeout; |
475 | i2o_status_block *sb = c->status_block.virt; | 518 | i2o_status_block *sb = c->status_block.virt; |
476 | int rc = 0; | 519 | int rc = 0; |
477 | 520 | ||
478 | pr_debug("%s: Resetting controller\n", c->name); | 521 | osm_debug("%s: Resetting controller\n", c->name); |
479 | 522 | ||
480 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); | 523 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); |
481 | if (m == I2O_QUEUE_EMPTY) | 524 | if (m == I2O_QUEUE_EMPTY) |
482 | return -ETIMEDOUT; | 525 | return -ETIMEDOUT; |
483 | 526 | ||
484 | memset(status, 0, 8); | 527 | memset(c->status_block.virt, 0, 8); |
485 | 528 | ||
486 | /* Quiesce all IOPs first */ | 529 | /* Quiesce all IOPs first */ |
487 | i2o_iop_quiesce_all(); | 530 | i2o_iop_quiesce_all(); |
@@ -493,49 +536,43 @@ static int i2o_iop_reset(struct i2o_controller *c) | |||
493 | writel(0, &msg->u.s.tcntxt); //FIXME: use reasonable transaction context | 536 | writel(0, &msg->u.s.tcntxt); //FIXME: use reasonable transaction context |
494 | writel(0, &msg->body[0]); | 537 | writel(0, &msg->body[0]); |
495 | writel(0, &msg->body[1]); | 538 | writel(0, &msg->body[1]); |
496 | writel(i2o_ptr_low((void *)c->status.phys), &msg->body[2]); | 539 | writel(i2o_dma_low(c->status.phys), &msg->body[2]); |
497 | writel(i2o_ptr_high((void *)c->status.phys), &msg->body[3]); | 540 | writel(i2o_dma_high(c->status.phys), &msg->body[3]); |
498 | 541 | ||
499 | i2o_msg_post(c, m); | 542 | i2o_msg_post(c, m); |
500 | 543 | ||
501 | /* Wait for a reply */ | 544 | /* Wait for a reply */ |
502 | timeout = jiffies + I2O_TIMEOUT_RESET * HZ; | 545 | timeout = jiffies + I2O_TIMEOUT_RESET * HZ; |
503 | while (!*status) { | 546 | while (!*status) { |
504 | if (time_after(jiffies, timeout)) { | 547 | if (time_after(jiffies, timeout)) |
505 | printk(KERN_ERR "%s: IOP reset timeout.\n", c->name); | ||
506 | rc = -ETIMEDOUT; | ||
507 | goto exit; | ||
508 | } | ||
509 | |||
510 | /* Promise bug */ | ||
511 | if (status[1] || status[4]) { | ||
512 | *status = 0; | ||
513 | break; | 548 | break; |
514 | } | ||
515 | 549 | ||
516 | set_current_state(TASK_UNINTERRUPTIBLE); | 550 | set_current_state(TASK_UNINTERRUPTIBLE); |
517 | schedule_timeout(1); | 551 | schedule_timeout(1); |
518 | |||
519 | rmb(); | ||
520 | } | 552 | } |
521 | 553 | ||
522 | if (*status == I2O_CMD_IN_PROGRESS) { | 554 | switch (*status) { |
555 | case I2O_CMD_REJECTED: | ||
556 | osm_warn("%s: IOP reset rejected\n", c->name); | ||
557 | rc = -EPERM; | ||
558 | break; | ||
559 | |||
560 | case I2O_CMD_IN_PROGRESS: | ||
523 | /* | 561 | /* |
524 | * Once the reset is sent, the IOP goes into the INIT state | 562 | * Once the reset is sent, the IOP goes into the INIT state |
525 | * which is indeterminate. We need to wait until the IOP | 563 | * which is indeterminate. We need to wait until the IOP has |
526 | * has rebooted before we can let the system talk to | 564 | * rebooted before we can let the system talk to it. We read |
527 | * it. We read the inbound Free_List until a message is | 565 | * the inbound Free_List until a message is available. If we |
528 | * available. If we can't read one in the given ammount of | 566 | * can't read one in the given ammount of time, we assume the |
529 | * time, we assume the IOP could not reboot properly. | 567 | * IOP could not reboot properly. |
530 | */ | 568 | */ |
531 | pr_debug("%s: Reset in progress, waiting for reboot...\n", | 569 | osm_debug("%s: Reset in progress, waiting for reboot...\n", |
532 | c->name); | 570 | c->name); |
533 | 571 | ||
534 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); | 572 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); |
535 | while (m == I2O_QUEUE_EMPTY) { | 573 | while (m == I2O_QUEUE_EMPTY) { |
536 | if (time_after(jiffies, timeout)) { | 574 | if (time_after(jiffies, timeout)) { |
537 | printk(KERN_ERR "%s: IOP reset timeout.\n", | 575 | osm_err("%s: IOP reset timeout.\n", c->name); |
538 | c->name); | ||
539 | rc = -ETIMEDOUT; | 576 | rc = -ETIMEDOUT; |
540 | goto exit; | 577 | goto exit; |
541 | } | 578 | } |
@@ -545,19 +582,26 @@ static int i2o_iop_reset(struct i2o_controller *c) | |||
545 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); | 582 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); |
546 | } | 583 | } |
547 | i2o_msg_nop(c, m); | 584 | i2o_msg_nop(c, m); |
548 | } | ||
549 | 585 | ||
550 | /* from here all quiesce commands are safe */ | 586 | /* from here all quiesce commands are safe */ |
551 | c->no_quiesce = 0; | 587 | c->no_quiesce = 0; |
552 | 588 | ||
553 | /* If IopReset was rejected or didn't perform reset, try IopClear */ | 589 | /* verify if controller is in state RESET */ |
554 | i2o_status_get(c); | 590 | i2o_status_get(c); |
555 | if (*status == I2O_CMD_REJECTED || sb->iop_state != ADAPTER_STATE_RESET) { | 591 | |
556 | printk(KERN_WARNING "%s: Reset rejected, trying to clear\n", | 592 | if (!c->promise && (sb->iop_state != ADAPTER_STATE_RESET)) |
557 | c->name); | 593 | osm_warn("%s: reset completed, but adapter not in RESET" |
558 | i2o_iop_clear(c); | 594 | " state.\n", c->name); |
559 | } else | 595 | else |
560 | pr_debug("%s: Reset completed.\n", c->name); | 596 | osm_debug("%s: reset completed.\n", c->name); |
597 | |||
598 | break; | ||
599 | |||
600 | default: | ||
601 | osm_err("%s: IOP reset timeout.\n", c->name); | ||
602 | rc = -ETIMEDOUT; | ||
603 | break; | ||
604 | } | ||
561 | 605 | ||
562 | exit: | 606 | exit: |
563 | /* Enable all IOPs */ | 607 | /* Enable all IOPs */ |
@@ -567,88 +611,6 @@ static int i2o_iop_reset(struct i2o_controller *c) | |||
567 | }; | 611 | }; |
568 | 612 | ||
569 | /** | 613 | /** |
570 | * i2o_iop_init_outbound_queue - setup the outbound message queue | ||
571 | * @c: I2O controller | ||
572 | * | ||
573 | * Clear and (re)initialize IOP's outbound queue and post the message | ||
574 | * frames to the IOP. | ||
575 | * | ||
576 | * Returns 0 on success or a negative errno code on failure. | ||
577 | */ | ||
578 | static int i2o_iop_init_outbound_queue(struct i2o_controller *c) | ||
579 | { | ||
580 | u8 *status = c->status.virt; | ||
581 | u32 m; | ||
582 | struct i2o_message __iomem *msg; | ||
583 | ulong timeout; | ||
584 | int i; | ||
585 | |||
586 | pr_debug("%s: Initializing Outbound Queue...\n", c->name); | ||
587 | |||
588 | memset(status, 0, 4); | ||
589 | |||
590 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); | ||
591 | if (m == I2O_QUEUE_EMPTY) | ||
592 | return -ETIMEDOUT; | ||
593 | |||
594 | writel(EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6, &msg->u.head[0]); | ||
595 | writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID, | ||
596 | &msg->u.head[1]); | ||
597 | writel(i2o_exec_driver.context, &msg->u.s.icntxt); | ||
598 | writel(0x0106, &msg->u.s.tcntxt); /* FIXME: why 0x0106, maybe in | ||
599 | Spec? */ | ||
600 | writel(PAGE_SIZE, &msg->body[0]); | ||
601 | writel(MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); /* Outbound msg frame | ||
602 | size in words and Initcode */ | ||
603 | writel(0xd0000004, &msg->body[2]); | ||
604 | writel(i2o_ptr_low((void *)c->status.phys), &msg->body[3]); | ||
605 | writel(i2o_ptr_high((void *)c->status.phys), &msg->body[4]); | ||
606 | |||
607 | i2o_msg_post(c, m); | ||
608 | |||
609 | timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ; | ||
610 | while (*status <= I2O_CMD_IN_PROGRESS) { | ||
611 | if (time_after(jiffies, timeout)) { | ||
612 | printk(KERN_WARNING "%s: Timeout Initializing\n", | ||
613 | c->name); | ||
614 | return -ETIMEDOUT; | ||
615 | } | ||
616 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
617 | schedule_timeout(1); | ||
618 | |||
619 | rmb(); | ||
620 | } | ||
621 | |||
622 | m = c->out_queue.phys; | ||
623 | |||
624 | /* Post frames */ | ||
625 | for (i = 0; i < NMBR_MSG_FRAMES; i++) { | ||
626 | i2o_flush_reply(c, m); | ||
627 | udelay(1); /* Promise */ | ||
628 | m += MSG_FRAME_SIZE * 4; | ||
629 | } | ||
630 | |||
631 | return 0; | ||
632 | } | ||
633 | |||
634 | /** | ||
635 | * i2o_iop_send_nop - send a core NOP message | ||
636 | * @c: controller | ||
637 | * | ||
638 | * Send a no-operation message with a reply set to cause no | ||
639 | * action either. Needed for bringing up promise controllers. | ||
640 | */ | ||
641 | static int i2o_iop_send_nop(struct i2o_controller *c) | ||
642 | { | ||
643 | struct i2o_message __iomem *msg; | ||
644 | u32 m = i2o_msg_get_wait(c, &msg, HZ); | ||
645 | if (m == I2O_QUEUE_EMPTY) | ||
646 | return -ETIMEDOUT; | ||
647 | i2o_msg_nop(c, m); | ||
648 | return 0; | ||
649 | } | ||
650 | |||
651 | /** | ||
652 | * i2o_iop_activate - Bring controller up to HOLD | 614 | * i2o_iop_activate - Bring controller up to HOLD |
653 | * @c: controller | 615 | * @c: controller |
654 | * | 616 | * |
@@ -659,78 +621,62 @@ static int i2o_iop_send_nop(struct i2o_controller *c) | |||
659 | */ | 621 | */ |
660 | static int i2o_iop_activate(struct i2o_controller *c) | 622 | static int i2o_iop_activate(struct i2o_controller *c) |
661 | { | 623 | { |
662 | struct pci_dev *i960 = NULL; | ||
663 | i2o_status_block *sb = c->status_block.virt; | 624 | i2o_status_block *sb = c->status_block.virt; |
664 | int rc; | 625 | int rc; |
665 | 626 | int state; | |
666 | if (c->promise) { | ||
667 | /* Beat up the hardware first of all */ | ||
668 | i960 = | ||
669 | pci_find_slot(c->pdev->bus->number, | ||
670 | PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0)); | ||
671 | if (i960) | ||
672 | pci_write_config_word(i960, 0x42, 0); | ||
673 | |||
674 | /* Follow this sequence precisely or the controller | ||
675 | ceases to perform useful functions until reboot */ | ||
676 | if ((rc = i2o_iop_send_nop(c))) | ||
677 | return rc; | ||
678 | |||
679 | if ((rc = i2o_iop_reset(c))) | ||
680 | return rc; | ||
681 | } | ||
682 | 627 | ||
683 | /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */ | 628 | /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */ |
684 | /* In READY state, Get status */ | 629 | /* In READY state, Get status */ |
685 | 630 | ||
686 | rc = i2o_status_get(c); | 631 | rc = i2o_status_get(c); |
687 | if (rc) { | 632 | if (rc) { |
688 | printk(KERN_INFO "%s: Unable to obtain status, " | 633 | osm_info("%s: Unable to obtain status, attempting a reset.\n", |
689 | "attempting a reset.\n", c->name); | 634 | c->name); |
690 | if (i2o_iop_reset(c)) | 635 | rc = i2o_iop_reset(c); |
636 | if (rc) | ||
691 | return rc; | 637 | return rc; |
692 | } | 638 | } |
693 | 639 | ||
694 | if (sb->i2o_version > I2OVER15) { | 640 | if (sb->i2o_version > I2OVER15) { |
695 | printk(KERN_ERR "%s: Not running version 1.5 of the I2O " | 641 | osm_err("%s: Not running version 1.5 of the I2O Specification." |
696 | "Specification.\n", c->name); | 642 | "\n", c->name); |
697 | return -ENODEV; | 643 | return -ENODEV; |
698 | } | 644 | } |
699 | 645 | ||
700 | switch (sb->iop_state) { | 646 | switch (sb->iop_state) { |
701 | case ADAPTER_STATE_FAULTED: | 647 | case ADAPTER_STATE_FAULTED: |
702 | printk(KERN_CRIT "%s: hardware fault\n", c->name); | 648 | osm_err("%s: hardware fault\n", c->name); |
703 | return -ENODEV; | 649 | return -EFAULT; |
704 | 650 | ||
705 | case ADAPTER_STATE_READY: | 651 | case ADAPTER_STATE_READY: |
706 | case ADAPTER_STATE_OPERATIONAL: | 652 | case ADAPTER_STATE_OPERATIONAL: |
707 | case ADAPTER_STATE_HOLD: | 653 | case ADAPTER_STATE_HOLD: |
708 | case ADAPTER_STATE_FAILED: | 654 | case ADAPTER_STATE_FAILED: |
709 | pr_debug("%s: already running, trying to reset...\n", c->name); | 655 | osm_debug("%s: already running, trying to reset...\n", c->name); |
710 | if (i2o_iop_reset(c)) | 656 | rc = i2o_iop_reset(c); |
711 | return -ENODEV; | 657 | if (rc) |
658 | return rc; | ||
712 | } | 659 | } |
713 | 660 | ||
661 | /* preserve state */ | ||
662 | state = sb->iop_state; | ||
663 | |||
714 | rc = i2o_iop_init_outbound_queue(c); | 664 | rc = i2o_iop_init_outbound_queue(c); |
715 | if (rc) | 665 | if (rc) |
716 | return rc; | 666 | return rc; |
717 | 667 | ||
718 | if (c->promise) { | 668 | /* if adapter was not in RESET state clear now */ |
719 | if ((rc = i2o_iop_send_nop(c))) | 669 | if (state != ADAPTER_STATE_RESET) |
720 | return rc; | 670 | i2o_iop_clear(c); |
721 | 671 | ||
722 | if ((rc = i2o_status_get(c))) | 672 | i2o_status_get(c); |
723 | return rc; | ||
724 | 673 | ||
725 | if (i960) | 674 | if (sb->iop_state != ADAPTER_STATE_HOLD) { |
726 | pci_write_config_word(i960, 0x42, 0x3FF); | 675 | osm_err("%s: failed to bring IOP into HOLD state\n", c->name); |
676 | return -EIO; | ||
727 | } | 677 | } |
728 | 678 | ||
729 | /* In HOLD state */ | 679 | return i2o_hrt_get(c); |
730 | |||
731 | rc = i2o_hrt_get(c); | ||
732 | |||
733 | return rc; | ||
734 | }; | 680 | }; |
735 | 681 | ||
736 | /** | 682 | /** |
@@ -756,20 +702,18 @@ static int i2o_iop_systab_set(struct i2o_controller *c) | |||
756 | res->flags = IORESOURCE_MEM; | 702 | res->flags = IORESOURCE_MEM; |
757 | res->start = 0; | 703 | res->start = 0; |
758 | res->end = 0; | 704 | res->end = 0; |
759 | printk(KERN_INFO "%s: requires private memory resources.\n", | 705 | osm_info("%s: requires private memory resources.\n", c->name); |
760 | c->name); | ||
761 | root = pci_find_parent_resource(c->pdev, res); | 706 | root = pci_find_parent_resource(c->pdev, res); |
762 | if (root == NULL) | 707 | if (root == NULL) |
763 | printk(KERN_WARNING "%s: Can't find parent resource!\n", | 708 | osm_warn("%s: Can't find parent resource!\n", c->name); |
764 | c->name); | ||
765 | if (root && allocate_resource(root, res, sb->desired_mem_size, sb->desired_mem_size, sb->desired_mem_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */ | 709 | if (root && allocate_resource(root, res, sb->desired_mem_size, sb->desired_mem_size, sb->desired_mem_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */ |
766 | NULL, NULL) >= 0) { | 710 | NULL, NULL) >= 0) { |
767 | c->mem_alloc = 1; | 711 | c->mem_alloc = 1; |
768 | sb->current_mem_size = 1 + res->end - res->start; | 712 | sb->current_mem_size = 1 + res->end - res->start; |
769 | sb->current_mem_base = res->start; | 713 | sb->current_mem_base = res->start; |
770 | printk(KERN_INFO "%s: allocated %ld bytes of PCI memory" | 714 | osm_info("%s: allocated %ld bytes of PCI memory at " |
771 | " at 0x%08lX.\n", c->name, | 715 | "0x%08lX.\n", c->name, |
772 | 1 + res->end - res->start, res->start); | 716 | 1 + res->end - res->start, res->start); |
773 | } | 717 | } |
774 | } | 718 | } |
775 | 719 | ||
@@ -779,20 +723,18 @@ static int i2o_iop_systab_set(struct i2o_controller *c) | |||
779 | res->flags = IORESOURCE_IO; | 723 | res->flags = IORESOURCE_IO; |
780 | res->start = 0; | 724 | res->start = 0; |
781 | res->end = 0; | 725 | res->end = 0; |
782 | printk(KERN_INFO "%s: requires private memory resources.\n", | 726 | osm_info("%s: requires private memory resources.\n", c->name); |
783 | c->name); | ||
784 | root = pci_find_parent_resource(c->pdev, res); | 727 | root = pci_find_parent_resource(c->pdev, res); |
785 | if (root == NULL) | 728 | if (root == NULL) |
786 | printk(KERN_WARNING "%s: Can't find parent resource!\n", | 729 | osm_warn("%s: Can't find parent resource!\n", c->name); |
787 | c->name); | ||
788 | if (root && allocate_resource(root, res, sb->desired_io_size, sb->desired_io_size, sb->desired_io_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */ | 730 | if (root && allocate_resource(root, res, sb->desired_io_size, sb->desired_io_size, sb->desired_io_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */ |
789 | NULL, NULL) >= 0) { | 731 | NULL, NULL) >= 0) { |
790 | c->io_alloc = 1; | 732 | c->io_alloc = 1; |
791 | sb->current_io_size = 1 + res->end - res->start; | 733 | sb->current_io_size = 1 + res->end - res->start; |
792 | sb->current_mem_base = res->start; | 734 | sb->current_mem_base = res->start; |
793 | printk(KERN_INFO "%s: allocated %ld bytes of PCI I/O at" | 735 | osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX" |
794 | " 0x%08lX.\n", c->name, | 736 | ".\n", c->name, 1 + res->end - res->start, |
795 | 1 + res->end - res->start, res->start); | 737 | res->start); |
796 | } | 738 | } |
797 | } | 739 | } |
798 | 740 | ||
@@ -836,10 +778,10 @@ static int i2o_iop_systab_set(struct i2o_controller *c) | |||
836 | PCI_DMA_TODEVICE); | 778 | PCI_DMA_TODEVICE); |
837 | 779 | ||
838 | if (rc < 0) | 780 | if (rc < 0) |
839 | printk(KERN_ERR "%s: Unable to set SysTab (status=%#x).\n", | 781 | osm_err("%s: Unable to set SysTab (status=%#x).\n", c->name, |
840 | c->name, -rc); | 782 | -rc); |
841 | else | 783 | else |
842 | pr_debug("%s: SysTab set.\n", c->name); | 784 | osm_debug("%s: SysTab set.\n", c->name); |
843 | 785 | ||
844 | i2o_status_get(c); // Entered READY state | 786 | i2o_status_get(c); // Entered READY state |
845 | 787 | ||
@@ -863,7 +805,7 @@ static int i2o_iop_online(struct i2o_controller *c) | |||
863 | return rc; | 805 | return rc; |
864 | 806 | ||
865 | /* In READY state */ | 807 | /* In READY state */ |
866 | pr_debug("%s: Attempting to enable...\n", c->name); | 808 | osm_debug("%s: Attempting to enable...\n", c->name); |
867 | rc = i2o_iop_enable(c); | 809 | rc = i2o_iop_enable(c); |
868 | if (rc) | 810 | if (rc) |
869 | return rc; | 811 | return rc; |
@@ -882,7 +824,7 @@ void i2o_iop_remove(struct i2o_controller *c) | |||
882 | { | 824 | { |
883 | struct i2o_device *dev, *tmp; | 825 | struct i2o_device *dev, *tmp; |
884 | 826 | ||
885 | pr_debug("%s: deleting controller\n", c->name); | 827 | osm_debug("%s: deleting controller\n", c->name); |
886 | 828 | ||
887 | i2o_driver_notify_controller_remove_all(c); | 829 | i2o_driver_notify_controller_remove_all(c); |
888 | 830 | ||
@@ -891,8 +833,12 @@ void i2o_iop_remove(struct i2o_controller *c) | |||
891 | list_for_each_entry_safe(dev, tmp, &c->devices, list) | 833 | list_for_each_entry_safe(dev, tmp, &c->devices, list) |
892 | i2o_device_remove(dev); | 834 | i2o_device_remove(dev); |
893 | 835 | ||
836 | device_del(&c->device); | ||
837 | |||
894 | /* Ask the IOP to switch to RESET state */ | 838 | /* Ask the IOP to switch to RESET state */ |
895 | i2o_iop_reset(c); | 839 | i2o_iop_reset(c); |
840 | |||
841 | put_device(&c->device); | ||
896 | } | 842 | } |
897 | 843 | ||
898 | /** | 844 | /** |
@@ -927,8 +873,7 @@ static int i2o_systab_build(void) | |||
927 | 873 | ||
928 | systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL); | 874 | systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL); |
929 | if (!systab) { | 875 | if (!systab) { |
930 | printk(KERN_ERR "i2o: unable to allocate memory for System " | 876 | osm_err("unable to allocate memory for System Table\n"); |
931 | "Table\n"); | ||
932 | return -ENOMEM; | 877 | return -ENOMEM; |
933 | } | 878 | } |
934 | memset(systab, 0, i2o_systab.len); | 879 | memset(systab, 0, i2o_systab.len); |
@@ -940,8 +885,8 @@ static int i2o_systab_build(void) | |||
940 | i2o_status_block *sb; | 885 | i2o_status_block *sb; |
941 | 886 | ||
942 | if (count >= num_controllers) { | 887 | if (count >= num_controllers) { |
943 | printk(KERN_ERR "i2o: controller added while building " | 888 | osm_err("controller added while building system table" |
944 | "system table\n"); | 889 | "\n"); |
945 | break; | 890 | break; |
946 | } | 891 | } |
947 | 892 | ||
@@ -955,9 +900,8 @@ static int i2o_systab_build(void) | |||
955 | * it is techninically not part of the I2O subsystem... | 900 | * it is techninically not part of the I2O subsystem... |
956 | */ | 901 | */ |
957 | if (unlikely(i2o_status_get(c))) { | 902 | if (unlikely(i2o_status_get(c))) { |
958 | printk(KERN_ERR "%s: Deleting b/c could not get status" | 903 | osm_err("%s: Deleting b/c could not get status while " |
959 | " while attempting to build system table\n", | 904 | "attempting to build system table\n", c->name); |
960 | c->name); | ||
961 | i2o_iop_remove(c); | 905 | i2o_iop_remove(c); |
962 | continue; // try the next one | 906 | continue; // try the next one |
963 | } | 907 | } |
@@ -971,8 +915,10 @@ static int i2o_systab_build(void) | |||
971 | systab->iops[count].frame_size = sb->inbound_frame_size; | 915 | systab->iops[count].frame_size = sb->inbound_frame_size; |
972 | systab->iops[count].last_changed = change_ind; | 916 | systab->iops[count].last_changed = change_ind; |
973 | systab->iops[count].iop_capabilities = sb->iop_capabilities; | 917 | systab->iops[count].iop_capabilities = sb->iop_capabilities; |
974 | systab->iops[count].inbound_low = i2o_ptr_low(c->post_port); | 918 | systab->iops[count].inbound_low = |
975 | systab->iops[count].inbound_high = i2o_ptr_high(c->post_port); | 919 | i2o_dma_low(c->base.phys + I2O_IN_PORT); |
920 | systab->iops[count].inbound_high = | ||
921 | i2o_dma_high(c->base.phys + I2O_IN_PORT); | ||
976 | 922 | ||
977 | count++; | 923 | count++; |
978 | } | 924 | } |
@@ -1010,11 +956,11 @@ int i2o_status_get(struct i2o_controller *c) | |||
1010 | { | 956 | { |
1011 | struct i2o_message __iomem *msg; | 957 | struct i2o_message __iomem *msg; |
1012 | u32 m; | 958 | u32 m; |
1013 | u8 *status_block; | 959 | volatile u8 *status_block; |
1014 | unsigned long timeout; | 960 | unsigned long timeout; |
1015 | 961 | ||
1016 | status_block = (u8 *) c->status_block.virt; | 962 | status_block = (u8 *) c->status_block.virt; |
1017 | memset(status_block, 0, sizeof(i2o_status_block)); | 963 | memset(c->status_block.virt, 0, sizeof(i2o_status_block)); |
1018 | 964 | ||
1019 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); | 965 | m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); |
1020 | if (m == I2O_QUEUE_EMPTY) | 966 | if (m == I2O_QUEUE_EMPTY) |
@@ -1027,8 +973,8 @@ int i2o_status_get(struct i2o_controller *c) | |||
1027 | writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context | 973 | writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context |
1028 | writel(0, &msg->body[0]); | 974 | writel(0, &msg->body[0]); |
1029 | writel(0, &msg->body[1]); | 975 | writel(0, &msg->body[1]); |
1030 | writel(i2o_ptr_low((void *)c->status_block.phys), &msg->body[2]); | 976 | writel(i2o_dma_low(c->status_block.phys), &msg->body[2]); |
1031 | writel(i2o_ptr_high((void *)c->status_block.phys), &msg->body[3]); | 977 | writel(i2o_dma_high(c->status_block.phys), &msg->body[3]); |
1032 | writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */ | 978 | writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */ |
1033 | 979 | ||
1034 | i2o_msg_post(c, m); | 980 | i2o_msg_post(c, m); |
@@ -1037,14 +983,12 @@ int i2o_status_get(struct i2o_controller *c) | |||
1037 | timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ; | 983 | timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ; |
1038 | while (status_block[87] != 0xFF) { | 984 | while (status_block[87] != 0xFF) { |
1039 | if (time_after(jiffies, timeout)) { | 985 | if (time_after(jiffies, timeout)) { |
1040 | printk(KERN_ERR "%s: Get status timeout.\n", c->name); | 986 | osm_err("%s: Get status timeout.\n", c->name); |
1041 | return -ETIMEDOUT; | 987 | return -ETIMEDOUT; |
1042 | } | 988 | } |
1043 | 989 | ||
1044 | set_current_state(TASK_UNINTERRUPTIBLE); | 990 | set_current_state(TASK_UNINTERRUPTIBLE); |
1045 | schedule_timeout(1); | 991 | schedule_timeout(1); |
1046 | |||
1047 | rmb(); | ||
1048 | } | 992 | } |
1049 | 993 | ||
1050 | #ifdef DEBUG | 994 | #ifdef DEBUG |
@@ -1088,8 +1032,8 @@ static int i2o_hrt_get(struct i2o_controller *c) | |||
1088 | rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt); | 1032 | rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt); |
1089 | 1033 | ||
1090 | if (rc < 0) { | 1034 | if (rc < 0) { |
1091 | printk(KERN_ERR "%s: Unable to get HRT (status=%#x)\n", | 1035 | osm_err("%s: Unable to get HRT (status=%#x)\n", c->name, |
1092 | c->name, -rc); | 1036 | -rc); |
1093 | return rc; | 1037 | return rc; |
1094 | } | 1038 | } |
1095 | 1039 | ||
@@ -1103,13 +1047,41 @@ static int i2o_hrt_get(struct i2o_controller *c) | |||
1103 | return i2o_parse_hrt(c); | 1047 | return i2o_parse_hrt(c); |
1104 | } | 1048 | } |
1105 | 1049 | ||
1106 | printk(KERN_ERR "%s: Unable to get HRT after %d tries, giving up\n", | 1050 | osm_err("%s: Unable to get HRT after %d tries, giving up\n", c->name, |
1107 | c->name, I2O_HRT_GET_TRIES); | 1051 | I2O_HRT_GET_TRIES); |
1108 | 1052 | ||
1109 | return -EBUSY; | 1053 | return -EBUSY; |
1110 | } | 1054 | } |
1111 | 1055 | ||
1112 | /** | 1056 | /** |
1057 | * i2o_iop_free - Free the i2o_controller struct | ||
1058 | * @c: I2O controller to free | ||
1059 | */ | ||
1060 | void i2o_iop_free(struct i2o_controller *c) | ||
1061 | { | ||
1062 | kfree(c); | ||
1063 | }; | ||
1064 | |||
1065 | /** | ||
1066 | * i2o_iop_release - release the memory for a I2O controller | ||
1067 | * @dev: I2O controller which should be released | ||
1068 | * | ||
1069 | * Release the allocated memory. This function is called if refcount of | ||
1070 | * device reaches 0 automatically. | ||
1071 | */ | ||
1072 | static void i2o_iop_release(struct device *dev) | ||
1073 | { | ||
1074 | struct i2o_controller *c = to_i2o_controller(dev); | ||
1075 | |||
1076 | i2o_iop_free(c); | ||
1077 | }; | ||
1078 | |||
1079 | /* I2O controller class */ | ||
1080 | static struct class i2o_controller_class = { | ||
1081 | .name = "i2o_controller", | ||
1082 | }; | ||
1083 | |||
1084 | /** | ||
1113 | * i2o_iop_alloc - Allocate and initialize a i2o_controller struct | 1085 | * i2o_iop_alloc - Allocate and initialize a i2o_controller struct |
1114 | * | 1086 | * |
1115 | * Allocate the necessary memory for a i2o_controller struct and | 1087 | * Allocate the necessary memory for a i2o_controller struct and |
@@ -1125,8 +1097,8 @@ struct i2o_controller *i2o_iop_alloc(void) | |||
1125 | 1097 | ||
1126 | c = kmalloc(sizeof(*c), GFP_KERNEL); | 1098 | c = kmalloc(sizeof(*c), GFP_KERNEL); |
1127 | if (!c) { | 1099 | if (!c) { |
1128 | printk(KERN_ERR "i2o: Insufficient memory to allocate a I2O " | 1100 | osm_err("i2o: Insufficient memory to allocate a I2O controller." |
1129 | "controller.\n"); | 1101 | "\n"); |
1130 | return ERR_PTR(-ENOMEM); | 1102 | return ERR_PTR(-ENOMEM); |
1131 | } | 1103 | } |
1132 | memset(c, 0, sizeof(*c)); | 1104 | memset(c, 0, sizeof(*c)); |
@@ -1137,6 +1109,16 @@ struct i2o_controller *i2o_iop_alloc(void) | |||
1137 | c->unit = unit++; | 1109 | c->unit = unit++; |
1138 | sprintf(c->name, "iop%d", c->unit); | 1110 | sprintf(c->name, "iop%d", c->unit); |
1139 | 1111 | ||
1112 | device_initialize(&c->device); | ||
1113 | class_device_initialize(&c->classdev); | ||
1114 | |||
1115 | c->device.release = &i2o_iop_release; | ||
1116 | c->classdev.class = &i2o_controller_class; | ||
1117 | c->classdev.dev = &c->device; | ||
1118 | |||
1119 | snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit); | ||
1120 | snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit); | ||
1121 | |||
1140 | #if BITS_PER_LONG == 64 | 1122 | #if BITS_PER_LONG == 64 |
1141 | spin_lock_init(&c->context_list_lock); | 1123 | spin_lock_init(&c->context_list_lock); |
1142 | atomic_set(&c->context_list_counter, 0); | 1124 | atomic_set(&c->context_list_counter, 0); |
@@ -1147,15 +1129,6 @@ struct i2o_controller *i2o_iop_alloc(void) | |||
1147 | }; | 1129 | }; |
1148 | 1130 | ||
1149 | /** | 1131 | /** |
1150 | * i2o_iop_free - Free the i2o_controller struct | ||
1151 | * @c: I2O controller to free | ||
1152 | */ | ||
1153 | void i2o_iop_free(struct i2o_controller *c) | ||
1154 | { | ||
1155 | kfree(c); | ||
1156 | }; | ||
1157 | |||
1158 | /** | ||
1159 | * i2o_iop_add - Initialize the I2O controller and add him to the I2O core | 1132 | * i2o_iop_add - Initialize the I2O controller and add him to the I2O core |
1160 | * @c: controller | 1133 | * @c: controller |
1161 | * | 1134 | * |
@@ -1168,45 +1141,58 @@ int i2o_iop_add(struct i2o_controller *c) | |||
1168 | { | 1141 | { |
1169 | int rc; | 1142 | int rc; |
1170 | 1143 | ||
1171 | printk(KERN_INFO "%s: Activating I2O controller...\n", c->name); | 1144 | if ((rc = device_add(&c->device))) { |
1172 | printk(KERN_INFO "%s: This may take a few minutes if there are many " | 1145 | osm_err("%s: could not add controller\n", c->name); |
1173 | "devices\n", c->name); | 1146 | goto iop_reset; |
1147 | } | ||
1174 | 1148 | ||
1175 | if ((rc = i2o_iop_activate(c))) { | 1149 | if ((rc = class_device_add(&c->classdev))) { |
1176 | printk(KERN_ERR "%s: could not activate controller\n", | 1150 | osm_err("%s: could not add controller class\n", c->name); |
1177 | c->name); | 1151 | goto device_del; |
1178 | i2o_iop_reset(c); | ||
1179 | return rc; | ||
1180 | } | 1152 | } |
1181 | 1153 | ||
1182 | pr_debug("%s: building sys table...\n", c->name); | 1154 | osm_info("%s: Activating I2O controller...\n", c->name); |
1155 | osm_info("%s: This may take a few minutes if there are many devices\n", | ||
1156 | c->name); | ||
1183 | 1157 | ||
1184 | if ((rc = i2o_systab_build())) { | 1158 | if ((rc = i2o_iop_activate(c))) { |
1185 | i2o_iop_reset(c); | 1159 | osm_err("%s: could not activate controller\n", c->name); |
1186 | return rc; | 1160 | goto class_del; |
1187 | } | 1161 | } |
1188 | 1162 | ||
1189 | pr_debug("%s: online controller...\n", c->name); | 1163 | osm_debug("%s: building sys table...\n", c->name); |
1190 | 1164 | ||
1191 | if ((rc = i2o_iop_online(c))) { | 1165 | if ((rc = i2o_systab_build())) |
1192 | i2o_iop_reset(c); | 1166 | goto class_del; |
1193 | return rc; | ||
1194 | } | ||
1195 | 1167 | ||
1196 | pr_debug("%s: getting LCT...\n", c->name); | 1168 | osm_debug("%s: online controller...\n", c->name); |
1197 | 1169 | ||
1198 | if ((rc = i2o_exec_lct_get(c))) { | 1170 | if ((rc = i2o_iop_online(c))) |
1199 | i2o_iop_reset(c); | 1171 | goto class_del; |
1200 | return rc; | 1172 | |
1201 | } | 1173 | osm_debug("%s: getting LCT...\n", c->name); |
1174 | |||
1175 | if ((rc = i2o_exec_lct_get(c))) | ||
1176 | goto class_del; | ||
1202 | 1177 | ||
1203 | list_add(&c->list, &i2o_controllers); | 1178 | list_add(&c->list, &i2o_controllers); |
1204 | 1179 | ||
1205 | i2o_driver_notify_controller_add_all(c); | 1180 | i2o_driver_notify_controller_add_all(c); |
1206 | 1181 | ||
1207 | printk(KERN_INFO "%s: Controller added\n", c->name); | 1182 | osm_info("%s: Controller added\n", c->name); |
1208 | 1183 | ||
1209 | return 0; | 1184 | return 0; |
1185 | |||
1186 | class_del: | ||
1187 | class_device_del(&c->classdev); | ||
1188 | |||
1189 | device_del: | ||
1190 | device_del(&c->device); | ||
1191 | |||
1192 | iop_reset: | ||
1193 | i2o_iop_reset(c); | ||
1194 | |||
1195 | return rc; | ||
1210 | }; | 1196 | }; |
1211 | 1197 | ||
1212 | /** | 1198 | /** |
@@ -1264,16 +1250,18 @@ static int __init i2o_iop_init(void) | |||
1264 | if (rc) | 1250 | if (rc) |
1265 | goto exit; | 1251 | goto exit; |
1266 | 1252 | ||
1267 | rc = i2o_driver_init(); | 1253 | if ((rc = class_register(&i2o_controller_class))) { |
1268 | if (rc) | 1254 | osm_err("can't register class i2o_controller\n"); |
1269 | goto device_exit; | 1255 | goto device_exit; |
1256 | } | ||
1270 | 1257 | ||
1271 | rc = i2o_exec_init(); | 1258 | if ((rc = i2o_driver_init())) |
1272 | if (rc) | 1259 | goto class_exit; |
1260 | |||
1261 | if ((rc = i2o_exec_init())) | ||
1273 | goto driver_exit; | 1262 | goto driver_exit; |
1274 | 1263 | ||
1275 | rc = i2o_pci_init(); | 1264 | if ((rc = i2o_pci_init())) |
1276 | if (rc < 0) | ||
1277 | goto exec_exit; | 1265 | goto exec_exit; |
1278 | 1266 | ||
1279 | return 0; | 1267 | return 0; |
@@ -1284,6 +1272,9 @@ static int __init i2o_iop_init(void) | |||
1284 | driver_exit: | 1272 | driver_exit: |
1285 | i2o_driver_exit(); | 1273 | i2o_driver_exit(); |
1286 | 1274 | ||
1275 | class_exit: | ||
1276 | class_unregister(&i2o_controller_class); | ||
1277 | |||
1287 | device_exit: | 1278 | device_exit: |
1288 | i2o_device_exit(); | 1279 | i2o_device_exit(); |
1289 | 1280 | ||
@@ -1301,6 +1292,7 @@ static void __exit i2o_iop_exit(void) | |||
1301 | i2o_pci_exit(); | 1292 | i2o_pci_exit(); |
1302 | i2o_exec_exit(); | 1293 | i2o_exec_exit(); |
1303 | i2o_driver_exit(); | 1294 | i2o_driver_exit(); |
1295 | class_unregister(&i2o_controller_class); | ||
1304 | i2o_device_exit(); | 1296 | i2o_device_exit(); |
1305 | }; | 1297 | }; |
1306 | 1298 | ||