πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23191

Re: [PATCH net-next v8 3/3] net: macb: distribute evenly Tx SRAM segments

#23191
From: netdev-bot+sashiko
Date: Thu, 26 Nov 2026 16:45
104 lines
11538 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] gem_sram_distribute_segments()
  (drivers/net/ethernet/cadence/macb_main.c) writes 0 to…

--

net: macb: distribute evenly Tx SRAM segments

This adds gem_sram_distribute_segments(), which programs the GEM
TXQSEGALLOC register so the Tx SRAM segments reported by DCFG6 are spread
across the active queues as powers of two. It runs from macb_init_hw() and
macb_context_swap_end(). The new MACB_CAPS_TXQSEGALLOC capability enables
it on zynqmp, versal and eyeq5.

> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index bcf77b2763448..b939a1391273b 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3319,6 +3319,69 @@ static u32 macb_dbw(struct macb *bp)
>  	}
>  }
>  
> +/*
> + * Distribute evenly available segments across active queues. The computation
> + * is complex because (1) segments are counted in powers of two and (2) a queue
> + * can only use up to 128 segments. There are four types of cases:

[ ... ]

> + *  - Sharing all segments is not doable because not enough segments are
> + *    available. Take num_queues=4 and num_segments=2.

[ ... ]

> +static void gem_sram_distribute_segments(struct macb *bp)
> +{
> +	unsigned int num_segments, pow, remaining_segments, i;
> +	unsigned int num_queues = bp->ctx->num_queues;
> +	unsigned int num_advantaged_queues = 0;
> +	u32 val = 0;
> +
> +	if (!(bp->caps & MACB_CAPS_TXQSEGALLOC))
> +		return;
> +
> +	num_segments = 1U << GEM_BFEXT(SEGMENTS_BIT_SIZE, gem_readl(bp, DCFG6));
> +
> +	/* When growing the max # of queues, make sure to write into
> +	 * TXQSEGALLOC_UPPER too.
> +	 */
> +	static_assert(MACB_MAX_QUEUES == 8);
> +
> +	/* pow=0 for all queues. ilog2(0) is dangerous. */
> +	if (num_queues >= num_segments)
> +		goto writel;

[Severity: Low]
Is the num_queues > num_segments case really handled here?

Each 3-bit GEM_TXQSEGALLOC_MASK() field encodes 2^v segments, so a field
cannot mean zero segments. Writing val = 0 gives every active queue
2^0 = 1 segment.

When num_queues == num_segments that fits exactly. When num_queues is
larger, the hardware is told to use num_queues segments on a buffer that
has only num_segments.

The block comment lists "num_queues=4 and num_segments=2" as one of the
four handled cases. In that example the code programs 4 x 1 = 4 segments
on a 2-segment SRAM.

Nothing seems to prevent this configuration. macb_set_channels() checks
the requested count only against max_num_queues:

    if (num_queues > bp->max_num_queues)
        return -EINVAL;

So on versal and eyeq5 (MACB_CAPS_QUEUE_DISABLE), ethtool -L can select
more queues than DCFG6 reports segments. The same applies at probe/open
time when all queues are active.

Should the active queue count be limited to num_segments on
MACB_CAPS_TXQSEGALLOC parts? If not, should the comment stop describing
this case as handled?

> +
> +	pow = min_t(unsigned int, ilog2(num_segments / num_queues), 7);
> +	remaining_segments = num_segments - num_queues * (1U << pow);

[ ... ]

> +writel:
> +	gem_writel(bp, TXQSEGALLOC_LOWER, val);
> +}

