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: 10352993 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 8395F600CC for ; Fri, 20 Apr 2018 15:40:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7008328474 for ; Fri, 20 Apr 2018 15:40:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 631C4287B1; Fri, 20 Apr 2018 15:40:28 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BED2628474 for ; Fri, 20 Apr 2018 15:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=0+lIfkAJwNV12rSXmAFcMuKb1kylfhnXzioYsoA4/hI=; b=oTK QXmERb4P3gCmJyaGBmfNoxtvEv7Zir6jMKQRTppjfIznU4Ib4dgtwPbLNCQ28MpOLEQ4H0O2sls1s v9WF9QvDhixCeqd49C4FUfMWWdj4ZcuA4XL5XVJc7jkT9rwHDWfLXzpoDWvMfqpsK58LPc0el/TSQ KzbRZA/1pYjigcpna0twSiJn3+OKrtPT5zZY5x3T/MhTdhk+XKKhuLbnbH+NhqfSsApgj/Q5HfjLD 8mKzlbbCPx7Npoe7Gcdok9g7sxaa5GHRmW/XT+4yEwpSbOaeCuMweYeHCsyCVrytD3OEnH6B2t6o2 T7HCXyrCnXGCVfn/fZRjfvPV9SSgScw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9Y96-0002to-El; Fri, 20 Apr 2018 15:40:20 +0000 Received: from ch3vs01.rockwellcollins.com ([205.175.226.27]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9Y90-0001xP-Cx for ath10k@lists.infradead.org; Fri, 20 Apr 2018 15:40:17 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_084014_574526_BA40F335 X-CRM114-Status: UNSURE ( 8.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Jared Bents MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.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; }