From patchwork Fri Apr 20 15:39:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jared Bents X-Patchwork-Id: 10353029 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD67C6023A for ; Fri, 20 Apr 2018 15:49:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF81F287BB for ; Fri, 20 Apr 2018 15:49:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B45D3287BE; Fri, 20 Apr 2018 15:49:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AA1B287BB for ; Fri, 20 Apr 2018 15:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755848AbeDTPth (ORCPT ); Fri, 20 Apr 2018 11:49:37 -0400 Received: from ch3vs01.rockwellcollins.com ([205.175.226.27]:64191 "EHLO ch3vs01.rockwellcollins.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755836AbeDTPte (ORCPT ); Fri, 20 Apr 2018 11:49:34 -0400 X-Greylist: delayed 574 seconds by postgrey-1.27 at vger.kernel.org; Fri, 20 Apr 2018 11:49:34 EDT Received: from ofwch3n02.rockwellcollins.com (HELO dtulimr01.rockwellcollins.com) ([205.175.226.14]) by ch3vs01.rockwellcollins.com with ESMTP; 20 Apr 2018 10:39:59 -0500 X-Received: from largo.rockwellcollins.com (unknown [192.168.140.76]) by dtulimr01.rockwellcollins.com (Postfix) with ESMTP id 98FED601D6; Fri, 20 Apr 2018 10:39:59 -0500 (CDT) From: Jared Bents To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Jared Bents Subject: [PATCH v1 1/1] ath10k: convert kmemdup to dma_alloc_coherent Date: Fri, 20 Apr 2018 10:39:53 -0500 Message-Id: <1524238793-24481-1-git-send-email-jared.bents@rockwellcollins.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }