mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: filipp.dunsky@gmail.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Linus Walleij <linusw@kernel.org>
Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>,
	Russell King <linux@armlinux.org.uk>,
	devicetree@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/3] net: cortina: Add CS7542 CPU network datapath
Date: Wed, 25 Nov 2026 12:12:30 +0100	[thread overview]
Message-ID: <ef5dea6e69e0947489f4825540d0f77903960f78.camel@pengutronix.de> (raw)
In-Reply-To: <20261125-b4-cs7542-ethernet-v2-2-d0ea3c6eb375@gmail.com>

On Mi, 2026-11-25 at 13:36 +0300, Fil Dunsky via B4 Relay wrote:
> From: Fil Dunsky <filipp.dunsky@gmail.com>
> 
> Add the three-GMAC CS7542 CPU network datapath with phylink, per-port
> NAPI RX and a shared coherent TX ring. Support scatter-gather TX and
> multi-buffer RX while validating DMA addresses and ring ownership.
> Use the normal NAPI weight and the supported external-DDR QM/TM setup.
> 
> Bound indirect initialization and require confirmed complete-domain
> reset before freeing active DMA mappings. Pin mappings and context when
> reset fails. Keep resource publication and shared-ring timer cancellation
> under the TX lock so completions cannot wake a closing or failed port.
> Use shared ndo_open cleanup labels and let the compiler inline MMIO
> helpers when appropriate.
> 
> Acquire NI, FE, TM, SCH, QM, DMA and NI-XRAM controls exclusively from
> the global provider. Assert and verify all seven without rolling back
> protective assertions; preserve the first error and retain all active
> DMA allocations on any failure. Deassert in reverse order. The shared
> DMA control covers both LSO and SSP. Require the verified 64 MiB no-map
> queue-manager reservation on the supported DDR layout.
> 
> Serialize read-modify-write accesses to NI registers shared by the MACs.
> Abort initialization on the first scheduler command error before the
> network engine can publish DMA buffers.
> 
> Resolve NVMEM MAC deferral before installing hardware cleanup, when no
> reset or DMA state needs unwinding. Register the plain managed cleanup
> action immediately before the first reset attempt, preserving protective
> cleanup for that attempt and all later failures. Propagate a later
> -EPROBE_DEFER instead of silently generating a random address.
> 
> Count RX fragments independently of whether the frame is deliverable.
> Start with a masked NAPI poll to service previously queued RX descriptors.
> Keep TX completion reaping available while closed ports still own queued
> mappings; never release descriptors whose hardware ownership remains set.
> 
> Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
> ---
>  drivers/net/ethernet/cortina/Kconfig         |   14 +
>  drivers/net/ethernet/cortina/Makefile        |    3 +
>  drivers/net/ethernet/cortina/cs752x_fe.c     |  477 +++++++
>  drivers/net/ethernet/cortina/cs752x_ne.c     | 1869 ++++++++++++++++++++++++++
>  drivers/net/ethernet/cortina/cs752x_ne.h     |   13 +
>  drivers/net/ethernet/cortina/cs752x_sch_tm.c |  687 ++++++++++
>  6 files changed, 3063 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cortina/Kconfig b/drivers/net/ethernet/cortina/Kconfig
> index aaf9e294b..52c0683be 100644
> --- a/drivers/net/ethernet/cortina/Kconfig
> +++ b/drivers/net/ethernet/cortina/Kconfig
> @@ -20,4 +20,18 @@ config GEMINI_ETHERNET
>  	help
>  	  This driver supports StorLink SL351x (Gemini) dual Gigabit Ethernet.
>  
> +config CS7542_ETHERNET
> +	tristate "Cortina CS7542 network engine"
> +	depends on OF && OF_RESERVED_MEM && HAS_IOMEM
> +	select PHYLINK
> +	select MFD_SYSCON
> +	select RESET_CONTROLLER

Drop, this driver does not register a reset controller.

