diff --git a/drivers/net/ethernet/freescale/enetc/ntmp.c b/drivers/net/ethernet/freescale/enetc/ntmp.c index 635032d24dc7..f71cad943424 100644 --- a/drivers/net/ethernet/freescale/enetc/ntmp.c +++ b/drivers/net/ethernet/freescale/enetc/ntmp.c @@ -146,11 +146,16 @@ static void ntmp_clean_cbdr(struct netc_cbdr *cbdr) static void ntmp_select_and_lock_cbdr(struct ntmp_user *user, struct netc_cbdr **cbdr) { - /* Currently only ENETC is supported, and it has only one command - * BD ring. - */ - *cbdr = &user->ring[0]; + for (int i = 0; i < user->cbdr_num; i++) { + *cbdr = &user->ring[i]; + if (mutex_trylock(&(*cbdr)->ring_lock)) + return; + } + /* If all command BD rings are locked, we need to select one of + * them and wait for it. + */ + *cbdr = &user->ring[raw_smp_processor_id() % user->cbdr_num]; mutex_lock(&(*cbdr)->ring_lock); }