public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: edk2-devel-01 <edk2-devel@lists.01.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	 nadavh@marvell.com, Neta Zur Hershkovits <neta@marvell.com>,
	 Kostya Porotchkin <kostap@marvell.com>,
	Hua Jing <jinghua@marvell.com>,
	 semihalf-dabros-jan <jsd@semihalf.com>
Subject: Re: [platforms: PATCH v2 07/10] Marvell/Drivers: Pp2Dxe: Change settings for the always-up link
Date: Fri, 27 Oct 2017 16:49:59 +0200	[thread overview]
Message-ID: <CAPv3WKcaAQ9FNYXY7_3e+28vkOkpMJ6+TbSbi944Wv-7ESAa5Q@mail.gmail.com> (raw)
In-Reply-To: <20171027143640.msneayaflrcc6u54@bivouac.eciton.net>

2017-10-27 16:36 GMT+02:00 Leif Lindholm <leif.lindholm@linaro.org>:
>
> On Fri, Oct 27, 2017 at 03:13:49AM +0200, Marcin Wojtas wrote:
> > Currently initial forcing link status happened for all ports, not only
> > marked as 'always-up'. Although this didn't actually matter for the MAC
> > settings, because MAC is automatically updated with PHY HW polling
> > feature of the controller, perform mv_gop110_fl_cfg only when
> > the appropriate flag is true. Also in such case, force the link as up,
> > using a new library routine.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> > ---
> >  Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c | 25 ++++++++++++++++++++
> >  Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.h |  6 +++++
> >  Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c   |  6 ++++-
> >  3 files changed, 36 insertions(+), 1 deletion(-)
> >
> > diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c b/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c
> > index 53154db..c2d0199 100644
> > --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c
> > +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.c
> > @@ -4804,6 +4804,31 @@ MvGop110PortEventsMask (
> >    return 0;
> >  }
> >
> > +/*
> > + * Sets "Force Link Pass" and "Do Not Force Link Fail" bits.
> > + * This function should only be called when the port is disabled.
> > + */
> > +VOID
> > +MvGop110GmacForceLinkModeSet(
> > +  IN PP2DXE_PORT *Port,
> > +  IN BOOLEAN LinkUp
> > +  )
> > +{
> > +  UINT32 RegVal;
> > +
> > +  RegVal = MvGop110GmacRead (Port, MVPP2_PORT_AUTO_NEG_CFG_REG);
> > +
> > +  if (LinkUp) {
> > +    RegVal |= MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_UP_MASK;
> > +    RegVal &= ~MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_DOWN_MASK;
>
> So, I know UP and DOWN are separate bits (what's that about!?), but
> unless you know that, the above two lines look like they're in the
> wrong order.
>

There is a 3rd case that if both are set to '1', autonegotiation is
forced, but we don't use it. I can even more simplify according to the
usecase (only 1 call in Pp2Dxe driver):

VOID
MvGop110GmacForceLinkUp(
  IN PP2DXE_PORT *Port
  )
{
  UINT32 RegVal;

  RegVal = MvGop110GmacRead (Port, MVPP2_PORT_AUTO_NEG_CFG_REG);

  RegVal |= MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_UP_MASK;
  RegVal &= ~MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_DOWN_MASK;

  MvGop110GmacWrite (Port, MVPP2_PORT_AUTO_NEG_CFG_REG, RegVal);
}

What do you think?

> If you flip those around (and make it like the 'else' clause):

Ok.

> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>
> > +  } else {
> > +    RegVal &= ~MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_UP_MASK;
> > +    RegVal |= MVPP2_PORT_AUTO_NEG_CFG_FORCE_LINK_DOWN_MASK;
> > +  }
> > +
> > +  MvGop110GmacWrite (Port, MVPP2_PORT_AUTO_NEG_CFG_REG, RegVal);
> > +}
> > +
> >  INT32
> >  MvGop110FlCfg (
> >    IN PP2DXE_PORT *Port
> > diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.h b/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.h
> > index a7011f7..3ebe294 100644
> > --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.h
> > +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Mvpp2Lib.h
> > @@ -504,6 +504,12 @@ MvGop110XlgPortLinkEventMask (
> >    IN PP2DXE_PORT *Port
> >    );
> >
> > +VOID
> > +MvGop110GmacForceLinkModeSet (
> > +  IN PP2DXE_PORT *Port,
> > +  IN BOOLEAN LinkUp
> > +  );
> > +
> >  INT32
> >  MvGop110FlCfg (
> >    IN PP2DXE_PORT *Port
> > diff --git a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
> > index 2827976..4a1b9d5 100644
> > --- a/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
> > +++ b/Platform/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
> > @@ -1310,7 +1310,11 @@ Pp2DxeInitialiseController (
> >      NetCompConfig |= MvpPp2xGop110NetcCfgCreate(&Pp2Context->Port);
> >
> >      MvGop110PortInit(&Pp2Context->Port);
> > -    MvGop110FlCfg(&Pp2Context->Port);
> > +
> > +    if (Pp2Context->Port.AlwaysUp == TRUE) {
> > +      MvGop110GmacForceLinkModeSet (&Pp2Context->Port, TRUE);
> > +      MvGop110FlCfg (&Pp2Context->Port);
> > +    }
> >
> >      Status = gBS->CreateEvent (
> >                   EVT_SIGNAL_EXIT_BOOT_SERVICES,
> > --
> > 2.7.4
> >


  reply	other threads:[~2017-10-27 14:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27  1:13 [platforms: PATCH v2 00/10] Armada 7k/8k - misc improvements pt.2 Marcin Wojtas
2017-10-27  1:13 ` [platforms: PATCH v2 01/10] Marvell/Drivers: MvI2cDxe: Abort transaction immediately upon fail Marcin Wojtas
2017-10-27 14:28   ` Leif Lindholm
2017-10-27  1:13 ` [platforms: PATCH v2 02/10] Marvell/Drivers: MvI2cDxe: Fix returning status in MvI2cStartRequest Marcin Wojtas
2017-10-27 14:29   ` Leif Lindholm
2017-10-27  1:13 ` [platforms: PATCH v2 03/10] Marvell/Drivers: MvI2cDxe: Reduce bus occupation time Marcin Wojtas
2017-10-27  1:13 ` [platforms: PATCH v2 04/10] Marvell/Library: MppLib: Prevent overwriting PCD values Marcin Wojtas
2017-10-27  1:13 ` [platforms: PATCH v2 05/10] Marvell/Library: MppLib: Disable the stack protector Marcin Wojtas
2017-10-27  1:13 ` [platforms: PATCH v2 06/10] Marvell/Library: MppLib: Take 0xFF placeholders into account Marcin Wojtas
2017-10-27 14:30   ` Leif Lindholm
2017-10-27  1:13 ` [platforms: PATCH v2 07/10] Marvell/Drivers: Pp2Dxe: Change settings for the always-up link Marcin Wojtas
2017-10-27 14:36   ` Leif Lindholm
2017-10-27 14:49     ` Marcin Wojtas [this message]
2017-10-27  1:13 ` [platforms: PATCH v2 08/10] Marvell/Drivers: XenonDxe: Fix UHS signalling mode setting Marcin Wojtas
2017-10-27 14:37   ` Leif Lindholm
2017-10-27  1:13 ` [platforms: PATCH v2 09/10] Marvell/Drivers: XenonDxe: Allow overriding base clock frequency Marcin Wojtas
2017-10-27 14:51   ` Leif Lindholm
2017-10-27 15:30     ` Marcin Wojtas
2017-10-27  1:13 ` [platforms: PATCH v2 10/10] Marvell/Drivers: XenonDxe: Do not modify FIFO default values Marcin Wojtas

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-list 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=CAPv3WKcaAQ9FNYXY7_3e+28vkOkpMJ6+TbSbi944Wv-7ESAa5Q@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /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