Lines Matching +full:aac +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Adaptec AAC series RAID controller driver
9 * Copyright (c) 2000-2010 Adaptec, Inc.
10 * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
11 * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
59 const unsigned long fibsize = dev->max_fib_size; in aac_alloc_comm()
66 if ((dev->comm_interface == AAC_COMM_MESSAGE_TYPE1) || in aac_alloc_comm()
67 (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2) || in aac_alloc_comm()
68 (dev->comm_interface == AAC_COMM_MESSAGE_TYPE3 && in aac_alloc_comm()
69 !dev->sa_firmware)) { in aac_alloc_comm()
71 (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB) in aac_alloc_comm()
74 } else if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE3 && in aac_alloc_comm()
75 dev->sa_firmware) { in aac_alloc_comm()
76 host_rrq_size = (dev->scsi_host_ptr->can_queue in aac_alloc_comm()
79 (AAC_MAX_HRRQ - 1) * sizeof(struct _rrq); in aac_alloc_comm()
87 base = dma_alloc_coherent(&dev->pdev->dev, size, &phys, GFP_KERNEL); in aac_alloc_comm()
93 dev->comm_addr = (void *)base; in aac_alloc_comm()
94 dev->comm_phys = phys; in aac_alloc_comm()
95 dev->comm_size = size; in aac_alloc_comm()
97 if ((dev->comm_interface == AAC_COMM_MESSAGE_TYPE1) || in aac_alloc_comm()
98 (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2) || in aac_alloc_comm()
99 (dev->comm_interface == AAC_COMM_MESSAGE_TYPE3)) { in aac_alloc_comm()
100 dev->host_rrq = (u32 *)(base + fibsize); in aac_alloc_comm()
101 dev->host_rrq_pa = phys + fibsize; in aac_alloc_comm()
102 memset(dev->host_rrq, 0, host_rrq_size); in aac_alloc_comm()
105 dev->init = (union aac_init *)(base + fibsize + host_rrq_size); in aac_alloc_comm()
106 dev->init_pa = phys + fibsize + host_rrq_size; in aac_alloc_comm()
108 init = dev->init; in aac_alloc_comm()
110 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE3) { in aac_alloc_comm()
114 init->r8.init_struct_revision = in aac_alloc_comm()
116 init->r8.init_flags = cpu_to_le32(INITFLAGS_NEW_COMM_SUPPORTED | in aac_alloc_comm()
119 init->r8.init_flags |= in aac_alloc_comm()
121 init->r8.rr_queue_count = cpu_to_le32(dev->max_msix); in aac_alloc_comm()
122 init->r8.max_io_size = in aac_alloc_comm()
123 cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9); in aac_alloc_comm()
124 init->r8.max_num_aif = init->r8.reserved1 = in aac_alloc_comm()
125 init->r8.reserved2 = 0; in aac_alloc_comm()
127 for (i = 0; i < dev->max_msix; i++) { in aac_alloc_comm()
128 addr = (u64)dev->host_rrq_pa + dev->vector_cap * i * in aac_alloc_comm()
130 init->r8.rrq[i].host_addr_high = cpu_to_le32( in aac_alloc_comm()
132 init->r8.rrq[i].host_addr_low = cpu_to_le32( in aac_alloc_comm()
134 init->r8.rrq[i].msix_id = i; in aac_alloc_comm()
135 init->r8.rrq[i].element_count = cpu_to_le16( in aac_alloc_comm()
136 (u16)dev->vector_cap); in aac_alloc_comm()
137 init->r8.rrq[i].comp_thresh = in aac_alloc_comm()
138 init->r8.rrq[i].unused = 0; in aac_alloc_comm()
143 init->r7.init_struct_revision = in aac_alloc_comm()
145 if (dev->max_fib_size != sizeof(struct hw_fib)) in aac_alloc_comm()
146 init->r7.init_struct_revision = in aac_alloc_comm()
148 init->r7.no_of_msix_vectors = cpu_to_le32(SA_MINIPORT_REVISION); in aac_alloc_comm()
149 init->r7.fsrev = cpu_to_le32(dev->fsrev); in aac_alloc_comm()
155 dev->aif_base_va = (struct hw_fib *)base; in aac_alloc_comm()
157 init->r7.adapter_fibs_virtual_address = 0; in aac_alloc_comm()
158 init->r7.adapter_fibs_physical_address = cpu_to_le32((u32)phys); in aac_alloc_comm()
159 init->r7.adapter_fibs_size = cpu_to_le32(fibsize); in aac_alloc_comm()
160 init->r7.adapter_fib_align = cpu_to_le32(sizeof(struct hw_fib)); in aac_alloc_comm()
170 dma_get_required_mask(&dev->pdev->dev) >> 12; in aac_alloc_comm()
172 init->r7.host_phys_mem_pages = in aac_alloc_comm()
175 init->r7.host_phys_mem_pages = in aac_alloc_comm()
178 init->r7.init_flags = in aac_alloc_comm()
181 init->r7.max_io_commands = in aac_alloc_comm()
182 cpu_to_le32(dev->scsi_host_ptr->can_queue + in aac_alloc_comm()
184 init->r7.max_io_size = in aac_alloc_comm()
185 cpu_to_le32(dev->scsi_host_ptr->max_sectors << 9); in aac_alloc_comm()
186 init->r7.max_fib_size = cpu_to_le32(dev->max_fib_size); in aac_alloc_comm()
187 init->r7.max_num_aif = cpu_to_le32(dev->max_num_aif); in aac_alloc_comm()
189 if (dev->comm_interface == AAC_COMM_MESSAGE) { in aac_alloc_comm()
190 init->r7.init_flags |= in aac_alloc_comm()
193 } else if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE1) { in aac_alloc_comm()
194 init->r7.init_struct_revision = in aac_alloc_comm()
196 init->r7.init_flags |= in aac_alloc_comm()
200 init->r7.host_rrq_addr_high = in aac_alloc_comm()
201 cpu_to_le32(upper_32_bits(dev->host_rrq_pa)); in aac_alloc_comm()
202 init->r7.host_rrq_addr_low = in aac_alloc_comm()
203 cpu_to_le32(lower_32_bits(dev->host_rrq_pa)); in aac_alloc_comm()
205 } else if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2) { in aac_alloc_comm()
206 init->r7.init_struct_revision = in aac_alloc_comm()
208 init->r7.init_flags |= in aac_alloc_comm()
212 init->r7.host_rrq_addr_high = in aac_alloc_comm()
213 cpu_to_le32(upper_32_bits(dev->host_rrq_pa)); in aac_alloc_comm()
214 init->r7.host_rrq_addr_low = in aac_alloc_comm()
215 cpu_to_le32(lower_32_bits(dev->host_rrq_pa)); in aac_alloc_comm()
216 init->r7.no_of_msix_vectors = in aac_alloc_comm()
217 cpu_to_le32(dev->max_msix); in aac_alloc_comm()
233 align = (commalign - ((uintptr_t)(base) & (commalign - 1))); in aac_alloc_comm()
240 if (dev->comm_interface != AAC_COMM_MESSAGE_TYPE3) in aac_alloc_comm()
241 init->r7.comm_header_address = cpu_to_le32((u32)phys); in aac_alloc_comm()
250 dev->printfbuf = (void *)base; in aac_alloc_comm()
251 if (dev->comm_interface != AAC_COMM_MESSAGE_TYPE3) { in aac_alloc_comm()
252 init->r7.printfbuf = cpu_to_le32(phys); in aac_alloc_comm()
253 init->r7.printfbufsiz = cpu_to_le32(printfbufsiz); in aac_alloc_comm()
261 atomic_set(&q->numpending, 0); in aac_queue_init()
262 q->dev = dev; in aac_queue_init()
263 init_waitqueue_head(&q->cmdready); in aac_queue_init()
264 INIT_LIST_HEAD(&q->cmdq); in aac_queue_init()
265 init_waitqueue_head(&q->qfull); in aac_queue_init()
266 spin_lock_init(&q->lockdata); in aac_queue_init()
267 q->lock = &q->lockdata; in aac_queue_init()
268 q->headers.producer = (__le32 *)mem; in aac_queue_init()
269 q->headers.consumer = (__le32 *)(mem+1); in aac_queue_init()
270 *(q->headers.producer) = cpu_to_le32(qsize); in aac_queue_init()
271 *(q->headers.consumer) = cpu_to_le32(qsize); in aac_queue_init()
272 q->entries = qsize; in aac_queue_init()
279 if (aac_priv(cmd)->owner == AAC_OWNER_FIRMWARE) in wait_for_io_iter()
283 static void aac_wait_for_io_completion(struct aac_dev *aac) in aac_wait_for_io_completion() argument
287 for (i = 60; i; --i) { in aac_wait_for_io_completion()
290 scsi_host_busy_iter(aac->scsi_host_ptr, in aac_wait_for_io_completion()
297 dev_info(&aac->pdev->dev, in aac_wait_for_io_completion()
302 dev_err(&aac->pdev->dev, in aac_wait_for_io_completion()
307 * aac_send_shutdown - shutdown an adapter
322 if (!dev->adapter_shutdown) { in aac_send_shutdown()
323 mutex_lock(&dev->ioctl_mutex); in aac_send_shutdown()
324 dev->adapter_shutdown = 1; in aac_send_shutdown()
325 mutex_unlock(&dev->ioctl_mutex); in aac_send_shutdown()
332 return -ENOMEM; in aac_send_shutdown()
336 cmd->command = cpu_to_le32(VM_CloseAll); in aac_send_shutdown()
337 cmd->cid = cpu_to_le32(0xfffffffe); in aac_send_shutdown()
343 -2 /* Timeout silently */, 1, in aac_send_shutdown()
349 if (status != -ERESTARTSYS) in aac_send_shutdown()
352 dev->msi_enabled) in aac_send_shutdown()
358 * aac_comm_init - Initialise FSA data structures
364 * 1 - if we were able to init the commuication interface.
365 * 0 - If there were errors initing. This is a fatal error.
375 struct aac_queue_block * comm = dev->queues; in aac_comm_init()
382 spin_lock_init(&dev->fib_lock); in aac_comm_init()
392 return -ENOMEM; in aac_comm_init()
397 comm->queue[HostNormCmdQueue].base = queues; in aac_comm_init()
398 aac_queue_init(dev, &comm->queue[HostNormCmdQueue], headers, HOST_NORM_CMD_ENTRIES); in aac_comm_init()
403 comm->queue[HostHighCmdQueue].base = queues; in aac_comm_init()
404 aac_queue_init(dev, &comm->queue[HostHighCmdQueue], headers, HOST_HIGH_CMD_ENTRIES); in aac_comm_init()
410 comm->queue[AdapNormCmdQueue].base = queues; in aac_comm_init()
411 aac_queue_init(dev, &comm->queue[AdapNormCmdQueue], headers, ADAP_NORM_CMD_ENTRIES); in aac_comm_init()
417 comm->queue[AdapHighCmdQueue].base = queues; in aac_comm_init()
418 aac_queue_init(dev, &comm->queue[AdapHighCmdQueue], headers, ADAP_HIGH_CMD_ENTRIES); in aac_comm_init()
424 comm->queue[HostNormRespQueue].base = queues; in aac_comm_init()
425 aac_queue_init(dev, &comm->queue[HostNormRespQueue], headers, HOST_NORM_RESP_ENTRIES); in aac_comm_init()
430 comm->queue[HostHighRespQueue].base = queues; in aac_comm_init()
431 aac_queue_init(dev, &comm->queue[HostHighRespQueue], headers, HOST_HIGH_RESP_ENTRIES); in aac_comm_init()
437 comm->queue[AdapNormRespQueue].base = queues; in aac_comm_init()
438 aac_queue_init(dev, &comm->queue[AdapNormRespQueue], headers, ADAP_NORM_RESP_ENTRIES); in aac_comm_init()
444 comm->queue[AdapHighRespQueue].base = queues; in aac_comm_init()
445 aac_queue_init(dev, &comm->queue[AdapHighRespQueue], headers, ADAP_HIGH_RESP_ENTRIES); in aac_comm_init()
447 comm->queue[AdapNormCmdQueue].lock = comm->queue[HostNormRespQueue].lock; in aac_comm_init()
448 comm->queue[AdapHighCmdQueue].lock = comm->queue[HostHighRespQueue].lock; in aac_comm_init()
449 comm->queue[AdapNormRespQueue].lock = comm->queue[HostNormCmdQueue].lock; in aac_comm_init()
450 comm->queue[AdapHighRespQueue].lock = comm->queue[HostHighCmdQueue].lock; in aac_comm_init()
461 if (dev->max_msix == 0 || in aac_define_int_mode()
462 dev->pdev->device == PMC_DEVICE_S6 || in aac_define_int_mode()
463 dev->sync_mode) { in aac_define_int_mode()
464 dev->max_msix = 1; in aac_define_int_mode()
465 dev->vector_cap = in aac_define_int_mode()
466 dev->scsi_host_ptr->can_queue + in aac_define_int_mode()
471 /* Don't bother allocating more MSI-X vectors than cpus */ in aac_define_int_mode()
472 msi_count = min(dev->max_msix, in aac_define_int_mode()
475 dev->max_msix = msi_count; in aac_define_int_mode()
481 pci_find_capability(dev->pdev, PCI_CAP_ID_MSIX)) { in aac_define_int_mode()
483 i = pci_alloc_irq_vectors(dev->pdev, in aac_define_int_mode()
487 dev->msi_enabled = 1; in aac_define_int_mode()
490 dev->msi_enabled = 0; in aac_define_int_mode()
491 dev_err(&dev->pdev->dev, in aac_define_int_mode()
496 if (!dev->msi_enabled) in aac_define_int_mode()
497 dev->max_msix = msi_count = 1; in aac_define_int_mode()
499 if (dev->max_msix > msi_count) in aac_define_int_mode()
500 dev->max_msix = msi_count; in aac_define_int_mode()
502 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE3 && dev->sa_firmware) in aac_define_int_mode()
503 dev->vector_cap = dev->scsi_host_ptr->can_queue + in aac_define_int_mode()
506 dev->vector_cap = (dev->scsi_host_ptr->can_queue + in aac_define_int_mode()
513 struct Scsi_Host * host = dev->scsi_host_ptr; in aac_init_adapter()
519 dev->management_fib_count = 0; in aac_init_adapter()
520 spin_lock_init(&dev->manage_lock); in aac_init_adapter()
521 spin_lock_init(&dev->sync_lock); in aac_init_adapter()
522 spin_lock_init(&dev->iq_lock); in aac_init_adapter()
523 dev->max_fib_size = sizeof(struct hw_fib); in aac_init_adapter()
524 dev->sg_tablesize = host->sg_tablesize = (dev->max_fib_size in aac_init_adapter()
525 - sizeof(struct aac_fibhdr) - sizeof(struct aac_write)) in aac_init_adapter()
527 dev->comm_interface = AAC_COMM_PRODUCER; in aac_init_adapter()
528 dev->raw_io_interface = dev->raw_io_64 = 0; in aac_init_adapter()
532 * Enable INTX mode, if not done already Enabled in aac_init_adapter()
536 dev_info(&dev->pdev->dev, "Changed firmware to INTX mode"); in aac_init_adapter()
543 dev->doorbell_mask = status[3]; in aac_init_adapter()
545 dev->raw_io_64 = 1; in aac_init_adapter()
546 dev->sync_mode = aac_sync_mode; in aac_init_adapter()
547 if (dev->a_ops.adapter_comm && in aac_init_adapter()
549 dev->comm_interface = AAC_COMM_MESSAGE; in aac_init_adapter()
550 dev->raw_io_interface = 1; in aac_init_adapter()
553 dev->comm_interface = AAC_COMM_MESSAGE_TYPE1; in aac_init_adapter()
556 dev->comm_interface = AAC_COMM_MESSAGE_TYPE2; in aac_init_adapter()
559 dev->comm_interface = AAC_COMM_MESSAGE_TYPE3; in aac_init_adapter()
561 /* not supported TYPE - switch to sync. mode */ in aac_init_adapter()
562 dev->comm_interface = AAC_COMM_MESSAGE_TYPE2; in aac_init_adapter()
563 dev->sync_mode = 1; in aac_init_adapter()
568 dev->sa_firmware = 1; in aac_init_adapter()
570 dev->sa_firmware = 0; in aac_init_adapter()
573 dev->soft_reset_support = 1; in aac_init_adapter()
575 dev->soft_reset_support = 0; in aac_init_adapter()
577 if ((dev->comm_interface == AAC_COMM_MESSAGE) && in aac_init_adapter()
578 (status[2] > dev->base_size)) { in aac_init_adapter()
580 dev->base_size = status[2]; in aac_init_adapter()
583 dev->comm_interface = AAC_COMM_PRODUCER; in aac_init_adapter()
592 dev->max_msix = 0; in aac_init_adapter()
593 dev->msi_enabled = 0; in aac_init_adapter()
594 dev->adapter_shutdown = 0; in aac_init_adapter()
606 host->max_sectors = (status[1] >> 16) << 1; in aac_init_adapter()
608 dev->max_fib_size = status[1] & 0xFFE0; in aac_init_adapter()
609 host->sg_tablesize = status[2] >> 16; in aac_init_adapter()
610 dev->sg_tablesize = status[2] & 0xFFFF; in aac_init_adapter()
612 if (host->can_queue > (status[3] >> 16) - in aac_init_adapter()
614 host->can_queue = (status[3] >> 16) - in aac_init_adapter()
616 } else if (host->can_queue > (status[3] & 0xFFFF) - in aac_init_adapter()
618 host->can_queue = (status[3] & 0xFFFF) - in aac_init_adapter()
621 dev->max_num_aif = status[4] & 0xFFFF; in aac_init_adapter()
624 if (numacb < host->can_queue) in aac_init_adapter()
625 host->can_queue = numacb; in aac_init_adapter()
636 dev->queues = kzalloc(sizeof(struct aac_queue_block), GFP_KERNEL); in aac_init_adapter()
637 if (dev->queues == NULL) { in aac_init_adapter()
643 kfree(dev->queues); in aac_init_adapter()
644 dev->queues = NULL; in aac_init_adapter()
651 kfree(dev->queues); in aac_init_adapter()
652 dev->queues = NULL; in aac_init_adapter()
656 INIT_LIST_HEAD(&dev->fib_list); in aac_init_adapter()
657 INIT_LIST_HEAD(&dev->sync_fib_list); in aac_init_adapter()