From patchwork Wed Oct 31 12:42:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shamir Rabinovitch X-Patchwork-Id: 10662601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 948DB13BF for ; Wed, 31 Oct 2018 12:43:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83D9E2AA66 for ; Wed, 31 Oct 2018 12:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77E822AB67; Wed, 31 Oct 2018 12:43:07 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 1B2432AA66 for ; Wed, 31 Oct 2018 12:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729053AbeJaVk5 (ORCPT ); Wed, 31 Oct 2018 17:40:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:52072 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729042AbeJaVk5 (ORCPT ); Wed, 31 Oct 2018 17:40:57 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9VCgvIx184800; Wed, 31 Oct 2018 12:42:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=wWFdr5bmL5s9MozwLD8uGNrs0d1Vk4RnJcWBoT2Xx/A=; b=mWSnvMT33hg1d6PazNZbxsVpZlm7jFPmZra3TI2lgz4Lxioc/eC85csQkazSWjzPSd/+ mYKbK3nb1xvE5cDyv9+Z8036Ku++vrIHiKlhE0rLInVcpoIeWoQ9PAyO1hxnXansIWMy mjctLIiMHrQB2IH52jGPuCEGiVWhI5+0fCw1F7F3v7NP5udOjpSfUwBAkMPhwocVgOUm VcycSz6kYmGMa9X5WqGrWaF2itb3C0bA8YKuscE4cdnQ94qMepaPeU8Gt+S8mnwrmayX YCR56wyBPgkEw3D59Mf+MgF98ELNXAJJfAKnR+aLmKJiN3S2SJdFRZMnPCFVawWDwEzL kA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2ncgnr2n5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Oct 2018 12:42:58 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9VCgv65006305 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Oct 2018 12:42:57 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9VCgv1Q024157; Wed, 31 Oct 2018 12:42:57 GMT Received: from localhost.localdomain (/10.175.5.115) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 31 Oct 2018 05:42:56 -0700 From: Shamir Rabinovitch To: linux-rdma@vger.kernel.org Cc: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, santosh.shilimkar@oracle.com, shamir.rabinovitch@oracle.com Subject: [PATCH v3 1/5] IB/mlx5: device resources must be created from ib_core Date: Wed, 31 Oct 2018 14:42:38 +0200 Message-Id: <20181031124242.24239-2-shamir.rabinovitch@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031124242.24239-1-shamir.rabinovitch@oracle.com> References: <20181031124242.24239-1-shamir.rabinovitch@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9062 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310105 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 Bypassing ib_core leave the restrack and other fields uninitialized. Signed-off-by: Shamir Rabinovitch --- drivers/infiniband/hw/mlx5/main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index be701d4..97b44e9 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -4565,26 +4565,19 @@ static int create_dev_resources(struct mlx5_ib_resources *devr) mutex_init(&devr->mutex); - devr->p0 = mlx5_ib_alloc_pd(&dev->ib_dev, NULL, NULL); + /* must call ib_core here to initialize restrack! */ + devr->p0 = ib_alloc_pd(&dev->ib_dev, 0); if (IS_ERR(devr->p0)) { ret = PTR_ERR(devr->p0); goto error0; } - devr->p0->device = &dev->ib_dev; - devr->p0->uobject = NULL; - atomic_set(&devr->p0->usecnt, 0); - devr->c0 = mlx5_ib_create_cq(&dev->ib_dev, &cq_attr, NULL, NULL); + /* must call ib_core here to initialize restrack! */ + devr->c0 = ib_create_cq(&dev->ib_dev, NULL, NULL, NULL, &cq_attr); if (IS_ERR(devr->c0)) { ret = PTR_ERR(devr->c0); goto error1; } - devr->c0->device = &dev->ib_dev; - devr->c0->uobject = NULL; - devr->c0->comp_handler = NULL; - devr->c0->event_handler = NULL; - devr->c0->cq_context = NULL; - atomic_set(&devr->c0->usecnt, 0); devr->x0 = mlx5_ib_alloc_xrcd(&dev->ib_dev, NULL, NULL); if (IS_ERR(devr->x0)) { @@ -4649,6 +4642,7 @@ static int create_dev_resources(struct mlx5_ib_resources *devr) devr->s1->srq_context = NULL; devr->s1->srq_type = IB_SRQT_BASIC; devr->s1->ext.cq = devr->c0; + atomic_inc(&devr->s1->ext.cq->usecnt); atomic_inc(&devr->p0->usecnt); atomic_set(&devr->s1->usecnt, 0); @@ -4662,14 +4656,16 @@ static int create_dev_resources(struct mlx5_ib_resources *devr) error5: mlx5_ib_destroy_srq(devr->s0); + atomic_dec(&devr->p0->usecnt); + atomic_dec(&devr->s0->ext.cq->usecnt); error4: mlx5_ib_dealloc_xrcd(devr->x1); error3: mlx5_ib_dealloc_xrcd(devr->x0); error2: - mlx5_ib_destroy_cq(devr->c0); + ib_destroy_cq(devr->c0); error1: - mlx5_ib_dealloc_pd(devr->p0); + ib_dealloc_pd(devr->p0); error0: return ret; } @@ -4681,11 +4677,15 @@ static void destroy_dev_resources(struct mlx5_ib_resources *devr) int port; mlx5_ib_destroy_srq(devr->s1); + atomic_dec(&devr->p0->usecnt); + atomic_dec(&devr->s1->ext.cq->usecnt); mlx5_ib_destroy_srq(devr->s0); + atomic_dec(&devr->p0->usecnt); + atomic_dec(&devr->s0->ext.cq->usecnt); mlx5_ib_dealloc_xrcd(devr->x0); mlx5_ib_dealloc_xrcd(devr->x1); - mlx5_ib_destroy_cq(devr->c0); - mlx5_ib_dealloc_pd(devr->p0); + ib_destroy_cq(devr->c0); + ib_dealloc_pd(devr->p0); /* Make sure no change P_Key work items are still executing */ for (port = 0; port < dev->num_ports; ++port)