From e2a65f4aa550d59e8ddda2d84e73c200f76ce543 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Mon, 7 Nov 2016 14:40:24 +0100 Subject: [PATCH] bgmac: backport small DMA fix MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It's supposed to significantly improve performance but doesn't seem to affect Northstar unfortunately. It seems only some other platforms were limited because of this DMA setup mistake. Signed-off-by: Rafał Miłecki --- ...pelling-mistake-connecton-connection.patch | 25 ++++++++ ...ing-DMA-receive-control-register-rig.patch | 59 +++++++++++++++++++ ...versed-checks-for-clock-control-flag.patch | 2 +- .../773-bgmac-add-srab-switch.patch | 6 +- 4 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 target/linux/generic/patches-4.4/077-0004-net-bgmac-fix-spelling-mistake-connecton-connection.patch create mode 100644 target/linux/generic/patches-4.4/077-0005-bgmac-stop-clearing-DMA-receive-control-register-rig.patch diff --git a/target/linux/generic/patches-4.4/077-0004-net-bgmac-fix-spelling-mistake-connecton-connection.patch b/target/linux/generic/patches-4.4/077-0004-net-bgmac-fix-spelling-mistake-connecton-connection.patch new file mode 100644 index 0000000000..9abe559e1d --- /dev/null +++ b/target/linux/generic/patches-4.4/077-0004-net-bgmac-fix-spelling-mistake-connecton-connection.patch @@ -0,0 +1,25 @@ +From c121f72a66c5f92fbe2fc53baa274eef39875cec Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Mon, 24 Oct 2016 23:46:18 +0100 +Subject: [PATCH] net: bgmac: fix spelling mistake: "connecton" -> "connection" + +trivial fix to spelling mistake in dev_err message + +Signed-off-by: Colin Ian King +Acked-by: Jon Mason +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -1465,7 +1465,7 @@ static int bgmac_phy_connect(struct bgma + phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link, + PHY_INTERFACE_MODE_MII); + if (IS_ERR(phy_dev)) { +- dev_err(bgmac->dev, "PHY connecton failed\n"); ++ dev_err(bgmac->dev, "PHY connection failed\n"); + return PTR_ERR(phy_dev); + } + diff --git a/target/linux/generic/patches-4.4/077-0005-bgmac-stop-clearing-DMA-receive-control-register-rig.patch b/target/linux/generic/patches-4.4/077-0005-bgmac-stop-clearing-DMA-receive-control-register-rig.patch new file mode 100644 index 0000000000..0c4767895b --- /dev/null +++ b/target/linux/generic/patches-4.4/077-0005-bgmac-stop-clearing-DMA-receive-control-register-rig.patch @@ -0,0 +1,59 @@ +From fcdefccac976ee51dd6071832b842d8fb41c479c Mon Sep 17 00:00:00 2001 +From: Andy Gospodarek +Date: Mon, 31 Oct 2016 13:32:03 -0400 +Subject: [PATCH] bgmac: stop clearing DMA receive control register right after + it is set + +Current bgmac code initializes some DMA settings in the receive control +register for some hardware and then immediately clears those settings. +Not clearing those settings results in ~420Mbps *improvement* in +throughput; this system can now receive frames at line-rate on Broadcom +5871x hardware compared to ~520Mbps today. I also tested a few other +values but found there to be no discernible difference in CPU +utilization even if burst size and prefetching values are different. + +On the hardware tested there was no need to keep the code that cleared +all but bits 16-17, but since there is a wide variety of hardware that +used this driver (I did not look at all hardware docs for hardware using +this IP block), I find it wise to move this call up and clear bits just +after reading the default value from the hardware rather than completely +removing it. + +This is a good candidate for -stable >=3.14 since that is when the code +that was supposed to improve performance (but did not) was introduced. + +Signed-off-by: Andy Gospodarek +Fixes: 56ceecde1f29 ("bgmac: initialize the DMA controller of core...") +Cc: Hauke Mehrtens +Acked-by: Hauke Mehrtens +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/broadcom/bgmac.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c +index 31ca204..91cbf92 100644 +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -307,6 +307,10 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac, + u32 ctl; + + ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL); ++ ++ /* preserve ONLY bits 16-17 from current hardware value */ ++ ctl &= BGMAC_DMA_RX_ADDREXT_MASK; ++ + if (bgmac->feature_flags & BGMAC_FEAT_RX_MASK_SETUP) { + ctl &= ~BGMAC_DMA_RX_BL_MASK; + ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT; +@@ -317,7 +321,6 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac, + ctl &= ~BGMAC_DMA_RX_PT_MASK; + ctl |= BGMAC_DMA_RX_PT_1 << BGMAC_DMA_RX_PT_SHIFT; + } +- ctl &= BGMAC_DMA_RX_ADDREXT_MASK; + ctl |= BGMAC_DMA_RX_ENABLE; + ctl |= BGMAC_DMA_RX_PARITY_DISABLE; + ctl |= BGMAC_DMA_RX_OVERFLOW_CONT; +-- +2.10.1 + diff --git a/target/linux/generic/patches-4.4/170-net-bgmac-fix-reversed-checks-for-clock-control-flag.patch b/target/linux/generic/patches-4.4/170-net-bgmac-fix-reversed-checks-for-clock-control-flag.patch index b4c5d7f5e3..97d8951589 100644 --- a/target/linux/generic/patches-4.4/170-net-bgmac-fix-reversed-checks-for-clock-control-flag.patch +++ b/target/linux/generic/patches-4.4/170-net-bgmac-fix-reversed-checks-for-clock-control-flag.patch @@ -18,7 +18,7 @@ Cc: Jon Mason --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c -@@ -1046,9 +1046,9 @@ static void bgmac_enable(struct bgmac *b +@@ -1049,9 +1049,9 @@ static void bgmac_enable(struct bgmac *b mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >> BGMAC_DS_MM_SHIFT; diff --git a/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch b/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch index 49c0dcac3d..990d23dc8e 100644 --- a/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch +++ b/target/linux/generic/patches-4.4/773-bgmac-add-srab-switch.patch @@ -12,7 +12,7 @@ Signed-off-by: Hauke Mehrtens #include #include "bgmac.h" -@@ -1400,6 +1401,17 @@ static const struct ethtool_ops bgmac_et +@@ -1403,6 +1404,17 @@ static const struct ethtool_ops bgmac_et .get_drvinfo = bgmac_get_drvinfo, }; @@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens /************************************************** * MII **************************************************/ -@@ -1536,6 +1548,14 @@ int bgmac_enet_probe(struct bgmac *info) +@@ -1539,6 +1551,14 @@ int bgmac_enet_probe(struct bgmac *info) net_dev->hw_features = net_dev->features; net_dev->vlan_features = net_dev->features; @@ -45,7 +45,7 @@ Signed-off-by: Hauke Mehrtens err = register_netdev(bgmac->net_dev); if (err) { dev_err(bgmac->dev, "Cannot register net device\n"); -@@ -1559,6 +1579,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe); +@@ -1562,6 +1582,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe); void bgmac_enet_remove(struct bgmac *bgmac) { -- 2.30.2