[BUG] The genet is not working
Hi, The genet of Broadcom MIPS 40nm platforms with internal PHY isn't working after v4.20-rc1, but 28nm ARM platforms or external PHY is working. [1.064000] bcmgenet 1043.ethernet: configuring instance for internal PHY [1.068000] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [1.196000] bcmgenet 1043.ethernet eth0: Link is Down [ 11.076000] Waiting up to 110 more seconds for network. [ 21.088000] Waiting up to 100 more seconds for network. [ 31.10] Waiting up to 90 more seconds for network. [ 41.112000] Waiting up to 80 more seconds for network. [ 51.124000] Waiting up to 70 more seconds for network. [ 61.136000] Waiting up to 60 more seconds for network. [ 71.148000] Waiting up to 50 more seconds for network. [ 81.16] Waiting up to 40 more seconds for network. [ 91.172000] Waiting up to 30 more seconds for network. [ 101.184000] Waiting up to 20 more seconds for network. [ 111.196000] Waiting up to 10 more seconds for network. I tried bisecting for this between v4.19 and v4.20-rc1, I found a problematic commit 6e2d85ec0559 ("net: phy: Stop with excessive soft reset"). Thanks, Jaedon
[PATCH] Revert "net: ethernet: bcmgenet: use phydev from struct net_device"
This reverts commit 62469c76007e ("net: ethernet: bcmgenet: use phydev from struct net_device") without this patch, we call twice bcmgenet_mii_reset, and that is intended: - first time from bcmgenet_power_up() to make sure the PHY is initialized *before* we get to initialize the UniMAC, this is critical - second time from bcmgenet_mii_probe(), through the normal phy_init_hw() with this patch, we only get to call bcmgenet_mii_reset once, in bcmgenet_mii_probe() because the first time in bcmgenet_power_up(), dev->phydev is NULL, because of a prior call to phy_disconnect() in bcmgenet_close(), unfortunately, there has been MAC activity, so the PHY gets in a bad state Signed-off-by: Jaedon Shin --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 45 ++ drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 24 +++--- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 8d4f8495dbb3..541456398dfb 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -453,25 +453,29 @@ static inline void bcmgenet_rdma_ring_writel(struct bcmgenet_priv *priv, static int bcmgenet_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { + struct bcmgenet_priv *priv = netdev_priv(dev); + if (!netif_running(dev)) return -EINVAL; - if (!dev->phydev) + if (!priv->phydev) return -ENODEV; - return phy_ethtool_gset(dev->phydev, cmd); + return phy_ethtool_gset(priv->phydev, cmd); } static int bcmgenet_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) { + struct bcmgenet_priv *priv = netdev_priv(dev); + if (!netif_running(dev)) return -EINVAL; - if (!dev->phydev) + if (!priv->phydev) return -ENODEV; - return phy_ethtool_sset(dev->phydev, cmd); + return phy_ethtool_sset(priv->phydev, cmd); } static int bcmgenet_set_rx_csum(struct net_device *dev, @@ -937,7 +941,7 @@ static int bcmgenet_get_eee(struct net_device *dev, struct ethtool_eee *e) e->eee_active = p->eee_active; e->tx_lpi_timer = bcmgenet_umac_readl(priv, UMAC_EEE_LPI_TIMER); - return phy_ethtool_get_eee(dev->phydev, e); + return phy_ethtool_get_eee(priv->phydev, e); } static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e) @@ -954,7 +958,7 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e) if (!p->eee_enabled) { bcmgenet_eee_enable_set(dev, false); } else { - ret = phy_init_eee(dev->phydev, 0); + ret = phy_init_eee(priv->phydev, 0); if (ret) { netif_err(priv, hw, dev, "EEE initialization failed\n"); return ret; @@ -964,12 +968,14 @@ static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e) bcmgenet_eee_enable_set(dev, true); } - return phy_ethtool_set_eee(dev->phydev, e); + return phy_ethtool_set_eee(priv->phydev, e); } static int bcmgenet_nway_reset(struct net_device *dev) { - return genphy_restart_aneg(dev->phydev); + struct bcmgenet_priv *priv = netdev_priv(dev); + + return genphy_restart_aneg(priv->phydev); } /* standard ethtool support functions. */ @@ -996,13 +1002,12 @@ static struct ethtool_ops bcmgenet_ethtool_ops = { static int bcmgenet_power_down(struct bcmgenet_priv *priv, enum bcmgenet_power_mode mode) { - struct net_device *ndev = priv->dev; int ret = 0; u32 reg; switch (mode) { case GENET_POWER_CABLE_SENSE: - phy_detach(ndev->phydev); + phy_detach(priv->phydev); break; case GENET_POWER_WOL_MAGIC: @@ -1063,6 +1068,7 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv, /* ioctl handle special commands that are not present in ethtool. */ static int bcmgenet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { + struct bcmgenet_priv *priv = netdev_priv(dev); int val = 0; if (!netif_running(dev)) @@ -1072,10 +1078,10 @@ static int bcmgenet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) case SIOCGMIIPHY: case SIOCGMIIREG: case SIOCSMIIREG: - if (!dev->phydev) + if (!priv->phydev) val = -ENODEV; else - val = phy_mii_ioctl(dev->phydev, rq, cmd); + val = phy_mii_ioct
Re: [PATCH] net: bcmgenet: Fix EPHY reset in power up
Hi Florian, > On 24 Sep 2016, at 1:54 AM, Florian Fainelli wrote: > > On 09/23/2016 08:04 AM, Jaedon Shin wrote: >> Hi Andrew, >> >> On 23 Sep 2016, at 11:06 PM, Andrew Lunn wrote: >>> >>> On Fri, Sep 23, 2016 at 10:20:04PM +0900, Jaedon Shin wrote: >>>> The bcmgenet_mii_reset() is always not running in power up sequence >>>> after 'commit 62469c76007e ("net: ethernet: bcmgenet: use phydev from >>>> struct net_device")'. This'll show extremely high latency and duplicate >>>> packets while interface down and up repeatedly. >>>> >>>> For now, adds again a private phydev for mii reset when runs power up to >>>> open interface. >>> >>> Hi Jaedon >>> >>> How does this fix the issue? It sounds like you are papering over the >>> crack, not truly fixing it. >>> >>> Andrew >> >> Yes, It feel like a workaround, but I think it must need v4.8 stable >> version. If we find better way that fixes internal PHY to initialize >> after re-open interface, this patch will be dropped. > > I can observe the faulting behavior with 4.8-rc7 that the link below > fixed initially: > > # ping fainelli-linux > PING fainelli-linux (10.112.156.244): 56 data bytes > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=1.352 ms > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=1.472 ms (DUP!) > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=1.496 ms (DUP!) > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=1.517 ms (DUP!) > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=1.536 ms (DUP!) > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=1.557 ms (DUP!) > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=752.448 ms (DUP!) > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=1.291 ms > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=1.421 ms (DUP!) > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=1.444 ms (DUP!) > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=1.464 ms (DUP!) > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=1.483 ms (DUP!) > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=1.505 ms (DUP!) > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=24.964 ms (DUP!) > > If we revert this patch, we indeed get the normal and expected behavior > back: > > # ping fainelli-linux > PING fainelli-linux (10.112.156.244): 56 data bytes > 64 bytes from 10.112.156.244: seq=0 ttl=61 time=0.417 ms > 64 bytes from 10.112.156.244: seq=1 ttl=61 time=0.415 ms > 64 bytes from 10.112.156.244: seq=2 ttl=61 time=0.424 ms > > Actually, the key thing is this: > > - without Philippe's patch we call twice bcmgenet_mii_reset, and that is > intended: > - first time from bcmgenet_power_up() to make sure the PHY is > initialized *before* we get to initialize the UniMAC, this is critical > - second time from bcmgenet_mii_probe(), through the normal > phy_init_hw() > > - with Philippe's patch, we only get to call bcmgenet_mii_reset once, in > bcmgenet_mii_probe() because the first time in bcmgenet_power_up(), > dev->phydev is NULL, because of a prior call to phy_disconnect() in > bcmgenet_close(), unfortunately, there has been MAC activity, so the PHY > gets in a bad state > > Jaedon, feel free to use the explanation above, and send a plain revert > of commit 62469c76007e11428e2ee3c6de90cbe74b588d44. > Will send revert patch. Thanks, Jaedon > Thanks! > > Thanks! > -- > Florian
Re: [PATCH] net: bcmgenet: Fix EPHY reset in power up
Hi Andrew, On 23 Sep 2016, at 11:06 PM, Andrew Lunn wrote: > > On Fri, Sep 23, 2016 at 10:20:04PM +0900, Jaedon Shin wrote: >> The bcmgenet_mii_reset() is always not running in power up sequence >> after 'commit 62469c76007e ("net: ethernet: bcmgenet: use phydev from >> struct net_device")'. This'll show extremely high latency and duplicate >> packets while interface down and up repeatedly. >> >> For now, adds again a private phydev for mii reset when runs power up to >> open interface. > > Hi Jaedon > > How does this fix the issue? It sounds like you are papering over the > crack, not truly fixing it. > > Andrew Yes, It feel like a workaround, but I think it must need v4.8 stable version. If we find better way that fixes internal PHY to initialize after re-open interface, this patch will be dropped. Additionally, http://www.spinics.net/lists/netdev/msg350506.html Thanks, Jaedon
[PATCH] net: bcmgenet: Fix EPHY reset in power up
The bcmgenet_mii_reset() is always not running in power up sequence after 'commit 62469c76007e ("net: ethernet: bcmgenet: use phydev from struct net_device")'. This'll show extremely high latency and duplicate packets while interface down and up repeatedly. For now, adds again a private phydev for mii reset when runs power up to open interface. Signed-off-by: Jaedon Shin --- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + drivers/net/ethernet/broadcom/genet/bcmmii.c | 9 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h index 0f0868c56f05..1e2dc34d331a 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -597,6 +597,7 @@ struct bcmgenet_priv { /* MDIO bus variables */ wait_queue_head_t wq; + struct phy_device *phydev; bool internal_phy; struct device_node *phy_dn; struct device_node *mdio_dn; diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index e907acd81da9..b2bd5302c478 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -183,9 +183,9 @@ void bcmgenet_mii_reset(struct net_device *dev) if (GENET_IS_V4(priv)) return; - if (dev->phydev) { - phy_init_hw(dev->phydev); - phy_start_aneg(dev->phydev); + if (priv->phydev) { + phy_init_hw(priv->phydev); + phy_start_aneg(priv->phydev); } } @@ -383,6 +383,8 @@ int bcmgenet_mii_probe(struct net_device *dev) } } + priv->phydev = phydev; + /* Configure port multiplexer based on what the probed PHY device since * reading the 'max-speed' property determines the maximum supported * PHY speed which is needed for bcmgenet_mii_config() to configure @@ -605,6 +607,7 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv) } + priv->phydev = phydev; priv->phy_interface = pd->phy_interface; return 0; -- 2.10.0
[PATCH] net: phy: bcm7xxx: Add entries for Broadcom BCM7346 and BCM7362
Add PHY entries for the Broadcom BCM7346 and BCM7362 chips, these are 40nm generation Ethernet PHY. Fixes: 815717d1473e ("net: phy: bcm7xxx: Remove wildcard entries") Signed-off-by: Jaedon Shin --- drivers/net/phy/bcm7xxx.c | 4 include/linux/brcmphy.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/net/phy/bcm7xxx.c b/drivers/net/phy/bcm7xxx.c index b881a7b1e4f6..9636da0b6efc 100644 --- a/drivers/net/phy/bcm7xxx.c +++ b/drivers/net/phy/bcm7xxx.c @@ -339,6 +339,8 @@ static struct phy_driver bcm7xxx_driver[] = { BCM7XXX_28NM_GPHY(PHY_ID_BCM7439, "Broadcom BCM7439"), BCM7XXX_28NM_GPHY(PHY_ID_BCM7439_2, "Broadcom BCM7439 (2)"), BCM7XXX_28NM_GPHY(PHY_ID_BCM7445, "Broadcom BCM7445"), + BCM7XXX_40NM_EPHY(PHY_ID_BCM7346, "Broadcom BCM7346"), + BCM7XXX_40NM_EPHY(PHY_ID_BCM7362, "Broadcom BCM7362"), BCM7XXX_40NM_EPHY(PHY_ID_BCM7425, "Broadcom BCM7425"), BCM7XXX_40NM_EPHY(PHY_ID_BCM7429, "Broadcom BCM7429"), BCM7XXX_40NM_EPHY(PHY_ID_BCM7435, "Broadcom BCM7435"), @@ -348,6 +350,8 @@ static struct mdio_device_id __maybe_unused bcm7xxx_tbl[] = { { PHY_ID_BCM7250, 0xfff0, }, { PHY_ID_BCM7364, 0xfff0, }, { PHY_ID_BCM7366, 0xfff0, }, + { PHY_ID_BCM7346, 0xfff0, }, + { PHY_ID_BCM7362, 0xfff0, }, { PHY_ID_BCM7425, 0xfff0, }, { PHY_ID_BCM7429, 0xfff0, }, { PHY_ID_BCM7439, 0xfff0, }, diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h index f0ba9c2ec639..e3354b74286c 100644 --- a/include/linux/brcmphy.h +++ b/include/linux/brcmphy.h @@ -24,6 +24,8 @@ #define PHY_ID_BCM7250 0xae025280 #define PHY_ID_BCM7364 0xae025260 #define PHY_ID_BCM7366 0x600d8490 +#define PHY_ID_BCM7346 0x600d8650 +#define PHY_ID_BCM7362 0x600d84b0 #define PHY_ID_BCM7425 0x600d86b0 #define PHY_ID_BCM7429 0x600d8730 #define PHY_ID_BCM7435 0x600d8750 -- 2.7.4
[PATCH] net: bcmgenet: Fix internal PHY link state
The PHY link state is not chaged in GENETv2 caused by the previous commit 49f7a471e4d1 ("net: bcmgenet: Properly configure PHY to ignore interrupt") was set to PHY_IGNORE_INTERRUPT in bcmgenet_mii_probe(). The internal PHY should use phy_mac_interrupt() when not in use PHY_POLL. The statement for phy_mac_interrupt() has two conditions. The first condition to check GENET_HAS_MDIO_INTR is not related PHY link state, so this patch removes it. Fixes: 49f7a471e4d1 ("net: bcmgenet: Properly configure PHY to ignore interrupt") Signed-off-by: Jaedon Shin --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index b15a60d787c7..d7e01a74e927 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2445,8 +2445,7 @@ static void bcmgenet_irq_task(struct work_struct *work) } /* Link UP/DOWN event */ - if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) && - (priv->irq0_stat & UMAC_IRQ_LINK_EVENT)) { + if (priv->irq0_stat & UMAC_IRQ_LINK_EVENT) { phy_mac_interrupt(priv->phydev, !!(priv->irq0_stat & UMAC_IRQ_LINK_UP)); priv->irq0_stat &= ~UMAC_IRQ_LINK_EVENT; -- 2.7.1
Re: [PATCH] net: bcmgenet: Add MDIO_INTR in GENETv2
Hi Florian, > On Feb 16, 2016, at 3:18 AM, Florian Fainelli wrote: > > Hi Jaedon, > > On 15/02/2016 00:42, Jaedon Shin wrote: >> The GENETv2 chipsets has MDIO interrupt like the GENETv3+ chipsets. >> >> The previous commit d5c3d84657db ("net: phy: Avoid polling PHY with >> PHY_IGNORE_INTERRUPTS") and commit 49f7a471e4d1 ("net: bcmgenet: Properly >> configure PHY to ignore interrupt") cause link-down PHY always in some >> 40nm generation chipsets. > > Humm, these are two different things here: > > - GENET_HAS_MDIO_INTR is about telling the driver whether the hardware > supports MDIO_INTR_DONE and MDIO_INTR_ERROR > - eliminating PHY polling is about utilizing LINK_UP and LINK_DOWN to > avoid polling the PHY > > So the original problem is actually here: > > bcmgenet_irq_task(): > > /* Link UP/DOWN event */ > if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) && > (priv->irq0_stat & UMAC_IRQ_LINK_EVENT)) { > > These two checks are actually orthogonal, so we should remove the first > check on GENET_HAS_MDIO_INTR. > As you said, the part in bcmgenet_irq_task() is a problem. The bcmgenet using internal PHY should use phy_mac_interrupt() cause it has not PHY_POLL, and it depends on Ethernet MAC ISR. UMAC_IRQ_LINK_EVENT(LINK_UP and LINK_DOWN) was working correctly in GENETv2, but (priv->hw_params->flags & GENET_HAS_MDIO_INTR) was blocking to call phy_mac_interrupt(). I didn't find a reason through datasheet without MDIO_INTR in GENETv2. However, I'm not sure using MDIO_INTR. Therefore if MDIO_INTR is not valid in GENETv2, I will send the patch again to remove the first chicken GENET_HAS_MDIO_INTR after your confirm. Thanks, Jaedon > Your patch remains valid though, just the explanation needs a bit > tweaking, thanks! > >> >> Signed-off-by: Jaedon Shin >> --- >> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++-- >> drivers/net/ethernet/broadcom/genet/bcmgenet.h | 2 +- >> 2 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> index b15a60d787c7..8e9aa8f6390d 100644 >> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> @@ -1904,7 +1904,7 @@ static int init_umac(struct bcmgenet_priv *priv) >> bcmgenet_bp_mc_set(priv, reg); >> } >> >> -/* Enable MDIO interrupts on GENET v3+ */ >> +/* Enable MDIO interrupts on GENET v2+ */ >> if (priv->hw_params->flags & GENET_HAS_MDIO_INTR) >> int0_enable |= (UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR); >> >> @@ -3168,7 +3168,7 @@ static struct bcmgenet_hw_params bcmgenet_hw_params[] >> = { >> .rdma_offset = 0x3000, >> .tdma_offset = 0x4000, >> .words_per_bd = 2, >> -.flags = GENET_HAS_EXT, >> +.flags = GENET_HAS_EXT | GENET_HAS_MDIO_INTR, >> }, >> [GENET_V3] = { >> .tx_queues = 4, >> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h >> b/drivers/net/ethernet/broadcom/genet/bcmgenet.h >> index 967367557309..c14bfbfbe06a 100644 >> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h >> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h >> @@ -310,7 +310,7 @@ struct bcmgenet_mib_counters { >> #define UMAC_IRQ_TXDMA_BDONE (1 << 18) >> #define UMAC_IRQ_TXDMA_DONE UMAC_IRQ_TXDMA_MBDONE >> >> -/* Only valid for GENETv3+ */ >> +/* Only valid for GENETv2+ */ >> #define UMAC_IRQ_MDIO_DONE (1 << 23) >> #define UMAC_IRQ_MDIO_ERROR (1 << 24) >> >>
[PATCH] net: bcmgenet: Add MDIO_INTR in GENETv2
The GENETv2 chipsets has MDIO interrupt like the GENETv3+ chipsets. The previous commit d5c3d84657db ("net: phy: Avoid polling PHY with PHY_IGNORE_INTERRUPTS") and commit 49f7a471e4d1 ("net: bcmgenet: Properly configure PHY to ignore interrupt") cause link-down PHY always in some 40nm generation chipsets. Signed-off-by: Jaedon Shin --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++-- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index b15a60d787c7..8e9aa8f6390d 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -1904,7 +1904,7 @@ static int init_umac(struct bcmgenet_priv *priv) bcmgenet_bp_mc_set(priv, reg); } - /* Enable MDIO interrupts on GENET v3+ */ + /* Enable MDIO interrupts on GENET v2+ */ if (priv->hw_params->flags & GENET_HAS_MDIO_INTR) int0_enable |= (UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR); @@ -3168,7 +3168,7 @@ static struct bcmgenet_hw_params bcmgenet_hw_params[] = { .rdma_offset = 0x3000, .tdma_offset = 0x4000, .words_per_bd = 2, - .flags = GENET_HAS_EXT, + .flags = GENET_HAS_EXT | GENET_HAS_MDIO_INTR, }, [GENET_V3] = { .tx_queues = 4, diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h index 967367557309..c14bfbfbe06a 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -310,7 +310,7 @@ struct bcmgenet_mib_counters { #define UMAC_IRQ_TXDMA_BDONE (1 << 18) #define UMAC_IRQ_TXDMA_DONEUMAC_IRQ_TXDMA_MBDONE -/* Only valid for GENETv3+ */ +/* Only valid for GENETv2+ */ #define UMAC_IRQ_MDIO_DONE (1 << 23) #define UMAC_IRQ_MDIO_ERROR(1 << 24) -- 2.7.1
[PATCH v2] net: bcmgenet: fix uncleaned dma flags
Clean the dma flags of multiq ring buffer int the interface stop process. This patch fixes that the genet is not running while the interface is re-enabled. $ ifup eth0 - running after booting $ ifdown eth0 $ ifup eth0 - not running and occur tx_timeout The bcmgenet_dma_disable() in bcmgenet_open() do clean ring16 dma flag only. If the genet has multiq, the dma register is not cleaned. and bcmgenet_init_dma() is not done correctly. in case GENET_V2(tx_queues=4), tdma_ctrl has 0x1e after running bcmgenet_dma_disable(). Signed-off-by: Jaedon Shin --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 64c1e9db6b0b..4812565c783e 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2126,6 +2126,8 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv) int ret = 0; int timeout = 0; u32 reg; + u32 dma_ctrl; + int i; /* Disable TDMA to stop add more frames in TX DMA */ reg = bcmgenet_tdma_readl(priv, DMA_CTRL); @@ -2169,6 +2171,20 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv) ret = -ETIMEDOUT; } + dma_ctrl = 0; + for (i = 0; i < priv->hw_params->rx_queues; i++) + dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT)); + reg = bcmgenet_rdma_readl(priv, DMA_CTRL); + reg &= ~dma_ctrl; + bcmgenet_rdma_writel(priv, reg, DMA_CTRL); + + dma_ctrl = 0; + for (i = 0; i < priv->hw_params->tx_queues; i++) + dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT)); + reg = bcmgenet_tdma_readl(priv, DMA_CTRL); + reg &= ~dma_ctrl; + bcmgenet_tdma_writel(priv, reg, DMA_CTRL); + return ret; } -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] net: bcmgenet: fix uncleaned dma flags
> 2015. 8. 21., 오전 7:04, Florian Fainelli 작성: > > On 19/08/15 20:17, Jaedon Shin wrote: >> Clean the dma flags of multiq ring buffer int the interface stop >> process. This patch fixes that the genet is not running while the >> interface is re-enabled. >> >> $ ifup eth0 - running after booting >> $ ifdown eth0 >> $ ifup eth0 - not running and occur tx_timeout >> >> The bcmgenet_dma_disable() in bcmgenet_open() do clean ring16 dma flag >> only. If the genet has multiq, the dma register is not cleaned. and >> bcmgenet_init_dma() is not done correctly. in case >> GENET_V2(tx_queues=4), tdma_ctrl has 0x1e after running >> bcmgenet_dma_disable(). > > It sounds like this should be moved to bcmgenet_dma_disable() where we > are already modifying DMA_CTRL and returning a dma_ctrl value back to > the caller, or at the very last bcmgenet_dma_teardown(). > > Thanks! > I will send the changes immediately. Thanks. >> >> Signed-off-by: Jaedon Shin >> --- >> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 >> 1 file changed, 16 insertions(+) >> >> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> index 64c1e9db6b0b..81bde6fa70b7 100644 >> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> @@ -2174,6 +2174,8 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv >> *priv) >> >> static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) >> { >> +u32 dma_ctrl; >> +u32 reg; >> int i; >> >> bcmgenet_fini_rx_napi(priv); >> @@ -2182,6 +2184,20 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv >> *priv) >> /* disable DMA */ >> bcmgenet_dma_teardown(priv); >> >> +dma_ctrl = 0; >> +for (i = 0; i < priv->hw_params->rx_queues; i++) >> +dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT)); >> +reg = bcmgenet_rdma_readl(priv, DMA_CTRL); >> +reg &= ~dma_ctrl; >> +bcmgenet_rdma_writel(priv, reg, DMA_CTRL); >> + >> +dma_ctrl = 0; >> +for (i = 0; i < priv->hw_params->tx_queues; i++) >> +dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT)); >> +reg = bcmgenet_tdma_readl(priv, DMA_CTRL); >> +reg &= ~dma_ctrl; >> +bcmgenet_tdma_writel(priv, reg, DMA_CTRL); >> + >> for (i = 0; i < priv->num_tx_bds; i++) { >> if (priv->tx_cbs[i].skb != NULL) { >> dev_kfree_skb(priv->tx_cbs[i].skb); >> > > > -- > Florian -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] net: bcmgenet: fix uncleaned dma flags
Clean the dma flags of multiq ring buffer int the interface stop process. This patch fixes that the genet is not running while the interface is re-enabled. $ ifup eth0 - running after booting $ ifdown eth0 $ ifup eth0 - not running and occur tx_timeout The bcmgenet_dma_disable() in bcmgenet_open() do clean ring16 dma flag only. If the genet has multiq, the dma register is not cleaned. and bcmgenet_init_dma() is not done correctly. in case GENET_V2(tx_queues=4), tdma_ctrl has 0x1e after running bcmgenet_dma_disable(). Signed-off-by: Jaedon Shin --- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 64c1e9db6b0b..81bde6fa70b7 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2174,6 +2174,8 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv) static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) { + u32 dma_ctrl; + u32 reg; int i; bcmgenet_fini_rx_napi(priv); @@ -2182,6 +2184,20 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) /* disable DMA */ bcmgenet_dma_teardown(priv); + dma_ctrl = 0; + for (i = 0; i < priv->hw_params->rx_queues; i++) + dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT)); + reg = bcmgenet_rdma_readl(priv, DMA_CTRL); + reg &= ~dma_ctrl; + bcmgenet_rdma_writel(priv, reg, DMA_CTRL); + + dma_ctrl = 0; + for (i = 0; i < priv->hw_params->tx_queues; i++) + dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT)); + reg = bcmgenet_tdma_readl(priv, DMA_CTRL); + reg &= ~dma_ctrl; + bcmgenet_tdma_writel(priv, reg, DMA_CTRL); + for (i = 0; i < priv->num_tx_bds; i++) { if (priv->tx_cbs[i].skb != NULL) { dev_kfree_skb(priv->tx_cbs[i].skb); -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 0/6] net: bcmgenet: PHY initialization rework
> On Jul 17, 2015, at 7:51 AM, Florian Fainelli wrote: > > Hi David, Petri, Jaedon, > > This patch series reworks how we perform PHY initialization and resets in the > GENET driver. Although this contains mostly fixes, some of the changes are a > bit too intrusive to be backported to 'net' at the moment. > > Some of the motivations behind these changes were to reduce the time spent in > how > performing MDIO transactions, since it is better to perform then when we have > interrupts enabled. This reduces the bring-up time of GENET from ~600 msecs > down > to ~8 msecs, and about the same time for suspend/resume. > > Since I do not currently have a system which is not DT-aware, can you (Petri, > Jaedon) give this a try and confirm things keep working as expected? > > Thanks! > I tested your patch series on Broadcom 40nm set-top box platform that used internal phy. I did not have the exact measurements. but I expect it to improve on the interface-up or link-up time. and I compared the changes roughly from kernel print time. please see below. - before patching [1.865126] bcmgenet 1043.ethernet eth0: Link is Down [3.941132] bcmgenet 1043.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx - after patching [3.145127] bcmgenet 1043.ethernet eth0: Link is Down [4.189140] bcmgenet 1043.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx > Florian Fainelli (6): > net: bcmgenet: Remove excessive PHY reset > net: bcmgenet: Use correct dev_id for free_irq > net: bcmgenet: Power on integrated GPHY in bcmgenet_power_up() > net: bcmgenet: Determine PHY type before scanning MDIO bus > net: bcmgenet: Delay PHY initialization to bcmgenet_open() > net: bcmgenet: Remove init parameter from bcmgenet_mii_config > > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 33 +- > drivers/net/ethernet/broadcom/genet/bcmgenet.h | 5 +- > drivers/net/ethernet/broadcom/genet/bcmmii.c | 84 -- > 3 files changed, 59 insertions(+), 63 deletions(-) > > -- > 2.1.0 > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html