/* ------------------------------------------------------------ * Routines for driver initialization */ int ibmvscsi_init_crq_queue(struct crq_queue *queue, struct ibmvscsi_host_data *hostdata, int max_requests) { int rc; single_host_data = hostdata; rc = viopath_open(viopath_hostLp, viomajorsubtype_scsi, max_requests); if (rc < 0) { printk("viopath_open failed with rc %d in open_event_path\n", rc); goto viopath_open_failed; } rc = vio_setHandler(viomajorsubtype_scsi, ibmvscsi_handle_event); if (rc < 0) { printk("vio_setHandler failed with rc %d in open_event_path\n", rc); goto vio_setHandler_failed; } return 0; vio_setHandler_failed: viopath_close(viopath_hostLp, viomajorsubtype_scsi, max_requests); viopath_open_failed: return -1; }
static void __init get_viotape_info(struct device_node *vio_root) { HvLpEvent_Rc hvrc; u32 unit; struct vio_resource *unitinfo; dma_addr_t unitinfo_dmaaddr; size_t len = sizeof(*unitinfo) * HVMAXARCHITECTEDVIRTUALTAPES; struct vio_waitevent we; int ret; init_completion(&we.com); ret = viopath_open(viopath_hostLp, viomajorsubtype_tape, 2); if (ret) { printk(KERN_WARNING "get_viotape_info: " "error on viopath_open to hostlp %d\n", ret); return; } vio_setHandler(viomajorsubtype_tape, handle_tape_event); unitinfo = iseries_hv_alloc(len, &unitinfo_dmaaddr, GFP_ATOMIC); if (!unitinfo) goto clear_handler; memset(unitinfo, 0, len); hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, HvLpEvent_Type_VirtualIo, viomajorsubtype_tape | viotapegetinfo, HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck, viopath_sourceinst(viopath_hostLp), viopath_targetinst(viopath_hostLp), (u64)(unsigned long)&we, VIOVERSION << 16, unitinfo_dmaaddr, len, 0, 0); if (hvrc != HvLpEvent_Rc_Good) { printk(KERN_WARNING "get_viotape_info: hv error on op %d\n", (int)hvrc); goto hv_free; } wait_for_completion(&we.com); for (unit = 0; (unit < HVMAXARCHITECTEDVIRTUALTAPES) && unitinfo[unit].rsrcname[0]; unit++) { if (!do_device_node(vio_root, "viotape", FIRST_VIOTAPE + unit, unit, "byte", "IBM,iSeries-viotape", &unitinfo[unit])) break; } hv_free: iseries_hv_free(len, unitinfo, unitinfo_dmaaddr); clear_handler: vio_clearHandler(viomajorsubtype_tape); viopath_close(viopath_hostLp, viomajorsubtype_tape, 2); }
static void __init get_viodasd_info(struct device_node *vio_root) { int rc; u32 unit; rc = viopath_open(viopath_hostLp, viomajorsubtype_blockio, 2); if (rc) { printk(KERN_WARNING "get_viodasd_info: " "error opening path to host partition %d\n", viopath_hostLp); return; } /* Initialize our request handler */ vio_setHandler(viomajorsubtype_blockio, handle_block_event); for (unit = 0; unit < HVMAXARCHITECTEDVIRTUALDISKS; unit++) probe_disk(vio_root, unit); vio_clearHandler(viomajorsubtype_blockio); viopath_close(viopath_hostLp, viomajorsubtype_blockio, 2); }
static void __init get_viocd_info(struct device_node *vio_root) { HvLpEvent_Rc hvrc; u32 unit; struct vio_waitevent we; struct vio_resource *unitinfo; dma_addr_t unitinfo_dmaaddr; int ret; ret = viopath_open(viopath_hostLp, viomajorsubtype_cdio, 2); if (ret) { printk(KERN_WARNING "get_viocd_info: error opening path to host partition %d\n", viopath_hostLp); return; } /* Initialize our request handler */ vio_setHandler(viomajorsubtype_cdio, handle_cd_event); unitinfo = iseries_hv_alloc( sizeof(*unitinfo) * HVMAXARCHITECTEDVIRTUALCDROMS, &unitinfo_dmaaddr, GFP_ATOMIC); if (!unitinfo) { printk(KERN_WARNING "get_viocd_info: error allocating unitinfo\n"); goto clear_handler; } memset(unitinfo, 0, sizeof(*unitinfo) * HVMAXARCHITECTEDVIRTUALCDROMS); init_completion(&we.com); hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, HvLpEvent_Type_VirtualIo, viomajorsubtype_cdio | viocdgetinfo, HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck, viopath_sourceinst(viopath_hostLp), viopath_targetinst(viopath_hostLp), (u64)&we, VIOVERSION << 16, unitinfo_dmaaddr, 0, sizeof(*unitinfo) * HVMAXARCHITECTEDVIRTUALCDROMS, 0); if (hvrc != HvLpEvent_Rc_Good) { printk(KERN_WARNING "get_viocd_info: cdrom error sending event. rc %d\n", (int)hvrc); goto hv_free; } wait_for_completion(&we.com); if (we.rc) { printk(KERN_WARNING "get_viocd_info: bad rc %d:0x%04X\n", we.rc, we.sub_result); goto hv_free; } for (unit = 0; (unit < HVMAXARCHITECTEDVIRTUALCDROMS) && unitinfo[unit].rsrcname[0]; unit++) { if (!do_device_node(vio_root, "viocd", FIRST_VIOCD + unit, unit, "block", "IBM,iSeries-viocd", &unitinfo[unit])) break; } hv_free: iseries_hv_free(sizeof(*unitinfo) * HVMAXARCHITECTEDVIRTUALCDROMS, unitinfo, unitinfo_dmaaddr); clear_handler: vio_clearHandler(viomajorsubtype_cdio); viopath_close(viopath_hostLp, viomajorsubtype_cdio, 2); }
static int __init viocons_init2(void) { atomic_t wait_flag; int rc; /* +2 for fudge */ rc = viopath_open(HvLpConfig_getPrimaryLpIndex(), viomajorsubtype_chario, VIOCHAR_WINDOW + 2); if (rc) printk(VIOCONS_KERN_WARN "error opening to primary %d\n", rc); if (viopath_hostLp == HvLpIndexInvalid) vio_set_hostlp(); /* * And if the primary is not the same as the hosting LP, open to the * hosting lp */ if ((viopath_hostLp != HvLpIndexInvalid) && (viopath_hostLp != HvLpConfig_getPrimaryLpIndex())) { printk(VIOCONS_KERN_INFO "open path to hosting (%d)\n", viopath_hostLp); rc = viopath_open(viopath_hostLp, viomajorsubtype_chario, VIOCHAR_WINDOW + 2); /* +2 for fudge */ if (rc) printk(VIOCONS_KERN_WARN "error opening to partition %d: %d\n", viopath_hostLp, rc); } if (vio_setHandler(viomajorsubtype_chario, vioHandleCharEvent) < 0) printk(VIOCONS_KERN_WARN "error seting handler for console events!\n"); /* * First, try to open the console to the hosting lp. * Wait on a semaphore for the response. */ atomic_set(&wait_flag, 0); if ((viopath_isactive(viopath_hostLp)) && (send_open(viopath_hostLp, (void *)&wait_flag) == 0)) { printk(VIOCONS_KERN_INFO "hosting partition %d\n", viopath_hostLp); while (atomic_read(&wait_flag) == 0) mb(); atomic_set(&wait_flag, 0); } /* * If we don't have an active console, try the primary */ if ((!viopath_isactive(port_info[0].lp)) && (viopath_isactive(HvLpConfig_getPrimaryLpIndex())) && (send_open(HvLpConfig_getPrimaryLpIndex(), (void *)&wait_flag) == 0)) { printk(VIOCONS_KERN_INFO "opening console to primary partition\n"); while (atomic_read(&wait_flag) == 0) mb(); } /* Initialize the tty_driver structure */ viotty_driver = alloc_tty_driver(VTTY_PORTS); viotty_driver->owner = THIS_MODULE; viotty_driver->driver_name = "vioconsole"; viotty_driver->devfs_name = "vcs/"; viotty_driver->name = "tty"; viotty_driver->name_base = 1; viotty_driver->major = TTY_MAJOR; viotty_driver->minor_start = 1; viotty_driver->type = TTY_DRIVER_TYPE_CONSOLE; viotty_driver->subtype = 1; viotty_driver->init_termios = tty_std_termios; viotty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; tty_set_operations(viotty_driver, &serial_ops); if (tty_register_driver(viotty_driver)) { printk(VIOCONS_KERN_WARN "couldn't register console driver\n"); put_tty_driver(viotty_driver); viotty_driver = NULL; } viocons_init_cfu_buffer(); unregister_console(&viocons_early); register_console(&viocons); return 0; }