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 snprintf(a->fw_event_q_name, ESAS2R_KOBJ_NAME_LEN, "esas2r/%d", in esas2r_init_adapter()
315 a->index); in esas2r_init_adapter()
316 a->fw_event_q = create_singlethread_workqueue(a->fw_event_q_name); in esas2r_init_adapter()
318 init_waitqueue_head(&a->buffered_ioctl_waiter); in esas2r_init_adapter()
319 init_waitqueue_head(&a->nvram_waiter); in esas2r_init_adapter()
320 init_waitqueue_head(&a->fm_api_waiter); in esas2r_init_adapter()
321 init_waitqueue_head(&a->fs_api_waiter); in esas2r_init_adapter()
322 init_waitqueue_head(&a->vda_waiter); in esas2r_init_adapter()
324 INIT_LIST_HEAD(&a->general_req.req_list); in esas2r_init_adapter()
325 INIT_LIST_HEAD(&a->active_list); in esas2r_init_adapter()
326 INIT_LIST_HEAD(&a->defer_list); in esas2r_init_adapter()
327 INIT_LIST_HEAD(&a->free_sg_list_head); in esas2r_init_adapter()
328 INIT_LIST_HEAD(&a->avail_request); in esas2r_init_adapter()
329 INIT_LIST_HEAD(&a->vrq_mds_head); in esas2r_init_adapter()
330 INIT_LIST_HEAD(&a->fw_event_list); in esas2r_init_adapter()
336 INIT_LIST_HEAD(&last_request->req_list); in esas2r_init_adapter()
337 list_add_tail(&last_request->comp_list, &a->avail_request); in esas2r_init_adapter()
352 esas2r_log(ESAS2R_LOG_CRIT, "could not map PCI regions!"); in esas2r_init_adapter()
357 a->index = index; in esas2r_init_adapter()
360 atomic_inc(&a->dis_ints_cnt); in esas2r_init_adapter()
361 atomic_inc(&a->disable_cnt); in esas2r_init_adapter()
362 set_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter()
363 set_bit(AF_DISC_PENDING, &a->flags); in esas2r_init_adapter()
364 set_bit(AF_FIRST_INIT, &a->flags); in esas2r_init_adapter()
365 set_bit(AF_LEGACY_SGE_MODE, &a->flags); in esas2r_init_adapter()
367 a->init_msg = ESAS2R_INIT_MSG_START; in esas2r_init_adapter()
368 a->max_vdareq_size = 128; in esas2r_init_adapter()
369 a->build_sgl = esas2r_build_sg_list_sge; in esas2r_init_adapter()
373 a->uncached_size = esas2r_get_uncached_size(a); in esas2r_init_adapter()
374 a->uncached = dma_alloc_coherent(&pcid->dev, in esas2r_init_adapter()
375 (size_t)a->uncached_size, in esas2r_init_adapter()
378 if (a->uncached == NULL) { in esas2r_init_adapter()
381 a->uncached_size); in esas2r_init_adapter()
386 a->uncached_phys = bus_addr; in esas2r_init_adapter()
389 a->uncached_size, in esas2r_init_adapter()
390 a->uncached, in esas2r_init_adapter()
393 memset(a->uncached, 0, a->uncached_size); in esas2r_init_adapter()
394 next_uncached = a->uncached; in esas2r_init_adapter()
404 tasklet_init(&a->tasklet, in esas2r_init_adapter()
423 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) in esas2r_init_adapter()
426 set_bit(AF2_INIT_DONE, &a->flags2); in esas2r_init_adapter()
427 if (!test_bit(AF_DEGRADED_MODE, &a->flags)) in esas2r_init_adapter()
430 a, a->disable_cnt); in esas2r_init_adapter()
440 if ((test_bit(AF2_INIT_DONE, &a->flags2)) in esas2r_adapter_power_down()
441 && (!test_bit(AF_DEGRADED_MODE, &a->flags))) { in esas2r_adapter_power_down()
443 del_timer_sync(&a->timer); in esas2r_adapter_power_down()
444 tasklet_kill(&a->tasklet); in esas2r_adapter_power_down()
458 if (a->sysfs_fw_created) { in esas2r_adapter_power_down()
459 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_fw); in esas2r_adapter_power_down()
460 a->sysfs_fw_created = 0; in esas2r_adapter_power_down()
463 if (a->sysfs_fs_created) { in esas2r_adapter_power_down()
464 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_fs); in esas2r_adapter_power_down()
465 a->sysfs_fs_created = 0; in esas2r_adapter_power_down()
468 if (a->sysfs_vda_created) { in esas2r_adapter_power_down()
469 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_vda); in esas2r_adapter_power_down()
470 a->sysfs_vda_created = 0; in esas2r_adapter_power_down()
473 if (a->sysfs_hw_created) { in esas2r_adapter_power_down()
474 sysfs_remove_bin_file(&a->host->shost_dev.kobj, &bin_attr_hw); in esas2r_adapter_power_down()
475 a->sysfs_hw_created = 0; in esas2r_adapter_power_down()
478 if (a->sysfs_live_nvram_created) { in esas2r_adapter_power_down()
479 sysfs_remove_bin_file(&a->host->shost_dev.kobj, in esas2r_adapter_power_down()
481 a->sysfs_live_nvram_created = 0; in esas2r_adapter_power_down()
484 if (a->sysfs_default_nvram_created) { in esas2r_adapter_power_down()
485 sysfs_remove_bin_file(&a->host->shost_dev.kobj, in esas2r_adapter_power_down()
487 a->sysfs_default_nvram_created = 0; in esas2r_adapter_power_down()
491 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) { in esas2r_adapter_power_down()
493 &(a->pcid->dev), in esas2r_adapter_power_down()
494 "free_irq(%d) called", a->pcid->irq); in esas2r_adapter_power_down()
496 free_irq(a->pcid->irq, a); in esas2r_adapter_power_down()
498 clear_bit(AF2_IRQ_CLAIMED, &a->flags2); in esas2r_adapter_power_down()
501 if (test_bit(AF2_MSI_ENABLED, &a->flags2)) { in esas2r_adapter_power_down()
502 pci_disable_msi(a->pcid); in esas2r_adapter_power_down()
503 clear_bit(AF2_MSI_ENABLED, &a->flags2); in esas2r_adapter_power_down()
507 if (a->inbound_list_md.virt_addr) in esas2r_adapter_power_down()
508 esas2r_initmem_free(a, &a->inbound_list_md); in esas2r_adapter_power_down()
510 if (a->outbound_list_md.virt_addr) in esas2r_adapter_power_down()
511 esas2r_initmem_free(a, &a->outbound_list_md); in esas2r_adapter_power_down()
513 list_for_each_entry_safe(memdesc, next, &a->free_sg_list_head, in esas2r_adapter_power_down()
519 list_for_each_entry_safe(memdesc, next, &a->vrq_mds_head, next_desc) { in esas2r_adapter_power_down()
521 list_del(&memdesc->next_desc); in esas2r_adapter_power_down()
525 kfree(a->first_ae_req); in esas2r_adapter_power_down()
526 a->first_ae_req = NULL; in esas2r_adapter_power_down()
528 kfree(a->sg_list_mds); in esas2r_adapter_power_down()
529 a->sg_list_mds = NULL; in esas2r_adapter_power_down()
531 kfree(a->req_table); in esas2r_adapter_power_down()
532 a->req_table = NULL; in esas2r_adapter_power_down()
534 if (a->regs) { in esas2r_adapter_power_down()
536 a->regs = NULL; in esas2r_adapter_power_down()
537 a->data_window = NULL; in esas2r_adapter_power_down()
538 esas2r_debug("regions unmapped"); in esas2r_adapter_power_down()
554 (a->pcid == esas2r_buffered_ioctl_pcid)) { in esas2r_kill_adapter()
555 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
562 if (a->vda_buffer) { in esas2r_kill_adapter()
563 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
565 a->vda_buffer, in esas2r_kill_adapter()
566 (dma_addr_t)a->ppvda_buffer); in esas2r_kill_adapter()
567 a->vda_buffer = NULL; in esas2r_kill_adapter()
569 if (a->fs_api_buffer) { in esas2r_kill_adapter()
570 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
571 (size_t)a->fs_api_buffer_size, in esas2r_kill_adapter()
572 a->fs_api_buffer, in esas2r_kill_adapter()
573 (dma_addr_t)a->ppfs_api_buffer); in esas2r_kill_adapter()
574 a->fs_api_buffer = NULL; in esas2r_kill_adapter()
577 kfree(a->local_atto_ioctl); in esas2r_kill_adapter()
578 a->local_atto_ioctl = NULL; in esas2r_kill_adapter()
580 spin_lock_irqsave(&a->fw_event_lock, flags); in esas2r_kill_adapter()
581 wq = a->fw_event_q; in esas2r_kill_adapter()
582 a->fw_event_q = NULL; in esas2r_kill_adapter()
583 spin_unlock_irqrestore(&a->fw_event_lock, flags); in esas2r_kill_adapter()
587 if (a->uncached) { in esas2r_kill_adapter()
588 dma_free_coherent(&a->pcid->dev, in esas2r_kill_adapter()
589 (size_t)a->uncached_size, in esas2r_kill_adapter()
590 a->uncached, in esas2r_kill_adapter()
591 (dma_addr_t)a->uncached_phys); in esas2r_kill_adapter()
592 a->uncached = NULL; in esas2r_kill_adapter()
597 &(a->pcid->dev), in esas2r_kill_adapter()
600 a->pcid->msix_enabled, in esas2r_kill_adapter()
601 a->pcid->msi_enabled, in esas2r_kill_adapter()
602 a->pcid->irq, in esas2r_kill_adapter()
603 a->pcid->pin); in esas2r_kill_adapter()
606 &(a->pcid->dev), in esas2r_kill_adapter()
608 a->pcid->enable_cnt.counter); in esas2r_kill_adapter()
610 pci_disable_device(a->pcid); in esas2r_kill_adapter()
612 &(a->pcid->dev), in esas2r_kill_adapter()
614 a->pcid->enable_cnt.counter); in esas2r_kill_adapter()
617 &(a->pcid->dev), in esas2r_kill_adapter()
619 a->pcid); in esas2r_kill_adapter()
621 pci_set_drvdata(a->pcid, NULL); in esas2r_kill_adapter()
624 if (test_bit(AF2_INIT_DONE, &a->flags2)) { in esas2r_kill_adapter()
625 clear_bit(AF2_INIT_DONE, &a->flags2); in esas2r_kill_adapter()
627 set_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_kill_adapter()
630 &(a->host->shost_gendev), in esas2r_kill_adapter()
633 scsi_remove_host(a->host); in esas2r_kill_adapter()
636 &(a->host->shost_gendev), in esas2r_kill_adapter()
639 scsi_host_put(a->host); in esas2r_kill_adapter()
647 struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; in esas2r_suspend()
651 return -ENODEV; in esas2r_suspend()
661 struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; in esas2r_resume()
667 rez = -ENODEV; in esas2r_resume()
672 esas2r_log(ESAS2R_LOG_CRIT, "could not re-map PCI regions!"); in esas2r_resume()
673 rez = -ENOMEM; in esas2r_resume()
678 esas2r_setup_interrupts(a, a->intr_mode); in esas2r_resume()
687 rez = -ENOMEM; in esas2r_resume()
693 if (test_bit(AF2_IRQ_CLAIMED, &a->flags2)) { in esas2r_resume()
702 esas2r_log(ESAS2R_LOG_CRIT, "could not re-claim IRQ!"); in esas2r_resume()
703 rez = -ENOMEM; in esas2r_resume()
717 set_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_set_degraded_mode()
727 + ALIGN(sizeof(u32), 8) /* outbound list copy pointer */ in esas2r_get_uncached_size()
742 if (pci_is_pcie(a->pcid)) { in esas2r_init_pci_cfg_space()
745 pcie_capability_read_word(a->pcid, PCI_EXP_DEVCTL, &devcontrol); in esas2r_init_pci_cfg_space()
750 "max read request size > 512B"); in esas2r_init_pci_cfg_space()
754 pcie_capability_write_word(a->pcid, PCI_EXP_DEVCTL, in esas2r_init_pci_cfg_space()
773 spin_lock_init(&a->sg_list_lock); in esas2r_init_adapter_struct()
774 spin_lock_init(&a->mem_lock); in esas2r_init_adapter_struct()
775 spin_lock_init(&a->queue_lock); in esas2r_init_adapter_struct()
777 a->targetdb_end = &a->targetdb[ESAS2R_MAX_TARGETS]; in esas2r_init_adapter_struct()
779 if (!alloc_vda_req(a, &a->general_req)) { in esas2r_init_adapter_struct()
786 a->first_ae_req = in esas2r_init_adapter_struct()
790 if (a->first_ae_req == NULL) { in esas2r_init_adapter_struct()
797 a->sg_list_mds = kcalloc(num_sg_lists, sizeof(struct esas2r_mem_desc), in esas2r_init_adapter_struct()
800 if (a->sg_list_mds == NULL) { in esas2r_init_adapter_struct()
807 a->req_table = in esas2r_init_adapter_struct()
812 if (a->req_table == NULL) { in esas2r_init_adapter_struct()
825 if ((a->pcid->subsystem_vendor == ATTO_VENDOR_ID) in esas2r_init_adapter_struct()
826 && (a->pcid->subsystem_device & ATTO_SSDID_TBT)) in esas2r_init_adapter_struct()
827 a->flags2 |= AF2_THUNDERBOLT; in esas2r_init_adapter_struct()
829 if (test_bit(AF2_THUNDERBOLT, &a->flags2)) in esas2r_init_adapter_struct()
830 a->flags2 |= AF2_SERIAL_FLASH; in esas2r_init_adapter_struct()
832 if (a->pcid->subsystem_device == ATTO_TLSH_1068) in esas2r_init_adapter_struct()
833 a->flags2 |= AF2_THUNDERLINK; in esas2r_init_adapter_struct()
840 for (i = 0, sgl = a->sg_list_mds; i < num_sg_lists; i++, sgl++) { in esas2r_init_adapter_struct()
841 sgl->size = sgl_page_size; in esas2r_init_adapter_struct()
843 list_add_tail(&sgl->next_desc, &a->free_sg_list_head); in esas2r_init_adapter_struct()
854 a->list_size = num_requests + ESAS2R_LIST_EXTRA; in esas2r_init_adapter_struct()
857 a->inbound_list_md.size = a->list_size * in esas2r_init_adapter_struct()
861 if (!esas2r_initmem_alloc(a, &a->inbound_list_md, ESAS2R_LIST_ALIGN)) { in esas2r_init_adapter_struct()
866 /* allocate the outbound list */ in esas2r_init_adapter_struct()
867 a->outbound_list_md.size = a->list_size * in esas2r_init_adapter_struct()
870 if (!esas2r_initmem_alloc(a, &a->outbound_list_md, in esas2r_init_adapter_struct()
877 a->nvram = (struct esas2r_sas_nvram *)high; in esas2r_init_adapter_struct()
881 a->disc_buffer = high; in esas2r_init_adapter_struct()
885 /* allocate the outbound list copy pointer */ in esas2r_init_adapter_struct()
886 a->outbound_copy = (u32 volatile *)high; in esas2r_init_adapter_struct()
889 if (!test_bit(AF_NVR_VALID, &a->flags)) in esas2r_init_adapter_struct()
896 if (test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_init_adapter_struct()
901 (struct esas2r_inbound_list_source_entry *)a-> in esas2r_init_adapter_struct()
905 for (i = 0; i < a->list_size; i++) { in esas2r_init_adapter_struct()
906 element->address = 0; in esas2r_init_adapter_struct()
907 element->reserved = 0; in esas2r_init_adapter_struct()
908 element->length = cpu_to_le32(HWILSE_INTERFACE_F0 in esas2r_init_adapter_struct()
917 for (rq = a->first_ae_req, i = 0; i < num_ae_requests; rq++, in esas2r_init_adapter_struct()
919 INIT_LIST_HEAD(&rq->req_list); in esas2r_init_adapter_struct()
929 rq->comp_cb = esas2r_ae_complete; in esas2r_init_adapter_struct()
948 if (test_bit(AF_CHPRST_DETECTED, &a->flags)) in esas2r_check_adapter()
972 if ((jiffies_to_msecs(jiffies) - starttime) > 2000) in esas2r_check_adapter()
986 set_bit(AF_LEGACY_SGE_MODE, &a->flags); in esas2r_check_adapter()
988 a->max_vdareq_size = 128; in esas2r_check_adapter()
989 a->build_sgl = esas2r_build_sg_list_sge; in esas2r_check_adapter()
991 clear_bit(AF_LEGACY_SGE_MODE, &a->flags); in esas2r_check_adapter()
993 a->max_vdareq_size = 1024; in esas2r_check_adapter()
994 a->build_sgl = esas2r_build_sg_list_prd; in esas2r_check_adapter()
1004 if ((jiffies_to_msecs(jiffies) - starttime) > 180000) { in esas2r_check_adapter()
1027 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_check_adapter()
1045 ppaddr = a->inbound_list_md.phys_addr; in esas2r_check_adapter()
1050 ppaddr = a->outbound_list_md.phys_addr; in esas2r_check_adapter()
1055 ppaddr = a->uncached_phys + in esas2r_check_adapter()
1056 ((u8 *)a->outbound_copy - a->uncached); in esas2r_check_adapter()
1063 *a->outbound_copy = in esas2r_check_adapter()
1064 a->last_write = in esas2r_check_adapter()
1065 a->last_read = a->list_size - 1; in esas2r_check_adapter()
1066 set_bit(AF_COMM_LIST_TOGGLE, &a->flags); in esas2r_check_adapter()
1068 a->last_write); in esas2r_check_adapter()
1070 a->last_write); in esas2r_check_adapter()
1072 a->last_write); in esas2r_check_adapter()
1074 MU_OLW_TOGGLE | a->last_write); in esas2r_check_adapter()
1091 | (a->list_size << MU_ILC_NUMBER_SHIFT); in esas2r_check_adapter()
1095 dw |= MU_OLC_ENTRY_4_DW | (a->list_size << MU_OLC_NUMBER_SHIFT); in esas2r_check_adapter()
1116 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_check_adapter()
1131 set_bit(AF2_VDA_POWER_DOWN, &a->flags2); in esas2r_check_adapter()
1133 clear_bit(AF2_VDA_POWER_DOWN, &a->flags2); in esas2r_check_adapter()
1136 * enable assertion of outbound queue and doorbell interrupts in the in esas2r_check_adapter()
1148 u32 msg = a->init_msg; in esas2r_format_init_msg()
1151 a->init_msg = 0; in esas2r_format_init_msg()
1163 ci = (struct atto_vda_cfg_init *)&rq->vrq->cfg.data.init; in esas2r_format_init_msg()
1164 ci->sgl_page_size = cpu_to_le32(sgl_page_size); in esas2r_format_init_msg()
1166 ci->epoch_time = cpu_to_le32(ktime_get_real_seconds()); in esas2r_format_init_msg()
1167 rq->flags |= RF_FAILURE_OK; in esas2r_format_init_msg()
1168 a->init_msg = ESAS2R_INIT_MSG_INIT; in esas2r_format_init_msg()
1173 if (rq->req_stat == RS_SUCCESS) { in esas2r_format_init_msg()
1178 a->fw_version = le16_to_cpu( in esas2r_format_init_msg()
1179 rq->func_rsp.cfg_rsp.vda_version); in esas2r_format_init_msg()
1180 a->fw_build = rq->func_rsp.cfg_rsp.fw_build; in esas2r_format_init_msg()
1182 rq->func_rsp.cfg_rsp.fw_release); in esas2r_format_init_msg()
1185 a->fw_version += (major << 16) + (minor << 24); in esas2r_format_init_msg()
1195 if ((test_bit(AF2_THUNDERBOLT, &a->flags2)) in esas2r_format_init_msg()
1196 || (be32_to_cpu(a->fw_version) > 0x00524702)) { in esas2r_format_init_msg()
1204 rq->vrq->cfg.sg_list_offset = offsetof( in esas2r_format_init_msg()
1207 rq->vrq->cfg.data.prde.ctl_len = in esas2r_format_init_msg()
1209 rq->vrq->cfg.data.prde.address = cpu_to_le64( in esas2r_format_init_msg()
1210 rq->vrq_md->phys_addr + in esas2r_format_init_msg()
1212 rq->flags |= RF_FAILURE_OK; in esas2r_format_init_msg()
1213 a->init_msg = ESAS2R_INIT_MSG_GET_INIT; in esas2r_format_init_msg()
1220 ci = (struct atto_vda_cfg_init *)rq->data_buf; in esas2r_format_init_msg()
1221 if (rq->req_stat == RS_SUCCESS) { in esas2r_format_init_msg()
1222 a->num_targets_backend = in esas2r_format_init_msg()
1223 le32_to_cpu(ci->num_targets_backend); in esas2r_format_init_msg()
1224 a->ioctl_tunnel = in esas2r_format_init_msg()
1225 le32_to_cpu(ci->ioctl_tunnel); in esas2r_format_init_msg()
1233 rq->req_stat = RS_SUCCESS; in esas2r_format_init_msg()
1246 struct esas2r_request *rq = &a->general_req; in esas2r_init_msgs()
1249 rq->comp_cb = esas2r_dummy_complete; in esas2r_init_msgs()
1251 if (a->init_msg == 0) in esas2r_init_msgs()
1252 a->init_msg = ESAS2R_INIT_MSG_REINIT; in esas2r_init_msgs()
1254 while (a->init_msg) { in esas2r_init_msgs()
1258 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_init_msgs()
1260 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_init_msgs()
1262 if (rq->req_stat != RS_PENDING) in esas2r_init_msgs()
1267 if (rq->req_stat == RS_SUCCESS in esas2r_init_msgs()
1268 || ((rq->flags & RF_FAILURE_OK) in esas2r_init_msgs()
1269 && rq->req_stat != RS_TIMEOUT)) in esas2r_init_msgs()
1273 a->init_msg, rq->req_stat, rq->flags); in esas2r_init_msgs()
1274 a->init_msg = ESAS2R_INIT_MSG_START; in esas2r_init_msgs()
1290 if (test_bit(AF_DEGRADED_MODE, &a->flags)) in esas2r_init_adapter_hw()
1293 if (!test_bit(AF_NVR_VALID, &a->flags)) { in esas2r_init_adapter_hw()
1305 clear_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_init_adapter_hw()
1306 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter_hw()
1309 for (i = 0, rq = a->first_ae_req; i < num_ae_requests; i++, rq++) in esas2r_init_adapter_hw()
1312 if (!a->flash_rev[0]) in esas2r_init_adapter_hw()
1315 if (!a->image_type[0]) in esas2r_init_adapter_hw()
1318 if (a->fw_version == 0) in esas2r_init_adapter_hw()
1319 a->fw_rev[0] = 0; in esas2r_init_adapter_hw()
1321 sprintf(a->fw_rev, "%1d.%02d", in esas2r_init_adapter_hw()
1322 (int)LOBYTE(HIWORD(a->fw_version)), in esas2r_init_adapter_hw()
1323 (int)HIBYTE(HIWORD(a->fw_version))); in esas2r_init_adapter_hw()
1325 esas2r_hdebug("firmware revision: %s", a->fw_rev); in esas2r_init_adapter_hw()
1327 if (test_bit(AF_CHPRST_DETECTED, &a->flags) in esas2r_init_adapter_hw()
1328 && (test_bit(AF_FIRST_INIT, &a->flags))) { in esas2r_init_adapter_hw()
1344 u32 currtime = a->disc_start_time; in esas2r_init_adapter_hw()
1352 set_bit(AF_TASKLET_SCHEDULED, &a->flags); in esas2r_init_adapter_hw()
1353 set_bit(AF_DISC_POLLED, &a->flags); in esas2r_init_adapter_hw()
1360 if (test_bit(AF_FIRST_INIT, &a->flags)) in esas2r_init_adapter_hw()
1361 atomic_dec(&a->disable_cnt); in esas2r_init_adapter_hw()
1363 while (test_bit(AF_DISC_PENDING, &a->flags)) { in esas2r_init_adapter_hw()
1373 deltatime = jiffies_to_msecs(jiffies) - currtime; in esas2r_init_adapter_hw()
1382 if (!test_bit(AF_CHPRST_PENDING, &a->flags)) in esas2r_init_adapter_hw()
1394 nexttick -= deltatime; in esas2r_init_adapter_hw()
1402 if (test_bit(AF_FIRST_INIT, &a->flags)) in esas2r_init_adapter_hw()
1403 atomic_inc(&a->disable_cnt); in esas2r_init_adapter_hw()
1405 clear_bit(AF_DISC_POLLED, &a->flags); in esas2r_init_adapter_hw()
1406 clear_bit(AF_TASKLET_SCHEDULED, &a->flags); in esas2r_init_adapter_hw()
1422 a->int_mask = ESAS2R_INT_STS_MASK; in esas2r_init_adapter_hw()
1433 if (test_bit(AF_CHPRST_DETECTED, &a->flags) && in esas2r_init_adapter_hw()
1434 test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_init_adapter_hw()
1441 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter_hw()
1443 /* First initialization or a subsequent re-init is complete. */ in esas2r_init_adapter_hw()
1445 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_init_adapter_hw()
1446 clear_bit(AF_DISC_PENDING, &a->flags); in esas2r_init_adapter_hw()
1451 if (test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_init_adapter_hw()
1452 clear_bit(AF_FIRST_INIT, &a->flags); in esas2r_init_adapter_hw()
1454 if (atomic_dec_return(&a->disable_cnt) == 0) in esas2r_init_adapter_hw()
1464 set_bit(AF_OS_RESET, &a->flags); in esas2r_reset_adapter()
1479 if (test_bit(AF2_COREDUMP_AVAIL, &a->flags2) && in esas2r_reset_chip()
1480 !test_bit(AF2_COREDUMP_SAVED, &a->flags2)) { in esas2r_reset_chip()
1482 a->fw_coredump_buff, in esas2r_reset_chip()
1486 set_bit(AF2_COREDUMP_SAVED, &a->flags2); in esas2r_reset_chip()
1489 clear_bit(AF2_COREDUMP_AVAIL, &a->flags2); in esas2r_reset_chip()
1492 if (a->pcid->revision == MVR_FREY_B2) in esas2r_reset_chip()
1522 if ((jiffies_to_msecs(jiffies) - starttime) > 30000) { in esas2r_power_down_notify_firmware()
1535 set_bit(AF_POWER_MGT, &a->flags); in esas2r_power_down()
1536 set_bit(AF_POWER_DOWN, &a->flags); in esas2r_power_down()
1538 if (!test_bit(AF_DEGRADED_MODE, &a->flags)) { in esas2r_power_down()
1567 if ((jiffies_to_msecs(jiffies) - starttime) > 3000) { in esas2r_power_down()
1578 if (test_bit(AF2_VDA_POWER_DOWN, &a->flags2)) in esas2r_power_down()
1583 set_bit(AF_OS_RESET, &a->flags); in esas2r_power_down()
1584 set_bit(AF_DISC_PENDING, &a->flags); in esas2r_power_down()
1585 set_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_power_down()
1590 a->prev_dev_cnt = esas2r_targ_db_get_tgt_cnt(a); in esas2r_power_down()
1602 clear_bit(AF_POWER_DOWN, &a->flags); in esas2r_power_up()
1604 set_bit(AF_FIRST_INIT, &a->flags); in esas2r_power_up()
1605 atomic_inc(&a->disable_cnt); in esas2r_power_up()
1616 clear_bit(AF_POWER_MGT, &a->flags); in esas2r_power_up()
1622 if (test_bit(AF_NOT_PRESENT, &a->flags)) in esas2r_is_adapter_present()
1626 set_bit(AF_NOT_PRESENT, &a->flags); in esas2r_is_adapter_present()
1635 switch (a->pcid->subsystem_device) { in esas2r_get_model_name()
1669 switch (a->pcid->subsystem_device) { in esas2r_get_model_name_short()