From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794709572; b=QZa70xgD83/TukzonDlNEfnZr5kGqVCRuLV5w+cNynh+RgyXr1R2jPrQzewillQqK0Xh NIF/BoiHjF9VIe9622vsK/EPxUTAAhGouBef9/DMW4uLX2l4jMpMgS6BcElWJnQRMeeiv SVbDkP54BjdgFvk/ITzvlkQoJ3YeShIXErFNXGlQKkSNvYjlWnXF7GBg6BLVL4DBEOuzx 6UZUke7pSp6q08KeBN+fDkOWiOqvGL5a6m6ryj03DEqwAFLFXPxbs5GGW0rlF3FkkUaRL a5Gh26U9by1W5Htc5niaO89Jt7MfBUV09WVm3lntktRnCfSGzMRk0noIMDbOvw1v5cQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794709572; 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=M3P7ujHQBJpighPNvjdFs5yAEbsTyYNTue7OiVYVJQQ=; b=Rhp/m01JTz/PoP7gqUdoIb6Lu5bNbKzYrwXawgIPKerbLiW0MnlCBd00HW0LEL87kNwf mXkRKcwD2RpcdLcMtZ50EVaAWOuA9KYFSFGroyuzQ6ia88BDBW3zrrTJn7iH6y7VXX/Vu 1plKvcraBX3jb+qlCR4UmUrZ33zNy63BGGve2s4+xgv75vm2SERRODXCxynpHsObMwH5/ sbaaevHICwvESHsqY7znP+6YkYvHS9KTxR3RX5BoanWBr0yuakWd1QSJ6mVRC+wEzIYhi /6sdhPlYRpLfT+n1n5UFrX5gq0y0G+1djnpUQ/4big2bcaeOXRkVW4dC/RoDy4bhLkg== 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=EgEKYz0B; arc=none smtp.remote-ip=74.125.82.69 Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) (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 08D73606A89B for ; Sun, 15 Nov 2026 02:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 08D73606A89B 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=EgEKYz0B Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-1aa0fb7f157so2732138c88.0 for ; Sat, 14 Nov 2026 18:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1794709571; x=1795314371; 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=M3P7ujHQBJpighPNvjdFs5yAEbsTyYNTue7OiVYVJQQ=; b=EgEKYz0Bm+WCTC8JE7UBzWUGxO6HtTnCPy94pBDbjRzdfq5KFbSr4BcjfUDjDnmOXc tgYmATM3y6ACDdsvOijbF8imopDA1fxUBlAsBNf5xipjIjRx0xSsxtTWiLiGhDKcguhT kDtlF0JzClm/6AxgxRs2XhNH7vQLcKSf2tzx1SNlCfJCvjdfOollGNaiAmDc8XFFasp3 5ItI9wZ7Z0Xmbgfy8miBzYXeAAF4CgQkrT1oXZ1RPTXrD7eVNk6LG0MDMM68Tdv6pLv4 ShF4KYshTkY34y9FcXbwmbC0AoaKc2XjJHre+RUPDnP4eLgG5/9oNOjz4F/ytHz/PV9Z 5XPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794709571; x=1795314371; 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=M3P7ujHQBJpighPNvjdFs5yAEbsTyYNTue7OiVYVJQQ=; b=KAaqz8iBesbtvt0W0zRCFo6GH7DdZQZZW0wrRSoKgTm7BCMIUUlfJXksfx9T1bwmxs +oD2F/8lhB6lRV7rJvcuMX5IMFs4AYXeazl5watPfvY6iTq7DgsCvmFOXSaumRGlnYsO 2ohf6UhaVfJaRkRBehGSv5nrPmRWTyZl8Js3dD08mby5PnDMK9xW5QUUaBAyxXil98mO LS7nfnyCTf160T6NPVqLhVD1RCvWW9X6ZnNgZym0CQzLqSXF9aeK994uiFLvzTooe+Pf ZcREsxjt38njk3NaB66ivHW6Z9JeG07mFnS3A6WbOIlSqbBhAC+xtjQZAHhlrxE7Woum 6xIA== X-Forwarded-Encrypted: i=1; AL+hErEr3sp4bsni06clYubUFG9qmryHYH6fKxf505NDVohBhp+RaJkW1u4evCN+cY7lcLLQ8OJKyAEBd0M0szY=@vger.kernel.org X-Gm-Message-State: APuU4Z901eTZTwB0Gs8XkPbF1FSvaOXBNraVD1Wjxo6OT7pmGU0ze+sg Sk7D0+GRG9C+tibU+bg6MH9oOLScXiat6BYWMqFaLsz013lEew+EygcXv4ndT4vBMH6+AniMFjp OZln4Skdxg3GsuwpVc8xwc4T75w== X-Received: from dlbpt1.prod.google.com ([2002:a05:7022:e801:b0:1b0:ab15:db1d]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:4354:b0:14c:1f57:3e86 with SMTP id a92af1059eb24-1b50312160emr6123231c88.47.1794709570523; Sat, 14 Nov 2026 18:26:10 -0800 (PST) Date: Sun, 15 Nov 2026 02:26:03 +0000 In-Reply-To: <20261115022607.348112-1-almasrymina@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261115022607.348112-1-almasrymina@google.com> X-Mailer: git-send-email 2.56.0.611.g1030f0b940-goog Message-ID: <20261115022607.348112-3-almasrymina@google.com> Subject: [PATCH net-next v3 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, Weiming Shi , 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. Reviewed-by: Dragos Tatulea Signed-off-by: Mina Almasry --- 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 a230ecce9327d..405811b99589b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4192,7 +4192,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 6fa7b909b86e8..db60d1b5ea229 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; @@ -558,8 +560,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; } @@ -683,8 +685,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.611.g1030f0b940-goog