![John Audia](/assets/img/avatar_default.png)
Manually rebased: backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch Removed upstreamed: backport-5.15/060-v6.0-01-tools-build-Add-feature-test-for-init_disassemble_in.patch[1] backport-5.15/060-v6.0-02-tools-include-add-dis-asm-compat.h-to-handle-version.patch[2] backport-5.15/060-v6.0-03-tools-perf-Fix-compilation-error-with-new-binutils.patch[3] backport-5.15/060-v6.0-04-tools-bpf_jit_disasm-Fix-compilation-error-with-new-.patch[4] backport-5.15/060-v6.0-05-tools-bpftool-Fix-compilation-error-with-new-binutil.patch[5] pending-5.15/733-02-net-ethernet-mtk_eth_soc-fix-RX-data-corruption-issu.patch[6] bcm47xx/patches-5.15/170-bgmac-fix-initial-chip-reset-to-support-BCM5358.patch[7] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=51b99dc38c1a053e2e732d7f9e2740e343ae7eae 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=451c9d7b16169645ed291ebb2ca9844caa088f2d 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=97f005c0bdbaf656a7808586d234965385a06c58 4. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=1c27fab243333821375e4d63128d60093fdbe149 5. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=4441a90091931fd81607567961dc122f24f735bb 6. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=2adc29350a5b4669544566f71f208d2abaec60ab 7. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=04bfc5bcdfc0fdb73587487c71b04d63807ae15a Build system: x86_64 Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia <therealgraysky@proton.me>
168 lines
5.1 KiB
Diff
168 lines
5.1 KiB
Diff
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Date: Fri, 20 May 2022 20:11:28 +0200
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: add txd_size to mtk_soc_data
|
|
|
|
In order to remove mtk_tx_dma size dependency, introduce txd_size in
|
|
mtk_soc_data data structure. Rely on txd_size in mtk_init_fq_dma() and
|
|
mtk_dma_free() routines.
|
|
This is a preliminary patch to add mt7986 ethernet support.
|
|
|
|
Tested-by: Sam Shih <sam.shih@mediatek.com>
|
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
@@ -838,20 +838,20 @@ static void *mtk_max_lro_buf_alloc(gfp_t
|
|
/* the qdma core needs scratch memory to be setup */
|
|
static int mtk_init_fq_dma(struct mtk_eth *eth)
|
|
{
|
|
+ const struct mtk_soc_data *soc = eth->soc;
|
|
dma_addr_t phy_ring_tail;
|
|
int cnt = MTK_DMA_SIZE;
|
|
dma_addr_t dma_addr;
|
|
int i;
|
|
|
|
eth->scratch_ring = dma_alloc_coherent(eth->dma_dev,
|
|
- cnt * sizeof(struct mtk_tx_dma),
|
|
+ cnt * soc->txrx.txd_size,
|
|
ð->phy_scratch_ring,
|
|
GFP_KERNEL);
|
|
if (unlikely(!eth->scratch_ring))
|
|
return -ENOMEM;
|
|
|
|
- eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE,
|
|
- GFP_KERNEL);
|
|
+ eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, GFP_KERNEL);
|
|
if (unlikely(!eth->scratch_head))
|
|
return -ENOMEM;
|
|
|
|
@@ -861,16 +861,19 @@ static int mtk_init_fq_dma(struct mtk_et
|
|
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
|
|
return -ENOMEM;
|
|
|
|
- phy_ring_tail = eth->phy_scratch_ring +
|
|
- (sizeof(struct mtk_tx_dma) * (cnt - 1));
|
|
+ phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt - 1);
|
|
|
|
for (i = 0; i < cnt; i++) {
|
|
- eth->scratch_ring[i].txd1 =
|
|
- (dma_addr + (i * MTK_QDMA_PAGE_SIZE));
|
|
+ struct mtk_tx_dma *txd;
|
|
+
|
|
+ txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size;
|
|
+ txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE;
|
|
if (i < cnt - 1)
|
|
- eth->scratch_ring[i].txd2 = (eth->phy_scratch_ring +
|
|
- ((i + 1) * sizeof(struct mtk_tx_dma)));
|
|
- eth->scratch_ring[i].txd3 = TX_DMA_SDL(MTK_QDMA_PAGE_SIZE);
|
|
+ txd->txd2 = eth->phy_scratch_ring +
|
|
+ (i + 1) * soc->txrx.txd_size;
|
|
+
|
|
+ txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE);
|
|
+ txd->txd4 = 0;
|
|
}
|
|
|
|
mtk_w32(eth, eth->phy_scratch_ring, MTK_QDMA_FQ_HEAD);
|
|
@@ -2170,6 +2173,7 @@ static int mtk_dma_init(struct mtk_eth *
|
|
|
|
static void mtk_dma_free(struct mtk_eth *eth)
|
|
{
|
|
+ const struct mtk_soc_data *soc = eth->soc;
|
|
int i;
|
|
|
|
for (i = 0; i < MTK_MAC_COUNT; i++)
|
|
@@ -2177,9 +2181,8 @@ static void mtk_dma_free(struct mtk_eth
|
|
netdev_reset_queue(eth->netdev[i]);
|
|
if (eth->scratch_ring) {
|
|
dma_free_coherent(eth->dma_dev,
|
|
- MTK_DMA_SIZE * sizeof(struct mtk_tx_dma),
|
|
- eth->scratch_ring,
|
|
- eth->phy_scratch_ring);
|
|
+ MTK_DMA_SIZE * soc->txrx.txd_size,
|
|
+ eth->scratch_ring, eth->phy_scratch_ring);
|
|
eth->scratch_ring = NULL;
|
|
eth->phy_scratch_ring = 0;
|
|
}
|
|
@@ -3391,6 +3394,9 @@ static const struct mtk_soc_data mt2701_
|
|
.hw_features = MTK_HW_FEATURES,
|
|
.required_clks = MT7623_CLKS_BITMAP,
|
|
.required_pctl = true,
|
|
+ .txrx = {
|
|
+ .txd_size = sizeof(struct mtk_tx_dma),
|
|
+ },
|
|
};
|
|
|
|
static const struct mtk_soc_data mt7621_data = {
|
|
@@ -3399,6 +3405,9 @@ static const struct mtk_soc_data mt7621_
|
|
.required_clks = MT7621_CLKS_BITMAP,
|
|
.required_pctl = false,
|
|
.offload_version = 2,
|
|
+ .txrx = {
|
|
+ .txd_size = sizeof(struct mtk_tx_dma),
|
|
+ },
|
|
};
|
|
|
|
static const struct mtk_soc_data mt7622_data = {
|
|
@@ -3408,6 +3417,9 @@ static const struct mtk_soc_data mt7622_
|
|
.required_clks = MT7622_CLKS_BITMAP,
|
|
.required_pctl = false,
|
|
.offload_version = 2,
|
|
+ .txrx = {
|
|
+ .txd_size = sizeof(struct mtk_tx_dma),
|
|
+ },
|
|
};
|
|
|
|
static const struct mtk_soc_data mt7623_data = {
|
|
@@ -3416,6 +3428,9 @@ static const struct mtk_soc_data mt7623_
|
|
.required_clks = MT7623_CLKS_BITMAP,
|
|
.required_pctl = true,
|
|
.offload_version = 2,
|
|
+ .txrx = {
|
|
+ .txd_size = sizeof(struct mtk_tx_dma),
|
|
+ },
|
|
};
|
|
|
|
static const struct mtk_soc_data mt7629_data = {
|
|
@@ -3424,6 +3439,9 @@ static const struct mtk_soc_data mt7629_
|
|
.hw_features = MTK_HW_FEATURES,
|
|
.required_clks = MT7629_CLKS_BITMAP,
|
|
.required_pctl = false,
|
|
+ .txrx = {
|
|
+ .txd_size = sizeof(struct mtk_tx_dma),
|
|
+ },
|
|
};
|
|
|
|
static const struct mtk_soc_data rt5350_data = {
|
|
@@ -3431,6 +3449,9 @@ static const struct mtk_soc_data rt5350_
|
|
.hw_features = MTK_HW_FEATURES_MT7628,
|
|
.required_clks = MT7628_CLKS_BITMAP,
|
|
.required_pctl = false,
|
|
+ .txrx = {
|
|
+ .txd_size = sizeof(struct mtk_tx_dma),
|
|
+ },
|
|
};
|
|
|
|
const struct of_device_id of_mtk_match[] = {
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
@@ -864,6 +864,7 @@ struct mtk_tx_dma_desc_info {
|
|
* the target SoC
|
|
* @required_pctl A bool value to show whether the SoC requires
|
|
* the extra setup for those pins used by GMAC.
|
|
+ * @txd_size Tx DMA descriptor size.
|
|
*/
|
|
struct mtk_soc_data {
|
|
u32 ana_rgc3;
|
|
@@ -872,6 +873,9 @@ struct mtk_soc_data {
|
|
bool required_pctl;
|
|
u8 offload_version;
|
|
netdev_features_t hw_features;
|
|
+ struct {
|
|
+ u32 txd_size;
|
|
+ } txrx;
|
|
};
|
|
|
|
/* currently no SoC has more than 2 macs */
|