public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Quentin Schulz <quentin.schulz@bootlin.com>
Cc: davem@davemloft.net, f.fainelli@gmail.com,
	allan.nielsen@microchip.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, thomas.petazzoni@bootlin.com,
	alexandre.belloni@bootlin.com
Subject: Re: [PATCH net] net: phy: mscc: fix deadlock in vsc85xx_default_config
Date: Thu, 22 Nov 2018 20:28:37 +0100	[thread overview]
Message-ID: <20181122192837.GH10697@lunn.ch> (raw)
In-Reply-To: <20181122131232.32032-1-quentin.schulz@bootlin.com>

On Thu, Nov 22, 2018 at 02:12:32PM +0100, Quentin Schulz wrote:
> The vsc85xx_default_config function called in the vsc85xx_config_init
> function which is used by VSC8530, VSC8531, VSC8540 and VSC8541 PHYs
> mistakenly calls phy_read and phy_write in-between phy_select_page and
> phy_restore_page.
> 
> phy_select_page and phy_restore_page actually take and release the MDIO
> bus lock so __phy_write and __phy_read (which assume that you already
> have the MDIO bus lock unlike phy_write and phy_read) should be used for
> any call in between the two said functions.
> 
> Let's fix this deadlock.
> 
> Fixes: 6a0bfbbe20b0 ("net: phy: mscc: migrate to phy_select/restore_page functions")
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
> ---
>  drivers/net/phy/mscc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
> index 62269e578718..6856fe4d1a60 100644
> --- a/drivers/net/phy/mscc.c
> +++ b/drivers/net/phy/mscc.c
> @@ -814,10 +814,10 @@ static int vsc85xx_default_config(struct phy_device *phydev)
>  	if (rc < 0)
>  		goto out_unlock;
>  
> -	reg_val = phy_read(phydev, MSCC_PHY_RGMII_CNTL);
> +	reg_val = __phy_read(phydev, MSCC_PHY_RGMII_CNTL);
>  	reg_val &= ~(RGMII_RX_CLK_DELAY_MASK);
>  	reg_val |= (RGMII_RX_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS);
> -	phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val);
> +	__phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val);

Hi Quentin

You appear to be only accessing a single register, read/modify/write.
I think you can use phy_modify_paged(), which will take care of all
the locking for you.

    Andrew

  reply	other threads:[~2018-11-22 19:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 13:12 [PATCH net] net: phy: mscc: fix deadlock in vsc85xx_default_config Quentin Schulz
2018-11-22 19:28 ` Andrew Lunn [this message]
2018-11-23  8:18   ` Quentin Schulz

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=20181122192837.GH10697@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=quentin.schulz@bootlin.com \
    --cc=thomas.petazzoni@bootlin.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