Lines Matching +full:mgmt +full:- +full:sticky
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (c) 2003-2004 LSI Logic Corporation.
20 * --- ------------ --- --- ---- ----
37 * LSI MegaRAID SCSI 320-0 1000 1960 1000 A520
38 * LSI MegaRAID SCSI 320-1 1000 1960 1000 0520
39 * LSI MegaRAID SCSI 320-2 1000 1960 1000 0518
40 * LSI MegaRAID SCSI 320-0X 1000 0407 1000 0530
41 * LSI MegaRAID SCSI 320-2X 1000 0407 1000 0532
42 * LSI MegaRAID SCSI 320-4X 1000 0407 1000 0531
43 * LSI MegaRAID SCSI 320-1E 1000 0408 1000 0001
44 * LSI MegaRAID SCSI 320-2E 1000 0408 1000 0002
45 * LSI MegaRAID SATA 150-4 1000 1960 1000 4523
46 * LSI MegaRAID SATA 150-6 1000 1960 1000 0523
47 * LSI MegaRAID SATA 300-4X 1000 0409 1000 3004
48 * LSI MegaRAID SATA 300-8X 1000 0409 1000 3008
61 * ACER MegaRAID ROMB-2E 1000 0408 1025 004D
181 * This would result in non-disk devices being skipped during driver load
191 * mraid_debug level - threshold for amount of information to be displayed by
343 * megaraid_init - module load hook
368 // register as a PCI hot-plug driver module in megaraid_init()
380 * megaraid_exit - driver unload entry point
397 * megaraid_probe_one - PCI hotplug entry point
413 pdev->vendor, pdev->device, pdev->subsystem_vendor, in megaraid_probe_one()
414 pdev->subsystem_device)); in megaraid_probe_one()
416 con_log(CL_ANN, ("bus %d:slot %d:func %d\n", pdev->bus->number, in megaraid_probe_one()
417 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn))); in megaraid_probe_one()
423 return -ENODEV; in megaraid_probe_one()
426 // Enable bus-mastering on this controller in megaraid_probe_one()
440 // set up PCI related soft state and other pre-known parameters in megaraid_probe_one()
441 adapter->unique_id = pci_dev_id(pdev); in megaraid_probe_one()
442 adapter->irq = pdev->irq; in megaraid_probe_one()
443 adapter->pdev = pdev; in megaraid_probe_one()
445 atomic_set(&adapter->being_detached, 0); in megaraid_probe_one()
449 if (dma_set_mask(&adapter->pdev->dev, DMA_BIT_MASK(32))) { in megaraid_probe_one()
458 spin_lock_init(&adapter->lock); in megaraid_probe_one()
462 INIT_LIST_HEAD(&adapter->kscb_pool); in megaraid_probe_one()
465 INIT_LIST_HEAD(&adapter->pend_list); in megaraid_probe_one()
468 INIT_LIST_HEAD(&adapter->completed_list); in megaraid_probe_one()
492 // attach with scsi mid-layer in megaraid_probe_one()
511 return -ENODEV; in megaraid_probe_one()
516 * megaraid_detach_one - release framework resources and call LLD release routine
538 pdev->vendor, pdev->device, pdev->subsystem_vendor, in megaraid_detach_one()
539 pdev->subsystem_device)); in megaraid_detach_one()
546 pdev->vendor, pdev->device, pdev->subsystem_vendor, in megaraid_detach_one()
547 pdev->subsystem_device)); in megaraid_detach_one()
551 host = adapter->host; in megaraid_detach_one()
557 atomic_set(&adapter->being_detached, 1); in megaraid_detach_one()
559 // detach from the IO sub-system in megaraid_detach_one()
582 * megaraid_mbox_shutdown - PCI shutdown for megaraid HBA
610 * megaraid_io_attach - attach a device with the IO subsystem
626 return -1; in megaraid_io_attach()
630 adapter->host = host; in megaraid_io_attach()
632 host->irq = adapter->irq; in megaraid_io_attach()
633 host->unique_id = adapter->unique_id; in megaraid_io_attach()
634 host->can_queue = adapter->max_cmds; in megaraid_io_attach()
635 host->this_id = adapter->init_id; in megaraid_io_attach()
636 host->sg_tablesize = adapter->sglen; in megaraid_io_attach()
637 host->max_sectors = adapter->max_sectors; in megaraid_io_attach()
638 host->cmd_per_lun = adapter->cmd_per_lun; in megaraid_io_attach()
639 host->max_channel = adapter->max_channel; in megaraid_io_attach()
640 host->max_id = adapter->max_target; in megaraid_io_attach()
641 host->max_lun = adapter->max_lun; in megaraid_io_attach()
644 // notify mid-layer about the new controller in megaraid_io_attach()
645 if (scsi_add_host(host, &adapter->pdev->dev)) { in megaraid_io_attach()
652 return -1; in megaraid_io_attach()
662 * megaraid_io_detach - detach a device from the IO subsystem
674 host = adapter->host; in megaraid_io_detach()
689 * megaraid_init_mbox - initialize controller
692 * - Allocate 16-byte aligned mailbox memory for firmware handshake
693 * - Allocate controller's memory resources
694 * - Find out all initialization data
695 * - Allocate memory required for all the commands
696 * - Use internal library of FW routines, build up complete soft state
707 adapter->ito = MBOX_TIMEOUT; in megaraid_init_mbox()
708 pdev = adapter->pdev; in megaraid_init_mbox()
715 if (raid_dev == NULL) return -1; in megaraid_init_mbox()
721 adapter->raid_device = (caddr_t)raid_dev; in megaraid_init_mbox()
722 raid_dev->fast_load = megaraid_fast_load; in megaraid_init_mbox()
726 raid_dev->baseport = pci_resource_start(pdev, 0); in megaraid_init_mbox()
736 raid_dev->baseaddr = ioremap(raid_dev->baseport, 128); in megaraid_init_mbox()
738 if (!raid_dev->baseaddr) { in megaraid_init_mbox()
747 spin_lock_init(&raid_dev->mailbox_lock); in megaraid_init_mbox()
767 if (request_irq(adapter->irq, megaraid_isr, IRQF_SHARED, "megaraid", in megaraid_init_mbox()
771 "megaraid: Couldn't register IRQ %d!\n", adapter->irq)); in megaraid_init_mbox()
781 adapter->max_cdb_sz = 10; in megaraid_init_mbox()
783 adapter->max_cdb_sz = 16; in megaraid_init_mbox()
789 * NOTE: In a non-cluster aware firmware environment, the LLD should in megaraid_init_mbox()
792 adapter->ha = 0; in megaraid_init_mbox()
793 adapter->init_id = -1; in megaraid_init_mbox()
794 if (megaraid_mbox_support_ha(adapter, &adapter->init_id) == 0) { in megaraid_init_mbox()
795 adapter->ha = 1; in megaraid_init_mbox()
813 adapter->device_ids[adapter->max_channel][i] += 0x80; in megaraid_init_mbox()
815 adapter->device_ids[adapter->max_channel][adapter->init_id] = in megaraid_init_mbox()
818 raid_dev->random_del_supported = 1; in megaraid_init_mbox()
822 * find out the maximum number of scatter-gather elements supported by in megaraid_init_mbox()
825 adapter->sglen = megaraid_mbox_get_max_sg(adapter); in megaraid_init_mbox()
836 adapter->max_sectors = megaraid_max_sectors; in megaraid_init_mbox()
841 adapter->cmd_per_lun = megaraid_cmd_per_lun; in megaraid_init_mbox()
850 // Set the DMA mask to 64-bit. All supported controllers as capable of in megaraid_init_mbox()
852 pci_read_config_dword(adapter->pdev, PCI_CONF_AMISIG64, &magic64); in megaraid_init_mbox()
855 ((adapter->pdev->subsystem_device != in megaraid_init_mbox()
857 (adapter->pdev->subsystem_device != in megaraid_init_mbox()
859 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC && in megaraid_init_mbox()
860 adapter->pdev->device == PCI_DEVICE_ID_VERDE) || in megaraid_init_mbox()
861 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC && in megaraid_init_mbox()
862 adapter->pdev->device == PCI_DEVICE_ID_DOBSON) || in megaraid_init_mbox()
863 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC && in megaraid_init_mbox()
864 adapter->pdev->device == PCI_DEVICE_ID_LINDSAY) || in megaraid_init_mbox()
865 (adapter->pdev->vendor == PCI_VENDOR_ID_DELL && in megaraid_init_mbox()
866 adapter->pdev->device == PCI_DEVICE_ID_PERC4_DI_EVERGLADES) || in megaraid_init_mbox()
867 (adapter->pdev->vendor == PCI_VENDOR_ID_DELL && in megaraid_init_mbox()
868 adapter->pdev->device == PCI_DEVICE_ID_PERC4E_DI_KOBUK)) { in megaraid_init_mbox()
869 if (dma_set_mask(&adapter->pdev->dev, DMA_BIT_MASK(64))) { in megaraid_init_mbox()
871 "megaraid: DMA mask for 64-bit failed\n")); in megaraid_init_mbox()
873 if (dma_set_mask(&adapter->pdev->dev, in megaraid_init_mbox()
876 "megaraid: 32-bit DMA mask failed\n")); in megaraid_init_mbox()
883 tasklet_init(&adapter->dpc_h, megaraid_mbox_dpc, in megaraid_init_mbox()
894 free_irq(adapter->irq, adapter); in megaraid_init_mbox()
898 iounmap(raid_dev->baseaddr); in megaraid_init_mbox()
904 return -1; in megaraid_init_mbox()
909 * megaraid_fini_mbox - undo controller initialization
920 tasklet_kill(&adapter->dpc_h); in megaraid_fini_mbox()
926 free_irq(adapter->irq, adapter); in megaraid_fini_mbox()
928 iounmap(raid_dev->baseaddr); in megaraid_fini_mbox()
930 pci_release_regions(adapter->pdev); in megaraid_fini_mbox()
939 * megaraid_alloc_cmd_packets - allocate shared mailbox
960 pdev = adapter->pdev; in megaraid_alloc_cmd_packets()
964 * Allocate the common 16-byte aligned memory for the handshake in megaraid_alloc_cmd_packets()
967 raid_dev->una_mbox64 = dma_alloc_coherent(&adapter->pdev->dev, in megaraid_alloc_cmd_packets()
969 &raid_dev->una_mbox64_dma, in megaraid_alloc_cmd_packets()
972 if (!raid_dev->una_mbox64) { in megaraid_alloc_cmd_packets()
976 return -1; in megaraid_alloc_cmd_packets()
980 * Align the mailbox at 16-byte boundary in megaraid_alloc_cmd_packets()
982 raid_dev->mbox = &raid_dev->una_mbox64->mbox32; in megaraid_alloc_cmd_packets()
984 raid_dev->mbox = (mbox_t *)((((unsigned long)raid_dev->mbox) + 15) & in megaraid_alloc_cmd_packets()
987 raid_dev->mbox64 = (mbox64_t *)(((unsigned long)raid_dev->mbox) - 8); in megaraid_alloc_cmd_packets()
989 align = ((void *)raid_dev->mbox - in megaraid_alloc_cmd_packets()
990 ((void *)&raid_dev->una_mbox64->mbox32)); in megaraid_alloc_cmd_packets()
992 raid_dev->mbox_dma = (unsigned long)raid_dev->una_mbox64_dma + 8 + in megaraid_alloc_cmd_packets()
996 adapter->ibuf = dma_alloc_coherent(&pdev->dev, MBOX_IBUF_SIZE, in megaraid_alloc_cmd_packets()
997 &adapter->ibuf_dma_h, GFP_KERNEL); in megaraid_alloc_cmd_packets()
998 if (!adapter->ibuf) { in megaraid_alloc_cmd_packets()
1018 adapter->kscb_list = kcalloc(MBOX_MAX_SCSI_CMDS, sizeof(scb_t), GFP_KERNEL); in megaraid_alloc_cmd_packets()
1020 if (adapter->kscb_list == NULL) { in megaraid_alloc_cmd_packets()
1036 epthru_pci_blk = raid_dev->epthru_pool; in megaraid_alloc_cmd_packets()
1037 sg_pci_blk = raid_dev->sg_pool; in megaraid_alloc_cmd_packets()
1038 mbox_pci_blk = raid_dev->mbox_pool; in megaraid_alloc_cmd_packets()
1041 scb = adapter->kscb_list + i; in megaraid_alloc_cmd_packets()
1042 ccb = raid_dev->ccb_list + i; in megaraid_alloc_cmd_packets()
1044 ccb->mbox = (mbox_t *)(mbox_pci_blk[i].vaddr + 16); in megaraid_alloc_cmd_packets()
1045 ccb->raw_mbox = (uint8_t *)ccb->mbox; in megaraid_alloc_cmd_packets()
1046 ccb->mbox64 = (mbox64_t *)(mbox_pci_blk[i].vaddr + 8); in megaraid_alloc_cmd_packets()
1047 ccb->mbox_dma_h = (unsigned long)mbox_pci_blk[i].dma_addr + 16; in megaraid_alloc_cmd_packets()
1050 if (ccb->mbox_dma_h & 0x0F) { in megaraid_alloc_cmd_packets()
1052 "megaraid mbox: not aligned on 16-bytes\n")); in megaraid_alloc_cmd_packets()
1057 ccb->epthru = (mraid_epassthru_t *) in megaraid_alloc_cmd_packets()
1059 ccb->epthru_dma_h = epthru_pci_blk[i].dma_addr; in megaraid_alloc_cmd_packets()
1060 ccb->pthru = (mraid_passthru_t *)ccb->epthru; in megaraid_alloc_cmd_packets()
1061 ccb->pthru_dma_h = ccb->epthru_dma_h; in megaraid_alloc_cmd_packets()
1064 ccb->sgl64 = (mbox_sgl64 *)sg_pci_blk[i].vaddr; in megaraid_alloc_cmd_packets()
1065 ccb->sgl_dma_h = sg_pci_blk[i].dma_addr; in megaraid_alloc_cmd_packets()
1066 ccb->sgl32 = (mbox_sgl32 *)ccb->sgl64; in megaraid_alloc_cmd_packets()
1068 scb->ccb = (caddr_t)ccb; in megaraid_alloc_cmd_packets()
1069 scb->gp = 0; in megaraid_alloc_cmd_packets()
1071 scb->sno = i; // command index in megaraid_alloc_cmd_packets()
1073 scb->scp = NULL; in megaraid_alloc_cmd_packets()
1074 scb->state = SCB_FREE; in megaraid_alloc_cmd_packets()
1075 scb->dma_direction = DMA_NONE; in megaraid_alloc_cmd_packets()
1076 scb->dma_type = MRAID_DMA_NONE; in megaraid_alloc_cmd_packets()
1077 scb->dev_channel = -1; in megaraid_alloc_cmd_packets()
1078 scb->dev_target = -1; in megaraid_alloc_cmd_packets()
1081 list_add_tail(&scb->list, &adapter->kscb_pool); in megaraid_alloc_cmd_packets()
1089 kfree(adapter->kscb_list); in megaraid_alloc_cmd_packets()
1091 dma_free_coherent(&pdev->dev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, in megaraid_alloc_cmd_packets()
1092 adapter->ibuf_dma_h); in megaraid_alloc_cmd_packets()
1094 dma_free_coherent(&adapter->pdev->dev, sizeof(mbox64_t), in megaraid_alloc_cmd_packets()
1095 (caddr_t)raid_dev->una_mbox64, raid_dev->una_mbox64_dma); in megaraid_alloc_cmd_packets()
1097 return -1; in megaraid_alloc_cmd_packets()
1102 * megaraid_free_cmd_packets - free memory
1114 kfree(adapter->kscb_list); in megaraid_free_cmd_packets()
1116 dma_free_coherent(&adapter->pdev->dev, MBOX_IBUF_SIZE, in megaraid_free_cmd_packets()
1117 (void *)adapter->ibuf, adapter->ibuf_dma_h); in megaraid_free_cmd_packets()
1119 dma_free_coherent(&adapter->pdev->dev, sizeof(mbox64_t), in megaraid_free_cmd_packets()
1120 (caddr_t)raid_dev->una_mbox64, raid_dev->una_mbox64_dma); in megaraid_free_cmd_packets()
1126 * megaraid_mbox_setup_dma_pools - setup dma pool for command packets
1130 * and scatter-gather lists.
1143 // Allocate memory for 16-bytes aligned mailboxes in megaraid_mbox_setup_dma_pools()
1144 raid_dev->mbox_pool_handle = dma_pool_create("megaraid mbox pool", in megaraid_mbox_setup_dma_pools()
1145 &adapter->pdev->dev, in megaraid_mbox_setup_dma_pools()
1149 if (raid_dev->mbox_pool_handle == NULL) { in megaraid_mbox_setup_dma_pools()
1153 mbox_pci_blk = raid_dev->mbox_pool; in megaraid_mbox_setup_dma_pools()
1156 raid_dev->mbox_pool_handle, in megaraid_mbox_setup_dma_pools()
1172 raid_dev->epthru_pool_handle = dma_pool_create("megaraid mbox pthru", in megaraid_mbox_setup_dma_pools()
1173 &adapter->pdev->dev, sizeof(mraid_epassthru_t), 128, 0); in megaraid_mbox_setup_dma_pools()
1175 if (raid_dev->epthru_pool_handle == NULL) { in megaraid_mbox_setup_dma_pools()
1179 epthru_pci_blk = raid_dev->epthru_pool; in megaraid_mbox_setup_dma_pools()
1182 raid_dev->epthru_pool_handle, in megaraid_mbox_setup_dma_pools()
1191 // Allocate memory for each scatter-gather list. Request for 512 bytes in megaraid_mbox_setup_dma_pools()
1193 raid_dev->sg_pool_handle = dma_pool_create("megaraid mbox sg", in megaraid_mbox_setup_dma_pools()
1194 &adapter->pdev->dev, in megaraid_mbox_setup_dma_pools()
1198 if (raid_dev->sg_pool_handle == NULL) { in megaraid_mbox_setup_dma_pools()
1202 sg_pci_blk = raid_dev->sg_pool; in megaraid_mbox_setup_dma_pools()
1205 raid_dev->sg_pool_handle, in megaraid_mbox_setup_dma_pools()
1217 return -1; in megaraid_mbox_setup_dma_pools()
1222 * megaraid_mbox_teardown_dma_pools - teardown dma pools for command packets
1226 * structures, and scatter-gather lists.
1238 sg_pci_blk = raid_dev->sg_pool; in megaraid_mbox_teardown_dma_pools()
1240 dma_pool_free(raid_dev->sg_pool_handle, sg_pci_blk[i].vaddr, in megaraid_mbox_teardown_dma_pools()
1243 dma_pool_destroy(raid_dev->sg_pool_handle); in megaraid_mbox_teardown_dma_pools()
1246 epthru_pci_blk = raid_dev->epthru_pool; in megaraid_mbox_teardown_dma_pools()
1248 dma_pool_free(raid_dev->epthru_pool_handle, in megaraid_mbox_teardown_dma_pools()
1251 dma_pool_destroy(raid_dev->epthru_pool_handle); in megaraid_mbox_teardown_dma_pools()
1254 mbox_pci_blk = raid_dev->mbox_pool; in megaraid_mbox_teardown_dma_pools()
1256 dma_pool_free(raid_dev->mbox_pool_handle, in megaraid_mbox_teardown_dma_pools()
1259 dma_pool_destroy(raid_dev->mbox_pool_handle); in megaraid_mbox_teardown_dma_pools()
1266 * megaraid_alloc_scb - detach and return a scb from the free list
1276 struct list_head *head = &adapter->kscb_pool; in megaraid_alloc_scb()
1288 scb = list_entry(head->next, scb_t, list); in megaraid_alloc_scb()
1289 list_del_init(&scb->list); in megaraid_alloc_scb()
1293 scb->state = SCB_ACTIVE; in megaraid_alloc_scb()
1294 scb->scp = scp; in megaraid_alloc_scb()
1295 scb->dma_type = MRAID_DMA_NONE; in megaraid_alloc_scb()
1302 * megaraid_dealloc_scb - return the scb to the free pool
1317 scb->state = SCB_FREE; in megaraid_dealloc_scb()
1318 scb->scp = NULL; in megaraid_dealloc_scb()
1321 list_add(&scb->list, &adapter->kscb_pool); in megaraid_dealloc_scb()
1330 * megaraid_mbox_mksgl - make the scatter-gather list
1334 * Prepare the scatter-gather list.
1346 scp = scb->scp; in megaraid_mbox_mksgl()
1347 ccb = (mbox_ccb_t *)scb->ccb; in megaraid_mbox_mksgl()
1350 BUG_ON(sgcnt < 0 || sgcnt > adapter->sglen); in megaraid_mbox_mksgl()
1356 scb->dma_type = MRAID_DMA_WSG; in megaraid_mbox_mksgl()
1359 ccb->sgl64[i].address = sg_dma_address(sgl); in megaraid_mbox_mksgl()
1360 ccb->sgl64[i].length = sg_dma_len(sgl); in megaraid_mbox_mksgl()
1369 * mbox_post_cmd - issue a mailbox command
1386 ccb = (mbox_ccb_t *)scb->ccb; in mbox_post_cmd()
1387 mbox = raid_dev->mbox; in mbox_post_cmd()
1388 mbox64 = raid_dev->mbox64; in mbox_post_cmd()
1391 * Check for busy mailbox. If it is, return failure - the caller in mbox_post_cmd()
1396 if (unlikely(mbox->busy)) { in mbox_post_cmd()
1401 } while(mbox->busy && (i < max_mbox_busy_wait)); in mbox_post_cmd()
1403 if (mbox->busy) { in mbox_post_cmd()
1407 return -1; in mbox_post_cmd()
1413 memcpy((caddr_t)mbox64, (caddr_t)ccb->mbox64, 22); in mbox_post_cmd()
1414 mbox->cmdid = scb->sno; in mbox_post_cmd()
1416 adapter->outstanding_cmds++; in mbox_post_cmd()
1418 mbox->busy = 1; // Set busy in mbox_post_cmd()
1419 mbox->poll = 0; in mbox_post_cmd()
1420 mbox->ack = 0; in mbox_post_cmd()
1423 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); in mbox_post_cmd()
1432 * megaraid_queue_command_lck - generic queue entry point for all LLDs
1445 scp->result = 0; in megaraid_queue_command_lck()
1450 * not allocate scb. We will return non-zero status in that case. in megaraid_queue_command_lck()
1469 * megaraid_mbox_build_cmd - transform the mid-layer scsi commands in DEF_SCSI_QCMD()
1471 * @scp : mid-layer scsi command pointer in DEF_SCSI_QCMD()
1475 * Transform the mid-layer scsi command to megaraid firmware lingua. in DEF_SCSI_QCMD()
1476 * Convert the command issued by mid-layer to format understood by megaraid in DEF_SCSI_QCMD()
1506 switch (scp->cmnd[0]) { in DEF_SCSI_QCMD()
1512 if (!adapter->ha) { in DEF_SCSI_QCMD()
1513 scp->result = (DID_OK << 16); in DEF_SCSI_QCMD()
1518 scp->result = (DID_ERROR << 16); in DEF_SCSI_QCMD()
1523 scb->dma_direction = scp->sc_data_direction; in DEF_SCSI_QCMD()
1524 scb->dev_channel = 0xFF; in DEF_SCSI_QCMD()
1525 scb->dev_target = target; in DEF_SCSI_QCMD()
1526 ccb = (mbox_ccb_t *)scb->ccb; in DEF_SCSI_QCMD()
1532 ccb->raw_mbox[0] = CLUSTER_CMD; in DEF_SCSI_QCMD()
1533 ccb->raw_mbox[2] = RESERVATION_STATUS; in DEF_SCSI_QCMD()
1534 ccb->raw_mbox[3] = target; in DEF_SCSI_QCMD()
1547 memset(vaddr, 0, scp->cmnd[4]); in DEF_SCSI_QCMD()
1555 scp->result = (DID_OK << 16); in DEF_SCSI_QCMD()
1563 if (!(rdev->last_disp & (1L << SCP2CHANNEL(scp)))) { in DEF_SCSI_QCMD()
1567 adapter->host->host_no, in DEF_SCSI_QCMD()
1573 rdev->last_disp |= (1L << SCP2CHANNEL(scp)); in DEF_SCSI_QCMD()
1576 if (scp->cmnd[1] & MEGA_SCSI_INQ_EVPD) { in DEF_SCSI_QCMD()
1590 scp->result = (DID_BAD_TARGET << 16); in DEF_SCSI_QCMD()
1594 scp->result = (DID_BAD_TARGET << 16); in DEF_SCSI_QCMD()
1601 scp->result = (DID_ERROR << 16); in DEF_SCSI_QCMD()
1606 ccb = (mbox_ccb_t *)scb->ccb; in DEF_SCSI_QCMD()
1607 scb->dev_channel = 0xFF; in DEF_SCSI_QCMD()
1608 scb->dev_target = target; in DEF_SCSI_QCMD()
1609 pthru = ccb->pthru; in DEF_SCSI_QCMD()
1610 mbox = ccb->mbox; in DEF_SCSI_QCMD()
1611 mbox64 = ccb->mbox64; in DEF_SCSI_QCMD()
1613 pthru->timeout = 0; in DEF_SCSI_QCMD()
1614 pthru->ars = 1; in DEF_SCSI_QCMD()
1615 pthru->reqsenselen = 14; in DEF_SCSI_QCMD()
1616 pthru->islogical = 1; in DEF_SCSI_QCMD()
1617 pthru->logdrv = target; in DEF_SCSI_QCMD()
1618 pthru->cdblen = scp->cmd_len; in DEF_SCSI_QCMD()
1619 memcpy(pthru->cdb, scp->cmnd, scp->cmd_len); in DEF_SCSI_QCMD()
1621 mbox->cmd = MBOXCMD_PASSTHRU64; in DEF_SCSI_QCMD()
1622 scb->dma_direction = scp->sc_data_direction; in DEF_SCSI_QCMD()
1624 pthru->dataxferlen = scsi_bufflen(scp); in DEF_SCSI_QCMD()
1625 pthru->dataxferaddr = ccb->sgl_dma_h; in DEF_SCSI_QCMD()
1626 pthru->numsge = megaraid_mbox_mksgl(adapter, in DEF_SCSI_QCMD()
1629 mbox->xferaddr = 0xFFFFFFFF; in DEF_SCSI_QCMD()
1630 mbox64->xferaddr_lo = (uint32_t )ccb->pthru_dma_h; in DEF_SCSI_QCMD()
1631 mbox64->xferaddr_hi = 0; in DEF_SCSI_QCMD()
1646 scp->result = (DID_ERROR << 16); in DEF_SCSI_QCMD()
1650 ccb = (mbox_ccb_t *)scb->ccb; in DEF_SCSI_QCMD()
1651 scb->dev_channel = 0xFF; in DEF_SCSI_QCMD()
1652 scb->dev_target = target; in DEF_SCSI_QCMD()
1653 mbox = ccb->mbox; in DEF_SCSI_QCMD()
1654 mbox64 = ccb->mbox64; in DEF_SCSI_QCMD()
1655 mbox->logdrv = target; in DEF_SCSI_QCMD()
1661 mbox->cmd = (scp->cmnd[0] & 0x02) ? MBOXCMD_LWRITE64: in DEF_SCSI_QCMD()
1665 * 6-byte READ(0x08) or WRITE(0x0A) cdb in DEF_SCSI_QCMD()
1667 if (scp->cmd_len == 6) { in DEF_SCSI_QCMD()
1668 mbox->numsectors = (uint32_t)scp->cmnd[4]; in DEF_SCSI_QCMD()
1669 mbox->lba = in DEF_SCSI_QCMD()
1670 ((uint32_t)scp->cmnd[1] << 16) | in DEF_SCSI_QCMD()
1671 ((uint32_t)scp->cmnd[2] << 8) | in DEF_SCSI_QCMD()
1672 (uint32_t)scp->cmnd[3]; in DEF_SCSI_QCMD()
1674 mbox->lba &= 0x1FFFFF; in DEF_SCSI_QCMD()
1678 * 10-byte READ(0x28) or WRITE(0x2A) cdb in DEF_SCSI_QCMD()
1680 else if (scp->cmd_len == 10) { in DEF_SCSI_QCMD()
1681 mbox->numsectors = in DEF_SCSI_QCMD()
1682 (uint32_t)scp->cmnd[8] | in DEF_SCSI_QCMD()
1683 ((uint32_t)scp->cmnd[7] << 8); in DEF_SCSI_QCMD()
1684 mbox->lba = in DEF_SCSI_QCMD()
1685 ((uint32_t)scp->cmnd[2] << 24) | in DEF_SCSI_QCMD()
1686 ((uint32_t)scp->cmnd[3] << 16) | in DEF_SCSI_QCMD()
1687 ((uint32_t)scp->cmnd[4] << 8) | in DEF_SCSI_QCMD()
1688 (uint32_t)scp->cmnd[5]; in DEF_SCSI_QCMD()
1692 * 12-byte READ(0xA8) or WRITE(0xAA) cdb in DEF_SCSI_QCMD()
1694 else if (scp->cmd_len == 12) { in DEF_SCSI_QCMD()
1695 mbox->lba = in DEF_SCSI_QCMD()
1696 ((uint32_t)scp->cmnd[2] << 24) | in DEF_SCSI_QCMD()
1697 ((uint32_t)scp->cmnd[3] << 16) | in DEF_SCSI_QCMD()
1698 ((uint32_t)scp->cmnd[4] << 8) | in DEF_SCSI_QCMD()
1699 (uint32_t)scp->cmnd[5]; in DEF_SCSI_QCMD()
1701 mbox->numsectors = in DEF_SCSI_QCMD()
1702 ((uint32_t)scp->cmnd[6] << 24) | in DEF_SCSI_QCMD()
1703 ((uint32_t)scp->cmnd[7] << 16) | in DEF_SCSI_QCMD()
1704 ((uint32_t)scp->cmnd[8] << 8) | in DEF_SCSI_QCMD()
1705 (uint32_t)scp->cmnd[9]; in DEF_SCSI_QCMD()
1713 scp->result = (DID_ERROR << 16); in DEF_SCSI_QCMD()
1717 scb->dma_direction = scp->sc_data_direction; in DEF_SCSI_QCMD()
1719 // Calculate Scatter-Gather info in DEF_SCSI_QCMD()
1720 mbox64->xferaddr_lo = (uint32_t )ccb->sgl_dma_h; in DEF_SCSI_QCMD()
1721 mbox->numsge = megaraid_mbox_mksgl(adapter, in DEF_SCSI_QCMD()
1723 mbox->xferaddr = 0xFFFFFFFF; in DEF_SCSI_QCMD()
1724 mbox64->xferaddr_hi = 0; in DEF_SCSI_QCMD()
1733 if (!adapter->ha) { in DEF_SCSI_QCMD()
1734 scp->result = (DID_BAD_TARGET << 16); in DEF_SCSI_QCMD()
1742 scp->result = (DID_ERROR << 16); in DEF_SCSI_QCMD()
1747 ccb = (mbox_ccb_t *)scb->ccb; in DEF_SCSI_QCMD()
1748 scb->dev_channel = 0xFF; in DEF_SCSI_QCMD()
1749 scb->dev_target = target; in DEF_SCSI_QCMD()
1750 ccb->raw_mbox[0] = CLUSTER_CMD; in DEF_SCSI_QCMD()
1751 ccb->raw_mbox[2] = (scp->cmnd[0] == RESERVE) ? in DEF_SCSI_QCMD()
1754 ccb->raw_mbox[3] = target; in DEF_SCSI_QCMD()
1755 scb->dma_direction = scp->sc_data_direction; in DEF_SCSI_QCMD()
1760 scp->result = (DID_BAD_TARGET << 16); in DEF_SCSI_QCMD()
1768 scp->result = (DID_BAD_TARGET << 16); in DEF_SCSI_QCMD()
1775 if (rdev->fast_load && (target == 15) && in DEF_SCSI_QCMD()
1776 (SCP2CHANNEL(scp) == adapter->max_channel -1)) { in DEF_SCSI_QCMD()
1779 "megaraid[%d]: physical device scan re-enabled\n", in DEF_SCSI_QCMD()
1780 adapter->host->host_no)); in DEF_SCSI_QCMD()
1781 rdev->fast_load = 0; in DEF_SCSI_QCMD()
1787 if (!(rdev->last_disp & (1L << SCP2CHANNEL(scp)))) { in DEF_SCSI_QCMD()
1789 ss = rdev->fast_load ? skip : scan; in DEF_SCSI_QCMD()
1793 adapter->host->host_no, ss, SCP2CHANNEL(scp), in DEF_SCSI_QCMD()
1797 " for non-raid devices\n")); in DEF_SCSI_QCMD()
1799 rdev->last_disp |= (1L << SCP2CHANNEL(scp)); in DEF_SCSI_QCMD()
1803 if (rdev->fast_load) { in DEF_SCSI_QCMD()
1804 scp->result = (DID_BAD_TARGET << 16); in DEF_SCSI_QCMD()
1810 scp->result = (DID_ERROR << 16); in DEF_SCSI_QCMD()
1815 ccb = (mbox_ccb_t *)scb->ccb; in DEF_SCSI_QCMD()
1816 scb->dev_channel = channel; in DEF_SCSI_QCMD()
1817 scb->dev_target = target; in DEF_SCSI_QCMD()
1818 scb->dma_direction = scp->sc_data_direction; in DEF_SCSI_QCMD()
1819 mbox = ccb->mbox; in DEF_SCSI_QCMD()
1820 mbox64 = ccb->mbox64; in DEF_SCSI_QCMD()
1823 if (adapter->max_cdb_sz == 16) { in DEF_SCSI_QCMD()
1824 mbox->cmd = MBOXCMD_EXTPTHRU; in DEF_SCSI_QCMD()
1828 mbox64->xferaddr_lo = (uint32_t)ccb->epthru_dma_h; in DEF_SCSI_QCMD()
1829 mbox64->xferaddr_hi = 0; in DEF_SCSI_QCMD()
1830 mbox->xferaddr = 0xFFFFFFFF; in DEF_SCSI_QCMD()
1833 mbox->cmd = MBOXCMD_PASSTHRU64; in DEF_SCSI_QCMD()
1837 mbox64->xferaddr_lo = (uint32_t)ccb->pthru_dma_h; in DEF_SCSI_QCMD()
1838 mbox64->xferaddr_hi = 0; in DEF_SCSI_QCMD()
1839 mbox->xferaddr = 0xFFFFFFFF; in DEF_SCSI_QCMD()
1849 * megaraid_mbox_runpendq - execute commands queued in the pending queue
1870 scb_q->state = SCB_PENDQ; in megaraid_mbox_runpendq()
1871 list_add_tail(&scb_q->list, &adapter->pend_list); in megaraid_mbox_runpendq()
1875 if (adapter->quiescent) { in megaraid_mbox_runpendq()
1880 while (!list_empty(&adapter->pend_list)) { in megaraid_mbox_runpendq()
1884 scb = list_entry(adapter->pend_list.next, scb_t, list); in megaraid_mbox_runpendq()
1890 list_del_init(&scb->list); in megaraid_mbox_runpendq()
1898 scb->state = SCB_ISSUED; in megaraid_mbox_runpendq()
1904 scb->state = SCB_PENDQ; in megaraid_mbox_runpendq()
1906 list_add(&scb->list, &adapter->pend_list); in megaraid_mbox_runpendq()
1925 * megaraid_mbox_prepare_pthru - prepare a command for physical devices
1928 * @scp : scsi command from the mid-layer
1941 ccb = (mbox_ccb_t *)scb->ccb; in megaraid_mbox_prepare_pthru()
1942 pthru = ccb->pthru; in megaraid_mbox_prepare_pthru()
1943 channel = scb->dev_channel; in megaraid_mbox_prepare_pthru()
1944 target = scb->dev_target; in megaraid_mbox_prepare_pthru()
1947 pthru->timeout = 4; in megaraid_mbox_prepare_pthru()
1948 pthru->ars = 1; in megaraid_mbox_prepare_pthru()
1949 pthru->islogical = 0; in megaraid_mbox_prepare_pthru()
1950 pthru->channel = 0; in megaraid_mbox_prepare_pthru()
1951 pthru->target = (channel << 4) | target; in megaraid_mbox_prepare_pthru()
1952 pthru->logdrv = SCP2LUN(scp); in megaraid_mbox_prepare_pthru()
1953 pthru->reqsenselen = 14; in megaraid_mbox_prepare_pthru()
1954 pthru->cdblen = scp->cmd_len; in megaraid_mbox_prepare_pthru()
1956 memcpy(pthru->cdb, scp->cmnd, scp->cmd_len); in megaraid_mbox_prepare_pthru()
1959 pthru->dataxferlen = scsi_bufflen(scp); in megaraid_mbox_prepare_pthru()
1960 pthru->dataxferaddr = ccb->sgl_dma_h; in megaraid_mbox_prepare_pthru()
1961 pthru->numsge = megaraid_mbox_mksgl(adapter, scb); in megaraid_mbox_prepare_pthru()
1964 pthru->dataxferaddr = 0; in megaraid_mbox_prepare_pthru()
1965 pthru->dataxferlen = 0; in megaraid_mbox_prepare_pthru()
1966 pthru->numsge = 0; in megaraid_mbox_prepare_pthru()
1973 * megaraid_mbox_prepare_epthru - prepare a command for physical devices
1976 * @scp : scsi command from the mid-layer
1990 ccb = (mbox_ccb_t *)scb->ccb; in megaraid_mbox_prepare_epthru()
1991 epthru = ccb->epthru; in megaraid_mbox_prepare_epthru()
1992 channel = scb->dev_channel; in megaraid_mbox_prepare_epthru()
1993 target = scb->dev_target; in megaraid_mbox_prepare_epthru()
1996 epthru->timeout = 4; in megaraid_mbox_prepare_epthru()
1997 epthru->ars = 1; in megaraid_mbox_prepare_epthru()
1998 epthru->islogical = 0; in megaraid_mbox_prepare_epthru()
1999 epthru->channel = 0; in megaraid_mbox_prepare_epthru()
2000 epthru->target = (channel << 4) | target; in megaraid_mbox_prepare_epthru()
2001 epthru->logdrv = SCP2LUN(scp); in megaraid_mbox_prepare_epthru()
2002 epthru->reqsenselen = 14; in megaraid_mbox_prepare_epthru()
2003 epthru->cdblen = scp->cmd_len; in megaraid_mbox_prepare_epthru()
2005 memcpy(epthru->cdb, scp->cmnd, scp->cmd_len); in megaraid_mbox_prepare_epthru()
2008 epthru->dataxferlen = scsi_bufflen(scp); in megaraid_mbox_prepare_epthru()
2009 epthru->dataxferaddr = ccb->sgl_dma_h; in megaraid_mbox_prepare_epthru()
2010 epthru->numsge = megaraid_mbox_mksgl(adapter, scb); in megaraid_mbox_prepare_epthru()
2013 epthru->dataxferaddr = 0; in megaraid_mbox_prepare_epthru()
2014 epthru->dataxferlen = 0; in megaraid_mbox_prepare_epthru()
2015 epthru->numsge = 0; in megaraid_mbox_prepare_epthru()
2022 * megaraid_ack_sequence - interrupt ack sequence for memory mapped HBAs
2045 mbox = raid_dev->mbox; in megaraid_ack_sequence()
2068 if (mbox->numstatus != 0xFF) { in megaraid_ack_sequence()
2069 nstatus = mbox->numstatus; in megaraid_ack_sequence()
2074 mbox->numstatus = 0xFF; in megaraid_ack_sequence()
2076 adapter->outstanding_cmds -= nstatus; in megaraid_ack_sequence()
2082 if (mbox->completed[i] != 0xFF) break; in megaraid_ack_sequence()
2085 completed[i] = mbox->completed[i]; in megaraid_ack_sequence()
2086 mbox->completed[i] = 0xFF; in megaraid_ack_sequence()
2099 scb = adapter->uscb_list + (completed[i] - in megaraid_ack_sequence()
2104 scb = adapter->kscb_list + completed[i]; in megaraid_ack_sequence()
2107 scb->status = mbox->status; in megaraid_ack_sequence()
2108 list_add_tail(&scb->list, &clist); in megaraid_ack_sequence()
2123 list_splice(&clist, &adapter->completed_list); in megaraid_ack_sequence()
2130 tasklet_schedule(&adapter->dpc_h); in megaraid_ack_sequence()
2137 * megaraid_isr - isr for memory based mailbox based controllers
2141 * Interrupt service routine for memory-mapped mailbox controllers.
2152 if (!adapter->quiescent) { in megaraid_isr()
2161 * megaraid_mbox_dpc - the tasklet to complete the commands from completed list
2200 list_splice_init(&adapter->completed_list, &clist); in megaraid_mbox_dpc()
2207 status = scb->status; in megaraid_mbox_dpc()
2208 scp = scb->scp; in megaraid_mbox_dpc()
2209 ccb = (mbox_ccb_t *)scb->ccb; in megaraid_mbox_dpc()
2210 pthru = ccb->pthru; in megaraid_mbox_dpc()
2211 epthru = ccb->epthru; in megaraid_mbox_dpc()
2212 mbox = ccb->mbox; in megaraid_mbox_dpc()
2215 if (scb->state != SCB_ISSUED) { in megaraid_mbox_dpc()
2218 scb->sno, scb->state, scp)); in megaraid_mbox_dpc()
2224 if (scb->sno >= MBOX_MAX_SCSI_CMDS) { in megaraid_mbox_dpc()
2225 scb->state = SCB_FREE; in megaraid_mbox_dpc()
2226 scb->status = status; in megaraid_mbox_dpc()
2229 list_del_init(&scb->list); in megaraid_mbox_dpc()
2231 kioc = (uioc_t *)scb->gp; in megaraid_mbox_dpc()
2232 kioc->status = 0; in megaraid_mbox_dpc()
2240 if (scb->state & SCB_ABORT) { in megaraid_mbox_dpc()
2243 scb->sno)); in megaraid_mbox_dpc()
2255 if (scp->cmnd[0] == INQUIRY && status == 0 && islogical == 0 in megaraid_mbox_dpc()
2256 && IS_RAID_CH(raid_dev, scb->dev_channel)) { in megaraid_mbox_dpc()
2269 pdev_index = (scb->dev_channel * 16) + in megaraid_mbox_dpc()
2270 scb->dev_target; in megaraid_mbox_dpc()
2272 raid_dev->pdrv_state[pdev_index] & 0x0F; in megaraid_mbox_dpc()
2290 scp->result = (DID_OK << 16); in megaraid_mbox_dpc()
2296 if (mbox->cmd == MBOXCMD_PASSTHRU || in megaraid_mbox_dpc()
2297 mbox->cmd == MBOXCMD_PASSTHRU64) { in megaraid_mbox_dpc()
2299 memcpy(scp->sense_buffer, pthru->reqsensearea, in megaraid_mbox_dpc()
2302 scp->result = SAM_STAT_CHECK_CONDITION; in megaraid_mbox_dpc()
2305 if (mbox->cmd == MBOXCMD_EXTPTHRU) { in megaraid_mbox_dpc()
2307 memcpy(scp->sense_buffer, in megaraid_mbox_dpc()
2308 epthru->reqsensearea, 14); in megaraid_mbox_dpc()
2310 scp->result = SAM_STAT_CHECK_CONDITION; in megaraid_mbox_dpc()
2319 scp->result = DID_BUS_BUSY << 16 | status; in megaraid_mbox_dpc()
2328 if (scp->cmnd[0] == TEST_UNIT_READY) { in megaraid_mbox_dpc()
2329 scp->result = DID_ERROR << 16 | in megaraid_mbox_dpc()
2337 if (status == 1 && (scp->cmnd[0] == RESERVE || in megaraid_mbox_dpc()
2338 scp->cmnd[0] == RELEASE)) { in megaraid_mbox_dpc()
2340 scp->result = DID_ERROR << 16 | in megaraid_mbox_dpc()
2344 scp->result = DID_BAD_TARGET << 16 | status; in megaraid_mbox_dpc()
2356 list_del_init(&scb->list); in megaraid_mbox_dpc()
2370 * megaraid_abort_handler - abort the scsi command
2393 scp->cmnd[0], SCP2CHANNEL(scp), in megaraid_abort_handler()
2397 if (raid_dev->hw_error) { in megaraid_abort_handler()
2409 list_for_each_entry_safe(scb, tmp, &adapter->completed_list, list) { in megaraid_abort_handler()
2411 if (scb->scp == scp) { // Found command in megaraid_abort_handler()
2413 list_del_init(&scb->list); // from completed list in megaraid_abort_handler()
2417 scb->sno, scb->dev_channel, scb->dev_target)); in megaraid_abort_handler()
2419 scp->result = (DID_ABORT << 16); in megaraid_abort_handler()
2437 list_for_each_entry_safe(scb, tmp, &adapter->pend_list, list) { in megaraid_abort_handler()
2439 if (scb->scp == scp) { // Found command in megaraid_abort_handler()
2441 list_del_init(&scb->list); // from pending list in megaraid_abort_handler()
2443 ASSERT(!(scb->state & SCB_ISSUED)); in megaraid_abort_handler()
2447 scb->dev_channel, scb->dev_target)); in megaraid_abort_handler()
2449 scp->result = (DID_ABORT << 16); in megaraid_abort_handler()
2468 spin_lock_irq(&adapter->lock); in megaraid_abort_handler()
2470 scb = adapter->kscb_list + i; in megaraid_abort_handler()
2472 if (scb->scp == scp) { in megaraid_abort_handler()
2476 if (!(scb->state & SCB_ISSUED)) { in megaraid_abort_handler()
2479 scb->sno, scb->dev_channel, scb->dev_target)); in megaraid_abort_handler()
2485 scb->sno, scb->dev_channel, scb->dev_target)); in megaraid_abort_handler()
2489 spin_unlock_irq(&adapter->lock); in megaraid_abort_handler()
2505 * megaraid_reset_handler - device reset handler for mailbox based driver
2532 if (raid_dev->hw_error) { in megaraid_reset_handler()
2544 list_for_each_entry_safe(scb, tmp, &adapter->pend_list, list) { in megaraid_reset_handler()
2545 list_del_init(&scb->list); // from pending list in megaraid_reset_handler()
2547 if (scb->sno >= MBOX_MAX_SCSI_CMDS) { in megaraid_reset_handler()
2550 scb->sno, scb->dev_channel, scb->dev_target)); in megaraid_reset_handler()
2552 scb->status = -1; in megaraid_reset_handler()
2554 kioc = (uioc_t *)scb->gp; in megaraid_reset_handler()
2555 kioc->status = -EFAULT; in megaraid_reset_handler()
2559 if (scb->scp == scp) { // Found command in megaraid_reset_handler()
2562 scb->sno, scb->dev_channel, scb->dev_target)); in megaraid_reset_handler()
2566 scb->sno, scb->dev_channel, scb->dev_target)); in megaraid_reset_handler()
2569 scb->scp->result = (DID_RESET << 16); in megaraid_reset_handler()
2570 scsi_done(scb->scp); in megaraid_reset_handler()
2577 if (adapter->outstanding_cmds) { in megaraid_reset_handler()
2580 adapter->outstanding_cmds, in megaraid_reset_handler()
2594 adapter->outstanding_cmds, in megaraid_reset_handler()
2595 (MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT) - i)); in megaraid_reset_handler()
2599 if (adapter->outstanding_cmds == 0) { in megaraid_reset_handler()
2606 spin_lock(&adapter->lock); in megaraid_reset_handler()
2609 if (adapter->outstanding_cmds) { in megaraid_reset_handler()
2613 raid_dev->hw_error = 1; in megaraid_reset_handler()
2625 if (!adapter->ha) { in megaraid_reset_handler()
2646 spin_unlock(&adapter->lock); in megaraid_reset_handler()
2658 * mbox_post_sync_cmd() - blocking command to the mailbox based controllers
2662 * Issue a scb in synchronous and non-interrupt mode for mailbox based
2673 mbox = raid_dev->mbox; in mbox_post_sync_cmd()
2685 mbox->cmdid = 0xFE; in mbox_post_sync_cmd()
2686 mbox->busy = 1; in mbox_post_sync_cmd()
2687 mbox->poll = 0; in mbox_post_sync_cmd()
2688 mbox->ack = 0; in mbox_post_sync_cmd()
2689 mbox->numstatus = 0xFF; in mbox_post_sync_cmd()
2690 mbox->status = 0xFF; in mbox_post_sync_cmd()
2693 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); in mbox_post_sync_cmd()
2698 if (mbox->numstatus == 0xFF) { // status not yet available in mbox_post_sync_cmd()
2701 for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) { in mbox_post_sync_cmd()
2711 for (i = 0; (mbox->numstatus == 0xFF) && in mbox_post_sync_cmd()
2715 MBOX_RESET_WAIT - i)); in mbox_post_sync_cmd()
2724 return -1; in mbox_post_sync_cmd()
2731 if (mbox->poll != 0x77) { in mbox_post_sync_cmd()
2734 for (i = 0; (mbox->poll != 0x77) && (i < 1000); i++) { in mbox_post_sync_cmd()
2742 return -1; in mbox_post_sync_cmd()
2746 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x2); in mbox_post_sync_cmd()
2761 return -1; in mbox_post_sync_cmd()
2764 mbox->poll = 0; in mbox_post_sync_cmd()
2765 mbox->ack = 0x77; in mbox_post_sync_cmd()
2767 status = mbox->status; in mbox_post_sync_cmd()
2771 mbox->numstatus = 0xFF; in mbox_post_sync_cmd()
2772 mbox->status = 0xFF; in mbox_post_sync_cmd()
2774 mbox->completed[i] = 0xFF; in mbox_post_sync_cmd()
2782 return -1; in mbox_post_sync_cmd()
2787 * mbox_post_sync_cmd_fast - blocking command to the mailbox based controllers
2791 * Issue a scb in synchronous and non-interrupt mode for mailbox based
2793 * therefore can be called in interrupt-context as well.
2803 mbox = raid_dev->mbox; in mbox_post_sync_cmd_fast()
2806 if (mbox->busy) return -1; in mbox_post_sync_cmd_fast()
2810 mbox->cmdid = 0xFE; in mbox_post_sync_cmd_fast()
2811 mbox->busy = 1; in mbox_post_sync_cmd_fast()
2812 mbox->poll = 0; in mbox_post_sync_cmd_fast()
2813 mbox->ack = 0; in mbox_post_sync_cmd_fast()
2814 mbox->numstatus = 0xFF; in mbox_post_sync_cmd_fast()
2815 mbox->status = 0xFF; in mbox_post_sync_cmd_fast()
2818 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); in mbox_post_sync_cmd_fast()
2821 if (mbox->numstatus != 0xFF) break; in mbox_post_sync_cmd_fast()
2827 // We may need to re-calibrate the counter in mbox_post_sync_cmd_fast()
2832 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x2); in mbox_post_sync_cmd_fast()
2835 return mbox->status; in mbox_post_sync_cmd_fast()
2840 * megaraid_busywait_mbox() - Wait until the controller's mailbox is available
2849 mbox_t *mbox = raid_dev->mbox; in megaraid_busywait_mbox()
2852 if (mbox->busy) { in megaraid_busywait_mbox()
2854 for (i = 0; mbox->busy && i < 1000; i++) in megaraid_busywait_mbox()
2859 else return -1; in megaraid_busywait_mbox()
2864 * megaraid_mbox_product_info - some static information about the controller
2889 pinfo = dma_alloc_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), in megaraid_mbox_product_info()
2896 return -1; in megaraid_mbox_product_info()
2899 mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h; in megaraid_mbox_product_info()
2900 memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE); in megaraid_mbox_product_info()
2911 dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), in megaraid_mbox_product_info()
2914 return -1; in megaraid_mbox_product_info()
2922 mraid_inq3 = (mraid_inquiry3_t *)adapter->ibuf; in megaraid_mbox_product_info()
2924 raid_dev->pdrv_state[i] = mraid_inq3->pdrv_state[i]; in megaraid_mbox_product_info()
2932 mbox->xferaddr = (uint32_t)pinfo_dma_h; in megaraid_mbox_product_info()
2942 dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), in megaraid_mbox_product_info()
2945 return -1; in megaraid_mbox_product_info()
2951 adapter->max_channel = pinfo->nchannels; in megaraid_mbox_product_info()
2957 adapter->max_target = MAX_LOGICAL_DRIVES_40LD + 1; in megaraid_mbox_product_info()
2958 adapter->max_lun = 8; // up to 8 LUNs for non-disk devices in megaraid_mbox_product_info()
2961 * These are the maximum outstanding commands for the scsi-layer in megaraid_mbox_product_info()
2963 adapter->max_cmds = MBOX_MAX_SCSI_CMDS; in megaraid_mbox_product_info()
2965 memset(adapter->fw_version, 0, VERSION_SIZE); in megaraid_mbox_product_info()
2966 memset(adapter->bios_version, 0, VERSION_SIZE); in megaraid_mbox_product_info()
2968 memcpy(adapter->fw_version, pinfo->fw_version, 4); in megaraid_mbox_product_info()
2969 adapter->fw_version[4] = 0; in megaraid_mbox_product_info()
2971 memcpy(adapter->bios_version, pinfo->bios_version, 4); in megaraid_mbox_product_info()
2972 adapter->bios_version[4] = 0; in megaraid_mbox_product_info()
2976 adapter->fw_version, adapter->bios_version)); in megaraid_mbox_product_info()
2978 dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, in megaraid_mbox_product_info()
2987 * megaraid_mbox_extended_cdb - check for support for extended CDBs
3003 mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h; in megaraid_mbox_extended_cdb()
3005 memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE); in megaraid_mbox_extended_cdb()
3015 rval = -1; in megaraid_mbox_extended_cdb()
3023 * megaraid_mbox_support_ha - Do we support clustering
3041 mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h; in megaraid_mbox_support_ha()
3043 memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE); in megaraid_mbox_support_ha()
3049 rval = -1; in megaraid_mbox_support_ha()
3052 *init_id = *(uint8_t *)adapter->ibuf; in megaraid_mbox_support_ha()
3066 * megaraid_mbox_support_random_del - Do we support random deletion
3082 if (adapter->pdev->vendor == PCI_VENDOR_ID_AMI && in megaraid_mbox_support_random_del()
3083 adapter->pdev->device == PCI_DEVICE_ID_AMI_MEGARAID3 && in megaraid_mbox_support_random_del()
3084 adapter->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL && in megaraid_mbox_support_random_del()
3085 adapter->pdev->subsystem_device == PCI_SUBSYS_ID_CERC_ATA100_4CH && in megaraid_mbox_support_random_del()
3086 (adapter->fw_version[0] > '6' || in megaraid_mbox_support_random_del()
3087 (adapter->fw_version[0] == '6' && in megaraid_mbox_support_random_del()
3088 adapter->fw_version[2] > '6') || in megaraid_mbox_support_random_del()
3089 (adapter->fw_version[0] == '6' in megaraid_mbox_support_random_del()
3090 && adapter->fw_version[2] == '6' in megaraid_mbox_support_random_del()
3091 && adapter->fw_version[3] > '1'))) { in megaraid_mbox_support_random_del()
3115 * megaraid_mbox_get_max_sg - maximum sg elements supported by the firmware
3118 * Find out the maximum number of scatter-gather elements supported by the
3133 mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h; in megaraid_mbox_get_max_sg()
3135 memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE); in megaraid_mbox_get_max_sg()
3142 nsg = *(uint8_t *)adapter->ibuf; in megaraid_mbox_get_max_sg()
3155 * megaraid_mbox_enum_raid_scsi - enumerate the RAID and SCSI channels
3173 mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h; in megaraid_mbox_enum_raid_scsi()
3175 memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE); in megaraid_mbox_enum_raid_scsi()
3182 raid_dev->channel_class = 0xFF; in megaraid_mbox_enum_raid_scsi()
3184 raid_dev->channel_class = *(uint8_t *)adapter->ibuf; in megaraid_mbox_enum_raid_scsi()
3192 * megaraid_mbox_flush_cache - flush adapter and disks cache
3221 * megaraid_mbox_fire_sync_cmd - fire the sync cmd
3240 mbox = raid_dev->mbox; in megaraid_mbox_fire_sync_cmd()
3250 mbox->cmdid = 0xFE; in megaraid_mbox_fire_sync_cmd()
3251 mbox->busy = 1; in megaraid_mbox_fire_sync_cmd()
3252 mbox->poll = 0; in megaraid_mbox_fire_sync_cmd()
3253 mbox->ack = 0; in megaraid_mbox_fire_sync_cmd()
3254 mbox->numstatus = 0; in megaraid_mbox_fire_sync_cmd()
3255 mbox->status = 0; in megaraid_mbox_fire_sync_cmd()
3258 WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); in megaraid_mbox_fire_sync_cmd()
3262 * mbox->cmd will be set to 0 in megaraid_mbox_fire_sync_cmd()
3265 * mbox->numstatus set to 1 in megaraid_mbox_fire_sync_cmd()
3270 while (!mbox->numstatus && mbox->cmd == 0xFF) { in megaraid_mbox_fire_sync_cmd()
3279 if (mbox->numstatus == 1) in megaraid_mbox_fire_sync_cmd()
3295 * megaraid_mbox_display_scb - display SCB information, mostly debug purposes
3312 ccb = (mbox_ccb_t *)scb->ccb; in megaraid_mbox_display_scb()
3313 scp = scb->scp; in megaraid_mbox_display_scb()
3314 mbox = ccb->mbox; in megaraid_mbox_display_scb()
3319 "megaraid mailbox: status:%#x cmd:%#x id:%#x ", scb->status, in megaraid_mbox_display_scb()
3320 mbox->cmd, scb->sno)); in megaraid_mbox_display_scb()
3323 mbox->numsectors, mbox->lba, mbox->xferaddr, mbox->logdrv, in megaraid_mbox_display_scb()
3324 mbox->numsge)); in megaraid_mbox_display_scb()
3330 for (i = 0; i < scp->cmd_len; i++) { in megaraid_mbox_display_scb()
3331 con_log(level, ("%#2.02x ", scp->cmnd[i])); in megaraid_mbox_display_scb()
3341 * megaraid_mbox_setup_device_map - manage device ids
3359 adapter->device_ids[adapter->max_channel][t] = in megaraid_mbox_setup_device_map()
3360 (t < adapter->init_id) ? t : t - 1; in megaraid_mbox_setup_device_map()
3362 adapter->device_ids[adapter->max_channel][adapter->init_id] = 0xFF; in megaraid_mbox_setup_device_map()
3367 for (c = 0; c < adapter->max_channel; c++) in megaraid_mbox_setup_device_map()
3369 adapter->device_ids[c][t] = (c << 8) | t; in megaraid_mbox_setup_device_map()
3385 * megaraid_cmm_register - register with the management module
3403 adapter->uscb_list = kcalloc(MBOX_MAX_USER_CMDS, sizeof(scb_t), GFP_KERNEL); in megaraid_cmm_register()
3405 if (adapter->uscb_list == NULL) { in megaraid_cmm_register()
3409 return -1; in megaraid_cmm_register()
3415 INIT_LIST_HEAD(&adapter->uscb_pool); in megaraid_cmm_register()
3427 scb = adapter->uscb_list + i; in megaraid_cmm_register()
3428 ccb = raid_dev->uccb_list + i; in megaraid_cmm_register()
3430 scb->ccb = (caddr_t)ccb; in megaraid_cmm_register()
3431 ccb->mbox64 = raid_dev->umbox64 + i; in megaraid_cmm_register()
3432 ccb->mbox = &ccb->mbox64->mbox32; in megaraid_cmm_register()
3433 ccb->raw_mbox = (uint8_t *)ccb->mbox; in megaraid_cmm_register()
3435 scb->gp = 0; in megaraid_cmm_register()
3437 // COMMAND ID 0 - (MBOX_MAX_SCSI_CMDS-1) ARE RESERVED FOR in megaraid_cmm_register()
3438 // COMMANDS COMING FROM IO SUBSYSTEM (MID-LAYER) in megaraid_cmm_register()
3439 scb->sno = i + MBOX_MAX_SCSI_CMDS; in megaraid_cmm_register()
3441 scb->scp = NULL; in megaraid_cmm_register()
3442 scb->state = SCB_FREE; in megaraid_cmm_register()
3443 scb->dma_direction = DMA_NONE; in megaraid_cmm_register()
3444 scb->dma_type = MRAID_DMA_NONE; in megaraid_cmm_register()
3445 scb->dev_channel = -1; in megaraid_cmm_register()
3446 scb->dev_target = -1; in megaraid_cmm_register()
3449 list_add_tail(&scb->list, &adapter->uscb_pool); in megaraid_cmm_register()
3452 adp.unique_id = adapter->unique_id; in megaraid_cmm_register()
3455 adp.pdev = adapter->pdev; in megaraid_cmm_register()
3465 kfree(adapter->uscb_list); in megaraid_cmm_register()
3473 * megaraid_cmm_unregister - un-register with the management module
3476 * Un-register with the management module.
3477 * FIXME: mgmt module must return failure for unregister if it has pending
3483 kfree(adapter->uscb_list); in megaraid_cmm_unregister()
3484 mraid_mm_unregister_adp(adapter->unique_id); in megaraid_cmm_unregister()
3490 * megaraid_mbox_mm_handler - interface for CMM to issue commands to LLD
3508 return (-ENOTSUPP); in megaraid_mbox_mm_handler()
3514 if (atomic_read(&adapter->being_detached)) { in megaraid_mbox_mm_handler()
3517 return (-ENODEV); in megaraid_mbox_mm_handler()
3520 switch (kioc->opcode) { in megaraid_mbox_mm_handler()
3524 kioc->status = gather_hbainfo(adapter, (mraid_hba_info_t *) in megaraid_mbox_mm_handler()
3525 (unsigned long)kioc->buf_vaddr); in megaraid_mbox_mm_handler()
3527 kioc->done(kioc); in megaraid_mbox_mm_handler()
3529 return kioc->status; in megaraid_mbox_mm_handler()
3536 kioc->status = (-EINVAL); in megaraid_mbox_mm_handler()
3537 kioc->done(kioc); in megaraid_mbox_mm_handler()
3538 return (-EINVAL); in megaraid_mbox_mm_handler()
3545 * megaraid_mbox_mm_command - issues commands routed through CMM
3554 struct list_head *head = &adapter->uscb_pool; in megaraid_mbox_mm_command()
3571 return (-EINVAL); in megaraid_mbox_mm_command()
3574 scb = list_entry(head->next, scb_t, list); in megaraid_mbox_mm_command()
3575 list_del_init(&scb->list); in megaraid_mbox_mm_command()
3579 scb->state = SCB_ACTIVE; in megaraid_mbox_mm_command()
3580 scb->dma_type = MRAID_DMA_NONE; in megaraid_mbox_mm_command()
3581 scb->dma_direction = DMA_NONE; in megaraid_mbox_mm_command()
3583 ccb = (mbox_ccb_t *)scb->ccb; in megaraid_mbox_mm_command()
3584 mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf; in megaraid_mbox_mm_command()
3585 raw_mbox = (uint8_t *)&mbox64->mbox32; in megaraid_mbox_mm_command()
3587 memcpy(ccb->mbox64, mbox64, sizeof(mbox64_t)); in megaraid_mbox_mm_command()
3589 scb->gp = (unsigned long)kioc; in megaraid_mbox_mm_command()
3601 kioc->status = -ETIME; in megaraid_mbox_mm_command()
3603 scb->status = -1; in megaraid_mbox_mm_command()
3607 return (-ETIME); in megaraid_mbox_mm_command()
3610 INIT_LIST_HEAD(&scb->list); in megaraid_mbox_mm_command()
3612 scb->state = SCB_ISSUED; in megaraid_mbox_mm_command()
3618 kioc->status = -EBUSY; in megaraid_mbox_mm_command()
3620 scb->status = -1; in megaraid_mbox_mm_command()
3624 return (-EBUSY); in megaraid_mbox_mm_command()
3647 spin_lock_irqsave(&adapter->lock, flags); in wait_till_fw_empty()
3648 adapter->quiescent++; in wait_till_fw_empty()
3649 spin_unlock_irqrestore(&adapter->lock, flags); in wait_till_fw_empty()
3655 for (i = 0; i < 60 && adapter->outstanding_cmds; i++) { in wait_till_fw_empty()
3658 adapter->outstanding_cmds)); in wait_till_fw_empty()
3663 return adapter->outstanding_cmds; in wait_till_fw_empty()
3668 * megaraid_mbox_mm_done - callback for CMM commands
3683 kioc = (uioc_t *)scb->gp; in megaraid_mbox_mm_done()
3684 mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf; in megaraid_mbox_mm_done()
3685 mbox64->mbox32.status = scb->status; in megaraid_mbox_mm_done()
3686 raw_mbox = (uint8_t *)&mbox64->mbox32; in megaraid_mbox_mm_done()
3690 scb->state = SCB_FREE; in megaraid_mbox_mm_done()
3691 scb->scp = NULL; in megaraid_mbox_mm_done()
3695 list_add(&scb->list, &adapter->uscb_pool); in megaraid_mbox_mm_done()
3703 adapter->quiescent--; in megaraid_mbox_mm_done()
3708 kioc->done(kioc); in megaraid_mbox_mm_done()
3715 * gather_hbainfo - HBA characteristics for the applications
3722 hinfo->pci_vendor_id = adapter->pdev->vendor; in gather_hbainfo()
3723 hinfo->pci_device_id = adapter->pdev->device; in gather_hbainfo()
3724 hinfo->subsys_vendor_id = adapter->pdev->subsystem_vendor; in gather_hbainfo()
3725 hinfo->subsys_device_id = adapter->pdev->subsystem_device; in gather_hbainfo()
3727 hinfo->pci_bus = adapter->pdev->bus->number; in gather_hbainfo()
3728 hinfo->pci_dev_fn = adapter->pdev->devfn; in gather_hbainfo()
3729 hinfo->pci_slot = PCI_SLOT(adapter->pdev->devfn); in gather_hbainfo()
3730 hinfo->irq = adapter->host->irq; in gather_hbainfo()
3731 hinfo->baseport = ADAP2RAIDDEV(adapter)->baseport; in gather_hbainfo()
3733 hinfo->unique_id = (hinfo->pci_bus << 8) | adapter->pdev->devfn; in gather_hbainfo()
3734 hinfo->host_no = adapter->host->host_no; in gather_hbainfo()
3746 * megaraid_sysfs_alloc_resources - allocate sysfs related resources
3750 * are read. These attributes would require up-to-date information from the
3755 * Return -ERROR_CODE on failure.
3763 raid_dev->sysfs_uioc = kmalloc(sizeof(uioc_t), GFP_KERNEL); in megaraid_sysfs_alloc_resources()
3765 raid_dev->sysfs_mbox64 = kmalloc(sizeof(mbox64_t), GFP_KERNEL); in megaraid_sysfs_alloc_resources()
3767 raid_dev->sysfs_buffer = dma_alloc_coherent(&adapter->pdev->dev, in megaraid_sysfs_alloc_resources()
3768 PAGE_SIZE, &raid_dev->sysfs_buffer_dma, GFP_KERNEL); in megaraid_sysfs_alloc_resources()
3770 if (!raid_dev->sysfs_uioc || !raid_dev->sysfs_mbox64 || in megaraid_sysfs_alloc_resources()
3771 !raid_dev->sysfs_buffer) { in megaraid_sysfs_alloc_resources()
3777 rval = -ENOMEM; in megaraid_sysfs_alloc_resources()
3782 mutex_init(&raid_dev->sysfs_mtx); in megaraid_sysfs_alloc_resources()
3784 init_waitqueue_head(&raid_dev->sysfs_wait_q); in megaraid_sysfs_alloc_resources()
3791 * megaraid_sysfs_free_resources - free sysfs related resources
3801 kfree(raid_dev->sysfs_uioc); in megaraid_sysfs_free_resources()
3802 kfree(raid_dev->sysfs_mbox64); in megaraid_sysfs_free_resources()
3804 if (raid_dev->sysfs_buffer) { in megaraid_sysfs_free_resources()
3805 dma_free_coherent(&adapter->pdev->dev, PAGE_SIZE, in megaraid_sysfs_free_resources()
3806 raid_dev->sysfs_buffer, raid_dev->sysfs_buffer_dma); in megaraid_sysfs_free_resources()
3812 * megaraid_sysfs_get_ldmap_done - callback for get ldmap
3820 adapter_t *adapter = (adapter_t *)uioc->buf_vaddr; in megaraid_sysfs_get_ldmap_done()
3823 uioc->status = 0; in megaraid_sysfs_get_ldmap_done()
3825 wake_up(&raid_dev->sysfs_wait_q); in megaraid_sysfs_get_ldmap_done()
3829 * megaraid_sysfs_get_ldmap_timeout - timeout handling for get ldmap
3840 uioc_t *uioc = timeout->uioc; in megaraid_sysfs_get_ldmap_timeout()
3841 adapter_t *adapter = (adapter_t *)uioc->buf_vaddr; in megaraid_sysfs_get_ldmap_timeout()
3844 uioc->status = -ETIME; in megaraid_sysfs_get_ldmap_timeout()
3846 wake_up(&raid_dev->sysfs_wait_q); in megaraid_sysfs_get_ldmap_timeout()
3851 * megaraid_sysfs_get_ldmap - get update logical drive map
3865 * Return -1 on failure.
3882 mutex_lock(&raid_dev->sysfs_mtx); in megaraid_sysfs_get_ldmap()
3884 uioc = raid_dev->sysfs_uioc; in megaraid_sysfs_get_ldmap()
3885 mbox64 = raid_dev->sysfs_mbox64; in megaraid_sysfs_get_ldmap()
3886 ldmap = raid_dev->sysfs_buffer; in megaraid_sysfs_get_ldmap()
3890 memset(ldmap, 0, sizeof(raid_dev->curr_ldmap)); in megaraid_sysfs_get_ldmap()
3892 mbox = &mbox64->mbox32; in megaraid_sysfs_get_ldmap()
3894 uioc->cmdbuf = (uint64_t)(unsigned long)mbox64; in megaraid_sysfs_get_ldmap()
3895 uioc->buf_vaddr = (caddr_t)adapter; in megaraid_sysfs_get_ldmap()
3896 uioc->status = -ENODATA; in megaraid_sysfs_get_ldmap()
3897 uioc->done = megaraid_sysfs_get_ldmap_done; in megaraid_sysfs_get_ldmap()
3903 mbox->xferaddr = (uint32_t)raid_dev->sysfs_buffer_dma; in megaraid_sysfs_get_ldmap()
3909 * Setup a timer to recover from a non-responding controller in megaraid_sysfs_get_ldmap()
3924 wait_event(raid_dev->sysfs_wait_q, (uioc->status != -ENODATA)); in megaraid_sysfs_get_ldmap()
3929 if (uioc->status == -ETIME) { in megaraid_sysfs_get_ldmap()
3933 rval = -ETIME; in megaraid_sysfs_get_ldmap()
3936 rval = mbox->status; in megaraid_sysfs_get_ldmap()
3940 memcpy(raid_dev->curr_ldmap, ldmap, in megaraid_sysfs_get_ldmap()
3941 sizeof(raid_dev->curr_ldmap)); in megaraid_sysfs_get_ldmap()
3957 mutex_unlock(&raid_dev->sysfs_mtx); in megaraid_sysfs_get_ldmap()
3964 * megaraid_mbox_app_hndl_show - display application handle for this adapter
3980 app_hndl = mraid_mm_adapter_app_handle(adapter->unique_id); in megaraid_mbox_app_hndl_show()
3987 * megaraid_mbox_ld_show - display the logical drive number for this device
3993 * logical drive. For physical devices, "-1" is returned.
3997 * <SCSI ID> <LD NUM> <LD STICKY ID> <APP ADAPTER HANDLE>
4005 adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(sdev->host); in megaraid_mbox_ld_show()
4007 int scsi_id = -1; in megaraid_mbox_ld_show()
4008 int logical_drv = -1; in megaraid_mbox_ld_show()
4009 int ldid_map = -1; in megaraid_mbox_ld_show()
4015 if (raid_dev->random_del_supported && in megaraid_mbox_ld_show()
4023 mapped_sdev_id = sdev->id; in megaraid_mbox_ld_show()
4025 if (sdev->id > adapter->init_id) { in megaraid_mbox_ld_show()
4026 mapped_sdev_id -= 1; in megaraid_mbox_ld_show()
4029 if (raid_dev->curr_ldmap[i] == mapped_sdev_id) { in megaraid_mbox_ld_show()
4031 scsi_id = sdev->id; in megaraid_mbox_ld_show()
4035 ldid_map = raid_dev->curr_ldmap[i]; in megaraid_mbox_ld_show()
4038 adapter->unique_id); in megaraid_mbox_ld_show()