From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795450598; b=F29PpU+cR85ZTec1IYfr1HWQKuDvCS8Di26VQxa0hbS+UwXqhkZmrwDG56njacMPdLIF MXiOCTyOiAnQ8hvrGeZdYh9hhbxS47PbZtMUW4HORL+AMtlhZJsu1cb2zhc3v2UQZVC89 D7vZbdFZijc2kqSK/2IEuKMv7vUQ0DAu+fSfYUbiyBuid0TaTBPWZUVFW3A0benr9SLMl COGeIGxZiwyxuJCvSyh3E3DlnQNToFyuiYZoXV8TdyWBfbZyQHS0T2jIFNyBvx1Uzd1tu 7XkcgidjwixI94FKIStms2ZeJXBYxw2zOeWqJdey7ERAuRtppj3m30MvaOS8BOpoKeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795450598; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:Mime-Version: Content-Transfer-Encoding:Content-Type:Date:Message-Id:Cc:To:From: Subject:X-Mailer:References:In-Reply-To:X-Last-TLS-Session-Version; bh=7GWT3S/j9/aO65w9mriGtCTik2Oh9QF71C7dfpUwzzc=; b=qEX0Nvmw/+FaxU/ii7w76+1E0KCrT0xcW/WyVmnzEQ29hl7ohUv+LB9Yw0nz2eIFOppn BDft6Ghi1MaDOjT1ad+rw8tOY3LK5vE4kmF2/lhA54PkfQRYNJv6fgG/BAh80aGWuXBnD LtGcUVSg8Ofwhl1R5uYPOlLosbrXPvNUCVgsZ25DqINgKPuiZrCs/6tPUimzLMWD1blvy cfNb8ypbo/IgRpRUdWbrd4XVRwj1IHS/U/N3w8yr+6G/VCIBXkQHUa1Wpq0Ob1m6V//7j VQDhvYODJiEb6ZbSTNZdiZABuDCqPGgPe/WSeY+i9jHroV3JnN4njsF8oOOyW+wqpog== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=eIYvsQdJ; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1423606A31E for ; Mon, 23 Nov 2026 16:16:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F1423606A31E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=eIYvsQdJ Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 68F681A179E; Mon, 23 Nov 2026 16:16:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 24996601E1; Mon, 23 Nov 2026 16:16:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 40D5411E6A6F4; Mon, 23 Nov 2026 17:16:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795450590; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=7GWT3S/j9/aO65w9mriGtCTik2Oh9QF71C7dfpUwzzc=; b=eIYvsQdJtYxWZ/9Mp4YVjUbwRpWXdnFJZDKQxAIIKnxVA225RdGHFg2r38CZr1c839J4sE ognTwskLHcLYue5GxHvYt6P3j1glKRAFdJEKuYRhmCdUPXE9GOfwWBFWCCyzjSBm7A23EN lw8W49H1OgRz849nmvj6O4t3ZgAkmFTFxUs3LxW2j6wvB5v29zN1ujaRebiHbMGnLCQyd8 5aPtk91XDGO7mSCIOVm0D6Exht214aw0S8Cyzt1lxjaBsPSiTepZ1ro5I0yl3gU4SMqxh8 /Appw7k/YtmYhjbo6pF8YplmJDsKvk+q/1Wd5KiTpoLCqURAB4F0I0+vP1nS7w== X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 23 Nov 2026 17:16:26 +0100 Message-Id: Cc: , , , , , , , , , , , , , , , To: From: =?utf-8?q?Th=C3=A9o_Lebrun?= Subject: Re: [PATCH net-next v7 3/3] net: macb: distribute evenly Tx SRAM segments X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261118-macb-set-channels-v7-3-2dbc00f686af@bootlin.com> <179537769513.3135.7979336425983650280@kernel.org> In-Reply-To: <179537769513.3135.7979336425983650280@kernel.org> X-Last-TLS-Session-Version: TLSv1.3 Hello netdev-bot+sashiko, On Sun Nov 22, 2026 at 9:01 PM CET, wrote: > 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 ca= se > you want to address the nit picks below when you respin. > > Low priority / nit picks for your consideration: > > - [Low] gem_sram_distribute_segments() in > drivers/net/ethernet/cadence/macb_main.c handles num_queues >=3D=E2=80= =A6 > - [Low] The comment above static_assert(MACB_MAX_QUEUES =3D=3D 8) in > gem_sram_distribute_segments()=E2=80=A6 > > -- > > net: macb: distribute evenly Tx SRAM segments > > This patch adds gem_sram_distribute_segments(). It programs the GEM > TXQSEGALLOC register so that the Tx SRAM segments reported in DCFG6 are > spread across the active queues as powers of two. It is called from > macb_init_hw() and macb_context_swap_end(), and it is enabled for the > zynqmp, versal and eyeq5 configs. > >> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethe= rnet/cadence/macb_main.c >> index 180da5d62f09a..5d382f0e4aec3 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) >> } >> } >> =20 >> +/* >> + * Distribute evenly available segments across active queues. The compu= tation >> + * 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 ar= e >> + * available. Take num_queues=3D4 and num_segments=3D2. > > [ ... ] > >> +static void gem_sram_distribute_segments(struct macb *bp) >> +{ >> + unsigned int num_segments, pow, remaining_segments, i; >> + unsigned int num_queues =3D bp->ctx->num_queues; >> + unsigned int num_advantaged_queues =3D 0; >> + u32 val =3D 0; >> + >> + if (!(bp->caps & MACB_CAPS_TXQSEGALLOC)) >> + return; >> + >> + num_segments =3D 1U << GEM_BFEXT(SEGMENTS_BIT_SIZE, gem_readl(bp, DCFG= 6)); >> + >> + /* When growing the max # of queues, make sure to return a u64 here an= d >> + * to write into GEM_TXQSEGALLOC_UPPER. >> + */ >> + static_assert(MACB_MAX_QUEUES =3D=3D 8); > > [Severity: Low] > This isn't a bug, but the comment talks about returning a u64. > gem_sram_distribute_segments() is a static void function. It builds its > result in the local u32 val and writes it with: > > gem_writel(bp, TXQSEGALLOC_LOWER, val); > > To support more than 8 queues, wouldn't the change be to widen (or split) > val and add a second write to TXQSEGALLOC_UPPER, rather than to change a > return type? Could the comment say that instead? Yes; we shall replace: When growing the max # of queues, make sure to return a u64 here and to write into GEM_TXQSEGALLOC_UPPER. By: When growing the max # of queues, make sure to write into TXQSEGALLOC_UPPER. For the full story for why this comment went stale: gem_sram_distribute_segments() used to return a u64 with the low 32 bits written into LOWER and the high 32 bits written into UPPER. That returned value was then writel() by the caller. But now that it can be called from two places, the writel() was moved into the function to avoid code duplication. >> + >> + /* pow=3D0 for all queues. ilog2(0) is dangerous. */ >> + if (num_queues >=3D num_segments) >> + goto writel; > > [Severity: Low] > What happens here when num_queues is strictly greater than num_segments? I don't know, but this is not our worry. This check has been introduced to deal with the equality case. >From my understanding, `num_queues > num_segments` is unreachable. And if `num_queues > num_segments` ever occurs, yes, we give each active queue 1 segment by doing a: writel(0, TXQSEGALLOC_LOWER) We will *not* introduce code to lower max_num_queues if num_segments is found to be lower than the runtime detected queue count from macb_probe_queues(). This would be useless. Thanks, -- Th=C3=A9o Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com