netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
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 23:13:26 +0100	[thread overview]
Message-ID: <8c455cf6-9556-63bb-7f2d-76f2c4027d73@gmail.com> (raw)
In-Reply-To: <20180112210107.GA7470@lunn.ch>

Am 12.01.2018 um 22:01 schrieb Andrew Lunn:
> 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,
> 
Uh, you are of course right.

> 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.
> 
Thanks for the hint. I have this option set, however my test system
doesn't use the irq-related callbacks. So it wasn't able to report
the issue. My fault.

> 	Andrew
> 

      reply	other threads:[~2018-01-12 22:13 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
2018-01-12 22:13   ` Heiner Kallweit [this message]

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=8c455cf6-9556-63bb-7f2d-76f2c4027d73@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --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).