lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 11 Aug 2023 16:52:35 -0700
From:   Florian Fainelli <florian.fainelli@...adcom.com>
To:     Giulio Benetti <giulio.benetti@...ettiengineering.com>,
        Broadcom internal kernel review list 
        <bcm-kernel-feedback-list@...adcom.com>,
        Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Cc:     Florian Fainelli <florian.fainelli@...adcom.com>,
        Russell King <linux@...linux.org.uk>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, Jim Reinhart <jimr@...vox.com>,
        James Autry <jautry@...vox.com>,
        Matthew Maron <matthewm@...vox.com>
Subject: Re: [PATCH] net: phy: broadcom: add support for BCM5221 phy



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@...vox.com>
> Cc: James Autry <jautry@...vox.com>
> Cc: Matthew Maron <matthewm@...vox.com>
> Signed-off-by: Giulio Benetti <giulio.benetti@...ettiengineering.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?

This should help address the locking that Russell suggested.

[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?

> +
> +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...
-- 
Florian

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4221 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