Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: robin.murphy@arm.com, m.szyprowski@samsung.com
Cc: tglx@kernel.org, dave.hansen@linux.intel.com, x86@kernel.org,
	joro@8bytes.org, will@kernel.org, leon@kernel.org,
	mbloch@nvidia.com, iommu@lists.linux.dev, netdev@vger.kernel.org,
	Jakub Kicinski <kuba@kernel.org>
Subject: [RFC 10/11] eth: mlx5: use dma_alloc_coherent_node()
Date: Mon, 26 Oct 2026 19:25:27 -0700	[thread overview]
Message-ID: <20261027022528.633359-11-kuba@kernel.org> (raw)
In-Reply-To: <20261027022528.633359-1-kuba@kernel.org>

Use dma_alloc_coherent_node() to allocate the DMA pool pages on the
pool's node, instead of temporarily changing the node of the device.
alloc_mutex only serialized those temporary changes, remove it.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 include/linux/mlx5/driver.h                   |  2 --
 .../net/ethernet/mellanox/mlx5/core/alloc.c   | 24 +++----------------
 .../net/ethernet/mellanox/mlx5/core/main.c    |  4 ----
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index abb99371ff13..c58cc5a8f8df 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -596,8 +596,6 @@ struct mlx5_priv {
 	struct mlx5_debugfs_entries dbg;
 
 	/* start: alloc stuff */
-	/* protect buffer allocation according to numa node */
-	struct mutex            alloc_mutex;
 	int                     numa_node;
 
 	struct mlx5_frag_buf_node_pools **frag_buf_node_pools;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
index dcd281c4691d..936ce07aaefb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
@@ -80,25 +80,6 @@ struct mlx5_dma_pool_stats {
  * register it in a memory region at HCA virtual address 0.
  */
 
-static void *mlx5_dma_zalloc_coherent_node(struct mlx5_core_dev *dev,
-					   size_t size, dma_addr_t *dma_handle,
-					   int node)
-{
-	struct device *device = mlx5_core_dma_dev(dev);
-	struct mlx5_priv *priv = &dev->priv;
-	int original_node;
-	void *cpu_handle;
-
-	mutex_lock(&priv->alloc_mutex);
-	original_node = dev_to_node(device);
-	set_dev_node(device, node);
-	cpu_handle = dma_alloc_coherent(device, size, dma_handle,
-					GFP_KERNEL);
-	set_dev_node(device, original_node);
-	mutex_unlock(&priv->alloc_mutex);
-	return cpu_handle;
-}
-
 static void mlx5_dma_pool_destroy(struct mlx5_dma_pool *pool)
 {
 	mutex_destroy(&pool->lock);
@@ -139,8 +120,9 @@ mlx5_dma_pool_page_alloc(struct mlx5_dma_pool *pool)
 		goto err_free_page;
 
 	bitmap_fill(page->bitmap, blocks_per_page);
-	page->buf = mlx5_dma_zalloc_coherent_node(pool->dev, PAGE_SIZE,
-						  &page->dma, node);
+	page->buf = dma_alloc_coherent_node(mlx5_core_dma_dev(pool->dev),
+					    PAGE_SIZE, &page->dma, GFP_KERNEL,
+					    node);
 	if (!page->buf)
 		goto err_free_bitmap;
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 1a45474ce03d..b06e7c5c6110 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1822,8 +1822,6 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
 	INIT_LIST_HEAD(&priv->bfregs.reg_head.list);
 	INIT_LIST_HEAD(&priv->bfregs.wc_head.list);
 
-	mutex_init(&priv->alloc_mutex);
-
 	priv->numa_node = dev_to_node(mlx5_core_dma_dev(dev));
 	priv->dbg.dbg_root = debugfs_create_dir(dev_name(dev->device),
 						mlx5_debugfs_root);
@@ -1902,7 +1900,6 @@ int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
 	mlx5_frag_buf_pools_cleanup(dev);
 err_frag_buf_pools_init:
 	debugfs_remove(dev->priv.dbg.dbg_root);
-	mutex_destroy(&priv->alloc_mutex);
 	mutex_destroy(&priv->bfregs.wc_head.lock);
 	mutex_destroy(&priv->bfregs.reg_head.lock);
 	mutex_destroy(&dev->intf_state_mutex);
@@ -1927,7 +1924,6 @@ void mlx5_mdev_uninit(struct mlx5_core_dev *dev)
 	mlx5_db_pools_cleanup(dev);
 	mlx5_frag_buf_pools_cleanup(dev);
 	debugfs_remove_recursive(dev->priv.dbg.dbg_root);
-	mutex_destroy(&priv->alloc_mutex);
 	mutex_destroy(&priv->bfregs.wc_head.lock);
 	mutex_destroy(&priv->bfregs.reg_head.lock);
 	mutex_destroy(&dev->wc_state_lock);
-- 
2.56.0


  parent reply	other threads:[~2026-10-27  2:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  2:25 [RFC 00/11] dma-mapping: add dma_alloc_attrs_node() and dma_alloc_coherent_node() Jakub Kicinski
2026-10-27  2:25 ` [RFC 01/11] dma-contiguous: pass the NUMA node to dma_alloc_contiguous() Jakub Kicinski
2026-10-27  2:25 ` [RFC 02/11] dma-direct: pass the NUMA node to dma_direct_alloc() Jakub Kicinski
2026-10-27  2:25 ` [RFC 03/11] iommu/dma: pass the NUMA node to iommu_dma_alloc() Jakub Kicinski
2026-10-27  2:25 ` [RFC 04/11] dma-mapping: add dma_alloc_attrs_node() and dma_alloc_coherent_node() Jakub Kicinski
2026-10-27  9:03   ` Björn Töpel
2026-10-27 15:53     ` Jakub Kicinski
2026-10-27 15:24   ` Marek Szyprowski
2026-10-27 17:52     ` Jakub Kicinski
2026-10-28  9:00       ` Marek Szyprowski
2026-10-27  2:25 ` [RFC 05/11] eth: libwx: restore the device's NUMA node after ring allocation Jakub Kicinski
2026-10-27  2:25 ` [RFC 06/11] eth: libwx: use dma_alloc_coherent_node() Jakub Kicinski
2026-10-27  2:25 ` [RFC 07/11] eth: ixgbe: " Jakub Kicinski
2026-10-27  9:06   ` Björn Töpel
2026-10-27 15:51     ` Jakub Kicinski
2026-10-27 16:06       ` Björn Töpel
2026-10-27 18:20         ` Jakub Kicinski
2026-10-27  2:25 ` [RFC 08/11] eth: xgbe: " Jakub Kicinski
2026-10-27  2:25 ` [RFC 09/11] eth: fungible: " Jakub Kicinski
2026-10-27  2:25 ` Jakub Kicinski [this message]
2026-10-27  2:25 ` [RFC 11/11] eth: mlx4: " Jakub Kicinski
2026-10-27  9:03 ` [RFC 00/11] dma-mapping: add dma_alloc_attrs_node() and dma_alloc_coherent_node() Björn Töpel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027022528.633359-11-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=leon@kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox