diff options
author | Michal Kazior <michal.kazior@tieto.com> | 2014-03-28 04:02:35 -0400 |
---|---|---|
committer | Kalle Valo <kvalo@qca.qualcomm.com> | 2014-03-28 08:32:01 -0400 |
commit | 68c03249f388aafe74f0e87e2743294d4384c00c (patch) | |
tree | 2c85edaa02f4ae855d873da75f0ad56f7d277205 | |
parent | c508671dd589e75c0d5092a0a3c15d0375d3ce48 (diff) |
ath10k: convert pci_alloc_consistent() to dma_alloc_coherent()
This allows to use GFP_KERNEL allocation. This
should decrease chance of allocation failure, e.g.
during firmware recovery.
Reported-By: Avery Pennarun <apenwarr@gmail.com>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
-rw-r--r-- | drivers/net/wireless/ath/ath10k/ce.c | 53 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath10k/pci.c | 22 |
2 files changed, 37 insertions, 38 deletions
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c index a79499c82350..653a240142e5 100644 --- a/drivers/net/wireless/ath/ath10k/ce.c +++ b/drivers/net/wireless/ath/ath10k/ce.c | |||
@@ -843,7 +843,6 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, | |||
843 | struct ath10k_ce_pipe *ce_state, | 843 | struct ath10k_ce_pipe *ce_state, |
844 | const struct ce_attr *attr) | 844 | const struct ce_attr *attr) |
845 | { | 845 | { |
846 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
847 | struct ath10k_ce_ring *src_ring; | 846 | struct ath10k_ce_ring *src_ring; |
848 | unsigned int nentries = attr->src_nentries; | 847 | unsigned int nentries = attr->src_nentries; |
849 | unsigned int ce_nbytes; | 848 | unsigned int ce_nbytes; |
@@ -885,10 +884,10 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, | |||
885 | * coherent DMA are unsupported | 884 | * coherent DMA are unsupported |
886 | */ | 885 | */ |
887 | src_ring->base_addr_owner_space_unaligned = | 886 | src_ring->base_addr_owner_space_unaligned = |
888 | pci_alloc_consistent(ar_pci->pdev, | 887 | dma_alloc_coherent(ar->dev, |
889 | (nentries * sizeof(struct ce_desc) + | 888 | (nentries * sizeof(struct ce_desc) + |
890 | CE_DESC_RING_ALIGN), | 889 | CE_DESC_RING_ALIGN), |
891 | &base_addr); | 890 | &base_addr, GFP_KERNEL); |
892 | if (!src_ring->base_addr_owner_space_unaligned) { | 891 | if (!src_ring->base_addr_owner_space_unaligned) { |
893 | kfree(ce_state->src_ring); | 892 | kfree(ce_state->src_ring); |
894 | ce_state->src_ring = NULL; | 893 | ce_state->src_ring = NULL; |
@@ -912,11 +911,11 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar, | |||
912 | kmalloc((nentries * sizeof(struct ce_desc) + | 911 | kmalloc((nentries * sizeof(struct ce_desc) + |
913 | CE_DESC_RING_ALIGN), GFP_KERNEL); | 912 | CE_DESC_RING_ALIGN), GFP_KERNEL); |
914 | if (!src_ring->shadow_base_unaligned) { | 913 | if (!src_ring->shadow_base_unaligned) { |
915 | pci_free_consistent(ar_pci->pdev, | 914 | dma_free_coherent(ar->dev, |
916 | (nentries * sizeof(struct ce_desc) + | 915 | (nentries * sizeof(struct ce_desc) + |
917 | CE_DESC_RING_ALIGN), | 916 | CE_DESC_RING_ALIGN), |
918 | src_ring->base_addr_owner_space, | 917 | src_ring->base_addr_owner_space, |
919 | src_ring->base_addr_ce_space); | 918 | src_ring->base_addr_ce_space); |
920 | kfree(ce_state->src_ring); | 919 | kfree(ce_state->src_ring); |
921 | ce_state->src_ring = NULL; | 920 | ce_state->src_ring = NULL; |
922 | return -ENOMEM; | 921 | return -ENOMEM; |
@@ -946,7 +945,6 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar, | |||
946 | struct ath10k_ce_pipe *ce_state, | 945 | struct ath10k_ce_pipe *ce_state, |
947 | const struct ce_attr *attr) | 946 | const struct ce_attr *attr) |
948 | { | 947 | { |
949 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
950 | struct ath10k_ce_ring *dest_ring; | 948 | struct ath10k_ce_ring *dest_ring; |
951 | unsigned int nentries = attr->dest_nentries; | 949 | unsigned int nentries = attr->dest_nentries; |
952 | unsigned int ce_nbytes; | 950 | unsigned int ce_nbytes; |
@@ -986,10 +984,10 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar, | |||
986 | * coherent DMA are unsupported | 984 | * coherent DMA are unsupported |
987 | */ | 985 | */ |
988 | dest_ring->base_addr_owner_space_unaligned = | 986 | dest_ring->base_addr_owner_space_unaligned = |
989 | pci_alloc_consistent(ar_pci->pdev, | 987 | dma_alloc_coherent(ar->dev, |
990 | (nentries * sizeof(struct ce_desc) + | 988 | (nentries * sizeof(struct ce_desc) + |
991 | CE_DESC_RING_ALIGN), | 989 | CE_DESC_RING_ALIGN), |
992 | &base_addr); | 990 | &base_addr, GFP_KERNEL); |
993 | if (!dest_ring->base_addr_owner_space_unaligned) { | 991 | if (!dest_ring->base_addr_owner_space_unaligned) { |
994 | kfree(ce_state->dest_ring); | 992 | kfree(ce_state->dest_ring); |
995 | ce_state->dest_ring = NULL; | 993 | ce_state->dest_ring = NULL; |
@@ -1112,26 +1110,25 @@ out: | |||
1112 | void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state) | 1110 | void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state) |
1113 | { | 1111 | { |
1114 | struct ath10k *ar = ce_state->ar; | 1112 | struct ath10k *ar = ce_state->ar; |
1115 | struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); | ||
1116 | 1113 | ||
1117 | if (ce_state->src_ring) { | 1114 | if (ce_state->src_ring) { |
1118 | kfree(ce_state->src_ring->shadow_base_unaligned); | 1115 | kfree(ce_state->src_ring->shadow_base_unaligned); |
1119 | pci_free_consistent(ar_pci->pdev, | 1116 | dma_free_coherent(ar->dev, |
1120 | (ce_state->src_ring->nentries * | 1117 | (ce_state->src_ring->nentries * |
1121 | sizeof(struct ce_desc) + | 1118 | sizeof(struct ce_desc) + |
1122 | CE_DESC_RING_ALIGN), | 1119 | CE_DESC_RING_ALIGN), |
1123 | ce_state->src_ring->base_addr_owner_space, | 1120 | ce_state->src_ring->base_addr_owner_space, |
1124 | ce_state->src_ring->base_addr_ce_space); | 1121 | ce_state->src_ring->base_addr_ce_space); |
1125 | kfree(ce_state->src_ring); | 1122 | kfree(ce_state->src_ring); |
1126 | } | 1123 | } |
1127 | 1124 | ||
1128 | if (ce_state->dest_ring) { | 1125 | if (ce_state->dest_ring) { |
1129 | pci_free_consistent(ar_pci->pdev, | 1126 | dma_free_coherent(ar->dev, |
1130 | (ce_state->dest_ring->nentries * | 1127 | (ce_state->dest_ring->nentries * |
1131 | sizeof(struct ce_desc) + | 1128 | sizeof(struct ce_desc) + |
1132 | CE_DESC_RING_ALIGN), | 1129 | CE_DESC_RING_ALIGN), |
1133 | ce_state->dest_ring->base_addr_owner_space, | 1130 | ce_state->dest_ring->base_addr_owner_space, |
1134 | ce_state->dest_ring->base_addr_ce_space); | 1131 | ce_state->dest_ring->base_addr_ce_space); |
1135 | kfree(ce_state->dest_ring); | 1132 | kfree(ce_state->dest_ring); |
1136 | } | 1133 | } |
1137 | 1134 | ||
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index dd34ac9a682f..337af7e22b30 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c | |||
@@ -358,9 +358,10 @@ static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data, | |||
358 | * 2) Buffer in DMA-able space | 358 | * 2) Buffer in DMA-able space |
359 | */ | 359 | */ |
360 | orig_nbytes = nbytes; | 360 | orig_nbytes = nbytes; |
361 | data_buf = (unsigned char *)pci_alloc_consistent(ar_pci->pdev, | 361 | data_buf = (unsigned char *)dma_alloc_coherent(ar->dev, |
362 | orig_nbytes, | 362 | orig_nbytes, |
363 | &ce_data_base); | 363 | &ce_data_base, |
364 | GFP_ATOMIC); | ||
364 | 365 | ||
365 | if (!data_buf) { | 366 | if (!data_buf) { |
366 | ret = -ENOMEM; | 367 | ret = -ENOMEM; |
@@ -458,8 +459,8 @@ done: | |||
458 | address, ret); | 459 | address, ret); |
459 | 460 | ||
460 | if (data_buf) | 461 | if (data_buf) |
461 | pci_free_consistent(ar_pci->pdev, orig_nbytes, | 462 | dma_free_coherent(ar->dev, orig_nbytes, data_buf, |
462 | data_buf, ce_data_base); | 463 | ce_data_base); |
463 | 464 | ||
464 | return ret; | 465 | return ret; |
465 | } | 466 | } |
@@ -502,9 +503,10 @@ static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, | |||
502 | * 2) Buffer in DMA-able space | 503 | * 2) Buffer in DMA-able space |
503 | */ | 504 | */ |
504 | orig_nbytes = nbytes; | 505 | orig_nbytes = nbytes; |
505 | data_buf = (unsigned char *)pci_alloc_consistent(ar_pci->pdev, | 506 | data_buf = (unsigned char *)dma_alloc_coherent(ar->dev, |
506 | orig_nbytes, | 507 | orig_nbytes, |
507 | &ce_data_base); | 508 | &ce_data_base, |
509 | GFP_ATOMIC); | ||
508 | if (!data_buf) { | 510 | if (!data_buf) { |
509 | ret = -ENOMEM; | 511 | ret = -ENOMEM; |
510 | goto done; | 512 | goto done; |
@@ -600,8 +602,8 @@ static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, | |||
600 | 602 | ||
601 | done: | 603 | done: |
602 | if (data_buf) { | 604 | if (data_buf) { |
603 | pci_free_consistent(ar_pci->pdev, orig_nbytes, data_buf, | 605 | dma_free_coherent(ar->dev, orig_nbytes, data_buf, |
604 | ce_data_base); | 606 | ce_data_base); |
605 | } | 607 | } |
606 | 608 | ||
607 | if (ret != 0) | 609 | if (ret != 0) |