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)
42 int isFastResponse, mode; in aac_src_intr_message() local
46 dev = ctx->dev; in aac_src_intr_message()
47 vector_no = ctx->vector_no; in aac_src_intr_message()
49 if (dev->msi_enabled) { in aac_src_intr_message()
50 mode = AAC_INT_MODE_MSI; in aac_src_intr_message()
54 mode |= AAC_INT_MODE_AIF; in aac_src_intr_message()
56 mode |= AAC_INT_MODE_SYNC; in aac_src_intr_message()
59 mode = AAC_INT_MODE_INTX; in aac_src_intr_message()
71 mode |= AAC_INT_MODE_AIF; in aac_src_intr_message()
73 mode |= AAC_INT_MODE_SYNC; in aac_src_intr_message()
77 if (mode & AAC_INT_MODE_SYNC) { in aac_src_intr_message()
83 if (!aac_sync_mode && !dev->msi_enabled) { in aac_src_intr_message()
88 if (dev->sync_fib) { in aac_src_intr_message()
89 if (dev->sync_fib->callback) in aac_src_intr_message()
90 dev->sync_fib->callback(dev->sync_fib->callback_data, in aac_src_intr_message()
91 dev->sync_fib); in aac_src_intr_message()
92 spin_lock_irqsave(&dev->sync_fib->event_lock, sflags); in aac_src_intr_message()
93 if (dev->sync_fib->flags & FIB_CONTEXT_FLAG_WAIT) { in aac_src_intr_message()
94 dev->management_fib_count--; in aac_src_intr_message()
95 complete(&dev->sync_fib->event_wait); in aac_src_intr_message()
97 spin_unlock_irqrestore(&dev->sync_fib->event_lock, in aac_src_intr_message()
99 spin_lock_irqsave(&dev->sync_lock, sflags); in aac_src_intr_message()
100 if (!list_empty(&dev->sync_fib_list)) { in aac_src_intr_message()
101 entry = dev->sync_fib_list.next; in aac_src_intr_message()
102 dev->sync_fib = list_entry(entry, in aac_src_intr_message()
108 dev->sync_fib = NULL; in aac_src_intr_message()
110 spin_unlock_irqrestore(&dev->sync_lock, sflags); in aac_src_intr_message()
113 (u32)dev->sync_fib->hw_fib_pa, in aac_src_intr_message()
118 if (!dev->msi_enabled) in aac_src_intr_message()
119 mode = 0; in aac_src_intr_message()
123 if (mode & AAC_INT_MODE_AIF) { in aac_src_intr_message()
125 if (dev->sa_firmware) { in aac_src_intr_message()
129 writel(events, &dev->IndexRegs->Mailbox[0]); in aac_src_intr_message()
132 if (dev->aif_thread && dev->fsa_dev) in aac_src_intr_message()
135 if (dev->msi_enabled) in aac_src_intr_message()
137 mode = 0; in aac_src_intr_message()
140 if (mode) { in aac_src_intr_message()
141 index = dev->host_rrq_idx[vector_no]; in aac_src_intr_message()
146 handle = le32_to_cpu((dev->host_rrq[index]) in aac_src_intr_message()
155 if (dev->msi_enabled && dev->max_msix > 1) in aac_src_intr_message()
156 atomic_dec(&dev->rrq_outstanding[vector_no]); in aac_src_intr_message()
158 dev->host_rrq[index++] = 0; in aac_src_intr_message()
159 if (index == (vector_no + 1) * dev->vector_cap) in aac_src_intr_message()
160 index = vector_no * dev->vector_cap; in aac_src_intr_message()
161 dev->host_rrq_idx[vector_no] = index; in aac_src_intr_message()
163 mode = 0; in aac_src_intr_message()
170 * aac_src_disable_interrupt - Disable interrupts
176 src_writel(dev, MUnit.OIMR, dev->OIMR = 0xffffffff); in aac_src_disable_interrupt()
180 * aac_src_enable_interrupt_message - Enable interrupts
190 * src_sync_cmd - send a command and wait
220 writel(command, &dev->IndexRegs->Mailbox[0]); in src_sync_cmd()
222 * Write the parameters into Mailboxes 1 - 6 in src_sync_cmd()
224 writel(p1, &dev->IndexRegs->Mailbox[1]); in src_sync_cmd()
225 writel(p2, &dev->IndexRegs->Mailbox[2]); in src_sync_cmd()
226 writel(p3, &dev->IndexRegs->Mailbox[3]); in src_sync_cmd()
227 writel(p4, &dev->IndexRegs->Mailbox[4]); in src_sync_cmd()
232 if (!dev->msi_enabled) in src_sync_cmd()
240 src_writel(dev, MUnit.OIMR, dev->OIMR = 0xffffffff); in src_sync_cmd()
253 if ((!dev->sync_mode || command != SEND_SYNCHRONOUS_FIB) && in src_sync_cmd()
254 !dev->in_soft_reset) { in src_sync_cmd()
274 if (dev->msi_enabled) in src_sync_cmd()
294 return -ETIMEDOUT; in src_sync_cmd()
300 *status = readl(&dev->IndexRegs->Mailbox[0]); in src_sync_cmd()
302 *r1 = readl(&dev->IndexRegs->Mailbox[1]); in src_sync_cmd()
304 *r2 = readl(&dev->IndexRegs->Mailbox[2]); in src_sync_cmd()
306 *r3 = readl(&dev->IndexRegs->Mailbox[3]); in src_sync_cmd()
308 *r4 = readl(&dev->IndexRegs->Mailbox[4]); in src_sync_cmd()
310 dev->max_msix = in src_sync_cmd()
311 readl(&dev->IndexRegs->Mailbox[5]) & 0xFFFF; in src_sync_cmd()
315 if (!dev->msi_enabled) in src_sync_cmd()
329 * aac_src_interrupt_adapter - interrupt adapter
343 * aac_src_notify_adapter - send an event to the adapter
386 * aac_src_start_adapter - activate adapter
389 * Start up processing on an i960 based AAC adapter
398 for (i = 0; i < dev->max_msix; i++) { in aac_src_start_adapter()
399 dev->host_rrq_idx[i] = i * dev->vector_cap; in aac_src_start_adapter()
400 atomic_set(&dev->rrq_outstanding[i], 0); in aac_src_start_adapter()
402 atomic_set(&dev->msix_counter, 0); in aac_src_start_adapter()
403 dev->fibs_pushed_no = 0; in aac_src_start_adapter()
405 init = dev->init; in aac_src_start_adapter()
406 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE3) { in aac_src_start_adapter()
407 init->r8.host_elapsed_seconds = in aac_src_start_adapter()
410 lower_32_bits(dev->init_pa), in aac_src_start_adapter()
411 upper_32_bits(dev->init_pa), in aac_src_start_adapter()
413 (AAC_MAX_HRRQ - 1) * sizeof(struct _rrq), in aac_src_start_adapter()
416 init->r7.host_elapsed_seconds = in aac_src_start_adapter()
420 (u32)(ulong)dev->init_pa, 0, 0, 0, 0, 0, in aac_src_start_adapter()
459 return -3; in aac_src_check_health()
466 return -1; in aac_src_check_health()
474 return atomic_inc_return(&dev->msix_counter)%dev->max_msix; in aac_get_vector()
485 struct aac_dev *dev = fib->dev; in aac_src_deliver_message()
486 struct aac_queue *q = &dev->queues->queue[AdapNormCmdQueue]; in aac_src_deliver_message()
497 atomic_inc(&q->numpending); in aac_src_deliver_message()
499 native_hba = (fib->flags & FIB_CONTEXT_FLAG_NATIVE_HBA) ? 1 : 0; in aac_src_deliver_message()
502 if (dev->msi_enabled && dev->max_msix > 1 && in aac_src_deliver_message()
503 (native_hba || fib->hw_fib_va->header.Command != AifRequest)) { in aac_src_deliver_message()
505 if ((dev->comm_interface == AAC_COMM_MESSAGE_TYPE3) in aac_src_deliver_message()
506 && dev->sa_firmware) in aac_src_deliver_message()
509 vector_no = fib->vector_no; in aac_src_deliver_message()
512 if (fib->flags & FIB_CONTEXT_FLAG_NATIVE_HBA_TMF) { in aac_src_deliver_message()
516 fib->hw_fib_va; in aac_src_deliver_message()
517 if (tm_req->iu_type == in aac_src_deliver_message()
520 fib->hw_fib_va)->reply_qid in aac_src_deliver_message()
523 fib->hw_fib_va)->request_id in aac_src_deliver_message()
527 fib->hw_fib_va)->reply_qid in aac_src_deliver_message()
530 fib->hw_fib_va)->request_id in aac_src_deliver_message()
535 fib->hw_fib_va)->reply_qid in aac_src_deliver_message()
538 fib->hw_fib_va)->request_id in aac_src_deliver_message()
542 fib->hw_fib_va->header.Handle += (vector_no << 16); in aac_src_deliver_message()
548 atomic_inc(&dev->rrq_outstanding[vector_no]); in aac_src_deliver_message()
551 address = fib->hw_fib_pa; in aac_src_deliver_message()
552 fibsize = (fib->hbacmd_size + 127) / 128 - 1; in aac_src_deliver_message()
559 spin_lock_irqsave(&fib->dev->iq_lock, flags); in aac_src_deliver_message()
563 spin_unlock_irqrestore(&fib->dev->iq_lock, flags); in aac_src_deliver_message()
566 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 || in aac_src_deliver_message()
567 dev->comm_interface == AAC_COMM_MESSAGE_TYPE3) { in aac_src_deliver_message()
569 fibsize = (le16_to_cpu(fib->hw_fib_va->header.Size) in aac_src_deliver_message()
570 + 127) / 128 - 1; in aac_src_deliver_message()
571 /* New FIB header, 32-bit */ in aac_src_deliver_message()
572 address = fib->hw_fib_pa; in aac_src_deliver_message()
573 fib->hw_fib_va->header.StructType = FIB_MAGIC2; in aac_src_deliver_message()
574 fib->hw_fib_va->header.SenderFibAddress = in aac_src_deliver_message()
576 fib->hw_fib_va->header.u.TimeStamp = 0; in aac_src_deliver_message()
581 le16_to_cpu(fib->hw_fib_va->header.Size) in aac_src_deliver_message()
582 + 127) / 128 - 1; in aac_src_deliver_message()
585 ((unsigned char *)fib->hw_fib_va - in aac_src_deliver_message()
587 pFibX->Handle = fib->hw_fib_va->header.Handle; in aac_src_deliver_message()
588 pFibX->HostAddress = in aac_src_deliver_message()
589 cpu_to_le64((u64)fib->hw_fib_pa); in aac_src_deliver_message()
590 pFibX->Size = cpu_to_le32( in aac_src_deliver_message()
591 le16_to_cpu(fib->hw_fib_va->header.Size)); in aac_src_deliver_message()
592 address = fib->hw_fib_pa - in aac_src_deliver_message()
602 spin_lock_irqsave(&fib->dev->iq_lock, flags); in aac_src_deliver_message()
606 spin_unlock_irqrestore(&fib->dev->iq_lock, flags); in aac_src_deliver_message()
621 iounmap(dev->regs.src.bar1); in aac_src_ioremap()
622 dev->regs.src.bar1 = NULL; in aac_src_ioremap()
623 iounmap(dev->regs.src.bar0); in aac_src_ioremap()
624 dev->base = dev->regs.src.bar0 = NULL; in aac_src_ioremap()
627 dev->regs.src.bar1 = ioremap(pci_resource_start(dev->pdev, 2), in aac_src_ioremap()
629 dev->base = NULL; in aac_src_ioremap()
630 if (dev->regs.src.bar1 == NULL) in aac_src_ioremap()
631 return -1; in aac_src_ioremap()
632 dev->base = dev->regs.src.bar0 = ioremap(dev->base_start, size); in aac_src_ioremap()
633 if (dev->base == NULL) { in aac_src_ioremap()
634 iounmap(dev->regs.src.bar1); in aac_src_ioremap()
635 dev->regs.src.bar1 = NULL; in aac_src_ioremap()
636 return -1; in aac_src_ioremap()
638 dev->IndexRegs = &((struct src_registers __iomem *) in aac_src_ioremap()
639 dev->base)->u.tupelo.IndexRegs; in aac_src_ioremap()
652 iounmap(dev->regs.src.bar0); in aac_srcv_ioremap()
653 dev->base = dev->regs.src.bar0 = NULL; in aac_srcv_ioremap()
657 dev->regs.src.bar1 = in aac_srcv_ioremap()
658 ioremap(pci_resource_start(dev->pdev, 2), AAC_MIN_SRCV_BAR1_SIZE); in aac_srcv_ioremap()
659 dev->base = NULL; in aac_srcv_ioremap()
660 if (dev->regs.src.bar1 == NULL) in aac_srcv_ioremap()
661 return -1; in aac_srcv_ioremap()
662 dev->base = dev->regs.src.bar0 = ioremap(dev->base_start, size); in aac_srcv_ioremap()
663 if (dev->base == NULL) { in aac_srcv_ioremap()
664 iounmap(dev->regs.src.bar1); in aac_srcv_ioremap()
665 dev->regs.src.bar1 = NULL; in aac_srcv_ioremap()
666 return -1; in aac_srcv_ioremap()
668 dev->IndexRegs = &((struct src_registers __iomem *) in aac_srcv_ioremap()
669 dev->base)->u.denali.IndexRegs; in aac_srcv_ioremap()
675 if (dev->msi_enabled) { in aac_set_intx_mode()
677 dev->msi_enabled = 0; in aac_set_intx_mode()
708 supported_options3 = dev->supplement_adapter_info.supported_options3; in aac_dump_fw_fib_iop_reset()
749 if (!dev->soft_reset_support) in aac_src_drop_io()
783 val = readl(((char *)(dev->base) + IBW_SWR_OFFSET)); in aac_send_hardware_soft_reset()
785 writel(val, ((char *)(dev->base) + IBW_SWR_OFFSET)); in aac_send_hardware_soft_reset()
798 dev_err(&dev->pdev->dev, "adapter kernel panic'd %x.\n", bled); in aac_src_restart_adapter()
803 if (bled >= 2 && dev->sa_firmware && reset_type & HW_IOP_RESET) in aac_src_restart_adapter()
806 dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; in aac_src_restart_adapter()
808 dev_err(&dev->pdev->dev, "Controller reset type is %d\n", reset_type); in aac_src_restart_adapter()
811 dev_info(&dev->pdev->dev, "Issuing IOP reset\n"); in aac_src_restart_adapter()
819 dev_err(&dev->pdev->dev, "IOP reset failed\n"); in aac_src_restart_adapter()
821 dev_info(&dev->pdev->dev, "IOP reset succeeded\n"); in aac_src_restart_adapter()
826 if (!dev->sa_firmware) { in aac_src_restart_adapter()
827 dev_err(&dev->pdev->dev, "ARC Reset attempt failed\n"); in aac_src_restart_adapter()
828 ret = -ENODEV; in aac_src_restart_adapter()
833 dev_info(&dev->pdev->dev, "Issuing SOFT reset\n"); in aac_src_restart_adapter()
835 dev->msi_enabled = 0; in aac_src_restart_adapter()
839 dev_err(&dev->pdev->dev, "SOFT reset failed\n"); in aac_src_restart_adapter()
840 ret = -ENODEV; in aac_src_restart_adapter()
843 dev_info(&dev->pdev->dev, "SOFT reset succeeded\n"); in aac_src_restart_adapter()
855 ret = -ENODEV; in aac_src_restart_adapter()
860 * aac_src_select_comm - Select communications method
868 dev->a_ops.adapter_intr = aac_src_intr_message; in aac_src_select_comm()
869 dev->a_ops.adapter_deliver = aac_src_deliver_message; in aac_src_select_comm()
878 * aac_src_init - initialize an Cardinal Frey Bar card
888 int instance = dev->id; in aac_src_init()
889 const char *name = dev->name; in aac_src_init()
891 dev->a_ops.adapter_ioremap = aac_src_ioremap; in aac_src_init()
892 dev->a_ops.adapter_comm = aac_src_select_comm; in aac_src_init()
894 dev->base_size = AAC_MIN_SRC_BAR0_SIZE; in aac_src_init()
895 if (aac_adapter_ioremap(dev, dev->base_size)) { in aac_src_init()
901 dev->a_ops.adapter_sync_cmd = src_sync_cmd; in aac_src_init()
902 dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; in aac_src_init()
904 if (dev->init_reset) { in aac_src_init()
905 dev->init_reset = false; in aac_src_init()
925 printk(KERN_ERR "%s%d: adapter self-test failed.\n", in aac_src_init()
926 dev->name, instance); in aac_src_init()
934 dev->name, instance); in aac_src_init()
947 dev->name, instance, status); in aac_src_init()
954 ? (startup_timeout - 60) in aac_src_init()
968 dev->a_ops.adapter_interrupt = aac_src_interrupt_adapter; in aac_src_init()
969 dev->a_ops.adapter_disable_int = aac_src_disable_interrupt; in aac_src_init()
970 dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; in aac_src_init()
971 dev->a_ops.adapter_notify = aac_src_notify_adapter; in aac_src_init()
972 dev->a_ops.adapter_sync_cmd = src_sync_cmd; in aac_src_init()
973 dev->a_ops.adapter_check_health = aac_src_check_health; in aac_src_init()
974 dev->a_ops.adapter_restart = aac_src_restart_adapter; in aac_src_init()
975 dev->a_ops.adapter_start = aac_src_start_adapter; in aac_src_init()
988 if (dev->comm_interface != AAC_COMM_MESSAGE_TYPE1) in aac_src_init()
991 dev->msi = !pci_enable_msi(dev->pdev); in aac_src_init()
993 dev->aac_msix[0].vector_no = 0; in aac_src_init()
994 dev->aac_msix[0].dev = dev; in aac_src_init()
996 if (request_irq(dev->pdev->irq, dev->a_ops.adapter_intr, in aac_src_init()
997 IRQF_SHARED, "aacraid", &(dev->aac_msix[0])) < 0) { in aac_src_init()
999 if (dev->msi) in aac_src_init()
1000 pci_disable_msi(dev->pdev); in aac_src_init()
1006 dev->dbg_base = pci_resource_start(dev->pdev, 2); in aac_src_init()
1007 dev->dbg_base_mapped = dev->regs.src.bar1; in aac_src_init()
1008 dev->dbg_size = AAC_MIN_SRC_BAR1_SIZE; in aac_src_init()
1009 dev->a_ops.adapter_enable_int = aac_src_enable_interrupt_message; in aac_src_init()
1013 if (!dev->sync_mode) { in aac_src_init()
1024 return -1; in aac_src_init()
1048 if (dev->msi_enabled) in aac_src_wait_sync()
1068 status[0] = readl(&dev->IndexRegs->Mailbox[0]); in aac_src_wait_sync()
1069 status[1] = readl(&dev->IndexRegs->Mailbox[1]); in aac_src_wait_sync()
1070 status[2] = readl(&dev->IndexRegs->Mailbox[2]); in aac_src_wait_sync()
1071 status[3] = readl(&dev->IndexRegs->Mailbox[3]); in aac_src_wait_sync()
1072 status[4] = readl(&dev->IndexRegs->Mailbox[4]); in aac_src_wait_sync()
1079 * aac_src_soft_reset - perform soft reset to speed up
1112 * We go into soft reset mode to allow us to handle response in aac_src_soft_reset()
1114 dev->in_soft_reset = 1; in aac_src_soft_reset()
1115 dev->msi_enabled = status_omr & AAC_INT_MODE_MSIX; in aac_src_soft_reset()
1138 dev->sa_firmware = 1; in aac_src_soft_reset()
1154 dev_err(&dev->pdev->dev, "%s: %d outstanding I/O pending\n", in aac_src_soft_reset()
1161 dev->in_soft_reset = 0; in aac_src_soft_reset()
1162 dev->msi_enabled = 0; in aac_src_soft_reset()
1164 dev_err(&dev->pdev->dev, "%s: %s status = %d", __func__, in aac_src_soft_reset()
1170 * aac_srcv_init - initialize an SRCv card
1180 int instance = dev->id; in aac_srcv_init()
1181 const char *name = dev->name; in aac_srcv_init()
1183 dev->a_ops.adapter_ioremap = aac_srcv_ioremap; in aac_srcv_init()
1184 dev->a_ops.adapter_comm = aac_src_select_comm; in aac_srcv_init()
1186 dev->base_size = AAC_MIN_SRCV_BAR0_SIZE; in aac_srcv_init()
1187 if (aac_adapter_ioremap(dev, dev->base_size)) { in aac_srcv_init()
1193 dev->a_ops.adapter_sync_cmd = src_sync_cmd; in aac_srcv_init()
1194 dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; in aac_srcv_init()
1196 if (dev->init_reset) { in aac_srcv_init()
1197 dev->init_reset = false; in aac_srcv_init()
1215 dev->name, instance); in aac_srcv_init()
1241 printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance); in aac_srcv_init()
1248 printk(KERN_ERR "%s%d: adapter monitor panic.\n", dev->name, instance); in aac_srcv_init()
1265 dev->name, instance, status); in aac_srcv_init()
1272 ? (startup_timeout - 60) in aac_srcv_init()
1287 dev->a_ops.adapter_interrupt = aac_src_interrupt_adapter; in aac_srcv_init()
1288 dev->a_ops.adapter_disable_int = aac_src_disable_interrupt; in aac_srcv_init()
1289 dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; in aac_srcv_init()
1290 dev->a_ops.adapter_notify = aac_src_notify_adapter; in aac_srcv_init()
1291 dev->a_ops.adapter_sync_cmd = src_sync_cmd; in aac_srcv_init()
1292 dev->a_ops.adapter_check_health = aac_src_check_health; in aac_srcv_init()
1293 dev->a_ops.adapter_restart = aac_src_restart_adapter; in aac_srcv_init()
1294 dev->a_ops.adapter_start = aac_src_start_adapter; in aac_srcv_init()
1307 if ((dev->comm_interface != AAC_COMM_MESSAGE_TYPE2) && in aac_srcv_init()
1308 (dev->comm_interface != AAC_COMM_MESSAGE_TYPE3)) in aac_srcv_init()
1310 if (dev->msi_enabled) in aac_srcv_init()
1316 dev->dbg_base = pci_resource_start(dev->pdev, 2); in aac_srcv_init()
1317 dev->dbg_base_mapped = dev->regs.src.bar1; in aac_srcv_init()
1318 dev->dbg_size = AAC_MIN_SRCV_BAR1_SIZE; in aac_srcv_init()
1319 dev->a_ops.adapter_enable_int = aac_src_enable_interrupt_message; in aac_srcv_init()
1323 if (!dev->sync_mode) { in aac_srcv_init()
1334 return -1; in aac_srcv_init()
1337 void aac_src_access_devreg(struct aac_dev *dev, int mode) in aac_src_access_devreg() argument
1341 switch (mode) { in aac_src_access_devreg()
1345 dev->OIMR = (dev->msi_enabled ? in aac_src_access_devreg()
1353 dev->OIMR = AAC_INT_DISABLE_ALL); in aac_src_access_devreg()
1422 if (!dev->msi_enabled) { in aac_src_get_sync_status()
1426 * if yes set the controller in MSIx mode and consider cmd in aac_src_get_sync_status()
1431 dev->msi_enabled = 1; in aac_src_get_sync_status()