提交 1aee383d 编写于 作者: J Joe Perches 提交者: Christoph Hellwig

lpfc: use dma_zalloc_coherent

Use the zeroing function instead of dma_alloc_coherent & memset(,0,)
Signed-off-by: NJoe Perches <joe@perches.com>
Reviewed-by: NJames Smart <james.smart@emulex.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
上级 9ab9b134
...@@ -2693,14 +2693,13 @@ lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba) ...@@ -2693,14 +2693,13 @@ lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba)
INIT_LIST_HEAD(&dmabuf->list); INIT_LIST_HEAD(&dmabuf->list);
/* now, allocate dma buffer */ /* now, allocate dma buffer */
dmabuf->virt = dma_alloc_coherent(&pcidev->dev, BSG_MBOX_SIZE, dmabuf->virt = dma_zalloc_coherent(&pcidev->dev, BSG_MBOX_SIZE,
&(dmabuf->phys), GFP_KERNEL); &(dmabuf->phys), GFP_KERNEL);
if (!dmabuf->virt) { if (!dmabuf->virt) {
kfree(dmabuf); kfree(dmabuf);
return NULL; return NULL;
} }
memset((uint8_t *)dmabuf->virt, 0, BSG_MBOX_SIZE);
return dmabuf; return dmabuf;
} }
......
...@@ -5848,16 +5848,14 @@ lpfc_sli4_create_rpi_hdr(struct lpfc_hba *phba) ...@@ -5848,16 +5848,14 @@ lpfc_sli4_create_rpi_hdr(struct lpfc_hba *phba)
if (!dmabuf) if (!dmabuf)
return NULL; return NULL;
dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev,
LPFC_HDR_TEMPLATE_SIZE, LPFC_HDR_TEMPLATE_SIZE,
&dmabuf->phys, &dmabuf->phys, GFP_KERNEL);
GFP_KERNEL);
if (!dmabuf->virt) { if (!dmabuf->virt) {
rpi_hdr = NULL; rpi_hdr = NULL;
goto err_free_dmabuf; goto err_free_dmabuf;
} }
memset(dmabuf->virt, 0, LPFC_HDR_TEMPLATE_SIZE);
if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) {
rpi_hdr = NULL; rpi_hdr = NULL;
goto err_free_coherent; goto err_free_coherent;
...@@ -6246,14 +6244,11 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba) ...@@ -6246,14 +6244,11 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba)
} }
/* Allocate memory for SLI-2 structures */ /* Allocate memory for SLI-2 structures */
phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, phba->slim2p.virt = dma_zalloc_coherent(&pdev->dev, SLI2_SLIM_SIZE,
SLI2_SLIM_SIZE, &phba->slim2p.phys, GFP_KERNEL);
&phba->slim2p.phys,
GFP_KERNEL);
if (!phba->slim2p.virt) if (!phba->slim2p.virt)
goto out_iounmap; goto out_iounmap;
memset(phba->slim2p.virt, 0, SLI2_SLIM_SIZE);
phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx);
phba->mbox_ext = (phba->slim2p.virt + phba->mbox_ext = (phba->slim2p.virt +
offsetof(struct lpfc_sli2_slim, mbx_ext_words)); offsetof(struct lpfc_sli2_slim, mbx_ext_words));
...@@ -6618,15 +6613,12 @@ lpfc_create_bootstrap_mbox(struct lpfc_hba *phba) ...@@ -6618,15 +6613,12 @@ lpfc_create_bootstrap_mbox(struct lpfc_hba *phba)
* plus an alignment restriction of 16 bytes. * plus an alignment restriction of 16 bytes.
*/ */
bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1);
dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, bmbx_size,
bmbx_size, &dmabuf->phys, GFP_KERNEL);
&dmabuf->phys,
GFP_KERNEL);
if (!dmabuf->virt) { if (!dmabuf->virt) {
kfree(dmabuf); kfree(dmabuf);
return -ENOMEM; return -ENOMEM;
} }
memset(dmabuf->virt, 0, bmbx_size);
/* /*
* Initialize the bootstrap mailbox pointers now so that the register * Initialize the bootstrap mailbox pointers now so that the register
......
...@@ -1811,12 +1811,12 @@ lpfc_sli4_config(struct lpfc_hba *phba, struct lpfcMboxq *mbox, ...@@ -1811,12 +1811,12 @@ lpfc_sli4_config(struct lpfc_hba *phba, struct lpfcMboxq *mbox,
* page, this is used as a priori size of SLI4_PAGE_SIZE for * page, this is used as a priori size of SLI4_PAGE_SIZE for
* the later DMA memory free. * the later DMA memory free.
*/ */
viraddr = dma_alloc_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, viraddr = dma_zalloc_coherent(&phba->pcidev->dev,
&phyaddr, GFP_KERNEL); SLI4_PAGE_SIZE, &phyaddr,
GFP_KERNEL);
/* In case of malloc fails, proceed with whatever we have */ /* In case of malloc fails, proceed with whatever we have */
if (!viraddr) if (!viraddr)
break; break;
memset(viraddr, 0, SLI4_PAGE_SIZE);
mbox->sge_array->addr[pagen] = viraddr; mbox->sge_array->addr[pagen] = viraddr;
/* Keep the first page for later sub-header construction */ /* Keep the first page for later sub-header construction */
if (pagen == 0) if (pagen == 0)
......
...@@ -4864,15 +4864,12 @@ lpfc_sli4_read_rev(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, ...@@ -4864,15 +4864,12 @@ lpfc_sli4_read_rev(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq,
* mailbox command. * mailbox command.
*/ */
dma_size = *vpd_size; dma_size = *vpd_size;
dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, dma_size,
dma_size, &dmabuf->phys, GFP_KERNEL);
&dmabuf->phys,
GFP_KERNEL);
if (!dmabuf->virt) { if (!dmabuf->virt) {
kfree(dmabuf); kfree(dmabuf);
return -ENOMEM; return -ENOMEM;
} }
memset(dmabuf->virt, 0, dma_size);
/* /*
* The SLI4 implementation of READ_REV conflicts at word1, * The SLI4 implementation of READ_REV conflicts at word1,
...@@ -12760,14 +12757,13 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t entry_size, ...@@ -12760,14 +12757,13 @@ lpfc_sli4_queue_alloc(struct lpfc_hba *phba, uint32_t entry_size,
dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
if (!dmabuf) if (!dmabuf)
goto out_fail; goto out_fail;
dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev,
hw_page_size, &dmabuf->phys, hw_page_size, &dmabuf->phys,
GFP_KERNEL); GFP_KERNEL);
if (!dmabuf->virt) { if (!dmabuf->virt) {
kfree(dmabuf); kfree(dmabuf);
goto out_fail; goto out_fail;
} }
memset(dmabuf->virt, 0, hw_page_size);
dmabuf->buffer_tag = x; dmabuf->buffer_tag = x;
list_add_tail(&dmabuf->list, &queue->page_list); list_add_tail(&dmabuf->list, &queue->page_list);
/* initialize queue's entry array */ /* initialize queue's entry array */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册