From patchwork Wed Dec 20 19:27:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Tan X-Patchwork-Id: 10126441 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9563E60390 for ; Wed, 20 Dec 2017 19:27:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8422729629 for ; Wed, 20 Dec 2017 19:27:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78ED6296DD; Wed, 20 Dec 2017 19:27:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B36D929629 for ; Wed, 20 Dec 2017 19:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756413AbdLTT1O (ORCPT ); Wed, 20 Dec 2017 14:27:14 -0500 Received: from mail-cys01nam02on0082.outbound.protection.outlook.com ([104.47.37.82]:15936 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756384AbdLTT1M (ORCPT ); Wed, 20 Dec 2017 14:27:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rnddKPnfOdmWh7mxPBokOkYt2+Pe2s7MNwVoK+kBgVM=; b=jgiN5ga99M1IQu/mcyyhrys6VHMY2ZUyFCCQPjocDAUMB1VTRsxSl9xuejgHGme+3c7WjJ0ewnQn2XUl5S6A/RlEKET+PfpF9Jqz4NxHln5MNSjbEBjWCijqsCzUYvHgQq3nrI1Fk/rF4pMMJ24G1oHsASVDT1gsBUCCGxjKVqM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bryantan@vmware.com; Received: from bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com (208.91.1.34) by CO2PR05MB2774.namprd05.prod.outlook.com (10.166.200.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.2; Wed, 20 Dec 2017 19:27:09 +0000 Date: Wed, 20 Dec 2017 11:27:00 -0800 From: Bryan Tan To: linux-rdma@vger.kernel.org Subject: [PATCH for-next 3/4] RDMA/vmw_pvrdma: Use refcount_t instead of atomic_t Message-ID: <20171220192655.GA32254@bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171220192305.GA28403@bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: YTOPR0101CA0051.CANPRD01.PROD.OUTLOOK.COM (52.132.42.28) To CO2PR05MB2774.namprd05.prod.outlook.com (10.166.200.26) X-MS-Office365-Filtering-Correlation-Id: bc6e601b-66aa-4bc4-d432-08d547dfaa3b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:CO2PR05MB2774; X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2774; 3:duW/p6vAjJCrdz/mtlsTmzKRXmSdcwoohhyFmrpWYlmf1rR6trbqfwSAdXrPjL26VM6E2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6Hey6CSE5hlMzfuGXT3Ie3kxT6xppQTdBiQOff8alZMuYgVhc30D+5lAfgJ0Et9+qobnaGlnw28BpDjwp8Sh0yxLfsCrQWzhsa5ZnWWV3NOibQMUlg0RCY1zEJt9uJgUtYt3hRudebC36SZcDRvJq705Lc0YSBs/iEyHdgt8oF8CtXcEC0Cr+GFWAZPVKRdNKSAx7Kx0Xho7sQAtxnWP0kCnj+SsvZ8AOUiG1QYIVmuE+7iPpBH60VFUKCENQU6/cm4zG6PH+uNQlc+UInhyO1hraW+KEODjHKVHu2bmw5pBT9n6; 4:eo5nJ5kHC9ETwxSypVWcdRX6+0OrZ1UwqTfLeFEDQ6Gn4wjg5+xUuXydDoyYVG6xHDRnrteQzgs7t0C2rsmQ2xKvsBMWd/x2DRXG8h5QvKVZZTugTqnmIvu4qN3YjGHiciL+mlpLDxiZvuQA1ZP0MOSsnfWCGjEqyH5Z7Reqtk8bAlUC/mF2+HHs2quzm5IRJuTA9rJg+fwJm9U2Zx8g8THKT0K9XyLSAOTk3NMVgB7efA2rSnEK4yTqw31NPl/+s1UiIYt6AxtUcckQLY+elGtv/8u8CON9i7RAbc0dKvGSuFbswEAXKVDDgHGHMlZw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(93006095)(93001095)(3002001)(10201501046)(6041268)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CO2PR05MB2774; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CO2PR05MB2774; X-Forefront-PRVS: 0527DFA348 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(396003)(346002)(39380400002)(366004)(39860400002)(199004)(189003)(2950100002)(6666003)(2906002)(5660300001)(55016002)(106356001)(6916009)(6116002)(105586002)(47776003)(66066001)(86362001)(33656002)(2351001)(2361001)(23726003)(7696005)(3846002)(81156014)(25786009)(50466002)(386003)(59450400001)(478600001)(316002)(68736007)(53936002)(16526018)(83506002)(8676002)(305945005)(52116002)(81166006)(58126008)(7736002)(8936002)(1076002)(16586007)(97736004)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR05MB2774; H:bryantan-devbox.prom.eng.vmware.com.prom.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR05MB2774; 23:FztejvLgp/vxCzz+7kzHremH0nCsy3i1Hlv0yDFAP?= =?us-ascii?Q?QPFnGj5qZn6PHac/xgtVfe8pZxK9/ssvHRhKdtnVwg8F72Ef3pba9nmJoOoh?= =?us-ascii?Q?/v+EYsoI4It65tmlwDVMLkyytN4Sk/X9xt2D0rFmsRcR+veO+T80UYHp8ILk?= =?us-ascii?Q?9NSMyRsLjpGLrpyelJNgmDo5NrZ6LPGtoL6sKi3DedKpUdSQpPxxrJfPWoQv?= =?us-ascii?Q?mci/nw1DuP49eZky1WF3PbCoksRTeAfHcKF4Rx6kZAnfE8Q50qwEhoun7S5R?= =?us-ascii?Q?g4QRzppFBWymtpGoP1LIehysm+6n2Oz2UB3WrNoMItl32jZL9zU7Q2+l5aip?= =?us-ascii?Q?D/+FMo0CAw+OLxVVtfe8G4JR0pHftaG6kkURBO6afgj6rTCkA9HG0bHD4+mL?= =?us-ascii?Q?nz5rw2BXBAEh5Ojo67N25MgS6T9Ofnf5zBWr0/He2FE5Dx3EiLpSPnGvkRDX?= =?us-ascii?Q?DLOZ6aOtehIQKshn7gANro2MvE2L3Yxw4U5ps8EyQsNbu/kwFvYbjKB25kDU?= =?us-ascii?Q?9LwqoW5AoRZA0UKBWSl6MPI1YfmLuKmCqaW1DctBs39NRAH9hf4TSvlHHjQC?= =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kTz4IIA=; 5:SZSApb0iwfn/dZowtYqpmvKgzh034IDcxtXxHZOfq2txQbIOxUXrLpGQ+QirvLY9nuprrUfyRJOgTgOGfcV4lz+Yv3XmeSJjt+WAU87zqBqdCsStTfqe58pewrlrZV7pUpeAR3wRKZO6hy5XHSEGCrjHpHuZ1rq85Sd0VpxaLz0=; 24:qdJOoVAbMRSBU+7x26j4wklqgDsDmYvaMrgHotl4zGXXLZKVvc+xnxpzFn74VAzKCHel2NWLY2WIUhMdshPlfde89epjVOuI0YDdyPf0VNE=; 7:+hXbO7xBvNYntqemYTjMSWZsOEV7CZZI9oDe4VRmCf2gEqQ+Os/5N2q8DH20yWEbo+RyE4lqtwAXNAHp1WN0t+/yR5l0OAnU5Ot75V4AfbJvWnFHZKD6AiplF5jkpikPsvlQl/Ht26FlQQV19yXsI+y/6NwLhIHtgt+51OMQwUh3y1Fr4d9vafNLI6mcSq2weznP7oraLXxNNCOLfKuXr+kMtOoJt7dbigSfrb0jpcPO7glgZSBjOyP/uDkWCJwn SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2774; 20:6mwn7RHFG2BPDlfuwXjp+XCxDVUhu78fUPQp1v/yefGRbbx8x+YGOlJmL3av1Ryr8lwwIsGTdOxNtSoytGH1eSDqjtOfJbQ5DcRKR8WDa4TxFpJJeAs+o9zz7ApBGKXwyg/M7VbWbO/3PTlZbzEMZEo8CrOo9jidtWQ6884xA58= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 19:27:09.7744 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc6e601b-66aa-4bc4-d432-08d547dfaa3b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR05MB2774 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP refcount_t is the preferred type for refcounts. Change the QP and CQ refcnt fields to use refcount_t. Reviewed-by: Adit Ranadive Reviewed-by: Aditya Sarwade Reviewed-by: Jorgen Hansen Signed-off-by: Bryan Tan --- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 4 ++-- drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c | 4 ++-- drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 12 ++++++------ drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h index 4f7bd3b6..44cb1cf 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h @@ -93,7 +93,7 @@ struct pvrdma_cq { struct pvrdma_page_dir pdir; u32 cq_handle; bool is_kernel; - atomic_t refcnt; + refcount_t refcnt; struct completion free; }; @@ -196,7 +196,7 @@ struct pvrdma_qp { u8 state; bool is_kernel; struct mutex mutex; /* QP state mutex. */ - atomic_t refcnt; + refcount_t refcnt; struct completion free; }; diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c index cc46161..faa9478 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c @@ -177,7 +177,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, else pvrdma_page_dir_insert_umem(&cq->pdir, cq->umem, 0); - atomic_set(&cq->refcnt, 1); + refcount_set(&cq->refcnt, 1); init_completion(&cq->free); spin_lock_init(&cq->cq_lock); @@ -229,7 +229,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev, static void pvrdma_free_cq(struct pvrdma_dev *dev, struct pvrdma_cq *cq) { - if (atomic_dec_and_test(&cq->refcnt)) + if (refcount_dec_and_test(&cq->refcnt)) complete(&cq->free); wait_for_completion(&cq->free); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c index 69835d1..939ac2f 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c @@ -333,7 +333,7 @@ static void pvrdma_qp_event(struct pvrdma_dev *dev, u32 qpn, int type) spin_lock_irqsave(&dev->qp_tbl_lock, flags); qp = dev->qp_tbl[qpn % dev->dsr->caps.max_qp]; if (qp) - atomic_inc(&qp->refcnt); + refcount_inc(&qp->refcnt); spin_unlock_irqrestore(&dev->qp_tbl_lock, flags); if (qp && qp->ibqp.event_handler) { @@ -346,7 +346,7 @@ static void pvrdma_qp_event(struct pvrdma_dev *dev, u32 qpn, int type) ibqp->event_handler(&e, ibqp->qp_context); } if (qp) { - if (atomic_dec_and_test(&qp->refcnt)) + if (refcount_dec_and_test(&qp->refcnt)) complete(&qp->free); } } @@ -359,7 +359,7 @@ static void pvrdma_cq_event(struct pvrdma_dev *dev, u32 cqn, int type) spin_lock_irqsave(&dev->cq_tbl_lock, flags); cq = dev->cq_tbl[cqn % dev->dsr->caps.max_cq]; if (cq) - atomic_inc(&cq->refcnt); + refcount_inc(&cq->refcnt); spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); if (cq && cq->ibcq.event_handler) { @@ -372,7 +372,7 @@ static void pvrdma_cq_event(struct pvrdma_dev *dev, u32 cqn, int type) ibcq->event_handler(&e, ibcq->cq_context); } if (cq) { - if (atomic_dec_and_test(&cq->refcnt)) + if (refcount_dec_and_test(&cq->refcnt)) complete(&cq->free); } } @@ -531,13 +531,13 @@ static irqreturn_t pvrdma_intrx_handler(int irq, void *dev_id) spin_lock_irqsave(&dev->cq_tbl_lock, flags); cq = dev->cq_tbl[cqne->info % dev->dsr->caps.max_cq]; if (cq) - atomic_inc(&cq->refcnt); + refcount_inc(&cq->refcnt); spin_unlock_irqrestore(&dev->cq_tbl_lock, flags); if (cq && cq->ibcq.comp_handler) cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context); if (cq) { - if (atomic_dec_and_test(&cq->refcnt)) + if (refcount_dec_and_test(&cq->refcnt)) complete(&cq->free); } pvrdma_idx_ring_inc(&ring->cons_head, ring_slots); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c index 9dd556a..7bf518b 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c @@ -245,7 +245,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd, spin_lock_init(&qp->sq.lock); spin_lock_init(&qp->rq.lock); mutex_init(&qp->mutex); - atomic_set(&qp->refcnt, 1); + refcount_set(&qp->refcnt, 1); init_completion(&qp->free); qp->state = IB_QPS_RESET; @@ -427,7 +427,7 @@ static void pvrdma_free_qp(struct pvrdma_qp *qp) pvrdma_unlock_cqs(scq, rcq, &scq_flags, &rcq_flags); - if (atomic_dec_and_test(&qp->refcnt)) + if (refcount_dec_and_test(&qp->refcnt)) complete(&qp->free); wait_for_completion(&qp->free);