Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2008842ybg; Thu, 24 Oct 2019 03:32:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8gt/6cLS+831HhLgVww1bzYUTjIk4c0ozxlloltayxAAmr9sGjX98z+kr9cjXEoPQeoOd X-Received: by 2002:a17:906:300a:: with SMTP id 10mr37697530ejz.104.1571913141195; Thu, 24 Oct 2019 03:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571913141; cv=none; d=google.com; s=arc-20160816; b=uUU61hUlaRLxZ8QoEj1A52Kf24j63TIGDtXSkF6zQ7ubAoYaQCZccRiYVf6l5rIRgY OvBCFBUGDiYjUrbeCGujMI4aI7QrMOvb08E3o667XwvSyK6DbJHCgyO8mio8SA6KcP74 S7IVf14QDqXBGtEqUYOdvHKeH0DxUgg8j+dBAAzBeGJDGstCmGArmmznuSsmiWRY+4oX 79YbnTgWp9Zc0aOfgHUnw7tD197a0bJJFLWvgXLtxljqu3VjQTfMHDuGxlEMrDvcK9P3 /KKWuKPnzxxbIuTWLBtTtVFNeOu2I7+1icHujNN+mwoHKdMeQSDRxw+MfHyYz6RA3zRe dtcA== 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=M8HISpKj9e/yrpMCh9Wv0iGhJlOU3H0qkGh9FnxnI1I=; b=dxlSXat6il5z4SDDuLPs9oUMvMzCbXzgYhgfNxnvrvATNkqUrXZzFYf9HkaYrV+n0j 8mX2LSFddWq+asYUJTnGC5osV0Y7+u4kkd5yjfviZqyqmZZbKtBfGeW1TA7GtRpbrqsM vvcIy+cBwE6hnTTK3P/qlv8lSZMr1PTDo3u0gSTrxMGnx6gR+EmcqYrix8Ux3EO6Npha W1p0hmxAIcf5fDb7EBQXvKPVV4B5FoNLUXuNpjhHpCJ3V2at69LekT1Jm7s3UyliqnJ9 +MUAI5vSqRCGypn6swYLFDjHw+0e8RBprlMwmJwdLKMFL4XpS4iw72Bt4dJdjvjuGLXA U+uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H6u7Wm0x; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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. [209.132.180.67]) by mx.google.com with ESMTP id g25si15127225edr.71.2019.10.24.03.31.48; Thu, 24 Oct 2019 03:32:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H6u7Wm0x; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 S2436772AbfJWWYc (ORCPT + 99 others); Wed, 23 Oct 2019 18:24:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436651AbfJWWYc (ORCPT ); Wed, 23 Oct 2019 18:24:32 -0400 Received: from lore-desk.lan (unknown [151.66.11.57]) (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 F3A412173B; Wed, 23 Oct 2019 22:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571869471; bh=mRzuMXKMhF/cUZKhXc6fkszUgY7R3oT+oL8NgDG8tLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H6u7Wm0xCvMJIQZ/zb6/F/J5fuosGNlelku980iIFAA6gaDKqX4JLZZCFKUNYsjje +ML14CXt/lrRvGho8lrZTiFjV8+4ilyYvmxPxbmSOkIjGM+XkuPx7inwfSjpQwtyem NqSG1P0OGCzwjYoHcwauaXgHZuQB5CZUOrxK3b70= From: Lorenzo Bianconi To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, nbd@nbd.name, sgruszka@redhat.com, lorenzo.bianconi@redhat.com, oleksandr@natalenko.name, netdev@vger.kernel.org Subject: [PATCH wireless-drivers 2/2] mt76: dma: fix buffer unmap with non-linear skbs Date: Thu, 24 Oct 2019 00:23:16 +0200 Message-Id: <1f7560e10edd517bfd9d3c0dd9820e6f420726b6.1571868221.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: 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 mt76 dma layer is supposed to unmap skb data buffers while keep txwi mapped on hw dma ring. At the moment mt76 wrongly unmap txwi or does not unmap data fragments in even positions for non-linear skbs. This issue may result in hw hangs with A-MSDU if the system relies on IOMMU or SWIOTLB. Fix this behaviour properly unmapping data fragments on non-linear skbs. Fixes: 17f1de56df05 ("mt76: add common code shared between multiple chipsets") Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/dma.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index c747eb24581c..8c27956875e7 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -93,11 +93,14 @@ static void mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx, struct mt76_queue_entry *prev_e) { - struct mt76_queue_entry *e = &q->entry[idx]; __le32 __ctrl = READ_ONCE(q->desc[idx].ctrl); + struct mt76_queue_entry *e = &q->entry[idx]; u32 ctrl = le32_to_cpu(__ctrl); + bool mcu = e->skb && !e->txwi; + bool first = e->skb == DMA_DUMMY_DATA || e->txwi == DMA_DUMMY_DATA || + (e->skb && !skb_is_nonlinear(e->skb)); - if (!e->txwi || !e->skb) { + if (!first || mcu) { __le32 addr = READ_ONCE(q->desc[idx].buf0); u32 len = FIELD_GET(MT_DMA_CTL_SD_LEN0, ctrl); @@ -105,7 +108,8 @@ 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 (!(ctrl & MT_DMA_CTL_LAST_SEC0) || + e->txwi == DMA_DUMMY_DATA) { __le32 addr = READ_ONCE(q->desc[idx].buf1); u32 len = FIELD_GET(MT_DMA_CTL_SD_LEN1, ctrl); -- 2.21.0