aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cnic.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2009-12-02 10:15:39 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-02 22:57:22 -0500
commit3248e1682035eef6774c280cd7be19984feb78bb (patch)
tree1bf8b30825850d35ee0c386ed226e01b54925d8f /drivers/net/cnic.c
parent15971c3ce3caf9a92b603a61b07e0be8c9b9d276 (diff)
cnic: Use dma_alloc_coherent().
Replace pci_alloc_consistent() with dma_alloc_coherent() so that appropriate GFP flags can be used. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cnic.c')
-rw-r--r--drivers/net/cnic.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index d78e8033c954..d4c6e7fcff53 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -667,14 +667,14 @@ static void cnic_free_dma(struct cnic_dev *dev, struct cnic_dma *dma)
667 667
668 for (i = 0; i < dma->num_pages; i++) { 668 for (i = 0; i < dma->num_pages; i++) {
669 if (dma->pg_arr[i]) { 669 if (dma->pg_arr[i]) {
670 pci_free_consistent(dev->pcidev, BCM_PAGE_SIZE, 670 dma_free_coherent(&dev->pcidev->dev, BCM_PAGE_SIZE,
671 dma->pg_arr[i], dma->pg_map_arr[i]); 671 dma->pg_arr[i], dma->pg_map_arr[i]);
672 dma->pg_arr[i] = NULL; 672 dma->pg_arr[i] = NULL;
673 } 673 }
674 } 674 }
675 if (dma->pgtbl) { 675 if (dma->pgtbl) {
676 pci_free_consistent(dev->pcidev, dma->pgtbl_size, 676 dma_free_coherent(&dev->pcidev->dev, dma->pgtbl_size,
677 dma->pgtbl, dma->pgtbl_map); 677 dma->pgtbl, dma->pgtbl_map);
678 dma->pgtbl = NULL; 678 dma->pgtbl = NULL;
679 } 679 }
680 kfree(dma->pg_arr); 680 kfree(dma->pg_arr);
@@ -725,9 +725,10 @@ static int cnic_alloc_dma(struct cnic_dev *dev, struct cnic_dma *dma,
725 dma->num_pages = pages; 725 dma->num_pages = pages;
726 726
727 for (i = 0; i < pages; i++) { 727 for (i = 0; i < pages; i++) {
728 dma->pg_arr[i] = pci_alloc_consistent(dev->pcidev, 728 dma->pg_arr[i] = dma_alloc_coherent(&dev->pcidev->dev,
729 BCM_PAGE_SIZE, 729 BCM_PAGE_SIZE,
730 &dma->pg_map_arr[i]); 730 &dma->pg_map_arr[i],
731 GFP_ATOMIC);
731 if (dma->pg_arr[i] == NULL) 732 if (dma->pg_arr[i] == NULL)
732 goto error; 733 goto error;
733 } 734 }
@@ -736,8 +737,8 @@ static int cnic_alloc_dma(struct cnic_dev *dev, struct cnic_dma *dma,
736 737
737 dma->pgtbl_size = ((pages * 8) + BCM_PAGE_SIZE - 1) & 738 dma->pgtbl_size = ((pages * 8) + BCM_PAGE_SIZE - 1) &
738 ~(BCM_PAGE_SIZE - 1); 739 ~(BCM_PAGE_SIZE - 1);
739 dma->pgtbl = pci_alloc_consistent(dev->pcidev, dma->pgtbl_size, 740 dma->pgtbl = dma_alloc_coherent(&dev->pcidev->dev, dma->pgtbl_size,
740 &dma->pgtbl_map); 741 &dma->pgtbl_map, GFP_ATOMIC);
741 if (dma->pgtbl == NULL) 742 if (dma->pgtbl == NULL)
742 goto error; 743 goto error;
743 744
@@ -757,9 +758,9 @@ static void cnic_free_context(struct cnic_dev *dev)
757 758
758 for (i = 0; i < cp->ctx_blks; i++) { 759 for (i = 0; i < cp->ctx_blks; i++) {
759 if (cp->ctx_arr[i].ctx) { 760 if (cp->ctx_arr[i].ctx) {
760 pci_free_consistent(dev->pcidev, cp->ctx_blk_size, 761 dma_free_coherent(&dev->pcidev->dev, cp->ctx_blk_size,
761 cp->ctx_arr[i].ctx, 762 cp->ctx_arr[i].ctx,
762 cp->ctx_arr[i].mapping); 763 cp->ctx_arr[i].mapping);
763 cp->ctx_arr[i].ctx = NULL; 764 cp->ctx_arr[i].ctx = NULL;
764 } 765 }
765 } 766 }
@@ -781,14 +782,14 @@ static void cnic_free_resc(struct cnic_dev *dev)
781 } 782 }
782 783
783 if (cp->l2_buf) { 784 if (cp->l2_buf) {
784 pci_free_consistent(dev->pcidev, cp->l2_buf_size, 785 dma_free_coherent(&dev->pcidev->dev, cp->l2_buf_size,
785 cp->l2_buf, cp->l2_buf_map); 786 cp->l2_buf, cp->l2_buf_map);
786 cp->l2_buf = NULL; 787 cp->l2_buf = NULL;
787 } 788 }
788 789
789 if (cp->l2_ring) { 790 if (cp->l2_ring) {
790 pci_free_consistent(dev->pcidev, cp->l2_ring_size, 791 dma_free_coherent(&dev->pcidev->dev, cp->l2_ring_size,
791 cp->l2_ring, cp->l2_ring_map); 792 cp->l2_ring, cp->l2_ring_map);
792 cp->l2_ring = NULL; 793 cp->l2_ring = NULL;
793 } 794 }
794 795
@@ -849,8 +850,10 @@ static int cnic_alloc_context(struct cnic_dev *dev)
849 850
850 for (i = 0; i < cp->ctx_blks; i++) { 851 for (i = 0; i < cp->ctx_blks; i++) {
851 cp->ctx_arr[i].ctx = 852 cp->ctx_arr[i].ctx =
852 pci_alloc_consistent(dev->pcidev, BCM_PAGE_SIZE, 853 dma_alloc_coherent(&dev->pcidev->dev,
853 &cp->ctx_arr[i].mapping); 854 BCM_PAGE_SIZE,
855 &cp->ctx_arr[i].mapping,
856 GFP_KERNEL);
854 if (cp->ctx_arr[i].ctx == NULL) 857 if (cp->ctx_arr[i].ctx == NULL)
855 return -ENOMEM; 858 return -ENOMEM;
856 } 859 }
@@ -863,15 +866,17 @@ static int cnic_alloc_l2_rings(struct cnic_dev *dev, int pages)
863 struct cnic_local *cp = dev->cnic_priv; 866 struct cnic_local *cp = dev->cnic_priv;
864 867
865 cp->l2_ring_size = pages * BCM_PAGE_SIZE; 868 cp->l2_ring_size = pages * BCM_PAGE_SIZE;
866 cp->l2_ring = pci_alloc_consistent(dev->pcidev, cp->l2_ring_size, 869 cp->l2_ring = dma_alloc_coherent(&dev->pcidev->dev, cp->l2_ring_size,
867 &cp->l2_ring_map); 870 &cp->l2_ring_map,
871 GFP_KERNEL | __GFP_COMP);
868 if (!cp->l2_ring) 872 if (!cp->l2_ring)
869 return -ENOMEM; 873 return -ENOMEM;
870 874
871 cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; 875 cp->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size;
872 cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size); 876 cp->l2_buf_size = PAGE_ALIGN(cp->l2_buf_size);
873 cp->l2_buf = pci_alloc_consistent(dev->pcidev, cp->l2_buf_size, 877 cp->l2_buf = dma_alloc_coherent(&dev->pcidev->dev, cp->l2_buf_size,
874 &cp->l2_buf_map); 878 &cp->l2_buf_map,
879 GFP_KERNEL | __GFP_COMP);
875 if (!cp->l2_buf) 880 if (!cp->l2_buf)
876 return -ENOMEM; 881 return -ENOMEM;
877 882
@@ -1006,8 +1011,9 @@ static int cnic_alloc_bnx2x_context(struct cnic_dev *dev)
1006 1011
1007 for (i = 0; i < blks; i++) { 1012 for (i = 0; i < blks; i++) {
1008 cp->ctx_arr[i].ctx = 1013 cp->ctx_arr[i].ctx =
1009 pci_alloc_consistent(dev->pcidev, cp->ctx_blk_size, 1014 dma_alloc_coherent(&dev->pcidev->dev, cp->ctx_blk_size,
1010 &cp->ctx_arr[i].mapping); 1015 &cp->ctx_arr[i].mapping,
1016 GFP_KERNEL);
1011 if (cp->ctx_arr[i].ctx == NULL) 1017 if (cp->ctx_arr[i].ctx == NULL)
1012 return -ENOMEM; 1018 return -ENOMEM;
1013 1019