Lines Matching refs:hostdata
210 static int NCR5380_poll_politely2(struct NCR5380_hostdata *hostdata, in NCR5380_poll_politely2() argument
215 unsigned long n = hostdata->poll_loops; in NCR5380_poll_politely2()
299 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_print() local
348 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_print_phase() local
373 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_info() local
375 return hostdata->info; in NCR5380_info()
394 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_init() local
401 hostdata->host = instance; in NCR5380_init()
402 hostdata->id_mask = 1 << instance->this_id; in NCR5380_init()
403 hostdata->id_higher_mask = 0; in NCR5380_init()
404 for (i = hostdata->id_mask; i <= 0x80; i <<= 1) in NCR5380_init()
405 if (i > hostdata->id_mask) in NCR5380_init()
406 hostdata->id_higher_mask |= i; in NCR5380_init()
408 hostdata->busy[i] = 0; in NCR5380_init()
409 hostdata->dma_len = 0; in NCR5380_init()
411 spin_lock_init(&hostdata->lock); in NCR5380_init()
412 hostdata->connected = NULL; in NCR5380_init()
413 hostdata->sensing = NULL; in NCR5380_init()
414 INIT_LIST_HEAD(&hostdata->autosense); in NCR5380_init()
415 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_init()
416 INIT_LIST_HEAD(&hostdata->disconnected); in NCR5380_init()
418 hostdata->flags = flags; in NCR5380_init()
420 INIT_WORK(&hostdata->main_task, NCR5380_main); in NCR5380_init()
421 hostdata->work_q = alloc_workqueue("ncr5380_%d", in NCR5380_init()
424 if (!hostdata->work_q) in NCR5380_init()
427 snprintf(hostdata->info, sizeof(hostdata->info), in NCR5380_init()
429 instance->hostt->name, instance->irq, hostdata->io_port, in NCR5380_init()
430 hostdata->base, instance->can_queue, instance->cmd_per_lun, in NCR5380_init()
432 hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "", in NCR5380_init()
433 hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", in NCR5380_init()
434 hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : ""); in NCR5380_init()
454 hostdata->poll_loops = NCR5380_REG_POLL_TIME * accesses_per_ms / 2; in NCR5380_init()
475 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_maybe_reset_bus() local
484 NCR5380_poll_politely(hostdata, in NCR5380_maybe_reset_bus()
498 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_maybe_reset_bus()
520 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_exit() local
522 cancel_work_sync(&hostdata->main_task); in NCR5380_exit()
523 destroy_workqueue(hostdata->work_q); in NCR5380_exit()
535 struct NCR5380_hostdata *hostdata = shost_priv(instance); in complete_cmd() local
539 if (hostdata->sensing == cmd) { in complete_cmd()
542 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in complete_cmd()
544 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in complete_cmd()
547 hostdata->sensing = NULL; in complete_cmd()
566 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_queue_command() local
583 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_queue_command()
586 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_queue_command()
599 list_add(&ncmd->list, &hostdata->unissued); in NCR5380_queue_command()
601 list_add_tail(&ncmd->list, &hostdata->unissued); in NCR5380_queue_command()
603 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_queue_command()
609 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_queue_command()
615 struct NCR5380_hostdata *hostdata = shost_priv(instance); in maybe_release_dma_irq() local
618 if (list_empty(&hostdata->disconnected) && in maybe_release_dma_irq()
619 list_empty(&hostdata->unissued) && in maybe_release_dma_irq()
620 list_empty(&hostdata->autosense) && in maybe_release_dma_irq()
621 !hostdata->connected && in maybe_release_dma_irq()
622 !hostdata->selecting) { in maybe_release_dma_irq()
640 struct NCR5380_hostdata *hostdata = shost_priv(instance); in dequeue_next_cmd() local
644 if (hostdata->sensing || list_empty(&hostdata->autosense)) { in dequeue_next_cmd()
645 list_for_each_entry(ncmd, &hostdata->unissued, list) { in dequeue_next_cmd()
648 cmd, scmd_id(cmd), hostdata->busy[scmd_id(cmd)], cmd->device->lun); in dequeue_next_cmd()
650 if (!(hostdata->busy[scmd_id(cmd)] & (1 << cmd->device->lun))) { in dequeue_next_cmd()
659 ncmd = list_first_entry(&hostdata->autosense, in dequeue_next_cmd()
665 scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0); in dequeue_next_cmd()
666 hostdata->sensing = cmd; in dequeue_next_cmd()
674 struct NCR5380_hostdata *hostdata = shost_priv(instance); in requeue_cmd() local
677 if (hostdata->sensing == cmd) { in requeue_cmd()
678 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in requeue_cmd()
679 list_add(&ncmd->list, &hostdata->autosense); in requeue_cmd()
680 hostdata->sensing = NULL; in requeue_cmd()
682 list_add(&ncmd->list, &hostdata->unissued); in requeue_cmd()
696 struct NCR5380_hostdata *hostdata = in NCR5380_main() local
698 struct Scsi_Host *instance = hostdata->host; in NCR5380_main()
704 spin_lock_irq(&hostdata->lock); in NCR5380_main()
705 while (!hostdata->connected && !hostdata->selecting) { in NCR5380_main()
734 if (hostdata->connected && !hostdata->dma_len) { in NCR5380_main()
739 if (!hostdata->connected) { in NCR5380_main()
740 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_main()
743 spin_unlock_irq(&hostdata->lock); in NCR5380_main()
759 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_dma_complete() local
766 if (hostdata->read_overruns) { in NCR5380_dma_complete()
767 p = hostdata->connected->SCp.phase; in NCR5380_dma_complete()
781 if (sun3scsi_dma_finish(hostdata->connected->sc_data_direction)) { in NCR5380_dma_complete()
801 transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); in NCR5380_dma_complete()
802 hostdata->dma_len = 0; in NCR5380_dma_complete()
804 data = (unsigned char **)&hostdata->connected->SCp.ptr; in NCR5380_dma_complete()
805 count = &hostdata->connected->SCp.this_residual; in NCR5380_dma_complete()
809 if (hostdata->read_overruns) { in NCR5380_dma_complete()
813 cnt = toPIO = hostdata->read_overruns; in NCR5380_dma_complete()
869 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_intr() local
874 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_intr()
892 if (hostdata->connected) { in NCR5380_intr()
894 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
899 } else if ((NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_mask) && in NCR5380_intr()
907 if (!hostdata->connected) { in NCR5380_intr()
909 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_intr()
911 if (!hostdata->connected) in NCR5380_intr()
912 NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); in NCR5380_intr()
937 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_intr()
968 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_select()
970 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_select() local
991 hostdata->selecting = cmd; in NCR5380_select()
1004 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask); in NCR5380_select()
1011 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1012 err = NCR5380_poll_politely2(hostdata, MODE_REG, MR_ARBITRATE, 0, in NCR5380_select()
1015 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1020 if (!hostdata->selecting) { in NCR5380_select()
1031 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1038 (NCR5380_read(CURRENT_SCSI_DATA_REG) & hostdata->id_higher_mask) || in NCR5380_select()
1042 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1058 if (hostdata->flags & FLAG_TOSHIBA_DELAY) in NCR5380_select()
1063 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1069 if (!hostdata->selecting) { in NCR5380_select()
1082 NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask | (1 << scmd_id(cmd))); in NCR5380_select()
1100 spin_unlock_irq(&hostdata->lock); in NCR5380_select()
1138 err = NCR5380_poll_politely(hostdata, STATUS_REG, SR_BSY, SR_BSY, in NCR5380_select()
1142 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1150 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1154 if (!hostdata->selecting) in NCR5380_select()
1184 err = NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, HZ); in NCR5380_select()
1185 spin_lock_irq(&hostdata->lock); in NCR5380_select()
1191 if (!hostdata->selecting) { in NCR5380_select()
1215 hostdata->connected = cmd; in NCR5380_select()
1216 hostdata->busy[cmd->device->id] |= 1 << cmd->device->lun; in NCR5380_select()
1227 if (!hostdata->selecting) in NCR5380_select()
1229 hostdata->selecting = NULL; in NCR5380_select()
1263 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_transfer_pio() local
1282 if (NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, in NCR5380_transfer_pio()
1328 if (NCR5380_poll_politely(hostdata, in NCR5380_transfer_pio()
1387 struct NCR5380_hostdata __maybe_unused *hostdata = shost_priv(instance); in do_reset() local
1411 struct NCR5380_hostdata *hostdata = shost_priv(instance); in do_abort() local
1429 rc = NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, in do_abort()
1441 rc = NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, 0, in do_abort()
1489 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_transfer_dma() local
1501 hostdata->connected->SCp.phase = p; in NCR5380_transfer_dma()
1504 if (hostdata->read_overruns) in NCR5380_transfer_dma()
1505 c -= hostdata->read_overruns; in NCR5380_transfer_dma()
1506 else if (hostdata->flags & FLAG_DMA_FIXUP) in NCR5380_transfer_dma()
1522 if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) { in NCR5380_transfer_dma()
1527 result = NCR5380_dma_recv_setup(hostdata, d, c); in NCR5380_transfer_dma()
1529 result = NCR5380_dma_send_setup(hostdata, d, c); in NCR5380_transfer_dma()
1556 if (hostdata->flags & FLAG_LATE_DMA_SETUP) { in NCR5380_transfer_dma()
1561 result = NCR5380_dma_recv_setup(hostdata, d, c); in NCR5380_transfer_dma()
1563 result = NCR5380_dma_send_setup(hostdata, d, c); in NCR5380_transfer_dma()
1572 hostdata->dma_len = result; in NCR5380_transfer_dma()
1577 hostdata->dma_len = c; in NCR5380_transfer_dma()
1613 if (hostdata->flags & FLAG_DMA_FIXUP) { in NCR5380_transfer_dma()
1630 if (NCR5380_poll_politely(hostdata, BUS_AND_STATUS_REG, in NCR5380_transfer_dma()
1635 if (NCR5380_poll_politely(hostdata, STATUS_REG, in NCR5380_transfer_dma()
1646 if (NCR5380_poll_politely2(hostdata, in NCR5380_transfer_dma()
1677 __releases(&hostdata->lock) __acquires(&hostdata->lock) in NCR5380_information_transfer()
1679 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_information_transfer() local
1692 while ((cmd = hostdata->connected)) { in NCR5380_information_transfer()
1710 count = sun3scsi_dma_xfer_len(hostdata, cmd); in NCR5380_information_transfer()
1714 sun3scsi_dma_send_setup(hostdata, in NCR5380_information_transfer()
1717 sun3scsi_dma_recv_setup(hostdata, in NCR5380_information_transfer()
1748 hostdata->connected = NULL; in NCR5380_information_transfer()
1749 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1776 transfersize = NCR5380_dma_xfer_len(hostdata, cmd); in NCR5380_information_transfer()
1828 hostdata->connected = NULL; in NCR5380_information_transfer()
1829 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
1843 &hostdata->autosense); in NCR5380_information_transfer()
1858 switch (hostdata->last_message) { in NCR5380_information_transfer()
1863 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF)); in NCR5380_information_transfer()
1872 hostdata->connected = NULL; in NCR5380_information_transfer()
1873 list_add(&ncmd->list, &hostdata->disconnected); in NCR5380_information_transfer()
1912 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
1950 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
1951 if (!hostdata->connected) in NCR5380_information_transfer()
1978 hostdata->last_message = msgout; in NCR5380_information_transfer()
1981 hostdata->connected = NULL; in NCR5380_information_transfer()
1982 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
2010 spin_unlock_irq(&hostdata->lock); in NCR5380_information_transfer()
2011 NCR5380_poll_politely(hostdata, STATUS_REG, SR_REQ, SR_REQ, HZ); in NCR5380_information_transfer()
2012 spin_lock_irq(&hostdata->lock); in NCR5380_information_transfer()
2029 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_reselect() local
2043 target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask); in NCR5380_reselect()
2060 if (NCR5380_poll_politely(hostdata, in NCR5380_reselect()
2072 if (NCR5380_poll_politely(hostdata, in NCR5380_reselect()
2124 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in NCR5380_reselect()
2148 hostdata->busy[target] &= ~(1 << lun); in NCR5380_reselect()
2158 count = sun3scsi_dma_xfer_len(hostdata, tmp); in NCR5380_reselect()
2162 sun3scsi_dma_send_setup(hostdata, in NCR5380_reselect()
2165 sun3scsi_dma_recv_setup(hostdata, in NCR5380_reselect()
2177 hostdata->connected = tmp; in NCR5380_reselect()
2249 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_abort() local
2253 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_abort()
2261 if (list_del_cmd(&hostdata->unissued, cmd)) { in NCR5380_abort()
2269 if (hostdata->selecting == cmd) { in NCR5380_abort()
2272 hostdata->selecting = NULL; in NCR5380_abort()
2278 if (list_del_cmd(&hostdata->disconnected, cmd)) { in NCR5380_abort()
2290 if (hostdata->connected == cmd) { in NCR5380_abort()
2292 hostdata->connected = NULL; in NCR5380_abort()
2293 hostdata->dma_len = 0; in NCR5380_abort()
2305 if (list_del_cmd(&hostdata->autosense, cmd)) { in NCR5380_abort()
2315 hostdata->busy[scmd_id(cmd)] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2319 queue_work(hostdata->work_q, &hostdata->main_task); in NCR5380_abort()
2320 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_abort()
2328 struct NCR5380_hostdata *hostdata = shost_priv(instance); in bus_reset_cleanup() local
2343 if (hostdata->selecting) { in bus_reset_cleanup()
2344 hostdata->selecting->result = DID_RESET << 16; in bus_reset_cleanup()
2345 complete_cmd(instance, hostdata->selecting); in bus_reset_cleanup()
2346 hostdata->selecting = NULL; in bus_reset_cleanup()
2349 list_for_each_entry(ncmd, &hostdata->disconnected, list) { in bus_reset_cleanup()
2355 INIT_LIST_HEAD(&hostdata->disconnected); in bus_reset_cleanup()
2357 list_for_each_entry(ncmd, &hostdata->autosense, list) { in bus_reset_cleanup()
2362 INIT_LIST_HEAD(&hostdata->autosense); in bus_reset_cleanup()
2364 if (hostdata->connected) { in bus_reset_cleanup()
2365 set_host_byte(hostdata->connected, DID_RESET); in bus_reset_cleanup()
2366 complete_cmd(instance, hostdata->connected); in bus_reset_cleanup()
2367 hostdata->connected = NULL; in bus_reset_cleanup()
2371 hostdata->busy[i] = 0; in bus_reset_cleanup()
2372 hostdata->dma_len = 0; in bus_reset_cleanup()
2374 queue_work(hostdata->work_q, &hostdata->main_task); in bus_reset_cleanup()
2387 struct NCR5380_hostdata *hostdata = shost_priv(instance); in NCR5380_host_reset() local
2391 spin_lock_irqsave(&hostdata->lock, flags); in NCR5380_host_reset()
2399 list_for_each_entry(ncmd, &hostdata->unissued, list) { in NCR5380_host_reset()
2405 INIT_LIST_HEAD(&hostdata->unissued); in NCR5380_host_reset()
2410 spin_unlock_irqrestore(&hostdata->lock, flags); in NCR5380_host_reset()