lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251120144046.GE661940@google.com>
Date: Thu, 20 Nov 2025 14:40:46 +0000
From: Lee Jones <lee@...nel.org>
To: Vladimir Oltean <vladimir.oltean@....com>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew@...n.ch>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Russell King <linux@...linux.org.uk>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 08/15] net: dsa: sja1105: transition OF-based
 MDIO drivers to standalone

On Tue, 18 Nov 2025, Vladimir Oltean wrote:

> Delete the duplicated drivers for 100base-T1 and 100base-TX from the DSA
> driver, and use devm_mfd_add_devices() to platform devices which probe
> on the dedicated drivers from drivers/net/mdio/. This makes the switch
> act as a sort of bus driver for devices in the "mdios" subnode.
> 
> We can use mfd because the switch driver interacts with the PHYs from
> these MDIO buses exclusively using phylink, which follows "phy-handle"
> fwnode references to them.
> 
> Cc: Lee Jones <lee@...nel.org>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> ---
>  drivers/net/dsa/sja1105/Kconfig        |   1 +
>  drivers/net/dsa/sja1105/Makefile       |   1 +
>  drivers/net/dsa/sja1105/sja1105.h      |   4 -
>  drivers/net/dsa/sja1105/sja1105_main.c |  13 ++
>  drivers/net/dsa/sja1105/sja1105_mdio.c | 270 +------------------------
>  drivers/net/dsa/sja1105/sja1105_mfd.c  |  69 +++++++
>  drivers/net/dsa/sja1105/sja1105_mfd.h  |   9 +
>  drivers/net/dsa/sja1105/sja1105_spi.c  |   6 -
>  8 files changed, 94 insertions(+), 279 deletions(-)
>  create mode 100644 drivers/net/dsa/sja1105/sja1105_mfd.c
>  create mode 100644 drivers/net/dsa/sja1105/sja1105_mfd.h
> 
> diff --git a/drivers/net/dsa/sja1105/Kconfig b/drivers/net/dsa/sja1105/Kconfig
> index 1291bba3f3b6..932bca545d69 100644
> --- a/drivers/net/dsa/sja1105/Kconfig
> +++ b/drivers/net/dsa/sja1105/Kconfig
> @@ -7,6 +7,7 @@ tristate "NXP SJA1105 Ethernet switch family support"
>  	select PCS_XPCS
>  	select PACKING
>  	select CRC32
> +	select MFD_CORE
>  	help
>  	  This is the driver for the NXP SJA1105 (5-port) and SJA1110 (10-port)
>  	  automotive Ethernet switch family. These are managed over an SPI
> diff --git a/drivers/net/dsa/sja1105/Makefile b/drivers/net/dsa/sja1105/Makefile
> index 40d69e6c0bae..3ac2d77dbe6c 100644
> --- a/drivers/net/dsa/sja1105/Makefile
> +++ b/drivers/net/dsa/sja1105/Makefile
> @@ -5,6 +5,7 @@ sja1105-objs := \
>      sja1105_spi.o \
>      sja1105_main.o \
>      sja1105_mdio.o \
> +    sja1105_mfd.o \
>      sja1105_flower.o \
>      sja1105_ethtool.o \
>      sja1105_devlink.o \
> diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h
> index 4fd6121bd07f..ff6b69663851 100644
> --- a/drivers/net/dsa/sja1105/sja1105.h
> +++ b/drivers/net/dsa/sja1105/sja1105.h
> @@ -91,8 +91,6 @@ struct sja1105_regs {
>  	u64 rmii_ref_clk[SJA1105_MAX_NUM_PORTS];
>  	u64 rmii_ext_tx_clk[SJA1105_MAX_NUM_PORTS];
>  	u64 stats[__MAX_SJA1105_STATS_AREA][SJA1105_MAX_NUM_PORTS];
> -	u64 mdio_100base_tx;
> -	u64 mdio_100base_t1;
>  	u64 pcs_base[SJA1105_MAX_NUM_PORTS];
>  };
>  
> @@ -279,8 +277,6 @@ struct sja1105_private {
>  	struct regmap *regmap;
>  	struct devlink_region **regions;
>  	struct sja1105_cbs_entry *cbs;
> -	struct mii_bus *mdio_base_t1;
> -	struct mii_bus *mdio_base_tx;
>  	struct mii_bus *mdio_pcs;
>  	struct phylink_pcs *pcs[SJA1105_MAX_NUM_PORTS];
>  	struct sja1105_ptp_data ptp_data;
> diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
> index 622264c13fdb..6da5c655dae7 100644
> --- a/drivers/net/dsa/sja1105/sja1105_main.c
> +++ b/drivers/net/dsa/sja1105/sja1105_main.c
> @@ -23,6 +23,7 @@
>  #include <linux/units.h>
>  
>  #include "sja1105.h"
> +#include "sja1105_mfd.h"
>  #include "sja1105_tas.h"
>  
>  #define SJA1105_UNKNOWN_MULTICAST	0x010000000000ull
> @@ -3316,6 +3317,11 @@ static int sja1105_probe(struct spi_device *spi)
>  	if (priv->max_xfer_len > max_msg - SJA1105_SIZE_SPI_MSG_HEADER)
>  		priv->max_xfer_len = max_msg - SJA1105_SIZE_SPI_MSG_HEADER;
>  
> +	/* Explicitly advertise "no DMA" support, to suppress
> +	 * "DMA mask not set" warning in MFD children
> +	 */
> +	dev->dma_mask = &dev->coherent_dma_mask;
> +
>  	priv->info = of_device_get_match_data(dev);
>  
>  	rc = sja1105_create_regmap(priv);
> @@ -3356,6 +3362,13 @@ static int sja1105_probe(struct spi_device *spi)
>  		return rc;
>  	}
>  
> +	rc = sja1105_mfd_add_devices(ds);
> +	if (rc) {
> +		dev_err(ds->dev, "Failed to create child devices: %pe\n",
> +			ERR_PTR(rc));
> +		return rc;
> +	}
> +
>  	if (IS_ENABLED(CONFIG_NET_SCH_CBS)) {
>  		priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers,
>  					 sizeof(struct sja1105_cbs_entry),
> diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c
> index 8d535c033cef..b803ce71f5cc 100644
> --- a/drivers/net/dsa/sja1105/sja1105_mdio.c
> +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c
> @@ -133,238 +133,6 @@ int sja1110_pcs_mdio_write_c45(struct mii_bus *bus, int phy, int mmd, int reg,
>  				&tmp, NULL);

[...]

> diff --git a/drivers/net/dsa/sja1105/sja1105_mfd.c b/drivers/net/dsa/sja1105/sja1105_mfd.c
> new file mode 100644
> index 000000000000..9e60cd3b5d01
> --- /dev/null
> +++ b/drivers/net/dsa/sja1105/sja1105_mfd.c
> @@ -0,0 +1,69 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright 2025 NXP
> + */
> +#include <linux/ioport.h>
> +#include <linux/mfd/core.h>

The MFD API is not to be {ab}used out side of drivers/mfd.

Maybe of_platform_populate() will scratch your itch instead.

[...]

-- 
Lee Jones [李琼斯]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