From: Florian Fainelli <f.fainelli@gmail.com>
To: Paul Burton <paul.burton@mips.com>, netdev@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH v7 06/11] net: pch_gbe: Only enable MAC when PHY link is active
Date: Wed, 27 Jun 2018 10:54:24 -0700 [thread overview]
Message-ID: <34bf7133-5f4d-ef61-2448-e1fcc1e3036a@gmail.com> (raw)
In-Reply-To: <20180627000612.27263-7-paul.burton@mips.com>
On 06/26/2018 05:06 PM, Paul Burton wrote:
> When using a PHY connected via RGMII, as the pch_gbe driver presumes is
> the case, the RX clock is provided by the PHY to the MAC. Various PHYs,
> including both the AR8031 used by the Minnowboard & the RTL8211E used by
> the MIPS Boston development board, will stop generating the RX clock
> when the ethernet link is down (eg. the ethernet cable is unplugged).
>
> Various pieces of functionality in the EG20T MAC, ranging from basics
> like completing a MAC reset to programming MAC addresses, rely upon the
> RX clock being provided. When the clock is not provided these pieces of
> functionality simply never complete, and the busy bits that indicate
> they're in progress remain set indefinitely.
>
> The pch_gbe driver currently requires that the RX clock is always
> provided, and attempts to enforce this by disabling the hibernation
> feature of the AR8031 PHY to keep it generating the RX clock. This patch
> moves us away from this model by only configuring the MAC when the PHY
> indicates that the ethernet link is up. When the link is up we should be
> able to safely expect that the RX clock is being provided, and therefore
> safely reset & configure the MAC.
What we ended up doing in the bcmgenet driver is loop back the RX and TX
clocks such that we always have a clock that we can use to perform any
MAC operation, including reset.
Is this an option here? You might also want to split the allocation from
the actual initialization if this is not done already.
>
> Signed-off-by: Paul Burton <paul.burton@mips.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: netdev@vger.kernel.org
> ---
>
> Changes in v7: New patch
>
> .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 44 +++++++++----------
> 1 file changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> index eb290c1edce0..721ce29b6467 100644
> --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> @@ -1837,7 +1837,6 @@ static int pch_gbe_request_irq(struct pch_gbe_adapter *adapter)
> int pch_gbe_up(struct pch_gbe_adapter *adapter)
> {
> struct net_device *netdev = adapter->netdev;
> - struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
> struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
> int err = -EINVAL;
>
> @@ -1847,14 +1846,6 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
> goto out;
> }
>
> - /* hardware has been reset, we need to reload some things */
> - pch_gbe_set_multi(netdev);
> -
> - pch_gbe_setup_tctl(adapter);
> - pch_gbe_configure_tx(adapter);
> - pch_gbe_setup_rctl(adapter);
> - pch_gbe_configure_rx(adapter);
> -
> err = pch_gbe_request_irq(adapter);
> if (err) {
> netdev_err(netdev,
> @@ -1867,18 +1858,9 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
> "Error: can't bring device up - alloc rx buffers pool failed\n");
> goto freeirq;
> }
> - pch_gbe_alloc_tx_buffers(adapter, tx_ring);
> - pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
> adapter->tx_queue_len = netdev->tx_queue_len;
> - pch_gbe_enable_dma_rx(&adapter->hw);
> - pch_gbe_enable_mac_rx(&adapter->hw);
>
> mod_timer(&adapter->watchdog_timer, jiffies);
> -
> - napi_enable(&adapter->napi);
> - pch_gbe_irq_enable(adapter);
> - netif_start_queue(adapter->netdev);
> -
> return 0;
>
> freeirq:
> @@ -1930,6 +1912,8 @@ static void pch_gbe_watchdog(struct timer_list *t)
> {
> struct pch_gbe_adapter *adapter = from_timer(adapter, t,
> watchdog_timer);
> + struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
> + struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
> struct net_device *netdev = adapter->netdev;
> struct pch_gbe_hw *hw = &adapter->hw;
>
> @@ -1950,12 +1934,32 @@ static void pch_gbe_watchdog(struct timer_list *t)
> }
> hw->mac.link_speed = ethtool_cmd_speed(&cmd);
> hw->mac.link_duplex = cmd.duplex;
> +
> + pch_gbe_reset(adapter);
> +
> /* Set the RGMII control. */
> pch_gbe_set_rgmii_ctrl(adapter, hw->mac.link_speed,
> hw->mac.link_duplex);
> /* Set the communication mode */
> pch_gbe_set_mode(adapter, hw->mac.link_speed,
> hw->mac.link_duplex);
> +
> + pch_gbe_set_multi(netdev);
> + pch_gbe_setup_tctl(adapter);
> + pch_gbe_configure_tx(adapter);
> + pch_gbe_setup_rctl(adapter);
> + pch_gbe_configure_rx(adapter);
> +
> + pch_gbe_alloc_tx_buffers(adapter, tx_ring);
> + pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
> +
> + pch_gbe_enable_dma_rx(&adapter->hw);
> + pch_gbe_enable_mac_rx(&adapter->hw);
> +
> + napi_enable(&adapter->napi);
> + pch_gbe_irq_enable(adapter);
> + netif_start_queue(adapter->netdev);
> +
> netdev_dbg(netdev,
> "Link is Up %d Mbps %s-Duplex\n",
> hw->mac.link_speed,
> @@ -2568,7 +2572,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
> (ETH_HLEN + ETH_FCS_LEN);
>
> pch_gbe_mac_load_mac_addr(&adapter->hw);
> - pch_gbe_mac_reset_hw(&adapter->hw);
>
> /* setup the private structure */
> ret = pch_gbe_sw_init(adapter);
> @@ -2610,9 +2613,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
> adapter->wake_up_evt = PCH_GBE_WL_INIT_SETTING;
> dev_info(&pdev->dev, "MAC address : %pM\n", netdev->dev_addr);
>
> - /* reset the hardware with the new settings */
> - pch_gbe_reset(adapter);
> -
> ret = register_netdev(netdev);
> if (ret)
> goto err_free_adapter;
>
--
Florian
next prev parent reply other threads:[~2018-06-27 17:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-27 0:06 [PATCH v7 00/11] net: pch_gbe: Fixes, conversion to phylib, enable for MIPS Paul Burton
2018-06-27 0:06 ` [PATCH v7 01/11] net: pch_gbe: Remove unused struct pch_gbe_adapter fields Paul Burton
2018-06-27 0:06 ` [PATCH v7 02/11] net: pch_gbe: Mask spare MAC addresses all at once Paul Burton
2018-06-27 0:06 ` [PATCH v7 03/11] net: pch_gbe: Probe PHY ID & initialize only once Paul Burton
2018-06-27 17:21 ` Andrew Lunn
2018-06-27 17:31 ` Paul Burton
2018-06-27 17:33 ` Andrew Lunn
2018-06-28 7:47 ` Andrew Lunn
2018-06-27 0:06 ` [PATCH v7 04/11] net: pch_gbe: Remove irq_sem Paul Burton
2018-06-27 0:06 ` [PATCH v7 05/11] net: pch_gbe: Move pch_gbe_watchdog lower in pch_gbe_main.c Paul Burton
2018-06-27 17:23 ` Andrew Lunn
2018-06-27 0:06 ` [PATCH v7 06/11] net: pch_gbe: Only enable MAC when PHY link is active Paul Burton
2018-06-27 17:30 ` Andrew Lunn
2018-06-27 17:54 ` Paul Burton
2018-06-28 7:36 ` Andrew Lunn
2018-06-27 17:54 ` Florian Fainelli [this message]
2018-06-27 18:15 ` Paul Burton
2018-06-27 0:06 ` [PATCH v7 07/11] net: pch_gbe: Remove AR8031 PHY hibernation disable Paul Burton
2018-06-27 17:30 ` Andrew Lunn
2018-06-27 0:06 ` [PATCH v7 08/11] net: pch_gbe: Clean up resets Paul Burton
2018-06-27 0:06 ` [PATCH v7 09/11] net: pch_gbe: Convert to mdiobus and phylib Paul Burton
2018-06-27 17:51 ` Andrew Lunn
2018-06-27 18:09 ` Paul Burton
2018-06-28 7:44 ` Andrew Lunn
2018-06-27 0:06 ` [PATCH v7 10/11] ptp: pch: Allow build on MIPS platforms Paul Burton
2018-06-27 17:53 ` Andrew Lunn
2018-06-27 0:06 ` [PATCH v7 11/11] net: pch_gbe: " Paul Burton
2018-06-27 17:54 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34bf7133-5f4d-ef61-2448-e1fcc1e3036a@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=paul.burton@mips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).