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)
65 "HP NetRAID-4M, IBM ServeRAID & ICP SCSI driver");
76 * become important. Check for on-board Raid first, add-in cards second.
94 { 0x9005, 0x0285, 0x9005, 0x0287, 0, 0, 13 }, /* Adaptec 2200S (Vulcan-2m) */
100 { 0x9005, 0x0285, 0x9005, 0x028a, 0, 0, 18 }, /* ASR-2020ZCR SCSI PCI-X ZCR (Skyhawk) */
101 { 0x9005, 0x0285, 0x9005, 0x028b, 0, 0, 19 }, /* ASR-2025ZCR SCSI SO-DIMM PCI-X ZCR (Terminator) */
102 { 0x9005, 0x0286, 0x9005, 0x028c, 0, 0, 20 }, /* ASR-2230S + ASR-2230SLP PCI-X (Lancer) */
103 { 0x9005, 0x0286, 0x9005, 0x028d, 0, 0, 21 }, /* ASR-2130S (Lancer) */
104 { 0x9005, 0x0286, 0x9005, 0x029b, 0, 0, 22 }, /* AAR-2820SA (Intruder) */
105 { 0x9005, 0x0286, 0x9005, 0x029c, 0, 0, 23 }, /* AAR-2620SA (Intruder) */
106 { 0x9005, 0x0286, 0x9005, 0x029d, 0, 0, 24 }, /* AAR-2420SA (Intruder) */
112 { 0x9005, 0x0285, 0x9005, 0x02a4, 0, 0, 30 }, /* ICP9085LI (Marauder-X) */
113 { 0x9005, 0x0285, 0x9005, 0x02a5, 0, 0, 31 }, /* ICP5085BR (Marauder-E) */
114 { 0x9005, 0x0286, 0x9005, 0x02a6, 0, 0, 32 }, /* ICP9067MA (Intruder-6) */
118 { 0x9005, 0x0285, 0x9005, 0x028e, 0, 0, 35 }, /* ASR-2020SA SATA PCI-X ZCR (Skyhawk) */
119 { 0x9005, 0x0285, 0x9005, 0x028f, 0, 0, 36 }, /* ASR-2025SA SATA SO-DIMM PCI-X ZCR (Terminator) */
120 { 0x9005, 0x0285, 0x9005, 0x0290, 0, 0, 37 }, /* AAR-2410SA PCI SATA 4ch (Jaguar II) */
122 { 0x9005, 0x0285, 0x9005, 0x0292, 0, 0, 39 }, /* AAR-2810SA PCI SATA 8ch (Corsair-8) */
123 { 0x9005, 0x0285, 0x9005, 0x0293, 0, 0, 40 }, /* AAR-21610SA PCI SATA 16ch (Corsair-16) */
124 { 0x9005, 0x0285, 0x9005, 0x0294, 0, 0, 41 }, /* ESD SO-DIMM PCI-X SATA ZCR (Prowler) */
125 { 0x9005, 0x0285, 0x103C, 0x3227, 0, 0, 42 }, /* AAR-2610SA PCI SATA 6ch */
126 { 0x9005, 0x0285, 0x9005, 0x0296, 0, 0, 43 }, /* ASR-2240S (SabreExpress) */
127 { 0x9005, 0x0285, 0x9005, 0x0297, 0, 0, 44 }, /* ASR-4005 */
130 { 0x9005, 0x0286, 0x1014, 0x9580, 0, 0, 46 }, /* IBM 8k/8k-l8 (Aurora) */
131 { 0x9005, 0x0286, 0x1014, 0x9540, 0, 0, 47 }, /* IBM 8k/8k-l4 (Aurora Lite) */
132 { 0x9005, 0x0285, 0x9005, 0x0298, 0, 0, 48 }, /* ASR-4000 (BlackBird) */
133 { 0x9005, 0x0285, 0x9005, 0x0299, 0, 0, 49 }, /* ASR-4800SAS (Marauder-X) */
134 { 0x9005, 0x0285, 0x9005, 0x029a, 0, 0, 50 }, /* ASR-4805SAS (Marauder-E) */
135 { 0x9005, 0x0286, 0x9005, 0x02a2, 0, 0, 51 }, /* ASR-3800 (Hurricane44) */
141 { 0x1011, 0x0046, 0x103c, 0x10c2, 0, 0, 56 }, /* HP NetRAID-4M */
156 * dmb - For now we add the number of channels to this structure.
174 …00S ", 2, AAC_QUIRK_31BIT | AAC_QUIRK_34SG | AAC_QUIRK_SCSI_32 }, /* Adaptec 2200S (Vulcan-2m) */
180 …{ aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2020ZCR ", 2 }, /* ASR-2020ZCR SCSI PCI-X ZCR (Sky…
181 …{ aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2025ZCR ", 2 }, /* ASR-2025ZCR SCSI SO-DIMM PCI-X …
182 …{ aac_rkt_init, "aacraid", "ADAPTEC ", "ASR-2230S PCI-X ", 2 }, /* ASR-2230S + ASR-2230SLP PCI-X …
183 { aac_rkt_init, "aacraid", "ADAPTEC ", "ASR-2130S PCI-X ", 1 }, /* ASR-2130S (Lancer) */
184 { aac_rkt_init, "aacraid", "ADAPTEC ", "AAR-2820SA ", 1 }, /* AAR-2820SA (Intruder) */
185 { aac_rkt_init, "aacraid", "ADAPTEC ", "AAR-2620SA ", 1 }, /* AAR-2620SA (Intruder) */
186 { aac_rkt_init, "aacraid", "ADAPTEC ", "AAR-2420SA ", 1 }, /* AAR-2420SA (Intruder) */
192 { aac_rx_init, "aacraid", "ICP ", "ICP9085LI ", 1 }, /* ICP9085LI (Marauder-X) */
193 { aac_rx_init, "aacraid", "ICP ", "ICP5085BR ", 1 }, /* ICP5085BR (Marauder-E) */
194 { aac_rkt_init, "aacraid", "ICP ", "ICP9067MA ", 1 }, /* ICP9067MA (Intruder-6) */
197 …{ aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2020SA ", 1 }, /* ASR-2020SA SATA PCI-X ZCR (Sky…
198 …{ aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2025SA ", 1 }, /* ASR-2025SA SATA SO-DIMM PCI-X …
199 …{ aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2410SA SATA ", 1, AAC_QUIRK_17SG }, /* AAR-2410SA PCI …
201 …ac_rx_init, "aacraid", "ADAPTEC ", "AAR-2810SA SATA ", 1, AAC_QUIRK_17SG }, /* AAR-2810SA PCI SAT…
202 …c_rx_init, "aacraid", "ADAPTEC ", "AAR-21610SA SATA", 1, AAC_QUIRK_17SG }, /* AAR-21610SA PCI SAT…
203 …{ aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2026ZCR ", 1 }, /* ESD SO-DIMM PCI-X SATA ZCR (Pro…
204 { aac_rx_init, "aacraid", "ADAPTEC ", "AAR-2610SA ", 1 }, /* SATA 6Ch (Bearcat) */
205 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-2240S ", 1 }, /* ASR-2240S (SabreExpress) */
206 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4005 ", 1 }, /* ASR-4005 */
208 { aac_rkt_init, "ServeRAID","IBM ", "ServeRAID 8k-l8 ", 1 }, /* IBM 8k/8k-l8 (Aurora) */
209 { aac_rkt_init, "ServeRAID","IBM ", "ServeRAID 8k-l4 ", 1 }, /* IBM 8k/8k-l4 (Aurora Lite) */
210 …{ aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4000 ", 1 }, /* ASR-4000 (BlackBird & AvonPark)…
211 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4800SAS ", 1 }, /* ASR-4800SAS (Marauder-X) */
212 { aac_rx_init, "aacraid", "ADAPTEC ", "ASR-4805SAS ", 1 }, /* ASR-4805SAS (Marauder-E) */
213 { aac_rkt_init, "aacraid", "ADAPTEC ", "ASR-3800 ", 1 }, /* ASR-3800 (Hurricane44) */
217 …{ aac_sa_init, "aacraid", "ADAPTEC ", "AAC-364 ", 4, AAC_QUIRK_34SG }, /* Adaptec 5400S (…
219 { aac_sa_init, "hpnraid", "HP ", "NetRAID ", 4, AAC_QUIRK_34SG }, /* HP NetRAID-4M */
232 * aac_queuecommand - queue a SCSI command
245 cmd->SCp.phase = AAC_OWNER_LOWLEVEL; in aac_queuecommand()
251 * aac_info - Returns the host adapter name
259 struct aac_dev *dev = (struct aac_dev *)shost->hostdata; in aac_info()
260 return aac_drivers[dev->cardtype].name; in aac_info()
276 * aac_biosparm - return BIOS parameters for disk
306 * Assuming extended translation is enabled - #REVISIT# in aac_biosparm()
310 param->heads = 255; in aac_biosparm()
311 param->sectors = 63; in aac_biosparm()
313 param->heads = 128; in aac_biosparm()
314 param->sectors = 32; in aac_biosparm()
317 param->heads = 64; in aac_biosparm()
318 param->sectors = 32; in aac_biosparm()
321 param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors); in aac_biosparm()
335 int saved_cylinders = param->cylinders; in aac_biosparm()
340 end_head = entry->end_head; in aac_biosparm()
341 end_sec = entry->end_sector & 0x3f; in aac_biosparm()
344 param->heads = 64; in aac_biosparm()
345 param->sectors = 32; in aac_biosparm()
348 param->heads = 128; in aac_biosparm()
349 param->sectors = 32; in aac_biosparm()
352 param->heads = 255; in aac_biosparm()
353 param->sectors = 63; in aac_biosparm()
360 end_head = first->end_head; in aac_biosparm()
361 end_sec = first->end_sector & 0x3f; in aac_biosparm()
364 param->cylinders = cap_to_cyls(capacity, param->heads * param->sectors); in aac_biosparm()
365 if (num < 4 && end_sec == param->sectors) { in aac_biosparm()
366 if (param->cylinders != saved_cylinders) { in aac_biosparm()
368 param->heads, param->sectors, num)); in aac_biosparm()
374 param->heads, param->sectors)); in aac_biosparm()
382 * aac_slave_configure - compute queue depths
392 struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata; in aac_slave_configure() local
402 if (chn < AAC_MAX_BUSES && tid < AAC_MAX_TARGETS && aac->sa_firmware) { in aac_slave_configure()
403 devtype = aac->hba_map[chn][tid].devtype; in aac_slave_configure()
406 depth = aac->hba_map[chn][tid].qd_limit; in aac_slave_configure()
417 if (aac->jbod && (sdev->type == TYPE_DISK)) in aac_slave_configure()
418 sdev->removable = 1; in aac_slave_configure()
420 if (sdev->type == TYPE_DISK in aac_slave_configure()
422 && (!aac->jbod || sdev->inq_periph_qual) in aac_slave_configure()
423 && (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))) { in aac_slave_configure()
426 return -ENXIO; in aac_slave_configure()
429 sdev->no_uld_attach = 1; in aac_slave_configure()
432 if (sdev->tagged_supported in aac_slave_configure()
433 && sdev->type == TYPE_DISK in aac_slave_configure()
434 && (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2)) in aac_slave_configure()
435 && !sdev->no_uld_attach) { in aac_slave_configure()
438 struct Scsi_Host *host = sdev->host; in aac_slave_configure()
445 for (cid = 0; cid < aac->maximum_num_containers; ++cid) in aac_slave_configure()
446 if (aac->fsa_dev[cid].valid) in aac_slave_configure()
450 if (dev->tagged_supported in aac_slave_configure()
451 && dev->type == TYPE_DISK in aac_slave_configure()
452 && (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2)) in aac_slave_configure()
453 && !dev->no_uld_attach) { in aac_slave_configure()
455 || !aac->fsa_dev[sdev_id(dev)].valid) { in aac_slave_configure()
466 depth = (host->can_queue - num_one) / num_lsu; in aac_slave_configure()
481 if (strncmp(sdev->vendor, "ATA", 3) == 0) in aac_slave_configure()
493 timeout = aac->sa_firmware ? AAC_SA_TIMEOUT : AAC_ARC_TIMEOUT; in aac_slave_configure()
494 blk_queue_rq_timeout(sdev->request_queue, timeout * HZ); in aac_slave_configure()
504 sdev->tagged_supported = 1; in aac_slave_configure()
510 * aac_change_queue_depth - alter queue depths
520 struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); in aac_change_queue_depth() local
526 aac->hba_map[chn][tid].devtype == AAC_DEVTYPE_NATIVE_RAW) in aac_change_queue_depth()
529 if (sdev->tagged_supported && (sdev->type == TYPE_DISK) && in aac_change_queue_depth()
532 struct Scsi_Host *host = sdev->host; in aac_change_queue_depth()
536 if (dev->tagged_supported && (dev->type == TYPE_DISK) && in aac_change_queue_depth()
541 if (num >= host->can_queue) in aac_change_queue_depth()
542 num = host->can_queue - 1; in aac_change_queue_depth()
543 if (depth > (host->can_queue - num)) in aac_change_queue_depth()
544 depth = host->can_queue - num; in aac_change_queue_depth()
551 scsi_change_queue_depth(sdev, aac->hba_map[chn][tid].qd_limit); in aac_change_queue_depth()
555 return sdev->queue_depth; in aac_change_queue_depth()
561 struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); in aac_show_raid_level() local
563 return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach in aac_show_raid_level()
565 ((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : "")); in aac_show_raid_level()
567 get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); in aac_show_raid_level()
573 .mode = S_IRUGO,
582 struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); in aac_show_unique_id() local
588 memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn)); in aac_show_unique_id()
601 .mode = 0444,
618 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata; in aac_ioctl()
620 return -EPERM; in aac_ioctl()
623 return -EBUSY; in aac_ioctl()
639 switch (scmnd->SCp.phase) { in fib_count_iter()
641 fib_count->fwcnt++; in fib_count_iter()
644 fib_count->ehcnt++; in fib_count_iter()
647 fib_count->llcnt++; in fib_count_iter()
650 fib_count->mlcnt++; in fib_count_iter()
653 fib_count->krlcnt++; in fib_count_iter()
660 static int get_num_of_incomplete_fibs(struct aac_dev *aac) in get_num_of_incomplete_fibs() argument
662 struct Scsi_Host *shost = aac->scsi_host_ptr; in get_num_of_incomplete_fibs()
668 ctrl_dev = &aac->pdev->dev; in get_num_of_incomplete_fibs()
670 dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", fcnt.mlcnt); in get_num_of_incomplete_fibs()
671 dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", fcnt.llcnt); in get_num_of_incomplete_fibs()
672 dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", fcnt.ehcnt); in get_num_of_incomplete_fibs()
673 dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fcnt.fwcnt); in get_num_of_incomplete_fibs()
674 dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", fcnt.krlcnt); in get_num_of_incomplete_fibs()
681 struct scsi_device * dev = cmd->device; in aac_eh_abort()
682 struct Scsi_Host * host = dev->host; in aac_eh_abort()
683 struct aac_dev * aac = (struct aac_dev *)host->hostdata; in aac_eh_abort() local
688 if (aac_adapter_check_health(aac)) in aac_eh_abort()
693 if (aac->hba_map[bus][cid].devtype == AAC_DEVTYPE_NATIVE_RAW) { in aac_eh_abort()
701 host->host_no, sdev_channel(dev), sdev_id(dev), (int)dev->lun); in aac_eh_abort()
704 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) { in aac_eh_abort()
705 fib = &aac->fibs[count]; in aac_eh_abort()
706 if (*(u8 *)fib->hw_fib_va != 0 && in aac_eh_abort()
707 (fib->flags & FIB_CONTEXT_FLAG_NATIVE_HBA) && in aac_eh_abort()
708 (fib->callback_data == cmd)) { in aac_eh_abort()
717 fib = aac_fib_alloc(aac); in aac_eh_abort()
721 tmf = (struct aac_hba_tm_req *)fib->hw_fib_va; in aac_eh_abort()
723 tmf->tmf = HBA_TMF_ABORT_TASK; in aac_eh_abort()
724 tmf->it_nexus = aac->hba_map[bus][cid].rmw_nexus; in aac_eh_abort()
725 tmf->lun[1] = cmd->device->lun; in aac_eh_abort()
727 address = (u64)fib->hw_error_pa; in aac_eh_abort()
728 tmf->error_ptr_hi = cpu_to_le32((u32)(address >> 32)); in aac_eh_abort()
729 tmf->error_ptr_lo = cpu_to_le32((u32)(address & 0xffffffff)); in aac_eh_abort()
730 tmf->error_length = cpu_to_le32(FW_ERROR_BUFFER_SIZE); in aac_eh_abort()
732 fib->hbacmd_size = sizeof(*tmf); in aac_eh_abort()
733 cmd->SCp.sent_command = 0; in aac_eh_abort()
738 if (status != -EINPROGRESS) { in aac_eh_abort()
745 if (cmd->SCp.sent_command) { in aac_eh_abort()
760 host->host_no, sdev_channel(dev), sdev_id(dev), in aac_eh_abort()
761 (int)dev->lun); in aac_eh_abort()
762 switch (cmd->cmnd[0]) { in aac_eh_abort()
764 if (!(aac->raw_io_interface) || in aac_eh_abort()
765 !(aac->raw_io_64) || in aac_eh_abort()
766 ((cmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16)) in aac_eh_abort()
776 count < (host->can_queue + AAC_NUM_MGT_FIB); in aac_eh_abort()
778 struct fib *fib = &aac->fibs[count]; in aac_eh_abort()
780 if (fib->hw_fib_va->header.XferState && in aac_eh_abort()
781 (fib->flags & FIB_CONTEXT_FLAG) && in aac_eh_abort()
782 (fib->callback_data == cmd)) { in aac_eh_abort()
783 fib->flags |= in aac_eh_abort()
785 cmd->SCp.phase = in aac_eh_abort()
797 count < (host->can_queue + AAC_NUM_MGT_FIB); in aac_eh_abort()
800 struct fib *fib = &aac->fibs[count]; in aac_eh_abort()
802 command = fib->callback_data; in aac_eh_abort()
804 if ((fib->hw_fib_va->header.XferState & in aac_eh_abort()
807 (fib->flags & FIB_CONTEXT_FLAG) && in aac_eh_abort()
809 (command->device == cmd->device)) { in aac_eh_abort()
810 fib->flags |= in aac_eh_abort()
812 command->SCp.phase = in aac_eh_abort()
831 tmf = (struct aac_hba_tm_req *)fib->hw_fib_va; in aac_eh_tmf_lun_reset_fib()
833 tmf->tmf = HBA_TMF_LUN_RESET; in aac_eh_tmf_lun_reset_fib()
834 tmf->it_nexus = info->rmw_nexus; in aac_eh_tmf_lun_reset_fib()
835 int_to_scsilun(tmf_lun, (struct scsi_lun *)tmf->lun); in aac_eh_tmf_lun_reset_fib()
837 address = (u64)fib->hw_error_pa; in aac_eh_tmf_lun_reset_fib()
838 tmf->error_ptr_hi = cpu_to_le32 in aac_eh_tmf_lun_reset_fib()
840 tmf->error_ptr_lo = cpu_to_le32 in aac_eh_tmf_lun_reset_fib()
842 tmf->error_length = cpu_to_le32(FW_ERROR_BUFFER_SIZE); in aac_eh_tmf_lun_reset_fib()
843 fib->hbacmd_size = sizeof(*tmf); in aac_eh_tmf_lun_reset_fib()
855 rst = (struct aac_hba_reset_req *)fib->hw_fib_va; in aac_eh_tmf_hard_reset_fib()
857 rst->it_nexus = info->rmw_nexus; in aac_eh_tmf_hard_reset_fib()
859 address = (u64)fib->hw_error_pa; in aac_eh_tmf_hard_reset_fib()
860 rst->error_ptr_hi = cpu_to_le32((u32)(address >> 32)); in aac_eh_tmf_hard_reset_fib()
861 rst->error_ptr_lo = cpu_to_le32((u32)(address & 0xffffffff)); in aac_eh_tmf_hard_reset_fib()
862 rst->error_length = cpu_to_le32(FW_ERROR_BUFFER_SIZE); in aac_eh_tmf_hard_reset_fib()
863 fib->hbacmd_size = sizeof(*rst); in aac_eh_tmf_hard_reset_fib()
871 &((struct aac_native_hba *)fibptr->hw_fib_va)->resp.err; in aac_tmf_callback()
875 switch (err->service_response) { in aac_tmf_callback()
877 res = -1; in aac_tmf_callback()
887 res = -2; in aac_tmf_callback()
892 info->reset_state = res; in aac_tmf_callback()
896 * aac_eh_dev_reset - Device reset command handling
902 struct scsi_device * dev = cmd->device; in aac_eh_dev_reset()
903 struct Scsi_Host * host = dev->host; in aac_eh_dev_reset()
904 struct aac_dev * aac = (struct aac_dev *)host->hostdata; in aac_eh_dev_reset() local
919 info = &aac->hba_map[bus][cid]; in aac_eh_dev_reset()
921 if (!(info->devtype == AAC_DEVTYPE_NATIVE_RAW && in aac_eh_dev_reset()
922 !(info->reset_state > 0))) in aac_eh_dev_reset()
928 fib = aac_fib_alloc(aac); in aac_eh_dev_reset()
933 command = aac_eh_tmf_lun_reset_fib(info, fib, dev->lun); in aac_eh_dev_reset()
935 info->reset_state = 1; in aac_eh_dev_reset()
940 if (status != -EINPROGRESS) { in aac_eh_dev_reset()
941 info->reset_state = 0; in aac_eh_dev_reset()
948 if (info->reset_state == 0) { in aac_eh_dev_reset()
949 ret = info->reset_state == 0 ? SUCCESS : FAILED; in aac_eh_dev_reset()
959 * aac_eh_target_reset - Target reset command handling
965 struct scsi_device * dev = cmd->device; in aac_eh_target_reset()
966 struct Scsi_Host * host = dev->host; in aac_eh_target_reset()
967 struct aac_dev * aac = (struct aac_dev *)host->hostdata; in aac_eh_target_reset() local
982 info = &aac->hba_map[bus][cid]; in aac_eh_target_reset()
984 if (!(info->devtype == AAC_DEVTYPE_NATIVE_RAW && in aac_eh_target_reset()
985 !(info->reset_state > 0))) in aac_eh_target_reset()
991 fib = aac_fib_alloc(aac); in aac_eh_target_reset()
999 info->reset_state = 2; in aac_eh_target_reset()
1005 if (status != -EINPROGRESS) { in aac_eh_target_reset()
1006 info->reset_state = 0; in aac_eh_target_reset()
1014 if (info->reset_state <= 0) { in aac_eh_target_reset()
1015 ret = info->reset_state == 0 ? SUCCESS : FAILED; in aac_eh_target_reset()
1025 * aac_eh_bus_reset - Bus reset command handling
1031 struct scsi_device * dev = cmd->device; in aac_eh_bus_reset()
1032 struct Scsi_Host * host = dev->host; in aac_eh_bus_reset()
1033 struct aac_dev * aac = (struct aac_dev *)host->hostdata; in aac_eh_bus_reset() local
1041 for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) { in aac_eh_bus_reset()
1042 struct fib *fib = &aac->fibs[count]; in aac_eh_bus_reset()
1044 if (fib->hw_fib_va->header.XferState && in aac_eh_bus_reset()
1045 (fib->flags & FIB_CONTEXT_FLAG) && in aac_eh_bus_reset()
1046 (fib->flags & FIB_CONTEXT_FLAG_SCSI_CMD)) { in aac_eh_bus_reset()
1050 cmd = (struct scsi_cmnd *)fib->callback_data; in aac_eh_bus_reset()
1055 info = &aac->hba_map[bus][cid]; in aac_eh_bus_reset()
1057 info->devtype != AAC_DEVTYPE_NATIVE_RAW) { in aac_eh_bus_reset()
1058 fib->flags |= FIB_CONTEXT_FLAG_EH_RESET; in aac_eh_bus_reset()
1059 cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER; in aac_eh_bus_reset()
1069 status = aac_adapter_check_health(aac); in aac_eh_bus_reset()
1071 dev_err(&aac->pdev->dev, "Adapter health - %d\n", status); in aac_eh_bus_reset()
1073 count = get_num_of_incomplete_fibs(aac); in aac_eh_bus_reset()
1078 * aac_eh_host_reset - Host reset command handling
1084 struct scsi_device * dev = cmd->device; in aac_eh_host_reset()
1085 struct Scsi_Host * host = dev->host; in aac_eh_host_reset()
1086 struct aac_dev * aac = (struct aac_dev *)host->hostdata; in aac_eh_host_reset() local
1096 supported_options2 = aac->supplement_adapter_info.supported_options2; in aac_eh_host_reset()
1107 && (aac_check_reset != -1 || !is_ignore_reset)) { in aac_eh_host_reset()
1109 if (aac_reset_adapter(aac, 2, IOP_HWSOFT_RESET) == 0) in aac_eh_host_reset()
1121 info = &aac->hba_map[bus][cid]; in aac_eh_host_reset()
1122 if (info->devtype == AAC_DEVTYPE_NATIVE_RAW) in aac_eh_host_reset()
1123 info->reset_state = 0; in aac_eh_host_reset()
1131 * aac_cfg_open - open a configuration file
1144 struct aac_dev *aac; in aac_cfg_open() local
1146 int err = -ENODEV; in aac_cfg_open()
1149 list_for_each_entry(aac, &aac_devices, entry) { in aac_cfg_open()
1150 if (aac->id == minor_number) { in aac_cfg_open()
1151 file->private_data = aac; in aac_cfg_open()
1162 * aac_cfg_ioctl - AAC configuration request
1177 struct aac_dev *aac = (struct aac_dev *)file->private_data; in aac_cfg_ioctl() local
1180 return -EPERM; in aac_cfg_ioctl()
1182 return aac_do_ioctl(aac, cmd, (void __user *)arg); in aac_cfg_ioctl()
1210 ret = -EFAULT; in aac_compat_do_ioctl()
1211 if (copy_in_user(f, (void __user *)arg, sizeof(struct fib_ioctl) - sizeof(u32))) in aac_compat_do_ioctl()
1212 ret = -EFAULT; in aac_compat_do_ioctl()
1219 ret = -ENOIOCTLCMD; in aac_compat_do_ioctl()
1228 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata; in aac_compat_ioctl()
1230 return -EPERM; in aac_compat_ioctl()
1237 return -EPERM; in aac_compat_cfg_ioctl()
1238 return aac_compat_do_ioctl(file->private_data, cmd, arg); in aac_compat_cfg_ioctl()
1245 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_model()
1248 if (dev->supplement_adapter_info.adapter_type_text[0]) { in aac_show_model()
1249 char *cp = dev->supplement_adapter_info.adapter_type_text; in aac_show_model()
1257 aac_drivers[dev->cardtype].model); in aac_show_model()
1264 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_vendor()
1268 sup_adap_info = &dev->supplement_adapter_info; in aac_show_vendor()
1269 if (sup_adap_info->adapter_type_text[0]) { in aac_show_vendor()
1270 char *cp = sup_adap_info->adapter_type_text; in aac_show_vendor()
1274 (int)(cp - (char *)sup_adap_info->adapter_type_text), in aac_show_vendor()
1275 sup_adap_info->adapter_type_text); in aac_show_vendor()
1278 aac_drivers[dev->cardtype].vname); in aac_show_vendor()
1286 struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata; in aac_show_flags()
1291 len += scnprintf(buf + len, PAGE_SIZE - len, in aac_show_flags()
1294 if (dev->raw_io_interface && dev->raw_io_64) in aac_show_flags()
1295 len += scnprintf(buf + len, PAGE_SIZE - len, in aac_show_flags()
1297 if (dev->jbod) in aac_show_flags()
1298 len += scnprintf(buf + len, PAGE_SIZE - len, in aac_show_flags()
1300 if (dev->supplement_adapter_info.supported_options2 & in aac_show_flags()
1302 len += scnprintf(buf + len, PAGE_SIZE - len, in aac_show_flags()
1304 if (dev->msi) in aac_show_flags()
1305 len += scnprintf(buf + len, PAGE_SIZE - len, "PCI_HAS_MSI\n"); in aac_show_flags()
1313 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_kernel_version()
1316 tmp = le32_to_cpu(dev->adapter_info.kernelrev); in aac_show_kernel_version()
1317 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", in aac_show_kernel_version()
1319 le32_to_cpu(dev->adapter_info.kernelbuild)); in aac_show_kernel_version()
1327 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_monitor_version()
1330 tmp = le32_to_cpu(dev->adapter_info.monitorrev); in aac_show_monitor_version()
1331 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", in aac_show_monitor_version()
1333 le32_to_cpu(dev->adapter_info.monitorbuild)); in aac_show_monitor_version()
1341 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_bios_version()
1344 tmp = le32_to_cpu(dev->adapter_info.biosrev); in aac_show_bios_version()
1345 len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", in aac_show_bios_version()
1347 le32_to_cpu(dev->adapter_info.biosbuild)); in aac_show_bios_version()
1361 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_serial_number()
1364 if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0) in aac_show_serial_number()
1366 le32_to_cpu(dev->adapter_info.serial[0])); in aac_show_serial_number()
1368 !memcmp(&dev->supplement_adapter_info.mfg_pcba_serial_no[ in aac_show_serial_number()
1369 sizeof(dev->supplement_adapter_info.mfg_pcba_serial_no)-len], in aac_show_serial_number()
1370 buf, len-1)) in aac_show_serial_number()
1372 (int)sizeof(dev->supplement_adapter_info.mfg_pcba_serial_no), in aac_show_serial_number()
1373 dev->supplement_adapter_info.mfg_pcba_serial_no); in aac_show_serial_number()
1382 class_to_shost(device)->max_channel); in aac_show_max_channel()
1389 class_to_shost(device)->max_id); in aac_show_max_id()
1396 int retval = -EACCES; in aac_store_reset_adapter()
1413 struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata; in aac_show_reset_adapter()
1417 if ((tmp == 0) && dev->in_reset) in aac_show_reset_adapter()
1418 tmp = -EBUSY; in aac_show_reset_adapter()
1426 .mode = S_IRUGO,
1433 .mode = S_IRUGO,
1440 .mode = S_IRUGO,
1447 .mode = S_IRUGO,
1454 .mode = S_IRUGO,
1461 .mode = S_IRUGO,
1468 .mode = 0444,
1475 .mode = S_IRUGO,
1482 .mode = S_IRUGO,
1489 .mode = S_IRUGO,
1496 .mode = S_IWUSR|S_IRUGO,
1534 .name = "AAC",
1565 static void __aac_shutdown(struct aac_dev * aac) in __aac_shutdown() argument
1569 mutex_lock(&aac->ioctl_mutex); in __aac_shutdown()
1570 aac->adapter_shutdown = 1; in __aac_shutdown()
1571 mutex_unlock(&aac->ioctl_mutex); in __aac_shutdown()
1573 if (aac->aif_thread) { in __aac_shutdown()
1576 for (i = 0; i < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); i++) { in __aac_shutdown()
1577 struct fib *fib = &aac->fibs[i]; in __aac_shutdown()
1578 if (!(fib->hw_fib_va->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && in __aac_shutdown()
1579 (fib->hw_fib_va->header.XferState & cpu_to_le32(ResponseExpected))) in __aac_shutdown()
1580 complete(&fib->event_wait); in __aac_shutdown()
1582 kthread_stop(aac->thread); in __aac_shutdown()
1583 aac->thread = NULL; in __aac_shutdown()
1586 aac_send_shutdown(aac); in __aac_shutdown()
1588 aac_adapter_disable_int(aac); in __aac_shutdown()
1590 if (aac_is_src(aac)) { in __aac_shutdown()
1591 if (aac->max_msix > 1) { in __aac_shutdown()
1592 for (i = 0; i < aac->max_msix; i++) { in __aac_shutdown()
1593 free_irq(pci_irq_vector(aac->pdev, i), in __aac_shutdown()
1594 &(aac->aac_msix[i])); in __aac_shutdown()
1597 free_irq(aac->pdev->irq, in __aac_shutdown()
1598 &(aac->aac_msix[0])); in __aac_shutdown()
1601 free_irq(aac->pdev->irq, aac); in __aac_shutdown()
1603 if (aac->msi) in __aac_shutdown()
1604 pci_disable_msi(aac->pdev); in __aac_shutdown()
1605 else if (aac->max_msix > 1) in __aac_shutdown()
1606 pci_disable_msix(aac->pdev); in __aac_shutdown()
1610 aac_cfg_major = register_chrdev(0, "aac", &aac_cfg_fops); in aac_init_char()
1612 pr_err("aacraid: unable to register \"aac\" device.\n"); in aac_init_char()
1616 void aac_reinit_aif(struct aac_dev *aac, unsigned int index) in aac_reinit_aif() argument
1625 aac_intr_normal(aac, 0, 2, 0, NULL); in aac_reinit_aif()
1631 unsigned index = id->driver_data; in aac_probe_one()
1633 struct aac_dev *aac; in aac_probe_one() local
1644 if (pdev->device == PMC_DEVICE_S7) in aac_probe_one()
1645 pdev->needs_freset = 1; in aac_probe_one()
1647 list_for_each_entry(aac, &aac_devices, entry) { in aac_probe_one()
1648 if (aac->id > unique_id) in aac_probe_one()
1650 insert = &aac->entry; in aac_probe_one()
1662 error = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in aac_probe_one()
1664 dev_err(&pdev->dev, "PCI 32 BIT dma mask set failed"); in aac_probe_one()
1681 error = dma_set_coherent_mask(&pdev->dev, dmamask); in aac_probe_one()
1683 dev_err(&pdev->dev, "PCI %d B consistent dma mask set failed\n" in aac_probe_one()
1692 error = -ENOMEM; in aac_probe_one()
1696 shost->irq = pdev->irq; in aac_probe_one()
1697 shost->unique_id = unique_id; in aac_probe_one()
1698 shost->max_cmd_len = 16; in aac_probe_one()
1703 aac = (struct aac_dev *)shost->hostdata; in aac_probe_one()
1704 aac->base_start = pci_resource_start(pdev, 0); in aac_probe_one()
1705 aac->scsi_host_ptr = shost; in aac_probe_one()
1706 aac->pdev = pdev; in aac_probe_one()
1707 aac->name = aac_driver_template.name; in aac_probe_one()
1708 aac->id = shost->unique_id; in aac_probe_one()
1709 aac->cardtype = index; in aac_probe_one()
1710 INIT_LIST_HEAD(&aac->entry); in aac_probe_one()
1713 aac->init_reset = true; in aac_probe_one()
1715 aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB, in aac_probe_one()
1718 if (!aac->fibs) { in aac_probe_one()
1719 error = -ENOMEM; in aac_probe_one()
1723 spin_lock_init(&aac->fib_lock); in aac_probe_one()
1725 mutex_init(&aac->ioctl_mutex); in aac_probe_one()
1726 mutex_init(&aac->scan_mutex); in aac_probe_one()
1728 INIT_DELAYED_WORK(&aac->safw_rescan_work, aac_safw_rescan_worker); in aac_probe_one()
1729 INIT_DELAYED_WORK(&aac->src_reinit_aif_worker, in aac_probe_one()
1734 aac->base_size = AAC_MIN_FOOTPRINT_SIZE; in aac_probe_one()
1735 if ((*aac_drivers[index].init)(aac)) { in aac_probe_one()
1736 error = -ENODEV; in aac_probe_one()
1740 if (aac->sync_mode) { in aac_probe_one()
1742 printk(KERN_INFO "%s%d: Sync. mode enforced " in aac_probe_one()
1745 aac->name, in aac_probe_one()
1746 aac->id); in aac_probe_one()
1748 printk(KERN_INFO "%s%d: Async. mode not supported " in aac_probe_one()
1749 "by current driver, sync. mode enforced." in aac_probe_one()
1751 aac->name, in aac_probe_one()
1752 aac->id); in aac_probe_one()
1758 aac->thread = kthread_run(aac_command_thread, aac, AAC_DRIVERNAME); in aac_probe_one()
1759 if (IS_ERR(aac->thread)) { in aac_probe_one()
1761 error = PTR_ERR(aac->thread); in aac_probe_one()
1762 aac->thread = NULL; in aac_probe_one()
1766 aac->maximum_num_channels = aac_drivers[index].channels; in aac_probe_one()
1767 error = aac_get_adapter_info(aac); in aac_probe_one()
1775 (shost->sg_tablesize > 34)) { in aac_probe_one()
1776 shost->sg_tablesize = 34; in aac_probe_one()
1777 shost->max_sectors = (shost->sg_tablesize * 8) + 112; in aac_probe_one()
1781 (shost->sg_tablesize > 17)) { in aac_probe_one()
1782 shost->sg_tablesize = 17; in aac_probe_one()
1783 shost->max_sectors = (shost->sg_tablesize * 8) + 112; in aac_probe_one()
1786 if (aac->adapter_info.options & AAC_OPT_NEW_COMM) in aac_probe_one()
1787 shost->max_segment_size = shost->max_sectors << 9; in aac_probe_one()
1789 shost->max_segment_size = 65536; in aac_probe_one()
1795 aac->printf_enabled = 1; in aac_probe_one()
1797 aac->printf_enabled = 0; in aac_probe_one()
1804 if (aac->nondasd_support || expose_physicals || aac->jbod) in aac_probe_one()
1805 shost->max_channel = aac->maximum_num_channels; in aac_probe_one()
1807 shost->max_channel = 0; in aac_probe_one()
1809 aac_get_config_status(aac, 0); in aac_probe_one()
1810 aac_get_containers(aac); in aac_probe_one()
1811 list_add(&aac->entry, insert); in aac_probe_one()
1813 shost->max_id = aac->maximum_num_containers; in aac_probe_one()
1814 if (shost->max_id < aac->maximum_num_physicals) in aac_probe_one()
1815 shost->max_id = aac->maximum_num_physicals; in aac_probe_one()
1816 if (shost->max_id < MAXIMUM_NUM_CONTAINERS) in aac_probe_one()
1817 shost->max_id = MAXIMUM_NUM_CONTAINERS; in aac_probe_one()
1819 shost->this_id = shost->max_id; in aac_probe_one()
1821 if (!aac->sa_firmware && aac_drivers[index].quirks & AAC_QUIRK_SRC) in aac_probe_one()
1822 aac_intr_normal(aac, 0, 2, 0, NULL); in aac_probe_one()
1825 * dmb - we may need to move the setting of these parms somewhere else once in aac_probe_one()
1828 shost->max_lun = AAC_MAX_LUN; in aac_probe_one()
1832 error = scsi_add_host(shost, &pdev->dev); in aac_probe_one()
1836 aac_scan_host(aac); in aac_probe_one()
1844 __aac_shutdown(aac); in aac_probe_one()
1846 aac_fib_map_free(aac); in aac_probe_one()
1847 if (aac->comm_addr) in aac_probe_one()
1848 dma_free_coherent(&aac->pdev->dev, aac->comm_size, in aac_probe_one()
1849 aac->comm_addr, aac->comm_phys); in aac_probe_one()
1850 kfree(aac->queues); in aac_probe_one()
1851 aac_adapter_ioremap(aac, 0); in aac_probe_one()
1852 kfree(aac->fibs); in aac_probe_one()
1853 kfree(aac->fsa_dev); in aac_probe_one()
1862 static void aac_release_resources(struct aac_dev *aac) in aac_release_resources() argument
1864 aac_adapter_disable_int(aac); in aac_release_resources()
1865 aac_free_irq(aac); in aac_release_resources()
1886 if (dev->msi_enabled) in aac_acquire_resources()
1895 * Re-assign vectors to fibs in aac_acquire_resources()
1899 if (!dev->sync_mode) { in aac_acquire_resources()
1903 dev->init->r7.no_of_msix_vectors = cpu_to_le32(dev->max_msix); in aac_acquire_resources()
1909 return -1; in aac_acquire_resources()
1918 struct aac_dev *aac = (struct aac_dev *)shost->hostdata; in aac_suspend() local
1921 aac_cancel_rescan_worker(aac); in aac_suspend()
1922 aac_send_shutdown(aac); in aac_suspend()
1924 aac_release_resources(aac); in aac_suspend()
1937 struct aac_dev *aac = (struct aac_dev *)shost->hostdata; in aac_resume() local
1949 if (aac_acquire_resources(aac)) in aac_resume()
1955 aac->adapter_shutdown = 0; in aac_resume()
1961 printk(KERN_INFO "%s%d: resume failed.\n", aac->name, aac->id); in aac_resume()
1964 return -ENODEV; in aac_resume()
1973 __aac_shutdown((struct aac_dev *)shost->hostdata); in aac_shutdown()
1979 struct aac_dev *aac = (struct aac_dev *)shost->hostdata; in aac_remove_one() local
1981 aac_cancel_rescan_worker(aac); in aac_remove_one()
1984 __aac_shutdown(aac); in aac_remove_one()
1985 aac_fib_map_free(aac); in aac_remove_one()
1986 dma_free_coherent(&aac->pdev->dev, aac->comm_size, aac->comm_addr, in aac_remove_one()
1987 aac->comm_phys); in aac_remove_one()
1988 kfree(aac->queues); in aac_remove_one()
1990 aac_adapter_ioremap(aac, 0); in aac_remove_one()
1992 kfree(aac->fibs); in aac_remove_one()
1993 kfree(aac->fsa_dev); in aac_remove_one()
1995 list_del(&aac->entry); in aac_remove_one()
1999 unregister_chrdev(aac_cfg_major, "aac"); in aac_remove_one()
2008 struct aac_dev *aac = shost_priv(shost); in aac_pci_error_detected() local
2010 dev_err(&pdev->dev, "aacraid: PCI error detected %x\n", error); in aac_pci_error_detected()
2016 aac->handle_pci_error = 1; in aac_pci_error_detected()
2019 aac_cancel_rescan_worker(aac); in aac_pci_error_detected()
2021 aac_release_resources(aac); in aac_pci_error_detected()
2024 aac_adapter_ioremap(aac, 0); in aac_pci_error_detected()
2028 aac->handle_pci_error = 1; in aac_pci_error_detected()
2039 dev_err(&pdev->dev, "aacraid: PCI error - mmio enabled\n"); in aac_pci_mmio_enabled()
2045 dev_err(&pdev->dev, "aacraid: PCI error - slot reset\n"); in aac_pci_slot_reset()
2048 dev_warn(&pdev->dev, in aac_pci_slot_reset()
2056 dev_err(&pdev->dev, "pci_enable_device_mem failed\n"); in aac_pci_slot_reset()
2063 dev_err(&pdev->dev, "aacraid: PCI error - slot reset failed\n"); in aac_pci_slot_reset()
2071 struct aac_dev *aac = (struct aac_dev *)shost_priv(shost); in aac_pci_resume() local
2073 if (aac_adapter_ioremap(aac, aac->base_size)) { in aac_pci_resume()
2075 dev_err(&pdev->dev, "aacraid: ioremap failed\n"); in aac_pci_resume()
2077 aac->comm_interface = AAC_COMM_PRODUCER; in aac_pci_resume()
2078 if (aac_adapter_ioremap(aac, AAC_MIN_FOOTPRINT_SIZE)) { in aac_pci_resume()
2079 dev_warn(&pdev->dev, in aac_pci_resume()
2088 aac_acquire_resources(aac); in aac_pci_resume()
2094 aac->adapter_shutdown = 0; in aac_pci_resume()
2095 aac->handle_pci_error = 0; in aac_pci_resume()
2098 aac_scan_host(aac); in aac_pci_resume()
2101 dev_err(&pdev->dev, "aacraid: PCI error - resume\n"); in aac_pci_resume()
2143 if (aac_cfg_major > -1) in aac_exit()
2144 unregister_chrdev(aac_cfg_major, "aac"); in aac_exit()