net: mana: Per-vPort EQ and MSI-X interrupt management
Subsystems (5)
v10 cover net: mana: Per-vPort EQ and MSI-X interrupt management
This series moves EQ ownership from the shared mana_context to per-vPort mana_port_context, enabling each vPort to have dedicated MSI-X vectors when the hardware provides enough vectors. When vectors are limited, the driver falls back to sharing MSI-X among vPorts.
The series introduces a GDMA IRQ Context (GIC) abstraction with reference counting to manage interrupt context lifecycle. This allows both Ethernet and RDMA EQs to dynamically acquire dedicated or shared MSI-X vectors at vPort creation time rather than pre-allocating all vectors at probe time.
This series touches both the net and RDMA MANA drivers and is intended to go through the net-next tree. The patches are available on a shared branch for both netdev and RDMA maintainers to review.
The following changes since commit 73d587ae684d176fac9db94173f77d78a794ea4f:
net: ethtool: fix missing closing paren in rings_reply_size() (2026-05-11 18:42:25 -0700)
are available in the Git repository at:
https://github.com/longlimsft/linux.git tags/mana-eq-msi-v10
for you to fetch changes up to fb1f61f57f46f9511c64a09aa20a3a94374aebf4:
RDMA/mana_ib: Allocate interrupt contexts on EQs
to go through the net-next tree. The patches are available on a shared branch for both netdev and RDMA maintainers to review.
Changes in v10:
- Add channel_changing flag to block RDMA from grabbing the vport during mana_set_channels() detach/attach window. The flag is checked in mana_cfg_vport() only when called from the RDMA path via a new check_channel_changing parameter (patch 1)
- Bind each PD to a single physical port via pd->vport_port to prevent cross-port PD sharing which would cause EQ scope mismatch. Returns -EINVAL if a second port tries to use an already-bound PD (patch 1)
- Guard gc->msi_sharing reset with pci_msix_can_alloc_dyn() to avoid overwriting the non-dyn platform constraint set by mana_gd_setup_hwc_irqs() (patch 2)
Changes in v9:
- RSS QPs now take a vport reference via pd->vport_use_count to ensure EQs outlive all QP consumers. EQs are only destroyed when the last QP (raw or RSS) on the PD releases its reference (patch 1)
- Serialize mana_set_channels() against RDMA vport configuration via apc->vport_mutex when the port is down. When the port is up, Ethernet owns the vport exclusively so no locking is needed (patch 1)
- Change WARN_ON(apc->eqs) to bail out with -EEXIST to prevent leaking prior EQ array if invariant is violated (patch 1)
- Only commit pd->tx_shortform_allowed and pd->tx_vp_offset after mana_create_eq() succeeds (patch 1)
- Reset gc->msi_sharing at the top of mana_gd_query_max_resources() so it is recomputed from current hardware state on resume (patch 2)
- Fix reverse Christmas tree variable declaration ordering (patches 1, 3, 5)
Changes in v8:
- Fix comment to reference per-vPort queue count instead of gc->max_num_queues (patch 2)
- Remove duplicate irq_update_affinity_hint() calls from error paths and mana_gd_remove_irqs(); the clearing is now centralized in mana_gd_put_gic() (patch 4)
- Note the IRQ name change (mana_q -> mana_msi) in the commit message (patch 4)
- Remove dead conditional write to spec.eq.msix_index (patch 5)
- Document GIC ownership contract and msix_index invariant change in commit message (patch 5)
- Populate eq.irq on RDMA EQs for consistency with the Ethernet path (patch 6)
- Document BIT(6) relocation and capability flag semantics in commit message (patch 6)
- Fix checkpatch --strict alignment and line length warnings
Changes in v7:
- Use rounddown_pow_of_two() instead of roundup_pow_of_two() when computing per-vPort queue count to avoid unnecessarily forcing shared MSI-X mode (patch 2)
- Call mana_gd_setup_remaining_irqs() unconditionally to ensure irq_contexts are populated in both dedicated and shared MSI-X modes, fixing bisectability between patches 2 and 5 (patch 2)
- Guard ibdev_dbg() in mana_ib_cfg_vport() with error check so the vport handle is not logged on the failure path (patch 1)
- Use cached gic->irq instead of pci_irq_vector() lookup in mana_gd_put_gic() for consistency with the allocation path (patch 3)
- Fix unsigned int* to int* pointer type mismatch when calling mana_gd_get_gic() by using a local int variable for the MSI index (patches 5, 6)
Changes in v6:
- Rebased on net-next/main (v7.1-rc1)
Changes in v5:
- Rebased on net-next/main
Changes in v4:
- Rebased on net-next/main 7.0-rc4
- Patch 2: Use MANA_DEF_NUM_QUEUES instead of hardcoded 16 for max_num_queues clamping
- Patch 3: Track dyn_msix in GIC context instead of re-checking pci_msix_can_alloc_dyn() on each call; improved remove_irqs iteration to skip unallocated entries
Changes in v3:
- Rebased on net-next/main
- Patch 1: Added NULL check for mpc->eqs in mana_ib_create_qp_rss() to prevent NULL pointer dereference when RSS QP is created before a raw QP has configured the vport and allocated EQs
Changes in v2:
- Rebased on net-next/main (adapted to kzalloc_objs/kzalloc_obj macros, new GDMA_DRV_CAP_FLAG definitions)
- Patch 2: Fixed misleading comment for max_num_queues vs max_num_queues_vport in gdma.h
- Patch 3: Fixed spelling typo in gdma_main.c ("difference" -> "different")
Long Li (6):
net: mana: Create separate EQs for each vPort
net: mana: Query device capabilities and configure MSI-X sharing for
EQs
net: mana: Introduce GIC context with refcounting for interrupt
management
net: mana: Use GIC functions to allocate global EQs
net: mana: Allocate interrupt context for each EQ when creating vPort RDMA/mana_ib: Allocate interrupt contexts on EQs
drivers/infiniband/hw/mana/main.c | 83 ++++- drivers/infiniband/hw/mana/mana_ib.h | 8 + drivers/infiniband/hw/mana/qp.c | 37 +- .../net/ethernet/microsoft/mana/gdma_main.c | 326 +++++++++++++----- drivers/net/ethernet/microsoft/mana/mana_en.c | 175 ++++++---- .../ethernet/microsoft/mana/mana_ethtool.c | 23 +- include/net/mana/gdma.h | 33 +- include/net/mana/mana.h | 15 +- 8 files changed, 520 insertions(+), 180 deletions(-)
Signature · 1 line
2.43.0
PATCH v10 1/6 net: mana: Create separate EQs for each vPort
To prepare for assigning vPorts to dedicated MSI-X vectors, remove EQ sharing among the vPorts and create dedicated EQs for each vPort.
Move the EQ definition from struct mana_context to struct mana_port_context and update related support functions. Export mana_create_eq() and mana_destroy_eq() for use by the MANA RDMA driver.
RSS QPs now take a vport reference via pd->vport_use_count to ensure EQs outlive all QP consumers. The vport must already be configured by a raw QP before an RSS QP can be created. EQs are only destroyed when the last QP (raw or RSS) on the PD releases its reference.
Reject cross-port PD sharing for raw QPs. Since EQs and vport configuration are per-port, a PD is bound to the port used by its first raw QP. Subsequent raw QPs on the same PD must use the same port or the creation fails with -EINVAL.
Serialize mana_set_channels() against RDMA vport configuration to prevent num_queues from changing while RDMA holds EQs sized to the current value. When the port is down, apc->vport_mutex is held for the entire operation since mana_detach()/mana_attach() do not take vport_mutex in that case. When the port is up, Ethernet owns the vport exclusively so no additional locking is needed.
--- drivers/infiniband/hw/mana/main.c | 40 ++++-- drivers/infiniband/hw/mana/mana_ib.h | 8 ++ drivers/infiniband/hw/mana/qp.c | 37 +++++- drivers/net/ethernet/microsoft/mana/mana_en.c | 117 +++++++++++------- .../ethernet/microsoft/mana/mana_ethtool.c | 23 +++- include/net/mana/mana.h | 15 ++- 6 files changed, 174 insertions(+), 66 deletions(-)
drivers/infiniband/hw/mana/main.c +32 -8
@@ -20,8 +20,10 @@ void mana_ib_uncfg_vport(struct mana_ib_dev *dev, struct mana_ib_pd *pd, pd->vport_use_count--;WARN_ON (pd->vport_use_count <0 ); -if (!pd->vport_use_count) +if (!pd->vport_use_count) { +mana_destroy_eq (mpc);mana_uncfg_vport (mpc); + }mutex_unlock (&pd->vport_mutex); }
@@ -40,13 +42,27 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd, pd->vport_use_count++;if (pd->vport_use_count >1 ) { +/* Reject cross-port PD sharing. EQs and vport config +* are per-port, so the PD must stay bound to the port +* that was configured on the first raw QP creation. +*/ +if (pd->vport_port != port) { + pd->vport_use_count--; +mutex_unlock (&pd->vport_mutex); +ibdev_dbg (&dev->ib_dev, +"PD already bound to port %u\n" , + pd->vport_port); +return -EINVAL ; + }ibdev_dbg (&dev->ib_dev,"Skip as this PD is already configured vport\n" );mutex_unlock (&pd->vport_mutex);return 0 ; } - err =mana_cfg_vport (mpc, pd->pdn, doorbell_id); + pd->vport_port = port; + + err =mana_cfg_vport (mpc, pd->pdn, doorbell_id, true);if (err) { pd->vport_use_count--;mutex_unlock (&pd->vport_mutex);
@@ -55,15 +71,23 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd,return err; } -mutex_unlock (&pd->vport_mutex); - pd->tx_shortform_allowed = mpc->tx_shortform_allowed; - pd->tx_vp_offset = mpc->tx_vp_offset; + err =mana_create_eq (mpc); +if (err) { +mana_uncfg_vport (mpc); + pd->vport_use_count--; + }else { + pd->tx_shortform_allowed = mpc->tx_shortform_allowed; + pd->tx_vp_offset = mpc->tx_vp_offset; + } + +mutex_unlock (&pd->vport_mutex); -ibdev_dbg (&dev->ib_dev,"vport handle %llx pdid %x doorbell_id %x\n" , - mpc->port_handle, pd->pdn, doorbell_id); +if (!err) +ibdev_dbg (&dev->ib_dev,"vport handle %llx pdid %x doorbell_id %x\n" , + mpc->port_handle, pd->pdn, doorbell_id); -return 0 ; +return err; }int mana_ib_alloc_pd (struct ib_pd *ibpd,struct ib_udata *udata)
drivers/infiniband/hw/mana/mana_ib.h +8 -0
@@ -102,6 +102,14 @@ struct mana_ib_pd {struct mutex vport_mutex;int vport_use_count; +/* Port bound to this PD for raw QP usage. A PD can only be +* associated with a single physical port because per-port EQs +* and vport configuration are tied to the PD's refcount. +* Set on the first raw QP creation; subsequent QPs on the +* same PD must use the same port or get -EINVAL. +*/ +u32 vport_port; +bool tx_shortform_allowed;u32 tx_vp_offset; };
drivers/infiniband/hw/mana/qp.c +31 -6
@@ -79,6 +79,7 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,struct ib_qp_init_attr *attr, struct ib_udata *udata) { + struct mana_ib_pd *mana_pd = container_of(pd, struct mana_ib_pd, ibpd); struct mana_ib_qp *qp = container_of(ibqp, struct mana_ib_qp, ibqp);struct mana_ib_dev *mdev = container_of(pd->device, struct mana_ib_dev, ib_dev);
@@ -155,6 +156,18 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, qp->port = port; +/* Take a reference on the vport to ensure EQs outlive this QP. +* The vport must already be configured by a raw QP. +*/ +mutex_lock (&mana_pd->vport_mutex); +if (!mana_pd->vport_use_count) { +mutex_unlock (&mana_pd->vport_mutex); + ret = -EINVAL ; + goto fail; + } + mana_pd->vport_use_count++; +mutex_unlock (&mana_pd->vport_mutex); +for (i =0 ; i < ind_tbl_size; i++) {struct mana_obj_spec wq_spec = {};struct mana_obj_spec cq_spec = {};
@@ -171,13 +184,13 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, cq_spec.gdma_region = cq->queue.gdma_region; cq_spec.queue_size = cq->cqe *COMP_ENTRY_SIZE ; cq_spec.modr_ctx_id =0 ; - eq = &mpc->ac->eqs[cq->comp_vector]; + eq = &mpc->eqs[cq->comp_vector % mpc->num_queues]; cq_spec.attached_eq = eq->eq->id; ret =mana_create_wq_obj (mpc, mpc->port_handle,GDMA_RQ , &wq_spec, &cq_spec, &wq->rx_object);if (ret) - goto fail; + goto free_vport;/* The GDMA regions are now owned by the WQ object */ wq->queue.gdma_region =GDMA_INVALID_DMA_REGION ;
@@ -199,7 +212,7 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, ret =mana_ib_install_cq_cb (mdev, cq);if (ret) {mana_destroy_wq_obj (mpc,GDMA_RQ , wq->rx_object); - goto fail; + goto free_vport; } } resp.num_entries = i;
@@ -210,7 +223,7 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, ucmd.rx_hash_key_len, ucmd.rx_hash_key);if (ret) - goto fail; + goto free_vport; ret =ib_copy_to_udata (udata, &resp,sizeof (resp));if (ret) {
@@ -226,7 +239,7 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, err_disable_vport_rx:mana_disable_vport_rx (mpc); -fail: +free_vport:while (i-- >0 ) { ibwq = ind_tbl->ind_tbl[i]; ibcq = ibwq->cq;
@@ -237,6 +250,9 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,mana_destroy_wq_obj (mpc,GDMA_RQ , wq->rx_object); } +mana_ib_uncfg_vport (mdev, mana_pd, port); + +fail:kfree (mana_ind_table);return ret;
@@ -321,7 +337,11 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd, cq_spec.queue_size = send_cq->cqe *COMP_ENTRY_SIZE ; cq_spec.modr_ctx_id =0 ; eq_vec = send_cq->comp_vector; - eq = &mpc->ac->eqs[eq_vec]; +if (!mpc->eqs) { + err = -EINVAL ; + goto err_destroy_queue; + } + eq = &mpc->eqs[eq_vec % mpc->num_queues]; cq_spec.attached_eq = eq->eq->id; err = mana_create_wq_obj(mpc, mpc->port_handle, GDMA_SQ, &wq_spec,
@@ -785,14 +805,17 @@ static int mana_ib_destroy_qp_rss(struct mana_ib_qp *qp, {struct mana_ib_dev *mdev = container_of(qp->ibqp.device, struct mana_ib_dev, ib_dev); +struct ib_pd *ibpd = qp->ibqp.pd;struct mana_port_context *mpc;struct net_device *ndev; +struct mana_ib_pd *pd;struct mana_ib_wq *wq;struct ib_wq *ibwq;int i; ndev =mana_ib_get_netdev (qp->ibqp.device, qp->port); mpc =netdev_priv (ndev); + pd = container_of(ibpd, struct mana_ib_pd, ibpd);/* Disable vPort RX steering before destroying RX WQ objects. * Otherwise firmware still routes traffic to the destroyed queues,
@@ -817,6 +840,8 @@ static int mana_ib_destroy_qp_rss(struct mana_ib_qp *qp,mana_destroy_wq_obj (mpc,GDMA_RQ , wq->rx_object); } +mana_ib_uncfg_vport (mdev, pd, qp->port); +return 0 ; }
drivers/net/ethernet/microsoft/mana/mana_en.c +69 -48
282 lines not on this page · raw message
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +22 -1
@@ -454,6 +454,11 @@ static int mana_set_coalesce(struct net_device *ndev,return err; } +/* mana_set_channels - change the number of queues on a port +* +* Returns -EBUSY if RDMA holds the vport with EQs sized to the +* current num_queues. +*/ static int mana_set_channels (struct net_device *ndev,struct ethtool_channels *channels) {
@@ -462,10 +467,22 @@ static int mana_set_channels(struct net_device *ndev,unsigned int old_count = apc->num_queues;int err; +/* Set channel_changing to block RDMA from grabbing the vport +* during the detach/attach window. mana_cfg_vport() checks +* this flag under vport_mutex and returns -EBUSY if set. +*/ +mutex_lock (&apc->vport_mutex); +if (!apc->port_is_up && apc->vport_use_count) { +mutex_unlock (&apc->vport_mutex); +return -EBUSY ; + } + apc->channel_changing = true; +mutex_unlock (&apc->vport_mutex); + err =mana_pre_alloc_rxbufs (apc, ndev->mtu, new_count);if (err) {netdev_err (ndev,"Insufficient memory for new allocations" ); -return err; + goto clear_flag; } err =mana_detach (ndev, false);
@@ -483,6 +500,10 @@ static int mana_set_channels(struct net_device *ndev, out:mana_pre_dealloc_rxbufs (apc); +clear_flag: +mutex_lock (&apc->vport_mutex); + apc->channel_changing = false; +mutex_unlock (&apc->vport_mutex);return err; }
include/net/mana/mana.h +12 -3
@@ -480,8 +480,6 @@ struct mana_context {u8 bm_hostmode;struct mana_ethtool_hc_stats hc_stats; -struct mana_eq *eqs; -struct dentry *mana_eqs_debugfs;struct workqueue_struct *per_port_queue_reset_wq;/* Workqueue for querying hardware stats */ struct delayed_work gf_stats_work;
@@ -501,6 +499,9 @@ struct mana_port_context {u8 mac_addr[ETH_ALEN ]; +struct mana_eq *eqs; +struct dentry *mana_eqs_debugfs; +enum TRI_STATE rss_state;mana_handle_t default_rxobj;
@@ -547,6 +548,12 @@ struct mana_port_context {struct mutex vport_mutex;int vport_use_count; +/* Set by mana_set_channels() under vport_mutex to block RDMA +* from grabbing the vport during the detach/attach window. +* Checked by mana_cfg_vport() when called from the RDMA path. +*/ +bool channel_changing; +/* Net shaper handle*/ struct net_shaper_handle handle;
@@ -1032,8 +1039,10 @@ void mana_destroy_wq_obj(struct mana_port_context *apc, u32 wq_type, mana_handle_t wq_obj);int mana_cfg_vport (struct mana_port_context *apc,u32 protection_dom_id, -u32 doorbell_pg_id); +u32 doorbell_pg_id,bool check_channel_changing);void mana_uncfg_vport (struct mana_port_context *apc); +int mana_create_eq (struct mana_port_context *apc); +void mana_destroy_eq (struct mana_port_context *apc); struct net_device *mana_get_primary_netdev(struct mana_context *ac, u32 port_index,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v10 1/6] net: mana: Create separate EQs for each vPort
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Critical] Missing cross-port validation in `mana_ib_create_qp_rss()` allows userspace to trigger NULL…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Missing cross-port validation in mana_ib_create_qp_rss() allows userspace to trigger NULL pointer dereferences and corrupt other ports' queues.
- [High] Use of boolean flag channel_changing as an ad-hoc lock in mana_set_channels() violates networking subsystem guidelines. --
commit ed2a523d0427d1b949add95925cad26c8b468ff8
Author: Long Li <[email protected]> Date: Fri May 15 04:05:03 2026 +0000
net: mana: Create separate EQs for each vPort
This commit separates EQs for each vPort, removing the shared EQ mechanism from the MANA driver to prepare for dedicated MSI-X vector assignment. RSS QPs are updated to take a vport reference, ensuring EQs outlive QP consumers.
Quoted 4 lines
drivers/infiniband/hw/mana/qp.c +0
-0
[ ... ]
Quoted 6 lines
drivers/infiniband/hw/mana/qp.c +2
-0@@ -155,6 +156,18 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, qp->port = port; +/* Take a reference on the vport to ensure EQs outlive this QP. +* The vport must already be configured by a raw QP.
drivers/infiniband/hw/mana/qp.c static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, · line 170
Quoted 10 lines
drivers/infiniband/hw/mana/qp.c +10
-0+*/ +mutex_lock (&mana_pd->vport_mutex); +if (!mana_pd->vport_use_count) { +mutex_unlock (&mana_pd->vport_mutex); + ret = -EINVAL ; + goto fail; + } + mana_pd->vport_use_count++; +mutex_unlock (&mana_pd->vport_mutex); +
Does this code need to verify that the requested port matches mana_pd->vport_port?
While mana_ib_cfg_vport() correctly rejects cross-port PD sharing for raw QPs, an RSS QP creation could specify a different port (e.g., Port B) using the same PD bound to Port A.
If Port B is unconfigured, could fetching its mpc result in a NULL pointer dereference when accessing mpc->eqs below?
If Port B is active, could this lead to erroneously destroying Port B's EQs or underflowing its vport_use_count when the PD drops its references during teardown?
Quoted 2 lines
drivers/infiniband/hw/mana/qp.c +0
-0for (i =0 ; i < ind_tbl_size; i++) {struct mana_obj_spec wq_spec = {};
[ ... ]
Quoted 4 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +0
-0
[ ... ]
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +2
-0@@ -462,10 +467,22 @@ static int mana_set_channels(struct net_device *ndev,unsigned int old_count = apc->num_queues;int err; +/* Set channel_changing to block RDMA from grabbing the vport +* during the detach/attach window. mana_cfg_vport() checks
drivers/net/ethernet/microsoft/mana/mana_ethtool.c static int mana_set_channels(struct net_device *ndev, · line 481
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +10
-0+* this flag under vport_mutex and returns -EBUSY if set. +*/ +mutex_lock (&apc->vport_mutex); +if (!apc->port_is_up && apc->vport_use_count) { +mutex_unlock (&apc->vport_mutex); +return -EBUSY ; + } + apc->channel_changing = true; +mutex_unlock (&apc->vport_mutex); +
Is channel_changing acting as an ad-hoc lock here?
The networking subsystem guidelines discourage using boolean flags set on entry and cleared on exit to guard code sections against concurrent access.
Since mana_detach() and mana_attach() are executed while this flag is held to prevent mana_cfg_vport() from proceeding, could this be replaced with a standard locking mechanism to ensure lockdep visibility?
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +1
-1err =mana_pre_alloc_rxbufs (apc, ndev->mtu, new_count);if (err) {netdev_err (ndev,"Insufficient memory for new allocations" ); -return err; + goto clear_flag; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Paolo Abeni
maintainerRe: [PATCH net-next v10 1/6] net: mana: Create separate EQs for each vPort
In reply to Long LiFrom: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: mana: Create separate EQs for each vPort
This patch moves EQ allocation from per-device to per-vPort, exports mana_create_eq()/mana_destroy_eq() for use by the RDMA driver, takes a vport reference for RSS QPs, and adds cross-port PD-sharing rejection for raw QPs along with serialization between mana_set_channels() and the RDMA vport configuration.
Quoted 23 lines
drivers/infiniband/hw/mana/main.c +12
-0@@ -40,13 +42,27 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd, pd->vport_use_count++;if (pd->vport_use_count >1 ) { +/* Reject cross-port PD sharing. EQs and vport config +* are per-port, so the PD must stay bound to the port +* that was configured on the first raw QP creation. +*/ +if (pd->vport_port != port) { + pd->vport_use_count--; +mutex_unlock (&pd->vport_mutex); +ibdev_dbg (&dev->ib_dev, +"PD already bound to port %u\n" , + pd->vport_port); +return -EINVAL ; + }ibdev_dbg (&dev->ib_dev,"Skip as this PD is already configured vport\n" );mutex_unlock (&pd->vport_mutex);
drivers/infiniband/hw/mana/main.c int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd, · line 68
Quoted 10 lines
drivers/infiniband/hw/mana/main.c +3
-1return 0 ; } - err =mana_cfg_vport (mpc, pd->pdn, doorbell_id); + pd->vport_port = port; + + err =mana_cfg_vport (mpc, pd->pdn, doorbell_id, true);if (err) { pd->vport_use_count--;mutex_unlock (&pd->vport_mutex);
[Low]
In the failure path of mana_ib_cfg_vport(), if mana_cfg_vport() or the later mana_create_eq() fails, vport_use_count is rolled back to 0 but pd->vport_port keeps the value just written.
Is the contract that pd->vport_port is only meaningful while vport_use_count > 0? That invariant is not documented in the struct mana_ib_pd comment, and a future reader who consults pd->vport_port without first checking vport_use_count under vport_mutex would see stale data. Would it be worth either resetting pd->vport_port on the rollback path or documenting the rule explicitly?
Quoted 16 lines
drivers/infiniband/hw/mana/main.c +8
-3@@ -55,15 +71,23 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd,return err; } -mutex_unlock (&pd->vport_mutex); - pd->tx_shortform_allowed = mpc->tx_shortform_allowed; - pd->tx_vp_offset = mpc->tx_vp_offset; + err =mana_create_eq (mpc); +if (err) { +mana_uncfg_vport (mpc); + pd->vport_use_count--; + }else { + pd->tx_shortform_allowed = mpc->tx_shortform_allowed; + pd->tx_vp_offset = mpc->tx_vp_offset; + }
[ ... ]
Quoted 10 lines
drivers/infiniband/hw/mana/qp.c +2
-0@@ -155,6 +156,18 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, qp->port = port; +/* Take a reference on the vport to ensure EQs outlive this QP. +* The vport must already be configured by a raw QP.
drivers/infiniband/hw/mana/qp.c static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, · line 170
Quoted 10 lines
drivers/infiniband/hw/mana/qp.c +10
-0+*/ +mutex_lock (&mana_pd->vport_mutex); +if (!mana_pd->vport_use_count) { +mutex_unlock (&mana_pd->vport_mutex); + ret = -EINVAL ; + goto fail; + } + mana_pd->vport_use_count++; +mutex_unlock (&mana_pd->vport_mutex); +
[Critical]
The cross-port PD-sharing check added to mana_ib_cfg_vport() is not mirrored here. mana_ib_create_qp_rss() takes the user-supplied port from ucmd.port and only checks that vport_use_count is non-zero, so the RSS path will happily attach to a different port than the one bound to the PD by the first raw QP.
If a user creates a raw QP on port A (which sets pd->vport_port=A and allocates mpc_A->eqs via mana_create_eq()), then creates an RSS QP on the same PD with ucmd.port=B where port B has no Ethernet up and no RDMA activity, mpc_B->eqs is NULL. The subsequent code in this same function:
eq = &mpc->eqs[cq->comp_vector % mpc->num_queues]; cq_spec.attached_eq = eq->eq->id;
would then dereference NULL through mpc_B->eqs.
If port B does have Ethernet up, mpc_B->eqs is owned by the Ethernet driver and the RSS QP attaches to those EQs. When the QP is destroyed mana_ib_destroy_qp_rss() calls mana_ib_uncfg_vport(mdev, pd, qp->port=B), and once pd->vport_use_count reaches 0 mana_ib_uncfg_vport() will run mana_destroy_eq(mpc_B) on Ethernet's live EQs and call mana_uncfg_vport on a port whose apc->vport_use_count was never incremented by this PD, tripping the WARN_ON in mana_uncfg_vport() and corrupting Ethernet's vport state. Meanwhile port A's EQs and vport configuration are leaked because nothing on this PD will destroy them.
Should mana_ib_create_qp_rss() apply the same pd->vport_port == port check that mana_ib_cfg_vport() now performs, before bumping vport_use_count?
[Medium]
The new "vport must already be configured by a raw QP" requirement is a visible uAPI change. Before this patch, EQs were allocated device-wide on mana_context at probe time, so an RSS QP could be created without any prior raw QP on the PD. After the patch, applications that legitimately use only RSS QPs (RX-only RDMA workloads) will see -EINVAL here unless they also create a raw QP first.
Was breaking the RSS-only case considered, and would lazy EQ creation on the first QP regardless of type be feasible to avoid the incompatibility?
Quoted 10 lines
drivers/infiniband/hw/mana/qp.c +1
-1for (i =0 ; i < ind_tbl_size; i++) {struct mana_obj_spec wq_spec = {};struct mana_obj_spec cq_spec = {};@@ -171,13 +184,13 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, cq_spec.gdma_region = cq->queue.gdma_region; cq_spec.queue_size = cq->cqe *COMP_ENTRY_SIZE ; cq_spec.modr_ctx_id =0 ; - eq = &mpc->ac->eqs[cq->comp_vector]; + eq = &mpc->eqs[cq->comp_vector % mpc->num_queues]; cq_spec.attached_eq = eq->eq->id;
[ ... ]
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +1
-0@@ -462,10 +467,22 @@ static int mana_set_channels(struct net_device *ndev,unsigned int new_count = channels->combined_count;unsigned int old_count = apc->num_queues;int err; +/* Set channel_changing to block RDMA from grabbing the vport
drivers/net/ethernet/microsoft/mana/mana_ethtool.c static int mana_set_channels(struct net_device *ndev, · line 481
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +10
-0+* during the detach/attach window. mana_cfg_vport() checks +* this flag under vport_mutex and returns -EBUSY if set. +*/ +mutex_lock (&apc->vport_mutex); +if (!apc->port_is_up && apc->vport_use_count) { +mutex_unlock (&apc->vport_mutex); +return -EBUSY ; + } + apc->channel_changing = true; +mutex_unlock (&apc->vport_mutex);
[Low]
The commit message says:
When the port is down, apc->vport_mutex is held for the entire operation since mana_detach()/mana_attach() do not take vport_mutex in that case. When the port is up, Ethernet owns the vport exclusively so no additional locking is needed.
Does this description match the code? mana_set_channels() drops apc->vport_mutex immediately after setting channel_changing=true and runs mana_pre_alloc_rxbufs(), mana_detach() and mana_attach() without the mutex held, then re-acquires the mutex only at the end to clear the flag.
The actual serialization mechanism is the channel_changing boolean checked by mana_cfg_vport() under vport_mutex, not a long mutex hold. Could the commit message be updated to match the implemented design so that future readers do not assume a different invariant?
Signature · 1 line
This is an AI-generated review.
Paolo Abeni
maintainerRe: [PATCH net-next v10 1/6] net: mana: Create separate EQs for each vPort
Quoted 128 lines · Paolo Abeni
From: AI Reviewer <[email protected]>
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible. Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
net: mana: Create separate EQs for each vPortThis patch moves EQ allocation from per-device to per-vPort, exports mana_create_eq()/mana_destroy_eq() for use by the RDMA driver, takes a vport reference for RSS QPs, and adds cross-port PD-sharing rejection for raw QPs along with serialization between
mana_set_channels()and the RDMA vport configuration.Quoted 23 lines
drivers/infiniband/hw/mana/main.c +12
-0@@ -40,13 +42,27 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd, pd->vport_use_count++;if (pd->vport_use_count >1 ) { +/* Reject cross-port PD sharing. EQs and vport config +* are per-port, so the PD must stay bound to the port +* that was configured on the first raw QP creation. +*/ +if (pd->vport_port != port) { + pd->vport_use_count--; +mutex_unlock (&pd->vport_mutex); +ibdev_dbg (&dev->ib_dev, +"PD already bound to port %u\n" , + pd->vport_port); +return -EINVAL ; + }ibdev_dbg (&dev->ib_dev,"Skip as this PD is already configured vport\n" );mutex_unlock (&pd->vport_mutex);drivers/infiniband/hw/mana/main.c int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd, · line 68
Quoted 10 lines
drivers/infiniband/hw/mana/main.c +3
-1return 0 ; } - err =mana_cfg_vport (mpc, pd->pdn, doorbell_id); + pd->vport_port = port; + + err =mana_cfg_vport (mpc, pd->pdn, doorbell_id, true);if (err) { pd->vport_use_count--;mutex_unlock (&pd->vport_mutex);[Low]
In the failure path ofmana_ib_cfg_vport(), ifmana_cfg_vport()or the latermana_create_eq()fails,vport_use_countis rolled back to 0 butpd->vport_portkeeps the value just written.Is the contract that
pd->vport_portis only meaningful whilevport_use_count> 0? That invariant is not documented in the structmana_ib_pdcomment, and a future reader who consultspd->vport_portwithout first checkingvport_use_countundervport_mutexwould see stale data. Would it be worth either resettingpd->vport_porton the rollback path or documenting the rule explicitly?Quoted 16 lines
drivers/infiniband/hw/mana/main.c +8
-3@@ -55,15 +71,23 @@ int mana_ib_cfg_vport(struct mana_ib_dev *dev, u32 port, struct mana_ib_pd *pd,return err; } -mutex_unlock (&pd->vport_mutex); - pd->tx_shortform_allowed = mpc->tx_shortform_allowed; - pd->tx_vp_offset = mpc->tx_vp_offset; + err =mana_create_eq (mpc); +if (err) { +mana_uncfg_vport (mpc); + pd->vport_use_count--; + }else { + pd->tx_shortform_allowed = mpc->tx_shortform_allowed; + pd->tx_vp_offset = mpc->tx_vp_offset; + }[ ... ]
Quoted 10 lines
drivers/infiniband/hw/mana/qp.c +2
-0@@ -155,6 +156,18 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, qp->port = port; +/* Take a reference on the vport to ensure EQs outlive this QP. +* The vport must already be configured by a raw QP. drivers/infiniband/hw/mana/qp.c static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd, · line 170
Quoted 10 lines
drivers/infiniband/hw/mana/qp.c +10
-0+*/ +mutex_lock (&mana_pd->vport_mutex); +if (!mana_pd->vport_use_count) { +mutex_unlock (&mana_pd->vport_mutex); + ret = -EINVAL ; + goto fail; + } + mana_pd->vport_use_count++; +mutex_unlock (&mana_pd->vport_mutex); +[Critical]
The cross-port PD-sharing check added tomana_ib_cfg_vport()is not mirrored here.mana_ib_create_qp_rss()takes the user-supplied port from ucmd.port and only checks thatvport_use_countis non-zero, so the RSS path will happily attach to a different port than the one bound to the PD by the first raw QP.If a user creates a raw QP on port A (which sets pd->vport_port=A and allocates
mpc_A->eqsviamana_create_eq()), then creates an RSS QP on the same PD with ucmd.port=B where port B has no Ethernet up and no RDMA activity,mpc_B->eqsis NULL. The subsequent code in this same function:eq = &mpc->eqs[cq->comp_vector % mpc->num_queues]; cq_spec.attached_eq = eq->eq->id;would then dereference NULL through
mpc_B->eqs.If port B does have Ethernet up,
mpc_B->eqsis owned by the Ethernet driver and the RSS QP attaches to those EQs. When the QP is destroyedmana_ib_destroy_qp_rss()callsmana_ib_uncfg_vport(mdev, pd, qp->port=B), and oncepd->vport_use_countreaches 0mana_ib_uncfg_vport()will runmana_destroy_eq(mpc_B)on Ethernet's live EQs and callmana_uncfg_vporton a port whoseapc->vport_use_countwas never incremented by this PD, tripping theWARN_ONinmana_uncfg_vport()and corrupting Ethernet's vport state. Meanwhile port A's EQs and vport configuration are leaked because nothing on this PD will destroy them.
Quoted 3 lines
Should
mana_ib_create_qp_rss()apply the samepd->vport_port== port check thatmana_ib_cfg_vport()now performs, before bumpingvport_use_count?
Sashiko reported alredy this problematic pattern in 2 separate places. Please ensure that there are no other similar buggy usage pattern elsewhere in the newly introduced code.
/P
PATCH v10 2/6 net: mana: Query device capabilities and configure MSI-X sharing for EQs
In reply to Long LiWhen querying the device, adjust the max number of queues to allow dedicated MSI-X vectors for each vPort. The per-vPort queue count is clamped towards MANA_DEF_NUM_QUEUES but will not exceed the hardware maximum reported by the device.
MSI-X sharing among vPorts is enabled when there are not enough MSI-X vectors for dedicated allocation, or when the platform does not support dynamic MSI-X allocation (in which case all vectors are pre-allocated at probe time and sharing is always used). The msi_sharing flag is reset at the top of mana_gd_query_max_resources() so it is recomputed from current hardware state on each probe or resume cycle.
A device reporting zero ports now results in a fatal probe error since the per-vPort MSI-X math requires at least one port.
Rename mana_query_device_cfg() to mana_gd_query_device_cfg() as it is used at GDMA device probe time for querying device capabilities.
--- .../net/ethernet/microsoft/mana/gdma_main.c | 69 ++++++++++++++++++- drivers/net/ethernet/microsoft/mana/mana_en.c | 40 +++++++---- include/net/mana/gdma.h | 13 +++- 3 files changed, 103 insertions(+), 19 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +66 -3
@@ -179,8 +179,21 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)struct gdma_context *gc =pci_get_drvdata (pdev);struct gdma_query_max_resources_resp resp = {};struct gdma_general_req req = {}; +unsigned int max_num_queues; +u8 bm_hostmode; +u16 num_ports;int err; +/* Reset msi_sharing so it is recomputed from current hardware +* state. On resume, num_online_cpus() or num_msix_usable may +* have changed, making dedicated MSI-X feasible where it was +* not before. Only reset on platforms that support dynamic +* MSI-X allocation; on non-dyn platforms msi_sharing is +* unconditionally true (set in mana_gd_setup_hwc_irqs). +*/ +if (pci_msix_can_alloc_dyn (to_pci_dev (gc->dev))) + gc->msi_sharing = false; +mana_gd_init_req_hdr (&req.hdr,GDMA_QUERY_MAX_RESOURCES ,sizeof (req),sizeof (resp));
@@ -227,6 +240,43 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)if (gc->max_num_queues ==0 )return -ENOSPC ; + err =mana_gd_query_device_cfg (gc,MANA_MAJOR_VERSION , +MANA_MINOR_VERSION , +MANA_MICRO_VERSION , + &num_ports, &bm_hostmode); +if (err) +return err; + +if (!num_ports) +return -EINVAL ; + +/* +* Adjust the per-vPort max queue count to allow dedicated +* MSIx for each vPort. Clamp to no less than MANA_DEF_NUM_QUEUES. +*/ + max_num_queues = (gc->num_msix_usable -1 ) / num_ports; + max_num_queues =rounddown_pow_of_two (max (max_num_queues,1U )); +if (max_num_queues <MANA_DEF_NUM_QUEUES ) + max_num_queues =MANA_DEF_NUM_QUEUES ; + +/* +* Use dedicated MSIx for EQs whenever possible, use MSIx sharing for +* Ethernet EQs when (max_num_queues * num_ports > num_msix_usable - 1). +*/ + max_num_queues =min (gc->max_num_queues, max_num_queues); +if (max_num_queues * num_ports > gc->num_msix_usable -1 ) + gc->msi_sharing = true; + +/* If MSI is shared, use max allowed value */ +if (gc->msi_sharing) + gc->max_num_queues_vport =min (gc->num_msix_usable -1 , + gc->max_num_queues); +else + gc->max_num_queues_vport = max_num_queues; + +dev_info (gc->dev,"MSI sharing mode %d max queues %d\n" , + gc->msi_sharing, gc->max_num_queues); +return 0 ; }
@@ -1889,6 +1939,7 @@ static int mana_gd_setup_hwc_irqs(struct pci_dev *pdev)/* Need 1 interrupt for HWC */ max_irqs =min (num_online_cpus (),MANA_MAX_NUM_QUEUES ) +1 ; min_irqs =2 ; + gc->msi_sharing = true; } nvec =pci_alloc_irq_vectors (pdev, min_irqs, max_irqs,PCI_IRQ_MSIX );
@@ -1967,6 +2018,8 @@ static void mana_gd_remove_irqs(struct pci_dev *pdev)pci_free_irq_vectors (pdev); +bitmap_free (gc->msi_bitmap); + gc->msi_bitmap =NULL ; gc->max_num_msix =0 ; gc->num_msix_usable =0 ; }
@@ -2001,6 +2054,10 @@ static int mana_gd_setup(struct pci_dev *pdev)if (err) goto destroy_hwc; + err =mana_gd_detect_devices (pdev); +if (err) + goto destroy_hwc; + err =mana_gd_query_max_resources (pdev);if (err) goto destroy_hwc;
@@ -2011,9 +2068,15 @@ static int mana_gd_setup(struct pci_dev *pdev) goto destroy_hwc; } - err =mana_gd_detect_devices (pdev); -if (err) - goto destroy_hwc; +if (!gc->msi_sharing) { + gc->msi_bitmap =bitmap_zalloc (gc->num_msix_usable,GFP_KERNEL ); +if (!gc->msi_bitmap) { + err = -ENOMEM ; + goto destroy_hwc; + } +/* Set bit for HWC */ +set_bit (0 , gc->msi_bitmap); + }dev_dbg (&pdev->dev,"mana gdma setup successful\n" );return 0 ;
drivers/net/ethernet/microsoft/mana/mana_en.c +25 -15
@@ -1007,10 +1007,9 @@ static int mana_init_port_context(struct mana_port_context *apc)return !apc->rxqs ? -ENOMEM :0 ; } -static int mana_send_request (struct mana_context *ac,void *in_buf, -u32 in_len,void *out_buf,u32 out_len) +static int gdma_mana_send_request (struct gdma_context *gc,void *in_buf, +u32 in_len,void *out_buf,u32 out_len) { -struct gdma_context *gc = ac->gdma_dev->gdma_context;struct gdma_resp_hdr *resp = out_buf;struct gdma_req_hdr *req = in_buf;struct device *dev = gc->dev;
@@ -1044,6 +1043,14 @@ static int mana_send_request(struct mana_context *ac, void *in_buf,return 0 ; } +static int mana_send_request (struct mana_context *ac,void *in_buf, +u32 in_len,void *out_buf,u32 out_len) +{ +struct gdma_context *gc = ac->gdma_dev->gdma_context; + +return gdma_mana_send_request (gc, in_buf, in_len, out_buf, out_len); +} +static int mana_verify_resp_hdr (const struct gdma_resp_hdr *resp_hdr,const enum mana_command_code expected_code,const u32 min_size)
@@ -1177,11 +1184,10 @@ static void mana_pf_deregister_filter(struct mana_port_context *apc) err, resp.hdr.status); } -static int mana_query_device_cfg (struct mana_context *ac,u32 proto_major_ver, -u32 proto_minor_ver,u32 proto_micro_ver, -u16 *max_num_vports,u8 *bm_hostmode) +int mana_gd_query_device_cfg (struct gdma_context *gc,u32 proto_major_ver, +u32 proto_minor_ver,u32 proto_micro_ver, +u16 *max_num_vports,u8 *bm_hostmode) { -struct gdma_context *gc = ac->gdma_dev->gdma_context;struct mana_query_device_cfg_resp resp = {};struct mana_query_device_cfg_req req = {};struct device *dev = gc->dev;
@@ -1196,7 +1202,8 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver, req.proto_minor_ver = proto_minor_ver; req.proto_micro_ver = proto_micro_ver; - err =mana_send_request (ac, &req,sizeof (req), &resp,sizeof (resp)); + err =gdma_mana_send_request (gc, &req,sizeof (req), + &resp,sizeof (resp));if (err) {dev_err (dev,"Failed to query config: %d" , err);return err;
@@ -1230,8 +1237,6 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,else *bm_hostmode =0 ; -debugfs_create_u16 ("adapter-MTU" ,0400 , gc->mana_pci_debugfs, &gc->adapter_mtu); -return 0 ; }
@@ -3417,7 +3422,7 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,int err; ndev =alloc_etherdev_mq (sizeof (struct mana_port_context ), - gc->max_num_queues); + gc->max_num_queues_vport);if (!ndev)return -ENOMEM ;
@@ -3426,9 +3431,9 @@ static int mana_probe_port(struct mana_context *ac, int port_idx, apc =netdev_priv (ndev); apc->ac = ac; apc->ndev = ndev; - apc->max_queues = gc->max_num_queues; + apc->max_queues = gc->max_num_queues_vport;/* Use MANA_DEF_NUM_QUEUES as default, still honoring the HW limit */ - apc->num_queues =min (gc->max_num_queues,MANA_DEF_NUM_QUEUES ); + apc->num_queues =min (gc->max_num_queues_vport,MANA_DEF_NUM_QUEUES ); apc->tx_queue_size =DEF_TX_BUFFERS_PER_QUEUE ; apc->rx_queue_size =DEF_RX_BUFFERS_PER_QUEUE ; apc->port_handle =INVALID_MANA_HANDLE ;
@@ -3692,13 +3697,18 @@ int mana_probe(struct gdma_dev *gd, bool resuming)INIT_DELAYED_WORK (&ac->gf_stats_work, mana_gf_stats_work_handler); - err =mana_query_device_cfg (ac,MANA_MAJOR_VERSION ,MANA_MINOR_VERSION , -MANA_MICRO_VERSION , &num_ports, &bm_hostmode); + err =mana_gd_query_device_cfg (gc,MANA_MAJOR_VERSION , +MANA_MINOR_VERSION , +MANA_MICRO_VERSION , + &num_ports, &bm_hostmode);if (err) goto out; ac->bm_hostmode = bm_hostmode; +debugfs_create_u16 ("adapter-MTU" ,0400 , + gc->mana_pci_debugfs, &gc->adapter_mtu); +if (!resuming) { ac->num_ports = num_ports; }else {
include/net/mana/gdma.h +12 -1
@@ -399,8 +399,10 @@ struct gdma_context {struct device *dev;struct dentry *mana_pci_debugfs; -/* Per-vPort max number of queues */ +/* Hardware max number of queues */ unsigned int max_num_queues; +/* Per-vPort max number of queues */ +unsigned int max_num_queues_vport;unsigned int max_num_msix;unsigned int num_msix_usable;struct xarray irq_contexts;
@@ -446,6 +448,12 @@ struct gdma_context {struct workqueue_struct *service_wq;unsigned long flags; + +/* Indicate if this device is sharing MSI for EQs on MANA */ +bool msi_sharing; + +/* Bitmap tracks where MSI is allocated when it is not shared for EQs */ +unsigned long *msi_bitmap; };static inline bool mana_gd_is_mana (struct gdma_dev *gd)
@@ -1018,4 +1026,7 @@ int mana_gd_resume(struct pci_dev *pdev);bool mana_need_log (struct gdma_context *gc,int err); +int mana_gd_query_device_cfg (struct gdma_context *gc,u32 proto_major_ver, +u32 proto_minor_ver,u32 proto_micro_ver, +u16 *max_num_vports,u8 *bm_hostmode);#endif /* _GDMA_H */
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v10 2/6] net: mana: Query device capabilities and configure MSI-X sharing for EQs
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Per-vPort queue counts are not clamped across device resume, leading to MSI-X vector exhaustion…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Per-vPort queue counts are not clamped across device resume, leading to MSI-X vector exhaustion and resume failure if available interrupts shrink. --
commit 5d1fd25db612c4024c6a414d322389f154cfe998
Author: Long Li <[email protected]> Date: Fri May 15 04:05:04 2026 +0000
net: mana: Query device capabilities and configure MSI-X sharing for EQs
This commit adjusts the maximum number of queues to allow dedicated MSI-X vectors for each vPort, calculating per-vPort limits based on hardware capabilities. It enables MSI-X sharing dynamically when there are not enough vectors for dedicated allocation and ensures a minimum of one port during probe.
Quoted 4 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +0
-0
[ ... ]
drivers/net/ethernet/microsoft/mana/mana_en.c static int mana_probe_port(struct mana_context *ac, int port_idx, · line 3437
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +2
-2@@ -3426,9 +3431,9 @@ static int mana_probe_port(struct mana_context *ac, int port_idx, apc =netdev_priv (ndev); apc->ac = ac; apc->ndev = ndev; - apc->max_queues = gc->max_num_queues; + apc->max_queues = gc->max_num_queues_vport;/* Use MANA_DEF_NUM_QUEUES as default, still honoring the HW limit */ - apc->num_queues =min (gc->max_num_queues,MANA_DEF_NUM_QUEUES ); + apc->num_queues =min (gc->max_num_queues_vport,MANA_DEF_NUM_QUEUES ); apc->tx_queue_size =DEF_TX_BUFFERS_PER_QUEUE ;
Does this code handle clamping apc->num_queues if the available MSI-X vectors decrease during a suspend/resume cycle?
During a device resume, mana_gd_query_max_resources() might recalculate a smaller gc->max_num_queues_vport if fewer MSI-X vectors are provided by the system.
Since apc->num_queues is set here during the initial probe, it appears to retain its previously configured size on resume. When mana_attach() is called in the resume path for existing ports, could it try to allocate the old, larger number of vectors from the newly undersized msi_bitmap, exhausting the bitmap and failing the resume with -ENOMEM?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v10 3/6 net: mana: Introduce GIC context with refcounting for interrupt management
In reply to Long LiTo allow Ethernet EQs to use dedicated or shared MSI-X vectors and RDMA EQs to share the same MSI-X, introduce a GIC (GDMA IRQ Context) with reference counting. This allows the driver to create an interrupt context on an assigned or unassigned MSI-X vector and share it across multiple EQ consumers.
--- .../net/ethernet/microsoft/mana/gdma_main.c | 159 ++++++++++++++++++ include/net/mana/gdma.h | 12 ++ 2 files changed, 171 insertions(+)
drivers/net/ethernet/microsoft/mana/gdma_main.c +159 -0
@@ -1658,6 +1658,164 @@ static irqreturn_t mana_gd_intr(int irq, void *arg)return IRQ_HANDLED ; } +void mana_gd_put_gic (struct gdma_context *gc,bool use_msi_bitmap,int msi) +{ +struct pci_dev *dev =to_pci_dev (gc->dev); +struct gdma_irq_context *gic; +struct msi_map irq_map; +int irq; + +mutex_lock (&gc->gic_mutex); + + gic =xa_load (&gc->irq_contexts, msi); +if (WARN_ON (!gic)) { +mutex_unlock (&gc->gic_mutex); +return ; + } + +if (use_msi_bitmap) + gic->bitmap_refs--; + +if (use_msi_bitmap && gic->bitmap_refs ==0 ) +clear_bit (msi, gc->msi_bitmap); + +if (!refcount_dec_and_test (&gic->refcount)) + goto out; + + irq = gic->irq; + +irq_update_affinity_hint (irq,NULL ); +free_irq (irq, gic); + +if (gic->dyn_msix) { + irq_map.virq = irq; + irq_map.index = msi; +pci_msix_free_irq (dev, irq_map); + } + +xa_erase (&gc->irq_contexts, msi); +kfree (gic); + +out: +mutex_unlock (&gc->gic_mutex); +} +EXPORT_SYMBOL_NS (mana_gd_put_gic,"NET_MANA" ); + +/* +* Get a GIC (GDMA IRQ Context) on a MSI vector +* a MSI can be shared between different EQs, this function supports setting +* up separate MSIs using a bitmap, or directly using the MSI index +* +* @use_msi_bitmap: +* True if MSI is assigned by this function on available slots from bitmap. +* False if MSI is passed from *msi_requested +*/ +struct gdma_irq_context *mana_gd_get_gic (struct gdma_context *gc, +bool use_msi_bitmap, +int *msi_requested) +{ +struct pci_dev *dev =to_pci_dev (gc->dev); +struct gdma_irq_context *gic; +struct msi_map irq_map = { }; +int irq; +int msi; +int err; + +mutex_lock (&gc->gic_mutex); + +if (use_msi_bitmap) { + msi =find_first_zero_bit (gc->msi_bitmap, gc->num_msix_usable); +if (msi >= gc->num_msix_usable) { +dev_err (gc->dev,"No free MSI vectors available\n" ); + gic =NULL ; + goto out; + } + *msi_requested = msi; + }else { + msi = *msi_requested; + } + + gic =xa_load (&gc->irq_contexts, msi); +if (gic) { +refcount_inc (&gic->refcount); +if (use_msi_bitmap) { + gic->bitmap_refs++; +set_bit (msi, gc->msi_bitmap); + } + goto out; + } + + irq =pci_irq_vector (dev, msi); +if (irq == -EINVAL ) { + irq_map =pci_msix_alloc_irq_at (dev, msi,NULL ); +if (!irq_map.virq) { + err = irq_map.index; +dev_err (gc->dev, +"Failed to alloc irq_map msi %d err %d\n" , + msi, err); + gic =NULL ; + goto out; + } + irq = irq_map.virq; + msi = irq_map.index; + } + + gic =kzalloc (sizeof (*gic),GFP_KERNEL ); +if (!gic) { +if (irq_map.virq) +pci_msix_free_irq (dev, irq_map); + goto out; + } + + gic->handler = mana_gd_process_eq_events; + gic->msi = msi; + gic->irq = irq; +INIT_LIST_HEAD (&gic->eq_list); +spin_lock_init (&gic->lock); + +if (!gic->msi) +snprintf (gic->name,MANA_IRQ_NAME_SZ ,"mana_hwc@pci:%s" , +pci_name (dev)); +else +snprintf (gic->name,MANA_IRQ_NAME_SZ ,"mana_msi%d@pci:%s" , + gic->msi,pci_name (dev)); + + err =request_irq (irq, mana_gd_intr,0 , gic->name, gic); +if (err) { +dev_err (gc->dev,"Failed to request irq %d %s\n" , + irq, gic->name); +kfree (gic); + gic =NULL ; +if (irq_map.virq) +pci_msix_free_irq (dev, irq_map); + goto out; + } + + gic->dyn_msix = !!irq_map.virq; +refcount_set (&gic->refcount,1 ); + gic->bitmap_refs = use_msi_bitmap ?1 :0 ; + + err =xa_err (xa_store (&gc->irq_contexts, msi, gic,GFP_KERNEL )); +if (err) { +dev_err (gc->dev,"Failed to store irq context for msi %d: %d\n" , + msi, err); +free_irq (irq, gic); +kfree (gic); + gic =NULL ; +if (irq_map.virq) +pci_msix_free_irq (dev, irq_map); + goto out; + } + +if (use_msi_bitmap) +set_bit (msi, gc->msi_bitmap); + +out: +mutex_unlock (&gc->gic_mutex); +return gic; +} +EXPORT_SYMBOL_NS (mana_gd_get_gic,"NET_MANA" ); +int mana_gd_alloc_res_map (u32 res_avail,struct gdma_resource *r) { r->map =bitmap_zalloc (res_avail,GFP_KERNEL );
@@ -2147,6 +2305,7 @@ static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto release_region;mutex_init (&gc->eq_test_event_mutex); +mutex_init (&gc->gic_mutex);pci_set_drvdata (pdev, gc); gc->bar0_pa =pci_resource_start (pdev,0 ); gc->bar0_size =pci_resource_len (pdev,0 );
include/net/mana/gdma.h +12 -0
@@ -388,6 +388,11 @@ struct gdma_irq_context {spinlock_t lock;struct list_head eq_list;char name[MANA_IRQ_NAME_SZ ]; +unsigned int msi; +unsigned int irq; +refcount_t refcount; +unsigned int bitmap_refs; +bool dyn_msix; };enum gdma_context_flags {
@@ -449,6 +454,9 @@ struct gdma_context {unsigned long flags; +/* Protect access to GIC context */ +struct mutex gic_mutex; +/* Indicate if this device is sharing MSI for EQs on MANA */ bool msi_sharing;
@@ -1026,6 +1034,10 @@ int mana_gd_resume(struct pci_dev *pdev);bool mana_need_log (struct gdma_context *gc,int err); +struct gdma_irq_context *mana_gd_get_gic (struct gdma_context *gc, +bool use_msi_bitmap, +int *msi_requested); +void mana_gd_put_gic (struct gdma_context *gc,bool use_msi_bitmap,int msi);int mana_gd_query_device_cfg (struct gdma_context *gc,u32 proto_major_ver,u32 proto_minor_ver,u32 proto_micro_ver,u16 *max_num_vports,u8 *bm_hostmode);
Signature · 1 line
2.43.0
PATCH v10 4/6 net: mana: Use GIC functions to allocate global EQs
In reply to Long LiReplace the GDMA global interrupt setup code with the new GIC allocation and release functions for managing interrupt contexts.
This changes the per-queue interrupt names in /proc/interrupts from mana_q0, mana_q1, ... to mana_msi1, mana_msi2, ... to reflect the MSI-X index rather than a zero-based queue number. The HWC interrupt name (mana_hwc) is unchanged.
--- .../net/ethernet/microsoft/mana/gdma_main.c | 96 +++---------------- 1 file changed, 13 insertions(+), 83 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +13 -83
@@ -1918,7 +1918,7 @@ static int mana_gd_setup_dyn_irqs(struct pci_dev *pdev, int nvec)struct gdma_context *gc =pci_get_drvdata (pdev);struct gdma_irq_context *gic;bool skip_first_cpu = false; -int *irqs, irq, err, i; +int *irqs, err, i; irqs =kmalloc_objs (int, nvec);if (!irqs)
@@ -1931,30 +1931,13 @@ static int mana_gd_setup_dyn_irqs(struct pci_dev *pdev, int nvec)* further used in irq_setup() */ for (i =1 ; i <= nvec; i++) { - gic =kzalloc_obj (*gic); + gic =mana_gd_get_gic (gc, false, &i);if (!gic) { err = -ENOMEM ; goto free_irq; } - gic->handler = mana_gd_process_eq_events; -INIT_LIST_HEAD (&gic->eq_list); -spin_lock_init (&gic->lock); - -snprintf (gic->name,MANA_IRQ_NAME_SZ ,"mana_q%d@pci:%s" , - i -1 ,pci_name (pdev)); - -/* one pci vector is already allocated for HWC */ - irqs[i -1 ] =pci_irq_vector (pdev, i); -if (irqs[i -1 ] <0 ) { - err = irqs[i -1 ]; - goto free_current_gic; - } - - err =request_irq (irqs[i -1 ], mana_gd_intr,0 , gic->name, gic); -if (err) - goto free_current_gic; -xa_store (&gc->irq_contexts, i, gic,GFP_KERNEL ); + irqs[i -1 ] = gic->irq; }/*
@@ -1976,20 +1959,9 @@ static int mana_gd_setup_dyn_irqs(struct pci_dev *pdev, int nvec)kfree (irqs);return 0 ; -free_current_gic: -kfree (gic); free_irq: -for (i -=1 ; i >0 ; i--) { - irq =pci_irq_vector (pdev, i); - gic =xa_load (&gc->irq_contexts, i); -if (WARN_ON (!gic)) -continue ; - -irq_update_affinity_hint (irq,NULL ); -free_irq (irq, gic); -xa_erase (&gc->irq_contexts, i); -kfree (gic); - } +for (i -=1 ; i >0 ; i--) +mana_gd_put_gic (gc, false, i);kfree (irqs);return err; }
@@ -1998,7 +1970,7 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev, int nvec) {struct gdma_context *gc =pci_get_drvdata (pdev);struct gdma_irq_context *gic; -int *irqs, *start_irqs, irq; +int *irqs, *start_irqs;unsigned int cpu;int err, i;
@@ -2009,34 +1981,13 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev, int nvec) start_irqs = irqs;for (i =0 ; i < nvec; i++) { - gic =kzalloc_obj (*gic); + gic =mana_gd_get_gic (gc, false, &i);if (!gic) { err = -ENOMEM ; goto free_irq; } - gic->handler = mana_gd_process_eq_events; -INIT_LIST_HEAD (&gic->eq_list); -spin_lock_init (&gic->lock); - -if (!i) -snprintf (gic->name,MANA_IRQ_NAME_SZ ,"mana_hwc@pci:%s" , -pci_name (pdev)); -else -snprintf (gic->name,MANA_IRQ_NAME_SZ ,"mana_q%d@pci:%s" , - i -1 ,pci_name (pdev)); - - irqs[i] =pci_irq_vector (pdev, i); -if (irqs[i] <0 ) { - err = irqs[i]; - goto free_current_gic; - } - - err =request_irq (irqs[i], mana_gd_intr,0 , gic->name, gic); -if (err) - goto free_current_gic; - -xa_store (&gc->irq_contexts, i, gic,GFP_KERNEL ); + irqs[i] = gic->irq; }/* If number of IRQ is one extra than number of online CPUs,
@@ -2065,20 +2016,9 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev, int nvec)kfree (start_irqs);return 0 ; -free_current_gic: -kfree (gic); free_irq: -for (i -=1 ; i >=0 ; i--) { - irq =pci_irq_vector (pdev, i); - gic =xa_load (&gc->irq_contexts, i); -if (WARN_ON (!gic)) -continue ; - -irq_update_affinity_hint (irq,NULL ); -free_irq (irq, gic); -xa_erase (&gc->irq_contexts, i); -kfree (gic); - } +for (i -=1 ; i >=0 ; i--) +mana_gd_put_gic (gc, false, i);kfree (start_irqs);return err;
@@ -2152,26 +2092,16 @@ static int mana_gd_setup_remaining_irqs(struct pci_dev *pdev)static void mana_gd_remove_irqs (struct pci_dev *pdev) {struct gdma_context *gc =pci_get_drvdata (pdev); -struct gdma_irq_context *gic; -int irq, i; +int i;if (gc->max_num_msix <1 )return ;for (i =0 ; i < gc->max_num_msix; i++) { - irq =pci_irq_vector (pdev, i); -if (irq <0 ) -continue ; - - gic =xa_load (&gc->irq_contexts, i); -if (WARN_ON (!gic)) +if (!xa_load (&gc->irq_contexts, i))continue ; -/* Need to clear the hint before free_irq */ -irq_update_affinity_hint (irq,NULL ); -free_irq (irq, gic); -xa_erase (&gc->irq_contexts, i); -kfree (gic); +mana_gd_put_gic (gc, false, i); }pci_free_irq_vectors (pdev);
Signature · 1 line
2.43.0
PATCH v10 5/6 net: mana: Allocate interrupt context for each EQ when creating vPort
In reply to Long LiUse GIC functions to create a dedicated interrupt context or acquire a shared interrupt context for each EQ when setting up a vPort.
The caller now owns the GIC reference across the EQ create/destroy
lifecycle: mana_create_eq() calls mana_gd_get_gic() before creating each EQ and mana_destroy_eq() calls mana_gd_put_gic() after destroying it. The msix_index invalidation is moved from mana_gd_deregister_irq() to the mana_gd_create_eq() error path so that mana_destroy_eq() can read the index before teardown.
--- .../net/ethernet/microsoft/mana/gdma_main.c | 2 +- drivers/net/ethernet/microsoft/mana/mana_en.c | 18 +++++++++++++++++- include/net/mana/gdma.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +1 -1
@@ -897,7 +897,6 @@ static void mana_gd_deregister_irq(struct gdma_queue *queue) }spin_unlock_irqrestore (&gic->lock, flags); - queue->eq.msix_index =INVALID_PCI_MSIX_INDEX ;synchronize_rcu (); }
@@ -1012,6 +1011,7 @@ static int mana_gd_create_eq(struct gdma_dev *gd, out:dev_err (dev,"Failed to create EQ: %d\n" , err);mana_gd_destroy_eq (gc, false, queue); + queue->eq.msix_index =INVALID_PCI_MSIX_INDEX ;return err; }
drivers/net/ethernet/microsoft/mana/mana_en.c +17 -1
@@ -1626,6 +1626,7 @@ void mana_destroy_eq(struct mana_port_context *apc)struct mana_context *ac = apc->ac;struct gdma_context *gc = ac->gdma_dev->gdma_context;struct gdma_queue *eq; +unsigned int msi;int i;if (!apc->eqs)
@@ -1639,7 +1640,9 @@ void mana_destroy_eq(struct mana_port_context *apc)if (!eq)continue ; + msi = eq->eq.msix_index;mana_gd_destroy_queue (gc, eq); +mana_gd_put_gic (gc, !gc->msi_sharing, msi); }kfree (apc->eqs);
@@ -1656,6 +1659,7 @@ static void mana_create_eq_debugfs(struct mana_port_context *apc, int i) eq.mana_eq_debugfs =debugfs_create_dir (eqnum, apc->mana_eqs_debugfs);debugfs_create_u32 ("head" ,0400 , eq.mana_eq_debugfs, &eq.eq->head);debugfs_create_u32 ("tail" ,0400 , eq.mana_eq_debugfs, &eq.eq->tail); +debugfs_create_u32 ("irq" ,0400 , eq.mana_eq_debugfs, &eq.eq->eq.irq);debugfs_create_file ("eq_dump" ,0400 , eq.mana_eq_debugfs, eq.eq, &mana_dbg_q_fops); }
@@ -1664,7 +1668,9 @@ int mana_create_eq(struct mana_port_context *apc)struct gdma_dev *gd = apc->ac->gdma_dev;struct gdma_context *gc = gd->gdma_context;struct gdma_queue_spec spec = {}; +struct gdma_irq_context *gic;int err; +int msi;int i;if (WARN_ON (apc->eqs))
@@ -1684,12 +1690,22 @@ int mana_create_eq(struct mana_port_context *apc)debugfs_create_dir ("EQs" , apc->mana_port_debugfs);for (i =0 ; i < apc->num_queues; i++) { - spec.eq.msix_index = (i +1 ) % gc->num_msix_usable; + msi = (i +1 ) % gc->num_msix_usable; + + gic =mana_gd_get_gic (gc, !gc->msi_sharing, &msi); +if (!gic) { + err = -ENOMEM ; + goto out; + } + spec.eq.msix_index = msi; + err =mana_gd_create_mana_eq (gd, &spec, &apc->eqs[i].eq);if (err) {dev_err (gc->dev,"Failed to create EQ %d : %d\n" , i, err); +mana_gd_put_gic (gc, !gc->msi_sharing, msi); goto out; } + apc->eqs[i].eq->eq.irq = gic->irq;mana_create_eq_debugfs (apc, i); }
include/net/mana/gdma.h +1 -0
@@ -342,6 +342,7 @@ struct gdma_queue {void *context;unsigned int msix_index; +unsigned int irq;u32 log2_throttle_limit; } eq;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v10 5/6] net: mana: Allocate interrupt context for each EQ when creating vPort
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The RDMA driver (mana_ib) fails to initialize because it does not allocate GIC references for its…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The RDMA driver (mana_ib) fails to initialize because it does not allocate GIC references for its EQs. --
commit 9f615e81497dbea890c8df0a9aa9efd643e9a6a7
Author: Long Li <[email protected]>
net: mana: Allocate interrupt context for each EQ when creating vPort
This commit updates the driver to use GIC functions to create a dedicated interrupt context or acquire a shared interrupt context for each EQ when setting up a vPort. The caller is now responsible for acquiring and releasing the GIC reference across the EQ create/destroy lifecycle.
Quoted 3 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +0
-0
[ ... ]
drivers/net/ethernet/microsoft/mana/mana_en.c int mana_create_eq(struct mana_port_context *apc) · line 1700
Quoted 13 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +8
-1@@ -1684,12 +1690,22 @@ int mana_create_eq(struct mana_port_context *apc)debugfs_create_dir ("EQs" , apc->mana_port_debugfs);for (i =0 ; i < apc->num_queues; i++) { - spec.eq.msix_index = (i +1 ) % gc->num_msix_usable; + msi = (i +1 ) % gc->num_msix_usable; + + gic =mana_gd_get_gic (gc, !gc->msi_sharing, &msi); +if (!gic) { + err = -ENOMEM ; + goto out; + } + spec.eq.msix_index = msi;
Will this change to the initialization logic break the RDMA driver (mana_ib)?
Since the caller is now required to manually acquire a GIC reference via mana_gd_get_gic() before creating EQs, and mana_ib hasn't been updated to do this, won't it trigger a WARN_ON(!gic) inside mana_gd_register_irq() and fail device initialization?
I noticed this was fixed later in the patch series by commit 'RDMA/mana_ib:
Allocate interrupt contexts on EQs', but could this break bisectability here?
Quoted 2 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +1
-0+ err =mana_gd_create_mana_eq (gd, &spec, &apc->eqs[i].eq);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v10 6/6 RDMA/mana_ib: Allocate interrupt contexts on EQs
In reply to Long LiUse the GIC functions to allocate interrupt contexts for RDMA EQs. These interrupt contexts may be shared with Ethernet EQs when MSI-X vectors are limited.
The driver now supports allocating dedicated MSI-X for each EQ. Indicate this capability through driver capability bits. The RDMA EQs pass use_msi_bitmap=false to share MSI-X vectors with Ethernet, while the capability flag advertises that the driver supports per-vPort EQ separation when hardware has sufficient vectors.
Populate eq.irq on all RDMA EQs for consistency with the Ethernet path.
Also relocate the GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE define to its numeric BIT(6) position among the other capability flags.
--- drivers/infiniband/hw/mana/main.c | 43 +++++++++++++++++++++++++------ include/net/mana/gdma.h | 7 +++-- 2 files changed, 40 insertions(+), 10 deletions(-)
drivers/infiniband/hw/mana/main.c +35 -8
@@ -764,7 +764,8 @@ int mana_ib_create_eqs(struct mana_ib_dev *mdev) {struct gdma_context *gc =mdev_to_gc (mdev);struct gdma_queue_spec spec = {}; -int err, i; +struct gdma_irq_context *gic; +int err, i, msi; spec.type =GDMA_EQ ; spec.monitor_avl_buf = false;
@@ -772,11 +773,19 @@ int mana_ib_create_eqs(struct mana_ib_dev *mdev) spec.eq.callback = mana_ib_event_handler; spec.eq.context = mdev; spec.eq.log2_throttle_limit =LOG2_EQ_THROTTLE ; - spec.eq.msix_index =0 ; + + msi =0 ; + gic =mana_gd_get_gic (gc, false, &msi); +if (!gic) +return -ENOMEM ; + spec.eq.msix_index = msi; err =mana_gd_create_mana_eq (mdev->gdma_dev, &spec, &mdev->fatal_err_eq); -if (err) +if (err) { +mana_gd_put_gic (gc, false,0 );return err; + } + mdev->fatal_err_eq->eq.irq = gic->irq; mdev->eqs = kzalloc_objs(struct gdma_queue *, mdev->ib_dev.num_comp_vectors);
@@ -786,32 +795,50 @@ int mana_ib_create_eqs(struct mana_ib_dev *mdev) } spec.eq.callback =NULL ;for (i =0 ; i < mdev->ib_dev.num_comp_vectors; i++) { - spec.eq.msix_index = (i +1 ) % gc->num_msix_usable; + msi = (i +1 ) % gc->num_msix_usable; + + gic =mana_gd_get_gic (gc, false, &msi); +if (!gic) { + err = -ENOMEM ; + goto destroy_eqs; + } + spec.eq.msix_index = msi; + err =mana_gd_create_mana_eq (mdev->gdma_dev, &spec, &mdev->eqs[i]); -if (err) +if (err) { +mana_gd_put_gic (gc, false, msi); goto destroy_eqs; + } + mdev->eqs[i]->eq.irq = gic->irq; }return 0 ; destroy_eqs: -while (i-- >0 ) +while (i-- >0 ) {mana_gd_destroy_queue (gc, mdev->eqs[i]); +mana_gd_put_gic (gc, false, (i +1 ) % gc->num_msix_usable); + }kfree (mdev->eqs); destroy_fatal_eq:mana_gd_destroy_queue (gc, mdev->fatal_err_eq); +mana_gd_put_gic (gc, false,0 );return err; }void mana_ib_destroy_eqs (struct mana_ib_dev *mdev) {struct gdma_context *gc =mdev_to_gc (mdev); -int i; +int i, msi;mana_gd_destroy_queue (gc, mdev->fatal_err_eq); +mana_gd_put_gic (gc, false,0 ); -for (i =0 ; i < mdev->ib_dev.num_comp_vectors; i++) +for (i =0 ; i < mdev->ib_dev.num_comp_vectors; i++) {mana_gd_destroy_queue (gc, mdev->eqs[i]); + msi = (i +1 ) % gc->num_msix_usable; +mana_gd_put_gic (gc, false, msi); + }kfree (mdev->eqs); }
include/net/mana/gdma.h +5 -2
@@ -615,6 +615,7 @@ enum {#define GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG BIT(3)#define GDMA_DRV_CAP_FLAG_1_GDMA_PAGES_4MB_1GB_2GB BIT(4)#define GDMA_DRV_CAP_FLAG_1_VARIABLE_INDIRECTION_TABLE_SUPPORT BIT(5) +#define GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE BIT(6)/* Driver can handle holes (zeros) in the device list */ #define GDMA_DRV_CAP_FLAG_1_DEV_LIST_HOLES_SUP BIT(11)
@@ -631,7 +632,8 @@ enum {/* Driver detects stalled send queues and recovers them */ #define GDMA_DRV_CAP_FLAG_1_HANDLE_STALL_SQ_RECOVERY BIT(18) -#define GDMA_DRV_CAP_FLAG_1_HW_VPORT_LINK_AWARE BIT(6) +/* Driver supports separate EQ/MSIs for each vPort */ +#define GDMA_DRV_CAP_FLAG_1_EQ_MSI_UNSHARE_MULTI_VPORT BIT(19)/* Driver supports linearizing the skb when num_sge exceeds hardware limit */ #define GDMA_DRV_CAP_FLAG_1_SKB_LINEARIZE BIT(20)
@@ -659,7 +661,8 @@ enum {GDMA_DRV_CAP_FLAG_1_SKB_LINEARIZE | \GDMA_DRV_CAP_FLAG_1_PROBE_RECOVERY | \GDMA_DRV_CAP_FLAG_1_HANDLE_STALL_SQ_RECOVERY | \ - GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECOVERY) +GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECOVERY | \ + GDMA_DRV_CAP_FLAG_1_EQ_MSI_UNSHARE_MULTI_VPORT) #define GDMA_DRV_CAP_FLAGS2 0
Signature · 1 line
2.43.0