Lines Matching +full:- +full:a +full:-

5  *  Copyright (c) 2001-2013 ATTO Technology, Inc.
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
22 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
38 * You should have received a copy of the GNU General Public License
40 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
46 static bool esas2r_initmem_alloc(struct esas2r_adapter *a, in esas2r_initmem_alloc() argument
50 mem_desc->esas2r_param = mem_desc->size + align; in esas2r_initmem_alloc()
51 mem_desc->virt_addr = NULL; in esas2r_initmem_alloc()
52 mem_desc->phys_addr = 0; in esas2r_initmem_alloc()
53 mem_desc->esas2r_data = dma_alloc_coherent(&a->pcid->dev, in esas2r_initmem_alloc()
54 (size_t)mem_desc-> in esas2r_initmem_alloc()
56 (dma_addr_t *)&mem_desc-> in esas2r_initmem_alloc()
60 if (mem_desc->esas2r_data == NULL) { in esas2r_initmem_alloc()
65 int)mem_desc->esas2r_param); in esas2r_initmem_alloc()
69 mem_desc->virt_addr = PTR_ALIGN(mem_desc->esas2r_data, align); in esas2r_initmem_alloc()
70 mem_desc->phys_addr = ALIGN(mem_desc->phys_addr, align); in esas2r_initmem_alloc()
71 memset(mem_desc->virt_addr, 0, mem_desc->size); in esas2r_initmem_alloc()
75 static void esas2r_initmem_free(struct esas2r_adapter *a, in esas2r_initmem_free() argument
78 if (mem_desc->virt_addr == NULL) in esas2r_initmem_free()
88 if (mem_desc->phys_addr) { in esas2r_initmem_free()
89 int unalign = ((u8 *)mem_desc->virt_addr) - in esas2r_initmem_free()
90 ((u8 *)mem_desc->esas2r_data); in esas2r_initmem_free()
92 dma_free_coherent(&a->pcid->dev, in esas2r_initmem_free()
93 (size_t)mem_desc->esas2r_param, in esas2r_initmem_free()
94 mem_desc->esas2r_data, in esas2r_initmem_free()
95 (dma_addr_t)(mem_desc->phys_addr - unalign)); in esas2r_initmem_free()
97 kfree(mem_desc->esas2r_data); in esas2r_initmem_free()
100 mem_desc->virt_addr = NULL; in esas2r_initmem_free()
103 static bool alloc_vda_req(struct esas2r_adapter *a, in alloc_vda_req() argument
114 memdesc->size = sizeof(union atto_vda_req) + in alloc_vda_req()
117 if (!esas2r_initmem_alloc(a, memdesc, 256)) { in alloc_vda_req()
123 a->num_vrqs++; in alloc_vda_req()
124 list_add(&memdesc->next_desc, &a->vrq_mds_head); in alloc_vda_req()
126 rq->vrq_md = memdesc; in alloc_vda_req()
127 rq->vrq = (union atto_vda_req *)memdesc->virt_addr; in alloc_vda_req()
128 rq->vrq->scsi.handle = a->num_vrqs; in alloc_vda_req()
133 static void esas2r_unmap_regions(struct esas2r_adapter *a) in esas2r_unmap_regions() argument
135 if (a->regs) in esas2r_unmap_regions()
136 iounmap((void __iomem *)a->regs); in esas2r_unmap_regions()
138 a->regs = NULL; in esas2r_unmap_regions()
140 pci_release_region(a->pcid, 2); in esas2r_unmap_regions()
142 if (a->data_window) in esas2r_unmap_regions()
143 iounmap((void __iomem *)a->data_window); in esas2r_unmap_regions()
145 a->data_window = NULL; in esas2r_unmap_regions()
147 pci_release_region(a->pcid, 0); in esas2r_unmap_regions()
150 static int esas2r_map_regions(struct esas2r_adapter *a) in esas2r_map_regions() argument
154 a->regs = NULL; in esas2r_map_regions()
155 a->data_window = NULL; in esas2r_map_regions()
157 error = pci_request_region(a->pcid, 2, a->name); in esas2r_map_regions()
166 a->regs = (void __force *)ioremap(pci_resource_start(a->pcid, 2), in esas2r_map_regions()
167 pci_resource_len(a->pcid, 2)); in esas2r_map_regions()
168 if (a->regs == NULL) { in esas2r_map_regions()
171 pci_release_region(a->pcid, 2); in esas2r_map_regions()
172 return -EFAULT; in esas2r_map_regions()
175 error = pci_request_region(a->pcid, 0, a->name); in esas2r_map_regions()
180 esas2r_unmap_regions(a); in esas2r_map_regions()
184 a->data_window = (void __force *)ioremap(pci_resource_start(a->pcid, in esas2r_map_regions()
186 pci_resource_len(a->pcid, 0)); in esas2r_map_regions()
187 if (a->data_window == NULL) { in esas2r_map_regions()
190 esas2r_unmap_regions(a); in esas2r_map_regions()
191 return -EFAULT; in esas2r_map_regions()
197 static void esas2r_setup_interrupts(struct esas2r_adapter *a, int intr_mode) in esas2r_setup_interrupts() argument
205 a->intr_mode = INTR_MODE_LEGACY; in esas2r_setup_interrupts()
209 i = pci_enable_msi(a->pcid); in esas2r_setup_interrupts()
214 "(err=%d)", a->index, in esas2r_setup_interrupts()
218 a->intr_mode = INTR_MODE_MSI; in esas2r_setup_interrupts()
219 set_bit(AF2_MSI_ENABLED, &a->flags2); in esas2r_setup_interrupts()
232 static void esas2r_claim_interrupts(struct esas2r_adapter *a) in esas2r_claim_interrupts() argument
236 if (a->intr_mode == INTR_MODE_LEGACY) in esas2r_claim_interrupts()
241 a->pcid->irq, a, a->name, flags); in esas2r_claim_interrupts()
243 if (request_irq(a->pcid->irq, in esas2r_claim_interrupts()
244 (a->intr_mode == in esas2r_claim_interrupts()
248 a->name, in esas2r_claim_interrupts()
249 a)) { in esas2r_claim_interrupts()
251 a->pcid->irq); in esas2r_claim_interrupts()
255 set_bit(AF2_IRQ_CLAIMED, &a->flags2); in esas2r_claim_interrupts()
258 a->pcid->irq, flags); in esas2r_claim_interrupts()
264 struct esas2r_adapter *a; in esas2r_init_adapter() local
285 a = (struct esas2r_adapter *)host->hostdata; in esas2r_init_adapter()
286 memset(a, 0, sizeof(struct esas2r_adapter)); in esas2r_init_adapter()
287 a->pcid = pcid; in esas2r_init_adapter()
288 a->host = host; in esas2r_init_adapter()
291 dma_get_required_mask(&pcid->dev) > DMA_BIT_MASK(32) && in esas2r_init_adapter()
292 !dma_set_mask_and_coherent(&pcid->dev, DMA_BIT_MASK(64))) in esas2r_init_adapter()
295 if (!dma64 && dma_set_mask_and_coherent(&pcid->dev, DMA_BIT_MASK(32))) { in esas2r_init_adapter()
301 esas2r_log_dev(ESAS2R_LOG_INFO, &pcid->dev, in esas2r_init_adapter()
302 "%s-bit PCI addressing enabled\n", dma64 ? "64" : "32"); in esas2r_init_adapter()
304 esas2r_adapters[index] = a; in esas2r_init_adapter()
305 sprintf(a->name, ESAS2R_DRVR_NAME "_%02d", index); in esas2r_init_adapter()
306 esas2r_debug("new adapter %p, name %s", a, a->name); in esas2r_init_adapter()
307 spin_lock_init(&a->request_lock); in esas2r_init_adapter()
308 spin_lock_init(&a->fw_event_lock); in esas2r_init_adapter()
309 mutex_init(&a->fm_api_mutex); in esas2r_init_adapter()
310 mutex_init(&a->fs_api_mutex); in esas2r_init_adapter()
311 sema_init(&a->nvram_semaphore, 1); in esas2r_init_adapter()
313 esas2r_fw_event_off(a); in esas2r_init_adapter()
314 a->fw_event_q = in esas2r_init_adapter()
315 alloc_ordered_workqueue("esas2r/%d", WQ_MEM_RECLAIM, a->index); in esas2r_init_adapter()
317 init_waitqueue_head(&a->buffered_ioctl_waiter); in esas2r_init_adapter()
318 init_waitqueue_head(&a->nvram_waiter); in esas2r_init_adapter()
319 init_waitqueue_head(&a->fm_api_waiter); in esas2r_init_adapter()
320 init_waitqueue_head(&a->fs_api_waiter); in esas2r_init_adapter()
321 init_waitqueue_head(&a->vda_waiter); in esas2r_init_adapter()
323 INIT_LIST_HEAD(&a->general_req.req_list); in esas2r_init_adapter()
324 INIT_LIST_HEAD(&a->active_list); in esas2r_init_adapter()
325 INIT_LIST_HEAD(&a->defer_list); in esas2r_init_adapter()
326 INIT_LIST_HEAD(&a->free_sg_list_head); in esas2r_init_adapter()
327 INIT_LIST_HEAD(&a->avail_request); in esas2r_init_adapter()
328 INIT_LIST_HEAD(&a->vrq_mds_head); in esas2r_init_adapter()
329 INIT_LIST_HEAD(&a->fw_event_list); in esas2r_init_adapter()
331 first_request = (struct esas2r_request *)((u8 *)(a + 1)); in esas2r_init_adapter()
335 INIT_LIST_HEAD(&last_request->req_list); in esas2r_init_adapter()
336 list_add_tail(&last_request->comp_list, &a->avail_request); in esas2r_init_adapter()
337 if (!alloc_vda_req(a, last_request)) { in esas2r_init_adapter()
339 "failed to allocate a VDA request!"); in esas2r_init_adapter()
350 if (esas2r_map_regions(a) != 0) { in esas2r_init_adapter()
356 a->index = index; in esas2r_init_adapter()
359 atomic_inc(&a->dis_ints_cnt); in esas2r_init_adapter()
360 atomic_inc(&a->disable_cnt); in esas2r_init_adapter()
361 set_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter()
362 set_bit(AF_DISC_PENDING, &a->flags); in esas2r_init_adapter()
363 set_bit(AF_FIRST_INIT, &a->flags); in esas2r_init_adapter()
364 set_bit(AF_LEGACY_SGE_MODE, &a->flags); in esas2r_init_adapter()
366 a->init_msg = ESAS2R_INIT_MSG_START; in esas2r_init_adapter()
367 a->max_vdareq_size = 128; in esas2r_init_adapter()
368 a->build_sgl = esas2r_build_sg_list_sge; in esas2r_init_adapter()
370 esas2r_setup_interrupts(a, interrupt_mode); in esas2r_init_adapter()
372 a->uncached_size = esas2r_get_uncached_size(a); in esas2r_init_adapter()
373 a->uncached = dma_alloc_coherent(&pcid->dev, in esas2r_init_adapter()
374 (size_t)a->uncached_size, in esas2r_init_adapter()
377 if (a->uncached == NULL) { in esas2r_init_adapter()
380 a->uncached_size); in esas2r_init_adapter()
385 a->uncached_phys = bus_addr; in esas2r_init_adapter()
388 a->uncached_size, in esas2r_init_adapter()
389 a->uncached, in esas2r_init_adapter()
392 memset(a->uncached, 0, a->uncached_size); in esas2r_init_adapter()
393 next_uncached = a->uncached; in esas2r_init_adapter()
395 if (!esas2r_init_adapter_struct(a, in esas2r_init_adapter()
403 tasklet_init(&a->tasklet, in esas2r_init_adapter()
405 (unsigned long)a); in esas2r_init_adapter()
411 esas2r_disable_chip_interrupts(a); in esas2r_init_adapter()
412 esas2r_check_adapter(a); in esas2r_init_adapter()
414 if (!esas2r_init_adapter_hw(a, true)) { in esas2r_init_adapter()
420 esas2r_claim_interrupts(a); in esas2r_init_adapter()
422 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) in esas2r_init_adapter()
423 esas2r_enable_chip_interrupts(a); in esas2r_init_adapter()
425 set_bit(AF2_INIT_DONE, &a->flags2); in esas2r_init_adapter()
426 if (!test_bit(AF_DEGRADED_MODE, &a->flags)) in esas2r_init_adapter()
427 esas2r_kickoff_timer(a); in esas2r_init_adapter()
429 a, a->disable_cnt); in esas2r_init_adapter()
434 static void esas2r_adapter_power_down(struct esas2r_adapter *a, in esas2r_adapter_power_down() argument
439 if ((test_bit(AF2_INIT_DONE, &a->flags2)) in esas2r_adapter_power_down()
440 && (!test_bit(AF_DEGRADED_MODE, &a->flags))) { in esas2r_adapter_power_down()
442 del_timer_sync(&a->timer); in esas2r_adapter_power_down()
443 tasklet_kill(&a->tasklet); in esas2r_adapter_power_down()
445 esas2r_power_down(a); in esas2r_adapter_power_down()
457 if (a->sysfs_fw_created) { in esas2r_adapter_power_down()
458 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_fw); in esas2r_adapter_power_down()
459 a->sysfs_fw_created = 0; in esas2r_adapter_power_down()
462 if (a->sysfs_fs_created) { in esas2r_adapter_power_down()
463 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_fs); in esas2r_adapter_power_down()
464 a->sysfs_fs_created = 0; in esas2r_adapter_power_down()
467 if (a->sysfs_vda_created) { in esas2r_adapter_power_down()
468 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_vda); in esas2r_adapter_power_down()
469 a->sysfs_vda_created = 0; in esas2r_adapter_power_down()
472 if (a->sysfs_hw_created) { in esas2r_adapter_power_down()
473 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_hw); in esas2r_adapter_power_down()
474 a->sysfs_hw_created = 0; in esas2r_adapter_power_down()
477 if (a->sysfs_live_nvram_created) { in esas2r_adapter_power_down()
478 sysfs_remove_bin_file(&a->host->shost_dev.kobj, in esas2r_adapter_power_down()
480 a->sysfs_live_nvram_created = 0; in esas2r_adapter_power_down()
483 if (a->sysfs_default_nvram_created) { in esas2r_adapter_power_down()
484 sysfs_remove_bin_file(&a->host->shost_dev.kobj, in esas2r_adapter_power_down()
486 a->sysfs_default_nvram_created = 0; in esas2r_adapter_power_down()
490 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) { in esas2r_adapter_power_down()
492 &(a->pcid->dev), in esas2r_adapter_power_down()
493 "free_irq(%d) called", a->pcid->irq); in esas2r_adapter_power_down()
495 free_irq(a->pcid->irq, a); in esas2r_adapter_power_down()
497 clear_bit(AF2_IRQ_CLAIMED, &a->flags2); in esas2r_adapter_power_down()
500 if (test_bit(AF2_MSI_ENABLED, &a->flags2)) { in esas2r_adapter_power_down()
501 pci_disable_msi(a->pcid); in esas2r_adapter_power_down()
502 clear_bit(AF2_MSI_ENABLED, &a->flags2); in esas2r_adapter_power_down()
506 if (a->inbound_list_md.virt_addr) in esas2r_adapter_power_down()
507 esas2r_initmem_free(a, &a->inbound_list_md); in esas2r_adapter_power_down()
509 if (a->outbound_list_md.virt_addr) in esas2r_adapter_power_down()
510 esas2r_initmem_free(a, &a->outbound_list_md); in esas2r_adapter_power_down()
512 list_for_each_entry_safe(memdesc, next, &a->free_sg_list_head, in esas2r_adapter_power_down()
514 esas2r_initmem_free(a, memdesc); in esas2r_adapter_power_down()
518 list_for_each_entry_safe(memdesc, next, &a->vrq_mds_head, next_desc) { in esas2r_adapter_power_down()
519 esas2r_initmem_free(a, memdesc); in esas2r_adapter_power_down()
520 list_del(&memdesc->next_desc); in esas2r_adapter_power_down()
524 kfree(a->first_ae_req); in esas2r_adapter_power_down()
525 a->first_ae_req = NULL; in esas2r_adapter_power_down()
527 kfree(a->sg_list_mds); in esas2r_adapter_power_down()
528 a->sg_list_mds = NULL; in esas2r_adapter_power_down()
530 kfree(a->req_table); in esas2r_adapter_power_down()
531 a->req_table = NULL; in esas2r_adapter_power_down()
533 if (a->regs) { in esas2r_adapter_power_down()
534 esas2r_unmap_regions(a); in esas2r_adapter_power_down()
535 a->regs = NULL; in esas2r_adapter_power_down()
536 a->data_window = NULL; in esas2r_adapter_power_down()
544 struct esas2r_adapter *a = esas2r_adapters[i]; in esas2r_kill_adapter() local
546 if (a) { in esas2r_kill_adapter()
549 esas2r_debug("killing adapter %p [%d] ", a, i); in esas2r_kill_adapter()
550 esas2r_fw_event_off(a); in esas2r_kill_adapter()
551 esas2r_adapter_power_down(a, 0); in esas2r_kill_adapter()
553 (a->pcid == esas2r_buffered_ioctl_pcid)) { in esas2r_kill_adapter()
554 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
561 if (a->vda_buffer) { in esas2r_kill_adapter()
562 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
564 a->vda_buffer, in esas2r_kill_adapter()
565 (dma_addr_t)a->ppvda_buffer); in esas2r_kill_adapter()
566 a->vda_buffer = NULL; in esas2r_kill_adapter()
568 if (a->fs_api_buffer) { in esas2r_kill_adapter()
569 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
570 (size_t)a->fs_api_buffer_size, in esas2r_kill_adapter()
571 a->fs_api_buffer, in esas2r_kill_adapter()
572 (dma_addr_t)a->ppfs_api_buffer); in esas2r_kill_adapter()
573 a->fs_api_buffer = NULL; in esas2r_kill_adapter()
576 kfree(a->local_atto_ioctl); in esas2r_kill_adapter()
577 a->local_atto_ioctl = NULL; in esas2r_kill_adapter()
579 spin_lock_irqsave(&a->fw_event_lock, flags); in esas2r_kill_adapter()
580 wq = a->fw_event_q; in esas2r_kill_adapter()
581 a->fw_event_q = NULL; in esas2r_kill_adapter()
582 spin_unlock_irqrestore(&a->fw_event_lock, flags); in esas2r_kill_adapter()
586 if (a->uncached) { in esas2r_kill_adapter()
587 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
588 (size_t)a->uncached_size, in esas2r_kill_adapter()
589 a->uncached, in esas2r_kill_adapter()
590 (dma_addr_t)a->uncached_phys); in esas2r_kill_adapter()
591 a->uncached = NULL; in esas2r_kill_adapter()
596 &(a->pcid->dev), in esas2r_kill_adapter()
599 a->pcid->msix_enabled, in esas2r_kill_adapter()
600 a->pcid->msi_enabled, in esas2r_kill_adapter()
601 a->pcid->irq, in esas2r_kill_adapter()
602 a->pcid->pin); in esas2r_kill_adapter()
605 &(a->pcid->dev), in esas2r_kill_adapter()
607 a->pcid->enable_cnt.counter); in esas2r_kill_adapter()
609 pci_disable_device(a->pcid); in esas2r_kill_adapter()
611 &(a->pcid->dev), in esas2r_kill_adapter()
613 a->pcid->enable_cnt.counter); in esas2r_kill_adapter()
616 &(a->pcid->dev), in esas2r_kill_adapter()
618 a->pcid); in esas2r_kill_adapter()
620 pci_set_drvdata(a->pcid, NULL); in esas2r_kill_adapter()
623 if (test_bit(AF2_INIT_DONE, &a->flags2)) { in esas2r_kill_adapter()
624 clear_bit(AF2_INIT_DONE, &a->flags2); in esas2r_kill_adapter()
626 set_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_kill_adapter()
629 &(a->host->shost_gendev), in esas2r_kill_adapter()
632 scsi_remove_host(a->host); in esas2r_kill_adapter()
635 &(a->host->shost_gendev), in esas2r_kill_adapter()
638 scsi_host_put(a->host); in esas2r_kill_adapter()
646 struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; in esas2r_suspend() local
649 if (!a) in esas2r_suspend()
650 return -ENODEV; in esas2r_suspend()
652 esas2r_adapter_power_down(a, 1); in esas2r_suspend()
660 struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; in esas2r_resume() local
665 if (!a) { in esas2r_resume()
666 rez = -ENODEV; in esas2r_resume()
670 if (esas2r_map_regions(a) != 0) { in esas2r_resume()
671 esas2r_log(ESAS2R_LOG_CRIT, "could not re-map PCI regions!"); in esas2r_resume()
672 rez = -ENOMEM; in esas2r_resume()
677 esas2r_setup_interrupts(a, a->intr_mode); in esas2r_resume()
683 esas2r_disable_chip_interrupts(a); in esas2r_resume()
684 if (!esas2r_power_up(a, true)) { in esas2r_resume()
686 rez = -ENOMEM; in esas2r_resume()
690 esas2r_claim_interrupts(a); in esas2r_resume()
692 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) { in esas2r_resume()
697 esas2r_enable_chip_interrupts(a); in esas2r_resume()
698 esas2r_kickoff_timer(a); in esas2r_resume()
701 esas2r_log(ESAS2R_LOG_CRIT, "could not re-claim IRQ!"); in esas2r_resume()
702 rez = -ENOMEM; in esas2r_resume()
714 bool esas2r_set_degraded_mode(struct esas2r_adapter *a, char *error_str) in esas2r_set_degraded_mode() argument
716 set_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_set_degraded_mode()
722 u32 esas2r_get_uncached_size(struct esas2r_adapter *a) in esas2r_get_uncached_size() argument
739 static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a) in esas2r_init_pci_cfg_space() argument
741 if (pci_is_pcie(a->pcid)) { in esas2r_init_pci_cfg_space()
744 pcie_capability_read_word(a->pcid, PCI_EXP_DEVCTL, &devcontrol); in esas2r_init_pci_cfg_space()
753 pcie_capability_write_word(a->pcid, PCI_EXP_DEVCTL, in esas2r_init_pci_cfg_space()
763 bool esas2r_init_adapter_struct(struct esas2r_adapter *a, in esas2r_init_adapter_struct() argument
772 spin_lock_init(&a->sg_list_lock); in esas2r_init_adapter_struct()
773 spin_lock_init(&a->mem_lock); in esas2r_init_adapter_struct()
774 spin_lock_init(&a->queue_lock); in esas2r_init_adapter_struct()
776 a->targetdb_end = &a->targetdb[ESAS2R_MAX_TARGETS]; in esas2r_init_adapter_struct()
778 if (!alloc_vda_req(a, &a->general_req)) { in esas2r_init_adapter_struct()
780 "failed to allocate a VDA request for the general req!"); in esas2r_init_adapter_struct()
785 a->first_ae_req = in esas2r_init_adapter_struct()
789 if (a->first_ae_req == NULL) { in esas2r_init_adapter_struct()
796 a->sg_list_mds = kcalloc(num_sg_lists, sizeof(struct esas2r_mem_desc), in esas2r_init_adapter_struct()
799 if (a->sg_list_mds == NULL) { in esas2r_init_adapter_struct()
806 a->req_table = in esas2r_init_adapter_struct()
811 if (a->req_table == NULL) { in esas2r_init_adapter_struct()
818 esas2r_init_pci_cfg_space(a); in esas2r_init_adapter_struct()
821 * the thunder_stream boards all have a serial flash part that has a in esas2r_init_adapter_struct()
824 if ((a->pcid->subsystem_vendor == ATTO_VENDOR_ID) in esas2r_init_adapter_struct()
825 && (a->pcid->subsystem_device & ATTO_SSDID_TBT)) in esas2r_init_adapter_struct()
826 a->flags2 |= AF2_THUNDERBOLT; in esas2r_init_adapter_struct()
828 if (test_bit(AF2_THUNDERBOLT, &a->flags2)) in esas2r_init_adapter_struct()
829 a->flags2 |= AF2_SERIAL_FLASH; in esas2r_init_adapter_struct()
831 if (a->pcid->subsystem_device == ATTO_TLSH_1068) in esas2r_init_adapter_struct()
832 a->flags2 |= AF2_THUNDERLINK; in esas2r_init_adapter_struct()
839 for (i = 0, sgl = a->sg_list_mds; i < num_sg_lists; i++, sgl++) { in esas2r_init_adapter_struct()
840 sgl->size = sgl_page_size; in esas2r_init_adapter_struct()
842 list_add_tail(&sgl->next_desc, &a->free_sg_list_head); in esas2r_init_adapter_struct()
844 if (!esas2r_initmem_alloc(a, sgl, ESAS2R_SGL_ALIGN)) { in esas2r_init_adapter_struct()
853 a->list_size = num_requests + ESAS2R_LIST_EXTRA; in esas2r_init_adapter_struct()
856 a->inbound_list_md.size = a->list_size * in esas2r_init_adapter_struct()
860 if (!esas2r_initmem_alloc(a, &a->inbound_list_md, ESAS2R_LIST_ALIGN)) { in esas2r_init_adapter_struct()
866 a->outbound_list_md.size = a->list_size * in esas2r_init_adapter_struct()
869 if (!esas2r_initmem_alloc(a, &a->outbound_list_md, in esas2r_init_adapter_struct()
876 a->nvram = (struct esas2r_sas_nvram *)high; in esas2r_init_adapter_struct()
880 a->disc_buffer = high; in esas2r_init_adapter_struct()
885 a->outbound_copy = (u32 volatile *)high; in esas2r_init_adapter_struct()
888 if (!test_bit(AF_NVR_VALID, &a->flags)) in esas2r_init_adapter_struct()
889 esas2r_nvram_set_defaults(a); in esas2r_init_adapter_struct()
895 if (test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_init_adapter_struct()
896 esas2r_targ_db_initialize(a); in esas2r_init_adapter_struct()
900 (struct esas2r_inbound_list_source_entry *)a-> in esas2r_init_adapter_struct()
904 for (i = 0; i < a->list_size; i++) { in esas2r_init_adapter_struct()
905 element->address = 0; in esas2r_init_adapter_struct()
906 element->reserved = 0; in esas2r_init_adapter_struct()
907 element->length = cpu_to_le32(HWILSE_INTERFACE_F0 in esas2r_init_adapter_struct()
916 for (rq = a->first_ae_req, i = 0; i < num_ae_requests; rq++, in esas2r_init_adapter_struct()
918 INIT_LIST_HEAD(&rq->req_list); in esas2r_init_adapter_struct()
919 if (!alloc_vda_req(a, rq)) { in esas2r_init_adapter_struct()
921 "failed to allocate a VDA request!"); in esas2r_init_adapter_struct()
925 esas2r_rq_init_request(rq, a); in esas2r_init_adapter_struct()
928 rq->comp_cb = esas2r_ae_complete; in esas2r_init_adapter_struct()
936 bool esas2r_check_adapter(struct esas2r_adapter *a) in esas2r_check_adapter() argument
944 * if the chip reset detected flag is set, we can bypass a bunch of in esas2r_check_adapter()
947 if (test_bit(AF_CHPRST_DETECTED, &a->flags)) in esas2r_check_adapter()
952 * may have left them enabled or we may be recovering from a fault. in esas2r_check_adapter()
954 esas2r_write_register_dword(a, MU_INT_MASK_OUT, ESAS2R_INT_DIS_MASK); in esas2r_check_adapter()
955 esas2r_flush_register_dword(a, MU_INT_MASK_OUT); in esas2r_check_adapter()
959 * waiting for a response. in esas2r_check_adapter()
964 esas2r_force_interrupt(a); in esas2r_check_adapter()
965 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_check_adapter()
969 * register access after a reset. in esas2r_check_adapter()
971 if ((jiffies_to_msecs(jiffies) - starttime) > 2000) in esas2r_check_adapter()
972 return esas2r_set_degraded_mode(a, in esas2r_check_adapter()
981 esas2r_write_register_dword(a, MU_DOORBELL_OUT, in esas2r_check_adapter()
985 set_bit(AF_LEGACY_SGE_MODE, &a->flags); in esas2r_check_adapter()
987 a->max_vdareq_size = 128; in esas2r_check_adapter()
988 a->build_sgl = esas2r_build_sg_list_sge; in esas2r_check_adapter()
990 clear_bit(AF_LEGACY_SGE_MODE, &a->flags); in esas2r_check_adapter()
992 a->max_vdareq_size = 1024; in esas2r_check_adapter()
993 a->build_sgl = esas2r_build_sg_list_prd; in esas2r_check_adapter()
995 return esas2r_set_degraded_mode(a, in esas2r_check_adapter()
1003 if ((jiffies_to_msecs(jiffies) - starttime) > 180000) { in esas2r_check_adapter()
1007 return esas2r_set_degraded_mode(a, in esas2r_check_adapter()
1013 esas2r_write_register_dword(a, MU_DOORBELL_IN, DRBL_MSG_IFC_DOWN); in esas2r_check_adapter()
1017 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_check_adapter()
1019 esas2r_write_register_dword(a, MU_DOORBELL_OUT, in esas2r_check_adapter()
1026 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_check_adapter()
1036 dw = esas2r_read_register_dword(a, MU_IN_LIST_CONFIG); in esas2r_check_adapter()
1038 esas2r_write_register_dword(a, MU_IN_LIST_CONFIG, dw); in esas2r_check_adapter()
1039 dw = esas2r_read_register_dword(a, MU_OUT_LIST_CONFIG); in esas2r_check_adapter()
1041 esas2r_write_register_dword(a, MU_OUT_LIST_CONFIG, dw); in esas2r_check_adapter()
1044 ppaddr = a->inbound_list_md.phys_addr; in esas2r_check_adapter()
1045 esas2r_write_register_dword(a, MU_IN_LIST_ADDR_LO, in esas2r_check_adapter()
1047 esas2r_write_register_dword(a, MU_IN_LIST_ADDR_HI, in esas2r_check_adapter()
1049 ppaddr = a->outbound_list_md.phys_addr; in esas2r_check_adapter()
1050 esas2r_write_register_dword(a, MU_OUT_LIST_ADDR_LO, in esas2r_check_adapter()
1052 esas2r_write_register_dword(a, MU_OUT_LIST_ADDR_HI, in esas2r_check_adapter()
1054 ppaddr = a->uncached_phys + in esas2r_check_adapter()
1055 ((u8 *)a->outbound_copy - a->uncached); in esas2r_check_adapter()
1056 esas2r_write_register_dword(a, MU_OUT_LIST_COPY_PTR_LO, in esas2r_check_adapter()
1058 esas2r_write_register_dword(a, MU_OUT_LIST_COPY_PTR_HI, in esas2r_check_adapter()
1062 *a->outbound_copy = in esas2r_check_adapter()
1063 a->last_write = in esas2r_check_adapter()
1064 a->last_read = a->list_size - 1; in esas2r_check_adapter()
1065 set_bit(AF_COMM_LIST_TOGGLE, &a->flags); in esas2r_check_adapter()
1066 esas2r_write_register_dword(a, MU_IN_LIST_WRITE, MU_ILW_TOGGLE | in esas2r_check_adapter()
1067 a->last_write); in esas2r_check_adapter()
1068 esas2r_write_register_dword(a, MU_OUT_LIST_COPY, MU_OLC_TOGGLE | in esas2r_check_adapter()
1069 a->last_write); in esas2r_check_adapter()
1070 esas2r_write_register_dword(a, MU_IN_LIST_READ, MU_ILR_TOGGLE | in esas2r_check_adapter()
1071 a->last_write); in esas2r_check_adapter()
1072 esas2r_write_register_dword(a, MU_OUT_LIST_WRITE, in esas2r_check_adapter()
1073 MU_OLW_TOGGLE | a->last_write); in esas2r_check_adapter()
1076 dw = esas2r_read_register_dword(a, MU_IN_LIST_IFC_CONFIG); in esas2r_check_adapter()
1078 esas2r_write_register_dword(a, MU_IN_LIST_IFC_CONFIG, in esas2r_check_adapter()
1080 dw = esas2r_read_register_dword(a, MU_OUT_LIST_IFC_CONFIG); in esas2r_check_adapter()
1082 esas2r_write_register_dword(a, MU_OUT_LIST_IFC_CONFIG, in esas2r_check_adapter()
1087 dw = esas2r_read_register_dword(a, MU_IN_LIST_CONFIG); in esas2r_check_adapter()
1090 | (a->list_size << MU_ILC_NUMBER_SHIFT); in esas2r_check_adapter()
1091 esas2r_write_register_dword(a, MU_IN_LIST_CONFIG, dw); in esas2r_check_adapter()
1092 dw = esas2r_read_register_dword(a, MU_OUT_LIST_CONFIG); in esas2r_check_adapter()
1094 dw |= MU_OLC_ENTRY_4_DW | (a->list_size << MU_OLC_NUMBER_SHIFT); in esas2r_check_adapter()
1095 esas2r_write_register_dword(a, MU_OUT_LIST_CONFIG, dw); in esas2r_check_adapter()
1102 esas2r_write_register_dword(a, MU_DOORBELL_IN, DRBL_MSG_IFC_INIT); in esas2r_check_adapter()
1106 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_check_adapter()
1108 esas2r_write_register_dword(a, MU_DOORBELL_OUT, in esas2r_check_adapter()
1115 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_check_adapter()
1119 return esas2r_set_degraded_mode(a, in esas2r_check_adapter()
1128 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_IN_ENB); in esas2r_check_adapter()
1130 set_bit(AF2_VDA_POWER_DOWN, &a->flags2); in esas2r_check_adapter()
1132 clear_bit(AF2_VDA_POWER_DOWN, &a->flags2); in esas2r_check_adapter()
1138 esas2r_write_register_dword(a, MU_OUT_LIST_INT_MASK, MU_OLIS_MASK); in esas2r_check_adapter()
1139 esas2r_write_register_dword(a, MU_DOORBELL_OUT_ENB, DRBL_ENB_MASK); in esas2r_check_adapter()
1144 static bool esas2r_format_init_msg(struct esas2r_adapter *a, in esas2r_format_init_msg() argument
1147 u32 msg = a->init_msg; in esas2r_format_init_msg()
1150 a->init_msg = 0; in esas2r_format_init_msg()
1157 esas2r_build_cfg_req(a, in esas2r_format_init_msg()
1162 ci = (struct atto_vda_cfg_init *)&rq->vrq->cfg.data.init; in esas2r_format_init_msg()
1163 ci->sgl_page_size = cpu_to_le32(sgl_page_size); in esas2r_format_init_msg()
1165 ci->epoch_time = cpu_to_le32(ktime_get_real_seconds()); in esas2r_format_init_msg()
1166 rq->flags |= RF_FAILURE_OK; in esas2r_format_init_msg()
1167 a->init_msg = ESAS2R_INIT_MSG_INIT; in esas2r_format_init_msg()
1172 if (rq->req_stat == RS_SUCCESS) { in esas2r_format_init_msg()
1177 a->fw_version = le16_to_cpu( in esas2r_format_init_msg()
1178 rq->func_rsp.cfg_rsp.vda_version); in esas2r_format_init_msg()
1179 a->fw_build = rq->func_rsp.cfg_rsp.fw_build; in esas2r_format_init_msg()
1181 rq->func_rsp.cfg_rsp.fw_release); in esas2r_format_init_msg()
1184 a->fw_version += (major << 16) + (minor << 24); in esas2r_format_init_msg()
1194 if ((test_bit(AF2_THUNDERBOLT, &a->flags2)) in esas2r_format_init_msg()
1195 || (be32_to_cpu(a->fw_version) > 0x00524702)) { in esas2r_format_init_msg()
1197 esas2r_build_cfg_req(a, in esas2r_format_init_msg()
1203 rq->vrq->cfg.sg_list_offset = offsetof( in esas2r_format_init_msg()
1206 rq->vrq->cfg.data.prde.ctl_len = in esas2r_format_init_msg()
1208 rq->vrq->cfg.data.prde.address = cpu_to_le64( in esas2r_format_init_msg()
1209 rq->vrq_md->phys_addr + in esas2r_format_init_msg()
1211 rq->flags |= RF_FAILURE_OK; in esas2r_format_init_msg()
1212 a->init_msg = ESAS2R_INIT_MSG_GET_INIT; in esas2r_format_init_msg()
1219 ci = (struct atto_vda_cfg_init *)rq->data_buf; in esas2r_format_init_msg()
1220 if (rq->req_stat == RS_SUCCESS) { in esas2r_format_init_msg()
1221 a->num_targets_backend = in esas2r_format_init_msg()
1222 le32_to_cpu(ci->num_targets_backend); in esas2r_format_init_msg()
1223 a->ioctl_tunnel = in esas2r_format_init_msg()
1224 le32_to_cpu(ci->ioctl_tunnel); in esas2r_format_init_msg()
1232 rq->req_stat = RS_SUCCESS; in esas2r_format_init_msg()
1242 bool esas2r_init_msgs(struct esas2r_adapter *a) in esas2r_init_msgs() argument
1245 struct esas2r_request *rq = &a->general_req; in esas2r_init_msgs()
1247 esas2r_rq_init_request(rq, a); in esas2r_init_msgs()
1248 rq->comp_cb = esas2r_dummy_complete; in esas2r_init_msgs()
1250 if (a->init_msg == 0) in esas2r_init_msgs()
1251 a->init_msg = ESAS2R_INIT_MSG_REINIT; in esas2r_init_msgs()
1253 while (a->init_msg) { in esas2r_init_msgs()
1254 if (esas2r_format_init_msg(a, rq)) { in esas2r_init_msgs()
1257 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_init_msgs()
1258 esas2r_start_vda_request(a, rq); in esas2r_init_msgs()
1259 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_init_msgs()
1260 esas2r_wait_request(a, rq); in esas2r_init_msgs()
1261 if (rq->req_stat != RS_PENDING) in esas2r_init_msgs()
1266 if (rq->req_stat == RS_SUCCESS in esas2r_init_msgs()
1267 || ((rq->flags & RF_FAILURE_OK) in esas2r_init_msgs()
1268 && rq->req_stat != RS_TIMEOUT)) in esas2r_init_msgs()
1272 a->init_msg, rq->req_stat, rq->flags); in esas2r_init_msgs()
1273 a->init_msg = ESAS2R_INIT_MSG_START; in esas2r_init_msgs()
1278 esas2r_rq_destroy_request(rq, a); in esas2r_init_msgs()
1283 bool esas2r_init_adapter_hw(struct esas2r_adapter *a, bool init_poll) in esas2r_init_adapter_hw() argument
1289 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in esas2r_init_adapter_hw()
1292 if (!test_bit(AF_NVR_VALID, &a->flags)) { in esas2r_init_adapter_hw()
1293 if (!esas2r_nvram_read_direct(a)) in esas2r_init_adapter_hw()
1298 if (!esas2r_init_msgs(a)) { in esas2r_init_adapter_hw()
1299 esas2r_set_degraded_mode(a, "init messages failed"); in esas2r_init_adapter_hw()
1304 clear_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_init_adapter_hw()
1305 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter_hw()
1308 for (i = 0, rq = a->first_ae_req; i < num_ae_requests; i++, rq++) in esas2r_init_adapter_hw()
1309 esas2r_start_ae_request(a, rq); in esas2r_init_adapter_hw()
1311 if (!a->flash_rev[0]) in esas2r_init_adapter_hw()
1312 esas2r_read_flash_rev(a); in esas2r_init_adapter_hw()
1314 if (!a->image_type[0]) in esas2r_init_adapter_hw()
1315 esas2r_read_image_type(a); in esas2r_init_adapter_hw()
1317 if (a->fw_version == 0) in esas2r_init_adapter_hw()
1318 a->fw_rev[0] = 0; in esas2r_init_adapter_hw()
1320 sprintf(a->fw_rev, "%1d.%02d", in esas2r_init_adapter_hw()
1321 (int)LOBYTE(HIWORD(a->fw_version)), in esas2r_init_adapter_hw()
1322 (int)HIBYTE(HIWORD(a->fw_version))); in esas2r_init_adapter_hw()
1324 esas2r_hdebug("firmware revision: %s", a->fw_rev); in esas2r_init_adapter_hw()
1326 if (test_bit(AF_CHPRST_DETECTED, &a->flags) in esas2r_init_adapter_hw()
1327 && (test_bit(AF_FIRST_INIT, &a->flags))) { in esas2r_init_adapter_hw()
1328 esas2r_enable_chip_interrupts(a); in esas2r_init_adapter_hw()
1333 esas2r_disc_initialize(a); in esas2r_init_adapter_hw()
1338 * resuming from a low power state. deferred device waiting will use in esas2r_init_adapter_hw()
1340 * avoid being in a TASKLET too long. in esas2r_init_adapter_hw()
1343 u32 currtime = a->disc_start_time; in esas2r_init_adapter_hw()
1351 set_bit(AF_TASKLET_SCHEDULED, &a->flags); in esas2r_init_adapter_hw()
1352 set_bit(AF_DISC_POLLED, &a->flags); in esas2r_init_adapter_hw()
1359 if (test_bit(AF_FIRST_INIT, &a->flags)) in esas2r_init_adapter_hw()
1360 atomic_dec(&a->disable_cnt); in esas2r_init_adapter_hw()
1362 while (test_bit(AF_DISC_PENDING, &a->flags)) { in esas2r_init_adapter_hw()
1366 * Determine the need for a timer tick based on the in esas2r_init_adapter_hw()
1372 deltatime = jiffies_to_msecs(jiffies) - currtime; in esas2r_init_adapter_hw()
1377 * up. If a chip reset happens during initial polling, in esas2r_init_adapter_hw()
1381 if (!test_bit(AF_CHPRST_PENDING, &a->flags)) in esas2r_init_adapter_hw()
1382 esas2r_disc_check_for_work(a); in esas2r_init_adapter_hw()
1384 /* Simulate a timer tick. */ in esas2r_init_adapter_hw()
1387 /* Time for a timer tick */ in esas2r_init_adapter_hw()
1389 esas2r_timer_tick(a); in esas2r_init_adapter_hw()
1393 nexttick -= deltatime; in esas2r_init_adapter_hw()
1396 if (esas2r_is_tasklet_pending(a)) in esas2r_init_adapter_hw()
1397 esas2r_do_tasklet_tasks(a); in esas2r_init_adapter_hw()
1401 if (test_bit(AF_FIRST_INIT, &a->flags)) in esas2r_init_adapter_hw()
1402 atomic_inc(&a->disable_cnt); in esas2r_init_adapter_hw()
1404 clear_bit(AF_DISC_POLLED, &a->flags); in esas2r_init_adapter_hw()
1405 clear_bit(AF_TASKLET_SCHEDULED, &a->flags); in esas2r_init_adapter_hw()
1409 esas2r_targ_db_report_changes(a); in esas2r_init_adapter_hw()
1412 * For cases where (a) the initialization messages processing may in esas2r_init_adapter_hw()
1413 * handle an interrupt for a port event and a discovery is waiting, but in esas2r_init_adapter_hw()
1418 esas2r_disc_start_waiting(a); in esas2r_init_adapter_hw()
1421 a->int_mask = ESAS2R_INT_STS_MASK; in esas2r_init_adapter_hw()
1422 esas2r_enable_chip_interrupts(a); in esas2r_init_adapter_hw()
1423 esas2r_enable_heartbeat(a); in esas2r_init_adapter_hw()
1432 if (test_bit(AF_CHPRST_DETECTED, &a->flags) && in esas2r_init_adapter_hw()
1433 test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_init_adapter_hw()
1440 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter_hw()
1442 /* First initialization or a subsequent re-init is complete. */ in esas2r_init_adapter_hw()
1444 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter_hw()
1445 clear_bit(AF_DISC_PENDING, &a->flags); in esas2r_init_adapter_hw()
1450 if (test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_init_adapter_hw()
1451 clear_bit(AF_FIRST_INIT, &a->flags); in esas2r_init_adapter_hw()
1453 if (atomic_dec_return(&a->disable_cnt) == 0) in esas2r_init_adapter_hw()
1454 esas2r_do_deferred_processes(a); in esas2r_init_adapter_hw()
1461 void esas2r_reset_adapter(struct esas2r_adapter *a) in esas2r_reset_adapter() argument
1463 set_bit(AF_OS_RESET, &a->flags); in esas2r_reset_adapter()
1464 esas2r_local_reset_adapter(a); in esas2r_reset_adapter()
1465 esas2r_schedule_tasklet(a); in esas2r_reset_adapter()
1468 void esas2r_reset_chip(struct esas2r_adapter *a) in esas2r_reset_chip() argument
1470 if (!esas2r_is_adapter_present(a)) in esas2r_reset_chip()
1476 * to not overwrite a previous crash that was saved. in esas2r_reset_chip()
1478 if (test_bit(AF2_COREDUMP_AVAIL, &a->flags2) && in esas2r_reset_chip()
1479 !test_bit(AF2_COREDUMP_SAVED, &a->flags2)) { in esas2r_reset_chip()
1480 esas2r_read_mem_block(a, in esas2r_reset_chip()
1481 a->fw_coredump_buff, in esas2r_reset_chip()
1485 set_bit(AF2_COREDUMP_SAVED, &a->flags2); in esas2r_reset_chip()
1488 clear_bit(AF2_COREDUMP_AVAIL, &a->flags2); in esas2r_reset_chip()
1491 if (a->pcid->revision == MVR_FREY_B2) in esas2r_reset_chip()
1492 esas2r_write_register_dword(a, MU_CTL_STATUS_IN_B2, in esas2r_reset_chip()
1495 esas2r_write_register_dword(a, MU_CTL_STATUS_IN, in esas2r_reset_chip()
1499 /* Stall a little while to let the reset condition clear */ in esas2r_reset_chip()
1503 static void esas2r_power_down_notify_firmware(struct esas2r_adapter *a) in esas2r_power_down_notify_firmware() argument
1508 esas2r_write_register_dword(a, MU_DOORBELL_IN, DRBL_POWER_DOWN); in esas2r_power_down_notify_firmware()
1512 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_power_down_notify_firmware()
1514 esas2r_write_register_dword(a, MU_DOORBELL_OUT, in esas2r_power_down_notify_firmware()
1521 if ((jiffies_to_msecs(jiffies) - starttime) > 30000) { in esas2r_power_down_notify_firmware()
1532 void esas2r_power_down(struct esas2r_adapter *a) in esas2r_power_down() argument
1534 set_bit(AF_POWER_MGT, &a->flags); in esas2r_power_down()
1535 set_bit(AF_POWER_DOWN, &a->flags); in esas2r_power_down()
1537 if (!test_bit(AF_DEGRADED_MODE, &a->flags)) { in esas2r_power_down()
1547 esas2r_disable_chip_interrupts(a); in esas2r_power_down()
1548 esas2r_disable_heartbeat(a); in esas2r_power_down()
1551 esas2r_write_register_dword(a, MU_DOORBELL_IN, in esas2r_power_down()
1557 esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_power_down()
1559 esas2r_write_register_dword(a, MU_DOORBELL_OUT, in esas2r_power_down()
1566 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_power_down()
1577 if (test_bit(AF2_VDA_POWER_DOWN, &a->flags2)) in esas2r_power_down()
1578 esas2r_power_down_notify_firmware(a); in esas2r_power_down()
1582 set_bit(AF_OS_RESET, &a->flags); in esas2r_power_down()
1583 set_bit(AF_DISC_PENDING, &a->flags); in esas2r_power_down()
1584 set_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_power_down()
1586 esas2r_process_adapter_reset(a); in esas2r_power_down()
1589 a->prev_dev_cnt = esas2r_targ_db_get_tgt_cnt(a); in esas2r_power_down()
1590 esas2r_targ_db_remove_all(a, false); in esas2r_power_down()
1597 bool esas2r_power_up(struct esas2r_adapter *a, bool init_poll) in esas2r_power_up() argument
1601 clear_bit(AF_POWER_DOWN, &a->flags); in esas2r_power_up()
1602 esas2r_init_pci_cfg_space(a); in esas2r_power_up()
1603 set_bit(AF_FIRST_INIT, &a->flags); in esas2r_power_up()
1604 atomic_inc(&a->disable_cnt); in esas2r_power_up()
1607 ret = esas2r_check_adapter(a); in esas2r_power_up()
1608 if (!esas2r_init_adapter_hw(a, init_poll)) in esas2r_power_up()
1612 esas2r_send_reset_ae(a, true); in esas2r_power_up()
1615 clear_bit(AF_POWER_MGT, &a->flags); in esas2r_power_up()
1619 bool esas2r_is_adapter_present(struct esas2r_adapter *a) in esas2r_is_adapter_present() argument
1621 if (test_bit(AF_NOT_PRESENT, &a->flags)) in esas2r_is_adapter_present()
1624 if (esas2r_read_register_dword(a, MU_DOORBELL_OUT) == 0xFFFFFFFF) { in esas2r_is_adapter_present()
1625 set_bit(AF_NOT_PRESENT, &a->flags); in esas2r_is_adapter_present()
1632 const char *esas2r_get_model_name(struct esas2r_adapter *a) in esas2r_get_model_name() argument
1634 switch (a->pcid->subsystem_device) { in esas2r_get_model_name()
1666 const char *esas2r_get_model_name_short(struct esas2r_adapter *a) in esas2r_get_model_name_short() argument
1668 switch (a->pcid->subsystem_device) { in esas2r_get_model_name_short()