public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Allan W. Nielsen" <allan.nielsen@microsemi•com>
To: Florian Fainelli <f.fainelli@gmail•com>
Cc: Andrew Lunn <andrew@lunn•ch>, <netdev@vger•kernel.org>,
	<davem@davemloft•net>, <bcm-kernel-feedback-list@broadcom•com>,
	<raju.lakkaraju@microsemi•com>,
	<vivien.didelot@savoirfairelinux•com>
Subject: Re: [PATCH net-next 4/5] net: phy: bcm7xxx: Add support for downshift/Wirespeed
Date: Wed, 23 Nov 2016 12:45:12 +0100	[thread overview]
Message-ID: <20161123114512.GB25778@microsemi.com> (raw)
In-Reply-To: <1902f0f0-46e5-d3b3-90c1-10867f4fb826@gmail.com>

Hi,

On 22/11/16 12:07, Florian Fainelli wrote:
> On 11/22/2016 12:02 PM, Andrew Lunn wrote:
> >> +static int bcm7xxx_28nm_set_tunable(struct phy_device *phydev,
> >> +                                struct ethtool_tunable *tuna,
> >> +                                const void *data)
> >> +{
> >> +    u8 count = *(u8 *)data;
> >> +    int ret;
> >> +
> >> +    switch (tuna->id) {
> >> +    case ETHTOOL_PHY_DOWNSHIFT:
> >> +            ret = bcm_phy_downshift_set(phydev, count);
> >> +            break;
> >> +    default:
> >> +            return -EOPNOTSUPP;
> >> +    }
> >> +
> >> +    if (ret)
> >> +            return ret;
> >> +
> >> +    /* Disable EEE advertisment since this prevents the PHY
> >> +     * from successfully linking up, trigger auto-negotiation restart
> >> +     * to let the MAC decide what to do.
> >> +     */
> >> +    ret = bcm_phy_set_eee(phydev, count == DOWNSHIFT_DEV_DISABLE);
> >> +    if (ret)
> >> +            return ret;
> >> +
> >> +    return genphy_restart_aneg(phydev);
> >> +}
> >
> > Hi Florian
> >
> > Is the locking O.K. here? The core code does not take the phy lock.
> > But i think your shadow register accesses at least need to be
> > protected by the lock?
> 
> There should be some kind of protection, but I was expecting it to be
> done at the caller level, so that when {get,set}_tunable run, they are
> serialized with respect to each other, clearly, by looking at the code,
> this is not the case.
> 
> >
> > Maybe we should think about this locking a bit. It is normal for the
> > lock to be held when using ops in the phy driver structure. The
> > exception is suspend/resume. Maybe we should also take the lock before
> > calling the phydev->drv->get_tunable() and phydev->drv->set_tunable()?
> 
> Yes, that certainly seems like a good approach to me, let me cook a
> patch doing that.

Just for my understanding (such that I will not make the same mistake again)...

Why is it that phy functions such as get_wol needs to take the phy_lock and
others like get_tunable does not.

I do understand the arguments on why the lock should be held by the caller of
get_tunable, but I do not understand why the same argument does not apply for
get_wol.

/Allan

  parent reply	other threads:[~2016-11-23 11:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22 19:40 [PATCH net-next 0/5] net: phy: broadcom: Wirespeed/downshift support Florian Fainelli
2016-11-22 19:40 ` [PATCH net-next 1/5] net: phy: broadcom: Move bcm54xx_auxctl_{read,write} to common library Florian Fainelli
2016-11-22 19:40 ` [PATCH net-next 2/5] net: phy: broadcom: Add support code for downshift/Wirespeed Florian Fainelli
2016-11-22 19:40 ` [PATCH net-next 3/5] net: phy: broadcom: Allow enabling or disabling of EEE Florian Fainelli
2016-11-22 19:40 ` [PATCH net-next 4/5] net: phy: bcm7xxx: Add support for downshift/Wirespeed Florian Fainelli
2016-11-22 20:02   ` Andrew Lunn
2016-11-22 20:07     ` Florian Fainelli
2016-11-22 20:57       ` Andrew Lunn
2016-11-22 21:01         ` Florian Fainelli
2016-11-23 11:45       ` Allan W. Nielsen [this message]
2016-11-23 14:46         ` Andrew Lunn
2016-11-23 18:16           ` Florian Fainelli
2016-11-22 19:40 ` [PATCH net-next 5/5] net: dsa: bcm_sf2: Ensure we re-negotiate EEE during after link change Florian Fainelli
2016-11-24 20:54 ` [PATCH net-next 0/5] net: phy: broadcom: Wirespeed/downshift support 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=20161123114512.GB25778@microsemi.com \
    --to=allan.nielsen@microsemi$(echo .)com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=bcm-kernel-feedback-list@broadcom$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=raju.lakkaraju@microsemi$(echo .)com \
    --cc=vivien.didelot@savoirfairelinux$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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