scsi: be2iscsi: switch to generic DMA API

Switch from the legacy PCI DMA API to the generic DMA API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Christoph Hellwig 2018-10-10 18:22:24 +02:00 committed by Martin K. Petersen
parent 48ecddb41b
commit 26a4c991af
4 changed files with 58 additions and 64 deletions

View File

@ -520,7 +520,7 @@ int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
**/ **/
tag_mem = &ctrl->ptag_state[tag].tag_mem_state; tag_mem = &ctrl->ptag_state[tag].tag_mem_state;
if (tag_mem->size) { if (tag_mem->size) {
pci_free_consistent(ctrl->pdev, tag_mem->size, dma_free_coherent(&ctrl->pdev->dev, tag_mem->size,
tag_mem->va, tag_mem->dma); tag_mem->va, tag_mem->dma);
tag_mem->size = 0; tag_mem->size = 0;
} }
@ -1269,12 +1269,12 @@ int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
struct be_sge *sge = nonembedded_sgl(wrb); struct be_sge *sge = nonembedded_sgl(wrb);
int status = 0; int status = 0;
nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev, nonemb_cmd.va = dma_alloc_coherent(&ctrl->pdev->dev,
sizeof(struct be_mgmt_controller_attributes), sizeof(struct be_mgmt_controller_attributes),
&nonemb_cmd.dma); &nonemb_cmd.dma, GFP_KERNEL);
if (nonemb_cmd.va == NULL) { if (nonemb_cmd.va == NULL) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
"BG_%d : pci_alloc_consistent failed in %s\n", "BG_%d : dma_alloc_coherent failed in %s\n",
__func__); __func__);
return -ENOMEM; return -ENOMEM;
} }
@ -1314,7 +1314,7 @@ int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
"BG_%d : Failed in beiscsi_check_supported_fw\n"); "BG_%d : Failed in beiscsi_check_supported_fw\n");
mutex_unlock(&ctrl->mbox_lock); mutex_unlock(&ctrl->mbox_lock);
if (nonemb_cmd.va) if (nonemb_cmd.va)
pci_free_consistent(ctrl->pdev, nonemb_cmd.size, dma_free_coherent(&ctrl->pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
return status; return status;

View File

@ -1071,9 +1071,9 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
else else
req_memsize = sizeof(struct tcp_connect_and_offload_in_v1); req_memsize = sizeof(struct tcp_connect_and_offload_in_v1);
nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
req_memsize, req_memsize,
&nonemb_cmd.dma); &nonemb_cmd.dma, GFP_KERNEL);
if (nonemb_cmd.va == NULL) { if (nonemb_cmd.va == NULL) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
@ -1091,7 +1091,7 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
"BS_%d : mgmt_open_connection Failed for cid=%d\n", "BS_%d : mgmt_open_connection Failed for cid=%d\n",
beiscsi_ep->ep_cid); beiscsi_ep->ep_cid);
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
beiscsi_free_ep(beiscsi_ep); beiscsi_free_ep(beiscsi_ep);
return -EAGAIN; return -EAGAIN;
@ -1104,8 +1104,9 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
"BS_%d : mgmt_open_connection Failed"); "BS_%d : mgmt_open_connection Failed");
if (ret != -EBUSY) if (ret != -EBUSY)
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.size, nonemb_cmd.va,
nonemb_cmd.dma);
beiscsi_free_ep(beiscsi_ep); beiscsi_free_ep(beiscsi_ep);
return ret; return ret;
@ -1118,7 +1119,7 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
"BS_%d : mgmt_open_connection Success\n"); "BS_%d : mgmt_open_connection Success\n");
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
return 0; return 0;
} }

View File

@ -511,18 +511,9 @@ static int beiscsi_enable_pci(struct pci_dev *pcidev)
} }
pci_set_master(pcidev); pci_set_master(pcidev);
ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(64)); ret = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(64));
if (ret) { if (ret) {
ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(32)); ret = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
goto pci_region_release;
} else {
ret = pci_set_consistent_dma_mask(pcidev,
DMA_BIT_MASK(32));
}
} else {
ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64));
if (ret) { if (ret) {
dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n"); dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
goto pci_region_release; goto pci_region_release;
@ -550,9 +541,8 @@ static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev)
if (status) if (status)
return status; return status;
mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16; mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16;
mbox_mem_alloc->va = pci_alloc_consistent(pdev, mbox_mem_alloc->va = dma_alloc_coherent(&pdev->dev,
mbox_mem_alloc->size, mbox_mem_alloc->size, &mbox_mem_alloc->dma, GFP_KERNEL);
&mbox_mem_alloc->dma);
if (!mbox_mem_alloc->va) { if (!mbox_mem_alloc->va) {
beiscsi_unmap_pci_function(phba); beiscsi_unmap_pci_function(phba);
return -ENOMEM; return -ENOMEM;
@ -2302,11 +2292,11 @@ static int hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task)
/* Map addr only if there is data_count */ /* Map addr only if there is data_count */
if (dsp_value) { if (dsp_value) {
io_task->mtask_addr = pci_map_single(phba->pcidev, io_task->mtask_addr = dma_map_single(&phba->pcidev->dev,
task->data, task->data,
task->data_count, task->data_count,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
if (pci_dma_mapping_error(phba->pcidev, if (dma_mapping_error(&phba->pcidev->dev,
io_task->mtask_addr)) io_task->mtask_addr))
return -ENOMEM; return -ENOMEM;
io_task->mtask_data_count = task->data_count; io_task->mtask_data_count = task->data_count;
@ -2517,10 +2507,9 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
BEISCSI_MAX_FRAGS_INIT); BEISCSI_MAX_FRAGS_INIT);
curr_alloc_size = min(be_max_phys_size * 1024, alloc_size); curr_alloc_size = min(be_max_phys_size * 1024, alloc_size);
do { do {
mem_arr->virtual_address = pci_alloc_consistent( mem_arr->virtual_address =
phba->pcidev, dma_alloc_coherent(&phba->pcidev->dev,
curr_alloc_size, curr_alloc_size, &bus_add, GFP_KERNEL);
&bus_add);
if (!mem_arr->virtual_address) { if (!mem_arr->virtual_address) {
if (curr_alloc_size <= BE_MIN_MEM_SIZE) if (curr_alloc_size <= BE_MIN_MEM_SIZE)
goto free_mem; goto free_mem;
@ -2558,7 +2547,7 @@ free_mem:
mem_descr->num_elements = j; mem_descr->num_elements = j;
while ((i) || (j)) { while ((i) || (j)) {
for (j = mem_descr->num_elements; j > 0; j--) { for (j = mem_descr->num_elements; j > 0; j--) {
pci_free_consistent(phba->pcidev, dma_free_coherent(&phba->pcidev->dev,
mem_descr->mem_array[j - 1].size, mem_descr->mem_array[j - 1].size,
mem_descr->mem_array[j - 1]. mem_descr->mem_array[j - 1].
virtual_address, virtual_address,
@ -3029,9 +3018,9 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
eq = &phwi_context->be_eq[i].q; eq = &phwi_context->be_eq[i].q;
mem = &eq->dma_mem; mem = &eq->dma_mem;
phwi_context->be_eq[i].phba = phba; phwi_context->be_eq[i].phba = phba;
eq_vaddress = pci_alloc_consistent(phba->pcidev, eq_vaddress = dma_alloc_coherent(&phba->pcidev->dev,
num_eq_pages * PAGE_SIZE, num_eq_pages * PAGE_SIZE,
&paddr); &paddr, GFP_KERNEL);
if (!eq_vaddress) { if (!eq_vaddress) {
ret = -ENOMEM; ret = -ENOMEM;
goto create_eq_error; goto create_eq_error;
@ -3067,7 +3056,7 @@ create_eq_error:
eq = &phwi_context->be_eq[i].q; eq = &phwi_context->be_eq[i].q;
mem = &eq->dma_mem; mem = &eq->dma_mem;
if (mem->va) if (mem->va)
pci_free_consistent(phba->pcidev, num_eq_pages dma_free_coherent(&phba->pcidev->dev, num_eq_pages
* PAGE_SIZE, * PAGE_SIZE,
mem->va, mem->dma); mem->va, mem->dma);
} }
@ -3095,9 +3084,9 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
pbe_eq->cq = cq; pbe_eq->cq = cq;
pbe_eq->phba = phba; pbe_eq->phba = phba;
mem = &cq->dma_mem; mem = &cq->dma_mem;
cq_vaddress = pci_alloc_consistent(phba->pcidev, cq_vaddress = dma_alloc_coherent(&phba->pcidev->dev,
num_cq_pages * PAGE_SIZE, num_cq_pages * PAGE_SIZE,
&paddr); &paddr, GFP_KERNEL);
if (!cq_vaddress) { if (!cq_vaddress) {
ret = -ENOMEM; ret = -ENOMEM;
goto create_cq_error; goto create_cq_error;
@ -3132,7 +3121,7 @@ create_cq_error:
cq = &phwi_context->be_cq[i]; cq = &phwi_context->be_cq[i];
mem = &cq->dma_mem; mem = &cq->dma_mem;
if (mem->va) if (mem->va)
pci_free_consistent(phba->pcidev, num_cq_pages dma_free_coherent(&phba->pcidev->dev, num_cq_pages
* PAGE_SIZE, * PAGE_SIZE,
mem->va, mem->dma); mem->va, mem->dma);
} }
@ -3324,7 +3313,7 @@ static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q)
{ {
struct be_dma_mem *mem = &q->dma_mem; struct be_dma_mem *mem = &q->dma_mem;
if (mem->va) { if (mem->va) {
pci_free_consistent(phba->pcidev, mem->size, dma_free_coherent(&phba->pcidev->dev, mem->size,
mem->va, mem->dma); mem->va, mem->dma);
mem->va = NULL; mem->va = NULL;
} }
@ -3339,7 +3328,8 @@ static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q,
q->len = len; q->len = len;
q->entry_size = entry_size; q->entry_size = entry_size;
mem->size = len * entry_size; mem->size = len * entry_size;
mem->va = pci_zalloc_consistent(phba->pcidev, mem->size, &mem->dma); mem->va = dma_zalloc_coherent(&phba->pcidev->dev, mem->size, &mem->dma,
GFP_KERNEL);
if (!mem->va) if (!mem->va)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
@ -3477,7 +3467,7 @@ static void be_mcc_queues_destroy(struct beiscsi_hba *phba)
&ctrl->ptag_state[tag].tag_state)) { &ctrl->ptag_state[tag].tag_state)) {
ptag_mem = &ctrl->ptag_state[tag].tag_mem_state; ptag_mem = &ctrl->ptag_state[tag].tag_mem_state;
if (ptag_mem->size) { if (ptag_mem->size) {
pci_free_consistent(ctrl->pdev, dma_free_coherent(&ctrl->pdev->dev,
ptag_mem->size, ptag_mem->size,
ptag_mem->va, ptag_mem->va,
ptag_mem->dma); ptag_mem->dma);
@ -3878,7 +3868,7 @@ static void beiscsi_free_mem(struct beiscsi_hba *phba)
j = 0; j = 0;
for (i = 0; i < SE_MEM_MAX; i++) { for (i = 0; i < SE_MEM_MAX; i++) {
for (j = mem_descr->num_elements; j > 0; j--) { for (j = mem_descr->num_elements; j > 0; j--) {
pci_free_consistent(phba->pcidev, dma_free_coherent(&phba->pcidev->dev,
mem_descr->mem_array[j - 1].size, mem_descr->mem_array[j - 1].size,
mem_descr->mem_array[j - 1].virtual_address, mem_descr->mem_array[j - 1].virtual_address,
(unsigned long)mem_descr->mem_array[j - 1]. (unsigned long)mem_descr->mem_array[j - 1].
@ -4253,10 +4243,10 @@ beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn,
} }
if (io_task->mtask_addr) { if (io_task->mtask_addr) {
pci_unmap_single(phba->pcidev, dma_unmap_single(&phba->pcidev->dev,
io_task->mtask_addr, io_task->mtask_addr,
io_task->mtask_data_count, io_task->mtask_data_count,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
io_task->mtask_addr = 0; io_task->mtask_addr = 0;
} }
} }
@ -4850,9 +4840,9 @@ static int beiscsi_bsg_request(struct bsg_job *job)
switch (bsg_req->msgcode) { switch (bsg_req->msgcode) {
case ISCSI_BSG_HST_VENDOR: case ISCSI_BSG_HST_VENDOR:
nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
job->request_payload.payload_len, job->request_payload.payload_len,
&nonemb_cmd.dma); &nonemb_cmd.dma, GFP_KERNEL);
if (nonemb_cmd.va == NULL) { if (nonemb_cmd.va == NULL) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BM_%d : Failed to allocate memory for " "BM_%d : Failed to allocate memory for "
@ -4865,7 +4855,7 @@ static int beiscsi_bsg_request(struct bsg_job *job)
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BM_%d : MBX Tag Allocation Failed\n"); "BM_%d : MBX Tag Allocation Failed\n");
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
return -EAGAIN; return -EAGAIN;
} }
@ -4879,7 +4869,7 @@ static int beiscsi_bsg_request(struct bsg_job *job)
if (!test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { if (!test_bit(BEISCSI_HBA_ONLINE, &phba->state)) {
clear_bit(MCC_TAG_STATE_RUNNING, clear_bit(MCC_TAG_STATE_RUNNING,
&phba->ctrl.ptag_state[tag].tag_state); &phba->ctrl.ptag_state[tag].tag_state);
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
return -EIO; return -EIO;
} }
@ -4896,7 +4886,7 @@ static int beiscsi_bsg_request(struct bsg_job *job)
bsg_reply->result = status; bsg_reply->result = status;
bsg_job_done(job, bsg_reply->result, bsg_job_done(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len); bsg_reply->reply_payload_rcv_len);
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
if (status || extd_status) { if (status || extd_status) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
@ -5753,7 +5743,7 @@ free_twq:
beiscsi_cleanup_port(phba); beiscsi_cleanup_port(phba);
beiscsi_free_mem(phba); beiscsi_free_mem(phba);
free_port: free_port:
pci_free_consistent(phba->pcidev, dma_free_coherent(&phba->pcidev->dev,
phba->ctrl.mbox_mem_alloced.size, phba->ctrl.mbox_mem_alloced.size,
phba->ctrl.mbox_mem_alloced.va, phba->ctrl.mbox_mem_alloced.va,
phba->ctrl.mbox_mem_alloced.dma); phba->ctrl.mbox_mem_alloced.dma);
@ -5797,7 +5787,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
/* ctrl uninit */ /* ctrl uninit */
beiscsi_unmap_pci_function(phba); beiscsi_unmap_pci_function(phba);
pci_free_consistent(phba->pcidev, dma_free_coherent(&phba->pcidev->dev,
phba->ctrl.mbox_mem_alloced.size, phba->ctrl.mbox_mem_alloced.size,
phba->ctrl.mbox_mem_alloced.va, phba->ctrl.mbox_mem_alloced.va,
phba->ctrl.mbox_mem_alloced.dma); phba->ctrl.mbox_mem_alloced.dma);

View File

@ -284,7 +284,7 @@ static int beiscsi_exec_nemb_cmd(struct beiscsi_hba *phba,
return rc; return rc;
free_cmd: free_cmd:
pci_free_consistent(ctrl->pdev, nonemb_cmd->size, dma_free_coherent(&ctrl->pdev->dev, nonemb_cmd->size,
nonemb_cmd->va, nonemb_cmd->dma); nonemb_cmd->va, nonemb_cmd->dma);
return rc; return rc;
} }
@ -293,7 +293,8 @@ static int beiscsi_prep_nemb_cmd(struct beiscsi_hba *phba,
struct be_dma_mem *cmd, struct be_dma_mem *cmd,
u8 subsystem, u8 opcode, u32 size) u8 subsystem, u8 opcode, u32 size)
{ {
cmd->va = pci_zalloc_consistent(phba->ctrl.pdev, size, &cmd->dma); cmd->va = dma_zalloc_coherent(&phba->ctrl.pdev->dev, size, &cmd->dma,
GFP_KERNEL);
if (!cmd->va) { if (!cmd->va) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BG_%d : Failed to allocate memory for if info\n"); "BG_%d : Failed to allocate memory for if info\n");
@ -315,7 +316,7 @@ static void __beiscsi_eq_delay_compl(struct beiscsi_hba *phba, unsigned int tag)
__beiscsi_mcc_compl_status(phba, tag, NULL, NULL); __beiscsi_mcc_compl_status(phba, tag, NULL, NULL);
tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state; tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
if (tag_mem->size) { if (tag_mem->size) {
pci_free_consistent(phba->pcidev, tag_mem->size, dma_free_coherent(&phba->pcidev->dev, tag_mem->size,
tag_mem->va, tag_mem->dma); tag_mem->va, tag_mem->dma);
tag_mem->size = 0; tag_mem->size = 0;
} }
@ -761,7 +762,7 @@ int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
"BG_%d : Memory Allocation Failure\n"); "BG_%d : Memory Allocation Failure\n");
/* Free the DMA memory for the IOCTL issuing */ /* Free the DMA memory for the IOCTL issuing */
pci_free_consistent(phba->ctrl.pdev, dma_free_coherent(&phba->ctrl.pdev->dev,
nonemb_cmd.size, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.va,
nonemb_cmd.dma); nonemb_cmd.dma);
@ -780,7 +781,7 @@ int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
ioctl_size += sizeof(struct be_cmd_req_hdr); ioctl_size += sizeof(struct be_cmd_req_hdr);
/* Free the previous allocated DMA memory */ /* Free the previous allocated DMA memory */
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.va,
nonemb_cmd.dma); nonemb_cmd.dma);
@ -869,7 +870,7 @@ static void beiscsi_boot_process_compl(struct beiscsi_hba *phba,
status); status);
boot_work = 0; boot_work = 0;
} }
pci_free_consistent(phba->ctrl.pdev, bs->nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, bs->nonemb_cmd.size,
bs->nonemb_cmd.va, bs->nonemb_cmd.dma); bs->nonemb_cmd.va, bs->nonemb_cmd.dma);
bs->nonemb_cmd.va = NULL; bs->nonemb_cmd.va = NULL;
break; break;
@ -1012,9 +1013,10 @@ unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba)
nonemb_cmd = &phba->boot_struct.nonemb_cmd; nonemb_cmd = &phba->boot_struct.nonemb_cmd;
nonemb_cmd->size = sizeof(struct be_cmd_get_session_resp); nonemb_cmd->size = sizeof(struct be_cmd_get_session_resp);
nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev, nonemb_cmd->va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
nonemb_cmd->size, nonemb_cmd->size,
&nonemb_cmd->dma); &nonemb_cmd->dma,
GFP_KERNEL);
if (!nonemb_cmd->va) { if (!nonemb_cmd->va) {
mutex_unlock(&ctrl->mbox_lock); mutex_unlock(&ctrl->mbox_lock);
return 0; return 0;
@ -1508,9 +1510,10 @@ int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba,
return -EINVAL; return -EINVAL;
nonemb_cmd.size = sizeof(union be_invldt_cmds_params); nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev, nonemb_cmd.va = dma_zalloc_coherent(&phba->ctrl.pdev->dev,
nonemb_cmd.size, nonemb_cmd.size,
&nonemb_cmd.dma); &nonemb_cmd.dma,
GFP_KERNEL);
if (!nonemb_cmd.va) { if (!nonemb_cmd.va) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
"BM_%d : invldt_cmds_params alloc failed\n"); "BM_%d : invldt_cmds_params alloc failed\n");
@ -1521,7 +1524,7 @@ int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba,
wrb = alloc_mcc_wrb(phba, &tag); wrb = alloc_mcc_wrb(phba, &tag);
if (!wrb) { if (!wrb) {
mutex_unlock(&ctrl->mbox_lock); mutex_unlock(&ctrl->mbox_lock);
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
return -ENOMEM; return -ENOMEM;
} }
@ -1548,7 +1551,7 @@ int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba,
rc = beiscsi_mccq_compl_wait(phba, tag, NULL, &nonemb_cmd); rc = beiscsi_mccq_compl_wait(phba, tag, NULL, &nonemb_cmd);
if (rc != -EBUSY) if (rc != -EBUSY)
pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
nonemb_cmd.va, nonemb_cmd.dma); nonemb_cmd.va, nonemb_cmd.dma);
return rc; return rc;
} }