@@ -2886,15 +2886,6 @@ static int irdma_sc_resume_qp(struct irdma_sc_cqp *cqp, struct irdma_sc_qp *qp,
28862886 return 0 ;
28872887}
28882888
2889- /**
2890- * irdma_sc_cq_ack - acknowledge completion q
2891- * @cq: cq struct
2892- */
2893- static inline void irdma_sc_cq_ack (struct irdma_sc_cq * cq )
2894- {
2895- writel (cq -> cq_uk .cq_id , cq -> cq_uk .cq_ack_db );
2896- }
2897-
28982889/**
28992890 * irdma_sc_cq_init - initialize completion q
29002891 * @cq: cq struct
@@ -2956,7 +2947,7 @@ static int irdma_sc_cq_create(struct irdma_sc_cq *cq, u64 scratch,
29562947 return - ENOMEM ;
29572948
29582949 set_64bit_val (wqe , 0 , cq -> cq_uk .cq_size );
2959- set_64bit_val (wqe , 8 , ( uintptr_t ) cq >> 1 );
2950+ set_64bit_val (wqe , 8 , cq -> cq_uk . cq_id );
29602951 set_64bit_val (wqe , 16 ,
29612952 FIELD_PREP (IRDMA_CQPSQ_CQ_SHADOW_READ_THRESHOLD , cq -> shadow_read_threshold ));
29622953 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)
30133004 return - ENOMEM ;
30143005
30153006 set_64bit_val (wqe , 0 , cq -> cq_uk .cq_size );
3016- set_64bit_val (wqe , 8 , ( uintptr_t ) cq >> 1 );
3007+ set_64bit_val (wqe , 8 , cq -> cq_uk . cq_id );
30173008 set_64bit_val (wqe , 40 , cq -> shadow_area_pa );
30183009 set_64bit_val (wqe , 48 ,
30193010 (cq -> virtual_map ? cq -> first_pm_pbl_idx : 0 ));
@@ -3082,7 +3073,7 @@ static int irdma_sc_cq_modify(struct irdma_sc_cq *cq,
30823073 return - ENOMEM ;
30833074
30843075 set_64bit_val (wqe , 0 , info -> cq_size );
3085- set_64bit_val (wqe , 8 , ( uintptr_t ) cq >> 1 );
3076+ set_64bit_val (wqe , 8 , cq -> cq_uk . cq_id );
30863077 set_64bit_val (wqe , 16 ,
30873078 FIELD_PREP (IRDMA_CQPSQ_CQ_SHADOW_READ_THRESHOLD , info -> shadow_read_threshold ));
30883079 set_64bit_val (wqe , 32 , info -> cq_pa );
@@ -4458,47 +4449,38 @@ int irdma_sc_ceq_destroy(struct irdma_sc_ceq *ceq, u64 scratch, bool post_sq)
44584449 * irdma_sc_process_ceq - process ceq
44594450 * @dev: sc device struct
44604451 * @ceq: ceq sc structure
4452+ * @cq_idx: Pointer to a CQ ID that will be populated.
44614453 *
44624454 * It is expected caller serializes this function with cleanup_ceqes()
44634455 * because these functions manipulate the same ceq
4456+ *
4457+ * Return: True if cq_idx has been populated with a CQ ID.
44644458 */
4465- void * irdma_sc_process_ceq (struct irdma_sc_dev * dev , struct irdma_sc_ceq * ceq )
4459+ bool irdma_sc_process_ceq (struct irdma_sc_dev * dev , struct irdma_sc_ceq * ceq ,
4460+ u32 * cq_idx )
44664461{
44674462 u64 temp ;
44684463 __le64 * ceqe ;
4469- struct irdma_sc_cq * cq = NULL ;
4470- struct irdma_sc_cq * temp_cq ;
44714464 u8 polarity ;
4472- u32 cq_idx ;
44734465
44744466 do {
4475- cq_idx = 0 ;
44764467 ceqe = IRDMA_GET_CURRENT_CEQ_ELEM (ceq );
44774468 get_64bit_val (ceqe , 0 , & temp );
44784469 polarity = (u8 )FIELD_GET (IRDMA_CEQE_VALID , temp );
44794470 if (polarity != ceq -> polarity )
4480- return NULL ;
4471+ return false ;
44814472
4482- temp_cq = (struct irdma_sc_cq * )(unsigned long )(temp << 1 );
4483- if (!temp_cq ) {
4484- cq_idx = IRDMA_INVALID_CQ_IDX ;
4485- IRDMA_RING_MOVE_TAIL (ceq -> ceq_ring );
4486-
4487- if (!IRDMA_RING_CURRENT_TAIL (ceq -> ceq_ring ))
4488- ceq -> polarity ^= 1 ;
4489- continue ;
4490- }
4491-
4492- cq = temp_cq ;
4473+ /* Truncate. Discard valid bit which is MSb of temp. */
4474+ * cq_idx = temp ;
4475+ if (* cq_idx >= dev -> hmc_info -> hmc_obj [IRDMA_HMC_IW_CQ ].cnt )
4476+ * cq_idx = IRDMA_INVALID_CQ_IDX ;
44934477
44944478 IRDMA_RING_MOVE_TAIL (ceq -> ceq_ring );
44954479 if (!IRDMA_RING_CURRENT_TAIL (ceq -> ceq_ring ))
44964480 ceq -> polarity ^= 1 ;
4497- } while (cq_idx == IRDMA_INVALID_CQ_IDX );
4481+ } while (* cq_idx == IRDMA_INVALID_CQ_IDX );
44984482
4499- if (cq )
4500- irdma_sc_cq_ack (cq );
4501- return cq ;
4483+ return true;
45024484}
45034485
45044486/**
@@ -4512,10 +4494,10 @@ void *irdma_sc_process_ceq(struct irdma_sc_dev *dev, struct irdma_sc_ceq *ceq)
45124494 */
45134495void irdma_sc_cleanup_ceqes (struct irdma_sc_cq * cq , struct irdma_sc_ceq * ceq )
45144496{
4515- struct irdma_sc_cq * next_cq ;
45164497 u8 ceq_polarity = ceq -> polarity ;
45174498 __le64 * ceqe ;
45184499 u8 polarity ;
4500+ u32 cq_idx ;
45194501 u64 temp ;
45204502 int next ;
45214503 u32 i ;
@@ -4530,9 +4512,10 @@ void irdma_sc_cleanup_ceqes(struct irdma_sc_cq *cq, struct irdma_sc_ceq *ceq)
45304512 if (polarity != ceq_polarity )
45314513 return ;
45324514
4533- next_cq = (struct irdma_sc_cq * )(unsigned long )(temp << 1 );
4534- if (cq == next_cq )
4535- set_64bit_val (ceqe , 0 , temp & IRDMA_CEQE_VALID );
4515+ cq_idx = temp ;
4516+ if (cq_idx == cq -> cq_uk .cq_id )
4517+ set_64bit_val (ceqe , 0 , (temp & IRDMA_CEQE_VALID ) |
4518+ IRDMA_INVALID_CQ_IDX );
45364519
45374520 next = IRDMA_RING_GET_NEXT_TAIL (ceq -> ceq_ring , i );
45384521 if (!next )
@@ -4973,7 +4956,7 @@ int irdma_sc_ccq_destroy(struct irdma_sc_cq *ccq, u64 scratch, bool post_sq)
49734956 return - ENOMEM ;
49744957
49754958 set_64bit_val (wqe , 0 , ccq -> cq_uk .cq_size );
4976- set_64bit_val (wqe , 8 , ( uintptr_t ) ccq >> 1 );
4959+ set_64bit_val (wqe , 8 , ccq -> cq_uk . cq_id );
49774960 set_64bit_val (wqe , 40 , ccq -> shadow_area_pa );
49784961
49794962 hdr = ccq -> cq_uk .cq_id |
@@ -6459,6 +6442,9 @@ int irdma_sc_dev_init(enum irdma_vers ver, struct irdma_sc_dev *dev,
64596442 int ret_code = 0 ;
64606443 u8 db_size ;
64616444
6445+ spin_lock_init (& dev -> puda_cq_lock );
6446+ dev -> ilq_cq = NULL ;
6447+ dev -> ieq_cq = NULL ;
64626448 INIT_LIST_HEAD (& dev -> cqp_cmd_head ); /* for CQP command backlog */
64636449 mutex_init (& dev -> ws_mutex );
64646450 dev -> hmc_fn_id = info -> hmc_fn_id ;
0 commit comments