Thread (29 messages) flat view 29 messages, 5 authors, 2026-03-19

Re: [PATCH net-next 08/14] net: enetc: add multiple command BD rings support

From: Frank Li <Frank.Li@nxp.com>
Date: 2026-03-18 22:42:03
Also in: imx, linux-arm-kernel, linux-devicetree, lkml, netdev

From: Frank Li (AI-BOT) <frank.li@nxp.com>
+static struct netc_cbdr *netc_select_cbdr(struct ntmp_user *user)
+{
+	int cpu, i;
+
+	for (i = 0; i < user->cbdr_num; i++) {
+		if (spin_is_locked(&user->ring[i].ring_lock))
+			continue;
+
+		return &user->ring[i];
+	}
+
+	/* If all the command BDRs are busy now, we select
+	 * one of them, but need to wait for a while to use.
+	 */
+	cpu = smp_processor_id();
+
+	return &user->ring[cpu % user->cbdr_num];
+}
AI: spin_is_locked() is not reliable for lockless checks on all architectures.
Consider using spin_trylock() instead, or document why this racy check isi
acceptable here.
+	if (user->cbdr_num == 1)
+		cbdr = &user->ring[0];
+	else
+		cbdr = netc_select_cbdr(user);
AI: The special case for cbdr_num == 1 is redundant; netc_select_cbdr() handles
it correctly. Simplify to: cbdr = netc_select_cbdr(user);

Need owner do futher judgement

Frank
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help