git: 09d7f260d4cd - main - cxgbe: stop open-coding kref access

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Mon, 05 Dec 2022 17:38:22 UTC
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=09d7f260d4cd77be3c517b1fa2b70df6c137e158

commit 09d7f260d4cd77be3c517b1fa2b70df6c137e158
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-12-05 17:35:08 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-12-05 17:38:17 +0000

    cxgbe: stop open-coding kref access
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h | 6 +++---
 sys/dev/cxgbe/iw_cxgbe/qp.c       | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
index 03d3b2b0ad38..8e33e2d04597 100644
--- a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
+++ b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
@@ -680,14 +680,14 @@ enum c4iw_mmid_state {
 
 #define c4iw_put_ep(ep) { \
 	CTR4(KTR_IW_CXGBE, "put_ep (%s:%u) ep %p, refcnt %d", \
-	     __func__, __LINE__, ep, atomic_read(&(ep)->kref.refcount)); \
-	WARN_ON(atomic_read(&(ep)->kref.refcount) < 1); \
+	     __func__, __LINE__, ep, kref_read(&(ep)->kref)); \
+	WARN_ON(kref_read(&(ep)->kref) < 1); \
         kref_put(&((ep)->kref), _c4iw_free_ep); \
 }
 
 #define c4iw_get_ep(ep) { \
 	CTR4(KTR_IW_CXGBE, "get_ep (%s:%u) ep %p, refcnt %d", \
-	      __func__, __LINE__, ep, atomic_read(&(ep)->kref.refcount)); \
+	      __func__, __LINE__, ep, kref_read(&(ep)->kref)); \
         kref_get(&((ep)->kref));  \
 }
 
diff --git a/sys/dev/cxgbe/iw_cxgbe/qp.c b/sys/dev/cxgbe/iw_cxgbe/qp.c
index d3d4c0573a6f..3b6c4c489414 100644
--- a/sys/dev/cxgbe/iw_cxgbe/qp.c
+++ b/sys/dev/cxgbe/iw_cxgbe/qp.c
@@ -1536,7 +1536,7 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
 	case C4IW_QP_STATE_RTS:
 		switch (attrs->next_state) {
 		case C4IW_QP_STATE_CLOSING:
-			BUG_ON(atomic_read(&qhp->ep->com.kref.refcount) < 2);
+			BUG_ON(kref_read(&qhp->ep->com.kref) < 2);
 			t4_set_wq_in_error(&qhp->wq);
 			set_state(qhp, C4IW_QP_STATE_CLOSING);
 			ep = qhp->ep;