Lines Matching +full:mbox +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
8 * Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com>
34 return shost->max_channel - 1; in myrb_logical_channel()
39 const char *name; member
56 return entry[i].name; in myrb_devstate_name()
63 const char *name; member
80 return entry[i].name; in myrb_raidlevel_name()
86 * myrb_create_mempools - allocates auxiliary data structures
95 elem_size = cb->host->sg_tablesize * elem_align; in myrb_create_mempools()
96 cb->sg_pool = dma_pool_create("myrb_sg", &pdev->dev, in myrb_create_mempools()
98 if (cb->sg_pool == NULL) { in myrb_create_mempools()
99 shost_printk(KERN_ERR, cb->host, in myrb_create_mempools()
104 cb->dcdb_pool = dma_pool_create("myrb_dcdb", &pdev->dev, in myrb_create_mempools()
107 if (!cb->dcdb_pool) { in myrb_create_mempools()
108 dma_pool_destroy(cb->sg_pool); in myrb_create_mempools()
109 cb->sg_pool = NULL; in myrb_create_mempools()
110 shost_printk(KERN_ERR, cb->host, in myrb_create_mempools()
115 cb->work_q = alloc_ordered_workqueue("myrb_wq_%d", WQ_MEM_RECLAIM, in myrb_create_mempools()
116 cb->host->host_no); in myrb_create_mempools()
117 if (!cb->work_q) { in myrb_create_mempools()
118 dma_pool_destroy(cb->dcdb_pool); in myrb_create_mempools()
119 cb->dcdb_pool = NULL; in myrb_create_mempools()
120 dma_pool_destroy(cb->sg_pool); in myrb_create_mempools()
121 cb->sg_pool = NULL; in myrb_create_mempools()
122 shost_printk(KERN_ERR, cb->host, in myrb_create_mempools()
130 INIT_DELAYED_WORK(&cb->monitor_work, myrb_monitor); in myrb_create_mempools()
131 queue_delayed_work(cb->work_q, &cb->monitor_work, 1); in myrb_create_mempools()
137 * myrb_destroy_mempools - tears down the memory pools for the controller
141 cancel_delayed_work_sync(&cb->monitor_work); in myrb_destroy_mempools()
142 destroy_workqueue(cb->work_q); in myrb_destroy_mempools()
144 dma_pool_destroy(cb->sg_pool); in myrb_destroy_mempools()
145 dma_pool_destroy(cb->dcdb_pool); in myrb_destroy_mempools()
149 * myrb_reset_cmd - reset command block
153 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_reset_cmd() local
155 memset(mbox, 0, sizeof(union myrb_cmd_mbox)); in myrb_reset_cmd()
156 cmd_blk->status = 0; in myrb_reset_cmd()
160 * myrb_qcmd - queues command block for execution
164 void __iomem *base = cb->io_base; in myrb_qcmd()
165 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_qcmd() local
166 union myrb_cmd_mbox *next_mbox = cb->next_cmd_mbox; in myrb_qcmd()
168 cb->write_cmd_mbox(next_mbox, mbox); in myrb_qcmd()
169 if (cb->prev_cmd_mbox1->words[0] == 0 || in myrb_qcmd()
170 cb->prev_cmd_mbox2->words[0] == 0) in myrb_qcmd()
171 cb->get_cmd_mbox(base); in myrb_qcmd()
172 cb->prev_cmd_mbox2 = cb->prev_cmd_mbox1; in myrb_qcmd()
173 cb->prev_cmd_mbox1 = next_mbox; in myrb_qcmd()
174 if (++next_mbox > cb->last_cmd_mbox) in myrb_qcmd()
175 next_mbox = cb->first_cmd_mbox; in myrb_qcmd()
176 cb->next_cmd_mbox = next_mbox; in myrb_qcmd()
180 * myrb_exec_cmd - executes command block and waits for completion.
190 cmd_blk->completion = &cmpl; in myrb_exec_cmd()
192 spin_lock_irqsave(&cb->queue_lock, flags); in myrb_exec_cmd()
193 cb->qcmd(cb, cmd_blk); in myrb_exec_cmd()
194 spin_unlock_irqrestore(&cb->queue_lock, flags); in myrb_exec_cmd()
197 return cmd_blk->status; in myrb_exec_cmd()
201 * myrb_exec_type3 - executes a type 3 command and waits for completion.
208 struct myrb_cmdblk *cmd_blk = &cb->dcmd_blk; in myrb_exec_type3()
209 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_exec_type3() local
212 mutex_lock(&cb->dcmd_mutex); in myrb_exec_type3()
214 mbox->type3.id = MYRB_DCMD_TAG; in myrb_exec_type3()
215 mbox->type3.opcode = op; in myrb_exec_type3()
216 mbox->type3.addr = addr; in myrb_exec_type3()
218 mutex_unlock(&cb->dcmd_mutex); in myrb_exec_type3()
223 * myrb_exec_type3D - executes a type 3D command and waits for completion.
231 struct myrb_cmdblk *cmd_blk = &cb->dcmd_blk; in myrb_exec_type3D()
232 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_exec_type3D() local
236 pdev_info_addr = dma_map_single(&cb->pdev->dev, pdev_info, in myrb_exec_type3D()
239 if (dma_mapping_error(&cb->pdev->dev, pdev_info_addr)) in myrb_exec_type3D()
242 mutex_lock(&cb->dcmd_mutex); in myrb_exec_type3D()
244 mbox->type3D.id = MYRB_DCMD_TAG; in myrb_exec_type3D()
245 mbox->type3D.opcode = op; in myrb_exec_type3D()
246 mbox->type3D.channel = sdev->channel; in myrb_exec_type3D()
247 mbox->type3D.target = sdev->id; in myrb_exec_type3D()
248 mbox->type3D.addr = pdev_info_addr; in myrb_exec_type3D()
250 mutex_unlock(&cb->dcmd_mutex); in myrb_exec_type3D()
251 dma_unmap_single(&cb->pdev->dev, pdev_info_addr, in myrb_exec_type3D()
254 mbox->type3D.opcode == MYRB_CMD_GET_DEVICE_STATE_OLD) in myrb_exec_type3D()
277 * myrb_get_event - get event log from HBA
285 struct myrb_cmdblk *cmd_blk = &cb->mcmd_blk; in myrb_get_event()
286 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_get_event() local
291 ev_buf = dma_alloc_coherent(&cb->pdev->dev, in myrb_get_event()
298 mbox->type3E.id = MYRB_MCMD_TAG; in myrb_get_event()
299 mbox->type3E.opcode = MYRB_CMD_EVENT_LOG_OPERATION; in myrb_get_event()
300 mbox->type3E.optype = DAC960_V1_GetEventLogEntry; in myrb_get_event()
301 mbox->type3E.opqual = 1; in myrb_get_event()
302 mbox->type3E.ev_seq = event; in myrb_get_event()
303 mbox->type3E.addr = ev_addr; in myrb_get_event()
306 shost_printk(KERN_INFO, cb->host, in myrb_get_event()
310 else if (ev_buf->seq_num == event) { in myrb_get_event()
314 scsi_normalize_sense(ev_buf->sense, 32, &sshdr); in myrb_get_event()
319 shost_printk(KERN_CRIT, cb->host, in myrb_get_event()
321 ev_buf->channel, ev_buf->target, in myrb_get_event()
324 shost_printk(KERN_CRIT, cb->host, in myrb_get_event()
326 ev_buf->channel, ev_buf->target, in myrb_get_event()
330 dma_free_coherent(&cb->pdev->dev, sizeof(struct myrb_log_entry), in myrb_get_event()
335 * myrb_get_errtable - retrieves the error table from the controller
341 struct myrb_cmdblk *cmd_blk = &cb->mcmd_blk; in myrb_get_errtable()
342 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_get_errtable() local
346 memcpy(&old_table, cb->err_table, sizeof(old_table)); in myrb_get_errtable()
349 mbox->type3.id = MYRB_MCMD_TAG; in myrb_get_errtable()
350 mbox->type3.opcode = MYRB_CMD_GET_ERROR_TABLE; in myrb_get_errtable()
351 mbox->type3.addr = cb->err_table_addr; in myrb_get_errtable()
354 struct myrb_error_entry *table = cb->err_table; in myrb_get_errtable()
359 shost_for_each_device(sdev, cb->host) { in myrb_get_errtable()
360 if (sdev->channel >= myrb_logical_channel(cb->host)) in myrb_get_errtable()
362 err_table_offset = sdev->channel * MYRB_MAX_TARGETS in myrb_get_errtable()
363 + sdev->id; in myrb_get_errtable()
366 if (new->parity_err == old->parity_err && in myrb_get_errtable()
367 new->soft_err == old->soft_err && in myrb_get_errtable()
368 new->hard_err == old->hard_err && in myrb_get_errtable()
369 new->misc_err == old->misc_err) in myrb_get_errtable()
373 new->parity_err, new->soft_err, in myrb_get_errtable()
374 new->hard_err, new->misc_err); in myrb_get_errtable()
380 * myrb_get_ldev_info - retrieves the logical device table from the controller
389 int ldev_num, ldev_cnt = cb->enquiry->ldev_count; in myrb_get_ldev_info()
390 struct Scsi_Host *shost = cb->host; in myrb_get_ldev_info()
393 cb->ldev_info_addr); in myrb_get_ldev_info()
399 struct myrb_ldev_info *new = cb->ldev_info_buf + ldev_num; in myrb_get_ldev_info()
405 if (new->state == MYRB_DEVICE_OFFLINE) in myrb_get_ldev_info()
409 ldev_num, myrb_devstate_name(new->state)); in myrb_get_ldev_info()
414 old = sdev->hostdata; in myrb_get_ldev_info()
415 if (new->state != old->state) in myrb_get_ldev_info()
418 ldev_num, myrb_devstate_name(new->state)); in myrb_get_ldev_info()
419 if (new->wb_enabled != old->wb_enabled) in myrb_get_ldev_info()
422 (new->wb_enabled ? "BACK" : "THRU")); in myrb_get_ldev_info()
430 * myrb_get_rbld_progress - get rebuild progress information
440 struct myrb_cmdblk *cmd_blk = &cb->mcmd_blk; in myrb_get_rbld_progress()
441 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_get_rbld_progress() local
446 rbld_buf = dma_alloc_coherent(&cb->pdev->dev, in myrb_get_rbld_progress()
453 mbox->type3.id = MYRB_MCMD_TAG; in myrb_get_rbld_progress()
454 mbox->type3.opcode = MYRB_CMD_GET_REBUILD_PROGRESS; in myrb_get_rbld_progress()
455 mbox->type3.addr = rbld_addr; in myrb_get_rbld_progress()
459 dma_free_coherent(&cb->pdev->dev, sizeof(struct myrb_rbld_progress), in myrb_get_rbld_progress()
465 * myrb_update_rbld_progress - updates the rebuild status
476 cb->last_rbld_status == MYRB_STATUS_SUCCESS) in myrb_update_rbld_progress()
480 rbld_buf.ldev_size - rbld_buf.blocks_left; in myrb_update_rbld_progress()
483 sdev = scsi_device_lookup(cb->host, in myrb_update_rbld_progress()
484 myrb_logical_channel(cb->host), in myrb_update_rbld_progress()
521 cb->last_rbld_status = status; in myrb_update_rbld_progress()
525 * myrb_get_cc_progress - retrieve the rebuild status
532 struct myrb_cmdblk *cmd_blk = &cb->mcmd_blk; in myrb_get_cc_progress()
533 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_get_cc_progress() local
538 rbld_buf = dma_alloc_coherent(&cb->pdev->dev, in myrb_get_cc_progress()
542 cb->need_cc_status = true; in myrb_get_cc_progress()
546 mbox->type3.id = MYRB_MCMD_TAG; in myrb_get_cc_progress()
547 mbox->type3.opcode = MYRB_CMD_REBUILD_STAT; in myrb_get_cc_progress()
548 mbox->type3.addr = rbld_addr; in myrb_get_cc_progress()
551 unsigned int ldev_num = rbld_buf->ldev_num; in myrb_get_cc_progress()
552 unsigned int ldev_size = rbld_buf->ldev_size; in myrb_get_cc_progress()
554 ldev_size - rbld_buf->blocks_left; in myrb_get_cc_progress()
557 sdev = scsi_device_lookup(cb->host, in myrb_get_cc_progress()
558 myrb_logical_channel(cb->host), in myrb_get_cc_progress()
568 dma_free_coherent(&cb->pdev->dev, sizeof(struct myrb_rbld_progress), in myrb_get_cc_progress()
573 * myrb_bgi_control - updates background initialisation status
579 struct myrb_cmdblk *cmd_blk = &cb->mcmd_blk; in myrb_bgi_control()
580 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_bgi_control() local
586 bgi = dma_alloc_coherent(&cb->pdev->dev, sizeof(struct myrb_bgi_status), in myrb_bgi_control()
589 shost_printk(KERN_ERR, cb->host, in myrb_bgi_control()
594 mbox->type3B.id = MYRB_DCMD_TAG; in myrb_bgi_control()
595 mbox->type3B.opcode = MYRB_CMD_BGI_CONTROL; in myrb_bgi_control()
596 mbox->type3B.optype = 0x20; in myrb_bgi_control()
597 mbox->type3B.addr = bgi_addr; in myrb_bgi_control()
599 last_bgi = &cb->bgi_status; in myrb_bgi_control()
600 sdev = scsi_device_lookup(cb->host, in myrb_bgi_control()
601 myrb_logical_channel(cb->host), in myrb_bgi_control()
602 bgi->ldev_num, 0); in myrb_bgi_control()
605 switch (bgi->status) { in myrb_bgi_control()
617 if (bgi->blocks_done == last_bgi->blocks_done && in myrb_bgi_control()
618 bgi->ldev_num == last_bgi->ldev_num) in myrb_bgi_control()
622 (100 * (bgi->blocks_done >> 7)) in myrb_bgi_control()
623 / (bgi->ldev_size >> 7)); in myrb_bgi_control()
638 memcpy(&cb->bgi_status, bgi, sizeof(struct myrb_bgi_status)); in myrb_bgi_control()
641 if (sdev && cb->bgi_status.status == MYRB_BGI_INPROGRESS) in myrb_bgi_control()
644 cb->bgi_status.status = MYRB_BGI_INVALID; in myrb_bgi_control()
647 if (sdev && cb->bgi_status.status == MYRB_BGI_INPROGRESS) in myrb_bgi_control()
652 cb->bgi_status.status = MYRB_BGI_INVALID; in myrb_bgi_control()
657 dma_free_coherent(&cb->pdev->dev, sizeof(struct myrb_bgi_status), in myrb_bgi_control()
662 * myrb_hba_enquiry - updates the controller status
673 memcpy(&old, cb->enquiry, sizeof(struct myrb_enquiry)); in myrb_hba_enquiry()
675 status = myrb_exec_type3(cb, MYRB_CMD_ENQUIRY, cb->enquiry_addr); in myrb_hba_enquiry()
679 new = cb->enquiry; in myrb_hba_enquiry()
680 if (new->ldev_count > old.ldev_count) { in myrb_hba_enquiry()
681 int ldev_num = old.ldev_count - 1; in myrb_hba_enquiry()
683 while (++ldev_num < new->ldev_count) in myrb_hba_enquiry()
684 shost_printk(KERN_CRIT, cb->host, in myrb_hba_enquiry()
688 if (new->ldev_count < old.ldev_count) { in myrb_hba_enquiry()
689 int ldev_num = new->ldev_count - 1; in myrb_hba_enquiry()
692 shost_printk(KERN_CRIT, cb->host, in myrb_hba_enquiry()
696 if (new->status.deferred != old.status.deferred) in myrb_hba_enquiry()
697 shost_printk(KERN_CRIT, cb->host, in myrb_hba_enquiry()
699 (new->status.deferred ? "TRUE" : "FALSE")); in myrb_hba_enquiry()
700 if (new->ev_seq != old.ev_seq) { in myrb_hba_enquiry()
701 cb->new_ev_seq = new->ev_seq; in myrb_hba_enquiry()
702 cb->need_err_info = true; in myrb_hba_enquiry()
703 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
705 cb->old_ev_seq, cb->new_ev_seq, in myrb_hba_enquiry()
706 old.ev_seq, new->ev_seq); in myrb_hba_enquiry()
708 if ((new->ldev_critical > 0 && in myrb_hba_enquiry()
709 new->ldev_critical != old.ldev_critical) || in myrb_hba_enquiry()
710 (new->ldev_offline > 0 && in myrb_hba_enquiry()
711 new->ldev_offline != old.ldev_offline) || in myrb_hba_enquiry()
712 (new->ldev_count != old.ldev_count)) { in myrb_hba_enquiry()
713 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
715 new->ldev_critical, in myrb_hba_enquiry()
716 new->ldev_offline, in myrb_hba_enquiry()
717 new->ldev_count); in myrb_hba_enquiry()
718 cb->need_ldev_info = true; in myrb_hba_enquiry()
720 if (new->pdev_dead > 0 || in myrb_hba_enquiry()
721 new->pdev_dead != old.pdev_dead || in myrb_hba_enquiry()
722 time_after_eq(jiffies, cb->secondary_monitor_time in myrb_hba_enquiry()
724 cb->need_bgi_status = cb->bgi_status_supported; in myrb_hba_enquiry()
725 cb->secondary_monitor_time = jiffies; in myrb_hba_enquiry()
727 if (new->rbld == MYRB_STDBY_RBLD_IN_PROGRESS || in myrb_hba_enquiry()
728 new->rbld == MYRB_BG_RBLD_IN_PROGRESS || in myrb_hba_enquiry()
731 cb->need_rbld = true; in myrb_hba_enquiry()
732 cb->rbld_first = (new->ldev_critical < old.ldev_critical); in myrb_hba_enquiry()
735 switch (new->rbld) { in myrb_hba_enquiry()
737 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
744 cb->need_cc_status = true; in myrb_hba_enquiry()
747 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
751 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
752 "Consistency Check Failed - Physical Device Failed\n"); in myrb_hba_enquiry()
755 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
756 "Consistency Check Failed - Logical Drive Failed\n"); in myrb_hba_enquiry()
759 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
760 "Consistency Check Failed - Other Causes\n"); in myrb_hba_enquiry()
763 shost_printk(KERN_INFO, cb->host, in myrb_hba_enquiry()
767 else if (new->rbld == MYRB_BG_CHECK_IN_PROGRESS) in myrb_hba_enquiry()
768 cb->need_cc_status = true; in myrb_hba_enquiry()
774 * myrb_set_pdev_state - sets the device state for a physical device
781 struct myrb_cmdblk *cmd_blk = &cb->dcmd_blk; in myrb_set_pdev_state()
782 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_set_pdev_state() local
785 mutex_lock(&cb->dcmd_mutex); in myrb_set_pdev_state()
786 mbox->type3D.opcode = MYRB_CMD_START_DEVICE; in myrb_set_pdev_state()
787 mbox->type3D.id = MYRB_DCMD_TAG; in myrb_set_pdev_state()
788 mbox->type3D.channel = sdev->channel; in myrb_set_pdev_state()
789 mbox->type3D.target = sdev->id; in myrb_set_pdev_state()
790 mbox->type3D.state = state & 0x1F; in myrb_set_pdev_state()
792 mutex_unlock(&cb->dcmd_mutex); in myrb_set_pdev_state()
798 * myrb_enable_mmio - enables the Memory Mailbox Interface
807 void __iomem *base = cb->io_base; in myrb_enable_mmio()
808 struct pci_dev *pdev = cb->pdev; in myrb_enable_mmio()
813 union myrb_cmd_mbox mbox; in myrb_enable_mmio() local
816 memset(&mbox, 0, sizeof(union myrb_cmd_mbox)); in myrb_enable_mmio()
818 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { in myrb_enable_mmio()
819 dev_err(&pdev->dev, "DMA mask out of range\n"); in myrb_enable_mmio()
823 cb->enquiry = dma_alloc_coherent(&pdev->dev, in myrb_enable_mmio()
825 &cb->enquiry_addr, GFP_KERNEL); in myrb_enable_mmio()
826 if (!cb->enquiry) in myrb_enable_mmio()
831 cb->err_table = dma_alloc_coherent(&pdev->dev, err_table_size, in myrb_enable_mmio()
832 &cb->err_table_addr, GFP_KERNEL); in myrb_enable_mmio()
833 if (!cb->err_table) in myrb_enable_mmio()
837 cb->ldev_info_buf = dma_alloc_coherent(&pdev->dev, ldev_info_size, in myrb_enable_mmio()
838 &cb->ldev_info_addr, GFP_KERNEL); in myrb_enable_mmio()
839 if (!cb->ldev_info_buf) in myrb_enable_mmio()
849 cb->cmd_mbox_size = MYRB_CMD_MBOX_COUNT * sizeof(union myrb_cmd_mbox); in myrb_enable_mmio()
850 cb->first_cmd_mbox = dma_alloc_coherent(&pdev->dev, in myrb_enable_mmio()
851 cb->cmd_mbox_size, in myrb_enable_mmio()
852 &cb->cmd_mbox_addr, in myrb_enable_mmio()
854 if (!cb->first_cmd_mbox) in myrb_enable_mmio()
857 cmd_mbox_mem = cb->first_cmd_mbox; in myrb_enable_mmio()
858 cmd_mbox_mem += MYRB_CMD_MBOX_COUNT - 1; in myrb_enable_mmio()
859 cb->last_cmd_mbox = cmd_mbox_mem; in myrb_enable_mmio()
860 cb->next_cmd_mbox = cb->first_cmd_mbox; in myrb_enable_mmio()
861 cb->prev_cmd_mbox1 = cb->last_cmd_mbox; in myrb_enable_mmio()
862 cb->prev_cmd_mbox2 = cb->last_cmd_mbox - 1; in myrb_enable_mmio()
865 cb->stat_mbox_size = MYRB_STAT_MBOX_COUNT * in myrb_enable_mmio()
867 cb->first_stat_mbox = dma_alloc_coherent(&pdev->dev, in myrb_enable_mmio()
868 cb->stat_mbox_size, in myrb_enable_mmio()
869 &cb->stat_mbox_addr, in myrb_enable_mmio()
871 if (!cb->first_stat_mbox) in myrb_enable_mmio()
874 stat_mbox_mem = cb->first_stat_mbox; in myrb_enable_mmio()
875 stat_mbox_mem += MYRB_STAT_MBOX_COUNT - 1; in myrb_enable_mmio()
876 cb->last_stat_mbox = stat_mbox_mem; in myrb_enable_mmio()
877 cb->next_stat_mbox = cb->first_stat_mbox; in myrb_enable_mmio()
880 cb->dual_mode_interface = true; in myrb_enable_mmio()
881 mbox.typeX.opcode = 0x2B; in myrb_enable_mmio()
882 mbox.typeX.id = 0; in myrb_enable_mmio()
883 mbox.typeX.opcode2 = 0x14; in myrb_enable_mmio()
884 mbox.typeX.cmd_mbox_addr = cb->cmd_mbox_addr; in myrb_enable_mmio()
885 mbox.typeX.stat_mbox_addr = cb->stat_mbox_addr; in myrb_enable_mmio()
887 status = mmio_init_fn(pdev, base, &mbox); in myrb_enable_mmio()
889 cb->dual_mode_interface = false; in myrb_enable_mmio()
890 mbox.typeX.opcode2 = 0x10; in myrb_enable_mmio()
891 status = mmio_init_fn(pdev, base, &mbox); in myrb_enable_mmio()
893 dev_err(&pdev->dev, in myrb_enable_mmio()
903 * myrb_get_hba_config - reads the configuration information
916 struct Scsi_Host *shost = cb->host; in myrb_get_hba_config()
917 struct pci_dev *pdev = cb->pdev; in myrb_get_hba_config()
920 int ret = -ENODEV, memsize = 0; in myrb_get_hba_config()
922 enquiry2 = dma_alloc_coherent(&pdev->dev, sizeof(struct myrb_enquiry2), in myrb_get_hba_config()
925 shost_printk(KERN_ERR, cb->host, in myrb_get_hba_config()
927 return -ENOMEM; in myrb_get_hba_config()
929 config2 = dma_alloc_coherent(&pdev->dev, sizeof(struct myrb_config2), in myrb_get_hba_config()
932 shost_printk(KERN_ERR, cb->host, in myrb_get_hba_config()
934 dma_free_coherent(&pdev->dev, sizeof(struct myrb_enquiry2), in myrb_get_hba_config()
936 return -ENOMEM; in myrb_get_hba_config()
938 mutex_lock(&cb->dma_mutex); in myrb_get_hba_config()
940 mutex_unlock(&cb->dma_mutex); in myrb_get_hba_config()
942 shost_printk(KERN_WARNING, cb->host, in myrb_get_hba_config()
949 shost_printk(KERN_WARNING, cb->host, in myrb_get_hba_config()
956 shost_printk(KERN_WARNING, cb->host, in myrb_get_hba_config()
963 shost_printk(KERN_WARNING, cb->host, in myrb_get_hba_config()
969 * Initialize the Controller Model Name and Full Model Name fields. in myrb_get_hba_config()
971 switch (enquiry2->hw.sub_model) { in myrb_get_hba_config()
973 if (enquiry2->scsi_cap.bus_speed == MYRB_SCSI_SPEED_ULTRA) in myrb_get_hba_config()
974 strcpy(cb->model_name, "DAC960PU"); in myrb_get_hba_config()
976 strcpy(cb->model_name, "DAC960PD"); in myrb_get_hba_config()
979 strcpy(cb->model_name, "DAC960PL"); in myrb_get_hba_config()
982 strcpy(cb->model_name, "DAC960PG"); in myrb_get_hba_config()
985 strcpy(cb->model_name, "DAC960PJ"); in myrb_get_hba_config()
988 strcpy(cb->model_name, "DAC960PR"); in myrb_get_hba_config()
991 strcpy(cb->model_name, "DAC960PT"); in myrb_get_hba_config()
994 strcpy(cb->model_name, "DAC960PTL0"); in myrb_get_hba_config()
997 strcpy(cb->model_name, "DAC960PRL"); in myrb_get_hba_config()
1000 strcpy(cb->model_name, "DAC960PTL1"); in myrb_get_hba_config()
1003 strcpy(cb->model_name, "eXtremeRAID 1100"); in myrb_get_hba_config()
1006 shost_printk(KERN_WARNING, cb->host, in myrb_get_hba_config()
1008 enquiry2->hw.sub_model); in myrb_get_hba_config()
1033 * KZPSC: D040347 (1-channel) or D040348 (2-channel) in myrb_get_hba_config()
1034 * or D040349 (3-channel) in myrb_get_hba_config()
1035 * KZPAC: D040395 (1-channel) or D040396 (2-channel) in myrb_get_hba_config()
1036 * or D040397 (3-channel) in myrb_get_hba_config()
1043 if (enquiry2->fw.major_version == 0) { in myrb_get_hba_config()
1044 enquiry2->fw.major_version = cb->enquiry->fw_major_version; in myrb_get_hba_config()
1045 enquiry2->fw.minor_version = cb->enquiry->fw_minor_version; in myrb_get_hba_config()
1046 enquiry2->fw.firmware_type = '0'; in myrb_get_hba_config()
1047 enquiry2->fw.turn_id = 0; in myrb_get_hba_config()
1049 snprintf(cb->fw_version, sizeof(cb->fw_version), in myrb_get_hba_config()
1050 "%u.%02u-%c-%02u", in myrb_get_hba_config()
1051 enquiry2->fw.major_version, in myrb_get_hba_config()
1052 enquiry2->fw.minor_version, in myrb_get_hba_config()
1053 enquiry2->fw.firmware_type, in myrb_get_hba_config()
1054 enquiry2->fw.turn_id); in myrb_get_hba_config()
1055 if (!((enquiry2->fw.major_version == 5 && in myrb_get_hba_config()
1056 enquiry2->fw.minor_version >= 6) || in myrb_get_hba_config()
1057 (enquiry2->fw.major_version == 4 && in myrb_get_hba_config()
1058 enquiry2->fw.minor_version >= 6) || in myrb_get_hba_config()
1059 (enquiry2->fw.major_version == 3 && in myrb_get_hba_config()
1060 enquiry2->fw.minor_version >= 51) || in myrb_get_hba_config()
1061 (enquiry2->fw.major_version == 2 && in myrb_get_hba_config()
1062 strcmp(cb->fw_version, FIRMWARE_27X) >= 0))) { in myrb_get_hba_config()
1063 shost_printk(KERN_WARNING, cb->host, in myrb_get_hba_config()
1065 cb->fw_version); in myrb_get_hba_config()
1069 * Initialize the Channels, Targets, Memory Size, and SAF-TE in myrb_get_hba_config()
1072 switch (enquiry2->hw.model) { in myrb_get_hba_config()
1084 pchan_max = enquiry2->cfg_chan; in myrb_get_hba_config()
1087 pchan_cur = enquiry2->cur_chan; in myrb_get_hba_config()
1088 if (enquiry2->scsi_cap.bus_width == MYRB_WIDTH_WIDE_32BIT) in myrb_get_hba_config()
1089 cb->bus_width = 32; in myrb_get_hba_config()
1090 else if (enquiry2->scsi_cap.bus_width == MYRB_WIDTH_WIDE_16BIT) in myrb_get_hba_config()
1091 cb->bus_width = 16; in myrb_get_hba_config()
1093 cb->bus_width = 8; in myrb_get_hba_config()
1094 cb->ldev_block_size = enquiry2->ldev_block_size; in myrb_get_hba_config()
1095 shost->max_channel = pchan_cur; in myrb_get_hba_config()
1096 shost->max_id = enquiry2->max_targets; in myrb_get_hba_config()
1097 memsize = enquiry2->mem_size >> 20; in myrb_get_hba_config()
1098 cb->safte_enabled = (enquiry2->fault_mgmt == MYRB_FAULT_SAFTE); in myrb_get_hba_config()
1107 shost->can_queue = cb->enquiry->max_tcq; in myrb_get_hba_config()
1108 if (shost->can_queue < 3) in myrb_get_hba_config()
1109 shost->can_queue = enquiry2->max_cmds; in myrb_get_hba_config()
1110 if (shost->can_queue < 3) in myrb_get_hba_config()
1112 shost->can_queue = 1; in myrb_get_hba_config()
1114 if (shost->can_queue > MYRB_CMD_MBOX_COUNT - 2) in myrb_get_hba_config()
1115 shost->can_queue = MYRB_CMD_MBOX_COUNT - 2; in myrb_get_hba_config()
1116 shost->max_sectors = enquiry2->max_sectors; in myrb_get_hba_config()
1117 shost->sg_tablesize = enquiry2->max_sge; in myrb_get_hba_config()
1118 if (shost->sg_tablesize > MYRB_SCATTER_GATHER_LIMIT) in myrb_get_hba_config()
1119 shost->sg_tablesize = MYRB_SCATTER_GATHER_LIMIT; in myrb_get_hba_config()
1123 cb->stripe_size = config2->blocks_per_stripe * config2->block_factor in myrb_get_hba_config()
1124 >> (10 - MYRB_BLKSIZE_BITS); in myrb_get_hba_config()
1125 cb->segment_size = config2->blocks_per_cacheline * config2->block_factor in myrb_get_hba_config()
1126 >> (10 - MYRB_BLKSIZE_BITS); in myrb_get_hba_config()
1128 cb->ldev_geom_heads = 255; in myrb_get_hba_config()
1129 cb->ldev_geom_sectors = 63; in myrb_get_hba_config()
1130 if (config2->drive_geometry) { in myrb_get_hba_config()
1131 cb->ldev_geom_heads = 128; in myrb_get_hba_config()
1132 cb->ldev_geom_sectors = 32; in myrb_get_hba_config()
1138 if ((cb->fw_version[0] == '4' && in myrb_get_hba_config()
1139 strcmp(cb->fw_version, "4.08") >= 0) || in myrb_get_hba_config()
1140 (cb->fw_version[0] == '5' && in myrb_get_hba_config()
1141 strcmp(cb->fw_version, "5.08") >= 0)) { in myrb_get_hba_config()
1142 cb->bgi_status_supported = true; in myrb_get_hba_config()
1145 cb->last_rbld_status = MYRB_NO_STDBY_RBLD_OR_CHECK_IN_PROGRESS; in myrb_get_hba_config()
1149 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1150 "Configuring %s PCI RAID Controller\n", cb->model_name); in myrb_get_hba_config()
1151 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1153 cb->fw_version, memsize); in myrb_get_hba_config()
1154 if (cb->io_addr == 0) in myrb_get_hba_config()
1155 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1157 (unsigned long)cb->pci_addr, cb->irq); in myrb_get_hba_config()
1159 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1161 (unsigned long)cb->io_addr, (unsigned long)cb->pci_addr, in myrb_get_hba_config()
1162 cb->irq); in myrb_get_hba_config()
1163 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1165 cb->host->can_queue, cb->host->max_sectors); in myrb_get_hba_config()
1166 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1168 cb->host->can_queue, cb->host->sg_tablesize, in myrb_get_hba_config()
1170 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1172 cb->stripe_size, cb->segment_size, in myrb_get_hba_config()
1173 cb->ldev_geom_heads, cb->ldev_geom_sectors, in myrb_get_hba_config()
1174 cb->safte_enabled ? in myrb_get_hba_config()
1175 " SAF-TE Enclosure Management Enabled" : ""); in myrb_get_hba_config()
1176 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1178 pchan_cur, pchan_max, 0, cb->enquiry->pdev_dead, in myrb_get_hba_config()
1179 cb->host->max_id); in myrb_get_hba_config()
1181 shost_printk(KERN_INFO, cb->host, in myrb_get_hba_config()
1183 cb->enquiry->ldev_count, MYRB_MAX_LDEVS); in myrb_get_hba_config()
1186 dma_free_coherent(&pdev->dev, sizeof(struct myrb_enquiry2), in myrb_get_hba_config()
1188 dma_free_coherent(&pdev->dev, sizeof(struct myrb_config2), in myrb_get_hba_config()
1195 * myrb_unmap - unmaps controller structures
1199 if (cb->ldev_info_buf) { in myrb_unmap()
1202 dma_free_coherent(&cb->pdev->dev, ldev_info_size, in myrb_unmap()
1203 cb->ldev_info_buf, cb->ldev_info_addr); in myrb_unmap()
1204 cb->ldev_info_buf = NULL; in myrb_unmap()
1206 if (cb->err_table) { in myrb_unmap()
1209 dma_free_coherent(&cb->pdev->dev, err_table_size, in myrb_unmap()
1210 cb->err_table, cb->err_table_addr); in myrb_unmap()
1211 cb->err_table = NULL; in myrb_unmap()
1213 if (cb->enquiry) { in myrb_unmap()
1214 dma_free_coherent(&cb->pdev->dev, sizeof(struct myrb_enquiry), in myrb_unmap()
1215 cb->enquiry, cb->enquiry_addr); in myrb_unmap()
1216 cb->enquiry = NULL; in myrb_unmap()
1218 if (cb->first_stat_mbox) { in myrb_unmap()
1219 dma_free_coherent(&cb->pdev->dev, cb->stat_mbox_size, in myrb_unmap()
1220 cb->first_stat_mbox, cb->stat_mbox_addr); in myrb_unmap()
1221 cb->first_stat_mbox = NULL; in myrb_unmap()
1223 if (cb->first_cmd_mbox) { in myrb_unmap()
1224 dma_free_coherent(&cb->pdev->dev, cb->cmd_mbox_size, in myrb_unmap()
1225 cb->first_cmd_mbox, cb->cmd_mbox_addr); in myrb_unmap()
1226 cb->first_cmd_mbox = NULL; in myrb_unmap()
1231 * myrb_cleanup - cleanup controller structures
1235 struct pci_dev *pdev = cb->pdev; in myrb_cleanup()
1240 if (cb->mmio_base) { in myrb_cleanup()
1241 if (cb->disable_intr) in myrb_cleanup()
1242 cb->disable_intr(cb->io_base); in myrb_cleanup()
1243 iounmap(cb->mmio_base); in myrb_cleanup()
1245 if (cb->irq) in myrb_cleanup()
1246 free_irq(cb->irq, cb); in myrb_cleanup()
1247 if (cb->io_addr) in myrb_cleanup()
1248 release_region(cb->io_addr, 0x80); in myrb_cleanup()
1251 scsi_host_put(cb->host); in myrb_cleanup()
1256 struct Scsi_Host *shost = scmd->device->host; in myrb_host_reset()
1259 cb->reset(cb->io_base); in myrb_host_reset()
1269 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_pthru_queuecommand() local
1272 struct scsi_device *sdev = scmd->device; in myrb_pthru_queuecommand()
1278 dcdb = dma_pool_alloc(cb->dcdb_pool, GFP_ATOMIC, &dcdb_addr); in myrb_pthru_queuecommand()
1283 dma_pool_free(cb->dcdb_pool, dcdb, dcdb_addr); in myrb_pthru_queuecommand()
1284 scmd->result = (DID_ERROR << 16); in myrb_pthru_queuecommand()
1289 mbox->type3.opcode = MYRB_CMD_DCDB; in myrb_pthru_queuecommand()
1290 mbox->type3.id = rq->tag + 3; in myrb_pthru_queuecommand()
1291 mbox->type3.addr = dcdb_addr; in myrb_pthru_queuecommand()
1292 dcdb->channel = sdev->channel; in myrb_pthru_queuecommand()
1293 dcdb->target = sdev->id; in myrb_pthru_queuecommand()
1294 switch (scmd->sc_data_direction) { in myrb_pthru_queuecommand()
1296 dcdb->data_xfer = MYRB_DCDB_XFER_NONE; in myrb_pthru_queuecommand()
1299 dcdb->data_xfer = MYRB_DCDB_XFER_SYSTEM_TO_DEVICE; in myrb_pthru_queuecommand()
1302 dcdb->data_xfer = MYRB_DCDB_XFER_DEVICE_TO_SYSTEM; in myrb_pthru_queuecommand()
1305 dcdb->data_xfer = MYRB_DCDB_XFER_ILLEGAL; in myrb_pthru_queuecommand()
1308 dcdb->early_status = false; in myrb_pthru_queuecommand()
1309 if (rq->timeout <= 10) in myrb_pthru_queuecommand()
1310 dcdb->timeout = MYRB_DCDB_TMO_10_SECS; in myrb_pthru_queuecommand()
1311 else if (rq->timeout <= 60) in myrb_pthru_queuecommand()
1312 dcdb->timeout = MYRB_DCDB_TMO_60_SECS; in myrb_pthru_queuecommand()
1313 else if (rq->timeout <= 600) in myrb_pthru_queuecommand()
1314 dcdb->timeout = MYRB_DCDB_TMO_10_MINS; in myrb_pthru_queuecommand()
1316 dcdb->timeout = MYRB_DCDB_TMO_24_HRS; in myrb_pthru_queuecommand()
1317 dcdb->no_autosense = false; in myrb_pthru_queuecommand()
1318 dcdb->allow_disconnect = true; in myrb_pthru_queuecommand()
1320 dcdb->dma_addr = sg_dma_address(sgl); in myrb_pthru_queuecommand()
1322 dcdb->xfer_len_lo = sg_dma_len(sgl) & 0xffff; in myrb_pthru_queuecommand()
1323 dcdb->xfer_len_hi4 = sg_dma_len(sgl) >> 16; in myrb_pthru_queuecommand()
1325 dcdb->xfer_len_lo = sg_dma_len(sgl); in myrb_pthru_queuecommand()
1326 dcdb->xfer_len_hi4 = 0; in myrb_pthru_queuecommand()
1328 dcdb->cdb_len = scmd->cmd_len; in myrb_pthru_queuecommand()
1329 dcdb->sense_len = sizeof(dcdb->sense); in myrb_pthru_queuecommand()
1330 memcpy(&dcdb->cdb, scmd->cmnd, scmd->cmd_len); in myrb_pthru_queuecommand()
1332 spin_lock_irqsave(&cb->queue_lock, flags); in myrb_pthru_queuecommand()
1333 cb->qcmd(cb, cmd_blk); in myrb_pthru_queuecommand()
1334 spin_unlock_irqrestore(&cb->queue_lock, flags); in myrb_pthru_queuecommand()
1349 if (cb->bus_width > 16) in myrb_inquiry()
1351 if (cb->bus_width > 8) in myrb_inquiry()
1353 memcpy(&inq[16], cb->model_name, 16); in myrb_inquiry()
1354 memcpy(&inq[32], cb->fw_version, 1); in myrb_inquiry()
1355 memcpy(&inq[33], &cb->fw_version[2], 2); in myrb_inquiry()
1356 memcpy(&inq[35], &cb->fw_version[7], 1); in myrb_inquiry()
1369 dbd = (scmd->cmnd[1] & 0x08) == 0x08; in myrb_mode_sense()
1378 modes[0] = mode_len - 1; in myrb_mode_sense()
1383 put_unaligned_be32(ldev_info->size, &block_desc[0]); in myrb_mode_sense()
1384 put_unaligned_be32(cb->ldev_block_size, &block_desc[5]); in myrb_mode_sense()
1388 if (ldev_info->wb_enabled) in myrb_mode_sense()
1390 if (cb->segment_size) { in myrb_mode_sense()
1392 put_unaligned_be16(cb->segment_size, &mode_pg[14]); in myrb_mode_sense()
1402 scsi_sg_copy_from_buffer(scmd, scmd->sense_buffer, in myrb_request_sense()
1411 dev_dbg(&scmd->device->sdev_gendev, in myrb_read_capacity()
1413 ldev_info->size, cb->ldev_block_size); in myrb_read_capacity()
1414 put_unaligned_be32(ldev_info->size - 1, &data[0]); in myrb_read_capacity()
1415 put_unaligned_be32(cb->ldev_block_size, &data[4]); in myrb_read_capacity()
1424 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_ldev_queuecommand() local
1426 struct scsi_device *sdev = scmd->device; in myrb_ldev_queuecommand()
1433 ldev_info = sdev->hostdata; in myrb_ldev_queuecommand()
1434 if (ldev_info->state != MYRB_DEVICE_ONLINE && in myrb_ldev_queuecommand()
1435 ldev_info->state != MYRB_DEVICE_WO) { in myrb_ldev_queuecommand()
1436 dev_dbg(&shost->shost_gendev, "ldev %u in state %x, skip\n", in myrb_ldev_queuecommand()
1437 sdev->id, ldev_info ? ldev_info->state : 0xff); in myrb_ldev_queuecommand()
1438 scmd->result = (DID_BAD_TARGET << 16); in myrb_ldev_queuecommand()
1442 switch (scmd->cmnd[0]) { in myrb_ldev_queuecommand()
1444 scmd->result = (DID_OK << 16); in myrb_ldev_queuecommand()
1448 if (scmd->cmnd[1] & 1) { in myrb_ldev_queuecommand()
1453 scmd->result = (DID_OK << 16); in myrb_ldev_queuecommand()
1458 scmd->result = (DID_OK << 16); in myrb_ldev_queuecommand()
1462 if ((scmd->cmnd[2] & 0x3F) != 0x3F && in myrb_ldev_queuecommand()
1463 (scmd->cmnd[2] & 0x3F) != 0x08) { in myrb_ldev_queuecommand()
1468 scmd->result = (DID_OK << 16); in myrb_ldev_queuecommand()
1473 if ((scmd->cmnd[1] & 1) || in myrb_ldev_queuecommand()
1474 (scmd->cmnd[8] & 1)) { in myrb_ldev_queuecommand()
1480 lba = get_unaligned_be32(&scmd->cmnd[2]); in myrb_ldev_queuecommand()
1492 scmd->result = (DID_OK << 16); in myrb_ldev_queuecommand()
1495 if (scmd->cmnd[1] != 0x04) { in myrb_ldev_queuecommand()
1500 scmd->result = (DID_OK << 16); in myrb_ldev_queuecommand()
1505 if (ldev_info->state == MYRB_DEVICE_WO) { in myrb_ldev_queuecommand()
1513 lba = (((scmd->cmnd[1] & 0x1F) << 16) | in myrb_ldev_queuecommand()
1514 (scmd->cmnd[2] << 8) | in myrb_ldev_queuecommand()
1515 scmd->cmnd[3]); in myrb_ldev_queuecommand()
1516 block_cnt = scmd->cmnd[4]; in myrb_ldev_queuecommand()
1519 if (ldev_info->state == MYRB_DEVICE_WO) { in myrb_ldev_queuecommand()
1529 lba = get_unaligned_be32(&scmd->cmnd[2]); in myrb_ldev_queuecommand()
1530 block_cnt = get_unaligned_be16(&scmd->cmnd[7]); in myrb_ldev_queuecommand()
1533 if (ldev_info->state == MYRB_DEVICE_WO) { in myrb_ldev_queuecommand()
1543 lba = get_unaligned_be32(&scmd->cmnd[2]); in myrb_ldev_queuecommand()
1544 block_cnt = get_unaligned_be32(&scmd->cmnd[6]); in myrb_ldev_queuecommand()
1554 mbox->type5.id = scsi_cmd_to_rq(scmd)->tag + 3; in myrb_ldev_queuecommand()
1555 if (scmd->sc_data_direction == DMA_NONE) in myrb_ldev_queuecommand()
1560 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in myrb_ldev_queuecommand()
1561 mbox->type5.opcode = MYRB_CMD_READ; in myrb_ldev_queuecommand()
1563 mbox->type5.opcode = MYRB_CMD_WRITE; in myrb_ldev_queuecommand()
1565 mbox->type5.ld.xfer_len = block_cnt; in myrb_ldev_queuecommand()
1566 mbox->type5.ld.ldev_num = sdev->id; in myrb_ldev_queuecommand()
1567 mbox->type5.lba = lba; in myrb_ldev_queuecommand()
1568 mbox->type5.addr = (u32)sg_dma_address(sgl); in myrb_ldev_queuecommand()
1574 hw_sgl = dma_pool_alloc(cb->sg_pool, GFP_ATOMIC, &hw_sgl_addr); in myrb_ldev_queuecommand()
1578 cmd_blk->sgl = hw_sgl; in myrb_ldev_queuecommand()
1579 cmd_blk->sgl_addr = hw_sgl_addr; in myrb_ldev_queuecommand()
1581 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in myrb_ldev_queuecommand()
1582 mbox->type5.opcode = MYRB_CMD_READ_SG; in myrb_ldev_queuecommand()
1584 mbox->type5.opcode = MYRB_CMD_WRITE_SG; in myrb_ldev_queuecommand()
1586 mbox->type5.ld.xfer_len = block_cnt; in myrb_ldev_queuecommand()
1587 mbox->type5.ld.ldev_num = sdev->id; in myrb_ldev_queuecommand()
1588 mbox->type5.lba = lba; in myrb_ldev_queuecommand()
1589 mbox->type5.addr = hw_sgl_addr; in myrb_ldev_queuecommand()
1590 mbox->type5.sg_count = nsge; in myrb_ldev_queuecommand()
1593 hw_sgl->sge_addr = (u32)sg_dma_address(sgl); in myrb_ldev_queuecommand()
1594 hw_sgl->sge_count = (u32)sg_dma_len(sgl); in myrb_ldev_queuecommand()
1599 spin_lock_irqsave(&cb->queue_lock, flags); in myrb_ldev_queuecommand()
1600 cb->qcmd(cb, cmd_blk); in myrb_ldev_queuecommand()
1601 spin_unlock_irqrestore(&cb->queue_lock, flags); in myrb_ldev_queuecommand()
1609 struct scsi_device *sdev = scmd->device; in myrb_queuecommand()
1611 if (sdev->channel > myrb_logical_channel(shost)) { in myrb_queuecommand()
1612 scmd->result = (DID_BAD_TARGET << 16); in myrb_queuecommand()
1616 if (sdev->channel == myrb_logical_channel(shost)) in myrb_queuecommand()
1624 struct myrb_hba *cb = shost_priv(sdev->host); in myrb_ldev_slave_alloc()
1626 unsigned short ldev_num = sdev->id; in myrb_ldev_slave_alloc()
1629 ldev_info = cb->ldev_info_buf + ldev_num; in myrb_ldev_slave_alloc()
1631 return -ENXIO; in myrb_ldev_slave_alloc()
1633 sdev->hostdata = kzalloc(sizeof(*ldev_info), GFP_KERNEL); in myrb_ldev_slave_alloc()
1634 if (!sdev->hostdata) in myrb_ldev_slave_alloc()
1635 return -ENOMEM; in myrb_ldev_slave_alloc()
1636 dev_dbg(&sdev->sdev_gendev, in myrb_ldev_slave_alloc()
1638 ldev_num, ldev_info->state); in myrb_ldev_slave_alloc()
1639 memcpy(sdev->hostdata, ldev_info, in myrb_ldev_slave_alloc()
1641 switch (ldev_info->raid_level) { in myrb_ldev_slave_alloc()
1664 raid_set_level(myrb_raid_template, &sdev->sdev_gendev, level); in myrb_ldev_slave_alloc()
1670 struct myrb_hba *cb = shost_priv(sdev->host); in myrb_pdev_slave_alloc()
1674 if (sdev->id > MYRB_MAX_TARGETS) in myrb_pdev_slave_alloc()
1675 return -ENXIO; in myrb_pdev_slave_alloc()
1679 return -ENOMEM; in myrb_pdev_slave_alloc()
1684 dev_dbg(&sdev->sdev_gendev, in myrb_pdev_slave_alloc()
1688 return -ENXIO; in myrb_pdev_slave_alloc()
1690 if (!pdev_info->present) { in myrb_pdev_slave_alloc()
1691 dev_dbg(&sdev->sdev_gendev, in myrb_pdev_slave_alloc()
1694 return -ENXIO; in myrb_pdev_slave_alloc()
1696 dev_dbg(&sdev->sdev_gendev, in myrb_pdev_slave_alloc()
1698 sdev->channel, sdev->id, pdev_info->state); in myrb_pdev_slave_alloc()
1699 sdev->hostdata = pdev_info; in myrb_pdev_slave_alloc()
1706 if (sdev->channel > myrb_logical_channel(sdev->host)) in myrb_slave_alloc()
1707 return -ENXIO; in myrb_slave_alloc()
1709 if (sdev->lun > 0) in myrb_slave_alloc()
1710 return -ENXIO; in myrb_slave_alloc()
1712 if (sdev->channel == myrb_logical_channel(sdev->host)) in myrb_slave_alloc()
1722 if (sdev->channel > myrb_logical_channel(sdev->host)) in myrb_slave_configure()
1723 return -ENXIO; in myrb_slave_configure()
1725 if (sdev->channel < myrb_logical_channel(sdev->host)) { in myrb_slave_configure()
1726 sdev->no_uld_attach = 1; in myrb_slave_configure()
1729 if (sdev->lun != 0) in myrb_slave_configure()
1730 return -ENXIO; in myrb_slave_configure()
1732 ldev_info = sdev->hostdata; in myrb_slave_configure()
1734 return -ENXIO; in myrb_slave_configure()
1735 if (ldev_info->state != MYRB_DEVICE_ONLINE) in myrb_slave_configure()
1738 myrb_devstate_name(ldev_info->state)); in myrb_slave_configure()
1740 sdev->tagged_supported = 1; in myrb_slave_configure()
1746 kfree(sdev->hostdata); in myrb_slave_destroy()
1752 struct myrb_hba *cb = shost_priv(sdev->host); in myrb_biosparam()
1754 geom[0] = cb->ldev_geom_heads; in myrb_biosparam()
1755 geom[1] = cb->ldev_geom_sectors; in myrb_biosparam()
1765 struct myrb_hba *cb = shost_priv(sdev->host); in raid_state_show()
1768 if (!sdev->hostdata) in raid_state_show()
1771 if (sdev->channel == myrb_logical_channel(sdev->host)) { in raid_state_show()
1772 struct myrb_ldev_info *ldev_info = sdev->hostdata; in raid_state_show()
1773 const char *name; in raid_state_show() local
1775 name = myrb_devstate_name(ldev_info->state); in raid_state_show()
1776 if (name) in raid_state_show()
1777 ret = snprintf(buf, 64, "%s\n", name); in raid_state_show()
1780 ldev_info->state); in raid_state_show()
1782 struct myrb_pdev_state *pdev_info = sdev->hostdata; in raid_state_show()
1784 const char *name; in raid_state_show() local
1793 if (!pdev_info->present) in raid_state_show()
1794 name = "Removed"; in raid_state_show()
1796 name = myrb_devstate_name(pdev_info->state); in raid_state_show()
1797 if (name) in raid_state_show()
1798 ret = snprintf(buf, 64, "%s\n", name); in raid_state_show()
1801 pdev_info->state); in raid_state_show()
1810 struct myrb_hba *cb = shost_priv(sdev->host); in raid_state_store()
1823 return -EINVAL; in raid_state_store()
1825 pdev_info = sdev->hostdata; in raid_state_store()
1828 "Failed - no physical device information\n"); in raid_state_store()
1829 return -ENXIO; in raid_state_store()
1831 if (!pdev_info->present) { in raid_state_store()
1833 "Failed - device not present\n"); in raid_state_store()
1834 return -ENXIO; in raid_state_store()
1837 if (pdev_info->state == new_state) in raid_state_store()
1846 "Failed - Unable to Start Device\n"); in raid_state_store()
1847 count = -EAGAIN; in raid_state_store()
1851 "Failed - No Device at Address\n"); in raid_state_store()
1852 count = -ENODEV; in raid_state_store()
1856 "Failed - Invalid Channel or Target or Modifier\n"); in raid_state_store()
1857 count = -EINVAL; in raid_state_store()
1861 "Failed - Channel Busy\n"); in raid_state_store()
1862 count = -EBUSY; in raid_state_store()
1866 "Failed - Unexpected Status %04X\n", status); in raid_state_store()
1867 count = -EIO; in raid_state_store()
1879 if (sdev->channel == myrb_logical_channel(sdev->host)) { in raid_level_show()
1880 struct myrb_ldev_info *ldev_info = sdev->hostdata; in raid_level_show()
1881 const char *name; in raid_level_show() local
1884 return -ENXIO; in raid_level_show()
1886 name = myrb_raidlevel_name(ldev_info->raid_level); in raid_level_show()
1887 if (!name) in raid_level_show()
1889 ldev_info->state); in raid_level_show()
1890 return snprintf(buf, 64, "%s\n", name); in raid_level_show()
1900 struct myrb_hba *cb = shost_priv(sdev->host); in rebuild_show()
1904 if (sdev->channel < myrb_logical_channel(sdev->host)) in rebuild_show()
1905 return snprintf(buf, 64, "physical device - not rebuilding\n"); in rebuild_show()
1909 if (rbld_buf.ldev_num != sdev->id || in rebuild_show()
1914 rbld_buf.ldev_size - rbld_buf.blocks_left, in rebuild_show()
1922 struct myrb_hba *cb = shost_priv(sdev->host); in rebuild_store()
1924 union myrb_cmd_mbox *mbox; in rebuild_store() local
1933 if (sdev->channel >= myrb_logical_channel(sdev->host)) in rebuild_store()
1934 return -ENXIO; in rebuild_store()
1941 return -EALREADY; in rebuild_store()
1943 mutex_lock(&cb->dcmd_mutex); in rebuild_store()
1944 cmd_blk = &cb->dcmd_blk; in rebuild_store()
1946 mbox = &cmd_blk->mbox; in rebuild_store()
1947 mbox->type3D.opcode = MYRB_CMD_REBUILD_ASYNC; in rebuild_store()
1948 mbox->type3D.id = MYRB_DCMD_TAG; in rebuild_store()
1949 mbox->type3D.channel = sdev->channel; in rebuild_store()
1950 mbox->type3D.target = sdev->id; in rebuild_store()
1952 mutex_unlock(&cb->dcmd_mutex); in rebuild_store()
1954 struct pci_dev *pdev = cb->pdev; in rebuild_store()
1964 rate = dma_alloc_coherent(&pdev->dev, sizeof(char), in rebuild_store()
1968 "Cancellation of Rebuild Failed - Out of Memory\n"); in rebuild_store()
1969 return -ENOMEM; in rebuild_store()
1971 mutex_lock(&cb->dcmd_mutex); in rebuild_store()
1972 cmd_blk = &cb->dcmd_blk; in rebuild_store()
1974 mbox = &cmd_blk->mbox; in rebuild_store()
1975 mbox->type3R.opcode = MYRB_CMD_REBUILD_CONTROL; in rebuild_store()
1976 mbox->type3R.id = MYRB_DCMD_TAG; in rebuild_store()
1977 mbox->type3R.rbld_rate = 0xFF; in rebuild_store()
1978 mbox->type3R.addr = rate_addr; in rebuild_store()
1980 dma_free_coherent(&pdev->dev, sizeof(char), rate, rate_addr); in rebuild_store()
1981 mutex_unlock(&cb->dcmd_mutex); in rebuild_store()
1992 return -EIO; in rebuild_store()
2014 "Rebuild Failed - %s\n", msg); in rebuild_store()
2019 return -EIO; in rebuild_store()
2027 struct myrb_hba *cb = shost_priv(sdev->host); in consistency_check_store()
2030 union myrb_cmd_mbox *mbox; in consistency_check_store() local
2040 if (sdev->channel < myrb_logical_channel(sdev->host)) in consistency_check_store()
2041 return -ENXIO; in consistency_check_store()
2048 return -EALREADY; in consistency_check_store()
2050 mutex_lock(&cb->dcmd_mutex); in consistency_check_store()
2051 cmd_blk = &cb->dcmd_blk; in consistency_check_store()
2053 mbox = &cmd_blk->mbox; in consistency_check_store()
2054 mbox->type3C.opcode = MYRB_CMD_CHECK_CONSISTENCY_ASYNC; in consistency_check_store()
2055 mbox->type3C.id = MYRB_DCMD_TAG; in consistency_check_store()
2056 mbox->type3C.ldev_num = sdev->id; in consistency_check_store()
2057 mbox->type3C.auto_restore = true; in consistency_check_store()
2060 mutex_unlock(&cb->dcmd_mutex); in consistency_check_store()
2062 struct pci_dev *pdev = cb->pdev; in consistency_check_store()
2066 if (ldev_num != sdev->id) { in consistency_check_store()
2071 rate = dma_alloc_coherent(&pdev->dev, sizeof(char), in consistency_check_store()
2075 "Cancellation of Check Consistency Failed - Out of Memory\n"); in consistency_check_store()
2076 return -ENOMEM; in consistency_check_store()
2078 mutex_lock(&cb->dcmd_mutex); in consistency_check_store()
2079 cmd_blk = &cb->dcmd_blk; in consistency_check_store()
2081 mbox = &cmd_blk->mbox; in consistency_check_store()
2082 mbox->type3R.opcode = MYRB_CMD_REBUILD_CONTROL; in consistency_check_store()
2083 mbox->type3R.id = MYRB_DCMD_TAG; in consistency_check_store()
2084 mbox->type3R.rbld_rate = 0xFF; in consistency_check_store()
2085 mbox->type3R.addr = rate_addr; in consistency_check_store()
2087 dma_free_coherent(&pdev->dev, sizeof(char), rate, rate_addr); in consistency_check_store()
2088 mutex_unlock(&cb->dcmd_mutex); in consistency_check_store()
2099 return -EIO; in consistency_check_store()
2121 "Check Consistency Failed - %s\n", msg); in consistency_check_store()
2126 return -EIO; in consistency_check_store()
2142 return snprintf(buf, 20, "%u\n", cb->ctlr_num); in ctlr_num_show()
2152 return snprintf(buf, 16, "%s\n", cb->fw_version); in firmware_show()
2162 return snprintf(buf, 16, "%s\n", cb->model_name); in model_show()
2181 return -EIO; in flush_cache_store()
2207 .name = "DAC960",
2218 .this_id = -1,
2222 * myrb_is_raid - return boolean indicating device is raid volume
2229 return sdev->channel == myrb_logical_channel(sdev->host); in myrb_is_raid()
2233 * myrb_get_resync - get raid volume resync percent complete
2239 struct myrb_hba *cb = shost_priv(sdev->host); in myrb_get_resync()
2245 if (sdev->channel < myrb_logical_channel(sdev->host)) in myrb_get_resync()
2249 if (rbld_buf.ldev_num == sdev->id) { in myrb_get_resync()
2255 percent_complete = (ldev_size - remaining) * 100 / ldev_size; in myrb_get_resync()
2260 * myrb_get_state - get raid volume status
2266 struct myrb_hba *cb = shost_priv(sdev->host); in myrb_get_state()
2267 struct myrb_ldev_info *ldev_info = sdev->hostdata; in myrb_get_state()
2271 if (sdev->channel < myrb_logical_channel(sdev->host) || !ldev_info) in myrb_get_state()
2278 switch (ldev_info->state) { in myrb_get_state()
2311 if (cmd_blk->dcdb) { in myrb_handle_scsi()
2312 memcpy(scmd->sense_buffer, &cmd_blk->dcdb->sense, 64); in myrb_handle_scsi()
2313 dma_pool_free(cb->dcdb_pool, cmd_blk->dcdb, in myrb_handle_scsi()
2314 cmd_blk->dcdb_addr); in myrb_handle_scsi()
2315 cmd_blk->dcdb = NULL; in myrb_handle_scsi()
2317 if (cmd_blk->sgl) { in myrb_handle_scsi()
2318 dma_pool_free(cb->sg_pool, cmd_blk->sgl, cmd_blk->sgl_addr); in myrb_handle_scsi()
2319 cmd_blk->sgl = NULL; in myrb_handle_scsi()
2320 cmd_blk->sgl_addr = 0; in myrb_handle_scsi()
2322 status = cmd_blk->status; in myrb_handle_scsi()
2326 scmd->result = (DID_OK << 16) | status; in myrb_handle_scsi()
2329 dev_dbg(&scmd->device->sdev_gendev, in myrb_handle_scsi()
2331 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in myrb_handle_scsi()
2340 if (scmd->sc_data_direction == DMA_FROM_DEVICE) in myrb_handle_scsi()
2341 /* Unrecovered read error, auto-reallocation failed */ in myrb_handle_scsi()
2344 /* Write error, auto-reallocation failed */ in myrb_handle_scsi()
2348 dev_dbg(&scmd->device->sdev_gendev, in myrb_handle_scsi()
2350 scmd->result = (DID_BAD_TARGET << 16); in myrb_handle_scsi()
2353 dev_dbg(&scmd->device->sdev_gendev, in myrb_handle_scsi()
2359 dev_dbg(&scmd->device->sdev_gendev, "Device nonresponsive\n"); in myrb_handle_scsi()
2360 scmd->result = (DID_BAD_TARGET << 16); in myrb_handle_scsi()
2365 scmd->result = (DID_ERROR << 16); in myrb_handle_scsi()
2376 if (cmd_blk->completion) { in myrb_handle_cmdblk()
2377 complete(cmd_blk->completion); in myrb_handle_cmdblk()
2378 cmd_blk->completion = NULL; in myrb_handle_cmdblk()
2386 struct Scsi_Host *shost = cb->host; in myrb_monitor()
2389 dev_dbg(&shost->shost_gendev, "monitor tick\n"); in myrb_monitor()
2391 if (cb->new_ev_seq > cb->old_ev_seq) { in myrb_monitor()
2392 int event = cb->old_ev_seq; in myrb_monitor()
2394 dev_dbg(&shost->shost_gendev, in myrb_monitor()
2396 cb->new_ev_seq, event); in myrb_monitor()
2398 cb->old_ev_seq = event + 1; in myrb_monitor()
2400 } else if (cb->need_err_info) { in myrb_monitor()
2401 cb->need_err_info = false; in myrb_monitor()
2402 dev_dbg(&shost->shost_gendev, "get error table\n"); in myrb_monitor()
2405 } else if (cb->need_rbld && cb->rbld_first) { in myrb_monitor()
2406 cb->need_rbld = false; in myrb_monitor()
2407 dev_dbg(&shost->shost_gendev, in myrb_monitor()
2411 } else if (cb->need_ldev_info) { in myrb_monitor()
2412 cb->need_ldev_info = false; in myrb_monitor()
2413 dev_dbg(&shost->shost_gendev, in myrb_monitor()
2417 } else if (cb->need_rbld) { in myrb_monitor()
2418 cb->need_rbld = false; in myrb_monitor()
2419 dev_dbg(&shost->shost_gendev, in myrb_monitor()
2423 } else if (cb->need_cc_status) { in myrb_monitor()
2424 cb->need_cc_status = false; in myrb_monitor()
2425 dev_dbg(&shost->shost_gendev, in myrb_monitor()
2429 } else if (cb->need_bgi_status) { in myrb_monitor()
2430 cb->need_bgi_status = false; in myrb_monitor()
2431 dev_dbg(&shost->shost_gendev, "get background init status\n"); in myrb_monitor()
2435 dev_dbg(&shost->shost_gendev, "new enquiry\n"); in myrb_monitor()
2436 mutex_lock(&cb->dma_mutex); in myrb_monitor()
2438 mutex_unlock(&cb->dma_mutex); in myrb_monitor()
2439 if ((cb->new_ev_seq - cb->old_ev_seq > 0) || in myrb_monitor()
2440 cb->need_err_info || cb->need_rbld || in myrb_monitor()
2441 cb->need_ldev_info || cb->need_cc_status || in myrb_monitor()
2442 cb->need_bgi_status) { in myrb_monitor()
2443 dev_dbg(&shost->shost_gendev, in myrb_monitor()
2449 cb->primary_monitor_time = jiffies; in myrb_monitor()
2450 queue_delayed_work(cb->work_q, &cb->monitor_work, interval); in myrb_monitor()
2454 * myrb_err_status - reports controller BIOS messages
2464 struct pci_dev *pdev = cb->pdev; in myrb_err_status()
2468 dev_info(&pdev->dev, in myrb_err_status()
2473 dev_notice(&pdev->dev, "Spinning Up Drives\n"); in myrb_err_status()
2476 dev_notice(&pdev->dev, "Configuration Checksum Error\n"); in myrb_err_status()
2479 dev_notice(&pdev->dev, "Mirror Race Recovery Failed\n"); in myrb_err_status()
2482 dev_notice(&pdev->dev, "Mirror Race Recovery In Progress\n"); in myrb_err_status()
2485 dev_notice(&pdev->dev, "Physical Device %d:%d COD Mismatch\n", in myrb_err_status()
2489 dev_notice(&pdev->dev, "Logical Drive Installation Aborted\n"); in myrb_err_status()
2492 dev_notice(&pdev->dev, "Mirror Race On A Critical Logical Drive\n"); in myrb_err_status()
2495 dev_notice(&pdev->dev, "New Controller Configuration Found\n"); in myrb_err_status()
2498 dev_err(&pdev->dev, "Fatal Memory Parity Error\n"); in myrb_err_status()
2501 dev_err(&pdev->dev, "Unknown Initialization Error %02X\n", in myrb_err_status()
2509 * Hardware-specific functions
2585 union myrb_cmd_mbox *mbox) in DAC960_LA_write_cmd_mbox() argument
2587 mem_mbox->words[1] = mbox->words[1]; in DAC960_LA_write_cmd_mbox()
2588 mem_mbox->words[2] = mbox->words[2]; in DAC960_LA_write_cmd_mbox()
2589 mem_mbox->words[3] = mbox->words[3]; in DAC960_LA_write_cmd_mbox()
2592 mem_mbox->words[0] = mbox->words[0]; in DAC960_LA_write_cmd_mbox()
2598 union myrb_cmd_mbox *mbox) in DAC960_LA_write_hw_mbox() argument
2600 writel(mbox->words[0], base + DAC960_LA_CMDOP_OFFSET); in DAC960_LA_write_hw_mbox()
2601 writel(mbox->words[1], base + DAC960_LA_MBOX4_OFFSET); in DAC960_LA_write_hw_mbox()
2602 writel(mbox->words[2], base + DAC960_LA_MBOX8_OFFSET); in DAC960_LA_write_hw_mbox()
2603 writeb(mbox->bytes[12], base + DAC960_LA_MBOX12_OFFSET); in DAC960_LA_write_hw_mbox()
2630 union myrb_cmd_mbox *mbox) in DAC960_LA_mbox_init() argument
2642 dev_err(&pdev->dev, in DAC960_LA_mbox_init()
2646 DAC960_LA_write_hw_mbox(base, mbox); in DAC960_LA_mbox_init()
2656 dev_err(&pdev->dev, "Timeout waiting for mailbox status\n"); in DAC960_LA_mbox_init()
2680 return -ENODEV; in DAC960_LA_hw_init()
2685 dev_err(&pdev->dev, in DAC960_LA_hw_init()
2687 return -ETIMEDOUT; in DAC960_LA_hw_init()
2690 dev_err(&pdev->dev, in DAC960_LA_hw_init()
2693 return -ENODEV; in DAC960_LA_hw_init()
2696 cb->qcmd = myrb_qcmd; in DAC960_LA_hw_init()
2697 cb->write_cmd_mbox = DAC960_LA_write_cmd_mbox; in DAC960_LA_hw_init()
2698 if (cb->dual_mode_interface) in DAC960_LA_hw_init()
2699 cb->get_cmd_mbox = DAC960_LA_mem_mbox_new_cmd; in DAC960_LA_hw_init()
2701 cb->get_cmd_mbox = DAC960_LA_hw_mbox_new_cmd; in DAC960_LA_hw_init()
2702 cb->disable_intr = DAC960_LA_disable_intr; in DAC960_LA_hw_init()
2703 cb->reset = DAC960_LA_reset_ctrl; in DAC960_LA_hw_init()
2711 void __iomem *base = cb->io_base; in DAC960_LA_intr_handler()
2715 spin_lock_irqsave(&cb->queue_lock, flags); in DAC960_LA_intr_handler()
2717 next_stat_mbox = cb->next_stat_mbox; in DAC960_LA_intr_handler()
2718 while (next_stat_mbox->valid) { in DAC960_LA_intr_handler()
2719 unsigned char id = next_stat_mbox->id; in DAC960_LA_intr_handler()
2724 cmd_blk = &cb->dcmd_blk; in DAC960_LA_intr_handler()
2726 cmd_blk = &cb->mcmd_blk; in DAC960_LA_intr_handler()
2728 scmd = scsi_host_find_tag(cb->host, id - 3); in DAC960_LA_intr_handler()
2733 cmd_blk->status = next_stat_mbox->status; in DAC960_LA_intr_handler()
2735 dev_err(&cb->pdev->dev, in DAC960_LA_intr_handler()
2739 if (++next_stat_mbox > cb->last_stat_mbox) in DAC960_LA_intr_handler()
2740 next_stat_mbox = cb->first_stat_mbox; in DAC960_LA_intr_handler()
2749 cb->next_stat_mbox = next_stat_mbox; in DAC960_LA_intr_handler()
2750 spin_unlock_irqrestore(&cb->queue_lock, flags); in DAC960_LA_intr_handler()
2817 unsigned int imask = (unsigned int)-1; in DAC960_PG_enable_intr()
2825 unsigned int imask = (unsigned int)-1; in DAC960_PG_disable_intr()
2831 union myrb_cmd_mbox *mbox) in DAC960_PG_write_cmd_mbox() argument
2833 mem_mbox->words[1] = mbox->words[1]; in DAC960_PG_write_cmd_mbox()
2834 mem_mbox->words[2] = mbox->words[2]; in DAC960_PG_write_cmd_mbox()
2835 mem_mbox->words[3] = mbox->words[3]; in DAC960_PG_write_cmd_mbox()
2838 mem_mbox->words[0] = mbox->words[0]; in DAC960_PG_write_cmd_mbox()
2844 union myrb_cmd_mbox *mbox) in DAC960_PG_write_hw_mbox() argument
2846 writel(mbox->words[0], base + DAC960_PG_CMDOP_OFFSET); in DAC960_PG_write_hw_mbox()
2847 writel(mbox->words[1], base + DAC960_PG_MBOX4_OFFSET); in DAC960_PG_write_hw_mbox()
2848 writel(mbox->words[2], base + DAC960_PG_MBOX8_OFFSET); in DAC960_PG_write_hw_mbox()
2849 writeb(mbox->bytes[12], base + DAC960_PG_MBOX12_OFFSET); in DAC960_PG_write_hw_mbox()
2876 union myrb_cmd_mbox *mbox) in DAC960_PG_mbox_init() argument
2888 dev_err(&pdev->dev, in DAC960_PG_mbox_init()
2892 DAC960_PG_write_hw_mbox(base, mbox); in DAC960_PG_mbox_init()
2903 dev_err(&pdev->dev, in DAC960_PG_mbox_init()
2928 return -EIO; in DAC960_PG_hw_init()
2933 dev_err(&pdev->dev, in DAC960_PG_hw_init()
2935 return -ETIMEDOUT; in DAC960_PG_hw_init()
2938 dev_err(&pdev->dev, in DAC960_PG_hw_init()
2941 return -ENODEV; in DAC960_PG_hw_init()
2944 cb->qcmd = myrb_qcmd; in DAC960_PG_hw_init()
2945 cb->write_cmd_mbox = DAC960_PG_write_cmd_mbox; in DAC960_PG_hw_init()
2946 if (cb->dual_mode_interface) in DAC960_PG_hw_init()
2947 cb->get_cmd_mbox = DAC960_PG_mem_mbox_new_cmd; in DAC960_PG_hw_init()
2949 cb->get_cmd_mbox = DAC960_PG_hw_mbox_new_cmd; in DAC960_PG_hw_init()
2950 cb->disable_intr = DAC960_PG_disable_intr; in DAC960_PG_hw_init()
2951 cb->reset = DAC960_PG_reset_ctrl; in DAC960_PG_hw_init()
2959 void __iomem *base = cb->io_base; in DAC960_PG_intr_handler()
2963 spin_lock_irqsave(&cb->queue_lock, flags); in DAC960_PG_intr_handler()
2965 next_stat_mbox = cb->next_stat_mbox; in DAC960_PG_intr_handler()
2966 while (next_stat_mbox->valid) { in DAC960_PG_intr_handler()
2967 unsigned char id = next_stat_mbox->id; in DAC960_PG_intr_handler()
2972 cmd_blk = &cb->dcmd_blk; in DAC960_PG_intr_handler()
2974 cmd_blk = &cb->mcmd_blk; in DAC960_PG_intr_handler()
2976 scmd = scsi_host_find_tag(cb->host, id - 3); in DAC960_PG_intr_handler()
2981 cmd_blk->status = next_stat_mbox->status; in DAC960_PG_intr_handler()
2983 dev_err(&cb->pdev->dev, in DAC960_PG_intr_handler()
2987 if (++next_stat_mbox > cb->last_stat_mbox) in DAC960_PG_intr_handler()
2988 next_stat_mbox = cb->first_stat_mbox; in DAC960_PG_intr_handler()
2995 cb->next_stat_mbox = next_stat_mbox; in DAC960_PG_intr_handler()
2996 spin_unlock_irqrestore(&cb->queue_lock, flags); in DAC960_PG_intr_handler()
3063 union myrb_cmd_mbox *mbox) in DAC960_PD_write_cmd_mbox() argument
3065 writel(mbox->words[0], base + DAC960_PD_CMDOP_OFFSET); in DAC960_PD_write_cmd_mbox()
3066 writel(mbox->words[1], base + DAC960_PD_MBOX4_OFFSET); in DAC960_PD_write_cmd_mbox()
3067 writel(mbox->words[2], base + DAC960_PD_MBOX8_OFFSET); in DAC960_PD_write_cmd_mbox()
3068 writeb(mbox->bytes[12], base + DAC960_PD_MBOX12_OFFSET); in DAC960_PD_write_cmd_mbox()
3101 void __iomem *base = cb->io_base; in DAC960_PD_qcmd()
3102 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in DAC960_PD_qcmd() local
3106 DAC960_PD_write_cmd_mbox(base, mbox); in DAC960_PD_qcmd()
3116 if (!request_region(cb->io_addr, 0x80, "myrb")) { in DAC960_PD_hw_init()
3117 dev_err(&pdev->dev, "IO port 0x%lx busy\n", in DAC960_PD_hw_init()
3118 (unsigned long)cb->io_addr); in DAC960_PD_hw_init()
3119 return -EBUSY; in DAC960_PD_hw_init()
3129 return -EIO; in DAC960_PD_hw_init()
3134 dev_err(&pdev->dev, in DAC960_PD_hw_init()
3136 return -ETIMEDOUT; in DAC960_PD_hw_init()
3139 dev_err(&pdev->dev, in DAC960_PD_hw_init()
3142 return -ENODEV; in DAC960_PD_hw_init()
3145 cb->qcmd = DAC960_PD_qcmd; in DAC960_PD_hw_init()
3146 cb->disable_intr = DAC960_PD_disable_intr; in DAC960_PD_hw_init()
3147 cb->reset = DAC960_PD_reset_ctrl; in DAC960_PD_hw_init()
3155 void __iomem *base = cb->io_base; in DAC960_PD_intr_handler()
3158 spin_lock_irqsave(&cb->queue_lock, flags); in DAC960_PD_intr_handler()
3165 cmd_blk = &cb->dcmd_blk; in DAC960_PD_intr_handler()
3167 cmd_blk = &cb->mcmd_blk; in DAC960_PD_intr_handler()
3169 scmd = scsi_host_find_tag(cb->host, id - 3); in DAC960_PD_intr_handler()
3174 cmd_blk->status = DAC960_PD_read_status(base); in DAC960_PD_intr_handler()
3176 dev_err(&cb->pdev->dev, in DAC960_PD_intr_handler()
3187 spin_unlock_irqrestore(&cb->queue_lock, flags); in DAC960_PD_intr_handler()
3220 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_translate_to_rw_command() local
3221 int ldev_num = mbox->type5.ld.ldev_num; in myrb_translate_to_rw_command()
3223 mbox->bytes[3] &= 0x7; in myrb_translate_to_rw_command()
3224 mbox->bytes[3] |= mbox->bytes[7] << 6; in myrb_translate_to_rw_command()
3225 mbox->bytes[7] = ldev_num; in myrb_translate_to_rw_command()
3230 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in myrb_translate_from_rw_command() local
3231 int ldev_num = mbox->bytes[7]; in myrb_translate_from_rw_command()
3233 mbox->bytes[7] = mbox->bytes[3] >> 6; in myrb_translate_from_rw_command()
3234 mbox->bytes[3] &= 0x7; in myrb_translate_from_rw_command()
3235 mbox->bytes[3] |= ldev_num << 3; in myrb_translate_from_rw_command()
3240 void __iomem *base = cb->io_base; in DAC960_P_qcmd()
3241 union myrb_cmd_mbox *mbox = &cmd_blk->mbox; in DAC960_P_qcmd() local
3243 switch (mbox->common.opcode) { in DAC960_P_qcmd()
3245 mbox->common.opcode = MYRB_CMD_ENQUIRY_OLD; in DAC960_P_qcmd()
3248 mbox->common.opcode = MYRB_CMD_GET_DEVICE_STATE_OLD; in DAC960_P_qcmd()
3251 mbox->common.opcode = MYRB_CMD_READ_OLD; in DAC960_P_qcmd()
3255 mbox->common.opcode = MYRB_CMD_WRITE_OLD; in DAC960_P_qcmd()
3259 mbox->common.opcode = MYRB_CMD_READ_SG_OLD; in DAC960_P_qcmd()
3263 mbox->common.opcode = MYRB_CMD_WRITE_SG_OLD; in DAC960_P_qcmd()
3271 DAC960_PD_write_cmd_mbox(base, mbox); in DAC960_P_qcmd()
3282 if (!request_region(cb->io_addr, 0x80, "myrb")) { in DAC960_P_hw_init()
3283 dev_err(&pdev->dev, "IO port 0x%lx busy\n", in DAC960_P_hw_init()
3284 (unsigned long)cb->io_addr); in DAC960_P_hw_init()
3285 return -EBUSY; in DAC960_P_hw_init()
3295 return -EAGAIN; in DAC960_P_hw_init()
3300 dev_err(&pdev->dev, in DAC960_P_hw_init()
3302 return -ETIMEDOUT; in DAC960_P_hw_init()
3305 dev_err(&pdev->dev, in DAC960_P_hw_init()
3308 return -ETIMEDOUT; in DAC960_P_hw_init()
3311 cb->qcmd = DAC960_P_qcmd; in DAC960_P_hw_init()
3312 cb->disable_intr = DAC960_PD_disable_intr; in DAC960_P_hw_init()
3313 cb->reset = DAC960_PD_reset_ctrl; in DAC960_P_hw_init()
3321 void __iomem *base = cb->io_base; in DAC960_P_intr_handler()
3324 spin_lock_irqsave(&cb->queue_lock, flags); in DAC960_P_intr_handler()
3329 union myrb_cmd_mbox *mbox; in DAC960_P_intr_handler() local
3334 cmd_blk = &cb->dcmd_blk; in DAC960_P_intr_handler()
3336 cmd_blk = &cb->mcmd_blk; in DAC960_P_intr_handler()
3338 scmd = scsi_host_find_tag(cb->host, id - 3); in DAC960_P_intr_handler()
3343 cmd_blk->status = DAC960_PD_read_status(base); in DAC960_P_intr_handler()
3345 dev_err(&cb->pdev->dev, in DAC960_P_intr_handler()
3354 mbox = &cmd_blk->mbox; in DAC960_P_intr_handler()
3355 op = mbox->common.opcode; in DAC960_P_intr_handler()
3358 mbox->common.opcode = MYRB_CMD_ENQUIRY; in DAC960_P_intr_handler()
3359 myrb_translate_enquiry(cb->enquiry); in DAC960_P_intr_handler()
3362 mbox->common.opcode = MYRB_CMD_READ; in DAC960_P_intr_handler()
3366 mbox->common.opcode = MYRB_CMD_WRITE; in DAC960_P_intr_handler()
3370 mbox->common.opcode = MYRB_CMD_READ_SG; in DAC960_P_intr_handler()
3374 mbox->common.opcode = MYRB_CMD_WRITE_SG; in DAC960_P_intr_handler()
3385 spin_unlock_irqrestore(&cb->queue_lock, flags); in DAC960_P_intr_handler()
3399 (struct myrb_privdata *)entry->driver_data; in myrb_detect()
3400 irq_handler_t irq_handler = privdata->irq_handler; in myrb_detect()
3401 unsigned int mmio_size = privdata->mmio_size; in myrb_detect()
3407 dev_err(&pdev->dev, "Unable to allocate Controller\n"); in myrb_detect()
3410 shost->max_cmd_len = 12; in myrb_detect()
3411 shost->max_lun = 256; in myrb_detect()
3413 mutex_init(&cb->dcmd_mutex); in myrb_detect()
3414 mutex_init(&cb->dma_mutex); in myrb_detect()
3415 cb->pdev = pdev; in myrb_detect()
3416 cb->host = shost; in myrb_detect()
3419 dev_err(&pdev->dev, "Failed to enable PCI device\n"); in myrb_detect()
3424 if (privdata->hw_init == DAC960_PD_hw_init || in myrb_detect()
3425 privdata->hw_init == DAC960_P_hw_init) { in myrb_detect()
3426 cb->io_addr = pci_resource_start(pdev, 0); in myrb_detect()
3427 cb->pci_addr = pci_resource_start(pdev, 1); in myrb_detect()
3429 cb->pci_addr = pci_resource_start(pdev, 0); in myrb_detect()
3432 spin_lock_init(&cb->queue_lock); in myrb_detect()
3435 cb->mmio_base = ioremap(cb->pci_addr & PAGE_MASK, mmio_size); in myrb_detect()
3436 if (cb->mmio_base == NULL) { in myrb_detect()
3437 dev_err(&pdev->dev, in myrb_detect()
3442 cb->io_base = cb->mmio_base + (cb->pci_addr & ~PAGE_MASK); in myrb_detect()
3443 if (privdata->hw_init(pdev, cb, cb->io_base)) in myrb_detect()
3446 if (request_irq(pdev->irq, irq_handler, IRQF_SHARED, "myrb", cb) < 0) { in myrb_detect()
3447 dev_err(&pdev->dev, in myrb_detect()
3448 "Unable to acquire IRQ Channel %d\n", pdev->irq); in myrb_detect()
3451 cb->irq = pdev->irq; in myrb_detect()
3455 dev_err(&pdev->dev, in myrb_detect()
3468 return -ENODEV; in myrb_probe()
3477 ret = -ENOMEM; in myrb_probe()
3481 ret = scsi_add_host(cb->host, &dev->dev); in myrb_probe()
3483 dev_err(&dev->dev, "scsi_add_host failed with %d\n", ret); in myrb_probe()
3487 scsi_scan_host(cb->host); in myrb_probe()
3499 shost_printk(KERN_NOTICE, cb->host, "Flushing Cache..."); in myrb_remove()
3529 .name = "myrb",
3541 return -ENODEV; in myrb_init_module()