From patchwork Thu Jan 21 13:13:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 8081061 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 69C369F96D for ; Thu, 21 Jan 2016 13:12:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9814720411 for ; Thu, 21 Jan 2016 13:12:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C05342041E for ; Thu, 21 Jan 2016 13:12:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMF2j-0001Tg-3S; Thu, 21 Jan 2016 13:12:53 +0000 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMF2c-0001Nc-PW for ath10k@lists.infradead.org; Thu, 21 Jan 2016 13:12:48 +0000 Received: by mail-lf0-x22d.google.com with SMTP id m198so26302174lfm.0 for ; Thu, 21 Jan 2016 05:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ckq98Z3gTItB/Nzv5TKeQAehWwUJXglnQfv7b3B7BsM=; b=2TP74L/Z6MrxldKKAd2waBSf41xeY5DAODDHxeDnjknb9nbTNcHQJrWz3SwwHjGD3Y BJq6BgfiwtR5PmqgIrCbXiV9Uj8peQ1TZGDwmmr4zf6FIWC0VT7/mPX0K6/o4AUaKORP qdh88R9rn+zWsS3gKi5080ra8kaShTtet/Kto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ckq98Z3gTItB/Nzv5TKeQAehWwUJXglnQfv7b3B7BsM=; b=W3/aQncqmeiv0pP7hsGpxDZFn8zvO3FLq1cFjKQu7dN77qBqwm3brkxTV2/yI9iQyr VqD5lIGqBbd+KbMcWLy3EHkEzy28RwJoaQkAHlZc/tEqptzcMHKhuoCG5JOxU8LpXc2d PWOw5XlDEqfKO5XbFnn0I/9p6siwCcxneTlXGUXd/SI9g6TNxsCHev8/b5w7yNeS8loY kugzd4EhWjG1o90G4qoY4TQ23XqaHVfVvGXBIXvZX+I6+yxDchq+wdwDAvxdG6k+Oq99 RkxbBneWrbG4QS6+4cakcn0vSWZPoO98MwbvLclQ7PZT+FxwpasVaOges0Jh6lM0NKMP 912w== X-Gm-Message-State: ALoCoQnUFvfQhFljpWu/0IjEQHtNIfgkNi6+Ic7hd7HXLSWdyvCKaN/YDeQWUWtpYU4dN35HtoYWX87iM2tOlrUDbaIlUsWxtGL8ln+WVCyfdCsLj5CvOjKTUm78LuFYAW93/51k1qwScvzc3LFHwzXwLLK4dKWbmiy++b9oi7SZWuUGrMeceTzqh+G2p/qoP0GjkRyLQANHb6S9Aa7oSQ5YZ4WbKxAgFQ== X-Received: by 10.25.18.89 with SMTP id h86mr12568178lfi.165.1453381944895; Thu, 21 Jan 2016 05:12:24 -0800 (PST) Received: from localhost.localdomain ([91.198.246.10]) by smtp.gmail.com with ESMTPSA id tv1sm189406lbb.4.2016.01.21.05.12.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 05:12:23 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Subject: [PATCH 4/5] ath10k: clean up cont frag desc init code Date: Thu, 21 Jan 2016 14:13:26 +0100 Message-Id: <1453382007-24622-5-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453382007-24622-1-git-send-email-michal.kazior@tieto.com> References: <1452693668-30030-1-git-send-email-michal.kazior@tieto.com> <1453382007-24622-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160121_051247_186177_4D076D01 X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -2.7 (--) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Michal Kazior MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This makes the code easier to extend and re-use. While at it fix _warn to _err. Other than that there are no functional changes. Signed-off-by: Michal Kazior --- Notes: v2: * fix gfp allocation [Ben] drivers/net/wireless/ath/ath10k/htt_tx.c | 58 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c index b3adadb5f824..28b8d7af8506 100644 --- a/drivers/net/wireless/ath/ath10k/htt_tx.c +++ b/drivers/net/wireless/ath/ath10k/htt_tx.c @@ -97,6 +97,41 @@ void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id) idr_remove(&htt->pending_tx, msdu_id); } +static void ath10k_htt_tx_free_cont_frag_desc(struct ath10k_htt *htt) +{ + size_t size; + + if (!htt->frag_desc.vaddr) + return; + + size = htt->max_num_pending_tx * sizeof(struct htt_msdu_ext_desc); + + dma_free_coherent(htt->ar->dev, + size, + htt->frag_desc.vaddr, + htt->frag_desc.paddr); +} + +static int ath10k_htt_tx_alloc_cont_frag_desc(struct ath10k_htt *htt) +{ + struct ath10k *ar = htt->ar; + size_t size; + + if (!ar->hw_params.continuous_frag_desc) + return 0; + + size = htt->max_num_pending_tx * sizeof(struct htt_msdu_ext_desc); + htt->frag_desc.vaddr = dma_alloc_coherent(ar->dev, size, + &htt->frag_desc.paddr, + GFP_KERNEL); + if (!htt->frag_desc.vaddr) { + ath10k_err(ar, "failed to alloc fragment desc memory\n"); + return -ENOMEM; + } + + return 0; +} + int ath10k_htt_tx_alloc(struct ath10k_htt *htt) { struct ath10k *ar = htt->ar; @@ -118,20 +153,12 @@ int ath10k_htt_tx_alloc(struct ath10k_htt *htt) goto free_idr_pending_tx; } - if (!ar->hw_params.continuous_frag_desc) - goto skip_frag_desc_alloc; - - size = htt->max_num_pending_tx * sizeof(struct htt_msdu_ext_desc); - htt->frag_desc.vaddr = dma_alloc_coherent(ar->dev, size, - &htt->frag_desc.paddr, - GFP_KERNEL); - if (!htt->frag_desc.vaddr) { - ath10k_warn(ar, "failed to alloc fragment desc memory\n"); - ret = -ENOMEM; + ret = ath10k_htt_tx_alloc_cont_frag_desc(htt); + if (ret) { + ath10k_err(ar, "failed to alloc cont frag desc: %d\n", ret); goto free_txbuf; } -skip_frag_desc_alloc: return 0; free_txbuf: @@ -139,8 +166,10 @@ free_txbuf: sizeof(struct ath10k_htt_txbuf); dma_free_coherent(htt->ar->dev, size, htt->txbuf.vaddr, htt->txbuf.paddr); + free_idr_pending_tx: idr_destroy(&htt->pending_tx); + return ret; } @@ -174,12 +203,7 @@ void ath10k_htt_tx_free(struct ath10k_htt *htt) htt->txbuf.paddr); } - if (htt->frag_desc.vaddr) { - size = htt->max_num_pending_tx * - sizeof(struct htt_msdu_ext_desc); - dma_free_coherent(htt->ar->dev, size, htt->frag_desc.vaddr, - htt->frag_desc.paddr); - } + ath10k_htt_tx_free_cont_frag_desc(htt); } void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)