Lines Matching +full:cmdq +full:- +full:sync

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 ** Device driver for the PCI-SCSI NCR538XX controller family.
8 **-----------------------------------------------------------------------------
22 ** Stefan Esser <se@mi.Uni-Koeln.de>
27 **-----------------------------------------------------------------------------
38 ** Support for Fast-20 scsi.
42 ** Support for Fast-40 scsi.
43 ** Support for on-Board RAM.
46 ** Full support for scsi scripts instructions pre-fetching.
57 ** Low PCI traffic for command handling when on-chip RAM is present.
61 ** PCI-ectomy. This driver now supports only the 720 chip (see the
68 ** Supported SCSI-II features:
77 ** 53C720 (Wide, Fast SCSI-2, intfly problems)
81 #define SCSI_NCR_DRIVER_NAME "ncr53c8xx-3.4.3g"
87 #include <linux/dma-mapping.h>
159 struct list_head *elem = head->next; in ncr_list_pop()
170 ** Simple power of two buddy-like allocator.
179 ** Enhanced in linux-2.3.44 to provide a memory pool
197 #define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
199 typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
213 #define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
224 struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
233 m_link_s *h = mp->h; in ___m_alloc()
246 h[j].next = (m_link_s *)mp->getp(mp); in ___m_alloc()
248 h[j].next->next = NULL; in ___m_alloc()
256 h[j].next = h[j].next->next; in ___m_alloc()
258 j -= 1; in ___m_alloc()
261 h[j].next->next = NULL; in ___m_alloc()
276 m_link_s *h = mp->h; in ___m_free()
295 mp->freep(mp, a); in ___m_free()
301 while (q->next && q->next != (m_link_s *) b) { in ___m_free()
302 q = q->next; in ___m_free()
304 if (!q->next) { in ___m_free()
305 ((m_link_s *) a)->next = h[i].next; in ___m_free()
309 q->next = q->next->next; in ___m_free()
325 printk ("new %-10s[%4d] @%p.\n", name, size, p); in __m_calloc2()
340 printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr); in __m_free()
356 ++mp->nump; in ___mp0_getp()
363 --mp->nump; in ___mp0_freep()
384 vp = (m_addr_t) dma_alloc_coherent(mp->bush, in ___dma_getp()
389 vbp->vaddr = vp; in ___dma_getp()
390 vbp->baddr = daddr; in ___dma_getp()
391 vbp->next = mp->vtob[hc]; in ___dma_getp()
392 mp->vtob[hc] = vbp; in ___dma_getp()
393 ++mp->nump; in ___dma_getp()
407 vbpp = &mp->vtob[hc]; in ___dma_freep()
408 while (*vbpp && (*vbpp)->vaddr != m) in ___dma_freep()
409 vbpp = &(*vbpp)->next; in ___dma_freep()
412 *vbpp = (*vbpp)->next; in ___dma_freep()
413 dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER, in ___dma_freep()
414 (void *)vbp->vaddr, (dma_addr_t)vbp->baddr); in ___dma_freep()
416 --mp->nump; in ___dma_freep()
423 for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next); in ___get_dma_pool()
433 mp->bush = bush; in ___cre_dma_pool()
434 mp->getp = ___dma_getp; in ___cre_dma_pool()
435 mp->freep = ___dma_freep; in ___cre_dma_pool()
436 mp->next = mp0.next; in ___cre_dma_pool()
447 pp = &(*pp)->next; in ___del_dma_pool()
449 *pp = (*pp)->next; in ___del_dma_pool()
466 if (mp && !mp->nump) in __m_calloc_dma()
482 if (mp && !mp->nump) in __m_free_dma()
498 vp = mp->vtob[hc]; in __vtobus()
499 while (vp && (m_addr_t) vp->vaddr != a) in __vtobus()
500 vp = vp->next; in __vtobus()
503 return vp ? vp->baddr + (((m_addr_t) m) - a) : 0; in __vtobus()
506 #define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
507 #define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
510 #define _vtobus(np, p) __vtobus(np->dev, p)
523 switch(cmd->__data_mapped) { in __unmap_scsi_data()
528 cmd->__data_mapped = 0; in __unmap_scsi_data()
539 cmd->__data_mapped = 2; in __map_scsi_sg_data()
540 cmd->__data_mapping = use_sg; in __map_scsi_sg_data()
545 #define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
546 #define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
553 ** options. It can be overridden at boot-up by the boot
569 #define bootverbose (np->verbose)
627 "sync:" "verb:"
650 if (!strncmp(p, cur, pc - cur)) in get_setup_token()
685 i < sizeof(driver_setup.tag_ctrl)-1) { in sym53c8xx__setup()
768 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); in sym53c8xx__setup()
787 #define ALL_TARGETS -2
788 #define NO_TARGET -1
789 #define ALL_LUNS -2
790 #define NO_LUN -1
798 h = -1; in device_queue_depth()
824 case '-': in device_queue_depth()
844 ** atomically, 64 bit little-endian architecture requires
864 /* All > 32 bit (64 bit) architectures regardless endian-ness */
922 ** n permits target numbers 0..n-1.
935 ** n enables logic unit numbers 0..n-1.
947 ** Asynchronous pre-scaler (ns). Shall be 40
980 ** The data scripts are broken into 2 sub-scripts.
981 ** 80 (MAX_SCATTERL) segments are moved from a sub-script
982 ** in on-chip RAM. This makes data transfers shorter than
990 #define MAX_SCATTERH (MAX_SCATTER - MAX_SCATTERL)
992 #define MAX_SCATTERL (MAX_SCATTER-1)
1007 #define bootverbose (np->verbose)
1018 #define HS_NEGOTIATE (2) /* sync/wide data transfer*/
1154 /*----------------------------------------------------------------
1160 **----------------------------------------------------------------
1164 /*----------------------------------------------------------------
1166 ** register (sync/wide mode).
1170 **----------------------------------------------------------------
1174 /*----------------------------------------------------------------
1178 **----------------------------------------------------------------
1182 /*----------------------------------------------------------------
1190 **----------------------------------------------------------------
1195 /*----------------------------------------------------------------
1199 **----------------------------------------------------------------
1203 /*----------------------------------------------------------------
1205 **----------------------------------------------------------------
1210 /*----------------------------------------------------------------
1212 **----------------------------------------------------------------
1247 /*----------------------------------------------------------------
1259 **----------------------------------------------------------------
1266 /*----------------------------------------------------------------
1272 **----------------------------------------------------------------
1277 /*----------------------------------------------------------------
1279 **----------------------------------------------------------------
1292 /*----------------------------------------------------------------
1296 **----------------------------------------------------------------
1305 /*----------------------------------------------------------------
1307 **----------------------------------------------------------------
1309 /*----------------------------------------------------------------
1311 **----------------------------------------------------------------
1330 **------------------------------------------------------------------------
1333 /*----------------------------------------------------------------
1336 **----------------------------------------------------------------
1354 **------------------------------------------------------------------------
1358 /*----------------------------------------------------------------
1364 **----------------------------------------------------------------
1370 /*----------------------------------------------------------------
1374 **----------------------------------------------------------------
1379 /*----------------------------------------------------------------
1381 **----------------------------------------------------------------
1385 /*----------------------------------------------------------------
1387 **----------------------------------------------------------------
1466 ** the script-processor-changeable data and
1469 **----------------------------------------------------------
1499 /*----------------------------------------------------------------
1504 **----------------------------------------------------------------
1508 /*----------------------------------------------------------------
1509 ** Mini-script used at CCB execution start-up.
1512 **----------------------------------------------------------------
1516 /*----------------------------------------------------------------
1517 ** Mini-script used at CCB relection to restart the nexus.
1520 **----------------------------------------------------------------
1524 /*----------------------------------------------------------------
1529 **----------------------------------------------------------------
1533 /*----------------------------------------------------------------
1536 **----------------------------------------------------------------
1543 /*----------------------------------------------------------------
1549 ** While negotiating sync or wide transfer,
1551 **----------------------------------------------------------------
1556 /*----------------------------------------------------------------
1558 **----------------------------------------------------------------
1574 #define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl))
1584 /*----------------------------------------------------------------
1589 **----------------------------------------------------------------
1593 /*----------------------------------------------------------------
1595 **----------------------------------------------------------------
1603 /*----------------------------------------------------------------
1605 **----------------------------------------------------------------
1610 /*----------------------------------------------------------------
1614 **----------------------------------------------------------------
1619 /*----------------------------------------------------------------
1623 **----------------------------------------------------------------
1628 /*----------------------------------------------------------------
1637 **----------------------------------------------------------------
1642 /*----------------------------------------------------------------
1644 **----------------------------------------------------------------
1648 unsigned long paddr2; /* On-chip RAM bus address. */
1652 /*----------------------------------------------------------------
1654 ** 'script' is loaded in the on-chip RAM if present.
1656 **----------------------------------------------------------------
1664 /*----------------------------------------------------------------
1666 **----------------------------------------------------------------
1675 u_char minsync; /* Minimum sync period factor */
1676 u_char maxsync; /* Maximum sync period factor */
1682 /*----------------------------------------------------------------
1686 **----------------------------------------------------------------
1693 /*----------------------------------------------------------------
1695 **----------------------------------------------------------------
1701 /*----------------------------------------------------------------
1703 **----------------------------------------------------------------
1708 /*----------------------------------------------------------------
1709 ** Miscellaneous buffers accessed by the scripts-processor.
1712 **----------------------------------------------------------------
1719 /*----------------------------------------------------------------
1721 **----------------------------------------------------------------
1730 /*----------------------------------------------------------------
1732 **----------------------------------------------------------------
1738 /*----------------------------------------------------------------
1740 **----------------------------------------------------------------
1747 #define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl))
1748 #define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl))
1753 ** Script for NCR-Processor.
1768 **----------------------------------------------------------
1789 ** Script fragments which are loaded into the on-chip RAM
1949 return np->inst_name; in ncr_name()
1956 ** Scripts for NCR-Processor.
1969 **----------------------------------------------------------
1986 /*--------------------------< START >-----------------------*/ {
2004 }/*-------------------------< STARTPOS >--------------------*/,{
2007 }/*-------------------------< SELECT >----------------------*/,{
2031 }/*-------------------------< SELECT2 >----------------------*/,{
2048 ** complete or selection time-out to occur.
2076 ** COPY command with the DSA-register.
2092 }/*-------------------------< LOADPOS >---------------------*/,{
2097 ** to complete or time-out.
2102 }/*-------------------------< SEND_IDENT >----------------------*/,{
2117 }/*-------------------------< PREPARE >----------------------*/,{
2131 }/*-------------------------< PREPARE2 >---------------------*/,{
2147 }/*-------------------------< COMMAND >--------------------*/,{
2163 }/*-----------------------< DISPATCH >----------------------*/,{
2175 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 4.
2177 ** This work-around resets the addressing logic prior to the
2213 }/*-------------------------< CLRACK >----------------------*/,{
2222 }/*-------------------------< NO_DATA >--------------------*/,{
2252 }/*-------------------------< STATUS >--------------------*/,{
2268 }/*-------------------------< MSG_IN >--------------------*/,{
2278 }/*-------------------------< MSG_IN2 >--------------------*/,{
2305 }/*-------------------------< MSG_BAD >------------------*/,{
2307 ** unimplemented message - reject it.
2313 }/*-------------------------< SETMSG >----------------------*/,{
2321 }/*-------------------------< CLEANUP >-------------------*/,{
2326 ** HS_REG: Host-Status (<>0!)
2339 }/*-------------------------< COMPLETE >-----------------*/,{
2368 }/*-------------------------< CLEANUP_OK >----------------*/,{
2387 }/*-------------------------< CLEANUP0 >--------------------*/,{
2389 }/*-------------------------< SIGNAL >----------------------*/,{
2428 }/*------------------------< DONE_POS >---------------------*/,{
2430 }/*------------------------< DONE_PLUG >--------------------*/,{
2433 }/*------------------------< DONE_END >---------------------*/,{
2444 }/*-------------------------< SAVE_DP >------------------*/,{
2456 }/*-------------------------< RESTORE_DP >---------------*/,{
2467 }/*-------------------------< DISCONNECT >---------------*/,{
2491 }/*-------------------------< MSG_OUT >-------------------*/,{
2511 }/*-------------------------< MSG_OUT_DONE >--------------*/,{
2525 }/*-------------------------< IDLE >------------------------*/,{
2534 }/*-------------------------< RESELECT >--------------------*/,{
2552 }/*-------------------------< RESELECTED >------------------*/,{
2566 ** - struct ncb
2567 ** - struct tcb
2568 ** - struct lcb
2569 ** - struct ccb
2579 }/*-------------------------< RESEL_DSA >-------------------*/,{
2592 ** COPY command with the DSA-register.
2609 }/*-------------------------< LOADPOS1 >-------------------*/,{
2618 }/*-------------------------< RESEL_LUN >-------------------*/,{
2639 }/*-------------------------< RESEL_TAG >-------------------*/,{
2644 ** driver only supports conformant devices for tags. ;-)
2650 ** Still an aggressive optimization. ;-)
2659 }/*-------------------------< JUMP_TO_NEXUS >-------------------*/,{
2668 }/*-------------------------< NEXUS_INDIRECT >-------------------*/,{
2673 }/*-------------------------< RESEL_NOTAG >-------------------*/,{
2682 }/*-------------------------< DATA_IN >--------------------*/,{
2695 **---------------------------------------------------------
2698 }/*-------------------------< DATA_IN2 >-------------------*/,{
2703 }/*-------------------------< DATA_OUT >--------------------*/,{
2716 **---------------------------------------------------------
2719 }/*-------------------------< DATA_OUT2 >-------------------*/,{
2724 }/*--------------------------------------------------------*/
2728 /*-------------------------< TRYLOOP >---------------------*/{
2738 **-----------------------------------------------------------
2745 **-----------------------------------------------------------
2748 }/*------------------------< TRYLOOP2 >---------------------*/,{
2754 }/*------------------------< DONE_QUEUE >-------------------*/,{
2761 **-----------------------------------------------------------
2771 **-----------------------------------------------------------
2774 }/*------------------------< DONE_QUEUE2 >------------------*/,{
2779 }/*------------------------< SELECT_NO_ATN >-----------------*/,{
2794 }/*-------------------------< CANCEL >------------------------*/,{
2800 }/*-------------------------< SKIP >------------------------*/,{
2817 ** COPY command with the DSA-register.
2833 }/*-------------------------< SKIP2 >---------------------*/,{
2860 },/*-------------------------< PAR_ERR_DATA_IN >---------------*/{
2869 -24,
2870 },/*-------------------------< PAR_ERR_OTHER >------------------*/{
2881 }/*-------------------------< MSG_REJECT >---------------*/,{
2897 }/*-------------------------< MSG_IGN_RESIDUE >----------*/,{
2945 }/*-------------------------< MSG_EXTENDED >-------------*/,{
2964 }/*-------------------------< MSG_EXT_2 >----------------*/,{
2981 }/*-------------------------< MSG_WDTR >-----------------*/,{
3006 }/*-------------------------< SEND_WDTR >----------------*/,{
3018 }/*-------------------------< MSG_EXT_3 >----------------*/,{
3036 }/*-------------------------< MSG_SDTR >-----------------*/,{
3061 }/*-------------------------< SEND_SDTR >-------------*/,{
3073 }/*-------------------------< NEGO_BAD_PHASE >------------*/,{
3079 }/*-------------------------< MSG_OUT_ABORT >-------------*/,{
3099 }/*-------------------------< HDATA_IN >-------------------*/,{
3112 **---------------------------------------------------------
3115 }/*-------------------------< HDATA_IN2 >------------------*/,{
3119 }/*-------------------------< HDATA_OUT >-------------------*/,{
3132 **---------------------------------------------------------
3135 }/*-------------------------< HDATA_OUT2 >------------------*/,{
3139 }/*-------------------------< RESET >----------------------*/,{
3148 }/*-------------------------< ABORTTAG >-------------------*/,{
3156 }/*-------------------------< ABORT >----------------------*/,{
3162 }/*-------------------------< ABORT_RESEL >----------------*/,{
3187 }/*-------------------------< RESEND_IDENT >-------------------*/,{
3198 }/*-------------------------< CLRATN_GO_ON >-------------------*/,{
3202 }/*-------------------------< NXTDSP_GO_ON >-------------------*/,{
3204 }/*-------------------------< SDATA_IN >-------------------*/,{
3213 }/*-------------------------< DATA_IO >--------------------*/,{
3218 ** savep --> DATA_IO
3219 ** lastp --> start pointer when DATA_IN
3220 ** goalp --> goal pointer when DATA_IN
3221 ** wlastp --> start pointer when DATA_OUT
3222 ** wgoalp --> goal pointer when DATA_OUT
3254 -64,
3255 }/*-------------------------< BAD_IDENTIFY >---------------*/,{
3280 }/*-------------------------< BAD_I_T_L >------------------*/,{
3290 }/*-------------------------< BAD_I_T_L_Q >----------------*/,{
3300 }/*-------------------------< BAD_TARGET >-----------------*/,{
3315 }/*-------------------------< BAD_STATUS >-----------------*/,{
3329 }/*-------------------------< START_RAM >-------------------*/,{
3331 ** Load the script into on-chip RAM,
3342 }/*-------------------------< START_RAM0 >--------------------*/,{
3347 }/*-------------------------< STO_RESTART >-------------------*/,{
3358 }/*-------------------------< WAIT_DMA >-------------------*/,{
3369 }/*-------------------------< SNOOPTEST >-------------------*/,{
3388 }/*-------------------------< SNOOPEND >-------------------*/,{
3394 }/*--------------------------------------------------------*/
3411 p = scrh->tryloop; in ncr_script_fill()
3417 BUG_ON((u_long)p != (u_long)&scrh->tryloop + sizeof (scrh->tryloop)); in ncr_script_fill()
3421 p = scrh->done_queue; in ncr_script_fill()
3430 BUG_ON((u_long)p != (u_long)&scrh->done_queue+sizeof(scrh->done_queue)); in ncr_script_fill()
3434 p = scrh->hdata_in; in ncr_script_fill()
3442 BUG_ON((u_long)p != (u_long)&scrh->hdata_in + sizeof (scrh->hdata_in)); in ncr_script_fill()
3444 p = scr->data_in; in ncr_script_fill()
3452 BUG_ON((u_long)p != (u_long)&scr->data_in + sizeof (scr->data_in)); in ncr_script_fill()
3454 p = scrh->hdata_out; in ncr_script_fill()
3462 BUG_ON((u_long)p != (u_long)&scrh->hdata_out + sizeof (scrh->hdata_out)); in ncr_script_fill()
3464 p = scr->data_out; in ncr_script_fill()
3472 BUG_ON((u_long) p != (u_long)&scr->data_out + sizeof (scr->data_out)); in ncr_script_fill()
3509 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3515 (src-1), (unsigned)opcode); in ncr_script_copy_and_bind()
3539 ncr_name(np), (int) (src-start-1)); in ncr_script_copy_and_bind()
3546 if ((opcode & SCR_NO_FLUSH) && !(np->features & FE_PFEN)) { in ncr_script_copy_and_bind()
3547 dst[-1] = cpu_to_scr(opcode & ~SCR_NO_FLUSH); in ncr_script_copy_and_bind()
3562 ** don't relocate if relative :-) in ncr_script_copy_and_bind()
3583 while (relocs--) { in ncr_script_copy_and_bind()
3588 new = (old & ~RELOC_MASK) + np->paddr; in ncr_script_copy_and_bind()
3591 new = (old & ~RELOC_MASK) + np->p_script; in ncr_script_copy_and_bind()
3594 new = (old & ~RELOC_MASK) + np->p_scripth; in ncr_script_copy_and_bind()
3597 new = (old & ~RELOC_MASK) + np->p_ncb; in ncr_script_copy_and_bind()
3638 #define PRINT_ADDR(cmd, arg...) dev_info(&cmd->device->sdev_gendev , ## arg)
3642 PRINT_ADDR(cp->cmd, "%s: ", label); in ncr_print_msg()
3691 u_char *be = &np->rv_ctest0; in ncr_init_burst()
3693 np->rv_dmode &= ~(0x3 << 6); in ncr_init_burst()
3694 np->rv_ctest5 &= ~0x4; in ncr_init_burst()
3699 --bc; in ncr_init_burst()
3700 np->rv_dmode |= ((bc & 0x3) << 6); in ncr_init_burst()
3701 np->rv_ctest5 |= (bc & 0x4); in ncr_init_burst()
3715 np->sv_scntl0 = INB(nc_scntl0) & 0x0a; in ncr_prepare_setting()
3716 np->sv_scntl3 = INB(nc_scntl3) & 0x07; in ncr_prepare_setting()
3717 np->sv_dmode = INB(nc_dmode) & 0xce; in ncr_prepare_setting()
3718 np->sv_dcntl = INB(nc_dcntl) & 0xa8; in ncr_prepare_setting()
3719 np->sv_ctest0 = INB(nc_ctest0) & 0x84; in ncr_prepare_setting()
3720 np->sv_ctest3 = INB(nc_ctest3) & 0x01; in ncr_prepare_setting()
3721 np->sv_ctest4 = INB(nc_ctest4) & 0x80; in ncr_prepare_setting()
3722 np->sv_ctest5 = INB(nc_ctest5) & 0x24; in ncr_prepare_setting()
3723 np->sv_gpcntl = INB(nc_gpcntl); in ncr_prepare_setting()
3724 np->sv_stest2 = INB(nc_stest2) & 0x20; in ncr_prepare_setting()
3725 np->sv_stest4 = INB(nc_stest4); in ncr_prepare_setting()
3731 np->maxwide = (np->features & FE_WIDE)? 1 : 0; in ncr_prepare_setting()
3736 if (np->features & FE_ULTRA) in ncr_prepare_setting()
3737 np->clock_khz = 80000; in ncr_prepare_setting()
3739 np->clock_khz = 40000; in ncr_prepare_setting()
3744 if (np->features & FE_QUAD) in ncr_prepare_setting()
3745 np->multiplier = 4; in ncr_prepare_setting()
3746 else if (np->features & FE_DBLR) in ncr_prepare_setting()
3747 np->multiplier = 2; in ncr_prepare_setting()
3749 np->multiplier = 1; in ncr_prepare_setting()
3755 if (np->features & FE_VARCLK) in ncr_prepare_setting()
3756 ncr_getclock(np, np->multiplier); in ncr_prepare_setting()
3759 * Divisor to be used for async (timer pre-scaler). in ncr_prepare_setting()
3761 i = np->clock_divn - 1; in ncr_prepare_setting()
3762 while (--i >= 0) { in ncr_prepare_setting()
3763 if (10ul * SCSI_NCR_MIN_ASYNC * np->clock_khz > div_10M[i]) { in ncr_prepare_setting()
3768 np->rv_scntl3 = i+1; in ncr_prepare_setting()
3775 period = (4 * div_10M[0] + np->clock_khz - 1) / np->clock_khz; in ncr_prepare_setting()
3776 if (period <= 250) np->minsync = 10; in ncr_prepare_setting()
3777 else if (period <= 303) np->minsync = 11; in ncr_prepare_setting()
3778 else if (period <= 500) np->minsync = 12; in ncr_prepare_setting()
3779 else np->minsync = (period + 40 - 1) / 40; in ncr_prepare_setting()
3782 * Check against chip SCSI standard support (SCSI-2,ULTRA,ULTRA2). in ncr_prepare_setting()
3785 if (np->minsync < 25 && !(np->features & FE_ULTRA)) in ncr_prepare_setting()
3786 np->minsync = 25; in ncr_prepare_setting()
3792 period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz); in ncr_prepare_setting()
3793 np->maxsync = period > 2540 ? 254 : period / 10; in ncr_prepare_setting()
3799 np->rv_scntl0 = np->sv_scntl0; in ncr_prepare_setting()
3800 np->rv_dmode = np->sv_dmode; in ncr_prepare_setting()
3801 np->rv_dcntl = np->sv_dcntl; in ncr_prepare_setting()
3802 np->rv_ctest0 = np->sv_ctest0; in ncr_prepare_setting()
3803 np->rv_ctest3 = np->sv_ctest3; in ncr_prepare_setting()
3804 np->rv_ctest4 = np->sv_ctest4; in ncr_prepare_setting()
3805 np->rv_ctest5 = np->sv_ctest5; in ncr_prepare_setting()
3806 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3814 burst_max = burst_code(np->sv_dmode, np->sv_ctest0); in ncr_prepare_setting()
3817 if (burst_max > np->maxburst) in ncr_prepare_setting()
3818 burst_max = np->maxburst; in ncr_prepare_setting()
3823 if (np->features & FE_ERL) in ncr_prepare_setting()
3824 np->rv_dmode |= ERL; /* Enable Read Line */ in ncr_prepare_setting()
3825 if (np->features & FE_BOF) in ncr_prepare_setting()
3826 np->rv_dmode |= BOF; /* Burst Opcode Fetch */ in ncr_prepare_setting()
3827 if (np->features & FE_ERMP) in ncr_prepare_setting()
3828 np->rv_dmode |= ERMP; /* Enable Read Multiple */ in ncr_prepare_setting()
3829 if (np->features & FE_PFEN) in ncr_prepare_setting()
3830 np->rv_dcntl |= PFEN; /* Prefetch Enable */ in ncr_prepare_setting()
3831 if (np->features & FE_CLSE) in ncr_prepare_setting()
3832 np->rv_dcntl |= CLSE; /* Cache Line Size Enable */ in ncr_prepare_setting()
3833 if (np->features & FE_WRIE) in ncr_prepare_setting()
3834 np->rv_ctest3 |= WRIE; /* Write and Invalidate */ in ncr_prepare_setting()
3835 if (np->features & FE_DFS) in ncr_prepare_setting()
3836 np->rv_ctest5 |= DFS; /* Dma Fifo Size */ in ncr_prepare_setting()
3837 if (np->features & FE_MUX) in ncr_prepare_setting()
3838 np->rv_ctest4 |= MUX; /* Host bus multiplex mode */ in ncr_prepare_setting()
3839 if (np->features & FE_EA) in ncr_prepare_setting()
3840 np->rv_dcntl |= EA; /* Enable ACK */ in ncr_prepare_setting()
3841 if (np->features & FE_EHP) in ncr_prepare_setting()
3842 np->rv_ctest0 |= EHP; /* Even host parity */ in ncr_prepare_setting()
3848 np->rv_ctest4 |= MPEE; /* Master parity checking */ in ncr_prepare_setting()
3850 np->rv_scntl0 |= 0x0a; /* full arb., ena parity, par->ATN */ in ncr_prepare_setting()
3855 if (np->myaddr == 255) { in ncr_prepare_setting()
3856 np->myaddr = INB(nc_scid) & 0x07; in ncr_prepare_setting()
3857 if (!np->myaddr) in ncr_prepare_setting()
3858 np->myaddr = SCSI_NCR_MYADDR; in ncr_prepare_setting()
3871 ** - ULTRA2 chips (895/895A/896) report the current in ncr_prepare_setting()
3873 ** - For previous generation chips (825/825A/875), in ncr_prepare_setting()
3877 np->scsi_mode = SMODE_SE; in ncr_prepare_setting()
3878 if (np->features & FE_DIFF) { in ncr_prepare_setting()
3881 if (np->sv_scntl3) { in ncr_prepare_setting()
3882 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3883 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3892 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3895 if (np->sv_stest2 & 0x20) in ncr_prepare_setting()
3896 np->scsi_mode = SMODE_HVD; in ncr_prepare_setting()
3902 if (np->scsi_mode == SMODE_HVD) in ncr_prepare_setting()
3903 np->rv_stest2 |= 0x20; in ncr_prepare_setting()
3913 !(np->features & FE_LEDC) && !(np->sv_gpcntl & 0x01)) in ncr_prepare_setting()
3914 np->features |= FE_LED0; in ncr_prepare_setting()
3921 np->rv_dcntl |= IRQM; in ncr_prepare_setting()
3924 np->rv_dcntl |= (np->sv_dcntl & IRQM); in ncr_prepare_setting()
3932 ** Allow to override sync, wide and NOSCAN from in ncr_prepare_setting()
3936 struct tcb *tp = &np->target[i]; in ncr_prepare_setting()
3938 tp->usrsync = driver_setup.default_sync; in ncr_prepare_setting()
3939 tp->usrwide = driver_setup.max_wide; in ncr_prepare_setting()
3940 tp->usrtags = MAX_TAGS; in ncr_prepare_setting()
3941 tp->period = 0xffff; in ncr_prepare_setting()
3943 np->target[i].usrflag = UF_NODISC; in ncr_prepare_setting()
3950 printk(KERN_INFO "%s: ID %d, Fast-%d%s%s\n", ncr_name(np), in ncr_prepare_setting()
3951 np->myaddr, in ncr_prepare_setting()
3952 np->minsync < 12 ? 40 : (np->minsync < 25 ? 20 : 10), in ncr_prepare_setting()
3953 (np->rv_scntl0 & 0xa) ? ", Parity Checking" : ", NO Parity", in ncr_prepare_setting()
3954 (np->rv_stest2 & 0x20) ? ", Differential" : ""); in ncr_prepare_setting()
3959 ncr_name(np), np->sv_scntl3, np->sv_dmode, np->sv_dcntl, in ncr_prepare_setting()
3960 np->sv_ctest3, np->sv_ctest4, np->sv_ctest5); in ncr_prepare_setting()
3964 ncr_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, in ncr_prepare_setting()
3965 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); in ncr_prepare_setting()
3968 if (bootverbose && np->paddr2) in ncr_prepare_setting()
3969 printk (KERN_INFO "%s: on-chip RAM at 0x%lx\n", in ncr_prepare_setting()
3970 ncr_name(np), np->paddr2); in ncr_prepare_setting()
3995 cmd->host_scribble = (char *) np->done_list; in ncr_queue_done_cmd()
3996 np->done_list = cmd; in ncr_queue_done_cmd()
4005 lcmd = (struct scsi_cmnd *) cmd->host_scribble; in ncr_flush_done_cmds()
4006 cmd->scsi_done(cmd); in ncr_flush_done_cmds()
4026 struct tcb *tp = &np->target[cp->target]; in ncr_prepare_nego()
4029 struct scsi_target *starget = tp->starget; in ncr_prepare_nego()
4032 if (!tp->widedone) { in ncr_prepare_nego()
4036 tp->widedone=1; in ncr_prepare_nego()
4040 if (!nego && !tp->period) { in ncr_prepare_nego()
4044 tp->period =0xffff; in ncr_prepare_nego()
4045 dev_info(&starget->dev, "target did not report SYNC.\n"); in ncr_prepare_nego()
4052 tp->maxoffs ? tp->minsync : 0, tp->maxoffs); in ncr_prepare_nego()
4055 msglen += spi_populate_width_msg(msgptr + msglen, tp->usrwide); in ncr_prepare_nego()
4059 cp->nego_status = nego; in ncr_prepare_nego()
4062 tp->nego_cp = cp; in ncr_prepare_nego()
4085 struct scsi_device *sdev = cmd->device; in ncr_queue_command()
4086 struct tcb *tp = &np->target[sdev->id]; in ncr_queue_command()
4087 struct lcb *lp = tp->lp[sdev->lun]; in ncr_queue_command()
4096 /*--------------------------------------------- in ncr_queue_command()
4100 **--------------------------------------------- in ncr_queue_command()
4102 if ((sdev->id == np->myaddr ) || in ncr_queue_command()
4103 (sdev->id >= MAX_TARGET) || in ncr_queue_command()
4104 (sdev->lun >= MAX_LUN )) { in ncr_queue_command()
4108 /*--------------------------------------------- in ncr_queue_command()
4115 **--------------------------------------------- in ncr_queue_command()
4117 if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12) && in ncr_queue_command()
4118 (tp->usrflag & UF_NOSCAN)) { in ncr_queue_command()
4119 tp->usrflag &= ~UF_NOSCAN; in ncr_queue_command()
4124 PRINT_ADDR(cmd, "CMD=%x ", cmd->cmnd[0]); in ncr_queue_command()
4127 /*--------------------------------------------------- in ncr_queue_command()
4135 **---------------------------------------------------- in ncr_queue_command()
4137 if (np->settle_time && scsi_cmd_to_rq(cmd)->timeout >= HZ) { in ncr_queue_command()
4138 u_long tlimit = jiffies + scsi_cmd_to_rq(cmd)->timeout - HZ; in ncr_queue_command()
4139 if (time_after(np->settle_time, tlimit)) in ncr_queue_command()
4140 np->settle_time = tlimit; in ncr_queue_command()
4143 if (np->settle_time || !(cp=ncr_get_ccb (np, cmd))) { in ncr_queue_command()
4147 cp->cmd = cmd; in ncr_queue_command()
4149 /*---------------------------------------------------- in ncr_queue_command()
4153 **---------------------------------------------------- in ncr_queue_command()
4156 idmsg = IDENTIFY(0, sdev->lun); in ncr_queue_command()
4158 if (cp ->tag != NO_TAG || in ncr_queue_command()
4159 (cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC))) in ncr_queue_command()
4162 msgptr = cp->scsi_smsg; in ncr_queue_command()
4166 if (cp->tag != NO_TAG) { in ncr_queue_command()
4167 char order = np->order; in ncr_queue_command()
4173 if (lp && time_after(jiffies, lp->tags_stime)) { in ncr_queue_command()
4174 if (lp->tags_smap) { in ncr_queue_command()
4181 lp->tags_stime = jiffies + 3*HZ; in ncr_queue_command()
4182 lp->tags_smap = lp->tags_umap; in ncr_queue_command()
4189 switch (cmd->cmnd[0]) { in ncr_queue_command()
4205 msgptr[msglen++] = (cp->tag << 1) + 1; in ncr_queue_command()
4208 /*---------------------------------------------------- in ncr_queue_command()
4212 **---------------------------------------------------- in ncr_queue_command()
4215 direction = cmd->sc_data_direction; in ncr_queue_command()
4217 segments = ncr_scatter(np, cp, cp->cmd); in ncr_queue_command()
4224 cp->data_len = 0; in ncr_queue_command()
4228 /*--------------------------------------------------- in ncr_queue_command()
4234 **--------------------------------------------------- in ncr_queue_command()
4237 cp->nego_status = 0; in ncr_queue_command()
4239 if ((!tp->widedone || !tp->period) && !tp->nego_cp && lp) { in ncr_queue_command()
4243 /*---------------------------------------------------- in ncr_queue_command()
4247 **---------------------------------------------------- in ncr_queue_command()
4249 if (!cp->data_len) in ncr_queue_command()
4263 lastp = goalp - 8 - (segments * 16); in ncr_queue_command()
4266 lastp -= (segments - MAX_SCATTERL) * 16; in ncr_queue_command()
4270 cp->phys.header.wgoalp = cpu_to_scr(goalp); in ncr_queue_command()
4271 cp->phys.header.wlastp = cpu_to_scr(lastp); in ncr_queue_command()
4276 lastp = goalp - 8 - (segments * 16); in ncr_queue_command()
4279 lastp -= (segments - MAX_SCATTERL) * 16; in ncr_queue_command()
4292 cp->phys.header.lastp = cpu_to_scr(lastp); in ncr_queue_command()
4293 cp->phys.header.goalp = cpu_to_scr(goalp); in ncr_queue_command()
4296 cp->phys.header.savep = in ncr_queue_command()
4299 cp->phys.header.savep= cpu_to_scr(lastp); in ncr_queue_command()
4305 cp->startp = cp->phys.header.savep; in ncr_queue_command()
4307 /*---------------------------------------------------- in ncr_queue_command()
4311 **---------------------------------------------------- in ncr_queue_command()
4314 ** physical -> virtual backlink in ncr_queue_command()
4321 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, select)); in ncr_queue_command()
4322 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_dsa)); in ncr_queue_command()
4326 cp->phys.select.sel_id = sdev_id(sdev); in ncr_queue_command()
4327 cp->phys.select.sel_scntl3 = tp->wval; in ncr_queue_command()
4328 cp->phys.select.sel_sxfer = tp->sval; in ncr_queue_command()
4332 cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg)); in ncr_queue_command()
4333 cp->phys.smsg.size = cpu_to_scr(msglen); in ncr_queue_command()
4338 memcpy(cp->cdb_buf, cmd->cmnd, min_t(int, cmd->cmd_len, sizeof(cp->cdb_buf))); in ncr_queue_command()
4339 cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, cdb_buf[0])); in ncr_queue_command()
4340 cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len); in ncr_queue_command()
4345 cp->actualquirks = 0; in ncr_queue_command()
4346 cp->host_status = cp->nego_status ? HS_NEGOTIATE : HS_BUSY; in ncr_queue_command()
4347 cp->scsi_status = SAM_STAT_ILLEGAL; in ncr_queue_command()
4348 cp->parity_status = 0; in ncr_queue_command()
4350 cp->xerr_status = XE_OK; in ncr_queue_command()
4352 /*---------------------------------------------------- in ncr_queue_command()
4356 **---------------------------------------------------- in ncr_queue_command()
4360 cp->magic = CCB_MAGIC; in ncr_queue_command()
4366 cp->auto_sense = 0; in ncr_queue_command()
4393 if (lp->held_ccb) in ncr_start_next_ccb()
4396 while (maxn-- && lp->queuedccbs < lp->queuedepth) { in ncr_start_next_ccb()
4397 qp = ncr_list_pop(&lp->wait_ccbq); in ncr_start_next_ccb()
4400 ++lp->queuedccbs; in ncr_start_next_ccb()
4402 list_add_tail(qp, &lp->busy_ccbq); in ncr_start_next_ccb()
4403 lp->jump_ccb[cp->tag == NO_TAG ? 0 : cp->tag] = in ncr_start_next_ccb()
4416 if (!np->squeueput) np->squeueput = 1; in ncr_put_start_queue()
4417 qidx = np->squeueput + 2; in ncr_put_start_queue()
4420 np->scripth->tryloop [qidx] = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_put_start_queue()
4422 np->scripth->tryloop [np->squeueput] = cpu_to_scr(CCB_PHYS (cp, start)); in ncr_put_start_queue()
4424 np->squeueput = qidx; in ncr_put_start_queue()
4425 ++np->queuedccbs; in ncr_put_start_queue()
4426 cp->queued = 1; in ncr_put_start_queue()
4429 printk ("%s: queuepos=%d.\n", ncr_name (np), np->squeueput); in ncr_put_start_queue()
4445 np->settle_time = jiffies + settle_delay * HZ; in ncr_reset_scsi_bus()
4476 ((INW(nc_sbdl) & 0xff) << 9) | /* d7-0 */ in ncr_reset_scsi_bus()
4477 ((INW(nc_sbdl) & 0xff00) << 10) | /* d15-8 */ in ncr_reset_scsi_bus()
4480 if (!(np->features & FE_WIDE)) in ncr_reset_scsi_bus()
4486 printk("%s: %sdp0,d7-0,rst,req,ack,bsy,sel,atn,msg,c/d,i/o = " in ncr_reset_scsi_bus()
4489 (np->features & FE_WIDE) ? "dp1,d15-8," : "", in ncr_reset_scsi_bus()
4508 if (!np->settle_time) { in ncr_start_reset()
4527 if (np->settle_time) { in ncr_reset_bus()
4538 * Wake-up all awaiting commands with DID_RESET. in ncr_reset_bus()
4542 * Wake-up all pending commands with HS_RESET -> DID_RESET. in ncr_reset_bus()
4571 np->release_stage = 1; in ncr_detach()
4572 for (i = 50 ; i && np->release_stage != 2 ; i--) in ncr_detach()
4574 if (np->release_stage != 2) in ncr_detach()
4576 else np->release_stage = 2; in ncr_detach()
4596 OUTB(nc_dmode, np->sv_dmode); in ncr_detach()
4597 OUTB(nc_dcntl, np->sv_dcntl); in ncr_detach()
4598 OUTB(nc_ctest0, np->sv_ctest0); in ncr_detach()
4599 OUTB(nc_ctest3, np->sv_ctest3); in ncr_detach()
4600 OUTB(nc_ctest4, np->sv_ctest4); in ncr_detach()
4601 OUTB(nc_ctest5, np->sv_ctest5); in ncr_detach()
4602 OUTB(nc_gpcntl, np->sv_gpcntl); in ncr_detach()
4603 OUTB(nc_stest2, np->sv_stest2); in ncr_detach()
4605 ncr_selectclock(np, np->sv_scntl3); in ncr_detach()
4611 while ((cp=np->ccb->link_ccb) != NULL) { in ncr_detach()
4612 np->ccb->link_ccb = cp->link_ccb; in ncr_detach()
4613 if (cp->host_status) { in ncr_detach()
4615 ncr_name(np), cp->host_status); in ncr_detach()
4626 tp=&np->target[target]; in ncr_detach()
4628 lp = tp->lp[lun]; in ncr_detach()
4633 if (lp->jump_ccb != &lp->jump_ccb_0) in ncr_detach()
4634 m_free_dma(lp->jump_ccb,256,"JUMP_CCB"); in ncr_detach()
4640 if (np->scripth0) in ncr_detach()
4641 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH"); in ncr_detach()
4642 if (np->script0) in ncr_detach()
4643 m_free_dma(np->script0, sizeof(struct script), "SCRIPT"); in ncr_detach()
4644 if (np->ccb) in ncr_detach()
4645 m_free_dma(np->ccb, sizeof(struct ccb), "CCB"); in ncr_detach()
4671 if (!cp || cp->magic != CCB_MAGIC || !cp->cmd) in ncr_complete()
4680 cp->host_status,cp->scsi_status); in ncr_complete()
4686 cmd = cp->cmd; in ncr_complete()
4687 cp->cmd = NULL; in ncr_complete()
4688 tp = &np->target[cmd->device->id]; in ncr_complete()
4689 lp = tp->lp[cmd->device->lun]; in ncr_complete()
4697 if (cp == tp->nego_cp) in ncr_complete()
4698 tp->nego_cp = NULL; in ncr_complete()
4701 ** If auto-sense performed, change scsi status. in ncr_complete()
4703 if (cp->auto_sense) { in ncr_complete()
4704 cp->scsi_status = cp->auto_sense; in ncr_complete()
4709 ** auto-sense, requeue skipped CCBs to the wait queue. in ncr_complete()
4712 if (lp && lp->held_ccb) { in ncr_complete()
4713 if (cp == lp->held_ccb) { in ncr_complete()
4714 list_splice_init(&lp->skip_ccbq, &lp->wait_ccbq); in ncr_complete()
4715 lp->held_ccb = NULL; in ncr_complete()
4723 if (cp->parity_status > 1) { in ncr_complete()
4724 PRINT_ADDR(cmd, "%d parity error(s).\n",cp->parity_status); in ncr_complete()
4731 if (cp->xerr_status != XE_OK) { in ncr_complete()
4732 switch (cp->xerr_status) { in ncr_complete()
4741 cp->xerr_status); in ncr_complete()
4744 if (cp->host_status==HS_COMPLETE) in ncr_complete()
4745 cp->host_status = HS_FAIL; in ncr_complete()
4752 if (cp->host_status != HS_COMPLETE || in ncr_complete()
4753 cp->scsi_status != SAM_STAT_GOOD) { in ncr_complete()
4755 "scsi_status=%x\n", cmd->cmnd[0], in ncr_complete()
4756 cp->host_status, cp->scsi_status); in ncr_complete()
4763 cmd->result = 0; in ncr_complete()
4764 if ( (cp->host_status == HS_COMPLETE) in ncr_complete()
4765 && (cp->scsi_status == SAM_STAT_GOOD || in ncr_complete()
4766 cp->scsi_status == SAM_STAT_CONDITION_MET)) { in ncr_complete()
4770 * `Pre-Fetch' or `Search data' success. in ncr_complete()
4772 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4779 /* if (cp->phys.header.lastp != cp->phys.header.goalp) */ in ncr_complete()
4785 ncr_alloc_lcb (np, cmd->device->id, cmd->device->lun); in ncr_complete()
4787 tp->bytes += cp->data_len; in ncr_complete()
4788 tp->transfers ++; in ncr_complete()
4794 if (lp && lp->usetags && lp->numtags < lp->maxtags) { in ncr_complete()
4795 ++lp->num_good; in ncr_complete()
4796 if (lp->num_good >= 1000) { in ncr_complete()
4797 lp->num_good = 0; in ncr_complete()
4798 ++lp->numtags; in ncr_complete()
4799 ncr_setup_tags (np, cmd->device); in ncr_complete()
4802 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4803 && (cp->scsi_status == SAM_STAT_CHECK_CONDITION)) { in ncr_complete()
4812 memcpy(cmd->sense_buffer, cp->sense_buf, in ncr_complete()
4814 sizeof(cp->sense_buf))); in ncr_complete()
4817 u_char *p = cmd->sense_buffer; in ncr_complete()
4823 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4824 && (cp->scsi_status == SAM_STAT_RESERVATION_CONFLICT)) { in ncr_complete()
4830 } else if ((cp->host_status == HS_COMPLETE) in ncr_complete()
4831 && (cp->scsi_status == SAM_STAT_BUSY || in ncr_complete()
4832 cp->scsi_status == SAM_STAT_TASK_SET_FULL)) { in ncr_complete()
4837 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4839 } else if ((cp->host_status == HS_SEL_TIMEOUT) in ncr_complete()
4840 || (cp->host_status == HS_TIMEOUT)) { in ncr_complete()
4845 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4848 } else if (cp->host_status == HS_RESET) { in ncr_complete()
4853 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4856 } else if (cp->host_status == HS_ABORTED) { in ncr_complete()
4861 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4870 cp->host_status, cp->scsi_status, cp); in ncr_complete()
4872 set_status_byte(cmd, cp->scsi_status); in ncr_complete()
4880 if (tp->usrflag & UF_TRACE) { in ncr_complete()
4884 p = (u_char*) &cmd->cmnd[0]; in ncr_complete()
4885 for (i=0; i<cmd->cmd_len; i++) printk (" %x", *p++); in ncr_complete()
4887 if (cp->host_status==HS_COMPLETE) { in ncr_complete()
4888 switch (cp->scsi_status) { in ncr_complete()
4894 p = (u_char*) &cmd->sense_buffer; in ncr_complete()
4899 printk (" STAT: %x\n", cp->scsi_status); in ncr_complete()
4902 } else printk (" HOSTERROR: %x", cp->host_status); in ncr_complete()
4914 if (lp && lp->queuedccbs < lp->queuedepth && in ncr_complete()
4915 !list_empty(&lp->wait_ccbq)) in ncr_complete()
4921 if (np->waiting_list) in ncr_complete()
4945 struct tcb *tp = &np->target[cp->target]; in ncr_ccb_skipped()
4946 struct lcb *lp = tp->lp[cp->lun]; in ncr_ccb_skipped()
4948 if (lp && cp != np->ccb) { in ncr_ccb_skipped()
4949 cp->host_status &= ~HS_SKIPMASK; in ncr_ccb_skipped()
4950 cp->start.schedule.l_paddr = in ncr_ccb_skipped()
4952 list_move_tail(&cp->link_ccbq, &lp->skip_ccbq); in ncr_ccb_skipped()
4953 if (cp->queued) { in ncr_ccb_skipped()
4954 --lp->queuedccbs; in ncr_ccb_skipped()
4957 if (cp->queued) { in ncr_ccb_skipped()
4958 --np->queuedccbs; in ncr_ccb_skipped()
4959 cp->queued = 0; in ncr_ccb_skipped()
4973 i = np->ccb_done_ic; in ncr_wakeup_done()
4979 cp = np->ccb_done[j]; in ncr_wakeup_done()
4983 np->ccb_done[j] = (struct ccb *)CCB_DONE_EMPTY; in ncr_wakeup_done()
4984 np->scripth->done_queue[5*j + 4] = in ncr_wakeup_done()
4987 np->scripth->done_queue[5*i + 4] = in ncr_wakeup_done()
4990 if (cp->host_status & HS_DONEMASK) in ncr_wakeup_done()
4992 else if (cp->host_status & HS_SKIPMASK) in ncr_wakeup_done()
4997 np->ccb_done_ic = i; in ncr_wakeup_done()
4999 cp = np->ccb; in ncr_wakeup_done()
5001 if (cp->host_status & HS_DONEMASK) in ncr_wakeup_done()
5003 else if (cp->host_status & HS_SKIPMASK) in ncr_wakeup_done()
5005 cp = cp->link_ccb; in ncr_wakeup_done()
5015 struct ccb *cp = np->ccb; in ncr_wakeup()
5018 if (cp->host_status != HS_IDLE) { in ncr_wakeup()
5019 cp->host_status = code; in ncr_wakeup()
5022 cp = cp->link_ccb; in ncr_wakeup()
5040 if (np->features & FE_EHP) in ncr_chip_reset()
5042 if (np->features & FE_MUX) in ncr_chip_reset()
5082 np->queuedepth = MAX_START - 1; /* 1 entry needed as end marker */ in ncr_init()
5084 np->scripth0->tryloop[i] = in ncr_init()
5090 np->squeueput = 0; in ncr_init()
5091 np->script0->startpos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np, tryloop)); in ncr_init()
5098 np->ccb_done[i] = (struct ccb *)CCB_DONE_EMPTY; in ncr_init()
5099 np->scripth0->done_queue[5*i + 4] = in ncr_init()
5107 np->script0->done_pos[0] = cpu_to_scr(NCB_SCRIPTH_PHYS (np,done_queue)); in ncr_init()
5108 np->ccb_done_ic = MAX_DONE-1; in ncr_init()
5109 np->scripth0->done_queue[5*(MAX_DONE-1) + 4] = in ncr_init()
5127 OUTB (nc_scntl0, np->rv_scntl0 | 0xc0); in ncr_init()
5128 /* full arb., ena parity, par->ATN */ in ncr_init()
5131 ncr_selectclock(np, np->rv_scntl3); /* Select SCSI clock */ in ncr_init()
5133 OUTB (nc_scid , RRE|np->myaddr); /* Adapter SCSI address */ in ncr_init()
5134 OUTW (nc_respid, 1ul<<np->myaddr); /* Id to respond to */ in ncr_init()
5136 OUTB (nc_dmode , np->rv_dmode); /* Burst length, dma mode */ in ncr_init()
5137 OUTB (nc_ctest5, np->rv_ctest5); /* Large fifo + large burst */ in ncr_init()
5139 OUTB (nc_dcntl , NOCOM|np->rv_dcntl); /* Protect SFBR */ in ncr_init()
5140 OUTB (nc_ctest0, np->rv_ctest0); /* 720: CDIS and EHP */ in ncr_init()
5141 OUTB (nc_ctest3, np->rv_ctest3); /* Write and invalidate */ in ncr_init()
5142 OUTB (nc_ctest4, np->rv_ctest4); /* Master parity checking */ in ncr_init()
5144 OUTB (nc_stest2, EXT|np->rv_stest2); /* Extended Sreq/Sack filtering */ in ncr_init()
5152 np->disc = 0; in ncr_init()
5158 if (np->features & FE_LED0) { in ncr_init()
5173 ** Prepare sync negotiation according to actual SCSI bus mode. in ncr_init()
5177 struct tcb *tp = &np->target[i]; in ncr_init()
5179 tp->sval = 0; in ncr_init()
5180 tp->wval = np->rv_scntl3; in ncr_init()
5182 if (tp->usrsync != 255) { in ncr_init()
5183 if (tp->usrsync <= np->maxsync) { in ncr_init()
5184 if (tp->usrsync < np->minsync) { in ncr_init()
5185 tp->usrsync = np->minsync; in ncr_init()
5189 tp->usrsync = 255; in ncr_init()
5192 if (tp->usrwide > np->maxwide) in ncr_init()
5193 tp->usrwide = np->maxwide; in ncr_init()
5200 if (np->paddr2) { in ncr_init()
5204 OUTL (nc_scratcha, vtobus(np->script0)); in ncr_init()
5225 u_long minsync = tp->usrsync; in ncr_negotiate()
5231 if (np->scsi_mode && np->scsi_mode == SMODE_SE) { in ncr_negotiate()
5239 if (minsync < np->minsync) in ncr_negotiate()
5240 minsync = np->minsync; in ncr_negotiate()
5246 if (minsync > np->maxsync) in ncr_negotiate()
5249 if (tp->maxoffs > np->maxoffs) in ncr_negotiate()
5250 tp->maxoffs = np->maxoffs; in ncr_negotiate()
5252 tp->minsync = minsync; in ncr_negotiate()
5253 tp->maxoffs = (minsync<255 ? tp->maxoffs : 0); in ncr_negotiate()
5256 ** period=0: has to negotiate sync transfer in ncr_negotiate()
5259 tp->period=0; in ncr_negotiate()
5264 tp->widedone=0; in ncr_negotiate()
5269 ** Get clock factor and sync divisor for a given
5279 u_long clk = np->clock_khz; /* SCSI clock frequency in kHz */ in ncr_getsync()
5280 int div = np->clock_divn; /* Number of divisors supported */ in ncr_getsync()
5281 u_long fak; /* Sync factor in sxfer */ in ncr_getsync()
5286 ** Compute the synchronous period in tenths of nano-seconds in ncr_getsync()
5298 while (--div > 0) in ncr_getsync()
5305 fak = (kpc - 1) / div_10M[div] + 1; in ncr_getsync()
5310 ** Compute and return sync parameters for the ncr in ncr_getsync()
5312 *fakp = fak - 4; in ncr_getsync()
5319 ** Set actual values, sync status and patch all ccbs of
5320 ** a target according to new sync/wide agreement.
5328 struct tcb *tp = &np->target[target]; in ncr_set_sync_wide_status()
5333 OUTB (nc_sxfer, tp->sval); in ncr_set_sync_wide_status()
5334 np->sync_st = tp->sval; in ncr_set_sync_wide_status()
5335 OUTB (nc_scntl3, tp->wval); in ncr_set_sync_wide_status()
5336 np->wide_st = tp->wval; in ncr_set_sync_wide_status()
5341 for (cp = np->ccb; cp; cp = cp->link_ccb) { in ncr_set_sync_wide_status()
5342 if (!cp->cmd) continue; in ncr_set_sync_wide_status()
5343 if (scmd_id(cp->cmd) != target) continue; in ncr_set_sync_wide_status()
5344 cp->phys.select.sel_scntl3 = tp->wval; in ncr_set_sync_wide_status()
5345 cp->phys.select.sel_sxfer = tp->sval; in ncr_set_sync_wide_status()
5351 ** Switch sync mode for current job and it's target
5358 struct scsi_cmnd *cmd = cp->cmd; in ncr_setsync()
5365 tp = &np->target[target]; in ncr_setsync()
5368 scntl3 = np->rv_scntl3; in ncr_setsync()
5369 scntl3 = (scntl3 & 0xf0) | (tp->wval & EWS) | (np->rv_scntl3 & 0x07); in ncr_setsync()
5372 ** Deduce the value of controller sync period from scntl3. in ncr_setsync()
5373 ** period is in tenths of nano-seconds. in ncr_setsync()
5378 tp->period = (((sxfer>>5)+4)*div_10M[idiv-1])/np->clock_khz; in ncr_setsync()
5380 tp->period = 0xffff; in ncr_setsync()
5382 /* Stop there if sync parameters are unchanged */ in ncr_setsync()
5383 if (tp->sval == sxfer && tp->wval == scntl3) in ncr_setsync()
5385 tp->sval = sxfer; in ncr_setsync()
5386 tp->wval = scntl3; in ncr_setsync()
5390 if (tp->period <= 2000) in ncr_setsync()
5394 spi_display_xfer_agreement(tp->starget); in ncr_setsync()
5415 struct scsi_cmnd *cmd = cp->cmd; in ncr_setwide()
5423 tp = &np->target[target]; in ncr_setwide()
5424 tp->widedone = wide+1; in ncr_setwide()
5425 scntl3 = (tp->wval & (~EWS)) | (wide ? EWS : 0); in ncr_setwide()
5427 sxfer = ack ? 0 : tp->sval; in ncr_setwide()
5430 ** Stop there if sync/wide parameters are unchanged in ncr_setwide()
5432 if (tp->sval == sxfer && tp->wval == scntl3) return; in ncr_setwide()
5433 tp->sval = sxfer; in ncr_setwide()
5434 tp->wval = scntl3; in ncr_setwide()
5437 ** Bells and whistles ;-) in ncr_setwide()
5440 dev_info(&cmd->device->sdev_target->dev, "WIDE SCSI %sabled.\n", in ncr_setwide()
5460 unsigned char tn = sdev->id, ln = sdev->lun; in ncr_setup_tags()
5461 struct tcb *tp = &np->target[tn]; in ncr_setup_tags()
5462 struct lcb *lp = tp->lp[ln]; in ncr_setup_tags()
5474 if (!lp->scdev_depth) in ncr_setup_tags()
5482 maxdepth = lp->scdev_depth; in ncr_setup_tags()
5483 if (maxdepth > lp->maxnxs) maxdepth = lp->maxnxs; in ncr_setup_tags()
5484 if (lp->maxtags > maxdepth) lp->maxtags = maxdepth; in ncr_setup_tags()
5485 if (lp->numtags > maxdepth) lp->numtags = maxdepth; in ncr_setup_tags()
5492 if (sdev->tagged_supported && lp->numtags > 1) { in ncr_setup_tags()
5493 reqtags = lp->numtags; in ncr_setup_tags()
5501 lp->numtags = reqtags; in ncr_setup_tags()
5502 if (lp->numtags > lp->maxtags) in ncr_setup_tags()
5503 lp->maxtags = lp->numtags; in ncr_setup_tags()
5509 if (reqtags > 1 && lp->usetags) { /* Stay in tagged mode */ in ncr_setup_tags()
5510 if (lp->queuedepth == reqtags) /* Already announced */ in ncr_setup_tags()
5512 lp->queuedepth = reqtags; in ncr_setup_tags()
5514 else if (reqtags <= 1 && !lp->usetags) { /* Stay in untagged mode */ in ncr_setup_tags()
5515 lp->queuedepth = reqtags; in ncr_setup_tags()
5519 if (lp->busyccbs) /* If not yet safe, return */ in ncr_setup_tags()
5521 lp->queuedepth = reqtags; in ncr_setup_tags()
5522 lp->usetags = reqtags > 1 ? 1 : 0; in ncr_setup_tags()
5526 ** Patch the lun mini-script, according to tag mode. in ncr_setup_tags()
5528 lp->jump_tag.l_paddr = lp->usetags? in ncr_setup_tags()
5536 if (lp->usetags) { in ncr_setup_tags()
5537 dev_info(&sdev->sdev_gendev, in ncr_setup_tags()
5541 dev_info(&sdev->sdev_gendev, in ncr_setup_tags()
5558 **----------------------------------------------------------
5571 if (np->release_stage) { in ncr_timeout()
5572 if (np->release_stage == 1) np->release_stage = 2; in ncr_timeout()
5576 np->timer.expires = jiffies + SCSI_NCR_TIMER_INTERVAL; in ncr_timeout()
5577 add_timer(&np->timer); in ncr_timeout()
5583 if (np->settle_time) { in ncr_timeout()
5584 if (np->settle_time <= thistime) { in ncr_timeout()
5587 np->settle_time = 0; in ncr_timeout()
5588 np->disc = 1; in ncr_timeout()
5599 if (np->lasttime + 4*HZ < thistime) { in ncr_timeout()
5603 np->lasttime = thistime; in ncr_timeout()
5623 ** "ncr0 targ 0?: ERROR (ds:si) (so-si-sd) (sxfer/scntl3) @ name (dsp:dbc)."
5660 if (dsp > np->p_script && dsp <= np->p_script + sizeof(struct script)) { in ncr_log_hard_error()
5661 script_ofs = dsp - np->p_script; in ncr_log_hard_error()
5663 script_base = (u_char *) np->script0; in ncr_log_hard_error()
5666 else if (np->p_scripth < dsp && in ncr_log_hard_error()
5667 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_log_hard_error()
5668 script_ofs = dsp - np->p_scripth; in ncr_log_hard_error()
5670 script_base = (u_char *) np->scripth0; in ncr_log_hard_error()
5679 printk ("%s:%d: ERROR (%x:%x) (%x-%x-%x) (%x/%x) @ (%s %x:%08x).\n", in ncr_log_hard_error()
5799 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 2. in ncr_exception()
5820 ** we ignore them. In any case we do enough fix-up in ncr_exception()
5834 ** DEL 397 - 53C875 Rev 3 - Part Number 609-0392410 - ITEM 1. in ncr_exception()
5855 if (time_after(jiffies, np->regtime)) { in ncr_exception()
5856 np->regtime = jiffies + 10*HZ; in ncr_exception()
5857 for (i = 0; i<sizeof(np->regdump); i++) in ncr_exception()
5858 ((char*)&np->regdump)[i] = INB_OFF(i); in ncr_exception()
5859 np->regdump.nc_dstat = dstat; in ncr_exception()
5860 np->regdump.nc_sist = sist; in ncr_exception()
5903 ** Although a STO-Interrupt is pending,
5909 **----------------------------------------------------------
5923 cp = np->ccb; in ncr_int_sto()
5925 cp = cp->link_ccb; in ncr_int_sto()
5928 cp-> host_status = HS_SEL_TIMEOUT; in ncr_int_sto()
5946 ** spi2-r12 11.2.3 says a transceiver mode change must
5954 **----------------------------------------------------------
5961 if (scsi_mode != np->scsi_mode) { in ncr_int_sbmc()
5963 ncr_name(np), np->scsi_mode, scsi_mode); in ncr_int_sbmc()
5965 np->scsi_mode = scsi_mode; in ncr_int_sbmc()
5972 np->settle_time = jiffies + HZ; in ncr_int_sbmc()
5986 **----------------------------------------------------------
5994 int phase = -1; in ncr_int_par()
5995 int msg = -1; in ncr_int_par()
6046 np->msgout[0] = msg; in ncr_int_par()
6066 **----------------------------------------------------------
6100 ctest5 = (np->rv_ctest5 & DFS) ? INB (nc_ctest5) : 0; in ncr_int_ma()
6102 delta=(((ctest5 << 8) | (INB (nc_dfifo) & 0xff)) - rest) & 0x3ff; in ncr_int_ma()
6104 delta=(INB (nc_dfifo) - rest) & 0x7f; in ncr_int_ma()
6108 ** the target -> add the amount to the rest in ncr_int_ma()
6145 cp = np->header.cp; in ncr_int_ma()
6149 cp = np->ccb; in ncr_int_ma()
6151 cp = cp->link_ccb; in ncr_int_ma()
6160 if (dsp > np->p_script && in ncr_int_ma()
6161 dsp <= np->p_script + sizeof(struct script)) { in ncr_int_ma()
6162 vdsp = (u32 *)((char*)np->script0 + (dsp-np->p_script-8)); in ncr_int_ma()
6165 else if (dsp > np->p_scripth && in ncr_int_ma()
6166 dsp <= np->p_scripth + sizeof(struct scripth)) { in ncr_int_ma()
6167 vdsp = (u32 *)((char*)np->scripth0 + (dsp-np->p_scripth-8)); in ncr_int_ma()
6172 vdsp = &cp->patch[0]; in ncr_int_ma()
6176 vdsp = &cp->patch[4]; in ncr_int_ma()
6187 cp, np->header.cp, in ncr_int_ma()
6194 ** block. This should not happen since we donnot use multi-byte in ncr_int_ma()
6201 ncr_name (np), (u_long) np->header.cp); in ncr_int_ma()
6212 tblp = (u32 *) ((char*) &cp->phys + oadr); in ncr_int_ma()
6233 PRINT_ADDR(cp->cmd, "internal error: cmd=%02x != %02x=(vdsp[0] " in ncr_int_ma()
6240 ** cp != np->header.cp means that the header of the CCB in ncr_int_ma()
6245 if (cp != np->header.cp) { in ncr_int_ma()
6248 ncr_name (np), (u_long) cp, (u_long) np->header.cp); in ncr_int_ma()
6256 PRINT_ADDR(cp->cmd, "phase change %x-%x %d@%08x resid=%d.\n", in ncr_int_ma()
6267 newcmd = cp->patch; in ncr_int_ma()
6269 if (newtmp == scr_to_cpu(cp->phys.header.savep)) { in ncr_int_ma()
6270 newcmd = &cp->patch[4]; in ncr_int_ma()
6279 newcmd[1] = cpu_to_scr(oadr + olen - rest); in ncr_int_ma()
6284 PRINT_ADDR(cp->cmd, "newcmd[%d] %x %x %x %x.\n", in ncr_int_ma()
6285 (int) (newcmd - cp->patch), in ncr_int_ma()
6307 ** COMMAND --> MSG IN SCSI parity error detected by target. in ncr_int_ma()
6308 ** COMMAND --> STATUS Bad command or refused by target. in ncr_int_ma()
6309 ** MSG OUT --> MSG IN Message rejected by target. in ncr_int_ma()
6310 ** MSG OUT --> COMMAND Bogus target that discards extended in ncr_int_ma()
6327 dsp -= 8; in ncr_int_ma()
6340 np->scripth->nxtdsp_go_on[0] = cpu_to_scr(dsp + 8); in ncr_int_ma()
6342 cp->host_status = HS_BUSY; in ncr_int_ma()
6369 struct scsi_cmnd *cmd = cp->cmd; in ncr_sir_to_redo()
6370 struct tcb *tp = &np->target[cmd->device->id]; in ncr_sir_to_redo()
6371 struct lcb *lp = tp->lp[cmd->device->lun]; in ncr_sir_to_redo()
6386 qp = lp->busy_ccbq.prev; in ncr_sir_to_redo()
6387 while (qp != &lp->busy_ccbq) { in ncr_sir_to_redo()
6389 qp = qp->prev; in ncr_sir_to_redo()
6393 cp2->start.schedule.l_paddr = in ncr_sir_to_redo()
6396 lp->held_ccb = cp; /* Requeue when this one completes */ in ncr_sir_to_redo()
6397 disc_cnt = lp->queuedccbs - busy_cnt; in ncr_sir_to_redo()
6413 if (disc_cnt < lp->numtags) { in ncr_sir_to_redo()
6414 lp->numtags = disc_cnt > 2 ? disc_cnt : 2; in ncr_sir_to_redo()
6415 lp->num_good = 0; in ncr_sir_to_redo()
6416 ncr_setup_tags (np, cmd->device); in ncr_sir_to_redo()
6424 cp->phys.header.savep = cp->startp; in ncr_sir_to_redo()
6425 cp->host_status = HS_BUSY; in ncr_sir_to_redo()
6426 cp->scsi_status = SAM_STAT_ILLEGAL; in ncr_sir_to_redo()
6438 if (cp->auto_sense) in ncr_sir_to_redo()
6448 cp->scsi_smsg2[0] = IDENTIFY(0, cmd->device->lun); in ncr_sir_to_redo()
6449 cp->phys.smsg.addr = cpu_to_scr(CCB_PHYS (cp, scsi_smsg2)); in ncr_sir_to_redo()
6450 cp->phys.smsg.size = cpu_to_scr(1); in ncr_sir_to_redo()
6455 cp->phys.cmd.addr = cpu_to_scr(CCB_PHYS (cp, sensecmd)); in ncr_sir_to_redo()
6456 cp->phys.cmd.size = cpu_to_scr(6); in ncr_sir_to_redo()
6461 cp->sensecmd[0] = 0x03; in ncr_sir_to_redo()
6462 cp->sensecmd[1] = (cmd->device->lun & 0x7) << 5; in ncr_sir_to_redo()
6463 cp->sensecmd[4] = sizeof(cp->sense_buf); in ncr_sir_to_redo()
6468 memset(cp->sense_buf, 0, sizeof(cp->sense_buf)); in ncr_sir_to_redo()
6469 cp->phys.sense.addr = cpu_to_scr(CCB_PHYS(cp,sense_buf[0])); in ncr_sir_to_redo()
6470 cp->phys.sense.size = cpu_to_scr(sizeof(cp->sense_buf)); in ncr_sir_to_redo()
6477 cp->phys.header.savep = startp; in ncr_sir_to_redo()
6478 cp->phys.header.goalp = startp + 24; in ncr_sir_to_redo()
6479 cp->phys.header.lastp = startp; in ncr_sir_to_redo()
6480 cp->phys.header.wgoalp = startp + 24; in ncr_sir_to_redo()
6481 cp->phys.header.wlastp = startp; in ncr_sir_to_redo()
6483 cp->host_status = HS_BUSY; in ncr_sir_to_redo()
6484 cp->scsi_status = SAM_STAT_ILLEGAL; in ncr_sir_to_redo()
6485 cp->auto_sense = s_status; in ncr_sir_to_redo()
6487 cp->start.schedule.l_paddr = in ncr_sir_to_redo()
6493 if (cmd->device->select_no_atn) in ncr_sir_to_redo()
6494 cp->start.schedule.l_paddr = in ncr_sir_to_redo()
6526 struct tcb *tp = &np->target[target]; in ncr_int_sir()
6527 struct scsi_target *starget = tp->starget; in ncr_int_sir()
6551 if (tp->lp[0]) { in ncr_int_sir()
6552 OUTL_DSP (scr_to_cpu(tp->lp[0]->jump_ccb[0])); in ncr_int_sir()
6570 cp = np->header.cp; in ncr_int_sir()
6579 cp = np->ccb; in ncr_int_sir()
6581 cp = cp->link_ccb; in ncr_int_sir()
6584 BUG_ON(cp != np->header.cp); in ncr_int_sir()
6586 if (!cp || cp != np->header.cp) in ncr_int_sir()
6591 /*----------------------------------------------------------------------------- in ncr_int_sir()
6597 ** We try to negotiate sync and wide transfer only after in ncr_int_sir()
6633 ** -> target doesn't msgin NEG FAIL noop defa. - dispatch in ncr_int_sir()
6634 ** -> target rejected our msg NEG FAIL reject defa. - dispatch in ncr_int_sir()
6635 ** -> target answered (ok) NEG SYNC sdtr set - clrack in ncr_int_sir()
6636 ** -> target answered (!ok) NEG SYNC sdtr defa. REJ--->msg_bad in ncr_int_sir()
6637 ** -> target answered (ok) NEG WIDE wdtr set - clrack in ncr_int_sir()
6638 ** -> target answered (!ok) NEG WIDE wdtr defa. REJ--->msg_bad in ncr_int_sir()
6639 ** -> any other msgin NEG FAIL noop defa. - dispatch in ncr_int_sir()
6642 ** -> incoming message --- SYNC sdtr set SDTR - in ncr_int_sir()
6643 ** -> incoming message --- WIDE wdtr set WDTR - in ncr_int_sir()
6645 ** -> target doesn't msgout --- PROTO ? defa. - dispatch in ncr_int_sir()
6647 **----------------------------------------------------------------------------- in ncr_int_sir()
6651 /*------------------------------------------------------- in ncr_int_sir()
6659 **------------------------------------------------------- in ncr_int_sir()
6666 /*------------------------------------------------------- in ncr_int_sir()
6671 **------------------------------------------------------- in ncr_int_sir()
6675 PRINT_ADDR(cp->cmd, "negotiation failed sir=%x " in ncr_int_sir()
6676 "status=%x.\n", num, cp->nego_status); in ncr_int_sir()
6683 switch (cp->nego_status) { in ncr_int_sir()
6697 np->msgin [0] = NOP; in ncr_int_sir()
6698 np->msgout[0] = NOP; in ncr_int_sir()
6699 cp->nego_status = 0; in ncr_int_sir()
6704 ncr_print_msg(cp, "sync msgin", np->msgin); in ncr_int_sir()
6708 per = np->msgin[3]; in ncr_int_sir()
6709 ofs = np->msgin[4]; in ncr_int_sir()
6724 if (per < np->minsync) in ncr_int_sir()
6725 {chg = 1; per = np->minsync;} in ncr_int_sir()
6726 if (per < tp->minsync) in ncr_int_sir()
6727 {chg = 1; per = tp->minsync;} in ncr_int_sir()
6728 if (ofs > tp->maxoffs) in ncr_int_sir()
6729 {chg = 1; ofs = tp->maxoffs;} in ncr_int_sir()
6747 tp->minsync = 0; in ncr_int_sir()
6751 PRINT_ADDR(cp->cmd, "sync: per=%d scntl3=0x%x ofs=%d " in ncr_int_sir()
6757 switch (cp->nego_status) { in ncr_int_sir()
6792 spi_populate_sync_msg(np->msgout, per, ofs); in ncr_int_sir()
6793 cp->nego_status = NS_SYNC; in ncr_int_sir()
6796 ncr_print_msg(cp, "sync msgout", np->msgout); in ncr_int_sir()
6803 np->msgin [0] = NOP; in ncr_int_sir()
6812 ncr_print_msg(cp, "wide msgin", np->msgin); in ncr_int_sir()
6820 wide = np->msgin[3]; in ncr_int_sir()
6834 if (wide > tp->usrwide) in ncr_int_sir()
6835 {chg = 1; wide = tp->usrwide;} in ncr_int_sir()
6838 PRINT_ADDR(cp->cmd, "wide: wide=%d chg=%d.\n", wide, in ncr_int_sir()
6844 switch (cp->nego_status) { in ncr_int_sir()
6878 spi_populate_width_msg(np->msgout, wide); in ncr_int_sir()
6880 np->msgin [0] = NOP; in ncr_int_sir()
6882 cp->nego_status = NS_WIDE; in ncr_int_sir()
6885 ncr_print_msg(cp, "wide msgout", np->msgin); in ncr_int_sir()
6889 /*-------------------------------------------------------------------- in ncr_int_sir()
6893 **-------------------------------------------------------------------- in ncr_int_sir()
6897 /*----------------------------------------------- in ncr_int_sir()
6901 **----------------------------------------------- in ncr_int_sir()
6904 PRINT_ADDR(cp->cmd, "MESSAGE_REJECT received (%x:%x).\n", in ncr_int_sir()
6905 (unsigned)scr_to_cpu(np->lastmsg), np->msgout[0]); in ncr_int_sir()
6909 /*----------------------------------------------- in ncr_int_sir()
6913 **----------------------------------------------- in ncr_int_sir()
6916 ncr_print_msg(cp, "MESSAGE_REJECT sent for", np->msgin); in ncr_int_sir()
6919 /*-------------------------------------------------------------------- in ncr_int_sir()
6923 **-------------------------------------------------------------------- in ncr_int_sir()
6927 /*----------------------------------------------- in ncr_int_sir()
6932 **----------------------------------------------- in ncr_int_sir()
6935 PRINT_ADDR(cp->cmd, "IGNORE_WIDE_RESIDUE received, but not yet " in ncr_int_sir()
6940 /*----------------------------------------------- in ncr_int_sir()
6945 **----------------------------------------------- in ncr_int_sir()
6948 PRINT_ADDR(cp->cmd, "DISCONNECT received, but datapointer " in ncr_int_sir()
6951 (unsigned) scr_to_cpu(np->header.savep), in ncr_int_sir()
6952 (unsigned) scr_to_cpu(np->header.goalp)); in ncr_int_sir()
6972 u_char tn = cmd->device->id; in ncr_get_ccb()
6973 u_char ln = cmd->device->lun; in ncr_get_ccb()
6974 struct tcb *tp = &np->target[tn]; in ncr_get_ccb()
6975 struct lcb *lp = tp->lp[ln]; in ncr_get_ccb()
6987 if (lp->usetags && lp->busyccbs >= lp->maxnxs) in ncr_get_ccb()
6993 if (list_empty(&lp->free_ccbq)) in ncr_get_ccb()
6999 qp = ncr_list_pop(&lp->free_ccbq); in ncr_get_ccb()
7002 if (cp->magic) { in ncr_get_ccb()
7007 list_add_tail(qp, &lp->wait_ccbq); in ncr_get_ccb()
7008 ++lp->busyccbs; in ncr_get_ccb()
7017 if (lp->usetags) in ncr_get_ccb()
7018 tag = lp->cb_tags[lp->ia_tag]; in ncr_get_ccb()
7020 else if (lp->actccbs > 0) in ncr_get_ccb()
7028 cp = np->ccb; in ncr_get_ccb()
7034 while (cp->magic) { in ncr_get_ccb()
7041 if (cp->magic) in ncr_get_ccb()
7044 cp->magic = 1; in ncr_get_ccb()
7051 ++lp->ia_tag; in ncr_get_ccb()
7052 if (lp->ia_tag == MAX_TAGS) in ncr_get_ccb()
7053 lp->ia_tag = 0; in ncr_get_ccb()
7054 lp->tags_umap |= (((tagmap_t) 1) << tag); in ncr_get_ccb()
7061 cp->tag = tag; in ncr_get_ccb()
7062 cp->target = tn; in ncr_get_ccb()
7063 cp->lun = ln; in ncr_get_ccb()
7083 struct tcb *tp = &np->target[cp->target]; in ncr_free_ccb()
7084 struct lcb *lp = tp->lp[cp->lun]; in ncr_free_ccb()
7087 PRINT_ADDR(cp->cmd, "ccb @%p freeing tag %d.\n", cp, cp->tag); in ncr_free_ccb()
7096 if (cp->tag != NO_TAG) { in ncr_free_ccb()
7097 lp->cb_tags[lp->if_tag++] = cp->tag; in ncr_free_ccb()
7098 if (lp->if_tag == MAX_TAGS) in ncr_free_ccb()
7099 lp->if_tag = 0; in ncr_free_ccb()
7100 lp->tags_umap &= ~(((tagmap_t) 1) << cp->tag); in ncr_free_ccb()
7101 lp->tags_smap &= lp->tags_umap; in ncr_free_ccb()
7102 lp->jump_ccb[cp->tag] = in ncr_free_ccb()
7105 lp->jump_ccb[0] = in ncr_free_ccb()
7115 if (cp != np->ccb) in ncr_free_ccb()
7116 list_move(&cp->link_ccbq, &lp->free_ccbq); in ncr_free_ccb()
7117 --lp->busyccbs; in ncr_free_ccb()
7118 if (cp->queued) { in ncr_free_ccb()
7119 --lp->queuedccbs; in ncr_free_ccb()
7122 cp -> host_status = HS_IDLE; in ncr_free_ccb()
7123 cp -> magic = 0; in ncr_free_ccb()
7124 if (cp->queued) { in ncr_free_ccb()
7125 --np->queuedccbs; in ncr_free_ccb()
7126 cp->queued = 0; in ncr_free_ccb()
7130 if (cp == np->ccb) in ncr_free_ccb()
7136 #define ncr_reg_bus_addr(r) (np->paddr + offsetof (struct ncr_reg, r))
7138 /*------------------------------------------------------------------------
7140 **------------------------------------------------------------------------
7141 **------------------------------------------------------------------------
7145 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_init_ccb()
7150 cp->p_ccb = vtobus(cp); in ncr_init_ccb()
7151 cp->phys.header.cp = cp; in ncr_init_ccb()
7156 INIT_LIST_HEAD(&cp->link_ccbq); in ncr_init_ccb()
7164 cp->start.setup_dsa[0] = cpu_to_scr(copy_4); in ncr_init_ccb()
7165 cp->start.setup_dsa[1] = cpu_to_scr(CCB_PHYS(cp, start.p_phys)); in ncr_init_ccb()
7166 cp->start.setup_dsa[2] = cpu_to_scr(ncr_reg_bus_addr(nc_dsa)); in ncr_init_ccb()
7167 cp->start.schedule.l_cmd = cpu_to_scr(SCR_JUMP); in ncr_init_ccb()
7168 cp->start.p_phys = cpu_to_scr(CCB_PHYS(cp, phys)); in ncr_init_ccb()
7170 memcpy(&cp->restart, &cp->start, sizeof(cp->restart)); in ncr_init_ccb()
7172 cp->start.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, idle)); in ncr_init_ccb()
7173 cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPTH_PHYS (np, abort)); in ncr_init_ccb()
7177 /*------------------------------------------------------------------------
7179 **------------------------------------------------------------------------
7180 **------------------------------------------------------------------------
7184 struct tcb *tp = &np->target[tn]; in ncr_alloc_ccb()
7185 struct lcb *lp = tp->lp[ln]; in ncr_alloc_ccb()
7198 lp->actccbs++; in ncr_alloc_ccb()
7199 np->actccbs++; in ncr_alloc_ccb()
7207 cp->link_ccb = np->ccb->link_ccb; in ncr_alloc_ccb()
7208 np->ccb->link_ccb = cp; in ncr_alloc_ccb()
7210 list_add(&cp->link_ccbq, &lp->free_ccbq); in ncr_alloc_ccb()
7223 /*------------------------------------------------------------------------
7225 **------------------------------------------------------------------------
7229 **------------------------------------------------------------------------
7233 struct tcb *tp = &np->target[tn]; in ncr_init_tcb()
7234 ncrcmd copy_1 = np->features & FE_PFEN ? SCR_COPY(1) : SCR_COPY_F(1); in ncr_init_tcb()
7242 tp->jump_tcb.l_cmd = in ncr_init_tcb()
7244 tp->jump_tcb.l_paddr = np->jump_tcb[th].l_paddr; in ncr_init_tcb()
7248 ** COPY @(tp->sval), @(sxfer) in ncr_init_tcb()
7250 tp->getscr[0] = cpu_to_scr(copy_1); in ncr_init_tcb()
7251 tp->getscr[1] = cpu_to_scr(vtobus (&tp->sval)); in ncr_init_tcb()
7253 tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer) ^ 3); in ncr_init_tcb()
7255 tp->getscr[2] = cpu_to_scr(ncr_reg_bus_addr(nc_sxfer)); in ncr_init_tcb()
7260 ** COPY @(tp->wval), @(scntl3) in ncr_init_tcb()
7262 tp->getscr[3] = cpu_to_scr(copy_1); in ncr_init_tcb()
7263 tp->getscr[4] = cpu_to_scr(vtobus (&tp->wval)); in ncr_init_tcb()
7265 tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3) ^ 3); in ncr_init_tcb()
7267 tp->getscr[5] = cpu_to_scr(ncr_reg_bus_addr(nc_scntl3)); in ncr_init_tcb()
7274 tp->call_lun.l_cmd = cpu_to_scr(SCR_CALL); in ncr_init_tcb()
7275 tp->call_lun.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_lun)); in ncr_init_tcb()
7283 tp->jump_lcb[i].l_cmd = in ncr_init_tcb()
7285 tp->jump_lcb[i].l_paddr = in ncr_init_tcb()
7292 np->jump_tcb[th].l_paddr = cpu_to_scr(vtobus (&tp->jump_tcb)); in ncr_init_tcb()
7311 /*------------------------------------------------------------------------
7313 **------------------------------------------------------------------------
7316 **------------------------------------------------------------------------
7320 struct tcb *tp = &np->target[tn]; in ncr_alloc_lcb()
7321 struct lcb *lp = tp->lp[ln]; in ncr_alloc_lcb()
7322 ncrcmd copy_4 = np->features & FE_PFEN ? SCR_COPY(4) : SCR_COPY_F(4); in ncr_alloc_lcb()
7338 tp->lp[ln] = lp; in ncr_alloc_lcb()
7343 if (!tp->jump_tcb.l_cmd) in ncr_alloc_lcb()
7349 INIT_LIST_HEAD(&lp->free_ccbq); in ncr_alloc_lcb()
7350 INIT_LIST_HEAD(&lp->busy_ccbq); in ncr_alloc_lcb()
7351 INIT_LIST_HEAD(&lp->wait_ccbq); in ncr_alloc_lcb()
7352 INIT_LIST_HEAD(&lp->skip_ccbq); in ncr_alloc_lcb()
7358 lp->maxnxs = 1; in ncr_alloc_lcb()
7359 lp->jump_ccb = &lp->jump_ccb_0; in ncr_alloc_lcb()
7360 lp->p_jump_ccb = cpu_to_scr(vtobus(lp->jump_ccb)); in ncr_alloc_lcb()
7370 ** COPY @(lp->p_jump_ccb), @(temp) in ncr_alloc_lcb()
7373 lp->jump_lcb.l_cmd = in ncr_alloc_lcb()
7375 lp->jump_lcb.l_paddr = tp->jump_lcb[lh].l_paddr; in ncr_alloc_lcb()
7377 lp->load_jump_ccb[0] = cpu_to_scr(copy_4); in ncr_alloc_lcb()
7378 lp->load_jump_ccb[1] = cpu_to_scr(vtobus (&lp->p_jump_ccb)); in ncr_alloc_lcb()
7379 lp->load_jump_ccb[2] = cpu_to_scr(ncr_reg_bus_addr(nc_temp)); in ncr_alloc_lcb()
7381 lp->jump_tag.l_cmd = cpu_to_scr(SCR_JUMP); in ncr_alloc_lcb()
7382 lp->jump_tag.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_notag)); in ncr_alloc_lcb()
7387 tp->jump_lcb[lh].l_paddr = cpu_to_scr(vtobus (&lp->jump_lcb)); in ncr_alloc_lcb()
7392 lp->busyccbs = 1; in ncr_alloc_lcb()
7393 lp->queuedccbs = 1; in ncr_alloc_lcb()
7394 lp->queuedepth = 1; in ncr_alloc_lcb()
7400 /*------------------------------------------------------------------------
7402 **------------------------------------------------------------------------
7403 ** We only support WIDE, SYNC for targets and CMDQ for logical units.
7405 ** will play with CHANGE DEFINITION commands. :-)
7406 **------------------------------------------------------------------------
7410 unsigned char tn = sdev->id, ln = sdev->lun; in ncr_setup_lcb()
7411 struct tcb *tp = &np->target[tn]; in ncr_setup_lcb()
7412 struct lcb *lp = tp->lp[ln]; in ncr_setup_lcb()
7422 if (sdev->tagged_supported && lp->jump_ccb == &lp->jump_ccb_0) { in ncr_setup_lcb()
7424 lp->jump_ccb = m_calloc_dma(256, "JUMP_CCB"); in ncr_setup_lcb()
7425 if (!lp->jump_ccb) { in ncr_setup_lcb()
7426 lp->jump_ccb = &lp->jump_ccb_0; in ncr_setup_lcb()
7429 lp->p_jump_ccb = cpu_to_scr(vtobus(lp->jump_ccb)); in ncr_setup_lcb()
7431 lp->jump_ccb[i] = in ncr_setup_lcb()
7434 lp->cb_tags[i] = i; in ncr_setup_lcb()
7435 lp->maxnxs = MAX_TAGS; in ncr_setup_lcb()
7436 lp->tags_stime = jiffies + 3*HZ; in ncr_setup_lcb()
7458 **----------------------------------------------------------
7479 cp->data_len = 0; in ncr_scatter()
7488 return -1; in ncr_scatter()
7491 data = &cp->phys.data[MAX_SCATTER - use_sg]; in ncr_scatter()
7498 cp->data_len += len; in ncr_scatter()
7501 segment = -2; in ncr_scatter()
7509 ** Test the bus snoop logic :-(
7533 printk ("CACHE TEST FAILED: reg dstat-sstat2 readback %x.\n",
7544 if (np->reg) {
7557 np->ncr_cache = cpu_to_scr(host_wr);
7576 host_rd = scr_to_cpu(np->ncr_cache);
7641 **----------------------------------------------------------
7649 if (np->multiplier < 2) {
7658 if (np->multiplier > 2) { /* Poll bit 5 of stest4 for quadrupler */
7660 while (!(INB(nc_stest4) & LCKFRQ) && --i > 0)
7664 } else /* Wait 20 micro-seconds for doubler */
7701 OUTB (nc_scntl3, 4); /* set pre-scaler to divide by 3 */
7733 np->multiplier = 1;
7742 np->multiplier = mult;
7750 if (np->multiplier != mult || (scntl3 & 7) < 3 || !(scntl3 & 1)) {
7771 np->multiplier = mult;
7778 f1 /= np->multiplier;
7784 f1 *= np->multiplier;
7785 np->clock_khz = f1;
7792 struct Scsi_Host *host = device->host;
7793 struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
7794 struct tcb *tp = &np->target[device->id];
7795 tp->starget = device->sdev_target;
7802 struct Scsi_Host *host = device->host;
7803 struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
7804 struct tcb *tp = &np->target[device->id];
7805 struct lcb *lp = tp->lp[device->lun];
7816 numtags = device_queue_depth(np->unit, device->id, device->lun);
7817 if (numtags > tp->usrtags)
7818 numtags = tp->usrtags;
7819 if (!device->tagged_supported)
7839 lp->numtags = lp->maxtags = numtags;
7840 lp->scdev_depth = depth_to_use;
7846 np->unit, device->id, device->lun, depth_to_use);
7849 if (spi_support_sync(device->sdev_target) &&
7850 !spi_initial_dv(device->sdev_target))
7857 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
7865 cmd->scsi_done = done;
7866 cmd->host_scribble = NULL;
7867 cmd->__data_mapped = 0;
7868 cmd->__data_mapping = 0;
7870 spin_lock_irqsave(&np->smp_lock, flags);
7875 printk("ncr53c8xx : command not queued - result=%d\n", sts);
7883 spin_unlock_irqrestore(&np->smp_lock, flags);
7900 struct host_data *host_data = (struct host_data *)shost->hostdata;
7901 struct ncb *np = host_data->ncb;
7910 spin_lock_irqsave(&np->smp_lock, flags);
7912 done_list = np->done_list;
7913 np->done_list = NULL;
7914 spin_unlock_irqrestore(&np->smp_lock, flags);
7929 spin_lock_irqsave(&np->smp_lock, flags);
7931 done_list = np->done_list;
7932 np->done_list = NULL;
7933 spin_unlock_irqrestore(&np->smp_lock, flags);
7941 struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
7947 * If the mid-level driver told us reset is synchronous, it seems
7949 * even if this command was not queued to the low-level driver,
7953 spin_lock_irqsave(&np->smp_lock, flags);
7956 done_list = np->done_list;
7957 np->done_list = NULL;
7958 spin_unlock_irqrestore(&np->smp_lock, flags);
7988 cmd->next_wcmd = NULL;
7989 if (!(wcmd = np->waiting_list)) np->waiting_list = cmd;
7991 while (wcmd->next_wcmd)
7992 wcmd = (struct scsi_cmnd *) wcmd->next_wcmd;
7993 wcmd->next_wcmd = (char *) cmd;
8001 waiting_list = np->waiting_list;
8002 np->waiting_list = NULL;
8008 waiting_list = (struct scsi_cmnd *) wcmd->next_wcmd;
8009 wcmd->next_wcmd = NULL;
8032 struct host_data *host_data = (struct host_data *)host->hostdata;
8034 return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
8086 if (!tpnt->name)
8087 tpnt->name = SCSI_NCR_DRIVER_NAME;
8088 if (!tpnt->shost_attrs)
8089 tpnt->shost_attrs = ncr53c8xx_host_attrs;
8091 tpnt->queuecommand = ncr53c8xx_queue_command;
8092 tpnt->slave_configure = ncr53c8xx_slave_configure;
8093 tpnt->slave_alloc = ncr53c8xx_slave_alloc;
8094 tpnt->eh_bus_reset_handler = ncr53c8xx_bus_reset;
8095 tpnt->can_queue = SCSI_NCR_CAN_QUEUE;
8096 tpnt->this_id = 7;
8097 tpnt->sg_tablesize = SCSI_NCR_SG_TABLESIZE;
8098 tpnt->cmd_per_lun = SCSI_NCR_CMD_PER_LUN;
8100 if (device->differential)
8101 driver_setup.diff_support = device->differential;
8103 printk(KERN_INFO "ncr53c720-%d: rev 0x%x irq %d\n",
8104 unit, device->chip.revision_id, device->slot.irq);
8109 host_data = (struct host_data *) instance->hostdata;
8111 np = __m_calloc_dma(device->dev, sizeof(struct ncb), "NCB");
8114 spin_lock_init(&np->smp_lock);
8115 np->dev = device->dev;
8116 np->p_ncb = vtobus(np);
8117 host_data->ncb = np;
8119 np->ccb = m_calloc_dma(sizeof(struct ccb), "CCB");
8120 if (!np->ccb)
8124 np->unit = unit;
8125 np->verbose = driver_setup.verbose;
8126 sprintf(np->inst_name, "ncr53c720-%d", np->unit);
8127 np->revision_id = device->chip.revision_id;
8128 np->features = device->chip.features;
8129 np->clock_divn = device->chip.nr_divisor;
8130 np->maxoffs = device->chip.offset_max;
8131 np->maxburst = device->chip.burst_max;
8132 np->myaddr = device->host_id;
8135 np->script0 = m_calloc_dma(sizeof(struct script), "SCRIPT");
8136 if (!np->script0)
8138 np->scripth0 = m_calloc_dma(sizeof(struct scripth), "SCRIPTH");
8139 if (!np->scripth0)
8142 timer_setup(&np->timer, ncr53c8xx_timeout, 0);
8146 np->paddr = device->slot.base;
8147 np->paddr2 = (np->features & FE_RAM) ? device->slot.base_2 : 0;
8149 if (device->slot.base_v)
8150 np->vaddr = device->slot.base_v;
8152 np->vaddr = ioremap(device->slot.base_c, 128);
8154 if (!np->vaddr) {
8161 "%s: using memory mapped IO at virtual address 0x%lx\n", ncr_name(np), (u_long) np->vaddr);
8168 np->reg = (struct ncr_reg __iomem *)np->vaddr;
8173 if (np->paddr2 && sizeof(struct script) > 4096) {
8174 np->paddr2 = 0;
8179 instance->max_channel = 0;
8180 instance->this_id = np->myaddr;
8181 instance->max_id = np->maxwide ? 16 : 8;
8182 instance->max_lun = SCSI_NCR_MAX_LUN;
8183 instance->base = (unsigned long) np->reg;
8184 instance->irq = device->slot.irq;
8185 instance->unique_id = device->slot.base;
8186 instance->dma_channel = 0;
8187 instance->cmd_per_lun = MAX_TAGS;
8188 instance->can_queue = (MAX_START-4);
8192 instance->transportt = ncr53c8xx_transport_template;
8197 np->scripth = np->scripth0;
8198 np->p_scripth = vtobus(np->scripth);
8199 np->p_script = (np->paddr2) ? np->paddr2 : vtobus(np->script0);
8202 (ncrcmd *) np->script0, sizeof(struct script));
8204 (ncrcmd *) np->scripth0, sizeof(struct scripth));
8205 np->ccb->p_ccb = vtobus (np->ccb);
8209 if (np->features & FE_LED0) {
8210 np->script0->idle[0] =
8212 np->script0->reselected[0] =
8214 np->script0->start[0] =
8224 np->jump_tcb[i].l_cmd =
8226 np->jump_tcb[i].l_paddr =
8240 np->irq = device->slot.irq;
8243 ncr_init_ccb(np, np->ccb);
8251 spin_lock_irqsave(&np->smp_lock, flags);
8253 …printk(KERN_ERR "%s: FATAL ERROR: CHECK SCSI BUS - CABLES, TERMINATION, DEVICE POWER etc.!\n", ncr…
8255 spin_unlock_irqrestore(&np->smp_lock, flags);
8260 np->disc = 1;
8263 * The middle-level SCSI driver does not wait for devices to settle.
8273 np->lasttime=0;
8278 np->order = SIMPLE_QUEUE_TAG;
8281 spin_unlock_irqrestore(&np->smp_lock, flags);
8291 if (np->scripth0)
8292 m_free_dma(np->scripth0, sizeof(struct scripth), "SCRIPTH");
8293 if (np->script0)
8294 m_free_dma(np->script0, sizeof(struct script), "SCRIPT");
8295 if (np->ccb)
8296 m_free_dma(np->ccb, sizeof(struct ccb), "CCB");
8298 host_data->ncb = NULL;
8313 if (host_data->ncb)
8314 ncr_detach(host_data->ncb);
8320 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8321 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8322 struct tcb *tp = &np->target[starget->id];
8324 if (period > np->maxsync)
8325 period = np->maxsync;
8326 else if (period < np->minsync)
8327 period = np->minsync;
8329 tp->usrsync = period;
8336 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8337 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8338 struct tcb *tp = &np->target[starget->id];
8340 if (offset > np->maxoffs)
8341 offset = np->maxoffs;
8345 tp->maxoffs = offset;
8352 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
8353 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8354 struct tcb *tp = &np->target[starget->id];
8356 if (width > np->maxwide)
8357 width = np->maxwide;
8361 tp->usrwide = width;
8368 struct ncb *np = ((struct host_data *)shost->hostdata)->ncb;
8371 switch (np->scsi_mode) {
8399 return -ENODEV;