Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2020083iob; Thu, 5 May 2022 13:29:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOJK9uWjzZJamshcAKeguP/d6ieW/dPcIbRjoMKH5oqXQuDsnawkjg32R/4lH+p9vALWZ8 X-Received: by 2002:a63:2a02:0:b0:3aa:c641:cd86 with SMTP id q2-20020a632a02000000b003aac641cd86mr22959755pgq.614.1651782593740; Thu, 05 May 2022 13:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651782593; cv=none; d=google.com; s=arc-20160816; b=MOcaKz8Y2UrSZ4B0Q00qngGyTHNnEHXX2ScmJfdun5z+uyiCzfNThyaLoRONjk4qpi T24bBqtml+q0sDfyzFpo2lQVyk/M02IItS4RtQJLOd80J570k7q36D8zbkEuBio2bdfV PlZ96HhYSHFJdKCvB0W6wj/0X9l4v/RD0j/b1iTUKL4VsTWkZk8byMyRTqu5NkOs2ZFj wenfGxvcZbnPKR9Pf7So45xWsn64RAZ1p4X+HOBUvH+AtIaakxHFD/OJijN/XV6OOCXi qYYdWCGxNIXYWMrhEsQzMKdOfD8lSEqfX8iXU6I1ZmuXz85KGm6cGDJ4+eMupzydOyYm 25pg== 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:to:from:dkim-signature; bh=rtxPhpU+bMqsJ45E71PSj8ZuRYXipqHmHrgApLgb4lI=; b=UP9Ghvze+6KSY2v3y+ktSkmgAGr3k622DmezluuPJxYoDsSHHj692bZHIF1++b0cGe 6S3G4pMu3N1NwPmdugvTx5WPQXRASH87ECqwdKE+HwpvV0mZpiKq2swhMmB/dRHhxrT3 OyI+FkJA3eTSsgidHx5i1cOfyWQ6jnDULvqxzIgLSJzRP+Jg8txto1/Yfen8jNntL3Up LSOdGjiLu+dKReKSLpjH/JGLMVScmiEa/pNelVFhdoSyt5yK6GNIzSs3Duih14a/ftx8 ja+wwsX8XaHSeCYsNngQ0RzHSrx2IMdPiGs3hC9J8cUEcjIfUAOXsg47BWHJaFQun8WJ wdxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=pbunzW3A; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s14-20020a17090a440e00b001d4e0d81848si8531030pjg.152.2022.05.05.13.29.38; Thu, 05 May 2022 13:29:53 -0700 (PDT) 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=pbunzW3A; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358341AbiEELmA (ORCPT + 68 others); Thu, 5 May 2022 07:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358100AbiEELlv (ORCPT ); Thu, 5 May 2022 07:41:51 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363014EF49 for ; Thu, 5 May 2022 04:38:11 -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: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rtxPhpU+bMqsJ45E71PSj8ZuRYXipqHmHrgApLgb4lI=; b=pbunzW3AJ1XLSWnR8vdY0tLyJ2 PKTkniap/4rxT3aTOCZCvaWm1IwIGVnnefJOmGC1NR7d3VviY5TrrxfSdhzLjuwYiqDhwc7O8njek xyRZOv5cxHq+A0Bo9c4NRQ8UeD7NVOPDj3XBKjWRVDIJ0f2FpLIuYYivzMTBqzEmkh5c=; Received: from p200300daa70ef200412f484bca3869cd.dip0.t-ipconnect.de ([2003:da:a70e:f200:412f:484b:ca38:69cd] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nmZo9-0007Ts-5x for linux-wireless@vger.kernel.org; Thu, 05 May 2022 13:38:09 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 1/4] mt76: dma: add wrapper macro for accessing queue registers Date: Thu, 5 May 2022 13:37:26 +0200 Message-Id: <20220505113729.50380-1-nbd@nbd.name> X-Mailer: git-send-email 2.35.1 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, T_SCC_BODY_TEXT_LINE 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 Preparation for adding indirection used for Wireless Ethernet Dispatch support Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/dma.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 09dc37bbf112..03d5beb1afdd 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -7,6 +7,10 @@ #include "mt76.h" #include "dma.h" +#define Q_READ(_dev, _q, _field) readl(&(_q)->regs->_field) +#define Q_WRITE(_dev, _q, _field, _val) writel(_val, &(_q)->regs->_field) + + static struct mt76_txwi_cache * mt76_alloc_txwi(struct mt76_dev *dev) { @@ -84,9 +88,9 @@ mt76_free_pending_txwi(struct mt76_dev *dev) static void mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q) { - writel(q->desc_dma, &q->regs->desc_base); - writel(q->ndesc, &q->regs->ring_size); - q->head = readl(&q->regs->dma_idx); + Q_WRITE(dev, q, desc_base, q->desc_dma); + Q_WRITE(dev, q, ring_size, q->ndesc); + q->head = Q_READ(dev, q, dma_idx); q->tail = q->head; } @@ -102,8 +106,8 @@ mt76_dma_queue_reset(struct mt76_dev *dev, struct mt76_queue *q) for (i = 0; i < q->ndesc; i++) q->desc[i].ctrl = cpu_to_le32(MT_DMA_CTL_DMA_DONE); - writel(0, &q->regs->cpu_idx); - writel(0, &q->regs->dma_idx); + Q_WRITE(dev, q, cpu_idx, 0); + Q_WRITE(dev, q, dma_idx, 0); mt76_dma_sync_idx(dev, q); } @@ -226,7 +230,7 @@ static void mt76_dma_kick_queue(struct mt76_dev *dev, struct mt76_queue *q) { wmb(); - writel(q->head, &q->regs->cpu_idx); + Q_WRITE(dev, q, cpu_idx, q->head); } static void @@ -242,7 +246,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) if (flush) last = -1; else - last = readl(&q->regs->dma_idx); + last = Q_READ(dev, q, dma_idx); while (q->queued > 0 && q->tail != last) { mt76_dma_tx_cleanup_idx(dev, q, q->tail, &entry); @@ -254,8 +258,7 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) } if (!flush && q->tail == last) - last = readl(&q->regs->dma_idx); - + last = Q_READ(dev, q, dma_idx); } spin_unlock_bh(&q->cleanup_lock); -- 2.35.1