Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp342482pxa; Wed, 5 Aug 2020 02:34:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR1n6GzBmtv/FmHW6oOMWsBwhBna5o7RuWeeoP2tlYO5BxrG7LCEs6U6uFpQQikXqStgKl X-Received: by 2002:aa7:ce90:: with SMTP id y16mr1936439edv.325.1596620075099; Wed, 05 Aug 2020 02:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596620075; cv=none; d=google.com; s=arc-20160816; b=SmUZl0XqIuWEktAwD7Hif6MS7DX5tdSBoWw+EomyoyWoSVKecTxaRheIptHnM0UAWv jgL5kjJIoeZXXIbD0g0VURCMkfwMj/7kPnmCaaqFRkZBaH9/Ejlxe/GGorHMtOtR+vtc yy0KQ3K1pvVYsvzEL7ehSv2w3dUr2iW+gY/w6TrcZ0lti60WVJmzifJd51oK8auJ5OVj K/pT4e3XzY+v8xBtzdO4Em7qVVso1TRhiBIuB+Mc2+pkw/ILBEVVlJACNbL6dKM8fSEX iJ/NsE7028i30dV6m83JapZqxLcLiNwPrrG2QpVCRMtVS5B8FE4TFT4uJ8b8QuU4RfQI dIOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=d2nQW1/Vrl7bAp6cyjYEOCoVqP5mQdG8nvhubxdmiLM=; b=eNlYrUfPZKni3H3vftBsNR9GOL183b0Et3EzJh+mqaRTeqLdYjwrwgBT1g4cVUmH1A 3IqAqKTP0rdqSHY1XIXhcSjKHR/0Xvv6utt/QX0CODpOO4ut0HKPgiXoyIBACDTMwtPY FLKfq/SkAhwYqtWf/X28x/+xCgCOlwI1le5cMi8/E4V2it92Fjg/Hgx5gLkbs8C/+X12 lDOyA6P/HlZwD8OPeQPxCQJsuuOmFBMikwc3R6F7X6QB0WVpcJ/ztYJ8xq3Td6EGoq7+ /5jjDinOZi2bke5Ut8MWDwzS1Hyz/8q211bY0mYKGU2LG3YlE7fIxb9pRuSjRYX4ISNW 6fCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=bcXxxbyv; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn9si929701ejb.192.2020.08.05.02.34.04; Wed, 05 Aug 2020 02:34:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=bcXxxbyv; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727941AbgHEJdu (ORCPT + 99 others); Wed, 5 Aug 2020 05:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728100AbgHEJck (ORCPT ); Wed, 5 Aug 2020 05:32:40 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B96C061756 for ; Wed, 5 Aug 2020 02:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=d2nQW1/Vrl7bAp6cyjYEOCoVqP5mQdG8nvhubxdmiLM=; b=bcXxxbyvJJGG1MzPR/xUp9ZMjF 9utHHX/HL5FFpByrLaCvyvB88sBAPr5vQEwZIc1QQGXQZC7Efp0p+WJJmeO5XvjX7TV7IxjoEfIjJ wyE9Q3FcLq50v7f7lbjawQgJ5pkCW8I2XTDmklk62ISBieF0TF3MAvtajJAK+B6KaQaQ=; Received: from p54ae996c.dip0.t-ipconnect.de ([84.174.153.108] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1k3Fmn-0008Si-FX for linux-wireless@vger.kernel.org; Wed, 05 Aug 2020 11:32:37 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 2/2] mt76: fix double DMA unmap of the first buffer on 7615/7915 Date: Wed, 5 Aug 2020 11:32:35 +0200 Message-Id: <20200805093235.52506-2-nbd@nbd.name> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200805093235.52506-1-nbd@nbd.name> References: <20200805093235.52506-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org A small part of the first skb buffer is passed to the firmware for parsing via DMA, while the full buffer is passed as part of the TXP. Avoid calling DMA unmap on the first part (with a different length than map) Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/dma.c | 8 +++++++- drivers/net/wireless/mediatek/mt76/mt76.h | 4 +++- drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c | 1 + drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 6c25859dd386..ade2d58b8da9 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -61,10 +61,16 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, for (i = 0; i < nbufs; i += 2, buf += 2) { u32 buf0 = buf[0].addr, buf1 = 0; + if (buf[0].skip_unmap) + q->entry[q->head].skip_buf0 = true; + q->entry[q->head].skip_buf1 = i == nbufs - 1; + ctrl = FIELD_PREP(MT_DMA_CTL_SD_LEN0, buf[0].len); if (i < nbufs - 1) { buf1 = buf[1].addr; ctrl |= FIELD_PREP(MT_DMA_CTL_SD_LEN1, buf[1].len); + if (buf[1].skip_unmap) + q->entry[q->head].skip_buf1 = true; } if (i == nbufs - 1) @@ -107,7 +113,7 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx, DMA_TO_DEVICE); } - if (!(ctrl & MT_DMA_CTL_LAST_SEC0)) { + if (!e->skip_buf1) { __le32 addr = READ_ONCE(q->desc[idx].buf1); u32 len = FIELD_GET(MT_DMA_CTL_SD_LEN1, ctrl); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index a06f8f5abeb2..c7afc1c7cb2f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -79,7 +79,8 @@ enum mt76_rxq_id { struct mt76_queue_buf { dma_addr_t addr; - int len; + u16 len; + bool skip_unmap; }; struct mt76_tx_info { @@ -101,6 +102,7 @@ struct mt76_queue_entry { }; enum mt76_txq_id qid; bool skip_buf0:1; + bool skip_buf1:1; bool schedule:1; bool done:1; }; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c index 2d67f9a148cd..51b2e0467592 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c @@ -107,6 +107,7 @@ mt7615_write_fw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info, /* pass partial skb header to fw */ tx_info->buf[0].len = MT_TXD_SIZE + sizeof(*txp); tx_info->buf[1].len = MT_CT_PARSE_LEN; + tx_info->buf[1].skip_unmap = true; tx_info->nbuf = MT_CT_DMA_BUF_NUM; txp->flags = cpu_to_le16(MT_CT_INFO_APPLY_TXD); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 6825afca1efb..99ab5fca0f6d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -715,6 +715,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, /* pass partial skb header to fw */ tx_info->buf[1].len = MT_CT_PARSE_LEN; + tx_info->buf[1].skip_unmap = true; tx_info->nbuf = MT_CT_DMA_BUF_NUM; txp->flags = cpu_to_le16(MT_CT_INFO_APPLY_TXD); -- 2.24.0