[source] kernel: backport simple bgmac cleanup & fix from Jon

LEDE Commits lede-commits at lists.infradead.org
Tue Aug 16 14:32:30 PDT 2016


rmilecki pushed a commit to source.git, branch master:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=6d3fbf28185624506e4b128d2939414309d2a993

commit 6d3fbf28185624506e4b128d2939414309d2a993
Author: Rafał Miłecki <rafal at milecki.pl>
AuthorDate: Tue Aug 16 23:24:26 2016 +0200

    kernel: backport simple bgmac cleanup & fix from Jon
    
    These 2 trivial patches will be followed by a bigger bgmac rework so
    they are worth backporting in a separated patch.
    
    Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 ...t-bgmac-change-bgmac_-prints-to-dev_-prin.patch | 407 +++++++++++++++++++++
 ...02-net-ethernet-bgmac-add-dma_dev-pointer.patch | 112 ++++++
 .../patches-4.4/773-bgmac-add-srab-switch.patch    |  10 +-
 3 files changed, 524 insertions(+), 5 deletions(-)

diff --git a/target/linux/generic/patches-4.4/075-0001-net-ethernet-bgmac-change-bgmac_-prints-to-dev_-prin.patch b/target/linux/generic/patches-4.4/075-0001-net-ethernet-bgmac-change-bgmac_-prints-to-dev_-prin.patch
new file mode 100644
index 0000000..63b4f4a
--- /dev/null
+++ b/target/linux/generic/patches-4.4/075-0001-net-ethernet-bgmac-change-bgmac_-prints-to-dev_-prin.patch
@@ -0,0 +1,407 @@
+From d00a8281bcc962027dfe409c2f3e3f0546be9200 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason at broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:53 -0400
+Subject: [PATCH 1/5] net: ethernet: bgmac: change bgmac_* prints to dev_*
+ prints
+
+The bgmac_* print wrappers call dev_* prints with the dev pointer from
+the bcma core.  In anticipation of removing the bcma requirement for
+this driver, these must be changed to not reference that struct.  So,
+simply change all of the bgmac_* prints to their dev_* counterparts.  In
+some cases netdev_* prints are more appropriate, so change those as
+well.
+
+Signed-off-by: Jon Mason <jon.mason at broadcom.com>
+Acked-by: Arnd Bergmann <arnd at arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli at gmail.com>
+Tested-by: Florian Fainelli <f.fainelli at gmail.com>
+Signed-off-by: David S. Miller <davem at davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 103 +++++++++++++++++-----------------
+ drivers/net/ethernet/broadcom/bgmac.h |  14 +----
+ 2 files changed, 55 insertions(+), 62 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -50,7 +50,7 @@ static bool bgmac_wait_value(struct bcma
+ 			return true;
+ 		udelay(10);
+ 	}
+-	pr_err("Timeout waiting for reg 0x%X\n", reg);
++	dev_err(&core->dev, "Timeout waiting for reg 0x%X\n", reg);
+ 	return false;
+ }
+ 
+@@ -84,8 +84,8 @@ static void bgmac_dma_tx_reset(struct bg
+ 		udelay(10);
+ 	}
+ 	if (i)
+-		bgmac_err(bgmac, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
+-			  ring->mmio_base, val);
++		dev_err(bgmac->dev, "Timeout suspending DMA TX ring 0x%X (BGMAC_DMA_TX_STAT: 0x%08X)\n",
++			ring->mmio_base, val);
+ 
+ 	/* Remove SUSPEND bit */
+ 	bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_TX_CTL, 0);
+@@ -93,13 +93,13 @@ static void bgmac_dma_tx_reset(struct bg
+ 			      ring->mmio_base + BGMAC_DMA_TX_STATUS,
+ 			      BGMAC_DMA_TX_STAT, BGMAC_DMA_TX_STAT_DISABLED,
+ 			      10000)) {
+-		bgmac_warn(bgmac, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
+-			   ring->mmio_base);
++		dev_warn(bgmac->dev, "DMA TX ring 0x%X wasn't disabled on time, waiting additional 300us\n",
++			 ring->mmio_base);
+ 		udelay(300);
+ 		val = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_TX_STATUS);
+ 		if ((val & BGMAC_DMA_TX_STAT) != BGMAC_DMA_TX_STAT_DISABLED)
+-			bgmac_err(bgmac, "Reset of DMA TX ring 0x%X failed\n",
+-				  ring->mmio_base);
++			dev_err(bgmac->dev, "Reset of DMA TX ring 0x%X failed\n",
++				ring->mmio_base);
+ 	}
+ }
+ 
+@@ -161,7 +161,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
+ 	int i;
+ 
+ 	if (skb->len > BGMAC_DESC_CTL1_LEN) {
+-		bgmac_err(bgmac, "Too long skb (%d)\n", skb->len);
++		netdev_err(bgmac->net_dev, "Too long skb (%d)\n", skb->len);
+ 		goto err_drop;
+ 	}
+ 
+@@ -174,7 +174,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
+ 	 * even when ring->end overflows
+ 	 */
+ 	if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
+-		bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
++		netdev_err(bgmac->net_dev, "TX ring is full, queue should be stopped!\n");
+ 		netif_stop_queue(net_dev);
+ 		return NETDEV_TX_BUSY;
+ 	}
+@@ -241,8 +241,8 @@ err_dma:
+ 	}
+ 
+ err_dma_head:
+-	bgmac_err(bgmac, "Mapping error of skb on ring 0x%X\n",
+-		  ring->mmio_base);
++	netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
++		   ring->mmio_base);
+ 
+ err_drop:
+ 	dev_kfree_skb(skb);
+@@ -321,8 +321,8 @@ static void bgmac_dma_rx_reset(struct bg
+ 			      ring->mmio_base + BGMAC_DMA_RX_STATUS,
+ 			      BGMAC_DMA_RX_STAT, BGMAC_DMA_RX_STAT_DISABLED,
+ 			      10000))
+-		bgmac_err(bgmac, "Reset of ring 0x%X RX failed\n",
+-			  ring->mmio_base);
++		dev_err(bgmac->dev, "Reset of ring 0x%X RX failed\n",
++			ring->mmio_base);
+ }
+ 
+ static void bgmac_dma_rx_enable(struct bgmac *bgmac,
+@@ -371,7 +371,7 @@ static int bgmac_dma_rx_skb_for_slot(str
+ 	dma_addr = dma_map_single(dma_dev, buf + BGMAC_RX_BUF_OFFSET,
+ 				  BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
+ 	if (dma_mapping_error(dma_dev, dma_addr)) {
+-		bgmac_err(bgmac, "DMA mapping error\n");
++		netdev_err(bgmac->net_dev, "DMA mapping error\n");
+ 		put_page(virt_to_head_page(buf));
+ 		return -ENOMEM;
+ 	}
+@@ -466,16 +466,16 @@ static int bgmac_dma_rx_read(struct bgma
+ 
+ 			/* Check for poison and drop or pass the packet */
+ 			if (len == 0xdead && flags == 0xbeef) {
+-				bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
+-					  ring->start);
++				netdev_err(bgmac->net_dev, "Found poisoned packet at slot %d, DMA issue!\n",
++					   ring->start);
+ 				put_page(virt_to_head_page(buf));
+ 				bgmac->net_dev->stats.rx_errors++;
+ 				break;
+ 			}
+ 
+ 			if (len > BGMAC_RX_ALLOC_SIZE) {
+-				bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
+-					  ring->start);
++				netdev_err(bgmac->net_dev, "Found oversized packet at slot %d, DMA issue!\n",
++					   ring->start);
+ 				put_page(virt_to_head_page(buf));
+ 				bgmac->net_dev->stats.rx_length_errors++;
+ 				bgmac->net_dev->stats.rx_errors++;
+@@ -487,7 +487,7 @@ static int bgmac_dma_rx_read(struct bgma
+ 
+ 			skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
+ 			if (unlikely(!skb)) {
+-				bgmac_err(bgmac, "build_skb failed\n");
++				netdev_err(bgmac->net_dev, "build_skb failed\n");
+ 				put_page(virt_to_head_page(buf));
+ 				bgmac->net_dev->stats.rx_errors++;
+ 				break;
+@@ -641,7 +641,7 @@ static int bgmac_dma_alloc(struct bgmac
+ 	BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base));
+ 
+ 	if (!(bcma_aread32(bgmac->core, BCMA_IOST) & BCMA_IOST_DMA64)) {
+-		bgmac_err(bgmac, "Core does not report 64-bit DMA\n");
++		dev_err(bgmac->dev, "Core does not report 64-bit DMA\n");
+ 		return -ENOTSUPP;
+ 	}
+ 
+@@ -655,8 +655,8 @@ static int bgmac_dma_alloc(struct bgmac
+ 						     &ring->dma_base,
+ 						     GFP_KERNEL);
+ 		if (!ring->cpu_base) {
+-			bgmac_err(bgmac, "Allocation of TX ring 0x%X failed\n",
+-				  ring->mmio_base);
++			dev_err(bgmac->dev, "Allocation of TX ring 0x%X failed\n",
++				ring->mmio_base);
+ 			goto err_dma_free;
+ 		}
+ 
+@@ -680,8 +680,8 @@ static int bgmac_dma_alloc(struct bgmac
+ 						     &ring->dma_base,
+ 						     GFP_KERNEL);
+ 		if (!ring->cpu_base) {
+-			bgmac_err(bgmac, "Allocation of RX ring 0x%X failed\n",
+-				  ring->mmio_base);
++			dev_err(bgmac->dev, "Allocation of RX ring 0x%X failed\n",
++				ring->mmio_base);
+ 			err = -ENOMEM;
+ 			goto err_dma_free;
+ 		}
+@@ -800,8 +800,8 @@ static u16 bgmac_phy_read(struct bgmac *
+ 	bcma_write32(core, phy_access_addr, tmp);
+ 
+ 	if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
+-		bgmac_err(bgmac, "Reading PHY %d register 0x%X failed\n",
+-			  phyaddr, reg);
++		dev_err(bgmac->dev, "Reading PHY %d register 0x%X failed\n",
++			phyaddr, reg);
+ 		return 0xffff;
+ 	}
+ 
+@@ -833,7 +833,7 @@ static int bgmac_phy_write(struct bgmac
+ 
+ 	bgmac_write(bgmac, BGMAC_INT_STATUS, BGMAC_IS_MDIO);
+ 	if (bgmac_read(bgmac, BGMAC_INT_STATUS) & BGMAC_IS_MDIO)
+-		bgmac_warn(bgmac, "Error setting MDIO int\n");
++		dev_warn(bgmac->dev, "Error setting MDIO int\n");
+ 
+ 	tmp = BGMAC_PA_START;
+ 	tmp |= BGMAC_PA_WRITE;
+@@ -843,8 +843,8 @@ static int bgmac_phy_write(struct bgmac
+ 	bcma_write32(core, phy_access_addr, tmp);
+ 
+ 	if (!bgmac_wait_value(core, phy_access_addr, BGMAC_PA_START, 0, 1000)) {
+-		bgmac_err(bgmac, "Writing to PHY %d register 0x%X failed\n",
+-			  phyaddr, reg);
++		dev_err(bgmac->dev, "Writing to PHY %d register 0x%X failed\n",
++			phyaddr, reg);
+ 		return -ETIMEDOUT;
+ 	}
+ 
+@@ -897,7 +897,7 @@ static void bgmac_phy_reset(struct bgmac
+ 	bgmac_phy_write(bgmac, bgmac->phyaddr, MII_BMCR, BMCR_RESET);
+ 	udelay(100);
+ 	if (bgmac_phy_read(bgmac, bgmac->phyaddr, MII_BMCR) & BMCR_RESET)
+-		bgmac_err(bgmac, "PHY reset failed\n");
++		dev_err(bgmac->dev, "PHY reset failed\n");
+ 	bgmac_phy_init(bgmac);
+ }
+ 
+@@ -998,7 +998,8 @@ static void bgmac_mac_speed(struct bgmac
+ 		set |= BGMAC_CMDCFG_ES_2500;
+ 		break;
+ 	default:
+-		bgmac_err(bgmac, "Unsupported speed: %d\n", bgmac->mac_speed);
++		dev_err(bgmac->dev, "Unsupported speed: %d\n",
++			bgmac->mac_speed);
+ 	}
+ 
+ 	if (bgmac->mac_duplex == DUPLEX_HALF)
+@@ -1097,8 +1098,8 @@ static void bgmac_chip_reset(struct bgma
+ 
+ 		if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
+ 			if (kstrtou8(buf, 0, &et_swtype))
+-				bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
+-					  buf);
++				dev_err(bgmac->dev, "Failed to parse et_swtype (%s)\n",
++					buf);
+ 			et_swtype &= 0x0f;
+ 			et_swtype <<= 4;
+ 			sw_type = et_swtype;
+@@ -1261,7 +1262,7 @@ static irqreturn_t bgmac_interrupt(int i
+ 
+ 	int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
+ 	if (int_status)
+-		bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
++		dev_err(bgmac->dev, "Unknown IRQs: 0x%08X\n", int_status);
+ 
+ 	/* Disable new interrupts until handling existing ones */
+ 	bgmac_chip_intrs_off(bgmac);
+@@ -1315,7 +1316,7 @@ static int bgmac_open(struct net_device
+ 	err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
+ 			  KBUILD_MODNAME, net_dev);
+ 	if (err < 0) {
+-		bgmac_err(bgmac, "IRQ request error: %d!\n", err);
++		dev_err(bgmac->dev, "IRQ request error: %d!\n", err);
+ 		bgmac_dma_cleanup(bgmac);
+ 		return err;
+ 	}
+@@ -1596,14 +1597,14 @@ static int bgmac_fixed_phy_register(stru
+ 
+ 	phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
+ 	if (!phy_dev || IS_ERR(phy_dev)) {
+-		bgmac_err(bgmac, "Failed to register fixed PHY device\n");
++		dev_err(bgmac->dev, "Failed to register fixed PHY device\n");
+ 		return -ENODEV;
+ 	}
+ 
+ 	err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
+ 				 PHY_INTERFACE_MODE_MII);
+ 	if (err) {
+-		bgmac_err(bgmac, "Connecting PHY failed\n");
++		dev_err(bgmac->dev, "Connecting PHY failed\n");
+ 		return err;
+ 	}
+ 
+@@ -1643,7 +1644,7 @@ static int bgmac_mii_register(struct bgm
+ 
+ 	err = mdiobus_register(mii_bus);
+ 	if (err) {
+-		bgmac_err(bgmac, "Registration of mii bus failed\n");
++		dev_err(bgmac->dev, "Registration of mii bus failed\n");
+ 		goto err_free_irq;
+ 	}
+ 
+@@ -1655,7 +1656,7 @@ static int bgmac_mii_register(struct bgm
+ 	phy_dev = phy_connect(bgmac->net_dev, bus_id, &bgmac_adjust_link,
+ 			      PHY_INTERFACE_MODE_MII);
+ 	if (IS_ERR(phy_dev)) {
+-		bgmac_err(bgmac, "PHY connecton failed\n");
++		dev_err(bgmac->dev, "PHY connecton failed\n");
+ 		err = PTR_ERR(phy_dev);
+ 		goto err_unregister_bus;
+ 	}
+@@ -1704,7 +1705,8 @@ static int bgmac_probe(struct bcma_devic
+ 		mac = sprom->et2mac;
+ 		break;
+ 	default:
+-		pr_err("Unsupported core_unit %d\n", core->core_unit);
++		dev_err(&core->dev, "Unsupported core_unit %d\n",
++			core->core_unit);
+ 		return -ENOTSUPP;
+ 	}
+ 
+@@ -1727,6 +1729,7 @@ static int bgmac_probe(struct bcma_devic
+ 	net_dev->irq = core->irq;
+ 	net_dev->ethtool_ops = &bgmac_ethtool_ops;
+ 	bgmac = netdev_priv(net_dev);
++	bgmac->dev = &core->dev;
+ 	bgmac->net_dev = net_dev;
+ 	bgmac->core = core;
+ 	bcma_set_drvdata(core, bgmac);
+@@ -1738,7 +1741,7 @@ static int bgmac_probe(struct bcma_devic
+ 	/* On BCM4706 we need common core to access PHY */
+ 	if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
+ 	    !core->bus->drv_gmac_cmn.core) {
+-		bgmac_err(bgmac, "GMAC CMN core not found (required for BCM4706)\n");
++		dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n");
+ 		err = -ENODEV;
+ 		goto err_netdev_free;
+ 	}
+@@ -1757,15 +1760,15 @@ static int bgmac_probe(struct bcma_devic
+ 	}
+ 	bgmac->phyaddr &= BGMAC_PHY_MASK;
+ 	if (bgmac->phyaddr == BGMAC_PHY_MASK) {
+-		bgmac_err(bgmac, "No PHY found\n");
++		dev_err(bgmac->dev, "No PHY found\n");
+ 		err = -ENODEV;
+ 		goto err_netdev_free;
+ 	}
+-	bgmac_info(bgmac, "Found PHY addr: %d%s\n", bgmac->phyaddr,
+-		   bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
++	dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr,
++		 bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : "");
+ 
+ 	if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
+-		bgmac_err(bgmac, "PCI setup not implemented\n");
++		dev_err(bgmac->dev, "PCI setup not implemented\n");
+ 		err = -ENOTSUPP;
+ 		goto err_netdev_free;
+ 	}
+@@ -1794,7 +1797,7 @@ static int bgmac_probe(struct bcma_devic
+ 
+ 	err = bgmac_dma_alloc(bgmac);
+ 	if (err) {
+-		bgmac_err(bgmac, "Unable to alloc memory for DMA\n");
++		dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
+ 		goto err_netdev_free;
+ 	}
+ 
+@@ -1808,16 +1811,16 @@ static int bgmac_probe(struct bcma_devic
+ 	bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo &
+ 			       BGMAC_BFL_ENETROBO);
+ 	if (bgmac->has_robosw)
+-		bgmac_warn(bgmac, "Support for Roboswitch not implemented\n");
++		dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
+ 
+ 	if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
+-		bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
++		dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
+ 
+ 	netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
+ 
+ 	err = bgmac_mii_register(bgmac);
+ 	if (err) {
+-		bgmac_err(bgmac, "Cannot register MDIO\n");
++		dev_err(bgmac->dev, "Cannot connect to phy\n");
+ 		goto err_dma_free;
+ 	}
+ 
+@@ -1827,7 +1830,7 @@ static int bgmac_probe(struct bcma_devic
+ 
+ 	err = register_netdev(bgmac->net_dev);
+ 	if (err) {
+-		bgmac_err(bgmac, "Cannot register net device\n");
++		dev_err(bgmac->dev, "Cannot register net device\n");
+ 		goto err_mii_unregister;
+ 	}
+ 
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -1,17 +1,6 @@
+ #ifndef _BGMAC_H
+ #define _BGMAC_H
+ 
+-#define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
+-
+-#define bgmac_err(bgmac, fmt, ...) \
+-	dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
+-#define bgmac_warn(bgmac, fmt, ...) \
+-	dev_warn(&(bgmac)->core->dev, fmt,  ##__VA_ARGS__)
+-#define bgmac_info(bgmac, fmt, ...) \
+-	dev_info(&(bgmac)->core->dev, fmt,  ##__VA_ARGS__)
+-#define bgmac_dbg(bgmac, fmt, ...) \
+-	dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__)
+-
+ #include <linux/bcma/bcma.h>
+ #include <linux/brcmphy.h>
+ #include <linux/netdevice.h>
+@@ -438,6 +427,8 @@ struct bgmac_rx_header {
+ struct bgmac {
+ 	struct bcma_device *core;
+ 	struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
++
++	struct device *dev;
+ 	struct net_device *net_dev;
+ 	struct napi_struct napi;
+ 	struct mii_bus *mii_bus;
+@@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgma
+ {
+ 	bgmac_maskset(bgmac, offset, ~0, set);
+ }
+-
+ #endif /* _BGMAC_H */
diff --git a/target/linux/generic/patches-4.4/075-0002-net-ethernet-bgmac-add-dma_dev-pointer.patch b/target/linux/generic/patches-4.4/075-0002-net-ethernet-bgmac-add-dma_dev-pointer.patch
new file mode 100644
index 0000000..eeef86a
--- /dev/null
+++ b/target/linux/generic/patches-4.4/075-0002-net-ethernet-bgmac-add-dma_dev-pointer.patch
@@ -0,0 +1,112 @@
+From a0b68486f6f680c7c0352a47c60042d7d95ffd87 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason at broadcom.com>
+Date: Thu, 7 Jul 2016 19:08:54 -0400
+Subject: [PATCH 2/5] net: ethernet: bgmac: add dma_dev pointer
+
+The dma buffer allocation, etc references a dma_dev device pointer from
+the bcma core.  In anticipation of removing the bcma requirement for
+this driver, these must be changed to not reference that struct.  Add a
+dma_dev device pointer to the bgmac stuct and reference that instead.
+
+Signed-off-by: Jon Mason <jon.mason at broadcom.com>
+Acked-by: Arnd Bergmann <arnd at arndb.de>
+Reviewed-by: Florian Fainelli <f.fainelli at gmail.com>
+Tested-by: Florian Fainelli <f.fainelli at gmail.com>
+Signed-off-by: David S. Miller <davem at davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac.c | 17 +++++++++--------
+ drivers/net/ethernet/broadcom/bgmac.h |  1 +
+ 2 files changed, 10 insertions(+), 8 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -152,7 +152,7 @@ static netdev_tx_t bgmac_dma_tx_add(stru
+ 				    struct bgmac_dma_ring *ring,
+ 				    struct sk_buff *skb)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	struct net_device *net_dev = bgmac->net_dev;
+ 	int index = ring->end % BGMAC_TX_RING_SLOTS;
+ 	struct bgmac_slot_info *slot = &ring->slots[index];
+@@ -254,7 +254,7 @@ err_drop:
+ /* Free transmitted packets */
+ static void bgmac_dma_tx_free(struct bgmac *bgmac, struct bgmac_dma_ring *ring)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	int empty_slot;
+ 	bool freed = false;
+ 	unsigned bytes_compl = 0, pkts_compl = 0;
+@@ -352,7 +352,7 @@ static void bgmac_dma_rx_enable(struct b
+ static int bgmac_dma_rx_skb_for_slot(struct bgmac *bgmac,
+ 				     struct bgmac_slot_info *slot)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	dma_addr_t dma_addr;
+ 	struct bgmac_rx_header *rx;
+ 	void *buf;
+@@ -441,7 +441,7 @@ static int bgmac_dma_rx_read(struct bgma
+ 	end_slot /= sizeof(struct bgmac_dma_desc);
+ 
+ 	while (ring->start != end_slot) {
+-		struct device *dma_dev = bgmac->core->dma_dev;
++		struct device *dma_dev = bgmac->dma_dev;
+ 		struct bgmac_slot_info *slot = &ring->slots[ring->start];
+ 		struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
+ 		struct sk_buff *skb;
+@@ -544,7 +544,7 @@ static bool bgmac_dma_unaligned(struct b
+ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
+ 				   struct bgmac_dma_ring *ring)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	struct bgmac_dma_desc *dma_desc = ring->cpu_base;
+ 	struct bgmac_slot_info *slot;
+ 	int i;
+@@ -570,7 +570,7 @@ static void bgmac_dma_tx_ring_free(struc
+ static void bgmac_dma_rx_ring_free(struct bgmac *bgmac,
+ 				   struct bgmac_dma_ring *ring)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	struct bgmac_slot_info *slot;
+ 	int i;
+ 
+@@ -591,7 +591,7 @@ static void bgmac_dma_ring_desc_free(str
+ 				     struct bgmac_dma_ring *ring,
+ 				     int num_slots)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	int size;
+ 
+ 	if (!ring->cpu_base)
+@@ -629,7 +629,7 @@ static void bgmac_dma_free(struct bgmac
+ 
+ static int bgmac_dma_alloc(struct bgmac *bgmac)
+ {
+-	struct device *dma_dev = bgmac->core->dma_dev;
++	struct device *dma_dev = bgmac->dma_dev;
+ 	struct bgmac_dma_ring *ring;
+ 	static const u16 ring_base[] = { BGMAC_DMA_BASE0, BGMAC_DMA_BASE1,
+ 					 BGMAC_DMA_BASE2, BGMAC_DMA_BASE3, };
+@@ -1730,6 +1730,7 @@ static int bgmac_probe(struct bcma_devic
+ 	net_dev->ethtool_ops = &bgmac_ethtool_ops;
+ 	bgmac = netdev_priv(net_dev);
+ 	bgmac->dev = &core->dev;
++	bgmac->dma_dev = core->dma_dev;
+ 	bgmac->net_dev = net_dev;
+ 	bgmac->core = core;
+ 	bcma_set_drvdata(core, bgmac);
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -429,6 +429,7 @@ struct bgmac {
+ 	struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */
+ 
+ 	struct device *dev;
++	struct device *dma_dev;
+ 	struct net_device *net_dev;
+ 	struct napi_struct napi;
+ 	struct mii_bus *mii_bus;
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 14986b5..3892d8e 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 <hauke at hauke-m.de>
  #include <linux/bcm47xx_nvram.h>
  
  static const struct bcma_device_id bgmac_bcma_tbl[] = {
-@@ -1680,6 +1681,17 @@ static void bgmac_mii_unregister(struct
+@@ -1681,6 +1682,17 @@ static void bgmac_mii_unregister(struct
  	mdiobus_free(mii_bus);
  }
  
@@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
  /**************************************************
   * BCMA bus ops
   **************************************************/
-@@ -1825,6 +1837,14 @@ static int bgmac_probe(struct bcma_devic
+@@ -1829,6 +1841,14 @@ static int bgmac_probe(struct bcma_devic
  	net_dev->hw_features = net_dev->features;
  	net_dev->vlan_features = net_dev->features;
  
@@ -44,8 +44,8 @@ Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
 +
  	err = register_netdev(bgmac->net_dev);
  	if (err) {
- 		bgmac_err(bgmac, "Cannot register net device\n");
-@@ -1851,6 +1871,10 @@ static void bgmac_remove(struct bcma_dev
+ 		dev_err(bgmac->dev, "Cannot register net device\n");
+@@ -1855,6 +1875,10 @@ static void bgmac_remove(struct bcma_dev
  {
  	struct bgmac *bgmac = bcma_get_drvdata(core);
  
@@ -58,7 +58,7 @@ Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
  	netif_napi_del(&bgmac->napi);
 --- a/drivers/net/ethernet/broadcom/bgmac.h
 +++ b/drivers/net/ethernet/broadcom/bgmac.h
-@@ -462,6 +462,9 @@ struct bgmac {
+@@ -454,6 +454,9 @@ struct bgmac {
  	bool has_robosw;
  
  	bool loopback;



More information about the lede-commits mailing list