forked from openwrt/openwrt
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: backport upstream mtk_eth_soc patches
Includes MT7986 ethernet support Signed-off-by: Felix Fietkau <nbd@nbd.name>
- Loading branch information
Showing
28 changed files
with
3,272 additions
and
13 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...ric/backport-5.15/702-v5.19-11-net-ethernet-mtk_eth_soc-wed-fix-sparse-endian-warni.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
From: Felix Fietkau <nbd@nbd.name> | ||
Date: Fri, 8 Apr 2022 10:59:45 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc/wed: fix sparse endian warnings | ||
|
||
Descriptor fields are little-endian | ||
|
||
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") | ||
Reported-by: kernel test robot <lkp@intel.com> | ||
Signed-off-by: Felix Fietkau <nbd@nbd.name> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c | ||
@@ -144,16 +144,17 @@ mtk_wed_buffer_alloc(struct mtk_wed_devi | ||
|
||
for (s = 0; s < MTK_WED_BUF_PER_PAGE; s++) { | ||
u32 txd_size; | ||
+ u32 ctrl; | ||
|
||
txd_size = dev->wlan.init_buf(buf, buf_phys, token++); | ||
|
||
- desc->buf0 = buf_phys; | ||
- desc->buf1 = buf_phys + txd_size; | ||
- desc->ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, | ||
- txd_size) | | ||
- FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1, | ||
- MTK_WED_BUF_SIZE - txd_size) | | ||
- MTK_WDMA_DESC_CTRL_LAST_SEG1; | ||
+ desc->buf0 = cpu_to_le32(buf_phys); | ||
+ desc->buf1 = cpu_to_le32(buf_phys + txd_size); | ||
+ ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, txd_size) | | ||
+ FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1, | ||
+ MTK_WED_BUF_SIZE - txd_size) | | ||
+ MTK_WDMA_DESC_CTRL_LAST_SEG1; | ||
+ desc->ctrl = cpu_to_le32(ctrl); | ||
desc->info = 0; | ||
desc++; | ||
|
||
@@ -184,12 +185,14 @@ mtk_wed_free_buffer(struct mtk_wed_devic | ||
|
||
for (i = 0, page_idx = 0; i < dev->buf_ring.size; i += MTK_WED_BUF_PER_PAGE) { | ||
void *page = page_list[page_idx++]; | ||
+ dma_addr_t buf_addr; | ||
|
||
if (!page) | ||
break; | ||
|
||
- dma_unmap_page(dev->hw->dev, desc[i].buf0, | ||
- PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
+ buf_addr = le32_to_cpu(desc[i].buf0); | ||
+ dma_unmap_page(dev->hw->dev, buf_addr, PAGE_SIZE, | ||
+ DMA_BIDIRECTIONAL); | ||
__free_page(page); | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
...ric/backport-5.15/702-v5.19-12-net-ethernet-mtk_eth_soc-fix-return-value-check-in-m.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From: Yang Yingliang <yangyingliang@huawei.com> | ||
Date: Fri, 8 Apr 2022 11:22:46 +0800 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: fix return value check in | ||
mtk_wed_add_hw() | ||
|
||
If syscon_regmap_lookup_by_phandle() fails, it never return NULL pointer, | ||
change the check to IS_ERR(). | ||
|
||
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") | ||
Reported-by: Hulk Robot <hulkci@huawei.com> | ||
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c | ||
@@ -816,7 +816,7 @@ void mtk_wed_add_hw(struct device_node * | ||
return; | ||
|
||
regs = syscon_regmap_lookup_by_phandle(np, NULL); | ||
- if (!regs) | ||
+ if (IS_ERR(regs)) | ||
return; | ||
|
||
rcu_assign_pointer(mtk_soc_wed_ops, &wed_ops); |
35 changes: 35 additions & 0 deletions
35
...ric/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Mon, 11 Apr 2022 12:13:25 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: use standard property for | ||
cci-control-port | ||
|
||
Rely on standard cci-control-port property to identify CCI port | ||
reference. | ||
Update mt7622 dts binding. | ||
|
||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
--- | ||
|
||
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi | ||
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi | ||
@@ -962,7 +962,7 @@ | ||
power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>; | ||
mediatek,ethsys = <ðsys>; | ||
mediatek,sgmiisys = <&sgmiisys>; | ||
- mediatek,cci-control = <&cci_control2>; | ||
+ cci-control-port = <&cci_control2>; | ||
mediatek,wed = <&wed0>, <&wed1>; | ||
mediatek,pcie-mirror = <&pcie_mirror>; | ||
mediatek,hifsys = <&hifsys>; | ||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -3165,7 +3165,7 @@ static int mtk_probe(struct platform_dev | ||
struct regmap *cci; | ||
|
||
cci = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, | ||
- "mediatek,cci-control"); | ||
+ "cci-control-port"); | ||
/* enable CPU/bus coherency */ | ||
if (!IS_ERR(cci)) | ||
regmap_write(cci, 0, 3); |
33 changes: 33 additions & 0 deletions
33
...ric/backport-5.15/702-v5.19-14-net-ethernet-mtk_eth_soc-use-after-free-in-__mtk_ppe.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From: Dan Carpenter <dan.carpenter@oracle.com> | ||
Date: Tue, 12 Apr 2022 12:24:19 +0300 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: use after free in | ||
__mtk_ppe_check_skb() | ||
|
||
The __mtk_foe_entry_clear() function frees "entry" so we have to use | ||
the _safe() version of hlist_for_each_entry() to prevent a use after | ||
free. | ||
|
||
Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries") | ||
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c | ||
@@ -600,6 +600,7 @@ void __mtk_ppe_check_skb(struct mtk_ppe | ||
struct mtk_foe_entry *hwe = &ppe->foe_table[hash]; | ||
struct mtk_flow_entry *entry; | ||
struct mtk_foe_bridge key = {}; | ||
+ struct hlist_node *n; | ||
struct ethhdr *eh; | ||
bool found = false; | ||
u8 *tag; | ||
@@ -609,7 +610,7 @@ void __mtk_ppe_check_skb(struct mtk_ppe | ||
if (FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == MTK_FOE_STATE_BIND) | ||
goto out; | ||
|
||
- hlist_for_each_entry(entry, head, list) { | ||
+ hlist_for_each_entry_safe(entry, n, head, list) { | ||
if (entry->type == MTK_FLOW_TYPE_L2_SUBFLOW) { | ||
if (unlikely(FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == | ||
MTK_FOE_STATE_BIND)) |
22 changes: 22 additions & 0 deletions
22
...ric/backport-5.15/702-v5.19-15-net-ethernet-mtk_eth_soc-add-check-for-allocation-fa.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
From: Dan Carpenter <dan.carpenter@oracle.com> | ||
Date: Thu, 21 Apr 2022 18:49:02 +0300 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: add check for allocation failure | ||
|
||
Check if the kzalloc() failed. | ||
|
||
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") | ||
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c | ||
@@ -827,6 +827,8 @@ void mtk_wed_add_hw(struct device_node * | ||
goto unlock; | ||
|
||
hw = kzalloc(sizeof(*hw), GFP_KERNEL); | ||
+ if (!hw) | ||
+ goto unlock; | ||
hw->node = np; | ||
hw->regs = regs; | ||
hw->eth = eth; |
26 changes: 26 additions & 0 deletions
26
...ric/backport-5.15/702-v5.19-16-eth-mtk_eth_soc-silence-the-GCC-12-array-bounds-warn.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From: Jakub Kicinski <kuba@kernel.org> | ||
Date: Fri, 20 May 2022 12:56:03 -0700 | ||
Subject: [PATCH] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning | ||
|
||
GCC 12 gets upset because in mtk_foe_entry_commit_subflow() | ||
this driver allocates a partial structure. The writes are | ||
within bounds. | ||
|
||
Silence these warnings for now, our build bot runs GCC 12 | ||
so we won't allow any new instances. | ||
|
||
Signed-off-by: Jakub Kicinski <kuba@kernel.org> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/Makefile | ||
+++ b/drivers/net/ethernet/mediatek/Makefile | ||
@@ -11,3 +11,8 @@ mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) + | ||
endif | ||
obj-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_ops.o | ||
obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o | ||
+ | ||
+# FIXME: temporarily silence -Warray-bounds on non W=1+ builds | ||
+ifndef KBUILD_EXTRA_WARN | ||
+CFLAGS_mtk_ppe.o += -Wno-array-bounds | ||
+endif |
52 changes: 52 additions & 0 deletions
52
...ric/backport-5.15/702-v5.19-17-net-ethernet-mtk_eth_soc-rely-on-GFP_KERNEL-for-dma_.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:26 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on GFP_KERNEL for | ||
dma_alloc_coherent whenever possible | ||
|
||
Rely on GFP_KERNEL for dma descriptors mappings in mtk_tx_alloc(), | ||
mtk_rx_alloc() and mtk_init_fq_dma() since they are run in non-irq | ||
context. | ||
|
||
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 | ||
@@ -834,7 +834,7 @@ static int mtk_init_fq_dma(struct mtk_et | ||
eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, | ||
cnt * sizeof(struct mtk_tx_dma), | ||
ð->phy_scratch_ring, | ||
- GFP_ATOMIC); | ||
+ GFP_KERNEL); | ||
if (unlikely(!eth->scratch_ring)) | ||
return -ENOMEM; | ||
|
||
@@ -1609,7 +1609,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
goto no_tx_mem; | ||
|
||
ring->dma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, | ||
- &ring->phys, GFP_ATOMIC); | ||
+ &ring->phys, GFP_KERNEL); | ||
if (!ring->dma) | ||
goto no_tx_mem; | ||
|
||
@@ -1627,8 +1627,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
*/ | ||
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { | ||
ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, | ||
- &ring->phys_pdma, | ||
- GFP_ATOMIC); | ||
+ &ring->phys_pdma, GFP_KERNEL); | ||
if (!ring->dma_pdma) | ||
goto no_tx_mem; | ||
|
||
@@ -1740,7 +1739,7 @@ static int mtk_rx_alloc(struct mtk_eth * | ||
|
||
ring->dma = dma_alloc_coherent(eth->dma_dev, | ||
rx_dma_size * sizeof(*ring->dma), | ||
- &ring->phys, GFP_ATOMIC); | ||
+ &ring->phys, GFP_KERNEL); | ||
if (!ring->dma) | ||
return -ENOMEM; | ||
|
Oops, something went wrong.