Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp703320rwb; Fri, 13 Jan 2023 03:13:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXvOo8D+ES9y4+NdEEewM+JOJpch9mht992bOw8bupwnHY35k+mcEfTx8kyImYZR6CAjT7PZ X-Received: by 2002:a05:6a20:c125:b0:b0:5144:2c1f with SMTP id bh37-20020a056a20c12500b000b051442c1fmr86586003pzb.52.1673608434330; Fri, 13 Jan 2023 03:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673608434; cv=none; d=google.com; s=arc-20160816; b=LQLNIpbNGEg3Z1lGRq7hT4h34/irZr7JB22X2vZQitNYVpJGgbGdmK2AOu8Xh1eYLz Kr65T+RlOOoxb1l7MNcGQu6067eMVE/HOIkPB0k9ne/FIpgdZrcgVtQdM7AVd0D1wNAR JzeFhebFdI3EvRby7DgS5tbdcjqoSA37ZqGpzdmqPuvdrJJiVxcIrn8zLXIB8OVm7Zr+ KXLqMlti2DSSd610HlYjk1FnF3tiwMMMigSjMwh+Sdt63PUr1mvXRBcwUn1rldnHxW6L XBSQOBKYavKe+d/MUWGptrr73TqYptRX1IZKHBBpWhUR+VyJWKxiJOffsIXhE2Scrxzl dgig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=R9TLngDLbogCdvFiCuC6HiBlaUZd4cmETAgHFgK9oRE=; b=EegEM+5s6674dtSg9H+1oLHsPtyYwlo6dqlQmBDTFzWKcpAeLVf9vl0vNG+fBL8zB4 zA0mCYBNqYSgqkOi93xAXIV5EvE6hFCd4AOsuwSfYM4deMWgSRymzJrDCi4Zd9ZJU3y+ +F+X4EX36DgfK+c7estIbRgI1pZQbIOev9JuJOKD7hv7YPTzOv3ItpquA9RQ689GL8RC /tavyXLoJjmTlqki78S2dVqXG/CbLM4MRIAgdE8qPIzsfB9qMAchf8Oic1QidBnSfRgM yh9L1Y14EEcbJq5RWhw12bys6V0n2vL4Oa1Havh1e4xOnk9w5C+l9IwVeB2WRXv8E1CE tq9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=DpFsQzjU; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a63e347000000b00457f4e8e21esi19830235pgj.731.2023.01.13.03.13.42; Fri, 13 Jan 2023 03:13:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=DpFsQzjU; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241378AbjAMLKC (ORCPT + 65 others); Fri, 13 Jan 2023 06:10:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241264AbjAMLJX (ORCPT ); Fri, 13 Jan 2023 06:09:23 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7F0D7A234 for ; Fri, 13 Jan 2023 02:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=R9TLngDLbogCdvFiCuC6HiBlaUZd4cmETAgHFgK9oRE=; b=DpFsQzjUsZQrVeH4CaTXZzlCcG 7kuPKMFq0DFGaqi64Xo3M6+p7NWKU0GQ8nde3Ik5k4IPSsisJAW9x9ve/i5CrnnJ6c+DkIw49669G j1qTISOSq1629osPcvhgaMamuwuMbO7ChlzC659+ivoqZ4cXPJsukyc7qp4wQaHtf9+w=; Received: from [37.59.164.104] (helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1pGHm2-00GQpV-FQ; Fri, 13 Jan 2023 11:59:02 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: Kalle Valo , Lorenzo Bianconi Subject: [PATCH wireless 1/3] wifi: mt76: dma: do not increment queue head if mt76_dma_add_buf fails Date: Fri, 13 Jan 2023 11:58:46 +0100 Message-Id: <20230113105848.34642-1-nbd@nbd.name> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Lorenzo Bianconi Do not increment queue head if mt76_dma_add_buf fails for Wireless Ethernet Dispatcher rx queues. Fixes: cd372b8c99c5 ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau (cherry picked from commit fe13dad8992be0b26c1be390bcd111acf9892c17) --- drivers/net/wireless/mediatek/mt76/dma.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index f795548562f5..c058a02e9ba5 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -212,14 +212,14 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, { struct mt76_queue_entry *entry; struct mt76_desc *desc; - u32 ctrl; int i, idx = -1; + u32 ctrl, next; for (i = 0; i < nbufs; i += 2, buf += 2) { u32 buf0 = buf[0].addr, buf1 = 0; idx = q->head; - q->head = (q->head + 1) % q->ndesc; + next = (q->head + 1) % q->ndesc; desc = &q->desc[idx]; entry = &q->entry[idx]; @@ -239,8 +239,8 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, MT_DMA_CTL_TO_HOST; } else { if (txwi) { - q->entry[q->head].txwi = DMA_DUMMY_DATA; - q->entry[q->head].skip_buf0 = true; + q->entry[next].txwi = DMA_DUMMY_DATA; + q->entry[next].skip_buf0 = true; } if (buf[0].skip_unmap) @@ -271,6 +271,7 @@ mt76_dma_add_buf(struct mt76_dev *dev, struct mt76_queue *q, WRITE_ONCE(desc->info, cpu_to_le32(info)); WRITE_ONCE(desc->ctrl, cpu_to_le32(ctrl)); + q->head = next; q->queued++; } -- 2.39.0