All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jared Bents <jared.bents@rockwellcollins.com>
To: ath10k@lists.infradead.org
Cc: Jared Bents <jared.bents@rockwellcollins.com>
Subject: [PATCH v1 1/1] ath10k: convert kmemdup to dma_alloc_coherent
Date: Mon, 26 Mar 2018 10:12:02 -0500	[thread overview]
Message-ID: <1522077122-31134-1-git-send-email-jared.bents@rockwellcollins.com> (raw)

Update to convert the use of kmemdup to dma_alloc_coherent as
dma_alloc_coherent will consider DMA region limits such as
those seen with CONFIG_FSL_PCI && CONFIG_ZONE_DMA32 whereas
kmemdup does not take those limitations into account.

Signed-off-by: Jared Bents <jared.bents@rockwellcollins.com>
---
 drivers/net/wireless/ath/ath10k/pci.c | 36 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 3c4c800..8637bfe 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1372,28 +1372,16 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
 	if (resp && resp_len && *resp_len == 0)
 		return -EINVAL;
 
-	treq = kmemdup(req, req_len, GFP_KERNEL);
-	if (!treq)
-		return -ENOMEM;
-
-	req_paddr = dma_map_single(ar->dev, treq, req_len, DMA_TO_DEVICE);
-	ret = dma_mapping_error(ar->dev, req_paddr);
-	if (ret) {
+	treq = dma_alloc_coherent(ar->dev, req_len, &req_paddr, GFP_KERNEL);
+	if (!treq) {
 		ret = -EIO;
 		goto err_dma;
 	}
+	memcpy(treq, req, req_len);
 
 	if (resp && resp_len) {
-		tresp = kzalloc(*resp_len, GFP_KERNEL);
+		tresp = dma_alloc_coherent(ar->dev, *resp_len, &resp_paddr, GFP_KERNEL);
 		if (!tresp) {
-			ret = -ENOMEM;
-			goto err_req;
-		}
-
-		resp_paddr = dma_map_single(ar->dev, tresp, *resp_len,
-					    DMA_FROM_DEVICE);
-		ret = dma_mapping_error(ar->dev, resp_paddr);
-		if (ret) {
 			ret = EIO;
 			goto err_req;
 		}
@@ -1422,23 +1410,19 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
 	}
 
 err_resp:
+	if (ret == 0 && resp_len) {
+		*resp_len = min(*resp_len, xfer.resp_len);
+		memcpy(resp, tresp, xfer.resp_len);
+	}
 	if (resp) {
 		u32 unused_buffer;
 
 		ath10k_ce_revoke_recv_next(ce_rx, NULL, &unused_buffer);
-		dma_unmap_single(ar->dev, resp_paddr,
-				 *resp_len, DMA_FROM_DEVICE);
+		dma_free_coherent(ar->dev, *resp_len, tresp, resp_paddr);
 	}
 err_req:
-	dma_unmap_single(ar->dev, req_paddr, req_len, DMA_TO_DEVICE);
-
-	if (ret == 0 && resp_len) {
-		*resp_len = min(*resp_len, xfer.resp_len);
-		memcpy(resp, tresp, xfer.resp_len);
-	}
+	dma_free_coherent(ar->dev, req_len, treq, req_paddr);
 err_dma:
-	kfree(treq);
-	kfree(tresp);
 
 	return ret;
 }
-- 
1.9.1


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

             reply	other threads:[~2018-03-26 15:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-26 15:12 Jared Bents [this message]
2018-04-13 11:35 ` [PATCH v1 1/1] ath10k: convert kmemdup to dma_alloc_coherent Kalle Valo
2018-04-20 15:39 Jared Bents
2018-04-20 15:39 ` Jared Bents
2018-04-21  7:10 ` Kalle Valo
2018-04-21  7:10   ` Kalle Valo
2018-04-23 18:21   ` Jared Bents
2018-04-23 18:21     ` Jared Bents
2018-04-24  7:32     ` Kalle Valo
2018-04-24  7:32       ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1522077122-31134-1-git-send-email-jared.bents@rockwellcollins.com \
    --to=jared.bents@rockwellcollins.com \
    --cc=ath10k@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.