🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7724

[RFC 10/11] eth: mlx5: use dma_alloc_coherent_node()

#7724
From: Jakub Kicinski
Date: Tue, 27 Oct 2026 02:25
98 lines
11441 bytes
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
Technical Details
Message-ID: <20261027022528.633359-11-kuba@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352191-linux-kernel-netdev=dewy.ru
References: <20261027022528.633359-1-kuba@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352191-linux-kernel-netdev=dewy.ru
From: kuba@kernel.org (Jakub Kicinski)
Newsgroups: linux.kernel.netdev
Subject: [RFC 10/11] eth: mlx5: use dma_alloc_coherent_node()
Date: Mon, 26 Oct 2026 19:25:27 -0700
Organization: Usenet Network
Message-ID: <20261027022528.633359-11-kuba@kernel.org>
References: <20261027022528.633359-1-kuba@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1448165"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:J8uRjHEngSSnK3YivgMaLThtVK0= sha256:8PNP+OaVjLhUq5RhfriuB5nwmepeW9lFvGjiVm6QyAs=
	sha1:NjtDThf0sVe3TSrwYUVw6eFM9PU= sha256:hhUiCHn1IY5CUXDpHI+jWV/PFHMhOcKk8Txcey0WV6M=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id A535A125BD7; Tue, 27 Oct 2026 05:26:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ffrb7_WAv0fu;
	Tue, 27 Oct 2026 05:26:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-352191-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id C3839125BD8; Tue, 27 Oct 2026 05:26:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id CF53B28A11; Tue, 27 Oct 2026 02:26:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793067983;
	b=E5Hva0M+zsifBJ339jYaI5PRJ1pxHdojNhHf4FJnLNxaI/0ajqHkYuCeDWj1fltbdDeS
	 GUir5kdpz6zW3fGdgVhTCMySyZY1bh5DBb9GWKKbiy+I+iAFnnpC1jr+a5y382VAii7wt
	 mxwD1/9zT6/cJBpL0PDsyH8HbcmbXygxpPNk1Jx9FWoxKIbABZO404fXrPAkT5+sit/HV
	 os/P6vPIShlo7KFcWvKOABxiQdUrTe5ro0JF7lvFTl+g7mW7DWIaPyXvej137enh07MbW
	 j3/bW6RyK5RTheO6zoNqeOTnwvaf+BcnvFJNVvWVGp9x4UWewQVBvkEaMj1mWBLfgbQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793067983;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=sFMJ9G+BCCkIGTPexs2eTVxqNd1RzrfJlfVrNTosRLA=;
	b=YWATXlcSixtiQaOXwsQLJU4fBzJVUrQOyzkKJuAhMhauG7dumQCSkb6k1CInyImR84BA
	 1mqwFqYYgey7dik3KySvi/CzECQy3vvoaUACeBKaG7FYXL67AAaksA0uRu7aG7BQv8IkC
	 cEUQ1ECySIxtt4irgfdstxDmkWKi8O867YTIBcwlJ5Shwgn4bwI1lulyo9C7DHI2rl8X0
	 P1cVwvlBGWjS1Lpn3JtoTI8LDJ4T8K5+7Lq5j+4KQvEDNjTQ2n0B/oh7DnJdoYf2uWbjE
	 eEwXeEROsZjYvmsgNxUDiTThEPlXiu0LqbeoeojBkFaD9zrxT69TJ/1IGqwjvz+rXiA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tias2084;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 485EA60A2601;
	Tue, 27 Oct 2026 02:26:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tias2084
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793067972;
	b=NkoUEWaa2+BFiy4tPy9/4gWBgkD/9zoOpli/dmlTQ4yUU2tJL1KmKQ6l9TjYqk9tEZYy
	 L7ffEV5cwYub7nj9qERCX66PGk7HKOxu4mhhbAenSTNwEMoK/fztOuMFRNgA0/rXvdY1q
	 czdranhfOLWzCr+ucpooPSv0HsariiphGadg51P5/KFwKMhfBORoUFv1Q5rDrw//IXpS0
	 A6GQ1S0HPlJqC3zYqBYUAe6IT5Sw0n3EYq4MlrtZYd8++iDVaCxwzJ8Sc7yNe5SOmk0lm
	 U4ibUJt7tW94djzYjUIdaJ2Bf3dRvzWKb/xhSBK9nvJJBqK/Obw4hAj/CS02AzYvLAQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793067972;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=sFMJ9G+BCCkIGTPexs2eTVxqNd1RzrfJlfVrNTosRLA=;
	b=mF4k9iGF2Mha6uzPzUFQps3opLWjlZJbwcXMFq7bRLFrpIN5+HGCQxnHWteUdoMLQug9
	 lJnPXbiAdp4jUaMUz1N55pKp9Awc+cb8H6Hzb5ZO/IHCFr40QmP0ZRKspxVuYWTER5O55
	 71d4TzDJ0vYr2694IkqxnKDdBXSq+6sIRqN/JrXWQ3ybe99Uq0IsZPnN1UC97xhWSuL7h
	 3CEOK/4xE7fIfy2VVcFx19XM0XPj0S0BP6Iu5PTI+FvDE7lr+b8Ef1BS+LYmm++59mYpb
	 FJD1z7+WKplhA1TMDLAz0v2Hg7kEeGvlJ8QB8x6LCRufWbo0XRLUrlr1LWEcBCRhRhw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Tias2084;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B7CC606A32F;
	Tue, 27 Oct 2026 02:26:12 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A664F1F031E0;
	Tue, 27 Oct 2026 02:26:11 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793067972;
	bh=sFMJ9G+BCCkIGTPexs2eTVxqNd1RzrfJlfVrNTosRLA=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=Tias2084e9gMkncSNqg5FbzbyN8PJTgblajFs43jPT7r6lNl99xyFDj+OHYAWIm/D
	 Op+oHB6dHaQabgTWZzyT7o4peOabLYIxeUXpWAcWRS8uYB/1w2D4mek/8G4pSgdGPb
	 EjRbG6xIEFtPGwbpMrli3sipBu/2xhMjIgsLAfA74lqEnf96tSTYKBdL4SAfLlgom3
	 5LD4dZbxqPgoEtL5eDvcT+zxLBj+bJIKYuRdyrzvGfh2hIwKjtOQRmjhFFQuvZ/Fru
	 vg4ReMs2pXsrCnZUkCcMdtXiwsrGp+EraOg2RTya0TLe2dqlKa44rn2vnbgEK5XQrw
	 g+n8c2g5Gkl8A==
X-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>
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261027022528.633359-1-kuba@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list