Lines Matching refs:megaCfg
656 static ulong RDINDOOR (mega_host_config * megaCfg) in RDINDOOR() argument
658 return readl (megaCfg->base + 0x20); in RDINDOOR()
661 static void WRINDOOR (mega_host_config * megaCfg, ulong value) in WRINDOOR() argument
663 writel (value, megaCfg->base + 0x20); in WRINDOOR()
666 static ulong RDOUTDOOR (mega_host_config * megaCfg) in RDOUTDOOR() argument
668 return readl (megaCfg->base + 0x2C); in RDOUTDOOR()
671 static void WROUTDOOR (mega_host_config * megaCfg, ulong value) in WROUTDOOR() argument
673 writel (value, megaCfg->base + 0x2C); in WROUTDOOR()
823 #define COPY_BACK if (offset > megaCfg->procidx) { \
825 megaCfg->procidx = 0; \
826 megaCfg->procbuf[0] = 0; \
828 if ((count + offset) > megaCfg->procidx) { \
829 count = megaCfg->procidx - offset; \
831 memcpy(page, &megaCfg->procbuf[offset], count); \
832 megaCfg->procidx = 0; \
833 megaCfg->procbuf[0] = 0;
995 static void mega_freeSCB (mega_host_config * megaCfg, mega_scb * pScb) in mega_freeSCB() argument
1008 pci_unmap_single (megaCfg->dev, pScb->dma_h_bulkdata, in mega_freeSCB()
1013 pci_unmap_single (megaCfg->dev, pScb->dma_h_bulkdata, in mega_freeSCB()
1021 pci_unmap_single (megaCfg->dev, in mega_freeSCB()
1030 pci_unmap_single (megaCfg->dev, in mega_freeSCB()
1036 pci_unmap_sg (megaCfg->dev, in mega_freeSCB()
1046 if (pScb == megaCfg->qPendingH) { in mega_freeSCB()
1048 if (megaCfg->qPendingH == megaCfg->qPendingT) in mega_freeSCB()
1049 megaCfg->qPendingH = megaCfg->qPendingT = NULL; in mega_freeSCB()
1051 megaCfg->qPendingH = megaCfg->qPendingH->next; in mega_freeSCB()
1053 megaCfg->qPcnt--; in mega_freeSCB()
1056 for (pScbtmp = megaCfg->qPendingH; pScbtmp; in mega_freeSCB()
1063 if (pScb == megaCfg->qPendingT) { in mega_freeSCB()
1064 megaCfg->qPendingT = pScbtmp; in mega_freeSCB()
1067 megaCfg->qPcnt--; in mega_freeSCB()
1077 if (megaCfg->qFreeH == (mega_scb *) NULL) { in mega_freeSCB()
1078 megaCfg->qFreeH = megaCfg->qFreeT = pScb; in mega_freeSCB()
1080 megaCfg->qFreeT->next = pScb; in mega_freeSCB()
1081 megaCfg->qFreeT = pScb; in mega_freeSCB()
1084 megaCfg->qFreeT->next = NULL; in mega_freeSCB()
1085 megaCfg->qFcnt++; in mega_freeSCB()
1093 static mega_scb *mega_allocateSCB (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) in mega_allocateSCB() argument
1098 if ((pScb = megaCfg->qFreeH) != NULL) { in mega_allocateSCB()
1099 megaCfg->qFreeH = pScb->next; in mega_allocateSCB()
1100 megaCfg->qFcnt--; in mega_allocateSCB()
1120 static void mega_rundoneq (mega_host_config * megaCfg) in mega_rundoneq() argument
1124 while ((SCpnt = megaCfg->qCompletedH) != NULL) { in mega_rundoneq()
1125 megaCfg->qCompletedH = (Scsi_Cmnd *) SCpnt->host_scribble; in mega_rundoneq()
1126 megaCfg->qCcnt--; in mega_rundoneq()
1133 megaCfg->qCompletedH = megaCfg->qCompletedT = NULL; in mega_rundoneq()
1140 static int mega_runpendq (mega_host_config * megaCfg) in mega_runpendq() argument
1146 for (pScb = megaCfg->qPendingH; pScb; pScb = pScb->next) { in mega_runpendq()
1149 megaIssueCmd (megaCfg, pScb->mboxData, pScb, 1)) == -1) in mega_runpendq()
1158 static void mega_cmd_done (mega_host_config * megaCfg, mega_scb * pScb, int status) in mega_cmd_done() argument
1194 islogical = ( (SCpnt->channel >= megaCfg->productInfo.SCSIChanPresent) && in mega_cmd_done()
1195 (SCpnt->channel <= megaCfg->host->max_channel) ); in mega_cmd_done()
1198 islogical = (SCpnt->channel == megaCfg->host->max_channel); in mega_cmd_done()
1200 islogical = megaCfg->logdrv_chan[SCpnt->channel]; in mega_cmd_done()
1219 mega_freeSCB (megaCfg, pScb); in mega_cmd_done()
1243 if(IS_RAID_CH(megaCfg, SCpnt->channel) && ((c & 0x1F) == TYPE_DISK)) { in mega_cmd_done()
1305 if (megaCfg->qCompletedH == NULL) { in mega_cmd_done()
1306 megaCfg->qCompletedH = megaCfg->qCompletedT = SCpnt; in mega_cmd_done()
1308 megaCfg->qCompletedT->host_scribble = (unsigned char *) SCpnt; in mega_cmd_done()
1309 megaCfg->qCompletedT = SCpnt; in mega_cmd_done()
1312 megaCfg->qCompletedT->host_scribble = (unsigned char *) NULL; in mega_cmd_done()
1313 megaCfg->qCcnt++; in mega_cmd_done()
1325 static mega_scb *mega_build_cmd (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) in mega_build_cmd() argument
1339 return megadev_doioctl (megaCfg, SCpnt); in mega_build_cmd()
1344 return mega_ioctl (megaCfg, SCpnt); /* Handle IOCTL command */ in mega_build_cmd()
1354 islogical = ( (SCpnt->channel >= megaCfg->productInfo.SCSIChanPresent) && in mega_build_cmd()
1355 (SCpnt->channel <= megaCfg->host->max_channel) ); in mega_build_cmd()
1359 (SCpnt->channel == megaCfg->host->max_channel)); in mega_build_cmd()
1365 islogical = megaCfg->logdrv_chan[SCpnt->channel]; in mega_build_cmd()
1374 if( megaCfg->boot_pdrv_enabled ) { in mega_build_cmd()
1377 channel = SCpnt->channel - megaCfg->productInfo.SCSIChanPresent; in mega_build_cmd()
1389 target = megaCfg->boot_pdrv_tgt; in mega_build_cmd()
1391 else if( target == megaCfg->boot_pdrv_tgt ) { in mega_build_cmd()
1406 if ( ! megaCfg->support_ext_cdb ) { in mega_build_cmd()
1429 ldrv_num = mega_get_ldrv_num(megaCfg, SCpnt, channel); in mega_build_cmd()
1431 max_ldrv_num = (megaCfg->flag & BOARD_40LD) ? in mega_build_cmd()
1437 if(megaCfg->read_ldidmap) { in mega_build_cmd()
1476 if(!(megaCfg->flag & (1L << SCpnt->channel))) { in mega_build_cmd()
1479 megaCfg->host->host_no, channel); in mega_build_cmd()
1481 megaCfg->flag |= (1L << SCpnt->channel); in mega_build_cmd()
1485 if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) { in mega_build_cmd()
1514 = pci_map_single (megaCfg->dev, in mega_build_cmd()
1550 if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) { in mega_build_cmd()
1560 if (megaCfg->flag & BOARD_64BIT) { in mega_build_cmd()
1582 megaCfg->nReads[(int)ldrv_num]++; in mega_build_cmd()
1583 megaCfg->nReadBlocks[(int)ldrv_num] += in mega_build_cmd()
1586 megaCfg->nWrites[(int)ldrv_num]++; in mega_build_cmd()
1587 megaCfg->nWriteBlocks[(int)ldrv_num] += in mega_build_cmd()
1604 megaCfg->nReads[(int)ldrv_num]++; in mega_build_cmd()
1605 megaCfg->nReadBlocks[(int)ldrv_num] += in mega_build_cmd()
1608 megaCfg->nWrites[(int)ldrv_num]++; in mega_build_cmd()
1609 megaCfg->nWriteBlocks[(int)ldrv_num] += in mega_build_cmd()
1629 megaCfg->nReads[(int)ldrv_num]++; in mega_build_cmd()
1630 megaCfg->nReadBlocks[(int)ldrv_num] += in mega_build_cmd()
1633 megaCfg->nWrites[(int)ldrv_num]++; in mega_build_cmd()
1634 megaCfg->nWriteBlocks[(int)ldrv_num] += in mega_build_cmd()
1649 mbox->numsgelements = mega_build_sglist (megaCfg, pScb, in mega_build_cmd()
1678 if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) { in mega_build_cmd()
1687 if ( megaCfg->support_ext_cdb && SCpnt->cmd_len > 10 ) { in mega_build_cmd()
1688 epthru = mega_prepare_extpassthru(megaCfg, pScb, SCpnt, channel, in mega_build_cmd()
1704 pthru = mega_prepare_passthru(megaCfg, pScb, SCpnt, channel, in mega_build_cmd()
1912 static int mega_driver_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) in mega_driver_ioctl() argument
1941 static void inline set_mbox_xfer_addr (mega_host_config * megaCfg, mega_scb * pScb, in set_mbox_xfer_addr() argument
1959 = pci_map_single (megaCfg->dev, in set_mbox_xfer_addr()
1975 static mega_scb *mega_ioctl (mega_host_config * megaCfg, Scsi_Cmnd * SCpnt) in mega_ioctl() argument
1985 if ((pScb = mega_allocateSCB (megaCfg, SCpnt)) == NULL) { in mega_ioctl()
2013 pthru->numsgelements = mega_build_sglist (megaCfg, pScb, in mega_ioctl()
2112 set_mbox_xfer_addr (megaCfg, pScb, mbox, TO_DEVICE); in mega_ioctl()
2118 set_mbox_xfer_addr (megaCfg, pScb, mbox, TO_DEVICE); in mega_ioctl()
2129 if (megaCfg->flag & BOARD_64BIT) in mega_ioctl()
2135 if (megaCfg->flag & BOARD_64BIT) in mega_ioctl()
2137 set_mbox_xfer_addr (megaCfg, pScb, mbox, in mega_ioctl()
2143 if (megaCfg->flag & BOARD_64BIT) in mega_ioctl()
2154 set_mbox_xfer_addr (megaCfg, pScb, mbox, in mega_ioctl()
2162 set_mbox_xfer_addr (megaCfg, pScb, mbox, in mega_ioctl()
2167 set_mbox_xfer_addr (megaCfg, pScb, mbox, in mega_ioctl()
2174 set_mbox_xfer_addr (megaCfg, pScb, mbox, FROMTO_DEVICE); in mega_ioctl()
2180 mbox->numsgelements = mega_build_sglist (megaCfg, pScb, in mega_ioctl()
2262 mega_host_config * megaCfg; in megaraid_isr() local
2271 megaCfg = (mega_host_config *) devp; in megaraid_isr()
2277 if (megaCfg->flag & BOARD_QUARTZ) { in megaraid_isr()
2278 dword = RDOUTDOOR (megaCfg); in megaraid_isr()
2284 WROUTDOOR (megaCfg, 0x10001234); in megaraid_isr()
2286 byte = READ_PORT (megaCfg->host->io_port, INTR_PORT); in megaraid_isr()
2292 WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte); in megaraid_isr()
2299 megaCfg->nInterrupts++; in megaraid_isr()
2300 while ((qCnt = megaCfg->mbox->numstatus) == 0xFF) ; in megaraid_isr()
2301 megaCfg->mbox->numstatus = 0xFF; in megaraid_isr()
2305 while ((completed[idx] = megaCfg->mbox->completed[idx]) == 0xFF); in megaraid_isr()
2306 megaCfg->mbox->completed[idx] = 0xFF; in megaraid_isr()
2309 qStatus = megaCfg->mbox->status; in megaraid_isr()
2311 if (megaCfg->flag & BOARD_QUARTZ) { in megaraid_isr()
2313 WRINDOOR (megaCfg, 0x2); in megaraid_isr()
2314 while (RDINDOOR (megaCfg) & 0x02) ; in megaraid_isr()
2316 CLEAR_INTR (megaCfg->host->io_port); in megaraid_isr()
2322 pScb = &megaCfg->scbList[sIdx - 1]; in megaraid_isr()
2344 mega_freeSCB (megaCfg, pScb); in megaraid_isr()
2346 if (megaCfg->qCompletedH == NULL) { in megaraid_isr()
2347 megaCfg->qCompletedH = in megaraid_isr()
2348 megaCfg->qCompletedT = in megaraid_isr()
2351 megaCfg->qCompletedT-> in megaraid_isr()
2354 megaCfg->qCompletedT = SCpnt; in megaraid_isr()
2356 megaCfg->qCompletedT->host_scribble = in megaraid_isr()
2358 megaCfg->qCcnt++; in megaraid_isr()
2372 mega_cmd_done (megaCfg, pScb, qStatus); in megaraid_isr()
2381 mega_rundoneq (megaCfg); in megaraid_isr()
2383 megaCfg->flag &= ~IN_ISR; in megaraid_isr()
2385 mega_runpendq (megaCfg); in megaraid_isr()
2394 static inline int mega_busyWaitMbox (mega_host_config * megaCfg) in mega_busyWaitMbox() argument
2396 mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox; in mega_busyWaitMbox()
2423 static int megaIssueCmd (mega_host_config * megaCfg, u_char * mboxData, in megaIssueCmd() argument
2426 volatile mega_mailbox *mbox = (mega_mailbox *) megaCfg->mbox; in megaIssueCmd()
2429 volatile mega_mailbox64 *mbox64 = (mega_mailbox64 *) megaCfg->mbox64; in megaIssueCmd()
2447 phys_mbox = megaCfg->adjdmahandle64; in megaIssueCmd()
2449 phys_mbox = virt_to_bus (megaCfg->mbox); in megaIssueCmd()
2453 if (mega_busyWaitMbox (megaCfg)) { in megaIssueCmd()
2460 megaCfg->mbox64->xferSegment_lo = 0; in megaIssueCmd()
2461 megaCfg->mbox64->xferSegment_hi = 0; in megaIssueCmd()
2479 if (megaCfg->flag & BOARD_QUARTZ) { in megaIssueCmd()
2483 WRINDOOR (megaCfg, phys_mbox | 0x1); in megaIssueCmd()
2485 ENABLE_INTR (megaCfg->host->io_port); in megaIssueCmd()
2486 ISSUE_COMMAND (megaCfg->host->io_port); in megaIssueCmd()
2492 disable_irq (megaCfg->host->irq); in megaIssueCmd()
2493 if (megaCfg->flag & BOARD_QUARTZ) { in megaIssueCmd()
2498 WRINDOOR (megaCfg, phys_mbox | 0x1); in megaIssueCmd()
2507 mega_cmd_done (megaCfg, pScb, mbox->status); in megaIssueCmd()
2510 WRINDOOR (megaCfg, phys_mbox | 0x2); in megaIssueCmd()
2511 while (RDINDOOR (megaCfg) & 0x2) ; in megaIssueCmd()
2514 DISABLE_INTR (megaCfg->host->io_port); in megaIssueCmd()
2515 ISSUE_COMMAND (megaCfg->host->io_port); in megaIssueCmd()
2519 READ_PORT (megaCfg->host->io_port, in megaIssueCmd()
2521 WRITE_PORT (megaCfg->host->io_port, INTR_PORT, byte); in megaIssueCmd()
2523 ENABLE_INTR (megaCfg->host->io_port); in megaIssueCmd()
2524 CLEAR_INTR (megaCfg->host->io_port); in megaIssueCmd()
2527 mega_cmd_done (megaCfg, pScb, mbox->status); in megaIssueCmd()
2537 enable_irq (megaCfg->host->irq); in megaIssueCmd()
2552 mega_build_sglist (mega_host_config * megaCfg, mega_scb * scb, in mega_build_sglist() argument
2569 scb->dma_h_bulkdata = pci_map_single (megaCfg->dev, in mega_build_sglist()
2576 if ((megaCfg->flag & BOARD_64BIT) && in mega_build_sglist()
2601 scb->dma_h_bulkdata = pci_map_single (megaCfg->dev, in mega_build_sglist()
2605 if ((megaCfg->flag & BOARD_64BIT) && in mega_build_sglist()
2628 sgcnt = pci_map_sg (megaCfg->dev, in mega_build_sglist()
2637 if ((megaCfg->flag & BOARD_64BIT) && in mega_build_sglist()
2699 mega_register_mailbox (mega_host_config * megaCfg, u32 paddr) in mega_register_mailbox() argument
2703 megaCfg->mbox = &megaCfg->mailbox64ptr->mailbox; in mega_register_mailbox()
2705 megaCfg->mbox = &megaCfg->mailbox64.mailbox; in mega_register_mailbox()
2709 megaCfg->mbox = (mega_mailbox *) ((((u64) megaCfg->mbox) + 16) & ((u64) (-1) ^ 0x0F)); in mega_register_mailbox()
2710 megaCfg->adjdmahandle64 = (megaCfg->dma_handle64 + 16) & ((u64) (-1) ^ 0x0F); in mega_register_mailbox()
2711 megaCfg->mbox64 = (mega_mailbox64 *) ((u_char *) megaCfg->mbox - sizeof (u64)); in mega_register_mailbox()
2714 megaCfg->mbox in mega_register_mailbox()
2715 = (mega_mailbox *) ((((u32) megaCfg->mbox) + 16) & 0xFFFFFFF0); in mega_register_mailbox()
2718 megaCfg->adjdmahandle64 = ((megaCfg->dma_handle64 + 16) & 0xFFFFFFF0); in mega_register_mailbox()
2721 megaCfg->mbox64 = (mega_mailbox64 *) ((u_char *) megaCfg->mbox - 8); in mega_register_mailbox()
2726 if (!(megaCfg->flag & BOARD_QUARTZ)) { in mega_register_mailbox()
2727 WRITE_PORT (megaCfg->host->io_port, MBOX_PORT0, paddr & 0xFF); in mega_register_mailbox()
2728 WRITE_PORT (megaCfg->host->io_port, MBOX_PORT1, in mega_register_mailbox()
2730 WRITE_PORT (megaCfg->host->io_port, MBOX_PORT2, in mega_register_mailbox()
2732 WRITE_PORT (megaCfg->host->io_port, MBOX_PORT3, in mega_register_mailbox()
2734 WRITE_PORT (megaCfg->host->io_port, ENABLE_MBOX_REGION, in mega_register_mailbox()
2737 CLEAR_INTR (megaCfg->host->io_port); in mega_register_mailbox()
2738 ENABLE_INTR (megaCfg->host->io_port); in mega_register_mailbox()
2782 static int mega_i_query_adapter (mega_host_config * megaCfg) in mega_i_query_adapter() argument
2797 memset ((void *) megaCfg->mega_buffer, 0, in mega_i_query_adapter()
2798 sizeof (megaCfg->mega_buffer)); in mega_i_query_adapter()
2807 enquiry3_dma_handle = pci_map_single (megaCfg->dev, in mega_i_query_adapter()
2808 (void *) megaCfg->mega_buffer, in mega_i_query_adapter()
2814 mbox->xferaddr = virt_to_bus ((void *) megaCfg->mega_buffer); in mega_i_query_adapter()
2818 enquiry3Pnt = (mega_Enquiry3 *) megaCfg->mega_buffer; in mega_i_query_adapter()
2826 …if ((retval = megaIssueCmd (megaCfg, mboxData, NULL, 0)) != 0) { /* the adapter does not support 4… in mega_i_query_adapter()
2831 raid_inq_dma_handle = pci_map_single (megaCfg->dev, in mega_i_query_adapter()
2843 retval = megaIssueCmd (megaCfg, mboxData, NULL, 0); in mega_i_query_adapter()
2845 pci_unmap_single (megaCfg->dev, in mega_i_query_adapter()
2852 (megaRaidProductInfo *) & megaCfg-> in mega_i_query_adapter()
2856 megaCfg->flag |= BOARD_40LD; in mega_i_query_adapter()
2858 pci_unmap_single (megaCfg->dev, in mega_i_query_adapter()
2864 = pci_map_single (megaCfg->dev, in mega_i_query_adapter()
2865 (void *) &megaCfg->productInfo, in mega_i_query_adapter()
2871 mbox->xferaddr = virt_to_bus ((void *) &megaCfg->productInfo); in mega_i_query_adapter()
2877 if ((retval = megaIssueCmd (megaCfg, mboxData, NULL, 0)) != 0) in mega_i_query_adapter()
2881 pci_unmap_single (megaCfg->dev, in mega_i_query_adapter()
2890 megaCfg->host->max_channel = in mega_i_query_adapter()
2891 megaCfg->productInfo.SCSIChanPresent + NVIRT_CHAN -1; in mega_i_query_adapter()
2893 megaCfg->host->max_id = 16; /* max targets per channel */ in mega_i_query_adapter()
2895 megaCfg->host->max_lun = 7; /* Upto 7 luns for non disk devices */ in mega_i_query_adapter()
2897 megaCfg->host->cmd_per_lun = MAX_CMD_PER_LUN; in mega_i_query_adapter()
2899 megaCfg->numldrv = enquiry3Pnt->numLDrv; in mega_i_query_adapter()
2900 megaCfg->max_cmds = megaCfg->productInfo.MaxConcCmds; in mega_i_query_adapter()
2901 if (megaCfg->max_cmds > MAX_COMMANDS) in mega_i_query_adapter()
2902 megaCfg->max_cmds = MAX_COMMANDS - 1; in mega_i_query_adapter()
2904 megaCfg->host->can_queue = megaCfg->max_cmds - 1; in mega_i_query_adapter()
2907 if (megaCfg->productInfo.subSystemVendorID == HP_SUBSYS_ID) { in mega_i_query_adapter()
2908 sprintf (megaCfg->fwVer, "%c%d%d.%d%d", in mega_i_query_adapter()
2909 megaCfg->productInfo.FwVer[2], in mega_i_query_adapter()
2910 megaCfg->productInfo.FwVer[1] >> 8, in mega_i_query_adapter()
2911 megaCfg->productInfo.FwVer[1] & 0x0f, in mega_i_query_adapter()
2912 megaCfg->productInfo.FwVer[0] >> 8, in mega_i_query_adapter()
2913 megaCfg->productInfo.FwVer[0] & 0x0f); in mega_i_query_adapter()
2914 sprintf (megaCfg->biosVer, "%c%d%d.%d%d", in mega_i_query_adapter()
2915 megaCfg->productInfo.BiosVer[2], in mega_i_query_adapter()
2916 megaCfg->productInfo.BiosVer[1] >> 8, in mega_i_query_adapter()
2917 megaCfg->productInfo.BiosVer[1] & 0x0f, in mega_i_query_adapter()
2918 megaCfg->productInfo.BiosVer[0] >> 8, in mega_i_query_adapter()
2919 megaCfg->productInfo.BiosVer[0] & 0x0f); in mega_i_query_adapter()
2921 memcpy (megaCfg->fwVer, (char *) megaCfg->productInfo.FwVer, 4); in mega_i_query_adapter()
2922 megaCfg->fwVer[4] = 0; in mega_i_query_adapter()
2924 memcpy (megaCfg->biosVer, (char *) megaCfg->productInfo.BiosVer, 4); in mega_i_query_adapter()
2925 megaCfg->biosVer[4] = 0; in mega_i_query_adapter()
2927 megaCfg->support_ext_cdb = mega_support_ext_cdb(megaCfg); in mega_i_query_adapter()
2930 megaCfg->fwVer, megaCfg->biosVer, megaCfg->numldrv); in mega_i_query_adapter()
2932 if ( megaCfg->support_ext_cdb ) { in mega_i_query_adapter()
2964 mega_host_config *megaCfg = NULL; local
3147 megaCfg = (mega_host_config *) host->hostdata;
3148 memset (megaCfg, 0, sizeof (mega_host_config));
3158 megaCfg->qCompletedH = NULL;
3159 megaCfg->qCompletedT = NULL;
3160 megaCfg->qPendingH = NULL;
3161 megaCfg->qPendingT = NULL;
3162 megaCfg->qFreeH = NULL;
3163 megaCfg->qFreeT = NULL;
3164 megaCfg->qFcnt = 0;
3165 megaCfg->qPcnt = 0;
3166 megaCfg->qCcnt = 0;
3167 megaCfg->lock_free = SPIN_LOCK_UNLOCKED;
3168 megaCfg->lock_pend = SPIN_LOCK_UNLOCKED;
3169 megaCfg->lock_scsicmd = SPIN_LOCK_UNLOCKED;
3170 megaCfg->flag = flag;
3171 megaCfg->int_qh = NULL;
3172 megaCfg->int_qt = NULL;
3173 megaCfg->int_qlen = 0;
3176 megaCfg->dev = pdev;
3178 megaCfg->host = host;
3179 megaCfg->base = megaBase;
3180 megaCfg->host->irq = megaIrq;
3181 megaCfg->host->io_port = megaBase;
3182 megaCfg->host->n_io_port = 16;
3183 megaCfg->host->unique_id = (pciBus << 8) | pciDevFun;
3184 megaCtlrs[numCtlrs] = megaCfg;
3187 megaCfg->host->base = tbase;
3192 "megaraid", megaCfg)) {
3205 megaCfg->mailbox64ptr
3206 = pci_alloc_consistent (megaCfg->dev,
3208 &(megaCfg->dma_handle64));
3210 mega_register_mailbox (megaCfg,megaCfg->dma_handle64);
3212 mega_register_mailbox (megaCfg,
3213 virt_to_bus ((void *) &megaCfg->
3217 mega_i_query_adapter (megaCfg);
3224 if( strcmp(megaCfg->fwVer, "3.00") == 0 ||
3225 strcmp(megaCfg->fwVer, "3.01") == 0 ) {
3253 if( strcmp(megaCfg->fwVer, "H01.07") == 0 ||
3254 strcmp(megaCfg->fwVer, "H01.08") == 0 ||
3255 strcmp(megaCfg->fwVer, "H01.09") == 0 )
3262 megaCfg->flag &= ~BOARD_64BIT;
3266 if (mega_is_bios_enabled (megaCfg)) {
3273 mega_enum_raid_scsi(megaCfg);
3283 mega_get_boot_drv(megaCfg);
3285 if( ! megaCfg->boot_pdrv_enabled ) {
3287 megaCfg->logdrv_chan[i] = 1;
3290 megaCfg->logdrv_chan[i] = 0;
3292 megaCfg->mega_ch_class <<= NVIRT_CHAN;
3295 j = megaCfg->productInfo.SCSIChanPresent;
3297 megaCfg->logdrv_chan[i] = 0;
3300 megaCfg->logdrv_chan[i] = 1;
3304 mega_hbas[numCtlrs].hostdata_addr = megaCfg;
3309 megaCfg->read_ldidmap = 0; /* set it after first logdrv delete cmd */
3310 megaCfg->support_random_del = mega_support_random_del(megaCfg);
3313 if (mega_init_scb (megaCfg)) {
3314 pci_free_consistent (megaCfg->dev,
3316 (void *) megaCfg->mailbox64ptr,
3317 megaCfg->dma_handle64);
3332 mcontroller[i].numldrv = megaCfg->numldrv;
3345 if ((megaCfg->flag & BOARD_64BIT) && BITS_PER_LONG == 64)
3474 static inline void mega_freeSgList (mega_host_config * megaCfg) argument
3478 for (i = 0; i < megaCfg->max_cmds; i++) {
3479 if (megaCfg->scbList[i].sgList)
3480 pci_free_consistent (megaCfg->dev,
3483 megaCfg->scbList[i].sgList,
3484 megaCfg->scbList[i].
3487 kfree (megaCfg->scbList[i].sgList); /* free sgList */
3497 mega_host_config *megaCfg; local
3502 megaCfg = (mega_host_config *) pSHost->hostdata;
3509 free_irq (megaCfg->host->irq, megaCfg); /* Must be freed first, otherwise
3513 megaIssueCmd (megaCfg, mboxData, NULL, 0);
3516 if (megaCfg->flag & BOARD_QUARTZ) {
3517 iounmap ((void *) megaCfg->base);
3518 release_mem_region(megaCfg->host->base, 128);
3520 release_region (megaCfg->host->io_port, 16);
3523 mega_freeSgList (megaCfg);
3524 pci_free_consistent (megaCfg->dev,
3526 (void *) megaCfg->mailbox64ptr,
3527 megaCfg->dma_handle64);
3530 if (megaCfg->controller_proc_dir_entry) {
3531 remove_proc_entry ("stat", megaCfg->controller_proc_dir_entry);
3533 megaCfg->controller_proc_dir_entry);
3535 megaCfg->controller_proc_dir_entry);
3537 megaCfg->controller_proc_dir_entry);
3907 mega_host_config *megaCfg; local
3909 megaCfg = (mega_host_config *) pSHost->hostdata;
3913 megaCfg->fwVer, megaCfg->productInfo.MaxConcCmds,
3914 megaCfg->host->max_id-1, megaCfg->host->max_channel,
3915 megaCfg->host->max_lun);
3936 DRIVER_LOCK_T mega_host_config * megaCfg; local
3940 megaCfg = (mega_host_config *) SCpnt->host->hostdata;
3941 DRIVER_LOCK (megaCfg);
3944 if (!(megaCfg->flag & (1L << SCpnt->channel))) {
3945 if (SCpnt->channel < megaCfg->productInfo.SCSIChanPresent)
3948 megaCfg->host->host_no, SCpnt->channel);
3952 megaCfg->host->host_no,
3953 SCpnt->channel-megaCfg->productInfo.SCSIChanPresent+1);
3955 megaCfg->flag |= (1L << SCpnt->channel);
3961 if (mega_driver_ioctl (megaCfg, SCpnt))
3965 if (megaCfg->flag & IN_ABORT) {
3968 if (megaCfg->qCompletedH == NULL) {
3969 megaCfg->qCompletedH = megaCfg->qCompletedT = SCpnt;
3971 megaCfg->qCompletedT->host_scribble =
3973 megaCfg->qCompletedT = SCpnt;
3975 megaCfg->qCompletedT->host_scribble = (unsigned char *) NULL;
3976 megaCfg->qCcnt++;
3978 DRIVER_UNLOCK (megaCfg);
3980 } else if (megaCfg->flag & IN_RESET) {
3983 if (megaCfg->qCompletedH == NULL) {
3984 megaCfg->qCompletedH = megaCfg->qCompletedT = SCpnt;
3986 megaCfg->qCompletedT->host_scribble =
3988 megaCfg->qCompletedT = SCpnt;
3990 megaCfg->qCompletedT->host_scribble = (unsigned char *) NULL;
3991 megaCfg->qCcnt++;
3993 DRIVER_UNLOCK (megaCfg);
3997 megaCfg->flag |= IN_QUEUE;
3999 if ((pScb = mega_build_cmd (megaCfg, SCpnt)) != NULL) {
4006 if( ! megaCfg->quiescent ) {
4008 if (megaCfg->qPendingH == NULL) {
4009 megaCfg->qPendingH = megaCfg->qPendingT = pScb;
4011 megaCfg->qPendingT->next = pScb;
4012 megaCfg->qPendingT = pScb;
4014 megaCfg->qPendingT->next = NULL;
4015 megaCfg->qPcnt++;
4017 if (mega_runpendq (megaCfg) == -1) {
4018 DRIVER_UNLOCK (megaCfg);
4024 if (megaCfg->int_qh == NULL) {
4025 megaCfg->int_qh = megaCfg->int_qt = pScb;
4027 megaCfg->int_qt->next = pScb;
4028 megaCfg->int_qt = pScb;
4030 megaCfg->int_qt->next = NULL;
4031 megaCfg->int_qlen++;
4046 DRIVER_LOCK (megaCfg);
4049 mega_cmd_done (megaCfg, pScb, pScb->SCpnt->result);
4050 mega_rundoneq (megaCfg);
4051 mega_runpendq (megaCfg);
4052 DRIVER_UNLOCK (megaCfg);
4055 megaCfg->flag &= ~IN_QUEUE;
4059 DRIVER_UNLOCK (megaCfg);
4099 mega_host_config *megaCfg; local
4105 megaCfg = (mega_host_config *) SCpnt->host->hostdata;
4107 megaCfg->flag |= IN_ABORT;
4109 for (pScb = megaCfg->qPendingH; pScb; pScb = pScb->next) {
4138 mega_freeSCB (megaCfg, pScb);
4140 if (megaCfg->qCompletedH == NULL) {
4141 megaCfg->qCompletedH =
4142 megaCfg->qCompletedT = SCpnt;
4144 megaCfg->qCompletedT->host_scribble =
4146 megaCfg->qCompletedT = SCpnt;
4148 megaCfg->qCompletedT->host_scribble =
4150 megaCfg->qCcnt++;
4163 megaCfg->flag &= ~IN_ABORT;
4166 if (megaCfg->flag & IN_QUEUE)
4168 if (megaCfg->qCompletedH == NULL)
4177 if (megaCfg->qCompletedH) {
4178 SCpnt = megaCfg->qCompletedH;
4179 megaCfg->qCompletedH = (Scsi_Cmnd *) SCpnt->host_scribble;
4180 megaCfg->qCcnt--;
4186 mega_rundoneq (megaCfg);
4197 mega_host_config *megaCfg; local
4203 megaCfg = (mega_host_config *) SCpnt->host->hostdata;
4205 megaCfg->flag |= IN_RESET;
4219 for (idx = 0; idx < megaCfg->max_cmds; idx++) {
4220 if (megaCfg->scbList[idx].state != SCB_FREE) {
4221 SCpnt = megaCfg->scbList[idx].SCpnt;
4222 pScb = &megaCfg->scbList[idx];
4230 megaCfg->flag &= ~IN_RESET;
4232 mega_rundoneq (megaCfg);
4238 static int proc_printf (mega_host_config * megaCfg, const char *fmt, ...) argument
4243 if (megaCfg->procidx > PROCBUFSIZE)
4247 i = vsprintf ((megaCfg->procbuf + megaCfg->procidx), fmt, args);
4250 megaCfg->procidx += i;
4258 mega_host_config *megaCfg = (mega_host_config *) data; local
4262 if (megaCfg->productInfo.ProductName[0] != 0)
4263 proc_printf (megaCfg, "%s\n", megaCfg->productInfo.ProductName);
4265 proc_printf (megaCfg, "Controller Type: ");
4267 if (megaCfg->flag & BOARD_QUARTZ)
4268 proc_printf (megaCfg, "438/466/467/471/493\n");
4270 proc_printf (megaCfg, "418/428/434\n");
4272 if (megaCfg->flag & BOARD_40LD)
4273 proc_printf (megaCfg,
4276 if (megaCfg->flag & BOARD_64BIT)
4277 proc_printf (megaCfg,
4280 proc_printf (megaCfg, "Base = %08x, Irq = %d, ", megaCfg->base,
4281 megaCfg->host->irq);
4283 proc_printf (megaCfg, "Logical Drives = %d, Channels = %d\n",
4284 megaCfg->numldrv, megaCfg->productInfo.SCSIChanPresent);
4286 proc_printf (megaCfg, "Version =%s:%s, DRAM = %dMb\n",
4287 megaCfg->fwVer, megaCfg->biosVer,
4288 megaCfg->productInfo.DramSize);
4290 proc_printf (megaCfg,
4292 megaCfg->productInfo.MaxConcCmds, megaCfg->max_cmds);
4300 mega_host_config *megaCfg = (mega_host_config *) data; local
4304 proc_printf (megaCfg, "Statistical Information for this controller\n");
4305 proc_printf (megaCfg, "Interrupts Collected = %lu\n",
4306 megaCfg->nInterrupts);
4308 proc_printf (megaCfg, "INTERFACE DISABLED\n");
4313 for (i = 0; i < megaCfg->numldrv; i++) {
4314 proc_printf (megaCfg, "Logical Drive %d:\n", i);
4316 proc_printf (megaCfg,
4318 megaCfg->nReads[i], megaCfg->nWrites[i]);
4320 proc_printf (megaCfg,
4322 megaCfg->nReadBlocks[i], megaCfg->nWriteBlocks[i]);
4334 mega_host_config *megaCfg = (mega_host_config *) data; local
4337 proc_printf (megaCfg, "TBD\n");
4346 mega_host_config *megaCfg = (mega_host_config *) data; local
4347 volatile mega_mailbox *mbox = megaCfg->mbox;
4351 proc_printf (megaCfg, "Contents of Mail Box Structure\n");
4352 proc_printf (megaCfg, " Fw Command = 0x%02x\n", mbox->cmd);
4353 proc_printf (megaCfg, " Cmd Sequence = 0x%02x\n", mbox->cmdid);
4354 proc_printf (megaCfg, " No of Sectors= %04d\n", mbox->numsectors);
4355 proc_printf (megaCfg, " LBA = 0x%02x\n", mbox->lba);
4356 proc_printf (megaCfg, " DTA = 0x%08x\n", mbox->xferaddr);
4357 proc_printf (megaCfg, " Logical Drive= 0x%02x\n", mbox->logdrv);
4358 proc_printf (megaCfg, " No of SG Elmt= 0x%02x\n", mbox->numsgelements);
4359 proc_printf (megaCfg, " Busy = %01x\n", mbox->busy);
4360 proc_printf (megaCfg, " Status = 0x%02x\n", mbox->status);
4390 fxn, megaCfg)
4392 …ing, fxn) create_proc_read_entry(string,S_IRUSR | S_IFREG, controller_proc_dir_entry, fxn, megaCfg)
4398 read_proc_t * fxn, mega_host_config * megaCfg) argument
4415 temp->data = (void *) megaCfg;
4425 mega_host_config *megaCfg = megaCtlrs[index]; local
4432 megaCfg->controller_proc_dir_entry = proc_mkdir (string, parent);
4435 megaCfg->controller_proc_dir_entry =
4442 megaCfg->proc_read =
4444 megaCfg->proc_status =
4446 megaCfg->proc_stat = CREATE_READ_PROC ("stat", proc_read_stat);
4447 megaCfg->proc_mbox =
4467 mega_host_config *megaCfg; local
4470 megaCfg = (mega_host_config *) disk->device->host->hostdata;
4472 if( IS_RAID_CH(megaCfg, disk->device->channel)) {
4596 mega_host_config *megaCfg; local
4605 megaCfg = (mega_host_config *) pSHost->hostdata;
4615 free_irq (megaCfg->host->irq, megaCfg);
4621 megaIssueCmd (megaCfg, mboxData, NULL, 0);