From patchwork Mon Mar 11 12:35:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10847415 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22EF91515 for ; Mon, 11 Mar 2019 12:35:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D69B28C35 for ; Mon, 11 Mar 2019 12:35:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01D3128E6B; Mon, 11 Mar 2019 12:35:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 A1F0428C35 for ; Mon, 11 Mar 2019 12:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727219AbfCKMfz (ORCPT ); Mon, 11 Mar 2019 08:35:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:51044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbfCKMfy (ORCPT ); Mon, 11 Mar 2019 08:35:54 -0400 Received: from localhost.localdomain (unknown [151.66.48.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 40A052084F; Mon, 11 Mar 2019 12:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552307754; bh=XSWTr19u5U8iGiZwuXk2fkCwpeqjXaEW5p+vIsS3vxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sns+rnDbX1d3tvIhtLCLTpyX4Uc9ubuHROPKLCH0HxgUFm9rYKeXiW5Orpuy8I6ii 3Z+o9eHyS8xL524cqMkt4UbofU8jBP1dHJWLdFPDtk6aGAmSlLoOhp/Eae9ata73Ht bl3PoWrTLVJefs3JrEIf6RPNVawCd6dwRImnN4LA= From: Lorenzo Bianconi To: nbd@nbd.name Cc: ryder.lee@mediatek.com, roychl666@gmail.com, linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com Subject: [PATCH 3/4] mt76: move skb dma mapping before running tx_prepare_skb Date: Mon, 11 Mar 2019 13:35:25 +0100 Message-Id: <34d158de1d7476e03ade43c2c974363f18e042f8.1552306908.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 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 Move skb dma mapping before configuring txwi since new chipsets (mt7615) will need skb dma addresses in order to properly configure txwi Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/dma.c | 29 ++++++++++-------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 14dd6585bab4..a29b2aa95a51 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -287,11 +287,10 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, struct mt76_queue_entry e; struct mt76_txwi_cache *t; struct mt76_queue_buf buf[32]; + int len, n = 0, ret = -ENOMEM; struct sk_buff *iter; dma_addr_t addr; - int len; u32 tx_info = 0; - int n, ret; t = mt76_get_txwi(dev); if (!t) { @@ -303,23 +302,11 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, if (dev->drv->tx_aligned4_skbs) mt76_insert_hdr_pad(skb); - dma_sync_single_for_cpu(dev->dev, t->dma_addr, sizeof(t->txwi), - DMA_TO_DEVICE); - ret = dev->drv->tx_prepare_skb(dev, &t->txwi, skb, qid, wcid, sta, - &tx_info); - dma_sync_single_for_device(dev->dev, t->dma_addr, sizeof(t->txwi), - DMA_TO_DEVICE); - if (ret < 0) - goto free; - - len = skb->len - skb->data_len; + len = skb_headlen(skb); addr = dma_map_single(dev->dev, skb->data, len, DMA_TO_DEVICE); - if (dma_mapping_error(dev->dev, addr)) { - ret = -ENOMEM; + if (dma_mapping_error(dev->dev, addr)) goto free; - } - n = 0; buf[n].addr = t->dma_addr; buf[n++].len = dev->drv->txwi_size; buf[n].addr = addr; @@ -341,10 +328,18 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid, if (q->queued + (n + 1) / 2 >= q->ndesc - 1) goto unmap; + dma_sync_single_for_cpu(dev->dev, t->dma_addr, sizeof(t->txwi), + DMA_TO_DEVICE); + ret = dev->drv->tx_prepare_skb(dev, &t->txwi, skb, qid, wcid, sta, + &tx_info); + dma_sync_single_for_device(dev->dev, t->dma_addr, sizeof(t->txwi), + DMA_TO_DEVICE); + if (ret < 0) + goto unmap; + return mt76_dma_add_buf(dev, q, buf, n, tx_info, skb, t); unmap: - ret = -ENOMEM; for (n--; n > 0; n--) dma_unmap_single(dev->dev, buf[n].addr, buf[n].len, DMA_TO_DEVICE);