diff options
Diffstat (limited to 'drivers/scsi/megaraid')
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mbox.c | 117 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mbox.h | 2 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_base.c | 153 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas_fusion.c | 16 |
4 files changed, 115 insertions, 173 deletions
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 530358cdcb39..3b7abe5ca7f5 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -202,13 +202,6 @@ module_param_named(debug_level, mraid_debug_level, int, 0); MODULE_PARM_DESC(debug_level, "Debug level for driver (default=0)"); /* - * ### global data ### - */ -static uint8_t megaraid_mbox_version[8] = - { 0x02, 0x20, 0x04, 0x06, 3, 7, 20, 5 }; - - -/* * PCI table for all supported controllers. */ static struct pci_device_id pci_id_table_g[] = { @@ -457,10 +450,9 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) // Setup the default DMA mask. This would be changed later on // depending on hardware capabilities - if (pci_set_dma_mask(adapter->pdev, DMA_BIT_MASK(32)) != 0) { - + if (dma_set_mask(&adapter->pdev->dev, DMA_BIT_MASK(32))) { con_log(CL_ANN, (KERN_WARNING - "megaraid: pci_set_dma_mask failed:%d\n", __LINE__)); + "megaraid: dma_set_mask failed:%d\n", __LINE__)); goto out_free_adapter; } @@ -484,7 +476,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) // Start the mailbox based controller if (megaraid_init_mbox(adapter) != 0) { con_log(CL_ANN, (KERN_WARNING - "megaraid: maibox adapter did not initialize\n")); + "megaraid: mailbox adapter did not initialize\n")); goto out_free_adapter; } @@ -878,11 +870,12 @@ megaraid_init_mbox(adapter_t *adapter) adapter->pdev->device == PCI_DEVICE_ID_PERC4_DI_EVERGLADES) || (adapter->pdev->vendor == PCI_VENDOR_ID_DELL && adapter->pdev->device == PCI_DEVICE_ID_PERC4E_DI_KOBUK)) { - if (pci_set_dma_mask(adapter->pdev, DMA_BIT_MASK(64))) { + if (dma_set_mask(&adapter->pdev->dev, DMA_BIT_MASK(64))) { con_log(CL_ANN, (KERN_WARNING "megaraid: DMA mask for 64-bit failed\n")); - if (pci_set_dma_mask (adapter->pdev, DMA_BIT_MASK(32))) { + if (dma_set_mask(&adapter->pdev->dev, + DMA_BIT_MASK(32))) { con_log(CL_ANN, (KERN_WARNING "megaraid: 32-bit DMA mask failed\n")); goto out_free_sysfs_res; @@ -950,7 +943,7 @@ megaraid_fini_mbox(adapter_t *adapter) * megaraid_alloc_cmd_packets - allocate shared mailbox * @adapter : soft state of the raid controller * - * Allocate and align the shared mailbox. This maibox is used to issue + * Allocate and align the shared mailbox. This mailbox is used to issue * all the commands. For IO based controllers, the mailbox is also registered * with the FW. Allocate memory for all commands as well. * This is our big allocator. @@ -975,9 +968,9 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) * Allocate the common 16-byte aligned memory for the handshake * mailbox. */ - raid_dev->una_mbox64 = pci_zalloc_consistent(adapter->pdev, - sizeof(mbox64_t), - &raid_dev->una_mbox64_dma); + raid_dev->una_mbox64 = dma_zalloc_coherent(&adapter->pdev->dev, + sizeof(mbox64_t), &raid_dev->una_mbox64_dma, + GFP_KERNEL); if (!raid_dev->una_mbox64) { con_log(CL_ANN, (KERN_WARNING @@ -1003,8 +996,8 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) align; // Allocate memory for commands issued internally - adapter->ibuf = pci_zalloc_consistent(pdev, MBOX_IBUF_SIZE, - &adapter->ibuf_dma_h); + adapter->ibuf = dma_zalloc_coherent(&pdev->dev, MBOX_IBUF_SIZE, + &adapter->ibuf_dma_h, GFP_KERNEL); if (!adapter->ibuf) { con_log(CL_ANN, (KERN_WARNING @@ -1082,7 +1075,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) scb->scp = NULL; scb->state = SCB_FREE; - scb->dma_direction = PCI_DMA_NONE; + scb->dma_direction = DMA_NONE; scb->dma_type = MRAID_DMA_NONE; scb->dev_channel = -1; scb->dev_target = -1; @@ -1098,10 +1091,10 @@ out_teardown_dma_pools: out_free_scb_list: kfree(adapter->kscb_list); out_free_ibuf: - pci_free_consistent(pdev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, + dma_free_coherent(&pdev->dev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, adapter->ibuf_dma_h); out_free_common_mbox: - pci_free_consistent(adapter->pdev, sizeof(mbox64_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mbox64_t), (caddr_t)raid_dev->una_mbox64, raid_dev->una_mbox64_dma); return -1; @@ -1123,10 +1116,10 @@ megaraid_free_cmd_packets(adapter_t *adapter) kfree(adapter->kscb_list); - pci_free_consistent(adapter->pdev, MBOX_IBUF_SIZE, + dma_free_coherent(&adapter->pdev->dev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, adapter->ibuf_dma_h); - pci_free_consistent(adapter->pdev, sizeof(mbox64_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mbox64_t), (caddr_t)raid_dev->una_mbox64, raid_dev->una_mbox64_dma); return; } @@ -1428,12 +1421,6 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb) adapter->outstanding_cmds++; - if (scb->dma_direction == PCI_DMA_TODEVICE) - pci_dma_sync_sg_for_device(adapter->pdev, - scsi_sglist(scb->scp), - scsi_sg_count(scb->scp), - PCI_DMA_TODEVICE); - mbox->busy = 1; // Set busy mbox->poll = 0; mbox->ack = 0; @@ -2181,31 +2168,6 @@ megaraid_isr(int irq, void *devp) /** - * megaraid_mbox_sync_scb - sync kernel buffers - * @adapter : controller's soft state - * @scb : pointer to the resource packet - * - * DMA sync if required. - */ -static void -megaraid_mbox_sync_scb(adapter_t *adapter, scb_t *scb) -{ - mbox_ccb_t *ccb; - - ccb = (mbox_ccb_t *)scb->ccb; - - if (scb->dma_direction == PCI_DMA_FROMDEVICE) - pci_dma_sync_sg_for_cpu(adapter->pdev, - scsi_sglist(scb->scp), - scsi_sg_count(scb->scp), - PCI_DMA_FROMDEVICE); - - scsi_dma_unmap(scb->scp); - return; -} - - -/** * megaraid_mbox_dpc - the tasklet to complete the commands from completed list * @devp : pointer to HBA soft state * @@ -2403,9 +2365,7 @@ megaraid_mbox_dpc(unsigned long devp) megaraid_mbox_display_scb(adapter, scb); } - // Free our internal resources and call the mid-layer callback - // routine - megaraid_mbox_sync_scb(adapter, scb); + scsi_dma_unmap(scp); // remove from local clist list_del_init(&scb->list); @@ -2577,7 +2537,6 @@ megaraid_reset_handler(struct scsi_cmnd *scp) uint8_t raw_mbox[sizeof(mbox_t)]; int rval; int recovery_window; - int recovering; int i; uioc_t *kioc; @@ -2591,7 +2550,6 @@ megaraid_reset_handler(struct scsi_cmnd *scp) return FAILED; } - // Under exceptional conditions, FW can take up to 3 minutes to // complete command processing. Wait for additional 2 minutes for the // pending commands counter to go down to 0. If it doesn't, let the @@ -2640,8 +2598,6 @@ megaraid_reset_handler(struct scsi_cmnd *scp) recovery_window = MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT; - recovering = adapter->outstanding_cmds; - for (i = 0; i < recovery_window; i++) { megaraid_ack_sequence(adapter); @@ -2725,13 +2681,10 @@ static int mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[]) { mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter); - mbox64_t *mbox64; mbox_t *mbox; uint8_t status; int i; - - mbox64 = raid_dev->mbox64; mbox = raid_dev->mbox; /* @@ -2948,9 +2901,8 @@ megaraid_mbox_product_info(adapter_t *adapter) * Issue an ENQUIRY3 command to find out certain adapter parameters, * e.g., max channels, max commands etc. */ - pinfo = pci_zalloc_consistent(adapter->pdev, sizeof(mraid_pinfo_t), - &pinfo_dma_h); - + pinfo = dma_zalloc_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), + &pinfo_dma_h, GFP_KERNEL); if (pinfo == NULL) { con_log(CL_ANN, (KERN_WARNING "megaraid: out of memory, %s %d\n", __func__, @@ -2971,7 +2923,7 @@ megaraid_mbox_product_info(adapter_t *adapter) con_log(CL_ANN, (KERN_WARNING "megaraid: Inquiry3 failed\n")); - pci_free_consistent(adapter->pdev, sizeof(mraid_pinfo_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, pinfo_dma_h); return -1; @@ -3002,7 +2954,7 @@ megaraid_mbox_product_info(adapter_t *adapter) con_log(CL_ANN, (KERN_WARNING "megaraid: product info failed\n")); - pci_free_consistent(adapter->pdev, sizeof(mraid_pinfo_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, pinfo_dma_h); return -1; @@ -3038,7 +2990,7 @@ megaraid_mbox_product_info(adapter_t *adapter) "megaraid: fw version:[%s] bios version:[%s]\n", adapter->fw_version, adapter->bios_version)); - pci_free_consistent(adapter->pdev, sizeof(mraid_pinfo_t), pinfo, + dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, pinfo_dma_h); return 0; @@ -3135,7 +3087,6 @@ megaraid_mbox_support_ha(adapter_t *adapter, uint16_t *init_id) static int megaraid_mbox_support_random_del(adapter_t *adapter) { - mbox_t *mbox; uint8_t raw_mbox[sizeof(mbox_t)]; int rval; @@ -3157,8 +3108,6 @@ megaraid_mbox_support_random_del(adapter_t *adapter) return 0; } - mbox = (mbox_t *)raw_mbox; - memset((caddr_t)raw_mbox, 0, sizeof(mbox_t)); raw_mbox[0] = FC_DEL_LOGDRV; @@ -3263,12 +3212,8 @@ megaraid_mbox_enum_raid_scsi(adapter_t *adapter) static void megaraid_mbox_flush_cache(adapter_t *adapter) { - mbox_t *mbox; uint8_t raw_mbox[sizeof(mbox_t)]; - - mbox = (mbox_t *)raw_mbox; - memset((caddr_t)raw_mbox, 0, sizeof(mbox_t)); raw_mbox[0] = FLUSH_ADAPTER; @@ -3299,7 +3244,6 @@ megaraid_mbox_fire_sync_cmd(adapter_t *adapter) mbox_t *mbox; uint8_t raw_mbox[sizeof(mbox_t)]; mraid_device_t *raid_dev = ADAP2RAIDDEV(adapter); - mbox64_t *mbox64; int status = 0; int i; uint32_t dword; @@ -3310,7 +3254,6 @@ megaraid_mbox_fire_sync_cmd(adapter_t *adapter) raw_mbox[0] = 0xFF; - mbox64 = raid_dev->mbox64; mbox = raid_dev->mbox; /* Wait until mailbox is free */ @@ -3515,7 +3458,7 @@ megaraid_cmm_register(adapter_t *adapter) scb->scp = NULL; scb->state = SCB_FREE; - scb->dma_direction = PCI_DMA_NONE; + scb->dma_direction = DMA_NONE; scb->dma_type = MRAID_DMA_NONE; scb->dev_channel = -1; scb->dev_target = -1; @@ -3653,7 +3596,7 @@ megaraid_mbox_mm_command(adapter_t *adapter, uioc_t *kioc) scb->state = SCB_ACTIVE; scb->dma_type = MRAID_DMA_NONE; - scb->dma_direction = PCI_DMA_NONE; + scb->dma_direction = DMA_NONE; ccb = (mbox_ccb_t *)scb->ccb; mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf; @@ -3794,10 +3737,6 @@ megaraid_mbox_mm_done(adapter_t *adapter, scb_t *scb) static int gather_hbainfo(adapter_t *adapter, mraid_hba_info_t *hinfo) { - uint8_t dmajor; - - dmajor = megaraid_mbox_version[0]; - hinfo->pci_vendor_id = adapter->pdev->vendor; hinfo->pci_device_id = adapter->pdev->device; hinfo->subsys_vendor_id = adapter->pdev->subsystem_vendor; @@ -3843,8 +3782,8 @@ megaraid_sysfs_alloc_resources(adapter_t *adapter) raid_dev->sysfs_mbox64 = kmalloc(sizeof(mbox64_t), GFP_KERNEL); - raid_dev->sysfs_buffer = pci_alloc_consistent(adapter->pdev, - PAGE_SIZE, &raid_dev->sysfs_buffer_dma); + raid_dev->sysfs_buffer = dma_alloc_coherent(&adapter->pdev->dev, + PAGE_SIZE, &raid_dev->sysfs_buffer_dma, GFP_KERNEL); if (!raid_dev->sysfs_uioc || !raid_dev->sysfs_mbox64 || !raid_dev->sysfs_buffer) { @@ -3881,7 +3820,7 @@ megaraid_sysfs_free_resources(adapter_t *adapter) kfree(raid_dev->sysfs_mbox64); if (raid_dev->sysfs_buffer) { - pci_free_consistent(adapter->pdev, PAGE_SIZE, + dma_free_coherent(&adapter->pdev->dev, PAGE_SIZE, raid_dev->sysfs_buffer, raid_dev->sysfs_buffer_dma); } } diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h index c1d86d961a92..e075aeb4012f 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.h +++ b/drivers/scsi/megaraid/megaraid_mbox.h @@ -117,7 +117,7 @@ * @raw_mbox : raw mailbox pointer * @mbox : mailbox * @mbox64 : extended mailbox - * @mbox_dma_h : maibox dma address + * @mbox_dma_h : mailbox dma address * @sgl64 : 64-bit scatter-gather list * @sgl32 : 32-bit scatter-gather list * @sgl_dma_h : dma handle for the scatter-gather list diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 9aa9590c5373..9b90c716f06d 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -1330,11 +1330,11 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, device_id = MEGASAS_DEV_INDEX(scp); pthru = (struct megasas_pthru_frame *)cmd->frame; - if (scp->sc_data_direction == PCI_DMA_TODEVICE) + if (scp->sc_data_direction == DMA_TO_DEVICE) flags = MFI_FRAME_DIR_WRITE; - else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) + else if (scp->sc_data_direction == DMA_FROM_DEVICE) flags = MFI_FRAME_DIR_READ; - else if (scp->sc_data_direction == PCI_DMA_NONE) + else if (scp->sc_data_direction == DMA_NONE) flags = MFI_FRAME_DIR_NONE; if (instance->flag_ieee == 1) { @@ -1428,9 +1428,9 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, device_id = MEGASAS_DEV_INDEX(scp); ldio = (struct megasas_io_frame *)cmd->frame; - if (scp->sc_data_direction == PCI_DMA_TODEVICE) + if (scp->sc_data_direction == DMA_TO_DEVICE) flags = MFI_FRAME_DIR_WRITE; - else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) + else if (scp->sc_data_direction == DMA_FROM_DEVICE) flags = MFI_FRAME_DIR_READ; if (instance->flag_ieee == 1) { @@ -2240,9 +2240,9 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, sizeof(struct MR_LD_VF_AFFILIATION_111)); else { new_affiliation_111 = - pci_zalloc_consistent(instance->pdev, + dma_zalloc_coherent(&instance->pdev->dev, sizeof(struct MR_LD_VF_AFFILIATION_111), - &new_affiliation_111_h); + &new_affiliation_111_h, GFP_KERNEL); if (!new_affiliation_111) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " "memory for new affiliation for scsi%d\n", @@ -2302,7 +2302,7 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, } out: if (new_affiliation_111) { - pci_free_consistent(instance->pdev, + dma_free_coherent(&instance->pdev->dev, sizeof(struct MR_LD_VF_AFFILIATION_111), new_affiliation_111, new_affiliation_111_h); @@ -2347,10 +2347,10 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, sizeof(struct MR_LD_VF_AFFILIATION)); else { new_affiliation = - pci_zalloc_consistent(instance->pdev, + dma_zalloc_coherent(&instance->pdev->dev, (MAX_LOGICAL_DRIVES + 1) * sizeof(struct MR_LD_VF_AFFILIATION), - &new_affiliation_h); + &new_affiliation_h, GFP_KERNEL); if (!new_affiliation) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " "memory for new affiliation for scsi%d\n", @@ -2470,7 +2470,7 @@ out: } if (new_affiliation) - pci_free_consistent(instance->pdev, + dma_free_coherent(&instance->pdev->dev, (MAX_LOGICAL_DRIVES + 1) * sizeof(struct MR_LD_VF_AFFILIATION), new_affiliation, new_affiliation_h); @@ -2513,9 +2513,9 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance, if (initial) { instance->hb_host_mem = - pci_zalloc_consistent(instance->pdev, + dma_zalloc_coherent(&instance->pdev->dev, sizeof(struct MR_CTRL_HB_HOST_MEM), - &instance->hb_host_mem_h); + &instance->hb_host_mem_h, GFP_KERNEL); if (!instance->hb_host_mem) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate" " memory for heartbeat host memory for scsi%d\n", @@ -4995,9 +4995,8 @@ megasas_init_adapter_mfi(struct megasas_instance *instance) context_sz = sizeof(u32); reply_q_sz = context_sz * (instance->max_fw_cmds + 1); - instance->reply_queue = pci_alloc_consistent(instance->pdev, - reply_q_sz, - &instance->reply_queue_h); + instance->reply_queue = dma_alloc_coherent(&instance->pdev->dev, + reply_q_sz, &instance->reply_queue_h, GFP_KERNEL); if (!instance->reply_queue) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "Out of DMA mem for reply queue\n"); @@ -5029,7 +5028,7 @@ megasas_init_adapter_mfi(struct megasas_instance *instance) fail_fw_init: - pci_free_consistent(instance->pdev, reply_q_sz, + dma_free_coherent(&instance->pdev->dev, reply_q_sz, instance->reply_queue, instance->reply_queue_h); fail_reply_queue: megasas_free_cmds(instance); @@ -5533,7 +5532,7 @@ static int megasas_init_fw(struct megasas_instance *instance) else { if (instance->crash_dump_buf) - pci_free_consistent(instance->pdev, + dma_free_coherent(&instance->pdev->dev, CRASH_DMA_BUF_SIZE, instance->crash_dump_buf, instance->crash_dump_h); @@ -5616,7 +5615,7 @@ static void megasas_release_mfi(struct megasas_instance *instance) u32 reply_q_sz = sizeof(u32) *(instance->max_mfi_cmds + 1); if (instance->reply_queue) - pci_free_consistent(instance->pdev, reply_q_sz, + dma_free_coherent(&instance->pdev->dev, reply_q_sz, instance->reply_queue, instance->reply_queue_h); megasas_free_cmds(instance); @@ -5655,10 +5654,9 @@ megasas_get_seq_num(struct megasas_instance *instance, } dcmd = &cmd->frame->dcmd; - el_info = pci_zalloc_consistent(instance->pdev, - sizeof(struct megasas_evt_log_info), - &el_info_h); - + el_info = dma_zalloc_coherent(&instance->pdev->dev, + sizeof(struct megasas_evt_log_info), &el_info_h, + GFP_KERNEL); if (!el_info) { megasas_return_cmd(instance, cmd); return -ENOMEM; @@ -5695,8 +5693,9 @@ megasas_get_seq_num(struct megasas_instance *instance, eli->boot_seq_num = el_info->boot_seq_num; dcmd_failed: - pci_free_consistent(instance->pdev, sizeof(struct megasas_evt_log_info), - el_info, el_info_h); + dma_free_coherent(&instance->pdev->dev, + sizeof(struct megasas_evt_log_info), + el_info, el_info_h); megasas_return_cmd(instance, cmd); @@ -6134,10 +6133,10 @@ static inline void megasas_set_adapter_type(struct megasas_instance *instance) static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance) { - instance->producer = pci_alloc_consistent(instance->pdev, sizeof(u32), - &instance->producer_h); - instance->consumer = pci_alloc_consistent(instance->pdev, sizeof(u32), - &instance->consumer_h); + instance->producer = dma_alloc_coherent(&instance->pdev->dev, + sizeof(u32), &instance->producer_h, GFP_KERNEL); + instance->consumer = dma_alloc_coherent(&instance->pdev->dev, + sizeof(u32), &instance->consumer_h, GFP_KERNEL); if (!instance->producer || !instance->consumer) { dev_err(&instance->pdev->dev, @@ -6199,11 +6198,11 @@ static inline void megasas_free_ctrl_mem(struct megasas_instance *instance) kfree(instance->reply_map); if (instance->adapter_type == MFI_SERIES) { if (instance->producer) - pci_free_consistent(instance->pdev, sizeof(u32), + dma_free_coherent(&instance->pdev->dev, sizeof(u32), instance->producer, instance->producer_h); if (instance->consumer) - pci_free_consistent(instance->pdev, sizeof(u32), + dma_free_coherent(&instance->pdev->dev, sizeof(u32), instance->consumer, instance->consumer_h); } else { @@ -6224,10 +6223,9 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) struct pci_dev *pdev = instance->pdev; struct fusion_context *fusion = instance->ctrl_context; - instance->evt_detail = - pci_alloc_consistent(pdev, - sizeof(struct megasas_evt_detail), - &instance->evt_detail_h); + instance->evt_detail = dma_alloc_coherent(&pdev->dev, + sizeof(struct megasas_evt_detail), + &instance->evt_detail_h, GFP_KERNEL); if (!instance->evt_detail) { dev_err(&instance->pdev->dev, @@ -6250,9 +6248,9 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) } instance->pd_list_buf = - pci_alloc_consistent(pdev, + dma_alloc_coherent(&pdev->dev, MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST), - &instance->pd_list_buf_h); + &instance->pd_list_buf_h, GFP_KERNEL); if (!instance->pd_list_buf) { dev_err(&pdev->dev, "Failed to allocate PD list buffer\n"); @@ -6260,9 +6258,9 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) } instance->ctrl_info_buf = - pci_alloc_consistent(pdev, + dma_alloc_coherent(&pdev->dev, sizeof(struct megasas_ctrl_info), - &instance->ctrl_info_buf_h); + &instance->ctrl_info_buf_h, GFP_KERNEL); if (!instance->ctrl_info_buf) { dev_err(&pdev->dev, @@ -6271,9 +6269,9 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) } instance->ld_list_buf = - pci_alloc_consistent(pdev, + dma_alloc_coherent(&pdev->dev, sizeof(struct MR_LD_LIST), - &instance->ld_list_buf_h); + &instance->ld_list_buf_h, GFP_KERNEL); if (!instance->ld_list_buf) { dev_err(&pdev->dev, "Failed to allocate LD list buffer\n"); @@ -6281,9 +6279,9 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) } instance->ld_targetid_list_buf = - pci_alloc_consistent(pdev, - sizeof(struct MR_LD_TARGETID_LIST), - &instance->ld_targetid_list_buf_h); + dma_alloc_coherent(&pdev->dev, + sizeof(struct MR_LD_TARGETID_LIST), + &instance->ld_targetid_list_buf_h, GFP_KERNEL); if (!instance->ld_targetid_list_buf) { dev_err(&pdev->dev, @@ -6293,21 +6291,20 @@ int megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance) if (!reset_devices) { instance->system_info_buf = - pci_alloc_consistent(pdev, - sizeof(struct MR_DRV_SYSTEM_INFO), - &instance->system_info_h); + dma_alloc_coherent(&pdev->dev, + sizeof(struct MR_DRV_SYSTEM_INFO), + &instance->system_info_h, GFP_KERNEL); instance->pd_info = - pci_alloc_consistent(pdev, - sizeof(struct MR_PD_INFO), - &instance->pd_info_h); + dma_alloc_coherent(&pdev->dev, + sizeof(struct MR_PD_INFO), + &instance->pd_info_h, GFP_KERNEL); instance->tgt_prop = - pci_alloc_consistent(pdev, - sizeof(struct MR_TARGET_PROPERTIES), - &instance->tgt_prop_h); + dma_alloc_coherent(&pdev->dev, + sizeof(struct MR_TARGET_PROPERTIES), + &instance->tgt_prop_h, GFP_KERNEL); instance->crash_dump_buf = - pci_alloc_consistent(pdev, - CRASH_DMA_BUF_SIZE, - &instance->crash_dump_h); + dma_alloc_coherent(&pdev->dev, CRASH_DMA_BUF_SIZE, + &instance->crash_dump_h, GFP_KERNEL); if (!instance->system_info_buf) dev_err(&instance->pdev->dev, @@ -6343,7 +6340,7 @@ void megasas_free_ctrl_dma_buffers(struct megasas_instance *instance) struct fusion_context *fusion = instance->ctrl_context; if (instance->evt_detail) - pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), + dma_free_coherent(&pdev->dev, sizeof(struct megasas_evt_detail), instance->evt_detail, instance->evt_detail_h); @@ -6354,41 +6351,41 @@ void megasas_free_ctrl_dma_buffers(struct megasas_instance *instance) fusion->ioc_init_request_phys); if (instance->pd_list_buf) - pci_free_consistent(pdev, + dma_free_coherent(&pdev->dev, MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST), instance->pd_list_buf, instance->pd_list_buf_h); if (instance->ld_list_buf) - pci_free_consistent(pdev, sizeof(struct MR_LD_LIST), + dma_free_coherent(&pdev->dev, sizeof(struct MR_LD_LIST), instance->ld_list_buf, instance->ld_list_buf_h); if (instance->ld_targetid_list_buf) - pci_free_consistent(pdev, sizeof(struct MR_LD_TARGETID_LIST), + dma_free_coherent(&pdev->dev, sizeof(struct MR_LD_TARGETID_LIST), instance->ld_targetid_list_buf, instance->ld_targetid_list_buf_h); if (instance->ctrl_info_buf) - pci_free_consistent(pdev, sizeof(struct megasas_ctrl_info), + dma_free_coherent(&pdev->dev, sizeof(struct megasas_ctrl_info), instance->ctrl_info_buf, instance->ctrl_info_buf_h); if (instance->system_info_buf) - pci_free_consistent(pdev, sizeof(struct MR_DRV_SYSTEM_INFO), + dma_free_coherent(&pdev->dev, sizeof(struct MR_DRV_SYSTEM_INFO), instance->system_info_buf, instance->system_info_h); if (instance->pd_info) - pci_free_consistent(pdev, sizeof(struct MR_PD_INFO), + dma_free_coherent(&pdev->dev, sizeof(struct MR_PD_INFO), instance->pd_info, instance->pd_info_h); if (instance->tgt_prop) - pci_free_consistent(pdev, sizeof(struct MR_TARGET_PROPERTIES), + dma_free_coherent(&pdev->dev, sizeof(struct MR_TARGET_PROPERTIES), instance->tgt_prop, instance->tgt_prop_h); if (instance->crash_dump_buf) - pci_free_consistent(pdev, CRASH_DMA_BUF_SIZE, + dma_free_coherent(&pdev->dev, CRASH_DMA_BUF_SIZE, instance->crash_dump_buf, instance->crash_dump_h); } @@ -6516,17 +6513,20 @@ static int megasas_probe_one(struct pci_dev *pdev, if (instance->requestorId) { if (instance->PlasmaFW111) { instance->vf_affiliation_111 = - pci_alloc_consistent(pdev, sizeof(struct MR_LD_VF_AFFILIATION_111), - &instance->vf_affiliation_111_h); + dma_alloc_coherent(&pdev->dev, + sizeof(struct MR_LD_VF_AFFILIATION_111), + &instance->vf_affiliation_111_h, + GFP_KERNEL); if (!instance->vf_affiliation_111) dev_warn(&pdev->dev, "Can't allocate " "memory for VF affiliation buffer\n"); } else { instance->vf_affiliation = - pci_alloc_consistent(pdev, - (MAX_LOGICAL_DRIVES + 1) * - sizeof(struct MR_LD_VF_AFFILIATION), - &instance->vf_affiliation_h); + dma_alloc_coherent(&pdev->dev, + (MAX_LOGICAL_DRIVES + 1) * + sizeof(struct MR_LD_VF_AFFILIATION), + &instance->vf_affiliation_h, + GFP_KERNEL); if (!instance->vf_affiliation) dev_warn(&pdev->dev, "Can't allocate " "memory for VF affiliation buffer\n"); @@ -6994,19 +6994,19 @@ skip_firing_dcmds: } if (instance->vf_affiliation) - pci_free_consistent(pdev, (MAX_LOGICAL_DRIVES + 1) * + dma_free_coherent(&pdev->dev, (MAX_LOGICAL_DRIVES + 1) * sizeof(struct MR_LD_VF_AFFILIATION), instance->vf_affiliation, instance->vf_affiliation_h); if (instance->vf_affiliation_111) - pci_free_consistent(pdev, + dma_free_coherent(&pdev->dev, sizeof(struct MR_LD_VF_AFFILIATION_111), instance->vf_affiliation_111, instance->vf_affiliation_111_h); if (instance->hb_host_mem) - pci_free_consistent(pdev, sizeof(struct MR_CTRL_HB_HOST_MEM), + dma_free_coherent(&pdev->dev, sizeof(struct MR_CTRL_HB_HOST_MEM), instance->hb_host_mem, instance->hb_host_mem_h); @@ -7254,7 +7254,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, /* * We don't change the dma_coherent_mask, so - * pci_alloc_consistent only returns 32bit addresses + * dma_alloc_coherent only returns 32bit addresses */ if (instance->consistent_mask_64bit) { kern_sge64[i].phys_addr = cpu_to_le64(buf_handle); @@ -7523,6 +7523,9 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) get_user(user_sense_off, &cioc->sense_off)) return -EFAULT; + if (local_sense_off != user_sense_off) + return -EINVAL; + if (local_sense_len) { void __user **sense_ioc_ptr = (void __user **)((u8 *)((unsigned long)&ioc->frame.raw) + local_sense_off); diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index c7f95bace353..f74b5ea24f0f 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -684,8 +684,8 @@ megasas_alloc_rdpq_fusion(struct megasas_instance *instance) array_size = sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) * MAX_MSIX_QUEUES_FUSION; - fusion->rdpq_virt = pci_zalloc_consistent(instance->pdev, array_size, - &fusion->rdpq_phys); + fusion->rdpq_virt = dma_zalloc_coherent(&instance->pdev->dev, + array_size, &fusion->rdpq_phys, GFP_KERNEL); if (!fusion->rdpq_virt) { dev_err(&instance->pdev->dev, "Failed from %s %d\n", __func__, __LINE__); @@ -813,7 +813,7 @@ megasas_free_rdpq_fusion(struct megasas_instance *instance) { dma_pool_destroy(fusion->reply_frames_desc_pool_align); if (fusion->rdpq_virt) - pci_free_consistent(instance->pdev, + dma_free_coherent(&instance->pdev->dev, sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) * MAX_MSIX_QUEUES_FUSION, fusion->rdpq_virt, fusion->rdpq_phys); } @@ -2209,7 +2209,7 @@ megasas_set_pd_lba(struct MPI2_RAID_SCSI_IO_REQUEST *io_request, u8 cdb_len, cdb[0] = MEGASAS_SCSI_VARIABLE_LENGTH_CMD; cdb[7] = MEGASAS_SCSI_ADDL_CDB_LEN; - if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) + if (scp->sc_data_direction == DMA_FROM_DEVICE) cdb[9] = MEGASAS_SCSI_SERVICE_ACTION_READ32; else cdb[9] = MEGASAS_SCSI_SERVICE_ACTION_WRITE32; @@ -2238,7 +2238,7 @@ megasas_set_pd_lba(struct MPI2_RAID_SCSI_IO_REQUEST *io_request, u8 cdb_len, cdb[31] = (u8)(num_blocks & 0xff); /* set SCSI IO EEDPFlags */ - if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) { + if (scp->sc_data_direction == DMA_FROM_DEVICE) { io_request->EEDPFlags = cpu_to_le16( MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG | MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG | @@ -2621,7 +2621,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance, scsi_buff_len = scsi_bufflen(scp); io_request->DataLength = cpu_to_le32(scsi_buff_len); - if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) + if (scp->sc_data_direction == DMA_FROM_DEVICE) io_info.isRead = 1; local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)]; @@ -3088,9 +3088,9 @@ megasas_build_io_fusion(struct megasas_instance *instance, io_request->SGLFlags = cpu_to_le16(MPI2_SGE_FLAGS_64_BIT_ADDRESSING); - if (scp->sc_data_direction == PCI_DMA_TODEVICE) + if (scp->sc_data_direction == DMA_TO_DEVICE) io_request->Control |= cpu_to_le32(MPI2_SCSIIO_CONTROL_WRITE); - else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) + else if (scp->sc_data_direction == DMA_FROM_DEVICE) io_request->Control |= cpu_to_le32(MPI2_SCSIIO_CONTROL_READ); io_request->SGLOffset0 = |