Lines Matching full:hba
391 static struct status_msg *stex_get_status(struct st_hba *hba) in stex_get_status() argument
393 struct status_msg *status = hba->status_buffer + hba->status_tail; in stex_get_status()
395 ++hba->status_tail; in stex_get_status()
396 hba->status_tail %= hba->sts_count+1; in stex_get_status()
409 static struct req_msg *stex_alloc_req(struct st_hba *hba) in stex_alloc_req() argument
411 struct req_msg *req = hba->dma_mem + hba->req_head * hba->rq_size; in stex_alloc_req()
413 ++hba->req_head; in stex_alloc_req()
414 hba->req_head %= hba->rq_count+1; in stex_alloc_req()
419 static struct req_msg *stex_ss_alloc_req(struct st_hba *hba) in stex_ss_alloc_req() argument
421 return (struct req_msg *)(hba->dma_mem + in stex_ss_alloc_req()
422 hba->req_head * hba->rq_size + sizeof(struct st_msg_header)); in stex_ss_alloc_req()
425 static int stex_map_sg(struct st_hba *hba, in stex_map_sg() argument
442 dst->max_sg_count = cpu_to_le16(hba->host->sg_tablesize); in stex_map_sg()
457 static int stex_ss_map_sg(struct st_hba *hba, in stex_ss_map_sg() argument
474 dst->max_sg_count = cpu_to_le16(hba->host->sg_tablesize); in stex_ss_map_sg()
490 static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb) in stex_controller_info() argument
495 p = hba->copy_buffer; in stex_controller_info()
498 *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0); in stex_controller_info()
506 p->bus = hba->pdev->bus->number; in stex_controller_info()
507 p->slot = hba->pdev->devfn; in stex_controller_info()
509 p->irq_vec = hba->pdev->irq; in stex_controller_info()
510 p->id = hba->pdev->vendor << 16 | hba->pdev->device; in stex_controller_info()
512 hba->pdev->subsystem_vendor << 16 | hba->pdev->subsystem_device; in stex_controller_info()
518 stex_send_cmd(struct st_hba *hba, struct req_msg *req, u16 tag) in stex_send_cmd() argument
522 hba->ccb[tag].req = req; in stex_send_cmd()
523 hba->out_req_cnt++; in stex_send_cmd()
525 writel(hba->req_head, hba->mmio_base + IMR0); in stex_send_cmd()
526 writel(MU_INBOUND_DOORBELL_REQHEADCHANGED, hba->mmio_base + IDBL); in stex_send_cmd()
527 readl(hba->mmio_base + IDBL); /* flush */ in stex_send_cmd()
531 stex_ss_send_cmd(struct st_hba *hba, struct req_msg *req, u16 tag) in stex_ss_send_cmd() argument
539 hba->ccb[tag].req = req; in stex_ss_send_cmd()
540 hba->out_req_cnt++; in stex_ss_send_cmd()
542 cmd = hba->ccb[tag].cmd; in stex_ss_send_cmd()
548 addr = hba->dma_handle + hba->req_head * hba->rq_size; in stex_ss_send_cmd()
549 addr += (hba->ccb[tag].sg_count+4)/11; in stex_ss_send_cmd()
552 ++hba->req_head; in stex_ss_send_cmd()
553 hba->req_head %= hba->rq_count+1; in stex_ss_send_cmd()
554 if (hba->cardtype == st_P3) { in stex_ss_send_cmd()
555 writel((addr >> 16) >> 16, hba->mmio_base + YH2I_REQ_HI); in stex_ss_send_cmd()
556 writel(addr, hba->mmio_base + YH2I_REQ); in stex_ss_send_cmd()
558 writel((addr >> 16) >> 16, hba->mmio_base + YH2I_REQ_HI); in stex_ss_send_cmd()
559 readl(hba->mmio_base + YH2I_REQ_HI); /* flush */ in stex_ss_send_cmd()
560 writel(addr, hba->mmio_base + YH2I_REQ); in stex_ss_send_cmd()
561 readl(hba->mmio_base + YH2I_REQ); /* flush */ in stex_ss_send_cmd()
565 static void return_abnormal_state(struct st_hba *hba, int status) in return_abnormal_state() argument
571 spin_lock_irqsave(hba->host->host_lock, flags); in return_abnormal_state()
572 for (tag = 0; tag < hba->host->can_queue; tag++) { in return_abnormal_state()
573 ccb = &hba->ccb[tag]; in return_abnormal_state()
584 spin_unlock_irqrestore(hba->host->host_lock, flags); in return_abnormal_state()
599 struct st_hba *hba; in stex_queuecommand_lck() local
608 hba = (struct st_hba *) &host->hostdata[0]; in stex_queuecommand_lck()
609 if (hba->mu_status == MU_STATE_NOCONNECT) { in stex_queuecommand_lck()
614 if (unlikely(hba->mu_status != MU_STATE_STARTED)) in stex_queuecommand_lck()
640 if (hba->cardtype == st_shasta || id == host->max_id - 1) { in stex_queuecommand_lck()
678 .host_no = hba->host->host_no, in stex_queuecommand_lck()
700 req = hba->alloc_rq(hba); in stex_queuecommand_lck()
715 hba->ccb[tag].cmd = cmd; in stex_queuecommand_lck()
716 hba->ccb[tag].sense_bufflen = SCSI_SENSE_BUFFERSIZE; in stex_queuecommand_lck()
717 hba->ccb[tag].sense_buffer = cmd->sense_buffer; in stex_queuecommand_lck()
719 if (!hba->map_sg(hba, req, &hba->ccb[tag])) { in stex_queuecommand_lck()
720 hba->ccb[tag].sg_count = 0; in stex_queuecommand_lck()
724 hba->send(hba, req, tag); in stex_queuecommand_lck()
787 static void stex_check_cmd(struct st_hba *hba, in stex_check_cmd() argument
796 static void stex_mu_intr(struct st_hba *hba, u32 doorbell) in stex_mu_intr() argument
798 void __iomem *base = hba->mmio_base; in stex_mu_intr()
808 hba->status_head = readl(base + OMR1); in stex_mu_intr()
809 if (unlikely(hba->status_head > hba->sts_count)) { in stex_mu_intr()
811 pci_name(hba->pdev)); in stex_mu_intr()
823 if (unlikely(hba->out_req_cnt <= 0 || in stex_mu_intr()
824 (hba->mu_status == MU_STATE_RESETTING && in stex_mu_intr()
825 hba->cardtype != st_yosemite))) { in stex_mu_intr()
826 hba->status_tail = hba->status_head; in stex_mu_intr()
830 while (hba->status_tail != hba->status_head) { in stex_mu_intr()
831 resp = stex_get_status(hba); in stex_mu_intr()
833 if (unlikely(tag >= hba->host->can_queue)) { in stex_mu_intr()
835 "(%s): invalid tag\n", pci_name(hba->pdev)); in stex_mu_intr()
839 hba->out_req_cnt--; in stex_mu_intr()
840 ccb = &hba->ccb[tag]; in stex_mu_intr()
841 if (unlikely(hba->wait_ccb == ccb)) in stex_mu_intr()
842 hba->wait_ccb = NULL; in stex_mu_intr()
845 "(%s): lagging req\n", pci_name(hba->pdev)); in stex_mu_intr()
853 pci_name(hba->pdev)); in stex_mu_intr()
865 if (hba->cardtype == st_yosemite) in stex_mu_intr()
866 stex_check_cmd(hba, ccb, resp); in stex_mu_intr()
870 stex_controller_info(hba, ccb); in stex_mu_intr()
879 writel(hba->status_head, base + IMR1); in stex_mu_intr()
885 struct st_hba *hba = __hba; in stex_intr() local
886 void __iomem *base = hba->mmio_base; in stex_intr()
890 spin_lock_irqsave(hba->host->host_lock, flags); in stex_intr()
898 stex_mu_intr(hba, data); in stex_intr()
899 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_intr()
901 hba->cardtype == st_shasta)) in stex_intr()
902 queue_work(hba->work_q, &hba->reset_work); in stex_intr()
906 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_intr()
911 static void stex_ss_mu_intr(struct st_hba *hba) in stex_ss_mu_intr() argument
921 if (unlikely(hba->out_req_cnt <= 0 || in stex_ss_mu_intr()
922 hba->mu_status == MU_STATE_RESETTING)) in stex_ss_mu_intr()
925 while (count < hba->sts_count) { in stex_ss_mu_intr()
926 scratch = hba->scratch + hba->status_tail; in stex_ss_mu_intr()
931 resp = hba->status_buffer + hba->status_tail; in stex_ss_mu_intr()
934 ++hba->status_tail; in stex_ss_mu_intr()
935 hba->status_tail %= hba->sts_count+1; in stex_ss_mu_intr()
938 if (unlikely(tag >= hba->host->can_queue)) { in stex_ss_mu_intr()
940 "(%s): invalid tag\n", pci_name(hba->pdev)); in stex_ss_mu_intr()
944 hba->out_req_cnt--; in stex_ss_mu_intr()
945 ccb = &hba->ccb[tag]; in stex_ss_mu_intr()
946 if (unlikely(hba->wait_ccb == ccb)) in stex_ss_mu_intr()
947 hba->wait_ccb = NULL; in stex_ss_mu_intr()
950 "(%s): lagging req\n", pci_name(hba->pdev)); in stex_ss_mu_intr()
966 pci_name(hba->pdev)); in stex_ss_mu_intr()
973 stex_check_cmd(hba, ccb, resp); in stex_ss_mu_intr()
986 struct st_hba *hba = __hba; in stex_ss_intr() local
987 void __iomem *base = hba->mmio_base; in stex_ss_intr()
991 spin_lock_irqsave(hba->host->host_lock, flags); in stex_ss_intr()
993 if (hba->cardtype == st_yel) { in stex_ss_intr()
998 stex_ss_mu_intr(hba); in stex_ss_intr()
999 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_ss_intr()
1001 queue_work(hba->work_q, &hba->reset_work); in stex_ss_intr()
1012 stex_ss_mu_intr(hba); in stex_ss_intr()
1013 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_ss_intr()
1015 queue_work(hba->work_q, &hba->reset_work); in stex_ss_intr()
1020 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_ss_intr()
1025 static int stex_common_handshake(struct st_hba *hba) in stex_common_handshake() argument
1027 void __iomem *base = hba->mmio_base; in stex_common_handshake()
1041 pci_name(hba->pdev)); in stex_common_handshake()
1054 if (hba->host->can_queue > data) { in stex_common_handshake()
1055 hba->host->can_queue = data; in stex_common_handshake()
1056 hba->host->cmd_per_lun = data; in stex_common_handshake()
1060 h = (struct handshake_frame *)hba->status_buffer; in stex_common_handshake()
1061 h->rb_phy = cpu_to_le64(hba->dma_handle); in stex_common_handshake()
1062 h->req_sz = cpu_to_le16(hba->rq_size); in stex_common_handshake()
1063 h->req_cnt = cpu_to_le16(hba->rq_count+1); in stex_common_handshake()
1065 h->status_cnt = cpu_to_le16(hba->sts_count+1); in stex_common_handshake()
1068 if (hba->extra_offset) { in stex_common_handshake()
1069 h->extra_offset = cpu_to_le32(hba->extra_offset); in stex_common_handshake()
1070 h->extra_size = cpu_to_le32(hba->dma_size - hba->extra_offset); in stex_common_handshake()
1074 status_phys = hba->dma_handle + (hba->rq_count+1) * hba->rq_size; in stex_common_handshake()
1091 pci_name(hba->pdev)); in stex_common_handshake()
1109 static int stex_ss_handshake(struct st_hba *hba) in stex_ss_handshake() argument
1111 void __iomem *base = hba->mmio_base; in stex_ss_handshake()
1121 if (hba->cardtype == st_yel) { in stex_ss_handshake()
1127 pci_name(hba->pdev)); in stex_ss_handshake()
1139 pci_name(hba->pdev)); in stex_ss_handshake()
1147 msg_h = (struct st_msg_header *)hba->dma_mem; in stex_ss_handshake()
1148 msg_h->handle = cpu_to_le64(hba->dma_handle); in stex_ss_handshake()
1152 h->rb_phy = cpu_to_le64(hba->dma_handle); in stex_ss_handshake()
1153 h->req_sz = cpu_to_le16(hba->rq_size); in stex_ss_handshake()
1154 h->req_cnt = cpu_to_le16(hba->rq_count+1); in stex_ss_handshake()
1156 h->status_cnt = cpu_to_le16(hba->sts_count+1); in stex_ss_handshake()
1160 scratch_size = (hba->sts_count+1)*sizeof(u32); in stex_ss_handshake()
1163 if (hba->cardtype == st_yel) { in stex_ss_handshake()
1167 writel((hba->dma_handle >> 16) >> 16, base + YH2I_REQ_HI); in stex_ss_handshake()
1169 writel(hba->dma_handle, base + YH2I_REQ); in stex_ss_handshake()
1176 if (hba->msi_lock == 0) { in stex_ss_handshake()
1179 hba->msi_lock = 1; in stex_ss_handshake()
1181 writel((hba->dma_handle >> 16) >> 16, base + YH2I_REQ_HI); in stex_ss_handshake()
1182 writel(hba->dma_handle, base + YH2I_REQ); in stex_ss_handshake()
1186 scratch = hba->scratch; in stex_ss_handshake()
1187 if (hba->cardtype == st_yel) { in stex_ss_handshake()
1192 pci_name(hba->pdev)); in stex_ss_handshake()
1205 pci_name(hba->pdev)); in stex_ss_handshake()
1220 static int stex_handshake(struct st_hba *hba) in stex_handshake() argument
1226 if (hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_handshake()
1227 err = stex_ss_handshake(hba); in stex_handshake()
1229 err = stex_common_handshake(hba); in stex_handshake()
1230 spin_lock_irqsave(hba->host->host_lock, flags); in stex_handshake()
1231 mu_status = hba->mu_status; in stex_handshake()
1233 hba->req_head = 0; in stex_handshake()
1234 hba->req_tail = 0; in stex_handshake()
1235 hba->status_head = 0; in stex_handshake()
1236 hba->status_tail = 0; in stex_handshake()
1237 hba->out_req_cnt = 0; in stex_handshake()
1238 hba->mu_status = MU_STATE_STARTED; in stex_handshake()
1240 hba->mu_status = MU_STATE_FAILED; in stex_handshake()
1242 wake_up_all(&hba->reset_waitq); in stex_handshake()
1243 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_handshake()
1250 struct st_hba *hba = (struct st_hba *)host->hostdata; in stex_abort() local
1259 base = hba->mmio_base; in stex_abort()
1262 hba->ccb[tag].req && hba->ccb[tag].cmd == cmd) in stex_abort()
1263 hba->wait_ccb = &hba->ccb[tag]; in stex_abort()
1267 if (hba->cardtype == st_yel) { in stex_abort()
1273 stex_ss_mu_intr(hba); in stex_abort()
1274 } else if (hba->cardtype == st_P3) { in stex_abort()
1282 stex_ss_mu_intr(hba); in stex_abort()
1290 stex_mu_intr(hba, data); in stex_abort()
1292 if (hba->wait_ccb == NULL) { in stex_abort()
1294 "(%s): lost interrupt\n", pci_name(hba->pdev)); in stex_abort()
1300 hba->wait_ccb->req = NULL; /* nullify the req's future return */ in stex_abort()
1301 hba->wait_ccb = NULL; in stex_abort()
1308 static void stex_hard_reset(struct st_hba *hba) in stex_hard_reset() argument
1316 pci_read_config_dword(hba->pdev, i * 4, in stex_hard_reset()
1317 &hba->pdev->saved_config_space[i]); in stex_hard_reset()
1321 bus = hba->pdev->bus; in stex_hard_reset()
1335 pci_read_config_word(hba->pdev, PCI_COMMAND, &pci_cmd); in stex_hard_reset()
1343 pci_write_config_dword(hba->pdev, i * 4, in stex_hard_reset()
1344 hba->pdev->saved_config_space[i]); in stex_hard_reset()
1347 static int stex_yos_reset(struct st_hba *hba) in stex_yos_reset() argument
1353 base = hba->mmio_base; in stex_yos_reset()
1357 while (hba->out_req_cnt > 0) { in stex_yos_reset()
1360 "(%s): reset timeout\n", pci_name(hba->pdev)); in stex_yos_reset()
1367 spin_lock_irqsave(hba->host->host_lock, flags); in stex_yos_reset()
1369 hba->mu_status = MU_STATE_FAILED; in stex_yos_reset()
1371 hba->mu_status = MU_STATE_STARTED; in stex_yos_reset()
1372 wake_up_all(&hba->reset_waitq); in stex_yos_reset()
1373 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_yos_reset()
1378 static void stex_ss_reset(struct st_hba *hba) in stex_ss_reset() argument
1380 writel(SS_H2I_INT_RESET, hba->mmio_base + YH2I_INT); in stex_ss_reset()
1381 readl(hba->mmio_base + YH2I_INT); in stex_ss_reset()
1385 static void stex_p3_reset(struct st_hba *hba) in stex_p3_reset() argument
1387 writel(SS_H2I_INT_RESET, hba->mmio_base + YH2I_INT); in stex_p3_reset()
1391 static int stex_do_reset(struct st_hba *hba) in stex_do_reset() argument
1396 spin_lock_irqsave(hba->host->host_lock, flags); in stex_do_reset()
1397 if (hba->mu_status == MU_STATE_STARTING) { in stex_do_reset()
1398 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_do_reset()
1400 pci_name(hba->pdev)); in stex_do_reset()
1403 while (hba->mu_status == MU_STATE_RESETTING) { in stex_do_reset()
1404 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_do_reset()
1405 wait_event_timeout(hba->reset_waitq, in stex_do_reset()
1406 hba->mu_status != MU_STATE_RESETTING, in stex_do_reset()
1408 spin_lock_irqsave(hba->host->host_lock, flags); in stex_do_reset()
1409 mu_status = hba->mu_status; in stex_do_reset()
1413 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_do_reset()
1417 hba->mu_status = MU_STATE_RESETTING; in stex_do_reset()
1418 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_do_reset()
1420 if (hba->cardtype == st_yosemite) in stex_do_reset()
1421 return stex_yos_reset(hba); in stex_do_reset()
1423 if (hba->cardtype == st_shasta) in stex_do_reset()
1424 stex_hard_reset(hba); in stex_do_reset()
1425 else if (hba->cardtype == st_yel) in stex_do_reset()
1426 stex_ss_reset(hba); in stex_do_reset()
1427 else if (hba->cardtype == st_P3) in stex_do_reset()
1428 stex_p3_reset(hba); in stex_do_reset()
1430 return_abnormal_state(hba, DID_RESET); in stex_do_reset()
1432 if (stex_handshake(hba) == 0) in stex_do_reset()
1436 pci_name(hba->pdev)); in stex_do_reset()
1442 struct st_hba *hba; in stex_reset() local
1444 hba = (struct st_hba *) &cmd->device->host->hostdata[0]; in stex_reset()
1449 return stex_do_reset(hba) ? FAILED : SUCCESS; in stex_reset()
1454 struct st_hba *hba = container_of(work, struct st_hba, reset_work); in stex_reset_work() local
1456 stex_do_reset(hba); in stex_reset_work()
1617 static int stex_request_irq(struct st_hba *hba) in stex_request_irq() argument
1619 struct pci_dev *pdev = hba->pdev; in stex_request_irq()
1622 if (msi || hba->cardtype == st_P3) { in stex_request_irq()
1629 hba->msi_enabled = 1; in stex_request_irq()
1631 hba->msi_enabled = 0; in stex_request_irq()
1634 (hba->cardtype == st_yel || hba->cardtype == st_P3) ? in stex_request_irq()
1635 stex_ss_intr : stex_intr, IRQF_SHARED, DRV_NAME, hba); in stex_request_irq()
1638 if (hba->msi_enabled) in stex_request_irq()
1644 static void stex_free_irq(struct st_hba *hba) in stex_free_irq() argument
1646 struct pci_dev *pdev = hba->pdev; in stex_free_irq()
1648 free_irq(pdev->irq, hba); in stex_free_irq()
1649 if (hba->msi_enabled) in stex_free_irq()
1655 struct st_hba *hba; in stex_probe() local
1679 hba = (struct st_hba *)host->hostdata; in stex_probe()
1680 memset(hba, 0, sizeof(struct st_hba)); in stex_probe()
1689 hba->mmio_base = pci_ioremap_bar(pdev, 0); in stex_probe()
1690 if ( !hba->mmio_base) { in stex_probe()
1706 hba->cardtype = (unsigned int) id->driver_data; in stex_probe()
1707 ci = &stex_card_info[hba->cardtype]; in stex_probe()
1723 if (hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_probe()
1724 hba->supports_pm = 1; in stex_probe()
1728 if (hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_probe()
1731 hba->dma_size = cp_offset + sizeof(struct st_frame); in stex_probe()
1732 if (hba->cardtype == st_seq || in stex_probe()
1733 (hba->cardtype == st_vsc && (pdev->subsystem_device & 1))) { in stex_probe()
1734 hba->extra_offset = hba->dma_size; in stex_probe()
1735 hba->dma_size += ST_ADDITIONAL_MEM; in stex_probe()
1737 hba->dma_mem = dma_alloc_coherent(&pdev->dev, in stex_probe()
1738 hba->dma_size, &hba->dma_handle, GFP_KERNEL); in stex_probe()
1739 if (!hba->dma_mem) { in stex_probe()
1741 if (hba->cardtype == st_seq || in stex_probe()
1742 (hba->cardtype == st_vsc && (pdev->subsystem_device & 1))) { in stex_probe()
1746 hba->dma_size = hba->extra_offset in stex_probe()
1748 hba->dma_mem = dma_alloc_coherent(&pdev->dev, in stex_probe()
1749 hba->dma_size, &hba->dma_handle, GFP_KERNEL); in stex_probe()
1752 if (!hba->dma_mem) { in stex_probe()
1760 hba->ccb = kcalloc(ci->rq_count, sizeof(struct st_ccb), GFP_KERNEL); in stex_probe()
1761 if (!hba->ccb) { in stex_probe()
1768 if (hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_probe()
1769 hba->scratch = (__le32 *)(hba->dma_mem + scratch_offset); in stex_probe()
1770 hba->status_buffer = (struct status_msg *)(hba->dma_mem + sts_offset); in stex_probe()
1771 hba->copy_buffer = hba->dma_mem + cp_offset; in stex_probe()
1772 hba->rq_count = ci->rq_count; in stex_probe()
1773 hba->rq_size = ci->rq_size; in stex_probe()
1774 hba->sts_count = ci->sts_count; in stex_probe()
1775 hba->alloc_rq = ci->alloc_rq; in stex_probe()
1776 hba->map_sg = ci->map_sg; in stex_probe()
1777 hba->send = ci->send; in stex_probe()
1778 hba->mu_status = MU_STATE_STARTING; in stex_probe()
1779 hba->msi_lock = 0; in stex_probe()
1781 if (hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_probe()
1793 hba->host = host; in stex_probe()
1794 hba->pdev = pdev; in stex_probe()
1795 init_waitqueue_head(&hba->reset_waitq); in stex_probe()
1797 hba->work_q = alloc_ordered_workqueue("stex_wq_%d", WQ_MEM_RECLAIM, in stex_probe()
1799 if (!hba->work_q) { in stex_probe()
1805 INIT_WORK(&hba->reset_work, stex_reset_work); in stex_probe()
1807 err = stex_request_irq(hba); in stex_probe()
1814 err = stex_handshake(hba); in stex_probe()
1818 pci_set_drvdata(pdev, hba); in stex_probe()
1832 stex_free_irq(hba); in stex_probe()
1834 destroy_workqueue(hba->work_q); in stex_probe()
1836 kfree(hba->ccb); in stex_probe()
1838 dma_free_coherent(&pdev->dev, hba->dma_size, in stex_probe()
1839 hba->dma_mem, hba->dma_handle); in stex_probe()
1841 iounmap(hba->mmio_base); in stex_probe()
1852 static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic) in stex_hba_stop() argument
1860 spin_lock_irqsave(hba->host->host_lock, flags); in stex_hba_stop()
1862 if ((hba->cardtype == st_yel || hba->cardtype == st_P3) && in stex_hba_stop()
1863 hba->supports_pm == 1) { in stex_hba_stop()
1865 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_hba_stop()
1869 req = hba->alloc_rq(hba); in stex_hba_stop()
1870 if (hba->cardtype == st_yel || hba->cardtype == st_P3) { in stex_hba_stop()
1872 memset(msg_h, 0, hba->rq_size); in stex_hba_stop()
1874 memset(req, 0, hba->rq_size); in stex_hba_stop()
1876 if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel in stex_hba_stop()
1877 || hba->cardtype == st_P3) in stex_hba_stop()
1883 } else if ((hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_hba_stop()
1895 hba->ccb[tag].cmd = NULL; in stex_hba_stop()
1896 hba->ccb[tag].sg_count = 0; in stex_hba_stop()
1897 hba->ccb[tag].sense_bufflen = 0; in stex_hba_stop()
1898 hba->ccb[tag].sense_buffer = NULL; in stex_hba_stop()
1899 hba->ccb[tag].req_type = PASSTHRU_REQ_TYPE; in stex_hba_stop()
1900 hba->send(hba, req, tag); in stex_hba_stop()
1901 spin_unlock_irqrestore(hba->host->host_lock, flags); in stex_hba_stop()
1903 while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) { in stex_hba_stop()
1905 hba->ccb[tag].req_type = 0; in stex_hba_stop()
1906 hba->mu_status = MU_STATE_STOP; in stex_hba_stop()
1911 hba->mu_status = MU_STATE_STOP; in stex_hba_stop()
1914 static void stex_hba_free(struct st_hba *hba) in stex_hba_free() argument
1916 stex_free_irq(hba); in stex_hba_free()
1918 destroy_workqueue(hba->work_q); in stex_hba_free()
1920 iounmap(hba->mmio_base); in stex_hba_free()
1922 pci_release_regions(hba->pdev); in stex_hba_free()
1924 kfree(hba->ccb); in stex_hba_free()
1926 dma_free_coherent(&hba->pdev->dev, hba->dma_size, in stex_hba_free()
1927 hba->dma_mem, hba->dma_handle); in stex_hba_free()
1932 struct st_hba *hba = pci_get_drvdata(pdev); in stex_remove() local
1934 hba->mu_status = MU_STATE_NOCONNECT; in stex_remove()
1935 return_abnormal_state(hba, DID_NO_CONNECT); in stex_remove()
1936 scsi_remove_host(hba->host); in stex_remove()
1938 scsi_block_requests(hba->host); in stex_remove()
1940 stex_hba_free(hba); in stex_remove()
1942 scsi_host_put(hba->host); in stex_remove()
1951 struct st_hba *hba = pci_get_drvdata(pdev); in stex_shutdown() local
1953 if (hba->supports_pm == 0) { in stex_shutdown()
1954 stex_hba_stop(hba, ST_IGNORED); in stex_shutdown()
1955 } else if (hba->supports_pm == 1 && S6flag) { in stex_shutdown()
1957 stex_hba_stop(hba, ST_S6); in stex_shutdown()
1959 stex_hba_stop(hba, ST_S5); in stex_shutdown()
1962 static int stex_choice_sleep_mic(struct st_hba *hba, pm_message_t state) in stex_choice_sleep_mic() argument
1968 hba->msi_lock = 0; in stex_choice_sleep_mic()
1977 struct st_hba *hba = pci_get_drvdata(pdev); in stex_suspend() local
1979 if ((hba->cardtype == st_yel || hba->cardtype == st_P3) in stex_suspend()
1980 && hba->supports_pm == 1) in stex_suspend()
1981 stex_hba_stop(hba, stex_choice_sleep_mic(hba, state)); in stex_suspend()
1983 stex_hba_stop(hba, ST_IGNORED); in stex_suspend()
1989 struct st_hba *hba = pci_get_drvdata(pdev); in stex_resume() local
1991 hba->mu_status = MU_STATE_STARTING; in stex_resume()
1992 stex_handshake(hba); in stex_resume()