netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	Allan Nielsen <Allan.Nielsen@microsemi.com>
Subject: Re: Microsemi VSC 8531/41 PHY Driver
Date: Tue, 26 Jul 2016 14:43:47 +0200	[thread overview]
Message-ID: <20160726124347.GD11538@lunn.ch> (raw)
In-Reply-To: <646450A91FAED74E85C6E9C4D6E936A145329E97@avsrvexchmbx1.microsemi.net>

> +/* RGMII Rx Clock delay value change with board lay-out */
> +static u8 rgmii_rx_clk_delay = RGMII_RX_CLK_DELAY_1_1_NS;

Doesn't this stop you from having a board with two PHYs with different
layouts? You should be getting this value from the device tree.

> +	phydev->supported = (SUPPORTED_1000baseT_Full |
> +			     SUPPORTED_1000baseT_Half |
> +			     SUPPORTED_100baseT_Full  |
> +			     SUPPORTED_100baseT_Half  |
> +			     SUPPORTED_10baseT_Full   |
> +			     SUPPORTED_10baseT_Half   |
> +			     SUPPORTED_Autoneg        |
> +			     SUPPORTED_Pause          |
> +			     SUPPORTED_Asym_Pause     |
> +			     SUPPORTED_TP);
> +
> +	phydev->speed = SPEED_1000;
> +	phydev->duplex = DUPLEX_FULL;
> +	phydev->pause = 0;
> +	phydev->asym_pause = 0;
> +	phydev->interface = PHY_INTERFACE_MODE_RGMII;
> +	phydev->mdix = ETH_TP_MDI_AUTO;

Why are you setting all these? This is not normal, if you look at
other drivers.

> +
> +	mutex_lock(&phydev->lock);

What are you locking against?

> +	rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED_2);
> +	if (rc != 0) {
> +		rc = -EINVAL;

Why do you overwrite the error code vsc85xx_phy_page_set gives you?

> +		goto out_unlock;
> +	}
> +	reg_val = phy_read(phydev, MSCC_PHY_RGMII_CNTL);
> +	reg_val &= ~(RGMII_RX_CLK_DELAY_MASK);
> +	reg_val |= (rgmii_rx_clk_delay << RGMII_RX_CLK_DELAY_POS);
> +	phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val);
> +	rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD);
> +	if (rc != 0)
> +		rc = -EINVAL;

Same here.

> +
> +out_unlock:
> +	mutex_unlock(&phydev->lock);
> +
> +	return rc;
> +}
> +
> +static int vsc85xx_config_init(struct phy_device *phydev)
> +{
> +	int rc = 0;

No need to initialise rc.

> +	rc = vsc85xx_default_config(phydev);

  	if (rc)
    		return rc;

> +	rc = genphy_config_init(phydev);
> +
> +	return rc;

Or just 
	return genphy_config_init(phydev);

> +}
> +
> +static int vsc85xx_ack_interrupt(struct phy_device *phydev)
> +{
> +	int rc = 0;
> +
> +	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
> +		rc = phy_read(phydev, MII_VSC85XX_INT_STATUS);
> +
> +	return (rc < 0) ? rc : 0;
> +}
> +
> +static int vsc85xx_config_intr(struct phy_device *phydev)
> +{
> +	int rc;
> +
> +	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
> +		rc = phy_write(phydev, MII_VSC85XX_INT_MASK,
> +			       MII_VSC85XX_INT_MASK_MASK);
> +	} else {
> +		rc = phy_read(phydev, MII_VSC85XX_INT_STATUS);
> +		if (rc < 0)
> +			return rc;

And the purpose of this read is? I assume it clears an outstanding
interrupt? If so, shouldn't you do it after disabling interrupts, not
before? Otherwise you have a race condition.

> +		rc = phy_write(phydev, MII_VSC85XX_INT_MASK, 0);
> +	}
> +
> +	return rc;

  Andrew

  reply	other threads:[~2016-07-26 12:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26  9:49 Microsemi VSC 8531/41 PHY Driver Raju Lakkaraju
2016-07-26 11:55 ` Andrew Lunn
2016-07-26 12:20   ` Raju Lakkaraju
2016-07-26 12:43     ` Andrew Lunn [this message]
2016-07-28  6:44       ` Raju Lakkaraju
2016-07-28 17:35         ` Florian Fainelli
2016-08-04  9:31           ` Nagaraju Lakkaraju
2016-07-29  8:04         ` Andrew Lunn
2016-07-29  8:17         ` Andrew Lunn
2016-08-04  9:17           ` Nagaraju Lakkaraju
2016-08-05 12:24           ` Nagaraju Lakkaraju
2016-08-16 19:41             ` Andrew Lunn
2016-08-16 19:48             ` Andrew Lunn
2016-09-08  8:39               ` [PATCH net-next 1/1] net: phy: Fixed checkpatch errors for Microsemi PHYs Raju Lakkaraju
2016-09-10  1:16                 ` David Miller

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=20160726124347.GD11538@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Allan.Nielsen@microsemi.com \
    --cc=Raju.Lakkaraju@microsemi.com \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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).