Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2827667ybg; Thu, 24 Oct 2019 16:08:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOVtYYvuiWT9Rzjb65wp+irzkRVhkqHcLafjNUsakedDHTRQLEKnS4DT0u0wi7JZLrhBDg X-Received: by 2002:aa7:de1a:: with SMTP id h26mr660852edv.289.1571958508212; Thu, 24 Oct 2019 16:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571958508; cv=none; d=google.com; s=arc-20160816; b=ddsW4jvv8ZckD7LMJmDku6KiarH13cSFxIs1VdwV+8gXTlR76KC1aVW+WJDibtoaPR pgpOvdcXhzqxDKShQegaXUaf3uLDpjDqSMAGz7snsyYTBT21/+1FjLcQkKPu871a1wTd iBn/7NmGPP7+kaM8MdW0eWOxU6ZAjitxRNxJRXTpIoWDn471A//IdGTt3duE3BXoU7Tc /cdET8BvbQ6YMH+laaTm120KeRdeHq/UR6WVP1Rykb+gbm2uhLm3CY2M3dIVbZlTLOji eduHfZETwTylev4apMorlj+p8PhxMuUGgPQIXpCXgPRQAbfN1MjQnuB2epOXgfQEz1Bq 7v4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iUU4XisJlicj+W2Ht8NrSYQhFK2TGjm36W78eDFsQYw=; b=fkpDnmacW3tno2sxwC1d6gcB/AujSQbg4ONCi5eQwTSIyIu/5hanJB0rO7uEJgJyIN wzhMLAue2+eig6CDE492HhKTBX4/nRuhbXsjWE+f/r/qDB86LseSfgGZgR578IIFRrGK 3JhTWpPIh14sfRy5zkZkDoBpI4tPu2/Uk/Cue0KzzHNmeFgT4/+CqdXfs/iGEyC2rxfp AT/QjbRsYPWMovsBLBM2Ag72D7eX8NXzJaaMOCxyo5K4/hbxfUykcqsaOfih2XbQWmbr ftNO0/tz9wUz3WRtNET4W6jNDmJiCKFHn422zAyB8AAHa14z2AUpjZlEVPRjwE3wvirr fIRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e9FSky7X; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gg26si137920ejb.142.2019.10.24.16.08.02; Thu, 24 Oct 2019 16:08:28 -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=@redhat.com header.s=mimecast20190719 header.b=e9FSky7X; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438074AbfJXIS2 (ORCPT + 99 others); Thu, 24 Oct 2019 04:18:28 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23807 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726395AbfJXIS2 (ORCPT ); Thu, 24 Oct 2019 04:18:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571905106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iUU4XisJlicj+W2Ht8NrSYQhFK2TGjm36W78eDFsQYw=; b=e9FSky7XQbJKdqQYmJXOVh1BLYPy6PE1z7vYcuPgocFQjq7Aj5DEgFeiozjtLAdw9tJ3Hy hzPfnWn28Fn+lnxFwYtJd2c9rLrD5cSnLwKInCT17zGLCU1rF4q6kji7Mm3fIX7WPtJFia 4DXTvN/NZOTYRbQAhip2GcVr2TvVIlo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-9zpOSi7ZMAaRh8uSwKlnsA-1; Thu, 24 Oct 2019 04:18:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44ACF107AD31; Thu, 24 Oct 2019 08:18:24 +0000 (UTC) Received: from localhost (unknown [10.43.2.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 759715D9CA; Thu, 24 Oct 2019 08:18:18 +0000 (UTC) Date: Thu, 24 Oct 2019 10:18:16 +0200 From: Stanislaw Gruszka To: Lorenzo Bianconi Cc: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, nbd@nbd.name, lorenzo.bianconi@redhat.com, oleksandr@natalenko.name, netdev@vger.kernel.org Subject: Re: [PATCH wireless-drivers 2/2] mt76: dma: fix buffer unmap with non-linear skbs Message-ID: <20191024081816.GA2440@redhat.com> References: <1f7560e10edd517bfd9d3c0dd9820e6f420726b6.1571868221.git.lorenzo@kernel.org> MIME-Version: 1.0 In-Reply-To: <1f7560e10edd517bfd9d3c0dd9820e6f420726b6.1571868221.git.lorenzo@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 9zpOSi7ZMAaRh8uSwKlnsA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, Oct 24, 2019 at 12:23:16AM +0200, Lorenzo Bianconi wrote: > 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. If we have to keep txwi mapped, before unmap fragments, when then txwi is unmaped ? Stanislaw > Fixes: 17f1de56df05 ("mt76: add common code shared between multiple chips= ets") > Signed-off-by: Lorenzo Bianconi > --- > drivers/net/wireless/mediatek/mt76/dma.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wirel= ess/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, > =09=09=09struct mt76_queue_entry *prev_e) > { > -=09struct mt76_queue_entry *e =3D &q->entry[idx]; > =09__le32 __ctrl =3D READ_ONCE(q->desc[idx].ctrl); > +=09struct mt76_queue_entry *e =3D &q->entry[idx]; > =09u32 ctrl =3D le32_to_cpu(__ctrl); > +=09bool mcu =3D e->skb && !e->txwi; > +=09bool first =3D e->skb =3D=3D DMA_DUMMY_DATA || e->txwi =3D=3D DMA_DUM= MY_DATA || > +=09=09 (e->skb && !skb_is_nonlinear(e->skb)); > =20 > -=09if (!e->txwi || !e->skb) { > +=09if (!first || mcu) { > =09=09__le32 addr =3D READ_ONCE(q->desc[idx].buf0); > =09=09u32 len =3D FIELD_GET(MT_DMA_CTL_SD_LEN0, ctrl); > =20 > @@ -105,7 +108,8 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct = mt76_queue *q, int idx, > =09=09=09=09 DMA_TO_DEVICE); > =09} > =20 > -=09if (!(ctrl & MT_DMA_CTL_LAST_SEC0)) { > +=09if (!(ctrl & MT_DMA_CTL_LAST_SEC0) || > +=09 e->txwi =3D=3D DMA_DUMMY_DATA) { > =09=09__le32 addr =3D READ_ONCE(q->desc[idx].buf1); > =09=09u32 len =3D FIELD_GET(MT_DMA_CTL_SD_LEN1, ctrl); > =20 > --=20 > 2.21.0 >=20