2020-09-04 17:41:46 +00:00
|
|
|
From: Felix Fietkau <nbd@nbd.name>
|
|
|
|
Date: Fri, 4 Sep 2020 18:36:06 +0200
|
|
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: add support for coherent DMA
|
|
|
|
|
|
|
|
It improves performance by eliminating the need for a cache flush on rx and tx
|
|
|
|
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
|
|
---
|
|
|
|
|
|
|
|
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
|
|
|
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
|
|
|
@@ -357,7 +357,7 @@
|
|
|
|
};
|
|
|
|
|
|
|
|
cci_control2: slave-if@5000 {
|
|
|
|
- compatible = "arm,cci-400-ctrl-if";
|
|
|
|
+ compatible = "arm,cci-400-ctrl-if", "syscon";
|
|
|
|
interface-type = "ace";
|
|
|
|
reg = <0x5000 0x1000>;
|
|
|
|
};
|
2021-03-04 20:37:13 +00:00
|
|
|
@@ -969,6 +969,8 @@
|
2020-09-04 17:41:46 +00:00
|
|
|
power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>;
|
|
|
|
mediatek,ethsys = <ðsys>;
|
|
|
|
mediatek,sgmiisys = <&sgmiisys>;
|
|
|
|
+ mediatek,cci-control = <&cci_control2>;
|
|
|
|
+ dma-coherent;
|
|
|
|
#address-cells = <1>;
|
|
|
|
#size-cells = <0>;
|
|
|
|
status = "disabled";
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_mdio.h>
|
|
|
|
#include <linux/of_net.h>
|
|
|
|
+#include <linux/of_address.h>
|
|
|
|
#include <linux/mfd/syscon.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/clk.h>
|
2020-12-18 16:10:04 +00:00
|
|
|
@@ -2485,6 +2486,13 @@ static int mtk_hw_init(struct mtk_eth *e
|
2020-09-04 17:41:46 +00:00
|
|
|
if (ret)
|
|
|
|
goto err_disable_pm;
|
|
|
|
|
|
|
|
+ if (of_dma_is_coherent(eth->dev->of_node)) {
|
2020-10-08 11:44:33 +00:00
|
|
|
+ u32 mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA |
|
|
|
|
+ ETHSYS_DMA_AG_MAP_PPE;
|
2020-09-04 17:41:46 +00:00
|
|
|
+
|
|
|
|
+ regmap_update_bits(eth->ethsys, ETHSYS_DMA_AG_MAP, mask, mask);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
|
|
|
|
ret = device_reset(eth->dev);
|
|
|
|
if (ret) {
|
2020-12-18 16:10:04 +00:00
|
|
|
@@ -3083,6 +3091,16 @@ static int mtk_probe(struct platform_dev
|
2020-09-04 17:41:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (of_dma_is_coherent(pdev->dev.of_node)) {
|
|
|
|
+ struct regmap *cci;
|
|
|
|
+
|
|
|
|
+ cci = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
|
|
|
|
+ "mediatek,cci-control");
|
|
|
|
+ /* enable CPU/bus coherency */
|
|
|
|
+ if (!IS_ERR(cci))
|
|
|
|
+ regmap_write(cci, 0, 3);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) {
|
|
|
|
eth->sgmii = devm_kzalloc(eth->dev, sizeof(*eth->sgmii),
|
|
|
|
GFP_KERNEL);
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
2020-10-08 11:44:33 +00:00
|
|
|
@@ -435,6 +435,12 @@
|
2020-09-04 17:41:46 +00:00
|
|
|
#define RSTCTRL_FE BIT(6)
|
|
|
|
#define RSTCTRL_PPE BIT(31)
|
|
|
|
|
|
|
|
+/* ethernet dma channel agent map */
|
|
|
|
+#define ETHSYS_DMA_AG_MAP 0x408
|
|
|
|
+#define ETHSYS_DMA_AG_MAP_PDMA BIT(0)
|
|
|
|
+#define ETHSYS_DMA_AG_MAP_QDMA BIT(1)
|
2020-10-08 11:44:33 +00:00
|
|
|
+#define ETHSYS_DMA_AG_MAP_PPE BIT(2)
|
2020-09-04 17:41:46 +00:00
|
|
|
+
|
|
|
|
/* SGMII subsystem config registers */
|
|
|
|
/* Register to auto-negotiation restart */
|
|
|
|
#define SGMSYS_PCS_CONTROL_1 0x0
|