From patchwork Mon Mar 26 15:12:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jared Bents X-Patchwork-Id: 10308061 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 4E40860386 for ; Mon, 26 Mar 2018 15:12:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3361128FC7 for ; Mon, 26 Mar 2018 15:12:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24E2F29715; Mon, 26 Mar 2018 15:12:32 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 8B6BA29713 for ; Mon, 26 Mar 2018 15:12:31 +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=E3M cyDLCTgkSgZHAoitT9aKijnQtPfGp6eXA3m78AbtempMltoFp6Hp60ukbPQKyFyDf6ejNg60Ub2EH RjIOvOGMrNrq3tKQtjAumaPDHruuz2AT7p5GPEiDLa8RFHL+ArV786NUunHnY82SZ1wKggIIGHVwb 96FUPy83kAueEtF2pHTWxm4NZt4tz9nYvha1oap48Z6j0Izo3OEMlaG27A1fX24bADVRS0q5KHJAd nJzz1q/FcTU8mi0IrlcYLF/2yX+Y9MllLzJGqAzbVw1WpTUMLwoYnANblNrTL75fASIamkoCIRi59 z1Nx5p2CzOKG09eALRJmXmY6NNWC1Tg==; 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 1f0TnN-0004YH-UV; Mon, 26 Mar 2018 15:12:25 +0000 Received: from da1vs02.rockwellcollins.com ([205.175.227.29]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0TnH-0004Uk-40 for ath10k@lists.infradead.org; Mon, 26 Mar 2018 15:12:24 +0000 Received: from ofwda1n02.rockwellcollins.com (HELO crulimr01.rockwellcollins.com) ([205.175.227.14]) by da1vs02.rockwellcollins.com with ESMTP; 26 Mar 2018 10:12:07 -0500 X-Received: from largo.rockwellcollins.com (unknown [192.168.140.76]) by crulimr01.rockwellcollins.com (Postfix) with ESMTP id C35FC6027B; Mon, 26 Mar 2018 10:12:06 -0500 (CDT) From: Jared Bents To: ath10k@lists.infradead.org Subject: [PATCH v1 1/1] ath10k: convert kmemdup to dma_alloc_coherent Date: Mon, 26 Mar 2018 10:12:02 -0500 Message-Id: <1522077122-31134-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-20180326_081219_249853_AB43BC32 X-CRM114-Status: UNSURE ( 8.81 ) 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: 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; }