netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Sasha Levin <sashal@kernel.org>,
	Antoine Tenart <antoine.tenart@bootlin.com>,
	stable@vger.kernel.org, Russell King <rmk+kernel@armlinux.org.uk>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>, Gabor Samu <samu_gabor@yahoo.ca>,
	Jon Nettleton <jon@solid-run.com>,
	Andrew Elwell <andrew.elwell@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH net-next 2/4] net: mvpp2: add mvpp2_phylink_to_port() helper
Date: Sun, 20 Dec 2020 18:08:19 +0100	[thread overview]
Message-ID: <CAPv3WKfCfECmwjtXLAMbNe-vuGkws_icoQ+MrgJhZJqFcgGDyw@mail.gmail.com> (raw)
In-Reply-To: <CAPv3WKdKOnd+iBkfcVkoOZkHj16jOpBprY3A01ERJeq6ZQCkVQ@mail.gmail.com>

Hi Jakub,

czw., 10 gru 2020 o 15:35 Marcin Wojtas <mw@semihalf.com> napisał(a):
>
> Hi Greg,
>
> śr., 9 gru 2020 o 11:59 Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> napisał(a):
> >
> > On Tue, Dec 08, 2020 at 04:02:50PM +0100, Marcin Wojtas wrote:
> > > Hi Sasha,
> > >
> > > wt., 8 gru 2020 o 14:35 Sasha Levin <sashal@kernel.org> napisał(a):
> > > >
> > > > On Tue, Dec 08, 2020 at 01:03:38PM +0100, Marcin Wojtas wrote:
> > > > >Hi Greg,
> > > > >
> > > > >Apologies for delayed response:.
> > > > >
> > > > >
> > > > >pon., 2 lis 2020 o 19:02 Greg Kroah-Hartman
> > > > ><gregkh@linuxfoundation.org> napisał(a):
> > > > >>
> > > > >> On Mon, Nov 02, 2020 at 06:38:54PM +0100, Marcin Wojtas wrote:
> > > > >> > Hi Greg and Sasha,
> > > > >> >
> > > > >> > pt., 9 paź 2020 o 05:43 Marcin Wojtas <mw@semihalf.com> napisał(a):
> > > > >> > >
> > > > >> > > Hi,
> > > > >> > >
> > > > >> > > sob., 20 cze 2020 o 11:21 Russell King <rmk+kernel@armlinux.org.uk> napisał(a):
> > > > >> > > >
> > > > >> > > > Add a helper to convert the struct phylink_config pointer passed in
> > > > >> > > > from phylink to the drivers internal struct mvpp2_port.
> > > > >> > > >
> > > > >> > > > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > > > >> > > > ---
> > > > >> > > >  .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 29 +++++++++----------
> > > > >> > > >  1 file changed, 14 insertions(+), 15 deletions(-)
> > > > >> > > >
> > > > >> > > > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > > >> > > > index 7653277d03b7..313f5a60a605 100644
> > > > >> > > > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > > >> > > > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > > > >> > > > @@ -4767,12 +4767,16 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
> > > > >> > > >         eth_hw_addr_random(dev);
> > > > >> > > >  }
> > > > >> > > >
> > > > >> > > > +static struct mvpp2_port *mvpp2_phylink_to_port(struct phylink_config *config)
> > > > >> > > > +{
> > > > >> > > > +       return container_of(config, struct mvpp2_port, phylink_config);
> > > > >> > > > +}
> > > > >> > > > +
> > > > >> > > >  static void mvpp2_phylink_validate(struct phylink_config *config,
> > > > >> > > >                                    unsigned long *supported,
> > > > >> > > >                                    struct phylink_link_state *state)
> > > > >> > > >  {
> > > > >> > > > -       struct mvpp2_port *port = container_of(config, struct mvpp2_port,
> > > > >> > > > -                                              phylink_config);
> > > > >> > > > +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
> > > > >> > > >         __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
> > > > >> > > >
> > > > >> > > >         /* Invalid combinations */
> > > > >> > > > @@ -4913,8 +4917,7 @@ static void mvpp2_gmac_pcs_get_state(struct mvpp2_port *port,
> > > > >> > > >  static void mvpp2_phylink_mac_pcs_get_state(struct phylink_config *config,
> > > > >> > > >                                             struct phylink_link_state *state)
> > > > >> > > >  {
> > > > >> > > > -       struct mvpp2_port *port = container_of(config, struct mvpp2_port,
> > > > >> > > > -                                              phylink_config);
> > > > >> > > > +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
> > > > >> > > >
> > > > >> > > >         if (port->priv->hw_version == MVPP22 && port->gop_id == 0) {
> > > > >> > > >                 u32 mode = readl(port->base + MVPP22_XLG_CTRL3_REG);
> > > > >> > > > @@ -4931,8 +4934,7 @@ static void mvpp2_phylink_mac_pcs_get_state(struct phylink_config *config,
> > > > >> > > >
> > > > >> > > >  static void mvpp2_mac_an_restart(struct phylink_config *config)
> > > > >> > > >  {
> > > > >> > > > -       struct mvpp2_port *port = container_of(config, struct mvpp2_port,
> > > > >> > > > -                                              phylink_config);
> > > > >> > > > +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
> > > > >> > > >         u32 val = readl(port->base + MVPP2_GMAC_AUTONEG_CONFIG);
> > > > >> > > >
> > > > >> > > >         writel(val | MVPP2_GMAC_IN_BAND_RESTART_AN,
> > > > >> > > > @@ -5105,13 +5107,12 @@ static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,
> > > > >> > > >  static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
> > > > >> > > >                              const struct phylink_link_state *state)
> > > > >> > > >  {
> > > > >> > > > -       struct net_device *dev = to_net_dev(config->dev);
> > > > >> > > > -       struct mvpp2_port *port = netdev_priv(dev);
> > > > >> > > > +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
> > > > >> > > >         bool change_interface = port->phy_interface != state->interface;
> > > > >> > > >
> > > > >> > > >         /* Check for invalid configuration */
> > > > >> > > >         if (mvpp2_is_xlg(state->interface) && port->gop_id != 0) {
> > > > >> > > > -               netdev_err(dev, "Invalid mode on %s\n", dev->name);
> > > > >> > > > +               netdev_err(port->dev, "Invalid mode on %s\n", port->dev->name);
> > > > >> > > >                 return;
> > > > >> > > >         }
> > > > >> > > >
> > > > >> > > > @@ -5151,8 +5152,7 @@ static void mvpp2_mac_link_up(struct phylink_config *config,
> > > > >> > > >                               int speed, int duplex,
> > > > >> > > >                               bool tx_pause, bool rx_pause)
> > > > >> > > >  {
> > > > >> > > > -       struct net_device *dev = to_net_dev(config->dev);
> > > > >> > > > -       struct mvpp2_port *port = netdev_priv(dev);
> > > > >> > > > +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
> > > > >> > > >         u32 val;
> > > > >> > > >
> > > > >> > > >         if (mvpp2_is_xlg(interface)) {
> > > > >> > > > @@ -5199,14 +5199,13 @@ static void mvpp2_mac_link_up(struct phylink_config *config,
> > > > >> > > >
> > > > >> > > >         mvpp2_egress_enable(port);
> > > > >> > > >         mvpp2_ingress_enable(port);
> > > > >> > > > -       netif_tx_wake_all_queues(dev);
> > > > >> > > > +       netif_tx_wake_all_queues(port->dev);
> > > > >> > > >  }
> > > > >> > > >
> > > > >> > > >  static void mvpp2_mac_link_down(struct phylink_config *config,
> > > > >> > > >                                 unsigned int mode, phy_interface_t interface)
> > > > >> > > >  {
> > > > >> > > > -       struct net_device *dev = to_net_dev(config->dev);
> > > > >> > > > -       struct mvpp2_port *port = netdev_priv(dev);
> > > > >> > > > +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
> > > > >> > > >         u32 val;
> > > > >> > > >
> > > > >> > > >         if (!phylink_autoneg_inband(mode)) {
> > > > >> > > > @@ -5223,7 +5222,7 @@ static void mvpp2_mac_link_down(struct phylink_config *config,
> > > > >> > > >                 }
> > > > >> > > >         }
> > > > >> > > >
> > > > >> > > > -       netif_tx_stop_all_queues(dev);
> > > > >> > > > +       netif_tx_stop_all_queues(port->dev);
> > > > >> > > >         mvpp2_egress_disable(port);
> > > > >> > > >         mvpp2_ingress_disable(port);
> > > > >> > > >
> > > > >> > > > --
> > > > >> > > > 2.20.1
> > > > >> > > >
> > > > >> > >
> > > > >> > > This patch fixes a regression that was introduced in v5.3:
> > > > >> > > Commit 44cc27e43fa3 ("net: phylink: Add struct phylink_config to PHYLINK API")
> > > > >> > >
> > > > >> > > Above results in a NULL pointer dereference when booting the
> > > > >> > > Armada7k8k/CN913x with ACPI between 5.3 and 5.8, which will be
> > > > >> > > problematic especially for the distros using LTSv5.4 and above (the
> > > > >> > > issue was reported on Fedora 32).
> > > > >> > >
> > > > >> > > Please help with backporting to the stable v5.3+ branches (it applies
> > > > >> > > smoothly on v5.4/v5.6/v5.8).
> > > > >> > >
> > > > >> >
> > > > >> > Any chances to backport this patch to relevant v5.3+ stable branches?
> > > > >>
> > > > >> What patch?  What git commit id needs to be backported?
> > > > >>
> > > > >
> > > > >The actual patch is:
> > > > >Commit 6c2b49eb9671  ("net: mvpp2: add mvpp2_phylink_to_port() helper").
> > > > >
> > > > >URL for reference:
> > > > >https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/net/ethernet/marvell/mvpp2?h=v5.10-rc7&id=6c2b49eb96716e91f202756bfbd3f5fea3b2b172
> > > > >
> > > > >Do you think it would be possible to get it merged to v5.3+ stable branches?
> > > >
> > > > Could you explain how that patch fixes anything? It reads like a
> > > > cleanup.
> > > >
> > >
> > > Indeed, I am aware of it, but I'm not sure about the best way to fix
> > > it. In fact the mentioned patch is an unintentional fix. Commit
> > > 44cc27e43fa3 ("net: phylink: Add struct phylink_config to PHYLINK
> > > API") reworked an argument list of mvpp2_mac_config() routine in a way
> > > that resulted in a NULL pointer dereference when booting the
> > > Armada7k8k/CN913x with ACPI between 5.3 and 5.8. Part of Russell's
> > > patch resolves this issue.
> >
> > What part fixes the issue?  I can't see it...
> >
>
> I re-checked in my setup and here's the smallest part of the original
> patch, that fixes previously described issue:
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index e98be8372780..9d71a4fe1750 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -4767,6 +4767,11 @@ static void mvpp2_port_copy_mac_addr(struct
> net_device *dev, struct mvpp2 *priv,
>         eth_hw_addr_random(dev);
>  }
>
> +static struct mvpp2_port *mvpp2_phylink_to_port(struct phylink_config *config)
> +{
> +       return container_of(config, struct mvpp2_port, phylink_config);
> +}
> +
>  static void mvpp2_phylink_validate(struct phylink_config *config,
>                                    unsigned long *supported,
>                                    struct phylink_link_state *state)
> @@ -5105,13 +5110,12 @@ static void mvpp2_gmac_config(struct
> mvpp2_port *port, unsigned int mode,
>  static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
>                              const struct phylink_link_state *state)
>  {
> -       struct net_device *dev = to_net_dev(config->dev);
> -       struct mvpp2_port *port = netdev_priv(dev);
> +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
>         bool change_interface = port->phy_interface != state->interface;
>
>         /* Check for invalid configuration */
>         if (mvpp2_is_xlg(state->interface) && port->gop_id != 0) {
> -               netdev_err(dev, "Invalid mode on %s\n", dev->name);
> +               netdev_err(port->dev, "Invalid mode on %s\n", port->dev->name);
>                 return;
>         }
>
> @@ -5151,8 +5155,7 @@ static void mvpp2_mac_link_up(struct
> phylink_config *config,
>                               int speed, int duplex,
>                               bool tx_pause, bool rx_pause)
>  {
> -       struct net_device *dev = to_net_dev(config->dev);
> -       struct mvpp2_port *port = netdev_priv(dev);
> +       struct mvpp2_port *port = mvpp2_phylink_to_port(config);
>         u32 val;
>
>         if (mvpp2_is_xlg(interface)) {
> @@ -5199,7 +5202,7 @@ static void mvpp2_mac_link_up(struct
> phylink_config *config,
>
>         mvpp2_egress_enable(port);
>         mvpp2_ingress_enable(port);
> -       netif_tx_wake_all_queues(dev);
> +       netif_tx_wake_all_queues(port->dev);
>  }
>
>  static void mvpp2_mac_link_down(struct phylink_config *config,
> --
>
> Do you think there is a point of slicing the original patch or rather
> cherry-pick as-is?
>

Do you think there is a chance to get the above fix merged to stable (v5.3+)?

Best regards,
Marcin

  parent reply	other threads:[~2020-12-20 17:09 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20  9:20 [PATCH net-next v2 0/4] Marvell mvpp2 improvements Russell King - ARM Linux admin
2020-06-20  9:21 ` [PATCH net-next 1/4] net: mvpp2: add port support helpers Russell King
2020-06-20  9:21 ` [PATCH net-next 2/4] net: mvpp2: add mvpp2_phylink_to_port() helper Russell King
2020-10-09  3:43   ` Marcin Wojtas
2020-11-02 17:38     ` Marcin Wojtas
2020-11-02 18:03       ` Greg Kroah-Hartman
2020-12-08 12:03         ` Marcin Wojtas
2020-12-08 13:35           ` Sasha Levin
2020-12-08 15:02             ` Marcin Wojtas
2020-12-09 11:00               ` Greg Kroah-Hartman
2020-12-10 14:35                 ` Marcin Wojtas
2020-12-10 15:46                   ` Russell King - ARM Linux admin
2020-12-10 17:43                     ` Marcin Wojtas
2020-12-10 17:56                       ` Russell King - ARM Linux admin
2020-12-10 18:22                         ` Marcin Wojtas
2020-12-10 20:26                           ` Andrew Lunn
2020-12-10 23:45                             ` Marcin Wojtas
2020-12-11  5:03                             ` Jon Nettleton
2020-12-11 14:01                               ` Andrew Lunn
2020-12-20 17:08                   ` Marcin Wojtas [this message]
2020-12-21 18:25                     ` Jakub Kicinski
2020-12-21 18:30                       ` Russell King - ARM Linux admin
2020-12-21 18:47                         ` Jakub Kicinski
2020-12-21 19:07                           ` Sasha Levin
2020-12-21 21:12                             ` Marcin Wojtas
2020-11-02 23:02       ` Russell King - ARM Linux admin
2020-06-20  9:21 ` [PATCH net-next 3/4] net: mvpp2: add register modification helper Russell King
2020-06-20  9:21 ` [PATCH net-next 4/4] net: mvpp2: set xlg flow control in mvpp2_mac_link_up() Russell King
2020-06-21  4:38 ` [PATCH net-next v2 0/4] Marvell mvpp2 improvements David Miller
  -- strict thread matches above, loose matches on Subject: below --
2020-06-18 15:38 [PATCH net-next " Russell King - ARM Linux admin
2020-06-18 15:38 ` [PATCH net-next 2/4] net: mvpp2: add mvpp2_phylink_to_port() helper Russell King
2020-06-20  3:20   ` David Miller

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=CAPv3WKfCfECmwjtXLAMbNe-vuGkws_icoQ+MrgJhZJqFcgGDyw@mail.gmail.com \
    --to=mw@semihalf.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew.elwell@gmail.com \
    --cc=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jon@solid-run.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=samu_gabor@yahoo.ca \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).