mbox series

[v3,0/3] net: dsa: mv88e6xxx: serdes link without phy

Message ID 20201020034558.19438-1-chris.packham@alliedtelesis.co.nz
Headers show
Series net: dsa: mv88e6xxx: serdes link without phy | expand

Message

Chris Packham Oct. 20, 2020, 3:45 a.m. UTC
This small series gets my hardware into a working state. The key points are to
make sure we don't force the link and that we ask the MAC for the link status.
I also have updated my dts to say `phy-mode = "1000base-x";` and `managed =
"in-band-status";`

I've included patch #3 in this series but I don't have anything to test it on.
It's just a guess based on the datasheets. I'd suggest applying patch 1 & 2
and leaving 3 for the mailing list archives.

Chris Packham (3):
  net: dsa: mv88e6xxx: Don't force link when using in-band-status
  net: dsa: mv88e6xxx: Support serdes ports on MV88E6097/6095/6185
  net: dsa: mv88e6xxx: Support serdes ports on MV88E6123/6131

 drivers/net/dsa/mv88e6xxx/chip.c   |  26 ++++++-
 drivers/net/dsa/mv88e6xxx/serdes.c | 106 +++++++++++++++++++++++++++++
 drivers/net/dsa/mv88e6xxx/serdes.h |   9 +++
 3 files changed, 139 insertions(+), 2 deletions(-)

Comments

Russell King (Oracle) Oct. 20, 2020, 10:18 a.m. UTC | #1
On Tue, Oct 20, 2020 at 04:45:58PM +1300, Chris Packham wrote:
> +void mv88e6123_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)
> +{
> +	u16 *p = _p;
> +	u16 reg;
> +	int i;
> +
> +	if (mv88e6xxx_serdes_get_lane(chip, port) == 0)
> +		return;
> +
> +	for (i = 0; i < 26; i++) {
> +		mv88e6xxx_phy_read(chip, port, i, &reg);

Shouldn't this deal with a failed read in some way, rather than just
assigning the last or possibly uninitialised value to p[i] ?
Chris Packham Oct. 20, 2020, 9:24 p.m. UTC | #2
On 20/10/20 11:18 pm, Russell King - ARM Linux admin wrote:
> On Tue, Oct 20, 2020 at 04:45:58PM +1300, Chris Packham wrote:

>> +void mv88e6123_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)

>> +{

>> +	u16 *p = _p;

>> +	u16 reg;

>> +	int i;

>> +

>> +	if (mv88e6xxx_serdes_get_lane(chip, port) == 0)

>> +		return;

>> +

>> +	for (i = 0; i < 26; i++) {

>> +		mv88e6xxx_phy_read(chip, port, i, &reg);

> Shouldn't this deal with a failed read in some way, rather than just

> assigning the last or possibly uninitialised value to p[i] ?


mv88e6390_serdes_get_regs() and mv88e6352_serdes_get_regs() also ignore 
the error. The generic mv88e6xxx_get_regs() memsets p[] to 0xff so if 
the serdes_get_regs functions just left it alone we'd return 0xffff 
which is probably better than repeating the last value although it's 
still ambiguous because 0xffff is a valid value for plenty of these 
registers.

Since it looks like I need to come up with an alternative to patch #1 
I'll concentrate on that but making the serdes_get_regs() a little more 
error tolerant is a cleanup I can easily tack on onto this series.
Russell King (Oracle) Oct. 20, 2020, 9:34 p.m. UTC | #3
On Tue, Oct 20, 2020 at 09:24:04PM +0000, Chris Packham wrote:
> 
> On 20/10/20 11:18 pm, Russell King - ARM Linux admin wrote:
> > On Tue, Oct 20, 2020 at 04:45:58PM +1300, Chris Packham wrote:
> >> +void mv88e6123_serdes_get_regs(struct mv88e6xxx_chip *chip, int port, void *_p)
> >> +{
> >> +	u16 *p = _p;
> >> +	u16 reg;
> >> +	int i;
> >> +
> >> +	if (mv88e6xxx_serdes_get_lane(chip, port) == 0)
> >> +		return;
> >> +
> >> +	for (i = 0; i < 26; i++) {
> >> +		mv88e6xxx_phy_read(chip, port, i, &reg);
> > Shouldn't this deal with a failed read in some way, rather than just
> > assigning the last or possibly uninitialised value to p[i] ?
> 
> mv88e6390_serdes_get_regs() and mv88e6352_serdes_get_regs() also ignore 
> the error. The generic mv88e6xxx_get_regs() memsets p[] to 0xff so if 
> the serdes_get_regs functions just left it alone we'd return 0xffff 
> which is probably better than repeating the last value although it's 
> still ambiguous because 0xffff is a valid value for plenty of these 
> registers.
> 
> Since it looks like I need to come up with an alternative to patch #1 
> I'll concentrate on that but making the serdes_get_regs() a little more 
> error tolerant is a cleanup I can easily tack on onto this series.

Yep, it looks like they all suffer the same problem. Interestingly,
mv88e6xxx_get_regs() does handle the error by avoiding writing the
register entry (so it gets left as 0xffff.)

Incidentally, that's also the value you'll get when reading from a
PHY that doesn't respond, since the MDIO data line is pulled high
when undriven.