Lines Matching refs:c

91 static int i2o_systab_send(struct i2o_controller *c);
208 static void i2o_core_reply(struct i2o_handler *h, struct i2o_controller *c, in i2o_core_reply() argument
217 u32 *preserved_msg = (u32*)(c->mem_offset + msg[7]); in i2o_core_reply()
230 i2o_post_message(c, msg[7]); in i2o_core_reply()
255 events[evt_in].iop = c; in i2o_core_reply()
272 up(&c->lct_sem); in i2o_core_reply()
284 c->name); in i2o_core_reply()
353 int i2o_install_device(struct i2o_controller *c, struct i2o_device *d) in i2o_install_device() argument
358 d->controller=c; in i2o_install_device()
360 d->next=c->devices; in i2o_install_device()
362 if (c->devices != NULL) in i2o_install_device()
363 c->devices->prev=d; in i2o_install_device()
364 c->devices=d; in i2o_install_device()
474 int i2o_install_controller(struct i2o_controller *c) in i2o_install_controller() argument
482 c->dlct = (i2o_lct*)kmalloc(8192, GFP_KERNEL); in i2o_install_controller()
483 if(c->dlct==NULL) in i2o_install_controller()
488 i2o_controllers[i]=c; in i2o_install_controller()
489 c->devices = NULL; in i2o_install_controller()
490 c->next=i2o_controller_chain; in i2o_install_controller()
491 i2o_controller_chain=c; in i2o_install_controller()
492 c->unit = i; in i2o_install_controller()
493 c->page_frame = NULL; in i2o_install_controller()
494 c->hrt = NULL; in i2o_install_controller()
495 c->lct = NULL; in i2o_install_controller()
496 c->status_block = NULL; in i2o_install_controller()
497 sprintf(c->name, "i2o/iop%d", i); in i2o_install_controller()
499 init_MUTEX_LOCKED(&c->lct_sem); in i2o_install_controller()
518 int i2o_delete_controller(struct i2o_controller *c) in i2o_delete_controller() argument
525 dprintk(KERN_INFO "Deleting controller %s\n", c->name); in i2o_delete_controller()
530 if(c->status_block->iop_state == ADAPTER_STATE_OPERATIONAL) in i2o_delete_controller()
531 i2o_event_register(c, core_context, 0, 0, 0); in i2o_delete_controller()
534 if((users=atomic_read(&c->users))) in i2o_delete_controller()
537 c->name); in i2o_delete_controller()
541 while(c->devices) in i2o_delete_controller()
543 if(__i2o_delete_device(c->devices)<0) in i2o_delete_controller()
546 c->bus_disable(c); in i2o_delete_controller()
555 if(c->lct_running) { in i2o_delete_controller()
556 stat = kill_proc(c->lct_pid, SIGTERM, 1); in i2o_delete_controller()
559 while(c->lct_running && --count) { in i2o_delete_controller()
567 c->name); in i2o_delete_controller()
575 if(*p==c) in i2o_delete_controller()
578 i2o_reset_controller(c); in i2o_delete_controller()
581 c->destructor(c); in i2o_delete_controller()
583 *p=c->next; in i2o_delete_controller()
586 if(c->page_frame) in i2o_delete_controller()
588 pci_unmap_single(c->pdev, c->page_frame_map, MSG_POOL_SIZE, PCI_DMA_FROMDEVICE); in i2o_delete_controller()
589 kfree(c->page_frame); in i2o_delete_controller()
591 if(c->hrt) in i2o_delete_controller()
592 kfree(c->hrt); in i2o_delete_controller()
593 if(c->lct) in i2o_delete_controller()
594 kfree(c->lct); in i2o_delete_controller()
595 if(c->status_block) in i2o_delete_controller()
596 kfree(c->status_block); in i2o_delete_controller()
597 if(c->dlct) in i2o_delete_controller()
598 kfree(c->dlct); in i2o_delete_controller()
600 i2o_controllers[c->unit]=NULL; in i2o_delete_controller()
601 memcpy(name, c->name, strlen(c->name)+1); in i2o_delete_controller()
602 kfree(c); in i2o_delete_controller()
624 void i2o_unlock_controller(struct i2o_controller *c) in i2o_unlock_controller() argument
626 atomic_dec(&c->users); in i2o_unlock_controller()
639 struct i2o_controller *c; in i2o_find_controller() local
645 c=i2o_controllers[n]; in i2o_find_controller()
646 if(c!=NULL) in i2o_find_controller()
647 atomic_inc(&c->users); in i2o_find_controller()
649 return c; in i2o_find_controller()
666 static int i2o_issue_claim(u32 cmd, struct i2o_controller *c, int tid, u32 type) in i2o_issue_claim() argument
675 return i2o_post_wait(c, msg, sizeof(msg), 60); in i2o_issue_claim()
830 int i2o_event_register(struct i2o_controller *c, u32 tid, in i2o_event_register() argument
843 return i2o_post_this(c, msg, sizeof(msg)); in i2o_event_register()
856 int i2o_event_ack(struct i2o_controller *c, u32 *msg) in i2o_event_ack() argument
862 return i2o_post_wait(c, msg, m->size * 4, 2); in i2o_event_ack()
873 struct i2o_controller *c = NULL; in i2o_core_evt() local
903 c = reply->iop; in i2o_core_evt()
904 dprintk(KERN_INFO "I2O IRTOS EVENT: iop%d, event %#10x\n", c->unit, msg[4]); in i2o_core_evt()
918 printk(KERN_ERR "%s: Out of resources\n", c->name); in i2o_core_evt()
922 printk(KERN_ERR "%s: Power failure\n", c->name); in i2o_core_evt()
939 c->name, fail[msg[5]]); in i2o_core_evt()
941 printk(KERN_ERR "%s: Unknown Hardware Failure\n", c->name); in i2o_core_evt()
964 d->controller = c; in i2o_core_evt()
967 i2o_report_controller_unit(c, d); in i2o_core_evt()
968 i2o_install_device(c,d); in i2o_core_evt()
977 i2o_handlers[i]->new_dev_notify(c,d); in i2o_core_evt()
994 for(d = c->devices; d; d = d->next) in i2o_core_evt()
1006 printk(KERN_WARNING "%s requires user configuration\n", c->name); in i2o_core_evt()
1011 "Check configuration for errors!\n", c->name); in i2o_core_evt()
1019 printk(KERN_WARNING "%s: No handler for event (0x%08x)\n", c->name, msg[4]); in i2o_core_evt()
1037 struct i2o_controller *c = (struct i2o_controller *)foo; in i2o_dyn_lct() local
1050 sprintf(name, "iop%d_lctd", c->unit); in i2o_dyn_lct()
1053 c->lct_running = 1; in i2o_dyn_lct()
1057 down_interruptible(&c->lct_sem); in i2o_dyn_lct()
1060 dprintk(KERN_ERR "%s: LCT thread dead\n", c->name); in i2o_dyn_lct()
1061 c->lct_running = 0; in i2o_dyn_lct()
1065 entries = c->dlct->table_size; in i2o_dyn_lct()
1069 dprintk(KERN_INFO "%s: Dynamic LCT Update\n",c->name); in i2o_dyn_lct()
1070 dprintk(KERN_INFO "%s: Dynamic LCT contains %d entries\n", c->name, entries); in i2o_dyn_lct()
1074 printk(KERN_INFO "%s: Empty LCT???\n", c->name); in i2o_dyn_lct()
1086 for(d = c->devices; d; ) in i2o_dyn_lct()
1093 if(d->lct_data.tid == c->dlct->lct_entry[i].tid) in i2o_dyn_lct()
1112 i2o_lct_notify(c); in i2o_dyn_lct()
1122 if(c->lct->table_size < c->dlct->table_size) in i2o_dyn_lct()
1124 tmp = c->lct; in i2o_dyn_lct()
1125 c->lct = kmalloc(c->dlct->table_size<<2, GFP_KERNEL); in i2o_dyn_lct()
1126 if(!c->lct) in i2o_dyn_lct()
1128 printk(KERN_ERR "%s: No memory for LCT!\n", c->name); in i2o_dyn_lct()
1129 c->lct = tmp; in i2o_dyn_lct()
1134 memcpy(c->lct, c->dlct, c->dlct->table_size<<2); in i2o_dyn_lct()
1148 void i2o_run_queue(struct i2o_controller *c) in i2o_run_queue() argument
1158 if((mv=I2O_REPLY_READ32(c))==0xFFFFFFFF) in i2o_run_queue()
1159 mv=I2O_REPLY_READ32(c); in i2o_run_queue()
1174 pci_dma_sync_single(c->pdev, c->page_frame_map, MSG_FRAME_SIZE, PCI_DMA_FROMDEVICE); in i2o_run_queue()
1182 i->reply(i,c,m); in i2o_run_queue()
1188 i2o_flush_reply(c,mv); in i2o_run_queue()
1192 if((mv=I2O_REPLY_READ32(c))==0xFFFFFFFF) in i2o_run_queue()
1193 mv=I2O_REPLY_READ32(c); in i2o_run_queue()
1282 u32 i2o_wait_message(struct i2o_controller *c, char *why) in i2o_wait_message() argument
1286 while((m=I2O_POST_READ32(c))==0xFFFFFFFF) in i2o_wait_message()
1291 c->name, why); in i2o_wait_message()
1310 void i2o_report_controller_unit(struct i2o_controller *c, struct i2o_device *d) in i2o_report_controller_unit() argument
1321 if((ret=i2o_query_scalar(c, unit, 0xF100, 3, buf, 16))>=0) in i2o_report_controller_unit()
1326 if((ret=i2o_query_scalar(c, unit, 0xF100, 4, buf, 16))>=0) in i2o_report_controller_unit()
1331 if(i2o_query_scalar(c, unit, 0xF100, 5, buf, 16)>=0) in i2o_report_controller_unit()
1336 if((ret=i2o_query_scalar(c, unit, 0xF100, 6, buf, 8))>=0) in i2o_report_controller_unit()
1372 static int i2o_parse_hrt(struct i2o_controller *c) in i2o_parse_hrt() argument
1375 u32 *rows=(u32*)c->hrt; in i2o_parse_hrt()
1376 u8 *p=(u8 *)c->hrt; in i2o_parse_hrt()
1386 c->name); in i2o_parse_hrt()
1394 c->name, count, length<<2); in i2o_parse_hrt()
1465 static int i2o_parse_lct(struct i2o_controller *c) in i2o_parse_lct() argument
1471 i2o_lct *lct = c->lct; in i2o_parse_lct()
1474 printk(KERN_ERR "%s: LCT is empty???\n", c->name); in i2o_parse_lct()
1482 printk(KERN_INFO "%s: LCT has %d entries.\n", c->name, max); in i2o_parse_lct()
1485 printk(KERN_WARNING "%s: Configuration dialog desired.\n", c->name); in i2o_parse_lct()
1496 d->controller = c; in i2o_parse_lct()
1504 i2o_report_controller_unit(c, d); in i2o_parse_lct()
1506 i2o_install_device(c, d); in i2o_parse_lct()
1520 int i2o_quiesce_controller(struct i2o_controller *c) in i2o_quiesce_controller() argument
1525 i2o_status_get(c); in i2o_quiesce_controller()
1529 if ((c->status_block->iop_state != ADAPTER_STATE_READY) && in i2o_quiesce_controller()
1530 (c->status_block->iop_state != ADAPTER_STATE_OPERATIONAL)) in i2o_quiesce_controller()
1541 if ((ret = i2o_post_wait(c, msg, sizeof(msg), 240))) in i2o_quiesce_controller()
1543 c->name, -ret); in i2o_quiesce_controller()
1545 dprintk(KERN_INFO "%s: Quiesced.\n", c->name); in i2o_quiesce_controller()
1547 i2o_status_get(c); // Entered READY state in i2o_quiesce_controller()
1560 int i2o_enable_controller(struct i2o_controller *c) in i2o_enable_controller() argument
1565 i2o_status_get(c); in i2o_enable_controller()
1568 if(c->status_block->iop_state != ADAPTER_STATE_READY) in i2o_enable_controller()
1576 if ((ret = i2o_post_wait(c, msg, sizeof(msg), 240))) in i2o_enable_controller()
1578 c->name, -ret); in i2o_enable_controller()
1580 dprintk(KERN_INFO "%s: Enabled.\n", c->name); in i2o_enable_controller()
1582 i2o_status_get(c); // entered OPERATIONAL state in i2o_enable_controller()
1597 int i2o_clear_controller(struct i2o_controller *c) in i2o_clear_controller() argument
1612 if ((ret=i2o_post_wait(c, msg, sizeof(msg), 30))) in i2o_clear_controller()
1614 c->name, -ret); in i2o_clear_controller()
1616 dprintk(KERN_INFO "%s: Cleared.\n",c->name); in i2o_clear_controller()
1618 i2o_status_get(c); in i2o_clear_controller()
1623 if (iop != c) in i2o_clear_controller()
1640 static int i2o_reset_controller(struct i2o_controller *c) in i2o_reset_controller() argument
1656 m=i2o_wait_message(c, "AdapterReset"); in i2o_reset_controller()
1659 msg=(u32 *)(c->mem_offset+m); in i2o_reset_controller()
1677 i2o_post_message(c,m); in i2o_reset_controller()
1705 c->name); in i2o_reset_controller()
1708 m = I2O_POST_READ32(c); in i2o_reset_controller()
1714 c->name); in i2o_reset_controller()
1719 m = I2O_POST_READ32(c); in i2o_reset_controller()
1721 i2o_flush_reply(c,m); in i2o_reset_controller()
1726 i2o_status_get(c); in i2o_reset_controller()
1728 c->status_block->iop_state != ADAPTER_STATE_RESET) in i2o_reset_controller()
1730 printk(KERN_WARNING "%s: Reset rejected, trying to clear\n",c->name); in i2o_reset_controller()
1731 i2o_clear_controller(c); in i2o_reset_controller()
1734 dprintk(KERN_INFO "%s: Reset completed.\n", c->name); in i2o_reset_controller()
1739 if (iop != c) in i2o_reset_controller()
1757 int i2o_status_get(struct i2o_controller *c) in i2o_status_get() argument
1764 if (c->status_block == NULL) in i2o_status_get()
1766 c->status_block = (i2o_status_block *) in i2o_status_get()
1768 if (c->status_block == NULL) in i2o_status_get()
1771 c->name); in i2o_status_get()
1776 status_block = (u8*)c->status_block; in i2o_status_get()
1777 memset(c->status_block,0,sizeof(i2o_status_block)); in i2o_status_get()
1779 m=i2o_wait_message(c, "StatusGet"); in i2o_status_get()
1782 msg=(u32 *)(c->mem_offset+m); in i2o_status_get()
1790 msg[6]=virt_to_bus(c->status_block); in i2o_status_get()
1794 i2o_post_message(c,m); in i2o_status_get()
1803 printk(KERN_ERR "%s: Get status timeout.\n",c->name); in i2o_status_get()
1811 printk(KERN_INFO "%s: State = ", c->name); in i2o_status_get()
1812 switch (c->status_block->iop_state) { in i2o_status_get()
1835 printk("%x (unknown !!)\n",c->status_block->iop_state); in i2o_status_get()
1847 int i2o_hrt_get(struct i2o_controller *c) in i2o_hrt_get() argument
1855 if (c->hrt == NULL) { in i2o_hrt_get()
1856 c->hrt=kmalloc(size, GFP_KERNEL); in i2o_hrt_get()
1857 if (c->hrt == NULL) { in i2o_hrt_get()
1858 printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", c->name); in i2o_hrt_get()
1867 msg[5]= virt_to_bus(c->hrt); /* Dump it here */ in i2o_hrt_get()
1869 ret = i2o_post_wait_mem(c, msg, sizeof(msg), 20, c->hrt, NULL); in i2o_hrt_get()
1875 c->hrt = NULL; in i2o_hrt_get()
1882 c->name, -ret); in i2o_hrt_get()
1886 if (c->hrt->num_entries * c->hrt->entry_len << 2 > size) { in i2o_hrt_get()
1887 size = c->hrt->num_entries * c->hrt->entry_len << 2; in i2o_hrt_get()
1888 kfree(c->hrt); in i2o_hrt_get()
1889 c->hrt = NULL; in i2o_hrt_get()
1891 } while (c->hrt == NULL); in i2o_hrt_get()
1893 i2o_parse_hrt(c); // just for debugging in i2o_hrt_get()
2175 int i2o_init_outbound_q(struct i2o_controller *c) in i2o_init_outbound_q() argument
2182 dprintk(KERN_INFO "%s: Initializing Outbound Queue...\n", c->name); in i2o_init_outbound_q()
2183 m=i2o_wait_message(c, "OutboundInit"); in i2o_init_outbound_q()
2186 msg=(u32 *)(c->mem_offset+m); in i2o_init_outbound_q()
2191 c->name); in i2o_init_outbound_q()
2206 i2o_post_message(c,m); in i2o_init_outbound_q()
2216 c->name); in i2o_init_outbound_q()
2219 c->name); in i2o_init_outbound_q()
2229 printk(KERN_ERR "%s: IOP outbound initialise failed.\n", c->name); in i2o_init_outbound_q()
2247 int i2o_post_outbound_messages(struct i2o_controller *c) in i2o_post_outbound_messages() argument
2253 c->page_frame = kmalloc(MSG_POOL_SIZE, GFP_KERNEL); in i2o_post_outbound_messages()
2254 if(c->page_frame==NULL) { in i2o_post_outbound_messages()
2256 c->name); in i2o_post_outbound_messages()
2260 c->page_frame_map = pci_map_single(c->pdev, c->page_frame, MSG_POOL_SIZE, PCI_DMA_FROMDEVICE); in i2o_post_outbound_messages()
2262 if(c->page_frame_map == 0) in i2o_post_outbound_messages()
2264 kfree(c->page_frame); in i2o_post_outbound_messages()
2265 printk(KERN_ERR "%s: Unable to map outbound queue.\n", c->name); in i2o_post_outbound_messages()
2269 m = c->page_frame_map; in i2o_post_outbound_messages()
2274 I2O_REPLY_WRITE32(c,m); in i2o_post_outbound_messages()
2285 int i2o_lct_get(struct i2o_controller *c) in i2o_lct_get() argument
2288 int ret, size = c->status_block->expected_lct_size; in i2o_lct_get()
2291 if (c->lct == NULL) { in i2o_lct_get()
2292 c->lct = kmalloc(size, GFP_KERNEL); in i2o_lct_get()
2293 if(c->lct == NULL) { in i2o_lct_get()
2295 c->name); in i2o_lct_get()
2299 memset(c->lct, 0, size); in i2o_lct_get()
2308 msg[7] = virt_to_bus(c->lct); in i2o_lct_get()
2310 ret=i2o_post_wait_mem(c, msg, sizeof(msg), 120, c->lct, NULL); in i2o_lct_get()
2314 c->lct = NULL; in i2o_lct_get()
2321 c->name, -ret); in i2o_lct_get()
2325 if (c->lct->table_size << 2 > size) { in i2o_lct_get()
2326 size = c->lct->table_size << 2; in i2o_lct_get()
2327 kfree(c->lct); in i2o_lct_get()
2328 c->lct = NULL; in i2o_lct_get()
2330 } while (c->lct == NULL); in i2o_lct_get()
2332 if ((ret=i2o_parse_lct(c)) < 0) in i2o_lct_get()
2344 int i2o_lct_notify(struct i2o_controller *c) in i2o_lct_notify() argument
2353 msg[5] = c->dlct->change_ind+1; /* Next change */ in i2o_lct_notify()
2355 msg[7] = virt_to_bus(c->dlct); in i2o_lct_notify()
2357 return i2o_post_this(c, msg, sizeof(msg)); in i2o_lct_notify()
2489 int i2o_post_this(struct i2o_controller *c, u32 *data, int len) in i2o_post_this() argument
2498 m = I2O_POST_READ32(c); in i2o_post_this()
2505 c->name); in i2o_post_this()
2508 msg = (u32 *)(c->mem_offset + m); in i2o_post_this()
2510 i2o_post_message(c,m); in i2o_post_this()
2536 int i2o_post_wait_mem(struct i2o_controller *c, u32 *msg, int len, int timeout, void *mem1, void *m… in i2o_post_wait_mem() argument
2583 if ((status = i2o_post_this(c, msg, len))==0) { in i2o_post_wait_mem()
2635 int i2o_post_wait(struct i2o_controller *c, u32 *msg, int len, int timeout) in i2o_post_wait() argument
2637 return i2o_post_wait_mem(c, msg, len, timeout, NULL, NULL); in i2o_post_wait()
3375 struct i2o_controller *c = NULL; in i2o_reboot_event() local
3390 for(c = i2o_controller_chain; c; c = c->next) in i2o_reboot_event()
3392 if(i2o_quiesce_controller(c)) in i2o_reboot_event()
3396 c->name); in i2o_reboot_event()