public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
	lxu@maxlinear.com, hkallweit1@gmail.com, yweng@maxlinear.com,
	ajayaraman@maxlinear.com, andrew@lunn.ch, netdev@vger.kernel.org,
	bxu@maxlinear.com, krzk+dt@kernel.org,
	linux-kernel@vger.kernel.org, lrosu@maxlinear.com,
	chad@monroe.io, conor+dt@kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, edumazet@google.com, pabeni@redhat.com,
	cezary.wilmanski@adtran.com, davem@davemloft.net,
	john@phrozen.org, frankwu@gmx.de, jpovazanec@maxlinear.com,
	linux@armlinux.org.uk, fchan@maxlinear.com, horms@kernel.org
Subject: Re: [net-next,v11,4/4] net: dsa: add basic initial driver for MxL862xx switches
Date: Mon, 2 Feb 2026 13:15:44 +0200	[thread overview]
Message-ID: <20260202111544.r2mlklwdvviqq7q3@skbuf> (raw)
In-Reply-To: <aYCBS40IO_GwAEBy@makrotopia.org>

On Mon, Feb 02, 2026 at 10:49:47AM +0000, Daniel Golle wrote:
> > > The dsa_to_port() function can return NULL if the port is not found in
> > > the switch tree. The code stores the result in dp but doesn't check if
> > > dp is NULL before dereferencing dp->cpu_dp->index.
> > > 
> > > Looking at include/net/dsa.h, dsa_to_port() returns NULL when the port
> > > is not found:
> > > 
> > >     static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
> > >     {
> > >         struct dsa_switch_tree *dst = ds->dst;
> > >         struct dsa_port *dp;
> > > 
> > >         list_for_each_entry(dp, &dst->ports, list)
> > >             if (dp->ds == ds && dp->index == p)
> > >                 return dp;
> > > 
> > >         return NULL;
> > >     }
> > > 
> > > Additionally, even if dp is non-NULL, dp->cpu_dp could also be NULL if
> > > the CPU port hasn't been properly assigned during initialization.
> > 
> > mxl862xx_add_single_port_bridge() has been called when all other port
> > types except user ports have been excluded. All user and DSA ports have
> > a non-NULL dp->cpu_dp pointer after dsa_tree_setup_cpu_ports() runs,
> > i.e. also at the time of ds->ops->port_setup().
> 
> here, as well as in mxl862xx_setup_cpu_bridge(), right?

Yeah. If you think adding a comment helps keep spirits calm, you can also do that.

> > Technically ds->ops->setup() runs under dsa2_mutex, but the "static int idx"
> > is still not ideal due to the ever-increasing index upon unbinding and
> > rebinding.
> 
> As mentioned in my reply to Jakub[1] many drivers follow this pattern and it would
> imho be a good idea to agree on a convention or even provide a helper function
> which names the MII bus for DSA drivers. What do you think?
> 
> [1]: https://patchwork.kernel.org/comment/26768088/

I don't really have an opinion, the internal MDIO bus is part of each
driver's housekeeping, and DSA tries to stay out of that as much as possible.

Maybe PHY maintainers may know more what user space tooling may break if
the mii_bus->id gets changed, or may prefer a naming convention irrespective
of the bus being part of a DSA switch or not.

      reply	other threads:[~2026-02-02 13:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-31  0:10 [PATCH net-next v11 0/4] net: dsa: initial support for MaxLinear MxL862xx switches Daniel Golle
2026-01-31  0:10 ` [PATCH net-next v11 1/4] dt-bindings: net: dsa: add MaxLinear MxL862xx Daniel Golle
2026-01-31  0:11 ` [PATCH net-next v11 2/4] net: dsa: add tag format for MxL862xx switches Daniel Golle
2026-01-31  0:11 ` [PATCH net-next v11 3/4] net: mdio: add unlocked mdiodev C45 bus accessors Daniel Golle
2026-02-02 11:03   ` Russell King (Oracle)
2026-01-31  0:11 ` [PATCH net-next v11 4/4] net: dsa: add basic initial driver for MxL862xx switches Daniel Golle
2026-01-31 17:52   ` [net-next,v11,4/4] " Jakub Kicinski
2026-02-01  0:55     ` Daniel Golle
2026-02-02 11:10       ` Russell King (Oracle)
2026-02-02 11:15         ` Daniel Golle
2026-02-02  9:44     ` Vladimir Oltean
2026-02-02 10:49       ` Daniel Golle
2026-02-02 11:15         ` Vladimir Oltean [this message]

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=20260202111544.r2mlklwdvviqq7q3@skbuf \
    --to=olteanv@gmail.com \
    --cc=ajayaraman@maxlinear.com \
    --cc=andrew@lunn.ch \
    --cc=bxu@maxlinear.com \
    --cc=cezary.wilmanski@adtran.com \
    --cc=chad@monroe.io \
    --cc=conor+dt@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=fchan@maxlinear.com \
    --cc=frankwu@gmx.de \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=john@phrozen.org \
    --cc=jpovazanec@maxlinear.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lrosu@maxlinear.com \
    --cc=lxu@maxlinear.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=yweng@maxlinear.com \
    /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