From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796425836; b=NwCKey47doth9JpByVKqUWxNPQ0CFFczykqBcnG11/g4PCjxZP2yuAzfDVULhZ/cFowP OJIGYNNkIaBJX43Cf+v0SDLWKtAMCVAfFJRnVkkFfuxx87K/70DRHffEulwyQPT+Ywz0O p6Ep8zqTzZosXgaJjOIu3v1QDPMuXdWH9vy438HgYdkYZbJQ8uU6N4mKcU7U1POBbaHcx Q5aHZwsQFgZqB80LYayNSY38G61Y+xJ4qNSZqCOqdcFtKGeJ/Zl1lBQAThsjRBYa39+qI EWt18XacSXyHWwAi+JNbewP/jCCrlLgo4X2y5sQIOaYIQit9iBx2bl2BTJjPgzz2mZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796425836; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=KTRP0W1shRcXIMIjgBKg3D6uCuco1lUFCSE52ETni/0=; b=vJb86kl3F3DXB7cImKkSAIrKVv2aDSF48hqzypV81UwULwDPW/L2DFF8foO60e4hH8tW RF5Dm33mpAvjrzr50rnd+4raidtUf4KKbwkS1BW9Mb0PtEXZ/PH7xqXmAOc8fjTK//4gD HZ6FzeKKSe4TXO714B84WY3ZleyfoRkdRivLMQ2WNYubWtLujBzHo0nlk9DWKyNAo39S/ y0ML5TufTr6dGXfCqIWyQTiMDNqN80GxfeToSleNtbx1fnNSRYRHSynk/8sojYkhRDe81 XvkHcIiEpQpXzgItGPnz3Gmptb482TtkQ0T5/SaaDJDWlOxWm81Cb4j0I8kUDb/T4zw== 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=klHmX5jf; arc=none smtp.remote-ip=209.85.161.69 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.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 A31FD606A333 for ; Fri, 4 Dec 2026 23:10:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A31FD606A333 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=klHmX5jf Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-71b16de75bbso904175eaf.2 for ; Fri, 04 Dec 2026 15:10:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796425835; x=1797030635; 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=KTRP0W1shRcXIMIjgBKg3D6uCuco1lUFCSE52ETni/0=; b=klHmX5jfz4bbU++chZtsTQC+wcSWZHu4ZVps2ngLKrvcXyahSzfMQyOwL1QYYuWHf4 7GI+kX0m0dvpyyZNhsWuo8bj5V3WJeI84c8I6UAc/RXBhyZ4emrU09wDWCQ2ZiYpAo+D XdVzPgz2i5fY5cjwJDl/P7e255Ts8QOoKHeKChPfdjRb+pd6BAl4crplqgTX3vZigG5p bK1PSaahhuahaOUArzRCmmzzfAOdS3UJH+IjoSsxCF9FcEs9ewgavoS9Ez6YGyBlnjlv O4hH8rX689F8Xef51gGeRFEKi3IxDT0shVfrK3T6QzdPdrFEZMoFRfC+sKhfE7A9DhDG drFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796425835; x=1797030635; 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=KTRP0W1shRcXIMIjgBKg3D6uCuco1lUFCSE52ETni/0=; b=G61iDTtefuizTUk70etaDxyZ3WW1GPlvC9H0YOY2Z+p4YKSmo7pzDkyDP1ZqHtHiYL GAzUuP93RaFsb45Askyr/W8YQFbFXD4jTmdmJFzBA72PzJY0F2FS7GJZWRu/Z72aTW2L ah2Emo/l43fGAbCyH9Dymmy2RhxpPH5RUOKw+Uby3kbZgg4TQtGEM6vQICkT+8dUOIMk fwnTBqOnspY8tO9jKWVmn9zJwl4J41BkNP/4yETggz0w+KphYecxmUX+OLSd++h3Qx/7 zl41Y0dVpcVbFok8NVKPefpm3Eoaz5YmBz3o/U6KQlUHfiXuK/MM8Ba6xAEHNw9sWVjX Z3zQ== X-Gm-Message-State: APuU4Z8wijpy5YkWolEssuXLbz0vw1sUHTaGnwyxS9dkLjgtQeyHz4mF O/UPxGkwhlhYWuxV91Qd50F+VkrDHjV7bh6AMTDzXFFS4Kbn4kw1xn+lx2evXNRk5K8IWy0aLuC 04JC2lFxO+p1dw7GEKzRecyLfq++gPaMFJjz+GYc0zyoHBcBnCPryiQGjfpwPLLN4HXNYw7RCVy aCdSrm4+npexDqGkqJwN4Mi9ofwW9ZW7t6mWrN4M4vKtjNOfO5KR4wpY6WCZ80Fmk= X-Received: from ilbeu3-n1.prod.google.com ([2002:a05:6e02:2f03:10b0:54e:91a3:243d]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:c5d4:10b0:71b:e3e7:82c8 with SMTP id 006d021491bc7-71bf20a0644mr2445507eaf.46.1796425834297; Fri, 04 Dec 2026 15:10:34 -0800 (PST) Date: Fri, 4 Dec 2026 23:10:27 +0000 In-Reply-To: <20261204231030.3815575-1-almasrymina@google.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261204231030.3815575-1-almasrymina@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261204231030.3815575-4-almasrymina@google.com> Subject: [PATCH net-next v5 3/6] net: devmem: resolve leased RX queues to physical device on bind From: Mina Almasry To: netdev@vger.kernel.org Cc: Mina Almasry , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Shuah Khan , linux-kselftest@vger.kernel.org, Stanislav Fomichev , Bobby Eshleman , Nikolay Aleksandrov , Daniel Borkmann , David Wei , Pavel Begunkov , Jens Axboe , Weiming Shi , io-uring@vger.kernel.org, Jesper Dangaard Brouer , Ilias Apalodimas Content-Type: text/plain; charset="UTF-8" Currently, netdev_nl_bind_rx_doit() stores the virtual leasee (e.g. netkit) in binding->dev and its virtual RX queues in binding->bound_rxqs, relying on netif_mp_{open,close}_rxq() to redirect each queue operation to the underlying physical device. This breaks netdev unregistration for leased RX bindings in several ways: - When the physical device unregisters first, dev_memory_provider_uninstall(phys_dev) passes phys_rxq to mp_dmabuf_devmem_uninstall(), which searches binding->bound_rxqs for virt_rxq, fails to match, and leaves the dmabuf mapped. - When the virtual device unregisters first, mp_dmabuf_devmem_uninstall() skips unmapping whenever rxq->lease is set, leaking the DMA mapping on the physical device until the netlink socket closes. - Leaving rxq->mp_params clearing to each memory provider (done by io_pp_uninstall() but not mp_dmabuf_devmem_uninstall()) causes the cascaded netif_rxq_cleanup_unlease() on physical device unregister to invoke ->uninstall() a second time on an already-uninstalled queue. - netdev_nl_sock_priv_destroy() locks binding->dev (virt_dev) while physical device teardown locks phys_dev, leaving unmap/unbind unsynchronized across the two lock domains. - Calling netdev_queue_get_dma_dev() and netif_mp_open_rxq() without holding netdev_lock(phys_dev) continuously leaves a TOCTOU window where phys_dev can begin unregistering mid-bind. Resolve leased RX queues to their physical net_device and physical rx_queue indices once at bind-rx time, holding netdev_lock(virt_dev) -> netdev_lock(phys_dev) continuously across DMA device lookup, dmabuf mapping, and queue opens: - Store phys_dev in binding->dev and phys_rxq in binding->bound_rxqs so RX teardown paths (dev_memory_provider_uninstall(), netif_rxq_cleanup_unlease(), netdev_nl_sock_priv_destroy(), and net_devmem_dev_unregister()) serialize on netdev_lock(phys_dev). - Reject direct bind-rx on leased-out physical queues, unleased or mixed virtual queues, and queues spanning multiple physical devices up front in netdev_nl_resolve_rx_phys(), and reject any queue returning a NULL DMA device in netdev_nl_get_dma_dev(). - Expose __netdev_queue_get_dma_dev() and __netif_mp_{open,close}_rxq() internally so devmem operates directly on the already-validated and locked phys_dev, while netif_mp_{open,close}_rxq() continues to proxy for io_uring/zcrx. - Clear rxq->mp_params centrally in __netif_mp_uninstall_rxq() (dropping the now-redundant clearing from io_pp_uninstall()), pass phys_rxq to __netif_mp_uninstall_rxq() in netif_rxq_cleanup_unlease(), and drop the !rxq->lease guard in mp_dmabuf_devmem_uninstall() so virtual-first, physical-first, and same-batch teardown all unmap once bound_rxqs empties. These issues were identified by code inspection and selftest development while extending devmem unregister teardown to leased queues; they have not been observed in production or tested on real hardware. Verified with netdevsim and netkit selftests in nl_netdev.py and nk_qlease.py. Signed-off-by: Mina Almasry --- v4 -> v5: - Drop v4's dual-device bind_dev/map_dev split in favour of resolving leased RX queues to phys_dev and phys_rxq at bind-rx time while holding netdev_lock(virt_dev) -> netdev_lock(phys_dev) continuously (Willem). - Clear rxq->mp_params centrally in __netif_mp_uninstall_rxq(). --- io_uring/zcrx.c | 4 -- net/core/dev.h | 10 ++- net/core/devmem.c | 36 +++++----- net/core/netdev-genl.c | 130 +++++++++++++++++++++++++++++++++---- net/core/netdev_queues.c | 4 +- net/core/netdev_rx_queue.c | 35 ++++++---- 6 files changed, 166 insertions(+), 53 deletions(-) diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c index 21e042b3ccb97..20597bfa146d6 100644 --- a/io_uring/zcrx.c +++ b/io_uring/zcrx.c @@ -1459,15 +1459,11 @@ static int io_pp_nl_fill(void *mp_priv, struct sk_buff *rsp, static void io_pp_uninstall(void *mp_priv, struct netdev_rx_queue *rxq) { - struct pp_memory_provider_params *p = &rxq->mp_params; struct io_zcrx_ifq *ifq = mp_priv; guard(mutex)(&ifq->pp_lock); io_zcrx_unmap_areas(ifq); io_zcrx_drop_netdev(ifq); - - p->mp_ops = NULL; - p->mp_priv = NULL; } static const struct memory_provider_ops io_uring_pp_zc_ops = { diff --git a/net/core/dev.h b/net/core/dev.h index 4e9e8cd156977..183c580006b54 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -119,12 +119,16 @@ bool netif_rxq_has_mp(struct net_device *dev, unsigned int rxq_idx); bool netif_rxq_is_leased(struct net_device *dev, unsigned int rxq_idx); bool netif_is_queue_leasee(const struct net_device *dev); +struct device *__netdev_queue_get_dma_dev(struct net_device *dev, + unsigned int idx); +int __netif_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx, + const struct pp_memory_provider_params *p, + struct netlink_ext_ack *extack); +int __netif_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx, + const struct pp_memory_provider_params *old_p); void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq, const struct pp_memory_provider_params *p); -void netif_rxq_cleanup_unlease(struct netdev_rx_queue *phys_rxq, - struct netdev_rx_queue *virt_rxq); - /* netdev management, shared between various uAPI entry points */ struct netdev_name_node { struct hlist_node hlist; diff --git a/net/core/devmem.c b/net/core/devmem.c index f00c1d8fcc2d2..3a894ff06b32b 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -219,21 +219,24 @@ void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding) if (binding->list.next) list_del(&binding->list); - xa_for_each(&binding->bound_rxqs, xa_idx, rxq) { - const struct pp_memory_provider_params mp_params = { - .mp_priv = binding, - .mp_ops = &dmabuf_devmem_ops, - }; - - rxq_idx = get_netdev_rx_queue_index(rxq); - - if (netif_mp_close_rxq(binding->dev, rxq_idx, &mp_params)) - busy = true; - } + if (READ_ONCE(binding->dev)) { + xa_for_each(&binding->bound_rxqs, xa_idx, rxq) { + const struct pp_memory_provider_params mp_params = { + .mp_priv = binding, + .mp_ops = &dmabuf_devmem_ops, + }; + + rxq_idx = get_netdev_rx_queue_index(rxq); + + if (__netif_mp_close_rxq(binding->dev, rxq_idx, + &mp_params)) + busy = true; + } - if (binding->direction == DMA_FROM_DEVICE && binding->dev && !busy) { - net_devmem_dmabuf_binding_unmap(binding); - WRITE_ONCE(binding->dev, NULL); + if (binding->direction == DMA_FROM_DEVICE && !busy) { + net_devmem_dmabuf_binding_unmap(binding); + WRITE_ONCE(binding->dev, NULL); + } } percpu_ref_kill(&binding->ref); @@ -296,7 +299,7 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx, if (err) return err; - err = netif_mp_open_rxq(dev, rxq_idx, &mp_params, extack); + err = __netif_mp_open_rxq(dev, rxq_idx, &mp_params, extack); if (err) xa_erase(&binding->bound_rxqs, xa_idx); @@ -693,8 +696,7 @@ static void mp_dmabuf_devmem_uninstall(void *mp_priv, xa_erase(&binding->bound_rxqs, xa_idx); if (xa_empty(&binding->bound_rxqs)) { - if (!rxq->lease) - net_devmem_dmabuf_binding_unmap(binding); + net_devmem_dmabuf_binding_unmap(binding); ASSERT_EXCLUSIVE_WRITER(binding->dev); WRITE_ONCE(binding->dev, NULL); } diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 87dac9c5e84c3..5150e8b0a0c57 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -1003,6 +1003,91 @@ static int netdev_nl_read_rxq_bitmap(struct genl_info *info, return 0; } +static int netdev_nl_resolve_rx_phys(struct net_device *netdev, + unsigned long *rxq_bitmap, + struct net_device **phys_dev_out, + unsigned long **phys_bitmap_out, + struct netlink_ext_ack *extack) +{ + struct net_device *phys_dev = NULL; + unsigned long *phys_bitmap; + u32 rxq_idx; + int err; + + if (!netif_is_queue_leasee(netdev)) { + for_each_set_bit(rxq_idx, rxq_bitmap, + netdev->real_num_rx_queues) { + if (netif_rxq_is_leased(netdev, rxq_idx)) { + NL_SET_ERR_MSG(extack, + "rx queue leased to a virtual netdev"); + return -EOPNOTSUPP; + } + } + *phys_dev_out = netdev; + *phys_bitmap_out = rxq_bitmap; + return 0; + } + + for_each_set_bit(rxq_idx, rxq_bitmap, netdev->real_num_rx_queues) { + struct netdev_rx_queue *rxq = __netif_get_rx_queue(netdev, + rxq_idx); + + if (!rxq->lease || !rxq->lease->dev->dev.parent) { + NL_SET_ERR_MSG(extack, + "rx queue belongs to a virtual netdev"); + return -EOPNOTSUPP; + } + if (phys_dev && rxq->lease->dev != phys_dev) { + NL_SET_ERR_MSG(extack, + "Cannot bind queues from different physical devices"); + return -EOPNOTSUPP; + } + phys_dev = rxq->lease->dev; + } + + if (!phys_dev) + return -EINVAL; + + if (!netdev_lock_if_alive(phys_dev)) { + NL_SET_ERR_MSG(extack, "Device is being unregistered"); + return -ENODEV; + } + + if (!netif_device_present(phys_dev)) { + err = -ENODEV; + goto err_unlock_phys; + } + + phys_bitmap = bitmap_zalloc(phys_dev->real_num_rx_queues, GFP_KERNEL); + if (!phys_bitmap) { + err = -ENOMEM; + goto err_unlock_phys; + } + + for_each_set_bit(rxq_idx, rxq_bitmap, netdev->real_num_rx_queues) { + struct netdev_rx_queue *phys_rxq = + __netif_get_rx_queue(netdev, rxq_idx)->lease; + unsigned int phys_rxq_idx = get_netdev_rx_queue_index(phys_rxq); + + if (WARN_ON_ONCE(phys_rxq_idx >= + phys_dev->real_num_rx_queues)) { + err = -ERANGE; + goto err_free_bitmap; + } + bitmap_set(phys_bitmap, phys_rxq_idx, 1); + } + + *phys_dev_out = phys_dev; + *phys_bitmap_out = phys_bitmap; + return 0; + +err_free_bitmap: + bitmap_free(phys_bitmap); +err_unlock_phys: + netdev_unlock(phys_dev); + return err; +} + static struct device * netdev_nl_get_dma_dev(struct net_device *netdev, unsigned long *rxq_bitmap, struct netlink_ext_ack *extack) @@ -1013,8 +1098,11 @@ netdev_nl_get_dma_dev(struct net_device *netdev, unsigned long *rxq_bitmap, for_each_set_bit(rxq_idx, rxq_bitmap, netdev->real_num_rx_queues) { struct device *rxq_dma_dev; - rxq_dma_dev = netdev_queue_get_dma_dev(netdev, rxq_idx, - NETDEV_QUEUE_TYPE_RX); + rxq_dma_dev = __netdev_queue_get_dma_dev(netdev, rxq_idx); + if (!rxq_dma_dev) { + NL_SET_ERR_MSG(extack, "Device doesn't support DMA"); + return ERR_PTR(-EOPNOTSUPP); + } if (dma_dev && rxq_dma_dev != dma_dev) { NL_SET_ERR_MSG_FMT(extack, "DMA device mismatch between queue %u and %u (multi-PF device?)", rxq_idx, prev_rxq_idx); @@ -1031,11 +1119,11 @@ netdev_nl_get_dma_dev(struct net_device *netdev, unsigned long *rxq_bitmap, int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info) { struct net_devmem_dmabuf_binding *binding; + unsigned long *rxq_bitmap, *phys_bitmap; unsigned int niov_shift = PAGE_SHIFT; + struct net_device *netdev, *phys_dev; u32 ifindex, dmabuf_fd, rxq_idx; struct netdev_nl_sock *priv; - struct net_device *netdev; - unsigned long *rxq_bitmap; struct device *dma_dev; struct sk_buff *rsp; int err = 0; @@ -1104,23 +1192,29 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info) if (err) goto err_rxq_bitmap; - dma_dev = netdev_nl_get_dma_dev(netdev, rxq_bitmap, info->extack); + err = netdev_nl_resolve_rx_phys(netdev, rxq_bitmap, &phys_dev, + &phys_bitmap, info->extack); + if (err) + goto err_rxq_bitmap; + + dma_dev = netdev_nl_get_dma_dev(phys_dev, phys_bitmap, info->extack); if (IS_ERR(dma_dev)) { err = PTR_ERR(dma_dev); - goto err_rxq_bitmap; + goto err_unlock_phys; } - binding = net_devmem_bind_dmabuf(netdev, NULL, dma_dev, DMA_FROM_DEVICE, - dmabuf_fd, niov_shift, priv, - NETLINK_CB(skb).sk, info->extack); + binding = net_devmem_bind_dmabuf(phys_dev, NULL, dma_dev, + DMA_FROM_DEVICE, dmabuf_fd, niov_shift, + priv, NETLINK_CB(skb).sk, + info->extack); if (IS_ERR(binding)) { err = PTR_ERR(binding); - goto err_rxq_bitmap; + goto err_unlock_phys; } - for_each_set_bit(rxq_idx, rxq_bitmap, netdev->real_num_rx_queues) { - err = net_devmem_bind_dmabuf_to_queue(netdev, rxq_idx, binding, - info->extack); + for_each_set_bit(rxq_idx, phys_bitmap, phys_dev->real_num_rx_queues) { + err = net_devmem_bind_dmabuf_to_queue(phys_dev, rxq_idx, + binding, info->extack); if (err) goto err_unbind; } @@ -1132,6 +1226,11 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info) err = genlmsg_reply(rsp, info); + if (phys_dev != netdev) { + bitmap_free(phys_bitmap); + netdev_unlock(phys_dev); + } + bitmap_free(rxq_bitmap); netdev_unlock(netdev); @@ -1142,6 +1241,11 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info) err_unbind: net_devmem_unbind_dmabuf(binding); +err_unlock_phys: + if (phys_dev != netdev) { + bitmap_free(phys_bitmap); + netdev_unlock(phys_dev); + } err_rxq_bitmap: bitmap_free(rxq_bitmap); err_unlock: diff --git a/net/core/netdev_queues.c b/net/core/netdev_queues.c index c796957c07f4b..19ef14d58e045 100644 --- a/net/core/netdev_queues.c +++ b/net/core/netdev_queues.c @@ -6,8 +6,8 @@ #include "dev.h" -static struct device * -__netdev_queue_get_dma_dev(struct net_device *dev, unsigned int idx) +struct device *__netdev_queue_get_dma_dev(struct net_device *dev, + unsigned int idx) { const struct netdev_queue_mgmt_ops *queue_ops = dev->queue_mgmt_ops; struct device *dma_dev; diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c index e3ae99210caeb..dc918f6cd4eeb 100644 --- a/net/core/netdev_rx_queue.c +++ b/net/core/netdev_rx_queue.c @@ -10,6 +10,8 @@ #include "dev.h" #include "page_pool_priv.h" +static void netif_rxq_cleanup_unlease(struct netdev_rx_queue *phys_rxq); + void netdev_rx_queue_lease(struct netdev_rx_queue *rxq_dst, struct netdev_rx_queue *rxq_src) { @@ -28,7 +30,7 @@ void netdev_rx_queue_unlease(struct netdev_rx_queue *rxq_dst, netdev_assert_locked(rxq_dst->dev); netdev_assert_locked(rxq_src->dev); - netif_rxq_cleanup_unlease(rxq_src, rxq_dst); + netif_rxq_cleanup_unlease(rxq_src); WRITE_ONCE(rxq_src->lease, NULL); WRITE_ONCE(rxq_dst->lease, NULL); @@ -184,9 +186,9 @@ int netdev_rx_queue_restart(struct net_device *dev, unsigned int rxq_idx) } EXPORT_SYMBOL_NS_GPL(netdev_rx_queue_restart, "NETDEV_INTERNAL"); -static int __netif_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx, - const struct pp_memory_provider_params *p, - struct netlink_ext_ack *extack) +int __netif_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx, + const struct pp_memory_provider_params *p, + struct netlink_ext_ack *extack) { const struct netdev_queue_mgmt_ops *qops = dev->queue_mgmt_ops; struct netdev_queue_config qcfg[2]; @@ -278,8 +280,8 @@ int netif_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx, return ret; } -static int __netif_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx, - const struct pp_memory_provider_params *old_p) +int __netif_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx, + const struct pp_memory_provider_params *old_p) { struct netdev_queue_config qcfg[2]; struct netdev_rx_queue *rxq; @@ -338,20 +340,25 @@ int netif_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx, void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq, const struct pp_memory_provider_params *p) { - if (p->mp_ops && p->mp_ops->uninstall) - p->mp_ops->uninstall(p->mp_priv, rxq); + struct pp_memory_provider_params tmp = *p; + + if (!tmp.mp_ops) + return; + + memset(&rxq->mp_params, 0, sizeof(rxq->mp_params)); + if (tmp.mp_ops->uninstall) + tmp.mp_ops->uninstall(tmp.mp_priv, rxq); } /* Clean up memory provider state when a queue lease is torn down. If - * a memory provider was installed on the physical queue via the lease, + * a memory provider was installed on the physical queue while leased, * close it now. The memory provider is a property of the queue itself, - * and it was _guaranteed_ to be installed on the physical queue via - * the lease redirection. The extra __netif_mp_close_rxq is needed + * and it was _guaranteed_ to be installed on the physical queue while + * the lease was active. The extra __netif_mp_close_rxq is needed * since the physical queue can outlive the virtual queue in the lease * case, so it needs to be reconfigured to clear the memory provider. */ -void netif_rxq_cleanup_unlease(struct netdev_rx_queue *phys_rxq, - struct netdev_rx_queue *virt_rxq) +static void netif_rxq_cleanup_unlease(struct netdev_rx_queue *phys_rxq) { unsigned int rxq_idx = get_netdev_rx_queue_index(phys_rxq); struct pp_memory_provider_params p = phys_rxq->mp_params; @@ -360,5 +367,5 @@ void netif_rxq_cleanup_unlease(struct netdev_rx_queue *phys_rxq, return; __netif_mp_close_rxq(phys_rxq->dev, rxq_idx, &p); - __netif_mp_uninstall_rxq(virt_rxq, &p); + __netif_mp_uninstall_rxq(phys_rxq, &p); } -- 2.56.1.915.g69d5ec7298-goog