RDMA/irdma: Add enum defs for reserved CQs/QPs
Subsystems (2)
PATCH 1/2 RDMA/irdma: Add enum defs for reserved CQs/QPs
Added definitions for the special reserved CQs and QPs.
--- drivers/infiniband/hw/irdma/hw.c | 20 ++++++++++---------- drivers/infiniband/hw/irdma/type.h | 12 ++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-)
drivers/infiniband/hw/irdma/hw.c +10 -10
@@ -1532,8 +1532,8 @@ static int irdma_initialize_ilq(struct irdma_device *iwdev)int status; info.type =IRDMA_PUDA_RSRC_TYPE_ILQ ; - info.cq_id =1 ; - info.qp_id =1 ; + info.cq_id =IRDMA_RSVD_CQ_ID_ILQ ; + info.qp_id =IRDMA_RSVD_QP_ID_GSI_ILQ ; info.count =1 ; info.pd_id =1 ; info.abi_ver =IRDMA_ABI_VER ;
@@ -1562,7 +1562,7 @@ static int irdma_initialize_ieq(struct irdma_device *iwdev)int status; info.type =IRDMA_PUDA_RSRC_TYPE_IEQ ; - info.cq_id =2 ; + info.cq_id =IRDMA_RSVD_CQ_ID_IEQ ; info.qp_id = iwdev->vsi.exception_lan_q; info.count =1 ; info.pd_id =2 ;
@@ -1868,7 +1868,7 @@ int irdma_rt_init_hw(struct irdma_device *iwdev, vsi_info.pf_data_vsi_num = iwdev->vsi_num; vsi_info.register_qset = rf->gen_ops.register_qset; vsi_info.unregister_qset = rf->gen_ops.unregister_qset; - vsi_info.exception_lan_q =2 ; + vsi_info.exception_lan_q =IRDMA_RSVD_QP_ID_IEQ ;irdma_sc_vsi_init (&iwdev->vsi, &vsi_info); status =irdma_setup_cm_core (iwdev, rf->rdma_ver);
@@ -2099,18 +2099,18 @@ u32 irdma_initialize_hw_rsrc(struct irdma_pci_f *rf)irdma_set_hw_rsrc (rf);set_bit (0 , rf->allocated_mrs); -set_bit (0 , rf->allocated_qps); -set_bit (0 , rf->allocated_cqs); +set_bit (IRDMA_RSVD_QP_ID_0 , rf->allocated_qps); +set_bit (IRDMA_RSVD_CQ_ID_CQP , rf->allocated_cqs);set_bit (0 , rf->allocated_srqs);set_bit (0 , rf->allocated_pds);set_bit (0 , rf->allocated_arps);set_bit (0 , rf->allocated_ahs);set_bit (0 , rf->allocated_mcgs); -set_bit (2 , rf->allocated_qps);/* qp 2 IEQ */ -set_bit (1 , rf->allocated_qps);/* qp 1 ILQ */ -set_bit (1 , rf->allocated_cqs); +set_bit (IRDMA_RSVD_QP_ID_IEQ , rf->allocated_qps); +set_bit (IRDMA_RSVD_QP_ID_GSI_ILQ , rf->allocated_qps); +set_bit (IRDMA_RSVD_CQ_ID_ILQ , rf->allocated_cqs);set_bit (1 , rf->allocated_pds); -set_bit (2 , rf->allocated_cqs); +set_bit (IRDMA_RSVD_CQ_ID_IEQ , rf->allocated_cqs);set_bit (2 , rf->allocated_pds);INIT_LIST_HEAD (&rf->mc_qht_list.list);
drivers/infiniband/hw/irdma/type.h +12 -0
@@ -239,6 +239,18 @@ enum irdma_queue_type { IRDMA_QUEUE_TYPE_SRQ, }; +enum irdma_rsvd_cq_id { +IRDMA_RSVD_CQ_ID_CQP , +IRDMA_RSVD_CQ_ID_ILQ , +IRDMA_RSVD_CQ_ID_IEQ , +}; + +enum irdma_rsvd_qp_id { +IRDMA_RSVD_QP_ID_0 , +IRDMA_RSVD_QP_ID_GSI_ILQ , +IRDMA_RSVD_QP_ID_IEQ , +}; +struct irdma_sc_dev ;struct irdma_vsi_pestat ;
Signature · 1 line
2.52.0.457.g6b5491de43-goog
PATCH 2/2 RDMA/irdma: Use CQ ID for CEQE context
The hardware allows for an opaque CQ context field to be carried over into CEQEs for the CQ. Previously, a pointer to the CQ was used for this context. In the normal CQ destroy flow, the CEQ ring is scrubbed to remove any preexisting CEQEs for the CQ that may not have been processed yet so that the CQ structure is not dereferenced in the CEQ ISR after the CQ has been freed.
However, in some cases, it is possible for a CEQE to be in flight in HW even after the CQ destroy command completion is received, so it could be missed during the scrub.
To protect against this, we can take advantage of the CQ table that already exists and use the CQ ID for this context rather than a CQ pointer.
--- drivers/infiniband/hw/irdma/ctrl.c | 62 ++++++++------------ drivers/infiniband/hw/irdma/hw.c | 88 +++++++++++++++++++++++++---- drivers/infiniband/hw/irdma/puda.c | 14 +++++ drivers/infiniband/hw/irdma/type.h | 6 +- drivers/infiniband/hw/irdma/utils.c | 3 +- drivers/infiniband/hw/irdma/verbs.c | 5 +- 6 files changed, 127 insertions(+), 51 deletions(-)
drivers/infiniband/hw/irdma/ctrl.c +24 -38
@@ -2886,15 +2886,6 @@ static int irdma_sc_resume_qp(struct irdma_sc_cqp *cqp, struct irdma_sc_qp *qp,return 0 ; } -/** -* irdma_sc_cq_ack - acknowledge completion q -* @cq: cq struct -*/ -static inline void irdma_sc_cq_ack (struct irdma_sc_cq *cq) -{ -writel (cq->cq_uk.cq_id, cq->cq_uk.cq_ack_db); -} -/** * irdma_sc_cq_init - initialize completion q * @cq: cq struct
@@ -2956,7 +2947,7 @@ static int irdma_sc_cq_create(struct irdma_sc_cq *cq, u64 scratch,return -ENOMEM ;set_64bit_val (wqe,0 , cq->cq_uk.cq_size); -set_64bit_val (wqe,8 , (uintptr_t )cq >>1 ); +set_64bit_val (wqe,8 , cq->cq_uk.cq_id);set_64bit_val (wqe,16 ,FIELD_PREP (IRDMA_CQPSQ_CQ_SHADOW_READ_THRESHOLD , cq->shadow_read_threshold));set_64bit_val (wqe,32 , (cq->virtual_map ?0 : cq->cq_pa));
@@ -3013,7 +3004,7 @@ int irdma_sc_cq_destroy(struct irdma_sc_cq *cq, u64 scratch, bool post_sq)return -ENOMEM ;set_64bit_val (wqe,0 , cq->cq_uk.cq_size); -set_64bit_val (wqe,8 , (uintptr_t )cq >>1 ); +set_64bit_val (wqe,8 , cq->cq_uk.cq_id);set_64bit_val (wqe,40 , cq->shadow_area_pa);set_64bit_val (wqe,48 , (cq->virtual_map ? cq->first_pm_pbl_idx :0 ));
@@ -3082,7 +3073,7 @@ static int irdma_sc_cq_modify(struct irdma_sc_cq *cq,return -ENOMEM ;set_64bit_val (wqe,0 , info->cq_size); -set_64bit_val (wqe,8 , (uintptr_t )cq >>1 ); +set_64bit_val (wqe,8 , cq->cq_uk.cq_id);set_64bit_val (wqe,16 ,FIELD_PREP (IRDMA_CQPSQ_CQ_SHADOW_READ_THRESHOLD , info->shadow_read_threshold));set_64bit_val (wqe,32 , info->cq_pa);
@@ -4460,47 +4451,38 @@ int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq)* irdma_sc_process_ceq - process ceq * @dev: sc device struct * @ceq: ceq sc structure +* @cq_idx: Pointer to a CQ ID that will be populated. * * It is expected caller serializes this function with cleanup_ceqes() * because these functions manipulate the same ceq +* +* Return: True if cq_idx has been populated with a CQ ID. */ -void *irdma_sc_process_ceq (struct irdma_sc_dev *dev,struct irdma_sc_ceq *ceq) +bool irdma_sc_process_ceq (struct irdma_sc_dev *dev,struct irdma_sc_ceq *ceq, +u32 *cq_idx) {u64 temp;__le64 *ceqe; -struct irdma_sc_cq *cq =NULL ; -struct irdma_sc_cq *temp_cq;u8 polarity; -u32 cq_idx;do { - cq_idx =0 ; ceqe =IRDMA_GET_CURRENT_CEQ_ELEM (ceq);get_64bit_val (ceqe,0 , &temp); polarity = (u8 )FIELD_GET (IRDMA_CEQE_VALID , temp);if (polarity != ceq->polarity) -return NULL ; +return false; - temp_cq = (struct irdma_sc_cq *)(unsigned long )(temp <<1 ); -if (!temp_cq) { - cq_idx =IRDMA_INVALID_CQ_IDX ; -IRDMA_RING_MOVE_TAIL (ceq->ceq_ring); - -if (!IRDMA_RING_CURRENT_TAIL (ceq->ceq_ring)) - ceq->polarity ^=1 ; -continue ; - } - - cq = temp_cq; +/* Truncate. Discard valid bit which is MSb of temp. */ + *cq_idx = temp; +if (*cq_idx >= dev->hmc_info->hmc_obj[IRDMA_HMC_IW_CQ ].cnt) + *cq_idx =IRDMA_INVALID_CQ_IDX ;IRDMA_RING_MOVE_TAIL (ceq->ceq_ring);if (!IRDMA_RING_CURRENT_TAIL (ceq->ceq_ring)) ceq->polarity ^=1 ; - }while (cq_idx ==IRDMA_INVALID_CQ_IDX ); + }while (*cq_idx ==IRDMA_INVALID_CQ_IDX ); -if (cq) -irdma_sc_cq_ack (cq); -return cq; +return true; }/**
@@ -4514,10 +4496,10 @@ void *irdma_sc_process_ceq(struct irdma_sc_dev *dev, struct irdma_sc_ceq *ceq)*/ void irdma_sc_cleanup_ceqes (struct irdma_sc_cq *cq,struct irdma_sc_ceq *ceq) { -struct irdma_sc_cq *next_cq;u8 ceq_polarity = ceq->polarity;__le64 *ceqe;u8 polarity; +u32 cq_idx;u64 temp;int next;u32 i;
@@ -4532,9 +4514,10 @@ void irdma_sc_cleanup_ceqes(struct irdma_sc_cq *cq, struct irdma_sc_ceq *ceq)if (polarity != ceq_polarity)return ; - next_cq = (struct irdma_sc_cq *)(unsigned long )(temp <<1 ); -if (cq == next_cq) -set_64bit_val (ceqe,0 , temp &IRDMA_CEQE_VALID ); + cq_idx = temp; +if (cq_idx == cq->cq_uk.cq_id) +set_64bit_val (ceqe,0 , (temp &IRDMA_CEQE_VALID ) | +IRDMA_INVALID_CQ_IDX ); next =IRDMA_RING_GET_NEXT_TAIL (ceq->ceq_ring, i);if (!next)
@@ -4975,7 +4958,7 @@ int irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, bool post_sq)return -ENOMEM ;set_64bit_val (wqe,0 , ccq->cq_uk.cq_size); -set_64bit_val (wqe,8 , (uintptr_t )ccq >>1 ); +set_64bit_val (wqe,8 , ccq->cq_uk.cq_id);set_64bit_val (wqe,40 , ccq->shadow_area_pa); hdr = ccq->cq_uk.cq_id |
@@ -6462,6 +6445,9 @@ int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev,int ret_code =0 ;u8 db_size; +spin_lock_init (&dev->puda_cq_lock); + dev->ilq_cq =NULL ; + dev->ieq_cq =NULL ;INIT_LIST_HEAD (&dev->cqp_cmd_head);/* for CQP command backlog */ mutex_init (&dev->ws_mutex); dev->hmc_fn_id = info->hmc_fn_id;
drivers/infiniband/hw/irdma/hw.c +78 -10
112 lines not on this page · raw message
drivers/infiniband/hw/irdma/puda.c +14 -0
@@ -809,6 +809,13 @@ static int irdma_puda_cq_create(struct irdma_puda_rsrc *rsrc)dma_free_coherent (dev->hw->device, rsrc->cqmem.size, rsrc->cqmem.va, rsrc->cqmem.pa); rsrc->cqmem.va =NULL ; + }else { + scoped_guard(spinlock_irqsave, &dev->puda_cq_lock) { +if (rsrc->type ==IRDMA_PUDA_RSRC_TYPE_ILQ ) + dev->ilq_cq = cq; +else + dev->ieq_cq = cq; + } }return ret;
@@ -856,6 +863,13 @@ static void irdma_puda_free_cq(struct irdma_puda_rsrc *rsrc)struct irdma_ccq_cqe_info compl_info;struct irdma_sc_dev *dev = rsrc->dev; + scoped_guard(spinlock_irqsave, &dev->puda_cq_lock) { +if (rsrc->type ==IRDMA_PUDA_RSRC_TYPE_ILQ ) + dev->ilq_cq =NULL ; +else + dev->ieq_cq =NULL ; + } +if (rsrc->dev->ceq_valid) {irdma_cqp_cq_destroy_cmd (dev, &rsrc->cq);return ;
drivers/infiniband/hw/irdma/type.h +5 -1
@@ -707,6 +707,9 @@ struct irdma_sc_dev {struct irdma_sc_aeq *aeq;struct irdma_sc_ceq *ceq[IRDMA_CEQ_MAX_COUNT ];struct irdma_sc_cq *ccq; +spinlock_t puda_cq_lock; +struct irdma_sc_cq *ilq_cq; +struct irdma_sc_cq *ieq_cq;const struct irdma_irq_ops *irq_ops;struct irdma_qos qos[IRDMA_MAX_USER_PRIORITY ];struct irdma_hmc_fpm_misc hmc_fpm_misc;
@@ -1344,7 +1347,8 @@ int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq);int irdma_sc_ceq_init (struct irdma_sc_ceq *ceq,struct irdma_ceq_init_info *info);void irdma_sc_cleanup_ceqes (struct irdma_sc_cq *cq,struct irdma_sc_ceq *ceq); -void *irdma_sc_process_ceq (struct irdma_sc_dev *dev,struct irdma_sc_ceq *ceq); +bool irdma_sc_process_ceq (struct irdma_sc_dev *dev,struct irdma_sc_ceq *ceq, +u32 *cq_idx);int irdma_sc_aeq_init (struct irdma_sc_aeq *aeq,struct irdma_aeq_init_info *info);
drivers/infiniband/hw/irdma/utils.c +2 -1
@@ -830,7 +830,8 @@ void irdma_cq_rem_ref(struct ib_cq *ibcq)return ; } - iwdev->rf->cq_table[iwcq->cq_num] =NULL ; +/* May be asynchronously sampled by CEQ ISR without holding tbl lock. */ +WRITE_ONCE (iwdev->rf->cq_table[iwcq->cq_num],NULL );spin_unlock_irqrestore (&iwdev->rf->cqtable_lock, flags);complete (&iwcq->free_cq); }
drivers/infiniband/hw/irdma/verbs.c +4 -1
@@ -2669,9 +2669,12 @@ static int irdma_create_cq(struct ib_cq *ibcq, goto cq_destroy; } } - rf->cq_table[cq_num] = iwcq; +init_completion (&iwcq->free_cq); +/* Populate table entry after CQ is fully created. */ +smp_store_release (&rf->cq_table[cq_num], iwcq); +return 0 ; cq_destroy:irdma_cq_wq_destroy (rf, cq);
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Leon Romanovsky
AppliedQuoted 3 lines · Jacob Moroni
Added definitions for the special reserved CQs and QPs.
Applied, thanks!
[1/2] RDMA/irdma: Add enum defs for reserved CQs/QPs
https://git.kernel.org/rdma/rdma/c/2b7c2ba1308a54 [2/2] RDMA/irdma: Use CQ ID for CEQE context https://git.kernel.org/rdma/rdma/c/2529aead516738
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>