netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PROBLEM: smsc95xx loses config on link down/up
@ 2019-11-28  7:19 Sam Lewis
  2019-12-02 13:46 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Lewis @ 2019-11-28  7:19 UTC (permalink / raw)
  To: steve.glendinning, UNGLinuxDriver; +Cc: netdev

I'm using a LAN9514 chip in my embedded Linux device and have noticed
that changing Ethernet configuration (with ethtool for example) does
not persist after putting the link up.

I have tested this on kernel versions 4.14.0 and 5.0.0-36. As far as I
can tell the driver hasn't had any related fixes since 5.0.0, so I
don't think the behavior has changed in more recent kernel versions.

To demonstrate, what I mean, if I:

1) Take the link down (with `ip link set eth0 down`)
2) Turn auto-negotiation off (with `ethtool -s eth0 autoneg off`)
3) Take the link up (with `ip link set eth0 up`)

Then auto-negotiation is turned back on after the Ethernet interface
is brought back up. This seems to be true for any of the ethtool
configuration settings, like speed and duplex as well.

This is frustrating for a few reasons:

- I can't set the Ethernet configuration before I put the link up
- I can't use systemd .link files for managing link properties as they
seem to set the properties of the link before it's up

I've hacked through the driver code (without really knowing what I'm
doing, just adding various print statements) and I think this happens
because setting a link up causes the `smsc95xx_reset` function to be
called which seems to clear all configuration through:

1) Doing a PHY reset (with `smsc95xx_write_reg(dev, PM_CTRL, PM_CTL_PHY_RST_)`)
2) Doing (another?) PHY reset (with `smsc95xx_mdio_write(dev->net,
dev->mii.phy_id, MII_BMCR, BMCR_RESET)`)

I tested this by looking at the configuration through calling
`mii_ethtool_gset` before and after those two resets. After the
resets, it appears the configuration is cleared.

I'm using the LAN9514 without an attached EEPROM, so understand that
any settings set will not persist through a power cycle, but it would
still be nice if they persisted through setting the interface down and
then up. This seems to be the behavior on other Ethernet devices that
I've tried (even ones without NV storage), so maybe this is a bug with
the LAN95xx driver implementation?

It's very possible that I'm doing something wrong though, I'm happy to
hear if there's some other way to achieve what I'm trying to do.

If this is a real bug I'd be happy to take a look into trying to fix
it. Would it be acceptable to restore any configuration read from a
`mii_ethtool_gset` after the `smsc95xx_reset` is run?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-03 13:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  7:19 PROBLEM: smsc95xx loses config on link down/up Sam Lewis
2019-12-02 13:46 ` Andrew Lunn
2019-12-03  6:19   ` Sam Lewis
2019-12-03 13:27     ` Andrew Lunn

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).