* [PATCH rdma-next v3] RDMA/mana_ib: Enable RDMA devices on the CDX bus
@ 2026-12-03 6:34 Zhiyue Qiu
2026-12-03 6:54 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Zhiyue Qiu @ 2026-12-03 6:34 UTC (permalink / raw)
To: Konstantin Taranov, Snehal Sanghvi, longli@microsoft.com,
jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Enable MANA RDMA on CDX by depending on the shared GDMA core and matching
the CDX auxiliary devices.
On arm64, ioremap() maps the CDX doorbell pages in BAR0 as Device-nGnRE,
but pgprot_writecombine() maps them as Normal-NC in userspace. Using
pgprot_device() to match the kernel mapping fixes the observed CDX
lockup. PCI write-combining is unchanged.
mana_ib_query_device() reads the vendor ID through to_pci_dev(), but the
GDMA device on CDX is not a pci_dev. Both MANA transport ID tables match
only Microsoft's vendor ID (0x1414). Report PCI_VENDOR_ID_MICROSOFT
directly so userspace gets the same ID on either bus without a PCI cast.
Allocate missing DMA parameters before GDMA setup using managed memory.
Register a cleanup action to clear the device pointer before the memory
is freed. Set the 32-bit DMA mask and segment limits in CDX probe before
GDMA sets up interrupts or queues. These are device-wide constraints,
not properties of the HWC IRQs.
Signed-off-by: Zhiyue Qiu <zhiyueqiu@microsoft.com>
Co-developed-by: Konstantin Taranov <kotaranov@microsoft.com>
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
---
Changes in v3:
- Explain the CDX doorbell memory type and the source of the RDMA vendor ID.
- Leave the Kconfig help text unchanged.
- Move CDX DMA mask and segment setup from HWC IRQ setup to probe.
Changes in v2:
- Allocate missing CDX DMA parameters before GDMA setup.
drivers/infiniband/hw/mana/Kconfig | 2 +-
drivers/infiniband/hw/mana/device.c | 2 +
drivers/infiniband/hw/mana/main.c | 9 ++-
.../net/ethernet/microsoft/mana/gdma_cdx.c | 70 ++++++++++++-------
4 files changed, 54 insertions(+), 29 deletions(-)
diff --git a/drivers/infiniband/hw/mana/Kconfig b/drivers/infiniband/hw/mana/Kconfig
index 546640657bac..51f920e7a0f9 100644
--- a/drivers/infiniband/hw/mana/Kconfig
+++ b/drivers/infiniband/hw/mana/Kconfig
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
config MANA_INFINIBAND
tristate "Microsoft Azure Network Adapter support"
- depends on NETDEVICES && ETHERNET && PCI && MICROSOFT_MANA
+ depends on NETDEVICES && ETHERNET && MICROSOFT_GDMA_CORE
help
This driver provides low-level RDMA support for Microsoft Azure
Network Adapter (MANA). MANA supports RDMA features that can be used
diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c
index 62c7803ca6c6..33e47490755f 100644
--- a/drivers/infiniband/hw/mana/device.c
+++ b/drivers/infiniband/hw/mana/device.c
@@ -257,6 +257,8 @@ static void mana_ib_remove(struct auxiliary_device *adev)
static const struct auxiliary_device_id mana_id_table[] = {
{ .name = "mana.rdma", },
{ .name = "mana.eth", },
+ { .name = "mana_cdx.rdma", },
+ { .name = "mana_cdx.eth", },
{},
};
diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c
index 858bbc325eb2..afb8fa002f73 100644
--- a/drivers/infiniband/hw/mana/main.c
+++ b/drivers/infiniband/hw/mana/main.c
@@ -572,7 +572,11 @@ int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)
pfn = (gc->phys_db_page_base +
gc->db_page_size * mana_ucontext->doorbell) >>
PAGE_SHIFT;
- prot = pgprot_writecombine(vma->vm_page_prot);
+ /* Match the Device attributes used by the CDX transport. */
+ if (dev_is_pci(gc->dev))
+ prot = pgprot_writecombine(vma->vm_page_prot);
+ else
+ prot = pgprot_device(vma->vm_page_prot);
ret = rdma_user_mmap_io(ibcontext, vma, pfn, PAGE_SIZE, prot,
NULL);
@@ -623,14 +627,13 @@ int mana_ib_query_device(struct ib_device *ibdev, struct ib_device_attr *props,
struct ib_udata *uhw)
{
struct mana_ib_dev *dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
- struct pci_dev *pdev = to_pci_dev(mdev_to_gc(dev)->dev);
int err;
err = ib_no_udata_io(uhw);
if (err)
return err;
- props->vendor_id = pdev->vendor;
+ props->vendor_id = PCI_VENDOR_ID_MICROSOFT;
props->vendor_part_id = dev->gdma_dev->dev_id.type;
props->max_mr_size = MANA_IB_MAX_MR_SIZE;
props->page_size_cap = dev->adapter_caps.page_size_cap;
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_cdx.c b/drivers/net/ethernet/microsoft/mana/gdma_cdx.c
index 0d01e3d2f0d9..836dd29ee4e9 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_cdx.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_cdx.c
@@ -3,6 +3,7 @@
#include <linux/module.h>
#include <linux/bitmap.h>
#include <linux/cdx/cdx_bus.h>
+#include <linux/device.h>
#include <linux/msi.h>
#include <linux/xarray.h>
@@ -42,31 +43,6 @@ static int mana_cdx_setup_hwc_irqs(struct gdma_context *gc)
return -ENOSPC;
}
- /* Constrain the device to 32-bit DMA addresses, for both the MSI
- * doorbells and the data path buffers, and never widen it afterwards.
- *
- * The MSI doorbell address has to land within the low 4GB. The data
- * path carries a second constraint: the device does not perform
- * writes to the final page of the 48-bit IOVA window, and
- * iommu_dma_alloc_iova() allocates downwards from the top of that
- * window, so the first queue created lands on the unusable page and
- * its event queue stalls permanently. PCI devices are shielded from
- * this by the low-4GB first attempt in iommu_dma_alloc_iova(), but
- * that attempt is gated on dev_is_pci() and CDX devices do not
- * qualify.
- */
- err = dma_set_mask_and_coherent(gc->dev, DMA_BIT_MASK(32));
- if (err) {
- dev_err(&cdx_dev->dev, "Failed to set 32-bit DMA mask\n");
- return err;
- }
-
- /* The PCI path also calls dma_set_max_seg_size(), but that is
- * deliberately omitted here: the CDX core does not attach a
- * dma_parms to the device, so the helper would only WARN, and MANA
- * never builds scatter-gather lists, so the limit is never read.
- */
-
err = cdx_enable_msi(cdx_dev);
if (err) {
dev_err(&cdx_dev->dev, "Failed to enable MSI\n");
@@ -196,6 +172,13 @@ static const struct gdma_bus_ops mana_cdx_bus_ops = {
.dev_reset = mana_cdx_dev_reset,
};
+static void mana_cdx_clear_dma_parms(void *data)
+{
+ struct device *dev = data;
+
+ dev->dma_parms = NULL;
+}
+
static int mana_cdx_gd_probe(struct cdx_device *cdx_dev)
{
struct gdma_context *gc;
@@ -241,6 +224,43 @@ static int mana_cdx_gd_probe(struct cdx_device *cdx_dev)
gc->bar0_va = bar0_va;
gc->dev = &cdx_dev->dev;
gc->bus_ops = &mana_cdx_bus_ops;
+ if (!gc->dev->dma_parms) {
+ gc->dev->dma_parms = devm_kzalloc(gc->dev,
+ sizeof(*gc->dev->dma_parms),
+ GFP_KERNEL);
+ if (!gc->dev->dma_parms) {
+ err = -ENOMEM;
+ goto unmap_bar;
+ }
+
+ /* Clear the pointer before devres frees the allocation. */
+ err = devm_add_action_or_reset(gc->dev, mana_cdx_clear_dma_parms,
+ gc->dev);
+ if (err)
+ goto unmap_bar;
+ }
+
+ /* Constrain the device to 32-bit DMA addresses, for both the MSI
+ * doorbells and the data path buffers, and never widen it afterwards.
+ *
+ * The MSI doorbell address has to land within the low 4GB. The data
+ * path carries a second constraint: the device does not perform
+ * writes to the final page of the 48-bit IOVA window, and
+ * iommu_dma_alloc_iova() allocates downwards from the top of that
+ * window, so the first queue created lands on the unusable page and
+ * its event queue stalls permanently. PCI devices are shielded from
+ * this by the low-4GB first attempt in iommu_dma_alloc_iova(), but
+ * that attempt is gated on dev_is_pci() and CDX devices do not
+ * qualify.
+ */
+ err = dma_set_mask_and_coherent(gc->dev, DMA_BIT_MASK(32));
+ if (err) {
+ dev_err(gc->dev, "Failed to set 32-bit DMA mask\n");
+ goto unmap_bar;
+ }
+
+ dma_set_max_seg_size(gc->dev, UINT_MAX);
+ dma_set_seg_boundary(gc->dev, DMA_BIT_MASK(32));
/* gc->is_pf is intentionally left clear: this device uses the VF
* register layout, and the vPort and MAC filter registration that
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH rdma-next v3] RDMA/mana_ib: Enable RDMA devices on the CDX bus
2026-12-03 6:34 [PATCH rdma-next v3] RDMA/mana_ib: Enable RDMA devices on the CDX bus Zhiyue Qiu
@ 2026-12-03 6:54 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-03 6:54 UTC (permalink / raw)
To: Zhiyue Qiu; +Cc: linux-rdma@vger.kernel.org
> Enable MANA RDMA on CDX by depending on the shared GDMA core and matching
> the CDX auxiliary devices.
>
> On arm64, ioremap() maps the CDX doorbell pages in BAR0 as Device-nGnRE,
> but pgprot_writecombine() maps them as Normal-NC in userspace. Using
> pgprot_device() to match the kernel mapping fixes the observed CDX
> lockup. PCI write-combining is unchanged.
>
> mana_ib_query_device() reads the vendor ID through to_pci_dev(), but the
> GDMA device on CDX is not a pci_dev. Both MANA transport ID tables match
> only Microsoft's vendor ID (0x1414). Report PCI_VENDOR_ID_MICROSOFT
> directly so userspace gets the same ID on either bus without a PCI cast.
>
> Allocate missing DMA parameters before GDMA setup using managed memory.
> Register a cleanup action to clear the device pointer before the memory
> is freed. Set the 32-bit DMA mask and segment limits in CDX probe before
> GDMA sets up interrupts or queues. These are device-wide constraints,
> not properties of the HWC IRQs.
>
> Signed-off-by: Zhiyue Qiu <zhiyueqiu@microsoft.com>
> Co-developed-by: Konstantin Taranov <kotaranov@microsoft.com>
> Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/PH0PR21MB5918CB654FDD560F4CDD96EFBE4B2@PH0PR21MB5918.namprd21.prod.outlook.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 6:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 6:34 [PATCH rdma-next v3] RDMA/mana_ib: Enable RDMA devices on the CDX bus Zhiyue Qiu
2026-12-03 6:54 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox