Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp110254ybg; Mon, 8 Jun 2020 17:53:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi4gC2JvMPiGvGZu9GCPxdaGTKf6Toiq2K+lRsOuz2sm7xX4SKLG4++CWXZCwtDlFIYHN5 X-Received: by 2002:a50:eb0c:: with SMTP id y12mr23823368edp.165.1591664011439; Mon, 08 Jun 2020 17:53:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664011; cv=none; d=google.com; s=arc-20160816; b=Q76cxYiX3JZv/OXC9G7kTboOP6O1tdRplTYunqp1olB4LiCxGUMh+VOMdJQxvhUWEE CRAR9waLzyRYXDUI3JP7EXhAAW0XRYimwrqGMl2Pm/zU3ONrkX2ttnEAu6DlNiP+RRCu 70tav8M1dYwghsV5Mtjfen6egVT9/IFlFJvQFt8VB8V7kQrG5Z122aKfG515oFudYoUZ H2uYjhS1wwkITqnkyTR7iA/TkEwLjLtybtIM6oYnfKO4BtzXudNyfyEV1zqfQVsBH93C rHV0RiqxOj+ryk4DRpKqWGOhdSbY8EIF21ZIX3rmcZyi8AYCDH0hkMx6pEQvui6ypCq3 IrdQ== 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:cc:to:from :dkim-signature; bh=TaXzFwNG4tjtn4Y+GKRpM6sX/1Tcv+Y+Icwsr6NAL6E=; b=zbYzCq2grlyZDqJzdrtSCZyoAF6223OvZ0MeMbS7P9QWYydX/xmgNLcCCaHBJDDqpw KPGp457kn27nkbCM7NLVBxQjc/Fb/rRjizomodkyyvYIO34CjIW1OVjRs19Z3zGz6dMP isIUDQ3jurE/hIKx2U44BMANkAkoouNU7CgMDqv8NpMOH9ngHUwu9JKqWwIsO/WxKnDh WK2wMwDiflkJts7zJlInFwb2ZPc7y8wylrTm04B0EgYy62Y7kLaYt2O40wH7Mzvzf8Jo yop4nlwsVvgylEbujVbY0HUQHAi7SDNGzS8AVbb0npFmt5d8+ssBQNyjeYfSqBuuOENC YYkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QsVV9tZc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si10518069edr.214.2020.06.08.17.53.08; Mon, 08 Jun 2020 17:53:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QsVV9tZc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbgFIAvP (ORCPT + 99 others); Mon, 8 Jun 2020 20:51:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:56472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728628AbgFHXKU (ORCPT ); Mon, 8 Jun 2020 19:10:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30931208B8; Mon, 8 Jun 2020 23:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657820; bh=wwX3oMSrctskPbGkvudSONYgRfHBUkGW7Urvxsugfos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QsVV9tZcHDRoGkUFwAUS3YCpoybfjeEge99/f7AnUG/ZrAkMd8t45OFEaUyMvy1dz 4Af1PGKLppJ5LpRYphJ7ENVmgUTHWJqlc6PA8BamO7fDhk8oxyoPY9H7AnGBs570Vq sKUCBTuFB9uhdfxWy5dwG4QecFxhclyQ1q1zCcCo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lorenzo Bianconi , Sean Wang , Soul Huang , Sasha Levin , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.7 193/274] mt76: mt7663: fix DMA unmap length Date: Mon, 8 Jun 2020 19:04:46 -0400 Message-Id: <20200608230607.3361041-193-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit 89829c9e65ab680f7e5a1658cb74bc6316ab036e ] Fix DMA unmap length for mt7663e devices in mt7615_txp_skb_unmap_hw Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support") Co-developed-by: Sean Wang Signed-off-by: Sean Wang Co-developed-by: Soul Huang Signed-off-by: Soul Huang Signed-off-by: Lorenzo Bianconi Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7615/mac.c | 20 +++++++++++++------ .../net/wireless/mediatek/mt76/mt7615/mac.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index b5249d08564c..f66b76ff2978 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -666,15 +666,18 @@ mt7615_txp_skb_unmap_fw(struct mt76_dev *dev, struct mt7615_fw_txp *txp) static void mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp) { + u32 last_mask; int i; + last_mask = is_mt7663(dev) ? MT_TXD_LEN_LAST : MT_TXD_LEN_MSDU_LAST; + for (i = 0; i < ARRAY_SIZE(txp->ptr); i++) { struct mt7615_txp_ptr *ptr = &txp->ptr[i]; bool last; u16 len; len = le16_to_cpu(ptr->len0); - last = len & MT_TXD_LEN_MSDU_LAST; + last = len & last_mask; len &= MT_TXD_LEN_MASK; dma_unmap_single(dev->dev, le32_to_cpu(ptr->buf0), len, DMA_TO_DEVICE); @@ -682,7 +685,7 @@ mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp) break; len = le16_to_cpu(ptr->len1); - last = len & MT_TXD_LEN_MSDU_LAST; + last = len & last_mask; len &= MT_TXD_LEN_MASK; dma_unmap_single(dev->dev, le32_to_cpu(ptr->buf1), len, DMA_TO_DEVICE); @@ -1098,21 +1101,26 @@ mt7615_write_hw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info, { struct mt7615_hw_txp *txp = txp_ptr; struct mt7615_txp_ptr *ptr = &txp->ptr[0]; - int nbuf = tx_info->nbuf - 1; - int i; + int i, nbuf = tx_info->nbuf - 1; + u32 last_mask; tx_info->buf[0].len = MT_TXD_SIZE + sizeof(*txp); tx_info->nbuf = 1; txp->msdu_id[0] = cpu_to_le16(id | MT_MSDU_ID_VALID); + if (is_mt7663(&dev->mt76)) + last_mask = MT_TXD_LEN_LAST; + else + last_mask = MT_TXD_LEN_AMSDU_LAST | + MT_TXD_LEN_MSDU_LAST; + for (i = 0; i < nbuf; i++) { u16 len = tx_info->buf[i + 1].len & MT_TXD_LEN_MASK; u32 addr = tx_info->buf[i + 1].addr; if (i == nbuf - 1) - len |= MT_TXD_LEN_MSDU_LAST | - MT_TXD_LEN_AMSDU_LAST; + len |= last_mask; if (i & 1) { ptr->buf1 = cpu_to_le32(addr); diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.h b/drivers/net/wireless/mediatek/mt76/mt7615/mac.h index 53ac184ab2d6..d3da40df7f32 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.h @@ -255,6 +255,8 @@ enum tx_phy_bandwidth { #define MT_TXD_LEN_MASK GENMASK(11, 0) #define MT_TXD_LEN_MSDU_LAST BIT(14) #define MT_TXD_LEN_AMSDU_LAST BIT(15) +/* mt7663 */ +#define MT_TXD_LEN_LAST BIT(15) struct mt7615_txp_ptr { __le32 buf0; -- 2.25.1