• Home
  • Raw
  • Download

Lines Matching refs:card

57 static void rsxx_mask_interrupts(struct rsxx_cardinfo *card)  in rsxx_mask_interrupts()  argument
59 card->isr_mask = 0; in rsxx_mask_interrupts()
60 card->ier_mask = 0; in rsxx_mask_interrupts()
80 void rsxx_enable_ier(struct rsxx_cardinfo *card, unsigned int intr) in rsxx_enable_ier() argument
82 if (unlikely(card->halt) || in rsxx_enable_ier()
83 unlikely(card->eeh_state)) in rsxx_enable_ier()
86 __enable_intr(&card->ier_mask, intr); in rsxx_enable_ier()
87 iowrite32(card->ier_mask, card->regmap + IER); in rsxx_enable_ier()
90 void rsxx_disable_ier(struct rsxx_cardinfo *card, unsigned int intr) in rsxx_disable_ier() argument
92 if (unlikely(card->eeh_state)) in rsxx_disable_ier()
95 __disable_intr(&card->ier_mask, intr); in rsxx_disable_ier()
96 iowrite32(card->ier_mask, card->regmap + IER); in rsxx_disable_ier()
99 void rsxx_enable_ier_and_isr(struct rsxx_cardinfo *card, in rsxx_enable_ier_and_isr() argument
102 if (unlikely(card->halt) || in rsxx_enable_ier_and_isr()
103 unlikely(card->eeh_state)) in rsxx_enable_ier_and_isr()
106 __enable_intr(&card->isr_mask, intr); in rsxx_enable_ier_and_isr()
107 __enable_intr(&card->ier_mask, intr); in rsxx_enable_ier_and_isr()
108 iowrite32(card->ier_mask, card->regmap + IER); in rsxx_enable_ier_and_isr()
110 void rsxx_disable_ier_and_isr(struct rsxx_cardinfo *card, in rsxx_disable_ier_and_isr() argument
113 if (unlikely(card->eeh_state)) in rsxx_disable_ier_and_isr()
116 __disable_intr(&card->isr_mask, intr); in rsxx_disable_ier_and_isr()
117 __disable_intr(&card->ier_mask, intr); in rsxx_disable_ier_and_isr()
118 iowrite32(card->ier_mask, card->regmap + IER); in rsxx_disable_ier_and_isr()
123 struct rsxx_cardinfo *card = pdata; in rsxx_isr() local
129 spin_lock(&card->irq_lock); in rsxx_isr()
134 if (unlikely(card->eeh_state)) in rsxx_isr()
137 isr = ioread32(card->regmap + ISR); in rsxx_isr()
144 dev_info(CARD_TO_DEV(card), in rsxx_isr()
149 isr &= card->isr_mask; in rsxx_isr()
153 for (i = 0; i < card->n_targets; i++) { in rsxx_isr()
155 if (card->ier_mask & CR_INTR_DMA(i)) { in rsxx_isr()
156 rsxx_disable_ier(card, CR_INTR_DMA(i)); in rsxx_isr()
159 queue_work(card->ctrl[i].done_wq, in rsxx_isr()
160 &card->ctrl[i].dma_done_work); in rsxx_isr()
166 schedule_work(&card->creg_ctrl.done_work); in rsxx_isr()
171 schedule_work(&card->event_work); in rsxx_isr()
172 rsxx_disable_ier_and_isr(card, CR_INTR_EVENT); in rsxx_isr()
177 spin_unlock(&card->irq_lock); in rsxx_isr()
194 static void card_state_change(struct rsxx_cardinfo *card, in card_state_change() argument
199 dev_info(CARD_TO_DEV(card), in card_state_change()
201 rsxx_card_state_to_str(card->state), in card_state_change()
204 card->state = new_state; in card_state_change()
207 if (!card->config_valid) in card_state_change()
212 dev_crit(CARD_TO_DEV(card), in card_state_change()
219 st = rsxx_get_card_size8(card, &card->size8); in card_state_change()
221 dev_err(CARD_TO_DEV(card), in card_state_change()
224 if (card->config_valid) in card_state_change()
225 set_capacity(card->gendisk, card->size8 >> 9); in card_state_change()
229 dev_crit(CARD_TO_DEV(card), in card_state_change()
244 set_capacity(card->gendisk, 0); in card_state_change()
251 struct rsxx_cardinfo *card; in card_event_handler() local
256 card = container_of(work, struct rsxx_cardinfo, event_work); in card_event_handler()
258 if (unlikely(card->halt)) in card_event_handler()
266 spin_lock_irqsave(&card->irq_lock, flags); in card_event_handler()
267 rsxx_enable_ier_and_isr(card, CR_INTR_EVENT); in card_event_handler()
268 spin_unlock_irqrestore(&card->irq_lock, flags); in card_event_handler()
270 st = rsxx_get_card_state(card, &state); in card_event_handler()
272 dev_info(CARD_TO_DEV(card), in card_event_handler()
277 if (card->state != state) in card_event_handler()
278 card_state_change(card, state); in card_event_handler()
280 if (card->creg_ctrl.creg_stats.stat & CREG_STAT_LOG_PENDING) in card_event_handler()
281 rsxx_read_hw_log(card); in card_event_handler()
285 static int card_shutdown(struct rsxx_cardinfo *card) in card_shutdown() argument
295 st = rsxx_get_card_state(card, &state); in card_shutdown()
307 st = rsxx_issue_card_cmd(card, CARD_CMD_SHUTDOWN); in card_shutdown()
314 st = rsxx_get_card_state(card, &state); in card_shutdown()
328 struct rsxx_cardinfo *card = pci_get_drvdata(dev); in rsxx_eeh_frozen() local
334 card->eeh_state = 1; in rsxx_eeh_frozen()
335 rsxx_mask_interrupts(card); in rsxx_eeh_frozen()
346 st = rsxx_eeh_save_issued_dmas(card); in rsxx_eeh_frozen()
350 rsxx_eeh_save_issued_creg(card); in rsxx_eeh_frozen()
352 for (i = 0; i < card->n_targets; i++) { in rsxx_eeh_frozen()
353 if (card->ctrl[i].status.buf) in rsxx_eeh_frozen()
354 pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, in rsxx_eeh_frozen()
355 card->ctrl[i].status.buf, in rsxx_eeh_frozen()
356 card->ctrl[i].status.dma_addr); in rsxx_eeh_frozen()
357 if (card->ctrl[i].cmd.buf) in rsxx_eeh_frozen()
358 pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, in rsxx_eeh_frozen()
359 card->ctrl[i].cmd.buf, in rsxx_eeh_frozen()
360 card->ctrl[i].cmd.dma_addr); in rsxx_eeh_frozen()
368 struct rsxx_cardinfo *card = pci_get_drvdata(dev); in rsxx_eeh_failure() local
373 card->eeh_state = 1; in rsxx_eeh_failure()
375 for (i = 0; i < card->n_targets; i++) in rsxx_eeh_failure()
376 del_timer_sync(&card->ctrl[i].activity_timer); in rsxx_eeh_failure()
378 rsxx_eeh_cancel_dmas(card); in rsxx_eeh_failure()
381 static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card) in rsxx_eeh_fifo_flush_poll() argument
388 status = ioread32(card->regmap + PCI_RECONFIG); in rsxx_eeh_fifo_flush_poll()
396 dev_warn(CARD_TO_DEV(card), "HW: flash controller timeout\n"); in rsxx_eeh_fifo_flush_poll()
429 struct rsxx_cardinfo *card = pci_get_drvdata(dev); in rsxx_slot_reset() local
443 st = rsxx_eeh_fifo_flush_poll(card); in rsxx_slot_reset()
447 rsxx_dma_queue_reset(card); in rsxx_slot_reset()
449 for (i = 0; i < card->n_targets; i++) { in rsxx_slot_reset()
450 st = rsxx_hw_buffers_init(dev, &card->ctrl[i]); in rsxx_slot_reset()
455 if (card->config_valid) in rsxx_slot_reset()
456 rsxx_dma_configure(card); in rsxx_slot_reset()
459 st = ioread32(card->regmap + ISR); in rsxx_slot_reset()
461 card->eeh_state = 0; in rsxx_slot_reset()
463 st = rsxx_eeh_remap_dmas(card); in rsxx_slot_reset()
467 spin_lock_irqsave(&card->irq_lock, flags); in rsxx_slot_reset()
468 if (card->n_targets & RSXX_MAX_TARGETS) in rsxx_slot_reset()
469 rsxx_enable_ier_and_isr(card, CR_INTR_ALL_G); in rsxx_slot_reset()
471 rsxx_enable_ier_and_isr(card, CR_INTR_ALL_C); in rsxx_slot_reset()
472 spin_unlock_irqrestore(&card->irq_lock, flags); in rsxx_slot_reset()
474 rsxx_kick_creg_queue(card); in rsxx_slot_reset()
476 for (i = 0; i < card->n_targets; i++) { in rsxx_slot_reset()
477 spin_lock(&card->ctrl[i].queue_lock); in rsxx_slot_reset()
478 if (list_empty(&card->ctrl[i].queue)) { in rsxx_slot_reset()
479 spin_unlock(&card->ctrl[i].queue_lock); in rsxx_slot_reset()
482 spin_unlock(&card->ctrl[i].queue_lock); in rsxx_slot_reset()
484 queue_work(card->ctrl[i].issue_wq, in rsxx_slot_reset()
485 &card->ctrl[i].issue_dma_work); in rsxx_slot_reset()
494 for (i = 0; i < card->n_targets; i++) { in rsxx_slot_reset()
495 if (card->ctrl[i].status.buf) in rsxx_slot_reset()
496 pci_free_consistent(card->dev, in rsxx_slot_reset()
498 card->ctrl[i].status.buf, in rsxx_slot_reset()
499 card->ctrl[i].status.dma_addr); in rsxx_slot_reset()
500 if (card->ctrl[i].cmd.buf) in rsxx_slot_reset()
501 pci_free_consistent(card->dev, in rsxx_slot_reset()
503 card->ctrl[i].cmd.buf, in rsxx_slot_reset()
504 card->ctrl[i].cmd.dma_addr); in rsxx_slot_reset()
515 static int rsxx_compatibility_check(struct rsxx_cardinfo *card) in rsxx_compatibility_check() argument
519 pci_read_config_byte(card->dev, PCI_REVISION_ID, &pci_rev); in rsxx_compatibility_check()
529 struct rsxx_cardinfo *card; in rsxx_pci_probe() local
534 card = kzalloc(sizeof(*card), GFP_KERNEL); in rsxx_pci_probe()
535 if (!card) in rsxx_pci_probe()
538 card->dev = dev; in rsxx_pci_probe()
539 pci_set_drvdata(dev, card); in rsxx_pci_probe()
548 st = ida_get_new(&rsxx_disk_ida, &card->disk_id); in rsxx_pci_probe()
564 dev_err(CARD_TO_DEV(card), in rsxx_pci_probe()
571 dev_err(CARD_TO_DEV(card), in rsxx_pci_probe()
577 dev_err(CARD_TO_DEV(card), "BAR0 has length 0!\n"); in rsxx_pci_probe()
582 card->regmap = pci_iomap(dev, 0, 0); in rsxx_pci_probe()
583 if (!card->regmap) { in rsxx_pci_probe()
584 dev_err(CARD_TO_DEV(card), "Failed to map BAR0\n"); in rsxx_pci_probe()
589 spin_lock_init(&card->irq_lock); in rsxx_pci_probe()
590 card->halt = 0; in rsxx_pci_probe()
591 card->eeh_state = 0; in rsxx_pci_probe()
593 spin_lock_irq(&card->irq_lock); in rsxx_pci_probe()
594 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); in rsxx_pci_probe()
595 spin_unlock_irq(&card->irq_lock); in rsxx_pci_probe()
600 dev_warn(CARD_TO_DEV(card), in rsxx_pci_probe()
605 DRIVER_NAME, card); in rsxx_pci_probe()
607 dev_err(CARD_TO_DEV(card), in rsxx_pci_probe()
613 rsxx_creg_setup(card); in rsxx_pci_probe()
615 spin_lock_irq(&card->irq_lock); in rsxx_pci_probe()
616 rsxx_enable_ier_and_isr(card, CR_INTR_CREG); in rsxx_pci_probe()
617 spin_unlock_irq(&card->irq_lock); in rsxx_pci_probe()
619 st = rsxx_compatibility_check(card); in rsxx_pci_probe()
621 dev_warn(CARD_TO_DEV(card), in rsxx_pci_probe()
628 st = rsxx_load_config(card); in rsxx_pci_probe()
630 dev_err(CARD_TO_DEV(card), in rsxx_pci_probe()
634 st = rsxx_get_num_targets(card, &card->n_targets); in rsxx_pci_probe()
636 dev_info(CARD_TO_DEV(card), in rsxx_pci_probe()
639 card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL); in rsxx_pci_probe()
640 if (!card->ctrl) { in rsxx_pci_probe()
645 st = rsxx_dma_setup(card); in rsxx_pci_probe()
647 dev_info(CARD_TO_DEV(card), in rsxx_pci_probe()
653 INIT_WORK(&card->event_work, card_event_handler); in rsxx_pci_probe()
655 st = rsxx_setup_dev(card); in rsxx_pci_probe()
659 rsxx_get_card_state(card, &card->state); in rsxx_pci_probe()
661 dev_info(CARD_TO_DEV(card), in rsxx_pci_probe()
663 rsxx_card_state_to_str(card->state)); in rsxx_pci_probe()
670 spin_lock_irq(&card->irq_lock); in rsxx_pci_probe()
671 rsxx_enable_ier_and_isr(card, CR_INTR_EVENT); in rsxx_pci_probe()
672 spin_unlock_irq(&card->irq_lock); in rsxx_pci_probe()
674 if (card->state == CARD_STATE_SHUTDOWN) { in rsxx_pci_probe()
675 st = rsxx_issue_card_cmd(card, CARD_CMD_STARTUP); in rsxx_pci_probe()
677 dev_crit(CARD_TO_DEV(card), in rsxx_pci_probe()
679 } else if (card->state == CARD_STATE_GOOD || in rsxx_pci_probe()
680 card->state == CARD_STATE_RD_ONLY_FAULT) { in rsxx_pci_probe()
681 st = rsxx_get_card_size8(card, &card->size8); in rsxx_pci_probe()
683 card->size8 = 0; in rsxx_pci_probe()
686 rsxx_attach_dev(card); in rsxx_pci_probe()
691 rsxx_dma_destroy(card); in rsxx_pci_probe()
694 spin_lock_irq(&card->irq_lock); in rsxx_pci_probe()
695 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); in rsxx_pci_probe()
696 spin_unlock_irq(&card->irq_lock); in rsxx_pci_probe()
697 free_irq(dev->irq, card); in rsxx_pci_probe()
701 pci_iounmap(dev, card->regmap); in rsxx_pci_probe()
709 ida_remove(&rsxx_disk_ida, card->disk_id); in rsxx_pci_probe()
712 kfree(card); in rsxx_pci_probe()
719 struct rsxx_cardinfo *card = pci_get_drvdata(dev); in rsxx_pci_remove() local
724 if (!card) in rsxx_pci_remove()
727 dev_info(CARD_TO_DEV(card), in rsxx_pci_remove()
730 rsxx_detach_dev(card); in rsxx_pci_remove()
732 for (i = 0; i < card->n_targets; i++) { in rsxx_pci_remove()
733 spin_lock_irqsave(&card->irq_lock, flags); in rsxx_pci_remove()
734 rsxx_disable_ier_and_isr(card, CR_INTR_DMA(i)); in rsxx_pci_remove()
735 spin_unlock_irqrestore(&card->irq_lock, flags); in rsxx_pci_remove()
738 st = card_shutdown(card); in rsxx_pci_remove()
740 dev_crit(CARD_TO_DEV(card), "Shutdown failed!\n"); in rsxx_pci_remove()
743 spin_lock_irqsave(&card->irq_lock, flags); in rsxx_pci_remove()
744 rsxx_disable_ier_and_isr(card, CR_INTR_EVENT); in rsxx_pci_remove()
745 spin_unlock_irqrestore(&card->irq_lock, flags); in rsxx_pci_remove()
747 cancel_work_sync(&card->event_work); in rsxx_pci_remove()
749 rsxx_destroy_dev(card); in rsxx_pci_remove()
750 rsxx_dma_destroy(card); in rsxx_pci_remove()
752 spin_lock_irqsave(&card->irq_lock, flags); in rsxx_pci_remove()
753 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); in rsxx_pci_remove()
754 spin_unlock_irqrestore(&card->irq_lock, flags); in rsxx_pci_remove()
757 card->halt = 1; in rsxx_pci_remove()
759 free_irq(dev->irq, card); in rsxx_pci_remove()
764 rsxx_creg_destroy(card); in rsxx_pci_remove()
766 pci_iounmap(dev, card->regmap); in rsxx_pci_remove()
771 kfree(card); in rsxx_pci_remove()
782 struct rsxx_cardinfo *card = pci_get_drvdata(dev); in rsxx_pci_shutdown() local
786 if (!card) in rsxx_pci_shutdown()
789 dev_info(CARD_TO_DEV(card), "Shutting down PCI-Flash SSD.\n"); in rsxx_pci_shutdown()
791 rsxx_detach_dev(card); in rsxx_pci_shutdown()
793 for (i = 0; i < card->n_targets; i++) { in rsxx_pci_shutdown()
794 spin_lock_irqsave(&card->irq_lock, flags); in rsxx_pci_shutdown()
795 rsxx_disable_ier_and_isr(card, CR_INTR_DMA(i)); in rsxx_pci_shutdown()
796 spin_unlock_irqrestore(&card->irq_lock, flags); in rsxx_pci_shutdown()
799 card_shutdown(card); in rsxx_pci_shutdown()