From: Andrew Lunn <andrew@lunn.ch>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH] phy: realtek: use new helpers for paged register access
Date: Fri, 12 Jan 2018 22:01:07 +0100 [thread overview]
Message-ID: <20180112210107.GA7470@lunn.ch> (raw)
In-Reply-To: <ac76cb9b-f834-96a5-80f4-3c6225fd037f@gmail.com>
On Fri, Jan 12, 2018 at 09:30:08PM +0100, Heiner Kallweit wrote:
> Make use of the new helpers for paged register access.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/phy/realtek.c | 59 +++++++++++------------------------------------
> 1 file changed, 14 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index 7c1bf688d..887bad07a 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -41,37 +41,14 @@ MODULE_DESCRIPTION("Realtek PHY driver");
> MODULE_AUTHOR("Johnson Leung");
> MODULE_LICENSE("GPL");
>
> -static int rtl8211x_page_read(struct phy_device *phydev, u16 page, u16 address)
> +static int rtl821x_read_page(struct phy_device *phydev)
> {
> - int ret;
> -
> - ret = phy_write(phydev, RTL821x_PAGE_SELECT, page);
> - if (ret)
> - return ret;
> -
> - ret = phy_read(phydev, address);
> -
> - /* restore to default page 0 */
> - phy_write(phydev, RTL821x_PAGE_SELECT, 0x0);
> -
> - return ret;
> + return phy_read(phydev, RTL821x_PAGE_SELECT);
Hi Heiner
It think this is wrong. You need to use __phy_read(). phy_read() does
an mdiobus_read(), which takes the bus->mdio_lock. However,
int phy_save_page(struct phy_device *phydev)
{
mutex_lock(&phydev->mdio.bus->mdio_lock);
return __phy_read_page(phydev);
}
This also takes the same lock. So this should deadlock.
Try turning on CONFIG_PROVE_LOCKING, it will detect problems like
this.
Andrew
next prev parent reply other threads:[~2018-01-12 21:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 20:30 [PATCH] phy: realtek: use new helpers for paged register access Heiner Kallweit
2018-01-12 21:01 ` Andrew Lunn [this message]
2018-01-12 22:13 ` Heiner Kallweit
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=20180112210107.GA7470@lunn.ch \
--to=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@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).