[OpenWrt-Devel] [PATCH] ath79: use downstream ag71xx for Kernel 5.4
David Bauer
mail at david-bauer.net
Thu Mar 12 20:07:39 EDT 2020
The ag71xx driver from Linux 5.4 currently has various shortcomings
when used with OpenWrt compared to our downstream version.
For example, the upstream driver does not support modifying the ethernet
clock and configuring RGMII delays on the MAC side.
While we should certainly switch to the upstream driver, the amount of
necessary patches would make it cumbersome to work with. It's also
highly likely we won't be able to finish patching the upstream driver in
time for a Linux 5.4 release.
Tested on Siemens WS-AP3610.
CC: Hauke Mehrtens <hauke at hauke-m.de>
Signed-off-by: David Bauer <mail at david-bauer.net>
---
.../net/ethernet/atheros/ag71xx/Kconfig | 0
.../net/ethernet/atheros/ag71xx/Makefile | 0
.../net/ethernet/atheros/ag71xx/ag71xx.h | 0
.../ethernet/atheros/ag71xx/ag71xx_debugfs.c | 0
.../ethernet/atheros/ag71xx/ag71xx_ethtool.c | 0
.../net/ethernet/atheros/ag71xx/ag71xx_gmac.c | 0
.../net/ethernet/atheros/ag71xx/ag71xx_main.c | 2 +-
.../net/ethernet/atheros/ag71xx/ag71xx_mdio.c | 0
.../net/ethernet/atheros/ag71xx/ag71xx_phy.c | 0
...location-errors-in-ag71xx_rings_init.patch | 61 ----------------
...xx_hw_disable-in-case-phy_conenct-fa.patch | 45 ------------
...-ag71xx_link_adjust-only-when-needed.patch | 69 -------------------
.../420-net-use-downstream-ag71xx.patch | 28 ++++++++
13 files changed, 29 insertions(+), 176 deletions(-)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/Kconfig (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/Makefile (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx.h (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c (99%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c (100%)
rename target/linux/ath79/{files-4.19 => files}/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c (100%)
delete mode 100644 target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch
delete mode 100644 target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch
delete mode 100644 target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch
create mode 100644 target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Kconfig b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Kconfig
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Kconfig
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Makefile b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Makefile
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Makefile
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Makefile
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx.h b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
similarity index 99%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
index 2394ccc90d..5979a61afd 100644
--- a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
+++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c
@@ -1581,7 +1581,7 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc->next = (u32) ag->stop_desc_dma;
mac_addr = of_get_mac_address(np);
- if (mac_addr)
+ if (mac_addr && !IS_ERR(mac_addr))
memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
if (!mac_addr || !is_valid_ether_addr(dev->dev_addr)) {
dev_err(&pdev->dev, "invalid MAC address, using random address\n");
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c
diff --git a/target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
similarity index 100%
rename from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
rename to target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
diff --git a/target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch b/target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch
deleted file mode 100644
index 6631cb8e17..0000000000
--- a/target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From 2cee757eaf5cc6175bc0ac7b0b808794124ec40a Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke at hauke-m.de>
-Date: Mon, 17 Feb 2020 23:40:14 +0100
-Subject: [PATCH 1/3] ag71xx: Handle allocation errors in ag71xx_rings_init()
-
-Free the allocated resources in ag71xx_rings_init() in case
-ag71xx_ring_rx_init() returns an error.
-
-This is only a potential problem, I did not ran into this one.
-
-Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
-Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
----
- drivers/net/ethernet/atheros/ag71xx.c | 22 ++++++++++++++++++----
- 1 file changed, 18 insertions(+), 4 deletions(-)
-
---- a/drivers/net/ethernet/atheros/ag71xx.c
-+++ b/drivers/net/ethernet/atheros/ag71xx.c
-@@ -1133,6 +1133,7 @@ static int ag71xx_rings_init(struct ag71
- struct ag71xx_ring *tx = &ag->tx_ring;
- struct ag71xx_ring *rx = &ag->rx_ring;
- int ring_size, tx_size;
-+ int ret;
-
- ring_size = BIT(tx->order) + BIT(rx->order);
- tx_size = BIT(tx->order);
-@@ -1145,9 +1146,8 @@ static int ag71xx_rings_init(struct ag71
- ring_size * AG71XX_DESC_SIZE,
- &tx->descs_dma, GFP_KERNEL);
- if (!tx->descs_cpu) {
-- kfree(tx->buf);
-- tx->buf = NULL;
-- return -ENOMEM;
-+ ret = -ENOMEM;
-+ goto err_free_buf;
- }
-
- rx->buf = &tx->buf[tx_size];
-@@ -1155,7 +1155,21 @@ static int ag71xx_rings_init(struct ag71
- rx->descs_dma = tx->descs_dma + tx_size * AG71XX_DESC_SIZE;
-
- ag71xx_ring_tx_init(ag);
-- return ag71xx_ring_rx_init(ag);
-+ ret = ag71xx_ring_rx_init(ag);
-+ if (ret)
-+ goto err_free_dma;
-+
-+ return 0;
-+
-+err_free_dma:
-+ dma_free_coherent(&ag->pdev->dev, ring_size * AG71XX_DESC_SIZE,
-+ tx->descs_cpu, tx->descs_dma);
-+ rx->buf = NULL;
-+err_free_buf:
-+ kfree(tx->buf);
-+ tx->buf = NULL;
-+
-+ return ret;
- }
-
- static void ag71xx_rings_free(struct ag71xx *ag)
diff --git a/target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch b/target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch
deleted file mode 100644
index 16d60a4e0c..0000000000
--- a/target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 2f8c5a68d0030ae5e65fca1bf5ca44929d5b3b06 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke at hauke-m.de>
-Date: Mon, 17 Feb 2020 23:50:23 +0100
-Subject: [PATCH 2/3] ag71xx: Call ag71xx_hw_disable() in case phy_conenct
- fails
-
-When the ag71xx_phy_connect() failed only parts of the actions done
-previously in this function wrere reverted, because only
-ag71xx_rings_cleanup() was called. My system crashed the next time
-open() was called because napi_disable() was not called again and this
-resulted in two calls to napi_enable(), which is not allowed.
-
-Fix this by disabling the device again.
-
-Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
-Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
----
- drivers/net/ethernet/atheros/ag71xx.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
---- a/drivers/net/ethernet/atheros/ag71xx.c
-+++ b/drivers/net/ethernet/atheros/ag71xx.c
-@@ -1263,18 +1263,18 @@ static int ag71xx_open(struct net_device
-
- ret = ag71xx_hw_enable(ag);
- if (ret)
-- goto err;
-+ return ret;
-
- ret = ag71xx_phy_connect(ag);
- if (ret)
-- goto err;
-+ goto err_hw_disable;
-
- phy_start(ndev->phydev);
-
- return 0;
-
--err:
-- ag71xx_rings_cleanup(ag);
-+err_hw_disable:
-+ ag71xx_hw_disable(ag);
- return ret;
- }
-
diff --git a/target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch b/target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch
deleted file mode 100644
index 00f34dffa1..0000000000
--- a/target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From d42c6bf2752a46bdf3931bd6e56db419742fbb20 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke at hauke-m.de>
-Date: Mon, 17 Feb 2020 23:55:22 +0100
-Subject: [PATCH 3/3] ag71xx: Run ag71xx_link_adjust() only when needed
-
-My system printed this line every second:
- ag71xx 19000000.eth eth0: Link is Up - 1Gbps/Full - flow control off
-The function ag71xx_phy_link_adjust() was called by the PHY layer every
-second even when nothing changed.
-
-With this patch the old status is stored and the real
-ag71xx_link_adjust() function is only called when when something really
-changed. This way the update and also this print is only done once any
-more.
-
-Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
-Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
----
- drivers/net/ethernet/atheros/ag71xx.c | 24 +++++++++++++++++++++++-
- 1 file changed, 23 insertions(+), 1 deletion(-)
-
---- a/drivers/net/ethernet/atheros/ag71xx.c
-+++ b/drivers/net/ethernet/atheros/ag71xx.c
-@@ -307,6 +307,10 @@ struct ag71xx {
- u32 msg_enable;
- const struct ag71xx_dcfg *dcfg;
-
-+ unsigned int link;
-+ unsigned int speed;
-+ int duplex;
-+
- /* From this point onwards we're not looking at per-packet fields. */
- void __iomem *mac_base;
-
-@@ -854,6 +858,7 @@ static void ag71xx_link_adjust(struct ag
-
- if (!phydev->link && update) {
- ag71xx_hw_stop(ag);
-+ phy_print_status(phydev);
- return;
- }
-
-@@ -907,8 +912,25 @@ static void ag71xx_link_adjust(struct ag
- static void ag71xx_phy_link_adjust(struct net_device *ndev)
- {
- struct ag71xx *ag = netdev_priv(ndev);
-+ struct phy_device *phydev = ndev->phydev;
-+ int status_change = 0;
-+
-+ if (phydev->link) {
-+ if (ag->duplex != phydev->duplex
-+ || ag->speed != phydev->speed) {
-+ status_change = 1;
-+ }
-+ }
-+
-+ if (phydev->link != ag->link)
-+ status_change = 1;
-+
-+ ag->link = phydev->link;
-+ ag->duplex = phydev->duplex;
-+ ag->speed = phydev->speed;
-
-- ag71xx_link_adjust(ag, true);
-+ if (status_change)
-+ ag71xx_link_adjust(ag, true);
- }
-
- static int ag71xx_phy_connect(struct ag71xx *ag)
diff --git a/target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch b/target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch
new file mode 100644
index 0000000000..17cf3ea957
--- /dev/null
+++ b/target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch
@@ -0,0 +1,28 @@
+--- a/drivers/net/ethernet/atheros/Kconfig
++++ b/drivers/net/ethernet/atheros/Kconfig
+@@ -17,13 +17,7 @@ config NET_VENDOR_ATHEROS
+
+ if NET_VENDOR_ATHEROS
+
+-config AG71XX
+- tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
+- depends on ATH79
+- select PHYLIB
+- help
+- If you wish to compile a kernel for AR7XXX/91XXX and enable
+- ethernet support, then you should always answer Y to this.
++source "drivers/net/ethernet/atheros/ag71xx/Kconfig"
+
+ config ATL2
+ tristate "Atheros L2 Fast Ethernet support"
+--- a/drivers/net/ethernet/atheros/Makefile
++++ b/drivers/net/ethernet/atheros/Makefile
+@@ -3,7 +3,7 @@
+ # Makefile for the Atheros network device drivers.
+ #
+
+-obj-$(CONFIG_AG71XX) += ag71xx.o
++obj-$(CONFIG_AG71XX) += ag71xx/
+ obj-$(CONFIG_ATL1) += atlx/
+ obj-$(CONFIG_ATL2) += atlx/
+ obj-$(CONFIG_ATL1E) += atl1e/
--
2.25.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list