[ ... ]

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124-macb-set-channels-v8-0-770cf8e50e6d%40bootlin.com
Technical Details
Message-ID: <179571152787.3135.16045423533153390042@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372250-linux-kernel-netdev=dewy.ru
References: <20261124-macb-set-channels-v8-3-770cf8e50e6d@bootlin.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372250-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v8 3/3] net: macb: distribute evenly Tx SRAM segments
Date: Thu, 26 Nov 2026 16:45:27 +0000
Organization: Usenet Network
Message-ID: <179571152787.3135.16045423533153390042@kernel.org>
References: <20261124-macb-set-channels-v8-3-770cf8e50e6d@bootlin.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="511948"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:BKfoIpYeUHKKWXwcSz4BSa0VdG0= sha256:5AycqekqoPHv0M1tyyx7UwiQ8WXfjZcfiNKVxtf43kc=
	sha1:ulGTia4a9eSbYkaqkvV32Cyv3b4= sha256:m8gGNAVdibAh2z72bfmOaouM1u/g24A2JncV+LLWn+E=
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 D0D25125EEE; Thu, 26 Nov 2026 19:45:50 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 7s0-l4USN6Qb;
	Thu, 26 Nov 2026 19:45:47 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372250-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 2A77D125EED; Thu, 26 Nov 2026 19:45:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id F328E27DF5; Thu, 26 Nov 2026 16:45:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795711530;
	b=J/qaVJmtG+L0wUewSAmFJ5YabjZyaPGbrlSYCEHSl+12HUEzLyoCXLMvjrMcizoN6ObH
	 UkeGxjG4ly79pYCXLV0ZMopvTHZ6eKCdqdoy8MdJdeIgD1SoogpkrbTENN34yo+qN0Lf3
	 ucgUek/SStIEb9zCzVzDE/sLuHD3L9v0eXM2emtpuhQZnitCV1Ilzwrhev5F0s9UBxLSa
	 T/mCI8HFvXgfZNpL/az4FrhKCzrYEgBazoW8lSxIsKYJ5k9r0jXXg1pwKNYfpJ8xhoH3z
	 uz1mRn3iTiTGp1ULEUHQjIs8duhDc9MMcj26fvAM3UvYIMEw+Fv+gcFGwE9uxtS+INQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795711530;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=NZxf7xGAxFBnM2URAY0wf9DnF6jEM57f0c1j/Omx8GU=;
	b=yr9rHK+A6VFBLZkyv6Swb4wZ7JArpjQNHArJqWaVO+GXYYg7cTbwQCKoxwBSoPY3qJj8
	 sIVw7UNbyhdNRa45FdtmhZ+imX4C2wqpPkS8sYBpHRPwMrEZ8aqNfpQi8iVyZ/ruZx6fM
	 JZORX65wnQ72mj5XUQy9c6CZEfFcAo4Zpjrjr8WEIODrq34zfe5VT1obtOLCV7ORJLJro
	 hz8DN5gHANSN1qTpE7RTo3gonK6BrO1CvHmu+3d4VV8chWHudNox47j32Bbtjq9kjhIk4
	 88LclT+MCfVRiqfUrEvhOI5oZFesJ0JaWXZfHT+F/1qzXK3ufzHcdBF5Wp19SpUPtPA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V4o8O64h;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 98AA7606A68F;
	Thu, 26 Nov 2026 16:45:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V4o8O64h
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795711529;
	b=xcH/O6/wHowmSftTSZPxID5+zqEQRrjofCCHnLnRmbXieH9q3f/ZGu9AuuKIOi6nfPuU
	 m2z+r55+fQa30tndgSJtxE723KX1hzulsYonkmkO22RIK86D7KtG0EJ8eiUwxpBupuBjh
	 GRLecK+3o95V3Ax3Yx4RoT99216d85y7DYNybPmWxfYXLXpNNmBkdcV+Jp9tcafDQdM7Z
	 EoqRnFS/WD92pyQQLdci/SZg4yaKIZxC9KSTkkvqKbR2qdVpwFYEyxCBk7lRur41ibfXt
	 Dg1lykiJmjW1fh953s4Noi4o4b9tGDI+YJcIUb71jfOUK3SkPoL3H1+FQAixqT47wgA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795711529;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=NZxf7xGAxFBnM2URAY0wf9DnF6jEM57f0c1j/Omx8GU=;
	b=HKLWfaVwJuxJBAWU5GGTIkZ+/ozFSAs+T1xn2m7tAZS4JUnZhooY/AyhWJGEvowObN8v
	 ljdYc4+eLRwfiYE5zHGFzOxh9ThDkW/nzitqI8QHz5jcgDomrfRi54WbrylyBl9pJ++Nn
	 D90sNqJ8fzSbngePVPWMWgc3/fp/JR1vG2xPcTAGxRUplWOYso/guJ29880fY7tu0AHIt
	 aHuJsVX1L/SO9HphHhLyJMj1wFfUqWj024+PGQX/P2jw9hMO3Zv8ZdSEIZOcYr7hTToSK
	 l/y3QrI7vmJv68M0PF/ZdPM4nuoyfx8mY67GQ5IZTfwjzRWj4LyhaUA4iGz7hHgLmhg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V4o8O64h;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA86B606A32C;
	Thu, 26 Nov 2026 16:45:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 562511F000D2;
	Thu, 26 Nov 2026 16:45:28 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795711529;
	bh=NZxf7xGAxFBnM2URAY0wf9DnF6jEM57f0c1j/Omx8GU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=V4o8O64hwOssgLmJIEd49oAhAuLqc0hqnbnJFRvmo6LNSFQcI2TjOUu3MISL1Zt9F
	 XF6qKic7N+mzYC30zvy7uT637k16QBURiOde8EYUPaQjw0RcAK/5Fl9qDzPoSzauOb
	 Rbkpwty2a69sRl9bOIwN8SblyF1fGNZuZiOHA4glrFhlGI2YxgKTWKNCtTxrgn/N+D
	 G+OKxYHIA4q+omJba1Q6Vqb08OauuCwPwmf5z22t6mBTJ3rkEr15OU6O5035BPESpd
	 TPYmvFwskfah85BaNrqCblawkJvmYJxEmp0POF0L26j5JEfm/02NL6r7T1aAVmwuFA
	 tEREPS1UKWGpw==
X-Cc: conor.dooley@microchip.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 linux@armlinux.org.uk, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 nb@tipi-net.de, pvalerio@redhat.com, vladimir.kondratiev@mobileye.com,
 gregory.clement@bootlin.com, benoit.monin@bootlin.com,
 tawfik.bayouk@mobileye.com, thomas.petazzoni@bootlin.com,
 vineeth.karumanchi@amd.com
X-In-Reply-To: <20261124-macb-set-channels-v8-3-770cf8e50e6d@bootlin.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list