linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Ivan Bornyakov <i.bornyakov@metrotek.ru>
Cc: "Marek Behún" <kabel@kernel.org>,
	system@metrotek.ru, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] net: phy: marvell-88x2222: check that link is operational
Date: Tue, 13 Apr 2021 15:07:08 +0200	[thread overview]
Message-ID: <YHWXfFEnOZvpqxWM@lunn.ch> (raw)
In-Reply-To: <20210413071349.r374hxctgboj7l5a@dhcp-179.ddg>

On Tue, Apr 13, 2021 at 10:13:49AM +0300, Ivan Bornyakov wrote:
> On Tue, Apr 13, 2021 at 01:32:12AM +0200, Marek Behún wrote:
> > On Mon, 12 Apr 2021 15:16:59 +0300
> > Ivan Bornyakov <i.bornyakov@metrotek.ru> wrote:
> > 
> > > Some SFP modules uses RX_LOS for link indication. In such cases link
> > > will be always up, even without cable connected. RX_LOS changes will
> > > trigger link_up()/link_down() upstream operations. Thus, check that SFP
> > > link is operational before actual read link status.
> > > 
> > > Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
> > > ---
> > >  drivers/net/phy/marvell-88x2222.c | 26 ++++++++++++++++++++++++++
> > >  1 file changed, 26 insertions(+)
> > > 
> > > diff --git a/drivers/net/phy/marvell-88x2222.c b/drivers/net/phy/marvell-88x2222.c
> > > index eca8c2f20684..fb285ac741b2 100644
> > > --- a/drivers/net/phy/marvell-88x2222.c
> > > +++ b/drivers/net/phy/marvell-88x2222.c
> > > @@ -51,6 +51,7 @@
> > >  struct mv2222_data {
> > >  	phy_interface_t line_interface;
> > >  	__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
> > > +	bool sfp_link;
> > >  };
> > >  
> > >  /* SFI PMA transmit enable */
> > > @@ -148,6 +149,9 @@ static int mv2222_read_status(struct phy_device *phydev)
> > >  	phydev->speed = SPEED_UNKNOWN;
> > >  	phydev->duplex = DUPLEX_UNKNOWN;
> > >  
> > > +	if (!priv->sfp_link)
> > > +		return 0;
> > > +
> > 
> > So if SFP is not used at all, if this PHY is used in a different
> > usecase, this function will always return 0? Is this correct?
> > 
> 
> Yes, probably. The thing is that I only have hardware with SFP cages, so
> I realy don't know if this driver work in other usecases.

It is O.K, to say you don't know if this will work for other setups,
but it is different thing to do something which could potentially
break those other setup. Somebody trying to use this without an SFP is
going to have a bad experience because of this change. And then they
are going to have to try to fix this, potentially breaking your setup.

if you truly need this, make it conditional on that you know you have
an SFP cage connected.

> > > +static void mv2222_sfp_link_down(void *upstream)
> > > +{
> > > +	struct phy_device *phydev = upstream;
> > > +	struct mv2222_data *priv;
> > > +
> > > +	priv = (struct mv2222_data *)phydev->priv;
> > 
> > This cast is redundant since the phydev->priv is (void*). You can cast
> > (void*) to (struct ... *).
> > 
> > You can also just use
> > 	struct mv2222_data *priv = phydev->priv;
> >
> 
> Yeah, I know, but reverse XMAS tree wouldn't line up.

Please move the assignment into the body of the function.

       Andrew

  reply	other threads:[~2021-04-13 13:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 12:16 [PATCH net-next 0/2] net: phy: marvell-88x2222: a couple of improvements Ivan Bornyakov
2021-04-12 12:16 ` [PATCH net-next 1/2] net: phy: marvell-88x2222: check that link is operational Ivan Bornyakov
2021-04-12 23:32   ` Marek Behún
2021-04-13  7:13     ` Ivan Bornyakov
2021-04-13 13:07       ` Andrew Lunn [this message]
2021-04-12 23:40   ` Andrew Lunn
2021-04-13  7:19     ` Ivan Bornyakov
2021-04-13  9:23       ` Russell King - ARM Linux admin
2021-04-13 10:06         ` Ivan Bornyakov
2021-04-13 13:12         ` Andrew Lunn
2021-04-13 13:16           ` Russell King - ARM Linux admin
2021-04-12 12:17 ` [PATCH net-next 2/2] net: phy: marvell-88x2222: swap 1G/10G modes on autoneg Ivan Bornyakov

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=YHWXfFEnOZvpqxWM@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=i.bornyakov@metrotek.ru \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=system@metrotek.ru \
    /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;
as well as URLs for NNTP newsgroup(s).