From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Andrew Lunn <andrew@lunn.ch>, Oleksij Rempel <o.rempel@pengutronix.de>
Cc: "Russell King (Oracle)" <linux@armlinux.org.uk>,
Wei Fang <wei.fang@nxp.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, Shenwei Wang <shenwei.wang@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>,
NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [PATCH net-next v6 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes
Date: Mon, 26 Feb 2024 09:50:02 -0800 [thread overview]
Message-ID: <e679f467-d4cd-4a1e-9bfc-92e2c9bf35d4@broadcom.com> (raw)
In-Reply-To: <c6b0716d-f093-4aba-8453-c89a562ab581@lunn.ch>
[-- Attachment #1: Type: text/plain, Size: 5396 bytes --]
On 2/26/24 08:44, Andrew Lunn wrote:
> On Sat, Feb 24, 2024 at 06:57:12PM +0100, Oleksij Rempel wrote:
>> On Fri, Feb 23, 2024 at 09:53:06AM -0800, Florian Fainelli wrote:
>>> On 2/23/24 05:26, Russell King (Oracle) wrote:
>>>> On Fri, Feb 23, 2024 at 02:17:59PM +0100, Andrew Lunn wrote:
>>>>> On Fri, Feb 23, 2024 at 10:38:20AM +0000, Russell King (Oracle) wrote:
>>>>>> On Fri, Feb 23, 2024 at 10:44:22AM +0100, Oleksij Rempel wrote:
>>>>>>> +static void phy_ethtool_set_eee_noneg(struct phy_device *phydev,
>>>>>>> + struct ethtool_keee *data)
>>>>>>> +{
>>>>>>> + if (phydev->eee_cfg.tx_lpi_enabled !=
>>>>>>> + data->tx_lpi_enabled) {
>>>>>>> + eee_to_eeecfg(data, &phydev->eee_cfg);
>>>>>>> + phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg);
>>>>>>> + if (phydev->link)
>>>>>>> + phy_link_up(phydev);
>>>>>>
>>>>>> I'm not convinced this is a good idea. Hasn't phylib previously had
>>>>>> the guarantee that the link will go down between two link-up events?
>>>>>> So calling phy_link_up() may result in either the MAC driver ignoring
>>>>>> it, or modifying registers that are only supposed to be modified while
>>>>>> the MAC side is down.
>>>>>
>>>>> When auto-neg is used, we expect the link to go down and come back up
>>>>> again.
>>>>>
>>>>> Here we are dealing with the case that autoneg is not used. The MAC
>>>>> needs informing somehow. If we want to preserve the down/up, we could
>>>>> call phy_link_down() and then phy_link_up() back to back.
>>>>
>>>> Would it be better to have a separate callback for EEE state (as I
>>>> mentioned in another comment on this series?) That would be better
>>>> for future SmartEEE support.
>>>
>>> That sounds like a good approach to me. The additional callback also helps
>>> figure out which drivers use the API and it should be simpler to audit for
>>> changes in the future, too.
>>
>> At this point I need help to understand how to proceed.
>> What exactly do you have in mind? Some description like following would
>> be helpful:
>> Add callback with name phy_link_set_eee(), which should be executed in
>> function bla/blup..
>
> When i first did this patchset, SmartEEE was out of scope. One
> question we should decide is, is it still out of scope, and we should
> first get 'dumb' EEE fixed everywhere, and than come back and look at
> SmartEEE? Or do we want to consider SmartEEE now?
I believe the considerations about SmartEEE (which BTW requires a less
QCA-centric name to be found) are somewhat orthogonal to the concerns
from Russell here.
The concern is that MAC drivers are not expecting to see the following
sequence of calls:
->adjust_link(link == 0)
->adjust_link(link == 1)
->adjust_link(link == 1)
The latter is somewhat unusual and could lead to some spectacular and
unknown bugs to be discovered. This is even more surprising for drivers
in that the TX LPI timer is typically programmed as part of the
.set_eee() callback.
>
> The idea of this patchset was to push as much as possible down into
> phylib. The MAC needs to say it supports EEE. I left handling of the
> tx_lpi_timer to the MAC driver, because the PHY has nothing it can do
> with that value. phylib then just needs to tell the MAC to enable or
> disable EEE when autoneg has completed. That i made part of the adjust
> link callback because that is the only callback we have, and most
> developers seem to understand it, and the locking around it. However,
> it does get messy when EEE can change without an auto-neg, as pointed
> out here.
>
> If we are leaving SmartEEE out of scope for the moment, i would say
> just doing a down/up is sufficient, lets get this merged and all
> 'dumb' EEE fixed.
>
> If we want feature creep and to think about SmartEEE then we need a
> few changes in the overall design.
I am fine with tackling Smart EEE later on, as a matter of fact, I don't
believe many, if any changes at all should be required to your patch
series here. We would need to find a less QCA-centric name since
SmartEEE and AutoGrEEEn are both trade marks, though QCA definitively
did a better job here at claiming a name people could understand.
>
> We need to make eee_get and eee_set transparent to the MAC driver,
> since the PHY could be doing it all. So phylib needs to track
> tx_lpi_timer. If the MAC driver indicates it can do 'dumb' EEE we
> probably want to use that in preference to SmartEEE, since i guess the
> MAC can also save a little power in LPI mode. So the adjust link
> callback needs to say: Enable MAC EEE with this value of tx_lpi_timer,
> or turn off MAC EEE. When using SmartEEE it will never actually do
> either.
Agreed.
>
> The current phylib model is that adjust_link is the only callback, and
> the MAC driver peeks into phydev to find what it needs. I would
> probably stick to that model, and not add MAC callbacks. phylink is
> slightly different, mac_link_up() passes everything the MAC needs to
> know as parameters, so one of my patches adds an extra parameter to
> indicate if EEE should be enabled or disabled. That would need
> extending with the tx_lpi_timer value.
This is the source of the concern, we don't know which MAC drivers we
might end-up breaking by calling adjust_link(link == 1) twice in a row,
hopefully none, because they should be well written to only update the
parameters that need updating, but who knows?
--
Florian
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]
next prev parent reply other threads:[~2024-02-26 17:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 9:44 [PATCH net-next v6 0/8] net: ethernet: Rework EEE Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 1/8] net: add helpers for EEE configuration Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 3/8] net: phy: Add helper to set EEE Clock stop enable bit Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 4/8] net: phy: Keep track of EEE configuration Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Oleksij Rempel
2024-02-23 10:38 ` Russell King (Oracle)
2024-02-23 12:49 ` Oleksij Rempel
2024-02-23 13:17 ` Andrew Lunn
2024-02-23 13:26 ` Russell King (Oracle)
2024-02-23 17:53 ` Florian Fainelli
2024-02-24 17:57 ` Oleksij Rempel
2024-02-26 16:44 ` Andrew Lunn
2024-02-26 17:50 ` Florian Fainelli [this message]
2024-02-26 17:53 ` Russell King (Oracle)
2024-02-26 18:59 ` Andrew Lunn
2024-02-27 5:35 ` Oleksij Rempel
2024-02-27 16:12 ` Andrew Lunn
2024-02-23 9:44 ` [PATCH net-next v6 6/8] net: phy: Add phy_support_eee() indicating MAC support EEE Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Oleksij Rempel
2024-02-23 9:44 ` [PATCH net-next v6 8/8] net: fec: Fixup EEE Oleksij Rempel
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=e679f467-d4cd-4a1e-9bfc-92e2c9bf35d4@broadcom.com \
--to=florian.fainelli@broadcom.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=shenwei.wang@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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;
as well as URLs for NNTP newsgroup(s).