From patchwork Wed May 23 22:57:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10422465 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 C988C60327 for ; Wed, 23 May 2018 22:57:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B63A1292C3 for ; Wed, 23 May 2018 22:57:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB117292C6; Wed, 23 May 2018 22:57:50 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 2D86E292C3 for ; Wed, 23 May 2018 22:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934990AbeEWW5r (ORCPT ); Wed, 23 May 2018 18:57:47 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53691 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934987AbeEWW5p (ORCPT ); Wed, 23 May 2018 18:57:45 -0400 Received: by mail-wm0-f66.google.com with SMTP id a67-v6so2055wmf.3 for ; Wed, 23 May 2018 15:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UOH1swtu++3LpVjtU15Mhm/BKPbpXRmLUrvEAi9HN64=; b=lFemqQuV3UfKVnvXolcjK/mjpNePt4E6BAnYP3JcXpdImmCYGzquAFqaNHYwWYUe33 XFx+QBDhNbgVwzdEPcgT7Yp+auoJrtvHmAJepUYYP0A3nGslccveD8v5jBjwSHyKieoA 4Fc+FqiUc6stnJ2LojXL+a5OVwKY64VLwbKTcmg2bsnj0+8H63DkLGSB4b4A7fakrBef SNWJuKXopwxYYZ5QUqnYul6L1Pi44on8FlVqNVt5XfM3araITtgazb34XssaxuAZZ2VB dhS8Vby35pzNo6S3tpl4jgWXwKhAPLJyRJ6Z12p8JFU0Vs84HJzxrPr7gCU0OTYPSIG0 6ubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UOH1swtu++3LpVjtU15Mhm/BKPbpXRmLUrvEAi9HN64=; b=jLpoSn1Go9L4JmX75g5RXgbsCKF/pWmn/n+p5CHWJpYjJIsWB3fIXNviTTwTvjWCLH JxTZUGkSRacw0W0FpYZAsZE1Fc05i++OzUzD/D+eWq+Sq1ZipX1Hel4+LjB1b6HUpcnN Nn8akCb67JMZsPK63kBDiVyEroZd6dgm0g4C7kYvbvoPdgph/h6My9/5LWyySO+D2eVt mMm5oZWIEathtQRftGaasQhYyqBcvfvJhE0m96SlCIpieeT7KAZO8gDpnh1cMQLoULTD X9wtUnMRe5dJpIUHBfICduanRAoKefHc6taeYla7MEzmBfFO0MZtq/J7oIbXCmcxCn4A z6hw== X-Gm-Message-State: ALKqPwdeyFq0arKScq2+Vp/pe1krw6rww38CoyN3TPfS4ugQNh9YpxWP cPuzrMOBwHCIrW5UPxS4nxc3Jw== X-Google-Smtp-Source: AB8JxZo7+xxH/n4/KdhnxCbJwLjvHnUNpty5SYYuJ1SJFbIpsFV8YaaKGmhK9mK3qptH9o3m3IizbA== X-Received: by 2002:a1c:97d3:: with SMTP id z202-v6mr5566713wmd.66.1527116263752; Wed, 23 May 2018 15:57:43 -0700 (PDT) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id q12-v6sm12097336wrp.54.2018.05.23.15.57.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 15:57:43 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1fLchP-0003pX-HO; Wed, 23 May 2018 16:57:39 -0600 Date: Wed, 23 May 2018 16:57:39 -0600 From: Jason Gunthorpe To: Leon Romanovsky Cc: Doug Ledford , Leon Romanovsky , RDMA mailing list , Parav Pandit Subject: Re: [PATCH rdma-next 1/2] IB/core: Introduce and use rdma_is_zero_gid() Message-ID: <20180523225739.GA14568@ziepe.ca> References: <20180522173346.3806-1-leon@kernel.org> <20180522173346.3806-2-leon@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180522173346.3806-2-leon@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) 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 On Tue, May 22, 2018 at 08:33:45PM +0300, Leon Romanovsky wrote: > From: Parav Pandit > > Instead of open coding memcmp() to check whether a given GID is zero or > not, use a helper function to do so. > > Signed-off-by: Parav Pandit > Signed-off-by: Leon Romanovsky > --- > drivers/infiniband/core/cache.c | 14 ++++++++++++-- > drivers/infiniband/hw/mlx4/main.c | 2 +- > drivers/infiniband/hw/mlx4/qp.c | 2 +- > include/rdma/ib_cache.h | 1 + > 4 files changed, 15 insertions(+), 4 deletions(-) Applied, but I noticed this missed a memcmp, and I decided to drop the memcpy's too. Here is delta, please check my change. Would be nice to see the last two zgid users go away and with them the global symbol too.. --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index c09b63f9960387..82699f70e9b60b 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -274,7 +274,7 @@ static void del_gid(struct ib_device *ib_dev, u8 port, if (rdma_protocol_roce(ib_dev, port)) del_roce_gid(ib_dev, port, table, ix); - memcpy(&table->data_vec[ix].gid, &zgid, sizeof(zgid)); + memset(&table->data_vec[ix].gid, 0, sizeof(table->data_vec[ix].gid)); memset(&table->data_vec[ix].attr, 0, sizeof(table->data_vec[ix].attr)); table->data_vec[ix].context = NULL; } @@ -734,8 +734,7 @@ static void cleanup_gid_table_port(struct ib_device *ib_dev, u8 port, mutex_lock(&table->lock); for (i = 0; i < table->sz; ++i) { - if (memcmp(&table->data_vec[i].gid, &zgid, - sizeof(table->data_vec[i].gid))) { + if (!rdma_is_zero_gid(&table->data_vec[i].gid)) { del_gid(ib_dev, port, table, i); deleted = true; } diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index c6d6c1c3410ecd..bf12394c13c165 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -345,7 +345,8 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context) if (!ctx->refcount) { unsigned int real_index = ctx->real_index; - memcpy(&port_gid_table->gids[real_index].gid, &zgid, sizeof(zgid)); + memset(&port_gid_table->gids[real_index].gid, 0, + sizeof(port_gid_table->gids[real_index].gid)); kfree(port_gid_table->gids[real_index].ctx); port_gid_table->gids[real_index].ctx = NULL; hw_update = 1;