Lines Matching +full:i +full:- +full:drive
1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * - fixes
10 * - speed-ups (list handling fixes, issued_list, optimizations.)
11 * - lots of cleanups.
14 * - new-style, hotplug-aware pci probing and scsi registration
16 * Version : v2.00.4 Mon Nov 14 14:02:43 EST 2005 - Seokmann Ju
26 * linux-scsi@vger.kernel.org .
44 #include <linux/dma-mapping.h>
72 MODULE_PARM_DESC(max_sectors_per_io, "Maximum number of sectors per I/O request (default=MAX_SECTOR…
79 #define RDINDOOR(adapter) readl((adapter)->mmio_base + 0x20)
80 #define RDOUTDOOR(adapter) readl((adapter)->mmio_base + 0x2C)
81 #define WRINDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x20)
82 #define WROUTDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x2C)
92 /* For controller re-ordering */
121 #define IS_RAID_CH(hba, ch) (((hba)->mega_ch_class >> (ch)) & 0x01)
140 adapter->una_mbox64 = dma_alloc_coherent(&adapter->dev->dev, in mega_setup_mailbox()
142 &adapter->una_mbox64_dma, in mega_setup_mailbox()
145 if( !adapter->una_mbox64 ) return -1; in mega_setup_mailbox()
147 adapter->mbox = &adapter->una_mbox64->mbox; in mega_setup_mailbox()
149 adapter->mbox = (mbox_t *)((((unsigned long) adapter->mbox) + 15) & in mega_setup_mailbox()
152 adapter->mbox64 = (mbox64_t *)(((unsigned long)adapter->mbox) - 8); in mega_setup_mailbox()
154 align = ((void *)adapter->mbox) - ((void *)&adapter->una_mbox64->mbox); in mega_setup_mailbox()
156 adapter->mbox_dma = adapter->una_mbox64_dma + 8 + align; in mega_setup_mailbox()
159 * Register the mailbox if the controller is an io-mapped controller in mega_setup_mailbox()
161 if( adapter->flag & BOARD_IOMAP ) { in mega_setup_mailbox()
163 outb(adapter->mbox_dma & 0xFF, in mega_setup_mailbox()
164 adapter->host->io_port + MBOX_PORT0); in mega_setup_mailbox()
166 outb((adapter->mbox_dma >> 8) & 0xFF, in mega_setup_mailbox()
167 adapter->host->io_port + MBOX_PORT1); in mega_setup_mailbox()
169 outb((adapter->mbox_dma >> 16) & 0xFF, in mega_setup_mailbox()
170 adapter->host->io_port + MBOX_PORT2); in mega_setup_mailbox()
172 outb((adapter->mbox_dma >> 24) & 0xFF, in mega_setup_mailbox()
173 adapter->host->io_port + MBOX_PORT3); in mega_setup_mailbox()
176 adapter->host->io_port + ENABLE_MBOX_REGION); in mega_setup_mailbox()
189 * @adapter - pointer to our soft state
205 memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE); in mega_query_adapter()
213 mbox.xferaddr = (u32)adapter->buf_dma_handle; in mega_query_adapter()
215 inquiry3 = (mega_inquiry3 *)adapter->mega_buffer; in mega_query_adapter()
217 raw_mbox[0] = FC_NEW_CONFIG; /* i.e. mbox->cmd=0xA1 */ in mega_query_adapter()
218 raw_mbox[2] = NC_SUBOP_ENQUIRY3; /* i.e. 0x0F */ in mega_query_adapter()
219 raw_mbox[3] = ENQ3_GET_SOLICITED_FULL; /* i.e. 0x02 */ in mega_query_adapter()
229 ext_inq = dma_alloc_coherent(&adapter->dev->dev, in mega_query_adapter()
233 if( ext_inq == NULL ) return -1; in mega_query_adapter()
235 inq = &ext_inq->raid_inq; in mega_query_adapter()
249 (mega_product_info *)&adapter->product_info); in mega_query_adapter()
251 dma_free_coherent(&adapter->dev->dev, in mega_query_adapter()
256 adapter->flag |= BOARD_40LD; in mega_query_adapter()
262 prod_info_dma_handle = dma_map_single(&adapter->dev->dev, in mega_query_adapter()
263 (void *)&adapter->product_info, in mega_query_adapter()
269 raw_mbox[0] = FC_NEW_CONFIG; /* i.e. mbox->cmd=0xA1 */ in mega_query_adapter()
270 raw_mbox[2] = NC_SUBOP_PRODUCT_INFO; /* i.e. 0x0E */ in mega_query_adapter()
273 dev_warn(&adapter->dev->dev, in mega_query_adapter()
277 dma_unmap_single(&adapter->dev->dev, prod_info_dma_handle, in mega_query_adapter()
285 adapter->host->max_channel = in mega_query_adapter()
286 adapter->product_info.nchannels + NVIRT_CHAN -1; in mega_query_adapter()
288 adapter->host->max_id = 16; /* max targets per channel */ in mega_query_adapter()
290 adapter->host->max_lun = 7; /* Up to 7 luns for non disk devices */ in mega_query_adapter()
292 adapter->host->cmd_per_lun = max_cmd_per_lun; in mega_query_adapter()
294 adapter->numldrv = inquiry3->num_ldrv; in mega_query_adapter()
296 adapter->max_cmds = adapter->product_info.max_commands; in mega_query_adapter()
298 if(adapter->max_cmds > MAX_COMMANDS) in mega_query_adapter()
299 adapter->max_cmds = MAX_COMMANDS; in mega_query_adapter()
301 adapter->host->can_queue = adapter->max_cmds - 1; in mega_query_adapter()
304 * Get the maximum number of scatter-gather elements supported by this in mega_query_adapter()
309 adapter->host->sg_tablesize = adapter->sglen; in mega_query_adapter()
315 if (adapter->product_info.subsysvid == PCI_VENDOR_ID_HP) { in mega_query_adapter()
316 snprintf(adapter->fw_version, sizeof(adapter->fw_version), in mega_query_adapter()
318 adapter->product_info.fw_version[2], in mega_query_adapter()
320 adapter->product_info.fw_version[1] & 0x0f, in mega_query_adapter()
322 adapter->product_info.fw_version[0] & 0x0f); in mega_query_adapter()
323 snprintf(adapter->bios_version, sizeof(adapter->fw_version), in mega_query_adapter()
325 adapter->product_info.bios_version[2], in mega_query_adapter()
327 adapter->product_info.bios_version[1] & 0x0f, in mega_query_adapter()
329 adapter->product_info.bios_version[0] & 0x0f); in mega_query_adapter()
331 memcpy(adapter->fw_version, in mega_query_adapter()
332 (char *)adapter->product_info.fw_version, 4); in mega_query_adapter()
333 adapter->fw_version[4] = 0; in mega_query_adapter()
335 memcpy(adapter->bios_version, in mega_query_adapter()
336 (char *)adapter->product_info.bios_version, 4); in mega_query_adapter()
338 adapter->bios_version[4] = 0; in mega_query_adapter()
341 dev_notice(&adapter->dev->dev, "[%s:%s] detected %d logical drives\n", in mega_query_adapter()
342 adapter->fw_version, adapter->bios_version, adapter->numldrv); in mega_query_adapter()
347 adapter->support_ext_cdb = mega_support_ext_cdb(adapter); in mega_query_adapter()
348 if (adapter->support_ext_cdb) in mega_query_adapter()
349 dev_notice(&adapter->dev->dev, "supports extended CDBs\n"); in mega_query_adapter()
364 if(!list_empty(&adapter->pending_list)) in mega_runpendq()
370 * @scmd - Issue this scsi command
371 * @done - the callback hook into the scsi mid-layer
373 * The command queuing entry point for the mid-layer.
382 adapter = (adapter_t *)scmd->device->host->hostdata; in megaraid_queue_lck()
387 * allocate scb. We will return non-zero status in that case. in megaraid_queue_lck()
393 spin_lock_irqsave(&adapter->lock, flags); in megaraid_queue_lck()
398 scb->state |= SCB_PENDQ; in megaraid_queue_lck()
399 list_add_tail(&scb->list, &adapter->pending_list); in megaraid_queue_lck()
403 * delete logical drive opertion. If it is, don't run in megaraid_queue_lck()
406 if (atomic_read(&adapter->quiescent) == 0) in megaraid_queue_lck()
411 spin_unlock_irqrestore(&adapter->lock, flags); in megaraid_queue_lck()
420 * @cmd: scsi command from the mid-layer in DEF_SCSI_QCMD()
428 struct list_head *head = &adapter->free_list; in DEF_SCSI_QCMD()
434 scb = list_entry(head->next, scb_t, list); in DEF_SCSI_QCMD()
436 list_del_init(head->next); in DEF_SCSI_QCMD()
438 scb->state = SCB_ACTIVE; in DEF_SCSI_QCMD()
439 scb->cmd = cmd; in DEF_SCSI_QCMD()
440 scb->dma_type = MEGA_DMA_TYPE_NONE; in DEF_SCSI_QCMD()
454 * Calculate the logical drive number based on the information in scsi command
463 tgt = cmd->device->id; in mega_get_ldrv_num()
465 if ( tgt > adapter->this_id ) in mega_get_ldrv_num()
466 tgt--; /* we do not get inquires for initiator id */ in mega_get_ldrv_num()
472 * If we have a logical drive with boot enabled, project it first in mega_get_ldrv_num()
474 if( adapter->boot_ldrv_enabled ) { in mega_get_ldrv_num()
476 ldrv_num = adapter->boot_ldrv; in mega_get_ldrv_num()
479 if( ldrv_num <= adapter->boot_ldrv ) { in mega_get_ldrv_num()
480 ldrv_num--; in mega_get_ldrv_num()
486 * If "delete logical drive" feature is enabled on this controller. in mega_get_ldrv_num()
487 * Do only if at least one delete logical drive operation was done. in mega_get_ldrv_num()
489 * Also, after logical drive deletion, instead of logical drive number, in mega_get_ldrv_num()
490 * the value returned should be 0x80+logical drive id. in mega_get_ldrv_num()
495 if (adapter->support_random_del && adapter->read_ldidmap ) in mega_get_ldrv_num()
496 switch (cmd->cmnd[0]) { in mega_get_ldrv_num()
514 * also finds out if the commands is intended for a logical drive or a
517 * We also re-order the logical drives and physical devices based on their
531 int ldrv_num = 0; /* logical drive number */ in mega_build_cmd()
534 * We know what channels our logical drives are on - mega_find_card() in mega_build_cmd()
536 islogical = adapter->logdrv_chan[cmd->device->channel]; in mega_build_cmd()
539 * The theory: If physical drive is chosen for boot, all the physical in mega_build_cmd()
541 * devices are pushed after logical drives, in which case - Kernel sees in mega_build_cmd()
545 if( adapter->boot_pdrv_enabled ) { in mega_build_cmd()
548 channel = cmd->device->channel - in mega_build_cmd()
549 adapter->product_info.nchannels; in mega_build_cmd()
553 channel = cmd->device->channel; in mega_build_cmd()
554 target = cmd->device->id; in mega_build_cmd()
562 target = adapter->boot_pdrv_tgt; in mega_build_cmd()
564 else if( target == adapter->boot_pdrv_tgt ) { in mega_build_cmd()
572 channel = cmd->device->channel; in mega_build_cmd()
576 channel = cmd->device->channel - NVIRT_CHAN; in mega_build_cmd()
577 target = cmd->device->id; in mega_build_cmd()
585 if (cmd->device->lun) { in mega_build_cmd()
586 cmd->result = (DID_BAD_TARGET << 16); in mega_build_cmd()
594 max_ldrv_num = (adapter->flag & BOARD_40LD) ? in mega_build_cmd()
598 * max_ldrv_num increases by 0x80 if some logical drive was in mega_build_cmd()
601 if(adapter->read_ldidmap) in mega_build_cmd()
605 cmd->result = (DID_BAD_TARGET << 16); in mega_build_cmd()
612 if( cmd->device->lun > 7) { in mega_build_cmd()
617 cmd->result = (DID_BAD_TARGET << 16); in mega_build_cmd()
625 * Logical drive commands in mega_build_cmd()
629 switch (cmd->cmnd[0]) { in mega_build_cmd()
636 if( !adapter->has_cluster ) { in mega_build_cmd()
637 cmd->result = (DID_OK << 16); in mega_build_cmd()
647 scb->raw_mbox[0] = MEGA_CLUSTER_CMD; in mega_build_cmd()
648 scb->raw_mbox[2] = MEGA_RESERVATION_STATUS; in mega_build_cmd()
649 scb->raw_mbox[3] = ldrv_num; in mega_build_cmd()
651 scb->dma_direction = DMA_NONE; in mega_build_cmd()
655 cmd->result = (DID_OK << 16); in mega_build_cmd()
665 buf = kmap_atomic(sg_page(sg)) + sg->offset; in mega_build_cmd()
667 memset(buf, 0, cmd->cmnd[4]); in mega_build_cmd()
668 kunmap_atomic(buf - sg->offset); in mega_build_cmd()
670 cmd->result = (DID_OK << 16); in mega_build_cmd()
678 if(!(adapter->flag & (1L << cmd->device->channel))) { in mega_build_cmd()
680 dev_notice(&adapter->dev->dev, in mega_build_cmd()
683 adapter->host->host_no, in mega_build_cmd()
684 cmd->device->channel); in mega_build_cmd()
686 adapter->flag |= (1L << cmd->device->channel); in mega_build_cmd()
694 pthru = scb->pthru; in mega_build_cmd()
696 mbox = (mbox_t *)scb->raw_mbox; in mega_build_cmd()
697 memset(mbox, 0, sizeof(scb->raw_mbox)); in mega_build_cmd()
700 pthru->timeout = 0; in mega_build_cmd()
701 pthru->ars = 1; in mega_build_cmd()
702 pthru->reqsenselen = 14; in mega_build_cmd()
703 pthru->islogical = 1; in mega_build_cmd()
704 pthru->logdrv = ldrv_num; in mega_build_cmd()
705 pthru->cdblen = cmd->cmd_len; in mega_build_cmd()
706 memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len); in mega_build_cmd()
708 if( adapter->has_64bit_addr ) { in mega_build_cmd()
709 mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU64; in mega_build_cmd()
712 mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU; in mega_build_cmd()
715 scb->dma_direction = DMA_FROM_DEVICE; in mega_build_cmd()
717 pthru->numsgelements = mega_build_sglist(adapter, scb, in mega_build_cmd()
718 &pthru->dataxferaddr, &pthru->dataxferlen); in mega_build_cmd()
720 mbox->m_out.xferaddr = scb->pthru_dma_addr; in mega_build_cmd()
736 mbox = (mbox_t *)scb->raw_mbox; in mega_build_cmd()
738 memset(mbox, 0, sizeof(scb->raw_mbox)); in mega_build_cmd()
739 mbox->m_out.logdrv = ldrv_num; in mega_build_cmd()
745 if( adapter->has_64bit_addr ) { in mega_build_cmd()
746 mbox->m_out.cmd = (*cmd->cmnd & 0x02) ? in mega_build_cmd()
751 mbox->m_out.cmd = (*cmd->cmnd & 0x02) ? in mega_build_cmd()
757 * 6-byte READ(0x08) or WRITE(0x0A) cdb in mega_build_cmd()
759 if( cmd->cmd_len == 6 ) { in mega_build_cmd()
760 mbox->m_out.numsectors = (u32) cmd->cmnd[4]; in mega_build_cmd()
761 mbox->m_out.lba = in mega_build_cmd()
762 ((u32)cmd->cmnd[1] << 16) | in mega_build_cmd()
763 ((u32)cmd->cmnd[2] << 8) | in mega_build_cmd()
764 (u32)cmd->cmnd[3]; in mega_build_cmd()
766 mbox->m_out.lba &= 0x1FFFFF; in mega_build_cmd()
770 * Take modulo 0x80, since the logical drive in mega_build_cmd()
772 * drive was deleted in mega_build_cmd()
774 if (*cmd->cmnd == READ_6) { in mega_build_cmd()
775 adapter->nreads[ldrv_num%0x80]++; in mega_build_cmd()
776 adapter->nreadblocks[ldrv_num%0x80] += in mega_build_cmd()
777 mbox->m_out.numsectors; in mega_build_cmd()
779 adapter->nwrites[ldrv_num%0x80]++; in mega_build_cmd()
780 adapter->nwriteblocks[ldrv_num%0x80] += in mega_build_cmd()
781 mbox->m_out.numsectors; in mega_build_cmd()
787 * 10-byte READ(0x28) or WRITE(0x2A) cdb in mega_build_cmd()
789 if( cmd->cmd_len == 10 ) { in mega_build_cmd()
790 mbox->m_out.numsectors = in mega_build_cmd()
791 (u32)cmd->cmnd[8] | in mega_build_cmd()
792 ((u32)cmd->cmnd[7] << 8); in mega_build_cmd()
793 mbox->m_out.lba = in mega_build_cmd()
794 ((u32)cmd->cmnd[2] << 24) | in mega_build_cmd()
795 ((u32)cmd->cmnd[3] << 16) | in mega_build_cmd()
796 ((u32)cmd->cmnd[4] << 8) | in mega_build_cmd()
797 (u32)cmd->cmnd[5]; in mega_build_cmd()
800 if (*cmd->cmnd == READ_10) { in mega_build_cmd()
801 adapter->nreads[ldrv_num%0x80]++; in mega_build_cmd()
802 adapter->nreadblocks[ldrv_num%0x80] += in mega_build_cmd()
803 mbox->m_out.numsectors; in mega_build_cmd()
805 adapter->nwrites[ldrv_num%0x80]++; in mega_build_cmd()
806 adapter->nwriteblocks[ldrv_num%0x80] += in mega_build_cmd()
807 mbox->m_out.numsectors; in mega_build_cmd()
813 * 12-byte READ(0xA8) or WRITE(0xAA) cdb in mega_build_cmd()
815 if( cmd->cmd_len == 12 ) { in mega_build_cmd()
816 mbox->m_out.lba = in mega_build_cmd()
817 ((u32)cmd->cmnd[2] << 24) | in mega_build_cmd()
818 ((u32)cmd->cmnd[3] << 16) | in mega_build_cmd()
819 ((u32)cmd->cmnd[4] << 8) | in mega_build_cmd()
820 (u32)cmd->cmnd[5]; in mega_build_cmd()
822 mbox->m_out.numsectors = in mega_build_cmd()
823 ((u32)cmd->cmnd[6] << 24) | in mega_build_cmd()
824 ((u32)cmd->cmnd[7] << 16) | in mega_build_cmd()
825 ((u32)cmd->cmnd[8] << 8) | in mega_build_cmd()
826 (u32)cmd->cmnd[9]; in mega_build_cmd()
829 if (*cmd->cmnd == READ_12) { in mega_build_cmd()
830 adapter->nreads[ldrv_num%0x80]++; in mega_build_cmd()
831 adapter->nreadblocks[ldrv_num%0x80] += in mega_build_cmd()
832 mbox->m_out.numsectors; in mega_build_cmd()
834 adapter->nwrites[ldrv_num%0x80]++; in mega_build_cmd()
835 adapter->nwriteblocks[ldrv_num%0x80] += in mega_build_cmd()
836 mbox->m_out.numsectors; in mega_build_cmd()
844 if( (*cmd->cmnd & 0x0F) == 0x08 ) { in mega_build_cmd()
845 scb->dma_direction = DMA_FROM_DEVICE; in mega_build_cmd()
848 scb->dma_direction = DMA_TO_DEVICE; in mega_build_cmd()
851 /* Calculate Scatter-Gather info */ in mega_build_cmd()
852 mbox->m_out.numsgelements = mega_build_sglist(adapter, scb, in mega_build_cmd()
853 (u32 *)&mbox->m_out.xferaddr, &seg); in mega_build_cmd()
864 if( ! adapter->has_cluster ) { in mega_build_cmd()
866 cmd->result = (DID_BAD_TARGET << 16); in mega_build_cmd()
877 scb->raw_mbox[0] = MEGA_CLUSTER_CMD; in mega_build_cmd()
878 scb->raw_mbox[2] = ( *cmd->cmnd == RESERVE ) ? in mega_build_cmd()
881 scb->raw_mbox[3] = ldrv_num; in mega_build_cmd()
883 scb->dma_direction = DMA_NONE; in mega_build_cmd()
889 cmd->result = (DID_BAD_TARGET << 16); in mega_build_cmd()
896 * Passthru drive commands in mega_build_cmd()
905 mbox = (mbox_t *)scb->raw_mbox; in mega_build_cmd()
906 memset(mbox, 0, sizeof(scb->raw_mbox)); in mega_build_cmd()
908 if( adapter->support_ext_cdb ) { in mega_build_cmd()
913 mbox->m_out.cmd = MEGA_MBOXCMD_EXTPTHRU; in mega_build_cmd()
915 mbox->m_out.xferaddr = scb->epthru_dma_addr; in mega_build_cmd()
924 if( adapter->has_64bit_addr ) { in mega_build_cmd()
925 mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU64; in mega_build_cmd()
928 mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU; in mega_build_cmd()
931 mbox->m_out.xferaddr = scb->pthru_dma_addr; in mega_build_cmd()
944 * @cmd: scsi command from the mid-layer
956 pthru = scb->pthru; in mega_prepare_passthru()
960 pthru->timeout = 2; in mega_prepare_passthru()
962 pthru->ars = 1; in mega_prepare_passthru()
963 pthru->reqsenselen = 14; in mega_prepare_passthru()
964 pthru->islogical = 0; in mega_prepare_passthru()
966 pthru->channel = (adapter->flag & BOARD_40LD) ? 0 : channel; in mega_prepare_passthru()
968 pthru->target = (adapter->flag & BOARD_40LD) ? in mega_prepare_passthru()
971 pthru->cdblen = cmd->cmd_len; in mega_prepare_passthru()
972 pthru->logdrv = cmd->device->lun; in mega_prepare_passthru()
974 memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len); in mega_prepare_passthru()
977 scb->dma_direction = DMA_BIDIRECTIONAL; in mega_prepare_passthru()
980 switch (cmd->cmnd[0]) { in mega_prepare_passthru()
983 if(!(adapter->flag & (1L << cmd->device->channel))) { in mega_prepare_passthru()
985 dev_notice(&adapter->dev->dev, in mega_prepare_passthru()
988 adapter->host->host_no, in mega_prepare_passthru()
989 cmd->device->channel, channel); in mega_prepare_passthru()
991 adapter->flag |= (1L << cmd->device->channel); in mega_prepare_passthru()
995 pthru->numsgelements = mega_build_sglist(adapter, scb, in mega_prepare_passthru()
996 &pthru->dataxferaddr, &pthru->dataxferlen); in mega_prepare_passthru()
1007 * @cmd: scsi command from the mid-layer
1021 epthru = scb->epthru; in mega_prepare_extpassthru()
1025 epthru->timeout = 2; in mega_prepare_extpassthru()
1027 epthru->ars = 1; in mega_prepare_extpassthru()
1028 epthru->reqsenselen = 14; in mega_prepare_extpassthru()
1029 epthru->islogical = 0; in mega_prepare_extpassthru()
1031 epthru->channel = (adapter->flag & BOARD_40LD) ? 0 : channel; in mega_prepare_extpassthru()
1032 epthru->target = (adapter->flag & BOARD_40LD) ? in mega_prepare_extpassthru()
1035 epthru->cdblen = cmd->cmd_len; in mega_prepare_extpassthru()
1036 epthru->logdrv = cmd->device->lun; in mega_prepare_extpassthru()
1038 memcpy(epthru->cdb, cmd->cmnd, cmd->cmd_len); in mega_prepare_extpassthru()
1041 scb->dma_direction = DMA_BIDIRECTIONAL; in mega_prepare_extpassthru()
1043 switch(cmd->cmnd[0]) { in mega_prepare_extpassthru()
1046 if(!(adapter->flag & (1L << cmd->device->channel))) { in mega_prepare_extpassthru()
1048 dev_notice(&adapter->dev->dev, in mega_prepare_extpassthru()
1051 adapter->host->host_no, in mega_prepare_extpassthru()
1052 cmd->device->channel, channel); in mega_prepare_extpassthru()
1054 adapter->flag |= (1L << cmd->device->channel); in mega_prepare_extpassthru()
1058 epthru->numsgelements = mega_build_sglist(adapter, scb, in mega_prepare_extpassthru()
1059 &epthru->dataxferaddr, &epthru->dataxferlen); in mega_prepare_extpassthru()
1073 list_for_each_safe(pos, next, &adapter->pending_list) { in __mega_runpendq()
1077 if( !(scb->state & SCB_ISSUED) ) { in __mega_runpendq()
1100 volatile mbox64_t *mbox64 = adapter->mbox64; in issue_scb()
1101 volatile mbox_t *mbox = adapter->mbox; in issue_scb()
1102 unsigned int i = 0; in issue_scb() local
1104 if(unlikely(mbox->m_in.busy)) { in issue_scb()
1107 i++; in issue_scb()
1108 } while( mbox->m_in.busy && (i < max_mbox_busy_wait) ); in issue_scb()
1110 if(mbox->m_in.busy) return -1; in issue_scb()
1114 memcpy((char *)&mbox->m_out, (char *)scb->raw_mbox, in issue_scb()
1117 mbox->m_out.cmdid = scb->idx; /* Set cmdid */ in issue_scb()
1118 mbox->m_in.busy = 1; /* Set busy */ in issue_scb()
1124 atomic_inc(&adapter->pend_cmds); in issue_scb()
1126 switch (mbox->m_out.cmd) { in issue_scb()
1131 mbox64->xfer_segment_lo = mbox->m_out.xferaddr; in issue_scb()
1132 mbox64->xfer_segment_hi = 0; in issue_scb()
1133 mbox->m_out.xferaddr = 0xFFFFFFFF; in issue_scb()
1136 mbox64->xfer_segment_lo = 0; in issue_scb()
1137 mbox64->xfer_segment_hi = 0; in issue_scb()
1143 scb->state |= SCB_ISSUED; in issue_scb()
1145 if( likely(adapter->flag & BOARD_MEMMAP) ) { in issue_scb()
1146 mbox->m_in.poll = 0; in issue_scb()
1147 mbox->m_in.ack = 0; in issue_scb()
1148 WRINDOOR(adapter, adapter->mbox_dma | 0x1); in issue_scb()
1164 if (adapter->mbox->m_in.busy) in mega_busywait_mbox()
1174 * Issue a scb in synchronous and non-interrupt mode
1179 volatile mbox64_t *mbox64 = adapter->mbox64; in issue_scb_block()
1180 volatile mbox_t *mbox = adapter->mbox; in issue_scb_block()
1189 mbox->m_out.cmdid = 0xFE; in issue_scb_block()
1190 mbox->m_in.busy = 1; in issue_scb_block()
1197 mbox64->xfer_segment_lo = mbox->m_out.xferaddr; in issue_scb_block()
1198 mbox64->xfer_segment_hi = 0; in issue_scb_block()
1199 mbox->m_out.xferaddr = 0xFFFFFFFF; in issue_scb_block()
1202 mbox64->xfer_segment_lo = 0; in issue_scb_block()
1203 mbox64->xfer_segment_hi = 0; in issue_scb_block()
1206 if( likely(adapter->flag & BOARD_MEMMAP) ) { in issue_scb_block()
1207 mbox->m_in.poll = 0; in issue_scb_block()
1208 mbox->m_in.ack = 0; in issue_scb_block()
1209 mbox->m_in.numstatus = 0xFF; in issue_scb_block()
1210 mbox->m_in.status = 0xFF; in issue_scb_block()
1211 WRINDOOR(adapter, adapter->mbox_dma | 0x1); in issue_scb_block()
1213 while((volatile u8)mbox->m_in.numstatus == 0xFF) in issue_scb_block()
1216 mbox->m_in.numstatus = 0xFF; in issue_scb_block()
1218 while( (volatile u8)mbox->m_in.poll != 0x77 ) in issue_scb_block()
1221 mbox->m_in.poll = 0; in issue_scb_block()
1222 mbox->m_in.ack = 0x77; in issue_scb_block()
1224 WRINDOOR(adapter, adapter->mbox_dma | 0x2); in issue_scb_block()
1241 return mbox->m_in.status; in issue_scb_block()
1244 dev_warn(&adapter->dev->dev, "Blocked mailbox......!!\n"); in issue_scb_block()
1246 return -1; in issue_scb_block()
1255 * Interrupt service routine for io-mapped controllers.
1274 spin_lock_irqsave(&adapter->lock, flags); in megaraid_isr_iomapped()
1287 while((nstatus = (volatile u8)adapter->mbox->m_in.numstatus) in megaraid_isr_iomapped()
1290 adapter->mbox->m_in.numstatus = 0xFF; in megaraid_isr_iomapped()
1292 status = adapter->mbox->m_in.status; in megaraid_isr_iomapped()
1297 atomic_sub(nstatus, &adapter->pend_cmds); in megaraid_isr_iomapped()
1299 memcpy(completed, (void *)adapter->mbox->m_in.completed, in megaraid_isr_iomapped()
1312 if(atomic_read(&adapter->quiescent) == 0) { in megaraid_isr_iomapped()
1320 spin_unlock_irqrestore(&adapter->lock, flags); in megaraid_isr_iomapped()
1331 * Interrupt service routine for memory-mapped controllers.
1350 spin_lock_irqsave(&adapter->lock, flags); in megaraid_isr_memmapped()
1363 while((nstatus = (volatile u8)adapter->mbox->m_in.numstatus) in megaraid_isr_memmapped()
1367 adapter->mbox->m_in.numstatus = 0xFF; in megaraid_isr_memmapped()
1369 status = adapter->mbox->m_in.status; in megaraid_isr_memmapped()
1374 atomic_sub(nstatus, &adapter->pend_cmds); in megaraid_isr_memmapped()
1376 memcpy(completed, (void *)adapter->mbox->m_in.completed, in megaraid_isr_memmapped()
1392 if(atomic_read(&adapter->quiescent) == 0) { in megaraid_isr_memmapped()
1400 spin_unlock_irqrestore(&adapter->lock, flags); in megaraid_isr_memmapped()
1411 * Complete the commands and call the scsi mid-layer callback hooks.
1425 int i; in mega_cmd_done() local
1428 * for all the commands completed, call the mid-layer callback routine in mega_cmd_done()
1431 for( i = 0; i < nstatus; i++ ) { in mega_cmd_done()
1433 cmdid = completed[i]; in mega_cmd_done()
1437 * mid-layer, not for which were issued internally in mega_cmd_done()
1443 scb = &adapter->int_scb; in mega_cmd_done()
1444 cmd = scb->cmd; in mega_cmd_done()
1446 list_del_init(&scb->list); in mega_cmd_done()
1447 scb->state = SCB_FREE; in mega_cmd_done()
1449 adapter->int_status = status; in mega_cmd_done()
1450 complete(&adapter->int_waitq); in mega_cmd_done()
1452 scb = &adapter->scb_list[cmdid]; in mega_cmd_done()
1457 if( !(scb->state & SCB_ISSUED) || scb->cmd == NULL ) { in mega_cmd_done()
1458 dev_crit(&adapter->dev->dev, "invalid command " in mega_cmd_done()
1459 "Id %d, scb->state:%x, scsi cmd:%p\n", in mega_cmd_done()
1460 cmdid, scb->state, scb->cmd); in mega_cmd_done()
1468 if( scb->state & SCB_ABORT ) { in mega_cmd_done()
1470 dev_warn(&adapter->dev->dev, in mega_cmd_done()
1472 scb->idx); in mega_cmd_done()
1474 scb->cmd->result = (DID_ABORT << 16); in mega_cmd_done()
1476 list_add_tail(SCSI_LIST(scb->cmd), in mega_cmd_done()
1477 &adapter->completed_list); in mega_cmd_done()
1487 if( scb->state & SCB_RESET ) { in mega_cmd_done()
1489 dev_warn(&adapter->dev->dev, in mega_cmd_done()
1491 scb->idx); in mega_cmd_done()
1493 scb->cmd->result = (DID_RESET << 16); in mega_cmd_done()
1495 list_add_tail(SCSI_LIST(scb->cmd), in mega_cmd_done()
1496 &adapter->completed_list); in mega_cmd_done()
1503 cmd = scb->cmd; in mega_cmd_done()
1504 pthru = scb->pthru; in mega_cmd_done()
1505 epthru = scb->epthru; in mega_cmd_done()
1506 mbox = (mbox_t *)scb->raw_mbox; in mega_cmd_done()
1511 int logdrv = mbox->m_out.logdrv; in mega_cmd_done()
1513 islogical = adapter->logdrv_chan[cmd->channel]; in mega_cmd_done()
1515 * Maintain an error counter for the logical drive. in mega_cmd_done()
1519 if( status && islogical && (cmd->cmnd[0] == READ_6 || in mega_cmd_done()
1520 cmd->cmnd[0] == READ_10 || in mega_cmd_done()
1521 cmd->cmnd[0] == READ_12)) { in mega_cmd_done()
1523 * Logical drive number increases by 0x80 when in mega_cmd_done()
1524 * a logical drive is deleted in mega_cmd_done()
1526 adapter->rd_errors[logdrv%0x80]++; in mega_cmd_done()
1529 if( status && islogical && (cmd->cmnd[0] == WRITE_6 || in mega_cmd_done()
1530 cmd->cmnd[0] == WRITE_10 || in mega_cmd_done()
1531 cmd->cmnd[0] == WRITE_12)) { in mega_cmd_done()
1533 * Logical drive number increases by 0x80 when in mega_cmd_done()
1534 * a logical drive is deleted in mega_cmd_done()
1536 adapter->wr_errors[logdrv%0x80]++; in mega_cmd_done()
1546 * hard disk and not logical, request should return failure! - in mega_cmd_done()
1549 islogical = adapter->logdrv_chan[cmd->device->channel]; in mega_cmd_done()
1550 if( cmd->cmnd[0] == INQUIRY && !islogical ) { in mega_cmd_done()
1556 dev_warn(&adapter->dev->dev, "invalid sg\n"); in mega_cmd_done()
1560 if(IS_RAID_CH(adapter, cmd->device->channel) && in mega_cmd_done()
1567 cmd->result = 0; in mega_cmd_done()
1571 case 0x00: /* SUCCESS , i.e. SCSI_STATUS_GOOD */ in mega_cmd_done()
1572 cmd->result |= (DID_OK << 16); in mega_cmd_done()
1575 case 0x02: /* ERROR_ABORTED, i.e. in mega_cmd_done()
1579 if( mbox->m_out.cmd == MEGA_MBOXCMD_PASSTHRU || in mega_cmd_done()
1580 mbox->m_out.cmd == MEGA_MBOXCMD_PASSTHRU64 ) { in mega_cmd_done()
1582 memcpy(cmd->sense_buffer, pthru->reqsensearea, in mega_cmd_done()
1585 cmd->result = SAM_STAT_CHECK_CONDITION; in mega_cmd_done()
1588 if (mbox->m_out.cmd == MEGA_MBOXCMD_EXTPTHRU) { in mega_cmd_done()
1590 memcpy(cmd->sense_buffer, in mega_cmd_done()
1591 epthru->reqsensearea, 14); in mega_cmd_done()
1593 cmd->result = SAM_STAT_CHECK_CONDITION; in mega_cmd_done()
1600 case 0x08: /* ERR_DEST_DRIVE_FAILED, i.e. in mega_cmd_done()
1602 cmd->result |= (DID_BUS_BUSY << 16) | status; in mega_cmd_done()
1611 if( cmd->cmnd[0] == TEST_UNIT_READY ) { in mega_cmd_done()
1612 cmd->result |= (DID_ERROR << 16) | in mega_cmd_done()
1621 (cmd->cmnd[0] == RESERVE || in mega_cmd_done()
1622 cmd->cmnd[0] == RELEASE) ) { in mega_cmd_done()
1624 cmd->result |= (DID_ERROR << 16) | in mega_cmd_done()
1629 cmd->result |= (DID_BAD_TARGET << 16)|status; in mega_cmd_done()
1635 list_add_tail(SCSI_LIST(cmd), &adapter->completed_list); in mega_cmd_done()
1650 list_for_each_entry(cmd_priv, &adapter->completed_list, entry) in mega_rundoneq()
1653 INIT_LIST_HEAD(&adapter->completed_list); in mega_rundoneq()
1664 switch( scb->dma_type ) { in mega_free_scb()
1670 scsi_dma_unmap(scb->cmd); in mega_free_scb()
1679 list_del_init(&scb->list); in mega_free_scb()
1682 scb->state = SCB_FREE; in mega_free_scb()
1683 scb->cmd = NULL; in mega_free_scb()
1685 list_add(&scb->list, &adapter->free_list); in mega_free_scb()
1692 volatile mbox_t *mbox = adapter->mbox; in __mega_busywait_mbox()
1696 if (!mbox->m_in.busy) in __mega_busywait_mbox()
1701 return -1; /* give up after 1 second */ in __mega_busywait_mbox()
1716 cmd = scb->cmd; in mega_build_sglist()
1719 * Copy Scatter-Gather list info into controller structure. in mega_build_sglist()
1725 scb->dma_type = MEGA_SGLIST; in mega_build_sglist()
1727 BUG_ON(sgcnt > adapter->sglen || sgcnt < 0); in mega_build_sglist()
1731 if (scsi_sg_count(cmd) == 1 && !adapter->has_64bit_addr) { in mega_build_sglist()
1733 scb->dma_h_bulkdata = sg_dma_address(sg); in mega_build_sglist()
1734 *buf = (u32)scb->dma_h_bulkdata; in mega_build_sglist()
1740 if (adapter->has_64bit_addr) { in mega_build_sglist()
1741 scb->sgl64[idx].address = sg_dma_address(sg); in mega_build_sglist()
1742 *len += scb->sgl64[idx].length = sg_dma_len(sg); in mega_build_sglist()
1744 scb->sgl[idx].address = sg_dma_address(sg); in mega_build_sglist()
1745 *len += scb->sgl[idx].length = sg_dma_len(sg); in mega_build_sglist()
1750 *buf = scb->sgl_dma_addr; in mega_build_sglist()
1767 int i; in mega_8_to_40ld() local
1769 product_info->max_commands = inquiry->adapter_info.max_commands; in mega_8_to_40ld()
1770 enquiry3->rebuild_rate = inquiry->adapter_info.rebuild_rate; in mega_8_to_40ld()
1771 product_info->nchannels = inquiry->adapter_info.nchannels; in mega_8_to_40ld()
1773 for (i = 0; i < 4; i++) { in mega_8_to_40ld()
1774 product_info->fw_version[i] = in mega_8_to_40ld()
1775 inquiry->adapter_info.fw_version[i]; in mega_8_to_40ld()
1777 product_info->bios_version[i] = in mega_8_to_40ld()
1778 inquiry->adapter_info.bios_version[i]; in mega_8_to_40ld()
1780 enquiry3->cache_flush_interval = in mega_8_to_40ld()
1781 inquiry->adapter_info.cache_flush_interval; in mega_8_to_40ld()
1783 product_info->dram_size = inquiry->adapter_info.dram_size; in mega_8_to_40ld()
1785 enquiry3->num_ldrv = inquiry->logdrv_info.num_ldrv; in mega_8_to_40ld()
1787 for (i = 0; i < MAX_LOGICAL_DRIVES_8LD; i++) { in mega_8_to_40ld()
1788 enquiry3->ldrv_size[i] = inquiry->logdrv_info.ldrv_size[i]; in mega_8_to_40ld()
1789 enquiry3->ldrv_prop[i] = inquiry->logdrv_info.ldrv_prop[i]; in mega_8_to_40ld()
1790 enquiry3->ldrv_state[i] = inquiry->logdrv_info.ldrv_state[i]; in mega_8_to_40ld()
1793 for (i = 0; i < (MAX_PHYSICAL_DRIVES); i++) in mega_8_to_40ld()
1794 enquiry3->pdrv_state[i] = inquiry->pdrv_info.pdrv_state[i]; in mega_8_to_40ld()
1801 int i; in mega_free_sgl() local
1803 for(i = 0; i < adapter->max_cmds; i++) { in mega_free_sgl()
1805 scb = &adapter->scb_list[i]; in mega_free_sgl()
1807 if( scb->sgl64 ) { in mega_free_sgl()
1808 dma_free_coherent(&adapter->dev->dev, in mega_free_sgl()
1809 sizeof(mega_sgl64) * adapter->sglen, in mega_free_sgl()
1810 scb->sgl64, scb->sgl_dma_addr); in mega_free_sgl()
1812 scb->sgl64 = NULL; in mega_free_sgl()
1815 if( scb->pthru ) { in mega_free_sgl()
1816 dma_free_coherent(&adapter->dev->dev, in mega_free_sgl()
1817 sizeof(mega_passthru), scb->pthru, in mega_free_sgl()
1818 scb->pthru_dma_addr); in mega_free_sgl()
1820 scb->pthru = NULL; in mega_free_sgl()
1823 if( scb->epthru ) { in mega_free_sgl()
1824 dma_free_coherent(&adapter->dev->dev, in mega_free_sgl()
1826 scb->epthru, scb->epthru_dma_addr); in mega_free_sgl()
1828 scb->epthru = NULL; in mega_free_sgl()
1844 adapter = (adapter_t *)host->hostdata; in megaraid_info()
1848 adapter->fw_version, adapter->product_info.max_commands, in megaraid_info()
1849 adapter->host->max_id, adapter->host->max_channel, in megaraid_info()
1850 (u32)adapter->host->max_lun); in megaraid_info()
1864 adapter = (adapter_t *)cmd->device->host->hostdata; in megaraid_abort()
1885 adapter = (adapter_t *)cmd->device->host->hostdata; in megaraid_reset()
1892 dev_warn(&adapter->dev->dev, "reservation reset failed\n"); in megaraid_reset()
1895 dev_info(&adapter->dev->dev, "reservation reset\n"); in megaraid_reset()
1899 spin_lock_irq(&adapter->lock); in megaraid_reset()
1908 spin_unlock_irq(&adapter->lock); in megaraid_reset()
1929 dev_warn(&adapter->dev->dev, in megaraid_abort_and_reset()
1931 cmd->cmnd[0], cmd->device->channel, in megaraid_abort_and_reset()
1932 cmd->device->id, (u32)cmd->device->lun); in megaraid_abort_and_reset()
1934 dev_warn(&adapter->dev->dev, "RESETTING\n"); in megaraid_abort_and_reset()
1936 if(list_empty(&adapter->pending_list)) in megaraid_abort_and_reset()
1939 list_for_each_safe(pos, next, &adapter->pending_list) { in megaraid_abort_and_reset()
1943 if (!cmd || scb->cmd == cmd) { /* Found command */ in megaraid_abort_and_reset()
1945 scb->state |= aor; in megaraid_abort_and_reset()
1953 if( scb->state & SCB_ISSUED ) { in megaraid_abort_and_reset()
1955 dev_warn(&adapter->dev->dev, in megaraid_abort_and_reset()
1958 scb->idx); in megaraid_abort_and_reset()
1966 dev_warn(&adapter->dev->dev, in megaraid_abort_and_reset()
1967 "%s-[%x], driver owner\n", in megaraid_abort_and_reset()
1969 scb->idx); in megaraid_abort_and_reset()
1973 cmd->result = (DID_ABORT << 16); in megaraid_abort_and_reset()
1975 &adapter->completed_list); in megaraid_abort_and_reset()
1990 if( *pdev == NULL ) return -1; in make_local_pdev()
1992 memcpy(*pdev, adapter->dev, sizeof(struct pci_dev)); in make_local_pdev()
1994 if (dma_set_mask(&(*pdev)->dev, DMA_BIT_MASK(32)) != 0) { in make_local_pdev()
1996 return -1; in make_local_pdev()
2018 return dma_alloc_coherent(&pdev->dev, sizeof(mega_inquiry3), in mega_allocate_inquiry()
2026 dma_free_coherent(&pdev->dev, sizeof(mega_inquiry3), inquiry, in mega_free_inquiry()
2045 adapter_t *adapter = m->private; in proc_show_config()
2048 if(adapter->product_info.product_name[0]) in proc_show_config()
2049 seq_printf(m, "%s\n", adapter->product_info.product_name); in proc_show_config()
2053 if( adapter->flag & BOARD_MEMMAP ) in proc_show_config()
2058 if(adapter->flag & BOARD_40LD) in proc_show_config()
2061 if(adapter->flag & BOARD_64BIT) in proc_show_config()
2062 seq_puts(m, "Controller capable of 64-bit memory addressing\n"); in proc_show_config()
2063 if( adapter->has_64bit_addr ) in proc_show_config()
2064 seq_puts(m, "Controller using 64-bit memory addressing\n"); in proc_show_config()
2066 seq_puts(m, "Controller is not using 64-bit memory addressing\n"); in proc_show_config()
2069 adapter->base, adapter->host->irq); in proc_show_config()
2072 adapter->numldrv, adapter->product_info.nchannels); in proc_show_config()
2075 adapter->fw_version, adapter->bios_version, in proc_show_config()
2076 adapter->product_info.dram_size); in proc_show_config()
2079 adapter->product_info.max_commands, adapter->max_cmds); in proc_show_config()
2081 seq_printf(m, "support_ext_cdb = %d\n", adapter->support_ext_cdb); in proc_show_config()
2082 seq_printf(m, "support_random_del = %d\n", adapter->support_random_del); in proc_show_config()
2083 seq_printf(m, "boot_ldrv_enabled = %d\n", adapter->boot_ldrv_enabled); in proc_show_config()
2084 seq_printf(m, "boot_ldrv = %d\n", adapter->boot_ldrv); in proc_show_config()
2085 seq_printf(m, "boot_pdrv_enabled = %d\n", adapter->boot_pdrv_enabled); in proc_show_config()
2086 seq_printf(m, "boot_pdrv_ch = %d\n", adapter->boot_pdrv_ch); in proc_show_config()
2087 seq_printf(m, "boot_pdrv_tgt = %d\n", adapter->boot_pdrv_tgt); in proc_show_config()
2089 atomic_read(&adapter->quiescent)); in proc_show_config()
2090 seq_printf(m, "has_cluster = %d\n", adapter->has_cluster); in proc_show_config()
2103 * Display statistical information about the I/O activity.
2108 adapter_t *adapter = m->private; in proc_show_stat()
2110 int i; in proc_show_stat() local
2114 seq_printf(m, "pend_cmds = %d\n", atomic_read(&adapter->pend_cmds)); in proc_show_stat()
2116 for(i = 0; i < adapter->numldrv; i++) { in proc_show_stat()
2117 seq_printf(m, "Logical Drive %d:\n", i); in proc_show_stat()
2119 adapter->nreads[i], adapter->nwrites[i]); in proc_show_stat()
2121 adapter->nreadblocks[i], adapter->nwriteblocks[i]); in proc_show_stat()
2123 adapter->rd_errors[i], adapter->wr_errors[i]); in proc_show_stat()
2143 adapter_t *adapter = m->private; in proc_show_mbox()
2144 volatile mbox_t *mbox = adapter->mbox; in proc_show_mbox()
2147 seq_printf(m, " Fw Command = 0x%02x\n", mbox->m_out.cmd); in proc_show_mbox()
2148 seq_printf(m, " Cmd Sequence = 0x%02x\n", mbox->m_out.cmdid); in proc_show_mbox()
2149 seq_printf(m, " No of Sectors= %04d\n", mbox->m_out.numsectors); in proc_show_mbox()
2150 seq_printf(m, " LBA = 0x%02x\n", mbox->m_out.lba); in proc_show_mbox()
2151 seq_printf(m, " DTA = 0x%08x\n", mbox->m_out.xferaddr); in proc_show_mbox()
2152 seq_printf(m, " Logical Drive= 0x%02x\n", mbox->m_out.logdrv); in proc_show_mbox()
2153 seq_printf(m, " No of SG Elmt= 0x%02x\n", mbox->m_out.numsgelements); in proc_show_mbox()
2154 seq_printf(m, " Busy = %01x\n", mbox->m_in.busy); in proc_show_mbox()
2155 seq_printf(m, " Status = 0x%02x\n", mbox->m_in.status); in proc_show_mbox()
2170 adapter_t *adapter = m->private; in proc_show_rebuild_rate()
2183 dev_warn(&adapter->dev->dev, "inquiry failed\n"); in proc_show_rebuild_rate()
2187 if( adapter->flag & BOARD_40LD ) in proc_show_rebuild_rate()
2189 ((mega_inquiry3 *)inquiry)->rebuild_rate); in proc_show_rebuild_rate()
2193 inquiry)->raid_inq.adapter_info.rebuild_rate); in proc_show_rebuild_rate()
2213 adapter_t *adapter = m->private; in proc_show_battery()
2227 dev_warn(&adapter->dev->dev, "inquiry failed\n"); in proc_show_battery()
2231 if( adapter->flag & BOARD_40LD ) { in proc_show_battery()
2232 battery_status = ((mega_inquiry3 *)inquiry)->battery_status; in proc_show_battery()
2235 battery_status = ((mraid_ext_inquiry *)inquiry)-> in proc_show_battery()
2260 seq_puts(m, " Charge In-progress"); in proc_show_battery()
2284 int i; in mega_print_inquiry() local
2294 i = scsi_inq[0] & 0x1f; in mega_print_inquiry()
2295 seq_printf(m, " Type: %s ", scsi_device_type(i)); in mega_print_inquiry()
2326 int i; in proc_show_pdrv() local
2336 dev_warn(&adapter->dev->dev, "inquiry failed\n"); in proc_show_pdrv()
2341 scsi_inq = dma_alloc_coherent(&pdev->dev, 256, &scsi_inq_dma_handle, in proc_show_pdrv()
2348 if( adapter->flag & BOARD_40LD ) { in proc_show_pdrv()
2349 pdrv_state = ((mega_inquiry3 *)inquiry)->pdrv_state; in proc_show_pdrv()
2352 pdrv_state = ((mraid_ext_inquiry *)inquiry)-> in proc_show_pdrv()
2356 max_channels = adapter->product_info.nchannels; in proc_show_pdrv()
2364 i = channel*16 + tgt; in proc_show_pdrv()
2366 state = *(pdrv_state + i); in proc_show_pdrv()
2389 seq_printf(m, "Channel:%2d Id:%2d State: Un-configured", in proc_show_pdrv()
2396 * only. Inquries for logical drives and non-disk in proc_show_pdrv()
2415 dma_free_coherent(&pdev->dev, 256, scsi_inq, scsi_inq_dma_handle); in proc_show_pdrv()
2433 return proc_show_pdrv(m, m->private, 0); in proc_show_pdrv_ch0()
2447 return proc_show_pdrv(m, m->private, 1); in proc_show_pdrv_ch1()
2461 return proc_show_pdrv(m, m->private, 2); in proc_show_pdrv_ch2()
2475 return proc_show_pdrv(m, m->private, 3); in proc_show_pdrv_ch3()
2483 * @start: starting logical drive to display
2484 * @end: ending logical drive to display
2502 int i; in proc_show_rdrv() local
2512 dev_warn(&adapter->dev->dev, "inquiry failed\n"); in proc_show_rdrv()
2518 if( adapter->flag & BOARD_40LD ) { in proc_show_rdrv()
2521 rdrv_state = ((mega_inquiry3 *)inquiry)->ldrv_state; in proc_show_rdrv()
2523 num_ldrv = ((mega_inquiry3 *)inquiry)->num_ldrv; in proc_show_rdrv()
2528 rdrv_state = ((mraid_ext_inquiry *)inquiry)-> in proc_show_rdrv()
2531 num_ldrv = ((mraid_ext_inquiry *)inquiry)-> in proc_show_rdrv()
2535 disk_array = dma_alloc_coherent(&pdev->dev, array_sz, in proc_show_rdrv()
2545 if( adapter->flag & BOARD_40LD ) { in proc_show_rdrv()
2567 for( i = start; i < ( (end+1 < num_ldrv) ? end+1 : num_ldrv ); i++ ) { in proc_show_rdrv()
2569 if( adapter->flag & BOARD_40LD ) { in proc_show_rdrv()
2571 &((disk_array_40ld *)disk_array)->ldrv[i].lparam; in proc_show_rdrv()
2575 &((disk_array_8ld *)disk_array)->ldrv[i].lparam; in proc_show_rdrv()
2580 * information about each logical drive. in proc_show_rdrv()
2582 seq_printf(m, "Logical drive:%2d:, ", i); in proc_show_rdrv()
2584 switch( rdrv_state[i] & 0x0F ) { in proc_show_rdrv()
2604 * for this logical drive. in proc_show_rdrv()
2606 if( (rdrv_state[i] & 0xF0) == 0x20 ) in proc_show_rdrv()
2607 seq_puts(m, ", check-consistency in progress"); in proc_show_rdrv()
2608 else if( (rdrv_state[i] & 0xF0) == 0x10 ) in proc_show_rdrv()
2613 seq_printf(m, "Span depth:%3d, ", lparam->span_depth); in proc_show_rdrv()
2614 seq_printf(m, "RAID level:%3d, ", lparam->level); in proc_show_rdrv()
2616 lparam->stripe_sz ? lparam->stripe_sz/2: 128); in proc_show_rdrv()
2617 seq_printf(m, "Row size:%3d\n", lparam->row_size); in proc_show_rdrv()
2620 switch(lparam->read_ahead) { in proc_show_rdrv()
2634 switch(lparam->write_mode) { in proc_show_rdrv()
2644 switch(lparam->direct_io) { in proc_show_rdrv()
2655 dma_free_coherent(&pdev->dev, array_sz, disk_array, in proc_show_rdrv()
2674 return proc_show_rdrv(m, m->private, 0, 9); in proc_show_rdrv_10()
2688 return proc_show_rdrv(m, m->private, 10, 19); in proc_show_rdrv_20()
2702 return proc_show_rdrv(m, m->private, 20, 29); in proc_show_rdrv_30()
2716 return proc_show_rdrv(m, m->private, 30, 39); in proc_show_rdrv_40()
2733 sprintf(string, "hba%d", adapter->host->host_no); in mega_create_proc_entry()
2736 dev_warn(&adapter->dev->dev, "proc_mkdir failed\n"); in mega_create_proc_entry()
2747 proc_create_single_data("rebuild-rate", S_IRUSR, dir, in mega_create_proc_entry()
2749 proc_create_single_data("battery-status", S_IRUSR, dir, in mega_create_proc_entry()
2751 proc_create_single_data("diskdrives-ch0", S_IRUSR, dir, in mega_create_proc_entry()
2753 proc_create_single_data("diskdrives-ch1", S_IRUSR, dir, in mega_create_proc_entry()
2755 proc_create_single_data("diskdrives-ch2", S_IRUSR, dir, in mega_create_proc_entry()
2757 proc_create_single_data("diskdrives-ch3", S_IRUSR, dir, in mega_create_proc_entry()
2759 proc_create_single_data("raiddrives-0-9", S_IRUSR, dir, in mega_create_proc_entry()
2761 proc_create_single_data("raiddrives-10-19", S_IRUSR, dir, in mega_create_proc_entry()
2763 proc_create_single_data("raiddrives-20-29", S_IRUSR, dir, in mega_create_proc_entry()
2765 proc_create_single_data("raiddrives-30-39", S_IRUSR, dir, in mega_create_proc_entry()
2792 adapter = (adapter_t *)sdev->host->hostdata; in megaraid_biosparam()
2794 if (IS_RAID_CH(adapter, sdev->channel)) { in megaraid_biosparam()
2819 dev_info(&adapter->dev->dev, in megaraid_biosparam()
2821 sdev->channel); in megaraid_biosparam()
2849 * scatter-gather list pointer, passthru and extended passthru structure
2856 int i; in mega_init_scb() local
2858 for( i = 0; i < adapter->max_cmds; i++ ) { in mega_init_scb()
2860 scb = &adapter->scb_list[i]; in mega_init_scb()
2862 scb->sgl64 = NULL; in mega_init_scb()
2863 scb->sgl = NULL; in mega_init_scb()
2864 scb->pthru = NULL; in mega_init_scb()
2865 scb->epthru = NULL; in mega_init_scb()
2868 for( i = 0; i < adapter->max_cmds; i++ ) { in mega_init_scb()
2870 scb = &adapter->scb_list[i]; in mega_init_scb()
2872 scb->idx = i; in mega_init_scb()
2874 scb->sgl64 = dma_alloc_coherent(&adapter->dev->dev, in mega_init_scb()
2875 sizeof(mega_sgl64) * adapter->sglen, in mega_init_scb()
2876 &scb->sgl_dma_addr, GFP_KERNEL); in mega_init_scb()
2878 scb->sgl = (mega_sglist *)scb->sgl64; in mega_init_scb()
2880 if( !scb->sgl ) { in mega_init_scb()
2881 dev_warn(&adapter->dev->dev, "RAID: Can't allocate sglist\n"); in mega_init_scb()
2883 return -1; in mega_init_scb()
2886 scb->pthru = dma_alloc_coherent(&adapter->dev->dev, in mega_init_scb()
2888 &scb->pthru_dma_addr, GFP_KERNEL); in mega_init_scb()
2890 if( !scb->pthru ) { in mega_init_scb()
2891 dev_warn(&adapter->dev->dev, "RAID: Can't allocate passthru\n"); in mega_init_scb()
2893 return -1; in mega_init_scb()
2896 scb->epthru = dma_alloc_coherent(&adapter->dev->dev, in mega_init_scb()
2898 &scb->epthru_dma_addr, GFP_KERNEL); in mega_init_scb()
2900 if( !scb->epthru ) { in mega_init_scb()
2901 dev_warn(&adapter->dev->dev, in mega_init_scb()
2904 return -1; in mega_init_scb()
2908 scb->dma_type = MEGA_DMA_TYPE_NONE; in mega_init_scb()
2915 scb->state = SCB_FREE; in mega_init_scb()
2916 scb->cmd = NULL; in mega_init_scb()
2917 list_add(&scb->list, &adapter->free_list); in mega_init_scb()
2938 if( !capable(CAP_SYS_ADMIN) ) return -EACCES; in megadev_open()
2980 return -EINVAL; in megadev_ioctl()
3000 return (-EFAULT); in megadev_ioctl()
3006 return (-EFAULT); in megadev_ioctl()
3021 return (-ENODEV); in megadev_ioctl()
3025 return (-EFAULT); in megadev_ioctl()
3035 return (-ENODEV); in megadev_ioctl()
3041 if( copy_from_user(&num_ldrv, &ustats->num_ldrv, sizeof(int)) ) in megadev_ioctl()
3042 return (-EFAULT); in megadev_ioctl()
3045 * Check for the validity of the logical drive number in megadev_ioctl()
3047 if( num_ldrv >= MAX_LOGICAL_DRIVES_40LD ) return -EINVAL; in megadev_ioctl()
3049 if( copy_to_user(ustats->nreads, adapter->nreads, in megadev_ioctl()
3051 return -EFAULT; in megadev_ioctl()
3053 if( copy_to_user(ustats->nreadblocks, adapter->nreadblocks, in megadev_ioctl()
3055 return -EFAULT; in megadev_ioctl()
3057 if( copy_to_user(ustats->nwrites, adapter->nwrites, in megadev_ioctl()
3059 return -EFAULT; in megadev_ioctl()
3061 if( copy_to_user(ustats->nwriteblocks, adapter->nwriteblocks, in megadev_ioctl()
3063 return -EFAULT; in megadev_ioctl()
3065 if( copy_to_user(ustats->rd_errors, adapter->rd_errors, in megadev_ioctl()
3067 return -EFAULT; in megadev_ioctl()
3069 if( copy_to_user(ustats->wr_errors, adapter->wr_errors, in megadev_ioctl()
3071 return -EFAULT; in megadev_ioctl()
3082 return (-ENODEV); in megadev_ioctl()
3087 * Deletion of logical drive is a special case. The adapter in megadev_ioctl()
3096 if( !adapter->support_random_del ) { in megadev_ioctl()
3097 dev_warn(&adapter->dev->dev, "logdrv " in megadev_ioctl()
3098 "delete on non-supporting F/W\n"); in megadev_ioctl()
3100 return (-EINVAL); in megadev_ioctl()
3117 * Reject extended passthru and 64-bit passthru in megadev_ioctl()
3122 dev_warn(&adapter->dev->dev, "rejected passthru\n"); in megadev_ioctl()
3124 return (-EINVAL); in megadev_ioctl()
3132 return -EIO; in megadev_ioctl()
3138 pthru = dma_alloc_coherent(&pdev->dev, in megadev_ioctl()
3144 return (-ENOMEM); in megadev_ioctl()
3150 upthru = (mega_passthru __user *)(unsigned long)MBOX(uioc)->xferaddr; in megadev_ioctl()
3158 dma_free_coherent(&pdev->dev, in megadev_ioctl()
3164 return (-EFAULT); in megadev_ioctl()
3170 if( pthru->dataxferlen ) { in megadev_ioctl()
3171 data = dma_alloc_coherent(&pdev->dev, in megadev_ioctl()
3172 pthru->dataxferlen, in megadev_ioctl()
3177 dma_free_coherent(&pdev->dev, in megadev_ioctl()
3184 return (-ENOMEM); in megadev_ioctl()
3191 uxferaddr = pthru->dataxferaddr; in megadev_ioctl()
3192 pthru->dataxferaddr = data_dma_hndl; in megadev_ioctl()
3197 * Is data coming down-stream in megadev_ioctl()
3199 if( pthru->dataxferlen && (uioc.flags & UIOC_WR) ) { in megadev_ioctl()
3204 pthru->dataxferlen) ) { in megadev_ioctl()
3205 rval = (-EFAULT); in megadev_ioctl()
3226 * Is data going up-stream in megadev_ioctl()
3228 if( pthru->dataxferlen && (uioc.flags & UIOC_RD) ) { in megadev_ioctl()
3230 pthru->dataxferlen) ) { in megadev_ioctl()
3231 rval = (-EFAULT); in megadev_ioctl()
3239 if (copy_to_user(upthru->reqsensearea, in megadev_ioctl()
3240 pthru->reqsensearea, 14)) in megadev_ioctl()
3241 rval = -EFAULT; in megadev_ioctl()
3244 if( pthru->dataxferlen ) { in megadev_ioctl()
3245 dma_free_coherent(&pdev->dev, in megadev_ioctl()
3246 pthru->dataxferlen, data, in megadev_ioctl()
3250 dma_free_coherent(&pdev->dev, sizeof(mega_passthru), in megadev_ioctl()
3264 data = dma_alloc_coherent(&pdev->dev, in megadev_ioctl()
3271 return (-ENOMEM); in megadev_ioctl()
3274 uxferaddr = MBOX(uioc)->xferaddr; in megadev_ioctl()
3278 * Is data coming down-stream in megadev_ioctl()
3287 dma_free_coherent(&pdev->dev, in megadev_ioctl()
3293 return (-EFAULT); in megadev_ioctl()
3310 dma_free_coherent(&pdev->dev, in megadev_ioctl()
3321 * Is data going up-stream in megadev_ioctl()
3327 rval = (-EFAULT); in megadev_ioctl()
3332 dma_free_coherent(&pdev->dev, uioc.xferlen, in megadev_ioctl()
3342 return (-EINVAL); in megadev_ioctl()
3387 return (-EFAULT); in mega_m_to_n()
3397 return -EINVAL; in mega_m_to_n()
3400 return (-EFAULT); in mega_m_to_n()
3411 return (-EFAULT); in mega_m_to_n()
3426 uioc->opcode = GET_DRIVER_VER; in mega_m_to_n()
3427 uioc->uioc_uaddr = uioc_mimd.data; in mega_m_to_n()
3431 uioc->opcode = GET_N_ADAP; in mega_m_to_n()
3432 uioc->uioc_uaddr = uioc_mimd.data; in mega_m_to_n()
3436 uioc->opcode = GET_ADAP_INFO; in mega_m_to_n()
3437 uioc->adapno = uioc_mimd.ui.fcs.adapno; in mega_m_to_n()
3438 uioc->uioc_uaddr = uioc_mimd.data; in mega_m_to_n()
3442 return(-EINVAL); in mega_m_to_n()
3450 uioc->opcode = MBOX_CMD; in mega_m_to_n()
3451 uioc->adapno = uioc_mimd.ui.fcs.adapno; in mega_m_to_n()
3453 memcpy(uioc->uioc_rmbox, uioc_mimd.mbox, 18); in mega_m_to_n()
3455 uioc->xferlen = uioc_mimd.ui.fcs.length; in mega_m_to_n()
3457 if( uioc_mimd.outlen ) uioc->flags = UIOC_RD; in mega_m_to_n()
3458 if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR; in mega_m_to_n()
3464 uioc->opcode = MBOX_CMD; in mega_m_to_n()
3465 uioc->adapno = uioc_mimd.ui.fcs.adapno; in mega_m_to_n()
3467 memcpy(uioc->uioc_rmbox, uioc_mimd.mbox, 18); in mega_m_to_n()
3472 uioc->xferlen = uioc_mimd.outlen > uioc_mimd.inlen ? in mega_m_to_n()
3475 if( uioc_mimd.outlen ) uioc->flags = UIOC_RD; in mega_m_to_n()
3476 if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR; in mega_m_to_n()
3481 return (-EINVAL); in mega_m_to_n()
3509 return -EFAULT; in mega_n_to_m()
3515 if( put_user(mc->status, (u8 __user *)&MBOX_P(uiocp)->status) ) in mega_n_to_m()
3516 return (-EFAULT); in mega_n_to_m()
3518 if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) { in mega_n_to_m()
3522 if (get_user(upthru, (mega_passthru __user * __user *)&umc->xferaddr)) in mega_n_to_m()
3523 return -EFAULT; in mega_n_to_m()
3525 if( put_user(mc->status, (u8 __user *)&upthru->scsistatus)) in mega_n_to_m()
3526 return (-EFAULT); in mega_n_to_m()
3532 if( put_user(mc->status, (u8 __user *)&uioc_mimd->mbox[17]) ) in mega_n_to_m()
3533 return (-EFAULT); in mega_n_to_m()
3535 if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) { in mega_n_to_m()
3537 umc = (megacmd_t __user *)uioc_mimd->mbox; in mega_n_to_m()
3539 if (get_user(upthru, (mega_passthru __user * __user *)&umc->xferaddr)) in mega_n_to_m()
3540 return (-EFAULT); in mega_n_to_m()
3542 if( put_user(mc->status, (u8 __user *)&upthru->scsistatus) ) in mega_n_to_m()
3543 return (-EFAULT); in mega_n_to_m()
3569 memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE); in mega_is_bios_enabled()
3571 mbox.xferaddr = (u32)adapter->buf_dma_handle; in mega_is_bios_enabled()
3578 return *(char *)adapter->mega_buffer; in mega_is_bios_enabled()
3588 * ROMB feature and non-disk devices.
3595 int i; in mega_enum_raid_scsi() local
3605 memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE); in mega_enum_raid_scsi()
3607 mbox.xferaddr = (u32)adapter->buf_dma_handle; in mega_enum_raid_scsi()
3610 * Non-ROMB firmware fail this command, so all channels in mega_enum_raid_scsi()
3613 adapter->mega_ch_class = 0xFF; in mega_enum_raid_scsi()
3616 adapter->mega_ch_class = *((char *)adapter->mega_buffer); in mega_enum_raid_scsi()
3620 for( i = 0; i < adapter->product_info.nchannels; i++ ) { in mega_enum_raid_scsi()
3621 if( (adapter->mega_ch_class >> i) & 0x01 ) { in mega_enum_raid_scsi()
3622 dev_info(&adapter->dev->dev, "channel[%d] is raid\n", in mega_enum_raid_scsi()
3623 i); in mega_enum_raid_scsi()
3626 dev_info(&adapter->dev->dev, "channel[%d] is scsi\n", in mega_enum_raid_scsi()
3627 i); in mega_enum_raid_scsi()
3639 * Find out which device is the boot device. Note, any logical drive or any
3651 int i; in mega_get_boot_drv() local
3658 memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE); in mega_get_boot_drv()
3660 mbox.xferaddr = (u32)adapter->buf_dma_handle; in mega_get_boot_drv()
3662 adapter->boot_ldrv_enabled = 0; in mega_get_boot_drv()
3663 adapter->boot_ldrv = 0; in mega_get_boot_drv()
3665 adapter->boot_pdrv_enabled = 0; in mega_get_boot_drv()
3666 adapter->boot_pdrv_ch = 0; in mega_get_boot_drv()
3667 adapter->boot_pdrv_tgt = 0; in mega_get_boot_drv()
3671 (struct private_bios_data *)adapter->mega_buffer; in mega_get_boot_drv()
3675 for (i = 0; i < 14; i++ ) { in mega_get_boot_drv()
3679 if (prv_bios_data->cksum == (u16)(0-cksum) ) { in mega_get_boot_drv()
3682 * If MSB is set, a physical drive is set as boot in mega_get_boot_drv()
3685 if( prv_bios_data->boot_drv & 0x80 ) { in mega_get_boot_drv()
3686 adapter->boot_pdrv_enabled = 1; in mega_get_boot_drv()
3687 boot_pdrv = prv_bios_data->boot_drv & 0x7F; in mega_get_boot_drv()
3688 adapter->boot_pdrv_ch = boot_pdrv / 16; in mega_get_boot_drv()
3689 adapter->boot_pdrv_tgt = boot_pdrv % 16; in mega_get_boot_drv()
3692 adapter->boot_ldrv_enabled = 1; in mega_get_boot_drv()
3693 adapter->boot_ldrv = prv_bios_data->boot_drv; in mega_get_boot_drv()
3757 * @logdrv: logical drive to be deleted
3759 * Delete the specified logical drive. It is the responsibility of the user
3773 atomic_set(&adapter->quiescent, 1); in mega_del_logdrv()
3779 while (atomic_read(&adapter->pend_cmds) > 0 || in mega_del_logdrv()
3780 !list_empty(&adapter->pending_list)) in mega_del_logdrv()
3785 spin_lock_irqsave(&adapter->lock, flags); in mega_del_logdrv()
3788 * If delete operation was successful, add 0x80 to the logical drive in mega_del_logdrv()
3791 if (adapter->read_ldidmap) { in mega_del_logdrv()
3793 list_for_each(pos, &adapter->pending_list) { in mega_del_logdrv()
3795 if (scb->pthru->logdrv < 0x80 ) in mega_del_logdrv()
3796 scb->pthru->logdrv += 0x80; in mega_del_logdrv()
3800 atomic_set(&adapter->quiescent, 0); in mega_del_logdrv()
3804 spin_unlock_irqrestore(&adapter->lock, flags); in mega_del_logdrv()
3826 dev_warn(&adapter->dev->dev, "Delete LD-%d failed", logdrv); in mega_do_del_logdrv()
3831 * After deleting first logical drive, the logical drives must be in mega_do_del_logdrv()
3832 * addressed by adding 0x80 to the logical drive id. in mega_do_del_logdrv()
3834 adapter->read_ldidmap = 1; in mega_do_del_logdrv()
3844 * Find out the maximum number of scatter-gather elements supported by this
3855 memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE); in mega_get_max_sgl()
3857 mbox.xferaddr = (u32)adapter->buf_dma_handle; in mega_get_max_sgl()
3867 adapter->sglen = MIN_SGLIST; in mega_get_max_sgl()
3870 adapter->sglen = *((char *)adapter->mega_buffer); in mega_get_max_sgl()
3876 if ( adapter->sglen > MAX_SGLIST ) in mega_get_max_sgl()
3877 adapter->sglen = MAX_SGLIST; in mega_get_max_sgl()
3898 memset((void *)adapter->mega_buffer, 0, MEGA_BUFFER_SIZE); in mega_support_cluster()
3900 mbox.xferaddr = (u32)adapter->buf_dma_handle; in mega_support_cluster()
3912 * Tell our id to mid-layer too. in mega_support_cluster()
3914 adapter->this_id = *(u32 *)adapter->mega_buffer; in mega_support_cluster()
3915 adapter->host->this_id = adapter->this_id; in mega_support_cluster()
3940 if( adapter->flag & BOARD_40LD ) { in mega_adapinq()
3952 return -1; in mega_adapinq()
3983 if( make_local_pdev(adapter, &pdev) != 0 ) return -1; in mega_internal_dev_inquiry()
3985 pthru = dma_alloc_coherent(&pdev->dev, sizeof(mega_passthru), in mega_internal_dev_inquiry()
3990 return -1; in mega_internal_dev_inquiry()
3993 pthru->timeout = 2; in mega_internal_dev_inquiry()
3994 pthru->ars = 1; in mega_internal_dev_inquiry()
3995 pthru->reqsenselen = 14; in mega_internal_dev_inquiry()
3996 pthru->islogical = 0; in mega_internal_dev_inquiry()
3998 pthru->channel = (adapter->flag & BOARD_40LD) ? 0 : ch; in mega_internal_dev_inquiry()
4000 pthru->target = (adapter->flag & BOARD_40LD) ? (ch << 4)|tgt : tgt; in mega_internal_dev_inquiry()
4002 pthru->cdblen = 6; in mega_internal_dev_inquiry()
4004 pthru->cdb[0] = INQUIRY; in mega_internal_dev_inquiry()
4005 pthru->cdb[1] = 0; in mega_internal_dev_inquiry()
4006 pthru->cdb[2] = 0; in mega_internal_dev_inquiry()
4007 pthru->cdb[3] = 0; in mega_internal_dev_inquiry()
4008 pthru->cdb[4] = 255; in mega_internal_dev_inquiry()
4009 pthru->cdb[5] = 0; in mega_internal_dev_inquiry()
4012 pthru->dataxferaddr = (u32)buf_dma_handle; in mega_internal_dev_inquiry()
4013 pthru->dataxferlen = 256; in mega_internal_dev_inquiry()
4022 dma_free_coherent(&pdev->dev, sizeof(mega_passthru), pthru, in mega_internal_dev_inquiry()
4041 * Note: parameter 'pthru' is null for non-passthru commands.
4053 * available command ids for the I/O commands. in mega_internal_command()
4055 mutex_lock(&adapter->int_mtx); in mega_internal_command()
4057 scb = &adapter->int_scb; in mega_internal_command()
4060 scb->idx = CMDID_INT_CMDS; in mega_internal_command()
4061 scb->state |= SCB_ACTIVE | SCB_PENDQ; in mega_internal_command()
4063 memcpy(scb->raw_mbox, mc, sizeof(megacmd_t)); in mega_internal_command()
4068 if (mc->cmd == MEGA_MBOXCMD_PASSTHRU) in mega_internal_command()
4069 scb->pthru = pthru; in mega_internal_command()
4071 spin_lock_irqsave(&adapter->lock, flags); in mega_internal_command()
4072 list_add_tail(&scb->list, &adapter->pending_list); in mega_internal_command()
4075 * delete logical drive opertion. If it is, don't run in mega_internal_command()
4078 if (atomic_read(&adapter->quiescent) == 0) in mega_internal_command()
4080 spin_unlock_irqrestore(&adapter->lock, flags); in mega_internal_command()
4082 wait_for_completion(&adapter->int_waitq); in mega_internal_command()
4084 mc->status = rval = adapter->int_status; in mega_internal_command()
4091 dev_info(&adapter->dev->dev, "cmd [%x, %x, %x] status:[%x]\n", in mega_internal_command()
4092 mc->cmd, mc->opcode, mc->subopcode, rval); in mega_internal_command()
4095 mutex_unlock(&adapter->int_mtx); in mega_internal_command()
4125 int irq, i, j; in megaraid_probe_one() local
4126 int error = -ENODEV; in megaraid_probe_one()
4135 pci_bus = pdev->bus->number; in megaraid_probe_one()
4136 pci_dev_func = pdev->devfn; in megaraid_probe_one()
4142 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { in megaraid_probe_one()
4148 if (pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ && in megaraid_probe_one()
4149 pdev->subsystem_device == 0xC000) in megaraid_probe_one()
4162 if (id->driver_data & BOARD_64BIT) in megaraid_probe_one()
4172 subsysvid = pdev->subsystem_vendor; in megaraid_probe_one()
4173 subsysid = pdev->subsystem_device; in megaraid_probe_one()
4175 dev_notice(&pdev->dev, "found 0x%4.04x:0x%4.04x\n", in megaraid_probe_one()
4176 id->vendor, id->device); in megaraid_probe_one()
4180 irq = pdev->irq; in megaraid_probe_one()
4187 dev_warn(&pdev->dev, "mem region busy!\n"); in megaraid_probe_one()
4193 dev_warn(&pdev->dev, "could not map hba memory\n"); in megaraid_probe_one()
4209 adapter = (adapter_t *)host->hostdata; in megaraid_probe_one()
4212 dev_notice(&pdev->dev, in megaraid_probe_one()
4214 host->host_no, mega_baseport, irq); in megaraid_probe_one()
4216 adapter->base = mega_baseport; in megaraid_probe_one()
4218 adapter->mmio_base = (void __iomem *) mega_baseport; in megaraid_probe_one()
4220 INIT_LIST_HEAD(&adapter->free_list); in megaraid_probe_one()
4221 INIT_LIST_HEAD(&adapter->pending_list); in megaraid_probe_one()
4222 INIT_LIST_HEAD(&adapter->completed_list); in megaraid_probe_one()
4224 adapter->flag = flag; in megaraid_probe_one()
4225 spin_lock_init(&adapter->lock); in megaraid_probe_one()
4227 host->cmd_per_lun = max_cmd_per_lun; in megaraid_probe_one()
4228 host->max_sectors = max_sectors_per_io; in megaraid_probe_one()
4230 adapter->dev = pdev; in megaraid_probe_one()
4231 adapter->host = host; in megaraid_probe_one()
4233 adapter->host->irq = irq; in megaraid_probe_one()
4236 adapter->host->base = tbase; in megaraid_probe_one()
4238 adapter->host->io_port = tbase; in megaraid_probe_one()
4239 adapter->host->n_io_port = 16; in megaraid_probe_one()
4242 adapter->host->unique_id = (pci_bus << 8) | pci_dev_func; in megaraid_probe_one()
4247 adapter->mega_buffer = dma_alloc_coherent(&adapter->dev->dev, in megaraid_probe_one()
4249 &adapter->buf_dma_handle, in megaraid_probe_one()
4251 if (!adapter->mega_buffer) { in megaraid_probe_one()
4252 dev_warn(&pdev->dev, "out of RAM\n"); in megaraid_probe_one()
4256 adapter->scb_list = kmalloc_array(MAX_COMMANDS, sizeof(scb_t), in megaraid_probe_one()
4258 if (!adapter->scb_list) { in megaraid_probe_one()
4259 dev_warn(&pdev->dev, "out of RAM\n"); in megaraid_probe_one()
4263 if (request_irq(irq, (adapter->flag & BOARD_MEMMAP) ? in megaraid_probe_one()
4266 dev_warn(&pdev->dev, "Couldn't register IRQ %d!\n", irq); in megaraid_probe_one()
4283 if (!strcmp(adapter->fw_version, "3.00") || in megaraid_probe_one()
4284 !strcmp(adapter->fw_version, "3.01")) { in megaraid_probe_one()
4286 dev_warn(&pdev->dev, in megaraid_probe_one()
4316 if (!strcmp(adapter->fw_version, "H01.07") || in megaraid_probe_one()
4317 !strcmp(adapter->fw_version, "H01.08") || in megaraid_probe_one()
4318 !strcmp(adapter->fw_version, "H01.09") ) { in megaraid_probe_one()
4319 dev_warn(&pdev->dev, in megaraid_probe_one()
4326 adapter->flag &= ~BOARD_64BIT; in megaraid_probe_one()
4341 * Find out if a logical drive is set as the boot drive. If in megaraid_probe_one()
4342 * there is one, will make that as the first logical drive. in megaraid_probe_one()
4343 * ROMB: Do we have to boot from a physical drive. Then all in megaraid_probe_one()
4350 if (adapter->boot_pdrv_enabled) { in megaraid_probe_one()
4351 j = adapter->product_info.nchannels; in megaraid_probe_one()
4352 for( i = 0; i < j; i++ ) in megaraid_probe_one()
4353 adapter->logdrv_chan[i] = 0; in megaraid_probe_one()
4354 for( i = j; i < NVIRT_CHAN + j; i++ ) in megaraid_probe_one()
4355 adapter->logdrv_chan[i] = 1; in megaraid_probe_one()
4357 for (i = 0; i < NVIRT_CHAN; i++) in megaraid_probe_one()
4358 adapter->logdrv_chan[i] = 1; in megaraid_probe_one()
4359 for (i = NVIRT_CHAN; i < MAX_CHANNELS+NVIRT_CHAN; i++) in megaraid_probe_one()
4360 adapter->logdrv_chan[i] = 0; in megaraid_probe_one()
4361 adapter->mega_ch_class <<= NVIRT_CHAN; in megaraid_probe_one()
4368 adapter->read_ldidmap = 0; /* set it after first logdrv in megaraid_probe_one()
4370 adapter->support_random_del = mega_support_random_del(adapter); in megaraid_probe_one()
4379 atomic_set(&adapter->pend_cmds, 0); in megaraid_probe_one()
4384 atomic_set(&adapter->quiescent, 0); in megaraid_probe_one()
4393 i = hba_count; in megaraid_probe_one()
4395 mcontroller[i].base = mega_baseport; in megaraid_probe_one()
4396 mcontroller[i].irq = irq; in megaraid_probe_one()
4397 mcontroller[i].numldrv = adapter->numldrv; in megaraid_probe_one()
4398 mcontroller[i].pcibus = pci_bus; in megaraid_probe_one()
4399 mcontroller[i].pcidev = id->device; in megaraid_probe_one()
4400 mcontroller[i].pcifun = PCI_FUNC (pci_dev_func); in megaraid_probe_one()
4401 mcontroller[i].pciid = -1; in megaraid_probe_one()
4402 mcontroller[i].pcivendor = id->vendor; in megaraid_probe_one()
4403 mcontroller[i].pcislot = PCI_SLOT(pci_dev_func); in megaraid_probe_one()
4404 mcontroller[i].uid = (pci_bus << 8) | pci_dev_func; in megaraid_probe_one()
4408 if ((adapter->flag & BOARD_64BIT) && (sizeof(dma_addr_t) == 8)) { in megaraid_probe_one()
4409 dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); in megaraid_probe_one()
4410 adapter->has_64bit_addr = 1; in megaraid_probe_one()
4412 dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in megaraid_probe_one()
4413 adapter->has_64bit_addr = 0; in megaraid_probe_one()
4416 mutex_init(&adapter->int_mtx); in megaraid_probe_one()
4417 init_completion(&adapter->int_waitq); in megaraid_probe_one()
4419 adapter->this_id = DEFAULT_INITIATOR_ID; in megaraid_probe_one()
4420 adapter->host->this_id = DEFAULT_INITIATOR_ID; in megaraid_probe_one()
4430 adapter->has_cluster = mega_support_cluster(adapter); in megaraid_probe_one()
4431 if (adapter->has_cluster) { in megaraid_probe_one()
4432 dev_notice(&pdev->dev, in megaraid_probe_one()
4434 adapter->this_id); in megaraid_probe_one()
4442 error = scsi_add_host(host, &pdev->dev); in megaraid_probe_one()
4451 dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t), in megaraid_probe_one()
4452 adapter->una_mbox64, adapter->una_mbox64_dma); in megaraid_probe_one()
4454 free_irq(adapter->host->irq, adapter); in megaraid_probe_one()
4456 kfree(adapter->scb_list); in megaraid_probe_one()
4458 dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE, in megaraid_probe_one()
4459 adapter->mega_buffer, adapter->buf_dma_handle); in megaraid_probe_one()
4481 int i; in __megaraid_shutdown() local
4484 memset(&mbox->m_out, 0, sizeof(raw_mbox)); in __megaraid_shutdown()
4487 free_irq(adapter->host->irq, adapter); in __megaraid_shutdown()
4493 memset(&mbox->m_out, 0, sizeof(raw_mbox)); in __megaraid_shutdown()
4499 if (atomic_read(&adapter->pend_cmds) > 0) in __megaraid_shutdown()
4500 dev_warn(&adapter->dev->dev, "pending commands!!\n"); in __megaraid_shutdown()
4506 for (i = 0; i <= 10; i++) in __megaraid_shutdown()
4514 adapter_t *adapter = (adapter_t *)host->hostdata; in megaraid_remove_one()
4522 if (adapter->flag & BOARD_MEMMAP) { in megaraid_remove_one()
4523 iounmap((void *)adapter->base); in megaraid_remove_one()
4524 release_mem_region(adapter->host->base, 128); in megaraid_remove_one()
4526 release_region(adapter->base, 16); in megaraid_remove_one()
4530 sprintf(buf, "hba%d", adapter->host->host_no); in megaraid_remove_one()
4533 dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE, in megaraid_remove_one()
4534 adapter->mega_buffer, adapter->buf_dma_handle); in megaraid_remove_one()
4535 kfree(adapter->scb_list); in megaraid_remove_one()
4536 dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t), in megaraid_remove_one()
4537 adapter->una_mbox64, adapter->una_mbox64_dma); in megaraid_remove_one()
4542 hba_count--; in megaraid_remove_one()
4549 adapter_t *adapter = (adapter_t *)host->hostdata; in megaraid_shutdown()