• Home
  • Raw
  • Download

Lines Matching refs:ctrl

215 		q_depth += atomic_read(&card->ctrl[i].stats.hw_q_depth);  in dma_intr_coal_auto_tune()
224 static void rsxx_free_dma(struct rsxx_dma_ctrl *ctrl, struct rsxx_dma *dma) in rsxx_free_dma() argument
227 if (!pci_dma_mapping_error(ctrl->card->dev, dma->dma_addr)) { in rsxx_free_dma()
228 pci_unmap_page(ctrl->card->dev, dma->dma_addr, in rsxx_free_dma()
239 static void rsxx_complete_dma(struct rsxx_dma_ctrl *ctrl, in rsxx_complete_dma() argument
244 ctrl->stats.dma_sw_err++; in rsxx_complete_dma()
246 ctrl->stats.dma_hw_fault++; in rsxx_complete_dma()
248 ctrl->stats.dma_cancelled++; in rsxx_complete_dma()
251 dma->cb(ctrl->card, dma->cb_data, status ? 1 : 0); in rsxx_complete_dma()
253 rsxx_free_dma(ctrl, dma); in rsxx_complete_dma()
256 int rsxx_cleanup_dma_queue(struct rsxx_dma_ctrl *ctrl, in rsxx_cleanup_dma_queue() argument
266 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED); in rsxx_cleanup_dma_queue()
268 rsxx_free_dma(ctrl, dma); in rsxx_cleanup_dma_queue()
275 static void rsxx_requeue_dma(struct rsxx_dma_ctrl *ctrl, in rsxx_requeue_dma() argument
282 spin_lock_bh(&ctrl->queue_lock); in rsxx_requeue_dma()
283 ctrl->stats.sw_q_depth++; in rsxx_requeue_dma()
284 list_add(&dma->list, &ctrl->queue); in rsxx_requeue_dma()
285 spin_unlock_bh(&ctrl->queue_lock); in rsxx_requeue_dma()
288 static void rsxx_handle_dma_error(struct rsxx_dma_ctrl *ctrl, in rsxx_handle_dma_error() argument
295 dev_dbg(CARD_TO_DEV(ctrl->card), in rsxx_handle_dma_error()
300 ctrl->stats.crc_errors++; in rsxx_handle_dma_error()
302 ctrl->stats.hard_errors++; in rsxx_handle_dma_error()
304 ctrl->stats.soft_errors++; in rsxx_handle_dma_error()
309 if (ctrl->card->scrub_hard) { in rsxx_handle_dma_error()
312 ctrl->stats.reads_retried++; in rsxx_handle_dma_error()
315 ctrl->stats.reads_failed++; in rsxx_handle_dma_error()
319 ctrl->stats.reads_failed++; in rsxx_handle_dma_error()
327 ctrl->stats.reads_failed++; in rsxx_handle_dma_error()
333 ctrl->stats.writes_failed++; in rsxx_handle_dma_error()
338 ctrl->stats.discards_failed++; in rsxx_handle_dma_error()
342 dev_err(CARD_TO_DEV(ctrl->card), in rsxx_handle_dma_error()
352 rsxx_requeue_dma(ctrl, dma); in rsxx_handle_dma_error()
354 rsxx_complete_dma(ctrl, dma, status); in rsxx_handle_dma_error()
359 struct rsxx_dma_ctrl *ctrl = (struct rsxx_dma_ctrl *)data; in dma_engine_stalled() local
362 if (atomic_read(&ctrl->stats.hw_q_depth) == 0 || in dma_engine_stalled()
363 unlikely(ctrl->card->eeh_state)) in dma_engine_stalled()
366 if (ctrl->cmd.idx != ioread32(ctrl->regmap + SW_CMD_IDX)) { in dma_engine_stalled()
371 dev_warn(CARD_TO_DEV(ctrl->card), in dma_engine_stalled()
373 iowrite32(ctrl->cmd.idx, ctrl->regmap + SW_CMD_IDX); in dma_engine_stalled()
374 mod_timer(&ctrl->activity_timer, in dma_engine_stalled()
377 dev_warn(CARD_TO_DEV(ctrl->card), in dma_engine_stalled()
379 ctrl->id); in dma_engine_stalled()
380 ctrl->card->dma_fault = 1; in dma_engine_stalled()
383 spin_lock(&ctrl->queue_lock); in dma_engine_stalled()
384 cnt = rsxx_cleanup_dma_queue(ctrl, &ctrl->queue, COMPLETE_DMA); in dma_engine_stalled()
385 spin_unlock(&ctrl->queue_lock); in dma_engine_stalled()
387 cnt += rsxx_dma_cancel(ctrl); in dma_engine_stalled()
390 dev_info(CARD_TO_DEV(ctrl->card), in dma_engine_stalled()
392 cnt, ctrl->id); in dma_engine_stalled()
396 static void rsxx_issue_dmas(struct rsxx_dma_ctrl *ctrl) in rsxx_issue_dmas() argument
404 hw_cmd_buf = ctrl->cmd.buf; in rsxx_issue_dmas()
406 if (unlikely(ctrl->card->halt) || in rsxx_issue_dmas()
407 unlikely(ctrl->card->eeh_state)) in rsxx_issue_dmas()
411 spin_lock_bh(&ctrl->queue_lock); in rsxx_issue_dmas()
412 if (list_empty(&ctrl->queue)) { in rsxx_issue_dmas()
413 spin_unlock_bh(&ctrl->queue_lock); in rsxx_issue_dmas()
416 spin_unlock_bh(&ctrl->queue_lock); in rsxx_issue_dmas()
418 tag = pop_tracker(ctrl->trackers); in rsxx_issue_dmas()
422 spin_lock_bh(&ctrl->queue_lock); in rsxx_issue_dmas()
423 dma = list_entry(ctrl->queue.next, struct rsxx_dma, list); in rsxx_issue_dmas()
425 ctrl->stats.sw_q_depth--; in rsxx_issue_dmas()
426 spin_unlock_bh(&ctrl->queue_lock); in rsxx_issue_dmas()
433 if (unlikely(ctrl->card->dma_fault)) { in rsxx_issue_dmas()
434 push_tracker(ctrl->trackers, tag); in rsxx_issue_dmas()
435 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED); in rsxx_issue_dmas()
455 dma->dma_addr = pci_map_page(ctrl->card->dev, dma->page, in rsxx_issue_dmas()
457 if (pci_dma_mapping_error(ctrl->card->dev, dma->dma_addr)) { in rsxx_issue_dmas()
458 push_tracker(ctrl->trackers, tag); in rsxx_issue_dmas()
459 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED); in rsxx_issue_dmas()
464 set_tracker_dma(ctrl->trackers, tag, dma); in rsxx_issue_dmas()
465 hw_cmd_buf[ctrl->cmd.idx].command = dma->cmd; in rsxx_issue_dmas()
466 hw_cmd_buf[ctrl->cmd.idx].tag = tag; in rsxx_issue_dmas()
467 hw_cmd_buf[ctrl->cmd.idx]._rsvd = 0; in rsxx_issue_dmas()
468 hw_cmd_buf[ctrl->cmd.idx].sub_page = in rsxx_issue_dmas()
472 hw_cmd_buf[ctrl->cmd.idx].device_addr = in rsxx_issue_dmas()
475 hw_cmd_buf[ctrl->cmd.idx].host_addr = in rsxx_issue_dmas()
478 dev_dbg(CARD_TO_DEV(ctrl->card), in rsxx_issue_dmas()
480 ctrl->id, dma->laddr, tag, ctrl->cmd.idx); in rsxx_issue_dmas()
482 ctrl->cmd.idx = (ctrl->cmd.idx + 1) & RSXX_CS_IDX_MASK; in rsxx_issue_dmas()
486 ctrl->stats.writes_issued++; in rsxx_issue_dmas()
488 ctrl->stats.discards_issued++; in rsxx_issue_dmas()
490 ctrl->stats.reads_issued++; in rsxx_issue_dmas()
495 atomic_add(cmds_pending, &ctrl->stats.hw_q_depth); in rsxx_issue_dmas()
496 mod_timer(&ctrl->activity_timer, in rsxx_issue_dmas()
499 if (unlikely(ctrl->card->eeh_state)) { in rsxx_issue_dmas()
500 del_timer_sync(&ctrl->activity_timer); in rsxx_issue_dmas()
504 iowrite32(ctrl->cmd.idx, ctrl->regmap + SW_CMD_IDX); in rsxx_issue_dmas()
508 static void rsxx_dma_done(struct rsxx_dma_ctrl *ctrl) in rsxx_dma_done() argument
517 hw_st_buf = ctrl->status.buf; in rsxx_dma_done()
519 if (unlikely(ctrl->card->halt) || in rsxx_dma_done()
520 unlikely(ctrl->card->dma_fault) || in rsxx_dma_done()
521 unlikely(ctrl->card->eeh_state)) in rsxx_dma_done()
524 count = le16_to_cpu(hw_st_buf[ctrl->status.idx].count); in rsxx_dma_done()
526 while (count == ctrl->e_cnt) { in rsxx_dma_done()
536 status = hw_st_buf[ctrl->status.idx].status; in rsxx_dma_done()
537 tag = hw_st_buf[ctrl->status.idx].tag; in rsxx_dma_done()
539 dma = get_tracker_dma(ctrl->trackers, tag); in rsxx_dma_done()
541 spin_lock_irqsave(&ctrl->card->irq_lock, flags); in rsxx_dma_done()
542 rsxx_disable_ier(ctrl->card, CR_INTR_DMA_ALL); in rsxx_dma_done()
543 spin_unlock_irqrestore(&ctrl->card->irq_lock, flags); in rsxx_dma_done()
545 dev_err(CARD_TO_DEV(ctrl->card), in rsxx_dma_done()
548 tag, ctrl->status.idx, ctrl->id); in rsxx_dma_done()
552 dev_dbg(CARD_TO_DEV(ctrl->card), in rsxx_dma_done()
555 ctrl->id, dma->laddr, tag, status, count, in rsxx_dma_done()
556 ctrl->status.idx); in rsxx_dma_done()
558 atomic_dec(&ctrl->stats.hw_q_depth); in rsxx_dma_done()
560 mod_timer(&ctrl->activity_timer, in rsxx_dma_done()
564 rsxx_handle_dma_error(ctrl, dma, status); in rsxx_dma_done()
566 rsxx_complete_dma(ctrl, dma, 0); in rsxx_dma_done()
568 push_tracker(ctrl->trackers, tag); in rsxx_dma_done()
570 ctrl->status.idx = (ctrl->status.idx + 1) & in rsxx_dma_done()
572 ctrl->e_cnt++; in rsxx_dma_done()
574 count = le16_to_cpu(hw_st_buf[ctrl->status.idx].count); in rsxx_dma_done()
577 dma_intr_coal_auto_tune(ctrl->card); in rsxx_dma_done()
579 if (atomic_read(&ctrl->stats.hw_q_depth) == 0) in rsxx_dma_done()
580 del_timer_sync(&ctrl->activity_timer); in rsxx_dma_done()
582 spin_lock_irqsave(&ctrl->card->irq_lock, flags); in rsxx_dma_done()
583 rsxx_enable_ier(ctrl->card, CR_INTR_DMA(ctrl->id)); in rsxx_dma_done()
584 spin_unlock_irqrestore(&ctrl->card->irq_lock, flags); in rsxx_dma_done()
586 spin_lock_bh(&ctrl->queue_lock); in rsxx_dma_done()
587 if (ctrl->stats.sw_q_depth) in rsxx_dma_done()
588 queue_work(ctrl->issue_wq, &ctrl->issue_dma_work); in rsxx_dma_done()
589 spin_unlock_bh(&ctrl->queue_lock); in rsxx_dma_done()
594 struct rsxx_dma_ctrl *ctrl; in rsxx_schedule_issue() local
596 ctrl = container_of(work, struct rsxx_dma_ctrl, issue_dma_work); in rsxx_schedule_issue()
598 mutex_lock(&ctrl->work_lock); in rsxx_schedule_issue()
599 rsxx_issue_dmas(ctrl); in rsxx_schedule_issue()
600 mutex_unlock(&ctrl->work_lock); in rsxx_schedule_issue()
605 struct rsxx_dma_ctrl *ctrl; in rsxx_schedule_done() local
607 ctrl = container_of(work, struct rsxx_dma_ctrl, dma_done_work); in rsxx_schedule_done()
609 mutex_lock(&ctrl->work_lock); in rsxx_schedule_done()
610 rsxx_dma_done(ctrl); in rsxx_schedule_done()
611 mutex_unlock(&ctrl->work_lock); in rsxx_schedule_done()
756 spin_lock_bh(&card->ctrl[i].queue_lock); in rsxx_dma_queue_bio()
757 card->ctrl[i].stats.sw_q_depth += dma_cnt[i]; in rsxx_dma_queue_bio()
758 list_splice_tail(&dma_list[i], &card->ctrl[i].queue); in rsxx_dma_queue_bio()
759 spin_unlock_bh(&card->ctrl[i].queue_lock); in rsxx_dma_queue_bio()
761 queue_work(card->ctrl[i].issue_wq, in rsxx_dma_queue_bio()
762 &card->ctrl[i].issue_dma_work); in rsxx_dma_queue_bio()
770 rsxx_cleanup_dma_queue(&card->ctrl[i], &dma_list[i], in rsxx_dma_queue_bio()
778 int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl) in rsxx_hw_buffers_init() argument
780 ctrl->status.buf = pci_alloc_consistent(dev, STATUS_BUFFER_SIZE8, in rsxx_hw_buffers_init()
781 &ctrl->status.dma_addr); in rsxx_hw_buffers_init()
782 ctrl->cmd.buf = pci_alloc_consistent(dev, COMMAND_BUFFER_SIZE8, in rsxx_hw_buffers_init()
783 &ctrl->cmd.dma_addr); in rsxx_hw_buffers_init()
784 if (ctrl->status.buf == NULL || ctrl->cmd.buf == NULL) in rsxx_hw_buffers_init()
787 memset(ctrl->status.buf, 0xac, STATUS_BUFFER_SIZE8); in rsxx_hw_buffers_init()
788 iowrite32(lower_32_bits(ctrl->status.dma_addr), in rsxx_hw_buffers_init()
789 ctrl->regmap + SB_ADD_LO); in rsxx_hw_buffers_init()
790 iowrite32(upper_32_bits(ctrl->status.dma_addr), in rsxx_hw_buffers_init()
791 ctrl->regmap + SB_ADD_HI); in rsxx_hw_buffers_init()
793 memset(ctrl->cmd.buf, 0x83, COMMAND_BUFFER_SIZE8); in rsxx_hw_buffers_init()
794 iowrite32(lower_32_bits(ctrl->cmd.dma_addr), ctrl->regmap + CB_ADD_LO); in rsxx_hw_buffers_init()
795 iowrite32(upper_32_bits(ctrl->cmd.dma_addr), ctrl->regmap + CB_ADD_HI); in rsxx_hw_buffers_init()
797 ctrl->status.idx = ioread32(ctrl->regmap + HW_STATUS_CNT); in rsxx_hw_buffers_init()
798 if (ctrl->status.idx > RSXX_MAX_OUTSTANDING_CMDS) { in rsxx_hw_buffers_init()
800 ctrl->status.idx); in rsxx_hw_buffers_init()
803 iowrite32(ctrl->status.idx, ctrl->regmap + HW_STATUS_CNT); in rsxx_hw_buffers_init()
804 iowrite32(ctrl->status.idx, ctrl->regmap + SW_STATUS_CNT); in rsxx_hw_buffers_init()
806 ctrl->cmd.idx = ioread32(ctrl->regmap + HW_CMD_IDX); in rsxx_hw_buffers_init()
807 if (ctrl->cmd.idx > RSXX_MAX_OUTSTANDING_CMDS) { in rsxx_hw_buffers_init()
809 ctrl->status.idx); in rsxx_hw_buffers_init()
812 iowrite32(ctrl->cmd.idx, ctrl->regmap + HW_CMD_IDX); in rsxx_hw_buffers_init()
813 iowrite32(ctrl->cmd.idx, ctrl->regmap + SW_CMD_IDX); in rsxx_hw_buffers_init()
819 struct rsxx_dma_ctrl *ctrl) in rsxx_dma_ctrl_init() argument
824 memset(&ctrl->stats, 0, sizeof(ctrl->stats)); in rsxx_dma_ctrl_init()
826 ctrl->trackers = vmalloc(DMA_TRACKER_LIST_SIZE8); in rsxx_dma_ctrl_init()
827 if (!ctrl->trackers) in rsxx_dma_ctrl_init()
830 ctrl->trackers->head = 0; in rsxx_dma_ctrl_init()
832 ctrl->trackers->list[i].next_tag = i + 1; in rsxx_dma_ctrl_init()
833 ctrl->trackers->list[i].dma = NULL; in rsxx_dma_ctrl_init()
835 ctrl->trackers->list[RSXX_MAX_OUTSTANDING_CMDS-1].next_tag = -1; in rsxx_dma_ctrl_init()
836 spin_lock_init(&ctrl->trackers->lock); in rsxx_dma_ctrl_init()
838 spin_lock_init(&ctrl->queue_lock); in rsxx_dma_ctrl_init()
839 mutex_init(&ctrl->work_lock); in rsxx_dma_ctrl_init()
840 INIT_LIST_HEAD(&ctrl->queue); in rsxx_dma_ctrl_init()
842 setup_timer(&ctrl->activity_timer, dma_engine_stalled, in rsxx_dma_ctrl_init()
843 (unsigned long)ctrl); in rsxx_dma_ctrl_init()
845 ctrl->issue_wq = alloc_ordered_workqueue(DRIVER_NAME"_issue", 0); in rsxx_dma_ctrl_init()
846 if (!ctrl->issue_wq) in rsxx_dma_ctrl_init()
849 ctrl->done_wq = alloc_ordered_workqueue(DRIVER_NAME"_done", 0); in rsxx_dma_ctrl_init()
850 if (!ctrl->done_wq) in rsxx_dma_ctrl_init()
853 INIT_WORK(&ctrl->issue_dma_work, rsxx_schedule_issue); in rsxx_dma_ctrl_init()
854 INIT_WORK(&ctrl->dma_done_work, rsxx_schedule_done); in rsxx_dma_ctrl_init()
856 st = rsxx_hw_buffers_init(dev, ctrl); in rsxx_dma_ctrl_init()
918 card->ctrl[i].regmap = card->regmap + (i * 4096); in rsxx_dma_setup()
927 st = rsxx_dma_ctrl_init(card->dev, &card->ctrl[i]); in rsxx_dma_setup()
931 card->ctrl[i].card = card; in rsxx_dma_setup()
932 card->ctrl[i].id = i; in rsxx_dma_setup()
951 struct rsxx_dma_ctrl *ctrl = &card->ctrl[i]; in rsxx_dma_setup() local
953 if (ctrl->issue_wq) { in rsxx_dma_setup()
954 destroy_workqueue(ctrl->issue_wq); in rsxx_dma_setup()
955 ctrl->issue_wq = NULL; in rsxx_dma_setup()
958 if (ctrl->done_wq) { in rsxx_dma_setup()
959 destroy_workqueue(ctrl->done_wq); in rsxx_dma_setup()
960 ctrl->done_wq = NULL; in rsxx_dma_setup()
963 if (ctrl->trackers) in rsxx_dma_setup()
964 vfree(ctrl->trackers); in rsxx_dma_setup()
966 if (ctrl->status.buf) in rsxx_dma_setup()
968 ctrl->status.buf, in rsxx_dma_setup()
969 ctrl->status.dma_addr); in rsxx_dma_setup()
970 if (ctrl->cmd.buf) in rsxx_dma_setup()
972 ctrl->cmd.buf, ctrl->cmd.dma_addr); in rsxx_dma_setup()
978 int rsxx_dma_cancel(struct rsxx_dma_ctrl *ctrl) in rsxx_dma_cancel() argument
986 dma = get_tracker_dma(ctrl->trackers, i); in rsxx_dma_cancel()
988 atomic_dec(&ctrl->stats.hw_q_depth); in rsxx_dma_cancel()
989 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED); in rsxx_dma_cancel()
990 push_tracker(ctrl->trackers, i); in rsxx_dma_cancel()
1000 struct rsxx_dma_ctrl *ctrl; in rsxx_dma_destroy() local
1004 ctrl = &card->ctrl[i]; in rsxx_dma_destroy()
1006 if (ctrl->issue_wq) { in rsxx_dma_destroy()
1007 destroy_workqueue(ctrl->issue_wq); in rsxx_dma_destroy()
1008 ctrl->issue_wq = NULL; in rsxx_dma_destroy()
1011 if (ctrl->done_wq) { in rsxx_dma_destroy()
1012 destroy_workqueue(ctrl->done_wq); in rsxx_dma_destroy()
1013 ctrl->done_wq = NULL; in rsxx_dma_destroy()
1016 if (timer_pending(&ctrl->activity_timer)) in rsxx_dma_destroy()
1017 del_timer_sync(&ctrl->activity_timer); in rsxx_dma_destroy()
1020 spin_lock_bh(&ctrl->queue_lock); in rsxx_dma_destroy()
1021 rsxx_cleanup_dma_queue(ctrl, &ctrl->queue, COMPLETE_DMA); in rsxx_dma_destroy()
1022 spin_unlock_bh(&ctrl->queue_lock); in rsxx_dma_destroy()
1024 rsxx_dma_cancel(ctrl); in rsxx_dma_destroy()
1026 vfree(ctrl->trackers); in rsxx_dma_destroy()
1029 ctrl->status.buf, ctrl->status.dma_addr); in rsxx_dma_destroy()
1031 ctrl->cmd.buf, ctrl->cmd.dma_addr); in rsxx_dma_destroy()
1052 dma = get_tracker_dma(card->ctrl[i].trackers, j); in rsxx_eeh_save_issued_dmas()
1057 card->ctrl[i].stats.writes_issued--; in rsxx_eeh_save_issued_dmas()
1059 card->ctrl[i].stats.discards_issued--; in rsxx_eeh_save_issued_dmas()
1061 card->ctrl[i].stats.reads_issued--; in rsxx_eeh_save_issued_dmas()
1072 push_tracker(card->ctrl[i].trackers, j); in rsxx_eeh_save_issued_dmas()
1076 spin_lock_bh(&card->ctrl[i].queue_lock); in rsxx_eeh_save_issued_dmas()
1077 list_splice(&issued_dmas[i], &card->ctrl[i].queue); in rsxx_eeh_save_issued_dmas()
1079 atomic_sub(cnt, &card->ctrl[i].stats.hw_q_depth); in rsxx_eeh_save_issued_dmas()
1080 card->ctrl[i].stats.sw_q_depth += cnt; in rsxx_eeh_save_issued_dmas()
1081 card->ctrl[i].e_cnt = 0; in rsxx_eeh_save_issued_dmas()
1082 spin_unlock_bh(&card->ctrl[i].queue_lock); in rsxx_eeh_save_issued_dmas()