All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <robert.hancock@calian.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"radhey.shyam.pandey@xilinx.com" <radhey.shyam.pandey@xilinx.com>
Subject: Re: [PATCH net 1/7] net: axienet: Reset core before accessing MAC and wait for core ready
Date: Wed, 12 Jan 2022 00:30:33 +0000	[thread overview]
Message-ID: <b66ac3d0a3c544ca082eb5c8d25c72dc1ce8f451.camel@calian.com> (raw)
In-Reply-To: <20220111211358.2699350-2-robert.hancock@calian.com>

On Tue, 2022-01-11 at 15:13 -0600, Robert Hancock wrote:
> In some cases where the Xilinx Ethernet core was used in 1000Base-X or
> SGMII modes, which use the internal PCS/PMA PHY, and the MGT
> transceiver clock source for the PCS was not running at the time the
> FPGA logic was loaded, the core would come up in a state where the
> PCS could not be found on the MDIO bus. To fix this, the Ethernet core
> (including the PCS) should be reset after enabling the clocks, prior to
> attempting to access the PCS using of_mdio_find_device.
> 
> Also, when resetting the device, wait for the PhyRstCmplt bit to be set
> in the interrupt status register before continuing initialization, to
> ensure that the core is actually ready. The MgtRdy bit could also be
> waited for, but unfortunately when using 7-series devices, the bit does
> not appear to work as documented (it seems to behave as some sort of
> link state indication and not just an indication the transceiver is
> ready) so it can't really be relied on.
> 
> Fixes: 3e08fd4a8298 (net: axienet: Properly handle PCS/PMA PHY for 1000BaseX
> mode)

Patchwork points out that this commit doesn't exist in mainline, it's from the
5.10 stable tree. The corresponding mainline commit is
1a02556086fc0eb16e0a0d09043e9ffb0e31c7db.

> Signed-off-by: Robert Hancock <robert.hancock@calian.com>
> ---
>  .../net/ethernet/xilinx/xilinx_axienet_main.c | 34 +++++++++++++------
>  1 file changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 90144ac7aee8..f4ae035bed35 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -496,7 +496,8 @@ static void axienet_setoptions(struct net_device *ndev,
> u32 options)
>  
>  static int __axienet_device_reset(struct axienet_local *lp)
>  {
> -	u32 timeout;
> +	u32 value;
> +	int ret;
>  
>  	/* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset
>  	 * process of Axi DMA takes a while to complete as all pending
> @@ -506,15 +507,23 @@ static int __axienet_device_reset(struct axienet_local
> *lp)
>  	 * they both reset the entire DMA core, so only one needs to be used.
>  	 */
>  	axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, XAXIDMA_CR_RESET_MASK);
> -	timeout = DELAY_OF_ONE_MILLISEC;
> -	while (axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET) &
> -				XAXIDMA_CR_RESET_MASK) {
> -		udelay(1);
> -		if (--timeout == 0) {
> -			netdev_err(lp->ndev, "%s: DMA reset timeout!\n",
> -				   __func__);
> -			return -ETIMEDOUT;
> -		}
> +	ret = read_poll_timeout(axienet_dma_in32, value,
> +				!(value & XAXIDMA_CR_RESET_MASK),
> +				DELAY_OF_ONE_MILLISEC, 50000, false, lp,
> +				XAXIDMA_TX_CR_OFFSET);
> +	if (ret) {
> +		dev_err(lp->dev, "%s: DMA reset timeout!\n", __func__);
> +		return ret;
> +	}
> +
> +	/* Wait for PhyRstCmplt bit to be set, indicating the PHY reset has
> finished */
> +	ret = read_poll_timeout(axienet_ior, value,
> +				value & XAE_INT_PHYRSTCMPLT_MASK,
> +				DELAY_OF_ONE_MILLISEC, 50000, false, lp,
> +				XAE_IS_OFFSET);
> +	if (ret) {
> +		dev_err(lp->dev, "%s: timeout waiting for PhyRstCmplt\n",
> __func__);
> +		return ret;
>  	}
>  
>  	return 0;
> @@ -2046,6 +2055,11 @@ static int axienet_probe(struct platform_device *pdev)
>  	lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
>  	lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
>  
> +	/* Reset core now that clocks are enabled, prior to accessing MDIO */
> +	ret = __axienet_device_reset(lp);
> +	if (ret)
> +		goto cleanup_clk;
> +
>  	lp->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
>  	if (lp->phy_node) {
>  		ret = axienet_mdio_setup(lp);

  reply	other threads:[~2022-01-12  0:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 21:13 [PATCH net 0/7] Xilinx axienet fixes Robert Hancock
2022-01-11 21:13 ` [PATCH net 1/7] net: axienet: Reset core before accessing MAC and wait for core ready Robert Hancock
2022-01-12  0:30   ` Robert Hancock [this message]
2022-01-12  3:24     ` Jakub Kicinski
2022-01-12 16:46       ` Robert Hancock
2022-01-11 21:13 ` [PATCH net 2/7] net: axienet: add missing memory barriers Robert Hancock
2022-01-11 21:13 ` [PATCH net 3/7] net: axienet: limit minimum TX ring size Robert Hancock
2022-01-11 21:13 ` [PATCH net 4/7] net: axienet: Fix TX ring slot available check Robert Hancock
2022-01-11 21:13 ` [PATCH net 5/7] net: axienet: fix number of TX ring slots for " Robert Hancock
2022-01-11 21:13 ` [PATCH net 6/7] net: axienet: fix for TX busy handling Robert Hancock
2022-01-12  3:49   ` Jakub Kicinski
2022-01-12 16:45     ` Robert Hancock
2022-01-12 17:01       ` Jakub Kicinski
2022-01-12 17:35         ` Robert Hancock
2022-01-11 21:13 ` [PATCH net 7/7] net: axienet: increase default TX ring size to 128 Robert Hancock

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=b66ac3d0a3c544ca082eb5c8d25c72dc1ce8f451.camel@calian.com \
    --to=robert.hancock@calian.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=radhey.shyam.pandey@xilinx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.