From: Andrew Lunn <andrew@lunn.ch>
To: "Kamil Horák (2N)" <kamilh@axis.com>
Cc: florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, hkallweit1@gmail.com,
linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v11 4/4] net: phy: bcm-phy-lib: Implement BroadR-Reach link modes
Date: Fri, 12 Jul 2024 17:45:28 +0200 [thread overview]
Message-ID: <ca6a5b50-6b34-4455-bd22-cfe152df4728@lunn.ch> (raw)
In-Reply-To: <bc1ce748-7620-45b0-b1ad-17d77f6d6331@axis.com>
On Fri, Jul 12, 2024 at 05:10:48PM +0200, Kamil Horák (2N) wrote:
>
> On 7/11/24 21:01, Andrew Lunn wrote:
> > > +static int bcm5481x_get_brrmode(struct phy_device *phydev, u8 *data)
> > > {
> > > - int err, reg;
> > > + int reg;
> > > - /* Disable BroadR-Reach function. */
> > > reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
> > > - reg &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
> > > - err = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
> > > - reg);
> > > - if (err < 0)
> > bcm_phy_read_exp() could fail. So you should keep the test. Also, the
> > caller of this function does look at the return value.
> True - it can at least return -EOPNOTSUPP from __mdiobus_read()
> Trying to handle it.
>
> This neglect can be found elsewhere such as bcm-phy-ptp.c and eg.
> bcm54xx_config_init()
>
> function. I feel that at least the latest one should be fixed but it would
> be unrelated to bcm54811,
>
> so leaving it as-is for now.
In general PHY drivers are a bit hit and miss with checking error
codes. If the first access works, it is very likely all further
accesses will work. If they fail, the hardware is probably dead and
there is little you can do about it other than report the error. So i
would say probe, suspend and resume should always check the error
codes, since that is where clock problems are likely to be. But after
that it is good practice to check error codes, but a driver is
unlikely to be NACKed because of missing checks.
> Done. Now we rely on the DT setting and never read the PHY state. It is
> vulnerable to external manipulation
>
> of MDIO registers and PHY reset as both hardware and software (bit 15 of
> register 0 in both
>
> IEEE and LRE modes) reset switch to IEEE mode.
I don't think this is any worse. With the old code you would of
silently swapped to standard IEEE modes, which cannot work. Now you
continue programming BRR registers, which just get ignored because it
is no longer in that mode.
But if somebody performed some sort of external manipulation, all bets
are off anyway.
Andrew
prev parent reply other threads:[~2024-07-12 15:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 10:27 [PATCH v11 0/4] net: phy: bcm5481x: add support for BroadR-Reach mode Kamil Horák (2N)
2024-07-08 10:27 ` [PATCH v11 1/4] net: phy: bcm54811: New link mode for BroadR-Reach Kamil Horák (2N)
2024-07-11 16:56 ` Jakub Kicinski
2024-07-11 18:28 ` Andrew Lunn
2024-07-29 8:31 ` Russell King (Oracle)
2024-07-08 10:27 ` [PATCH v11 2/4] net: phy: bcm54811: Add LRE registers definitions Kamil Horák (2N)
2024-07-08 10:27 ` [PATCH v11 3/4] dt-bindings: ethernet-phy: add optional brr-mode flag Kamil Horák (2N)
2024-07-08 14:44 ` Rob Herring (Arm)
2024-07-08 10:27 ` [PATCH v11 4/4] net: phy: bcm-phy-lib: Implement BroadR-Reach link modes Kamil Horák (2N)
2024-07-11 19:01 ` Andrew Lunn
2024-07-12 15:10 ` Kamil Horák (2N)
2024-07-12 15:45 ` Andrew Lunn [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=ca6a5b50-6b34-4455-bd22-cfe152df4728@lunn.ch \
--to=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kamilh@axis.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@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
all inboxes | Powered by JetHome®