diff options
author | Joe Perches <joe@perches.com> | 2014-09-03 12:56:12 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-09-16 12:10:06 -0400 |
commit | 1aee383d5912de15af3045a63a07e98f760f041c (patch) | |
tree | 6e58b144d1354008d497e3cd0003e9cb6e69e090 /drivers | |
parent | 9ab9b134a86ed9f897a29d2ba5abb93f7b162dca (diff) |
lpfc: use dma_zalloc_coherent
Use the zeroing function instead of dma_alloc_coherent & memset(,0,)
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: James Smart <james.smart@emulex.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_bsg.c | 5 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_init.c | 22 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_mbox.c | 6 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 14 |
4 files changed, 17 insertions, 30 deletions
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index 371474bec5a5..d236448b05b9 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c | |||
@@ -2693,14 +2693,13 @@ lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba) | |||
2693 | INIT_LIST_HEAD(&dmabuf->list); | 2693 | INIT_LIST_HEAD(&dmabuf->list); |
2694 | 2694 | ||
2695 | /* now, allocate dma buffer */ | 2695 | /* now, allocate dma buffer */ |
2696 | dmabuf->virt = dma_alloc_coherent(&pcidev->dev, BSG_MBOX_SIZE, | 2696 | dmabuf->virt = dma_zalloc_coherent(&pcidev->dev, BSG_MBOX_SIZE, |
2697 | &(dmabuf->phys), GFP_KERNEL); | 2697 | &(dmabuf->phys), GFP_KERNEL); |
2698 | 2698 | ||
2699 | if (!dmabuf->virt) { | 2699 | if (!dmabuf->virt) { |
2700 | kfree(dmabuf); | 2700 | kfree(dmabuf); |
2701 | return NULL; | 2701 | return NULL; |
2702 | } | 2702 | } |
2703 | memset((uint8_t *)dmabuf->virt, 0, BSG_MBOX_SIZE); | ||
2704 | 2703 | ||
2705 | return dmabuf; | 2704 | return dmabuf; |
2706 | } | 2705 | } |
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 60d9518a3e6b..990c3a29c51f 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -5848,16 +5848,14 @@ lpfc_sli4_create_rpi_hdr(struct lpfc_hba *phba) | |||
5848 | if (!dmabuf) | 5848 | if (!dmabuf) |
5849 | return NULL; | 5849 | return NULL; |
5850 | 5850 | ||
5851 | dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, | 5851 | dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, |
5852 | LPFC_HDR_TEMPLATE_SIZE, | 5852 | LPFC_HDR_TEMPLATE_SIZE, |
5853 | &dmabuf->phys, | 5853 | &dmabuf->phys, GFP_KERNEL); |
5854 | GFP_KERNEL); | ||
5855 | if (!dmabuf->virt) { | 5854 | if (!dmabuf->virt) { |
5856 | rpi_hdr = NULL; | 5855 | rpi_hdr = NULL; |
5857 | goto err_free_dmabuf; | 5856 | goto err_free_dmabuf; |
5858 | } | 5857 | } |
5859 | 5858 | ||
5860 | memset(dmabuf->virt, 0, LPFC_HDR_TEMPLATE_SIZE); | ||
5861 | if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { | 5859 | if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { |
5862 | rpi_hdr = NULL; | 5860 | rpi_hdr = NULL; |
5863 | goto err_free_coherent; | 5861 | goto err_free_coherent; |
@@ -6246,14 +6244,11 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba) | |||
6246 | } | 6244 | } |
6247 | 6245 | ||
6248 | /* Allocate memory for SLI-2 structures */ | 6246 | /* Allocate memory for SLI-2 structures */ |
6249 | phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, | 6247 | phba->slim2p.virt = dma_zalloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, |
6250 | SLI2_SLIM_SIZE, | 6248 | &phba->slim2p.phys, GFP_KERNEL); |
6251 | &phba->slim2p.phys, | ||
6252 | GFP_KERNEL); | ||
6253 | if (!phba->slim2p.virt) | 6249 | if (!phba->slim2p.virt) |
6254 | goto out_iounmap; | 6250 | goto out_iounmap; |
6255 | 6251 | ||
6256 | memset(phba->slim2p.virt, 0, SLI2_SLIM_SIZE); | ||
6257 | phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); | 6252 | phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); |
6258 | phba->mbox_ext = (phba->slim2p.virt + | 6253 | phba->mbox_ext = (phba->slim2p.virt + |
6259 | offsetof(struct lpfc_sli2_slim, mbx_ext_words)); | 6254 | offsetof(struct lpfc_sli2_slim, mbx_ext_words)); |
@@ -6618,15 +6613,12 @@ lpfc_create_bootstrap_mbox(struct lpfc_hba *phba) | |||
6618 | * plus an alignment restriction of 16 bytes. | 6613 | * plus an alignment restriction of 16 bytes. |
6619 | */ | 6614 | */ |
6620 | bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); | 6615 | bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); |
6621 | dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, | 6616 | dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, bmbx_size, |
6622 | bmbx_size, | 6617 | &dmabuf->phys, GFP_KERNEL); |
6623 | &dmabuf->phys, | ||
6624 | GFP_KERNEL); | ||
6625 | if (!dmabuf->virt) { | 6618 | if (!dmabuf->virt) { |
6626 | kfree(dmabuf); | 6619 | kfree(dmabuf); |
6627 | return -ENOMEM; | 6620 | return -ENOMEM; |
6628 | } | 6621 | } |
6629 | memset(dmabuf->virt, 0, bmbx_size); | ||
6630 | 6622 | ||
6631 | /* | 6623 | /* |
6632 | * Initialize the bootstrap mailbox pointers now so that the register | 6624 | * Initialize the bootstrap mailbox pointers now so that the register |
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 1f292e29d566..06241f590c1e 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -1811,12 +1811,12 @@ lpfc_sli4_config(struct lpfc_hba *phba, struct lpfcMboxq *mbox, | |||
1811 | * page, this is used as a priori size of SLI4_PAGE_SIZE for | 1811 | * page, this is used as a priori size of SLI4_PAGE_SIZE for |
1812 | * the later DMA memory free. | 1812 | * the later DMA memory free. |
1813 | */ | 1813 | */ |
1814 | viraddr = dma_alloc_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, | 1814 | viraddr = dma_zalloc_coherent(&phba->pcidev->dev, |
1815 | &phyaddr, GFP_KERNEL); | 1815 | SLI4_PAGE_SIZE, &phyaddr, |
1816 | GFP_KERNEL); | ||
1816 | /* In case of malloc fails, proceed with whatever we have */ | 1817 | /* In case of malloc fails, proceed with whatever we have */ |
1817 | if (!viraddr) | 1818 | if (!viraddr) |
1818 | break; | 1819 | break; |
1819 | memset(viraddr, 0, SLI4_PAGE_SIZE); | ||
1820 | mbox->sge_array->addr[pagen] = viraddr; | 1820 | mbox->sge_array->addr[pagen] = viraddr; |
1821 | /* Keep the first page for later sub-header construction */ | 1821 | /* Keep the first page for later sub-header construction */ |
1822 | if (pagen == 0) | 1822 | if (pagen == 0) |
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 04a8b749b67a..27221cb21bb8 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -4864,15 +4864,12 @@ lpfc_sli4_read_rev(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, | |||
4864 | * mailbox command. | 4864 | * mailbox command. |
4865 | */ | 4865 | */ |
4866 | dma_size = *vpd_size; | 4866 | dma_size = *vpd_size; |
4867 | dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, | 4867 | dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, dma_size, |
4868 | dma_size, | 4868 | &dmabuf->phys, GFP_KERNEL); |
4869 | &dmabuf->phys, | ||
4870 | GFP_KERNEL); | ||
4871 | if (!dmabuf->virt) { | 4869 | if (!dmabuf->virt) { |
4872 | kfree(dmabuf); | 4870 | kfree(dmabuf); |
4873 | return -ENOMEM; | 4871 | return -ENOMEM; |
4874 | } | 4872 | } |
4875 | memset(dmabuf->virt, 0, dma_size); | ||
4876 | 4873 | ||
4877 | /* | 4874 | /* |
4878 | * The SLI4 implementation of READ_REV conflicts at word1, | 4875 | * 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 | dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); | 12757 | dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL); |
12761 | if (!dmabuf) | 12758 | if (!dmabuf) |
12762 | goto out_fail; | 12759 | goto out_fail; |
12763 | dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, | 12760 | dmabuf->virt = dma_zalloc_coherent(&phba->pcidev->dev, |
12764 | hw_page_size, &dmabuf->phys, | 12761 | hw_page_size, &dmabuf->phys, |
12765 | GFP_KERNEL); | 12762 | GFP_KERNEL); |
12766 | if (!dmabuf->virt) { | 12763 | if (!dmabuf->virt) { |
12767 | kfree(dmabuf); | 12764 | kfree(dmabuf); |
12768 | goto out_fail; | 12765 | goto out_fail; |
12769 | } | 12766 | } |
12770 | memset(dmabuf->virt, 0, hw_page_size); | ||
12771 | dmabuf->buffer_tag = x; | 12767 | dmabuf->buffer_tag = x; |
12772 | list_add_tail(&dmabuf->list, &queue->page_list); | 12768 | list_add_tail(&dmabuf->list, &queue->page_list); |
12773 | /* initialize queue's entry array */ | 12769 | /* initialize queue's entry array */ |