Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp135932pxy; Wed, 21 Apr 2021 21:16:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztq9mKD+T3Rc+Q8PhL+Xyb9XsbaNMKtydbLCEZztjLvMDTgk3k6CB5h00kdVQN4AoZ5YHs X-Received: by 2002:a17:907:6192:: with SMTP id mt18mr1212486ejc.530.1619064994733; Wed, 21 Apr 2021 21:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619064994; cv=none; d=google.com; s=arc-20160816; b=w8QAxanuLZJVaaGsYgIiCOjC+otgAOFPSXzsk7dKd5px9dCAYnY3ExjIe/jTfkVyOM 4GglVJpXkWGJ6lSHPisFvvoXaqdogAuWzA2qibdjdlanJigY55uZpkKVirsMjnPZ6kEX vqlaMTXfYr/d2VUWNBViTFNCxpcjCyuutNtswwi4sswOoyma5ICHIlcL6kKpndELtA+o pCZZdwXE5uQdKy9waQlVGpfpb4bye8vZY2qCb6S20TTSam3Pvu852L64JGy7gYc4ncKA Tp7/1YOt8sVfr2op4dkXFgnWWdag8HTZGGYHOPhJeIhQysPV/+O1GudSFP3Pg6ZLMONU XBSA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Smtj4gwdxb0ZLZIeEWGZNPNrgYDMaUuIXb1nAA+jADw=; b=k4PtfRCzP8LeV3P+NWxJQa8EXCB+BKYPa4wXFTY7NGNT0j5YSoZhIkfLUju116XA/d 5EQ6zK+GbowUeIltiDUzTk0LA11FV1fnPmMkB06sHWsZonxAzNHy2uMfhcV0NSw3iGnY kRFf3i8+GERVxPiOdEPq5NnsEGyZZqKFtaFXuhw+SARhoxtR7OsMuFLa/Tka/HWi2MdX qfJVOJcX1moNLoMyZLQMTKzIH8Hu6ncEDfWYsV3C4du3uXCD1/QziFptktsO4vZmks5J TUeZ4giDhok07ysJoNRC097/7QmgJX9sXhdzI0NRSsT8vf/TdnyPZR7J0EuEl9tkRLQP AQgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="m2/PbzI8"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si1151072edh.359.2021.04.21.21.16.11; Wed, 21 Apr 2021 21:16:34 -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=@gmail.com header.s=20161025 header.b="m2/PbzI8"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234891AbhDVELQ (ORCPT + 99 others); Thu, 22 Apr 2021 00:11:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234670AbhDVEKV (ORCPT ); Thu, 22 Apr 2021 00:10:21 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58AA1C061347; Wed, 21 Apr 2021 21:09:46 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id nm3-20020a17090b19c3b029014e1bbf6c60so240563pjb.4; Wed, 21 Apr 2021 21:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Smtj4gwdxb0ZLZIeEWGZNPNrgYDMaUuIXb1nAA+jADw=; b=m2/PbzI84d6d9OgipdUa6ooqlmZ1yTJHHypRkqQkG2bpVUy3ScKdKsanBUcLcxPxe1 49Kl7GHhccN4bfMUvm5TbmHyZOKAy0qg1/Lkgd4NpuXTRdVO447y3T1pUIZNBFe+LkVB X2sHi/hwQvHU3pJJ8ahjC6omiel2gEdz77r1GYe90YLzLabr0xm7vqS7hBAison6UqOv 1BUr3umNN7qJe3cJGP4m7zsIIndBNxgYdCrODgwC1Lwzkt4BXbwzaPs9/jhbmsg2+mM8 0dH7Ab68oGanlDKPvEZLj18t06rr10OH3gBzdHJghF7LbzlSlKd2MXyLZtPiVMow5lUH T4dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Smtj4gwdxb0ZLZIeEWGZNPNrgYDMaUuIXb1nAA+jADw=; b=dWwCPWHPZC+zVB/Cfy0uZq2+3/Iz/4eCadYp1ImiHq++ElecbPXYpCLRNnTH7D5r1H zk4LXHIBWsE6lmwKfg/IKZ4DpLr/MrQOOjan/wWHnxlJJcY1J6vF4EdAvS5B46+HIVPH qvyNQEUnoXXPaqP139sH9w5JscTZqN+g5+jMvWHzxM+ah4zpZGQlwZCIHtLFtTgqeKat xG+skpY3qwC0Lgk4CKjWBvprA/Ty/IFsEcGm5TosF3X2ihb0rA5prW/7zbehMWEfWyzb lhQFBCnXJ104BUqnqGI9IHO1sQgOMmwuWiUiJQlLJN9LRIBx7twsRNCoVfl9/ortA/3f 0csg== X-Gm-Message-State: AOAM532jhHNAvJBqUYROVFw4jhcESLBct+7HCo4uBOiMdIqKJ+Fcapc9 1OajAhwFV8JGAo3J0AY7aOY= X-Received: by 2002:a17:902:edc4:b029:eb:159f:32b7 with SMTP id q4-20020a170902edc4b02900eb159f32b7mr1461172plk.11.1619064585968; Wed, 21 Apr 2021 21:09:45 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:45 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next 10/14] net: ethernet: mtk_eth_soc: cache HW pointer of last freed TX descriptor Date: Wed, 21 Apr 2021 21:09:10 -0700 Message-Id: <20210422040914.47788-11-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Fietkau The value is only updated by the CPU, so it is cheaper to access from the ring data structure than from a hardware register. Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 043ab5446524..01ad10c76d53 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1362,7 +1362,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, struct mtk_tx_buf *tx_buf; u32 cpu, dma; - cpu = mtk_r32(eth, MTK_QTX_CRX_PTR); + cpu = ring->last_free_ptr; dma = mtk_r32(eth, MTK_QTX_DRX_PTR); desc = mtk_qdma_phys_to_virt(ring, cpu); @@ -1396,6 +1396,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, cpu = next_cpu; } + ring->last_free_ptr = cpu; mtk_w32(eth, cpu, MTK_QTX_CRX_PTR); return budget; @@ -1596,6 +1597,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); ring->next_free = &ring->dma[0]; ring->last_free = &ring->dma[MTK_DMA_SIZE - 1]; + ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); ring->thresh = MAX_SKB_FRAGS; /* make sure that all changes to the dma ring are flushed before we @@ -1609,9 +1611,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) mtk_w32(eth, ring->phys + ((MTK_DMA_SIZE - 1) * sz), MTK_QTX_CRX_PTR); - mtk_w32(eth, - ring->phys + ((MTK_DMA_SIZE - 1) * sz), - MTK_QTX_DRX_PTR); + mtk_w32(eth, ring->last_free_ptr, MTK_QTX_DRX_PTR); mtk_w32(eth, (QDMA_RES_THRES << 8) | QDMA_RES_THRES, MTK_QTX_CFG(0)); } else { diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index a8d388b02558..214da569e869 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -642,6 +642,7 @@ struct mtk_tx_buf { * @phys: The physical addr of tx_buf * @next_free: Pointer to the next free descriptor * @last_free: Pointer to the last free descriptor + * @last_free_ptr: Hardware pointer value of the last free descriptor * @thresh: The threshold of minimum amount of free descriptors * @free_count: QDMA uses a linked list. Track how many free descriptors * are present @@ -652,6 +653,7 @@ struct mtk_tx_ring { dma_addr_t phys; struct mtk_tx_dma *next_free; struct mtk_tx_dma *last_free; + u32 last_free_ptr; u16 thresh; atomic_t free_count; int dma_size; -- 2.31.1