Article View: linux.kernel.netdev
Article #3500Re: [PATCH net-next v5 7/8] net: bcmgenet: allow the MTU to be changed
From: Nicolai Buchwitz
Date: Thu, 15 Oct 2026 08:55
Date: Thu, 15 Oct 2026 08:55
126 lines
10332 bytes
10332 bytes
On 14.10.2026 16:22, netdev-bot+sashiko@kernel.org wrote:
> [...]
> [Severity: Medium]
> This is a pre-existing issue that this patch did not introduce, but
> this
> patch adds a new caller that reaches it.
>
> bcmgenet_netif_stop() drops the return value of bcmgenet_dma_teardown()
> and then frees the RX pages anyway:
>
> bcmgenet_netif_stop()
> bcmgenet_dma_teardown(priv); /* -ETIMEDOUT ignored */
> ...
> bcmgenet_fini_dma(priv)
> bcmgenet_free_rx_buffers(priv);
> bcmgenet_destroy_rx_page_pools(priv);
>
> Suppose bcmgenet_rdma_disable() times out because DMA_STATUS never
> acknowledges the disable. Could the RDMA engine then keep writing into
> pages that have already gone back to the page pool?
In theory. bcmgenet_close() and suspend walk the same path today and I
have never seen the disable time out on a BCM2711, so I would rather not
rework the teardown on something I cannot trigger.
> [...]
> [Severity: Medium]
> Does this restart lose the user's TX interrupt coalescing setting?
>
> bcmgenet_set_coalesce() writes ec->tx_max_coalesced_frames straight
> into
> the DMA_MBUF_DONE_THRESH register of each TDMA ring and keeps no
> software
> copy. bcmgenet_get_coalesce() reads the value back from ring 0.
>
> This path rebuilds the TX rings with a hard-coded threshold:
>
> bcmgenet_init_dma()
> bcmgenet_init_tx_queues()
> bcmgenet_init_tx_ring()
> bcmgenet_tdma_ring_writel(priv, index, 1,
> DMA_MBUF_DONE_THRESH);
>
> bcmgenet_init_rx_coalesce() reapplies the RX coalescing, but nothing
> restores the TX value.
>
> Take "ethtool -C ethX tx-frames N" followed by an MTU change across
> ETH_DATA_LEN, such as 1500 to 3000. Would ethtool -c then report
> tx-frames 1?
It would, but IMHO suspend and resume drop the setting the same way
today,
so should be fixed in net rather than here.
> [...]
> [Severity: High]
> This isn't a bug introduced by this patch, but datapath_up now tracks
> exactly this state. Should bcmgenet_suspend() check it as well?
>
> Suppose bcmgenet_init_dma() fails in bcmgenet_resume(). The interface
> then stays netif_running() and detached:
>
> - the earlier bcmgenet_fini_dma() has already deleted the NAPIs
> - rx_cbs and tx_cbs are freed but not set to NULL
> - the clock is gated
>
> bcmgenet_resume()
> ret = bcmgenet_init_dma(priv, false);
> if (ret) {
> netdev_err(dev, "failed to initialize DMA\n");
> goto out_clk_disable;
> }
> ...
> out_clk_disable:
> if (priv->internal_phy)
> bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
> clk_disable_unprepare(priv->clk);
>
> On the next system suspend, bcmgenet_suspend() checks only
> netif_running(dev). Both of its branches reach
> bcmgenet_disable_tx_napi():
> the WoL branch directly, the other branch through
> bcmgenet_netif_stop().
>
> The TX NAPIs were deleted with SCHED and NPSVC still set. Would
> napi_disable_locked() then wait here forever?
>
> while (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
> usleep_range(20, 200);
> val = READ_ONCE(n->state);
> }
>
> If suspend ever got past that point, bcmgenet_tx_reclaim_all() would
> walk
> the freed tx_cbs. bcmgenet_fini_dma() would also kfree() rx_cbs and
> tx_cbs
> a second time, with the block unclocked.
>
> bcmgenet_change_mtu() already handles this state ("A datapath left down
> by
> a failed resume has nothing to reprogram either"). bcmgenet_suspend()
> only
> gets the assignment, not an early return.
>
> If the interface is closed after the failed resume, the new guard skips
> bcmgenet_netif_stop(). bcmgenet_close() still calls
> bcmgenet_power_down()
> and clk_disable_unprepare(priv->clk) unconditionally. The failed resume
> already balanced the clock, so does this underflow the clock's enable
> and
> prepare counts?
>
> Could bcmgenet_suspend() skip the teardown when !priv->datapath_up?
> Could
> the driver also track that the failed resume already gated the clock,
> so
> close and suspend_noirq do not disable it again?
Yes, still pre-existing as you say. It goes into the same net series as
the dangling rx_cbs/tx_cbs which make the second teardown a double free.
I will check the clock counts there too.
Technical Details
Message-ID:
<c8c99d1dd1e07a2467bc334f08fe920e@tipi-net.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346620-linux-kernel-netdev=dewy.ruReferences:
<20261013-nb-genet-mtu-nn-v2-v5-7-076b6fc240be@tipi-net.de> <179198777717.434549.10480959692013383148@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346620-linux-kernel-netdev=dewy.ru From: nb@tipi-net.de (Nicolai Buchwitz) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v5 7/8] net: bcmgenet: allow the MTU to be changed Date: Thu, 15 Oct 2026 10:55:28 +0200 Organization: Usenet Network Message-ID: <c8c99d1dd1e07a2467bc334f08fe920e@tipi-net.de> References: <20261013-nb-genet-mtu-nn-v2-v5-7-076b6fc240be@tipi-net.de> <179198777717.434549.10480959692013383148@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2489713"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ieTbqft5NkZVz3wMAT0T0bwKEVc= sha256:6EfBdWZ9NdMIWSbuY971Y8VhySA9wV0hGNUSMx7y+d0= sha1:45dGBnJ9E/xKW9CVtxfylZAfV1g= sha256:wVSSZhZNXL37/dZ96v49ZUXv0Xruw/43B/NSQ7OxBnQ= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id DBC9411028E; Thu, 15 Oct 2026 11:59:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -0.749 X-Spam-Status: No, score=-0.749 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=tipi-net.de X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xck1BBn4iyTl; Thu, 15 Oct 2026 11:59:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-346620-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=tipi-net.de X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 6833310F7E9; Thu, 15 Oct 2026 11:59:05 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 3059B31041; Thu, 15 Oct 2026 08:55:36 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93B2A48F854; Thu, 15 Oct 2026 08:55:35 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b="KN0R6K0K" X-Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6386B4968EF; Thu, 15 Oct 2026 08:55:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.13.80.246 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792054535; cv=none; b=sN3J2xJ5q62IREtLEzZApffbG5OnqCDobml3mEqBQb97Q+3XYyR83R5Q3x57L4UGVRvITsMv+Gd8x82aP0DIVMtdrCTpgyMAqJG7aJEqkxrkdIytjbh8AK/2z5XF9HOOUb6IiHB/+YtVfRDyBbIfv1Ts2hg9eVOXgxUsJHxgACw= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792054535; c=relaxed/simple; bh=Dq8hNNTdD+OCzU35HdaLKsYBRmRXoxYu/y1uvP4oatU=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type; b=l9Cs1cr88XkLc29VRFEAy1Ot+RSBHVBcMtwI0qQOerJYRMoz66kz8D8GEAzFeFnCOfhOj+4JyJRkLGA6c5yBliSn0SL7jVwAX3q2MROvl1bJ3qNdhOtHEfA3B2jkL6DQZq2AgmUaywjSyHbQ4a/DptSyxihfnY2evrFTxoWnTs4= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b=KN0R6K0K; arc=none smtp.client-ip=194.13.80.246 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de X-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C3BE9A1560; Thu, 15 Oct 2026 10:55:28 +0200 (CEST) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim; t=1792054530; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=CiCejlKL6IOFzq5NQXFhwejWWOoTsftHyAMtOfjwKOc=; b=KN0R6K0KbUK2Y1HxUp2sdr304/2a0/McrhguJdcq+fq/+CfaC7fx3ZkLFvh9eVJ+d6gWma JkTftfH6twjzHBiSWLFBiIcGuerNRtHaiV1UARWDwIQLYHpMMO7Qdb+Z3BxTYDduRl/xE7 AoTaVJpBxq6UOk5EVCAV7IRjK4TWEt+x4H2/1mbNmjrIyWo2bc6UK1SHSABINJ0diUvcws x4rb4Lqr+d2AzVns/YDVG1gA16mFk4ZqkQGKfdttvRmT1/EQDlREuVi0ahBS4LlW3I/X5c FtGKITa/KrnLAJAURJ2abcPfD/B5CPLXu/9qQaX+x/fI6w5NcMXMbtvSR805sA== X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-Cc: opendmb@gmail.com, florian.fainelli@broadcom.com, bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dave.stevenson@raspberrypi.com, justin.chen@broadcom.com, pierremarinleclercq88@gmail.com, f.fainelli@gmail.com X-In-Reply-To: <179198777717.434549.10480959692013383148@kernel.org> X-Sender: nb@tipi-net.de X-Last-TLS-Session-Version: TLSv1.3