netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yao Zi <ziyao@disroot.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Frank <Frank.Sae@motor-comm.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Choong Yong Liang <yong.liang.choong@linux.intel.com>,
	Chen-Yu Tsai <wens@csie.org>, Jisheng Zhang <jszhang@kernel.org>,
	Furong Xu <0x1207@gmail.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH net-next 3/4] net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller
Date: Sun, 19 Oct 2025 03:05:03 +0000	[thread overview]
Message-ID: <aPRVTvANvwLPrBnG@pie> (raw)
In-Reply-To: <cc564a19-7236-40d4-bf3c-6a24f7d00bec@lunn.ch>

On Sat, Oct 18, 2025 at 04:53:04PM +0200, Andrew Lunn wrote:
> > > I was also wondering about all the other parameters you set. Why have
> > > i not seen any other glue driver with similar code? What makes this
> > > glue driver different?
> > 
> > Most glue drivers are for SoC-integrated IPs, for which
> > stmmac_pltfr_probe() helper could be used to retrieve configuration
> > arguments from devicetree to fill plat_stmmacenet_data. However, YT6801
> > is a PCIe-based controller, and we couldn't rely on devicetree to carry
> > these parameters.
> > 
> > You could find similar parameter setup code in stmmac_pltfr_probe(), and
> > also other glue drivers for PCIe-based controllers, like dwmac-intel.c
> > (intel_mgbe_common_data) and dwmac-loongson.c (loongson_default_data).
> 
> Is there anything common with these two drivers? One of the problems
> stmmac has had in the past is that glue driver writers just
> copy/paste, rather than refactor other glue drivers to share code.  If
> there is shared code, maybe move it into stmmac_pci.c as helpers?

I don't think there's code that could be shared. Parameters configured
in plat(.{dma_cfg,axi}) are mostly hardware-details and dependent on
synthesis parameters, making them repeat less across drivers, e.g.
dwmac-loongson.c configures no AXI parameter, while
intel_mgbe_common_data() configures axi_blen as up to 16, but the
motorcomm controller is capable of burst length up to 32.

Another example is the rx/tx queue number (plat.{rx,tx}_queues_to_use),
which even varies among different controllers supported by dwmac-intel.c

Maybe the most common part among these argument setup routines is the
allocation of plat_stmmacenet_data and its members, but I doubt whether
extracting this part out as a routine helps much for maintenance.

But outside of plat_stmmacenet_data setup code, there is some code
duplicated across PCIe controller drivers and could be effectively
re-used. dwmac-intel.c, dwmac-loongson.c and stmmac_pci.c have the
same implementation for platform suspend/resume routines
(plat_stmmacenet_data.{suspend,resume}). I could send a series to
extract this part out, and re-use the common routine in the motorcomm
glue driver as well, though we still need to define a new function to
addtionally deassert EPHY_RESET.

> 	Andrew

Best regards.
Yao Zi

  reply	other threads:[~2025-10-19  3:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 16:47 [PATCH net-next 0/4] Add DWMAC glue driver for Motorcomm YT6801 Yao Zi
2025-10-14 16:47 ` [PATCH net-next 1/4] PCI: Add vendor ID for Motorcomm Electronic Technology Yao Zi
2025-10-14 20:43   ` Bjorn Helgaas
2025-10-15  9:57     ` Yao Zi
2025-10-14 16:47 ` [PATCH net-next 2/4] net: phy: motorcomm: Support YT8531S PHY in YT6801 Ethernet controller Yao Zi
2025-10-14 17:08   ` Russell King (Oracle)
2025-10-15 13:41     ` Yao Zi
2025-10-14 16:47 ` [PATCH net-next 3/4] net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller Yao Zi
2025-10-16 20:11   ` Andrew Lunn
2025-10-17 14:03     ` Yao Zi
2025-10-17 14:56       ` Andrew Lunn
2025-10-17 15:04         ` Russell King (Oracle)
2025-10-18  8:21           ` Yao Zi
2025-10-18  8:16         ` Yao Zi
2025-10-18 14:53           ` Andrew Lunn
2025-10-19  3:05             ` Yao Zi [this message]
2025-10-14 16:47 ` [PATCH net-next 4/4] MAINTAINERS: Assign myself as maintainer of Motorcomm DWMAC glue driver Yao Zi
2025-10-15  8:58 ` [PATCH net-next 0/4] Add DWMAC glue driver for Motorcomm YT6801 Mingcong Bai

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=aPRVTvANvwLPrBnG@pie \
    --to=ziyao@disroot.org \
    --cc=0x1207@gmail.com \
    --cc=Frank.Sae@motor-comm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=bhelgaas@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=jszhang@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vladimir.oltean@nxp.com \
    --cc=wens@csie.org \
    --cc=yong.liang.choong@linux.intel.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;
as well as URLs for NNTP newsgroup(s).