git: 80902b8b7cd4 - main - mlx5ib: advertise write-combining support for dynamic BlueFlame UARs

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 07 Jul 2026 11:30:07 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=80902b8b7cd409ade11048dc78212e7d43475c65

commit 80902b8b7cd409ade11048dc78212e7d43475c65
Author:     Ariel Ehrenberg <aehrenberg@nvidia.com>
AuthorDate: 2026-06-08 10:56:04 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-07 11:25:15 +0000

    mlx5ib: advertise write-combining support for dynamic BlueFlame UARs
    
    Import Linux upstream commit 1f3db161881b7e21efb149e0ae8152b79a571a8f.
    
    dev->wc_support was never set, so it was always false and the UAR ioctl
    refused BlueFlame (write-combining) UAR allocations with EOPNOTSUPP.
    That breaks QP creation in pure dynamic-UAR mode, where user space asks
    for a BF doorbell UAR.
    
    Reviewed by:    kib
    Tested by:      Wafa Hamzah <wafah@nvidia.com>
    Sponsored by:   Nvidia networking
    MFC after:      1 month
---
 sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
index 66d8d511f2f0..ee5288c07b35 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
@@ -3551,6 +3551,16 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
 
 	dev->mdev = mdev;
 
+	/*
+	 * Write-combining is required to expose BlueFlame (WC) UARs through the
+	 * dynamic MLX5_IB_OBJECT_UAR ioctl path.  The legacy static UAR path
+	 * already maps doorbell pages with pgprot_writecombine(), so advertise
+	 * WC support whenever the platform actually provides it.
+	 */
+#if defined(VM_MEMATTR_WRITE_COMBINING)
+	dev->wc_support = true;
+#endif
+
 	dev->port = kcalloc(MLX5_CAP_GEN(mdev, num_ports), sizeof(*dev->port),
 			    GFP_KERNEL);
 	if (!dev->port)