mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: Florian Fainelli <florian.fainelli@broadcom.com>,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Russell King <linux@armlinux.org.uk>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jim Reinhart <jimr@tekvox.com>, James Autry <jautry@tekvox.com>,
	Matthew Maron <matthewm@tekvox.com>
Subject: Re: [PATCH] net: phy: broadcom: add support for BCM5221 phy
Date: Sat, 12 Aug 2023 19:27:56 +0200	[thread overview]
Message-ID: <4a67a6ae-f697-1353-1b0f-55b42e5dbdfa@benettiengineering.com> (raw)
In-Reply-To: <859ff6a9-3ba9-ea2e-7b85-01813c5df0dd@broadcom.com>

Hello Florian,

thanks for reviewing,

On 12/08/23 01:52, Florian Fainelli wrote:
> 
> 
> On 8/11/2023 2:53 PM, Giulio Benetti wrote:
>> This patch adds the BCM5221 PHY support by reusing
>> brcm_fet_config_intr() and brcm_fet_handle_interrupt() and
>> implementing config_init()/suspend()/resume().
>>
>> Sponsored by: Tekvox Inc.
>> Cc: Jim Reinhart <jimr@tekvox.com>
>> Cc: James Autry <jautry@tekvox.com>
>> Cc: Matthew Maron <matthewm@tekvox.com>
>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> 
> Looks good, few comments below.
> 
>> ---
>>   drivers/net/phy/broadcom.c | 144 +++++++++++++++++++++++++++++++++++++
>>   include/linux/brcmphy.h    |   8 +++
>>   2 files changed, 152 insertions(+)
>>
>> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
>> index 59cae0d808aa..99f6c0485f01 100644
>> --- a/drivers/net/phy/broadcom.c
>> +++ b/drivers/net/phy/broadcom.c
>> @@ -754,6 +754,84 @@ static int brcm_fet_config_init(struct phy_device 
>> *phydev)
>>       return err;
>>   }
>> +static int bcm5221_config_init(struct phy_device *phydev)
>> +{
> 
> Very similar to brcm_fet_config_init() except that you configure fewer 
> interrupt sources, do not have the LED mode programming and your MDI-X 
> programming is done via a 10BaseT specific register rather than the shadow.
> 
> Can you consider adding parameters to brcm_fet_config_init() such that 
> you can specify the 5221 specific settings such as the interrupt mask 
> for instance?

So if I've understood correctly I should drop bcm5221_config_init() and
use brcm_fet_config_init() by checking the struct phy_driver .phy_id to
be PHY_ID_BCM5221.

> This should help address the locking that Russell suggested.

But I don't understand how this can help to prevent the locking Russell
suggested, can you please elaborate more or point me and example?
As far as I've understood I should take care to lock sections to prevent
from interrupts to occur during shadow mode switching, is it correct?
So maybe you mean that if I do this in brcm_fet_config_init() it will be
fixed for the other phys using brcm_fet_config_init(), correct?

> [snip]
>> +static int bcm5221_suspend(struct phy_device *phydev)
>> +{
>> +    int reg, err, err2, brcmtest;
>> +
>> +    /* Enable shadow register access */
>> +    brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST);
>> +    if (brcmtest < 0)
>> +        return brcmtest;
>> +
>> +    reg = brcmtest | MII_BRCM_FET_BT_SRE;
>> +
>> +    err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg);
>> +    if (err < 0)
>> +        return err;
>> +
>> +    /* Force Low Power Mode with clock enabled */
>> +    err = phy_set_bits(phydev, MII_BRCM_FET_SHDW_AUXMODE4,
>> +               BCM5221_SHDW_AM4_EN_CLK_LPM |
>> +               BCM5221_SHDW_AM4_FORCE_LPM);
>> +
>> +    /* Disable shadow register access */
>> +    err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest);
>> +    if (!err)
>> +        err = err2;
>> +
>> +    return err;
>> +}
> 
> bcm5221_suspend() is essentially brcm_fet_suspend() minus the setting of 
> the BMCR.PDOWN bit, can you consider factoring brcm_fet_suspend() into a 
> helper that can decide whether to set the power down bit or not? Does 
> not brcm_fet_suspend() work as-is?

Sure, I will,

>> +
>> +static int bcm5221_resume(struct phy_device *phydev)
>> +{
> 
> This should really be calling bcm5221_config_init() here, if the PHY was 
> on a power island that is powered off during system suspend, 
> bcm5221_resume() would not be restoring the auto-power down that is set 
> during config_init(), probably not desired because that means you will 
> burn power when the cable is disconnected...

oh yes! You're right, I will then drop bcm5221_resume() in favor of 
bcm5221_config_init(), so brcm_fet_config_init() with phy_id == 
PHY_ID_BCM5221 checks.

Thanks again
Best regards
-- 
Giulio Benetti
CEO&CTO@Benetti Engineering sas

      reply	other threads:[~2023-08-12 17:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11 21:53 Giulio Benetti
2023-08-11 22:16 ` Andrew Lunn
2023-08-11 22:39   ` Florian Fainelli
2023-08-12 14:19     ` Andrew Lunn
2023-08-12 17:12   ` Giulio Benetti
2023-08-11 22:22 ` Russell King (Oracle)
2023-08-12 17:15   ` Giulio Benetti
2023-08-11 23:52 ` Florian Fainelli
2023-08-12 17:27   ` Giulio Benetti [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=4a67a6ae-f697-1353-1b0f-55b42e5dbdfa@benettiengineering.com \
    --to=giulio.benetti@benettiengineering.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=jautry@tekvox.com \
    --cc=jimr@tekvox.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=matthewm@tekvox.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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

all inboxes | Powered by JetHome®