]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ath79: use downstream ag71xx for Kernel 5.4
authorDavid Bauer <mail@david-bauer.net>
Fri, 13 Mar 2020 00:07:39 +0000 (01:07 +0100)
committerDavid Bauer <mail@david-bauer.net>
Fri, 13 Mar 2020 19:43:57 +0000 (20:43 +0100)
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@hauke-m.de>
Signed-off-by: David Bauer <mail@david-bauer.net>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
14 files changed:
target/linux/ath79/config-5.4
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Kconfig [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Kconfig with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/Makefile [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/Makefile with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx.h with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_debugfs.c with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_ethtool.c with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_gmac.c with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c with 99% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_mdio.c with 100% similarity]
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c [moved from target/linux/ath79/files-4.19/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c with 100% similarity]
target/linux/ath79/patches-5.4/200-ag71xx-Handle-allocation-errors-in-ag71xx_rings_init.patch [deleted file]
target/linux/ath79/patches-5.4/201-ag71xx-Call-ag71xx_hw_disable-in-case-phy_conenct-fa.patch [deleted file]
target/linux/ath79/patches-5.4/202-ag71xx-Run-ag71xx_link_adjust-only-when-needed.patch [deleted file]
target/linux/ath79/patches-5.4/420-net-use-downstream-ag71xx.patch [new file with mode: 0644]

index 24475d9ae5c2ac8e9d94edc7f18872090b083e2a..6f607ee7e409db6809336864cc0ce2ffca181552 100644 (file)
@@ -1,4 +1,6 @@
 CONFIG_AG71XX=y
+# CONFIG_AG71XX_DEBUG is not set
+CONFIG_AG71XX_DEBUG_FS=y
 CONFIG_AR8216_PHY=y
 CONFIG_AR8216_PHY_LEDS=y
 CONFIG_ARCH_32BIT_OFF_T=y
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 2394ccc90d10883a64554232740b3608901d032d..edb026544c8ded0dde9fc7f5eba0a91e1b5bfa41 100644 (file)
@@ -1581,11 +1581,15 @@ 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)
-               memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
-       if (!mac_addr || !is_valid_ether_addr(dev->dev_addr)) {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0))
+       if (!mac_addr || !is_valid_ether_addr(mac_addr)) {
+#else
+       if (IS_ERR(mac_addr) || !is_valid_ether_addr(mac_addr)) {
+#endif
                dev_err(&pdev->dev, "invalid MAC address, using random address\n");
                eth_random_addr(dev->dev_addr);
+       } else {
+               memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
        }
 
        ag->phy_if_mode = of_get_phy_mode(np);
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 (file)
index 6631cb8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-From 2cee757eaf5cc6175bc0ac7b0b808794124ec40a Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@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@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 (file)
index 16d60a4..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-From 2f8c5a68d0030ae5e65fca1bf5ca44929d5b3b06 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@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@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 (file)
index 00f34df..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-From d42c6bf2752a46bdf3931bd6e56db419742fbb20 Mon Sep 17 00:00:00 2001
-From: Hauke Mehrtens <hauke@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@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 (file)
index 0000000..17cf3ea
--- /dev/null
@@ -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/