Lines Matching +full:host +full:- +full:to +full:- +full:chip
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * of PCI-SCSI IO processors.
6 * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
7 * Copyright (c) 2003-2005 Matthew Wilcox <matthew@wil.cx>
10 * Copyright (C) 1998-2000 Gerard Roudier
13 * a port of the FreeBSD ncr driver to Linux-1.2.13.
17 * Stefan Esser <se@mi.Uni-Koeln.de>
25 *-----------------------------------------------------------------------------
62 MODULE_PARM_DESC(cmd_per_lun, "The maximum number of tags to use by default");
63 MODULE_PARM_DESC(burst, "Maximum burst. 0 to disable, 255 to read from registers");
64 MODULE_PARM_DESC(led, "Set to 1 to enable LED support");
66 MODULE_PARM_DESC(irqm, "0 for open drain, 1 to leave alone, 2 for totem pole");
67 MODULE_PARM_DESC(buschk, "0 to not check, 1 for detach on error, 2 for warn on error");
68 MODULE_PARM_DESC(hostid, "The SCSI ID to use for the host adapters");
70 MODULE_PARM_DESC(debug, "Set bits to enable debugging");
73 MODULE_PARM_DESC(excl, "List ioport addresses here to prevent controllers from being attached");
74 MODULE_PARM_DESC(safe, "Set other settings to a \"safe mode\"");
107 " passed to safe option", safe_string); in sym2_setup_params()
122 #define SYM_SOFTC_PTR(cmd) sym_get_hcb(cmd->device->host)
131 if (ucmd->eh_done) in sym_xpt_done()
132 complete(ucmd->eh_done); in sym_xpt_done()
144 np->s.settle_time = jiffies + sym_driver_setup.settle_delay * HZ; in sym_xpt_async_bus_reset()
145 np->s.settle_time_valid = 1; in sym_xpt_async_bus_reset()
167 * Build CAM result for a failed or auto-sensed IO.
171 struct scsi_cmnd *cmd = cp->cmd; in sym_set_cam_result_error()
175 scsi_status = cp->ssss_status; in sym_set_cam_result_error()
177 if (cp->host_flags & HF_SENSE) { in sym_set_cam_result_error()
178 scsi_status = cp->sv_scsi_status; in sym_set_cam_result_error()
179 resid = cp->sv_resid; in sym_set_cam_result_error()
180 if (sym_verbose && cp->sv_xerr_status) in sym_set_cam_result_error()
181 sym_print_xerr(cmd, cp->sv_xerr_status); in sym_set_cam_result_error()
182 if (cp->host_status == HS_COMPLETE && in sym_set_cam_result_error()
183 cp->ssss_status == S_GOOD && in sym_set_cam_result_error()
184 cp->xerr_status == 0) { in sym_set_cam_result_error()
186 cp->sv_xerr_status); in sym_set_cam_result_error()
188 * Bounce back the sense data to user. in sym_set_cam_result_error()
190 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in sym_set_cam_result_error()
191 memcpy(cmd->sense_buffer, cp->sns_bbuf, in sym_set_cam_result_error()
196 * due to a RESET condition, we should consider all in sym_set_cam_result_error()
201 p = (u_char *) cmd->sense_data; in sym_set_cam_result_error()
204 cp->target,cp->lun, -1); in sym_set_cam_result_error()
214 sym_reset_scsi_target(np, cmd->device->id); in sym_set_cam_result_error()
217 } else if (cp->host_status == HS_COMPLETE) /* Bad SCSI status */ in sym_set_cam_result_error()
219 else if (cp->host_status == HS_SEL_TIMEOUT) /* Selection timeout */ in sym_set_cam_result_error()
221 else if (cp->host_status == HS_UNEXPECTED) /* Unexpected BUS FREE*/ in sym_set_cam_result_error()
226 cp->host_status, cp->ssss_status, in sym_set_cam_result_error()
227 cp->xerr_status); in sym_set_cam_result_error()
232 cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status); in sym_set_cam_result_error()
235 cmd->result = (cam_status << 16) | scsi_status; in sym_set_cam_result_error()
243 cp->data_len = 0; in sym_scatter()
248 struct sym_tcb *tp = &np->target[cp->target]; in sym_scatter()
253 return -1; in sym_scatter()
256 data = &cp->phys.data[SYM_CONF_MAX_SG - use_sg]; in sym_scatter()
262 if ((len & 1) && (tp->head.wval & EWS)) { in sym_scatter()
264 cp->odd_byte_adjustment++; in sym_scatter()
268 cp->data_len += len; in sym_scatter()
271 segment = -2; in sym_scatter()
282 struct scsi_device *sdev = cmd->device; in sym_queue_command()
291 tp = &np->target[sdev->id]; in sym_queue_command()
296 lp = sym_lp(tp, sdev->lun); in sym_queue_command()
297 order = (lp && lp->s.reqtags) ? M_SIMPLE_TAG : 0; in sym_queue_command()
314 memcpy(cp->cdb_buf, cmd->cmnd, cmd->cmd_len); in sym_setup_cdb()
316 cp->phys.cmd.addr = CCB_BA(cp, cdb_buf[0]); in sym_setup_cdb()
317 cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len); in sym_setup_cdb()
339 dir = cmd->sc_data_direction; in sym_setup_data_and_start()
341 cp->segments = sym_scatter(np, cp, cmd); in sym_setup_data_and_start()
342 if (cp->segments < 0) { in sym_setup_data_and_start()
350 if (!cp->segments) in sym_setup_data_and_start()
353 cp->data_len = 0; in sym_setup_data_and_start()
354 cp->segments = 0; in sym_setup_data_and_start()
367 lastp = goalp - 8 - (cp->segments * (2*4)); in sym_setup_data_and_start()
370 cp->host_flags |= HF_DATA_IN; in sym_setup_data_and_start()
372 lastp = goalp - 8 - (cp->segments * (2*4)); in sym_setup_data_and_start()
383 cp->phys.head.lastp = cpu_to_scr(lastp); in sym_setup_data_and_start()
384 cp->phys.head.savep = cpu_to_scr(lastp); in sym_setup_data_and_start()
385 cp->startp = cp->phys.head.savep; in sym_setup_data_and_start()
386 cp->goalp = cpu_to_scr(goalp); in sym_setup_data_and_start()
390 * panic on the first attempt to write to a SCSI device. in sym_setup_data_and_start()
391 * It is the first test we want to do after a driver in sym_setup_data_and_start()
395 switch (cp->cdb_buf[0]) { in sym_setup_data_and_start()
420 * Misused to keep the driver running when
430 np->s.timer.expires = thistime + SYM_CONF_TIMER_INTERVAL; in sym_timer()
431 add_timer(&np->s.timer); in sym_timer()
437 if (np->s.settle_time_valid) { in sym_timer()
438 if (time_before_eq(np->s.settle_time, thistime)) { in sym_timer()
442 np->s.settle_time_valid = 0; in sym_timer()
448 * Nothing to do for now, but that may come. in sym_timer()
450 if (np->s.lasttime + 4*HZ < thistime) { in sym_timer()
451 np->s.lasttime = thistime; in sym_timer()
456 * Some way-broken PCI bridges may lead to in sym_timer()
459 * concurrently with the chip raising this flag. in sym_timer()
474 struct pci_dev *pdev = sym_data->pdev; in sym_log_bus_error()
485 * queuecommand method. Entered with the host adapter lock held and
498 * this command not to time out. in sym53c8xx_queue_command_lck()
500 if (np->s.settle_time_valid && scsi_cmd_to_rq(cmd)->timeout) { in sym53c8xx_queue_command_lck()
501 unsigned long tlimit = jiffies + scsi_cmd_to_rq(cmd)->timeout; in sym53c8xx_queue_command_lck()
502 tlimit -= SYM_CONF_TIMER_INTERVAL*2; in sym53c8xx_queue_command_lck()
503 if (time_after(np->s.settle_time, tlimit)) { in sym53c8xx_queue_command_lck()
504 np->s.settle_time = tlimit; in sym53c8xx_queue_command_lck()
508 if (np->s.settle_time_valid) in sym53c8xx_queue_command_lck()
528 /* Avoid spinloop trying to handle interrupts on frozen device */ in DEF_SCSI_QCMD()
529 if (pci_channel_offline(sym_data->pdev)) in DEF_SCSI_QCMD()
534 spin_lock(shost->host_lock); in DEF_SCSI_QCMD()
536 spin_unlock(shost->host_lock); in DEF_SCSI_QCMD()
551 spin_lock_irqsave(np->s.host->host_lock, flags); in sym53c8xx_timer()
553 spin_unlock_irqrestore(np->s.host->host_lock, flags); in sym53c8xx_timer()
558 * What the eh thread wants us to perform.
565 * The 'op' argument tells what we have to do.
573 struct Scsi_Host *shost = cmd->device->host; in sym53c8xx_eh_abort_handler()
575 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_abort_handler()
576 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_abort_handler()
579 int sts = -1; in sym53c8xx_eh_abort_handler()
585 * Escalate to host reset if the PCI bus went down in sym53c8xx_eh_abort_handler()
590 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_abort_handler()
591 /* This one is queued in some place -> to wait for completion */ in sym53c8xx_eh_abort_handler()
592 FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { in sym53c8xx_eh_abort_handler()
594 if (cp->cmd == cmd) { in sym53c8xx_eh_abort_handler()
607 ucmd->eh_done = &eh_done; in sym53c8xx_eh_abort_handler()
608 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_abort_handler()
610 ucmd->eh_done = NULL; in sym53c8xx_eh_abort_handler()
611 sts = -2; in sym53c8xx_eh_abort_handler()
614 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_abort_handler()
617 dev_warn(&cmd->device->sdev_gendev, "ABORT operation %s.\n", in sym53c8xx_eh_abort_handler()
618 sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); in sym53c8xx_eh_abort_handler()
624 struct scsi_target *starget = scsi_target(cmd->device); in sym53c8xx_eh_target_reset_handler()
625 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym53c8xx_eh_target_reset_handler()
627 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_target_reset_handler()
628 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_target_reset_handler()
637 * Escalate to host reset if the PCI bus went down in sym53c8xx_eh_target_reset_handler()
642 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
643 sts = sym_reset_scsi_target(np, starget->id); in sym53c8xx_eh_target_reset_handler()
645 FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { in sym53c8xx_eh_target_reset_handler()
648 struct scsi_cmnd *cmd = cp->cmd; in sym53c8xx_eh_target_reset_handler()
651 if (!cmd || cmd->device->channel != starget->channel || in sym53c8xx_eh_target_reset_handler()
652 cmd->device->id != starget->id) in sym53c8xx_eh_target_reset_handler()
657 ucmd->eh_done = &eh_done; in sym53c8xx_eh_target_reset_handler()
658 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
660 ucmd->eh_done = NULL; in sym53c8xx_eh_target_reset_handler()
661 sts = -2; in sym53c8xx_eh_target_reset_handler()
663 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
666 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_target_reset_handler()
669 sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed"); in sym53c8xx_eh_target_reset_handler()
675 struct Scsi_Host *shost = cmd->device->host; in sym53c8xx_eh_bus_reset_handler()
677 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_bus_reset_handler()
678 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_bus_reset_handler()
683 * Escalate to host reset if the PCI bus went down in sym53c8xx_eh_bus_reset_handler()
688 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_bus_reset_handler()
690 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_bus_reset_handler()
692 dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n"); in sym53c8xx_eh_bus_reset_handler()
698 struct Scsi_Host *shost = cmd->device->host; in sym53c8xx_eh_host_reset_handler()
700 struct pci_dev *pdev = sym_data->pdev; in sym53c8xx_eh_host_reset_handler()
701 struct sym_hcb *np = sym_data->ncb; in sym53c8xx_eh_host_reset_handler()
705 shost_printk(KERN_WARNING, shost, "HOST RESET operation started\n"); in sym53c8xx_eh_host_reset_handler()
708 * went down. In this case, we need to wait until the in sym53c8xx_eh_host_reset_handler()
716 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
719 BUG_ON(sym_data->io_reset); in sym53c8xx_eh_host_reset_handler()
720 sym_data->io_reset = &eh_done; in sym53c8xx_eh_host_reset_handler()
723 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
726 (sym_data->io_reset, in sym53c8xx_eh_host_reset_handler()
728 spin_lock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
729 sym_data->io_reset = NULL; in sym53c8xx_eh_host_reset_handler()
730 spin_unlock_irq(shost->host_lock); in sym53c8xx_eh_host_reset_handler()
738 shost_printk(KERN_WARNING, shost, "HOST RESET operation %s.\n", in sym53c8xx_eh_host_reset_handler()
744 * Tune device queuing depth, according to various limits.
754 oldtags = lp->s.reqtags; in sym_tune_dev_queuing()
756 if (reqtags > lp->s.scdev_depth) in sym_tune_dev_queuing()
757 reqtags = lp->s.scdev_depth; in sym_tune_dev_queuing()
759 lp->s.reqtags = reqtags; in sym_tune_dev_queuing()
762 dev_info(&tp->starget->dev, in sym_tune_dev_queuing()
764 lp->s.reqtags ? "enabled" : "disabled", reqtags); in sym_tune_dev_queuing()
770 struct sym_hcb *np = sym_get_hcb(sdev->host); in sym53c8xx_sdev_init()
771 struct sym_tcb *tp = &np->target[sdev->id]; in sym53c8xx_sdev_init()
776 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) in sym53c8xx_sdev_init()
777 return -ENXIO; in sym53c8xx_sdev_init()
779 spin_lock_irqsave(np->s.host->host_lock, flags); in sym53c8xx_sdev_init()
784 * BIOS device numbering. Clearing the flag allows the user to in sym53c8xx_sdev_init()
790 if (tp->usrflags & SYM_SCAN_BOOT_DISABLED) { in sym53c8xx_sdev_init()
791 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED; in sym53c8xx_sdev_init()
792 starget_printk(KERN_INFO, sdev->sdev_target, in sym53c8xx_sdev_init()
794 error = -ENXIO; in sym53c8xx_sdev_init()
798 if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) { in sym53c8xx_sdev_init()
799 if (sdev->lun != 0) { in sym53c8xx_sdev_init()
800 error = -ENXIO; in sym53c8xx_sdev_init()
803 starget_printk(KERN_INFO, sdev->sdev_target, in sym53c8xx_sdev_init()
807 lp = sym_alloc_lcb(np, sdev->id, sdev->lun); in sym53c8xx_sdev_init()
809 error = -ENOMEM; in sym53c8xx_sdev_init()
812 if (tp->nlcb == 1) in sym53c8xx_sdev_init()
813 tp->starget = sdev->sdev_target; in sym53c8xx_sdev_init()
815 spi_min_period(tp->starget) = tp->usr_period; in sym53c8xx_sdev_init()
816 spi_max_width(tp->starget) = tp->usr_width; in sym53c8xx_sdev_init()
820 spin_unlock_irqrestore(np->s.host->host_lock, flags); in sym53c8xx_sdev_init()
831 struct sym_hcb *np = sym_get_hcb(sdev->host); in sym53c8xx_sdev_configure()
832 struct sym_tcb *tp = &np->target[sdev->id]; in sym53c8xx_sdev_configure()
833 struct sym_lcb *lp = sym_lp(tp, sdev->lun); in sym53c8xx_sdev_configure()
839 lp->curr_flags = lp->user_flags; in sym53c8xx_sdev_configure()
848 if (reqtags > tp->usrtags) in sym53c8xx_sdev_configure()
849 reqtags = tp->usrtags; in sym53c8xx_sdev_configure()
850 if (!sdev->tagged_supported) in sym53c8xx_sdev_configure()
856 lp->s.scdev_depth = depth_to_use; in sym53c8xx_sdev_configure()
857 sym_tune_dev_queuing(tp, sdev->lun, reqtags); in sym53c8xx_sdev_configure()
859 if (!spi_initial_dv(sdev->sdev_target)) in sym53c8xx_sdev_configure()
867 struct sym_hcb *np = sym_get_hcb(sdev->host); in sym53c8xx_sdev_destroy()
868 struct sym_tcb *tp = &np->target[sdev->id]; in sym53c8xx_sdev_destroy()
869 struct sym_lcb *lp = sym_lp(tp, sdev->lun); in sym53c8xx_sdev_destroy()
876 spin_lock_irqsave(np->s.host->host_lock, flags); in sym53c8xx_sdev_destroy()
878 if (lp->busy_itlq || lp->busy_itl) { in sym53c8xx_sdev_destroy()
881 * so let's try to stop all on-going I/O. in sym53c8xx_sdev_destroy()
883 starget_printk(KERN_WARNING, tp->starget, in sym53c8xx_sdev_destroy()
884 "Removing busy LCB (%d)\n", (u8)sdev->lun); in sym53c8xx_sdev_destroy()
888 if (sym_free_lcb(np, sdev->id, sdev->lun) == 0) { in sym53c8xx_sdev_destroy()
892 tp->head.sval = 0; in sym53c8xx_sdev_destroy()
893 tp->head.wval = np->rv_scntl3; in sym53c8xx_sdev_destroy()
894 tp->head.uval = 0; in sym53c8xx_sdev_destroy()
895 tp->tgoal.check_nego = 1; in sym53c8xx_sdev_destroy()
896 tp->starget = NULL; in sym53c8xx_sdev_destroy()
899 spin_unlock_irqrestore(np->s.host->host_lock, flags); in sym53c8xx_sdev_destroy()
905 static const char *sym53c8xx_info (struct Scsi_Host *host) in sym53c8xx_info() argument
918 * to the sym_usercmd() function.
944 switch (uc->cmd) { in sym_exec_user_command()
949 sym_debug_flags = uc->data; in sym_exec_user_command()
953 np->verbose = uc->data; in sym_exec_user_command()
957 * We assume that other commands apply to targets. in sym_exec_user_command()
959 * 4 lines to be repeated 6 times. in sym_exec_user_command()
962 if (!((uc->target >> t) & 1)) in sym_exec_user_command()
964 tp = &np->target[t]; in sym_exec_user_command()
965 if (!tp->nlcb) in sym_exec_user_command()
968 switch (uc->cmd) { in sym_exec_user_command()
971 if (!uc->data || uc->data >= 255) { in sym_exec_user_command()
972 tp->tgoal.iu = tp->tgoal.dt = in sym_exec_user_command()
973 tp->tgoal.qas = 0; in sym_exec_user_command()
974 tp->tgoal.offset = 0; in sym_exec_user_command()
975 } else if (uc->data <= 9 && np->minsync_dt) { in sym_exec_user_command()
976 if (uc->data < np->minsync_dt) in sym_exec_user_command()
977 uc->data = np->minsync_dt; in sym_exec_user_command()
978 tp->tgoal.iu = tp->tgoal.dt = in sym_exec_user_command()
979 tp->tgoal.qas = 1; in sym_exec_user_command()
980 tp->tgoal.width = 1; in sym_exec_user_command()
981 tp->tgoal.period = uc->data; in sym_exec_user_command()
982 tp->tgoal.offset = np->maxoffs_dt; in sym_exec_user_command()
984 if (uc->data < np->minsync) in sym_exec_user_command()
985 uc->data = np->minsync; in sym_exec_user_command()
986 tp->tgoal.iu = tp->tgoal.dt = in sym_exec_user_command()
987 tp->tgoal.qas = 0; in sym_exec_user_command()
988 tp->tgoal.period = uc->data; in sym_exec_user_command()
989 tp->tgoal.offset = np->maxoffs; in sym_exec_user_command()
991 tp->tgoal.check_nego = 1; in sym_exec_user_command()
994 tp->tgoal.width = uc->data ? 1 : 0; in sym_exec_user_command()
995 tp->tgoal.check_nego = 1; in sym_exec_user_command()
999 sym_tune_dev_queuing(tp, l, uc->data); in sym_exec_user_command()
1002 tp->to_reset = 1; in sym_exec_user_command()
1003 np->istat_sem = SEM; in sym_exec_user_command()
1009 if (lp) lp->to_clear = 1; in sym_exec_user_command()
1011 np->istat_sem = SEM; in sym_exec_user_command()
1015 tp->usrflags = uc->data; in sym_exec_user_command()
1027 for (cnt = len; cnt > 0 && (c = *ptr++) && isspace(c); cnt--); in sym_skip_spaces()
1029 return (len - cnt); in sym_skip_spaces()
1037 return (end - ptr); in get_int_arg()
1052 return -EINVAL; \
1053 ptr += arg_len; len -= arg_len;
1057 return -EINVAL; \
1058 ptr += arg_len; len -= arg_len;
1076 if (len > 0 && ptr[len-1] == '\n') in sym_user_command()
1077 --len; in sym_user_command()
1080 uc->cmd = UC_SETSYNC; in sym_user_command()
1082 uc->cmd = UC_SETTAGS; in sym_user_command()
1084 uc->cmd = UC_SETVERBOSE; in sym_user_command()
1086 uc->cmd = UC_SETWIDE; in sym_user_command()
1089 uc->cmd = UC_SETDEBUG; in sym_user_command()
1092 uc->cmd = UC_SETFLAG; in sym_user_command()
1094 uc->cmd = UC_RESETDEV; in sym_user_command()
1096 uc->cmd = UC_CLEARDEV; in sym_user_command()
1101 printk("sym_user_command: arg_len=%d, cmd=%ld\n", arg_len, uc->cmd); in sym_user_command()
1105 return -EINVAL; in sym_user_command()
1106 ptr += arg_len; len -= arg_len; in sym_user_command()
1108 switch(uc->cmd) { in sym_user_command()
1117 ptr += arg_len; len -= arg_len; in sym_user_command()
1118 uc->target = ~0; in sym_user_command()
1121 uc->target = (1<<target); in sym_user_command()
1129 switch(uc->cmd) { in sym_user_command()
1135 GET_INT_ARG(ptr, len, uc->data); in sym_user_command()
1137 printk("sym_user_command: data=%ld\n", uc->data); in sym_user_command()
1145 uc->data |= DEBUG_ALLOC; in sym_user_command()
1147 uc->data |= DEBUG_PHASE; in sym_user_command()
1149 uc->data |= DEBUG_QUEUE; in sym_user_command()
1151 uc->data |= DEBUG_RESULT; in sym_user_command()
1153 uc->data |= DEBUG_SCATTER; in sym_user_command()
1155 uc->data |= DEBUG_SCRIPT; in sym_user_command()
1157 uc->data |= DEBUG_TINY; in sym_user_command()
1159 uc->data |= DEBUG_TIMING; in sym_user_command()
1161 uc->data |= DEBUG_NEGO; in sym_user_command()
1163 uc->data |= DEBUG_TAGS; in sym_user_command()
1165 uc->data |= DEBUG_POINTER; in sym_user_command()
1167 return -EINVAL; in sym_user_command()
1168 ptr += arg_len; len -= arg_len; in sym_user_command()
1171 printk("sym_user_command: data=%ld\n", uc->data); in sym_user_command()
1179 uc->data &= ~SYM_DISC_ENABLED; in sym_user_command()
1181 return -EINVAL; in sym_user_command()
1182 ptr += arg_len; len -= arg_len; in sym_user_command()
1190 return -EINVAL; in sym_user_command()
1194 spin_lock_irqsave(shost->host_lock, flags); in sym_user_command()
1196 spin_unlock_irqrestore(shost->host_lock, flags); in sym_user_command()
1211 struct pci_dev *pdev = sym_data->pdev; in sym_show_info()
1212 struct sym_hcb *np = sym_data->ncb; in sym_show_info()
1214 seq_printf(m, "Chip " NAME53C "%s, device id 0x%x, " in sym_show_info()
1215 "revision id 0x%x\n", np->s.chip_name, in sym_show_info()
1216 pdev->device, pdev->revision); in sym_show_info()
1218 pci_name(pdev), pdev->irq); in sym_show_info()
1220 (int) (np->minsync_dt ? np->minsync_dt : np->minsync), in sym_show_info()
1221 np->maxwide ? "Wide" : "Narrow", in sym_show_info()
1222 np->minsync_dt ? ", DT capable" : ""); in sym_show_info()
1230 return -EINVAL; in sym_show_info()
1243 if (device->s.ioaddr) in sym_iounmap_device()
1244 pci_iounmap(device->pdev, device->s.ioaddr); in sym_iounmap_device()
1245 if (device->s.ramaddr) in sym_iounmap_device()
1246 pci_iounmap(device->pdev, device->s.ramaddr); in sym_iounmap_device()
1259 free_irq(pdev->irq, np->s.host); in sym_free_resources()
1260 if (np->s.ioaddr) in sym_free_resources()
1261 pci_iounmap(pdev, np->s.ioaddr); in sym_free_resources()
1262 if (np->s.ramaddr) in sym_free_resources()
1263 pci_iounmap(pdev, np->s.ramaddr); in sym_free_resources()
1273 * Host attach and initialisations.
1275 * Allocate host data and ncb structure.
1277 * Do chip initialization.
1287 struct pci_dev *pdev = dev->pdev; in sym_attach()
1293 unit, dev->chip.name, pdev->revision, pci_name(pdev), in sym_attach()
1294 pdev->irq); in sym_attach()
1297 * Get the firmware for this chip. in sym_attach()
1299 fw = sym_find_firmware(&dev->chip); in sym_attach()
1309 * Allocate immediately the host control block, in sym_attach()
1310 * since we are only expecting to succeed. :) in sym_attach()
1312 * are to be released on error. in sym_attach()
1314 np = __sym_calloc_dma(&pdev->dev, sizeof(*np), "HCB"); in sym_attach()
1317 np->bus_dmat = &pdev->dev; /* Result in 1 DMA pool per HBA */ in sym_attach()
1318 sym_data->ncb = np; in sym_attach()
1319 sym_data->pdev = pdev; in sym_attach()
1320 np->s.host = shost; in sym_attach()
1325 * Copy some useful infos to the HCB. in sym_attach()
1327 np->hcb_ba = vtobus(np); in sym_attach()
1328 np->verbose = sym_driver_setup.verbose; in sym_attach()
1329 np->s.unit = unit; in sym_attach()
1330 np->features = dev->chip.features; in sym_attach()
1331 np->clock_divn = dev->chip.nr_divisor; in sym_attach()
1332 np->maxoffs = dev->chip.offset_max; in sym_attach()
1333 np->maxburst = dev->chip.burst_max; in sym_attach()
1334 np->myaddr = dev->host_id; in sym_attach()
1335 np->mmio_ba = (u32)dev->mmio_base; in sym_attach()
1336 np->ram_ba = (u32)dev->ram_base; in sym_attach()
1337 np->s.ioaddr = dev->s.ioaddr; in sym_attach()
1338 np->s.ramaddr = dev->s.ramaddr; in sym_attach()
1343 strscpy(np->s.chip_name, dev->chip.name, sizeof(np->s.chip_name)); in sym_attach()
1344 sprintf(np->s.inst_name, "sym%d", np->s.unit); in sym_attach()
1346 if ((SYM_CONF_DMA_ADDRESSING_MODE > 0) && (np->features & FE_DAC) && in sym_attach()
1347 !dma_set_mask(&pdev->dev, DMA_DAC_MASK)) { in sym_attach()
1349 } else if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in sym_attach()
1354 if (sym_hcb_attach(shost, fw, dev->nvram)) in sym_attach()
1360 * we do not want to share the INTR line at all. in sym_attach()
1362 if (request_irq(pdev->irq, sym53c8xx_intr, IRQF_SHARED, NAME53C8XX, in sym_attach()
1365 sym_name(np), pdev->irq); in sym_attach()
1374 spin_lock_irqsave(shost->host_lock, flags); in sym_attach()
1386 timer_setup(&np->s.timer, sym53c8xx_timer, 0); in sym_attach()
1387 np->s.lasttime=0; in sym_attach()
1391 * Fill Linux host instance structure in sym_attach()
1394 shost->max_channel = 0; in sym_attach()
1395 shost->this_id = np->myaddr; in sym_attach()
1396 shost->max_id = np->maxwide ? 16 : 8; in sym_attach()
1397 shost->max_lun = SYM_CONF_MAX_LUN; in sym_attach()
1398 shost->unique_id = pci_resource_start(pdev, 0); in sym_attach()
1399 shost->cmd_per_lun = SYM_CONF_MAX_TAG; in sym_attach()
1400 shost->can_queue = (SYM_CONF_MAX_START-2); in sym_attach()
1401 shost->sg_tablesize = SYM_CONF_MAX_SG; in sym_attach()
1402 shost->max_cmd_len = 16; in sym_attach()
1404 shost->transportt = sym2_transport_template; in sym_attach()
1407 if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 2) in sym_attach()
1408 shost->dma_boundary = 0xFFFFFF; in sym_attach()
1410 spin_unlock_irqrestore(shost->host_lock, flags); in sym_attach()
1415 printf_err("%s: FATAL ERROR: CHECK SCSI BUS - CABLES, " in sym_attach()
1417 spin_unlock_irqrestore(shost->host_lock, flags); in sym_attach()
1432 * Detect and try to read SYMBIOS and TEKRAM NVRAM.
1437 devp->nvram = nvp; in sym_get_nvram()
1438 nvp->type = 0; in sym_get_nvram()
1450 struct sym_chip *chip; in sym_check_supported() local
1451 struct pci_dev *pdev = device->pdev; in sym_check_supported()
1456 * If user excluded this chip, do not initialize it. in sym_check_supported()
1462 return -ENODEV; in sym_check_supported()
1467 * Check if the chip is supported. Then copy the chip description in sym_check_supported()
1468 * to our device structure so we can make it match the actual device in sym_check_supported()
1471 chip = sym_lookup_chip_table(pdev->device, pdev->revision); in sym_check_supported()
1472 if (!chip) { in sym_check_supported()
1473 dev_info(&pdev->dev, "device not supported\n"); in sym_check_supported()
1474 return -ENODEV; in sym_check_supported()
1476 memcpy(&device->chip, chip, sizeof(device->chip)); in sym_check_supported()
1483 * These controllers set value 0x52414944 at RAM end - 16.
1489 if (!device->s.ramaddr) in sym_check_raid()
1492 if (device->chip.features & FE_RAM8K) in sym_check_raid()
1497 ram_val = readl(device->s.ramaddr + ram_size - 16); in sym_check_raid()
1501 dev_info(&device->pdev->dev, in sym_check_raid()
1503 return -ENODEV; in sym_check_raid()
1508 struct sym_chip *chip = &device->chip; in sym_set_workarounds() local
1509 struct pci_dev *pdev = device->pdev; in sym_set_workarounds()
1514 * We must ensure the chip will use WRITE AND INVALIDATE. in sym_set_workarounds()
1517 if (pdev->device == PCI_DEVICE_ID_NCR_53C896 && pdev->revision < 0x4) { in sym_set_workarounds()
1518 chip->features |= (FE_WRIE | FE_CLSE); in sym_set_workarounds()
1521 /* If the chip can do Memory Write Invalidate, enable it */ in sym_set_workarounds()
1522 if (chip->features & FE_WRIE) { in sym_set_workarounds()
1524 return -ENODEV; in sym_set_workarounds()
1534 * Recall: writes are not normal to status register - in sym_set_workarounds()
1535 * write a 1 to clear and a 0 to leave unchanged. in sym_set_workarounds()
1539 if (chip->features & FE_66MHZ) { in sym_set_workarounds()
1541 chip->features &= ~FE_66MHZ; in sym_set_workarounds()
1554 * Map HBA registers and on-chip SRAM (if present).
1558 struct pci_dev *pdev = device->pdev; in sym_iomap_device()
1562 pcibios_resource_to_bus(pdev->bus, &bus_addr, &pdev->resource[1]); in sym_iomap_device()
1563 device->mmio_base = bus_addr.start; in sym_iomap_device()
1565 if (device->chip.features & FE_RAM) { in sym_iomap_device()
1567 * If the BAR is 64-bit, resource 2 will be occupied by the in sym_iomap_device()
1570 if (!pdev->resource[i].flags) in sym_iomap_device()
1572 pcibios_resource_to_bus(pdev->bus, &bus_addr, in sym_iomap_device()
1573 &pdev->resource[i]); in sym_iomap_device()
1574 device->ram_base = bus_addr.start; in sym_iomap_device()
1578 if (device->mmio_base) in sym_iomap_device()
1579 device->s.ioaddr = pci_iomap(pdev, 1, in sym_iomap_device()
1582 if (!device->s.ioaddr) in sym_iomap_device()
1583 device->s.ioaddr = pci_iomap(pdev, 0, in sym_iomap_device()
1585 if (!device->s.ioaddr) { in sym_iomap_device()
1586 dev_err(&pdev->dev, "could not map registers; giving up.\n"); in sym_iomap_device()
1587 return -EIO; in sym_iomap_device()
1589 if (device->ram_base) { in sym_iomap_device()
1590 device->s.ramaddr = pci_iomap(pdev, i, in sym_iomap_device()
1592 if (!device->s.ramaddr) { in sym_iomap_device()
1593 dev_warn(&pdev->dev, in sym_iomap_device()
1595 device->ram_base = 0; in sym_iomap_device()
1608 * mode of operation, the 875s are slaved to the memory
1609 * controller for all transfers. To operate with the Linux
1611 * freed to function independently. The only wrinkle is that
1621 struct pci_dev *memc = pci_get_slot(pdev->bus, slot); in sym_config_pqs()
1623 if (!memc || memc->vendor != 0x101a || memc->device == 0x0009) { in sym_config_pqs()
1635 /* bit 2: drive individual 875 interrupts to the bus */ in sym_config_pqs()
1647 sym_dev->host_id = tmp; in sym_config_pqs()
1652 * Detach the host.
1653 * We have to free resources and halt the NCR chip.
1660 del_timer_sync(&np->s.timer); in sym_detach()
1663 * Reset NCR chip. in sym_detach()
1664 * We should use sym_soft_reset(), but we don't want to do in sym_detach()
1667 printk("%s: resetting chip\n", sym_name(np)); in sym_detach()
1680 * Driver host template.
1753 if (scsi_add_host(shost, &pdev->dev)) in sym2_probe()
1771 return -ENODEV; in sym2_probe()
1783 attach_count--; in sym2_remove()
1787 * sym2_io_error_detected() - called when PCI error is detected
1788 * @pdev: pointer to PCI device
1800 disable_irq(pdev->irq); in sym2_io_error_detected()
1808 * sym2_io_slot_dump - Enable MMIO and dump debug registers
1809 * @pdev: pointer to PCI device
1822 * sym2_reset_workarounds - hardware-specific work-arounds
1823 * @pdev: pointer to PCI device
1825 * This routine is similar to sym_set_workarounds(), except
1828 * of the steps taken there are un-needed here.
1833 struct sym_chip *chip; in sym2_reset_workarounds() local
1835 chip = sym_lookup_chip_table(pdev->device, pdev->revision); in sym2_reset_workarounds()
1838 * similar to what is done in sym_set_workarounds(). in sym2_reset_workarounds()
1841 if (!(chip->features & FE_66MHZ) && (status_reg & PCI_STATUS_66MHZ)) { in sym2_reset_workarounds()
1849 * sym2_io_slot_reset() - called when the pci bus has been reset.
1850 * @pdev: pointer to PCI device
1863 printk(KERN_ERR "%s: Unable to enable after PCI reset\n", in sym2_io_slot_reset()
1869 enable_irq(pdev->irq); in sym2_io_slot_reset()
1871 /* If the chip can do Memory Write Invalidate, enable it */ in sym2_io_slot_reset()
1872 if (np->features & FE_WRIE) { in sym2_io_slot_reset()
1877 /* Perform work-arounds, analogous to sym_set_workarounds() */ in sym2_io_slot_reset()
1880 /* Perform host reset only on one instance of the card */ in sym2_io_slot_reset()
1881 if (PCI_FUNC(pdev->devfn) == 0) { in sym2_io_slot_reset()
1883 printk(KERN_ERR "%s: Unable to reset scsi host\n", in sym2_io_slot_reset()
1894 * sym2_io_resume() - resume normal ops after PCI reset
1895 * @pdev: pointer to PCI device
1898 * OK to resume normal operation. Use completion to allow
1899 * halted scsi ops to resume.
1906 spin_lock_irq(shost->host_lock); in sym2_io_resume()
1907 if (sym_data->io_reset) in sym2_io_resume()
1908 complete(sym_data->io_reset); in sym2_io_resume()
1909 spin_unlock_irq(shost->host_lock); in sym2_io_resume()
1917 switch (np->scsi_mode) { in sym2_get_signalling()
1936 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_offset()
1938 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_offset()
1940 tp->tgoal.offset = offset; in sym2_set_offset()
1941 tp->tgoal.check_nego = 1; in sym2_set_offset()
1946 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_period()
1948 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_period()
1950 /* have to have DT for these transfers, but DT will also in sym2_set_period()
1952 if (period <= np->minsync && spi_width(starget)) in sym2_set_period()
1953 tp->tgoal.dt = 1; in sym2_set_period()
1955 tp->tgoal.period = period; in sym2_set_period()
1956 tp->tgoal.check_nego = 1; in sym2_set_period()
1961 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_width()
1963 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_width()
1965 /* It is illegal to have DT set on narrow transfers. If DT is in sym2_set_width()
1968 tp->tgoal.iu = tp->tgoal.dt = tp->tgoal.qas = 0; in sym2_set_width()
1970 tp->tgoal.width = width; in sym2_set_width()
1971 tp->tgoal.check_nego = 1; in sym2_set_width()
1976 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in sym2_set_dt()
1978 struct sym_tcb *tp = &np->target[starget->id]; in sym2_set_dt()
1982 tp->tgoal.dt = 1; in sym2_set_dt()
1984 tp->tgoal.iu = tp->tgoal.dt = tp->tgoal.qas = 0; in sym2_set_dt()
1985 tp->tgoal.check_nego = 1; in sym2_set_dt()
1991 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1993 struct sym_tcb *tp = &np->target[starget->id];
1996 tp->tgoal.iu = tp->tgoal.dt = 1;
1998 tp->tgoal.iu = 0;
1999 tp->tgoal.check_nego = 1;
2004 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
2006 struct sym_tcb *tp = &np->target[starget->id];
2009 tp->tgoal.dt = tp->tgoal.qas = 1;
2011 tp->tgoal.qas = 0;
2012 tp->tgoal.check_nego = 1;
2096 return -ENODEV; in sym2_init()