Subject: Re: [PATCH v2 net-next 1/3] net: phy: check that PHY is stopped when entering phy_disconnect

From: Andrew Lunn <[email-masked]>
Date: Wed, 16 Jan 2019 22:48:30 +0100

On Wed, Jan 16, 2019 at 09:25:15PM +0100, Heiner Kallweit wrote:
> Every driver should have called phy_stop() before calling
> phy_disconnect(). Let's check for this and ensure PHY is stopped
> when starting with the actual work in phy_disconnect().

Hi Heiner

Looking at the patch, i think why must the MAC driver call phy_stop()
before phy_disconnect()? It keeps is symmetrical, you need
phy_connect() and then phy_start(). But if the core can detect that
phy_stop() has not been called, and can call phy_stop() when needed,
we can probably simplify the MAC drivers by removing many of the
phy_stop() calls.

I think it might come down to where the phy_connect()/phy_disconnect()
is performed. Sometimes it is in probe()/remove(), sometimes it is in
open()/close(). If phy_disconnect() is in remove(), phy_stop() is
needed in close(). But if phy_disconnect() is called in close() the
phy_stop() could be skipped?

Before we start adding warning, we probably should first document the
expectations. Documentation/networking/phy.txt seems like a good
place.

	Andrew