From patchwork Sun Jan 1 14:17:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 9492891 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 B2D0660416 for ; Sun, 1 Jan 2017 14:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95AA21FF35 for ; Sun, 1 Jan 2017 14:17:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 763A126224; Sun, 1 Jan 2017 14:17:23 +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.9 required=2.0 tests=BAYES_00, 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 409A71FF35 for ; Sun, 1 Jan 2017 14:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755136AbdAAORU (ORCPT ); Sun, 1 Jan 2017 09:17:20 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54197 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755057AbdAAORU (ORCPT ); Sun, 1 Jan 2017 09:17:20 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Jan 2017 16:17:13 +0200 Received: from r-vnc08.mtr.labs.mlnx (r-vnc08.mtr.labs.mlnx [10.208.0.121]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v01EHCex004491; Sun, 1 Jan 2017 16:17:13 +0200 From: Max Gurtovoy To: bvanassche@acm.org, dledford@redhat.com, linux-rdma@vger.kernel.org Cc: israelr@mellanox.com, Max Gurtovoy Subject: [PATCH 2/2 v2] IB/srpt: allocate ib_qp_attr on the stack Date: Sun, 1 Jan 2017 16:17:12 +0200 Message-Id: <1483280232-13826-3-git-send-email-maxg@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1483280232-13826-1-git-send-email-maxg@mellanox.com> References: <1483280232-13826-1-git-send-email-maxg@mellanox.com> 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 No reason to use kzalloc that may increase memory fragmentation. This also simplifies the code in means of memory alloc/free in initialization flow. Signed-off-by: Max Gurtovoy --- drivers/infiniband/ulp/srpt/ib_srpt.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index d21ba9d..9117ca6 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -984,24 +984,19 @@ static int srpt_get_desc_tbl(struct srpt_send_ioctx *ioctx, */ static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp) { - struct ib_qp_attr *attr; + struct ib_qp_attr attr = { 0 }; int ret; - attr = kzalloc(sizeof(*attr), GFP_KERNEL); - if (!attr) - return -ENOMEM; - - attr->qp_state = IB_QPS_INIT; - attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ | + attr.qp_state = IB_QPS_INIT; + attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ | IB_ACCESS_REMOTE_WRITE; - attr->port_num = ch->sport->port; - attr->pkey_index = 0; + attr.port_num = ch->sport->port; + attr.pkey_index = 0; - ret = ib_modify_qp(qp, attr, + ret = ib_modify_qp(qp, &attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PORT | IB_QP_PKEY_INDEX); - kfree(attr); return ret; }