Lines Matching +full:max +full:- +full:outbound +full:- +full:regions
5 * Copyright (c) 2001-2013 ATTO Technology, Inc.
21 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
40 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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()
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()
114 memdesc->size = sizeof(union atto_vda_req) + 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()
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()
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()
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()
191 return -EFAULT; in esas2r_map_regions()
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()
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()
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()
285 a = (struct esas2r_adapter *)host->hostdata; 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()
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()
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()
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()
351 esas2r_log(ESAS2R_LOG_CRIT, "could not map PCI regions!"); 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()
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()
403 tasklet_init(&a->tasklet, in esas2r_init_adapter()
422 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) 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()
429 a, a->disable_cnt); in esas2r_init_adapter()
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()
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()
518 list_for_each_entry_safe(memdesc, next, &a->vrq_mds_head, next_desc) { 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()
535 a->regs = NULL; in esas2r_adapter_power_down()
536 a->data_window = NULL; in esas2r_adapter_power_down()
537 esas2r_debug("regions unmapped"); in esas2r_adapter_power_down()
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()
650 return -ENODEV; in esas2r_suspend()
660 struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; in esas2r_resume()
666 rez = -ENODEV; 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()
686 rez = -ENOMEM; in esas2r_resume()
692 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) { in esas2r_resume()
701 esas2r_log(ESAS2R_LOG_CRIT, "could not re-claim IRQ!"); in esas2r_resume()
702 rez = -ENOMEM; in esas2r_resume()
716 set_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_set_degraded_mode()
726 + ALIGN(sizeof(u32), 8) /* outbound list copy pointer */ in esas2r_get_uncached_size()
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()
749 "max read request size > 512B"); in esas2r_init_pci_cfg_space()
753 pcie_capability_write_word(a->pcid, PCI_EXP_DEVCTL, in esas2r_init_pci_cfg_space()
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()
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()
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()
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()
865 /* allocate the outbound list */ 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()
884 /* allocate the outbound list copy pointer */ 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()
895 if (test_bit(AF_FIRST_INIT, &a->flags)) { 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()
928 rq->comp_cb = esas2r_ae_complete; in esas2r_init_adapter_struct()
947 if (test_bit(AF_CHPRST_DETECTED, &a->flags)) in esas2r_check_adapter()
971 if ((jiffies_to_msecs(jiffies) - starttime) > 2000) 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()
1003 if ((jiffies_to_msecs(jiffies) - starttime) > 180000) { in esas2r_check_adapter()
1026 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_check_adapter()
1044 ppaddr = a->inbound_list_md.phys_addr; in esas2r_check_adapter()
1049 ppaddr = a->outbound_list_md.phys_addr; in esas2r_check_adapter()
1054 ppaddr = a->uncached_phys + in esas2r_check_adapter()
1055 ((u8 *)a->outbound_copy - a->uncached); 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()
1067 a->last_write); in esas2r_check_adapter()
1069 a->last_write); in esas2r_check_adapter()
1071 a->last_write); in esas2r_check_adapter()
1073 MU_OLW_TOGGLE | a->last_write); in esas2r_check_adapter()
1090 | (a->list_size << MU_ILC_NUMBER_SHIFT); in esas2r_check_adapter()
1094 dw |= MU_OLC_ENTRY_4_DW | (a->list_size << MU_OLC_NUMBER_SHIFT); in esas2r_check_adapter()
1115 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { 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()
1135 * enable assertion of outbound queue and doorbell interrupts in the in esas2r_check_adapter()
1147 u32 msg = a->init_msg; in esas2r_format_init_msg()
1150 a->init_msg = 0; 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()
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()
1245 struct esas2r_request *rq = &a->general_req; 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()
1257 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_init_msgs()
1259 spin_unlock_irqrestore(&a->queue_lock, flags); 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()
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()
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()
1311 if (!a->flash_rev[0]) in esas2r_init_adapter_hw()
1314 if (!a->image_type[0]) 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()
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()
1372 deltatime = jiffies_to_msecs(jiffies) - currtime; in esas2r_init_adapter_hw()
1381 if (!test_bit(AF_CHPRST_PENDING, &a->flags)) in esas2r_init_adapter_hw()
1393 nexttick -= deltatime; 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()
1421 a->int_mask = ESAS2R_INT_STS_MASK; 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()
1463 set_bit(AF_OS_RESET, &a->flags); in esas2r_reset_adapter()
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()
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()
1521 if ((jiffies_to_msecs(jiffies) - starttime) > 30000) { in esas2r_power_down_notify_firmware()
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()
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()
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()
1589 a->prev_dev_cnt = esas2r_targ_db_get_tgt_cnt(a); in esas2r_power_down()
1601 clear_bit(AF_POWER_DOWN, &a->flags); 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()
1615 clear_bit(AF_POWER_MGT, &a->flags); in esas2r_power_up()
1621 if (test_bit(AF_NOT_PRESENT, &a->flags)) in esas2r_is_adapter_present()
1625 set_bit(AF_NOT_PRESENT, &a->flags); in esas2r_is_adapter_present()
1634 switch (a->pcid->subsystem_device) { in esas2r_get_model_name()
1668 switch (a->pcid->subsystem_device) { in esas2r_get_model_name_short()