Re: [PATCH net-next v3 4/6] net: devmem: always populate bind_dev and detach both devices on unregister

From
Paolo Abeni <pabeni@redhat.com>
Date
2026-11-17 14:40:16
Also in
linux-kselftest, lkml
Reply to
Mina Almasry, 2026-11-15
On 11/15/26 03:26, Mina Almasry wrote:
quoted hunk ↗ jump to hunk
@@ -252,21 +254,18 @@ void net_devmem_dev_unregister(struct net_device *dev)
  
  	xa_lock(&net_devmem_dmabuf_bindings);
  	xa_for_each(&net_devmem_dmabuf_bindings, xa_idx, binding) {
-		if (binding->direction == DMA_FROM_DEVICE) {
-			if (READ_ONCE(binding->map_dev) != dev ||
-			    xa_get_mark(&net_devmem_dmabuf_bindings, xa_idx,
-					NET_DEVMEM_BINDING_LIVE))
-				continue;
-		} else {
-			if (READ_ONCE(binding->bind_dev) == dev)
-				WRITE_ONCE(binding->bind_dev, NULL);
-			if (READ_ONCE(binding->map_dev) != dev)
-				continue;
-			WRITE_ONCE(binding->bind_dev, NULL);
+		if (READ_ONCE(binding->bind_dev) == dev) {
  			__xa_clear_mark(&net_devmem_dmabuf_bindings, xa_idx,
  					NET_DEVMEM_BINDING_LIVE);
+			if (xa_empty(&binding->bound_rxqs) ||
+			    !netif_is_queue_leasee(dev))
+				WRITE_ONCE(binding->bind_dev, NULL);
  		}
+		if (READ_ONCE(binding->map_dev) != dev)
+			continue;
  
+		__xa_clear_mark(&net_devmem_dmabuf_bindings, xa_idx,
+				NET_DEVMEM_BINDING_LIVE);
  		xa_unlock(&net_devmem_dmabuf_bindings);
Clashiko note here a synchronize_rcu()/synchronize_net() may be needed:

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115022607.348112-1-almasrymina@google.com

even if the lack of it is not catastrophic. Sounded quite
convincing to me.

/P

Thread (10 messages) 10 messages, 3 authors, last reply 15h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help