Lines Matching refs:hba
47 static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec);
48 static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
50 static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 tag);
51 static void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag);
52 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg);
54 static int iop_wait_ready_itl(struct hptiop_hba *hba, u32 millisec) in iop_wait_ready_itl() argument
60 req = readl(&hba->u.itl.iop->inbound_queue); in iop_wait_ready_itl()
67 writel(req, &hba->u.itl.iop->outbound_queue); in iop_wait_ready_itl()
68 readl(&hba->u.itl.iop->outbound_intstatus); in iop_wait_ready_itl()
75 static int iop_wait_ready_mv(struct hptiop_hba *hba, u32 millisec) in iop_wait_ready_mv() argument
77 return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec); in iop_wait_ready_mv()
80 static int iop_wait_ready_mvfrey(struct hptiop_hba *hba, u32 millisec) in iop_wait_ready_mvfrey() argument
82 return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec); in iop_wait_ready_mvfrey()
85 static void hptiop_request_callback_itl(struct hptiop_hba *hba, u32 tag) in hptiop_request_callback_itl() argument
88 hptiop_host_request_callback_itl(hba, in hptiop_request_callback_itl()
91 hptiop_iop_request_callback_itl(hba, tag); in hptiop_request_callback_itl()
94 static void hptiop_drain_outbound_queue_itl(struct hptiop_hba *hba) in hptiop_drain_outbound_queue_itl() argument
98 while ((req = readl(&hba->u.itl.iop->outbound_queue)) != in hptiop_drain_outbound_queue_itl()
102 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
107 ((char __iomem *)hba->u.itl.iop + req); in hptiop_drain_outbound_queue_itl()
111 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
116 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
121 static int iop_intr_itl(struct hptiop_hba *hba) in iop_intr_itl() argument
123 struct hpt_iopmu_itl __iomem *iop = hba->u.itl.iop; in iop_intr_itl()
124 void __iomem *plx = hba->u.itl.plx; in iop_intr_itl()
138 hptiop_message_callback(hba, msg); in iop_intr_itl()
143 hptiop_drain_outbound_queue_itl(hba); in iop_intr_itl()
169 static void mv_inbound_write(u64 p, struct hptiop_hba *hba) in mv_inbound_write() argument
171 u32 inbound_head = readl(&hba->u.mv.mu->inbound_head); in mv_inbound_write()
177 memcpy_toio(&hba->u.mv.mu->inbound_q[inbound_head], &p, 8); in mv_inbound_write()
178 writel(head, &hba->u.mv.mu->inbound_head); in mv_inbound_write()
180 &hba->u.mv.regs->inbound_doorbell); in mv_inbound_write()
183 static void hptiop_request_callback_mv(struct hptiop_hba *hba, u64 tag) in hptiop_request_callback_mv() argument
195 hba->msg_done = 1; in hptiop_request_callback_mv()
199 req = hba->reqs[tag >> 8].req_virt; in hptiop_request_callback_mv()
203 hptiop_finish_scsi_req(hba, tag>>8, req); in hptiop_request_callback_mv()
211 static int iop_intr_mv(struct hptiop_hba *hba) in iop_intr_mv() argument
216 status = readl(&hba->u.mv.regs->outbound_doorbell); in iop_intr_mv()
217 writel(~status, &hba->u.mv.regs->outbound_doorbell); in iop_intr_mv()
221 msg = readl(&hba->u.mv.mu->outbound_msg); in iop_intr_mv()
223 hptiop_message_callback(hba, msg); in iop_intr_mv()
230 while ((tag = mv_outbound_read(hba->u.mv.mu))) in iop_intr_mv()
231 hptiop_request_callback_mv(hba, tag); in iop_intr_mv()
238 static void hptiop_request_callback_mvfrey(struct hptiop_hba *hba, u32 _tag) in hptiop_request_callback_mvfrey() argument
246 hba->msg_done = 1; in hptiop_request_callback_mvfrey()
250 req = hba->reqs[(_tag >> 4) & 0xff].req_virt; in hptiop_request_callback_mvfrey()
253 hptiop_finish_scsi_req(hba, (_tag >> 4) & 0xff, req); in hptiop_request_callback_mvfrey()
261 static int iop_intr_mvfrey(struct hptiop_hba *hba) in iop_intr_mvfrey() argument
266 if (hba->initialized) in iop_intr_mvfrey()
267 writel(0, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in iop_intr_mvfrey()
269 status = readl(&(hba->u.mvfrey.mu->f0_doorbell)); in iop_intr_mvfrey()
271 writel(status, &(hba->u.mvfrey.mu->f0_doorbell)); in iop_intr_mvfrey()
273 u32 msg = readl(&(hba->u.mvfrey.mu->cpu_to_f0_msg_a)); in iop_intr_mvfrey()
275 hptiop_message_callback(hba, msg); in iop_intr_mvfrey()
280 status = readl(&(hba->u.mvfrey.mu->isr_cause)); in iop_intr_mvfrey()
282 writel(status, &(hba->u.mvfrey.mu->isr_cause)); in iop_intr_mvfrey()
284 cptr = *hba->u.mvfrey.outlist_cptr & 0xff; in iop_intr_mvfrey()
285 cur_rptr = hba->u.mvfrey.outlist_rptr; in iop_intr_mvfrey()
288 if (cur_rptr == hba->u.mvfrey.list_count) in iop_intr_mvfrey()
291 _tag = hba->u.mvfrey.outlist[cur_rptr].val; in iop_intr_mvfrey()
293 hptiop_request_callback_mvfrey(hba, _tag); in iop_intr_mvfrey()
296 hba->u.mvfrey.outlist_rptr = cur_rptr; in iop_intr_mvfrey()
297 } while (cptr != (*hba->u.mvfrey.outlist_cptr & 0xff)); in iop_intr_mvfrey()
300 if (hba->initialized) in iop_intr_mvfrey()
301 writel(0x1010, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in iop_intr_mvfrey()
306 static int iop_send_sync_request_itl(struct hptiop_hba *hba, in iop_send_sync_request_itl() argument
314 writel((unsigned long)req - (unsigned long)hba->u.itl.iop, in iop_send_sync_request_itl()
315 &hba->u.itl.iop->inbound_queue); in iop_send_sync_request_itl()
316 readl(&hba->u.itl.iop->outbound_intstatus); in iop_send_sync_request_itl()
319 iop_intr_itl(hba); in iop_send_sync_request_itl()
328 static int iop_send_sync_request_mv(struct hptiop_hba *hba, in iop_send_sync_request_mv() argument
331 struct hpt_iop_request_header *reqhdr = hba->u.mv.internal_req; in iop_send_sync_request_mv()
334 hba->msg_done = 0; in iop_send_sync_request_mv()
336 mv_inbound_write(hba->u.mv.internal_req_phy | in iop_send_sync_request_mv()
337 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bits, hba); in iop_send_sync_request_mv()
340 iop_intr_mv(hba); in iop_send_sync_request_mv()
341 if (hba->msg_done) in iop_send_sync_request_mv()
348 static int iop_send_sync_request_mvfrey(struct hptiop_hba *hba, in iop_send_sync_request_mvfrey() argument
352 hba->u.mvfrey.internal_req.req_virt; in iop_send_sync_request_mvfrey()
355 hba->msg_done = 0; in iop_send_sync_request_mvfrey()
357 hba->ops->post_req(hba, &(hba->u.mvfrey.internal_req)); in iop_send_sync_request_mvfrey()
360 iop_intr_mvfrey(hba); in iop_send_sync_request_mvfrey()
361 if (hba->msg_done) in iop_send_sync_request_mvfrey()
365 return hba->msg_done ? 0 : -1; in iop_send_sync_request_mvfrey()
368 static void hptiop_post_msg_itl(struct hptiop_hba *hba, u32 msg) in hptiop_post_msg_itl() argument
370 writel(msg, &hba->u.itl.iop->inbound_msgaddr0); in hptiop_post_msg_itl()
371 readl(&hba->u.itl.iop->outbound_intstatus); in hptiop_post_msg_itl()
374 static void hptiop_post_msg_mv(struct hptiop_hba *hba, u32 msg) in hptiop_post_msg_mv() argument
376 writel(msg, &hba->u.mv.mu->inbound_msg); in hptiop_post_msg_mv()
377 writel(MVIOP_MU_INBOUND_INT_MSG, &hba->u.mv.regs->inbound_doorbell); in hptiop_post_msg_mv()
378 readl(&hba->u.mv.regs->inbound_doorbell); in hptiop_post_msg_mv()
381 static void hptiop_post_msg_mvfrey(struct hptiop_hba *hba, u32 msg) in hptiop_post_msg_mvfrey() argument
383 writel(msg, &(hba->u.mvfrey.mu->f0_to_cpu_msg_a)); in hptiop_post_msg_mvfrey()
384 readl(&(hba->u.mvfrey.mu->f0_to_cpu_msg_a)); in hptiop_post_msg_mvfrey()
387 static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec) in iop_send_sync_msg() argument
391 hba->msg_done = 0; in iop_send_sync_msg()
392 hba->ops->disable_intr(hba); in iop_send_sync_msg()
393 hba->ops->post_msg(hba, msg); in iop_send_sync_msg()
396 spin_lock_irq(hba->host->host_lock); in iop_send_sync_msg()
397 hba->ops->iop_intr(hba); in iop_send_sync_msg()
398 spin_unlock_irq(hba->host->host_lock); in iop_send_sync_msg()
399 if (hba->msg_done) in iop_send_sync_msg()
404 hba->ops->enable_intr(hba); in iop_send_sync_msg()
405 return hba->msg_done? 0 : -1; in iop_send_sync_msg()
408 static int iop_get_config_itl(struct hptiop_hba *hba, in iop_get_config_itl() argument
414 req32 = readl(&hba->u.itl.iop->inbound_queue); in iop_get_config_itl()
419 ((unsigned long)hba->u.itl.iop + req32); in iop_get_config_itl()
426 if (iop_send_sync_request_itl(hba, req, 20000)) { in iop_get_config_itl()
432 writel(req32, &hba->u.itl.iop->outbound_queue); in iop_get_config_itl()
436 static int iop_get_config_mv(struct hptiop_hba *hba, in iop_get_config_mv() argument
439 struct hpt_iop_request_get_config *req = hba->u.mv.internal_req; in iop_get_config_mv()
449 if (iop_send_sync_request_mv(hba, 0, 20000)) { in iop_get_config_mv()
458 static int iop_get_config_mvfrey(struct hptiop_hba *hba, in iop_get_config_mvfrey() argument
461 struct hpt_iop_request_get_config *info = hba->u.mvfrey.config; in iop_get_config_mvfrey()
480 static int iop_set_config_itl(struct hptiop_hba *hba, in iop_set_config_itl() argument
486 req32 = readl(&hba->u.itl.iop->inbound_queue); in iop_set_config_itl()
491 ((unsigned long)hba->u.itl.iop + req32); in iop_set_config_itl()
503 if (iop_send_sync_request_itl(hba, req, 20000)) { in iop_set_config_itl()
508 writel(req32, &hba->u.itl.iop->outbound_queue); in iop_set_config_itl()
512 static int iop_set_config_mv(struct hptiop_hba *hba, in iop_set_config_mv() argument
515 struct hpt_iop_request_set_config *req = hba->u.mv.internal_req; in iop_set_config_mv()
526 if (iop_send_sync_request_mv(hba, 0, 20000)) { in iop_set_config_mv()
534 static int iop_set_config_mvfrey(struct hptiop_hba *hba, in iop_set_config_mvfrey() argument
538 hba->u.mvfrey.internal_req.req_virt; in iop_set_config_mvfrey()
549 if (iop_send_sync_request_mvfrey(hba, 0, 20000)) { in iop_set_config_mvfrey()
557 static void hptiop_enable_intr_itl(struct hptiop_hba *hba) in hptiop_enable_intr_itl() argument
560 &hba->u.itl.iop->outbound_intmask); in hptiop_enable_intr_itl()
563 static void hptiop_enable_intr_mv(struct hptiop_hba *hba) in hptiop_enable_intr_mv() argument
566 &hba->u.mv.regs->outbound_intmask); in hptiop_enable_intr_mv()
569 static void hptiop_enable_intr_mvfrey(struct hptiop_hba *hba) in hptiop_enable_intr_mvfrey() argument
571 writel(CPU_TO_F0_DRBL_MSG_BIT, &(hba->u.mvfrey.mu->f0_doorbell_enable)); in hptiop_enable_intr_mvfrey()
572 writel(0x1, &(hba->u.mvfrey.mu->isr_enable)); in hptiop_enable_intr_mvfrey()
573 writel(0x1010, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in hptiop_enable_intr_mvfrey()
576 static int hptiop_initialize_iop(struct hptiop_hba *hba) in hptiop_initialize_iop() argument
579 hba->ops->enable_intr(hba); in hptiop_initialize_iop()
581 hba->initialized = 1; in hptiop_initialize_iop()
584 if (iop_send_sync_msg(hba, in hptiop_initialize_iop()
587 hba->host->host_no); in hptiop_initialize_iop()
593 static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index) in hptiop_map_pci_bar() argument
598 struct pci_dev *pcidev = hba->pcidev; in hptiop_map_pci_bar()
603 hba->host->host_no); in hptiop_map_pci_bar()
613 hba->host->host_no); in hptiop_map_pci_bar()
619 static int hptiop_map_pci_bar_itl(struct hptiop_hba *hba) in hptiop_map_pci_bar_itl() argument
621 struct pci_dev *pcidev = hba->pcidev; in hptiop_map_pci_bar_itl()
622 hba->u.itl.iop = hptiop_map_pci_bar(hba, 0); in hptiop_map_pci_bar_itl()
623 if (hba->u.itl.iop == NULL) in hptiop_map_pci_bar_itl()
626 hba->u.itl.plx = hba->u.itl.iop; in hptiop_map_pci_bar_itl()
627 hba->u.itl.iop = hptiop_map_pci_bar(hba, 2); in hptiop_map_pci_bar_itl()
628 if (hba->u.itl.iop == NULL) { in hptiop_map_pci_bar_itl()
629 iounmap(hba->u.itl.plx); in hptiop_map_pci_bar_itl()
636 static void hptiop_unmap_pci_bar_itl(struct hptiop_hba *hba) in hptiop_unmap_pci_bar_itl() argument
638 if (hba->u.itl.plx) in hptiop_unmap_pci_bar_itl()
639 iounmap(hba->u.itl.plx); in hptiop_unmap_pci_bar_itl()
640 iounmap(hba->u.itl.iop); in hptiop_unmap_pci_bar_itl()
643 static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba) in hptiop_map_pci_bar_mv() argument
645 hba->u.mv.regs = hptiop_map_pci_bar(hba, 0); in hptiop_map_pci_bar_mv()
646 if (hba->u.mv.regs == NULL) in hptiop_map_pci_bar_mv()
649 hba->u.mv.mu = hptiop_map_pci_bar(hba, 2); in hptiop_map_pci_bar_mv()
650 if (hba->u.mv.mu == NULL) { in hptiop_map_pci_bar_mv()
651 iounmap(hba->u.mv.regs); in hptiop_map_pci_bar_mv()
658 static int hptiop_map_pci_bar_mvfrey(struct hptiop_hba *hba) in hptiop_map_pci_bar_mvfrey() argument
660 hba->u.mvfrey.config = hptiop_map_pci_bar(hba, 0); in hptiop_map_pci_bar_mvfrey()
661 if (hba->u.mvfrey.config == NULL) in hptiop_map_pci_bar_mvfrey()
664 hba->u.mvfrey.mu = hptiop_map_pci_bar(hba, 2); in hptiop_map_pci_bar_mvfrey()
665 if (hba->u.mvfrey.mu == NULL) { in hptiop_map_pci_bar_mvfrey()
666 iounmap(hba->u.mvfrey.config); in hptiop_map_pci_bar_mvfrey()
673 static void hptiop_unmap_pci_bar_mv(struct hptiop_hba *hba) in hptiop_unmap_pci_bar_mv() argument
675 iounmap(hba->u.mv.regs); in hptiop_unmap_pci_bar_mv()
676 iounmap(hba->u.mv.mu); in hptiop_unmap_pci_bar_mv()
679 static void hptiop_unmap_pci_bar_mvfrey(struct hptiop_hba *hba) in hptiop_unmap_pci_bar_mvfrey() argument
681 iounmap(hba->u.mvfrey.config); in hptiop_unmap_pci_bar_mvfrey()
682 iounmap(hba->u.mvfrey.mu); in hptiop_unmap_pci_bar_mvfrey()
685 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg) in hptiop_message_callback() argument
691 hba->msg_done = 1; in hptiop_message_callback()
693 if (!hba->initialized) in hptiop_message_callback()
697 atomic_set(&hba->resetting, 0); in hptiop_message_callback()
698 wake_up(&hba->reset_wq); in hptiop_message_callback()
701 hba->msg_done = 1; in hptiop_message_callback()
704 static struct hptiop_request *get_req(struct hptiop_hba *hba) in get_req() argument
708 dprintk("get_req : req=%p\n", hba->req_list); in get_req()
710 ret = hba->req_list; in get_req()
712 hba->req_list = ret->next; in get_req()
717 static void free_req(struct hptiop_hba *hba, struct hptiop_request *req) in free_req() argument
720 req->next = hba->req_list; in free_req()
721 hba->req_list = req; in free_req()
724 static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag, in hptiop_finish_scsi_req() argument
737 scp = hba->reqs[tag].scp; in hptiop_finish_scsi_req()
782 free_req(hba, &hba->reqs[tag]); in hptiop_finish_scsi_req()
785 static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 _tag) in hptiop_host_request_callback_itl() argument
790 if (hba->iopintf_v2) { in hptiop_host_request_callback_itl()
792 req = hba->reqs[tag].req_virt; in hptiop_host_request_callback_itl()
797 req = hba->reqs[tag].req_virt; in hptiop_host_request_callback_itl()
800 hptiop_finish_scsi_req(hba, tag, req); in hptiop_host_request_callback_itl()
803 void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag) in hptiop_iop_request_callback_itl() argument
810 ((unsigned long)hba->u.itl.iop + tag); in hptiop_iop_request_callback_itl()
839 writel(tag, &hba->u.itl.iop->outbound_queue); in hptiop_iop_request_callback_itl()
844 struct hptiop_hba *hba = dev_id; in hptiop_intr() local
848 spin_lock_irqsave(hba->host->host_lock, flags); in hptiop_intr()
849 handled = hba->ops->iop_intr(hba); in hptiop_intr()
850 spin_unlock_irqrestore(hba->host->host_lock, flags); in hptiop_intr()
858 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_buildsgl() local
870 BUG_ON(HPT_SCP(scp)->sgcnt > hba->max_sg_descriptors); in hptiop_buildsgl()
874 hba->ops->host_phy_flag; in hptiop_buildsgl()
882 static void hptiop_post_req_itl(struct hptiop_hba *hba, in hptiop_post_req_itl() argument
891 if (hba->iopintf_v2) { in hptiop_post_req_itl()
903 &hba->u.itl.iop->inbound_queue); in hptiop_post_req_itl()
906 &hba->u.itl.iop->inbound_queue); in hptiop_post_req_itl()
909 static void hptiop_post_req_mv(struct hptiop_hba *hba, in hptiop_post_req_mv() argument
930 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba); in hptiop_post_req_mv()
933 static void hptiop_post_req_mvfrey(struct hptiop_hba *hba, in hptiop_post_req_mvfrey() argument
947 hba->u.mvfrey.inlist_wptr++; in hptiop_post_req_mvfrey()
948 index = hba->u.mvfrey.inlist_wptr & 0x3fff; in hptiop_post_req_mvfrey()
950 if (index == hba->u.mvfrey.list_count) { in hptiop_post_req_mvfrey()
952 hba->u.mvfrey.inlist_wptr &= ~0x3fff; in hptiop_post_req_mvfrey()
953 hba->u.mvfrey.inlist_wptr ^= CL_POINTER_TOGGLE; in hptiop_post_req_mvfrey()
956 hba->u.mvfrey.inlist[index].addr = in hptiop_post_req_mvfrey()
958 hba->u.mvfrey.inlist[index].intrfc_len = (reqhdr->size + 3) / 4; in hptiop_post_req_mvfrey()
959 writel(hba->u.mvfrey.inlist_wptr, in hptiop_post_req_mvfrey()
960 &(hba->u.mvfrey.mu->inbound_write_ptr)); in hptiop_post_req_mvfrey()
961 readl(&(hba->u.mvfrey.mu->inbound_write_ptr)); in hptiop_post_req_mvfrey()
964 static int hptiop_reset_comm_itl(struct hptiop_hba *hba) in hptiop_reset_comm_itl() argument
969 static int hptiop_reset_comm_mv(struct hptiop_hba *hba) in hptiop_reset_comm_mv() argument
974 static int hptiop_reset_comm_mvfrey(struct hptiop_hba *hba) in hptiop_reset_comm_mvfrey() argument
976 u32 list_count = hba->u.mvfrey.list_count; in hptiop_reset_comm_mvfrey()
978 if (iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET_COMM, 3000)) in hptiop_reset_comm_mvfrey()
984 writel(cpu_to_le32(hba->u.mvfrey.inlist_phy & 0xffffffff), in hptiop_reset_comm_mvfrey()
985 &(hba->u.mvfrey.mu->inbound_base)); in hptiop_reset_comm_mvfrey()
986 writel(cpu_to_le32((hba->u.mvfrey.inlist_phy >> 16) >> 16), in hptiop_reset_comm_mvfrey()
987 &(hba->u.mvfrey.mu->inbound_base_high)); in hptiop_reset_comm_mvfrey()
989 writel(cpu_to_le32(hba->u.mvfrey.outlist_phy & 0xffffffff), in hptiop_reset_comm_mvfrey()
990 &(hba->u.mvfrey.mu->outbound_base)); in hptiop_reset_comm_mvfrey()
991 writel(cpu_to_le32((hba->u.mvfrey.outlist_phy >> 16) >> 16), in hptiop_reset_comm_mvfrey()
992 &(hba->u.mvfrey.mu->outbound_base_high)); in hptiop_reset_comm_mvfrey()
994 writel(cpu_to_le32(hba->u.mvfrey.outlist_cptr_phy & 0xffffffff), in hptiop_reset_comm_mvfrey()
995 &(hba->u.mvfrey.mu->outbound_shadow_base)); in hptiop_reset_comm_mvfrey()
996 writel(cpu_to_le32((hba->u.mvfrey.outlist_cptr_phy >> 16) >> 16), in hptiop_reset_comm_mvfrey()
997 &(hba->u.mvfrey.mu->outbound_shadow_base_high)); in hptiop_reset_comm_mvfrey()
999 hba->u.mvfrey.inlist_wptr = (list_count - 1) | CL_POINTER_TOGGLE; in hptiop_reset_comm_mvfrey()
1000 *hba->u.mvfrey.outlist_cptr = (list_count - 1) | CL_POINTER_TOGGLE; in hptiop_reset_comm_mvfrey()
1001 hba->u.mvfrey.outlist_rptr = list_count - 1; in hptiop_reset_comm_mvfrey()
1009 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_queuecommand_lck() local
1017 _req = get_req(hba); in hptiop_queuecommand_lck()
1039 (scp->device->id > hba->max_devices) || in hptiop_queuecommand_lck()
1040 ((scp->device->id == (hba->max_devices-1)) && scp->device->lun)) { in hptiop_queuecommand_lck()
1042 free_req(hba, _req); in hptiop_queuecommand_lck()
1066 hba->ops->post_req(hba, _req); in hptiop_queuecommand_lck()
1082 static int hptiop_reset_hba(struct hptiop_hba *hba) in hptiop_reset_hba() argument
1084 if (atomic_xchg(&hba->resetting, 1) == 0) { in hptiop_reset_hba()
1085 atomic_inc(&hba->reset_count); in hptiop_reset_hba()
1086 hba->ops->post_msg(hba, IOPMU_INBOUND_MSG0_RESET); in hptiop_reset_hba()
1089 wait_event_timeout(hba->reset_wq, in hptiop_reset_hba()
1090 atomic_read(&hba->resetting) == 0, 60 * HZ); in hptiop_reset_hba()
1092 if (atomic_read(&hba->resetting)) { in hptiop_reset_hba()
1094 printk(KERN_ERR "scsi%d: reset failed\n", hba->host->host_no); in hptiop_reset_hba()
1098 if (iop_send_sync_msg(hba, in hptiop_reset_hba()
1101 hba->host->host_no); in hptiop_reset_hba()
1110 struct hptiop_hba * hba = (struct hptiop_hba *)host->hostdata; in hptiop_reset() local
1116 return hptiop_reset_hba(hba)? FAILED : SUCCESS; in hptiop_reset()
1122 struct hptiop_hba *hba = (struct hptiop_hba *)sdev->host->hostdata; in hptiop_adjust_disk_queue_depth() local
1124 if (queue_depth > hba->max_requests) in hptiop_adjust_disk_queue_depth()
1125 queue_depth = hba->max_requests; in hptiop_adjust_disk_queue_depth()
1139 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_show_fw_version() local
1142 hba->firmware_version >> 24, in hptiop_show_fw_version()
1143 (hba->firmware_version >> 16) & 0xff, in hptiop_show_fw_version()
1144 (hba->firmware_version >> 8) & 0xff, in hptiop_show_fw_version()
1145 hba->firmware_version & 0xff); in hptiop_show_fw_version()
1194 static int hptiop_internal_memalloc_itl(struct hptiop_hba *hba) in hptiop_internal_memalloc_itl() argument
1199 static int hptiop_internal_memalloc_mv(struct hptiop_hba *hba) in hptiop_internal_memalloc_mv() argument
1201 hba->u.mv.internal_req = dma_alloc_coherent(&hba->pcidev->dev, in hptiop_internal_memalloc_mv()
1202 0x800, &hba->u.mv.internal_req_phy, GFP_KERNEL); in hptiop_internal_memalloc_mv()
1203 if (hba->u.mv.internal_req) in hptiop_internal_memalloc_mv()
1209 static int hptiop_internal_memalloc_mvfrey(struct hptiop_hba *hba) in hptiop_internal_memalloc_mvfrey() argument
1211 u32 list_count = readl(&hba->u.mvfrey.mu->inbound_conf_ctl); in hptiop_internal_memalloc_mvfrey()
1215 BUG_ON(hba->max_request_size == 0); in hptiop_internal_memalloc_mvfrey()
1224 hba->u.mvfrey.list_count = list_count; in hptiop_internal_memalloc_mvfrey()
1225 hba->u.mvfrey.internal_mem_size = 0x800 + in hptiop_internal_memalloc_mvfrey()
1230 p = dma_alloc_coherent(&hba->pcidev->dev, in hptiop_internal_memalloc_mvfrey()
1231 hba->u.mvfrey.internal_mem_size, &phy, GFP_KERNEL); in hptiop_internal_memalloc_mvfrey()
1235 hba->u.mvfrey.internal_req.req_virt = p; in hptiop_internal_memalloc_mvfrey()
1236 hba->u.mvfrey.internal_req.req_shifted_phy = phy >> 5; in hptiop_internal_memalloc_mvfrey()
1237 hba->u.mvfrey.internal_req.scp = NULL; in hptiop_internal_memalloc_mvfrey()
1238 hba->u.mvfrey.internal_req.next = NULL; in hptiop_internal_memalloc_mvfrey()
1243 hba->u.mvfrey.inlist = (struct mvfrey_inlist_entry *)p; in hptiop_internal_memalloc_mvfrey()
1244 hba->u.mvfrey.inlist_phy = phy; in hptiop_internal_memalloc_mvfrey()
1249 hba->u.mvfrey.outlist = (struct mvfrey_outlist_entry *)p; in hptiop_internal_memalloc_mvfrey()
1250 hba->u.mvfrey.outlist_phy = phy; in hptiop_internal_memalloc_mvfrey()
1255 hba->u.mvfrey.outlist_cptr = (__le32 *)p; in hptiop_internal_memalloc_mvfrey()
1256 hba->u.mvfrey.outlist_cptr_phy = phy; in hptiop_internal_memalloc_mvfrey()
1261 static int hptiop_internal_memfree_itl(struct hptiop_hba *hba) in hptiop_internal_memfree_itl() argument
1266 static int hptiop_internal_memfree_mv(struct hptiop_hba *hba) in hptiop_internal_memfree_mv() argument
1268 if (hba->u.mv.internal_req) { in hptiop_internal_memfree_mv()
1269 dma_free_coherent(&hba->pcidev->dev, 0x800, in hptiop_internal_memfree_mv()
1270 hba->u.mv.internal_req, hba->u.mv.internal_req_phy); in hptiop_internal_memfree_mv()
1276 static int hptiop_internal_memfree_mvfrey(struct hptiop_hba *hba) in hptiop_internal_memfree_mvfrey() argument
1278 if (hba->u.mvfrey.internal_req.req_virt) { in hptiop_internal_memfree_mvfrey()
1279 dma_free_coherent(&hba->pcidev->dev, in hptiop_internal_memfree_mvfrey()
1280 hba->u.mvfrey.internal_mem_size, in hptiop_internal_memfree_mvfrey()
1281 hba->u.mvfrey.internal_req.req_virt, in hptiop_internal_memfree_mvfrey()
1283 hba->u.mvfrey.internal_req.req_shifted_phy << 5); in hptiop_internal_memfree_mvfrey()
1292 struct hptiop_hba *hba; in hptiop_probe() local
1333 hba = (struct hptiop_hba *)host->hostdata; in hptiop_probe()
1334 memset(hba, 0, sizeof(struct hptiop_hba)); in hptiop_probe()
1336 hba->ops = iop_ops; in hptiop_probe()
1337 hba->pcidev = pcidev; in hptiop_probe()
1338 hba->host = host; in hptiop_probe()
1339 hba->initialized = 0; in hptiop_probe()
1340 hba->iopintf_v2 = 0; in hptiop_probe()
1342 atomic_set(&hba->resetting, 0); in hptiop_probe()
1343 atomic_set(&hba->reset_count, 0); in hptiop_probe()
1345 init_waitqueue_head(&hba->reset_wq); in hptiop_probe()
1346 init_waitqueue_head(&hba->ioctl_wq); in hptiop_probe()
1354 if (hba->ops->map_pci_bar(hba)) in hptiop_probe()
1357 if (hba->ops->iop_wait_ready(hba, 20000)) { in hptiop_probe()
1359 hba->host->host_no); in hptiop_probe()
1363 if (hba->ops->family == MV_BASED_IOP) { in hptiop_probe()
1364 if (hba->ops->internal_memalloc(hba)) { in hptiop_probe()
1366 hba->host->host_no); in hptiop_probe()
1371 if (hba->ops->get_config(hba, &iop_config)) { in hptiop_probe()
1373 hba->host->host_no); in hptiop_probe()
1377 hba->max_requests = min(le32_to_cpu(iop_config.max_requests), in hptiop_probe()
1379 hba->max_devices = le32_to_cpu(iop_config.max_devices); in hptiop_probe()
1380 hba->max_request_size = le32_to_cpu(iop_config.request_size); in hptiop_probe()
1381 hba->max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count); in hptiop_probe()
1382 hba->firmware_version = le32_to_cpu(iop_config.firmware_version); in hptiop_probe()
1383 hba->interface_version = le32_to_cpu(iop_config.interface_version); in hptiop_probe()
1384 hba->sdram_size = le32_to_cpu(iop_config.sdram_size); in hptiop_probe()
1386 if (hba->ops->family == MVFREY_BASED_IOP) { in hptiop_probe()
1387 if (hba->ops->internal_memalloc(hba)) { in hptiop_probe()
1389 hba->host->host_no); in hptiop_probe()
1392 if (hba->ops->reset_comm(hba)) { in hptiop_probe()
1394 hba->host->host_no); in hptiop_probe()
1399 if (hba->firmware_version > 0x01020000 || in hptiop_probe()
1400 hba->interface_version > 0x01020000) in hptiop_probe()
1401 hba->iopintf_v2 = 1; in hptiop_probe()
1411 + sizeof(struct hpt_iopsg) * (hba->max_sg_descriptors - 1); in hptiop_probe()
1420 if (hba->ops->set_config(hba, &set_config)) { in hptiop_probe()
1422 hba->host->host_no); in hptiop_probe()
1429 driver_name, hba)) { in hptiop_probe()
1431 hba->host->host_no, pcidev->irq); in hptiop_probe()
1437 dprintk("req_size=%d, max_requests=%d\n", req_size, hba->max_requests); in hptiop_probe()
1439 hba->req_size = req_size; in hptiop_probe()
1440 hba->req_list = NULL; in hptiop_probe()
1442 for (i = 0; i < hba->max_requests; i++) { in hptiop_probe()
1444 hba->req_size + 0x20, in hptiop_probe()
1449 hba->host->host_no); in hptiop_probe()
1453 hba->dma_coherent[i] = start_virt; in hptiop_probe()
1454 hba->dma_coherent_handle[i] = start_phy; in hptiop_probe()
1462 hba->reqs[i].next = NULL; in hptiop_probe()
1463 hba->reqs[i].req_virt = start_virt; in hptiop_probe()
1464 hba->reqs[i].req_shifted_phy = start_phy >> 5; in hptiop_probe()
1465 hba->reqs[i].index = i; in hptiop_probe()
1466 free_req(hba, &hba->reqs[i]); in hptiop_probe()
1470 if (hptiop_initialize_iop(hba)) in hptiop_probe()
1475 hba->host->host_no); in hptiop_probe()
1481 dprintk("scsi%d: hptiop_probe successfully\n", hba->host->host_no); in hptiop_probe()
1485 for (i = 0; i < hba->max_requests; i++) { in hptiop_probe()
1486 if (hba->dma_coherent[i] && hba->dma_coherent_handle[i]) in hptiop_probe()
1487 dma_free_coherent(&hba->pcidev->dev, in hptiop_probe()
1488 hba->req_size + 0x20, in hptiop_probe()
1489 hba->dma_coherent[i], in hptiop_probe()
1490 hba->dma_coherent_handle[i]); in hptiop_probe()
1495 free_irq(hba->pcidev->irq, hba); in hptiop_probe()
1498 hba->ops->internal_memfree(hba); in hptiop_probe()
1500 hba->ops->unmap_pci_bar(hba); in hptiop_probe()
1518 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_shutdown() local
1520 dprintk("hptiop_shutdown(%p)\n", hba); in hptiop_shutdown()
1523 if (iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_SHUTDOWN, 60000)) in hptiop_shutdown()
1525 hba->host->host_no); in hptiop_shutdown()
1528 hba->ops->disable_intr(hba); in hptiop_shutdown()
1531 static void hptiop_disable_intr_itl(struct hptiop_hba *hba) in hptiop_disable_intr_itl() argument
1535 int_mask = readl(&hba->u.itl.iop->outbound_intmask); in hptiop_disable_intr_itl()
1538 &hba->u.itl.iop->outbound_intmask); in hptiop_disable_intr_itl()
1539 readl(&hba->u.itl.iop->outbound_intmask); in hptiop_disable_intr_itl()
1542 static void hptiop_disable_intr_mv(struct hptiop_hba *hba) in hptiop_disable_intr_mv() argument
1544 writel(0, &hba->u.mv.regs->outbound_intmask); in hptiop_disable_intr_mv()
1545 readl(&hba->u.mv.regs->outbound_intmask); in hptiop_disable_intr_mv()
1548 static void hptiop_disable_intr_mvfrey(struct hptiop_hba *hba) in hptiop_disable_intr_mvfrey() argument
1550 writel(0, &(hba->u.mvfrey.mu->f0_doorbell_enable)); in hptiop_disable_intr_mvfrey()
1551 readl(&(hba->u.mvfrey.mu->f0_doorbell_enable)); in hptiop_disable_intr_mvfrey()
1552 writel(0, &(hba->u.mvfrey.mu->isr_enable)); in hptiop_disable_intr_mvfrey()
1553 readl(&(hba->u.mvfrey.mu->isr_enable)); in hptiop_disable_intr_mvfrey()
1554 writel(0, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in hptiop_disable_intr_mvfrey()
1555 readl(&(hba->u.mvfrey.mu->pcie_f0_int_enable)); in hptiop_disable_intr_mvfrey()
1561 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_remove() local
1564 dprintk("scsi%d: hptiop_remove\n", hba->host->host_no); in hptiop_remove()
1570 free_irq(hba->pcidev->irq, hba); in hptiop_remove()
1572 for (i = 0; i < hba->max_requests; i++) { in hptiop_remove()
1573 if (hba->dma_coherent[i] && hba->dma_coherent_handle[i]) in hptiop_remove()
1574 dma_free_coherent(&hba->pcidev->dev, in hptiop_remove()
1575 hba->req_size + 0x20, in hptiop_remove()
1576 hba->dma_coherent[i], in hptiop_remove()
1577 hba->dma_coherent_handle[i]); in hptiop_remove()
1582 hba->ops->internal_memfree(hba); in hptiop_remove()
1584 hba->ops->unmap_pci_bar(hba); in hptiop_remove()
1586 pci_release_regions(hba->pcidev); in hptiop_remove()
1587 pci_set_drvdata(hba->pcidev, NULL); in hptiop_remove()
1588 pci_disable_device(hba->pcidev); in hptiop_remove()