All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
To: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Cc: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
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	[thread overview]
Message-ID: <20210422040914.47788-11-ilya.lipnitskiy@gmail.com> (raw)
In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com>

From: Felix Fietkau <nbd@nbd.name>

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 <nbd@nbd.name>
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 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


WARNING: multiple messages have this Message-ID (diff)
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
To: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Cc: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
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	[thread overview]
Message-ID: <20210422040914.47788-11-ilya.lipnitskiy@gmail.com> (raw)
In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com>

From: Felix Fietkau <nbd@nbd.name>

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 <nbd@nbd.name>
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 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


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
To: Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>,
	Sean Wang <sean.wang@mediatek.com>,
	Mark Lee <Mark-MC.Lee@mediatek.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Cc: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
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	[thread overview]
Message-ID: <20210422040914.47788-11-ilya.lipnitskiy@gmail.com> (raw)
In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com>

From: Felix Fietkau <nbd@nbd.name>

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 <nbd@nbd.name>
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-04-22  4:10 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  4:09 [PATCH net-next 00/14] mtk_eth_soc: fixes and performance improvements Ilya Lipnitskiy
2021-04-22  4:09 ` Ilya Lipnitskiy
2021-04-22  4:09 ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 01/14] net: ethernet: mtk_eth_soc: fix RX VLAN offload Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 02/14] net: ethernet: mtk_eth_soc: unmap RX data before calling build_skb Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 03/14] net: ethernet: mtk_eth_soc: fix build_skb cleanup Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 04/14] net: ethernet: mtk_eth_soc: use napi_consume_skb Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 05/14] net: ethernet: mtk_eth_soc: reduce MDIO bus access latency Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22 12:18   ` Andrew Lunn
2021-04-22 12:18     ` Andrew Lunn
2021-04-22 12:18     ` Andrew Lunn
2021-04-22 12:33   ` Felix Fietkau
2021-04-22 12:33     ` Felix Fietkau
2021-04-22 12:33     ` Felix Fietkau
2021-04-23  4:16     ` Ilya Lipnitskiy
2021-04-23  4:16       ` Ilya Lipnitskiy
2021-04-23  4:16       ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 06/14] net: ethernet: mtk_eth_soc: remove unnecessary TX queue stops Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 07/14] net: ethernet: mtk_eth_soc: use larger burst size for QDMA TX Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 08/14] net: ethernet: mtk_eth_soc: increase DMA ring sizes Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 09/14] net: ethernet: mtk_eth_soc: implement dynamic interrupt moderation Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` Ilya Lipnitskiy [this message]
2021-04-22  4:09   ` [PATCH net-next 10/14] net: ethernet: mtk_eth_soc: cache HW pointer of last freed TX descriptor Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 11/14] net: ethernet: mtk_eth_soc: only read the full RX descriptor if DMA is done Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 12/14] net: ethernet: mtk_eth_soc: reduce unnecessary interrupts Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22 16:26   ` Jakub Kicinski
2021-04-22 16:26     ` Jakub Kicinski
2021-04-22 16:26     ` Jakub Kicinski
2021-04-23  4:20     ` Ilya Lipnitskiy
2021-04-23  4:20       ` Ilya Lipnitskiy
2021-04-23  4:20       ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 13/14] net: ethernet: mtk_eth_soc: set PPE flow hash as skb hash if present Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09 ` [PATCH net-next 14/14] net: ethernet: mtk_eth_soc: use iopoll.h macro for DMA init Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22  4:09   ` Ilya Lipnitskiy
2021-04-22 12:20   ` Andrew Lunn
2021-04-22 12:20     ` Andrew Lunn
2021-04-22 12:20     ` Andrew Lunn
2021-04-22 12:23 ` [PATCH net-next 00/14] mtk_eth_soc: fixes and performance improvements Andrew Lunn
2021-04-22 12:23   ` Andrew Lunn
2021-04-22 12:23   ` Andrew Lunn
2021-04-23  4:18   ` Ilya Lipnitskiy
2021-04-23  4:18     ` Ilya Lipnitskiy
2021-04-23  4:18     ` Ilya Lipnitskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210422040914.47788-11-ilya.lipnitskiy@gmail.com \
    --to=ilya.lipnitskiy@gmail.com \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=davem@davemloft.net \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.