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

Frank Li Frank.Li at nxp.com
Thu Mar 19 09:41:40 AEDT 2026


From: Frank Li (AI-BOT) <frank.li at 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


More information about the Linuxppc-dev mailing list