[...]
> diff --git a/drivers/net/ethernet/cortina/cs752x_ne.c b/drivers/net/ethernet/cortina/cs752x_ne.c
> new file mode 100644
> index 000000000..081b42079
> --- /dev/null
> +++ b/drivers/net/ethernet/cortina/cs752x_ne.c
> @@ -0,0 +1,1869 @@
[...]
> +#define CS_NE_NUM_RESETS 7
> +static const char * const cs_ne_reset_names[CS_NE_NUM_RESETS] = {
> +	"ni", "fe", "tm", "sch", "qm", "dma", "xram",
> +};
> +
> +struct cs_ne {
> +	struct device *dev;
> +	/* Shared NI registers contain fields belonging to several MACs. */
> +	spinlock_t ni_lock;
> +	struct regmap *global;
> +	struct reset_control_bulk_data resets[CS_NE_NUM_RESETS];
[...]
> +/*
> + * Try every protective assert and check every line, retaining the first error.
> + * Bulk assert must not be used here: its rollback deasserts earlier lines.

Why is this an issue?

> + */
> +static int cs_ne_assert_resets(struct cs_ne *ne)
> +{
> +	int first = 0, ret, i;
> +
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++) {
> +		ret = reset_control_assert(ne->resets[i].rstc);
> +		if (ret && !first)
> +			first = ret;
> +	}
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++) {
> +		ret = reset_control_status(ne->resets[i].rstc);

Why is this needed?

The reset controller driver already polls the global reset register for
the "asserted" state in cs7542_reset_update(). If this returns 0, the
corresponding assert above should already have returned -ETIMEDOUT.

> +		if (ret != 1 && !first)
> +			first = ret < 0 ? ret : -EIO;
> +	}
> +	return first;
> +}
> +
> +static int cs_ne_deassert_resets(struct cs_ne *ne)
> +{
> +	int ret, i;
> +
> +	/* Reverse the consumer's assert order, as the bulk API would. */
> +	for (i = CS_NE_NUM_RESETS - 1; i >= 0; i--) {
> +		ret = reset_control_deassert(ne->resets[i].rstc);
> +		if (ret)
> +			return ret;
> +	}
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++) {
> +		ret = reset_control_status(ne->resets[i].rstc);

Same as above. The reset controller driver should guarantee that the
deasserted resets are actually deasserted at this point.

[...]
> +static int cs_ne_probe(struct platform_device *pdev)
> +{
[...]
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++)
> +		ne->resets[i].id = cs_ne_reset_names[i];
> +	ret = devm_reset_control_bulk_get_exclusive(dev, CS_NE_NUM_RESETS, ne->resets);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "exclusive engine resets\n");
[...]
> +
> +	ret = cs_ne_assert_resets(ne);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "assert engine reset\n");
> +	/* Reset pulse width, not an inferred DMA idle condition. */

What does this mean?

> +	usleep_range(100, 200);
> +	ret = cs_ne_deassert_resets(ne);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "release engine reset\n");

regards
Philipp

  reply	other threads:[~2026-11-25 11:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 10:36 [PATCH net-next v2 0/3] net: cortina: Add CS7542 network engine support Fil Dunsky via B4 Relay
2026-11-25 10:36 ` [PATCH net-next v2 1/3] dt-bindings: net: Add Cortina CS7542 network engine Fil Dunsky via B4 Relay
2026-11-25 10:36 ` [PATCH net-next v2 2/3] net: cortina: Add CS7542 CPU network datapath Fil Dunsky via B4 Relay
2026-11-25 11:12   ` Philipp Zabel [this message]
2026-11-25 11:24     ` Fil Dunsky
2026-11-25 10:36 ` [PATCH net-next v2 3/3] MAINTAINERS: Add CS7542 network engine support Fil Dunsky via B4 Relay

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=ef5dea6e69e0947489f4825540d0f77903960f78.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=filipp.dunsky@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=ulli.kroll@googlemail.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

all inboxes | Powered by JetHome®