Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794117493; b=KHIg65oTaCkIEjuopJcI7L7NWr+D5EAJr/gP4/GN41Gwt6m1ktyoWV0mKZLEP6pOG9Tl e/yTX5y68j+YsMwl3whHY/J/USO3WGd9cLys1Ei+/HCtxtnuRRzhwC314Nvo2Nau5BZ2/ DQzfOpX+t4OmPczlz3gyODZtr0SlVS6CLow4e9vToJvnQY5rF7dS7vap7mIQ2rd3oSD46 VVJbW6ai6G1gqU5Zaaj/tmEUqZX8yAxX75TTeMuldUQZKY7RQV7UBIKPyzL7pMKzH/QsD RMbc5Uh0A5Z7MUqc8NSaxIWh162EiNrsumfMlHOO8em8XtEDdLR/i/TBXVhV90lhcGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794117493; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=6TwrnnSzyutgOWVoGMu7Abk0FI3MRNb9Mt64/iSS3gc=; b=1L/s/GQ8ZOMOJFzKP6KIx63yH4RYSzyD9RwvLTlKemnOzbrv4lRXKRquO4Trd5t1oljk kBjTTKqT54RtewMqChyrzb8PvCmQWSPAVDod1VL44UXu6cvX2LokrUqVwEsNfpbQhx3JX 3XNwS6iNsbQDPk5urbpLvI8rHDx9eNLKpStHNPXeSoXwwSTKR0EeaCt04StiKH7Ap8yeB tT26iQeU0RoSRxx+TMlyEr+n0vaX0gp61YBY87jHi2EYB9l6iCOTldSjDHL9lHrwj08FR CBqjuv8Ct3U0hb++4CWARoh7h5DTokS5UqroDWksQkjTmt3eJ6sbBtmM2jw3siLt//g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Z7v7WR9I; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E6BA606D801 for ; Sun, 8 Nov 2026 05:58:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0E6BA606D801 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Z7v7WR9I Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-36de26cb4b3so305251eec.1 for ; Sat, 07 Nov 2026 21:58:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1794117492; x=1794722292; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6TwrnnSzyutgOWVoGMu7Abk0FI3MRNb9Mt64/iSS3gc=; b=Z7v7WR9IQNjihAj1TrJzpN22FXZC0gOOWmovny/nT9fXCBEWtYVfGNV8e8bAbYcFV/ oCoMsGrQZbamUvljE1IlFYvrP2imIfrMfnS5d+fmdN2jLzgjlcqKoSnW5Dr6hmlUb066 sp3Iap2m2zhvD8GCmrTxvWL5iLX2A+MZr7i+rkI10kpi5KgxTUmFLTJXU78vcTQoyX1r WKfF54p9wkCZnwmLdObIJVVsBgdXXcmLzIZiGAVYOOWq76fPAh9bjv8pMhVQpDpEFXC4 L/WmGCcqq3GtVsDWxrihCYm2+Cp5JBaXmJ6x/vrsaVsvVW+ghguM16IiC4H2oJ5Aflqn rYOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794117492; x=1794722292; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6TwrnnSzyutgOWVoGMu7Abk0FI3MRNb9Mt64/iSS3gc=; b=Qi5xkKoO4Y+JJTorjJH64UddMLx+psNTrEhdA0Nf/zJyqrUt6sh9COOkuPHpcPaGHC XHtUEyqvsPjUr+bEWI9QRLSrJmQL/aWKHMKx5H8sMhg6ym2iTRUttOXP+eTF8KSJlmD+ 8fOpHaIy328Xmkr9acgX58a90FUJsma7fCjkK7XJ2zE38MTyOAZUtexQTjN8SNrHHRbg peiX4P+gtOqzjAeg5JE+Z5wW2ZHO8OixCYAox5xy7bpZWhkZBDSYWoAu19GOPyQk6BAO CSnSKD4WfqiU5uzeCvlZ1vXtez6+1l9YfbgbvpGPP7rFBovPUOwtY184z3jiicbG70kf rDYg== X-Forwarded-Encrypted: i=1; AL+hErFvg4W0rHCSMmYgqaK1+XJSUGIXxBzO2gYUyLGd8BB6HBAU89sPU96ZGUkVBcbfzSbqxRdpb6yPocg012W9jH0=@vger.kernel.org X-Gm-Message-State: APuU4Z/ae29rgTz27xG5xx7vlwN3B7Es6XiUtNdWvsEwxr0w0OUUmfGe 0ay0HLY1DVmejUn/DXY1Pl0YSjyTItaln7I3YrnO3z5PrvwbiPy5k1W3yukv2g9esGlIo40Beii HlWZZUivG6doEOXQjIZLQMlEdXA== X-Received: from dycw22.prod.google.com ([2002:a05:7300:2156:b0:36a:16ac:9308]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:c83:b0:35e:2c6:d46c with SMTP id 5a478bee46e88-372566144c7mr1581855eec.10.1794117491885; Sat, 07 Nov 2026 21:58:11 -0800 (PST) Date: Sun, 8 Nov 2026 05:58:05 +0000 In-Reply-To: <20261108055809.2122934-1-almasrymina@google.com> X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261108055809.2122934-1-almasrymina@google.com> X-Mailer: git-send-email 2.56.0.455.g6c5a503b38-goog Message-ID: <20261108055809.2122934-3-almasrymina@google.com> Subject: [PATCH net-next v2 2/6] net: devmem: rename binding dev and vdev to map_dev and bind_dev From: Mina Almasry To: netdev@vger.kernel.org Cc: Mina Almasry , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Borkmann , Nikolay Aleksandrov , David Wei , Stanislav Fomichev , Bobby Eshleman , Dragos Tatulea Content-Type: text/plain; charset="UTF-8" struct net_devmem_dmabuf_binding currently tracks two device pointers under the names 'dev' and 'vdev': - 'dev' is the physical net_device whose dma_dev holds the DMA mapping. - 'vdev' is the virtual net_device the user bound to when using leased queues. Rename 'dev' to 'map_dev' and 'vdev' to 'bind_dev' (typed as struct net_device *), and rename the matching local variable in netdev_nl_bind_tx_doit() from 'bind_dev' to 'map_dev' to match. No functional change. Signed-off-by: Mina Almasry Reviewed-by: Dragos Tatulea --- net/core/dev.c | 2 +- net/core/devmem.c | 38 ++++++++++++++++++++------------------ net/core/devmem.h | 17 +++++++++-------- net/core/netdev-genl.c | 31 +++++++++++++++---------------- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 3b60b15e2175e..4b8d656207d9c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4186,7 +4186,7 @@ static struct sk_buff *validate_xmit_unreadable_skb(struct sk_buff *skb, niov = netmem_to_net_iov(skb_frag_netmem(&shinfo->frags[0])); if (net_is_devmem_iov(niov) && (net_devmem_iov_binding(niov)->direction != DMA_TO_DEVICE || - READ_ONCE(net_devmem_iov_binding(niov)->dev) != dev)) + READ_ONCE(net_devmem_iov_binding(niov)->map_dev) != dev)) goto out_free; } diff --git a/net/core/devmem.c b/net/core/devmem.c index f164c90e90b3b..6446355e787d4 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -157,7 +157,7 @@ void __net_devmem_dmabuf_binding_free(struct work_struct *wq) binding->area.num_niovs, binding->free_count); kvfree(binding->area.niovs); - dev = net_devmem_lock_dev(&binding->dev, &dev_tracker); + dev = net_devmem_lock_dev(&binding->map_dev, &dev_tracker); net_devmem_dmabuf_binding_unmap(binding); xa_erase(&net_devmem_dmabuf_bindings, binding->id); net_devmem_unlock_dev(dev, &dev_tracker); @@ -227,13 +227,14 @@ void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding) rxq_idx = get_netdev_rx_queue_index(rxq); - if (netif_mp_close_rxq(binding->dev, rxq_idx, &mp_params)) + if (netif_mp_close_rxq(binding->map_dev, rxq_idx, &mp_params)) busy = true; } - if (binding->direction == DMA_FROM_DEVICE && binding->dev && !busy) { + if (binding->direction == DMA_FROM_DEVICE && binding->map_dev && + !busy) { net_devmem_dmabuf_binding_unmap(binding); - WRITE_ONCE(binding->dev, NULL); + WRITE_ONCE(binding->map_dev, NULL); } percpu_ref_kill(&binding->ref); @@ -252,16 +253,16 @@ 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->dev) != dev || + 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->vdev) == dev) - WRITE_ONCE(binding->vdev, NULL); - if (READ_ONCE(binding->dev) != dev) + if (READ_ONCE(binding->bind_dev) == dev) + WRITE_ONCE(binding->bind_dev, NULL); + if (READ_ONCE(binding->map_dev) != dev) continue; - WRITE_ONCE(binding->vdev, NULL); + WRITE_ONCE(binding->bind_dev, NULL); __xa_clear_mark(&net_devmem_dmabuf_bindings, xa_idx, NET_DEVMEM_BINDING_LIVE); } @@ -270,7 +271,7 @@ void net_devmem_dev_unregister(struct net_device *dev) if (!netif_is_queue_leasee(dev)) net_devmem_dmabuf_binding_unmap(binding); xa_lock(&net_devmem_dmabuf_bindings); - WRITE_ONCE(binding->dev, NULL); + WRITE_ONCE(binding->map_dev, NULL); } xa_unlock(&net_devmem_dmabuf_bindings); } @@ -304,7 +305,8 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx, } struct net_devmem_dmabuf_binding * -net_devmem_bind_dmabuf(struct net_device *dev, void *vdev, +net_devmem_bind_dmabuf(struct net_device *map_dev, + struct net_device *bind_dev, struct device *dma_dev, enum dma_data_direction direction, unsigned int dmabuf_fd, unsigned int niov_shift, @@ -332,14 +334,14 @@ net_devmem_bind_dmabuf(struct net_device *dev, void *vdev, return ERR_CAST(dmabuf); binding = kzalloc_node(sizeof(*binding), GFP_KERNEL, - dev_to_node(&dev->dev)); + dev_to_node(&map_dev->dev)); if (!binding) { err = -ENOMEM; goto err_put_dmabuf; } - binding->dev = dev; - binding->vdev = vdev; + binding->map_dev = map_dev; + binding->bind_dev = bind_dev; write_pnet(&binding->net, sock_net(nl_sk)); binding->uid = sk_uid(nl_sk); binding->niov_shift = niov_shift; @@ -559,8 +561,8 @@ struct net_devmem_dmabuf_binding *net_devmem_get_binding(struct sock *sk, */ dst_dev = dst_dev_rcu(dst); if (unlikely(!dst_dev) || - unlikely(dst_dev != READ_ONCE(binding->dev) && - dst_dev != READ_ONCE(binding->vdev))) { + unlikely(dst_dev != READ_ONCE(binding->map_dev) && + dst_dev != READ_ONCE(binding->bind_dev))) { err = -ENODEV; goto out_unlock; } @@ -684,8 +686,8 @@ static void mp_dmabuf_devmem_uninstall(void *mp_priv, if (xa_empty(&binding->bound_rxqs)) { if (!rxq->lease) net_devmem_dmabuf_binding_unmap(binding); - ASSERT_EXCLUSIVE_WRITER(binding->dev); - WRITE_ONCE(binding->dev, NULL); + ASSERT_EXCLUSIVE_WRITER(binding->map_dev); + WRITE_ONCE(binding->map_dev, NULL); } break; } diff --git a/net/core/devmem.h b/net/core/devmem.h index c0aaba0041ff6..9dcb629e10bfd 100644 --- a/net/core/devmem.h +++ b/net/core/devmem.h @@ -22,14 +22,13 @@ struct net_devmem_dmabuf_binding { struct dma_buf_attachment *attachment; struct sg_table *sgt; /* Physical NIC that does the actual DMA for this binding. Set at bind - * time and cleared to NULL under netdev_lock(dev). + * time and cleared to NULL under netdev_lock(map_dev). */ - struct net_device *dev; - /* Opaque cookie identifying the virtual device (e.g. netkit) the user - * called bind-tx on. Used only for pointer comparison via READ_ONCE() - * and cleared with WRITE_ONCE() on unregistration. Never dereferenced. + struct net_device *map_dev; + /* Device the user called bind-rx or bind-tx on. Set at bind time and + * cleared to NULL on unregistration. */ - void *vdev; + struct net_device *bind_dev; possible_net_t net; kuid_t uid; /* Serialize net_devmem_dmabuf_binding_unmap() on attachment and sgt */ @@ -91,7 +90,8 @@ struct net_devmem_dmabuf_binding { #if defined(CONFIG_NET_DEVMEM) void __net_devmem_dmabuf_binding_free(struct work_struct *wq); struct net_devmem_dmabuf_binding * -net_devmem_bind_dmabuf(struct net_device *dev, void *vdev, +net_devmem_bind_dmabuf(struct net_device *map_dev, + struct net_device *bind_dev, struct device *dma_dev, enum dma_data_direction direction, unsigned int dmabuf_fd, unsigned int niov_shift, @@ -171,7 +171,8 @@ static inline void net_devmem_net_iov_dec_ref(struct net_iov *niov) } static inline struct net_devmem_dmabuf_binding * -net_devmem_bind_dmabuf(struct net_device *dev, void *vdev, +net_devmem_bind_dmabuf(struct net_device *map_dev, + struct net_device *bind_dev, struct device *dma_dev, enum dma_data_direction direction, unsigned int dmabuf_fd, diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 2826f7e328340..962d7a8c75e9a 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -1195,9 +1195,8 @@ netdev_find_netmem_tx_dev(struct net_device *dev) int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info) { struct net_devmem_dmabuf_binding *binding; - struct net_device *bind_dev; + struct net_device *netdev, *map_dev; struct netdev_nl_sock *priv; - struct net_device *netdev; struct device *dma_dev; u32 ifindex, dmabuf_fd; struct sk_buff *rsp; @@ -1245,27 +1244,27 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info) goto err_unlock_netdev; } - bind_dev = netdev_find_netmem_tx_dev(netdev); - if (!bind_dev) { + map_dev = netdev_find_netmem_tx_dev(netdev); + if (!map_dev) { err = -EOPNOTSUPP; NL_SET_ERR_MSG(info->extack, "No DMA-capable device found for netmem TX"); goto err_unlock_netdev; } - if (bind_dev != netdev) - netdev_lock(bind_dev); + if (map_dev != netdev) + netdev_lock(map_dev); - dma_dev = netdev_queue_get_dma_dev(bind_dev, 0, NETDEV_QUEUE_TYPE_TX); + dma_dev = netdev_queue_get_dma_dev(map_dev, 0, NETDEV_QUEUE_TYPE_TX); - binding = net_devmem_bind_dmabuf(bind_dev, - bind_dev != netdev ? netdev : NULL, + binding = net_devmem_bind_dmabuf(map_dev, + map_dev != netdev ? netdev : NULL, dma_dev, DMA_TO_DEVICE, dmabuf_fd, PAGE_SHIFT, priv, NETLINK_CB(skb).sk, info->extack); if (IS_ERR(binding)) { err = PTR_ERR(binding); - goto err_unlock_bind_dev; + goto err_unlock_map_dev; } /* rsp was allocated large enough */ @@ -1273,16 +1272,16 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info) genlmsg_end(rsp, hdr); - if (bind_dev != netdev) - netdev_unlock(bind_dev); + if (map_dev != netdev) + netdev_unlock(map_dev); netdev_unlock(netdev); mutex_unlock(&priv->lock); return genlmsg_reply(rsp, info); -err_unlock_bind_dev: - if (bind_dev != netdev) - netdev_unlock(bind_dev); +err_unlock_map_dev: + if (map_dev != netdev) + netdev_unlock(map_dev); err_unlock_netdev: netdev_unlock(netdev); err_unlock_sock: @@ -1476,7 +1475,7 @@ void netdev_nl_sock_priv_destroy(struct netdev_nl_sock *priv) mutex_lock(&priv->lock); list_for_each_entry_safe(binding, temp, &priv->bindings, list) { - dev = net_devmem_lock_dev(&binding->dev, &dev_tracker); + dev = net_devmem_lock_dev(&binding->map_dev, &dev_tracker); net_devmem_unbind_dmabuf(binding); net_devmem_unlock_dev(dev, &dev_tracker); } -- 2.56.0.455.g6c5a503b38-goog