• Home
  • Raw
  • Download

Lines Matching refs:hba

39 static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec);
40 static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,
42 static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 tag);
43 static void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag);
44 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg);
46 static int iop_wait_ready_itl(struct hptiop_hba *hba, u32 millisec) in iop_wait_ready_itl() argument
52 req = readl(&hba->u.itl.iop->inbound_queue); in iop_wait_ready_itl()
59 writel(req, &hba->u.itl.iop->outbound_queue); in iop_wait_ready_itl()
60 readl(&hba->u.itl.iop->outbound_intstatus); in iop_wait_ready_itl()
67 static int iop_wait_ready_mv(struct hptiop_hba *hba, u32 millisec) in iop_wait_ready_mv() argument
69 return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec); in iop_wait_ready_mv()
72 static int iop_wait_ready_mvfrey(struct hptiop_hba *hba, u32 millisec) in iop_wait_ready_mvfrey() argument
74 return iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_NOP, millisec); in iop_wait_ready_mvfrey()
77 static void hptiop_request_callback_itl(struct hptiop_hba *hba, u32 tag) in hptiop_request_callback_itl() argument
80 hptiop_host_request_callback_itl(hba, in hptiop_request_callback_itl()
83 hptiop_iop_request_callback_itl(hba, tag); in hptiop_request_callback_itl()
86 static void hptiop_drain_outbound_queue_itl(struct hptiop_hba *hba) in hptiop_drain_outbound_queue_itl() argument
90 while ((req = readl(&hba->u.itl.iop->outbound_queue)) != in hptiop_drain_outbound_queue_itl()
94 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
99 ((char __iomem *)hba->u.itl.iop + req); in hptiop_drain_outbound_queue_itl()
103 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
108 hptiop_request_callback_itl(hba, req); in hptiop_drain_outbound_queue_itl()
113 static int iop_intr_itl(struct hptiop_hba *hba) in iop_intr_itl() argument
115 struct hpt_iopmu_itl __iomem *iop = hba->u.itl.iop; in iop_intr_itl()
116 void __iomem *plx = hba->u.itl.plx; in iop_intr_itl()
130 hptiop_message_callback(hba, msg); in iop_intr_itl()
135 hptiop_drain_outbound_queue_itl(hba); in iop_intr_itl()
161 static void mv_inbound_write(u64 p, struct hptiop_hba *hba) in mv_inbound_write() argument
163 u32 inbound_head = readl(&hba->u.mv.mu->inbound_head); in mv_inbound_write()
169 memcpy_toio(&hba->u.mv.mu->inbound_q[inbound_head], &p, 8); in mv_inbound_write()
170 writel(head, &hba->u.mv.mu->inbound_head); in mv_inbound_write()
172 &hba->u.mv.regs->inbound_doorbell); in mv_inbound_write()
175 static void hptiop_request_callback_mv(struct hptiop_hba *hba, u64 tag) in hptiop_request_callback_mv() argument
187 hba->msg_done = 1; in hptiop_request_callback_mv()
191 req = hba->reqs[tag >> 8].req_virt; in hptiop_request_callback_mv()
195 hptiop_finish_scsi_req(hba, tag>>8, req); in hptiop_request_callback_mv()
203 static int iop_intr_mv(struct hptiop_hba *hba) in iop_intr_mv() argument
208 status = readl(&hba->u.mv.regs->outbound_doorbell); in iop_intr_mv()
209 writel(~status, &hba->u.mv.regs->outbound_doorbell); in iop_intr_mv()
213 msg = readl(&hba->u.mv.mu->outbound_msg); in iop_intr_mv()
215 hptiop_message_callback(hba, msg); in iop_intr_mv()
222 while ((tag = mv_outbound_read(hba->u.mv.mu))) in iop_intr_mv()
223 hptiop_request_callback_mv(hba, tag); in iop_intr_mv()
230 static void hptiop_request_callback_mvfrey(struct hptiop_hba *hba, u32 _tag) in hptiop_request_callback_mvfrey() argument
238 hba->msg_done = 1; in hptiop_request_callback_mvfrey()
242 req = hba->reqs[(_tag >> 4) & 0xff].req_virt; in hptiop_request_callback_mvfrey()
245 hptiop_finish_scsi_req(hba, (_tag >> 4) & 0xff, req); in hptiop_request_callback_mvfrey()
253 static int iop_intr_mvfrey(struct hptiop_hba *hba) in iop_intr_mvfrey() argument
258 if (hba->initialized) in iop_intr_mvfrey()
259 writel(0, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in iop_intr_mvfrey()
261 status = readl(&(hba->u.mvfrey.mu->f0_doorbell)); in iop_intr_mvfrey()
263 writel(status, &(hba->u.mvfrey.mu->f0_doorbell)); in iop_intr_mvfrey()
265 u32 msg = readl(&(hba->u.mvfrey.mu->cpu_to_f0_msg_a)); in iop_intr_mvfrey()
267 hptiop_message_callback(hba, msg); in iop_intr_mvfrey()
272 status = readl(&(hba->u.mvfrey.mu->isr_cause)); in iop_intr_mvfrey()
274 writel(status, &(hba->u.mvfrey.mu->isr_cause)); in iop_intr_mvfrey()
276 cptr = *hba->u.mvfrey.outlist_cptr & 0xff; in iop_intr_mvfrey()
277 cur_rptr = hba->u.mvfrey.outlist_rptr; in iop_intr_mvfrey()
280 if (cur_rptr == hba->u.mvfrey.list_count) in iop_intr_mvfrey()
283 _tag = hba->u.mvfrey.outlist[cur_rptr].val; in iop_intr_mvfrey()
285 hptiop_request_callback_mvfrey(hba, _tag); in iop_intr_mvfrey()
288 hba->u.mvfrey.outlist_rptr = cur_rptr; in iop_intr_mvfrey()
289 } while (cptr != (*hba->u.mvfrey.outlist_cptr & 0xff)); in iop_intr_mvfrey()
292 if (hba->initialized) in iop_intr_mvfrey()
293 writel(0x1010, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in iop_intr_mvfrey()
298 static int iop_send_sync_request_itl(struct hptiop_hba *hba, in iop_send_sync_request_itl() argument
306 writel((unsigned long)req - (unsigned long)hba->u.itl.iop, in iop_send_sync_request_itl()
307 &hba->u.itl.iop->inbound_queue); in iop_send_sync_request_itl()
308 readl(&hba->u.itl.iop->outbound_intstatus); in iop_send_sync_request_itl()
311 iop_intr_itl(hba); in iop_send_sync_request_itl()
320 static int iop_send_sync_request_mv(struct hptiop_hba *hba, in iop_send_sync_request_mv() argument
323 struct hpt_iop_request_header *reqhdr = hba->u.mv.internal_req; in iop_send_sync_request_mv()
326 hba->msg_done = 0; in iop_send_sync_request_mv()
328 mv_inbound_write(hba->u.mv.internal_req_phy | in iop_send_sync_request_mv()
329 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bits, hba); in iop_send_sync_request_mv()
332 iop_intr_mv(hba); in iop_send_sync_request_mv()
333 if (hba->msg_done) in iop_send_sync_request_mv()
340 static int iop_send_sync_request_mvfrey(struct hptiop_hba *hba, in iop_send_sync_request_mvfrey() argument
344 hba->u.mvfrey.internal_req.req_virt; in iop_send_sync_request_mvfrey()
347 hba->msg_done = 0; in iop_send_sync_request_mvfrey()
349 hba->ops->post_req(hba, &(hba->u.mvfrey.internal_req)); in iop_send_sync_request_mvfrey()
352 iop_intr_mvfrey(hba); in iop_send_sync_request_mvfrey()
353 if (hba->msg_done) in iop_send_sync_request_mvfrey()
357 return hba->msg_done ? 0 : -1; in iop_send_sync_request_mvfrey()
360 static void hptiop_post_msg_itl(struct hptiop_hba *hba, u32 msg) in hptiop_post_msg_itl() argument
362 writel(msg, &hba->u.itl.iop->inbound_msgaddr0); in hptiop_post_msg_itl()
363 readl(&hba->u.itl.iop->outbound_intstatus); in hptiop_post_msg_itl()
366 static void hptiop_post_msg_mv(struct hptiop_hba *hba, u32 msg) in hptiop_post_msg_mv() argument
368 writel(msg, &hba->u.mv.mu->inbound_msg); in hptiop_post_msg_mv()
369 writel(MVIOP_MU_INBOUND_INT_MSG, &hba->u.mv.regs->inbound_doorbell); in hptiop_post_msg_mv()
370 readl(&hba->u.mv.regs->inbound_doorbell); in hptiop_post_msg_mv()
373 static void hptiop_post_msg_mvfrey(struct hptiop_hba *hba, u32 msg) in hptiop_post_msg_mvfrey() argument
375 writel(msg, &(hba->u.mvfrey.mu->f0_to_cpu_msg_a)); in hptiop_post_msg_mvfrey()
376 readl(&(hba->u.mvfrey.mu->f0_to_cpu_msg_a)); in hptiop_post_msg_mvfrey()
379 static int iop_send_sync_msg(struct hptiop_hba *hba, u32 msg, u32 millisec) in iop_send_sync_msg() argument
383 hba->msg_done = 0; in iop_send_sync_msg()
384 hba->ops->disable_intr(hba); in iop_send_sync_msg()
385 hba->ops->post_msg(hba, msg); in iop_send_sync_msg()
388 spin_lock_irq(hba->host->host_lock); in iop_send_sync_msg()
389 hba->ops->iop_intr(hba); in iop_send_sync_msg()
390 spin_unlock_irq(hba->host->host_lock); in iop_send_sync_msg()
391 if (hba->msg_done) in iop_send_sync_msg()
396 hba->ops->enable_intr(hba); in iop_send_sync_msg()
397 return hba->msg_done? 0 : -1; in iop_send_sync_msg()
400 static int iop_get_config_itl(struct hptiop_hba *hba, in iop_get_config_itl() argument
406 req32 = readl(&hba->u.itl.iop->inbound_queue); in iop_get_config_itl()
411 ((unsigned long)hba->u.itl.iop + req32); in iop_get_config_itl()
418 if (iop_send_sync_request_itl(hba, req, 20000)) { in iop_get_config_itl()
424 writel(req32, &hba->u.itl.iop->outbound_queue); in iop_get_config_itl()
428 static int iop_get_config_mv(struct hptiop_hba *hba, in iop_get_config_mv() argument
431 struct hpt_iop_request_get_config *req = hba->u.mv.internal_req; in iop_get_config_mv()
441 if (iop_send_sync_request_mv(hba, 0, 20000)) { in iop_get_config_mv()
450 static int iop_get_config_mvfrey(struct hptiop_hba *hba, in iop_get_config_mvfrey() argument
453 struct hpt_iop_request_get_config *info = hba->u.mvfrey.config; in iop_get_config_mvfrey()
472 static int iop_set_config_itl(struct hptiop_hba *hba, in iop_set_config_itl() argument
478 req32 = readl(&hba->u.itl.iop->inbound_queue); in iop_set_config_itl()
483 ((unsigned long)hba->u.itl.iop + req32); in iop_set_config_itl()
495 if (iop_send_sync_request_itl(hba, req, 20000)) { in iop_set_config_itl()
500 writel(req32, &hba->u.itl.iop->outbound_queue); in iop_set_config_itl()
504 static int iop_set_config_mv(struct hptiop_hba *hba, in iop_set_config_mv() argument
507 struct hpt_iop_request_set_config *req = hba->u.mv.internal_req; in iop_set_config_mv()
518 if (iop_send_sync_request_mv(hba, 0, 20000)) { in iop_set_config_mv()
526 static int iop_set_config_mvfrey(struct hptiop_hba *hba, in iop_set_config_mvfrey() argument
530 hba->u.mvfrey.internal_req.req_virt; in iop_set_config_mvfrey()
541 if (iop_send_sync_request_mvfrey(hba, 0, 20000)) { in iop_set_config_mvfrey()
549 static void hptiop_enable_intr_itl(struct hptiop_hba *hba) in hptiop_enable_intr_itl() argument
552 &hba->u.itl.iop->outbound_intmask); in hptiop_enable_intr_itl()
555 static void hptiop_enable_intr_mv(struct hptiop_hba *hba) in hptiop_enable_intr_mv() argument
558 &hba->u.mv.regs->outbound_intmask); in hptiop_enable_intr_mv()
561 static void hptiop_enable_intr_mvfrey(struct hptiop_hba *hba) in hptiop_enable_intr_mvfrey() argument
563 writel(CPU_TO_F0_DRBL_MSG_BIT, &(hba->u.mvfrey.mu->f0_doorbell_enable)); in hptiop_enable_intr_mvfrey()
564 writel(0x1, &(hba->u.mvfrey.mu->isr_enable)); in hptiop_enable_intr_mvfrey()
565 writel(0x1010, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in hptiop_enable_intr_mvfrey()
568 static int hptiop_initialize_iop(struct hptiop_hba *hba) in hptiop_initialize_iop() argument
571 hba->ops->enable_intr(hba); in hptiop_initialize_iop()
573 hba->initialized = 1; in hptiop_initialize_iop()
576 if (iop_send_sync_msg(hba, in hptiop_initialize_iop()
579 hba->host->host_no); in hptiop_initialize_iop()
585 static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index) in hptiop_map_pci_bar() argument
590 struct pci_dev *pcidev = hba->pcidev; in hptiop_map_pci_bar()
595 hba->host->host_no); in hptiop_map_pci_bar()
605 hba->host->host_no); in hptiop_map_pci_bar()
611 static int hptiop_map_pci_bar_itl(struct hptiop_hba *hba) in hptiop_map_pci_bar_itl() argument
613 struct pci_dev *pcidev = hba->pcidev; in hptiop_map_pci_bar_itl()
614 hba->u.itl.iop = hptiop_map_pci_bar(hba, 0); in hptiop_map_pci_bar_itl()
615 if (hba->u.itl.iop == NULL) in hptiop_map_pci_bar_itl()
618 hba->u.itl.plx = hba->u.itl.iop; in hptiop_map_pci_bar_itl()
619 hba->u.itl.iop = hptiop_map_pci_bar(hba, 2); in hptiop_map_pci_bar_itl()
620 if (hba->u.itl.iop == NULL) { in hptiop_map_pci_bar_itl()
621 iounmap(hba->u.itl.plx); in hptiop_map_pci_bar_itl()
628 static void hptiop_unmap_pci_bar_itl(struct hptiop_hba *hba) in hptiop_unmap_pci_bar_itl() argument
630 if (hba->u.itl.plx) in hptiop_unmap_pci_bar_itl()
631 iounmap(hba->u.itl.plx); in hptiop_unmap_pci_bar_itl()
632 iounmap(hba->u.itl.iop); in hptiop_unmap_pci_bar_itl()
635 static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba) in hptiop_map_pci_bar_mv() argument
637 hba->u.mv.regs = hptiop_map_pci_bar(hba, 0); in hptiop_map_pci_bar_mv()
638 if (hba->u.mv.regs == NULL) in hptiop_map_pci_bar_mv()
641 hba->u.mv.mu = hptiop_map_pci_bar(hba, 2); in hptiop_map_pci_bar_mv()
642 if (hba->u.mv.mu == NULL) { in hptiop_map_pci_bar_mv()
643 iounmap(hba->u.mv.regs); in hptiop_map_pci_bar_mv()
650 static int hptiop_map_pci_bar_mvfrey(struct hptiop_hba *hba) in hptiop_map_pci_bar_mvfrey() argument
652 hba->u.mvfrey.config = hptiop_map_pci_bar(hba, 0); in hptiop_map_pci_bar_mvfrey()
653 if (hba->u.mvfrey.config == NULL) in hptiop_map_pci_bar_mvfrey()
656 hba->u.mvfrey.mu = hptiop_map_pci_bar(hba, 2); in hptiop_map_pci_bar_mvfrey()
657 if (hba->u.mvfrey.mu == NULL) { in hptiop_map_pci_bar_mvfrey()
658 iounmap(hba->u.mvfrey.config); in hptiop_map_pci_bar_mvfrey()
665 static void hptiop_unmap_pci_bar_mv(struct hptiop_hba *hba) in hptiop_unmap_pci_bar_mv() argument
667 iounmap(hba->u.mv.regs); in hptiop_unmap_pci_bar_mv()
668 iounmap(hba->u.mv.mu); in hptiop_unmap_pci_bar_mv()
671 static void hptiop_unmap_pci_bar_mvfrey(struct hptiop_hba *hba) in hptiop_unmap_pci_bar_mvfrey() argument
673 iounmap(hba->u.mvfrey.config); in hptiop_unmap_pci_bar_mvfrey()
674 iounmap(hba->u.mvfrey.mu); in hptiop_unmap_pci_bar_mvfrey()
677 static void hptiop_message_callback(struct hptiop_hba *hba, u32 msg) in hptiop_message_callback() argument
683 hba->msg_done = 1; in hptiop_message_callback()
685 if (!hba->initialized) in hptiop_message_callback()
689 atomic_set(&hba->resetting, 0); in hptiop_message_callback()
690 wake_up(&hba->reset_wq); in hptiop_message_callback()
693 hba->msg_done = 1; in hptiop_message_callback()
696 static struct hptiop_request *get_req(struct hptiop_hba *hba) in get_req() argument
700 dprintk("get_req : req=%p\n", hba->req_list); in get_req()
702 ret = hba->req_list; in get_req()
704 hba->req_list = ret->next; in get_req()
709 static void free_req(struct hptiop_hba *hba, struct hptiop_request *req) in free_req() argument
712 req->next = hba->req_list; in free_req()
713 hba->req_list = req; in free_req()
716 static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag, in hptiop_finish_scsi_req() argument
729 scp = hba->reqs[tag].scp; in hptiop_finish_scsi_req()
773 free_req(hba, &hba->reqs[tag]); in hptiop_finish_scsi_req()
776 static void hptiop_host_request_callback_itl(struct hptiop_hba *hba, u32 _tag) in hptiop_host_request_callback_itl() argument
781 if (hba->iopintf_v2) { in hptiop_host_request_callback_itl()
783 req = hba->reqs[tag].req_virt; in hptiop_host_request_callback_itl()
788 req = hba->reqs[tag].req_virt; in hptiop_host_request_callback_itl()
791 hptiop_finish_scsi_req(hba, tag, req); in hptiop_host_request_callback_itl()
794 static void hptiop_iop_request_callback_itl(struct hptiop_hba *hba, u32 tag) in hptiop_iop_request_callback_itl() argument
801 ((unsigned long)hba->u.itl.iop + tag); in hptiop_iop_request_callback_itl()
830 writel(tag, &hba->u.itl.iop->outbound_queue); in hptiop_iop_request_callback_itl()
835 struct hptiop_hba *hba = dev_id; in hptiop_intr() local
839 spin_lock_irqsave(hba->host->host_lock, flags); in hptiop_intr()
840 handled = hba->ops->iop_intr(hba); in hptiop_intr()
841 spin_unlock_irqrestore(hba->host->host_lock, flags); in hptiop_intr()
849 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_buildsgl() local
861 BUG_ON(HPT_SCP(scp)->sgcnt > hba->max_sg_descriptors); in hptiop_buildsgl()
865 hba->ops->host_phy_flag; in hptiop_buildsgl()
873 static void hptiop_post_req_itl(struct hptiop_hba *hba, in hptiop_post_req_itl() argument
882 if (hba->iopintf_v2) { in hptiop_post_req_itl()
894 &hba->u.itl.iop->inbound_queue); in hptiop_post_req_itl()
897 &hba->u.itl.iop->inbound_queue); in hptiop_post_req_itl()
900 static void hptiop_post_req_mv(struct hptiop_hba *hba, in hptiop_post_req_mv() argument
921 MVIOP_MU_QUEUE_ADDR_HOST_BIT | size_bit, hba); in hptiop_post_req_mv()
924 static void hptiop_post_req_mvfrey(struct hptiop_hba *hba, in hptiop_post_req_mvfrey() argument
938 hba->u.mvfrey.inlist_wptr++; in hptiop_post_req_mvfrey()
939 index = hba->u.mvfrey.inlist_wptr & 0x3fff; in hptiop_post_req_mvfrey()
941 if (index == hba->u.mvfrey.list_count) { in hptiop_post_req_mvfrey()
943 hba->u.mvfrey.inlist_wptr &= ~0x3fff; in hptiop_post_req_mvfrey()
944 hba->u.mvfrey.inlist_wptr ^= CL_POINTER_TOGGLE; in hptiop_post_req_mvfrey()
947 hba->u.mvfrey.inlist[index].addr = in hptiop_post_req_mvfrey()
949 hba->u.mvfrey.inlist[index].intrfc_len = (reqhdr->size + 3) / 4; in hptiop_post_req_mvfrey()
950 writel(hba->u.mvfrey.inlist_wptr, in hptiop_post_req_mvfrey()
951 &(hba->u.mvfrey.mu->inbound_write_ptr)); in hptiop_post_req_mvfrey()
952 readl(&(hba->u.mvfrey.mu->inbound_write_ptr)); in hptiop_post_req_mvfrey()
955 static int hptiop_reset_comm_itl(struct hptiop_hba *hba) in hptiop_reset_comm_itl() argument
960 static int hptiop_reset_comm_mv(struct hptiop_hba *hba) in hptiop_reset_comm_mv() argument
965 static int hptiop_reset_comm_mvfrey(struct hptiop_hba *hba) in hptiop_reset_comm_mvfrey() argument
967 u32 list_count = hba->u.mvfrey.list_count; in hptiop_reset_comm_mvfrey()
969 if (iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_RESET_COMM, 3000)) in hptiop_reset_comm_mvfrey()
975 writel(cpu_to_le32(hba->u.mvfrey.inlist_phy & 0xffffffff), in hptiop_reset_comm_mvfrey()
976 &(hba->u.mvfrey.mu->inbound_base)); in hptiop_reset_comm_mvfrey()
977 writel(cpu_to_le32((hba->u.mvfrey.inlist_phy >> 16) >> 16), in hptiop_reset_comm_mvfrey()
978 &(hba->u.mvfrey.mu->inbound_base_high)); in hptiop_reset_comm_mvfrey()
980 writel(cpu_to_le32(hba->u.mvfrey.outlist_phy & 0xffffffff), in hptiop_reset_comm_mvfrey()
981 &(hba->u.mvfrey.mu->outbound_base)); in hptiop_reset_comm_mvfrey()
982 writel(cpu_to_le32((hba->u.mvfrey.outlist_phy >> 16) >> 16), in hptiop_reset_comm_mvfrey()
983 &(hba->u.mvfrey.mu->outbound_base_high)); in hptiop_reset_comm_mvfrey()
985 writel(cpu_to_le32(hba->u.mvfrey.outlist_cptr_phy & 0xffffffff), in hptiop_reset_comm_mvfrey()
986 &(hba->u.mvfrey.mu->outbound_shadow_base)); in hptiop_reset_comm_mvfrey()
987 writel(cpu_to_le32((hba->u.mvfrey.outlist_cptr_phy >> 16) >> 16), in hptiop_reset_comm_mvfrey()
988 &(hba->u.mvfrey.mu->outbound_shadow_base_high)); in hptiop_reset_comm_mvfrey()
990 hba->u.mvfrey.inlist_wptr = (list_count - 1) | CL_POINTER_TOGGLE; in hptiop_reset_comm_mvfrey()
991 *hba->u.mvfrey.outlist_cptr = (list_count - 1) | CL_POINTER_TOGGLE; in hptiop_reset_comm_mvfrey()
992 hba->u.mvfrey.outlist_rptr = list_count - 1; in hptiop_reset_comm_mvfrey()
1000 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_queuecommand_lck() local
1008 _req = get_req(hba); in hptiop_queuecommand_lck()
1030 (scp->device->id > hba->max_devices) || in hptiop_queuecommand_lck()
1031 ((scp->device->id == (hba->max_devices-1)) && scp->device->lun)) { in hptiop_queuecommand_lck()
1033 free_req(hba, _req); in hptiop_queuecommand_lck()
1057 hba->ops->post_req(hba, _req); in hptiop_queuecommand_lck()
1073 static int hptiop_reset_hba(struct hptiop_hba *hba) in hptiop_reset_hba() argument
1075 if (atomic_xchg(&hba->resetting, 1) == 0) { in hptiop_reset_hba()
1076 atomic_inc(&hba->reset_count); in hptiop_reset_hba()
1077 hba->ops->post_msg(hba, IOPMU_INBOUND_MSG0_RESET); in hptiop_reset_hba()
1080 wait_event_timeout(hba->reset_wq, in hptiop_reset_hba()
1081 atomic_read(&hba->resetting) == 0, 60 * HZ); in hptiop_reset_hba()
1083 if (atomic_read(&hba->resetting)) { in hptiop_reset_hba()
1085 printk(KERN_ERR "scsi%d: reset failed\n", hba->host->host_no); in hptiop_reset_hba()
1089 if (iop_send_sync_msg(hba, in hptiop_reset_hba()
1092 hba->host->host_no); in hptiop_reset_hba()
1100 struct hptiop_hba * hba = (struct hptiop_hba *)scp->device->host->hostdata; in hptiop_reset() local
1105 return hptiop_reset_hba(hba)? FAILED : SUCCESS; in hptiop_reset()
1111 struct hptiop_hba *hba = (struct hptiop_hba *)sdev->host->hostdata; in hptiop_adjust_disk_queue_depth() local
1113 if (queue_depth > hba->max_requests) in hptiop_adjust_disk_queue_depth()
1114 queue_depth = hba->max_requests; in hptiop_adjust_disk_queue_depth()
1128 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_show_fw_version() local
1131 hba->firmware_version >> 24, in hptiop_show_fw_version()
1132 (hba->firmware_version >> 16) & 0xff, in hptiop_show_fw_version()
1133 (hba->firmware_version >> 8) & 0xff, in hptiop_show_fw_version()
1134 hba->firmware_version & 0xff); in hptiop_show_fw_version()
1181 static int hptiop_internal_memalloc_itl(struct hptiop_hba *hba) in hptiop_internal_memalloc_itl() argument
1186 static int hptiop_internal_memalloc_mv(struct hptiop_hba *hba) in hptiop_internal_memalloc_mv() argument
1188 hba->u.mv.internal_req = dma_alloc_coherent(&hba->pcidev->dev, in hptiop_internal_memalloc_mv()
1189 0x800, &hba->u.mv.internal_req_phy, GFP_KERNEL); in hptiop_internal_memalloc_mv()
1190 if (hba->u.mv.internal_req) in hptiop_internal_memalloc_mv()
1196 static int hptiop_internal_memalloc_mvfrey(struct hptiop_hba *hba) in hptiop_internal_memalloc_mvfrey() argument
1198 u32 list_count = readl(&hba->u.mvfrey.mu->inbound_conf_ctl); in hptiop_internal_memalloc_mvfrey()
1202 BUG_ON(hba->max_request_size == 0); in hptiop_internal_memalloc_mvfrey()
1211 hba->u.mvfrey.list_count = list_count; in hptiop_internal_memalloc_mvfrey()
1212 hba->u.mvfrey.internal_mem_size = 0x800 + in hptiop_internal_memalloc_mvfrey()
1217 p = dma_alloc_coherent(&hba->pcidev->dev, in hptiop_internal_memalloc_mvfrey()
1218 hba->u.mvfrey.internal_mem_size, &phy, GFP_KERNEL); in hptiop_internal_memalloc_mvfrey()
1222 hba->u.mvfrey.internal_req.req_virt = p; in hptiop_internal_memalloc_mvfrey()
1223 hba->u.mvfrey.internal_req.req_shifted_phy = phy >> 5; in hptiop_internal_memalloc_mvfrey()
1224 hba->u.mvfrey.internal_req.scp = NULL; in hptiop_internal_memalloc_mvfrey()
1225 hba->u.mvfrey.internal_req.next = NULL; in hptiop_internal_memalloc_mvfrey()
1230 hba->u.mvfrey.inlist = (struct mvfrey_inlist_entry *)p; in hptiop_internal_memalloc_mvfrey()
1231 hba->u.mvfrey.inlist_phy = phy; in hptiop_internal_memalloc_mvfrey()
1236 hba->u.mvfrey.outlist = (struct mvfrey_outlist_entry *)p; in hptiop_internal_memalloc_mvfrey()
1237 hba->u.mvfrey.outlist_phy = phy; in hptiop_internal_memalloc_mvfrey()
1242 hba->u.mvfrey.outlist_cptr = (__le32 *)p; in hptiop_internal_memalloc_mvfrey()
1243 hba->u.mvfrey.outlist_cptr_phy = phy; in hptiop_internal_memalloc_mvfrey()
1248 static int hptiop_internal_memfree_itl(struct hptiop_hba *hba) in hptiop_internal_memfree_itl() argument
1253 static int hptiop_internal_memfree_mv(struct hptiop_hba *hba) in hptiop_internal_memfree_mv() argument
1255 if (hba->u.mv.internal_req) { in hptiop_internal_memfree_mv()
1256 dma_free_coherent(&hba->pcidev->dev, 0x800, in hptiop_internal_memfree_mv()
1257 hba->u.mv.internal_req, hba->u.mv.internal_req_phy); in hptiop_internal_memfree_mv()
1263 static int hptiop_internal_memfree_mvfrey(struct hptiop_hba *hba) in hptiop_internal_memfree_mvfrey() argument
1265 if (hba->u.mvfrey.internal_req.req_virt) { in hptiop_internal_memfree_mvfrey()
1266 dma_free_coherent(&hba->pcidev->dev, in hptiop_internal_memfree_mvfrey()
1267 hba->u.mvfrey.internal_mem_size, in hptiop_internal_memfree_mvfrey()
1268 hba->u.mvfrey.internal_req.req_virt, in hptiop_internal_memfree_mvfrey()
1270 hba->u.mvfrey.internal_req.req_shifted_phy << 5); in hptiop_internal_memfree_mvfrey()
1279 struct hptiop_hba *hba; in hptiop_probe() local
1324 hba = (struct hptiop_hba *)host->hostdata; in hptiop_probe()
1325 memset(hba, 0, sizeof(struct hptiop_hba)); in hptiop_probe()
1327 hba->ops = iop_ops; in hptiop_probe()
1328 hba->pcidev = pcidev; in hptiop_probe()
1329 hba->host = host; in hptiop_probe()
1330 hba->initialized = 0; in hptiop_probe()
1331 hba->iopintf_v2 = 0; in hptiop_probe()
1333 atomic_set(&hba->resetting, 0); in hptiop_probe()
1334 atomic_set(&hba->reset_count, 0); in hptiop_probe()
1336 init_waitqueue_head(&hba->reset_wq); in hptiop_probe()
1337 init_waitqueue_head(&hba->ioctl_wq); in hptiop_probe()
1345 if (hba->ops->map_pci_bar(hba)) in hptiop_probe()
1348 if (hba->ops->iop_wait_ready(hba, 20000)) { in hptiop_probe()
1350 hba->host->host_no); in hptiop_probe()
1354 if (hba->ops->family == MV_BASED_IOP) { in hptiop_probe()
1355 if (hba->ops->internal_memalloc(hba)) { in hptiop_probe()
1357 hba->host->host_no); in hptiop_probe()
1362 if (hba->ops->get_config(hba, &iop_config)) { in hptiop_probe()
1364 hba->host->host_no); in hptiop_probe()
1368 hba->max_requests = min(le32_to_cpu(iop_config.max_requests), in hptiop_probe()
1370 hba->max_devices = le32_to_cpu(iop_config.max_devices); in hptiop_probe()
1371 hba->max_request_size = le32_to_cpu(iop_config.request_size); in hptiop_probe()
1372 hba->max_sg_descriptors = le32_to_cpu(iop_config.max_sg_count); in hptiop_probe()
1373 hba->firmware_version = le32_to_cpu(iop_config.firmware_version); in hptiop_probe()
1374 hba->interface_version = le32_to_cpu(iop_config.interface_version); in hptiop_probe()
1375 hba->sdram_size = le32_to_cpu(iop_config.sdram_size); in hptiop_probe()
1377 if (hba->ops->family == MVFREY_BASED_IOP) { in hptiop_probe()
1378 if (hba->ops->internal_memalloc(hba)) { in hptiop_probe()
1380 hba->host->host_no); in hptiop_probe()
1383 if (hba->ops->reset_comm(hba)) { in hptiop_probe()
1385 hba->host->host_no); in hptiop_probe()
1390 if (hba->firmware_version > 0x01020000 || in hptiop_probe()
1391 hba->interface_version > 0x01020000) in hptiop_probe()
1392 hba->iopintf_v2 = 1; in hptiop_probe()
1402 + sizeof(struct hpt_iopsg) * (hba->max_sg_descriptors - 1); in hptiop_probe()
1411 if (hba->ops->set_config(hba, &set_config)) { in hptiop_probe()
1413 hba->host->host_no); in hptiop_probe()
1420 driver_name, hba)) { in hptiop_probe()
1422 hba->host->host_no, pcidev->irq); in hptiop_probe()
1428 dprintk("req_size=%d, max_requests=%d\n", req_size, hba->max_requests); in hptiop_probe()
1430 hba->req_size = req_size; in hptiop_probe()
1431 hba->req_list = NULL; in hptiop_probe()
1433 for (i = 0; i < hba->max_requests; i++) { in hptiop_probe()
1435 hba->req_size + 0x20, in hptiop_probe()
1440 hba->host->host_no); in hptiop_probe()
1444 hba->dma_coherent[i] = start_virt; in hptiop_probe()
1445 hba->dma_coherent_handle[i] = start_phy; in hptiop_probe()
1453 hba->reqs[i].next = NULL; in hptiop_probe()
1454 hba->reqs[i].req_virt = start_virt; in hptiop_probe()
1455 hba->reqs[i].req_shifted_phy = start_phy >> 5; in hptiop_probe()
1456 hba->reqs[i].index = i; in hptiop_probe()
1457 free_req(hba, &hba->reqs[i]); in hptiop_probe()
1461 if (hptiop_initialize_iop(hba)) in hptiop_probe()
1466 hba->host->host_no); in hptiop_probe()
1472 dprintk("scsi%d: hptiop_probe successfully\n", hba->host->host_no); in hptiop_probe()
1476 for (i = 0; i < hba->max_requests; i++) { in hptiop_probe()
1477 if (hba->dma_coherent[i] && hba->dma_coherent_handle[i]) in hptiop_probe()
1478 dma_free_coherent(&hba->pcidev->dev, in hptiop_probe()
1479 hba->req_size + 0x20, in hptiop_probe()
1480 hba->dma_coherent[i], in hptiop_probe()
1481 hba->dma_coherent_handle[i]); in hptiop_probe()
1486 free_irq(hba->pcidev->irq, hba); in hptiop_probe()
1489 hba->ops->internal_memfree(hba); in hptiop_probe()
1491 hba->ops->unmap_pci_bar(hba); in hptiop_probe()
1509 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_shutdown() local
1511 dprintk("hptiop_shutdown(%p)\n", hba); in hptiop_shutdown()
1514 if (iop_send_sync_msg(hba, IOPMU_INBOUND_MSG0_SHUTDOWN, 60000)) in hptiop_shutdown()
1516 hba->host->host_no); in hptiop_shutdown()
1519 hba->ops->disable_intr(hba); in hptiop_shutdown()
1522 static void hptiop_disable_intr_itl(struct hptiop_hba *hba) in hptiop_disable_intr_itl() argument
1526 int_mask = readl(&hba->u.itl.iop->outbound_intmask); in hptiop_disable_intr_itl()
1529 &hba->u.itl.iop->outbound_intmask); in hptiop_disable_intr_itl()
1530 readl(&hba->u.itl.iop->outbound_intmask); in hptiop_disable_intr_itl()
1533 static void hptiop_disable_intr_mv(struct hptiop_hba *hba) in hptiop_disable_intr_mv() argument
1535 writel(0, &hba->u.mv.regs->outbound_intmask); in hptiop_disable_intr_mv()
1536 readl(&hba->u.mv.regs->outbound_intmask); in hptiop_disable_intr_mv()
1539 static void hptiop_disable_intr_mvfrey(struct hptiop_hba *hba) in hptiop_disable_intr_mvfrey() argument
1541 writel(0, &(hba->u.mvfrey.mu->f0_doorbell_enable)); in hptiop_disable_intr_mvfrey()
1542 readl(&(hba->u.mvfrey.mu->f0_doorbell_enable)); in hptiop_disable_intr_mvfrey()
1543 writel(0, &(hba->u.mvfrey.mu->isr_enable)); in hptiop_disable_intr_mvfrey()
1544 readl(&(hba->u.mvfrey.mu->isr_enable)); in hptiop_disable_intr_mvfrey()
1545 writel(0, &(hba->u.mvfrey.mu->pcie_f0_int_enable)); in hptiop_disable_intr_mvfrey()
1546 readl(&(hba->u.mvfrey.mu->pcie_f0_int_enable)); in hptiop_disable_intr_mvfrey()
1552 struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; in hptiop_remove() local
1555 dprintk("scsi%d: hptiop_remove\n", hba->host->host_no); in hptiop_remove()
1561 free_irq(hba->pcidev->irq, hba); in hptiop_remove()
1563 for (i = 0; i < hba->max_requests; i++) { in hptiop_remove()
1564 if (hba->dma_coherent[i] && hba->dma_coherent_handle[i]) in hptiop_remove()
1565 dma_free_coherent(&hba->pcidev->dev, in hptiop_remove()
1566 hba->req_size + 0x20, in hptiop_remove()
1567 hba->dma_coherent[i], in hptiop_remove()
1568 hba->dma_coherent_handle[i]); in hptiop_remove()
1573 hba->ops->internal_memfree(hba); in hptiop_remove()
1575 hba->ops->unmap_pci_bar(hba); in hptiop_remove()
1577 pci_release_regions(hba->pcidev); in hptiop_remove()
1578 pci_set_drvdata(hba->pcidev, NULL); in hptiop_remove()
1579 pci_disable_device(hba->pcidev); in hptiop_remove()